summaryrefslogtreecommitdiff
path: root/lib/kolabaccount.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-10-18 09:59:05 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-10-18 09:59:05 (GMT)
commitdfff5bc603fdcecd247a5a9c136371ef302e6b82 (patch)
treee8cdadc9a0286cd52fc0be9f1f255c737a723ac3 /lib/kolabaccount.cpp
parent17601c16ef211e3de6d9751bef85cccfae38e8fb (diff)
downloadkolab-utils-dfff5bc603fdcecd247a5a9c136371ef302e6b82.tar.gz
Refactoring to make a first FreebusyGenerator test possible.
Diffstat (limited to 'lib/kolabaccount.cpp')
-rw-r--r--lib/kolabaccount.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/kolabaccount.cpp b/lib/kolabaccount.cpp
index c55511f..7048a99 100644
--- a/lib/kolabaccount.cpp
+++ b/lib/kolabaccount.cpp
@@ -18,6 +18,7 @@
#include "kolabaccount.h"
#include "uiproxy.h"
#include <jobs/setupkolabfoldersjob.h>
+#include "jobs/fetchmessagesjob.h"
#include <kimap/session.h>
#include <kimap/logoutjob.h>
#include <kimap/appendjob.h>
@@ -71,6 +72,7 @@ bool KolabAccount::init()
mSession = new KIMAP::Session( mHost, mPort, this );
mSession->setUiProxy( KIMAP::SessionUiProxy::Ptr(new UiProxy()) );
KIMAP::LoginJob *loginJob = new KIMAP::LoginJob( mSession );
+ Debug() << mUsername << mAuthorizationName << mPw;
if (mAuthorizationName != mUsername) {
loginJob->setAuthorizationName(mAuthorizationName);
}
@@ -284,7 +286,6 @@ void KolabAccount::createFolder(const QString& name, Kolab::FolderType folderTyp
createFolder(name, QString::fromStdString(Kolab::folderAnnotation(folderType)).toLatin1());
}
-
void KolabAccount::setupFolders()
{
if (mDryRun) {
@@ -311,4 +312,40 @@ void KolabAccount::setupFolders()
createFolder("Trash", KOLAB_FOLDER_TYPE_MAIL KOLAB_FOLDER_TYPE_TRASH_SUFFIX);
}
+QList<Object> KolabAccount::getObjects(const QString& folder)
+{
+// Debug() << folder;
+ FetchMessagesJob *fetchJob = new FetchMessagesJob(folder, mSession, this);
+ fetchJob->exec();
+ Debug() << fetchJob->getMessages().size();
+ QList<Object> messages;
+ foreach (const KMime::Message::Ptr &msg, fetchJob->getMessages()) {
+ Object obj;
+ obj.message = msg;
+ obj.flags = fetchJob->getFlags(msg);
+ messages.append(obj);
+ }
+ return messages;
+}
+
+QStringList KolabAccount::lookupFolderList()
+{
+// Debug() << "lookupFolderList" << mHost << mPort << mUsername << mPw;
+ init();
+ mMailboxes.clear();
+
+ KIMAP::ListJob *listJob = new KIMAP::ListJob(mSession);
+ listJob->setOption(KIMAP::ListJob::IncludeUnsubscribed);
+ listJob->setQueriedNamespaces(mPersonalNamespaces);
+ QObject::connect( listJob, SIGNAL(mailBoxesReceived(QList<KIMAP::MailBoxDescriptor>,QList<QList<QByteArray> >)),
+ this, SLOT(mailBoxesReceived(QList<KIMAP::MailBoxDescriptor>,QList<QList<QByteArray> >)));
+ listJob->exec();
+ Debug() << "found " << mMailboxes.size();
+
+ QStringList mailboxes;
+ foreach (const KIMAP::MailBoxDescriptor &descriptor, mMailboxes) {
+ mailboxes.append(descriptor.name);
+ }
+ return mailboxes;
+}