diff --git a/MacOS-10/BlueBubblesHelper/BlueBubblesHelper.m b/MacOS-10/BlueBubblesHelper/BlueBubblesHelper.m index 8509ce6..4ffaab8 100644 --- a/MacOS-10/BlueBubblesHelper/BlueBubblesHelper.m +++ b/MacOS-10/BlueBubblesHelper/BlueBubblesHelper.m @@ -288,7 +288,7 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa } NSArray *handles = [[IMHandleRegistrar sharedInstance] getIMHandlesForID:(data[@"address"])]; - if (handles != nil) { + if (handles == nil) { if (transaction != nil) { [[NetworkController sharedInstance] sendMessage: @{@"transactionId": transaction, @"error": @"Failed to load handles for provided address!"}]; } diff --git a/MacOS-10/BlueBubblesHelper/NetworkController.m b/MacOS-10/BlueBubblesHelper/NetworkController.m index 7d86dd5..1b03ea6 100644 --- a/MacOS-10/BlueBubblesHelper/NetworkController.m +++ b/MacOS-10/BlueBubblesHelper/NetworkController.m @@ -33,12 +33,19 @@ + (NetworkController*)sharedInstance { #pragma mark - Public methods +#define CLAMP(x, low, high) ({\ + __typeof__(x) __x = (x); \ + __typeof__(low) __low = (low);\ + __typeof__(high) __high = (high);\ + __x > __high ? __high : (__x < __low ? __low : __x);\ + }) + - (void)connect { // we need to get the port to open the server on (to allow multiple users to use the bundle) // we'll base this off the users uid (a unique id for each user, starting from 501) // we'll subtract 501 to get an id starting at 0, incremented for each user // then we add this to the base port to get a unique port for the socket - int port = 45670 + getuid()-501; + int port = CLAMP(45670 + getuid()-501, 45670, 65535); DLog(@"BLUEBUBBLESHELPER: Connecting to socket on port %d", port); // connect to socket asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()]; diff --git a/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj b/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj index 7225b5b..5572fe6 100644 --- a/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj +++ b/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj @@ -468,7 +468,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEPLOYMENT_LOCATION = YES; DEVELOPMENT_TEAM = S6D73TBQQU; DSTROOT = /; @@ -483,7 +483,7 @@ INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins"; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.0.5; + MARKETING_VERSION = 0.0.6; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.bluebubbles.messaging; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -504,7 +504,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEPLOYMENT_LOCATION = YES; DEVELOPMENT_TEAM = S6D73TBQQU; DSTROOT = /; @@ -519,7 +519,7 @@ INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins"; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.0.5; + MARKETING_VERSION = 0.0.6; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.bluebubbles.messaging; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/MacOS-11+/BlueBubblesHelper.xcworkspace/xcuserdata/tanay.xcuserdatad/UserInterfaceState.xcuserstate b/MacOS-11+/BlueBubblesHelper.xcworkspace/xcuserdata/tanay.xcuserdatad/UserInterfaceState.xcuserstate index 4a7686b..183ea44 100644 Binary files a/MacOS-11+/BlueBubblesHelper.xcworkspace/xcuserdata/tanay.xcuserdatad/UserInterfaceState.xcuserstate and b/MacOS-11+/BlueBubblesHelper.xcworkspace/xcuserdata/tanay.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m b/MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m index d2fecc8..97fcd98 100644 --- a/MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m +++ b/MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m @@ -292,7 +292,7 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa } NSArray *handles = [[IMHandleRegistrar sharedInstance] getIMHandlesForID:(data[@"address"])]; - if (handles != nil) { + if (handles == nil) { if (transaction != nil) { [[NetworkController sharedInstance] sendMessage: @{@"transactionId": transaction, @"error": @"Failed to load handles for provided address!"}]; } diff --git a/MacOS-11+/BlueBubblesHelper/NetworkController.m b/MacOS-11+/BlueBubblesHelper/NetworkController.m index 7d86dd5..1b03ea6 100644 --- a/MacOS-11+/BlueBubblesHelper/NetworkController.m +++ b/MacOS-11+/BlueBubblesHelper/NetworkController.m @@ -33,12 +33,19 @@ + (NetworkController*)sharedInstance { #pragma mark - Public methods +#define CLAMP(x, low, high) ({\ + __typeof__(x) __x = (x); \ + __typeof__(low) __low = (low);\ + __typeof__(high) __high = (high);\ + __x > __high ? __high : (__x < __low ? __low : __x);\ + }) + - (void)connect { // we need to get the port to open the server on (to allow multiple users to use the bundle) // we'll base this off the users uid (a unique id for each user, starting from 501) // we'll subtract 501 to get an id starting at 0, incremented for each user // then we add this to the base port to get a unique port for the socket - int port = 45670 + getuid()-501; + int port = CLAMP(45670 + getuid()-501, 45670, 65535); DLog(@"BLUEBUBBLESHELPER: Connecting to socket on port %d", port); // connect to socket asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];