summaryrefslogtreecommitdiff
path: root/lib/kolabaccount.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-03-16 20:44:11 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-03-16 20:44:11 (GMT)
commit8ff4fa8ae7aae953a35cc4f695828fb27463f2f2 (patch)
tree9f07cd4db03f8fbacdd3b91495d039b422e3f14d /lib/kolabaccount.cpp
parent993c0af2fc51131827d1d691398e5ad17c5117c1 (diff)
downloadkolab-utils-8ff4fa8ae7aae953a35cc4f695828fb27463f2f2.tar.gz
Use job based api, so we can split the processing in several batches, and don't have to process one huge list in one go (otherwise we'll likely run out of memory).
Diffstat (limited to 'lib/kolabaccount.cpp')
-rw-r--r--lib/kolabaccount.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/kolabaccount.cpp b/lib/kolabaccount.cpp
index de56ba6..587d597 100644
--- a/lib/kolabaccount.cpp
+++ b/lib/kolabaccount.cpp
@@ -167,23 +167,22 @@ KMime::Message::Ptr KolabAccount::writeObject(const Object &obj)
return msg;
}
-void KolabAccount::appendObject(Object obj, const QString& folder)
+KJob* KolabAccount::appendObject(Object obj, const QString& folder)
{
if (mDryRun) {
Debug() << "append object in folder: " << folder;
- return;
+ return 0;
}
if (!mFolders.contains(folder)) {
Error() << "failed to find target folder: " << folder;
qDebug() << mFolders;
- return;
+ return 0;
}
KMime::Message::Ptr message = writeObject(obj);
-
if (!message) {
Error() << "got empty message";
- return;
+ return 0;
}
KIMAP::AppendJob *job = new KIMAP::AppendJob( mSession );
job->setMailBox( folder );
@@ -191,6 +190,15 @@ void KolabAccount::appendObject(Object obj, const QString& folder)
//The Recent flag is a special case which is not allowed in the append command
obj.flags.removeAll(QByteArray(FlagRecent2));
job->setFlags( obj.flags );
+ return job;
+}
+
+void KolabAccount::appendObjectSync(Object obj, const QString& folder)
+{
+ KJob *job = appendObject(obj, folder);
+ if (!job) {
+ return;
+ }
job->exec();
Debug() << "appended object in folder: " << folder;
if (job->error()) {