2 commits - src/containers src/kolabformat.cpp src/utils.h src/xcalconversions.h

Christian Mollekopf mollekopf at kolabsys.com
Fri Mar 21 17:30:58 CET 2014


 src/containers/kolabcontainers.cpp |    6 +++++-
 src/kolabformat.cpp                |   27 +++++++++++++++++++++++++++
 src/utils.h                        |    8 ++++----
 src/xcalconversions.h              |    5 +----
 4 files changed, 37 insertions(+), 9 deletions(-)

New commits:
commit 0580ae5453f84544a1880ed1256bd524ff5f6c9b
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Fri Mar 21 17:30:45 2014 +0100

    Made attachment mimetype optional.

diff --git a/src/containers/kolabcontainers.cpp b/src/containers/kolabcontainers.cpp
index 47c76e3..fc241a1 100644
--- a/src/containers/kolabcontainers.cpp
+++ b/src/containers/kolabcontainers.cpp
@@ -536,11 +536,13 @@ struct Attachment::Private
     std::string data;
     std::string mimetype;
     std::string label;
+    bool isValid;
 };
 
 Attachment::Attachment()
 :   d(new Attachment::Private)
 {
+    d->isValid = false;
 }
 
 Attachment::Attachment(const Kolab::Attachment &other)
@@ -568,6 +570,7 @@ bool Attachment::operator==(const Kolab::Attachment &other) const
 
 void Attachment::setUri(const std::string &uri, const std::string& mimetype)
 {
+    d->isValid = true;
     d->uri = uri;
     d->mimetype = mimetype;
 }
@@ -594,6 +597,7 @@ std::string Attachment::label() const
 
 void Attachment::setData(const std::string &data, const std::string& mimetype)
 {
+    d->isValid = true;
     d->data = data;
     d->mimetype = mimetype;
 }
@@ -605,7 +609,7 @@ std::string Attachment::data() const
 
 bool Attachment::isValid() const
 {
-    return !d->mimetype.empty(); //TODO use isValid variable
+    return d->isValid;
 }
 
 
diff --git a/src/xcalconversions.h b/src/xcalconversions.h
index 9326548..923646b 100644
--- a/src/xcalconversions.h
+++ b/src/xcalconversions.h
@@ -417,16 +417,13 @@ Kolab::Attachment toAttachment(T aProp)
             }
         }
     }
-    if (mimetype.empty()) {
-        ERROR("no mimetype");
-    }
 
     if (aProp.uri()) {
         a.setUri(*aProp.uri(), mimetype);
     } else if (aProp.binary()) {
         a.setData(base64_decode(*aProp.binary()), mimetype);
     } else {
-        ERROR("not uri and no data available");
+        ERROR("no uri and no data available");
     }
     return a;
 }


commit a8968196c72913fd38e875667f7a5ce68e31a0d8
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Fri Mar 21 17:25:11 2014 +0100

    Follow up the parsing error message with message that it occurred during writing.

diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index abd8f54..4ab8ed1 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -89,6 +89,9 @@ std::string writeEvent(const Kolab::Event &event, const std::string& productId)
     const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(event, productId);
     //Validate
     XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -109,6 +112,9 @@ std::string writeTodo(const Kolab::Todo &event, const std::string& productId)
     const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(event, productId);
     //Validate
     XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -129,6 +135,9 @@ std::string writeJournal(const Kolab::Journal &j, const std::string& productId)
     const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Journal> >(j, productId);
     //Validate
     XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Journal> >(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -148,6 +157,9 @@ std::string writeFreebusy(const Freebusy &f, const std::string& productId)
     validate(f);
     const std::string result = XCAL::serializeFreebusy<XCAL::IncidenceTrait<Kolab::Freebusy> >(f, productId);
     XCAL::deserializeIncidence<XCAL::IncidenceTrait<Kolab::Freebusy> >(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -168,6 +180,9 @@ std::string writeContact(const Contact &contact, const std::string& productId)
     const std::string result = XCARD::serializeCard(contact, productId);
     //Validate
     XCARD::deserializeCard<Kolab::Contact>(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -188,6 +203,9 @@ std::string writeDistlist(const DistList &list, const std::string& productId)
     const std::string result = XCARD::serializeCard(list, productId);
     //Validate
     XCARD::deserializeCard<Kolab::DistList>(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -208,6 +226,9 @@ std::string writeNote(const Note &note, const std::string& productId)
     const std::string result = Kolab::KolabObjects::serializeObject<Kolab::Note>(note, productId);
     //Validate
     Kolab::KolabObjects::deserializeObject<Kolab::Note>(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -228,6 +249,9 @@ std::string writeFile(const File &file, const std::string& productId)
     const std::string result = Kolab::KolabObjects::serializeObject<Kolab::File>(file, productId);
     //Validate
     Kolab::KolabObjects::deserializeObject<Kolab::File>(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
@@ -248,6 +272,9 @@ std::string writeConfiguration(const Configuration &config, const std::string& p
     const std::string result = Kolab::KolabObjects::serializeObject<Kolab::Configuration>(config, productId);
     //Validate
     Kolab::KolabObjects::deserializeObject<Kolab::Configuration>(result, false);
+    if (errorOccurred()) {
+        LOG("Error occurred while writing.")
+    }
     return result;
 }
 
diff --git a/src/utils.h b/src/utils.h
index 2c7e579..2688af4 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -33,10 +33,10 @@ std::string getUID(const std::string & = std::string());
 
 void logMessage(const std::string &,const std::string &, int, ErrorSeverity s);
      
-#define LOG(message) logMessage(message,__FILE__, __LINE__, NoError);
-#define WARNING(message) logMessage(message,__FILE__, __LINE__, Warning);
-#define ERROR(message) logMessage(message,__FILE__, __LINE__, Error);
-#define CRITICAL(message) logMessage(message,__FILE__, __LINE__, Critical);
+#define LOG(message) Utils::logMessage(message,__FILE__, __LINE__, NoError);
+#define WARNING(message) Utils::logMessage(message,__FILE__, __LINE__, Warning);
+#define ERROR(message) Utils::logMessage(message,__FILE__, __LINE__, Error);
+#define CRITICAL(message) Utils::logMessage(message,__FILE__, __LINE__, Critical);
 
 void logMessage(const std::string &, ErrorSeverity s = Warning);
 




More information about the commits mailing list