aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar DINH Viet Hoa <hoa@sprw.me>2013-01-17 00:08:32 -0800
committerGravatar DINH Viet Hoa <hoa@sprw.me>2013-01-17 00:08:32 -0800
commitada1598162092e9affc9337dedeb6c805ae72121 (patch)
tree3f4a48873cbe720b3ff78b34b994840f30237180 /tests
parente75be6c8b9a9b694e86c4054b4493f8ec405df2f (diff)
implemented POP async API
Diffstat (limited to 'tests')
-rw-r--r--tests/main.mm41
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/main.mm b/tests/main.mm
index 1ef4927d..622c35b1 100644
--- a/tests/main.mm
+++ b/tests/main.mm
@@ -234,6 +234,42 @@ static void testAsyncIMAP()
//session->release();
}
+class TestPOPCallback : public mailcore::Object, public mailcore::OperationCallback, public mailcore::POPOperationCallback {
+ virtual void operationFinished(mailcore::Operation * op)
+ {
+ mailcore::POPFetchMessagesOperation * fetchOp = (mailcore::POPFetchMessagesOperation *) op;
+ MCLog("callback %s %s", MCUTF8DESC(fetchOp->messages()), MCUTF8DESC(this));
+ }
+
+ virtual void bodyProgress(mailcore::IMAPOperation * op, unsigned int current, unsigned int maximum)
+ {
+ MCLog("progress %s %s %i/%i", MCUTF8DESC(op), MCUTF8DESC(this), current, maximum);
+ }
+};
+
+static void testAsyncPOP()
+{
+ mailcore::POPAsyncSession * session;
+ TestPOPCallback * callback = new TestPOPCallback();
+
+ session = new mailcore::POPAsyncSession();
+ session->setHostname(MCSTR("pop.gmail.com"));
+ session->setPort(995);
+ session->setUsername(email);
+ session->setPassword(password);
+ session->setConnectionType(mailcore::ConnectionTypeTLS);
+
+ mailcore::POPFetchMessagesOperation * op = session->fetchMessagesOperation();
+ op->setCallback(callback);
+ op->setPopCallback(callback);
+ op->start();
+
+ //mailcore::Array * messages = session->fetchMessages(&error);
+ //MCLog("%s", MCUTF8DESC(messages));
+
+ [[NSRunLoop currentRunLoop] run];
+}
+
void testAll()
{
u_setDataDirectory("/usr/local/share/icu");
@@ -242,13 +278,14 @@ void testAll()
mailstream_debug = 1;
- mailcore::Data * data = testMessageBuilder();
+ //mailcore::Data * data = testMessageBuilder();
//testMessageParser(data);
//testSMTP(data);
//testIMAP();
//testPOP();
//testAsyncSMTP(data);
- testAsyncIMAP();
+ //testAsyncIMAP();
+ testAsyncPOP();
MCLog("pool release");
pool->release();