diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2013-03-30 19:42:26 -0700 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2013-03-30 19:42:26 -0700 |
commit | 1e5482c0745a77b158ac07e1cc602f9ab2cc0caa (patch) | |
tree | cdcfff5920c926f0f3b681210905aa5ead1e9137 | |
parent | c51a8a2b44e6934de9d45d74ddec4b70b00f1abb (diff) |
Implemented ObjC API for SMTP and POP
43 files changed, 1059 insertions, 51 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index f7612fbc..0f168995 100644 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -220,6 +220,46 @@ C6A81BB41706891B00882C15 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6A81BB31706891B00882C15 /* CFNetwork.framework */; }; C6A81BBA17068C0600882C15 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BB717068C0600882C15 /* AppDelegate.mm */; }; C6A81BBB17068C0600882C15 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BB817068C0600882C15 /* main.m */; }; + C6A81BBF17068E5E00882C15 /* MCOSMTPSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BBE17068E5E00882C15 /* MCOSMTPSession.mm */; }; + C6A81BC017068E5E00882C15 /* MCOSMTPSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BBE17068E5E00882C15 /* MCOSMTPSession.mm */; }; + C6A81BC317068E9500882C15 /* MCOSMTPSendOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BC217068E9500882C15 /* MCOSMTPSendOperation.mm */; }; + C6A81BC417068E9500882C15 /* MCOSMTPSendOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BC217068E9500882C15 /* MCOSMTPSendOperation.mm */; }; + C6A81BC717068EB000882C15 /* MCOSMTPOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BC617068EB000882C15 /* MCOSMTPOperation.mm */; }; + C6A81BC817068EB000882C15 /* MCOSMTPOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BC617068EB000882C15 /* MCOSMTPOperation.mm */; }; + C6A81BD61706903500882C15 /* MCOPOPSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BD51706903500882C15 /* MCOPOPSession.mm */; }; + C6A81BD71706903500882C15 /* MCOPOPSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BD51706903500882C15 /* MCOPOPSession.mm */; }; + C6A81BDA1706903E00882C15 /* MCOPOPFetchHeaderOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BD91706903E00882C15 /* MCOPOPFetchHeaderOperation.mm */; }; + C6A81BDB1706903E00882C15 /* MCOPOPFetchHeaderOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BD91706903E00882C15 /* MCOPOPFetchHeaderOperation.mm */; }; + C6A81BDE1706904800882C15 /* MCOPOPFetchMessageOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BDD1706904800882C15 /* MCOPOPFetchMessageOperation.mm */; }; + C6A81BDF1706904800882C15 /* MCOPOPFetchMessageOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BDD1706904800882C15 /* MCOPOPFetchMessageOperation.mm */; }; + C6A81BE21706905600882C15 /* MCOPOPOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BE11706905600882C15 /* MCOPOPOperation.mm */; }; + C6A81BE31706905600882C15 /* MCOPOPOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BE11706905600882C15 /* MCOPOPOperation.mm */; }; + C6A81BE61706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BE51706906C00882C15 /* MCOPOPFetchMessagesOperation.mm */; }; + C6A81BE71706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BE51706906C00882C15 /* MCOPOPFetchMessagesOperation.mm */; }; + C6A81BE91707805B00882C15 /* MCOPOPSession.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BD41706903500882C15 /* MCOPOPSession.h */; }; + C6A81BEA1707805C00882C15 /* MCOPOPFetchHeaderOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BD81706903E00882C15 /* MCOPOPFetchHeaderOperation.h */; }; + C6A81BEB1707805E00882C15 /* MCOPOPFetchMessageOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BDC1706904800882C15 /* MCOPOPFetchMessageOperation.h */; }; + C6A81BEC1707805F00882C15 /* MCOPOPOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BE01706905600882C15 /* MCOPOPOperation.h */; }; + C6A81BED1707806100882C15 /* MCOPOPFetchMessagesOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BE41706906C00882C15 /* MCOPOPFetchMessagesOperation.h */; }; + C6A81BEE1707806500882C15 /* MCOSMTPSession.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BBD17068E5E00882C15 /* MCOSMTPSession.h */; }; + C6A81BEF1707806600882C15 /* MCOSMTPSendOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BC117068E9500882C15 /* MCOSMTPSendOperation.h */; }; + C6A81BF01707806800882C15 /* MCOSMTPOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BC517068EB000882C15 /* MCOSMTPOperation.h */; }; + C6A81BF1170780EC00882C15 /* MCOPOPSession.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BD41706903500882C15 /* MCOPOPSession.h */; }; + C6A81BF2170780F900882C15 /* MCOPOPOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BE01706905600882C15 /* MCOPOPOperation.h */; }; + C6A81BF3170780FB00882C15 /* MCOPOPFetchHeaderOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BD81706903E00882C15 /* MCOPOPFetchHeaderOperation.h */; }; + C6A81BF41707810900882C15 /* MCOPOPFetchMessageOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BDC1706904800882C15 /* MCOPOPFetchMessageOperation.h */; }; + C6A81BF51707810C00882C15 /* MCOPOPFetchMessagesOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BE41706906C00882C15 /* MCOPOPFetchMessagesOperation.h */; }; + C6A81BF61707810E00882C15 /* MCOSMTP.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BE81706A6B300882C15 /* MCOSMTP.h */; }; + C6A81BF71707811000882C15 /* MCOSMTPSession.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BBD17068E5E00882C15 /* MCOSMTPSession.h */; }; + C6A81BF81707811100882C15 /* MCOSMTPSendOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BC117068E9500882C15 /* MCOSMTPSendOperation.h */; }; + C6A81BF91707811500882C15 /* MCOSMTPOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BC517068EB000882C15 /* MCOSMTPOperation.h */; }; + C6A81BFA1707811D00882C15 /* MCOSMTP.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BE81706A6B300882C15 /* MCOSMTP.h */; }; + C6A81BFC1707821F00882C15 /* MCOPOP.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BFB170781BC00882C15 /* MCOPOP.h */; }; + C6A81BFD1707822200882C15 /* MCOPOP.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BFB170781BC00882C15 /* MCOPOP.h */; }; + C6A81C001707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BFF1707CEE500882C15 /* MCOPOPMessageInfo.mm */; }; + C6A81C011707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A81BFF1707CEE500882C15 /* MCOPOPMessageInfo.mm */; }; + C6A81C021707D96200882C15 /* MCOPOPMessageInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BFE1707CEE400882C15 /* MCOPOPMessageInfo.h */; }; + C6A81C031707D96500882C15 /* MCOPOPMessageInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BFE1707CEE400882C15 /* MCOPOPMessageInfo.h */; }; C6BA2B0C1705F4E6003F0E9E /* MCHTMLRendererCallback.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63CD68516BE148B00DB18F1 /* MCHTMLRendererCallback.h */; }; C6BA2B0D1705F4E6003F0E9E /* MCOMultipart.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C64BB26816FD44C2000DB34C /* MCOMultipart.h */; }; C6BA2B0E1705F4E6003F0E9E /* MCOMessageBuilder.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C64BB25F16FD438F000DB34C /* MCOMessageBuilder.h */; }; @@ -575,7 +615,16 @@ dstSubfolderSpec = 16; files = ( C63CD68C16BE1BC800DB18F1 /* MCHTMLRendererCallback.h in CopyFiles */, + C6A81BFC1707821F00882C15 /* MCOPOP.h in CopyFiles */, + C6A81BEB1707805E00882C15 /* MCOPOPFetchMessageOperation.h in CopyFiles */, + C6A81BEC1707805F00882C15 /* MCOPOPOperation.h in CopyFiles */, + C6A81BE91707805B00882C15 /* MCOPOPSession.h in CopyFiles */, C6F61FB1170288690073032E /* MCOMultipart.h in CopyFiles */, + C6A81BFA1707811D00882C15 /* MCOSMTP.h in CopyFiles */, + C6A81BEE1707806500882C15 /* MCOSMTPSession.h in CopyFiles */, + C6A81BF01707806800882C15 /* MCOSMTPOperation.h in CopyFiles */, + C6A81BED1707806100882C15 /* MCOPOPFetchMessagesOperation.h in CopyFiles */, + C6A81BEF1707806600882C15 /* MCOSMTPSendOperation.h in CopyFiles */, C6F61FAE170288640073032E /* MCOMessageBuilder.h in CopyFiles */, C6F61FB61702B5290073032E /* MCOIMAPBaseOperation.h in CopyFiles */, C6F61FB21702886B0073032E /* MCORFC822.h in CopyFiles */, @@ -700,8 +749,10 @@ C64EA774169E859600778456 /* MCPOPMessageInfo.h in CopyFiles */, C64EA775169E859600778456 /* MCPOPProgressCallback.h in CopyFiles */, C64EA776169E859600778456 /* MCPOPSession.h in CopyFiles */, + C6A81BEA1707805C00882C15 /* MCOPOPFetchHeaderOperation.h in CopyFiles */, C62C6F0716A7E7CC00737497 /* MCPOPFetchMessagesOperation.h in CopyFiles */, C64EA777169E859600778456 /* MCAttachment.h in CopyFiles */, + C6A81C031707D96500882C15 /* MCOPOPMessageInfo.h in CopyFiles */, C64EA7DC16A13A4C00778456 /* MCSMTPOperation.h in CopyFiles */, C64EA74D169E859600778456 /* MCSMTPAsyncSession.h in CopyFiles */, C64EA778169E859600778456 /* MCMessageBuilder.h in CopyFiles */, @@ -735,9 +786,18 @@ C6BA2B0C1705F4E6003F0E9E /* MCHTMLRendererCallback.h in CopyFiles */, C6BA2B0D1705F4E6003F0E9E /* MCOMultipart.h in CopyFiles */, C6BA2B0E1705F4E6003F0E9E /* MCOMessageBuilder.h in CopyFiles */, + C6A81BF1170780EC00882C15 /* MCOPOPSession.h in CopyFiles */, C6BA2B0F1705F4E6003F0E9E /* MCOIMAPBaseOperation.h in CopyFiles */, + C6A81BF2170780F900882C15 /* MCOPOPOperation.h in CopyFiles */, + C6A81BF51707810C00882C15 /* MCOPOPFetchMessagesOperation.h in CopyFiles */, + C6A81BF41707810900882C15 /* MCOPOPFetchMessageOperation.h in CopyFiles */, + C6A81BF61707810E00882C15 /* MCOSMTP.h in CopyFiles */, C6BA2B101705F4E6003F0E9E /* MCORFC822.h in CopyFiles */, + C6A81BFD1707822200882C15 /* MCOPOP.h in CopyFiles */, + C6A81BF91707811500882C15 /* MCOSMTPOperation.h in CopyFiles */, + C6A81BF81707811100882C15 /* MCOSMTPSendOperation.h in CopyFiles */, C6BA2B111705F4E6003F0E9E /* MCOConstants.h in CopyFiles */, + C6A81BF71707811000882C15 /* MCOSMTPSession.h in CopyFiles */, C6BA2B121705F4E6003F0E9E /* MCOAttachment.h in CopyFiles */, C6BA2B131705F4E6003F0E9E /* MCOMessageParser.h in CopyFiles */, C6BA2B141705F4E6003F0E9E /* MCOMessagePart.h in CopyFiles */, @@ -856,10 +916,12 @@ C6BA2B851705F4E6003F0E9E /* MCIMAPSession.h in CopyFiles */, C6BA2B861705F4E6003F0E9E /* MCPOP.h in CopyFiles */, C6BA2B871705F4E6003F0E9E /* MCPOPMessageInfo.h in CopyFiles */, + C6A81BF3170780FB00882C15 /* MCOPOPFetchHeaderOperation.h in CopyFiles */, C6BA2B881705F4E6003F0E9E /* MCPOPProgressCallback.h in CopyFiles */, C6BA2B891705F4E6003F0E9E /* MCPOPSession.h in CopyFiles */, C6BA2B8A1705F4E6003F0E9E /* MCPOPFetchMessagesOperation.h in CopyFiles */, C6BA2B8B1705F4E6003F0E9E /* MCAttachment.h in CopyFiles */, + C6A81C021707D96200882C15 /* MCOPOPMessageInfo.h in CopyFiles */, C6BA2B8C1705F4E6003F0E9E /* MCSMTPOperation.h in CopyFiles */, C6BA2B8D1705F4E6003F0E9E /* MCSMTPAsyncSession.h in CopyFiles */, C6BA2B8E1705F4E6003F0E9E /* MCMessageBuilder.h in CopyFiles */, @@ -1118,6 +1180,26 @@ C6A81BB717068C0600882C15 /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; }; C6A81BB817068C0600882C15 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; C6A81BB917068C0600882C15 /* tests-ios-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "tests-ios-Info.plist"; sourceTree = "<group>"; }; + C6A81BBD17068E5E00882C15 /* MCOSMTPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOSMTPSession.h; sourceTree = "<group>"; }; + C6A81BBE17068E5E00882C15 /* MCOSMTPSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOSMTPSession.mm; sourceTree = "<group>"; }; + C6A81BC117068E9500882C15 /* MCOSMTPSendOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOSMTPSendOperation.h; sourceTree = "<group>"; }; + C6A81BC217068E9500882C15 /* MCOSMTPSendOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOSMTPSendOperation.mm; sourceTree = "<group>"; }; + C6A81BC517068EB000882C15 /* MCOSMTPOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOSMTPOperation.h; sourceTree = "<group>"; }; + C6A81BC617068EB000882C15 /* MCOSMTPOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOSMTPOperation.mm; sourceTree = "<group>"; }; + C6A81BD41706903500882C15 /* MCOPOPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOPSession.h; sourceTree = "<group>"; }; + C6A81BD51706903500882C15 /* MCOPOPSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOPOPSession.mm; sourceTree = "<group>"; }; + C6A81BD81706903E00882C15 /* MCOPOPFetchHeaderOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOPFetchHeaderOperation.h; sourceTree = "<group>"; }; + C6A81BD91706903E00882C15 /* MCOPOPFetchHeaderOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOPOPFetchHeaderOperation.mm; sourceTree = "<group>"; }; + C6A81BDC1706904800882C15 /* MCOPOPFetchMessageOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOPFetchMessageOperation.h; sourceTree = "<group>"; }; + C6A81BDD1706904800882C15 /* MCOPOPFetchMessageOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOPOPFetchMessageOperation.mm; sourceTree = "<group>"; }; + C6A81BE01706905600882C15 /* MCOPOPOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOPOperation.h; sourceTree = "<group>"; }; + C6A81BE11706905600882C15 /* MCOPOPOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOPOPOperation.mm; sourceTree = "<group>"; }; + C6A81BE41706906C00882C15 /* MCOPOPFetchMessagesOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOPFetchMessagesOperation.h; sourceTree = "<group>"; }; + C6A81BE51706906C00882C15 /* MCOPOPFetchMessagesOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOPOPFetchMessagesOperation.mm; sourceTree = "<group>"; }; + C6A81BE81706A6B300882C15 /* MCOSMTP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCOSMTP.h; sourceTree = "<group>"; }; + C6A81BFB170781BC00882C15 /* MCOPOP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOP.h; sourceTree = "<group>"; }; + C6A81BFE1707CEE400882C15 /* MCOPOPMessageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOPOPMessageInfo.h; sourceTree = "<group>"; }; + C6A81BFF1707CEE500882C15 /* MCOPOPMessageInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOPOPMessageInfo.mm; sourceTree = "<group>"; }; C6BA2C191705F4E6003F0E9E /* libmailcore2-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libmailcore2-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C6CCC5C616FFE5190077A5FC /* MCORange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCORange.mm; sourceTree = "<group>"; }; C6CCC5C816FFE54F0077A5FC /* MCORange.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCORange.h; sourceTree = "<group>"; }; @@ -1289,7 +1371,6 @@ C64EA52C169E772200778456 = { isa = PBXGroup; children = ( - C6A81BB31706891B00882C15 /* CFNetwork.framework */, C64EA545169E78B100778456 /* src */, C64EA7A916A00AF400778456 /* tests */, C6A81BB517068C0600882C15 /* tests-ios */, @@ -1409,6 +1490,7 @@ C64EA68E169E847800778456 /* smtp */ = { isa = PBXGroup; children = ( + C64EA7E316A149EF00778456 /* MCAsyncSMTP.h */, C64EA68F169E847800778456 /* MCSMTPAsyncSession.cc */, C64EA690169E847800778456 /* MCSMTPAsyncSession.h */, C64EA79C169F29A700778456 /* MCSMTPSendWithDataOperation.cc */, @@ -1416,7 +1498,6 @@ C64EA7D816A1386500778456 /* MCSMTPOperation.cc */, C64EA7D916A1386600778456 /* MCSMTPOperation.h */, C64EA7E116A1425400778456 /* MCSMTPOperationCallback.h */, - C64EA7E316A149EF00778456 /* MCAsyncSMTP.h */, C64EA7E816A154B000778456 /* MCSMTPCheckAccountOperation.cc */, C64EA7E916A154B200778456 /* MCSMTPCheckAccountOperation.h */, ); @@ -1578,6 +1659,7 @@ C64EA78E169F259200778456 /* Frameworks */ = { isa = PBXGroup; children = ( + C6A81BB31706891B00882C15 /* CFNetwork.framework */, C64EA7B016A00BBB00778456 /* CoreServices.framework */, C64EA78F169F259200778456 /* Foundation.framework */, C6A81B921706840C00882C15 /* UIKit.framework */, @@ -1658,6 +1740,19 @@ C6F61F771701420A0073032E /* pop */ = { isa = PBXGroup; children = ( + C6A81BFB170781BC00882C15 /* MCOPOP.h */, + C6A81BD41706903500882C15 /* MCOPOPSession.h */, + C6A81BD51706903500882C15 /* MCOPOPSession.mm */, + C6A81BE01706905600882C15 /* MCOPOPOperation.h */, + C6A81BE11706905600882C15 /* MCOPOPOperation.mm */, + C6A81BD81706903E00882C15 /* MCOPOPFetchHeaderOperation.h */, + C6A81BD91706903E00882C15 /* MCOPOPFetchHeaderOperation.mm */, + C6A81BDC1706904800882C15 /* MCOPOPFetchMessageOperation.h */, + C6A81BDD1706904800882C15 /* MCOPOPFetchMessageOperation.mm */, + C6A81BE41706906C00882C15 /* MCOPOPFetchMessagesOperation.h */, + C6A81BE51706906C00882C15 /* MCOPOPFetchMessagesOperation.mm */, + C6A81BFE1707CEE400882C15 /* MCOPOPMessageInfo.h */, + C6A81BFF1707CEE500882C15 /* MCOPOPMessageInfo.mm */, ); path = pop; sourceTree = "<group>"; @@ -1665,6 +1760,13 @@ C6F61F781701420A0073032E /* smtp */ = { isa = PBXGroup; children = ( + C6A81BE81706A6B300882C15 /* MCOSMTP.h */, + C6A81BBD17068E5E00882C15 /* MCOSMTPSession.h */, + C6A81BBE17068E5E00882C15 /* MCOSMTPSession.mm */, + C6A81BC117068E9500882C15 /* MCOSMTPSendOperation.h */, + C6A81BC217068E9500882C15 /* MCOSMTPSendOperation.mm */, + C6A81BC517068EB000882C15 /* MCOSMTPOperation.h */, + C6A81BC617068EB000882C15 /* MCOSMTPOperation.mm */, ); path = smtp; sourceTree = "<group>"; @@ -1995,6 +2097,15 @@ C6F61F9917016B460073032E /* MCOIMAPSearchExpression.mm in Sources */, C6F61F9F17016EA10073032E /* MCOIMAPFolderInfo.m in Sources */, C6F61FB51702AB340073032E /* MCOIMAPBaseOperation.mm in Sources */, + C6A81BBF17068E5E00882C15 /* MCOSMTPSession.mm in Sources */, + C6A81BC317068E9500882C15 /* MCOSMTPSendOperation.mm in Sources */, + C6A81BC717068EB000882C15 /* MCOSMTPOperation.mm in Sources */, + C6A81BD61706903500882C15 /* MCOPOPSession.mm in Sources */, + C6A81BDA1706903E00882C15 /* MCOPOPFetchHeaderOperation.mm in Sources */, + C6A81BDE1706904800882C15 /* MCOPOPFetchMessageOperation.mm in Sources */, + C6A81BE21706905600882C15 /* MCOPOPOperation.mm in Sources */, + C6A81BE61706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */, + C6A81C001707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2145,6 +2256,15 @@ C6BA2C121705F4E6003F0E9E /* MCOIMAPSearchExpression.mm in Sources */, C6BA2C131705F4E6003F0E9E /* MCOIMAPFolderInfo.m in Sources */, C6BA2C141705F4E6003F0E9E /* MCOIMAPBaseOperation.mm in Sources */, + C6A81BC017068E5E00882C15 /* MCOSMTPSession.mm in Sources */, + C6A81BC417068E9500882C15 /* MCOSMTPSendOperation.mm in Sources */, + C6A81BC817068EB000882C15 /* MCOSMTPOperation.mm in Sources */, + C6A81BD71706903500882C15 /* MCOPOPSession.mm in Sources */, + C6A81BDB1706903E00882C15 /* MCOPOPFetchHeaderOperation.mm in Sources */, + C6A81BDF1706904800882C15 /* MCOPOPFetchMessageOperation.mm in Sources */, + C6A81BE31706905600882C15 /* MCOPOPOperation.mm in Sources */, + C6A81BE71706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */, + C6A81C011707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2394,6 +2514,10 @@ ); INFOPLIST_FILE = "../tests-ios/tests-ios-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../Externals/libsasl-ios/lib/sasl2\"", + ); OTHER_LDFLAGS = ( "-lctemplate-ios", "-letpan-ios", @@ -2428,6 +2552,10 @@ ); INFOPLIST_FILE = "../tests-ios/tests-ios-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../Externals/libsasl-ios/lib/sasl2\"", + ); OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_LDFLAGS = ( "-lctemplate-ios", @@ -2509,6 +2637,7 @@ C6A81BAB1706840C00882C15 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; C6BA2C161705F4E6003F0E9E /* Build configuration list for PBXNativeTarget "mailcore2 ios" */ = { isa = XCConfigurationList; diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc index 624fa6c2..155dd6e0 100644 --- a/src/async/pop/MCPOPAsyncSession.cc +++ b/src/async/pop/MCPOPAsyncSession.cc @@ -125,7 +125,7 @@ POPFetchHeaderOperation * POPAsyncSession::fetchHeaderOperation(unsigned int ind return op; } -POPFetchMessageOperation * POPAsyncSession::fetchMessage(unsigned int index) +POPFetchMessageOperation * POPAsyncSession::fetchMessageOperation(unsigned int index) { POPFetchMessageOperation * op = new POPFetchMessageOperation(); op->setSession(this); @@ -134,7 +134,7 @@ POPFetchMessageOperation * POPAsyncSession::fetchMessage(unsigned int index) return op; } -POPOperation * POPAsyncSession::deleteMessages(Array * indexes) +POPOperation * POPAsyncSession::deleteMessagesOperation(IndexSet * indexes) { POPDeleteMessagesOperation * op = new POPDeleteMessagesOperation(); op->setSession(this); diff --git a/src/async/pop/MCPOPAsyncSession.h b/src/async/pop/MCPOPAsyncSession.h index 4732eefd..66401eb6 100644 --- a/src/async/pop/MCPOPAsyncSession.h +++ b/src/async/pop/MCPOPAsyncSession.h @@ -55,10 +55,10 @@ namespace mailcore { virtual POPFetchHeaderOperation * fetchHeaderOperation(unsigned int index); - virtual POPFetchMessageOperation * fetchMessage(unsigned int index); + virtual POPFetchMessageOperation * fetchMessageOperation(unsigned int index); // Will disconnect. - virtual POPOperation * deleteMessages(Array * indexes); + virtual POPOperation * deleteMessagesOperation(IndexSet * indexes); private: POPSession * mSession; diff --git a/src/async/pop/MCPOPDeleteMessagesOperation.cc b/src/async/pop/MCPOPDeleteMessagesOperation.cc index d96789f8..a5d8907b 100644 --- a/src/async/pop/MCPOPDeleteMessagesOperation.cc +++ b/src/async/pop/MCPOPDeleteMessagesOperation.cc @@ -23,12 +23,12 @@ POPDeleteMessagesOperation::~POPDeleteMessagesOperation() MC_SAFE_RELEASE(mMessageIndexes); } -void POPDeleteMessagesOperation::setMessageIndexes(Array * indexes) +void POPDeleteMessagesOperation::setMessageIndexes(IndexSet * indexes) { - MC_SAFE_REPLACE_RETAIN(Array, mMessageIndexes, indexes); + MC_SAFE_REPLACE_RETAIN(IndexSet, mMessageIndexes, indexes); } -Array * POPDeleteMessagesOperation::messageIndexes() +IndexSet * POPDeleteMessagesOperation::messageIndexes() { return mMessageIndexes; } @@ -39,12 +39,14 @@ void POPDeleteMessagesOperation::main() return; ErrorCode error; - for(unsigned int i = 0 ; i < mMessageIndexes->count() ; i ++) { - Value * value = (Value *) mMessageIndexes->objectAtIndex(i); - session()->session()->deleteMessage(value->unsignedIntValue(), &error); - if (error != ErrorNone) { - setError(error); - return; + for(unsigned int i = 0 ; i < mMessageIndexes->rangesCount() ; i ++) { + Range range = mMessageIndexes->allRanges()[i]; + for(unsigned int k = 0 ; k <= range.length ; k ++) { + session()->session()->deleteMessage((unsigned int) (range.location + k), &error); + if (error != ErrorNone) { + setError(error); + return; + } } } session()->session()->disconnect(); diff --git a/src/async/pop/MCPOPDeleteMessagesOperation.h b/src/async/pop/MCPOPDeleteMessagesOperation.h index e5166e21..c7819ce6 100644 --- a/src/async/pop/MCPOPDeleteMessagesOperation.h +++ b/src/async/pop/MCPOPDeleteMessagesOperation.h @@ -20,14 +20,14 @@ namespace mailcore { POPDeleteMessagesOperation(); virtual ~POPDeleteMessagesOperation(); - virtual void setMessageIndexes(Array * indexes); - virtual Array * messageIndexes(); + virtual void setMessageIndexes(IndexSet * indexes); + virtual IndexSet * messageIndexes(); public: // subclass behavior virtual void main(); private: - Array * mMessageIndexes; + IndexSet * mMessageIndexes; }; diff --git a/src/async/pop/MCPOPFetchMessagesOperation.h b/src/async/pop/MCPOPFetchMessagesOperation.h index f21afa94..1078257c 100644 --- a/src/async/pop/MCPOPFetchMessagesOperation.h +++ b/src/async/pop/MCPOPFetchMessagesOperation.h @@ -19,7 +19,7 @@ namespace mailcore { POPFetchMessagesOperation(); virtual ~POPFetchMessagesOperation(); - virtual Array * messages(); + virtual Array * /* POPMessageInfo */ messages(); public: // subclass behavior virtual void main(); diff --git a/src/core/pop/MCPOPSession.h b/src/core/pop/MCPOPSession.h index cab3e50e..1f9af5cc 100644 --- a/src/core/pop/MCPOPSession.h +++ b/src/core/pop/MCPOPSession.h @@ -73,7 +73,7 @@ namespace mailcore { virtual void login(ErrorCode * pError); - Array * fetchMessages(ErrorCode * pError); + Array * /* POPMessageInfo */ fetchMessages(ErrorCode * pError); MessageHeader * fetchHeader(unsigned int index, ErrorCode * pError); MessageHeader * fetchHeader(POPMessageInfo * msg, ErrorCode * pError); diff --git a/src/objc/MCObjC.h b/src/objc/MCObjC.h index 8336de13..ca817cff 100644 --- a/src/objc/MCObjC.h +++ b/src/objc/MCObjC.h @@ -15,6 +15,8 @@ #import <mailcore/MCOAbstract.h> #import <mailcore/MCOIMAP.h> #import <mailcore/MCORFC822.h> +#import <mailcore/MCOPOP.h> +#import <mailcore/MCOSMTP.h> #endif diff --git a/src/objc/imap/MCOIMAPAppendMessageOperation.mm b/src/objc/imap/MCOIMAPAppendMessageOperation.mm index dc3409f7..678fb79d 100644 --- a/src/objc/imap/MCOIMAPAppendMessageOperation.mm +++ b/src/objc/imap/MCOIMAPAppendMessageOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, uint32_t createdUID); +typedef void (^CompletionType)(NSError *error, uint32_t createdUID); @implementation MCOIMAPAppendMessageOperation { - completionType _completionBlock; + CompletionType _completionBlock; MCOIMAPBaseOperationProgressBlock _progress; } diff --git a/src/objc/imap/MCOIMAPBaseOperation.mm b/src/objc/imap/MCOIMAPBaseOperation.mm index f89afc0f..be398ece 100644 --- a/src/objc/imap/MCOIMAPBaseOperation.mm +++ b/src/objc/imap/MCOIMAPBaseOperation.mm @@ -12,10 +12,6 @@ #import "MCAsyncIMAP.h" -@interface MCOIMAPBaseOperation () - -@end - class MCOIMAPBaseOperationIMAPCallback : public mailcore::IMAPOperationCallback { public: MCOIMAPBaseOperationIMAPCallback(MCOIMAPBaseOperation * op) diff --git a/src/objc/imap/MCOIMAPCapabilityOperation.mm b/src/objc/imap/MCOIMAPCapabilityOperation.mm index 97a635da..8e103bbc 100644 --- a/src/objc/imap/MCOIMAPCapabilityOperation.mm +++ b/src/objc/imap/MCOIMAPCapabilityOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, MCOIndexSet * capabilities); +typedef void (^CompletionType)(NSError *error, MCOIndexSet * capabilities); @implementation MCOIMAPCapabilityOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPCapabilityOperation diff --git a/src/objc/imap/MCOIMAPCopyMessagesOperation.mm b/src/objc/imap/MCOIMAPCopyMessagesOperation.mm index ddc80af6..8ac94c4e 100644 --- a/src/objc/imap/MCOIMAPCopyMessagesOperation.mm +++ b/src/objc/imap/MCOIMAPCopyMessagesOperation.mm @@ -14,10 +14,10 @@ #import "MCOUtils.h" #import "MCOIndexSet.h" -typedef void (^completionType)(NSError *error, MCOIndexSet * destUids); +typedef void (^CompletionType)(NSError *error, MCOIndexSet * destUids); @implementation MCOIMAPCopyMessagesOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPCopyMessagesOperation diff --git a/src/objc/imap/MCOIMAPFetchContentOperation.mm b/src/objc/imap/MCOIMAPFetchContentOperation.mm index d4e4192b..1f84d9d8 100644 --- a/src/objc/imap/MCOIMAPFetchContentOperation.mm +++ b/src/objc/imap/MCOIMAPFetchContentOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, NSData * data); +typedef void (^CompletionType)(NSError *error, NSData * data); @implementation MCOIMAPFetchContentOperation { - completionType _completionBlock; + CompletionType _completionBlock; MCOIMAPBaseOperationProgressBlock _progress; } diff --git a/src/objc/imap/MCOIMAPFetchFoldersOperation.h b/src/objc/imap/MCOIMAPFetchFoldersOperation.h index 65410c39..8f7b6592 100644 --- a/src/objc/imap/MCOIMAPFetchFoldersOperation.h +++ b/src/objc/imap/MCOIMAPFetchFoldersOperation.h @@ -10,9 +10,9 @@ #define __MAILCORE_MCOIMAPFETCHFOLDERSOPERATION_H_ -#import <mailcore/MCOOperation.h> +#import <mailcore/MCOIMAPBaseOperation.h> -@interface MCOIMAPFetchFoldersOperation : MCOOperation +@interface MCOIMAPFetchFoldersOperation : MCOIMAPBaseOperation - (void)start:(void (^)(NSError *error, NSArray *folder))completionBlock; @end diff --git a/src/objc/imap/MCOIMAPFetchFoldersOperation.mm b/src/objc/imap/MCOIMAPFetchFoldersOperation.mm index abf59611..7e33efe2 100644 --- a/src/objc/imap/MCOIMAPFetchFoldersOperation.mm +++ b/src/objc/imap/MCOIMAPFetchFoldersOperation.mm @@ -18,10 +18,10 @@ using namespace mailcore; -typedef void (^completionType)(NSError *error, NSArray *folder); +typedef void (^CompletionType)(NSError *error, NSArray *folder); @implementation MCOIMAPFetchFoldersOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPFetchFoldersOperation diff --git a/src/objc/imap/MCOIMAPFetchMessagesOperation.mm b/src/objc/imap/MCOIMAPFetchMessagesOperation.mm index c6a3699d..6aca50c2 100644 --- a/src/objc/imap/MCOIMAPFetchMessagesOperation.mm +++ b/src/objc/imap/MCOIMAPFetchMessagesOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, NSArray * messages, MCOIndexSet * vanishedMessages); +typedef void (^CompletionType)(NSError *error, NSArray * messages, MCOIndexSet * vanishedMessages); @implementation MCOIMAPFetchMessagesOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPFetchMessagesOperation diff --git a/src/objc/imap/MCOIMAPFetchNamespaceOperation.mm b/src/objc/imap/MCOIMAPFetchNamespaceOperation.mm index 798194b2..cc3a7473 100644 --- a/src/objc/imap/MCOIMAPFetchNamespaceOperation.mm +++ b/src/objc/imap/MCOIMAPFetchNamespaceOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, NSDictionary * namespaces); +typedef void (^CompletionType)(NSError *error, NSDictionary * namespaces); @implementation MCOIMAPFetchNamespaceOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPFetchNamespaceOperation diff --git a/src/objc/imap/MCOIMAPFolderInfoOperation.h b/src/objc/imap/MCOIMAPFolderInfoOperation.h index ebe881b2..ed11da95 100644 --- a/src/objc/imap/MCOIMAPFolderInfoOperation.h +++ b/src/objc/imap/MCOIMAPFolderInfoOperation.h @@ -7,7 +7,6 @@ // #import <mailcore/MCOIMAPBaseOperation.h> -#import <mailcore/MCOIMAPOperation.h> #ifndef __MAILCORE_MCOIMAPFOLDERINFOOPERATION_H_ diff --git a/src/objc/imap/MCOIMAPFolderInfoOperation.mm b/src/objc/imap/MCOIMAPFolderInfoOperation.mm index 5a7697d7..f896eac8 100644 --- a/src/objc/imap/MCOIMAPFolderInfoOperation.mm +++ b/src/objc/imap/MCOIMAPFolderInfoOperation.mm @@ -14,10 +14,10 @@ #import "MCOIMAPFolderInfo.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, MCOIMAPFolderInfo *info); +typedef void (^CompletionType)(NSError *error, MCOIMAPFolderInfo *info); @implementation MCOIMAPFolderInfoOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPFolderInfoOperation diff --git a/src/objc/imap/MCOIMAPIdentityOperation.mm b/src/objc/imap/MCOIMAPIdentityOperation.mm index ab358adf..ab4dab6a 100644 --- a/src/objc/imap/MCOIMAPIdentityOperation.mm +++ b/src/objc/imap/MCOIMAPIdentityOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error, NSDictionary * serverIdentity); +typedef void (^CompletionType)(NSError *error, NSDictionary * serverIdentity); @implementation MCOIMAPIdentityOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPIdentityOperation diff --git a/src/objc/imap/MCOIMAPIdleOperation.mm b/src/objc/imap/MCOIMAPIdleOperation.mm index 3de7b141..76591d72 100644 --- a/src/objc/imap/MCOIMAPIdleOperation.mm +++ b/src/objc/imap/MCOIMAPIdleOperation.mm @@ -13,10 +13,10 @@ #import "MCOOperation+Private.h" #import "MCOUtils.h" -typedef void (^completionType)(NSError *error); +typedef void (^CompletionType)(NSError *error); @implementation MCOIMAPIdleOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPIdleOperation diff --git a/src/objc/imap/MCOIMAPOperation.mm b/src/objc/imap/MCOIMAPOperation.mm index a928fede..e0938fd3 100644 --- a/src/objc/imap/MCOIMAPOperation.mm +++ b/src/objc/imap/MCOIMAPOperation.mm @@ -13,10 +13,10 @@ #import "MCOUtils.h" -typedef void (^completionType)(NSError *error); +typedef void (^CompletionType)(NSError *error); @implementation MCOIMAPOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPOperation diff --git a/src/objc/imap/MCOIMAPSearchOperation.mm b/src/objc/imap/MCOIMAPSearchOperation.mm index 1246ca02..a8eaf937 100644 --- a/src/objc/imap/MCOIMAPSearchOperation.mm +++ b/src/objc/imap/MCOIMAPSearchOperation.mm @@ -14,10 +14,10 @@ #import "MCOUtils.h" #import "MCOIndexSet.h" -typedef void (^completionType)(NSError *error, MCOIndexSet * searchResult); +typedef void (^CompletionType)(NSError *error, MCOIndexSet * searchResult); @implementation MCOIMAPSearchOperation { - completionType _completionBlock; + CompletionType _completionBlock; } #define nativeType mailcore::IMAPSearchOperation diff --git a/src/objc/pop/MCOPOP.h b/src/objc/pop/MCOPOP.h new file mode 100644 index 00000000..e06022e5 --- /dev/null +++ b/src/objc/pop/MCOPOP.h @@ -0,0 +1,19 @@ +// +// MCOPOP.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/30/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef mailcore2_MCOPOP_h +#define mailcore2_MCOPOP_h + +#import <mailcore/MCOPOPSession.h> +#import <mailcore/MCOPOPOperation.h> +#import <mailcore/MCOPOPFetchHeaderOperation.h> +#import <mailcore/MCOPOPFetchMessageOperation.h> +#import <mailcore/MCOPOPFetchMessagesOperation.h> +#import <mailcore/MCOPOPMessageInfo.h> + +#endif diff --git a/src/objc/pop/MCOPOPFetchHeaderOperation.h b/src/objc/pop/MCOPOPFetchHeaderOperation.h new file mode 100644 index 00000000..74ed96ef --- /dev/null +++ b/src/objc/pop/MCOPOPFetchHeaderOperation.h @@ -0,0 +1,22 @@ +// +// MCOFetchHeaderOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOPOPFETCHHEADEROPERATION_H_ + +#define __MAILCORE_MCOPOPFETCHHEADEROPERATION_H_ + +#import <Foundation/Foundation.h> +#import <mailcore/MCOPOPOperation.h> + +@class MCOMessageHeader; + +@interface MCOPOPFetchHeaderOperation : MCOPOPOperation +- (void)start:(void (^)(NSError *error, MCOMessageHeader * header))completionBlock; +@end + +#endif diff --git a/src/objc/pop/MCOPOPFetchHeaderOperation.mm b/src/objc/pop/MCOPOPFetchHeaderOperation.mm new file mode 100644 index 00000000..f7efea81 --- /dev/null +++ b/src/objc/pop/MCOPOPFetchHeaderOperation.mm @@ -0,0 +1,56 @@ +// +// MCOFetchHeaderOperation.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOPOPFetchHeaderOperation.h" + +#include "MCAsyncPOP.h" + +#import "MCOUtils.h" +#import "MCOOperation+Private.h" + +typedef void (^CompletionType)(NSError *error, MCOMessageHeader * header); + +@implementation MCOPOPFetchHeaderOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::POPFetchHeaderOperation + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (void) dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void)start:(void (^)(NSError *error, MCOMessageHeader * header))completionBlock +{ + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)operationCompleted { + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil, MCO_TO_OBJC(op->header())); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); + } +} + +@end diff --git a/src/objc/pop/MCOPOPFetchMessageOperation.h b/src/objc/pop/MCOPOPFetchMessageOperation.h new file mode 100644 index 00000000..231a5cb8 --- /dev/null +++ b/src/objc/pop/MCOPOPFetchMessageOperation.h @@ -0,0 +1,26 @@ +// +// MCOFetchMessageOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOPOPFETCHMESSAGEOPERATION_H_ + +#define __MAILCORE_MCOPOPFETCHMESSAGEOPERATION_H_ + +#import <Foundation/Foundation.h> +#import <mailcore/MCOPOPOperation.h> + +typedef void (^MCOPOPOperationProgressBlock)(unsigned int current, unsigned int maximum); + +@interface MCOPOPFetchMessageOperation : MCOPOPOperation + +@property (nonatomic, copy) MCOPOPOperationProgressBlock progress; + +- (void)start:(void (^)(NSError *error, NSData * messageData))completionBlock; + +@end + +#endif diff --git a/src/objc/pop/MCOPOPFetchMessageOperation.mm b/src/objc/pop/MCOPOPFetchMessageOperation.mm new file mode 100644 index 00000000..d2c1fde7 --- /dev/null +++ b/src/objc/pop/MCOPOPFetchMessageOperation.mm @@ -0,0 +1,99 @@ +// +// MCOFetchMessageOperation.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOPOPFetchMessageOperation.h" + +#import "MCAsyncPOP.h" + +#import "MCOUtils.h" +#import "MCOOperation+Private.h" + +#define nativeType mailcore::POPFetchMessageOperation + +typedef void (^CompletionType)(NSError *error, NSData * messageData); + +@interface MCOPOPFetchMessageOperation () + +- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum; + +@end + +class MCOPOPFetchMessageOperationCallback : public mailcore::POPOperationCallback { +public: + MCOPOPFetchMessageOperationCallback(MCOPOPFetchMessageOperation * op) + { + mOperation = op; + } + + virtual void bodyProgress(mailcore::POPOperation * session, unsigned int current, unsigned int maximum) { + [mOperation bodyProgress:current maximum:maximum]; + } + +private: + MCOPOPFetchMessageOperation * mOperation; +}; + +@implementation MCOPOPFetchMessageOperation { + CompletionType _completionBlock; + MCOPOPFetchMessageOperationCallback * _popCallback; + MCOPOPOperationProgressBlock _progress; +} + +@synthesize progress = _progress; + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (id)initWithMCOperation:(mailcore::Operation *)op +{ + self = [super initWithMCOperation:op]; + + _popCallback = new MCOPOPFetchMessageOperationCallback(self); + ((mailcore::POPOperation *) op)->setPopCallback(_popCallback); + + return self; +} + +- (void) dealloc +{ + [_progress release]; + [_completionBlock release]; + delete _popCallback; + [super dealloc]; +} + +- (void)start:(void (^)(NSError *error, NSData * messageData))completionBlock { + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)operationCompleted { + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil, MCO_TO_OBJC(op->data())); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); + } +} + +- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum +{ + if (_progress != NULL) { + _progress(current, maximum); + } +} + +@end diff --git a/src/objc/pop/MCOPOPFetchMessagesOperation.h b/src/objc/pop/MCOPOPFetchMessagesOperation.h new file mode 100644 index 00000000..d6d33965 --- /dev/null +++ b/src/objc/pop/MCOPOPFetchMessagesOperation.h @@ -0,0 +1,22 @@ +// +// MCOPOPFetchMessagesOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOPOPFETCHMESSAGESOPERATION_H_ + +#define __MAILCORE_MCOPOPFETCHMESSAGESOPERATION_H_ + +#import <Foundation/Foundation.h> +#import <mailcore/MCOPOPOperation.h> + +@interface MCOPOPFetchMessagesOperation : MCOPOPOperation + +- (void)start:(void (^)(NSError *error, NSArray * messages))completionBlock; + +@end + +#endif diff --git a/src/objc/pop/MCOPOPFetchMessagesOperation.mm b/src/objc/pop/MCOPOPFetchMessagesOperation.mm new file mode 100644 index 00000000..61168f80 --- /dev/null +++ b/src/objc/pop/MCOPOPFetchMessagesOperation.mm @@ -0,0 +1,57 @@ +// +// MCOPOPFetchMessagesOperation.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOPOPFetchMessagesOperation.h" + +#include "MCAsyncPOP.h" + +#import "MCOOperation+Private.h" +#import "MCOUtils.h" + +typedef void (^CompletionType)(NSError *error, NSArray * messages); + +@implementation MCOPOPFetchMessagesOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::POPFetchMessagesOperation + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (void) dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void)start:(void (^)(NSError *error, NSArray * messages))completionBlock +{ + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)operationCompleted { + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil, MCO_TO_OBJC(op->messages())); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); + } +} + + +@end diff --git a/src/objc/pop/MCOPOPMessageInfo.h b/src/objc/pop/MCOPOPMessageInfo.h new file mode 100644 index 00000000..5c6b529f --- /dev/null +++ b/src/objc/pop/MCOPOPMessageInfo.h @@ -0,0 +1,17 @@ +// +// MCOPOPMessageInfo.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/30/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@interface MCOPOPMessageInfo : NSObject <NSCopying> + +@property (nonatomic, assign) unsigned int index; +@property (nonatomic, assign) unsigned int size; +@property (nonatomic, copy) NSString * uid; + +@end diff --git a/src/objc/pop/MCOPOPMessageInfo.mm b/src/objc/pop/MCOPOPMessageInfo.mm new file mode 100644 index 00000000..55a4e1b6 --- /dev/null +++ b/src/objc/pop/MCOPOPMessageInfo.mm @@ -0,0 +1,71 @@ +// +// MCOPOPMessageInfo.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/30/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOPOPMessageInfo.h" + +#include "MCAsyncPOP.h" +#include "MCPOP.h" + +#import "MCOUtils.h" + +@implementation MCOPOPMessageInfo { + mailcore::POPMessageInfo * _nativeInfo; +} + +#define nativeType mailcore::POPMessageInfo + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + +- (id) copyWithZone:(NSZone *)zone +{ + nativeType * nativeObject = (nativeType *) [self mco_mcObject]->copy(); + id result = [[self class] mco_objectWithMCObject:nativeObject]; + MC_SAFE_RELEASE(nativeObject); + return [result retain]; +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + mailcore::POPMessageInfo * folder = (mailcore::POPMessageInfo *) object; + return [[[self alloc] initWithMCPOPMessageInfo:folder] autorelease]; +} + +- (mailcore::Object *) mco_mcObject +{ + return _nativeInfo; +} + +- (NSString *) description +{ + return MCO_OBJC_BRIDGE_GET(description); +} + +- (id) initWithMCPOPMessageInfo:(mailcore::POPMessageInfo *)info +{ + self = [super init]; + + _nativeInfo = info; + _nativeInfo->retain(); + + return self; +} + +- (void) dealloc +{ + MC_SAFE_RELEASE(_nativeInfo); + [super dealloc]; +} + +MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setIndex, index) +MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setSize, size) +MCO_OBJC_SYNTHESIZE_STRING(setUid, uid) + +@end diff --git a/src/objc/pop/MCOPOPOperation.h b/src/objc/pop/MCOPOPOperation.h new file mode 100644 index 00000000..774ff4ac --- /dev/null +++ b/src/objc/pop/MCOPOPOperation.h @@ -0,0 +1,20 @@ +// +// MCODeleteMessagesOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOPOPOPERATION_H_ + +#define __MAILCORE_MCOPOPOPERATION_H_ + +#import <Foundation/Foundation.h> +#import <mailcore/MCOOperation.h> + +@interface MCOPOPOperation : MCOOperation +- (void)start:(void (^)(NSError *error))completionBlock; +@end + +#endif diff --git a/src/objc/pop/MCOPOPOperation.mm b/src/objc/pop/MCOPOPOperation.mm new file mode 100644 index 00000000..d224846a --- /dev/null +++ b/src/objc/pop/MCOPOPOperation.mm @@ -0,0 +1,41 @@ +// +// MCODeleteMessagesOperation.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOPOPOperation.h" + +#include "MCAsyncPOP.h" + +#import "MCOUtils.h" +#import "MCOOperation+Private.h" + +typedef void (^CompletionType)(NSError *error); + +@implementation MCOPOPOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::POPOperation + +- (void) dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void)start:(void (^)(NSError *error))completionBlock { + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)operationCompleted { + NSError * error = [NSError mco_errorWithErrorCode:MCO_NATIVE_INSTANCE->error()]; + _completionBlock(error); +} + + +@end diff --git a/src/objc/pop/MCOPOPSession.h b/src/objc/pop/MCOPOPSession.h new file mode 100644 index 00000000..ae9bf1d9 --- /dev/null +++ b/src/objc/pop/MCOPOPSession.h @@ -0,0 +1,43 @@ +// +// MCOPOPSession.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOPOPSESSION_H_ + +#define __MAILCORE_MCOPOPSESSION_H_ + +#import <Foundation/Foundation.h> + +#import <mailcore/MCOConstants.h> + +@class MCOPOPFetchMessagesOperation; +@class MCOPOPFetchHeaderOperation; +@class MCOPOPFetchMessageOperation; +@class MCOPOPOperation; +@class MCOIndexSet; + +@interface MCOPOPSession : NSObject + +@property (nonatomic, copy) NSString * hostname; +@property (nonatomic, assign) unsigned int port; +@property (nonatomic, copy) NSString * username; +@property (nonatomic, copy) NSString * password; +@property (nonatomic, assign) MCOAuthType authType; +@property (nonatomic, assign) MCOConnectionType connectionType; +@property (nonatomic, assign) NSTimeInterval timeout; +@property (nonatomic, assign, getter=isCheckCertificateEnabled) BOOL checkCertificateEnabled; + +- (MCOPOPFetchMessagesOperation *) fetchMessagesOperation; +- (MCOPOPFetchHeaderOperation *) fetchHeaderOperationWithIndex:(unsigned int)index; +- (MCOPOPFetchMessageOperation *) fetchMessageOperationWithIndex:(unsigned int)index; + +// Will disconnect. +- (MCOPOPOperation *) deleteMessagesWithIndexes:(MCOIndexSet *)indexes; + +@end + +#endif diff --git a/src/objc/pop/MCOPOPSession.mm b/src/objc/pop/MCOPOPSession.mm new file mode 100644 index 00000000..1f468e99 --- /dev/null +++ b/src/objc/pop/MCOPOPSession.mm @@ -0,0 +1,83 @@ +// +// MCOPOPSession.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOPOPSession.h" + +#include "MCAsyncPOP.h" + +#import "MCOUtils.h" +#import "MCOPOPOperation.h" +#import "MCOOperation+Private.h" +#import "MCOPOPFetchMessagesOperation.h" + +@implementation MCOPOPSession { + mailcore::POPAsyncSession * _session; +} + +#define nativeType mailcore::POPAsyncSession + +- (mailcore::Object *) mco_mcObject +{ + return _session; +} + +- (NSString *) description +{ + return MCO_OBJC_BRIDGE_GET(description); +} + +- (id)init { + self = [super init]; + if (self) { + _session = new mailcore::POPAsyncSession(); + } + return self; +} + +- (void)dealloc { + _session->release(); + [super dealloc]; +} + +MCO_OBJC_SYNTHESIZE_STRING(setHostname, hostname) +MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setPort, port) +MCO_OBJC_SYNTHESIZE_STRING(setUsername, username) +MCO_OBJC_SYNTHESIZE_STRING(setPassword, password) +MCO_OBJC_SYNTHESIZE_SCALAR(MCOAuthType, mailcore::AuthType, setAuthType, authType) +MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConnectionType, connectionType) +MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout) +MCO_OBJC_SYNTHESIZE_BOOL(setCheckCertificateEnabled, isCheckCertificateEnabled) + +#pragma mark - Operations + +- (MCOPOPFetchMessagesOperation *) fetchMessagesOperation +{ + mailcore::POPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->fetchMessagesOperation(); + return MCO_TO_OBJC(coreOp); +} + +- (MCOPOPFetchHeaderOperation *) fetchHeaderOperationWithIndex:(unsigned int)index +{ + mailcore::POPFetchHeaderOperation * coreOp = MCO_NATIVE_INSTANCE->fetchHeaderOperation(index); + return MCO_TO_OBJC(coreOp); +} + +- (MCOPOPFetchMessageOperation *) fetchMessageOperationWithIndex:(unsigned int)index; +{ + mailcore::POPFetchMessageOperation * coreOp = MCO_NATIVE_INSTANCE->fetchMessageOperation(index); + return MCO_TO_OBJC(coreOp); +} + +// Will disconnect. +- (MCOPOPOperation *) deleteMessagesWithIndexes:(MCOIndexSet *)indexes +{ + mailcore::POPOperation * coreOp = MCO_NATIVE_INSTANCE->deleteMessagesOperation(MCO_FROM_OBJC(mailcore::IndexSet, indexes)); + return [[[MCOPOPOperation alloc] initWithMCOperation:coreOp] autorelease]; +} + +@end diff --git a/src/objc/smtp/MCOSMTP.h b/src/objc/smtp/MCOSMTP.h new file mode 100644 index 00000000..df8cec4d --- /dev/null +++ b/src/objc/smtp/MCOSMTP.h @@ -0,0 +1,16 @@ +// +// MCOSMTP.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef mailcore2_MCOSMTP_h +#define mailcore2_MCOSMTP_h + +#import <mailcore/MCOSMTPSession.h> +#import <mailcore/MCOSMTPSendOperation.h> +#import <mailcore/MCOSMTPOperation.h> + +#endif diff --git a/src/objc/smtp/MCOSMTPOperation.h b/src/objc/smtp/MCOSMTPOperation.h new file mode 100644 index 00000000..28b91857 --- /dev/null +++ b/src/objc/smtp/MCOSMTPOperation.h @@ -0,0 +1,19 @@ +// +// MCOSMTPCheckAccountOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOSMTPOPERATION_H_ + +#define __MAILCORE_MCOSMTPOPERATION_H_ + +#import <mailcore/MCOOperation.h> + +@interface MCOSMTPOperation : MCOOperation +- (void)start:(void (^)(NSError *error))completionBlock; +@end + +#endif diff --git a/src/objc/smtp/MCOSMTPOperation.mm b/src/objc/smtp/MCOSMTPOperation.mm new file mode 100644 index 00000000..5bd5ab3a --- /dev/null +++ b/src/objc/smtp/MCOSMTPOperation.mm @@ -0,0 +1,40 @@ +// +// MCOSMTPCheckAccountOperation.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOSMTPOperation.h" + +#include "MCAsyncSMTP.h" + +#import "MCOUtils.h" +#import "MCOOperation+Private.h" + +typedef void (^CompletionType)(NSError *error); + +@implementation MCOSMTPOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::SMTPOperation + +- (void) dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void)start:(void (^)(NSError *error))completionBlock { + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)operationCompleted { + NSError * error = [NSError mco_errorWithErrorCode:MCO_NATIVE_INSTANCE->error()]; + _completionBlock(error); +} + +@end diff --git a/src/objc/smtp/MCOSMTPSendOperation.h b/src/objc/smtp/MCOSMTPSendOperation.h new file mode 100644 index 00000000..e0ce3a05 --- /dev/null +++ b/src/objc/smtp/MCOSMTPSendOperation.h @@ -0,0 +1,25 @@ +// +// MCOSMTPSendOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOSMTPSENDOPERATION_H_ + +#define __MAILCORE_MCOSMTPSENDOPERATION_H_ + +#import <mailcore/MCOSMTPOperation.h> + +typedef void (^MCOSMTPOperationProgressBlock)(unsigned int current, unsigned int maximum); + +@interface MCOSMTPSendOperation : MCOSMTPOperation + +@property (nonatomic, copy) MCOSMTPOperationProgressBlock progress; + +- (void)start:(void (^)(NSError *error))completionBlock; + +@end + +#endif diff --git a/src/objc/smtp/MCOSMTPSendOperation.mm b/src/objc/smtp/MCOSMTPSendOperation.mm new file mode 100644 index 00000000..fcad264b --- /dev/null +++ b/src/objc/smtp/MCOSMTPSendOperation.mm @@ -0,0 +1,99 @@ +// +// MCOSMTPSendOperation.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOSMTPSendOperation.h" + +#include "MCAsyncSMTP.h" + +#import "MCOUtils.h" +#import "MCOOperation+Private.h" + +#define nativeType mailcore::SMTPOperation + +typedef void (^CompletionType)(NSError *error); + +@interface MCOSMTPSendOperation () + +- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum; + +@end + +class MCOSMTPSendOperationCallback : public mailcore::SMTPOperationCallback { +public: + MCOSMTPSendOperationCallback(MCOSMTPSendOperation * op) + { + mOperation = op; + } + + virtual void bodyProgress(mailcore::SMTPOperation * session, unsigned int current, unsigned int maximum) { + [mOperation bodyProgress:current maximum:maximum]; + } + +private: + MCOSMTPSendOperation * mOperation; +}; + +@implementation MCOSMTPSendOperation { + CompletionType _completionBlock; + MCOSMTPSendOperationCallback * _smtpCallback; + MCOSMTPOperationProgressBlock _progress; +} + +@synthesize progress = _progress; + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (id)initWithMCOperation:(mailcore::Operation *)op +{ + self = [super initWithMCOperation:op]; + + _smtpCallback = new MCOSMTPSendOperationCallback(self); + ((mailcore::SMTPOperation *) op)->setSmtpCallback(_smtpCallback); + + return self; +} + +- (void) dealloc +{ + [_progress release]; + [_completionBlock release]; + delete _smtpCallback; + [super dealloc]; +} + +- (void)start:(void (^)(NSError *error))completionBlock { + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)operationCompleted { + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()]); + } +} + +- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum +{ + if (_progress != NULL) { + _progress(current, maximum); + } +} + +@end diff --git a/src/objc/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h new file mode 100644 index 00000000..d5c940b9 --- /dev/null +++ b/src/objc/smtp/MCOSMTPSession.h @@ -0,0 +1,38 @@ +// +// MCOSMTPSession.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOSMTPSESSION_H_ + +#define __MAILCORE_MCOSMTPSESSION_H_ + +#import <Foundation/Foundation.h> + +#import <mailcore/MCOConstants.h> + +@class MCOSMTPSendOperation; +@class MCOSMTPOperation; +@class MCOAddress; + +@interface MCOSMTPSession : NSObject + +@property (nonatomic, copy) NSString * hostname; +@property (nonatomic, assign) unsigned int port; +@property (nonatomic, copy) NSString * username; +@property (nonatomic, copy) NSString * password; +@property (nonatomic, assign) MCOAuthType authType; +@property (nonatomic, assign) MCOConnectionType connectionType; +@property (nonatomic, assign) NSTimeInterval timeout; +@property (nonatomic, assign, getter=isCheckCertificateEnabled) BOOL checkCertificateEnabled; +@property (nonatomic, assign, getter=isUseHeloIPEnabled) BOOL useHeloIPEnabled; + +- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData; +- (MCOSMTPOperation *) checkAccountOperationWithFrom:(MCOAddress *)from; + +@end + +#endif diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm new file mode 100644 index 00000000..ad8f212e --- /dev/null +++ b/src/objc/smtp/MCOSMTPSession.mm @@ -0,0 +1,67 @@ +// +// MCOSMTPSession.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/29/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOSMTPSession.h" + +#include "MCAsyncSMTP.h" + +#import "MCOUtils.h" +#import "MCOSMTPSendOperation.h" +#import "MCOSMTPOperation.h" +#import "MCOOperation+Private.h" +#import "MCOAddress.h" + +@implementation MCOSMTPSession { + mailcore::SMTPAsyncSession * _session; +} + +#define nativeType mailcore::SMTPAsyncSession + +- (mailcore::Object *) mco_mcObject +{ + return _session; +} + +- (id)init { + self = [super init]; + if (self) { + _session = new mailcore::SMTPAsyncSession(); + } + return self; +} + +- (void)dealloc { + _session->release(); + [super dealloc]; +} + +MCO_OBJC_SYNTHESIZE_STRING(setHostname, hostname) +MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setPort, port) +MCO_OBJC_SYNTHESIZE_STRING(setUsername, username) +MCO_OBJC_SYNTHESIZE_STRING(setPassword, password) +MCO_OBJC_SYNTHESIZE_SCALAR(MCOAuthType, mailcore::AuthType, setAuthType, authType) +MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConnectionType, connectionType) +MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout) +MCO_OBJC_SYNTHESIZE_BOOL(setCheckCertificateEnabled, isCheckCertificateEnabled) +MCO_OBJC_SYNTHESIZE_BOOL(setUseHeloIPEnabled, useHeloIPEnabled) + +#pragma mark - Operations + +- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData +{ + mailcore::SMTPOperation * coreOp = MCO_NATIVE_INSTANCE->sendMessageOperation([messageData mco_mcData]); + return [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease]; +} + +- (MCOOperation *) checkAccountOperationWithFrom:(MCOAddress *)from +{ + mailcore::SMTPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(MCO_FROM_OBJC(mailcore::Address, from)); + return [[[MCOSMTPOperation alloc] initWithMCOperation:coreOp] autorelease]; +} + +@end |