diff --git a/External/Pearl b/External/Pearl index efe1b532..9b1a79dc 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit efe1b532952a2cdc725b489160114a135d1ca939 +Subproject commit 9b1a79dc981997c2c0c0276bca4aad2eeb9de9cd diff --git a/MasterPassword-Mac.xcodeproj/project.pbxproj b/MasterPassword-Mac.xcodeproj/project.pbxproj index b144446e..a528f468 100644 --- a/MasterPassword-Mac.xcodeproj/project.pbxproj +++ b/MasterPassword-Mac.xcodeproj/project.pbxproj @@ -7498,6 +7498,7 @@ LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; }; name = Debug; @@ -7520,6 +7521,7 @@ LD_DYLIB_INSTALL_NAME = "@rpath/$(EXECUTABLE_PATH)"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; }; name = Release; @@ -7530,8 +7532,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MasterPassword/Mac/MasterPassword-Prefix.pch"; INFOPLIST_FILE = "MasterPassword/Mac/MasterPassword-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; }; name = Debug; }; @@ -7541,8 +7541,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MasterPassword/Mac/MasterPassword-Prefix.pch"; INFOPLIST_FILE = "MasterPassword/Mac/MasterPassword-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; }; name = Release; }; @@ -7555,7 +7553,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Pearl/Pearl-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/External/Pearl/External/iOSPorts/include/**"; - PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; @@ -7568,7 +7565,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Pearl/Pearl-Prefix.pch"; HEADER_SEARCH_PATHS = "$(SRCROOT)/External/Pearl/External/iOSPorts/include/**"; - PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; @@ -7581,7 +7577,6 @@ "-DHAVE_CONFIG_H", "$(inherited)", ); - PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; @@ -7594,7 +7589,6 @@ "-DHAVE_CONFIG_H", "$(inherited)", ); - PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; @@ -7613,7 +7607,6 @@ "-DOPENSSL_NO_STORE", "$(inherited)", ); - PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; @@ -7632,7 +7625,6 @@ "-DOPENSSL_NO_STORE", "$(inherited)", ); - PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; diff --git a/MasterPassword-iOS.xcodeproj/project.pbxproj b/MasterPassword-iOS.xcodeproj/project.pbxproj index 8738da32..6b130164 100644 --- a/MasterPassword-iOS.xcodeproj/project.pbxproj +++ b/MasterPassword-iOS.xcodeproj/project.pbxproj @@ -712,6 +712,10 @@ DAB8D97A15036BF700CED3BC /* tip_location_wood.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB8D6F815036BF600CED3BC /* tip_location_wood.png */; }; DAB8D97B15036BF700CED3BC /* tip_location_wood@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB8D6F915036BF600CED3BC /* tip_location_wood@2x.png */; }; DAB8D97C1503718B00CED3BC /* jquery-1.6.1.min.js in Resources */ = {isa = PBXBuildFile; fileRef = DAB8D6AB15036BF600CED3BC /* jquery-1.6.1.min.js */; }; + DABB9809150FF40100B05417 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA5BFA4A147E415C00F98B1E /* Foundation.framework */; }; + DABB980F150FF40100B05417 /* SendToMac.m in Sources */ = {isa = PBXBuildFile; fileRef = DABB980E150FF40100B05417 /* SendToMac.m */; }; + DABB9814150FF5C100B05417 /* libSendToMac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DABB9808150FF40100B05417 /* libSendToMac.a */; }; + DABB981615100B4000B05417 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DABB981515100B4000B05417 /* SystemConfiguration.framework */; }; DAC6325E1486805C0075AEA5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA5BFA4A147E415C00F98B1E /* Foundation.framework */; }; DAC6326D148680650075AEA5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA5BFA4A147E415C00F98B1E /* Foundation.framework */; }; DAC63277148680700075AEA5 /* libuicolor-utilities.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC6325D1486805C0075AEA5 /* libuicolor-utilities.a */; }; @@ -1556,6 +1560,11 @@ DAB8D6F715036BF600CED3BC /* tip_location_teal@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tip_location_teal@2x.png"; sourceTree = ""; }; DAB8D6F815036BF600CED3BC /* tip_location_wood.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tip_location_wood.png; sourceTree = ""; }; DAB8D6F915036BF600CED3BC /* tip_location_wood@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tip_location_wood@2x.png"; sourceTree = ""; }; + DABB9808150FF40100B05417 /* libSendToMac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSendToMac.a; sourceTree = BUILT_PRODUCTS_DIR; }; + DABB980C150FF40100B05417 /* SendToMac-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SendToMac-Prefix.pch"; sourceTree = ""; }; + DABB980D150FF40100B05417 /* SendToMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SendToMac.h; sourceTree = ""; }; + DABB980E150FF40100B05417 /* SendToMac.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SendToMac.m; sourceTree = ""; }; + DABB981515100B4000B05417 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; DAC6325D1486805C0075AEA5 /* libuicolor-utilities.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libuicolor-utilities.a"; sourceTree = BUILT_PRODUCTS_DIR; }; DAC6326C148680650075AEA5 /* libjrswizzle.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libjrswizzle.a; sourceTree = BUILT_PRODUCTS_DIR; }; DAC632791486809A0075AEA5 /* JRSwizzle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JRSwizzle.h; path = External/Pearl/External/jrswizzle/JRSwizzle.h; sourceTree = SOURCE_ROOT; }; @@ -1648,6 +1657,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DABB981615100B4000B05417 /* SystemConfiguration.framework in Frameworks */, + DABB9814150FF5C100B05417 /* libSendToMac.a in Frameworks */, DA672D3014F9413D004A189C /* libPearl.a in Frameworks */, DA672D2F14F92C6B004A189C /* libz.dylib in Frameworks */, DAEBC45314F6364500987BF6 /* QuartzCore.framework in Frameworks */, @@ -1671,6 +1682,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DABB9805150FF40100B05417 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DABB9809150FF40100B05417 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DAC6325A1486805C0075AEA5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1715,9 +1734,9 @@ isa = PBXGroup; children = ( DA1A142714E494DA00BCFFBE /* scrypt.xcodeproj */, - DA95D5F014DF0B1E008D1B94 /* MessageUI.framework */, DA5BFA50147E415C00F98B1E /* MasterPassword */, DAB8D46F15036BF600CED3BC /* Resources */, + DABB980A150FF40100B05417 /* SendToMac */, DAC77CAF148291A600BCF976 /* Pearl */, DAC6325F1486805C0075AEA5 /* uicolor-utilities */, DAC6326E148680650075AEA5 /* jrswizzle */, @@ -1736,6 +1755,7 @@ DAC6325D1486805C0075AEA5 /* libuicolor-utilities.a */, DAC6326C148680650075AEA5 /* libjrswizzle.a */, DA95D59C14DF063C008D1B94 /* libInAppSettingsKit.a */, + DABB9808150FF40100B05417 /* libSendToMac.a */, ); name = Products; sourceTree = ""; @@ -1743,6 +1763,8 @@ DA5BFA47147E415C00F98B1E /* Frameworks */ = { isa = PBXGroup; children = ( + DA95D5F014DF0B1E008D1B94 /* MessageUI.framework */, + DABB981515100B4000B05417 /* SystemConfiguration.framework */, DA672D2E14F92C6B004A189C /* libz.dylib */, DAEBC45214F6364500987BF6 /* QuartzCore.framework */, DA04E33D14B1E70400ECA4F3 /* MobileCoreServices.framework */, @@ -2610,6 +2632,24 @@ name = "Supporting Files"; sourceTree = ""; }; + DABB980A150FF40100B05417 /* SendToMac */ = { + isa = PBXGroup; + children = ( + DABB980D150FF40100B05417 /* SendToMac.h */, + DABB980E150FF40100B05417 /* SendToMac.m */, + DABB980B150FF40100B05417 /* Supporting Files */, + ); + path = SendToMac; + sourceTree = ""; + }; + DABB980B150FF40100B05417 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + DABB980C150FF40100B05417 /* SendToMac-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; DAC6325F1486805C0075AEA5 /* uicolor-utilities */ = { isa = PBXGroup; children = ( @@ -2787,6 +2827,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DABB9806150FF40100B05417 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; DAC6325B1486805C0075AEA5 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -2886,6 +2933,23 @@ productReference = DA95D59C14DF063C008D1B94 /* libInAppSettingsKit.a */; productType = "com.apple.product-type.library.static"; }; + DABB9807150FF40100B05417 /* SendToMac */ = { + isa = PBXNativeTarget; + buildConfigurationList = DABB9810150FF40100B05417 /* Build configuration list for PBXNativeTarget "SendToMac" */; + buildPhases = ( + DABB9804150FF40100B05417 /* Sources */, + DABB9805150FF40100B05417 /* Frameworks */, + DABB9806150FF40100B05417 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SendToMac; + productName = SendToMac; + productReference = DABB9808150FF40100B05417 /* libSendToMac.a */; + productType = "com.apple.product-type.library.static"; + }; DAC6325C1486805C0075AEA5 /* uicolor-utilities */ = { isa = PBXNativeTarget; buildConfigurationList = DAC632651486805C0075AEA5 /* Build configuration list for PBXNativeTarget "uicolor-utilities" */; @@ -2973,6 +3037,7 @@ DAC6325C1486805C0075AEA5 /* uicolor-utilities */, DAC6326B148680650075AEA5 /* jrswizzle */, DA95D59B14DF063C008D1B94 /* InAppSettingsKit */, + DABB9807150FF40100B05417 /* SendToMac */, ); }; /* End PBXProject section */ @@ -3722,6 +3787,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DABB9804150FF40100B05417 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DABB980F150FF40100B05417 /* SendToMac.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DAC632591486805C0075AEA5 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -4014,6 +4087,54 @@ }; name = AppStore; }; + DABB9811150FF40100B05417 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + DSTROOT = /tmp/SendToMac.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "SendToMac/SendToMac-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_UNINITIALIZED_AUTOS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + DABB9812150FF40100B05417 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = YES; + DSTROOT = /tmp/SendToMac.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "SendToMac/SendToMac-Prefix.pch"; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; + DABB9813150FF40100B05417 /* AppStore */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = YES; + DSTROOT = /tmp/SendToMac.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "SendToMac/SendToMac-Prefix.pch"; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = AppStore; + }; DAC632661486805C0075AEA5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4123,6 +4244,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + DABB9810150FF40100B05417 /* Build configuration list for PBXNativeTarget "SendToMac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DABB9811150FF40100B05417 /* Debug */, + DABB9812150FF40100B05417 /* Release */, + DABB9813150FF40100B05417 /* AppStore */, + ); + defaultConfigurationIsVisible = 0; + }; DAC632651486805C0075AEA5 /* Build configuration list for PBXNativeTarget "uicolor-utilities" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/MasterPassword/Mac/MPAppDelegate.h b/MasterPassword/Mac/MPAppDelegate.h index 45b2ac92..782fb65a 100644 --- a/MasterPassword/Mac/MPAppDelegate.h +++ b/MasterPassword/Mac/MPAppDelegate.h @@ -9,7 +9,7 @@ #import #import "MPPasswordWindowController.h" -@interface MPAppDelegate : NSObject +@interface MPAppDelegate : NSObject @property (assign) IBOutlet NSWindow *window; @@ -17,8 +17,6 @@ @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; -@property (readonly, strong, nonatomic) NSNetService *netService; - + (NSManagedObjectModel *)managedObjectModel; + (NSManagedObjectContext *)managedObjectContext; diff --git a/MasterPassword/Mac/MPAppDelegate.m b/MasterPassword/Mac/MPAppDelegate.m index b90cee7a..9b33be55 100644 --- a/MasterPassword/Mac/MPAppDelegate.m +++ b/MasterPassword/Mac/MPAppDelegate.m @@ -9,17 +9,10 @@ #import "MPAppDelegate_Key.h" #import "MPConfig.h" -#import -#import - @interface MPAppDelegate () @property (readwrite, strong, nonatomic) MPPasswordWindowController *passwordWindow; -@property (readwrite, strong, nonatomic) NSNetService *netService; -@property (readwrite, assign, nonatomic) CFSocketRef listeningSocket; - -- (void)connectionEstablishedOnHandle:(CFSocketNativeHandle)handle; @end @@ -28,24 +21,18 @@ @synthesize persistentStoreCoordinator = __persistentStoreCoordinator; @synthesize managedObjectModel = __managedObjectModel; @synthesize managedObjectContext = __managedObjectContext; -@synthesize netService, listeningSocket; @synthesize passwordWindow; @synthesize key; @synthesize keyHash; @synthesize keyHashHex; -static void ListeningSocketCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) { - - [[MPAppDelegate get] connectionEstablishedOnHandle:*(const CFSocketNativeHandle *)data]; -} - + (void)initialize { [MPConfig get]; #ifdef DEBUG - [PearlLogger get].autoprintLevel = PearlLogLevelTrace; + [PearlLogger get].autoprintLevel = PearlLogLevelDebug; #endif } @@ -61,120 +48,8 @@ static void ListeningSocketCallback(CFSocketRef s, CFSocketCallBackType type, CF - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - [self setupNetworkListener]; } -- (void)setupNetworkListener { - - struct sockaddr_in6 serverAddress6; - socklen_t serverAddress6_len = sizeof(serverAddress6); - memset(&serverAddress6, 0, serverAddress6_len); - serverAddress6.sin6_len = serverAddress6_len; - serverAddress6.sin6_family = AF_INET6; - - NSSocketNativeHandle socketHandle; - if (0 > (socketHandle = socket(AF_INET6, SOCK_STREAM, 0))) { - err(@"Couldn't create socket: %@", errstr()); - return; - } - if (0 > bind(socketHandle, (const struct sockaddr *) &serverAddress6, serverAddress6_len)) { - err(@"Couldn't bind socket: %@", errstr()); - close(socketHandle); - return; - } - if (0 > getsockname(socketHandle, (struct sockaddr *) &serverAddress6, &serverAddress6_len)) { - err(@"Couldn't get socket info: %@", errstr()); - close(socketHandle); - return; - } - if (0 > listen(socketHandle, 5)) { - err(@"Couldn't get socket info: %@", errstr()); - close(socketHandle); - return; - } - if (!(self.listeningSocket = CFSocketCreateWithNative(NULL, socketHandle, kCFSocketAcceptCallBack, ListeningSocketCallback, NULL))) { - err(@"Couldn't start listening on the socket: %@", errstr()); - return; - } - - CFRunLoopSourceRef runLoopSource = CFSocketCreateRunLoopSource(NULL, self.listeningSocket, 0); - CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode); - CFRelease(runLoopSource); - - int chosenPort = ntohs(serverAddress6.sin6_port); - inf(@"Master Password bound to port %d", chosenPort); - self.netService = [[NSNetService alloc] initWithDomain:@"" type:@"_masterpassword._tcp." name:@"Master Password" port:chosenPort]; - if(!self.netService) { - err(@"Couldn't initialize the Bonjour service."); - return; - } - - self.netService.delegate = self; - [self.netService publish]; -} - -- (void)connectionEstablishedOnHandle:(CFSocketNativeHandle)handle { - - dbg(@"%@%d", NSStringFromSelector(_cmd), handle); -} - -/* Sent to the NSNetService instance's delegate prior to advertising the service on the network. If for some reason the service cannot be published, the delegate will not receive this message, and an error will be delivered to the delegate via the delegate's -netService:didNotPublish: method. - */ -- (void)netServiceWillPublish:(NSNetService *)sender { - - dbg(@"%@", NSStringFromSelector(_cmd)); -} - -/* Sent to the NSNetService instance's delegate when the publication of the instance is complete and successful. - */ -- (void)netServiceDidPublish:(NSNetService *)sender { - - dbg(@"%@", NSStringFromSelector(_cmd)); -} - -/* Sent to the NSNetService instance's delegate when an error in publishing the instance occurs. The error dictionary will contain two key/value pairs representing the error domain and code (see the NSNetServicesError enumeration above for error code constants). It is possible for an error to occur after a successful publication. - */ -- (void)netService:(NSNetService *)sender didNotPublish:(NSDictionary *)errorDict { - - dbg(@"%@%@", NSStringFromSelector(_cmd), errorDict); -} - -/* Sent to the NSNetService instance's delegate prior to resolving a service on the network. If for some reason the resolution cannot occur, the delegate will not receive this message, and an error will be delivered to the delegate via the delegate's -netService:didNotResolve: method. - */ -- (void)netServiceWillResolve:(NSNetService *)sender { - - dbg(@"%@", NSStringFromSelector(_cmd)); -} - -/* Sent to the NSNetService instance's delegate when one or more addresses have been resolved for an NSNetService instance. Some NSNetService methods will return different results before and after a successful resolution. An NSNetService instance may get resolved more than once; truly robust clients may wish to resolve again after an error, or to resolve more than once. - */ -- (void)netServiceDidResolveAddress:(NSNetService *)sender { - - dbg(@"%@", NSStringFromSelector(_cmd)); -} - -/* Sent to the NSNetService instance's delegate when an error in resolving the instance occurs. The error dictionary will contain two key/value pairs representing the error domain and code (see the NSNetServicesError enumeration above for error code constants). - */ -- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict { - - dbg(@"%@%@", NSStringFromSelector(_cmd), errorDict); -} - -/* Sent to the NSNetService instance's delegate when the instance's previously running publication or resolution request has stopped. - */ -- (void)netServiceDidStop:(NSNetService *)sender { - - dbg(@"%@", NSStringFromSelector(_cmd)); -} - -/* Sent to the NSNetService instance's delegate when the instance is being monitored and the instance's TXT record has been updated. The new record is contained in the data parameter. - */ -- (void)netService:(NSNetService *)sender didUpdateTXTRecordData:(NSData *)data { - - dbg(@"%@%@", NSStringFromSelector(_cmd), data); -} - - - (void)applicationDidBecomeActive:(NSNotification *)notification { if (!self.passwordWindow) diff --git a/MasterPassword/Mac/en.lproj/MainMenu.xib b/MasterPassword/Mac/en.lproj/MainMenu.xib index 1cd74cec..31f6322f 100644 --- a/MasterPassword/Mac/en.lproj/MainMenu.xib +++ b/MasterPassword/Mac/en.lproj/MainMenu.xib @@ -582,9 +582,42 @@ - 711 + 715 + + + + + MPAppDelegate + NSObject + + saveAction: + id + + + saveAction: + + saveAction: + id + + + + window + NSWindow + + + window + + window + NSWindow + + + + IBProjectSource + ./Classes/MPAppDelegate.h + + + - 0 IBCocoaFramework diff --git a/MasterPassword/iOS/MasterPassword-Prefix.pch b/MasterPassword/iOS/MasterPassword-Prefix.pch index de240c68..43379b65 100644 --- a/MasterPassword/iOS/MasterPassword-Prefix.pch +++ b/MasterPassword/iOS/MasterPassword-Prefix.pch @@ -5,20 +5,20 @@ #import #ifndef __IPHONE_5_0 -#warning "This project uses features only available in iOS SDK 5.0 and later." + #warning "This project uses features only available in iOS SDK 5.0 and later." #endif +#import "Pearl-Prefix.pch" + #ifdef __OBJC__ #import #import #import - #ifndef PRODUCTION - #import "TestFlight.h" + #ifdef TESTFLIGHT + #import "TestFlight.h" #endif + + #import "MPTypes.h" + #import "MPiOSConfig.h" #endif - -#import "Pearl-Prefix.pch" - -#import "MPTypes.h" -#import "MPiOSConfig.h" diff --git a/SendToMac/SendToMac-Prefix.pch b/SendToMac/SendToMac-Prefix.pch new file mode 100644 index 00000000..bc335dd5 --- /dev/null +++ b/SendToMac/SendToMac-Prefix.pch @@ -0,0 +1,9 @@ +// +// Prefix header for all source files of the 'SendToMac' target in the 'SendToMac' project +// + +#ifdef __OBJC__ + #import +#endif + +#import "Pearl-Prefix.pch" diff --git a/SendToMac/SendToMac.h b/SendToMac/SendToMac.h new file mode 100644 index 00000000..485766a2 --- /dev/null +++ b/SendToMac/SendToMac.h @@ -0,0 +1,17 @@ +// +// SendToMac.h +// SendToMac +// +// Created by Maarten Billemont on 13/03/12. +// Copyright (c) 2012 Lyndir. All rights reserved. +// + +#import + +@interface SendToMac : NSObject + +@property (assign) NSTimeInterval timeout; +@property (strong) NSNetServiceBrowser *netServiceBrowser; +@property (strong) NSMutableDictionary *messageQueues; + +@end diff --git a/SendToMac/SendToMac.m b/SendToMac/SendToMac.m new file mode 100644 index 00000000..f6a8b376 --- /dev/null +++ b/SendToMac/SendToMac.m @@ -0,0 +1,107 @@ +// +// SendToMac.m +// SendToMac +// +// Created by Maarten Billemont on 13/03/12. +// Copyright (c) 2012 Lyndir. All rights reserved. +// + +#import "SendToMac.h" + +#import +#import +#import +#include + +@implementation SendToMac +@synthesize timeout, netServiceBrowser, messageQueues; + +- (id)initWithDelegate:(id)delegate { + + if (!(self = [super init])) + return nil; + + self.timeout = 10; + self.messageQueues = [NSMutableDictionary dictionaryWithCapacity:1]; + + self.netServiceBrowser = [NSNetServiceBrowser new]; + self.netServiceBrowser.delegate = delegate; + + return self; +} + +- (void)start { + + [self.netServiceBrowser searchForServicesOfType:@"_sendtomac._tcp." inDomain:@""]; +} + +- (void)stop { + + [self.netServiceBrowser stop]; +} + +- (void)send:(NSString *)string toMac:(NSNetService *)service { + + NSMutableArray *messageQueue = [self.messageQueues objectForKey:service]; + if (!messageQueue) + [self.messageQueues setObject:messageQueue = [NSMutableArray arrayWithCapacity:3] forKey:service]; + [messageQueue addObject:string]; + + service.delegate = self; + [service resolveWithTimeout:self.timeout]; +} + +- (void)netServiceDidResolveAddress:(NSNetService *)sender { + + struct sockaddr *senderAddress = NULL; + for (NSData *address in sender.addresses) { + struct sockaddr *socketAddress = (struct sockaddr *)address.bytes; + char *addressName = inet_ntoa((((struct sockaddr_in *)socketAddress)->sin_addr)); + + SCNetworkReachabilityRef target = SCNetworkReachabilityCreateWithAddress(NULL, socketAddress); + SCNetworkReachabilityFlags flags; + if (!SCNetworkReachabilityGetFlags(target, &flags)) { + err(@"Couldn't determine reachability for address: %s", addressName); + continue; + } + + if (!(flags & kSCNetworkReachabilityFlagsReachable)) { + err(@"Not reachable: %s", addressName); + continue; + } + + senderAddress = socketAddress; + break; + } + if (senderAddress == NULL) { + dbg(@"Couldn't determine a reachable address for: %@", sender); + return; + } + + NSSocketNativeHandle socketHandle; + if (0 > (socketHandle = socket(senderAddress->sa_family, SOCK_STREAM, 0))) { + err(@"Couldn't create socket: %@", errstr()); + return; + } + if (0 > connect(socketHandle, senderAddress, senderAddress->sa_len)) { + err(@"Couldn't connect socket: %@", errstr()); + close(socketHandle); + return; + } + if (0 > close(socketHandle)) { + err(@"Couldn't close socket: %@", errstr()); + return; + } + + for (NSString *messange in [self.messageQueues objectForKey:sender]) { + + } +} + +- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict { + + err(@"%@%@", NSStringFromSelector(_cmd), errorDict); +} + + +@end