diff --git a/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj b/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj index b4fa231..90c96a3 100644 --- a/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj +++ b/MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj @@ -83,6 +83,7 @@ A68E87E128C3B18900882823 /* IMSharedUtilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IMSharedUtilities.framework; path = ../../../../../System/Library/PrivateFrameworks/IMSharedUtilities.framework; sourceTree = ""; }; A69A83DE27D18092007BB936 /* IMDPersistentAttachmentController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMDPersistentAttachmentController.h; sourceTree = ""; }; A69A83DF27D18385007BB936 /* IMDPersistence.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IMDPersistence.framework; path = ../../../../../System/Library/PrivateFrameworks/IMDPersistence.framework; sourceTree = ""; }; + A6DAE8E729CCD09F00C23C79 /* SKStatusSubscriptionServiceDelegate-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SKStatusSubscriptionServiceDelegate-Protocol.h"; sourceTree = ""; }; A6E1F4CF27166012000A0EF6 /* IMPinnedConversationsController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMPinnedConversationsController.h; sourceTree = ""; }; A6E7318229A3D37000AAED78 /* IMAggregateAttachmentMessagePartChatItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMAggregateAttachmentMessagePartChatItem.h; sourceTree = ""; }; A6E7318329A3D49600AAED78 /* IMAttachmentMessagePartChatItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMAttachmentMessagePartChatItem.h; sourceTree = ""; }; @@ -224,6 +225,7 @@ FBCE4EDB201C264F002F8A61 /* IMCore */ = { isa = PBXGroup; children = ( + A6DAE8E729CCD09F00C23C79 /* SKStatusSubscriptionServiceDelegate-Protocol.h */, A64B8891271232E200BAD446 /* IMChatItem.h */, A64B8893271232E300BAD446 /* IMInlineReplyController.h */, A64B8892271232E200BAD446 /* IMSendProgressDelegate-Protocol.h */, @@ -660,7 +662,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 16; + CURRENT_PROJECT_VERSION = 18; DEPLOYMENT_LOCATION = YES; DEVELOPMENT_TEAM = S6D73TBQQU; DSTROOT = /; @@ -675,7 +677,7 @@ INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins"; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.0.14; + MARKETING_VERSION = 0.0.16; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.bluebubbles.messaging; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -696,7 +698,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 16; + CURRENT_PROJECT_VERSION = 18; DEPLOYMENT_LOCATION = YES; DEVELOPMENT_TEAM = S6D73TBQQU; DSTROOT = /; @@ -711,7 +713,7 @@ INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins"; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.0.14; + MARKETING_VERSION = 0.0.16; 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 e7b4fcd..81fdca7 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 4f7d888..ff47a6c 100644 --- a/MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m +++ b/MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m @@ -441,8 +441,8 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa } else if ([event isEqualToString:@"send-multipart"]) { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString: @""]; NSMutableArray *transfers = [[NSMutableArray alloc] init]; - NSUInteger index = 0; for (NSDictionary *dict in data[@"parts"]) { + NSUInteger index = [dict[@"partIndex"] integerValue]; if (dict[@"filePath"] != [NSNull null] && [dict[@"filePath"] length] != 0) { NSString *filePath = dict[@"filePath"]; NSURL * fileUrl = [NSURL fileURLWithPath:filePath]; @@ -458,33 +458,13 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa [attributedString appendAttributedString:attachmentStr]; } else { if (dict[@"mention"] != [NSNull null] && [dict[@"mention"] length] != 0) { - NSMutableAttributedString *beforeStr = [[NSMutableAttributedString alloc] initWithString: [(NSString *) dict[@"text"] substringWithRange:NSMakeRange(0, [[dict[@"range"] firstObject] integerValue])]]; - [beforeStr addAttributes:@{ - @"__kIMBaseWritingDirectionAttributeName": @"-1", - @"__kIMMessagePartAttributeName": [NSNumber numberWithInt:index], - } range:NSMakeRange(0, [[beforeStr string] length])]; - NSMutableAttributedString *mentionStr = [[NSMutableAttributedString alloc] initWithString: [(NSString *) dict[@"text"] substringWithRange:NSMakeRange([[dict[@"range"] firstObject] integerValue], [[dict[@"range"] lastObject] integerValue])]]; + NSMutableAttributedString *mentionStr = [[NSMutableAttributedString alloc] initWithString: dict[@"text"]]; [mentionStr addAttributes:@{ @"__kIMBaseWritingDirectionAttributeName": @"-1", @"__kIMMentionConfirmedMention": dict[@"mention"], @"__kIMMessagePartAttributeName": [NSNumber numberWithInt:index], } range:NSMakeRange(0, [[mentionStr string] length])]; - NSUInteger begin = [[dict[@"range"] firstObject] integerValue] + [[dict[@"range"] lastObject] integerValue]; - NSUInteger end = [dict[@"text"] length] - begin; - NSMutableAttributedString *afterStr = [[NSMutableAttributedString alloc] initWithString: [(NSString *) dict[@"text"] substringWithRange:NSMakeRange(begin, end)]]; - [afterStr addAttributes:@{ - @"__kIMBaseWritingDirectionAttributeName": @"-1", - @"__kIMMessagePartAttributeName": [NSNumber numberWithInt:index], - } range:NSMakeRange(0, [[afterStr string] length])]; - if ([[beforeStr string] length] != 0) { - [attributedString appendAttributedString:beforeStr]; - } - if ([[mentionStr string] length] != 0) { - [attributedString appendAttributedString:mentionStr]; - } - if ([[afterStr string] length] != 0) { - [attributedString appendAttributedString:afterStr]; - } + [attributedString appendAttributedString:mentionStr]; } else { NSMutableAttributedString *messageStr = [[NSMutableAttributedString alloc] initWithString: dict[@"text"]]; [messageStr addAttributes:@{ @@ -494,7 +474,6 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa [attributedString appendAttributedString:messageStr]; } } - index++; } [BlueBubblesHelper sendMessage:(data) transfers:[transfers copy] attributedString:attributedString transaction:(transaction)]; // If the server tells us to get the vetted aliases @@ -603,19 +582,25 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa // Use reference to class since it doesn't exist on Big Sur Class cls = NSClassFromString(@"IMHandleAvailabilityManager"); if ([handles firstObject] != nil && cls != nil) { - [[cls sharedInstance] _fetchUpdatedStatusForHandle:([handles firstObject]) completion:^() { - // delay for 1 second to ensure we have latest status - NSTimeInterval delayInSeconds = 1.0; - dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); - dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ - NSInteger *status = [[cls sharedInstance] availabilityForHandle:([handles firstObject])]; - DLog("BLUEBUBBLESHELPER: Found status %{public}ld for %{public}@", (long)status, data[@"address"]); - if (transaction != nil) { - BOOL silenced = status == 2; - [[NetworkController sharedInstance] sendMessage: @{@"transactionId": transaction, @"silenced": [NSNumber numberWithBool:silenced]}]; - } - }); - }]; + if ([cls respondsToSelector:NSSelectorFromString(@"_fetchUpdatedStatusForHandle")]) { + [[cls sharedInstance] _fetchUpdatedStatusForHandle:([handles firstObject]) completion:^() { + // delay for 1 second to ensure we have latest status + NSTimeInterval delayInSeconds = 1.0; + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); + dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + NSInteger *status = [[cls sharedInstance] availabilityForHandle:([handles firstObject])]; + DLog("BLUEBUBBLESHELPER: Found status %{public}ld for %{public}@", (long)status, data[@"address"]); + if (transaction != nil) { + BOOL silenced = status == 2; + [[NetworkController sharedInstance] sendMessage: @{@"transactionId": transaction, @"silenced": [NSNumber numberWithBool:silenced]}]; + } + }); + }]; + } else { + if (transaction != nil) { + [[NetworkController sharedInstance] sendMessage: @{@"transactionId": transaction, @"error": @"Selector not found!"}]; + } + } } } else if ([event isEqualToString:@"notify-anyways"]) { IMChat *chat = [BlueBubblesHelper getChat:data[@"chatGuid"] :transaction]; diff --git a/MacOS-11+/BlueBubblesHelper/SKStatusSubscriptionServiceDelegate-Protocol.h b/MacOS-11+/BlueBubblesHelper/SKStatusSubscriptionServiceDelegate-Protocol.h new file mode 100644 index 0000000..60f349c --- /dev/null +++ b/MacOS-11+/BlueBubblesHelper/SKStatusSubscriptionServiceDelegate-Protocol.h @@ -0,0 +1,16 @@ +// Headers generated with ktool v1.4.0 +// https://github.com/cxnder/ktool | pip3 install k2l +// Platform: IOS | Minimum OS: 16.0.0 | SDK: 16.0.0 + + + +@protocol SKStatusSubscriptionServiceDelegate + + + +@optional +-(void)subscriptionInvitationReceived:(id)arg0 ; +-(void)subscriptionReceivedStatusUpdate:(id)arg0 ; +-(void)subscriptionServiceDaemonDisconnected:(id)arg0 ; +-(void)subscriptionStateChanged:(id)arg0 ; +@end