summaryrefslogtreecommitdiff
path: root/fbdaemon
diff options
context:
space:
mode:
authorSandro Knauß <mail@sandroknauss.de>2014-07-05 09:28:15 (GMT)
committerSandro Knauß <mail@sandroknauss.de>2014-07-05 09:28:15 (GMT)
commit088c51125d22ca3f26b35476edc0851a4742acfb (patch)
treefd6cdf4b47a698df418e822197ed8e121cd17107 /fbdaemon
parent22e87834909ef0fe35ec61563a2447a0ea1c6417 (diff)
downloadkolab-utils-088c51125d22ca3f26b35476edc0851a4742acfb.tar.gz
Fix #3184: Invalid freebusy data returned when folder/mailbox is empty
Bug: 3184
Diffstat (limited to 'fbdaemon')
-rw-r--r--fbdaemon/generatefbjob.cpp1
-rw-r--r--fbdaemon/tests/daemonconnectiontest.cpp44
-rw-r--r--fbdaemon/tests/fbgeneratorfoldertest.cpp3
3 files changed, 34 insertions, 14 deletions
diff --git a/fbdaemon/generatefbjob.cpp b/fbdaemon/generatefbjob.cpp
index 64c5915..f019048 100644
--- a/fbdaemon/generatefbjob.cpp
+++ b/fbdaemon/generatefbjob.cpp
@@ -90,6 +90,7 @@ void GenerateFBJob::onFetchDone(KJob *job)
Debug() << "found " << fetch->getMessages().size() << " messages";
if (fetch->getMessages().isEmpty()) {
+ mFreebusy = Kolab::FreebusyUtils::generateFreeBusy(QList<KCalCore::Event::Ptr>(), mStart, mEnd, KCalCore::Person::Ptr());
checkJobDone();
return;
}
diff --git a/fbdaemon/tests/daemonconnectiontest.cpp b/fbdaemon/tests/daemonconnectiontest.cpp
index 1cba5fa..0f2b3cb 100644
--- a/fbdaemon/tests/daemonconnectiontest.cpp
+++ b/fbdaemon/tests/daemonconnectiontest.cpp
@@ -174,18 +174,17 @@ void ConnectionTest::testGeneratorUserJob()
KCalCore::Calendar::Ptr cal(new KCalCore::MemoryCalendar(KDateTime::Spec::UTC()));
KCalCore::ScheduleMessage::Ptr msg = format.parseScheduleMessage(cal, sFb);
QVERIFY(msg);
- QVERIFY(msg->event());
- KCalCore::IncidenceBase::Ptr fb = msg->event();
- //const KCalCore::FreeBusy *fb = msg->event().constCast<KCalCore::FreeBusy>();// = const_cast<const KCalCore::FreeBusy*>(msg->event().data());
QCOMPARE(msg->method(), KCalCore::iTIPPublish);
QCOMPARE(format.timeSpec(), KDateTime::Spec::UTC());
- QCOMPARE(fb->organizer()->email(), QLatin1String("john.doe@example.com"));
- //QVERIFY(msg->event()->lastModified().isValid());
+ QVERIFY(msg->event());
- QCOMPARE(fb->dtStart(), start);
- //QCOMPARE(fb->dtEnd(), end);
+ KCalCore::FreeBusy::Ptr event = msg->event().staticCast<KCalCore::FreeBusy>();
+ QCOMPARE(event->organizer()->email(), QLatin1String("john.doe@example.com"));
- QVERIFY(!fb->uid().isEmpty());
+ QCOMPARE(event->dtStart(), start);
+ QCOMPARE(event->dtEnd(), end);
+
+ QVERIFY(!event->uid().isEmpty());
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();
@@ -226,13 +225,13 @@ void ConnectionTest::testGeneratorFolderJob()
QCOMPARE(msg->method(), KCalCore::iTIPPublish);
QCOMPARE(format.timeSpec(), KDateTime::Spec::UTC());
QVERIFY(msg->event());
- QCOMPARE(msg->event()->organizer()->email(), QLatin1String("fbdaemon@localhost"));
- //QVERIFY(msg->event()->lastModified().isValid());
+ KCalCore::FreeBusy::Ptr event = msg->event().staticCast<KCalCore::FreeBusy>();
+ QCOMPARE(event->organizer()->email(), QLatin1String("fbdaemon@localhost"));
- QCOMPARE(msg->event()->dtStart(), start);
- //QCOMPARE(msg->event()->dtEnd(), end);
+ QCOMPARE(event->dtStart(), start);
+ QCOMPARE(event->dtEnd(), end);
- QVERIFY(!msg->event()->uid().isEmpty());
+ QVERIFY(!event->uid().isEmpty());
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();
@@ -259,7 +258,7 @@ void ConnectionTest::testFailingFirst()
compareSendData("BAD IFB MyRights failed, server replied: A000005 NO Mailbox does not exist \r\n\r\n");
- connection->onNewLine("IFB FOLDER shared/Resources/mybeamer@example.com");
+ connection->onNewLine("IFB FOLDER shared/Resources/mybeamer@example.com slot:1400604981-1405788981");
connect(connection->job, SIGNAL(result(KJob*)),
&loop, SLOT(quit()));
loop.exec();
@@ -271,6 +270,23 @@ void ConnectionTest::testFailingFirst()
QCOMPARE(ifb.indexIn(arguments.at(0).toString()), 0);
QCOMPARE(ifb.cap(1).toInt(), ifb.cap(2).size()); // Object size == expected size
+ const QString sFb = ifb.cap(2);
+
+ KCalCore::ICalFormat format;
+ KCalCore::Calendar::Ptr cal(new KCalCore::MemoryCalendar(KDateTime::Spec::UTC()));
+ KCalCore::ScheduleMessage::Ptr msg = format.parseScheduleMessage(cal, sFb);
+ QVERIFY(msg);
+ QCOMPARE(msg->method(), KCalCore::iTIPPublish);
+ QCOMPARE(format.timeSpec(), KDateTime::Spec::UTC());
+ QVERIFY(msg->event());
+ KCalCore::FreeBusy::Ptr event = msg->event().staticCast<KCalCore::FreeBusy>();
+ QCOMPARE(event->organizer()->email(), QLatin1String("fbdaemon@localhost"));
+
+ QCOMPARE(event->dtStart(), start);
+ QCOMPARE(event->dtEnd(), end);
+
+ QVERIFY(!event->uid().isEmpty());
+
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();
}
diff --git a/fbdaemon/tests/fbgeneratorfoldertest.cpp b/fbdaemon/tests/fbgeneratorfoldertest.cpp
index 0e0f831..1d11640 100644
--- a/fbdaemon/tests/fbgeneratorfoldertest.cpp
+++ b/fbdaemon/tests/fbgeneratorfoldertest.cpp
@@ -135,6 +135,9 @@ void FBGeneratorFolderTest::testGeneratorEmpty()
QCOMPARE((int)fb1.periods().size(), 0);
QCOMPARE(fb1.organizer(), Kolab::ContactReference(QString("fbdaemon@localhost").toUtf8().constData()));
+ QCOMPARE(Kolab::Conversion::toDate(fb1.start()), start);
+ QCOMPARE(Kolab::Conversion::toDate(fb1.end()), end);
+ QVERIFY(!fb1.uid().empty());
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();