Attachments support!
This commit is contained in:
@@ -77,6 +77,8 @@
|
|||||||
CD83E166219BE91600F4CCEA /* agentHook.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E165219BE91600F4CCEA /* agentHook.m */; };
|
CD83E166219BE91600F4CCEA /* agentHook.m in Sources */ = {isa = PBXBuildFile; fileRef = CD83E165219BE91600F4CCEA /* agentHook.m */; };
|
||||||
CDE4556421A3578A0041F5DD /* IMChat+Encoded.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE4556321A3578A0041F5DD /* IMChat+Encoded.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 */; };
|
CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */; };
|
||||||
|
CDE455A421A5308D0041F5DD /* MBIMFetchAttachmentOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */; };
|
||||||
|
CDE455A721A531ED0041F5DD /* MBIMDataResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE455A621A531ED0041F5DD /* MBIMDataResponse.m */; };
|
||||||
CDF62335219A895D00690038 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CDF62334219A895D00690038 /* main.m */; };
|
CDF62335219A895D00690038 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CDF62334219A895D00690038 /* main.m */; };
|
||||||
CDF62339219A8A5600690038 /* MBIMBridge.h in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C4469219A4BC300F2AC00 /* MBIMBridge.h */; };
|
CDF62339219A8A5600690038 /* MBIMBridge.h in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C4469219A4BC300F2AC00 /* MBIMBridge.h */; };
|
||||||
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C446A219A4BC300F2AC00 /* MBIMBridge.m */; };
|
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C446A219A4BC300F2AC00 /* MBIMBridge.m */; };
|
||||||
@@ -221,6 +223,10 @@
|
|||||||
CDE4556321A3578A0041F5DD /* IMChat+Encoded.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "IMChat+Encoded.m"; 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>"; };
|
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMMarkOperation.h; sourceTree = "<group>"; };
|
||||||
CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMMarkOperation.m; sourceTree = "<group>"; };
|
CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMMarkOperation.m; sourceTree = "<group>"; };
|
||||||
|
CDE455A221A5308D0041F5DD /* MBIMFetchAttachmentOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMFetchAttachmentOperation.h; sourceTree = "<group>"; };
|
||||||
|
CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMFetchAttachmentOperation.m; sourceTree = "<group>"; };
|
||||||
|
CDE455A521A531ED0041F5DD /* MBIMDataResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBIMDataResponse.h; sourceTree = "<group>"; };
|
||||||
|
CDE455A621A531ED0041F5DD /* MBIMDataResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBIMDataResponse.m; sourceTree = "<group>"; };
|
||||||
CDF62332219A895D00690038 /* kordophoned */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = kordophoned; sourceTree = BUILT_PRODUCTS_DIR; };
|
CDF62332219A895D00690038 /* kordophoned */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = kordophoned; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
CDF62334219A895D00690038 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
CDF62334219A895D00690038 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
CDF62340219A9AAA00690038 /* EmailFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EmailFoundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/System/Library/PrivateFrameworks/EmailFoundation.framework; sourceTree = DEVELOPER_DIR; };
|
CDF62340219A9AAA00690038 /* EmailFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EmailFoundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/System/Library/PrivateFrameworks/EmailFoundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
@@ -345,6 +351,8 @@
|
|||||||
children = (
|
children = (
|
||||||
1AA43E8D219EBB2D00EDF1A7 /* MBIMJSONDataResponse.h */,
|
1AA43E8D219EBB2D00EDF1A7 /* MBIMJSONDataResponse.h */,
|
||||||
1AA43E8E219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m */,
|
1AA43E8E219EBB2D00EDF1A7 /* MBIMJSONDataResponse.m */,
|
||||||
|
CDE455A521A531ED0041F5DD /* MBIMDataResponse.h */,
|
||||||
|
CDE455A621A531ED0041F5DD /* MBIMDataResponse.m */,
|
||||||
1AA43E93219EC38E00EDF1A7 /* MBIMHTTPUtilities.h */,
|
1AA43E93219EC38E00EDF1A7 /* MBIMHTTPUtilities.h */,
|
||||||
1AA43E94219EC38E00EDF1A7 /* MBIMHTTPUtilities.m */,
|
1AA43E94219EC38E00EDF1A7 /* MBIMHTTPUtilities.m */,
|
||||||
);
|
);
|
||||||
@@ -509,6 +517,8 @@
|
|||||||
CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */,
|
CD60205B219B623F0024D9C5 /* MBIMMessagesListOperation.m */,
|
||||||
CD60205D219B674B0024D9C5 /* MBIMConversationListOperation.h */,
|
CD60205D219B674B0024D9C5 /* MBIMConversationListOperation.h */,
|
||||||
CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */,
|
CD60205E219B674B0024D9C5 /* MBIMConversationListOperation.m */,
|
||||||
|
CDE455A221A5308D0041F5DD /* MBIMFetchAttachmentOperation.h */,
|
||||||
|
CDE455A321A5308D0041F5DD /* MBIMFetchAttachmentOperation.m */,
|
||||||
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */,
|
CDE4559F21A365AD0041F5DD /* MBIMMarkOperation.h */,
|
||||||
CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */,
|
CDE455A021A365AD0041F5DD /* MBIMMarkOperation.m */,
|
||||||
CD602060219B68950024D9C5 /* MBIMSendMessageOperation.h */,
|
CD602060219B68950024D9C5 /* MBIMSendMessageOperation.h */,
|
||||||
@@ -785,6 +795,7 @@
|
|||||||
1AA43E91219EBC2C00EDF1A7 /* MBIMHTTPConnection.m in Sources */,
|
1AA43E91219EBC2C00EDF1A7 /* MBIMHTTPConnection.m in Sources */,
|
||||||
CDF62339219A8A5600690038 /* MBIMBridge.h in Sources */,
|
CDF62339219A8A5600690038 /* MBIMBridge.h in Sources */,
|
||||||
1AA43E95219EC38E00EDF1A7 /* MBIMHTTPUtilities.m in Sources */,
|
1AA43E95219EC38E00EDF1A7 /* MBIMHTTPUtilities.m in Sources */,
|
||||||
|
CDE455A421A5308D0041F5DD /* MBIMFetchAttachmentOperation.m in Sources */,
|
||||||
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */,
|
CD83E156219BE10A00F4CCEA /* hooking.m in Sources */,
|
||||||
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */,
|
CDF6233A219A8A5600690038 /* MBIMBridge.m in Sources */,
|
||||||
CDF62335219A895D00690038 /* main.m in Sources */,
|
CDF62335219A895D00690038 /* main.m in Sources */,
|
||||||
@@ -794,6 +805,7 @@
|
|||||||
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */,
|
CD602062219B68950024D9C5 /* MBIMSendMessageOperation.m in Sources */,
|
||||||
CD14F1A1219FE7D600E7DD22 /* MBIMUpdatePollOperation.m in Sources */,
|
CD14F1A1219FE7D600E7DD22 /* MBIMUpdatePollOperation.m in Sources */,
|
||||||
CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */,
|
CDE455A121A365AD0041F5DD /* MBIMMarkOperation.m in Sources */,
|
||||||
|
CDE455A721A531ED0041F5DD /* MBIMDataResponse.m in Sources */,
|
||||||
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 */,
|
||||||
|
|||||||
17
kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.h
Normal file
17
kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// MBIMFetchAttachmentOperation.h
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 11/20/18.
|
||||||
|
// Copyright © 2018 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MBIMBridgeOperation.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface MBIMFetchAttachmentOperation : MBIMBridgeOperation
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
71
kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.m
Normal file
71
kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.m
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// MBIMFetchAttachmentOperation.m
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 11/20/18.
|
||||||
|
// Copyright © 2018 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MBIMFetchAttachmentOperation.h"
|
||||||
|
#import "MBIMDataResponse.h"
|
||||||
|
|
||||||
|
#import <IMCore/IMCore.h>
|
||||||
|
|
||||||
|
@implementation MBIMFetchAttachmentOperation
|
||||||
|
|
||||||
|
+ (void)load { [super load]; }
|
||||||
|
|
||||||
|
+ (NSString *)endpointName
|
||||||
|
{
|
||||||
|
return @"attachment";
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)main
|
||||||
|
{
|
||||||
|
NSObject<HTTPResponse> *response = nil;
|
||||||
|
do {
|
||||||
|
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:self.requestURL resolvingAgainstBaseURL:NO];
|
||||||
|
|
||||||
|
NSString *guid = nil;
|
||||||
|
for (NSURLQueryItem *queryItem in [urlComponents queryItems]) {
|
||||||
|
if ([[queryItem name] isEqualToString:@"guid"]) {
|
||||||
|
guid = [queryItem value];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!guid) {
|
||||||
|
NSLog(@"No query item provided");
|
||||||
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:500];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMFileTransfer *transfer = [[IMFileTransferCenter sharedInstance] transferForGUID:guid];
|
||||||
|
if (!transfer) {
|
||||||
|
NSLog(@"No transfer found for guid: %@", guid);
|
||||||
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:404];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![transfer existsAtLocalPath]) {
|
||||||
|
NSLog(@"We don't have the file for this yet (still downloading to server?)");
|
||||||
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:404];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *localPath = [transfer localPath];
|
||||||
|
NSData *responseData = [NSData dataWithContentsOfFile:localPath];
|
||||||
|
if (!responseData) {
|
||||||
|
NSLog(@"Wasn't able to load data from local path: %@", localPath);
|
||||||
|
response = [[HTTPErrorResponse alloc] initWithErrorCode:404];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *mimeType = [transfer mimeType];
|
||||||
|
response = [[MBIMDataResponse alloc] initWithData:responseData contentType:mimeType];
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
self.serverCompletionBlock(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
18
kordophone/Bridge/Operations/Utilities/MBIMDataResponse.h
Normal file
18
kordophone/Bridge/Operations/Utilities/MBIMDataResponse.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// MBIMDataResponse.h
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 11/20/18.
|
||||||
|
// Copyright © 2018 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <CocoaHTTPServer/HTTPDataResponse.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface MBIMDataResponse : HTTPDataResponse
|
||||||
|
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType;
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
32
kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m
Normal file
32
kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// MBIMDataResponse.m
|
||||||
|
// kordophoned
|
||||||
|
//
|
||||||
|
// Created by James Magahern on 11/20/18.
|
||||||
|
// Copyright © 2018 James Magahern. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MBIMDataResponse.h"
|
||||||
|
|
||||||
|
@implementation MBIMDataResponse {
|
||||||
|
NSString *_contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType
|
||||||
|
{
|
||||||
|
self = [super initWithData:data];
|
||||||
|
if (self) {
|
||||||
|
_contentType = contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)httpHeaders
|
||||||
|
{
|
||||||
|
return @{
|
||||||
|
@"Content-Type" : _contentType
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <CocoaHTTPServer/HTTPDataResponse.h>
|
#import "MBIMDataResponse.h"
|
||||||
|
|
||||||
@interface MBIMJSONDataResponse : HTTPDataResponse
|
@interface MBIMJSONDataResponse : MBIMDataResponse
|
||||||
|
|
||||||
+ (instancetype)responseWithJSONObject:(id)object;
|
+ (instancetype)responseWithJSONObject:(id)object;
|
||||||
|
|
||||||
|
|||||||
@@ -17,16 +17,8 @@
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
MBIMJSONDataResponse *response = [[self alloc] initWithData:data];
|
MBIMJSONDataResponse *response = [[self alloc] initWithData:data contentType:@"application/json; charset=utf-8"];
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)httpHeaders
|
|
||||||
{
|
|
||||||
return @{
|
|
||||||
@"Content-Type" : @"application/json; charset=utf-8"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -32,6 +32,21 @@
|
|||||||
messageDict[@"date"] = MBIMWebServerFormatISO8601([self time]);
|
messageDict[@"date"] = MBIMWebServerFormatISO8601([self time]);
|
||||||
messageDict[@"sender"] = [self sender];
|
messageDict[@"sender"] = [self sender];
|
||||||
|
|
||||||
|
if ([self fileTransferGUIDs]) {
|
||||||
|
// Support only images right now
|
||||||
|
NSMutableArray *filteredFileTransferGUIDs = [NSMutableArray array];
|
||||||
|
for (NSString *guid in self.fileTransferGUIDs) {
|
||||||
|
IMFileTransfer *transfer = [[IMFileTransferCenter sharedInstance] transferForGUID:guid];
|
||||||
|
if ([[transfer mimeType] containsString:@"image"]) {
|
||||||
|
[filteredFileTransferGUIDs addObject:guid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([filteredFileTransferGUIDs count]) {
|
||||||
|
messageDict[@"fileTransferGUIDs"] = filteredFileTransferGUIDs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return messageDict;
|
return messageDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user