5 commits - src/kolabcontainers.h src/kolabconversions.h src/kolabformat.cpp src/kolabformat.h src/xcalconversions.h tests/bindingstest.cpp

Christian Mollekopf mollekopf at kolabsys.com
Wed May 30 14:58:57 CEST 2012


 src/kolabcontainers.h  |    3 +--
 src/kolabconversions.h |   31 +++++++++++++++++++------------
 src/kolabformat.cpp    |    5 +++++
 src/kolabformat.h      |   13 +++++++++++++
 src/xcalconversions.h  |    5 +----
 tests/bindingstest.cpp |    6 ++++++
 6 files changed, 45 insertions(+), 18 deletions(-)

New commits:
commit 6ff67e345780ba9dd7a92047a1f11ef114fe2cc6
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed May 30 14:58:53 2012 +0200

    check error during tests.

diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index f823e9d..9d6437c 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -38,8 +38,10 @@ void BindingsTest::categorycolorConfigurationCompletness()
     configuration.setLastModified(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
 
     const std::string &result = Kolab::writeConfiguration(configuration);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
 //     std::cout << result << std::endl;
     const Kolab::Configuration &re = Kolab::readConfiguration(result, false);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
     QCOMPARE(re.uid(), configuration.uid());
     QCOMPARE(re.created(), configuration.created());
     QCOMPARE(re.lastModified(), configuration.lastModified());
@@ -63,8 +65,10 @@ void BindingsTest::dictionaryConfigurationCompletness()
     configuration.setLastModified(Kolab::cDateTime(2006,1,6,12,0,0,true)); //UTC
 
     const std::string &result = Kolab::writeConfiguration(configuration);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
 //     std::cout << result << std::endl;
     const Kolab::Configuration &re = Kolab::readConfiguration(result, false);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
     QCOMPARE(re.uid(), configuration.uid());
     QCOMPARE(re.created(), configuration.created());
     QCOMPARE(re.lastModified(), configuration.lastModified());
@@ -85,9 +89,11 @@ void BindingsTest::noteCompletness()
     note.setDescription("description");
     note.setColor("color");
     const std::string &result = Kolab::writeNote(note);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
 //     std::cout << result << std::endl;
     
     const Kolab::Note &re = Kolab::readNote(result, false);
+    QCOMPARE(Kolab::error(), Kolab::NoError);
     QCOMPARE(re.uid(), note.uid());
     QCOMPARE(re.created(), note.created());
     QCOMPARE(re.lastModified(), note.lastModified());


commit 67730219645f2655b41628e880183f95698f870e
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed May 30 14:58:42 2012 +0200

    A warning is not an error, wrap that into function.

diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index 13d282b..b2e406b 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -31,6 +31,11 @@ ErrorSeverity error()
     return Utils::getError();
 }
 
+bool errorOccurred()
+{
+    return Utils::getError() > Warning;
+}
+
 std::string errorMessage()
 {
     return Utils::getErrorMessage();
diff --git a/src/kolabformat.h b/src/kolabformat.h
index 57e4940..5267025 100644
--- a/src/kolabformat.h
+++ b/src/kolabformat.h
@@ -32,8 +32,21 @@ namespace Kolab {
 
 /**
  * Check to see if serialization/deserialization was successful.
+ *
+ * Returns true if at least an Error occurred. Warning is not considered an error.
+ */
+bool errorOccurred();
+
+/**
+ * Returns the highest severity of the errors which occured.
+ *
+ * Note that a Warning is not considered an error, use errorOccurred to check for errors.
  */
 Kolab::ErrorSeverity error();
+
+/**
+ * Returns the corresponding error message to the reported error.
+ */
 std::string errorMessage();
 
 /**


commit e1b367aa9c312a2163cabe4b7ab7da56ff15c30d
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed May 30 14:58:15 2012 +0200

    Avoid unnecessary conversion errors

diff --git a/src/kolabconversions.h b/src/kolabconversions.h
index 5fd7edd..446771c 100644
--- a/src/kolabconversions.h
+++ b/src/kolabconversions.h
@@ -95,18 +95,21 @@ std::string serializeObject <Kolab::Configuration> (const Kolab::Configuration &
         const std::string &uid = getUID(note.uid());
         setCreatedUid(uid);
 
-        KolabXSD::Configuration::creation_date_type created = fromDateTime(note.created());
-        if (!note.created().isValid()) {
+        KolabXSD::Configuration::creation_date_type created(0,0,0,0,0,0);
+        if (note.created().isValid()) {
+            created = fromDateTime(note.created());
+        } else {
             created = fromDateTime(timestamp());
         }
-
-        KolabXSD::Configuration n(getUID(note.uid()), getProductId(prod), created, fromDateTime(timestamp()), getConfiguratinoType(note.type()));
+        KolabXSD::Configuration::last_modification_date_type lastModificationDate(0,0,0,0,0,0);
         if (note.lastModified().isValid()) {
-            n.last_modification_date(fromDateTime(note.lastModified()));
+            lastModificationDate = fromDateTime(note.lastModified());
         } else {
             WARNING("missing last_modification_date, fallback to current timestamp");
-            n.last_modification_date(fromDateTime(timestamp()));
+            lastModificationDate = fromDateTime(timestamp());
         }
+        KolabXSD::Configuration n(getUID(note.uid()), getProductId(prod), created, lastModificationDate, getConfiguratinoType(note.type()));
+
         switch (note.type()) {
             case Kolab::Configuration::TypeDictionary: {
                 const Kolab::Dictionary &dict = note.dictionary();
@@ -145,18 +148,22 @@ std::string serializeObject <Kolab::Note> (const Kolab::Note &note, const std::s
         const std::string &uid = getUID(note.uid());
         setCreatedUid(uid);
         
-        KolabXSD::Note::creation_date_type created = fromDateTime(note.created());
-        if (!note.created().isValid()) {
+        KolabXSD::Note::creation_date_type created(0,0,0,0,0,0);
+        if (note.created().isValid()) {
+            created = fromDateTime(note.created());
+        } else {
             created = fromDateTime(timestamp());
         }
-
-        KolabXSD::Note n(getUID(note.uid()), getProductId(prod), created, fromDateTime(timestamp()));
+        KolabXSD::Note::last_modification_date_type lastModificationDate(0,0,0,0,0,0);
         if (note.lastModified().isValid()) {
-            n.last_modification_date(fromDateTime(note.lastModified()));
+            lastModificationDate = fromDateTime(note.lastModified());
         } else {
             WARNING("missing last_modification_date, fallback to current timestamp");
-            n.last_modification_date(fromDateTime(timestamp()));
+            lastModificationDate = fromDateTime(timestamp());
         }
+
+        KolabXSD::Note n(getUID(note.uid()), getProductId(prod), created, lastModificationDate);
+
         if (!note.categories().empty()) {
             KolabXSD::Note::categories_sequence categories;
             const std::vector<std::string> &l = note.categories();


commit 6263dcb1b8b423b8c178b262e1cd503dabd44ff7
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed May 30 14:57:53 2012 +0200

    The type is not relevant for the comparison.

diff --git a/src/kolabcontainers.h b/src/kolabcontainers.h
index 5e9df0c..5f8318d 100644
--- a/src/kolabcontainers.h
+++ b/src/kolabcontainers.h
@@ -185,8 +185,7 @@ struct ContactReference {
             mUid = emailOrUID;
         }
     };
-    bool operator==(const ContactReference &other) const { return mType == other.mType &&
-                                                        mEmail == other.mEmail &&
+    bool operator==(const ContactReference &other) const { return mEmail == other.mEmail &&
                                                         mName == other.mName &&
                                                         mUid == other.mUid;
     };


commit 68bc5abbeaee36b3f6fa4e466c4cf9a02d1ab44b
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Fri May 25 17:12:14 2012 +0200

    Don't write default value

diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index ced0b27..98f6d9c 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -1196,12 +1196,9 @@ void getIncidenceProperties(T &prop, const I &inc)
                 p.baseParameter().push_back(delegatedFrom);
             }
 
-            if (a.cutype() != CutypeUnknown) {
+            if (a.cutype() != CutypeIndividual) {
                 std::string type;
                 switch (a.cutype()) {
-                    case CutypeIndividual:
-                        type = INDIVIDUAL;
-                        break;
                     case CutypeGroup:
                         type = GROUP;
                         break;





More information about the commits mailing list