diff options
-rw-r--r-- | build-mac/mailcore2.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | src/async/pop/MCPOPAsyncSession.cc | 9 | ||||
-rw-r--r-- | src/async/pop/MCPOPAsyncSession.h | 2 | ||||
-rw-r--r-- | src/async/pop/MCPOPCheckAccountOperation.cpp | 30 | ||||
-rw-r--r-- | src/async/pop/MCPOPCheckAccountOperation.h | 31 | ||||
-rw-r--r-- | src/core/pop/MCPOPSession.cc | 6 | ||||
-rw-r--r-- | src/core/pop/MCPOPSession.h | 2 | ||||
-rw-r--r-- | src/objc/pop/MCOPOPSession.h | 12 | ||||
-rw-r--r-- | src/objc/pop/MCOPOPSession.mm | 8 |
9 files changed, 107 insertions, 1 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 3472c0ea..a0831e29 100644 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -260,6 +260,8 @@ C6A81C031707D96500882C15 /* MCOPOPMessageInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A81BFE1707CEE400882C15 /* MCOPOPMessageInfo.h */; }; C6A81C04170A82F300882C15 /* MCIMAPSyncResult.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C64BB22016E34DCB000DB34C /* MCIMAPSyncResult.h */; }; C6A81C05170A82F600882C15 /* MCIMAPSyncResult.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C64BB22016E34DCB000DB34C /* MCIMAPSyncResult.h */; }; + C6AC110017114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6AC10FE17114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp */; }; + C6AC110117114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6AC10FE17114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp */; }; 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 */; }; @@ -1212,6 +1214,8 @@ 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>"; }; + C6AC10FE17114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCPOPCheckAccountOperation.cpp; sourceTree = "<group>"; }; + C6AC10FF17114DAF00B715B7 /* MCPOPCheckAccountOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCPOPCheckAccountOperation.h; sourceTree = "<group>"; }; C6BA2C191705F4E6003F0E9E /* libMailCore-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libMailCore-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C6BD288D170BD71100A91AC1 /* MailCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MailCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C6BD288E170BD71100A91AC1 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; @@ -1511,6 +1515,8 @@ C62C6EF716A7C6F500737497 /* MCPOPDeleteMessagesOperation.h */, C62C6F0416A7E54200737497 /* MCPOPFetchMessagesOperation.cc */, C62C6F0516A7E54400737497 /* MCPOPFetchMessagesOperation.h */, + C6AC10FE17114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp */, + C6AC10FF17114DAF00B715B7 /* MCPOPCheckAccountOperation.h */, C62C6EF916A7C93F00737497 /* MCPOPOperation.cc */, C62C6EFA16A7C94000737497 /* MCPOPOperation.h */, C62C6EFC16A7CA1500737497 /* MCPOPOperationCallback.h */, @@ -2212,6 +2218,7 @@ C6A81BE21706905600882C15 /* MCOPOPOperation.mm in Sources */, C6A81BE61706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */, C6A81C001707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */, + C6AC110017114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2371,6 +2378,7 @@ C6A81BE31706905600882C15 /* MCOPOPOperation.mm in Sources */, C6A81BE71706906D00882C15 /* MCOPOPFetchMessagesOperation.mm in Sources */, C6A81C011707CEE600882C15 /* MCOPOPMessageInfo.mm in Sources */, + C6AC110117114DAF00B715B7 /* MCPOPCheckAccountOperation.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc index 155dd6e0..2cdbd225 100644 --- a/src/async/pop/MCPOPAsyncSession.cc +++ b/src/async/pop/MCPOPAsyncSession.cc @@ -13,6 +13,7 @@ #include "MCPOPFetchMessageOperation.h" #include "MCPOPDeleteMessagesOperation.h" #include "MCPOPFetchMessagesOperation.h" +#include "MCPOPCheckAccountOperation.h" using namespace mailcore; @@ -143,6 +144,14 @@ POPOperation * POPAsyncSession::deleteMessagesOperation(IndexSet * indexes) return op; } +POPOperation * POPAsyncSession::checkAccountOperation() +{ + POPCheckAccountOperation * op = new POPCheckAccountOperation(); + op->setSession(this); + op->autorelease(); + return op; +} + POPSession * POPAsyncSession::session() { return mSession; diff --git a/src/async/pop/MCPOPAsyncSession.h b/src/async/pop/MCPOPAsyncSession.h index 41ada0ef..f05b98b5 100644 --- a/src/async/pop/MCPOPAsyncSession.h +++ b/src/async/pop/MCPOPAsyncSession.h @@ -61,6 +61,8 @@ namespace mailcore { // Will disconnect. virtual POPOperation * deleteMessagesOperation(IndexSet * indexes); + virtual POPOperation * checkAccountOperation(); + private: POPSession * mSession; OperationQueue * mQueue; diff --git a/src/async/pop/MCPOPCheckAccountOperation.cpp b/src/async/pop/MCPOPCheckAccountOperation.cpp new file mode 100644 index 00000000..f83cd740 --- /dev/null +++ b/src/async/pop/MCPOPCheckAccountOperation.cpp @@ -0,0 +1,30 @@ +// +// MCPOPCheckAccountOperation.cpp +// mailcore2 +// +// Created by DINH Viêt Hoà on 4/6/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#include "MCPOPCheckAccountOperation.h" + +#include "MCPOPAsyncSession.h" +#include "MCPOPSession.h" + +using namespace mailcore; + +POPCheckAccountOperation::POPCheckAccountOperation() +{ +} + +POPCheckAccountOperation::~POPCheckAccountOperation() +{ +} + +void POPCheckAccountOperation::main() +{ + ErrorCode error; + + session()->session()->checkAccount(&error); + setError(error); +} diff --git a/src/async/pop/MCPOPCheckAccountOperation.h b/src/async/pop/MCPOPCheckAccountOperation.h new file mode 100644 index 00000000..50e381fd --- /dev/null +++ b/src/async/pop/MCPOPCheckAccountOperation.h @@ -0,0 +1,31 @@ +// +// MCPOPCheckAccountOperation.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 4/6/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCPOPCHECKACCOUNTOPERATION_H_ +#define __MAILCORE_MCPOPCHECKACCOUNTOPERATION_H_ + +#include <MailCore/MCPOPOperation.h> + +#ifdef __cplusplus + +namespace mailcore { + + class POPCheckAccountOperation : public POPOperation { + public: + POPCheckAccountOperation(); + virtual ~POPCheckAccountOperation(); + + public: // subclass behavior + virtual void main(); + }; + +} + +#endif + +#endif diff --git a/src/core/pop/MCPOPSession.cc b/src/core/pop/MCPOPSession.cc index 95880198..88f80c8a 100644 --- a/src/core/pop/MCPOPSession.cc +++ b/src/core/pop/MCPOPSession.cc @@ -537,3 +537,9 @@ void POPSession::deleteMessage(POPMessageInfo * msg, ErrorCode * pError) { deleteMessage(msg->index(), pError); } + +void POPSession::checkAccount(ErrorCode * pError) +{ + loginIfNeeded(pError); +} + diff --git a/src/core/pop/MCPOPSession.h b/src/core/pop/MCPOPSession.h index 22eca94b..4c343877 100644 --- a/src/core/pop/MCPOPSession.h +++ b/src/core/pop/MCPOPSession.h @@ -73,6 +73,8 @@ namespace mailcore { virtual void login(ErrorCode * pError); + virtual void checkAccount(ErrorCode * pError); + Array * /* POPMessageInfo */ fetchMessages(ErrorCode * pError); MessageHeader * fetchHeader(unsigned int index, ErrorCode * pError); diff --git a/src/objc/pop/MCOPOPSession.h b/src/objc/pop/MCOPOPSession.h index 16b95a16..aa1f2904 100644 --- a/src/objc/pop/MCOPOPSession.h +++ b/src/objc/pop/MCOPOPSession.h @@ -106,6 +106,18 @@ // - (MCOPOPOperation *) deleteMessagesOperationWithIndexes:(MCOIndexSet *)indexes; +// Returns an operation that will check whether the POP account is valid. +// The operation needs to be started. +// +// { +// ... +// MCOPOPOperation * op = [session checkAccountOperation]; +// [op start:^(NSError * error) { +// ... +// }]; +// +- (MCOPOPOperation *) checkAccountOperation; + @end #endif diff --git a/src/objc/pop/MCOPOPSession.mm b/src/objc/pop/MCOPOPSession.mm index b82c1f23..cb060784 100644 --- a/src/objc/pop/MCOPOPSession.mm +++ b/src/objc/pop/MCOPOPSession.mm @@ -77,7 +77,13 @@ MCO_OBJC_SYNTHESIZE_BOOL(setCheckCertificateEnabled, isCheckCertificateEnabled) - (MCOPOPOperation *) deleteMessagesOperationWithIndexes:(MCOIndexSet *)indexes { mailcore::POPOperation * coreOp = MCO_NATIVE_INSTANCE->deleteMessagesOperation(MCO_FROM_OBJC(mailcore::IndexSet, indexes)); - return [[[MCOPOPOperation alloc] initWithMCOperation:coreOp] autorelease]; + return [[[MCOPOPOperation alloc] initWithMCOperation:coreOp] autorelease]; +} + +- (MCOPOPOperation *) checkAccountOperation +{ + mailcore::POPOperation * coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(); + return [[[MCOPOPOperation alloc] initWithMCOperation:coreOp] autorelease]; } @end |