Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tneotia committed Jun 12, 2023
2 parents 94dd89b + 0206a47 commit 8a91ee9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 41 deletions.
10 changes: 6 additions & 4 deletions MacOS-11+/BlueBubblesHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
A68E87E128C3B18900882823 /* IMSharedUtilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IMSharedUtilities.framework; path = ../../../../../System/Library/PrivateFrameworks/IMSharedUtilities.framework; sourceTree = "<group>"; };
A69A83DE27D18092007BB936 /* IMDPersistentAttachmentController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMDPersistentAttachmentController.h; sourceTree = "<group>"; };
A69A83DF27D18385007BB936 /* IMDPersistence.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IMDPersistence.framework; path = ../../../../../System/Library/PrivateFrameworks/IMDPersistence.framework; sourceTree = "<group>"; };
A6DAE8E729CCD09F00C23C79 /* SKStatusSubscriptionServiceDelegate-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SKStatusSubscriptionServiceDelegate-Protocol.h"; sourceTree = "<group>"; };
A6E1F4CF27166012000A0EF6 /* IMPinnedConversationsController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMPinnedConversationsController.h; sourceTree = "<group>"; };
A6E7318229A3D37000AAED78 /* IMAggregateAttachmentMessagePartChatItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMAggregateAttachmentMessagePartChatItem.h; sourceTree = "<group>"; };
A6E7318329A3D49600AAED78 /* IMAttachmentMessagePartChatItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMAttachmentMessagePartChatItem.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -224,6 +225,7 @@
FBCE4EDB201C264F002F8A61 /* IMCore */ = {
isa = PBXGroup;
children = (
A6DAE8E729CCD09F00C23C79 /* SKStatusSubscriptionServiceDelegate-Protocol.h */,
A64B8891271232E200BAD446 /* IMChatItem.h */,
A64B8893271232E300BAD446 /* IMInlineReplyController.h */,
A64B8892271232E200BAD446 /* IMSendProgressDelegate-Protocol.h */,
Expand Down Expand Up @@ -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 = /;
Expand All @@ -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)";
Expand All @@ -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 = /;
Expand All @@ -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)";
Expand Down
Binary file not shown.
59 changes: 22 additions & 37 deletions MacOS-11+/BlueBubblesHelper/BlueBubblesHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ -(void) handleMessage: (NetworkController*)controller message:(NSString *)messa
} else if ([event isEqualToString:@"send-multipart"]) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString: @""];
NSMutableArray<NSString*> *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];
Expand All @@ -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:@{
Expand All @@ -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
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8a91ee9

Please sign in to comment.