Branch 'kolab/integration/4.13.0' - 2 commits - kcalcore/attendee.h kcalcore/icalformat_p.cpp kcalcore/tests
Sandro Knauß
knauss at kolabsys.com
Thu May 1 12:17:38 CEST 2014
kcalcore/attendee.h | 10 +++++++
kcalcore/icalformat_p.cpp | 48 ++++++++++++++++++++++++++++++++++++++
kcalcore/tests/testicalformat.cpp | 30 +++++++++++++++++++++++
kcalcore/tests/testicalformat.h | 1
4 files changed, 89 insertions(+)
New commits:
commit 47360bf1e60e2b56314e06e60adaffacb374d521
Author: Sandro Knauà <knauss at kolabsys.com>
Date: Tue Apr 29 17:47:59 2014 +0200
Handling attendee cutype read&write ical
REVIEW: 117898
diff --git a/kcalcore/icalformat_p.cpp b/kcalcore/icalformat_p.cpp
index bfcce6d..b1d119c 100644
--- a/kcalcore/icalformat_p.cpp
+++ b/kcalcore/icalformat_p.cpp
@@ -821,6 +821,27 @@ icalproperty *ICalFormatImpl::writeAttendee(const Attendee::Ptr &attendee)
}
icalproperty_add_parameter(p, icalparameter_new_role(role));
+ icalparameter_cutype cutype = ICAL_CUTYPE_INDIVIDUAL;
+ switch (attendee->cuType()) {
+ case Attendee::Unknown:
+ cutype = ICAL_CUTYPE_UNKNOWN;
+ break;
+ default:
+ case Attendee::Individual:
+ cutype = ICAL_CUTYPE_INDIVIDUAL;
+ break;
+ case Attendee::Group:
+ cutype = ICAL_CUTYPE_GROUP;
+ break;
+ case Attendee::Resource:
+ cutype = ICAL_CUTYPE_RESOURCE;
+ break;
+ case Attendee::Room:
+ cutype = ICAL_CUTYPE_ROOM;
+ break;
+ }
+ icalproperty_add_parameter(p, icalparameter_new_cutype(cutype));
+
if (!attendee->uid().isEmpty()) {
icalparameter *icalparameter_uid = icalparameter_new_x(attendee->uid().toUtf8());
@@ -1439,6 +1460,32 @@ Attendee::Ptr ICalFormatImpl::readAttendee(icalproperty *attendee)
}
}
+ Attendee::CuType cuType = Attendee::Individual;
+ p = icalproperty_get_first_parameter( attendee, ICAL_CUTYPE_PARAMETER );
+ if (p) {
+ icalparameter_cutype cutypeParameter = icalparameter_get_cutype(p);
+ switch (cutypeParameter) {
+ case ICAL_CUTYPE_X:
+ case ICAL_CUTYPE_UNKNOWN:
+ cuType = Attendee::Unknown;
+ break;
+ default:
+ case ICAL_CUTYPE_NONE:
+ case ICAL_CUTYPE_INDIVIDUAL:
+ cuType = Attendee::Individual;
+ break;
+ case ICAL_CUTYPE_GROUP:
+ cuType = Attendee::Group;
+ break;
+ case ICAL_CUTYPE_RESOURCE:
+ cuType = Attendee::Resource;
+ break;
+ case ICAL_CUTYPE_ROOM:
+ cuType = Attendee::Room;
+ break;
+ }
+ }
+
p = icalproperty_get_first_parameter(attendee, ICAL_X_PARAMETER);
QMap<QByteArray, QString> custom;
while (p) {
@@ -1453,6 +1500,7 @@ Attendee::Ptr ICalFormatImpl::readAttendee(icalproperty *attendee)
}
Attendee::Ptr a(new Attendee(name, email, rsvp, status, role, uid));
+ a->setCuType(cuType);
a->customProperties().setCustomProperties(custom);
p = icalproperty_get_first_parameter(attendee, ICAL_DELEGATEDTO_PARAMETER);
diff --git a/kcalcore/tests/testicalformat.cpp b/kcalcore/tests/testicalformat.cpp
index 7115687..39b21d1 100644
--- a/kcalcore/tests/testicalformat.cpp
+++ b/kcalcore/tests/testicalformat.cpp
@@ -120,3 +120,33 @@ void ICalFormatTest::testVolatileProperties()
QCOMPARE(incidence->uid(), QLatin1String("12345"));
QVERIFY(incidence->customProperties().isEmpty());
}
+
+void ICalFormatTest::testCuType()
+{
+ ICalFormat format;
+ const QDate currentDate = QDate::currentDate();
+ Event::Ptr event(new Event());
+ event->setUid("12345");
+ event->setDtStart(KDateTime(currentDate));
+ event->setDtEnd(KDateTime(currentDate.addDays(1)));
+
+ Attendee::Ptr attendee(new Attendee("fred", "fred at flintstone.com"));
+ attendee->setCuType(Attendee::Resource);
+
+ event->addAttendee(attendee);
+
+ const QString serialized = format.toString(event.staticCast<Incidence>());
+
+ // test fromString(QString)
+ const QString serializedCalendar =
+ "BEGIN:VCALENDAR\nPRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN\nVERSION:2.0\n" +
+ serialized +
+ "\nEND:VCALENDAR";
+
+ Incidence::Ptr event2 = format.fromString(serializedCalendar);
+ QVERIFY(event2->attendeeCount() == 1);
+ Attendee::Ptr attendee2 = event2->attendees()[0];
+ QVERIFY(attendee2->cuType() == attendee->cuType());
+ QVERIFY(attendee2->name() == attendee->name());
+ QVERIFY(attendee2->email() == attendee->email());
+}
diff --git a/kcalcore/tests/testicalformat.h b/kcalcore/tests/testicalformat.h
index 585adff..c796c84 100644
--- a/kcalcore/tests/testicalformat.h
+++ b/kcalcore/tests/testicalformat.h
@@ -31,6 +31,7 @@ class ICalFormatTest : public QObject
private Q_SLOTS:
void testCharsets();
void testVolatileProperties();
+ void testCuType();
};
#endif
commit e5ad9fb3ec401a287631c37d7205f8d96017c771
Author: Sandro Knauà <mail at sandroknauss.de>
Date: Wed Apr 30 18:15:33 2014 +0200
Added @since header to kcalcore/attendee.h
diff --git a/kcalcore/attendee.h b/kcalcore/attendee.h
index 9ebea8c..4604e2f 100644
--- a/kcalcore/attendee.h
+++ b/kcalcore/attendee.h
@@ -91,6 +91,8 @@ public:
/**
* The different types of a participant.
+ *
+ * @since 4.14
*/
enum CuType {
Individual, /**< An individual (default) */
@@ -197,6 +199,8 @@ public:
@param cuType is the #CuType to use for the attendee.
@see cuType()
+
+ @since 4.14
*/
void setCuType(CuType cuType);
@@ -206,6 +210,8 @@ public:
@param cuType is the #CuType to use for the attendee.
@see cuType()
+
+ @since 4.14
*/
void setCuType(const QString &cuType);
@@ -214,6 +220,8 @@ public:
Returns the #CuType of the attendee.
@see setCuType()
+
+ @since 4.14
*/
CuType cuType() const;
@@ -221,6 +229,8 @@ public:
Returns the #CuType of the attendee.
@see setCuType()
+
+ @since 4.14
*/
QString cuTypeStr() const;
More information about the commits
mailing list