2 commits - schemas/ical src/incidence_p.h src/kolabcontainers.cpp src/kolabcontainers.h src/kolabevent.cpp src/kolabevent.h src/kolabformat.h src/kolabjournal.cpp src/kolabjournal.h src/kolabtodo.cpp src/kolabtodo.h src/xcalconversions.h tests/bindingstest.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Tue May 22 01:54:38 CEST 2012
schemas/ical/kolabformat-xcal.xsd | 3 +
src/incidence_p.h | 1
src/kolabcontainers.cpp | 42 +++++++++++++++++++++-
src/kolabcontainers.h | 14 +++++++
src/kolabevent.cpp | 10 +++++
src/kolabevent.h | 3 +
src/kolabformat.h | 2 -
src/kolabjournal.cpp | 10 +++++
src/kolabjournal.h | 3 +
src/kolabtodo.cpp | 10 +++++
src/kolabtodo.h | 3 +
src/xcalconversions.h | 70 +++++++++++++++++++++++++++++++++++---
tests/bindingstest.cpp | 26 +++++++++++---
13 files changed, 185 insertions(+), 12 deletions(-)
New commits:
commit 704b59a1d69377fccbdfe57140ea70d42060751d
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Mon May 21 23:21:35 2012 +0200
delegatedTo/delegatedFrom/cutype for attendees
diff --git a/src/kolabcontainers.cpp b/src/kolabcontainers.cpp
index 491f9d7..812269d 100644
--- a/src/kolabcontainers.cpp
+++ b/src/kolabcontainers.cpp
@@ -397,12 +397,17 @@ struct Attendee::Private
Private()
: partStat(PartNeedsAction),
role(Required),
- rsvp(false){};
+ rsvp(false),
+ cutype(Unknown)
+ {};
ContactReference contact;
PartStatus partStat;
Role role;
bool rsvp;
+ std::vector<ContactReference> delegatedTo;
+ std::vector<ContactReference> delegatedFrom;
+ Cutype cutype;
};
Attendee::Attendee()
@@ -438,7 +443,11 @@ bool Attendee::operator==(const Kolab::Attendee &other) const
if ( d->contact == other.contact() &&
d->partStat == other.partStat() &&
d->role == other.role() &&
- d->rsvp== other.rsvp()) {
+ d->rsvp == other.rsvp() &&
+ d->delegatedTo == other.delegatedTo() &&
+ d->delegatedFrom == other.delegatedFrom() &&
+ d->cutype == other.cutype()
+ ) {
return true;
}
return false;
@@ -490,6 +499,35 @@ bool Attendee::rsvp() const
return d->rsvp;
}
+void Attendee::setDelegatedTo(const std::vector< ContactReference > &del)
+{
+ d->delegatedTo = del;
+}
+
+std::vector< ContactReference > Attendee::delegatedTo() const
+{
+ return d->delegatedTo;
+}
+
+void Attendee::setDelegatedFrom(const std::vector< ContactReference > &del)
+{
+ d->delegatedFrom = del;
+}
+
+std::vector< ContactReference > Attendee::delegatedFrom() const
+{
+ return d->delegatedFrom;
+}
+
+void Attendee::setCuype(Cutype type)
+{
+ d->cutype = type;
+}
+
+Cutype Attendee::cutype() const
+{
+ return d->cutype;
+}
struct Attachment::Private
diff --git a/src/kolabcontainers.h b/src/kolabcontainers.h
index 256c3cd..90a1f54 100644
--- a/src/kolabcontainers.h
+++ b/src/kolabcontainers.h
@@ -340,6 +340,11 @@ enum Role {
NonParticipant
};
+enum Cutype {
+ Unknown,
+ Resource
+};
+
class Attendee {
public:
Attendee();
@@ -363,6 +368,15 @@ public:
void setRSVP(bool);
bool rsvp() const;
+
+ void setDelegatedTo(const std::vector<ContactReference> &);
+ std::vector<ContactReference> delegatedTo() const;
+
+ void setDelegatedFrom(const std::vector<ContactReference> &);
+ std::vector<ContactReference> delegatedFrom() const;
+
+ void setCuype(Cutype);
+ Cutype cutype() const;
private:
struct Private;
boost::scoped_ptr<Private> d;
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index ffa408f..76a27a3 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -96,6 +96,9 @@ const char* const FR = "FR";
const char* const SA = "SA";
const char* const SU = "SU";
+const char* const RESOURCE = "RESOURCE";
+const char* const UNKNOWN = "UNKNOWN";
+
//Alarms
const char* const START = "START";
const char* const END = "END";
@@ -890,6 +893,26 @@ void setIncidenceProperties(I &inc, const T &prop)
if (const icalendar_2_0::RsvpParamType * p = dynamic_cast<const icalendar_2_0::RsvpParamType*> (&*it)) {
a.setRSVP(p->boolean());
}
+ if (const icalendar_2_0::DelegatedToParamType * p = dynamic_cast<const icalendar_2_0::DelegatedToParamType*> (&*it)) {
+ std::vector<ContactReference> list;
+ BOOST_FOREACH(const icalendar_2_0::CalAddressListParamType::cal_address_type &adr, p->cal_address()) {
+ list.push_back(Shared::toContactReference(adr));
+ }
+ a.setDelegatedTo(list);
+ }
+ if (const icalendar_2_0::DelegatedFromParamType * p = dynamic_cast<const icalendar_2_0::DelegatedFromParamType*> (&*it)) {
+ std::vector<ContactReference> list;
+ BOOST_FOREACH(const icalendar_2_0::CalAddressListParamType::cal_address_type &adr, p->cal_address()) {
+ list.push_back(Shared::toContactReference(adr));
+ }
+ a.setDelegatedFrom(list);
+ }
+ if (const icalendar_2_0::CutypeParamType * p = dynamic_cast<const icalendar_2_0::CutypeParamType*> (&*it)) {
+ if (p->text() == RESOURCE) {
+ a.setCuype(Resource);
+ }
+ }
+
}
}
Kolab::ContactReference ref = toContactReference(aProp);
@@ -1144,6 +1167,36 @@ void getIncidenceProperties(T &prop, const I &inc)
p.baseParameter().push_back(icalendar_2_0::RsvpParamType(true));
}
+ if (!a.delegatedTo().empty()) {
+ icalendar_2_0::DelegatedToParamType delegatedTo;
+ BOOST_FOREACH(const Kolab::ContactReference &ref, a.delegatedTo()) {
+ delegatedTo.cal_address().push_back(CalAddressListParamType::cal_address_type(Shared::fromContactReference(ref, true)));
+ }
+ p.baseParameter().push_back(delegatedTo);
+ }
+
+ if (!a.delegatedFrom().empty()) {
+ icalendar_2_0::DelegatedFromParamType delegatedFrom;
+ BOOST_FOREACH(const Kolab::ContactReference &ref, a.delegatedFrom()) {
+ delegatedFrom.cal_address().push_back(CalAddressListParamType::cal_address_type(Shared::fromContactReference(ref, true)));
+ }
+ p.baseParameter().push_back(delegatedFrom);
+ }
+
+ if (a.cutype() != Unknown) {
+ std::string type;
+ switch (a.cutype()) {
+ case Resource:
+ type = RESOURCE;
+ break;
+ default:
+ WARNING("unknown cutype");
+ type = UNKNOWN;
+ break;
+ }
+ p.baseParameter().push_back(icalendar_2_0::CutypeParamType(type));
+ }
+
prop.attendee().push_back(attendee);
}
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index f7570a2..22367cd 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -93,6 +93,12 @@ void setIncidence(T &ev)
attendee.setPartStat(Kolab::PartDelegated);
attendee.setRole(Kolab::Chair);
attendee.setRSVP(true);
+ std::vector <Kolab::ContactReference > reflist;
+ reflist.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name"));
+ reflist.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail2", "name2"));
+ attendee.setDelegatedTo(reflist);
+ attendee.setDelegatedFrom(reflist);
+ attendee.setCuype(Kolab::Resource);
ev.setAttendees(std::vector<Kolab::Attendee>() << attendee << attendee);
@@ -271,6 +277,12 @@ void BindingsTest::journalCompletness()
attendee.setPartStat(Kolab::PartDelegated);
attendee.setRole(Kolab::Chair);
attendee.setRSVP(true);
+ std::vector <Kolab::ContactReference > reflist;
+ reflist.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail", "name"));
+ reflist.push_back(Kolab::ContactReference(Kolab::ContactReference::EmailReference, "mail2", "name2"));
+ attendee.setDelegatedTo(reflist);
+ attendee.setDelegatedFrom(reflist);
+ attendee.setCuype(Kolab::Resource);
ev.setAttendees(std::vector<Kolab::Attendee>() << attendee << attendee);
commit 071f6e076cd97c6316c6b41b710f849a4b43b558
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Mon May 21 19:00:50 2012 +0200
Implemented last-modified date change.
diff --git a/schemas/ical/kolabformat-xcal.xsd b/schemas/ical/kolabformat-xcal.xsd
index 0a0e9fd..04336f1 100644
--- a/schemas/ical/kolabformat-xcal.xsd
+++ b/schemas/ical/kolabformat-xcal.xsd
@@ -80,6 +80,7 @@
<xs:sequence>
<xs:element name="uid" type="UidPropType"/>
<xs:element name="created" type="CreatedPropType"/>
+ <xs:element name="last-modified" type="LastModifiedPropType" minOccurs="0"/>
<xs:element name="dtstamp" type="DtstampPropType"/>
<xs:element name="sequence" type="SequencePropType" minOccurs="0"/>
<xs:element name="class" type="ClassPropType" minOccurs="0"/>
@@ -121,6 +122,7 @@
<xs:sequence>
<xs:element name="uid" type="UidPropType"/>
<xs:element name="created" type="CreatedPropType"/>
+ <xs:element name="last-modified" type="LastModifiedPropType" minOccurs="0"/>
<xs:element name="dtstamp" type="DtstampPropType"/>
<xs:element name="sequence" type="SequencePropType" minOccurs="0"/>
<xs:element name="class" type="ClassPropType" minOccurs="0"/>
@@ -162,6 +164,7 @@
<xs:sequence>
<xs:element name="uid" type="UidPropType"/>
<xs:element name="created" type="CreatedPropType"/>
+ <xs:element name="last-modified" type="LastModifiedPropType" minOccurs="0"/>
<xs:element name="dtstamp" type="DtstampPropType"/>
<xs:element name="sequence" type="SequencePropType" minOccurs="0"/>
<xs:element name="class" type="ClassPropType" minOccurs="0"/>
diff --git a/src/incidence_p.h b/src/incidence_p.h
index 8602feb..42568d4 100644
--- a/src/incidence_p.h
+++ b/src/incidence_p.h
@@ -34,6 +34,7 @@ namespace Kolab {
std::string uid;
cDateTime created;
cDateTime lastModified;
+ cDateTime timestamp;
int sequence;
Classification classification;
std::vector< std::string > categories;
diff --git a/src/kolabevent.cpp b/src/kolabevent.cpp
index 81cb077..1ac4f71 100644
--- a/src/kolabevent.cpp
+++ b/src/kolabevent.cpp
@@ -90,6 +90,16 @@ cDateTime Event::lastModified() const
return d->lastModified;
}
+void Event::setTimestamp(const cDateTime &dt)
+{
+ d->timestamp = dt;
+}
+
+cDateTime Event::timestamp() const
+{
+ return d->timestamp;
+}
+
void Event::setSequence(int sequence)
{
d->sequence = sequence;
diff --git a/src/kolabevent.h b/src/kolabevent.h
index 415a1e9..c203ace 100644
--- a/src/kolabevent.h
+++ b/src/kolabevent.h
@@ -41,6 +41,9 @@ public:
void setLastModified(const cDateTime &);
cDateTime lastModified() const;
+
+ void setTimestamp(const cDateTime &);
+ cDateTime timestamp() const;
void setSequence(int);
int sequence() const;
diff --git a/src/kolabformat.h b/src/kolabformat.h
index 6b016b2..d419a33 100644
--- a/src/kolabformat.h
+++ b/src/kolabformat.h
@@ -61,7 +61,7 @@ std::string getSerializedUID();
* Use this function to override the timestamp which is normally generated upon serialization from the system time.
* To override the timestamp call this function once. You will need to clear the timestamp manually by setting a default constructed cDateTime().
*
- * The timestamp is used as lastModifiedDate on every write, and as creation-date on the first write (when there is no creation-date yet).
+ * The timestamp is used as timestamp property on every write, and as creation-date on the first write (when there is no creation-date yet).
*
* The supplied timestamp must be in UTC format.
*
diff --git a/src/kolabjournal.cpp b/src/kolabjournal.cpp
index ce37fbc..2f3e3ee 100644
--- a/src/kolabjournal.cpp
+++ b/src/kolabjournal.cpp
@@ -81,6 +81,16 @@ cDateTime Journal::lastModified() const
return d->lastModified;
}
+void Journal::setTimestamp(const cDateTime &dt)
+{
+ d->timestamp = dt;
+}
+
+cDateTime Journal::timestamp() const
+{
+ return d->timestamp;
+}
+
void Journal::setSequence(int sequence)
{
d->sequence = sequence;
diff --git a/src/kolabjournal.h b/src/kolabjournal.h
index 9a904d3..c10bb55 100644
--- a/src/kolabjournal.h
+++ b/src/kolabjournal.h
@@ -41,6 +41,9 @@ public:
void setLastModified(const cDateTime &);
cDateTime lastModified() const;
+
+ void setTimestamp(const cDateTime &);
+ cDateTime timestamp() const;
void setSequence(int);
int sequence() const;
diff --git a/src/kolabtodo.cpp b/src/kolabtodo.cpp
index ceefcf9..9100e91 100644
--- a/src/kolabtodo.cpp
+++ b/src/kolabtodo.cpp
@@ -88,6 +88,16 @@ cDateTime Todo::lastModified() const
return d->lastModified;
}
+void Todo::setTimestamp(const cDateTime &dt)
+{
+ d->timestamp = dt;
+}
+
+cDateTime Todo::timestamp() const
+{
+ return d->timestamp;
+}
+
void Todo::setSequence(int sequence)
{
d->sequence = sequence;
diff --git a/src/kolabtodo.h b/src/kolabtodo.h
index ce547e3..29b4a3b 100644
--- a/src/kolabtodo.h
+++ b/src/kolabtodo.h
@@ -42,6 +42,9 @@ public:
void setLastModified(const cDateTime &);
cDateTime lastModified() const;
+
+ void setTimestamp(const cDateTime &);
+ cDateTime timestamp() const;
void setSequence(int);
int sequence() const;
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index 5daf9f9..ffa408f 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -804,7 +804,10 @@ void setIncidenceProperties(I &inc, const T &prop)
{
inc.setUid(toString(prop.uid()));
inc.setCreated(*toDate(prop.created()));
- inc.setLastModified(*toDate(prop.dtstamp()));
+ if (prop.last_modified()) {
+ inc.setLastModified(*toDate(*prop.last_modified()));
+ }
+ inc.setTimestamp(*toDate(prop.dtstamp()));
if (prop.sequence()) {
inc.setSequence(toInt(*prop.sequence()));
@@ -1047,9 +1050,15 @@ template <typename T, typename I>
void getIncidenceProperties(T &prop, const I &inc)
{
using namespace icalendar_2_0;
-
- typedef T properties;
-
+
+ typedef T properties;
+
+ if (inc.lastModified().isValid()) {
+ icalendar_2_0::LastModifiedPropType p;
+ p.date_time(fromDateTime(inc.lastModified()));
+ prop.last_modified(p);
+ }
+
prop.sequence(fromInt<xml_schema::integer>(inc.sequence()));
switch (inc.classification()) {
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index 3bd9ff3..f7570a2 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -53,6 +53,7 @@ void setIncidence(T &ev)
{
ev.setUid("UID");
ev.setCreated(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
+ ev.setLastModified(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
ev.setSequence(1);
ev.setClassification(Kolab::ClassConfidential);
ev.addCategory("Category");
@@ -157,7 +158,8 @@ void checkIncidence(const T &ev, const T &re)
QCOMPARE(ev.uid(), re.uid());
QCOMPARE(ev.created(), re.created());
- QVERIFY(re.lastModified().isValid()); //TODO can we check this better?
+ QCOMPARE(ev.lastModified(), re.lastModified());
+ QVERIFY(re.timestamp().isValid()); //TODO can we check this better?
QCOMPARE(ev.sequence(), re.sequence());
QCOMPARE(ev.classification(), re.classification());
QCOMPARE(ev.categories(), re.categories());
@@ -208,7 +210,7 @@ void BindingsTest::eventCompletness()
ev.setTransparency(true);
std::string result = Kolab::writeEvent(ev);
- QVERIFY(Kolab::error() == Kolab::NoError);
+ QCOMPARE(Kolab::error(), Kolab::NoError);
// std::cout << result << endl;
Kolab::Event e = Kolab::readEvent(result, false);
QVERIFY(Kolab::error() == Kolab::NoError);
@@ -260,6 +262,7 @@ void BindingsTest::journalCompletness()
ev.setUid("UID");
ev.setCreated(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
+ ev.setLastModified(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
ev.setSequence(1);
ev.setClassification(Kolab::ClassConfidential);
ev.addCategory("Category");
@@ -319,7 +322,8 @@ void BindingsTest::journalCompletness()
QCOMPARE(ev.uid(), re.uid());
QCOMPARE(ev.created(), re.created());
- QVERIFY(re.lastModified().isValid()); //TODO can we check this better?
+ QCOMPARE(ev.lastModified(), re.lastModified());
+ QVERIFY(re.timestamp().isValid()); //TODO can we check this better?
QCOMPARE(ev.sequence(), re.sequence());
QCOMPARE(ev.classification(), re.classification());
QCOMPARE(ev.categories(), re.categories());
@@ -446,10 +450,10 @@ void BindingsTest::contactCompletness()
c.setCustomProperties(properties);
const std::string result = Kolab::writeContact(c);
- QVERIFY(Kolab::error() == Kolab::NoError);
+ QCOMPARE(Kolab::error(), Kolab::NoError);
// std::cout << result << endl;
Kolab::Contact e = Kolab::readContact(result, false);
- QVERIFY(Kolab::error() == Kolab::NoError);
+ QCOMPARE(Kolab::error(), Kolab::NoError);
QCOMPARE(e.uid(), c.uid());
QCOMPARE(e.categories(), c.categories());
QCOMPARE(e.name(), c.name());
More information about the commits
mailing list