summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-05-21 17:00:50 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-05-21 17:00:50 (GMT)
commit071f6e076cd97c6316c6b41b710f849a4b43b558 (patch)
treea4d87e9c8fd5ce0eac1de0fda15e9d9e2d616b86
parent2ce5dd24fd7a9f3c31f27f7c15e1b570c1b3c44b (diff)
downloadlibkolabxml-071f6e076cd97c6316c6b41b710f849a4b43b558.tar.gz
Implemented last-modified date change.
-rw-r--r--schemas/ical/kolabformat-xcal.xsd3
-rw-r--r--src/incidence_p.h1
-rw-r--r--src/kolabevent.cpp10
-rw-r--r--src/kolabevent.h3
-rw-r--r--src/kolabformat.h2
-rw-r--r--src/kolabjournal.cpp10
-rw-r--r--src/kolabjournal.h3
-rw-r--r--src/kolabtodo.cpp10
-rw-r--r--src/kolabtodo.h3
-rw-r--r--src/xcalconversions.h17
-rw-r--r--tests/bindingstest.cpp14
11 files changed, 66 insertions, 10 deletions
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());