aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-08-05 19:42:12 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-08-05 19:42:12 -0700
commit920c43dad5d30b6892f0fccb3b6093b2571b6e70 (patch)
treeed84c3df5d0d5b473321eb602baae64505231cf1
parent44a5e789f1e78d043f667ab2862a0097eaa2d06b (diff)
work in progress on automatic configuration
-rw-r--r--src/async/imap/MCIMAPAsyncConnection.cc13
-rw-r--r--src/async/imap/MCIMAPAsyncConnection.h4
-rw-r--r--src/async/imap/MCIMAPAsyncSession.cc11
-rw-r--r--src/async/imap/MCIMAPAsyncSession.h4
-rw-r--r--src/async/imap/MCIMAPOperation.cc12
-rw-r--r--src/async/imap/MCIMAPOperation.h3
6 files changed, 46 insertions, 1 deletions
diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc
index 85c411a8..1d6e8fa9 100644
--- a/src/async/imap/MCIMAPAsyncConnection.cc
+++ b/src/async/imap/MCIMAPAsyncConnection.cc
@@ -93,6 +93,7 @@ IMAPAsyncConnection::IMAPAsyncConnection()
mConnectionLogger = NULL;
pthread_mutex_init(&mConnectionLoggerLock, NULL);
mInternalLogger = new IMAPConnectionLogger(this);
+ mAutomaticConfigurationEnabled = true;
}
IMAPAsyncConnection::~IMAPAsyncConnection()
@@ -630,3 +631,15 @@ IMAPMessageRenderingOperation * IMAPAsyncConnection::plainTextBodyRenderingOpera
{
return renderingOperation(message, folder, IMAPMessageRenderingTypePlainTextBody);
}
+
+void IMAPAsyncConnection::setAutomaticConfigurationEnabled(bool enabled)
+{
+ mAutomaticConfigurationEnabled = enabled;
+ mSession->setAutomaticCapabilitiesEnabled(enabled);
+ mSession->setAutomaticNamespaceEnabled(enabled);
+}
+
+bool IMAPAsyncConnection::isAutomaticConfigurationEnabled()
+{
+ return mAutomaticConfigurationEnabled;
+}
diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h
index 45acb707..9594aef2 100644
--- a/src/async/imap/MCIMAPAsyncConnection.h
+++ b/src/async/imap/MCIMAPAsyncConnection.h
@@ -69,6 +69,9 @@ namespace mailcore {
virtual void setDelimiter(char delimiter);
virtual char delimiter();
+ virtual void setAutomaticConfigurationEnabled(bool enabled);
+ virtual bool isAutomaticConfigurationEnabled();
+
virtual void setDefaultNamespace(IMAPNamespace * ns);
virtual IMAPNamespace * defaultNamespace();
@@ -138,6 +141,7 @@ namespace mailcore {
ConnectionLogger * mConnectionLogger;
IMAPConnectionLogger * mInternalLogger;
pthread_mutex_t mConnectionLoggerLock;
+ bool mAutomaticConfigurationEnabled;
virtual void tryAutomaticDisconnectAfterDelay(void * context);
virtual IMAPMessageRenderingOperation * renderingOperation(IMAPMessage * message,
diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc
index 7aa37d83..93812f90 100644
--- a/src/async/imap/MCIMAPAsyncSession.cc
+++ b/src/async/imap/MCIMAPAsyncSession.cc
@@ -36,6 +36,7 @@ IMAPAsyncSession::IMAPAsyncSession()
mDefaultNamespace = NULL;
mTimeout = 30.;
mConnectionLogger = NULL;
+ mAutomaticConfigurationDone = false;
}
IMAPAsyncSession::~IMAPAsyncSession()
@@ -208,6 +209,9 @@ IMAPAsyncConnection * IMAPAsyncSession::session()
session->setVoIPEnabled(mVoIPEnabled);
session->setDelimiter(mDelimiter);
session->setDefaultNamespace(mDefaultNamespace);
+ if (mAutomaticConfigurationDone) {
+ session->setAutomaticConfigurationEnabled(false);
+ }
return session;
}
@@ -489,4 +493,9 @@ IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextBodyRenderingOperatio
{
IMAPAsyncConnection * session = sessionForFolder(folder);
return session->plainTextBodyRenderingOperation(message, folder);
-} \ No newline at end of file
+}
+
+void IMAPAsyncSession::automaticConfigurateDone()
+{
+ mAutomaticConfigurationDone = true;
+}
diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h
index 68e8899a..95c80c2f 100644
--- a/src/async/imap/MCIMAPAsyncSession.h
+++ b/src/async/imap/MCIMAPAsyncSession.h
@@ -138,6 +138,9 @@ namespace mailcore {
virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder);
virtual IMAPMessageRenderingOperation * plainTextRenderingOperation(IMAPMessage * message, String * folder);
virtual IMAPMessageRenderingOperation * plainTextBodyRenderingOperation(IMAPMessage * message, String * folder);
+
+ public: // private
+ virtual void automaticConfigurateDone();
private:
Array * mSessions;
@@ -157,6 +160,7 @@ namespace mailcore {
bool mAllowsFolderConcurrentAccessEnabled;
unsigned int mMaximumConnections;
ConnectionLogger * mConnectionLogger;
+ bool mAutomaticConfigurationDone;
virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false);
virtual IMAPAsyncConnection * session();
diff --git a/src/async/imap/MCIMAPOperation.cc b/src/async/imap/MCIMAPOperation.cc
index 35eedd6c..2ceb2b55 100644
--- a/src/async/imap/MCIMAPOperation.cc
+++ b/src/async/imap/MCIMAPOperation.cc
@@ -10,6 +10,7 @@
#include <stdlib.h>
+#include "MCIMAPAsyncSession.h"
#include "MCIMAPSession.h"
#include "MCIMAPAsyncConnection.h"
#include "MCIMAPOperationCallback.h"
@@ -133,3 +134,14 @@ void IMAPOperation::itemsProgressOnMainThread(void * ctx)
free(context);
release();
}
+
+void IMAPOperation::beforeMain()
+{
+}
+
+void IMAPOperation::afterMain()
+{
+ if (mSession->session()->isAutomaticConfigurationDone()) {
+ mSession->owner()->automaticConfigurateDone();
+ }
+}
diff --git a/src/async/imap/MCIMAPOperation.h b/src/async/imap/MCIMAPOperation.h
index f7e937db..e7dcb9a5 100644
--- a/src/async/imap/MCIMAPOperation.h
+++ b/src/async/imap/MCIMAPOperation.h
@@ -34,6 +34,9 @@ namespace mailcore {
virtual void setImapCallback(IMAPOperationCallback * callback);
virtual IMAPOperationCallback * imapCallback();
+ virtual void beforeMain();
+ virtual void afterMain();
+
virtual void start();
// Result.