From bd1758a4c3cd8611acc94b0867aa7206da51c109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=B6fstrand?= Date: Thu, 5 Dec 2013 22:57:37 +0100 Subject: [PATCH] Added sample code, fixed potential callback concurrency problems, added support for specifying dispatch queue to be used. --- .gitignore | 11 + HHService.m | 112 +++--- HHServiceBrowser.m | 38 +- HHServicePublisher.m | 28 +- HHServiceSupport.h | 16 + HHServiceSupport.m | 61 ++- HHServices-Prefix.pch | 7 + HHServices.xcodeproj/project.pbxproj | 268 +++++++++++++ .../contents.xcworkspacedata | 7 + .../BrowserSample.xcodeproj/project.pbxproj | 361 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../BrowserSample/BrowserSample/AppDelegate.h | 15 + .../BrowserSample/BrowserSample/AppDelegate.m | 23 ++ .../BrowserSample/BrowserSample-Info.plist | 36 ++ .../BrowserSample/BrowserSample-Prefix.pch | 16 + .../BrowserSample/ViewController.h | 15 + .../BrowserSample/ViewController.m | 128 +++++++ .../BrowserSample/en.lproj/InfoPlist.strings | 2 + samples/BrowserSample/BrowserSample/main.m | 18 + .../PublisherSample.xcodeproj/project.pbxproj | 361 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../PublisherSample/AppDelegate.h | 15 + .../PublisherSample/AppDelegate.m | 23 ++ .../PublisherSample-Info.plist | 36 ++ .../PublisherSample-Prefix.pch | 16 + .../PublisherSample/ViewController.h | 15 + .../PublisherSample/ViewController.m | 75 ++++ .../en.lproj/InfoPlist.strings | 2 + .../PublisherSample/PublisherSample/main.m | 18 + .../contents.xcworkspacedata | 10 + 30 files changed, 1660 insertions(+), 87 deletions(-) create mode 100644 .gitignore mode change 100755 => 100644 HHServiceBrowser.m create mode 100644 HHServices-Prefix.pch create mode 100644 HHServices.xcodeproj/project.pbxproj create mode 100644 HHServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 samples/BrowserSample/BrowserSample.xcodeproj/project.pbxproj create mode 100644 samples/BrowserSample/BrowserSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 samples/BrowserSample/BrowserSample/AppDelegate.h create mode 100644 samples/BrowserSample/BrowserSample/AppDelegate.m create mode 100644 samples/BrowserSample/BrowserSample/BrowserSample-Info.plist create mode 100644 samples/BrowserSample/BrowserSample/BrowserSample-Prefix.pch create mode 100644 samples/BrowserSample/BrowserSample/ViewController.h create mode 100644 samples/BrowserSample/BrowserSample/ViewController.m create mode 100644 samples/BrowserSample/BrowserSample/en.lproj/InfoPlist.strings create mode 100644 samples/BrowserSample/BrowserSample/main.m create mode 100644 samples/PublisherSample/PublisherSample.xcodeproj/project.pbxproj create mode 100644 samples/PublisherSample/PublisherSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 samples/PublisherSample/PublisherSample/AppDelegate.h create mode 100644 samples/PublisherSample/PublisherSample/AppDelegate.m create mode 100644 samples/PublisherSample/PublisherSample/PublisherSample-Info.plist create mode 100644 samples/PublisherSample/PublisherSample/PublisherSample-Prefix.pch create mode 100644 samples/PublisherSample/PublisherSample/ViewController.h create mode 100644 samples/PublisherSample/PublisherSample/ViewController.m create mode 100644 samples/PublisherSample/PublisherSample/en.lproj/InfoPlist.strings create mode 100644 samples/PublisherSample/PublisherSample/main.m create mode 100644 samples/Samples.xcworkspace/contents.xcworkspacedata diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06dfd13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.DS_Store + +**/xcuserdata/** +*.xcuserstate +*.pbxuser +*.xccheckout +*.hmap +*.ipa +build/ + +Pods diff --git a/HHService.m b/HHService.m index f32ac9a..bfbd351 100644 --- a/HHService.m +++ b/HHService.m @@ -49,6 +49,7 @@ @interface HHService () @property (nonatomic, retain, readwrite) NSData* txtData; @property (nonatomic, retain) NSMutableArray* resolveResults; +@property (assign) uint16_t lastResolvedPort; - (void) didResolveService:(ResolveResult*)resolveResult txtData:(NSData*)svcTxtData moreComing:(BOOL)moreComing error:(DNSServiceErrorType)error; - (void) didResolveServiceAddress:(NSData*)addressData error:(DNSServiceErrorType)error; @@ -63,56 +64,67 @@ - (void) didResolveServiceAddress:(NSData*)addressData error:(DNSServiceErrorTyp static void getAddrInfoCallback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* hostName, const struct sockaddr* address, uint32_t ttl, void* context ) { - ResolveResult* resolveResult = (ResolveResult*)context; - HHService* serviceResolver = resolveResult.serviceResolver; - NSData* addressData = nil; - if ( errorCode == kDNSServiceErr_NoError ) { + ContextWrapper* contextWrapper = (ContextWrapper*)context; + HHService* serviceResolver = contextWrapper.contextRetained; + + if( serviceResolver ) { + NSData* addressData = nil; + if ( errorCode == kDNSServiceErr_NoError ) { - // Set port if not set - struct sockaddr_in* sin = (struct sockaddr_in*)address; - if( sin->sin_port == 0 ) sin->sin_port = resolveResult.port; + // Set port if not set + struct sockaddr_in* sin = (struct sockaddr_in*)address; + if( sin->sin_port == 0 ) sin->sin_port = serviceResolver.lastResolvedPort; - addressData = [[NSData alloc] initWithBytes:address length:sizeof(struct sockaddr)]; + addressData = [[NSData alloc] initWithBytes:address length:sizeof(struct sockaddr)]; + } + dispatch_async(serviceResolver.mainDispatchQueue, ^{ + [serviceResolver didResolveServiceAddress:addressData error:errorCode]; + + [addressData release]; + }); } - dispatch_async(dispatch_get_main_queue(), ^{ - [serviceResolver didResolveServiceAddress:addressData error:errorCode]; - - [addressData release]; - }); + + [serviceResolver release]; } static void resolveCallback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char* fullname, const char* hosttarget, uint16_t port, uint16_t txtLen, const unsigned char* txtRecord, void* context) { - HHService* serviceResolver = (HHService*)context; - BOOL moreComing = flags & kDNSServiceFlagsMoreComing; - - ResolveResult* resolveResult = nil; - NSString* newName = [[NSString alloc] initWithCString:hosttarget encoding:NSUTF8StringEncoding]; + ContextWrapper* contextWrapper = (ContextWrapper*)context; + HHService* serviceResolver = contextWrapper.contextRetained; - if (errorCode == kDNSServiceErr_NoError) { - char interfaceName[IFNAMSIZ]; - if( if_indextoname(interfaceIndex, interfaceName) != NULL ) { - [serviceResolver HHLogDebug:@"Resolved host %@, port %d, interface index %d ('%s') - getting address info", newName, port, interfaceIndex, interfaceName]; - resolveResult = [[ResolveResult alloc] init]; - resolveResult.hostName = newName; - resolveResult.port = port; // Keep network byte ordering since we will use this in struct sockaddr_in - resolveResult.interfaceIndex = interfaceIndex; - } else { - [serviceResolver HHLogDebug:@"Resolve returned invalid interface index (%d)", interfaceIndex]; + if( serviceResolver ) { + BOOL moreComing = flags & kDNSServiceFlagsMoreComing; + + ResolveResult* resolveResult = nil; + NSString* newName = [[NSString alloc] initWithCString:hosttarget encoding:NSUTF8StringEncoding]; + + if (errorCode == kDNSServiceErr_NoError) { + char interfaceName[IFNAMSIZ]; + if( if_indextoname(interfaceIndex, interfaceName) != NULL ) { + [serviceResolver HHLogDebug:@"Resolved host %@, port %d, interface index %d ('%s') - getting address info", newName, port, interfaceIndex, interfaceName]; + resolveResult = [[ResolveResult alloc] init]; + resolveResult.hostName = newName; + resolveResult.port = port; // Keep network byte ordering since we will use this in struct sockaddr_in + resolveResult.interfaceIndex = interfaceIndex; + } else { + [serviceResolver HHLogDebug:@"Resolve returned invalid interface index (%d)", interfaceIndex]; + } } + + NSData* txtData = [[NSData alloc] initWithBytes:txtRecord length:txtLen]; + + dispatch_async(serviceResolver.mainDispatchQueue, ^{ + [serviceResolver didResolveService:resolveResult txtData:txtData moreComing:moreComing error:errorCode]; + + [resolveResult release]; + [newName release]; + [txtData release]; + }); } - NSData* txtData = [[NSData alloc] initWithBytes:txtRecord length:txtLen]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [serviceResolver didResolveService:resolveResult txtData:txtData moreComing:moreComing error:errorCode]; - - [resolveResult release]; - [newName release]; - [txtData release]; - }); + [serviceResolver release]; } @@ -120,9 +132,7 @@ static void resolveCallback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t #pragma mark HHService -@implementation HHService { -// DNSServiceRef getAddressInfoRef; -} +@implementation HHService @synthesize delegate, name, type, domain, includeP2P, @@ -220,14 +230,6 @@ - (void) dealloc { [super dealloc]; } -//- (void) doDestroy { -// if ( getAddressInfoRef != NULL ) { -// DNSServiceRefDeallocate(getAddressInfoRef); -// getAddressInfoRef = NULL; -// } -// [super doDestroy]; -//} - #pragma mark - #pragma mark Get address info methods (resolve step2) @@ -236,16 +238,12 @@ - (void) dealloc { - (void) getNextAddressInfo { ResolveResult* result = [self.resolveResults lastObject]; if( result ) { -// if( getAddressInfoRef ) { -// DNSServiceRefDeallocate(getAddressInfoRef); -// } -// DNSServiceRef getAddressInfoRef = self.sharedConnection.connectionRef; -// getAddressInfoRef = NULL; DNSServiceRef getAddressInfoRef = NULL; + self.lastResolvedPort = result.port; const char* hosttarget = [result.hostName cStringUsingEncoding:NSUTF8StringEncoding]; -// DNSServiceErrorType err = DNSServiceGetAddrInfo(&getAddressInfoRef, kDNSServiceFlagsShareConnection, result.interfaceIndex, kDNSServiceProtocol_IPv4, hosttarget, getAddrInfoCallback, result); - DNSServiceErrorType err = DNSServiceGetAddrInfo(&getAddressInfoRef, 0, result.interfaceIndex, kDNSServiceProtocol_IPv4, hosttarget, getAddrInfoCallback, result); + DNSServiceErrorType err = DNSServiceGetAddrInfo(&getAddressInfoRef, 0, result.interfaceIndex, kDNSServiceProtocol_IPv4, + hosttarget, getAddrInfoCallback, [self setCurrentCallbackContextWithContext:self]); if( err == kDNSServiceErr_NoError ) { [self HHLogDebug:@"Beginning address lookup"]; @@ -263,6 +261,8 @@ - (void) getNextAddressInfo { - (BOOL) beginResolve { + //[super resetServiceRef]; + self.resolved = NO; self.resolvedAddresses = [NSMutableArray array]; self.resolveResults = [NSMutableArray array]; @@ -278,7 +278,7 @@ - (BOOL) beginResolve { DNSServiceRef resolveRef = nil; DNSServiceErrorType err = DNSServiceResolve(&resolveRef, flags, kDNSServiceInterfaceIndexAny, - _name, _type, _domain, resolveCallback, self); + _name, _type, _domain, resolveCallback, [self setCurrentCallbackContextWithContext:self]); if( err == kDNSServiceErr_NoError ) { [self HHLogDebug:@"Beginning resolve"]; diff --git a/HHServiceBrowser.m b/HHServiceBrowser.m old mode 100755 new mode 100644 index 5e2d5ba..688a316 --- a/HHServiceBrowser.m +++ b/HHServiceBrowser.m @@ -29,24 +29,30 @@ - (void) browserReceviedResult:(DNSServiceErrorType)error serviceName:(NSString* static void browseCallBack(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context) { - HHServiceBrowser * serviceBrowser = (HHServiceBrowser *)context; - if( errorCode == kDNSServiceErr_NoError ) { - BOOL add = flags & kDNSServiceFlagsAdd; - BOOL moreComing = flags & kDNSServiceFlagsMoreComing; - - NSString* newName = serviceName ? [[NSString alloc] initWithCString:serviceName encoding:NSUTF8StringEncoding] : nil; - NSString* newDomain = replyDomain ? [[NSString alloc] initWithCString:replyDomain encoding:NSUTF8StringEncoding] : nil; - - dispatch_async(dispatch_get_main_queue(), ^{ - [serviceBrowser browserReceviedResult:errorCode serviceName:newName serviceDomain:newDomain add:add moreComing:moreComing]; + ContextWrapper* contextWrapper = (ContextWrapper*)context; + HHServiceBrowser* serviceBrowser = contextWrapper.contextRetained; + + if( serviceBrowser ) { + if( errorCode == kDNSServiceErr_NoError ) { + BOOL add = flags & kDNSServiceFlagsAdd; + BOOL moreComing = flags & kDNSServiceFlagsMoreComing; - [newName release]; - [newDomain release]; - }); - } else { - [serviceBrowser dnsServiceError:errorCode]; + NSString* newName = serviceName ? [[NSString alloc] initWithCString:serviceName encoding:NSUTF8StringEncoding] : nil; + NSString* newDomain = replyDomain ? [[NSString alloc] initWithCString:replyDomain encoding:NSUTF8StringEncoding] : nil; + + dispatch_async(serviceBrowser.mainDispatchQueue, ^{ + [serviceBrowser browserReceviedResult:errorCode serviceName:newName serviceDomain:newDomain add:add moreComing:moreComing]; + + [newName release]; + [newDomain release]; + }); + } else { + [serviceBrowser dnsServiceError:errorCode]; + } } + + [serviceBrowser release]; } @@ -120,7 +126,7 @@ - (BOOL) beginBrowse { DNSServiceRef browseRef = NULL; DNSServiceErrorType err = DNSServiceBrowse(&browseRef, flags, kDNSServiceInterfaceIndexAny, _type, _domain, - browseCallBack, self); + browseCallBack, [self setCurrentCallbackContextWithContext:self]); if( err == kDNSServiceErr_NoError ) { [self HHLogDebug:@"Beginning browse"]; diff --git a/HHServicePublisher.m b/HHServicePublisher.m index 76aa410..c63eba8 100644 --- a/HHServicePublisher.m +++ b/HHServicePublisher.m @@ -30,18 +30,24 @@ - (void) seviceDidRegister:(NSString*)newName error:(DNSServiceErrorType)error; static void registerServiceCallBack(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode, const char* name, const char* regType, const char* domain, void* context) { - HHServicePublisher * servicePublisher = (HHServicePublisher *)context; - if( errorCode == kDNSServiceErr_NoError ) { - NSString* newName = name ? [[NSString alloc] initWithCString:name encoding:NSUTF8StringEncoding] : nil; - dispatch_async(dispatch_get_main_queue(), ^{ - [servicePublisher seviceDidRegister:newName error:errorCode]; - - [newName release]; - }); - } else { - [servicePublisher dnsServiceError:errorCode]; + ContextWrapper* contextWrapper = (ContextWrapper*)context; + HHServicePublisher* servicePublisher = contextWrapper.contextRetained; + + if( servicePublisher ) { + if( errorCode == kDNSServiceErr_NoError ) { + NSString* newName = name ? [[NSString alloc] initWithCString:name encoding:NSUTF8StringEncoding] : nil; + dispatch_async(servicePublisher.mainDispatchQueue, ^{ + [servicePublisher seviceDidRegister:newName error:errorCode]; + + [newName release]; + }); + } else { + [servicePublisher dnsServiceError:errorCode]; + } } + + [servicePublisher release]; } @@ -125,7 +131,7 @@ - (BOOL) beginPublish { DNSServiceRef registerRef; DNSServiceErrorType err = DNSServiceRegister(®isterRef, flags, kDNSServiceInterfaceIndexAny, _name, _type, _domain, NULL, - bigEndianPort, _txtLen, _txtData, registerServiceCallBack, self); + bigEndianPort, _txtLen, _txtData, registerServiceCallBack, [self setCurrentCallbackContextWithContext:self]); if( err == kDNSServiceErr_NoError ) { return [super setServiceRef:registerRef]; diff --git a/HHServiceSupport.h b/HHServiceSupport.h index 612e4c0..27325b3 100644 --- a/HHServiceSupport.h +++ b/HHServiceSupport.h @@ -9,16 +9,32 @@ #import #import + +@interface ContextWrapper : NSObject + +@property (assign) id context; +@property (readonly) id contextRetained; + +@end + + @interface HHServiceSupport : NSObject @property (nonatomic, assign) DNSServiceErrorType lastError; @property (nonatomic, readonly) BOOL hasFailed; +@property (nonatomic, strong) ContextWrapper* currentCallbackContext; + +/** If you use HHServices in a different dispatch queue than the main dispatch queue, set this property to that queue. */ +@property (nonatomic, assign) dispatch_queue_t mainDispatchQueue; + - (void) dnsServiceError:(DNSServiceErrorType)error; - (BOOL) setServiceRef:(DNSServiceRef)serviceRef; - (void) resetServiceRef; +- (ContextWrapper*) setCurrentCallbackContextWithContext:(id)context; + @end diff --git a/HHServiceSupport.m b/HHServiceSupport.m index 9041dbc..757ab6b 100644 --- a/HHServiceSupport.m +++ b/HHServiceSupport.m @@ -10,12 +10,48 @@ #import "HHServiceSupport+Private.h" +@implementation ContextWrapper { + id context; +} + +- (id) initWithContext:(id)ctx { + if (self = [super init]) { + context = ctx; + } + return self; +} + +- (id) context { + @synchronized(self) { + return context; + } +} + +- (id) contextRetained { + @synchronized(self) { + return [context retain]; + } +} + +- (void) setContext:(id)ctx { + @synchronized(self) { + ctx = context; + } +} + +- (void) dealloc { + [self setContext:nil]; + [super dealloc]; +} + +@end + + @implementation HHServiceSupport { DNSServiceRef sdRef; - dispatch_queue_t sdDispatchQueue; } -@synthesize sdDispatchQueue, lastError; +@synthesize sdDispatchQueue, mainDispatchQueue; - (void) HHLogDebug:(NSString*)format, ... { @@ -37,14 +73,18 @@ - (id) init { self = [super init]; if (self) { sdDispatchQueue = dispatch_queue_create("se.leafnode.HHServices.sdDispatchQueue", DISPATCH_QUEUE_SERIAL); + mainDispatchQueue = dispatch_get_main_queue(); } return self; } - (void) dealloc { + self.currentCallbackContext = nil; + [self doDestroy]; dispatch_release(sdDispatchQueue); + dispatch_release(mainDispatchQueue); [super dealloc]; } @@ -63,7 +103,7 @@ - (void) doDestroy { - (void) dnsServiceError:(DNSServiceErrorType)error { [self HHLogDebug:@"Error: %d", error]; - lastError = error; + self.lastError = error; } @@ -89,7 +129,20 @@ - (void) resetServiceRef { } - (BOOL) hasFailed { - return lastError != kDNSServiceErr_NoError; + return self.lastError != kDNSServiceErr_NoError; +} + +- (ContextWrapper*) setCurrentCallbackContextWithContext:(id)context { + self.currentCallbackContext = [[ContextWrapper alloc] initWithContext:context]; + return self.currentCallbackContext; +} + +- (void) setMainDispatchQueue:(dispatch_queue_t)dispatchQueue { + if( dispatchQueue != mainDispatchQueue ) { + dispatch_release(mainDispatchQueue); + mainDispatchQueue = dispatchQueue; + if( dispatchQueue ) dispatch_retain(dispatchQueue); + } } diff --git a/HHServices-Prefix.pch b/HHServices-Prefix.pch new file mode 100644 index 0000000..1ac3bd3 --- /dev/null +++ b/HHServices-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'HHServices' target in the 'HHServices' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/HHServices.xcodeproj/project.pbxproj b/HHServices.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ae862b0 --- /dev/null +++ b/HHServices.xcodeproj/project.pbxproj @@ -0,0 +1,268 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + F64FD44C17426EE700662294 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F64FD44B17426EE700662294 /* Foundation.framework */; }; + F64FD46217426F4500662294 /* HHService.m in Sources */ = {isa = PBXBuildFile; fileRef = F64FD45A17426F4500662294 /* HHService.m */; }; + F64FD46317426F4500662294 /* HHServiceBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = F64FD45C17426F4500662294 /* HHServiceBrowser.m */; }; + F64FD46417426F4500662294 /* HHServicePublisher.m in Sources */ = {isa = PBXBuildFile; fileRef = F64FD45E17426F4500662294 /* HHServicePublisher.m */; }; + F64FD46517426F4500662294 /* HHServiceSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = F64FD46017426F4500662294 /* HHServiceSupport.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + F64FD44617426EE700662294 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/${PRODUCT_NAME}"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + F64FD44817426EE700662294 /* libHHServices.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libHHServices.a; sourceTree = BUILT_PRODUCTS_DIR; }; + F64FD44B17426EE700662294 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + F64FD44F17426EE700662294 /* HHServices-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HHServices-Prefix.pch"; sourceTree = ""; }; + F64FD45917426F4500662294 /* HHService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HHService.h; sourceTree = SOURCE_ROOT; }; + F64FD45A17426F4500662294 /* HHService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HHService.m; sourceTree = SOURCE_ROOT; }; + F64FD45B17426F4500662294 /* HHServiceBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HHServiceBrowser.h; sourceTree = SOURCE_ROOT; }; + F64FD45C17426F4500662294 /* HHServiceBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HHServiceBrowser.m; sourceTree = SOURCE_ROOT; }; + F64FD45D17426F4500662294 /* HHServicePublisher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HHServicePublisher.h; sourceTree = SOURCE_ROOT; }; + F64FD45E17426F4500662294 /* HHServicePublisher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HHServicePublisher.m; sourceTree = SOURCE_ROOT; }; + F64FD45F17426F4500662294 /* HHServiceSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HHServiceSupport.h; sourceTree = SOURCE_ROOT; }; + F64FD46017426F4500662294 /* HHServiceSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HHServiceSupport.m; sourceTree = SOURCE_ROOT; }; + F64FD46117426F4500662294 /* HHServiceSupport+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HHServiceSupport+Private.h"; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F64FD44517426EE700662294 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F64FD44C17426EE700662294 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F64FD43F17426EE700662294 = { + isa = PBXGroup; + children = ( + F64FD44D17426EE700662294 /* HHServices */, + F64FD44A17426EE700662294 /* Frameworks */, + F64FD44917426EE700662294 /* Products */, + ); + sourceTree = ""; + }; + F64FD44917426EE700662294 /* Products */ = { + isa = PBXGroup; + children = ( + F64FD44817426EE700662294 /* libHHServices.a */, + ); + name = Products; + sourceTree = ""; + }; + F64FD44A17426EE700662294 /* Frameworks */ = { + isa = PBXGroup; + children = ( + F64FD44B17426EE700662294 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + F64FD44D17426EE700662294 /* HHServices */ = { + isa = PBXGroup; + children = ( + F64FD45917426F4500662294 /* HHService.h */, + F64FD45A17426F4500662294 /* HHService.m */, + F64FD45B17426F4500662294 /* HHServiceBrowser.h */, + F64FD45C17426F4500662294 /* HHServiceBrowser.m */, + F64FD45D17426F4500662294 /* HHServicePublisher.h */, + F64FD45E17426F4500662294 /* HHServicePublisher.m */, + F64FD45F17426F4500662294 /* HHServiceSupport.h */, + F64FD46017426F4500662294 /* HHServiceSupport.m */, + F64FD46117426F4500662294 /* HHServiceSupport+Private.h */, + F64FD44E17426EE700662294 /* Supporting Files */, + ); + path = HHServices; + sourceTree = ""; + }; + F64FD44E17426EE700662294 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + F64FD44F17426EE700662294 /* HHServices-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F64FD44717426EE700662294 /* HHServices */ = { + isa = PBXNativeTarget; + buildConfigurationList = F64FD45617426EE700662294 /* Build configuration list for PBXNativeTarget "HHServices" */; + buildPhases = ( + F64FD44417426EE700662294 /* Sources */, + F64FD44517426EE700662294 /* Frameworks */, + F64FD44617426EE700662294 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HHServices; + productName = HHServices; + productReference = F64FD44817426EE700662294 /* libHHServices.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F64FD44017426EE700662294 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = "Leafnode AB"; + }; + buildConfigurationList = F64FD44317426EE700662294 /* Build configuration list for PBXProject "HHServices" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = F64FD43F17426EE700662294; + productRefGroup = F64FD44917426EE700662294 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F64FD44717426EE700662294 /* HHServices */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + F64FD44417426EE700662294 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F64FD46217426F4500662294 /* HHService.m in Sources */, + F64FD46317426F4500662294 /* HHServiceBrowser.m in Sources */, + F64FD46417426F4500662294 /* HHServicePublisher.m in Sources */, + F64FD46517426F4500662294 /* HHServiceSupport.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + F64FD45417426EE700662294 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + VALID_ARCHS = "arm64 armv7 armv7s i386"; + }; + name = Debug; + }; + F64FD45517426EE700662294 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + VALID_ARCHS = "arm64 armv7 armv7s i386"; + }; + name = Release; + }; + F64FD45717426EE700662294 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/HHServices.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "HHServices-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + F64FD45817426EE700662294 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/HHServices.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "HHServices-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F64FD44317426EE700662294 /* Build configuration list for PBXProject "HHServices" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F64FD45417426EE700662294 /* Debug */, + F64FD45517426EE700662294 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F64FD45617426EE700662294 /* Build configuration list for PBXNativeTarget "HHServices" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F64FD45717426EE700662294 /* Debug */, + F64FD45817426EE700662294 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F64FD44017426EE700662294 /* Project object */; +} diff --git a/HHServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/HHServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..aa46df2 --- /dev/null +++ b/HHServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/BrowserSample/BrowserSample.xcodeproj/project.pbxproj b/samples/BrowserSample/BrowserSample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e103b05 --- /dev/null +++ b/samples/BrowserSample/BrowserSample.xcodeproj/project.pbxproj @@ -0,0 +1,361 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 2757D0C01850CD4D003ACBAF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D0BF1850CD4D003ACBAF /* Foundation.framework */; }; + 2757D0C21850CD4D003ACBAF /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D0C11850CD4D003ACBAF /* CoreGraphics.framework */; }; + 2757D0C41850CD4D003ACBAF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D0C31850CD4D003ACBAF /* UIKit.framework */; }; + 2757D0CA1850CD4D003ACBAF /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2757D0C81850CD4D003ACBAF /* InfoPlist.strings */; }; + 2757D0CC1850CD4D003ACBAF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2757D0CB1850CD4D003ACBAF /* main.m */; }; + 2757D0D01850CD4D003ACBAF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2757D0CF1850CD4D003ACBAF /* AppDelegate.m */; }; + 2757D0D61850CD4D003ACBAF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2757D0D51850CD4D003ACBAF /* ViewController.m */; }; + 27BB92E71850E232008B2D66 /* libHHServices.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D13A1850CDFB003ACBAF /* libHHServices.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2757D1391850CDFB003ACBAF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2757D1351850CDFB003ACBAF /* HHServices.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = F64FD44817426EE700662294; + remoteInfo = HHServices; + }; + 27BB92E51850E22C008B2D66 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2757D1351850CDFB003ACBAF /* HHServices.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = F64FD44717426EE700662294; + remoteInfo = HHServices; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 2757D0BC1850CD4D003ACBAF /* BrowserSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BrowserSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 2757D0BF1850CD4D003ACBAF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2757D0C11850CD4D003ACBAF /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 2757D0C31850CD4D003ACBAF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 2757D0C71850CD4D003ACBAF /* BrowserSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BrowserSample-Info.plist"; sourceTree = ""; }; + 2757D0C91850CD4D003ACBAF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 2757D0CB1850CD4D003ACBAF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 2757D0CD1850CD4D003ACBAF /* BrowserSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BrowserSample-Prefix.pch"; sourceTree = ""; }; + 2757D0CE1850CD4D003ACBAF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 2757D0CF1850CD4D003ACBAF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 2757D0D41850CD4D003ACBAF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 2757D0D51850CD4D003ACBAF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 2757D1351850CDFB003ACBAF /* HHServices.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HHServices.xcodeproj; path = ../../HHServices.xcodeproj; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2757D0B91850CD4D003ACBAF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 27BB92E71850E232008B2D66 /* libHHServices.a in Frameworks */, + 2757D0C21850CD4D003ACBAF /* CoreGraphics.framework in Frameworks */, + 2757D0C41850CD4D003ACBAF /* UIKit.framework in Frameworks */, + 2757D0C01850CD4D003ACBAF /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2757D0B31850CD4D003ACBAF = { + isa = PBXGroup; + children = ( + 2757D1351850CDFB003ACBAF /* HHServices.xcodeproj */, + 2757D0C51850CD4D003ACBAF /* BrowserSample */, + 2757D0BE1850CD4D003ACBAF /* Frameworks */, + 2757D0BD1850CD4D003ACBAF /* Products */, + ); + sourceTree = ""; + }; + 2757D0BD1850CD4D003ACBAF /* Products */ = { + isa = PBXGroup; + children = ( + 2757D0BC1850CD4D003ACBAF /* BrowserSample.app */, + ); + name = Products; + sourceTree = ""; + }; + 2757D0BE1850CD4D003ACBAF /* Frameworks */ = { + isa = PBXGroup; + children = ( + 2757D0BF1850CD4D003ACBAF /* Foundation.framework */, + 2757D0C11850CD4D003ACBAF /* CoreGraphics.framework */, + 2757D0C31850CD4D003ACBAF /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 2757D0C51850CD4D003ACBAF /* BrowserSample */ = { + isa = PBXGroup; + children = ( + 2757D0CE1850CD4D003ACBAF /* AppDelegate.h */, + 2757D0CF1850CD4D003ACBAF /* AppDelegate.m */, + 2757D0D41850CD4D003ACBAF /* ViewController.h */, + 2757D0D51850CD4D003ACBAF /* ViewController.m */, + 2757D0C61850CD4D003ACBAF /* Supporting Files */, + ); + path = BrowserSample; + sourceTree = ""; + }; + 2757D0C61850CD4D003ACBAF /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 2757D0C71850CD4D003ACBAF /* BrowserSample-Info.plist */, + 2757D0C81850CD4D003ACBAF /* InfoPlist.strings */, + 2757D0CB1850CD4D003ACBAF /* main.m */, + 2757D0CD1850CD4D003ACBAF /* BrowserSample-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 2757D1361850CDFB003ACBAF /* Products */ = { + isa = PBXGroup; + children = ( + 2757D13A1850CDFB003ACBAF /* libHHServices.a */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2757D0BB1850CD4D003ACBAF /* BrowserSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2757D0EE1850CD4D003ACBAF /* Build configuration list for PBXNativeTarget "BrowserSample" */; + buildPhases = ( + 2757D0B81850CD4D003ACBAF /* Sources */, + 2757D0B91850CD4D003ACBAF /* Frameworks */, + 2757D0BA1850CD4D003ACBAF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 27BB92E61850E22C008B2D66 /* PBXTargetDependency */, + ); + name = BrowserSample; + productName = BrowserSample; + productReference = 2757D0BC1850CD4D003ACBAF /* BrowserSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2757D0B41850CD4D003ACBAF /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0500; + ORGANIZATIONNAME = "Leafnode AB"; + }; + buildConfigurationList = 2757D0B71850CD4D003ACBAF /* Build configuration list for PBXProject "BrowserSample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 2757D0B31850CD4D003ACBAF; + productRefGroup = 2757D0BD1850CD4D003ACBAF /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 2757D1361850CDFB003ACBAF /* Products */; + ProjectRef = 2757D1351850CDFB003ACBAF /* HHServices.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 2757D0BB1850CD4D003ACBAF /* BrowserSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 2757D13A1850CDFB003ACBAF /* libHHServices.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libHHServices.a; + remoteRef = 2757D1391850CDFB003ACBAF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 2757D0BA1850CD4D003ACBAF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2757D0CA1850CD4D003ACBAF /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2757D0B81850CD4D003ACBAF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2757D0D61850CD4D003ACBAF /* ViewController.m in Sources */, + 2757D0D01850CD4D003ACBAF /* AppDelegate.m in Sources */, + 2757D0CC1850CD4D003ACBAF /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 27BB92E61850E22C008B2D66 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = HHServices; + targetProxy = 27BB92E51850E22C008B2D66 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 2757D0C81850CD4D003ACBAF /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 2757D0C91850CD4D003ACBAF /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2757D0EC1850CD4D003ACBAF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = "\"$(PROJECT_DIR)/../../\""; + }; + name = Debug; + }; + 2757D0ED1850CD4D003ACBAF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = "\"$(PROJECT_DIR)/../../\""; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2757D0EF1850CD4D003ACBAF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "BrowserSample/BrowserSample-Prefix.pch"; + INFOPLIST_FILE = "BrowserSample/BrowserSample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 2757D0F01850CD4D003ACBAF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "BrowserSample/BrowserSample-Prefix.pch"; + INFOPLIST_FILE = "BrowserSample/BrowserSample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2757D0B71850CD4D003ACBAF /* Build configuration list for PBXProject "BrowserSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2757D0EC1850CD4D003ACBAF /* Debug */, + 2757D0ED1850CD4D003ACBAF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2757D0EE1850CD4D003ACBAF /* Build configuration list for PBXNativeTarget "BrowserSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2757D0EF1850CD4D003ACBAF /* Debug */, + 2757D0F01850CD4D003ACBAF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2757D0B41850CD4D003ACBAF /* Project object */; +} diff --git a/samples/BrowserSample/BrowserSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/BrowserSample/BrowserSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..8733c73 --- /dev/null +++ b/samples/BrowserSample/BrowserSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/BrowserSample/BrowserSample/AppDelegate.h b/samples/BrowserSample/BrowserSample/AppDelegate.h new file mode 100644 index 0000000..17b5aff --- /dev/null +++ b/samples/BrowserSample/BrowserSample/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// BrowserSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/samples/BrowserSample/BrowserSample/AppDelegate.m b/samples/BrowserSample/BrowserSample/AppDelegate.m new file mode 100644 index 0000000..2a34e2f --- /dev/null +++ b/samples/BrowserSample/BrowserSample/AppDelegate.m @@ -0,0 +1,23 @@ +// +// AppDelegate.m +// BrowserSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import "AppDelegate.h" + +#import "ViewController.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + self.window = [[UIWindow alloc] initWithFrame: screenBounds]; + self.window.rootViewController = [[ViewController alloc] init]; + [self.window makeKeyAndVisible]; + return YES; +} + +@end diff --git a/samples/BrowserSample/BrowserSample/BrowserSample-Info.plist b/samples/BrowserSample/BrowserSample/BrowserSample-Info.plist new file mode 100644 index 0000000..39d969f --- /dev/null +++ b/samples/BrowserSample/BrowserSample/BrowserSample-Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + se.leafnode.HHServices.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/samples/BrowserSample/BrowserSample/BrowserSample-Prefix.pch b/samples/BrowserSample/BrowserSample/BrowserSample-Prefix.pch new file mode 100644 index 0000000..82a2bb4 --- /dev/null +++ b/samples/BrowserSample/BrowserSample/BrowserSample-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/samples/BrowserSample/BrowserSample/ViewController.h b/samples/BrowserSample/BrowserSample/ViewController.h new file mode 100644 index 0000000..0b7d953 --- /dev/null +++ b/samples/BrowserSample/BrowserSample/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// BrowserSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import + +#import "HHServiceBrowser.h" + +@interface ViewController : UIViewController + +@end diff --git a/samples/BrowserSample/BrowserSample/ViewController.m b/samples/BrowserSample/BrowserSample/ViewController.m new file mode 100644 index 0000000..9a3a761 --- /dev/null +++ b/samples/BrowserSample/BrowserSample/ViewController.m @@ -0,0 +1,128 @@ +// +// ViewController.m +// BrowserSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import "ViewController.h" + +#import + +@interface ViewController () + +@end + +@implementation ViewController { + HHServiceBrowser* browser; + NSMutableArray* browseResult; + HHService* resolvingService; + + UITableView* tableView; +} + + +#pragma mark - Lifecycle + +- (id)init { + if (self = [super init]) { + // Browse for services - make sure you set the type parameter to your service type + browser = [[HHServiceBrowser alloc] initWithType:@"_myexampleservice._tcp." domain:@"local."]; + browser.delegate = self; + + browseResult = [[NSMutableArray alloc] init]; + } + return self; +} + + +- (void) loadView { + UIView* rootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; + rootView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1]; + rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + tableView = [[UITableView alloc] initWithFrame:CGRectMake(20, 40, 280, 200) style:UITableViewStylePlain]; + tableView.layer.cornerRadius = 4; + tableView.layer.borderColor = [UIColor colorWithWhite:0.5 alpha:1].CGColor; + tableView.layer.borderWidth = 1; + tableView.delegate = self; + tableView.dataSource = self; + [rootView addSubview:tableView]; + + UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(40, 250, 240, 44); + [button setTitle:@"Resolve selected" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(resolve) forControlEvents:UIControlEventTouchUpInside]; + [rootView addSubview:button]; + + self.view = rootView; + + [browser beginBrowse]; +} + + +#pragma mark - Actions + +- (void) resolve { + NSIndexPath* selectedRow = tableView.indexPathForSelectedRow; + if( !resolvingService && (selectedRow.row + 1) <= browseResult.count ) { + resolvingService = browseResult[selectedRow.row]; + resolvingService.delegate = self; + [resolvingService beginResolve]; + } else { + UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"Select a service" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; + [alert show]; + } +} + + +#pragma mark - HHServiceBrowserDelegate & HHServiceDelegate + +- (void) serviceDidResolve:(HHService*)service { + service.delegate = nil; + [service endResolve]; + resolvingService = nil; + + NSString* message = [NSString stringWithFormat:@"Service did resolve: %@", service]; + UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Resolve result" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; + [alert show]; +} + +- (void) serviceDidNotResolve:(HHService*)service { + service.delegate = nil; + [service endResolve]; + resolvingService = nil; + + NSString* message = [NSString stringWithFormat:@"Service did NOT resolve: %@", service]; + UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Resolve result" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; + [alert show]; +} + +- (void) serviceBrowser:(HHServiceBrowser*)serviceBrowser didFindService:(HHService*)service moreComing:(BOOL)moreComing { + if( ![browseResult containsObject:service] ) { + [browseResult addObject:service]; + [tableView reloadData]; + } +} + +- (void) serviceBrowser:(HHServiceBrowser*)serviceBrowser didRemoveService:(HHService*)service moreComing:(BOOL)moreComing { + [browseResult removeObject:service]; + [tableView reloadData]; +} + + +#pragma mark - UITableView + +- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return browseResult.count; +} + +- (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; + HHService* service = browseResult[indexPath.row]; + cell.textLabel.text = service.name; + return cell; +} + +@end diff --git a/samples/BrowserSample/BrowserSample/en.lproj/InfoPlist.strings b/samples/BrowserSample/BrowserSample/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/samples/BrowserSample/BrowserSample/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/samples/BrowserSample/BrowserSample/main.m b/samples/BrowserSample/BrowserSample/main.m new file mode 100644 index 0000000..56b2ffc --- /dev/null +++ b/samples/BrowserSample/BrowserSample/main.m @@ -0,0 +1,18 @@ +// +// main.m +// BrowserSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/samples/PublisherSample/PublisherSample.xcodeproj/project.pbxproj b/samples/PublisherSample/PublisherSample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b9f91cd --- /dev/null +++ b/samples/PublisherSample/PublisherSample.xcodeproj/project.pbxproj @@ -0,0 +1,361 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 2757D1011850CD94003ACBAF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D1001850CD94003ACBAF /* Foundation.framework */; }; + 2757D1031850CD94003ACBAF /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D1021850CD94003ACBAF /* CoreGraphics.framework */; }; + 2757D1051850CD94003ACBAF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D1041850CD94003ACBAF /* UIKit.framework */; }; + 2757D10B1850CD94003ACBAF /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2757D1091850CD94003ACBAF /* InfoPlist.strings */; }; + 2757D10D1850CD94003ACBAF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2757D10C1850CD94003ACBAF /* main.m */; }; + 2757D1111850CD94003ACBAF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2757D1101850CD94003ACBAF /* AppDelegate.m */; }; + 2757D1171850CD94003ACBAF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2757D1161850CD94003ACBAF /* ViewController.m */; }; + 27BB92E01850D724008B2D66 /* libHHServices.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2757D15E1850D476003ACBAF /* libHHServices.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2757D15D1850D476003ACBAF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2757D1591850D476003ACBAF /* HHServices.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = F64FD44817426EE700662294; + remoteInfo = HHServices; + }; + 27BB92DD1850D71D008B2D66 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2757D1591850D476003ACBAF /* HHServices.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = F64FD44717426EE700662294; + remoteInfo = HHServices; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 2757D0FD1850CD94003ACBAF /* PublisherSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PublisherSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 2757D1001850CD94003ACBAF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2757D1021850CD94003ACBAF /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 2757D1041850CD94003ACBAF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 2757D1081850CD94003ACBAF /* PublisherSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PublisherSample-Info.plist"; sourceTree = ""; }; + 2757D10A1850CD94003ACBAF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 2757D10C1850CD94003ACBAF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 2757D10E1850CD94003ACBAF /* PublisherSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PublisherSample-Prefix.pch"; sourceTree = ""; }; + 2757D10F1850CD94003ACBAF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 2757D1101850CD94003ACBAF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 2757D1151850CD94003ACBAF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 2757D1161850CD94003ACBAF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 2757D1591850D476003ACBAF /* HHServices.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HHServices.xcodeproj; path = ../../HHServices.xcodeproj; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2757D0FA1850CD94003ACBAF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 27BB92E01850D724008B2D66 /* libHHServices.a in Frameworks */, + 2757D1031850CD94003ACBAF /* CoreGraphics.framework in Frameworks */, + 2757D1051850CD94003ACBAF /* UIKit.framework in Frameworks */, + 2757D1011850CD94003ACBAF /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2757D0F41850CD94003ACBAF = { + isa = PBXGroup; + children = ( + 2757D1591850D476003ACBAF /* HHServices.xcodeproj */, + 2757D1061850CD94003ACBAF /* PublisherSample */, + 2757D0FF1850CD94003ACBAF /* Frameworks */, + 2757D0FE1850CD94003ACBAF /* Products */, + ); + sourceTree = ""; + }; + 2757D0FE1850CD94003ACBAF /* Products */ = { + isa = PBXGroup; + children = ( + 2757D0FD1850CD94003ACBAF /* PublisherSample.app */, + ); + name = Products; + sourceTree = ""; + }; + 2757D0FF1850CD94003ACBAF /* Frameworks */ = { + isa = PBXGroup; + children = ( + 2757D1001850CD94003ACBAF /* Foundation.framework */, + 2757D1021850CD94003ACBAF /* CoreGraphics.framework */, + 2757D1041850CD94003ACBAF /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 2757D1061850CD94003ACBAF /* PublisherSample */ = { + isa = PBXGroup; + children = ( + 2757D10F1850CD94003ACBAF /* AppDelegate.h */, + 2757D1101850CD94003ACBAF /* AppDelegate.m */, + 2757D1151850CD94003ACBAF /* ViewController.h */, + 2757D1161850CD94003ACBAF /* ViewController.m */, + 2757D1071850CD94003ACBAF /* Supporting Files */, + ); + path = PublisherSample; + sourceTree = ""; + }; + 2757D1071850CD94003ACBAF /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 2757D1081850CD94003ACBAF /* PublisherSample-Info.plist */, + 2757D1091850CD94003ACBAF /* InfoPlist.strings */, + 2757D10C1850CD94003ACBAF /* main.m */, + 2757D10E1850CD94003ACBAF /* PublisherSample-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 2757D15A1850D476003ACBAF /* Products */ = { + isa = PBXGroup; + children = ( + 2757D15E1850D476003ACBAF /* libHHServices.a */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2757D0FC1850CD94003ACBAF /* PublisherSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2757D12F1850CD95003ACBAF /* Build configuration list for PBXNativeTarget "PublisherSample" */; + buildPhases = ( + 2757D0F91850CD94003ACBAF /* Sources */, + 2757D0FA1850CD94003ACBAF /* Frameworks */, + 2757D0FB1850CD94003ACBAF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 27BB92DE1850D71D008B2D66 /* PBXTargetDependency */, + ); + name = PublisherSample; + productName = PublisherSample; + productReference = 2757D0FD1850CD94003ACBAF /* PublisherSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2757D0F51850CD94003ACBAF /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0500; + ORGANIZATIONNAME = "Leafnode AB"; + }; + buildConfigurationList = 2757D0F81850CD94003ACBAF /* Build configuration list for PBXProject "PublisherSample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 2757D0F41850CD94003ACBAF; + productRefGroup = 2757D0FE1850CD94003ACBAF /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 2757D15A1850D476003ACBAF /* Products */; + ProjectRef = 2757D1591850D476003ACBAF /* HHServices.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 2757D0FC1850CD94003ACBAF /* PublisherSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 2757D15E1850D476003ACBAF /* libHHServices.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libHHServices.a; + remoteRef = 2757D15D1850D476003ACBAF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 2757D0FB1850CD94003ACBAF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2757D10B1850CD94003ACBAF /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2757D0F91850CD94003ACBAF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2757D1171850CD94003ACBAF /* ViewController.m in Sources */, + 2757D1111850CD94003ACBAF /* AppDelegate.m in Sources */, + 2757D10D1850CD94003ACBAF /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 27BB92DE1850D71D008B2D66 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = HHServices; + targetProxy = 27BB92DD1850D71D008B2D66 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 2757D1091850CD94003ACBAF /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 2757D10A1850CD94003ACBAF /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2757D12D1850CD95003ACBAF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = "\"$(PROJECT_DIR)/../../\""; + }; + name = Debug; + }; + 2757D12E1850CD95003ACBAF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = "\"$(PROJECT_DIR)/../../\""; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2757D1301850CD95003ACBAF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "PublisherSample/PublisherSample-Prefix.pch"; + INFOPLIST_FILE = "PublisherSample/PublisherSample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 2757D1311850CD95003ACBAF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "PublisherSample/PublisherSample-Prefix.pch"; + INFOPLIST_FILE = "PublisherSample/PublisherSample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2757D0F81850CD94003ACBAF /* Build configuration list for PBXProject "PublisherSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2757D12D1850CD95003ACBAF /* Debug */, + 2757D12E1850CD95003ACBAF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2757D12F1850CD95003ACBAF /* Build configuration list for PBXNativeTarget "PublisherSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2757D1301850CD95003ACBAF /* Debug */, + 2757D1311850CD95003ACBAF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2757D0F51850CD94003ACBAF /* Project object */; +} diff --git a/samples/PublisherSample/PublisherSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/PublisherSample/PublisherSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..f80c835 --- /dev/null +++ b/samples/PublisherSample/PublisherSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/PublisherSample/PublisherSample/AppDelegate.h b/samples/PublisherSample/PublisherSample/AppDelegate.h new file mode 100644 index 0000000..fd0567d --- /dev/null +++ b/samples/PublisherSample/PublisherSample/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// PublisherSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/samples/PublisherSample/PublisherSample/AppDelegate.m b/samples/PublisherSample/PublisherSample/AppDelegate.m new file mode 100644 index 0000000..980c15d --- /dev/null +++ b/samples/PublisherSample/PublisherSample/AppDelegate.m @@ -0,0 +1,23 @@ +// +// AppDelegate.m +// PublisherSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import "AppDelegate.h" + +#import "ViewController.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + CGRect screenBounds = [[UIScreen mainScreen] bounds]; + self.window = [[UIWindow alloc] initWithFrame: screenBounds]; + self.window.rootViewController = [[ViewController alloc] init]; + [self.window makeKeyAndVisible]; + return YES; +} + +@end diff --git a/samples/PublisherSample/PublisherSample/PublisherSample-Info.plist b/samples/PublisherSample/PublisherSample/PublisherSample-Info.plist new file mode 100644 index 0000000..39d969f --- /dev/null +++ b/samples/PublisherSample/PublisherSample/PublisherSample-Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + se.leafnode.HHServices.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/samples/PublisherSample/PublisherSample/PublisherSample-Prefix.pch b/samples/PublisherSample/PublisherSample/PublisherSample-Prefix.pch new file mode 100644 index 0000000..82a2bb4 --- /dev/null +++ b/samples/PublisherSample/PublisherSample/PublisherSample-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/samples/PublisherSample/PublisherSample/ViewController.h b/samples/PublisherSample/PublisherSample/ViewController.h new file mode 100644 index 0000000..4e21fdc --- /dev/null +++ b/samples/PublisherSample/PublisherSample/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// PublisherSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import + +#import "HHServicePublisher.h" + +@interface ViewController : UIViewController + +@end diff --git a/samples/PublisherSample/PublisherSample/ViewController.m b/samples/PublisherSample/PublisherSample/ViewController.m new file mode 100644 index 0000000..d1f4a74 --- /dev/null +++ b/samples/PublisherSample/PublisherSample/ViewController.m @@ -0,0 +1,75 @@ +// +// ViewController.m +// PublisherSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import "ViewController.h" + + +@implementation ViewController { + HHServicePublisher* publisher; +} + + +#pragma mark - Lifecycle + +- (id) init { + if( self = [super init] ) { + NSUInteger serverPort = 12345; + + // Setup the service publisher - remember to update the type parameter with your actual service type + publisher = [[HHServicePublisher alloc] initWithName:@"MyDisplayName" + type:@"_myexampleservice._tcp." domain:@"local." txtData:nil port:serverPort]; + publisher.delegate = self; + } + return self; +} + +- (void) loadView { + UIView* rootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; + rootView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1]; + rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(40, 50, 240, 44); + [button setTitle:@"Publish" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(beginPublish) forControlEvents:UIControlEventTouchUpInside]; + [rootView addSubview:button]; + + button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(40, 100, 240, 44); + [button setTitle:@"Unpublish" forState:UIControlStateNormal]; + [button addTarget:self action:@selector(endPublish) forControlEvents:UIControlEventTouchUpInside]; + [rootView addSubview:button]; + + self.view = rootView; +} + + +#pragma mark - Actions + +- (void) beginPublish { + [publisher beginPublish]; +} + +- (void) endPublish { + [publisher endPublish]; +} + + +#pragma mark - HHServicePublisherDelegate + +- (void) serviceDidPublish:(HHServicePublisher*)servicePublisher { + UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Publish result" message:@"Publish successful!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; + [alert show]; +} + +- (void) serviceDidNotPublish:(HHServicePublisher*)servicePublisher { + UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Publish result" message:@"Publish failed!!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; + [alert show]; +} + +@end diff --git a/samples/PublisherSample/PublisherSample/en.lproj/InfoPlist.strings b/samples/PublisherSample/PublisherSample/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/samples/PublisherSample/PublisherSample/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/samples/PublisherSample/PublisherSample/main.m b/samples/PublisherSample/PublisherSample/main.m new file mode 100644 index 0000000..d8d9ef4 --- /dev/null +++ b/samples/PublisherSample/PublisherSample/main.m @@ -0,0 +1,18 @@ +// +// main.m +// PublisherSample +// +// Created by Tobias Löfstrand on 2013-09-21. +// Copyright (c) 2013 Leafnode AB. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/samples/Samples.xcworkspace/contents.xcworkspacedata b/samples/Samples.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..6810246 --- /dev/null +++ b/samples/Samples.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + +