summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <mail@sandroknauss.de>2014-06-25 11:50:20 (GMT)
committerSandro Knauß <mail@sandroknauss.de>2014-06-25 11:50:20 (GMT)
commit22e87834909ef0fe35ec61563a2447a0ea1c6417 (patch)
tree5b5c84978d0bd484d391ae22c959ea88079ad2b3
parent86530763597fae89221c4041a19738b5d1f6d380 (diff)
downloadkolab-utils-22e87834909ef0fe35ec61563a2447a0ea1c6417.tar.gz
daemon returns vcalender(ifb) file
-rw-r--r--fbdaemon/fbdaemonconnection.cpp7
-rw-r--r--fbdaemon/fbgeneratorfolderjob.cpp4
-rw-r--r--fbdaemon/tests/daemonconnectiontest.cpp47
-rw-r--r--fbdaemon/tests/data/aggregator/imap-2847010
-rw-r--r--fbdaemon/tests/fbaggregatortest.cpp6
-rw-r--r--fbdaemon/tests/fbgeneratorfoldertest.cpp7
6 files changed, 58 insertions, 23 deletions
diff --git a/fbdaemon/fbdaemonconnection.cpp b/fbdaemon/fbdaemonconnection.cpp
index c579730..e155658 100644
--- a/fbdaemon/fbdaemonconnection.cpp
+++ b/fbdaemon/fbdaemonconnection.cpp
@@ -23,6 +23,7 @@
#include "settings.h"
#include <xmlobject.h>
+#include <freebusy.h>
#include <kpimutils/email.h>
#include <kimap/rfccodecs.h>
@@ -317,9 +318,9 @@ void FbDaemonConnection::onGenerateUserDone(KJob* job)
void FbDaemonConnection::onSendFbObject(const Kolab::Freebusy &freebusy)
{
QByteArray block;
- const std::string &v3String = Kolab::writeFreebusy(freebusy);
- block = "* ({" + QByteArray::number((uint)v3String.length()) + "} \r\n";
- block += v3String.c_str();
+ const std::string &sIFB = Kolab::FreebusyUtils::toIFB(freebusy);
+ block = "* ({" + QByteArray::number((uint)sIFB.length()) + "} \r\n";
+ block += sIFB.c_str();
block += ")\r\n";
block += createStatusLine("OK", "completed");
diff --git a/fbdaemon/fbgeneratorfolderjob.cpp b/fbdaemon/fbgeneratorfolderjob.cpp
index 4671039..0dfc0da 100644
--- a/fbdaemon/fbgeneratorfolderjob.cpp
+++ b/fbdaemon/fbgeneratorfolderjob.cpp
@@ -26,6 +26,7 @@
#include <kimap/myrightsjob.h>
#include <kimap/listjob.h>
#include <kolabdefinitions.h>
+#include <commonconversion.h>
FBGeneratorFolderJob::FBGeneratorFolderJob(const SessionSettings &settings, QString folder, QObject* parent)
: KolabJob(settings, parent),
@@ -110,6 +111,9 @@ void FBGeneratorFolderJob::onGenerateFBDone(KJob* job)
mFreebusy = fbJob->getFreebusy();
+ const Kolab::ContactReference org(Kolab::ContactReference::EmailReference, Kolab::Conversion::toStdString(QLatin1String("fbdaemon@localhost")));
+ mFreebusy.setOrganizer(org);
+
logout();
}
diff --git a/fbdaemon/tests/daemonconnectiontest.cpp b/fbdaemon/tests/daemonconnectiontest.cpp
index e59fd6c..1cba5fa 100644
--- a/fbdaemon/tests/daemonconnectiontest.cpp
+++ b/fbdaemon/tests/daemonconnectiontest.cpp
@@ -23,6 +23,9 @@
#include "cyrusfakeserver.h"
#include "settings.h"
+#include <kcalcore/memorycalendar.h>
+#include <kcalcore/icalformat.h>
+
#include <kimaptest/fakeserver.h>
#include <xmlobject.h>
#include <kcalconversion.h>
@@ -165,10 +168,24 @@ void ConnectionTest::testGeneratorUserJob()
QCOMPARE(arguments.at(0).type(), QVariant::ByteArray);
QCOMPARE(ifb.indexIn(arguments.at(0).toString()), 0);
QCOMPARE(ifb.cap(1).toInt(), ifb.cap(2).size()); // Object size == expected size
- std::string sFb = ifb.cap(2).toUtf8().constData();
- Kolab::Freebusy fb = Kolab::readFreebusy(sFb, false);
- QCOMPARE(Kolab::Conversion::toDate(fb.start()), start);
- QCOMPARE(Kolab::Conversion::toDate(fb.end()), end);
+ 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);
+ 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());
+
+ QCOMPARE(fb->dtStart(), start);
+ //QCOMPARE(fb->dtEnd(), end);
+
+ QVERIFY(!fb->uid().isEmpty());
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();
@@ -199,10 +216,23 @@ void ConnectionTest::testGeneratorFolderJob()
QCOMPARE(arguments.at(0).type(), QVariant::ByteArray);
QCOMPARE(ifb.indexIn(arguments.at(0).toString()), 0);
QCOMPARE(ifb.cap(1).toInt(), ifb.cap(2).size()); // Object size == expected size
- std::string sFb = ifb.cap(2).toUtf8().constData();
- Kolab::Freebusy fb = Kolab::readFreebusy(sFb, false);
- QCOMPARE(Kolab::Conversion::toDate(fb.start()), start);
- QCOMPARE(Kolab::Conversion::toDate(fb.end()), end);
+
+ 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());
+ QCOMPARE(msg->event()->organizer()->email(), QLatin1String("fbdaemon@localhost"));
+ //QVERIFY(msg->event()->lastModified().isValid());
+
+ QCOMPARE(msg->event()->dtStart(), start);
+ //QCOMPARE(msg->event()->dtEnd(), end);
+
+ QVERIFY(!msg->event()->uid().isEmpty());
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();
@@ -230,7 +260,6 @@ 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");
- qDebug() << "job: " << connection->job;
connect(connection->job, SIGNAL(result(KJob*)),
&loop, SLOT(quit()));
loop.exec();
diff --git a/fbdaemon/tests/data/aggregator/imap-28470 b/fbdaemon/tests/data/aggregator/imap-28470
index d4f8753..34f0c76 100644
--- a/fbdaemon/tests/data/aggregator/imap-28470
+++ b/fbdaemon/tests/data/aggregator/imap-28470
@@ -12,16 +12,16 @@ A000005 OK Completed
* LIST (\HasNoChildren) "/" "Calendar/Personal Calendar"
* LIST (\HasNoChildren) "/" Freebusy
A000006 OK Completed (0.010 secs 4 calls)
-<1400750991<A000007 GETMETADATA (DEPTH 1 MAXSIZE 1234) "INBOX" (/shared/vendor/kolab/folder-type)
+<1400750991<A000007 GETMETADATA "INBOX" (/shared/vendor/kolab/folder-type)
>1400750991>* METADATA INBOX (/shared/vendor/kolab/folder-type NIL)
A000007 OK Completed
-<1400750991<A000009 GETMETADATA (DEPTH 1 MAXSIZE 1234) "Calendar" (/shared/vendor/kolab/folder-type)
+<1400750991<A000009 GETMETADATA "Calendar" (/shared/vendor/kolab/folder-type)
>1400750991>* METADATA Calendar (/shared/vendor/kolab/folder-type "event")
A000009 OK Completed
-<1400750991<A000010 GETMETADATA (DEPTH 1 MAXSIZE 1234) "Calendar/Personal Calendar" (/shared/vendor/kolab/folder-type)
+<1400750991<A000010 GETMETADATA "Calendar/Personal Calendar" (/shared/vendor/kolab/folder-type)
>1400750991>* METADATA "Calendar/Personal Calendar" (/shared/vendor/kolab/folder-type "event")
A000010 OK Completed
-<1400750991<A000016 GETMETADATA (DEPTH 1 MAXSIZE 1234) "Freebusy" (/shared/vendor/kolab/folder-type)
+<1400750991<A000016 GETMETADATA "Freebusy" (/shared/vendor/kolab/folder-type)
>1400750991>* METADATA Freebusy (/shared/vendor/kolab/folder-type "freebusy")
A000016 OK Completed
<1400750991<A000023 EXAMINE "Freebusy"
@@ -357,4 +357,4 @@ Content-Disposition: attachment; filename="kolab.xml"
A000025 OK Completed (0.040 sec)
<1400750991<A000026 LOGOUT
>1400750991>* BYE LOGOUT received
-A000026 OK Completed \ No newline at end of file
+A000026 OK Completed
diff --git a/fbdaemon/tests/fbaggregatortest.cpp b/fbdaemon/tests/fbaggregatortest.cpp
index 619d59b..aecb4eb 100644
--- a/fbdaemon/tests/fbaggregatortest.cpp
+++ b/fbdaemon/tests/fbaggregatortest.cpp
@@ -78,8 +78,6 @@ void FBAggregatorTest::checkFbObject()
QTextStream in(&file);
QString data = in.readAll();
- qDebug() << data;
-
KCalCore::ICalFormat format;
KCalCore::Calendar::Ptr cal(new KCalCore::MemoryCalendar(KDateTime::Spec::UTC()));
KCalCore::ScheduleMessage::Ptr msg = format.parseScheduleMessage(cal, data);
@@ -89,7 +87,7 @@ void FBAggregatorTest::checkFbObject()
QVERIFY(msg->event());
QCOMPARE(msg->event()->organizer()->email(), user);
QVERIFY(!msg->event()->uid().isEmpty());
- QVERIFY(msg->event()->lastModified().isValid());
+ //QVERIFY(msg->event()->lastModified().isValid());
//TODO:test content of aggregated file
}
@@ -108,4 +106,4 @@ void FBAggregatorTest::testGenerator()
QTEST_MAIN(FBAggregatorTest)
-#include "fbaggregatortest.moc" \ No newline at end of file
+#include "fbaggregatortest.moc"
diff --git a/fbdaemon/tests/fbgeneratorfoldertest.cpp b/fbdaemon/tests/fbgeneratorfoldertest.cpp
index 6f79c95..0e0f831 100644
--- a/fbdaemon/tests/fbgeneratorfoldertest.cpp
+++ b/fbdaemon/tests/fbgeneratorfoldertest.cpp
@@ -102,11 +102,14 @@ void FBGeneratorFolderTest::testGenerator()
Kolab::Freebusy fb2 = executeGeneration("shared/Resources/mybeamer@example.com", start, end);
QCOMPARE((int)fb1.periods().size(), 1);
- QCOMPARE(fb1.organizer(), Kolab::ContactReference(user.toUtf8().constData()));
+ QCOMPARE(fb1.organizer(), Kolab::ContactReference(QString("fbdaemon@localhost").toUtf8().constData()));
QCOMPARE(Kolab::Conversion::toDate(fb1.start()), start);
QCOMPARE(Kolab::Conversion::toDate(fb1.end()), end);
QCOMPARE((int)fb1.periods().at(0).periods().size(), 1);
QCOMPARE(fb1.periods().at(0).periods().at(0), period);
+ QVERIFY(!fb1.uid().empty());
+ QVERIFY(!fb2.uid().empty());
+
compareFreeBusy(fb2, fb1);
QVERIFY(fakeServer.isAllScenarioDone());
@@ -131,7 +134,7 @@ void FBGeneratorFolderTest::testGeneratorEmpty()
Kolab::Freebusy fb1 = executeGeneration("shared/Resources/mybeamer@example.com", start, end);
QCOMPARE((int)fb1.periods().size(), 0);
- QCOMPARE(fb1.organizer(), Kolab::ContactReference(user.toUtf8().constData()));
+ QCOMPARE(fb1.organizer(), Kolab::ContactReference(QString("fbdaemon@localhost").toUtf8().constData()));
QVERIFY(fakeServer.isAllScenarioDone());
fakeServer.quit();