aboutsummaryrefslogtreecommitdiffhomepage
path: root/example
diff options
context:
space:
mode:
authorGravatar Jonathan Willing <jwilling@me.com>2013-05-13 23:35:55 -0500
committerGravatar Jonathan Willing <jwilling@me.com>2013-05-13 23:35:55 -0500
commit55597469dfb5bc4d25dc8ba0d7469feabacdc55d (patch)
tree5a1f3a027f42d74fe8aa18d69a2c7cba9ce85e7f /example
parentd14a86e82a32d7ae923be1734c90d1efa38c6aba (diff)
remove unnecessary code
Diffstat (limited to 'example')
-rw-r--r--example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj6
-rwxr-xr-xexample/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.h31
-rwxr-xr-xexample/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.mm141
-rwxr-xr-xexample/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm95
4 files changed, 28 insertions, 245 deletions
diff --git a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj
index e49346ed..a4e6718f 100644
--- a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj
+++ b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj
@@ -27,7 +27,6 @@
ABE40268173F0151007F1FB3 /* MCOMessageViewScript.js in Sources */ = {isa = PBXBuildFile; fileRef = ABE40267173F0151007F1FB3 /* MCOMessageViewScript.js */; };
ABE40269173F0282007F1FB3 /* MCOMessageViewScript.js in Resources */ = {isa = PBXBuildFile; fileRef = ABE40267173F0151007F1FB3 /* MCOMessageViewScript.js */; };
ABE4026B173F3FCE007F1FB3 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ABE4026A173F3FCE007F1FB3 /* ImageIO.framework */; };
- B12AAA3317322654003551C7 /* MCOCIDURLProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = B12AAA2E17322654003551C7 /* MCOCIDURLProtocol.mm */; };
B12AAA3417322654003551C7 /* MCOMessageView.mm in Sources */ = {isa = PBXBuildFile; fileRef = B12AAA3017322654003551C7 /* MCOMessageView.mm */; };
B12AAA3517322654003551C7 /* MCTMsgViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = B12AAA3217322654003551C7 /* MCTMsgViewController.mm */; };
/* End PBXBuildFile section */
@@ -105,8 +104,6 @@
AB9EAE3F170374D900D750C7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
ABE40267173F0151007F1FB3 /* MCOMessageViewScript.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = MCOMessageViewScript.js; sourceTree = "<group>"; };
ABE4026A173F3FCE007F1FB3 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
- B12AAA2D17322654003551C7 /* MCOCIDURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOCIDURLProtocol.h; sourceTree = "<group>"; };
- B12AAA2E17322654003551C7 /* MCOCIDURLProtocol.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOCIDURLProtocol.mm; sourceTree = "<group>"; };
B12AAA2F17322654003551C7 /* MCOMessageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOMessageView.h; sourceTree = "<group>"; };
B12AAA3017322654003551C7 /* MCOMessageView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOMessageView.mm; sourceTree = "<group>"; };
B12AAA3117322654003551C7 /* MCTMsgViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCTMsgViewController.h; sourceTree = "<group>"; };
@@ -194,8 +191,6 @@
AB9EAE1D170368F000D750C7 /* MainStoryboard.storyboard */,
AB9EAE20170368F000D750C7 /* MasterViewController.h */,
AB9EAE21170368F000D750C7 /* MasterViewController.m */,
- B12AAA2D17322654003551C7 /* MCOCIDURLProtocol.h */,
- B12AAA2E17322654003551C7 /* MCOCIDURLProtocol.mm */,
B12AAA2F17322654003551C7 /* MCOMessageView.h */,
B12AAA3017322654003551C7 /* MCOMessageView.mm */,
ABE40267173F0151007F1FB3 /* MCOMessageViewScript.js */,
@@ -341,7 +336,6 @@
AB9EAE22170368F000D750C7 /* MasterViewController.m in Sources */,
AB9EAE3617036FD700D750C7 /* SettingsViewController.m in Sources */,
AB665BCD17134336007F2151 /* FXKeychain.m in Sources */,
- B12AAA3317322654003551C7 /* MCOCIDURLProtocol.mm in Sources */,
B12AAA3417322654003551C7 /* MCOMessageView.mm in Sources */,
B12AAA3517322654003551C7 /* MCTMsgViewController.mm in Sources */,
ABE40268173F0151007F1FB3 /* MCOMessageViewScript.js in Sources */,
diff --git a/example/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.h b/example/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.h
deleted file mode 100755
index ac4b0f2b..00000000
--- a/example/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// MCTCIDURLProtocol.h
-// testUI
-//
-// Created by DINH Viêt Hoà on 1/22/13.
-// Copyright (c) 2013 MailCore. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-#include <MailCore/MailCore.h>
-
-@interface MCOCIDURLProtocol : NSURLProtocol
-
-+ (void) registerProtocol;
-
-+ (BOOL) isCID:(NSURL *)url;
-+ (BOOL) isXMailcoreImage:(NSURL *)url;
-
-#ifdef __cplusplus
-+ (void) startLoadingWithMessage:(MCOAbstractMessage *)message
- partUniqueID:(NSString *)partUniqueID
- data:(NSData *)data
- request:(NSMutableURLRequest *)request;
-
-+ (void) partDownloadedMessage:(MCOAbstractMessage *)message
- partUniqueID:(NSString *)partUniqueID
- data:(NSData *)data;
-#endif
-
-@end
diff --git a/example/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.mm b/example/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.mm
deleted file mode 100755
index f0f47182..00000000
--- a/example/ios/iOS UI Test/iOS UI Test/MCOCIDURLProtocol.mm
+++ /dev/null
@@ -1,141 +0,0 @@
-//
-// MCTCIDURLProtocol.m
-// testUI
-//
-// Created by DINH Viêt Hoà on 1/22/13.
-// Copyright (c) 2013 MailCore. All rights reserved.
-//
-
-#import "MCOCIDURLProtocol.h"
-
-#import "MCOMessageView.h"
-
-#define MCOCIDURLProtocolDownloadedNotification @"MCOCIDURLProtocolDownloadedNotification"
-
-@implementation MCOCIDURLProtocol
-
-+ (void) registerProtocol
-{
- static dispatch_once_t onceToken = 0;
- dispatch_once(&onceToken, ^{
- [NSURLProtocol registerClass:[MCOCIDURLProtocol class]];
- });
-}
-
-+ (BOOL) canInitWithRequest:(NSURLRequest *)theRequest
-{
- if ([self isCID:[theRequest URL]])
- return YES;
- if ([self isXMailcoreImage:[theRequest URL]])
- return YES;
- return NO;
-}
-
-+ (BOOL) isCID:(NSURL *)url
-{
- NSString *theScheme = [url scheme];
- if ([theScheme caseInsensitiveCompare:@"cid"] == NSOrderedSame)
- return YES;
- return NO;
-}
-
-+ (BOOL) isXMailcoreImage:(NSURL *)url
-{
- NSString *theScheme = [url scheme];
- if ([theScheme caseInsensitiveCompare:@"x-mailcore-image"] == NSOrderedSame)
- return YES;
- return NO;
-}
-
-+ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request
-{
- return request;
-}
-
-- (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)cachedResponse client:(id < NSURLProtocolClient >)client
-{
- self = [super initWithRequest:request cachedResponse:cachedResponse client:client];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_downloaded:) name:MCOCIDURLProtocolDownloadedNotification object:nil];
- //NSLog(@"%@", [request mainDocumentURL]);
- return self;
-}
-
-- (void) dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
-
-- (NSString *) _partUniqueID
-{
- return [NSURLProtocol propertyForKey:@"PartUniqueID" inRequest:[self request]];
-}
-
-- (NSData *) _data
-{
- return [NSURLProtocol propertyForKey:@"Data" inRequest:[self request]];
-}
-
-- (MCOAbstractMessage *) _message
-{
- return (MCOAbstractMessage *) [NSURLProtocol propertyForKey:@"Message" inRequest:[self request]];
-}
-
-- (void) startLoading
-{
- if ([self _data] != NULL) {
- [[self class] partDownloadedMessage:[self _message] partUniqueID:[self _partUniqueID] data:[self _data]];
- }
-}
-
-- (void) _downloaded:(NSNotification *)notification
-{
- NSDictionary * userInfo = [notification userInfo];
-
- NSString * notifPartID = [userInfo objectForKey:@"PartUniqueID"];
- MCOAbstractMessage * notifMessage = [userInfo objectForKey:@"Message"];
- if (notifMessage != [self _message]) {
- return;
- }
- if (![[self _partUniqueID] isEqualToString:notifPartID]) {
- return;
- }
-
- NSData * data = [userInfo objectForKey:@"Data"];
- NSURLResponse * response = [[NSURLResponse alloc] initWithURL:[[self request] URL] MIMEType:@"application/data"
- expectedContentLength:[data length] textEncodingName:nil];
- [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
- [[self client] URLProtocol:self didLoadData:data];
- [[self client] URLProtocolDidFinishLoading:self];
-}
-
-- (void) stopLoading
-{
-}
-
-+ (void) startLoadingWithMessage:(MCOAbstractMessage *)message
- partUniqueID:(NSString *)partUniqueID
- data:(NSData *)data
- request:(NSMutableURLRequest *)request
-{
- [NSURLProtocol setProperty:message
- forKey:@"Message" inRequest:request];
- if (data != NULL) {
- [NSURLProtocol setProperty:data forKey:@"Data" inRequest:request];
- }
- [NSURLProtocol setProperty:partUniqueID forKey:@"PartUniqueID" inRequest:request];
-}
-
-+ (void) partDownloadedMessage:(MCOAbstractMessage *)message
- partUniqueID:(NSString *)partUniqueID
- data:(NSData *)data
-{
- NSMutableDictionary * userInfo = [[NSMutableDictionary alloc] init];
- [userInfo setObject:message forKey:@"Message"];
- [userInfo setObject:partUniqueID forKey:@"PartUniqueID"];
- if (data != NULL) {
- [userInfo setObject:data forKey:@"Data"];
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:MCOCIDURLProtocolDownloadedNotification object:nil userInfo:userInfo];
-}
-
-@end
diff --git a/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm b/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm
index 8ec27f64..5a3974cc 100755
--- a/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm
+++ b/example/ios/iOS UI Test/iOS UI Test/MCOMessageView.mm
@@ -8,7 +8,7 @@
#import "MCOMessageView.h"
-#import "MCOCIDURLProtocol.h"
+//#import "MCOCIDURLProtocol.h"
@interface MCOMessageView () <MCOHTMLRendererIMAPDelegate>
@@ -28,11 +28,6 @@
@synthesize prefetchIMAPImagesEnabled = _prefetchIMAPImagesEnabled;
@synthesize prefetchIMAPAttachmentsEnabled = _prefetchIMAPAttachmentsEnabled;
-+ (void) initialize
-{
- [MCOCIDURLProtocol registerProtocol];
-}
-
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
@@ -102,6 +97,22 @@
[_webView loadHTMLString:html baseURL:nil];
}
+- (BOOL) _isCID:(NSURL *)url
+{
+ NSString *theScheme = [url scheme];
+ if ([theScheme caseInsensitiveCompare:@"cid"] == NSOrderedSame)
+ return YES;
+ return NO;
+}
+
+- (BOOL) _isXMailcoreImage:(NSURL *)url
+{
+ NSString *theScheme = [url scheme];
+ if ([theScheme caseInsensitiveCompare:@"x-mailcore-image"] == NSOrderedSame)
+ return YES;
+ return NO;
+}
+
- (void) _loadImages
{
NSString * result = [_webView stringByEvaluatingJavaScriptFromString:@"findCIDImageURL()"];
@@ -114,10 +125,10 @@
NSURL * url;
url = [NSURL URLWithString:urlString];
- if ([MCOCIDURLProtocol isCID:url]) {
+ if ([self _isCID:url]) {
part = [self _partForCIDURL:url];
}
- else if ([MCOCIDURLProtocol isXMailcoreImage:url]) {
+ else if ([self _isXMailcoreImage:url]) {
NSString * specifier = [url resourceSpecifier];
NSString * partUniqueID = specifier;
part = [self _partForUniqueID:partUniqueID];
@@ -128,20 +139,20 @@
if (data == NULL) {
[[self delegate] MCOMessageView:self fetchDataForPartWithUniqueID:partUniqueID downloadedFinished:^(NSError * error) {
NSData * downloadedData = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID];
- NSData * previewData = [[self delegate] MCOMessageView:self previewForData:downloadedData isHTMLInlineImage:[MCOCIDURLProtocol isCID:url]];
+ NSData * previewData = [[self delegate] MCOMessageView:self previewForData:downloadedData isHTMLInlineImage:[self _isCID:url]];
NSString *filename = [NSString stringWithFormat:@"%lu", (unsigned long)urlString.hash];
NSURL *cacheURL = [self _cacheJPEGImageData:previewData withFilename:filename];
NSString *replaceScript = [NSString stringWithFormat:@"replaceImageSrc(\"%@\", \"%@\")", urlString, cacheURL.absoluteString];
[_webView stringByEvaluatingJavaScriptFromString:replaceScript];
- [MCOCIDURLProtocol partDownloadedMessage:_message partUniqueID:partUniqueID data:previewData];
+ //[MCOCIDURLProtocol partDownloadedMessage:_message partUniqueID:partUniqueID data:previewData];
}];
}
- [MCOCIDURLProtocol startLoadingWithMessage:_message
- partUniqueID:partUniqueID
- data:data
- request:nil];
+// [MCOCIDURLProtocol startLoadingWithMessage:_message
+// partUniqueID:partUniqueID
+// data:data
+// request:nil];
}
}
@@ -185,65 +196,15 @@
[webView loadRequest:responseRequest];
return NO;
}
-
}
- (NSURLRequest *)webView:(UIWebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(id)dataSource
-{
- MCOAbstractPart * part = NULL;
-
+{
if ([[[request URL] scheme] isEqualToString:@"x-mailcore-msgviewloaded"]) {
[self _loadImages];
- return request;
- }
-
- if ([MCOCIDURLProtocol isCID:[request URL]]) {
- part = [self _partForCIDURL:[request URL]];
- }
- else if ([MCOCIDURLProtocol isXMailcoreImage:[ request URL]]) {
- NSString * specifier = [[request URL] resourceSpecifier];
- NSString * partUniqueID = specifier;
- part = [self _partForUniqueID:partUniqueID];
- }
-
- if (part != NULL) {
- if ([_message isKindOfClass:[MCOIMAPMessage class]]) {
- NSMutableURLRequest * mutableRequest = [request mutableCopy];
- NSString * partUniqueID = [part uniqueID];
- NSData * data = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID];
- if (data == NULL) {
- [[self delegate] MCOMessageView:self fetchDataForPartWithUniqueID:partUniqueID downloadedFinished:^(NSError * error) {
- NSData * downloadedData = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID];
- NSData * previewData = [[self delegate] MCOMessageView:self previewForData:downloadedData isHTMLInlineImage:[MCOCIDURLProtocol isCID:[request URL]]];
- [MCOCIDURLProtocol partDownloadedMessage:_message partUniqueID:partUniqueID data:previewData];
- }];
- }
- [MCOCIDURLProtocol startLoadingWithMessage:_message
- partUniqueID:partUniqueID
- data:data
- request:mutableRequest];
-
- return mutableRequest;
- }
- else if ([_message isKindOfClass:[MCOMessageParser class]]) {
- NSMutableURLRequest * mutableRequest = [request mutableCopy];
- NSString * partUniqueID = [part uniqueID];
- NSData * data = [(MCOAttachment *) part data];
- NSData * previewData = [[self delegate] MCOMessageView:self previewForData:data isHTMLInlineImage:[MCOCIDURLProtocol isCID:[request URL]]];
- [MCOCIDURLProtocol startLoadingWithMessage:_message
- partUniqueID:partUniqueID
- data:previewData
- request:mutableRequest];
-
- return mutableRequest;
- }
- else {
- return request;
- }
- }
- else {
- return request;
}
+
+ return request;
}
- (BOOL) MCOAbstractMessage:(MCOAbstractMessage *)msg canPreviewPart:(MCOAbstractPart *)part