summaryrefslogtreecommitdiff
path: root/fbdaemon
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-07-25 09:52:25 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-07-25 09:52:25 (GMT)
commitc0f3c607ea05dcd47d4e9e734aa2035a6a305148 (patch)
tree50bac7024d511df96fa1af69128b3ea5efa25052 /fbdaemon
parente31e3594b5f78124f05c3b394832740c126c3702 (diff)
downloadkolab-utils-c0f3c607ea05dcd47d4e9e734aa2035a6a305148.tar.gz
Filter users by domain during generateall.
Diffstat (limited to 'fbdaemon')
-rw-r--r--fbdaemon/fbcoordinator.cpp3
-rw-r--r--fbdaemon/fbcoordinator.h2
-rw-r--r--fbdaemon/getuserlistjob.cpp9
-rw-r--r--fbdaemon/getuserlistjob.h2
-rw-r--r--fbdaemon/main.cpp22
5 files changed, 26 insertions, 12 deletions
diff --git a/fbdaemon/fbcoordinator.cpp b/fbdaemon/fbcoordinator.cpp
index 6f27691..3bf4ecf 100644
--- a/fbdaemon/fbcoordinator.cpp
+++ b/fbdaemon/fbcoordinator.cpp
@@ -30,13 +30,14 @@ FBCoordinator::FBCoordinator(QObject* parent)
//TODO get user from job (trigger)
}
-void FBCoordinator::generateForAllUsers()
+void FBCoordinator::generateForAllUsers(const QString &domain)
{
if (!mUserQueue.isEmpty()) {
kWarning() << "there is an existing processing queue, aborting";
return;
}
GetUserListJob *getUsersJob = new GetUserListJob(Settings::instance().getServerUri(), Settings::instance().getServerPort(), this);
+ getUsersJob->setFilterDomain(domain);
connect(getUsersJob, SIGNAL(result(KJob*)), this, SLOT(onGotUserList(KJob*)));
getUsersJob->start();
}
diff --git a/fbdaemon/fbcoordinator.h b/fbdaemon/fbcoordinator.h
index 9d7afea..9e06c7b 100644
--- a/fbdaemon/fbcoordinator.h
+++ b/fbdaemon/fbcoordinator.h
@@ -34,7 +34,7 @@ public:
/**
* Gets a list of all available users and triggers a generate job
*/
- void generateForAllUsers();
+ void generateForAllUsers(const QString &domain);
/**
* Generates a partial f/b list for the @param user
diff --git a/fbdaemon/getuserlistjob.cpp b/fbdaemon/getuserlistjob.cpp
index 6a01f8d..d1a4b50 100644
--- a/fbdaemon/getuserlistjob.cpp
+++ b/fbdaemon/getuserlistjob.cpp
@@ -41,6 +41,12 @@ GetUserListJob::GetUserListJob(const QString& hostName, qint16 port, QObject* pa
this, SLOT(onSessionStateChanged(KIMAP::Session::State,KIMAP::Session::State)) );
}
+void GetUserListJob::setFilterDomain(const QString &domain)
+{
+ mFilterDomain = domain;
+}
+
+
void GetUserListJob::onSessionStateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState)
{
kDebug() << newState;
@@ -127,6 +133,9 @@ void GetUserListJob::mailBoxesReceived(const QList<KIMAP::MailBoxDescriptor> &de
// For now we simply extract the name from: user/christian.mollekopf@klab.cc
foreach (const KIMAP::MailBoxDescriptor &descriptor, descriptors) {
//FIXME this contains to many assumptions about the server, maybe we can use the namespace result instead?
+ if (!mFilterDomain.isEmpty() && !descriptor.name.contains(mFilterDomain)) {
+ continue;
+ }
// int firstSep = descriptor.name.indexOf(QLatin1Char('/'));
int secondSep = descriptor.name.indexOf(QLatin1Char('/'), 6);
int index = descriptor.name.indexOf(QLatin1Char('@'), 6);
diff --git a/fbdaemon/getuserlistjob.h b/fbdaemon/getuserlistjob.h
index fd7e339..2d3fb4e 100644
--- a/fbdaemon/getuserlistjob.h
+++ b/fbdaemon/getuserlistjob.h
@@ -29,6 +29,7 @@ public:
explicit GetUserListJob(const QString &hostName, qint16 port, QObject* parent = 0);
virtual void start();
QStringList getUserList() const;
+ void setFilterDomain(const QString &);
private Q_SLOTS:
void onSessionStateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState);
void onAuthDone(KJob*);
@@ -36,6 +37,7 @@ private Q_SLOTS:
private:
QString mHostName;
qint16 mPort;
+ QString mFilterDomain;
KIMAP::Session *mSession;
QStringList mNames;
diff --git a/fbdaemon/main.cpp b/fbdaemon/main.cpp
index 6796668..f07f3ed 100644
--- a/fbdaemon/main.cpp
+++ b/fbdaemon/main.cpp
@@ -32,7 +32,8 @@ int main(int argc, char *argv[])
options.add("g").add("generate", ki18n("Generate partial f/b lists for <user>"));
options.add("a").add("aggregate", ki18n("Aggregate partial f/b lists for <user>"));
options.add("d").add("daemon", ki18n("Run daemon (todo)"));
- options.add("+[user]", ki18n("User for generation/aggregation"));
+ options.add("generateall", ki18n("Generate and aggregate for all users within domain"));
+ options.add("+[user/domain]", ki18n("User for generation/aggregation | Domain for which freebusy is generated"));
KCmdLineArgs::addCmdLineOptions( options );
@@ -53,17 +54,18 @@ int main(int argc, char *argv[])
FBCoordinator coordinator(&app);
QObject::connect(&coordinator, SIGNAL(quit()), &app, SLOT(quit()));
bool nothingTodo = true;
- if (args->isSet("generate")) {
- if (args->arg(0) == QLatin1String("all")) {
- coordinator.generateForAllUsers();
- } else {
+ if (args->isSet("generateall")) {
+ coordinator.generateForAllUsers(args->arg(0));
+ nothingTodo = false;
+ } else {
+ if (args->isSet("generate")) {
coordinator.generateForUser(args->arg(0));
+ nothingTodo = false;
+ }
+ if (args->isSet("aggregate")) {
+ coordinator.aggregateForUser(args->arg(0));
+ nothingTodo = false;
}
- nothingTodo = false;
- }
- if (args->isSet("aggregate")) {
- coordinator.aggregateForUser(args->arg(0));
- nothingTodo = false;
}
if (args->isSet("daemon")) {