Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 817197d390 | |||
| 1246cdd99a | |||
| b465d1bd3e | |||
| e4a4b6091a | |||
| 1e18a6b4dd | |||
| 3732a9769e | |||
| 6a4cd6a255 | |||
| 33069f8df1 | |||
| 1d4ee055d3 | |||
| b85d0934c8 | |||
| 7b03944277 | |||
| 8268e84803 | |||
| c215161f81 | |||
| 78a4b47019 | |||
| e1a9f74a4c | |||
| 39e7a13614 | |||
| 8913c60fe2 | |||
| 66618c90ef | |||
| 34751e29f3 | |||
| e58612d790 | |||
| 72def8c7c8 | |||
| f75d94f68e | |||
| 68b3518822 | |||
| 55c2017fab | |||
| 1b20901351 | |||
| b048483811 | |||
| d44138be77 | |||
| d716226a79 | |||
| 66a851115d | |||
| dd2ad745e7 | |||
| 6bb4d1ca84 | |||
| e6d5e8648e | |||
| 905bf5aeaa | |||
| 814478c94d | |||
| 8fb4ed3bbe | |||
| e22a886fbe | |||
| 73380c7541 | |||
| 2e1e550483 | |||
| 1169458c58 | |||
| 3a5e94af79 | |||
| 2d6e895593 | |||
| 00d390c35e | |||
| 1e8a68c08b | |||
| e22aca18fc | |||
| f9f2b930d8 | |||
| 8e7d1c50d6 | |||
| 28aa229fdd | |||
| b74d05fcfb | |||
| ee1760ebaf | |||
| a0bd47f488 | |||
| 15fe9c9210 | |||
| b52df2d647 | |||
| 95861d3764 | |||
| 0c096356c0 | |||
| d5b029aa80 | |||
| bc90b0946f | |||
| 6a7c75bbeb | |||
| 7883a1b021 | |||
| 1934f9cd51 | |||
| fc5c8a324e | |||
| dcd20b44d7 | |||
| b5fee7f1c9 | |||
| c98f744b1b | |||
| 7565fd2e46 | |||
| d28da84cfd | |||
| d3bf550e1d | |||
| 9c6c77e15b | |||
| 1e5dbbbd19 | |||
| d9a69fe3c7 | |||
| 1ce31638f1 | |||
| 2eeb378cf3 | |||
| 80011253ef | |||
| 3449724ef5 | |||
| 5515f5c5d2 | |||
| 50f14d03f4 | |||
| 405965d4a8 | |||
| e452c5c34d | |||
| a608925308 |
@@ -4,3 +4,4 @@ xcuserdata
|
||||
.DS_Store
|
||||
include/
|
||||
.idea
|
||||
TestData/account.plist
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[submodule "libetpan"]
|
||||
path = libetpan
|
||||
url = https://github.com/mronge/libetpan.git
|
||||
url = https://github.com/dinhviethoa/libetpan.git
|
||||
[submodule "iOSPorts"]
|
||||
path = iOSPorts
|
||||
url = https://github.com/mronge/iOSPorts.git
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
[msg setBody:body.stringValue];
|
||||
|
||||
BOOL auth = ([useAuth state] == NSOnState);
|
||||
BOOL tls = ([useTLS state] == NSOnState);
|
||||
CTSMTPConnectionType connectionType = CTSMTPConnectionTypePlain;
|
||||
if ([useTLS state] == NSOnState) {
|
||||
connectionType = CTSMTPConnectionTypeStartTLS;
|
||||
}
|
||||
|
||||
NSString *serverValue = server.stringValue;
|
||||
NSString *usernameValue = username.stringValue;
|
||||
@@ -27,8 +30,14 @@
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
NSError *error;
|
||||
BOOL success = [CTSMTPConnection sendMessage:msg server:serverValue username:usernameValue
|
||||
password:passwordValue port:portValue useTLS:tls useAuth:auth error:&error];
|
||||
BOOL success = [CTSMTPConnection sendMessage:msg
|
||||
server:serverValue
|
||||
username:usernameValue
|
||||
password:passwordValue
|
||||
port:portValue
|
||||
connectionType:connectionType
|
||||
useAuth:auth
|
||||
error:&error];
|
||||
if (!success) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[NSApp presentError:error];
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
2D538B46119803A6000AB4A2 /* CTSMTPAsyncConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D538B43119803A6000AB4A2 /* CTSMTPAsyncConnection.m */; };
|
||||
2D538B48119803E2000AB4A2 /* CTSMTPAsyncConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D538B43119803A6000AB4A2 /* CTSMTPAsyncConnection.m */; };
|
||||
8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
|
||||
F80A105917A576910063BCD2 /* libetpan-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F80A105117A573A50063BCD2 /* libetpan-ios.a */; };
|
||||
F81A8ADC0C03FC3B002F780A /* CTMIME_MessagePart.h in Headers */ = {isa = PBXBuildFile; fileRef = F81A8AD20C03FC3B002F780A /* CTMIME_MessagePart.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F81A8ADD0C03FC3B002F780A /* CTMIME_MessagePart.m in Sources */ = {isa = PBXBuildFile; fileRef = F81A8AD30C03FC3B002F780A /* CTMIME_MessagePart.m */; };
|
||||
F81A8ADE0C03FC3B002F780A /* CTMIME_MultiPart.h in Headers */ = {isa = PBXBuildFile; fileRef = F81A8AD40C03FC3B002F780A /* CTMIME_MultiPart.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -44,6 +45,7 @@
|
||||
F81E266F0C6ED4E100B3FBAC /* CTCoreAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = F81E266D0C6ED4E100B3FBAC /* CTCoreAttachment.m */; };
|
||||
F8245A6D0C041C8C005E08A8 /* CTMIMEFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F8245A2F0C04089D005E08A8 /* CTMIMEFactory.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F8245A700C041C91005E08A8 /* CTMIMEFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = F8245A300C04089D005E08A8 /* CTMIMEFactory.m */; };
|
||||
F82AA54116F26F2300BF76A8 /* CTXlistResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F369D01162DF5030043A3ED /* CTXlistResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F8430BB10C72B16000753941 /* CTMIME_Enumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = F8430BAF0C72B16000753941 /* CTMIME_Enumerator.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F8430BB20C72B16000753941 /* CTMIME_Enumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = F8430BB00C72B16000753941 /* CTMIME_Enumerator.m */; };
|
||||
F8483E4109CE7B9000B80440 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F8483E4009CE7B9000B80440 /* libssl.dylib */; };
|
||||
@@ -97,29 +99,59 @@
|
||||
F888630C158102660088CF38 /* CTCoreAddressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EA76120C1141C1004F85D8 /* CTCoreAddressTests.m */; };
|
||||
F888630D158102680088CF38 /* CTCoreMessageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EADFB40B3BB178000C8371 /* CTCoreMessageTests.m */; };
|
||||
F888630E1581026A0088CF38 /* CTMIMETests.m in Sources */ = {isa = PBXBuildFile; fileRef = F81A8AEC0C03FC58002F780A /* CTMIMETests.m */; };
|
||||
F8886336158103080088CF38 /* libsasl2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8886333158102F50088CF38 /* libsasl2.a */; };
|
||||
F8886338158103250088CF38 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8886337158103250088CF38 /* CFNetwork.framework */; };
|
||||
F8886345158103500088CF38 /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8886340158103460088CF38 /* libssl.a */; };
|
||||
F8886346158103610088CF38 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8886342158103460088CF38 /* libcrypto.a */; };
|
||||
F88CA0CE0BF7A7B00055AC29 /* CTSMTP.h in Headers */ = {isa = PBXBuildFile; fileRef = F88CA0CC0BF7A7B00055AC29 /* CTSMTP.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F88CA0CF0BF7A7B00055AC29 /* CTSMTP.m in Sources */ = {isa = PBXBuildFile; fileRef = F88CA0CD0BF7A7B00055AC29 /* CTSMTP.m */; };
|
||||
F88CA0D40BF7AC0B0055AC29 /* CTESMTP.h in Headers */ = {isa = PBXBuildFile; fileRef = F88CA0D20BF7AC0B0055AC29 /* CTESMTP.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F88CA0D50BF7AC0B0055AC29 /* CTESMTP.m in Sources */ = {isa = PBXBuildFile; fileRef = F88CA0D30BF7AC0B0055AC29 /* CTESMTP.m */; };
|
||||
F8B245CE144BAC15002B56DA /* libetpan_ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8B245CA144BABA4002B56DA /* libetpan_ios.a */; };
|
||||
F8B6D4F0156EE189008DE9EB /* libetpan_mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8B6D4EC156EE173008DE9EB /* libetpan_mac.a */; };
|
||||
F8DFCF4C15801A5000C01975 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8DFCF4B15801A5000C01975 /* SenTestingKit.framework */; };
|
||||
F8DFCF4E15801A5000C01975 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8DFCF4D15801A5000C01975 /* UIKit.framework */; };
|
||||
F8DFCF5015801A5000C01975 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8DFCF4F15801A5000C01975 /* Foundation.framework */; };
|
||||
F8DFCF5615801A5000C01975 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F8DFCF5415801A5000C01975 /* InfoPlist.strings */; };
|
||||
F8DFCF7415801B3500C01975 /* libetpan_ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8B245CA144BABA4002B56DA /* libetpan_ios.a */; };
|
||||
F8EC5B0314C37F60006AF4D3 /* CTMIME_HtmlPart.h in Headers */ = {isa = PBXBuildFile; fileRef = F8EC5B0114C37F60006AF4D3 /* CTMIME_HtmlPart.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F8EC5B0414C37F60006AF4D3 /* CTMIME_HtmlPart.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0214C37F60006AF4D3 /* CTMIME_HtmlPart.m */; };
|
||||
F8EC5B0514C37F60006AF4D3 /* CTMIME_HtmlPart.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0214C37F60006AF4D3 /* CTMIME_HtmlPart.m */; };
|
||||
F8EC5B0514C37F60006AF4D5 /* CTConnectedTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0514C37F60006AF4D4 /* CTConnectedTest.m */; };
|
||||
F8EC5B0514C37F60006AF4D8 /* CTCoreFolderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0514C37F60006AF4D7 /* CTCoreFolderTests.m */; };
|
||||
F9FC3A731683FC07004B2D1E /* TestData in Resources */ = {isa = PBXBuildFile; fileRef = F9FC3A721683FC07004B2D1E /* TestData */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
F80A104E17A573A50063BCD2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = C69AB10A10546FE500F32FBD;
|
||||
remoteInfo = "static libetpan";
|
||||
};
|
||||
F80A105017A573A50063BCD2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = C682E2C015B315EF00BE9DA7;
|
||||
remoteInfo = "libetpan ios";
|
||||
};
|
||||
F80A105317A573AD0063BCD2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = C682E21815B315EF00BE9DA7;
|
||||
remoteInfo = "libetpan ios";
|
||||
};
|
||||
F80A105517A575D00063BCD2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = C682E21815B315EF00BE9DA7;
|
||||
remoteInfo = "libetpan ios";
|
||||
};
|
||||
F80A105717A575D80063BCD2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = C69AB10910546FE500F32FBD;
|
||||
remoteInfo = "static libetpan";
|
||||
};
|
||||
F88863041581019F0088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
@@ -127,48 +159,6 @@
|
||||
remoteGlobalIDString = F8618B5610DADB5C00C41188;
|
||||
remoteInfo = "MailCore iOS";
|
||||
};
|
||||
F8886332158102F50088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = D2AAC07E0554694100DB518D;
|
||||
remoteInfo = sasl2;
|
||||
};
|
||||
F8886334158102FD0088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = D2AAC07D0554694100DB518D;
|
||||
remoteInfo = sasl2;
|
||||
};
|
||||
F888633F158103460088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F8886339158103460088CF38 /* openssl.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = D2AAC07E0554694100DB518D;
|
||||
remoteInfo = ssl;
|
||||
};
|
||||
F8886341158103460088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F8886339158103460088CF38 /* openssl.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = A0511C5A127770FD00DE46C4;
|
||||
remoteInfo = crypto;
|
||||
};
|
||||
F88863431581034C0088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F8886339158103460088CF38 /* openssl.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = D2AAC07D0554694100DB518D;
|
||||
remoteInfo = ssl;
|
||||
};
|
||||
F8886347158103630088CF38 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F8886339158103460088CF38 /* openssl.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = A0511C51127770FD00DE46C4;
|
||||
remoteInfo = crypto;
|
||||
};
|
||||
F890D39510CEECD50039817C /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
@@ -176,41 +166,6 @@
|
||||
remoteGlobalIDString = 8DC2EF5B0486A6940098B216;
|
||||
remoteInfo = libetpan;
|
||||
};
|
||||
F8B245C9144BABA4002B56DA /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = F8B2455E144B8C48002B56DA;
|
||||
remoteInfo = "static libetpan iOS";
|
||||
};
|
||||
F8B245CC144BAC04002B56DA /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = F8B244B6144B8C48002B56DA;
|
||||
remoteInfo = "static libetpan iOS";
|
||||
};
|
||||
F8B6D4EB156EE173008DE9EB /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = F8B6D4CC156EE0B6008DE9EB;
|
||||
remoteInfo = "static libetpan Mac";
|
||||
};
|
||||
F8B6D4EE156EE183008DE9EB /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = F8B6D422156EE0B6008DE9EB;
|
||||
remoteInfo = "static libetpan Mac";
|
||||
};
|
||||
F8DFCF7E15801B8200C01975 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = F8B244B6144B8C48002B56DA;
|
||||
remoteInfo = "static libetpan iOS";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -270,9 +225,7 @@
|
||||
F88804D50B4243C000D400E7 /* MailCoreUtilities.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MailCoreUtilities.h; path = Source/MailCoreUtilities.h; sourceTree = SOURCE_ROOT; };
|
||||
F88804D60B4243C000D400E7 /* MailCoreUtilities.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MailCoreUtilities.m; path = Source/MailCoreUtilities.m; sourceTree = SOURCE_ROOT; };
|
||||
F88863091581023C0088CF38 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libiconv.dylib; sourceTree = DEVELOPER_DIR; };
|
||||
F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Cyrus SASL.xcodeproj"; path = "iOSPorts/ports/security/cyrus-sasl/Cyrus SASL.xcodeproj"; sourceTree = "<group>"; };
|
||||
F8886337158103250088CF38 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; };
|
||||
F8886339158103460088CF38 /* openssl.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = openssl.xcodeproj; path = iOSPorts/ports/security/openssl/openssl.xcodeproj; sourceTree = "<group>"; };
|
||||
F88CA0CC0BF7A7B00055AC29 /* CTSMTP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTSMTP.h; path = Source/CTSMTP.h; sourceTree = "<group>"; };
|
||||
F88CA0CD0BF7A7B00055AC29 /* CTSMTP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTSMTP.m; path = Source/CTSMTP.m; sourceTree = "<group>"; };
|
||||
F88CA0D20BF7AC0B0055AC29 /* CTESMTP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTESMTP.h; path = Source/CTESMTP.h; sourceTree = "<group>"; };
|
||||
@@ -298,6 +251,7 @@
|
||||
F8EC5B0514C37F60006AF4D6 /* CTConnectedTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTConnectedTest.h; path = Tests/CTConnectedTest.h; sourceTree = "<group>"; };
|
||||
F8EC5B0514C37F60006AF4D7 /* CTCoreFolderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTCoreFolderTests.m; path = Tests/CTCoreFolderTests.m; sourceTree = "<group>"; };
|
||||
F8EC5B0514C37F60006AF4D9 /* CTCoreFolderTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTCoreFolderTests.h; path = Tests/CTCoreFolderTests.h; sourceTree = "<group>"; };
|
||||
F9FC3A721683FC07004B2D1E /* TestData */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestData; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -305,7 +259,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8B6D4F0156EE189008DE9EB /* libetpan_mac.a in Frameworks */,
|
||||
8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */,
|
||||
F8483E4109CE7B9000B80440 /* libssl.dylib in Frameworks */,
|
||||
F8483E4309CE7B9C00B80440 /* libiconv.dylib in Frameworks */,
|
||||
@@ -318,7 +271,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8B245CE144BAC15002B56DA /* libetpan_ios.a in Frameworks */,
|
||||
F80A105917A576910063BCD2 /* libetpan-ios.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -326,13 +279,9 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8886346158103610088CF38 /* libcrypto.a in Frameworks */,
|
||||
F8886345158103500088CF38 /* libssl.a in Frameworks */,
|
||||
F8886338158103250088CF38 /* CFNetwork.framework in Frameworks */,
|
||||
F8886336158103080088CF38 /* libsasl2.a in Frameworks */,
|
||||
F888630A1581023C0088CF38 /* libiconv.dylib in Frameworks */,
|
||||
F8886306158101A50088CF38 /* libmailcore.a in Frameworks */,
|
||||
F8DFCF7415801B3500C01975 /* libetpan_ios.a in Frameworks */,
|
||||
F8DFCF4C15801A5000C01975 /* SenTestingKit.framework in Frameworks */,
|
||||
F8DFCF4E15801A5000C01975 /* UIKit.framework in Frameworks */,
|
||||
F8DFCF5015801A5000C01975 /* Foundation.framework in Frameworks */,
|
||||
@@ -355,10 +304,9 @@
|
||||
0867D691FE84028FC02AAC07 /* MailCore */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8886339158103460088CF38 /* openssl.xcodeproj */,
|
||||
F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */,
|
||||
F890D38D10CEECD50039817C /* libetpan.xcodeproj */,
|
||||
F85A18AF09C7D8F200305C06 /* Tests */,
|
||||
F9FC3A721683FC07004B2D1E /* TestData */,
|
||||
08FB77AEFE84172EC02AAC07 /* Classes */,
|
||||
32C88DFF0371C24200C91783 /* Other Sources */,
|
||||
089C1665FE841158C02AAC07 /* Resources */,
|
||||
@@ -509,29 +457,12 @@
|
||||
name = Tests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F888632E158102F50088CF38 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8886333158102F50088CF38 /* libsasl2.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F888633A158103460088CF38 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8886340158103460088CF38 /* libssl.a */,
|
||||
F8886342158103460088CF38 /* libcrypto.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F890D39010CEECD50039817C /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F890D39610CEECD50039817C /* libetpan.framework */,
|
||||
F8B245CA144BABA4002B56DA /* libetpan_ios.a */,
|
||||
F8B6D4EC156EE173008DE9EB /* libetpan_mac.a */,
|
||||
F80A104F17A573A50063BCD2 /* libetpan.a */,
|
||||
F80A105117A573A50063BCD2 /* libetpan-ios.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -614,6 +545,7 @@
|
||||
F86B542314F476170080FB8F /* CTSMTPConnection.h in Headers */,
|
||||
F86B542414F4761C0080FB8F /* CTSMTPAsyncConnection.h in Headers */,
|
||||
F86B542514F4761E0080FB8F /* CTSMTP.h in Headers */,
|
||||
F82AA54116F26F2300BF76A8 /* CTXlistResult.h in Headers */,
|
||||
F86B542614F476200080FB8F /* CTESMTP.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -635,7 +567,7 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
F8B6D4EF156EE183008DE9EB /* PBXTargetDependency */,
|
||||
F80A105817A575D80063BCD2 /* PBXTargetDependency */,
|
||||
);
|
||||
name = MailCore;
|
||||
productInstallPath = "$(HOME)/Library/Frameworks";
|
||||
@@ -654,7 +586,7 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
F8B245CD144BAC04002B56DA /* PBXTargetDependency */,
|
||||
F80A105617A575D00063BCD2 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "MailCore iOS";
|
||||
productName = "MailCore iPhone";
|
||||
@@ -673,11 +605,8 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
F8886348158103630088CF38 /* PBXTargetDependency */,
|
||||
F88863441581034C0088CF38 /* PBXTargetDependency */,
|
||||
F8886335158102FD0088CF38 /* PBXTargetDependency */,
|
||||
F80A105417A573AD0063BCD2 /* PBXTargetDependency */,
|
||||
F88863051581019F0088CF38 /* PBXTargetDependency */,
|
||||
F8DFCF7F15801B8200C01975 /* PBXTargetDependency */,
|
||||
);
|
||||
name = Tests;
|
||||
productName = Tests;
|
||||
@@ -703,18 +632,10 @@
|
||||
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = F888632E158102F50088CF38 /* Products */;
|
||||
ProjectRef = F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = F890D39010CEECD50039817C /* Products */;
|
||||
ProjectRef = F890D38D10CEECD50039817C /* libetpan.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = F888633A158103460088CF38 /* Products */;
|
||||
ProjectRef = F8886339158103460088CF38 /* openssl.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = ..;
|
||||
targets = (
|
||||
@@ -726,25 +647,18 @@
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
F8886333158102F50088CF38 /* libsasl2.a */ = {
|
||||
F80A104F17A573A50063BCD2 /* libetpan.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libsasl2.a;
|
||||
remoteRef = F8886332158102F50088CF38 /* PBXContainerItemProxy */;
|
||||
path = libetpan.a;
|
||||
remoteRef = F80A104E17A573A50063BCD2 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F8886340158103460088CF38 /* libssl.a */ = {
|
||||
F80A105117A573A50063BCD2 /* libetpan-ios.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libssl.a;
|
||||
remoteRef = F888633F158103460088CF38 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F8886342158103460088CF38 /* libcrypto.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libcrypto.a;
|
||||
remoteRef = F8886341158103460088CF38 /* PBXContainerItemProxy */;
|
||||
path = "libetpan-ios.a";
|
||||
remoteRef = F80A105017A573A50063BCD2 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F890D39610CEECD50039817C /* libetpan.framework */ = {
|
||||
@@ -754,20 +668,6 @@
|
||||
remoteRef = F890D39510CEECD50039817C /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F8B245CA144BABA4002B56DA /* libetpan_ios.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libetpan_ios.a;
|
||||
remoteRef = F8B245C9144BABA4002B56DA /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F8B6D4EC156EE173008DE9EB /* libetpan_mac.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libetpan_mac.a;
|
||||
remoteRef = F8B6D4EB156EE173008DE9EB /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
@@ -784,6 +684,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8DFCF5615801A5000C01975 /* InfoPlist.strings in Resources */,
|
||||
F9FC3A731683FC07004B2D1E /* TestData in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -903,41 +804,26 @@
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
F80A105417A573AD0063BCD2 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "libetpan ios";
|
||||
targetProxy = F80A105317A573AD0063BCD2 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F80A105617A575D00063BCD2 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "libetpan ios";
|
||||
targetProxy = F80A105517A575D00063BCD2 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F80A105817A575D80063BCD2 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "static libetpan";
|
||||
targetProxy = F80A105717A575D80063BCD2 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F88863051581019F0088CF38 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = F8618B5610DADB5C00C41188 /* MailCore iOS */;
|
||||
targetProxy = F88863041581019F0088CF38 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F8886335158102FD0088CF38 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = sasl2;
|
||||
targetProxy = F8886334158102FD0088CF38 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F88863441581034C0088CF38 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = ssl;
|
||||
targetProxy = F88863431581034C0088CF38 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F8886348158103630088CF38 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = crypto;
|
||||
targetProxy = F8886347158103630088CF38 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F8B245CD144BAC04002B56DA /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "static libetpan iOS";
|
||||
targetProxy = F8B245CC144BAC04002B56DA /* PBXContainerItemProxy */;
|
||||
};
|
||||
F8B6D4EF156EE183008DE9EB /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "static libetpan Mac";
|
||||
targetProxy = F8B6D4EE156EE183008DE9EB /* PBXContainerItemProxy */;
|
||||
};
|
||||
F8DFCF7F15801B8200C01975 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = "static libetpan iOS";
|
||||
targetProxy = F8DFCF7E15801B8200C01975 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
@@ -971,6 +857,7 @@
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = MailCore_Prefix.pch;
|
||||
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/libetpan/build-mac/include/**";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "@loader_path/../Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
@@ -1006,6 +893,7 @@
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = MailCore_Prefix.pch;
|
||||
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/libetpan/build-mac/include/**";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "@loader_path/../Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
@@ -1033,6 +921,7 @@
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "libetpan/build-mac/include/**";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
@@ -1049,6 +938,7 @@
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "libetpan/build-mac/include/**";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
@@ -1058,10 +948,18 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
||||
HEADER_SEARCH_PATHS = "$BUILT_PRODUCTS_DIR/include/libetpan/**";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"/Users/mronge/Projects/virtru-ios-mail/MailCore/Prebuilt/libetpan-ios/lib",
|
||||
"/Users/mronge/Projects/virtru-ios-mail/MailCore/Prebuilt/libsasl-ios/lib",
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
PRIVATE_HEADERS_FOLDER_PATH = ../../include/MailCore/Private;
|
||||
PRODUCT_NAME = mailcore;
|
||||
@@ -1075,9 +973,17 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
||||
HEADER_SEARCH_PATHS = "$BUILT_PRODUCTS_DIR/include/libetpan/**";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"/Users/mronge/Projects/virtru-ios-mail/MailCore/Prebuilt/libetpan-ios/lib",
|
||||
"/Users/mronge/Projects/virtru-ios-mail/MailCore/Prebuilt/libsasl-ios/lib",
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
PRIVATE_HEADERS_FOLDER_PATH = ../../include/MailCore/Private;
|
||||
PRODUCT_NAME = mailcore;
|
||||
@@ -1111,7 +1017,7 @@
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
INFOPLIST_FILE = "Tests/Tests-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/iOSPorts/ports/security/cyrus-sasl/build/Debug-iphoneos\"",
|
||||
@@ -1138,7 +1044,7 @@
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
INFOPLIST_FILE = "Tests/Tests-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/iOSPorts/ports/security/cyrus-sasl/build/Debug-iphoneos\"",
|
||||
|
||||
@@ -5,7 +5,34 @@
|
||||
\/_/ \/_/ \/_/\/_/ \/_/ \/_____/ \/_____/ \/_____/ \/_/ /_/ \/_____/
|
||||
|
||||
|
||||
##Getting the code
|
||||
## What is MailCore
|
||||
|
||||
MailCore is a Mac and iOS library designed to ease the pain of dealing with e-mail protocols. MailCore makes the process of sending e-mail easy by hiding the nasty details like MIME composition from you. Instead, there is a single method required to send a message. Checking e-mail on an IMAP server is a more complex beast, but MailCore makes the job much simpler by presenting everything as a set of objects like Messages, Folders and Accounts.
|
||||
|
||||
## Example
|
||||
|
||||
This example shows how you can send email using MailCore.
|
||||
|
||||
```obj-c
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] init];
|
||||
CTCoreAddress *toAddress = [CTCoreAddress addressWithName:@"Monkey"
|
||||
email:@"monkey@monkey.com"];
|
||||
[msg setTo:[NSSet setWithObject:toAddress]];
|
||||
[msg setBody:@"This is a test message!"];
|
||||
|
||||
NSError *error;
|
||||
BOOL success = [CTSMTPConnection sendMessage:testMsg
|
||||
server:@"mail.test.com"
|
||||
username:@"test"
|
||||
password:@"test"
|
||||
port:587
|
||||
connectionType:CTSMTPConnectionTypeStartTLS
|
||||
useAuth:YES
|
||||
error:&error];
|
||||
```
|
||||
|
||||
|
||||
## Getting the code
|
||||
|
||||
First checkout the code and pulldown the required dependencies as submodules:
|
||||
|
||||
@@ -15,13 +42,45 @@ First checkout the code and pulldown the required dependencies as submodules:
|
||||
|
||||
Now open up MailCore.xcodeproj and build either the iOS static library or the Mac OS X framework depending on your needs.
|
||||
|
||||
##Website
|
||||
## Adding MailCore to Your iOS Project
|
||||
|
||||
The official site contains documentation, FAQs, and step by step instructions on how to include MailCore
|
||||
1. First checkout the latest code and make sure you get the required submodules
|
||||
2. Locate MailCore.xcodeproj and add it to your project as a subproject. You can do this by dragging the Mailcore.xcodeproj file into your Xcode project.
|
||||
3. Navigate to your app’s target and switch to your app’s Build Phases. Once in Build Phases expand “Link Binary With Libraries” and click the + button. And add these libraries:
|
||||
```
|
||||
libmailcore.a
|
||||
libssl.a
|
||||
libsasl2.a
|
||||
libcrypto.a
|
||||
libiconv.dylib
|
||||
CFNetwork.framework
|
||||
```
|
||||
|
||||
http://www.libmailcore.com
|
||||
4. Add “MailCore iOS” under “Target Dependencies”
|
||||
5. Under your app’s target, switch to Build Settings. Locate “Header Search Paths” in the Build Settings and add `"$(BUILT_PRODUCTS_DIR)/../../include"`
|
||||
6. You are now ready to use MailCore. To use MailCore add `#import <MailCore/MailCore.h>` to the top of your Objective-C files.
|
||||
|
||||
## Adding MailCore to Your Mac Project
|
||||
|
||||
1. First checkout the latest code and make sure you get the required submodules
|
||||
2. Locate MailCore.xcodeproj and add it to your project as a subproject. You can do this by dragging the Mailcore.xcodeproj file into your Xcode project.
|
||||
3. Navigate to your app’s target and switch to your app’s Build Phases. Once in Build Phases expand “Link Binary With Libraries” and click the + button. From there add MailCore.framework.
|
||||
4. While still under Build Phases click “Add Build Phase” in the lower right and select “Add Copy Files”. A new copy files phase will be added, make sure the destination is set to “Frameworks”. Now add MailCore.framework to that copy files phase by using the + button.
|
||||
5. Add “MailCore” under “Target Dependencies”
|
||||
6. You are now ready to use MailCore. To use MailCore add `#import <MailCore/MailCore.h>` to the top of your Objective-C files.
|
||||
|
||||
## More Docs
|
||||
|
||||
* [Getting Started](https://github.com/MailCore/MailCore/wiki/Getting-Started)
|
||||
* [FAQ](https://github.com/MailCore/MailCore/wiki/FAQ)
|
||||
* [API Docs](http://libmailcore.com/api/)
|
||||
* [Wiki](https://github.com/MailCore/MailCore/wiki)
|
||||
|
||||
## Consulting
|
||||
|
||||
Consulting services are available via [Astro HQ](http://www.astro-hq.com). At Astro HQ we have years of experience working on email apps. If you need custom e-mail functionality developed, please get in touch via our website.
|
||||
|
||||
Thanks,
|
||||
|
||||
Matt Ronge
|
||||
[@mronge](http://www.twitter.com/mronge)
|
||||
[@mronge](http://www.twitter.com/mronge)
|
||||
|
||||
@@ -316,6 +316,9 @@
|
||||
for (flagIter = clist_begin(flags->mbf_oflags); flagIter != NULL; flagIter = flagIter->next) {
|
||||
oflagStruct = flagIter->data;
|
||||
flagName = oflagStruct->of_flag_ext;
|
||||
if (flagName == NULL && oflagStruct->of_type == MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
|
||||
flagName = "NoInferiors";
|
||||
}
|
||||
flagNameObject = (NSString *)CFStringCreateWithCString(NULL, flagName, kCFStringEncodingUTF7_IMAP);
|
||||
[listResult addFlag:flagNameObject];
|
||||
[flagNameObject release];
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@,%@>", [self name],[self email]];
|
||||
return [NSString stringWithFormat:@"%@ <%@>", [self name],[self email]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
+60
-6
@@ -92,12 +92,12 @@
|
||||
This method take fetch attributes which configure what is fetched. Fetch attributes can be combined
|
||||
so you fetch all the message data at once, or select which pieces you want for your app. You can
|
||||
also fetch just the default attributes which will be as fast as possible. Pass in
|
||||
CTFetchAttrDefaultsOnly to attrs fetch the minimum possible, this includes the UID, RFC822.size, and
|
||||
CTFetchAttrDefaultsOnly to attrs fetch the minimum possible, this includes the UID and
|
||||
flags. The defaults are always fetched, even when you don't pass in this flag. Use
|
||||
CTFetchAttrBodyStructure to also fetch the body structure of the message. This prevents a future
|
||||
round trip done by [CTCoreMessage fetchBodyStructure], if it sees you already have the body
|
||||
structure it won't re-fetch it. Use CTFetchAttrEnvelope if you'd like to fetch the subject, to,
|
||||
from, cc, bcc, sender, date etc. You can also fetch both the envelope and body structure by passing
|
||||
from, cc, bcc, sender, date, size, etc. You can also fetch both the envelope and body structure by passing
|
||||
in CTFetchAttrEnvelope | CTFetchAttrBodyStructure
|
||||
|
||||
|
||||
@@ -121,6 +121,35 @@
|
||||
*/
|
||||
- (NSArray *)messagesFromUID:(NSUInteger)startUID to:(NSUInteger)endUID withFetchAttributes:(CTFetchAttributes)attrs;
|
||||
|
||||
|
||||
/**
|
||||
Use this method to download message lists from the server.
|
||||
|
||||
This method uses sequence numbers indexset to determine which messages to download.
|
||||
|
||||
@param sequenceNumbers The indexset of sequence numbers to load.
|
||||
@param attrs This controls what is fetched.
|
||||
@return Returns a NSArray of CTCoreMessage's. Returns nil on error
|
||||
@see messagesFromSequenceNumber:to:withFetchAttributes:
|
||||
*/
|
||||
- (NSArray *)messagesWithSequenceNumbers:(NSIndexSet *)sequenceNumbers
|
||||
fetchAttributes:(CTFetchAttributes)attrs;
|
||||
|
||||
|
||||
/**
|
||||
Use this method to download message lists from the server.
|
||||
|
||||
This method uses uid numbers indexset to determine which messages to download.
|
||||
|
||||
@param uidNumbers The indexset of uid numbers to load.
|
||||
@param attrs This controls what is fetched.
|
||||
@return Returns a NSArray of CTCoreMessage's. Returns nil on error
|
||||
@see messagesFromSequenceNumber:to:withFetchAttributes:
|
||||
*/
|
||||
- (NSArray *)messagesWithUIDs:(NSIndexSet *)uidNumbers
|
||||
fetchAttributes:(CTFetchAttributes)attrs;
|
||||
|
||||
|
||||
/**
|
||||
Pulls the sequence number for the message with the specified uid.
|
||||
It does not perform UID validation, and the sequence ID is only
|
||||
@@ -212,6 +241,31 @@
|
||||
*/
|
||||
- (BOOL)setFlags:(NSUInteger)flags forMessage:(CTCoreMessage *)msg;
|
||||
|
||||
/**
|
||||
Retrieves the message extension flags.
|
||||
@return Return YES on success, NO on error. Call method lastError to get error if one occurred
|
||||
*/
|
||||
- (BOOL)extensionFlagsForMessage:(CTCoreMessage *)msg flags:(NSArray **)flags;
|
||||
|
||||
/**
|
||||
Sets the message's extension flags on the server.
|
||||
@return Return YES on success, NO on error. Call method lastError to get error if one occurred
|
||||
*/
|
||||
- (BOOL)setExtensionFlags:(NSArray *)flags forMessage:(CTCoreMessage *)msg;
|
||||
|
||||
/**
|
||||
Retrieves the message's flags and extension flags, take a look at the
|
||||
documentation for flagsForMessage:
|
||||
@return Return YES on success, NO on error. Call method lastError to get error if one occurred
|
||||
*/
|
||||
- (BOOL)flagsForMessage:(CTCoreMessage *)msg flags:(NSUInteger *)flags extensionFlags:(NSArray **)extensionFlags;
|
||||
|
||||
/**
|
||||
Sets the message's flags and extension flags on the server.
|
||||
@return Return YES on success, NO on error. Call method lastError to get error if one occurred
|
||||
*/
|
||||
- (BOOL)setFlags:(NSUInteger)flags extensionFlags:(NSArray *)extensionFlags forMessage:(CTCoreMessage *)msg;
|
||||
|
||||
/**
|
||||
Deletes all messages contained in the folder that are marked for
|
||||
deletion. Deleting messages in IMAP is a little strange, first
|
||||
@@ -235,15 +289,15 @@
|
||||
- (BOOL)moveMessageWithUID:(NSUInteger)uid toPath:(NSString *)path;
|
||||
|
||||
/**
|
||||
Returns the number of unread messages. This causes a round trip to the server, as it fetches
|
||||
the count for each call.
|
||||
Pass in a pointer to a NSUInteger to get the number of unread messages. This causes a round trip to the server,
|
||||
as it fetches the count for each call.
|
||||
@return Return YES on success, NO on error. Call method lastError to get error if one occurred
|
||||
*/
|
||||
- (BOOL)unreadMessageCount:(NSUInteger *)unseenCount;
|
||||
|
||||
/**
|
||||
Returns the number of messages in the folder. The count was retrieved when the folder connection was
|
||||
established, so to refresh the count you must disconnect and reconnect.
|
||||
Pass in a pointer to a NSUInteger to get the number of messages in the folder. The count was retrieved
|
||||
when the folder connection was established, so to refresh the count you must disconnect and reconnect.
|
||||
@return Return YES on success, NO on error. Call method lastError to get error if one occurred
|
||||
*/
|
||||
- (BOOL)totalMessageCount:(NSUInteger *)totalCount;
|
||||
|
||||
+173
-41
@@ -40,6 +40,10 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
NSError* MailCoreCreateStringConvError() {
|
||||
return MailCoreCreateError(1, @"Unable to convert folder name");
|
||||
}
|
||||
|
||||
|
||||
//int imap_fetch_result_to_envelop_list(clist * fetch_result, struct mailmessage_list * env_list);
|
||||
//
|
||||
@@ -64,7 +68,11 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
myAccount = [account retain];
|
||||
|
||||
char buffer[MAX_PATH_SIZE];
|
||||
myFolder = mailfolder_new(storage, [self getUTF7String:buffer fromString:myPath], NULL);
|
||||
if (![self getUTF7String:buffer fromString:myPath]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
myFolder = mailfolder_new(storage, buffer, NULL);
|
||||
if (!myFolder) {
|
||||
return nil;
|
||||
}
|
||||
@@ -85,13 +93,12 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
}
|
||||
|
||||
|
||||
- (const char *)getUTF7String:(char *)buffer fromString:(NSString *)str {
|
||||
if (CFStringGetCString((CFStringRef)str, buffer, MAX_PATH_SIZE, kCFStringEncodingUTF7_IMAP)) {
|
||||
return buffer;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
- (BOOL)getUTF7String:(char *)buffer fromString:(NSString *)str {
|
||||
if (str == nil || buffer == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return CFStringGetCString((CFStringRef)str, buffer, MAX_PATH_SIZE, kCFStringEncodingUTF7_IMAP);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,10 +141,17 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
}
|
||||
|
||||
char newPath[MAX_PATH_SIZE];
|
||||
[self getUTF7String:newPath fromString:path];
|
||||
if (![self getUTF7String:newPath fromString:path]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
|
||||
char oldPath[MAX_PATH_SIZE];
|
||||
[self getUTF7String:newPath fromString:myPath];
|
||||
[self getUTF7String:oldPath fromString:myPath];
|
||||
if (![self getUTF7String:oldPath fromString:myPath]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
|
||||
err = mailimap_rename([myAccount session], oldPath, newPath);
|
||||
|
||||
@@ -246,7 +260,10 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
int err;
|
||||
|
||||
char path[MAX_PATH_SIZE];
|
||||
[self getUTF7String:path fromString:myPath];
|
||||
if (![self getUTF7String:path fromString:myPath]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
|
||||
err = mailimap_create([myAccount session], path);
|
||||
if (err != MAILIMAP_NO_ERROR) {
|
||||
@@ -266,7 +283,10 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
int err;
|
||||
|
||||
char path[MAX_PATH_SIZE];
|
||||
[self getUTF7String:path fromString:myPath];
|
||||
if (![self getUTF7String:path fromString:myPath]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
@@ -290,7 +310,10 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
int err;
|
||||
|
||||
char path[MAX_PATH_SIZE];
|
||||
[self getUTF7String:path fromString:myPath];
|
||||
if (![self getUTF7String:path fromString:myPath]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
@@ -310,7 +333,10 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
int err;
|
||||
|
||||
char path[MAX_PATH_SIZE];
|
||||
[self getUTF7String:path fromString:myPath];
|
||||
if (![self getUTF7String:path fromString:myPath]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
@@ -330,9 +356,15 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
NSString *msgStr = [msg render];
|
||||
if (![self connect])
|
||||
return NO;
|
||||
err = mailsession_append_message ([self folderSession],
|
||||
|
||||
struct mail_flags *flags = mail_flags_new(MAIL_FLAG_SEEN, clist_new());
|
||||
|
||||
err = mailsession_append_message_flags([self folderSession],
|
||||
[msgStr cStringUsingEncoding: NSUTF8StringEncoding],
|
||||
[msgStr lengthOfBytesUsingEncoding: NSUTF8StringEncoding]);
|
||||
[msgStr lengthOfBytesUsingEncoding: NSUTF8StringEncoding],
|
||||
flags);
|
||||
|
||||
mail_flags_free(flags);
|
||||
if (MAILIMAP_NO_ERROR != err)
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode (err);
|
||||
return MAILIMAP_NO_ERROR == err;
|
||||
@@ -427,7 +459,7 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
return YES;
|
||||
}
|
||||
|
||||
// We always fetch UID, RFC822.Size, and Flags
|
||||
// We always fetch UID and Flags
|
||||
- (NSArray *)messagesForSet:(struct mailimap_set *)set fetchAttributes:(CTFetchAttributes)attrs uidFetch:(BOOL)uidFetch {
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
@@ -464,14 +496,16 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Always fetch RFC822.Size
|
||||
fetch_att = mailimap_fetch_att_new_rfc822_size();
|
||||
r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
|
||||
if (r != MAILIMAP_NO_ERROR) {
|
||||
mailimap_fetch_att_free(fetch_att);
|
||||
mailimap_fetch_type_free(fetch_type);
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(r);
|
||||
return nil;
|
||||
// We only fetch RFC822.Size if the envelope is being fetched
|
||||
if (attrs & CTFetchAttrEnvelope) {
|
||||
fetch_att = mailimap_fetch_att_new_rfc822_size();
|
||||
r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
|
||||
if (r != MAILIMAP_NO_ERROR) {
|
||||
mailimap_fetch_att_free(fetch_att);
|
||||
mailimap_fetch_type_free(fetch_type);
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(r);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
// We only fetch the body structure if requested
|
||||
@@ -633,6 +667,27 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
return results;
|
||||
}
|
||||
|
||||
- (NSArray *)messagesWithSequenceNumbers:(NSIndexSet *)sequenceNumbers
|
||||
fetchAttributes:(CTFetchAttributes)attrs {
|
||||
struct mailimap_set *set = mailimap_set_new_empty();
|
||||
[sequenceNumbers enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
|
||||
mailimap_set_add_interval(set, range.location, range.location + range.length - 1);
|
||||
}];
|
||||
|
||||
return [self messagesForSet:set fetchAttributes:attrs uidFetch:NO];
|
||||
|
||||
}
|
||||
|
||||
- (NSArray *)messagesWithUIDs:(NSIndexSet *)uidNumbers
|
||||
fetchAttributes:(CTFetchAttributes)attrs {
|
||||
struct mailimap_set *set = mailimap_set_new_empty();
|
||||
[uidNumbers enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) {
|
||||
mailimap_set_add_interval(set, range.location, range.location + range.length - 1);
|
||||
}];
|
||||
|
||||
return [self messagesForSet:set fetchAttributes:attrs uidFetch:YES];
|
||||
}
|
||||
|
||||
- (CTCoreMessage *)messageWithUID:(NSUInteger)uid {
|
||||
int err;
|
||||
struct mailmessage *msgStruct;
|
||||
@@ -675,21 +730,7 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
already depends on CTCoreMessage so we aren't adding any dependencies here. */
|
||||
|
||||
- (BOOL)flagsForMessage:(CTCoreMessage *)msg flags:(NSUInteger *)flags {
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.lastError = nil;
|
||||
int err;
|
||||
struct mail_flags *flagStruct;
|
||||
err = mailmessage_get_flags([msg messageStruct], &flagStruct);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
*flags = flagStruct->fl_flags;
|
||||
return YES;
|
||||
return [self flagsForMessage:msg flags:flags extensionFlags:NULL];
|
||||
}
|
||||
|
||||
|
||||
@@ -714,6 +755,87 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)extensionFlagsForMessage:(CTCoreMessage *)msg flags:(NSArray **)flags {
|
||||
return [self flagsForMessage:msg flags:NULL extensionFlags:flags];
|
||||
}
|
||||
|
||||
- (BOOL)setExtensionFlags:(NSArray *)flags forMessage:(CTCoreMessage *)msg {
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
int err;
|
||||
clist *extensionFlags = MailCoreClistFromStringArray(flags);
|
||||
if ([msg messageStruct]->msg_flags->fl_extension) {
|
||||
clist_free([msg messageStruct]->msg_flags->fl_extension);
|
||||
[msg messageStruct]->msg_flags->fl_extension = NULL;
|
||||
}
|
||||
[msg messageStruct]->msg_flags->fl_extension = extensionFlags;
|
||||
err = mailmessage_check([msg messageStruct]);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
err = mailfolder_check(myFolder);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)flagsForMessage:(CTCoreMessage *)msg flags:(NSUInteger *)flags extensionFlags:(NSArray **)extensionFlags {
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.lastError = nil;
|
||||
int err;
|
||||
struct mail_flags *flagStruct;
|
||||
err = mailmessage_get_flags([msg messageStruct], &flagStruct);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
if (flags) {
|
||||
*flags = flagStruct->fl_flags;
|
||||
}
|
||||
if (extensionFlags) {
|
||||
NSArray *extionsionFlags = MailCoreStringArrayFromClist(flagStruct->fl_extension);
|
||||
*extensionFlags = extionsionFlags;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)setFlags:(NSUInteger)flags extensionFlags:(NSArray *)extensionFlags forMessage:(CTCoreMessage *)msg {
|
||||
BOOL success = [self connect];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
int err;
|
||||
[msg messageStruct]->msg_flags->fl_flags = flags;
|
||||
clist *extensions = MailCoreClistFromStringArray(extensionFlags);
|
||||
if ([msg messageStruct]->msg_flags->fl_extension) {
|
||||
clist_free([msg messageStruct]->msg_flags->fl_extension);
|
||||
[msg messageStruct]->msg_flags->fl_extension = NULL;
|
||||
}
|
||||
[msg messageStruct]->msg_flags->fl_extension = extensions;
|
||||
err = mailmessage_check([msg messageStruct]);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
err = mailfolder_check(myFolder);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)expunge {
|
||||
int err;
|
||||
@@ -735,7 +857,11 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
return NO;
|
||||
}
|
||||
|
||||
const char *mbPath = [path cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
char mbPath[MAX_PATH_SIZE];
|
||||
if (![self getUTF7String:mbPath fromString:path]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
int err = mailsession_copy_message([self folderSession], uid, mbPath);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
@@ -750,7 +876,11 @@ static const int MAX_PATH_SIZE = 1024;
|
||||
return NO;
|
||||
}
|
||||
|
||||
const char *mbPath = [path cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
char mbPath[MAX_PATH_SIZE];
|
||||
if (![self getUTF7String:mbPath fromString:path]) {
|
||||
self.lastError = MailCoreCreateStringConvError();
|
||||
return NO;
|
||||
}
|
||||
int err = mailsession_move_message([self folderSession], uid, mbPath);
|
||||
if (err != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
@@ -889,4 +1019,6 @@ int uid_list_to_env_list(clist * fetch_result, struct mailmessage_list ** result
|
||||
err:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
+38
-16
@@ -42,6 +42,13 @@
|
||||
|
||||
@class CTCoreFolder, CTCoreAddress, CTCoreAttachment, CTMIME;
|
||||
|
||||
typedef enum {
|
||||
CTCoreMessageUrgentPriority = 1,
|
||||
CTCoreMessageNormalPriority = 2,
|
||||
CTCoreMessageNonUrgentPriority
|
||||
} CTCoreMessagePriority;
|
||||
|
||||
|
||||
@interface CTCoreMessage : NSObject {
|
||||
struct mailmessage *myMessage;
|
||||
struct mailimf_single_fields *myFields;
|
||||
@@ -49,6 +56,7 @@
|
||||
NSUInteger mySequenceNumber;
|
||||
NSError *lastError;
|
||||
CTCoreFolder *parentFolder;
|
||||
CTCoreMessagePriority mailPriority;
|
||||
}
|
||||
/**
|
||||
If an error occurred (nil or return of NO) call this method to get the error
|
||||
@@ -91,6 +99,11 @@
|
||||
*/
|
||||
- (NSError *)lastError;
|
||||
|
||||
/**
|
||||
Returns YES if this message body structure has been downloaded, and NO otherwise.
|
||||
*/
|
||||
- (BOOL)hasBodyStructure;
|
||||
|
||||
/**
|
||||
If the messages body structure hasn't been downloaded already it will be fetched from the server.
|
||||
|
||||
@@ -131,6 +144,12 @@
|
||||
*/
|
||||
- (void)setHTMLBody:(NSString *)body;
|
||||
|
||||
/**
|
||||
Use this method to set both body Plaintext and HTML content.
|
||||
HTML will have higher priority
|
||||
*/
|
||||
- (void) setHTMLBody:(NSString*)htmlString textBody:(NSString*)plainString;
|
||||
|
||||
/**
|
||||
A list of attachments this message has
|
||||
*/
|
||||
@@ -154,26 +173,14 @@
|
||||
- (void)setSubject:(NSString *)subject;
|
||||
|
||||
/**
|
||||
Returns the timezone of the sender of the message (got from the Date field timezone attribute)
|
||||
*/
|
||||
- (NSTimeZone*)senderTimeZone;
|
||||
|
||||
/**
|
||||
Returns the date as given in the Date mail field (no timezone is applied)
|
||||
Returns the date as given in the Date mail field
|
||||
*/
|
||||
- (NSDate *)senderDate;
|
||||
|
||||
/**
|
||||
Returns the date in the Date field converted to GMT
|
||||
*/
|
||||
- (NSDate *)sentDateGMT;
|
||||
|
||||
/**
|
||||
Returns the date in the Date field converted to the local timezone
|
||||
|
||||
The local timezone is the one set in the device running this code
|
||||
*/
|
||||
- (NSDate *)sentDateLocalTimeZone;
|
||||
Returns YES if the message is deleted.
|
||||
*/
|
||||
- (BOOL)isDeleted;
|
||||
|
||||
/**
|
||||
Returns YES if the message is unread.
|
||||
@@ -219,6 +226,14 @@ The local timezone is the one set in the device running this code
|
||||
*/
|
||||
- (NSUInteger)flags;
|
||||
|
||||
/**
|
||||
Returns the message extionsion flags.
|
||||
|
||||
The extension flags contain flags other than standard flags in flags property. This include "Draft" flag.
|
||||
See MailCoreTypes.h for a list of constants
|
||||
*/
|
||||
- (NSArray *)extionsionFlags;
|
||||
|
||||
/**
|
||||
Set the message sequence number.
|
||||
|
||||
@@ -338,6 +353,13 @@ The local timezone is the one set in the device running this code
|
||||
*/
|
||||
- (NSString *)rfc822Header;
|
||||
|
||||
|
||||
/**
|
||||
Sets the outgoing message's priority header value.
|
||||
Support for Mail Prioirty header defined in IMAP 4021 and X-Prioirty header.
|
||||
*/
|
||||
- (void)setMailPriority:(CTCoreMessagePriority)priority;
|
||||
|
||||
/* Intended for advanced use only */
|
||||
- (struct mailmessage *)messageStruct;
|
||||
- (mailimap *)imapSession;
|
||||
|
||||
+204
-90
@@ -103,6 +103,13 @@
|
||||
return lastError;
|
||||
}
|
||||
|
||||
- (BOOL)hasBodyStructure {
|
||||
if (myParsedMIME == nil) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)fetchBodyStructure {
|
||||
if (myMessage == NULL) {
|
||||
return NO;
|
||||
@@ -144,7 +151,10 @@
|
||||
[self fetchBodyStructure];
|
||||
}
|
||||
NSMutableString *result = [NSMutableString string];
|
||||
[self _buildUpBodyText:myParsedMIME result:result];
|
||||
BOOL success = [self _buildUpBodyText:myParsedMIME result:result];
|
||||
if (!success) {
|
||||
return nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -170,8 +180,14 @@
|
||||
}
|
||||
|
||||
- (NSString *)htmlBody {
|
||||
if (myFields == NULL || myParsedMIME == nil) {
|
||||
[self fetchBodyStructure];
|
||||
}
|
||||
NSMutableString *result = [NSMutableString string];
|
||||
[self _buildUpHtmlBodyText:myParsedMIME result:result];
|
||||
BOOL success = [self _buildUpHtmlBodyText:myParsedMIME result:result];
|
||||
if (!success) {
|
||||
return nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -186,20 +202,24 @@
|
||||
}
|
||||
|
||||
|
||||
- (void)_buildUpBodyText:(CTMIME *)mime result:(NSMutableString *)result {
|
||||
- (BOOL)_buildUpBodyText:(CTMIME *)mime result:(NSMutableString *)result {
|
||||
if (mime == nil)
|
||||
return;
|
||||
return NO;
|
||||
|
||||
if ([mime isKindOfClass:[CTMIME_MessagePart class]]) {
|
||||
[self _buildUpBodyText:[mime content] result:result];
|
||||
return [self _buildUpBodyText:[mime content] result:result];
|
||||
}
|
||||
else if ([mime isKindOfClass:[CTMIME_TextPart class]]) {
|
||||
if ([[mime.contentType lowercaseString] rangeOfString:@"text/plain"].location != NSNotFound) {
|
||||
[(CTMIME_TextPart *)mime fetchPart];
|
||||
NSString* y = [mime content];
|
||||
if(y != nil) {
|
||||
[result appendString:y];
|
||||
BOOL success = [(CTMIME_TextPart *)mime fetchPart];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
NSString* y = [mime content];
|
||||
if(y == nil) {
|
||||
return NO;
|
||||
}
|
||||
[result appendString:y];
|
||||
}
|
||||
}
|
||||
else if ([mime isKindOfClass:[CTMIME_MultiPart class]]) {
|
||||
@@ -207,25 +227,34 @@
|
||||
NSEnumerator *enumer = [[mime content] objectEnumerator];
|
||||
CTMIME *subpart;
|
||||
while ((subpart = [enumer nextObject])) {
|
||||
[self _buildUpBodyText:subpart result:result];
|
||||
BOOL success = [self _buildUpBodyText:subpart result:result];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_buildUpHtmlBodyText:(CTMIME *)mime result:(NSMutableString *)result {
|
||||
- (BOOL)_buildUpHtmlBodyText:(CTMIME *)mime result:(NSMutableString *)result {
|
||||
if (mime == nil)
|
||||
return;
|
||||
return NO;
|
||||
|
||||
if ([mime isKindOfClass:[CTMIME_MessagePart class]]) {
|
||||
[self _buildUpHtmlBodyText:[mime content] result:result];
|
||||
return [self _buildUpHtmlBodyText:[mime content] result:result];
|
||||
}
|
||||
else if ([mime isKindOfClass:[CTMIME_TextPart class]]) {
|
||||
if ([[mime.contentType lowercaseString] rangeOfString:@"text/html"].location != NSNotFound) {
|
||||
[(CTMIME_TextPart *)mime fetchPart];
|
||||
NSString* y = [mime content];
|
||||
if(y != nil) {
|
||||
[result appendString:y];
|
||||
BOOL success = [(CTMIME_TextPart *)mime fetchPart];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString* y = [mime content];
|
||||
if(y == nil) {
|
||||
return NO;
|
||||
}
|
||||
[result appendString:y];
|
||||
}
|
||||
}
|
||||
else if ([mime isKindOfClass:[CTMIME_MultiPart class]]) {
|
||||
@@ -233,9 +262,42 @@
|
||||
NSEnumerator *enumer = [[mime content] objectEnumerator];
|
||||
CTMIME *subpart;
|
||||
while ((subpart = [enumer nextObject])) {
|
||||
[self _buildUpHtmlBodyText:subpart result:result];
|
||||
BOOL success = [self _buildUpHtmlBodyText:subpart result:result];
|
||||
if (!success) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) setHTMLBody:(NSString*)htmlString textBody:(NSString*)plainString {
|
||||
/*
|
||||
* Message structure:
|
||||
*
|
||||
* [ msg root ]
|
||||
* --> multipart/alternative (Body)
|
||||
* -----> text
|
||||
* -----> html
|
||||
*/
|
||||
|
||||
// Body (multipart/alternative)
|
||||
CTMIME_MultiPart* bodyMultipart = [CTMIME_MultiPart mimeMultiPart];
|
||||
bodyMultipart.contentType = @"multipart/alternative";
|
||||
|
||||
CTMIME_TextPart* bodyTextPart = [CTMIME_TextPart mimeTextPartWithString:plainString];
|
||||
CTMIME_HtmlPart* bodyHtmlPart = [CTMIME_HtmlPart mimeTextPartWithString:htmlString];
|
||||
|
||||
[bodyMultipart addMIMEPart: bodyTextPart ];
|
||||
[bodyMultipart addMIMEPart: bodyHtmlPart ];
|
||||
|
||||
// Root
|
||||
CTMIME_MessagePart* messagePartRoot = [CTMIME_MessagePart mimeMessagePartWithContent:bodyMultipart];
|
||||
|
||||
[myParsedMIME release];
|
||||
myParsedMIME = [messagePartRoot retain];
|
||||
}
|
||||
|
||||
|
||||
@@ -290,11 +352,38 @@
|
||||
msg = (CTMIME_MessagePart *)myParsedMIME;
|
||||
CTMIME *sub = [msg content];
|
||||
|
||||
|
||||
// Creat new multimime part if needed
|
||||
if ([sub isKindOfClass:[CTMIME_MultiPart class]]) {
|
||||
multi = (CTMIME_MultiPart *)sub;
|
||||
} else {
|
||||
// Assuming this is the body
|
||||
if ([sub.contentType isEqualToString:@"multipart/alternative"]) {
|
||||
/*
|
||||
* Transform the following
|
||||
* message structure:
|
||||
*
|
||||
* [ msg root ]
|
||||
* --> multipart/alternative
|
||||
* -----> text
|
||||
* -----> html
|
||||
*
|
||||
* into:
|
||||
*
|
||||
* [ MessagePart Root ]
|
||||
* --> multipart/mixed
|
||||
* -----> attachments
|
||||
* -----> multipart/alternative
|
||||
* --------> text
|
||||
* --------> html
|
||||
*/
|
||||
|
||||
CTMIME_MultiPart* multipartMixed = [CTMIME_MultiPart mimeMultiPart];
|
||||
[multipartMixed addMIMEPart:sub];
|
||||
multi = multipartMixed;
|
||||
[msg setContent:multipartMixed];
|
||||
}
|
||||
else
|
||||
multi = (CTMIME_MultiPart *)sub;
|
||||
}
|
||||
else {
|
||||
multi = [CTMIME_MultiPart mimeMultiPart];
|
||||
[multi addMIMEPart:sub];
|
||||
[msg setContent:multi];
|
||||
@@ -347,7 +436,7 @@
|
||||
|
||||
- (NSDate *)senderDate {
|
||||
if ( myFields->fld_orig_date == NULL) {
|
||||
return [NSDate distantPast];
|
||||
return nil;
|
||||
} else {
|
||||
struct mailimf_date_time *d;
|
||||
|
||||
@@ -355,6 +444,7 @@
|
||||
return nil;
|
||||
|
||||
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
|
||||
calendar.timeZone = [self senderTimeZone];
|
||||
NSDateComponents *comps = [[NSDateComponents alloc] init];
|
||||
|
||||
[comps setYear:d->dt_year];
|
||||
@@ -364,53 +454,34 @@
|
||||
[comps setMinute:d->dt_min];
|
||||
[comps setSecond:d->dt_sec];
|
||||
|
||||
NSDate *messageDateNoTimezone = [calendar dateFromComponents:comps];
|
||||
NSDate *messageDate = [calendar dateFromComponents:comps];
|
||||
|
||||
[comps release];
|
||||
[calendar release];
|
||||
|
||||
// no timezone applied
|
||||
return messageDateNoTimezone;
|
||||
return messageDate;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDate *)sentDateGMT {
|
||||
struct mailimf_date_time *d;
|
||||
|
||||
if((d = [self libetpanDateTime]) == NULL)
|
||||
return nil;
|
||||
|
||||
NSInteger timezoneOffsetInSeconds = 3600*d->dt_zone/100;
|
||||
|
||||
NSDate *date = [self senderDate];
|
||||
|
||||
return [date dateByAddingTimeInterval:timezoneOffsetInSeconds * -1];
|
||||
}
|
||||
|
||||
- (NSDate*)sentDateLocalTimeZone {
|
||||
return [[self sentDateGMT] dateByAddingTimeInterval:[[NSTimeZone localTimeZone] secondsFromGMT]];
|
||||
}
|
||||
|
||||
- (BOOL)isUnread {
|
||||
struct mail_flags *flags = myMessage->msg_flags;
|
||||
if (flags != NULL) {
|
||||
BOOL flag_seen = (flags->fl_flags & MAIL_FLAG_SEEN);
|
||||
return !flag_seen;
|
||||
}
|
||||
return NO;
|
||||
return ![self isFlagSet:MAIL_FLAG_SEEN withDefault:YES];
|
||||
}
|
||||
|
||||
- (BOOL)isDeleted {
|
||||
return [self isFlagSet:MAIL_FLAG_DELETED withDefault:NO];
|
||||
}
|
||||
|
||||
- (BOOL)isStarred {
|
||||
struct mail_flags *flags = myMessage->msg_flags;
|
||||
if (flags != NULL) {
|
||||
BOOL flag_starred = (flags->fl_flags & MAIL_FLAG_FLAGGED);
|
||||
return flag_starred;
|
||||
}
|
||||
return NO;
|
||||
return [self isFlagSet:MAIL_FLAG_FLAGGED withDefault:NO];
|
||||
}
|
||||
|
||||
- (BOOL)isFlagSet:(NSUInteger)flag withDefault:(BOOL)def {
|
||||
struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
|
||||
return flags == NULL ? def : flags->fl_flags & flag;
|
||||
}
|
||||
|
||||
- (BOOL)isNew {
|
||||
struct mail_flags *flags = myMessage->msg_flags;
|
||||
struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
|
||||
if (flags != NULL) {
|
||||
BOOL flag_seen = (flags->fl_flags & MAIL_FLAG_SEEN);
|
||||
BOOL flag_new = (flags->fl_flags & MAIL_FLAG_NEW);
|
||||
@@ -428,7 +499,7 @@
|
||||
}
|
||||
|
||||
- (NSUInteger)uid {
|
||||
if (myMessage->msg_uid) {
|
||||
if (myMessage && myMessage->msg_uid) {
|
||||
NSString *uidString = [[NSString alloc] initWithCString:myMessage->msg_uid encoding:NSASCIIStringEncoding];
|
||||
NSUInteger uid = (NSUInteger)[[[uidString componentsSeparatedByString:@"-"] objectAtIndex:1] intValue];
|
||||
[uidString release];
|
||||
@@ -448,6 +519,13 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSArray *)extionsionFlags {
|
||||
if (myMessage != NULL && myMessage->msg_flags != NULL) {
|
||||
return MailCoreStringArrayFromClist(myMessage->msg_flags->fl_extension);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSUInteger)sequenceNumber {
|
||||
return mySequenceNumber;
|
||||
}
|
||||
@@ -491,7 +569,10 @@
|
||||
|
||||
- (void)setTo:(NSSet *)addresses {
|
||||
struct mailimf_address_list *imf = [self _IMFAddressListFromAddresssList:addresses];
|
||||
|
||||
if (!imf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFields->fld_to != NULL) {
|
||||
mailimf_address_list_free(myFields->fld_to->to_addr_list);
|
||||
myFields->fld_to->to_addr_list = imf;
|
||||
@@ -504,12 +585,12 @@
|
||||
if (myFields->fld_in_reply_to == NULL)
|
||||
return nil;
|
||||
else
|
||||
return [self _stringArrayFromClist:myFields->fld_in_reply_to->mid_list];
|
||||
return MailCoreStringArrayFromClist(myFields->fld_in_reply_to->mid_list);
|
||||
}
|
||||
|
||||
|
||||
- (void)setInReplyTo:(NSArray *)messageIds {
|
||||
struct mailimf_in_reply_to *imf = mailimf_in_reply_to_new([self _clistFromStringArray:messageIds]);
|
||||
struct mailimf_in_reply_to *imf = mailimf_in_reply_to_new(MailCoreClistFromStringArray(messageIds));
|
||||
|
||||
if (myFields->fld_in_reply_to != NULL) {
|
||||
mailimf_in_reply_to_free(myFields->fld_in_reply_to);
|
||||
@@ -524,12 +605,12 @@
|
||||
if (myFields->fld_references == NULL)
|
||||
return nil;
|
||||
else
|
||||
return [self _stringArrayFromClist:myFields->fld_references->mid_list];
|
||||
return MailCoreStringArrayFromClist(myFields->fld_references->mid_list);
|
||||
}
|
||||
|
||||
|
||||
- (void)setReferences:(NSArray *)messageIds {
|
||||
struct mailimf_references *imf = mailimf_references_new([self _clistFromStringArray:messageIds]);
|
||||
struct mailimf_references *imf = mailimf_references_new(MailCoreClistFromStringArray(messageIds));
|
||||
|
||||
if (myFields->fld_references != NULL) {
|
||||
mailimf_references_free(myFields->fld_references);
|
||||
@@ -550,6 +631,10 @@
|
||||
|
||||
- (void)setCc:(NSSet *)addresses {
|
||||
struct mailimf_address_list *imf = [self _IMFAddressListFromAddresssList:addresses];
|
||||
if (!imf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFields->fld_cc != NULL) {
|
||||
mailimf_address_list_free(myFields->fld_cc->cc_addr_list);
|
||||
myFields->fld_cc->cc_addr_list = imf;
|
||||
@@ -569,6 +654,10 @@
|
||||
|
||||
- (void)setBcc:(NSSet *)addresses {
|
||||
struct mailimf_address_list *imf = [self _IMFAddressListFromAddresssList:addresses];
|
||||
if (!imf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFields->fld_bcc != NULL) {
|
||||
mailimf_address_list_free(myFields->fld_bcc->bcc_addr_list);
|
||||
myFields->fld_bcc->bcc_addr_list = imf;
|
||||
@@ -588,6 +677,10 @@
|
||||
|
||||
- (void)setReplyTo:(NSSet *)addresses {
|
||||
struct mailimf_address_list *imf = [self _IMFAddressListFromAddresssList:addresses];
|
||||
if (!imf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myFields->fld_reply_to != NULL) {
|
||||
mailimf_address_list_free(myFields->fld_reply_to->rt_addr_list);
|
||||
myFields->fld_reply_to->rt_addr_list = imf;
|
||||
@@ -613,9 +706,49 @@
|
||||
clist *references = (myFields->fld_references != NULL) ? (myFields->fld_references->mid_list) : NULL;
|
||||
char *subject = (myFields->fld_subject != NULL) ? (myFields->fld_subject->sbj_value) : NULL;
|
||||
|
||||
fields = mailimf_fields_new_with_data(from, sender, replyTo, to, cc, bcc, inReplyTo, references, subject);
|
||||
|
||||
if (self->mailPriority != 0) {
|
||||
char * xPriorityValue;
|
||||
char * rfcPriorityValue;
|
||||
switch (self->mailPriority) {
|
||||
case CTCoreMessageUrgentPriority: {
|
||||
xPriorityValue = "1";
|
||||
rfcPriorityValue = "urgent";
|
||||
break;
|
||||
}
|
||||
case CTCoreMessageNormalPriority: {
|
||||
xPriorityValue = "3";
|
||||
rfcPriorityValue = "normal";
|
||||
break;
|
||||
}
|
||||
case CTCoreMessageNonUrgentPriority: {
|
||||
xPriorityValue = "5";
|
||||
rfcPriorityValue = "non-urgent";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
struct mailimf_optional_field * priority = mailimf_optional_field_new("X-Priority", xPriorityValue);
|
||||
|
||||
struct mailimf_field * priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, priority);
|
||||
mailimf_fields_add(fields, priorityField);
|
||||
|
||||
priority = mailimf_optional_field_new("Priority", rfcPriorityValue);
|
||||
priorityField = mailimf_field_new(MAILIMF_FIELD_OPTIONAL_FIELD, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, priority);
|
||||
|
||||
mailimf_fields_add(fields, priorityField);
|
||||
}
|
||||
//TODO uh oh, when this get freed it frees stuff in the CTCoreMessage
|
||||
//TODO Need to make sure that fields gets freed somewhere
|
||||
fields = mailimf_fields_new_with_data(from, sender, replyTo, to, cc, bcc, inReplyTo, references, subject);
|
||||
[(CTMIME_MessagePart *)msgPart setIMFFields:fields];
|
||||
}
|
||||
return [myParsedMIME render];
|
||||
@@ -629,7 +762,7 @@
|
||||
[emlx appendData:msgContentAsData];
|
||||
|
||||
|
||||
struct mail_flags *flagsStruct = myMessage->msg_flags;
|
||||
struct mail_flags *flagsStruct = myMessage ? myMessage->msg_flags : NULL;
|
||||
uint64_t flags = 0;
|
||||
if (flagsStruct != NULL) {
|
||||
BOOL seen = (flagsStruct->fl_flags & CTFlagSeen) > 0;
|
||||
@@ -684,6 +817,10 @@
|
||||
return [nsresult autorelease];
|
||||
}
|
||||
|
||||
- (void)setMailPriority:(CTCoreMessagePriority)priority {
|
||||
mailPriority = priority;
|
||||
}
|
||||
|
||||
- (struct mailmessage *)messageStruct {
|
||||
return myMessage;
|
||||
}
|
||||
@@ -783,6 +920,10 @@
|
||||
|
||||
|
||||
- (struct mailimf_address_list *)_IMFAddressListFromAddresssList:(NSSet *)addresses {
|
||||
if (!addresses) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct mailimf_address_list *imfList = mailimf_address_list_new_empty();
|
||||
|
||||
NSEnumerator *objEnum = [addresses objectEnumerator];
|
||||
@@ -800,32 +941,5 @@
|
||||
return imfList;
|
||||
}
|
||||
|
||||
- (NSArray *)_stringArrayFromClist:(clist *)list {
|
||||
clistiter *iter;
|
||||
NSMutableArray *stringSet = [NSMutableArray array];
|
||||
char *string;
|
||||
|
||||
if(list == NULL)
|
||||
return stringSet;
|
||||
|
||||
for(iter = clist_begin(list); iter != NULL; iter = clist_next(iter)) {
|
||||
string = clist_content(iter);
|
||||
NSString *strObj = [[NSString alloc] initWithUTF8String:string];
|
||||
[stringSet addObject:strObj];
|
||||
[strObj release];
|
||||
}
|
||||
|
||||
return stringSet;
|
||||
}
|
||||
|
||||
- (clist *)_clistFromStringArray:(NSArray *)strings {
|
||||
clist * str_list = clist_new();
|
||||
|
||||
for (NSString *str in strings) {
|
||||
clist_append(str_list, strdup([str UTF8String]));
|
||||
}
|
||||
|
||||
return str_list;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -89,14 +89,12 @@
|
||||
struct mailmime *mime_sub;
|
||||
struct mailmime_content *content;
|
||||
struct mailmime_parameter *param;
|
||||
struct mailmime_disposition *disposition;
|
||||
struct mailmime_mechanism *encoding;
|
||||
int r;
|
||||
|
||||
/* text/html part */
|
||||
encoding = mailmime_mechanism_new(MAILMIME_MECHANISM_QUOTED_PRINTABLE, NULL);
|
||||
disposition = mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_INLINE, NULL, NULL, NULL, NULL, -1);
|
||||
mime_fields = mailmime_fields_new_with_data(encoding, NULL, NULL, disposition, NULL);
|
||||
mime_fields = mailmime_fields_new_with_data(encoding, NULL, NULL, NULL, NULL);
|
||||
|
||||
content = mailmime_content_new_with_str("text/html");
|
||||
param = mailmime_parameter_new(strdup("charset"), strdup(DEST_CHARSET));
|
||||
|
||||
@@ -62,4 +62,7 @@ typedef void (^CTProgressBlock)(size_t curr, size_t max);
|
||||
- (id)initWithData:(NSData *)data;
|
||||
- (BOOL)fetchPart;
|
||||
- (BOOL)fetchPartWithProgress:(CTProgressBlock)block;
|
||||
|
||||
// Advanced use only
|
||||
- (struct mailmime_single_fields *)mimeFields;
|
||||
@end
|
||||
|
||||
+35
-30
@@ -87,11 +87,15 @@ static void download_progress_callback(size_t current, size_t maximum, void * co
|
||||
|
||||
mMimeFields = mailmime_single_fields_new(mMime->mm_mime_fields, mMime->mm_content_type);
|
||||
if (mMimeFields != NULL) {
|
||||
if (mMimeFields->fld_id != NULL) {
|
||||
self.contentId = [NSString stringWithCString:mMimeFields->fld_id encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
struct mailmime_disposition *disp = mMimeFields->fld_disposition;
|
||||
if (disp != NULL) {
|
||||
if (disp->dsp_type != NULL) {
|
||||
self.attached = (disp->dsp_type->dsp_type ==
|
||||
MAILMIME_DISPOSITION_TYPE_ATTACHMENT);
|
||||
self.attached = (disp->dsp_type->dsp_type == MAILMIME_DISPOSITION_TYPE_ATTACHMENT ||
|
||||
disp->dsp_type->dsp_type == MAILMIME_DISPOSITION_TYPE_INLINE);
|
||||
|
||||
if (self.attached)
|
||||
{
|
||||
@@ -109,35 +113,33 @@ static void download_progress_callback(size_t current, size_t maximum, void * co
|
||||
|
||||
if (mMimeFields->fld_disposition_filename != NULL) {
|
||||
self.filename = [NSString stringWithCString:mMimeFields->fld_disposition_filename encoding:NSUTF8StringEncoding];
|
||||
|
||||
if (mMimeFields->fld_id != NULL)
|
||||
self.contentId = [NSString stringWithCString:mMimeFields->fld_id encoding:NSUTF8StringEncoding];
|
||||
|
||||
NSString* lowercaseName = [self.filename lowercaseString];
|
||||
if([lowercaseName hasSuffix:@".xls"] ||
|
||||
[lowercaseName hasSuffix:@".xlsx"] ||
|
||||
[lowercaseName hasSuffix:@".key.zip"] ||
|
||||
[lowercaseName hasSuffix:@".numbers.zip"] ||
|
||||
[lowercaseName hasSuffix:@".pages.zip"] ||
|
||||
[lowercaseName hasSuffix:@".pdf"] ||
|
||||
[lowercaseName hasSuffix:@".ppt"] ||
|
||||
[lowercaseName hasSuffix:@".doc"] ||
|
||||
[lowercaseName hasSuffix:@".docx"] ||
|
||||
[lowercaseName hasSuffix:@".rtf"] ||
|
||||
[lowercaseName hasSuffix:@".rtfd.zip"] ||
|
||||
[lowercaseName hasSuffix:@".key"] ||
|
||||
[lowercaseName hasSuffix:@".numbers"] ||
|
||||
[lowercaseName hasSuffix:@".pages"] ||
|
||||
[lowercaseName hasSuffix:@".png"] ||
|
||||
[lowercaseName hasSuffix:@".gif"] ||
|
||||
[lowercaseName hasSuffix:@".png"] ||
|
||||
[lowercaseName hasSuffix:@".jpg"] ||
|
||||
[lowercaseName hasSuffix:@".jpeg"] ||
|
||||
[lowercaseName hasSuffix:@".tiff"]) { // hack by gabor, improved by waseem, based on http://developer.apple.com/iphone/library/qa/qa2008/qa1630.html
|
||||
self.attached = YES;
|
||||
}
|
||||
} else if (mMimeFields->fld_location != NULL) {
|
||||
self.filename = [NSString stringWithCString:mMimeFields->fld_location encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
NSString* lowercaseName = [self.filename lowercaseString];
|
||||
if([lowercaseName hasSuffix:@".xls"] ||
|
||||
[lowercaseName hasSuffix:@".xlsx"] ||
|
||||
[lowercaseName hasSuffix:@".key.zip"] ||
|
||||
[lowercaseName hasSuffix:@".numbers.zip"] ||
|
||||
[lowercaseName hasSuffix:@".pages.zip"] ||
|
||||
[lowercaseName hasSuffix:@".pdf"] ||
|
||||
[lowercaseName hasSuffix:@".ppt"] ||
|
||||
[lowercaseName hasSuffix:@".doc"] ||
|
||||
[lowercaseName hasSuffix:@".docx"] ||
|
||||
[lowercaseName hasSuffix:@".rtf"] ||
|
||||
[lowercaseName hasSuffix:@".rtfd.zip"] ||
|
||||
[lowercaseName hasSuffix:@".key"] ||
|
||||
[lowercaseName hasSuffix:@".numbers"] ||
|
||||
[lowercaseName hasSuffix:@".pages"] ||
|
||||
[lowercaseName hasSuffix:@".png"] ||
|
||||
[lowercaseName hasSuffix:@".gif"] ||
|
||||
[lowercaseName hasSuffix:@".png"] ||
|
||||
[lowercaseName hasSuffix:@".jpg"] ||
|
||||
[lowercaseName hasSuffix:@".jpeg"] ||
|
||||
[lowercaseName hasSuffix:@".tiff"]) { // hack by gabor, improved by waseem, based on http://developer.apple.com/iphone/library/qa/qa2008/qa1630.html
|
||||
self.attached = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
@@ -204,7 +206,7 @@ static void download_progress_callback(size_t current, size_t maximum, void * co
|
||||
|
||||
if (mFilename) {
|
||||
char *charData = (char *)[mFilename cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
char *dupeData = malloc(strlen(charData));
|
||||
char *dupeData = malloc(strlen(charData) + 1);
|
||||
strcpy(dupeData, charData);
|
||||
mime_fields = mailmime_fields_new_filename( MAILMIME_DISPOSITION_TYPE_ATTACHMENT,
|
||||
dupeData,
|
||||
@@ -227,6 +229,9 @@ static void download_progress_callback(size_t current, size_t maximum, void * co
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (struct mailmime_single_fields *)mimeFields {
|
||||
return mMimeFields;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
mailmime_single_fields_free(mMimeFields);
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
@class CTSMTP;
|
||||
|
||||
|
||||
@interface CTSMTPAsyncConnection : NSObject
|
||||
@interface CTSMTPAsyncConnection : NSObject
|
||||
{
|
||||
CTSMTP* mSMTPObj;
|
||||
mailsmtp* mSMTP;
|
||||
@@ -63,11 +63,11 @@
|
||||
@property (retain) CTCoreMessage* message;
|
||||
@property (readonly) CTSMTPAsyncStatus status;
|
||||
|
||||
- (id)initWithServer:(NSString *)aServer
|
||||
- (id)initWithServer:(NSString *)aServer
|
||||
username:(NSString *)aUsername
|
||||
password:(NSString *)aPassword
|
||||
port:(unsigned int)aPort
|
||||
useTLS:(BOOL)aTls
|
||||
password:(NSString *)aPassword
|
||||
port:(unsigned int)aPort
|
||||
connectionType:(CTSMTPConnectionType)connectionType
|
||||
useAuth:(BOOL)aAuth
|
||||
delegate:(id<CTSMTPConnectionDelegate>)aDelegate;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ smtpProgress(size_t aCurrent, size_t aTotal) {
|
||||
username:(NSString *)aUsername
|
||||
password:(NSString *)aPassword
|
||||
port:(unsigned int)aPort
|
||||
useTLS:(BOOL)aTls
|
||||
connectionType:(CTSMTPConnectionType)connectionType
|
||||
useAuth:(BOOL)aAuth
|
||||
delegate:(id <CTSMTPConnectionDelegate>)aDelegate {
|
||||
|
||||
@@ -90,7 +90,7 @@ smtpProgress(size_t aCurrent, size_t aTotal) {
|
||||
aUsername, @"username",
|
||||
aPassword, @"password",
|
||||
[NSNumber numberWithInt:aPort], @"port",
|
||||
[NSNumber numberWithBool:aTls], @"tls",
|
||||
[NSNumber numberWithInt:connectionType], @"connectionType",
|
||||
[NSNumber numberWithBool:aAuth], @"auth", nil] retain];
|
||||
|
||||
//save clients from themselves (they could be leaking us - no dealloc)
|
||||
@@ -169,9 +169,19 @@ smtpProgress(size_t aCurrent, size_t aTotal) {
|
||||
mSMTPObj = [[CTESMTP alloc] initWithResource:mSMTP];
|
||||
|
||||
NSDictionary *theSettings = self.serverSettings;
|
||||
|
||||
success = [mSMTPObj connectToServer:[theSettings objectForKey:@"server"]
|
||||
port:[[theSettings objectForKey:@"port"] unsignedIntValue]];
|
||||
CTSMTPConnectionType connectionType = [[theSettings objectForKey:@"connectionType"] unsignedIntValue];
|
||||
NSString* server = [theSettings objectForKey:@"server"];
|
||||
unsigned int port = [[theSettings objectForKey:@"port"] unsignedIntValue];
|
||||
BOOL auth = [[theSettings objectForKey:@"auth"] boolValue];
|
||||
NSString* username = [theSettings objectForKey:@"username"];
|
||||
NSString* password = [theSettings objectForKey:@"password"];
|
||||
|
||||
if (connectionType == CTSMTPConnectionTypeStartTLS || connectionType == CTSMTPConnectionTypePlain) {
|
||||
success = [mSMTPObj connectToServer:server port:port];
|
||||
} else if (connectionType == CTSMTPConnectionTypeTLS) {
|
||||
success = [mSMTPObj connectWithTlsToServer:server port:port];
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
@@ -184,16 +194,16 @@ smtpProgress(size_t aCurrent, size_t aTotal) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if ([(NSNumber *) [theSettings objectForKey:@"tls"] boolValue]) {
|
||||
|
||||
if (connectionType == CTSMTPConnectionTypeStartTLS) {
|
||||
success = [mSMTPObj startTLS];
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if ([(NSNumber *) [theSettings objectForKey:@"auth"] boolValue]) {
|
||||
success = [mSMTPObj authenticateWithUsername:[theSettings objectForKey:@"username"]
|
||||
password:[theSettings objectForKey:@"password"]
|
||||
server:[theSettings objectForKey:@"server"]];
|
||||
|
||||
if (auth) {
|
||||
success = [mSMTPObj authenticateWithUsername:username password:password server:server];
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
@@ -213,9 +223,15 @@ smtpProgress(size_t aCurrent, size_t aTotal) {
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
NSSet *tmpBcc = theMessage.bcc;
|
||||
|
||||
// Temporarily wipe out BCC so it isn't sent with the message
|
||||
theMessage.bcc = nil;
|
||||
|
||||
//send
|
||||
success = [mSMTPObj setData:[theMessage render]];
|
||||
|
||||
theMessage.bcc = tmpBcc;
|
||||
if (success) {
|
||||
mStatus = CTSMTPAsyncSuccess;
|
||||
} else if (success && [mMailThread isCancelled]) {
|
||||
|
||||
@@ -92,9 +92,17 @@
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
NSSet *tmpBcc = message.bcc;
|
||||
|
||||
// Temporarily wipe out BCC so it isn't sent with the message
|
||||
message.bcc = nil;
|
||||
|
||||
/* data */
|
||||
success = [smtpObj setData:[message render]];
|
||||
|
||||
message.bcc = tmpBcc;
|
||||
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#import "CTSMTPConnection.h"
|
||||
#import "CTBareAttachment.h"
|
||||
#import "CTCoreAttachment.h"
|
||||
#import "CTXlistResult.h"
|
||||
#import <libetpan/libetpan.h>
|
||||
#import "MailCoreTypes.h"
|
||||
#import "MailCoreUtilities.h"
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <libetpan/libetpan.h>
|
||||
|
||||
#define MailCoreErrorDomain @"mailcore"
|
||||
|
||||
/**
|
||||
Enables logging of all streams, data is output to standard out.
|
||||
*/
|
||||
@@ -51,3 +53,7 @@ NSError* MailCoreCreateErrorFromIMAPCode(int errcode);
|
||||
NSError* MailCoreCreateErrorFromSMTPCode(int errcode);
|
||||
|
||||
NSString *MailCoreDecodeMIMEPhrase(char *data);
|
||||
|
||||
NSArray * MailCoreStringArrayFromClist(clist *list);
|
||||
clist *MailCoreClistFromStringArray(NSArray *strings);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void MailCoreDisableLogging() {
|
||||
NSError* MailCoreCreateError(int errcode, NSString *description) {
|
||||
NSMutableDictionary *errorDetail = [NSMutableDictionary dictionary];
|
||||
[errorDetail setValue:description forKey:NSLocalizedDescriptionKey];
|
||||
return [NSError errorWithDomain:@"mailcore" code:errcode userInfo:errorDetail];
|
||||
return [NSError errorWithDomain:MailCoreErrorDomain code:errcode userInfo:errorDetail];
|
||||
}
|
||||
|
||||
NSError* MailCoreCreateErrorFromSMTPCode(int errcode) {
|
||||
@@ -284,3 +284,31 @@ NSString *MailCoreDecodeMIMEPhrase(char *data) {
|
||||
free(decodedSubject);
|
||||
return result;
|
||||
}
|
||||
|
||||
NSArray * MailCoreStringArrayFromClist(clist *list) {
|
||||
clistiter *iter;
|
||||
NSMutableArray *stringSet = [NSMutableArray array];
|
||||
char *string;
|
||||
|
||||
if(list == NULL)
|
||||
return stringSet;
|
||||
|
||||
for(iter = clist_begin(list); iter != NULL; iter = clist_next(iter)) {
|
||||
string = clist_content(iter);
|
||||
NSString *strObj = [[NSString alloc] initWithUTF8String:string];
|
||||
[stringSet addObject:strObj];
|
||||
[strObj release];
|
||||
}
|
||||
|
||||
return stringSet;
|
||||
}
|
||||
|
||||
clist *MailCoreClistFromStringArray(NSArray *strings) {
|
||||
clist * str_list = clist_new();
|
||||
|
||||
for (NSString *str in strings) {
|
||||
clist_append(str_list, strdup([str UTF8String]));
|
||||
}
|
||||
|
||||
return str_list;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,5 @@
|
||||
@interface CTConnectedTest : SenTestCase
|
||||
@property (nonatomic, strong) CTCoreAccount *account;
|
||||
@property (nonatomic, strong) CTCoreFolder *folder;
|
||||
@property (nonatomic, strong) NSDictionary *credentials;
|
||||
@end
|
||||
+49
-8
@@ -35,15 +35,41 @@
|
||||
|
||||
@implementation CTConnectedTest {
|
||||
}
|
||||
@synthesize account, folder;
|
||||
NSString *SERVER = @"imap.gmail.com";
|
||||
NSString *USERNAME = @"mailcoretests@gmail.com";
|
||||
NSString *PASSWORD = @"MailCoreRockz";
|
||||
@synthesize account, folder, credentials;
|
||||
|
||||
/* Create a TestData/account.plist file to make these tests work. Start with this:
|
||||
|
||||
<?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>username</key>
|
||||
<string>username</string>
|
||||
<key>password</key>
|
||||
<string>password</string>
|
||||
<key>server</key>
|
||||
<string>server</string>
|
||||
<key>port</key>
|
||||
<integer>993</integer>
|
||||
<key>path</key>
|
||||
<string>MailCoreTests</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Because account.plist is included in the .gitignore file, your credentials won't be added
|
||||
to source control.
|
||||
|
||||
*/
|
||||
|
||||
- (void)setUp {
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/account" ofType:@"plist"];
|
||||
self.credentials = [NSDictionary dictionaryWithContentsOfFile:filePath];
|
||||
|
||||
STAssertNotNil(self.credentials, @"These tests will fail anyway if they can't connect");
|
||||
|
||||
self.account = [[CTCoreAccount alloc] init];
|
||||
[self connect];
|
||||
self.folder = [self.account folderWithPath:@"Test"];
|
||||
self.folder = [self.account folderWithPath:[self.credentials valueForKey:@"path"]];
|
||||
[self.folder connect];
|
||||
}
|
||||
|
||||
@@ -60,12 +86,27 @@ NSString *PASSWORD = @"MailCoreRockz";
|
||||
}
|
||||
|
||||
- (void)connect {
|
||||
[self.account connectToServer:SERVER port:993 connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain
|
||||
login:USERNAME password:PASSWORD];
|
||||
NSString *server = [self.credentials valueForKey:@"server"];
|
||||
int port = [[self.credentials objectForKey:@"port"] intValue];
|
||||
NSString *username = [self.credentials valueForKey:@"username"];
|
||||
NSString *password = [self.credentials valueForKey:@"password"];
|
||||
|
||||
STAssertFalse([server isEqualToString:@"server"], @"You need to provide your own account info");
|
||||
STAssertFalse([username isEqualToString:@"username"], @"You need to provide your own account info");
|
||||
STAssertFalse([password isEqualToString:@"password"], @"You need to provide your own account info");
|
||||
/* Once you've provided your own account info, create a folder with six messages in it.
|
||||
The path key in the account.plist should point to this directory, and you're ready! */
|
||||
|
||||
BOOL success = [self.account connectToServer:server port:port connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain login:username password:password];
|
||||
|
||||
STAssertTrue(success, @"should successfully connect to email account");
|
||||
if (!success) {
|
||||
NSLog(@"!!!!!!! Can't connect to account !!!!!!! Error: %@", [[self.account lastError] localizedDescription]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)disconnect {
|
||||
[self.folder disconnect];
|
||||
[self.account disconnect];
|
||||
}
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -34,32 +34,32 @@
|
||||
|
||||
@implementation CTCoreAttachmentTests
|
||||
- (void)testJPEG {
|
||||
NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6201.jpg"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6201" ofType:@"jpg"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
|
||||
STAssertEqualObjects(@"image/jpeg", [attach contentType], @"The content-type should have been image/jpeg");
|
||||
STAssertTrue([attach data] != nil, @"Data should not have been nil");
|
||||
[attach release];
|
||||
}
|
||||
|
||||
- (void)testPNG {
|
||||
NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6202.png"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6202" ofType:@"png"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
|
||||
STAssertEqualObjects(@"image/png", [attach contentType], @"The content-type should have been image/png");
|
||||
STAssertTrue([attach data] != nil, @"Data should not have been nil");
|
||||
[attach release];
|
||||
}
|
||||
|
||||
- (void)testTIFF {
|
||||
NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6193.tif"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6193" ofType:@"tif"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
|
||||
STAssertEqualObjects(@"image/tiff", [attach contentType], @"The content-type should have been image/TIFF");
|
||||
STAssertTrue([attach data] != nil, @"Data should not have been nil");
|
||||
[attach release];
|
||||
}
|
||||
|
||||
- (void)testNEF {
|
||||
NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6204.NEF"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6204" ofType:@"NEF"];
|
||||
CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
|
||||
STAssertEqualObjects(@"application/octet-stream", [attach contentType],
|
||||
@"The content-type should have been application/octet-stream");
|
||||
STAssertTrue([attach data] != nil, @"Data should not have been nil");
|
||||
|
||||
+11
-11
@@ -43,7 +43,7 @@
|
||||
STAssertTrue([msg uid] > 0, @"We should have the UID");
|
||||
STAssertTrue([msg messageSize] > 0, @"We always download message size");
|
||||
|
||||
STAssertNil([msg sentDateGMT], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg senderDate], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg subject], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg to], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg cc], @"We have no envelope so should be nil");
|
||||
@@ -52,7 +52,7 @@
|
||||
STAssertNil([msg bcc], @"We have no envelope so should be nil");
|
||||
|
||||
// This will force another download of message body data, checking to make sure it works
|
||||
NSString *body = [msg bodyPreferringPlainText];
|
||||
NSString *body = [msg body];
|
||||
STAssertTrue(body.length > 0, @"");
|
||||
}
|
||||
|
||||
@@ -63,14 +63,14 @@
|
||||
STAssertTrue([msg uid] > 0, @"We should have the UID");
|
||||
STAssertTrue([msg messageSize] > 0, @"We always download message size");
|
||||
|
||||
STAssertNotNil([msg sentDateGMT], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg senderDate], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg subject], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg to], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg sender], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg from], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
|
||||
// This will force another download of message body data, checking to make sure it works
|
||||
NSString *body = [msg bodyPreferringPlainText];
|
||||
NSString *body = [msg body];
|
||||
STAssertTrue(body.length > 0, @"");
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@
|
||||
STAssertTrue([msg uid] > 0, @"We should have the UID");
|
||||
STAssertTrue([msg messageSize] > 0, @"We always download message size");
|
||||
|
||||
STAssertNotNil([msg sentDateGMT], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg senderDate], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg subject], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg to], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg sender], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg from], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
|
||||
// This will force another download of message body data, checking to make sure it works
|
||||
NSString *body = [msg bodyPreferringPlainText];
|
||||
NSString *body = [msg body];
|
||||
STAssertTrue(body.length > 0, @"");
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
STAssertTrue([msg uid] > 0, @"We should have the UID");
|
||||
STAssertTrue([msg messageSize] > 0, @"We always download message size");
|
||||
|
||||
STAssertNil([msg sentDateGMT], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg senderDate], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg subject], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg to], @"We have no envelope so should be nil");
|
||||
STAssertNil([msg cc], @"We have no envelope so should be nil");
|
||||
@@ -108,7 +108,7 @@
|
||||
STAssertNil([msg bcc], @"We have no envelope so should be nil");
|
||||
|
||||
// A second call to fetch the body structure shouldn't be needed, we only need to fetch body
|
||||
NSString *body = [msg bodyPreferringPlainText];
|
||||
NSString *body = [msg body];
|
||||
STAssertTrue(body.length > 0, @"");
|
||||
}
|
||||
|
||||
@@ -119,14 +119,14 @@
|
||||
STAssertTrue([msg uid] > 0, @"We should have the UID");
|
||||
STAssertTrue([msg messageSize] > 0, @"We always download message size");
|
||||
|
||||
STAssertNotNil([msg sentDateGMT], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg senderDate], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg subject], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg to], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg sender], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
STAssertNotNil([msg from], @"We DO HAVE AN envelope so shouldn't be nil");
|
||||
|
||||
// A second call to fetch the body structure shouldn't be needed, we only need to fetch body
|
||||
NSString *body = [msg bodyPreferringPlainText];
|
||||
NSString *body = [msg body];
|
||||
STAssertTrue(body.length > 0, @"");
|
||||
}
|
||||
@end
|
||||
@end
|
||||
|
||||
+39
-16
@@ -38,7 +38,8 @@
|
||||
@implementation CTCoreMessageTests
|
||||
- (void)setUp {
|
||||
myMsg = [[CTCoreMessage alloc] init];
|
||||
myRealMsg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab" ofType:@""];
|
||||
myRealMsg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
@@ -46,6 +47,16 @@
|
||||
[myRealMsg release];
|
||||
}
|
||||
|
||||
- (void)testBody {
|
||||
STAssertTrue([[myRealMsg body] rangeOfString:@"Kiwi-dev mailing list"].location != NSNotFound, @"Expect to pull out the right text");
|
||||
NSLog(@"Body is %@", [myRealMsg body]);
|
||||
}
|
||||
|
||||
- (void)testHtmlBody {
|
||||
STAssertTrue([[myRealMsg htmlBody] rangeOfString:@"CTCoreMessage no longer depends"].location != NSNotFound, @"Expect to pull out the right text");
|
||||
NSLog(@"Html body is %@", [myRealMsg htmlBody]);
|
||||
}
|
||||
|
||||
- (void)testBasicSubject {
|
||||
[myMsg setSubject:@"Test value1!"];
|
||||
STAssertEqualObjects(@"Test value1!", [myMsg subject], @"Basic set and get of subject failed.");
|
||||
@@ -78,7 +89,8 @@
|
||||
}
|
||||
|
||||
- (void)testSubjectOnData {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
[msg fetchBodyStructure];
|
||||
STAssertEqualObjects(@"[Kiwi-dev] Revision 16", [msg subject], @"");
|
||||
NSRange notFound = NSMakeRange(NSNotFound, 0);
|
||||
@@ -93,11 +105,11 @@
|
||||
/* Do a few sanity checks on the str */
|
||||
NSRange notFound = NSMakeRange(NSNotFound, 0);
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"Date:"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"Message-ID:"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"MIME-Version: 1.0"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"Message-ID:"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"MIME-Version: 1.0"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"test"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"Content-Transfer-Encoding:"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(NSEqualRanges([str rangeOfString:@"not there"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"Content-Transfer-Encoding:"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(NSEqualRanges([str rangeOfString:@"not there"],notFound), @"Render sanity check failed!");
|
||||
}
|
||||
|
||||
- (void)testRenderWithToField {
|
||||
@@ -108,7 +120,7 @@
|
||||
/* Do a few sanity checks on the str */
|
||||
NSRange notFound = NSMakeRange(NSNotFound, 0);
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"message"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"To: Matt <test@test.com>"],notFound), @"Render sanity check failed!");
|
||||
STAssertTrue(!NSEqualRanges([str rangeOfString:@"To: Matt <test@test.com>"],notFound), @"Render sanity check failed!");
|
||||
}
|
||||
|
||||
- (void)testTo {
|
||||
@@ -126,7 +138,8 @@
|
||||
}
|
||||
|
||||
- (void)testFromSpecialChar {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/kiwi-dev/1162094633.15211_0.randymail-mx2:2,RSab"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/kiwi-dev/1162094633.15211_0.randymail-mx2:2,RSab" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
CTCoreAddress *addr = [[msg from] anyObject];
|
||||
STAssertEqualObjects(@"Joachim Mårtensson", [addr name], @"");
|
||||
[msg release];
|
||||
@@ -152,10 +165,19 @@
|
||||
}
|
||||
|
||||
- (void)testSentDate {
|
||||
// Is this right?? I'm super confused by this time zone stuff
|
||||
NSDate *sentDate = [myRealMsg sentDateGMT];
|
||||
NSDate *actualDate = [NSDate dateWithTimeIntervalSince1970:1167217609];
|
||||
STAssertEqualObjects(sentDate, actualDate, @"Date's should be equal!");
|
||||
NSTimeInterval sentSince1970 = [[myRealMsg senderDate] timeIntervalSince1970];
|
||||
|
||||
NSTimeInterval actualSince1970 = 1167196009;
|
||||
/*
|
||||
you can get this value by typing this into your browser console
|
||||
|
||||
> date = new Date('Tue, 26 Dec 2006 21:06:49 -0800 (PST)')
|
||||
Tue Dec 26 2006 21:06:49 GMT-0800 (PST)
|
||||
> date.getTime() / 1000
|
||||
1167196009
|
||||
*/
|
||||
|
||||
STAssertEquals(sentSince1970, actualSince1970, @"Dates should be equal!");
|
||||
}
|
||||
|
||||
- (void)testSettingFromTwice {
|
||||
@@ -166,16 +188,17 @@
|
||||
}
|
||||
|
||||
- (void)testAttachments {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:
|
||||
[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/png_attachment"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/png_attachment" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
[msg fetchBodyStructure];
|
||||
NSArray *attachments = [msg attachments];
|
||||
STAssertTrue([attachments count] == 1, @"Count should have been 1");
|
||||
STAssertEqualObjects([[attachments objectAtIndex:0] filename], @"Picture 1.png", @"Incorrect filename");
|
||||
CTBareAttachment *bareAttach = [attachments objectAtIndex:0];
|
||||
CTCoreAttachment *attach = [bareAttach fetchFullAttachment];
|
||||
NSData *origData = [NSData dataWithContentsOfFile:
|
||||
[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/Picture 1.png"]];
|
||||
|
||||
filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/Picture 1" ofType:@"png"];
|
||||
NSData *origData = [NSData dataWithContentsOfFile:filePath];
|
||||
STAssertEqualObjects(origData, attach.data, @"Original data and attach data should be the same");
|
||||
[msg release];
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
|
||||
#import <SenTestingKit/SenTestingKit.h>
|
||||
|
||||
const NSString *filePrefix;
|
||||
|
||||
@interface CTMIMETests : SenTestCase {
|
||||
|
||||
}
|
||||
|
||||
+21
-12
@@ -41,11 +41,10 @@
|
||||
#import "CTMIME_TextPart.h"
|
||||
#import "CTMIME_Enumerator.h"
|
||||
|
||||
const NSString *filePrefix = @"/Users/mronge/Projects/MailCore/";
|
||||
|
||||
@implementation CTMIMETests
|
||||
- (void)testMIMETextPart {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
|
||||
STAssertTrue([mime isKindOfClass:[CTMIME_MessagePart class]],@"Outmost MIME type should be Message but it's not!");
|
||||
STAssertTrue([[mime content] isKindOfClass:[CTMIME_MultiPart class]],@"Incorrect MIME structure found!");
|
||||
@@ -79,13 +78,19 @@ const NSString *filePrefix = @"/Users/mronge/Projects/MailCore/";
|
||||
|
||||
- (void)testBruteForce {
|
||||
// run it on a bunch of the files in the test data directory and see if we can get it to crash
|
||||
NSDirectoryEnumerator *dirEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:[filePrefix stringByAppendingString:@"TestData/kiwi-dev/"]];
|
||||
NSString *file;
|
||||
NSString *directory = [[NSBundle bundleForClass:[self class]] resourcePath];
|
||||
NSString *filesDirectory = [directory stringByAppendingPathComponent:@"TestData/kiwi-dev/"];
|
||||
|
||||
NSError *error;
|
||||
NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:filesDirectory error:&error];
|
||||
|
||||
NSRange notFound = NSMakeRange(NSNotFound, 0);
|
||||
while ((file = [dirEnumerator nextObject])) {
|
||||
for (NSString *file in directoryContents) {
|
||||
if (!NSEqualRanges([file rangeOfString:@".svn"],notFound))
|
||||
continue;
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@TestData/kiwi-dev/%@",filePrefix,file]];
|
||||
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:[NSString stringWithFormat:@"TestData/kiwi-dev/%@",file] ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
NSLog(@"%@", [msg subject]);
|
||||
[msg fetchBodyStructure];
|
||||
NSString *stuff = [msg body];
|
||||
@@ -95,7 +100,9 @@ const NSString *filePrefix = @"/Users/mronge/Projects/MailCore/";
|
||||
}
|
||||
|
||||
- (void)testImageJPEGAttachment {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/imagetest"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/imagetest" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
|
||||
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
|
||||
STAssertTrue([mime isKindOfClass:[CTMIME_MessagePart class]],@"Outmost MIME type should be Message but it's not!");
|
||||
STAssertTrue([[mime content] isKindOfClass:[CTMIME_MultiPart class]],@"Incorrect MIME structure found!");
|
||||
@@ -111,8 +118,9 @@ const NSString *filePrefix = @"/Users/mronge/Projects/MailCore/";
|
||||
}
|
||||
|
||||
- (void)testImagePNGAttachment {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:
|
||||
[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/png_attachment"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/png_attachment" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
|
||||
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:
|
||||
[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
|
||||
STAssertTrue([mime isKindOfClass:[CTMIME_MessagePart class]],
|
||||
@@ -133,8 +141,9 @@ const NSString *filePrefix = @"/Users/mronge/Projects/MailCore/";
|
||||
}
|
||||
|
||||
- (void)testEnumerator {
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:
|
||||
[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/png_attachment"]];
|
||||
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/png_attachment" ofType:@""];
|
||||
CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
|
||||
|
||||
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:
|
||||
[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
|
||||
CTMIME_Enumerator *enumerator = [mime mimeEnumerator];
|
||||
|
||||
+1
-1
Submodule libetpan updated: e43d8a0a11...fb73212f4d
Reference in New Issue
Block a user