Compare commits
18 Commits
Kordophone
...
Kordophone
| Author | SHA1 | Date | |
|---|---|---|---|
| b92c683a0e | |||
|
|
37ff0b375f | ||
|
|
d071e68a56 | ||
|
|
2f5d50188b | ||
|
|
56ae7982c6 | ||
|
|
bc9e4f52b4 | ||
|
|
3082c4ab19 | ||
| ba8f76f4bd | |||
|
|
e5b78d62f0 | ||
|
|
3ca9abcccd | ||
|
|
cad3425327 | ||
|
|
83ba072a9d | ||
|
|
bd01480ad6 | ||
|
|
c7087a394e | ||
| ebad248c1c | |||
| e161eedef3 | |||
| 7a3303da06 | |||
| 641e4c53fa |
@@ -3457,6 +3457,7 @@ __attribute__((visibility("default"))) @interface IMService : NSObject { }
|
||||
- (id)loadUnreadMessagesWithLimit:(unsigned long long)arg1 fallbackToMessagesUpToGUID:(id)arg2;
|
||||
- (id)loadFrequentRepliesLimit:(unsigned long long)arg1 loadImmediately:(BOOL)arg2;
|
||||
- (id)loadMessagesBeforeAndAfterGUID:(id)arg1 numberOfMessagesToLoadBeforeGUID:(unsigned long long)arg2 numberOfMessagesToLoadAfterGUID:(unsigned long long)arg3 loadImmediately:(BOOL)arg4;
|
||||
- (id)loadMessagesBeforeAndAfterGUID:(id)arg1 numberOfMessagesToLoadBeforeGUID:(unsigned long long)arg2 numberOfMessagesToLoadAfterGUID:(unsigned long long)arg3 loadImmediately:(BOOL)arg4 threadIdentifier:(id)tid;
|
||||
- (id)loadMessagesUpToGUID:(id)arg1 date:(id)arg2 limit:(unsigned long long)arg3 loadImmediately:(BOOL)arg4;
|
||||
- (id)loadMessagesBeforeDate:(id)arg1 limit:(unsigned long long)arg2 loadImmediately:(BOOL)arg3;
|
||||
- (id)loadMessagesBeforeDate:(id)arg1 limit:(unsigned long long)arg2;
|
||||
@@ -3679,6 +3680,16 @@ __attribute__((visibility("default"))) @interface IMService : NSObject { }
|
||||
|
||||
@end
|
||||
|
||||
typedef NS_ENUM(NSInteger, IMMessageDescriptionType) {
|
||||
IMMessageDescriptionAccessibility,
|
||||
IMMessageDescriptionAcknowledgement,
|
||||
IMMessageDescriptionConversationList,
|
||||
IMMessageDescriptionNotification,
|
||||
IMMessageDescriptionSiri,
|
||||
IMMessageDescriptionSPI,
|
||||
};
|
||||
|
||||
|
||||
@interface IMMessage : NSObject <NSCopying>
|
||||
{
|
||||
IMHandle *_sender;
|
||||
@@ -3803,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)_copyWithFlags:(unsigned long long)arg1;
|
||||
- (id)copyWithZone:(struct _NSZone *)arg1;
|
||||
- (id)descriptionForPurpose:(long long)arg1 inChat:(id)arg2;
|
||||
- (id)descriptionForPurpose:(long long)arg1;
|
||||
- (id)descriptionForPurpose:(IMMessageDescriptionType)arg1 inChat:(id)arg2;
|
||||
- (id)descriptionForPurpose:(IMMessageDescriptionType)arg1;
|
||||
- (void)_ovverrideGUIDForTest:(id)arg1;
|
||||
@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;
|
||||
|
||||
@@ -18,12 +18,18 @@ struct IMFileLocation_t {
|
||||
int _field5;
|
||||
};
|
||||
|
||||
struct IMPreviewConstraints {
|
||||
double _field1;
|
||||
struct CGSize _field2;
|
||||
double _field3;
|
||||
char _field4;
|
||||
};
|
||||
typedef struct IMPreviewConstraints {
|
||||
CGFloat maxPxWidth;
|
||||
CGSize minThumbnailPxSize;
|
||||
CGFloat scale;
|
||||
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 {
|
||||
int _field1;
|
||||
@@ -155,6 +161,8 @@ struct __va_list_tag {
|
||||
- (void)setObject:(id)arg1 forKey:(id)arg2;
|
||||
@end
|
||||
|
||||
extern NSURL* IMAttachmentPreviewFileURL(NSURL *attachmentURL, NSString *extension, BOOL generateIntermediaryDirectories);
|
||||
|
||||
@protocol IMPreviewGeneratorProtocol
|
||||
+ (BOOL)shouldShadePreview;
|
||||
+ (BOOL)shouldScaleUpPreview;
|
||||
|
||||
13
Makefile
Normal file
13
Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
INSTALL_PATH := /usr/share/kordophone
|
||||
|
||||
build/Release/kordophoned:
|
||||
xcodebuild
|
||||
|
||||
.PHONY: install
|
||||
install: build/Release/kordophoned
|
||||
install -d $(INSTALL_PATH)
|
||||
install build/Release/kordophoned $(INSTALL_PATH)
|
||||
cp -rf build/Release/CocoaHTTPServer.framework $(INSTALL_PATH)
|
||||
|
||||
clean:
|
||||
rm -Rf build
|
||||
@@ -73,14 +73,23 @@
|
||||
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A3219FF22700E7DD22 /* IMMessageItem+Encoded.m */; };
|
||||
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CD14F1A9219FF3B800E7DD22 /* MBIMUpdateQueue.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 */; };
|
||||
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 */; };
|
||||
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */; };
|
||||
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */; };
|
||||
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD602061219B68950024D9C5 /* MBIMSendMessageOperation.m */; };
|
||||
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E155219BE10A00F4CCEA /* hooking.m */; };
|
||||
CD83E166219BE91600F4CCEA /* agentHook.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E165219BE91600F4CCEA /* agentHook.m */; };
|
||||
CD936A32289B353F0093A1AC /* MBIMErrorResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = CD936A31289B353F0093A1AC /* MBIMErrorResponse.m */; };
|
||||
CD936A35289B47D60093A1AC /* MBIMVersionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD936A34289B47D50093A1AC /* MBIMVersionOperation.m */; };
|
||||
CD936A39289B49FC0093A1AC /* MBIMStatusOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CD936A38289B49FC0093A1AC /* MBIMStatusOperation.m */; };
|
||||
CDDCF78D283F398C0087ABDF /* MBIMDeleteConversationOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */; };
|
||||
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */; };
|
||||
CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */; };
|
||||
CDE455A421A5308D0041F5DD /* MBIMFetchAttachmentOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */; };
|
||||
@@ -219,10 +228,17 @@
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
@@ -236,6 +252,15 @@
|
||||
CD83E161219BE91500F4CCEA /* libagentHook.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libagentHook.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CD83E165219BE91600F4CCEA /* agentHook.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = agentHook.m; sourceTree = "<group>"; };
|
||||
CD83E1B5219BF78E00F4CCEA /* hookAgent.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = hookAgent.sh; sourceTree = "<group>"; };
|
||||
CD936A2F289B31740093A1AC /* kordophoned-RestrictedEntitlements.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "kordophoned-RestrictedEntitlements.plist"; sourceTree = "<group>"; };
|
||||
CD936A30289B353F0093A1AC /* MBIMErrorResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMErrorResponse.h; sourceTree = "<group>"; };
|
||||
CD936A31289B353F0093A1AC /* MBIMErrorResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMErrorResponse.m; sourceTree = "<group>"; };
|
||||
CD936A33289B47D50093A1AC /* MBIMVersionOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMVersionOperation.h; sourceTree = "<group>"; };
|
||||
CD936A34289B47D50093A1AC /* MBIMVersionOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMVersionOperation.m; sourceTree = "<group>"; };
|
||||
CD936A37289B49FC0093A1AC /* MBIMStatusOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMStatusOperation.h; sourceTree = "<group>"; };
|
||||
CD936A38289B49FC0093A1AC /* MBIMStatusOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMStatusOperation.m; sourceTree = "<group>"; };
|
||||
CDDCF78B283F398C0087ABDF /* MBIMDeleteConversationOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMDeleteConversationOperation.h; sourceTree = "<group>"; };
|
||||
CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMDeleteConversationOperation.m; sourceTree = "<group>"; };
|
||||
CDE4556221A3578A0041F5DD /* IMChat+Encoded.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IMChat+Encoded.h"; sourceTree = "<group>"; };
|
||||
CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "IMChat+Encoded.m"; sourceTree = "<group>"; };
|
||||
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMarkOperation.h; sourceTree = "<group>"; };
|
||||
@@ -274,8 +299,11 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CD2782BC29527FE500C0C030 /* IMSharedUtilities.framework in Frameworks */,
|
||||
1A257CCB23A8681200A4A2C8 /* Security.framework in Frameworks */,
|
||||
CD2783002952876700C0C030 /* ImageIO.framework in Frameworks */,
|
||||
1ACFCFDF219EB31400E2C237 /* CocoaHTTPServer.framework in Frameworks */,
|
||||
CD2782FE2952875F00C0C030 /* CoreGraphics.framework in Frameworks */,
|
||||
1A257CC923A867EF00A4A2C8 /* IMCore.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -321,6 +349,9 @@
|
||||
1A0C445E219A45B400F2AC00 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CD2782FF2952876700C0C030 /* ImageIO.framework */,
|
||||
CD2782FD2952875F00C0C030 /* CoreGraphics.framework */,
|
||||
CD2782BB29527FE500C0C030 /* IMSharedUtilities.framework */,
|
||||
1A257CCA23A8681200A4A2C8 /* Security.framework */,
|
||||
1A257CC823A867EF00A4A2C8 /* IMCore.framework */,
|
||||
);
|
||||
@@ -353,8 +384,14 @@
|
||||
1AA43E8E219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m */,
|
||||
CDE455A521A531ED0041F5DD /* MBIMDataResponse.h */,
|
||||
CDE455A621A531ED0041F5DD /* MBIMDataResponse.m */,
|
||||
CD936A30289B353F0093A1AC /* MBIMErrorResponse.h */,
|
||||
CD936A31289B353F0093A1AC /* MBIMErrorResponse.m */,
|
||||
1AA43E93219EC38E00EDF1A7 /* MBIMHTTPUtilities.h */,
|
||||
1AA43E94219EC38E00EDF1A7 /* MBIMHTTPUtilities.m */,
|
||||
CD2782BD2952832B00C0C030 /* MBIMImageUtils.h */,
|
||||
CD2782BE2952832B00C0C030 /* MBIMImageUtils.m */,
|
||||
CD3F62AF297769F2004305D9 /* MBIMURLUtilities.h */,
|
||||
CD3F62B0297769F2004305D9 /* MBIMURLUtilities.m */,
|
||||
);
|
||||
path = Utilities;
|
||||
sourceTree = "<group>";
|
||||
@@ -520,24 +557,30 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1AA43E90219EBB3400EDF1A7 /* Utilities */,
|
||||
CD2ECEC0269539100055E302 /* MBIMAuthenticateOperation.h */,
|
||||
CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */,
|
||||
CD602054219B5DFD0024D9C5 /* MBIMBridgeOperation.h */,
|
||||
CD602055219B5DFD0024D9C5 /* MBIMBridgeOperation.m */,
|
||||
CD60205A219B623F0024D9C5 /* MBIMMessagesListOperation.h */,
|
||||
CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */,
|
||||
CD60205D219B674B0024D9C5 /* MBIMConversationListOperation.h */,
|
||||
CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */,
|
||||
CDDCF78B283F398C0087ABDF /* MBIMDeleteConversationOperation.h */,
|
||||
CDDCF78C283F398C0087ABDF /* MBIMDeleteConversationOperation.m */,
|
||||
CDE455A221A5308D0041F5DD /* MBIMFetchAttachmentOperation.h */,
|
||||
CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */,
|
||||
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */,
|
||||
CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */,
|
||||
CD60205A219B623F0024D9C5 /* MBIMMessagesListOperation.h */,
|
||||
CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */,
|
||||
CD602060219B68950024D9C5 /* MBIMSendMessageOperation.h */,
|
||||
CD602061219B68950024D9C5 /* MBIMSendMessageOperation.m */,
|
||||
CD936A37289B49FC0093A1AC /* MBIMStatusOperation.h */,
|
||||
CD936A38289B49FC0093A1AC /* MBIMStatusOperation.m */,
|
||||
CD14F19F219FE7D600E7DD22 /* MBIMUpdatePollOperation.h */,
|
||||
CD14F1A0219FE7D600E7DD22 /* MBIMUpdatePollOperation.m */,
|
||||
1AD8936C21EFD986009B599A /* MBIMUploadAttachmentOperation.h */,
|
||||
1AD8936D21EFD986009B599A /* MBIMUploadAttachmentOperation.m */,
|
||||
CD2ECEC0269539100055E302 /* MBIMAuthenticateOperation.h */,
|
||||
CD2ECEC1269539100055E302 /* MBIMAuthenticateOperation.m */,
|
||||
CD936A33289B47D50093A1AC /* MBIMVersionOperation.h */,
|
||||
CD936A34289B47D50093A1AC /* MBIMVersionOperation.m */,
|
||||
);
|
||||
path = Operations;
|
||||
sourceTree = "<group>";
|
||||
@@ -569,6 +612,7 @@
|
||||
1A0C446D219A4BCD00F2AC00 /* Bridge */,
|
||||
CDF62334219A895D00690038 /* main.m */,
|
||||
1AAB32B221F835BD004A2A72 /* KPServer.pch */,
|
||||
CD936A2F289B31740093A1AC /* kordophoned-RestrictedEntitlements.plist */,
|
||||
);
|
||||
path = kordophone;
|
||||
sourceTree = "<group>";
|
||||
@@ -677,6 +721,7 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = CDF62336219A895D00690038 /* Build configuration list for PBXNativeTarget "kordophoned" */;
|
||||
buildPhases = (
|
||||
CD936A36289B48930093A1AC /* Compile Version String */,
|
||||
CDF6232E219A895D00690038 /* Sources */,
|
||||
CDF6232F219A895D00690038 /* Frameworks */,
|
||||
CDF62330219A895D00690038 /* CopyFiles */,
|
||||
@@ -773,6 +818,24 @@
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\nRESULT=$(install_name_tool -delete_rpath $BUILT_PRODUCTS_DIR $BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME 2> /dev/null)\n\ninstall_name_tool -add_rpath $BUILT_PRODUCTS_DIR $BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME\n";
|
||||
};
|
||||
CD936A36289B48930093A1AC /* Compile Version String */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Compile Version String";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nOUTPUT_FILE=\"$DERIVED_FILE_DIR/MBIMVersion.c\"\nVERSION_STR=`git describe`\n\necho \"const char* MBIMVersion() { return \\\"$VERSION_STR\\\"; }\" > $OUTPUT_FILE\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
@@ -836,20 +899,26 @@
|
||||
CD2ECEC526953F2A0055E302 /* MBIMAuthToken.m in Sources */,
|
||||
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */,
|
||||
1AAB32B121F82EB7004A2A72 /* MBIMLogging.m in Sources */,
|
||||
CDDCF78D283F398C0087ABDF /* MBIMDeleteConversationOperation.m in Sources */,
|
||||
1AD8936E21EFD986009B599A /* MBIMUploadAttachmentOperation.m in Sources */,
|
||||
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */,
|
||||
CDF62335219A895D00690038 /* main.m in Sources */,
|
||||
CD60205C219B623F0024D9C5 /* MBIMMessagesListOperation.m in Sources */,
|
||||
CD14F1AA219FF3B800E7DD22 /* MBIMUpdateQueue.m in Sources */,
|
||||
CD3F62B1297769F2004305D9 /* MBIMURLUtilities.m in Sources */,
|
||||
CD14F1A4219FF22700E7DD22 /* IMMessageItem+Encoded.m in Sources */,
|
||||
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */,
|
||||
CD14F1A1219FE7D600E7DD22 /* MBIMUpdatePollOperation.m in Sources */,
|
||||
CD936A39289B49FC0093A1AC /* MBIMStatusOperation.m in Sources */,
|
||||
CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */,
|
||||
CDE455A721A531ED0041F5DD /* MBIMDataResponse.m in Sources */,
|
||||
CD936A35289B47D60093A1AC /* MBIMVersionOperation.m in Sources */,
|
||||
CD602056219B5DFD0024D9C5 /* MBIMBridgeOperation.m in Sources */,
|
||||
CD60205F219B674B0024D9C5 /* MBIMConversationListOperation.m in Sources */,
|
||||
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */,
|
||||
CD2782BF2952832B00C0C030 /* MBIMImageUtils.m in Sources */,
|
||||
1AA43E8F219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m in Sources */,
|
||||
CD936A32289B353F0093A1AC /* MBIMErrorResponse.m in Sources */,
|
||||
CD2ECEC2269539100055E302 /* MBIMAuthenticateOperation.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1118,6 +1187,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = "kordophone/kordophoned-RestrictedEntitlements.plist";
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
GCC_PREFIX_HEADER = kordophone/KPServer.pch;
|
||||
|
||||
@@ -7,6 +7,9 @@ sudo defaults write /Library/Preferences/com.apple.security.coderequirements Ent
|
||||
|
||||
Maybe a better thing to do is to DYLD_PRELOAD `imagent` and swizzle `IMDAuditTokenTaskHasEntitlement` to always return YES.
|
||||
|
||||
Included in the project is "kordophoned-RestrictedEntitlements.plist", which contains all necessary restricted entitlements.
|
||||
On production macOS builds, the kernel will kill kordophoned immediately if it's signed using restricted entitlements, so agent hook is a
|
||||
better option when running on prod machines. By default, the project is configured to ignore kordophoned-RestrictedEntitlements.plist when building.
|
||||
|
||||
## Building/linking
|
||||
If you get dyld errors running from the command line, use `install_name_tool` to update the @rpath (where @rpath points to where linked Frameworks like GCDWebServer is).
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#import "MBIMBridge_Private.h"
|
||||
#import "MBIMBridgeOperation.h"
|
||||
#import "MBIMAuthToken.h"
|
||||
#import "MBIMUpdateQueue.h"
|
||||
#import "MBIMURLUtilities.h"
|
||||
|
||||
#import <Security/Security.h>
|
||||
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||
@@ -107,6 +109,7 @@
|
||||
if (operationClass != nil) {
|
||||
_currentOperation = [[operationClass alloc] initWithRequestURL:url completion:completion];
|
||||
_currentOperation.requestBodyData = _bodyData;
|
||||
_currentOperation.request = self->request;
|
||||
|
||||
[[[MBIMBridge sharedInstance] operationQueue] addOperation:_currentOperation];
|
||||
long status = dispatch_semaphore_wait(sema, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60.0 * NSEC_PER_SEC)));
|
||||
@@ -124,6 +127,24 @@
|
||||
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
|
||||
{
|
||||
if ([method isEqualToString:@"POST"]) {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#import "IMFoundation_ClassDump.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class GCDAsyncSocket;
|
||||
@class HTTPMessage;
|
||||
@class WebSocket;
|
||||
|
||||
@interface MBIMUpdateItem : NSObject
|
||||
@property (nonatomic, strong) IMChat *changedChat;
|
||||
@@ -24,11 +27,13 @@ typedef void (^MBIMUpdateConsumer)(NSArray<MBIMUpdateItem *> *items);
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
- (void)addConsumer:(MBIMUpdateConsumer)consumer withLastSyncedMessageSeq:(NSInteger)messageSeq;
|
||||
- (void)removeConsumer:(MBIMUpdateConsumer)consumer;
|
||||
- (void)addPollingConsumer:(MBIMUpdateConsumer)consumer withLastSyncedMessageSeq:(NSInteger)messageSeq;
|
||||
- (void)removePollingConsumer:(MBIMUpdateConsumer)consumer;
|
||||
|
||||
- (void)enqueueUpdateItem:(MBIMUpdateItem *)item;
|
||||
|
||||
- (WebSocket *)vendUpdateWebSocketConsumerForRequest:(HTTPMessage *)request socket:(GCDAsyncSocket *)socket;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -9,20 +9,29 @@
|
||||
#import "MBIMUpdateQueue.h"
|
||||
#import "IMMessageItem+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;
|
||||
|
||||
@interface MBIMUpdateItem (/*INTERNAL*/)
|
||||
@interface MBIMUpdateItem (/*INTERNAL*/) <WebSocketDelegate>
|
||||
@property (nonatomic, assign) NSUInteger messageSequenceNumber;
|
||||
@end
|
||||
|
||||
@implementation MBIMUpdateQueue {
|
||||
NSUInteger _messageSequenceNumber;
|
||||
dispatch_queue_t _accessQueue;
|
||||
NSMutableArray *_consumers;
|
||||
NSMutableArray *_longPollConsumers;
|
||||
|
||||
// Maps message sequence number to update item
|
||||
NSMutableDictionary<NSNumber *, MBIMUpdateItem *> *_updateItemHistory;
|
||||
|
||||
// WebSocket consumers
|
||||
NSMutableDictionary<NSString *, MBIMUpdateConsumer> *_websocketConsumers;
|
||||
}
|
||||
|
||||
+ (instancetype)sharedInstance
|
||||
@@ -41,20 +50,93 @@ static const NSUInteger kUpdateItemsCullingLength = 100;
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_accessQueue = dispatch_queue_create("net.buzzert.MBIMUpdateQueue", DISPATCH_QUEUE_SERIAL);
|
||||
_consumers = [[NSMutableArray alloc] init];
|
||||
_messageSequenceNumber = 0;
|
||||
_updateItemHistory = [[NSMutableDictionary alloc] init];
|
||||
_websocketConsumers = [[NSMutableDictionary alloc] init];
|
||||
_longPollConsumers = [[NSMutableArray alloc] init];
|
||||
}
|
||||
|
||||
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;
|
||||
dispatch_async(_accessQueue, ^{
|
||||
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, ^{
|
||||
if ((messageSeq >= 0) && messageSeq < self->_messageSequenceNumber) {
|
||||
NSMutableArray *batchedUpdates = [NSMutableArray array];
|
||||
for (NSUInteger seq = messageSeq + 1; seq <= self->_messageSequenceNumber; seq++) {
|
||||
MBIMUpdateItem *item = [updateItemHistory objectForKey:@(seq)];
|
||||
@@ -64,37 +146,10 @@ static const NSUInteger kUpdateItemsCullingLength = 100;
|
||||
}
|
||||
|
||||
consumer(batchedUpdates);
|
||||
} else {
|
||||
[consumers addObject:consumer];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)removeConsumer:(MBIMUpdateConsumer)consumer
|
||||
{
|
||||
__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];
|
||||
});
|
||||
return needsSync;
|
||||
}
|
||||
|
||||
- (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
|
||||
|
||||
@implementation MBIMUpdateItem
|
||||
|
||||
@@ -60,9 +60,14 @@
|
||||
MBIMAuthToken *token = [[MBIMAuthToken alloc] initWithUsername:username];
|
||||
|
||||
// All systems go
|
||||
response = [MBIMJSONDataResponse responseWithJSONObject:@{
|
||||
MBIMJSONDataResponse *dataResponse = [MBIMJSONDataResponse responseWithJSONObject:@{
|
||||
@"jwt" : token.jwtToken
|
||||
}];
|
||||
|
||||
// Send a cookie down so we can use httpOnly cookies
|
||||
dataResponse.httpHeaders[@"Set-Cookie"] = [NSString stringWithFormat:@"auth_token=%@", token.jwtToken];
|
||||
|
||||
response = dataResponse;
|
||||
} while (NO);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CocoaHTTPServer/HTTPMessage.h>
|
||||
#import <CocoaHTTPServer/HTTPResponse.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) BOOL requiresAuthentication; // default YES
|
||||
|
||||
@property (nonatomic, strong) HTTPMessage *request;
|
||||
@property (nonatomic, strong) NSData *requestBodyData;
|
||||
@property (nonatomic, readonly) NSURL *requestURL;
|
||||
@property (nonatomic, readonly) MBIMBridgeOperationCompletionBlock serverCompletionBlock;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
#import "MBIMURLUtilities.h"
|
||||
|
||||
@interface MBIMBridgeOperation (/*INTERNAL*/)
|
||||
@property (nonatomic, strong) NSURL *requestURL;
|
||||
@@ -79,18 +80,7 @@
|
||||
|
||||
- (NSString *)valueForQueryItemWithName:(NSString *)queryItemName
|
||||
{
|
||||
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self.requestURL
|
||||
resolvingAgainstBaseURL:NO];
|
||||
|
||||
NSString *value = nil;
|
||||
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
||||
if ([[queryItem name] isEqualToString:queryItemName]) {
|
||||
value = [queryItem value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
return [[self requestURL] valueForQueryItemWithName:queryItemName];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMDeleteConversationOperation.h
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 5/25/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMDeleteConversationOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// MBIMDeleteConversationOperation.m
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 5/25/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMDeleteConversationOperation.h"
|
||||
#import "IMChat+Encoded.h"
|
||||
|
||||
#import "IMCore_ClassDump.h"
|
||||
|
||||
@implementation MBIMDeleteConversationOperation
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
+ (NSString *)endpointName
|
||||
{
|
||||
return @"delete";
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
__block NSObject<HTTPResponse> *response = nil;
|
||||
do {
|
||||
NSString *guid = [self valueForQueryItemWithName:@"guid"];
|
||||
|
||||
if (!guid) {
|
||||
MBIMLogInfo(@"No conversation GUID provided.");
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
break;
|
||||
}
|
||||
|
||||
dispatch_sync([[self class] sharedIMAccessQueue], ^{
|
||||
IMChat *chat = [[IMChatRegistry sharedInstance] existingChatWithGUID:guid];
|
||||
if (!chat) {
|
||||
MBIMLogInfo(@"Chat with guid: %@ not found", guid);
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
} else {
|
||||
[chat remove];
|
||||
}
|
||||
});
|
||||
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:200];
|
||||
} while (0);
|
||||
|
||||
self.serverCompletionBlock(response);
|
||||
}
|
||||
@end
|
||||
@@ -8,8 +8,11 @@
|
||||
|
||||
#import "MBIMFetchAttachmentOperation.h"
|
||||
#import "MBIMDataResponse.h"
|
||||
#import "MBIMImageUtils.h"
|
||||
|
||||
#import "IMCore_ClassDump.h"
|
||||
#import "IMSharedUtilities_ClassDump.h"
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@implementation MBIMFetchAttachmentOperation
|
||||
|
||||
@@ -24,8 +27,8 @@
|
||||
{
|
||||
NSObject<HTTPResponse> *response = nil;
|
||||
do {
|
||||
BOOL preview = [[self valueForQueryItemWithName:@"preview"] boolValue];
|
||||
NSString *guid = [self valueForQueryItemWithName:@"guid"];
|
||||
|
||||
if (!guid) {
|
||||
MBIMLogInfo(@"No query item provided");
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
@@ -45,22 +48,68 @@
|
||||
break;
|
||||
}
|
||||
|
||||
NSString *localPath = [transfer localPath];
|
||||
NSData *responseData = [NSData dataWithContentsOfFile:localPath];
|
||||
NSData *responseData = nil;
|
||||
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) {
|
||||
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];
|
||||
break;
|
||||
}
|
||||
|
||||
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
|
||||
if (!mimeType) {
|
||||
NSString *extension = [[localPath pathExtension] lowercaseString];
|
||||
|
||||
// XXX: REALLY hacky
|
||||
mimeType = [NSString stringWithFormat:@"image/%@", extension];
|
||||
}
|
||||
|
||||
response = [[MBIMDataResponse alloc] initWithData:responseData contentType:mimeType];
|
||||
} while (0);
|
||||
|
||||
|
||||
@@ -9,9 +9,17 @@
|
||||
#import "MBIMMessagesListOperation.h"
|
||||
#import "MBIMHTTPUtilities.h"
|
||||
#import "IMMessageItem+Encoded.h"
|
||||
#import "MBIMErrorResponse.h"
|
||||
|
||||
#import "IMCore_ClassDump.h"
|
||||
|
||||
#define kDefaultMessagesLimit 75
|
||||
|
||||
@interface IMChat (MBIMSafeMessagesLoading)
|
||||
- (void)load:(NSUInteger)number messagesBeforeGUID:(NSString *)beforeMessageGUID;
|
||||
- (void)load:(NSUInteger)number messagesAfterGUID:(NSString *)afterMessageGUID;
|
||||
@end
|
||||
|
||||
@implementation MBIMMessagesListOperation
|
||||
|
||||
+ (void)load { [super load]; }
|
||||
@@ -25,11 +33,32 @@
|
||||
{
|
||||
__block NSObject<HTTPResponse> *response = nil;
|
||||
do {
|
||||
// Required parameters
|
||||
NSString *guid = [self valueForQueryItemWithName:@"guid"];
|
||||
|
||||
// Optional
|
||||
NSString *limitValue = [self valueForQueryItemWithName:@"limit"];
|
||||
|
||||
NSDate *beforeDate = nil;
|
||||
NSString *beforeDateValue = [self valueForQueryItemWithName:@"beforeDate"];
|
||||
if (beforeDateValue) {
|
||||
beforeDate = [beforeDateValue ISO8601Date];
|
||||
if (!beforeDate) {
|
||||
response = [[MBIMErrorResponse alloc] initWithErrorCode:500 message:@"Unable to decode ISO8601 beforeDate value"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NSString *beforeMessageGUID = [self valueForQueryItemWithName:@"beforeMessageGUID"];
|
||||
NSString *afterMessageGUID = [self valueForQueryItemWithName:@"afterMessageGUID"];
|
||||
|
||||
if (beforeMessageGUID && afterMessageGUID) {
|
||||
response = [[MBIMErrorResponse alloc] initWithErrorCode:500 message:@"Cannot provide both beforeMessageGUID and afterMessageGUID params."];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!guid) {
|
||||
MBIMLogInfo(@"No query item provided");
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
response = [[MBIMErrorResponse alloc] initWithErrorCode:500 message:@"No GUID provided."];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -41,12 +70,35 @@
|
||||
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||
} else {
|
||||
// Load messages
|
||||
[chat loadMessagesBeforeDate:[NSDate date] limit:50 loadImmediately:YES];
|
||||
// (Must be done on main queue for some reason)
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
NSUInteger limit = kDefaultMessagesLimit;
|
||||
if (limitValue) {
|
||||
limit = [limitValue integerValue];
|
||||
}
|
||||
|
||||
if (beforeMessageGUID) {
|
||||
[chat load:limit messagesBeforeGUID:beforeMessageGUID];
|
||||
} else if (afterMessageGUID) {
|
||||
[chat load:limit messagesAfterGUID:afterMessageGUID];
|
||||
} else {
|
||||
[chat loadMessagesBeforeDate:beforeDate limit:limit loadImmediately:YES];
|
||||
}
|
||||
|
||||
[[chat chatItems] enumerateMessagesWithOptions:0 usingBlock:^(IMMessage *message, BOOL *stop) {
|
||||
// Assume "beforeMessageGUID" is exclusive
|
||||
if ([[message guid] isEqual:beforeMessageGUID]) {
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
// Assume "afterMessageGUID" is exclusive.
|
||||
if (![[message guid] isEqual:afterMessageGUID]) {
|
||||
NSDictionary *messageDict = [message mbim_dictionaryRepresentation];
|
||||
[messages addObject:messageDict];
|
||||
}
|
||||
}];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,3 +109,35 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation IMChat (MBIMSafeMessagesLoading)
|
||||
|
||||
- (id)_safe_loadMessagesBeforeAndAfterGUID:(NSString *)messagesGUID numberOfMessagesToLoadBeforeGUID:(NSUInteger)limitBefore numberOfMessagesToLoadAfterGUID:(NSUInteger)limitAfter loadImmediately:(BOOL)loadImmediately
|
||||
{
|
||||
if ([self respondsToSelector:@selector(loadMessagesBeforeAndAfterGUID:
|
||||
numberOfMessagesToLoadBeforeGUID:
|
||||
numberOfMessagesToLoadAfterGUID:
|
||||
loadImmediately:threadIdentifier:)]) {
|
||||
return [self loadMessagesBeforeAndAfterGUID:messagesGUID
|
||||
numberOfMessagesToLoadBeforeGUID:limitBefore
|
||||
numberOfMessagesToLoadAfterGUID:limitAfter
|
||||
loadImmediately:YES threadIdentifier:nil];
|
||||
} else {
|
||||
return [self loadMessagesBeforeAndAfterGUID:messagesGUID
|
||||
numberOfMessagesToLoadBeforeGUID:limitBefore
|
||||
numberOfMessagesToLoadAfterGUID:limitAfter
|
||||
loadImmediately:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)load:(NSUInteger)number messagesBeforeGUID:(NSString *)beforeMessageGUID
|
||||
{
|
||||
[self _safe_loadMessagesBeforeAndAfterGUID:beforeMessageGUID numberOfMessagesToLoadBeforeGUID:number numberOfMessagesToLoadAfterGUID:0 loadImmediately:YES];
|
||||
}
|
||||
|
||||
- (void)load:(NSUInteger)number messagesAfterGUID:(NSString *)afterMessageGUID
|
||||
{
|
||||
[self _safe_loadMessagesBeforeAndAfterGUID:afterMessageGUID numberOfMessagesToLoadBeforeGUID:0 numberOfMessagesToLoadAfterGUID:number loadImmediately:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -46,7 +46,9 @@
|
||||
MBIMLogInfo(@"Chat does not exist: %@", chatGUID);
|
||||
result = NO;
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[chat sendMessage:reply];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
17
kordophone/Bridge/Operations/MBIMStatusOperation.h
Normal file
17
kordophone/Bridge/Operations/MBIMStatusOperation.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMStatusOperation.h
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 8/3/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMStatusOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
25
kordophone/Bridge/Operations/MBIMStatusOperation.m
Normal file
25
kordophone/Bridge/Operations/MBIMStatusOperation.m
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MBIMStatusOperation.m
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 8/3/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMStatusOperation.h"
|
||||
|
||||
@implementation MBIMStatusOperation
|
||||
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
+ (NSString *)endpointName
|
||||
{
|
||||
return @"status";
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
self.serverCompletionBlock([[MBIMDataResponse alloc] initWithData:[@"OK" dataUsingEncoding:NSUTF8StringEncoding]]);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -40,13 +40,13 @@
|
||||
weakSelf.serverCompletionBlock(response);
|
||||
};
|
||||
|
||||
[[MBIMUpdateQueue sharedInstance] addConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
||||
[[MBIMUpdateQueue sharedInstance] addPollingConsumer:_updateConsumer withLastSyncedMessageSeq:messageSeq];
|
||||
}
|
||||
|
||||
- (void)cancel
|
||||
{
|
||||
[super cancel];
|
||||
[[MBIMUpdateQueue sharedInstance] removeConsumer:_updateConsumer];
|
||||
[[MBIMUpdateQueue sharedInstance] removePollingConsumer:_updateConsumer];
|
||||
}
|
||||
|
||||
- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse
|
||||
|
||||
17
kordophone/Bridge/Operations/MBIMVersionOperation.h
Normal file
17
kordophone/Bridge/Operations/MBIMVersionOperation.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// MBIMVersionOperation.h
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 8/3/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMBridgeOperation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMVersionOperation : MBIMBridgeOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
40
kordophone/Bridge/Operations/MBIMVersionOperation.m
Normal file
40
kordophone/Bridge/Operations/MBIMVersionOperation.m
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// MBIMVersionOperation.m
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 8/3/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMVersionOperation.h"
|
||||
#import "MBIMErrorResponse.h"
|
||||
|
||||
#ifdef __clang_analyzer__
|
||||
const char* MBIMVersion() {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
#else
|
||||
#import "MBIMVersion.c"
|
||||
#endif
|
||||
|
||||
@implementation MBIMVersionOperation
|
||||
|
||||
+ (void)load { [super load]; }
|
||||
|
||||
+ (BOOL)requiresAuthentication
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (NSString *)endpointName
|
||||
{
|
||||
return @"version";
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSString *versionString = [NSString stringWithUTF8String:MBIMVersion()];
|
||||
self.serverCompletionBlock([[MBIMDataResponse alloc] initWithData:[versionString dataUsingEncoding:NSUTF8StringEncoding]]);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,6 +12,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMDataResponse : HTTPDataResponse
|
||||
@property (nonatomic, readonly) NSMutableDictionary *httpHeaders;
|
||||
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
|
||||
@end
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
@implementation MBIMDataResponse {
|
||||
NSString *_contentType;
|
||||
NSMutableDictionary *_httpHeaders;
|
||||
}
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
|
||||
@@ -17,6 +18,11 @@
|
||||
self = [super initWithData:data];
|
||||
if (self) {
|
||||
_contentType = contentType;
|
||||
_httpHeaders = [@{
|
||||
@"Content-Type" : _contentType ?: @"application/octet-stream",
|
||||
@"Access-Control-Allow-Origin" : @"*", // CORS
|
||||
@"Access-Control-Allow-Credentials" : @"true"
|
||||
} mutableCopy];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -24,9 +30,7 @@
|
||||
|
||||
- (NSDictionary *)httpHeaders
|
||||
{
|
||||
return @{
|
||||
@"Content-Type" : _contentType ?: @"application/octet-stream"
|
||||
};
|
||||
return _httpHeaders;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
18
kordophone/Bridge/Operations/Utilities/MBIMErrorResponse.h
Normal file
18
kordophone/Bridge/Operations/Utilities/MBIMErrorResponse.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// MBIMErrorResponse.h
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 8/3/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HTTPDataResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MBIMErrorResponse : HTTPDataResponse
|
||||
- (instancetype)initWithErrorCode:(int)httpErrorCode;
|
||||
- (instancetype)initWithErrorCode:(int)httpErrorCode message:(NSString *)message;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
38
kordophone/Bridge/Operations/Utilities/MBIMErrorResponse.m
Normal file
38
kordophone/Bridge/Operations/Utilities/MBIMErrorResponse.m
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// MBIMErrorResponse.m
|
||||
// kordophoned
|
||||
//
|
||||
// Created by James Magahern on 8/3/22.
|
||||
// Copyright © 2022 James Magahern. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MBIMErrorResponse.h"
|
||||
|
||||
@implementation MBIMErrorResponse {
|
||||
int _status;
|
||||
}
|
||||
|
||||
- (instancetype)initWithErrorCode:(int)httpErrorCode
|
||||
{
|
||||
if (self = [super initWithData:nil]) {
|
||||
_status = httpErrorCode;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithErrorCode:(int)httpErrorCode message:(NSString *)message
|
||||
{
|
||||
if (self = [super initWithData:[message dataUsingEncoding:NSUTF8StringEncoding]]) {
|
||||
_status = httpErrorCode;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)status
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,3 +10,13 @@
|
||||
|
||||
NSString* MBIMWebServerFormatRFC822(NSDate *date);
|
||||
NSString* MBIMWebServerFormatISO8601(NSDate *date);
|
||||
|
||||
@interface NSDate (MBIMWebServerFormat)
|
||||
- (NSString *)RFC822StringValue;
|
||||
- (NSString *)ISO8601StringValue;
|
||||
@end
|
||||
|
||||
@interface NSString (MBIMWebServerFormat)
|
||||
- (NSDate *)RFC822Date;
|
||||
- (NSDate *)ISO8601Date;
|
||||
@end
|
||||
|
||||
@@ -47,3 +47,31 @@ NSString* MBIMWebServerFormatISO8601(NSDate *date)
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@implementation NSDate (MBIMWebServerFormat)
|
||||
|
||||
- (NSString *)RFC822StringValue
|
||||
{
|
||||
return MBIMWebServerFormatRFC822(self);
|
||||
}
|
||||
|
||||
- (NSString *)ISO8601StringValue
|
||||
{
|
||||
return MBIMWebServerFormatISO8601(self);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSString (MBIMWebServerFormat)
|
||||
|
||||
- (NSDate *)RFC822Date
|
||||
{
|
||||
return [_dateFormatterRFC822 dateFromString:self];
|
||||
}
|
||||
|
||||
- (NSDate *)ISO8601Date
|
||||
{
|
||||
return [_dateFormatterISO8601 dateFromString:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
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
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "IMChat+Encoded.h"
|
||||
#import "IMMessageItem+Encoded.h"
|
||||
#import "MBIMHTTPUtilities.h"
|
||||
|
||||
@implementation IMChat (Encoded)
|
||||
@@ -21,7 +22,8 @@
|
||||
|
||||
IMMessage *lastMessage = [self lastMessage];
|
||||
if (lastMessage) {
|
||||
chatDict[@"lastMessagePreview"] = [[lastMessage text] string];
|
||||
chatDict[@"lastMessagePreview"] = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
|
||||
chatDict[@"lastMessage"] = [lastMessage mbim_dictionaryRepresentation];
|
||||
}
|
||||
|
||||
NSMutableArray *participantStrings = [NSMutableArray array];
|
||||
|
||||
@@ -21,16 +21,27 @@
|
||||
|
||||
if ([self fileTransferGUIDs]) {
|
||||
// Support only images right now
|
||||
NSMutableDictionary *attachmentMetadatas = [NSMutableDictionary dictionary];
|
||||
NSMutableArray *filteredFileTransferGUIDs = [NSMutableArray array];
|
||||
for (NSString *guid in self.fileTransferGUIDs) {
|
||||
NSMutableDictionary *metadata = [NSMutableDictionary dictionary];
|
||||
IMFileTransfer *transfer = [[IMFileTransferCenter sharedInstance] transferForGUID:guid];
|
||||
if ([[transfer mimeType] containsString:@"image"]) {
|
||||
[filteredFileTransferGUIDs addObject:guid];
|
||||
|
||||
if ([transfer attributionInfo] != nil) {
|
||||
metadata[@"attributionInfo"] = [transfer attributionInfo];
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata.count) {
|
||||
attachmentMetadatas[guid] = metadata;
|
||||
}
|
||||
}
|
||||
|
||||
if ([filteredFileTransferGUIDs count]) {
|
||||
messageDict[@"fileTransferGUIDs"] = filteredFileTransferGUIDs;
|
||||
messageDict[@"attachmentMetadata"] = attachmentMetadatas;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
kordophone/kordophoned-RestrictedEntitlements.plist
Normal file
16
kordophone/kordophoned-RestrictedEntitlements.plist
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.imagent</key>
|
||||
<true/>
|
||||
<key>com.apple.private.imagent</key>
|
||||
<true/>
|
||||
<key>com.apple.private.imcore.imagent</key>
|
||||
<true/>
|
||||
<key>com.apple.imagent.av</key>
|
||||
<true/>
|
||||
<key>com.apple.imagent.chat</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user