Compare commits
7 Commits
kordophone
...
Kordophone
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37ff0b375f | ||
|
|
d071e68a56 | ||
|
|
2f5d50188b | ||
|
|
56ae7982c6 | ||
|
|
bc9e4f52b4 | ||
|
|
3082c4ab19 | ||
| ba8f76f4bd |
@@ -3680,6 +3680,16 @@ __attribute__((visibility("default"))) @interface IMService : NSObject { }
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, IMMessageDescriptionType) {
|
||||||
|
IMMessageDescriptionAccessibility,
|
||||||
|
IMMessageDescriptionAcknowledgement,
|
||||||
|
IMMessageDescriptionConversationList,
|
||||||
|
IMMessageDescriptionNotification,
|
||||||
|
IMMessageDescriptionSiri,
|
||||||
|
IMMessageDescriptionSPI,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@interface IMMessage : NSObject <NSCopying>
|
@interface IMMessage : NSObject <NSCopying>
|
||||||
{
|
{
|
||||||
IMHandle *_sender;
|
IMHandle *_sender;
|
||||||
@@ -3804,8 +3814,8 @@ __attribute__((visibility("default"))) @interface IMService : NSObject { }
|
|||||||
- (id)_initWithSender:(id)arg1 time:(id)arg2 timeRead:(id)arg3 timeDelivered:(id)arg4 timePlayed:(id)arg5 plainText:(id)arg6 text:(id)arg7 messageSubject:(id)arg8 fileTransferGUIDs:(id)arg9 flags:(unsigned long long)arg10 error:(id)arg11 guid:(id)arg12 messageID:(long long)arg13 subject:(id)arg14 balloonBundleID:(id)arg15 payloadData:(id)arg16 expressiveSendStyleID:(id)arg17 timeExpressiveSendPlayed:(id)arg18 associatedMessageGUID:(id)arg19 associatedMessageType:(long long)arg20 associatedMessageRange:(struct _NSRange)arg21 messageSummaryInfo:(id)arg22;
|
- (id)_initWithSender:(id)arg1 time:(id)arg2 timeRead:(id)arg3 timeDelivered:(id)arg4 timePlayed:(id)arg5 plainText:(id)arg6 text:(id)arg7 messageSubject:(id)arg8 fileTransferGUIDs:(id)arg9 flags:(unsigned long long)arg10 error:(id)arg11 guid:(id)arg12 messageID:(long long)arg13 subject:(id)arg14 balloonBundleID:(id)arg15 payloadData:(id)arg16 expressiveSendStyleID:(id)arg17 timeExpressiveSendPlayed:(id)arg18 associatedMessageGUID:(id)arg19 associatedMessageType:(long long)arg20 associatedMessageRange:(struct _NSRange)arg21 messageSummaryInfo:(id)arg22;
|
||||||
- (id)_copyWithFlags:(unsigned long long)arg1;
|
- (id)_copyWithFlags:(unsigned long long)arg1;
|
||||||
- (id)copyWithZone:(struct _NSZone *)arg1;
|
- (id)copyWithZone:(struct _NSZone *)arg1;
|
||||||
- (id)descriptionForPurpose:(long long)arg1 inChat:(id)arg2;
|
- (id)descriptionForPurpose:(IMMessageDescriptionType)arg1 inChat:(id)arg2;
|
||||||
- (id)descriptionForPurpose:(long long)arg1;
|
- (id)descriptionForPurpose:(IMMessageDescriptionType)arg1;
|
||||||
- (void)_ovverrideGUIDForTest:(id)arg1;
|
- (void)_ovverrideGUIDForTest:(id)arg1;
|
||||||
@property(readonly, nonatomic) BOOL isAssociatedMessage;
|
@property(readonly, nonatomic) BOOL isAssociatedMessage;
|
||||||
- (id)initWithSender:(id)arg1 time:(id)arg2 text:(id)arg3 messageSubject:(id)arg4 fileTransferGUIDs:(id)arg5 flags:(unsigned long long)arg6 error:(id)arg7 guid:(id)arg8 subject:(id)arg9 associatedMessageGUID:(id)arg10 associatedMessageType:(long long)arg11 associatedMessageRange:(struct _NSRange)arg12 associatedMessageInfo:(id)arg13;
|
- (id)initWithSender:(id)arg1 time:(id)arg2 text:(id)arg3 messageSubject:(id)arg4 fileTransferGUIDs:(id)arg5 flags:(unsigned long long)arg6 error:(id)arg7 guid:(id)arg8 subject:(id)arg9 associatedMessageGUID:(id)arg10 associatedMessageType:(long long)arg11 associatedMessageRange:(struct _NSRange)arg12 associatedMessageInfo:(id)arg13;
|
||||||
|
|||||||
@@ -18,12 +18,18 @@ struct IMFileLocation_t {
|
|||||||
int _field5;
|
int _field5;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IMPreviewConstraints {
|
typedef struct IMPreviewConstraints {
|
||||||
double _field1;
|
CGFloat maxPxWidth;
|
||||||
struct CGSize _field2;
|
CGSize minThumbnailPxSize;
|
||||||
double _field3;
|
CGFloat scale;
|
||||||
char _field4;
|
BOOL isSticker;
|
||||||
};
|
BOOL generateMetadata;
|
||||||
|
} IMPreviewConstraints;
|
||||||
|
|
||||||
|
extern IMPreviewConstraints IMPreviewConstraintsFromDictionary(NSDictionary *dictionary);
|
||||||
|
extern NSDictionary *IMPreviewConstraintsDictionaryFromConstraint(IMPreviewConstraints constraint);
|
||||||
|
extern BOOL IMPreviewConstraintsEqualToConstraints(IMPreviewConstraints constraints1, IMPreviewConstraints constraints2);
|
||||||
|
extern IMPreviewConstraints IMPreviewConstraintsZero(void);
|
||||||
|
|
||||||
struct _TidyDoc {
|
struct _TidyDoc {
|
||||||
int _field1;
|
int _field1;
|
||||||
@@ -155,6 +161,8 @@ struct __va_list_tag {
|
|||||||
- (void)setObject:(id)arg1 forKey:(id)arg2;
|
- (void)setObject:(id)arg1 forKey:(id)arg2;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
extern NSURL* IMAttachmentPreviewFileURL(NSURL *attachmentURL, NSString *extension, BOOL generateIntermediaryDirectories);
|
||||||
|
|
||||||
@protocol IMPreviewGeneratorProtocol
|
@protocol IMPreviewGeneratorProtocol
|
||||||
+ (BOOL)shouldShadePreview;
|
+ (BOOL)shouldShadePreview;
|
||||||
+ (BOOL)shouldScaleUpPreview;
|
+ (BOOL)shouldScaleUpPreview;
|
||||||
|
|||||||
@@ -73,8 +73,13 @@
|
|||||||
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A3219FF22700E7DD22 /* IMMessageItem+Encoded.m */; };
|
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A3219FF22700E7DD22 /* IMMessageItem+Encoded.m */; };
|
||||||
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */; };
|
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */; };
|
||||||
CD14F1AD219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */; };
|
CD14F1AD219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */; };
|
||||||
|
CD2782BC29527FE500C0C030 /* IMSharedUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD2782BB29527FE500C0C030 /* IMSharedUtilities.framework */; };
|
||||||
|
CD2782BF2952832B00C0C030 /* MBIMImageUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2782BE2952832B00C0C030 /* MBIMImageUtils.m */; };
|
||||||
|
CD2782FE2952875F00C0C030 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD2782FD2952875F00C0C030 /* CoreGraphics.framework */; };
|
||||||
|
CD2783002952876700C0C030 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD2782FF2952876700C0C030 /* ImageIO.framework */; };
|
||||||
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */; };
|
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */; };
|
||||||
CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */; };
|
CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */ = {isa = PBXBuildFile; fileRef = CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */; };
|
||||||
|
CD3F62B1297769F2004305D9 /* MBIMURLUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = CD3F62B0297769F2004305D9 /* MBIMURLUtilities.m */; };
|
||||||
CD602056219B5DFD0024D9C5 /* MBIMBridgeOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */; };
|
CD602056219B5DFD0024D9C5 /* MBIMBridgeOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */; };
|
||||||
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */; };
|
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */; };
|
||||||
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */; };
|
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */; };
|
||||||
@@ -223,10 +228,17 @@
|
|||||||
CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMUpdateQueue.m; sourceTree = "<group>"; };
|
CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMUpdateQueue.m; sourceTree = "<group>"; };
|
||||||
CD14F1AB219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMConcurrentHTTPServer.h; sourceTree = "<group>"; };
|
CD14F1AB219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMConcurrentHTTPServer.h; sourceTree = "<group>"; };
|
||||||
CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMConcurrentHTTPServer.m; sourceTree = "<group>"; };
|
CD14F1AC219FFAE100E7DD22 /* MBIMConcurrentHTTPServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMConcurrentHTTPServer.m; sourceTree = "<group>"; };
|
||||||
|
CD2782BB29527FE500C0C030 /* IMSharedUtilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IMSharedUtilities.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.Internal.sdk/System/Library/PrivateFrameworks/IMSharedUtilities.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
|
CD2782BD2952832B00C0C030 /* MBIMImageUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMImageUtils.h; sourceTree = "<group>"; };
|
||||||
|
CD2782BE2952832B00C0C030 /* MBIMImageUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMImageUtils.m; sourceTree = "<group>"; };
|
||||||
|
CD2782FD2952875F00C0C030 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||||
|
CD2782FF2952876700C0C030 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
|
||||||
CD2ECEC0269539100055E302 /* MBIMAuthenticateOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAuthenticateOperation.h; sourceTree = "<group>"; };
|
CD2ECEC0269539100055E302 /* MBIMAuthenticateOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAuthenticateOperation.h; sourceTree = "<group>"; };
|
||||||
CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAuthenticateOperation.m; sourceTree = "<group>"; };
|
CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAuthenticateOperation.m; sourceTree = "<group>"; };
|
||||||
CD2ECEC326953F2A0055E302 /* MBIMAuthToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAuthToken.h; sourceTree = "<group>"; };
|
CD2ECEC326953F2A0055E302 /* MBIMAuthToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMAuthToken.h; sourceTree = "<group>"; };
|
||||||
CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAuthToken.m; sourceTree = "<group>"; };
|
CD2ECEC426953F2A0055E302 /* MBIMAuthToken.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMAuthToken.m; sourceTree = "<group>"; };
|
||||||
|
CD3F62AF297769F2004305D9 /* MBIMURLUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMURLUtilities.h; sourceTree = "<group>"; };
|
||||||
|
CD3F62B0297769F2004305D9 /* MBIMURLUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMURLUtilities.m; sourceTree = "<group>"; };
|
||||||
CD602054219B5DFD0024D9C5 /* MBIMBridgeOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMBridgeOperation.h; sourceTree = "<group>"; };
|
CD602054219B5DFD0024D9C5 /* MBIMBridgeOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMBridgeOperation.h; sourceTree = "<group>"; };
|
||||||
CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMBridgeOperation.m; sourceTree = "<group>"; };
|
CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMBridgeOperation.m; sourceTree = "<group>"; };
|
||||||
CD60205A219B623F0024D9C5 /* MBIMMessagesListOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMessagesListOperation.h; sourceTree = "<group>"; };
|
CD60205A219B623F0024D9C5 /* MBIMMessagesListOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMessagesListOperation.h; sourceTree = "<group>"; };
|
||||||
@@ -287,8 +299,11 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
CD2782BC29527FE500C0C030 /* IMSharedUtilities.framework in Frameworks */,
|
||||||
1A257CCB23A8681200A4A2C8 /* Security.framework in Frameworks */,
|
1A257CCB23A8681200A4A2C8 /* Security.framework in Frameworks */,
|
||||||
|
CD2783002952876700C0C030 /* ImageIO.framework in Frameworks */,
|
||||||
1ACFCFDF219EB31400E2C237 /* CocoaHTTPServer.framework in Frameworks */,
|
1ACFCFDF219EB31400E2C237 /* CocoaHTTPServer.framework in Frameworks */,
|
||||||
|
CD2782FE2952875F00C0C030 /* CoreGraphics.framework in Frameworks */,
|
||||||
1A257CC923A867EF00A4A2C8 /* IMCore.framework in Frameworks */,
|
1A257CC923A867EF00A4A2C8 /* IMCore.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -334,6 +349,9 @@
|
|||||||
1A0C445E219A45B400F2AC00 /* Frameworks */ = {
|
1A0C445E219A45B400F2AC00 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
CD2782FF2952876700C0C030 /* ImageIO.framework */,
|
||||||
|
CD2782FD2952875F00C0C030 /* CoreGraphics.framework */,
|
||||||
|
CD2782BB29527FE500C0C030 /* IMSharedUtilities.framework */,
|
||||||
1A257CCA23A8681200A4A2C8 /* Security.framework */,
|
1A257CCA23A8681200A4A2C8 /* Security.framework */,
|
||||||
1A257CC823A867EF00A4A2C8 /* IMCore.framework */,
|
1A257CC823A867EF00A4A2C8 /* IMCore.framework */,
|
||||||
);
|
);
|
||||||
@@ -370,6 +388,10 @@
|
|||||||
CD936A31289B353F0093A1AC /* MBIMErrorResponse.m */,
|
CD936A31289B353F0093A1AC /* MBIMErrorResponse.m */,
|
||||||
1AA43E93219EC38E00EDF1A7 /* MBIMHTTPUtilities.h */,
|
1AA43E93219EC38E00EDF1A7 /* MBIMHTTPUtilities.h */,
|
||||||
1AA43E94219EC38E00EDF1A7 /* MBIMHTTPUtilities.m */,
|
1AA43E94219EC38E00EDF1A7 /* MBIMHTTPUtilities.m */,
|
||||||
|
CD2782BD2952832B00C0C030 /* MBIMImageUtils.h */,
|
||||||
|
CD2782BE2952832B00C0C030 /* MBIMImageUtils.m */,
|
||||||
|
CD3F62AF297769F2004305D9 /* MBIMURLUtilities.h */,
|
||||||
|
CD3F62B0297769F2004305D9 /* MBIMURLUtilities.m */,
|
||||||
);
|
);
|
||||||
path = Utilities;
|
path = Utilities;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -883,6 +905,7 @@
|
|||||||
CDF62335219A895D00690038 /* main.m in Sources */,
|
CDF62335219A895D00690038 /* main.m in Sources */,
|
||||||
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */,
|
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */,
|
||||||
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */,
|
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */,
|
||||||
|
CD3F62B1297769F2004305D9 /* MBIMURLUtilities.m in Sources */,
|
||||||
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */,
|
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */,
|
||||||
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */,
|
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */,
|
||||||
CD14F1A1219FE7D600E7DD22 /* MBIMUpdatePollOperation.m in Sources */,
|
CD14F1A1219FE7D600E7DD22 /* MBIMUpdatePollOperation.m in Sources */,
|
||||||
@@ -893,6 +916,7 @@
|
|||||||
CD602056219B5DFD0024D9C5 /* MBIMBridgeOperation.m in Sources */,
|
CD602056219B5DFD0024D9C5 /* MBIMBridgeOperation.m in Sources */,
|
||||||
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */,
|
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */,
|
||||||
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */,
|
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */,
|
||||||
|
CD2782BF2952832B00C0C030 /* MBIMImageUtils.m in Sources */,
|
||||||
1AA43E8F219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m in Sources */,
|
1AA43E8F219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m in Sources */,
|
||||||
CD936A32289B353F0093A1AC /* MBIMErrorResponse.m in Sources */,
|
CD936A32289B353F0093A1AC /* MBIMErrorResponse.m in Sources */,
|
||||||
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */,
|
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */,
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#import "MBIMBridge_Private.h"
|
#import "MBIMBridge_Private.h"
|
||||||
#import "MBIMBridgeOperation.h"
|
#import "MBIMBridgeOperation.h"
|
||||||
#import "MBIMAuthToken.h"
|
#import "MBIMAuthToken.h"
|
||||||
|
#import "MBIMUpdateQueue.h"
|
||||||
|
#import "MBIMURLUtilities.h"
|
||||||
|
|
||||||
#import <Security/Security.h>
|
#import <Security/Security.h>
|
||||||
#import <CocoaHTTPServer/HTTPMessage.h>
|
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||||
@@ -107,6 +109,7 @@
|
|||||||
if (operationClass != nil) {
|
if (operationClass != nil) {
|
||||||
_currentOperation = [[operationClass alloc] initWithRequestURL:url completion:completion];
|
_currentOperation = [[operationClass alloc] initWithRequestURL:url completion:completion];
|
||||||
_currentOperation.requestBodyData = _bodyData;
|
_currentOperation.requestBodyData = _bodyData;
|
||||||
|
_currentOperation.request = self->request;
|
||||||
|
|
||||||
[[[MBIMBridge sharedInstance] operationQueue] addOperation:_currentOperation];
|
[[[MBIMBridge sharedInstance] operationQueue] addOperation:_currentOperation];
|
||||||
long status = dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60.0 * NSEC_PER_SEC)));
|
long status = dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60.0 * NSEC_PER_SEC)));
|
||||||
@@ -124,6 +127,24 @@
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (WebSocket *)webSocketForURI:(NSString *)path
|
||||||
|
{
|
||||||
|
NSURL *url = [NSURL URLWithString:path];
|
||||||
|
NSString *endpointName = [url lastPathComponent];
|
||||||
|
NSString *authTokenString = [url valueForQueryItemWithName:@"token"];
|
||||||
|
MBIMAuthToken *authToken = [[MBIMAuthToken alloc] initWithTokenString:authTokenString];
|
||||||
|
|
||||||
|
if ([endpointName isEqualToString:@"updates"]) {
|
||||||
|
if (![authToken isValid]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [[MBIMUpdateQueue sharedInstance] vendUpdateWebSocketConsumerForRequest:request socket:asyncSocket];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [super webSocketForURI:path];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)expectsRequestBodyFromMethod:(NSString *)method atPath:(NSString *)path
|
- (BOOL)expectsRequestBodyFromMethod:(NSString *)method atPath:(NSString *)path
|
||||||
{
|
{
|
||||||
if ([method isEqualToString:@"POST"]) {
|
if ([method isEqualToString:@"POST"]) {
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
#import "IMFoundation_ClassDump.h"
|
#import "IMFoundation_ClassDump.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
@class GCDAsyncSocket;
|
||||||
|
@class HTTPMessage;
|
||||||
|
@class WebSocket;
|
||||||
|
|
||||||
@interface MBIMUpdateItem : NSObject
|
@interface MBIMUpdateItem : NSObject
|
||||||
@property (nonatomic, strong) IMChat *changedChat;
|
@property (nonatomic, strong) IMChat *changedChat;
|
||||||
@@ -24,11 +27,13 @@ typedef void (^MBIMUpdateConsumer)(NSArray<MBIMUpdateItem *> *items);
|
|||||||
|
|
||||||
+ (instancetype)sharedInstance;
|
+ (instancetype)sharedInstance;
|
||||||
|
|
||||||
- (void)addConsumer:(MBIMUpdateConsumer)consumer withLastSyncedMessageSeq:(NSInteger)messageSeq;
|
- (void)addPollingConsumer:(MBIMUpdateConsumer)consumer withLastSyncedMessageSeq:(NSInteger)messageSeq;
|
||||||
- (void)removeConsumer:(MBIMUpdateConsumer)consumer;
|
- (void)removePollingConsumer:(MBIMUpdateConsumer)consumer;
|
||||||
|
|
||||||
- (void)enqueueUpdateItem:(MBIMUpdateItem *)item;
|
- (void)enqueueUpdateItem:(MBIMUpdateItem *)item;
|
||||||
|
|
||||||
|
- (WebSocket *)vendUpdateWebSocketConsumerForRequest:(HTTPMessage *)request socket:(GCDAsyncSocket *)socket;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@@ -9,20 +9,29 @@
|
|||||||
#import "MBIMUpdateQueue.h"
|
#import "MBIMUpdateQueue.h"
|
||||||
#import "IMMessageItem+Encoded.h"
|
#import "IMMessageItem+Encoded.h"
|
||||||
#import "IMChat+Encoded.h"
|
#import "IMChat+Encoded.h"
|
||||||
|
#import "MBIMHTTPConnection.h"
|
||||||
|
#import "MBIMURLUtilities.h"
|
||||||
|
|
||||||
|
#import <CocoaHTTPServer/GCDAsyncSocket.h>
|
||||||
|
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||||
|
#import <CocoaHTTPServer/WebSocket.h>
|
||||||
|
|
||||||
static const NSUInteger kUpdateItemsCullingLength = 100;
|
static const NSUInteger kUpdateItemsCullingLength = 100;
|
||||||
|
|
||||||
@interface MBIMUpdateItem (/*INTERNAL*/)
|
@interface MBIMUpdateItem (/*INTERNAL*/) <WebSocketDelegate>
|
||||||
@property (nonatomic, assign) NSUInteger messageSequenceNumber;
|
@property (nonatomic, assign) NSUInteger messageSequenceNumber;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MBIMUpdateQueue {
|
@implementation MBIMUpdateQueue {
|
||||||
NSUInteger _messageSequenceNumber;
|
NSUInteger _messageSequenceNumber;
|
||||||
dispatch_queue_t _accessQueue;
|
dispatch_queue_t _accessQueue;
|
||||||
NSMutableArray *_consumers;
|
NSMutableArray *_longPollConsumers;
|
||||||
|
|
||||||
// Maps message sequence number to update item
|
// Maps message sequence number to update item
|
||||||
NSMutableDictionary<NSNumber *, MBIMUpdateItem *> *_updateItemHistory;
|
NSMutableDictionary<NSNumber *, MBIMUpdateItem *> *_updateItemHistory;
|
||||||
|
|
||||||
|
// WebSocket consumers
|
||||||
|
NSMutableDictionary<NSString *, MBIMUpdateConsumer> *_websocketConsumers;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)sharedInstance
|
+ (instancetype)sharedInstance
|
||||||
@@ -41,20 +50,93 @@ static const NSUInteger kUpdateItemsCullingLength = 100;
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_accessQueue = dispatch_queue_create("net.buzzert.MBIMUpdateQueue", DISPATCH_QUEUE_SERIAL);
|
_accessQueue = dispatch_queue_create("net.buzzert.MBIMUpdateQueue", DISPATCH_QUEUE_SERIAL);
|
||||||
_consumers = [[NSMutableArray alloc] init];
|
|
||||||
_messageSequenceNumber = 0;
|
_messageSequenceNumber = 0;
|
||||||
_updateItemHistory = [[NSMutableDictionary alloc] init];
|
_updateItemHistory = [[NSMutableDictionary alloc] init];
|
||||||
|
_websocketConsumers = [[NSMutableDictionary alloc] init];
|
||||||
|
_longPollConsumers = [[NSMutableArray alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addConsumer:(MBIMUpdateConsumer)consumer withLastSyncedMessageSeq:(NSInteger)messageSeq
|
- (void)addPollingConsumer:(MBIMUpdateConsumer)consumer withLastSyncedMessageSeq:(NSInteger)messageSeq
|
||||||
{
|
{
|
||||||
__weak NSMutableArray *consumers = _consumers;
|
if (![self _syncConsumer:consumer fromLastMessageSeq:messageSeq]) {
|
||||||
|
__weak NSMutableArray *consumers = _longPollConsumers;
|
||||||
|
dispatch_async(_accessQueue, ^{
|
||||||
|
[consumers addObject:consumer];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)removePollingConsumer:(MBIMUpdateConsumer)consumer
|
||||||
|
{
|
||||||
|
__weak NSMutableArray *consumers = _longPollConsumers;
|
||||||
|
dispatch_async(_accessQueue, ^{
|
||||||
|
[consumers removeObject:consumer];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)enqueueUpdateItem:(MBIMUpdateItem *)item
|
||||||
|
{
|
||||||
|
__weak __auto_type pollingConsumers = _longPollConsumers;
|
||||||
|
__weak __auto_type websocketConsumers = _websocketConsumers;
|
||||||
__weak NSMutableDictionary *updateItemHistory = _updateItemHistory;
|
__weak NSMutableDictionary *updateItemHistory = _updateItemHistory;
|
||||||
dispatch_async(_accessQueue, ^{
|
dispatch_async(_accessQueue, ^{
|
||||||
if ((messageSeq >= 0) && messageSeq < self->_messageSequenceNumber) {
|
self->_messageSequenceNumber++;
|
||||||
|
item.messageSequenceNumber = self->_messageSequenceNumber;
|
||||||
|
|
||||||
|
// Notify polling consumers
|
||||||
|
for (MBIMUpdateConsumer consumer in pollingConsumers) {
|
||||||
|
consumer(@[ item ]);
|
||||||
|
}
|
||||||
|
[pollingConsumers removeAllObjects];
|
||||||
|
|
||||||
|
// Notify websocket consumers
|
||||||
|
for (MBIMUpdateConsumer consumer in [websocketConsumers allValues]) {
|
||||||
|
consumer(@[ item ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[updateItemHistory setObject:item forKey:@(item.messageSequenceNumber)];
|
||||||
|
|
||||||
|
[self _cullUpdateItems];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (WebSocket *)vendUpdateWebSocketConsumerForRequest:(HTTPMessage *)request socket:(GCDAsyncSocket *)gcdSocket
|
||||||
|
{
|
||||||
|
WebSocket *socket = [[WebSocket alloc] initWithRequest:request socket:gcdSocket];
|
||||||
|
socket.delegate = self;
|
||||||
|
|
||||||
|
MBIMUpdateConsumer consumer = ^(NSArray<MBIMUpdateItem *> *updates) {
|
||||||
|
NSMutableArray *encodedUpdates = [NSMutableArray array];
|
||||||
|
for (MBIMUpdateItem *item in updates) {
|
||||||
|
NSDictionary *updateDict = [item dictionaryRepresentation];
|
||||||
|
[encodedUpdates addObject:updateDict];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSData *data = [NSJSONSerialization dataWithJSONObject:encodedUpdates options:0 error:NULL];
|
||||||
|
[socket sendData:data];
|
||||||
|
};
|
||||||
|
|
||||||
|
NSString *messageSeqString = [[request url] valueForQueryItemWithName:@"seq"];
|
||||||
|
[self _syncConsumer:consumer fromLastMessageSeq:(messageSeqString ? [messageSeqString integerValue] : -1)];
|
||||||
|
|
||||||
|
__weak __auto_type websocketConsumers = _websocketConsumers;
|
||||||
|
dispatch_async(_accessQueue, ^{
|
||||||
|
NSString *websocketKey = [socket description];
|
||||||
|
[websocketConsumers setObject:consumer forKey:websocketKey];
|
||||||
|
});
|
||||||
|
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_syncConsumer:(MBIMUpdateConsumer)consumer fromLastMessageSeq:(NSInteger)messageSeq
|
||||||
|
{
|
||||||
|
const BOOL needsSync = (messageSeq >= 0) && messageSeq < self->_messageSequenceNumber;
|
||||||
|
if (needsSync) {
|
||||||
|
__weak NSMutableDictionary *updateItemHistory = _updateItemHistory;
|
||||||
|
dispatch_async(_accessQueue, ^{
|
||||||
NSMutableArray *batchedUpdates = [NSMutableArray array];
|
NSMutableArray *batchedUpdates = [NSMutableArray array];
|
||||||
for (NSUInteger seq = messageSeq + 1; seq <= self->_messageSequenceNumber; seq++) {
|
for (NSUInteger seq = messageSeq + 1; seq <= self->_messageSequenceNumber; seq++) {
|
||||||
MBIMUpdateItem *item = [updateItemHistory objectForKey:@(seq)];
|
MBIMUpdateItem *item = [updateItemHistory objectForKey:@(seq)];
|
||||||
@@ -64,37 +146,10 @@ static const NSUInteger kUpdateItemsCullingLength = 100;
|
|||||||
}
|
}
|
||||||
|
|
||||||
consumer(batchedUpdates);
|
consumer(batchedUpdates);
|
||||||
} else {
|
});
|
||||||
[consumers addObject:consumer];
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)removeConsumer:(MBIMUpdateConsumer)consumer
|
return needsSync;
|
||||||
{
|
|
||||||
__weak NSMutableArray *consumers = _consumers;
|
|
||||||
dispatch_async(_accessQueue, ^{
|
|
||||||
[consumers removeObject:consumer];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)enqueueUpdateItem:(MBIMUpdateItem *)item
|
|
||||||
{
|
|
||||||
__weak NSMutableArray *consumers = _consumers;
|
|
||||||
__weak NSMutableDictionary *updateItemHistory = _updateItemHistory;
|
|
||||||
dispatch_async(_accessQueue, ^{
|
|
||||||
self->_messageSequenceNumber++;
|
|
||||||
item.messageSequenceNumber = self->_messageSequenceNumber;
|
|
||||||
|
|
||||||
for (MBIMUpdateConsumer consumer in consumers) {
|
|
||||||
consumer(@[ item ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
[consumers removeAllObjects];
|
|
||||||
[updateItemHistory setObject:item forKey:@(item.messageSequenceNumber)];
|
|
||||||
|
|
||||||
[self _cullUpdateItems];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_cullUpdateItems
|
- (void)_cullUpdateItems
|
||||||
@@ -113,6 +168,18 @@ static const NSUInteger kUpdateItemsCullingLength = 100;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - <WebSocketDelegate>
|
||||||
|
|
||||||
|
- (void)webSocketDidClose:(WebSocket *)ws
|
||||||
|
{
|
||||||
|
// xxx: not great, but works.
|
||||||
|
NSString *websocketKey = [ws description];
|
||||||
|
__weak __auto_type websocketConsumers = _websocketConsumers;
|
||||||
|
dispatch_async(_accessQueue, ^{
|
||||||
|
[websocketConsumers removeObjectForKey:websocketKey];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MBIMUpdateItem
|
@implementation MBIMUpdateItem
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||||
#import <CocoaHTTPServer/HTTPResponse.h>
|
#import <CocoaHTTPServer/HTTPResponse.h>
|
||||||
#import <CocoaHTTPServer/HTTPErrorResponse.h>
|
#import <CocoaHTTPServer/HTTPErrorResponse.h>
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ typedef void (^MBIMBridgeOperationCompletionBlock)(NSObject<HTTPResponse> * _Nul
|
|||||||
@property (class, nonatomic, readonly) NSString *endpointName;
|
@property (class, nonatomic, readonly) NSString *endpointName;
|
||||||
@property (class, nonatomic, readonly) BOOL requiresAuthentication; // default YES
|
@property (class, nonatomic, readonly) BOOL requiresAuthentication; // default YES
|
||||||
|
|
||||||
|
@property (nonatomic, strong) HTTPMessage *request;
|
||||||
@property (nonatomic, strong) NSData *requestBodyData;
|
@property (nonatomic, strong) NSData *requestBodyData;
|
||||||
@property (nonatomic, readonly) NSURL *requestURL;
|
@property (nonatomic, readonly) NSURL *requestURL;
|
||||||
@property (nonatomic, readonly) MBIMBridgeOperationCompletionBlock serverCompletionBlock;
|
@property (nonatomic, readonly) MBIMBridgeOperationCompletionBlock serverCompletionBlock;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MBIMBridgeOperation.h"
|
#import "MBIMBridgeOperation.h"
|
||||||
|
#import "MBIMURLUtilities.h"
|
||||||
|
|
||||||
@interface MBIMBridgeOperation (/*INTERNAL*/)
|
@interface MBIMBridgeOperation (/*INTERNAL*/)
|
||||||
@property (nonatomic, strong) NSURL *requestURL;
|
@property (nonatomic, strong) NSURL *requestURL;
|
||||||
@@ -79,18 +80,7 @@
|
|||||||
|
|
||||||
- (NSString *)valueForQueryItemWithName:(NSString *)queryItemName
|
- (NSString *)valueForQueryItemWithName:(NSString *)queryItemName
|
||||||
{
|
{
|
||||||
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self.requestURL
|
return [[self requestURL] valueForQueryItemWithName:queryItemName];
|
||||||
resolvingAgainstBaseURL:NO];
|
|
||||||
|
|
||||||
NSString *value = nil;
|
|
||||||
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
|
||||||
if ([[queryItem name] isEqualToString:queryItemName]) {
|
|
||||||
value = [queryItem value];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -8,8 +8,11 @@
|
|||||||
|
|
||||||
#import "MBIMFetchAttachmentOperation.h"
|
#import "MBIMFetchAttachmentOperation.h"
|
||||||
#import "MBIMDataResponse.h"
|
#import "MBIMDataResponse.h"
|
||||||
|
#import "MBIMImageUtils.h"
|
||||||
|
|
||||||
#import "IMCore_ClassDump.h"
|
#import "IMCore_ClassDump.h"
|
||||||
|
#import "IMSharedUtilities_ClassDump.h"
|
||||||
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
|
|
||||||
@implementation MBIMFetchAttachmentOperation
|
@implementation MBIMFetchAttachmentOperation
|
||||||
|
|
||||||
@@ -24,8 +27,8 @@
|
|||||||
{
|
{
|
||||||
NSObject<HTTPResponse> *response = nil;
|
NSObject<HTTPResponse> *response = nil;
|
||||||
do {
|
do {
|
||||||
|
BOOL preview = [[self valueForQueryItemWithName:@"preview"] boolValue];
|
||||||
NSString *guid = [self valueForQueryItemWithName:@"guid"];
|
NSString *guid = [self valueForQueryItemWithName:@"guid"];
|
||||||
|
|
||||||
if (!guid) {
|
if (!guid) {
|
||||||
MBIMLogInfo(@"No query item provided");
|
MBIMLogInfo(@"No query item provided");
|
||||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||||
@@ -45,22 +48,68 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *localPath = [transfer localPath];
|
NSData *responseData = nil;
|
||||||
NSData *responseData = [NSData dataWithContentsOfFile:localPath];
|
NSURL *localURL = [transfer localURL];
|
||||||
|
NSString *extension = [[localURL pathExtension] lowercaseString];
|
||||||
|
if (preview) {
|
||||||
|
NSURL *previewURL = IMAttachmentPreviewFileURL(localURL, extension, YES);
|
||||||
|
if (![[NSFileManager defaultManager] fileExistsAtPath:[previewURL path]]) {
|
||||||
|
MBIMLogInfo(@"Generating preview image for guid: %@ at %@", guid, [previewURL path]);
|
||||||
|
|
||||||
|
// Fetch preview constraints from transfer
|
||||||
|
NSDictionary *previewConstraintsDict = [[transfer attributionInfo] objectForKey:@"pgenszc"];
|
||||||
|
if (!previewConstraintsDict) {
|
||||||
|
MBIMLogInfo(@"No preview constraints for attachment guid: %@", guid);
|
||||||
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPreviewConstraints constraints = IMPreviewConstraintsFromDictionary(previewConstraintsDict);
|
||||||
|
|
||||||
|
// Generate preview using preview generator manager
|
||||||
|
NSError *error = nil;
|
||||||
|
IMPreviewGeneratorManager *generator = [IMPreviewGeneratorManager sharedInstance];
|
||||||
|
CGImageRef previewImage = [generator newPreviewFromSourceURL:localURL withPreviewConstraints:constraints error:&error];
|
||||||
|
if (error) {
|
||||||
|
MBIMLogInfo(@"Unable to generate preview for attachment guid: %@", guid);
|
||||||
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to JPEG.
|
||||||
|
responseData = MBIMCGImageJPEGRepresentation(previewImage);
|
||||||
|
|
||||||
|
// Persist JPEG preview to disk
|
||||||
|
if (previewURL) {
|
||||||
|
[responseData writeToURL:previewURL atomically:YES];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// File exists
|
||||||
|
MBIMLogInfo(@"Using cached preview image for guid: %@ at %@", guid, [previewURL path]);
|
||||||
|
responseData = [NSData dataWithContentsOfURL:previewURL];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
responseData = [NSData dataWithContentsOfURL:localURL];
|
||||||
|
}
|
||||||
|
|
||||||
if (!responseData) {
|
if (!responseData) {
|
||||||
MBIMLogInfo(@"Wasn't able to load data from local path: %@", localPath);
|
MBIMLogInfo(@"Wasn't able to load data for guid: %@", guid);
|
||||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:404];
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:404];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *mimeType = [transfer mimeType];
|
NSString *mimeType = [transfer mimeType];
|
||||||
|
if ([mimeType isEqualToString:@"image/heic"]) {
|
||||||
|
// TODO: We should convert this to JPEG here. I don't want clients to have to deal with HEIC.
|
||||||
|
MBIMLogInfo(@"WARNING: Returning HEIC data for attachment %@", guid);
|
||||||
|
}
|
||||||
|
|
||||||
// It's unusual, but if this is nil, try to guess the MIME type based on the filename
|
// It's unusual, but if this is nil, try to guess the MIME type based on the filename
|
||||||
if (!mimeType) {
|
if (!mimeType) {
|
||||||
NSString *extension = [[localPath pathExtension] lowercaseString];
|
|
||||||
|
|
||||||
// XXX: REALLY hacky
|
// XXX: REALLY hacky
|
||||||
mimeType = [NSString stringWithFormat:@"image/%@", extension];
|
mimeType = [NSString stringWithFormat:@"image/%@", extension];
|
||||||
}
|
}
|
||||||
|
|
||||||
response = [[MBIMDataResponse alloc] initWithData:responseData contentType:mimeType];
|
response = [[MBIMDataResponse alloc] initWithData:responseData contentType:mimeType];
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
MBIMLogInfo(@"Chat does not exist: %@", chatGUID);
|
MBIMLogInfo(@"Chat does not exist: %@", chatGUID);
|
||||||
result = NO;
|
result = NO;
|
||||||
} else {
|
} else {
|
||||||
[chat sendMessage:reply];
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[chat sendMessage:reply];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,13 @@
|
|||||||
weakSelf.serverCompletionBlock(response);
|
weakSelf.serverCompletionBlock(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
[[MBIMUpdateQueue sharedInstance] addPollingConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)cancel
|
- (void)cancel
|
||||||
{
|
{
|
||||||
[super cancel];
|
[super cancel];
|
||||||
[[MBIMUpdateQueue sharedInstance] removeConsumer:_updateConsumer];
|
[[MBIMUpdateQueue sharedInstance] removePollingConsumer:_updateConsumer];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse
|
- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ const char* MBIMVersion() {
|
|||||||
|
|
||||||
+ (void)load { [super load]; }
|
+ (void)load { [super load]; }
|
||||||
|
|
||||||
|
+ (BOOL)requiresAuthentication
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSString *)endpointName
|
+ (NSString *)endpointName
|
||||||
{
|
{
|
||||||
return @"version";
|
return @"version";
|
||||||
|
|||||||
12
kordophone/Bridge/Operations/Utilities/MBIMImageUtils.h
Normal file
12
kordophone/Bridge/Operations/Utilities/MBIMImageUtils.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// MBIMImageUtils.h
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 12/20/22.
|
||||||
|
// Copyright © 2022 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
|
|
||||||
|
extern NSData* MBIMCGImageJPEGRepresentation(CGImageRef imageRef);
|
||||||
37
kordophone/Bridge/Operations/Utilities/MBIMImageUtils.m
Normal file
37
kordophone/Bridge/Operations/Utilities/MBIMImageUtils.m
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// MBIMImageUtils.m
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 12/20/22.
|
||||||
|
// Copyright © 2022 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MBIMImageUtils.h"
|
||||||
|
#import <ImageIO/ImageIO.h>
|
||||||
|
|
||||||
|
NSData* MBIMCGImageJPEGRepresentation(CGImageRef imageRef)
|
||||||
|
{
|
||||||
|
if (imageRef == NULL) return nil;
|
||||||
|
|
||||||
|
NSNumber *const DPI = @72.0;
|
||||||
|
NSNumber *const compressionQuality = @0.9;
|
||||||
|
NSDictionary *properties = @{
|
||||||
|
(__bridge NSString *)kCGImagePropertyDPIWidth : DPI,
|
||||||
|
(__bridge NSString *)kCGImagePropertyDPIHeight : DPI,
|
||||||
|
(__bridge NSString *)kCGImageDestinationLossyCompressionQuality : compressionQuality,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
NSMutableData *data = [NSMutableData data];
|
||||||
|
if (data) {
|
||||||
|
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((CFMutableDataRef)data, CFSTR("public.jpeg"), 1/*count*/, NULL/*options*/);
|
||||||
|
if (imageDestination != NULL) {
|
||||||
|
CGImageDestinationAddImage(imageDestination, imageRef, (__bridge CFDictionaryRef)properties);
|
||||||
|
success = CGImageDestinationFinalize(imageDestination);
|
||||||
|
CFRelease(imageDestination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success ? data : nil;
|
||||||
|
}
|
||||||
|
|
||||||
17
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.h
Normal file
17
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// MBIMURLUtilities.h
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 1/17/23.
|
||||||
|
// Copyright © 2023 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface NSURL (MBIMURLUtilities)
|
||||||
|
- (nullable NSString *)valueForQueryItemWithName:(NSString *)queryItemName;
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
28
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.m
Normal file
28
kordophone/Bridge/Operations/Utilities/MBIMURLUtilities.m
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// MBIMURLUtilities.m
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 1/17/23.
|
||||||
|
// Copyright © 2023 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MBIMURLUtilities.h"
|
||||||
|
|
||||||
|
@implementation NSURL (MBIMURLUtilities)
|
||||||
|
|
||||||
|
- (nullable NSString *)valueForQueryItemWithName:(NSString *)queryItemName
|
||||||
|
{
|
||||||
|
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self resolvingAgainstBaseURL:NO];
|
||||||
|
|
||||||
|
NSString *value = nil;
|
||||||
|
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
||||||
|
if ([[queryItem name] isEqualToString:queryItemName]) {
|
||||||
|
value = [queryItem value];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
IMMessage *lastMessage = [self lastMessage];
|
IMMessage *lastMessage = [self lastMessage];
|
||||||
if (lastMessage) {
|
if (lastMessage) {
|
||||||
chatDict[@"lastMessagePreview"] = [[lastMessage text] string];
|
chatDict[@"lastMessagePreview"] = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableArray *participantStrings = [NSMutableArray array];
|
NSMutableArray *participantStrings = [NSMutableArray array];
|
||||||
|
|||||||
@@ -21,16 +21,27 @@
|
|||||||
|
|
||||||
if ([self fileTransferGUIDs]) {
|
if ([self fileTransferGUIDs]) {
|
||||||
// Support only images right now
|
// Support only images right now
|
||||||
|
NSMutableDictionary *attachmentMetadatas = [NSMutableDictionary dictionary];
|
||||||
NSMutableArray *filteredFileTransferGUIDs = [NSMutableArray array];
|
NSMutableArray *filteredFileTransferGUIDs = [NSMutableArray array];
|
||||||
for (NSString *guid in self.fileTransferGUIDs) {
|
for (NSString *guid in self.fileTransferGUIDs) {
|
||||||
|
NSMutableDictionary *metadata = [NSMutableDictionary dictionary];
|
||||||
IMFileTransfer *transfer = [[IMFileTransferCenter sharedInstance] transferForGUID:guid];
|
IMFileTransfer *transfer = [[IMFileTransferCenter sharedInstance] transferForGUID:guid];
|
||||||
if ([[transfer mimeType] containsString:@"image"]) {
|
if ([[transfer mimeType] containsString:@"image"]) {
|
||||||
[filteredFileTransferGUIDs addObject:guid];
|
[filteredFileTransferGUIDs addObject:guid];
|
||||||
|
|
||||||
|
if ([transfer attributionInfo] != nil) {
|
||||||
|
metadata[@"attributionInfo"] = [transfer attributionInfo];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadata.count) {
|
||||||
|
attachmentMetadatas[guid] = metadata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([filteredFileTransferGUIDs count]) {
|
if ([filteredFileTransferGUIDs count]) {
|
||||||
messageDict[@"fileTransferGUIDs"] = filteredFileTransferGUIDs;
|
messageDict[@"fileTransferGUIDs"] = filteredFileTransferGUIDs;
|
||||||
|
messageDict[@"attachmentMetadata"] = attachmentMetadatas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user