summaryrefslogtreecommitdiff
path: root/fbdaemon
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-11-04 21:50:44 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-11-04 21:50:44 (GMT)
commitfc4896670ccff5dcbd3dce97cb33e6c172e16ef1 (patch)
tree0ce30ca718c4e727094daa312d971ea81314ec7d /fbdaemon
parent8827b110b4367f52d3efb25537f77ae9f01cffa0 (diff)
downloadkolab-utils-fc4896670ccff5dcbd3dce97cb33e6c172e16ef1.tar.gz
Separated ProbeIMAPServer from ProbeKolabServer. Moved folder setup to kolab job.
Diffstat (limited to 'fbdaemon')
-rw-r--r--fbdaemon/fbaggregatorjob.cpp6
-rw-r--r--fbdaemon/fbaggregatorjob.h2
-rw-r--r--fbdaemon/fbgeneratorjob.cpp8
-rw-r--r--fbdaemon/fbgeneratorjob.h2
-rw-r--r--fbdaemon/kolabjob.cpp34
-rw-r--r--fbdaemon/kolabjob.h7
6 files changed, 44 insertions, 15 deletions
diff --git a/fbdaemon/fbaggregatorjob.cpp b/fbdaemon/fbaggregatorjob.cpp
index 4531336..47a283a 100644
--- a/fbdaemon/fbaggregatorjob.cpp
+++ b/fbdaemon/fbaggregatorjob.cpp
@@ -39,16 +39,16 @@ QStringList FBAggregatorJob::requiredFolders()
return QStringList() << KOLAB_FOLDER_TYPE_FREEBUSY;
}
-void FBAggregatorJob::startWork(ProbeKolabServerJob* capabilitiesJob)
+void FBAggregatorJob::startWork()
{
Debug() << "starting aggregator job for " << mSessionSettings.userName;
- if (capabilitiesJob->kolabFolders().values(KOLAB_FOLDER_TYPE_FREEBUSY).isEmpty()) {
+ if (mKolabFolders.values(KOLAB_FOLDER_TYPE_FREEBUSY).isEmpty()) {
kWarning() << "no freebusy folder found";
setError(KJob::UserDefinedError);
logout();
return;
}
- mFreebusyFolder = capabilitiesJob->kolabFolders().values(KOLAB_FOLDER_TYPE_FREEBUSY).first();
+ mFreebusyFolder = mKolabFolders.values(KOLAB_FOLDER_TYPE_FREEBUSY).first();
FetchMessagesJob *fetchJob = new FetchMessagesJob(mFreebusyFolder, mSession, this);
connect( fetchJob, SIGNAL(result(KJob*)), this, SLOT(onFetchFBDone(KJob*)) );
diff --git a/fbdaemon/fbaggregatorjob.h b/fbdaemon/fbaggregatorjob.h
index 0b4c270..24c45ee 100644
--- a/fbdaemon/fbaggregatorjob.h
+++ b/fbdaemon/fbaggregatorjob.h
@@ -40,7 +40,7 @@ private Q_SLOTS:
// void onGenerateFBDone(KJob*);
// void onModDone(KJob*);
private:
- virtual void startWork(ProbeKolabServerJob* job);
+ virtual void startWork();
QString mFreebusyFolder;
QString mGeneratedFile;
diff --git a/fbdaemon/fbgeneratorjob.cpp b/fbdaemon/fbgeneratorjob.cpp
index 3617637..25afbe6 100644
--- a/fbdaemon/fbgeneratorjob.cpp
+++ b/fbdaemon/fbgeneratorjob.cpp
@@ -49,16 +49,16 @@ QStringList FBGeneratorJob::requiredFolders()
}
-void FBGeneratorJob::startWork(ProbeKolabServerJob* capabilitiesJob)
+void FBGeneratorJob::startWork()
{
- if (capabilitiesJob->kolabFolders().values(KOLAB_FOLDER_TYPE_FREEBUSY).isEmpty()) {
+ if (mKolabFolders.values(KOLAB_FOLDER_TYPE_FREEBUSY).isEmpty()) {
kWarning() << "no freebusy folder found";
setError(KJob::UserDefinedError);
logout();
return;
}
- mFreebusyFolder = capabilitiesJob->kolabFolders().values(KOLAB_FOLDER_TYPE_FREEBUSY).first();
- mEventFolders = capabilitiesJob->kolabFolders().values(KOLAB_FOLDER_TYPE_EVENT);
+ mFreebusyFolder = mKolabFolders.values(KOLAB_FOLDER_TYPE_FREEBUSY).first();
+ mEventFolders = mKolabFolders.values(KOLAB_FOLDER_TYPE_EVENT);
if (mEventFolders.isEmpty()) {
kWarning() << "no event folders available";
logout();
diff --git a/fbdaemon/fbgeneratorjob.h b/fbdaemon/fbgeneratorjob.h
index bdfc5a6..47ee128 100644
--- a/fbdaemon/fbgeneratorjob.h
+++ b/fbdaemon/fbgeneratorjob.h
@@ -35,7 +35,7 @@ private Q_SLOTS:
protected:
virtual QStringList requiredFolders();
private:
- virtual void startWork(ProbeKolabServerJob* job);
+ virtual void startWork();
QString mFreebusyFolder;
QStringList mEventFolders;
diff --git a/fbdaemon/kolabjob.cpp b/fbdaemon/kolabjob.cpp
index 373b08b..be50a90 100644
--- a/fbdaemon/kolabjob.cpp
+++ b/fbdaemon/kolabjob.cpp
@@ -24,6 +24,7 @@
#include "uiproxy.h"
#include "authenticationjob.h"
#include "jobs/probekolabserverjob.h"
+#include <jobs/setupkolabfoldersjob.h>
#include <sessionsettings.h>
KolabJob::KolabJob(const SessionSettings &sessionSettings, QObject* parent)
@@ -72,7 +73,6 @@ void KolabJob::onAuthDone(KJob *job)
}
// Debug() << "login successful";
ProbeKolabServerJob *probeJob = new ProbeKolabServerJob(mSession, this);
- probeJob->createDefaultsIfMissing(requiredFolders());
QObject::connect(probeJob, SIGNAL(result(KJob*)), this, SLOT(onProbeDone(KJob*)));
probeJob->start();
}
@@ -85,9 +85,35 @@ void KolabJob::onProbeDone(KJob* job)
emitResult();
return;
}
- ProbeKolabServerJob *capabilitiesJob = qobject_cast<ProbeKolabServerJob*>( job );
- Q_ASSERT(capabilitiesJob);
- startWork(capabilitiesJob);
+ ProbeKolabServerJob *probeJob = static_cast<ProbeKolabServerJob*>(job);
+ mKolabFolders = probeJob->kolabFolders();
+
+ QString rootFolder;
+ QStringList toCreate;
+ foreach (const QString &folderType, requiredFolders()) {
+ if (!mKolabFolders.contains(folderType)) {
+ toCreate << folderType;
+ }
+ }
+ if (toCreate.isEmpty()) {
+ startWork();
+ } else {
+ SetupKolabFoldersJob *setupJob = new SetupKolabFoldersJob(probeJob->capabilities(), rootFolder, mSession, this);
+ setupJob->setKolabFolders(toCreate);
+ connect(setupJob, SIGNAL(result(KJob*)), this, SLOT(onSetupDone(KJob*)));
+ setupJob->start();
+ }
+}
+
+void KolabJob::onSetupDone(KJob *job)
+{
+ if ( job->error() ) {
+ Warning() << job->errorString();
+ setError(KJob::UserDefinedError);
+ emitResult();
+ return;
+ }
+ startWork();
}
void KolabJob::logout()
diff --git a/fbdaemon/kolabjob.h b/fbdaemon/kolabjob.h
index 8a1749e..30595b1 100644
--- a/fbdaemon/kolabjob.h
+++ b/fbdaemon/kolabjob.h
@@ -19,6 +19,8 @@
#define KOLABJOB_H
#include <kimap/session.h>
#include <QStringList>
+#include <QHash>
+#include <kimap/listjob.h>
#include <sessionsettings.h>
#define X_ORIGIN_HEADER "X-Freebusy-Origin"
@@ -36,17 +38,18 @@ private Q_SLOTS:
void onAuthDone(KJob*);
void onProbeDone(KJob* job);
void onLogoutDone(KJob*);
+ void onSetupDone(KJob*);
protected:
virtual QStringList requiredFolders();
- virtual void startWork(ProbeKolabServerJob *job) = 0;
+ virtual void startWork() = 0;
void logout();
SessionSettings mSessionSettings;
QString mFreebusyFolder;
KIMAP::Session *mSession;
-
+ QMultiHash<QString, QString> mKolabFolders;
};
#endif // KOLABJOB_H