summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-11-11 23:54:19 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-11-11 23:54:19 (GMT)
commitb7007176dfb57218d7e4ea50bbca53c6fadc38cc (patch)
treefa2b9518dec042d44227a7b2f8a912c83aa7b5f6 /lib
parentbb70af914b7080e5a6a11b20bfe0873b84d01aea (diff)
downloadkolab-utils-b7007176dfb57218d7e4ea50bbca53c6fadc38cc.tar.gz
Async logout and user retrieval.
Diffstat (limited to 'lib')
-rw-r--r--lib/kolabaccount.cpp27
-rw-r--r--lib/kolabaccount.h3
2 files changed, 20 insertions, 10 deletions
diff --git a/lib/kolabaccount.cpp b/lib/kolabaccount.cpp
index a0b616c..a395f2f 100644
--- a/lib/kolabaccount.cpp
+++ b/lib/kolabaccount.cpp
@@ -50,6 +50,14 @@ KolabAccount::KolabAccount(QObject* parent)
}
+KolabAccount::~KolabAccount()
+{
+ if (mSession) {
+ mSession->close();
+ mSession->deleteLater();
+ }
+}
+
void KolabAccount::setVersion(Kolab::Version version)
{
mVersion = version;
@@ -212,17 +220,12 @@ void KolabAccount::appendObjectSync(Object obj, const QString& folder)
}
}
-void KolabAccount::logout()
+KJob *KolabAccount::logout()
{
if (!mSession) {
- return;
+ return 0;
}
- KIMAP::LogoutJob *logoutJob = new KIMAP::LogoutJob(mSession);
- logoutJob->exec();
- mSession->close();
-// mSession->deleteLater();
- mSession = 0;
- Debug() << "logout done";
+ return new KIMAP::LogoutJob(mSession);
}
const char* FlagDeleted2 = "\\Deleted";
@@ -303,7 +306,13 @@ void KolabAccount::cleanAccount()
mFolders.append(QLatin1String("inbox"));
//logging out and logging in again seems to help with the "NO Mailbox is locked" problem when creating folders afterwards.
- logout();
+ KJob *logoutJob = logout();
+ if (logoutJob) {
+ logoutJob->exec();
+ }
+ mSession->close();
+ mSession->deleteLater();
+ mSession = 0;
init();
}
diff --git a/lib/kolabaccount.h b/lib/kolabaccount.h
index e541a30..a80f2a5 100644
--- a/lib/kolabaccount.h
+++ b/lib/kolabaccount.h
@@ -34,6 +34,7 @@ class KolabAccount: public QObject
Q_OBJECT
public:
explicit KolabAccount(QObject* parent = 0);
+ virtual ~KolabAccount();
void setHost(const QString &host, qint16 port);
void setCredentials(const QString &username, const QString &pw, const QString &authorizationName);
@@ -51,7 +52,7 @@ public:
void setDryRun(bool);
void setWipeTargetFolders(bool);
- void logout();
+ KJob *logout();
QList<Object> getObjects(const QString& folder);
QStringList lookupFolderList();