Branch 'libkolab-0.5' - 6 commits - conversion/commonconversion.cpp conversion/kabcconversion.cpp kolabformat/formathelpers.cpp kolabformat/formathelpers.h kolabformat/kolabdefinitions.h tests/testutils.h tests/timezonetest.cpp tests/timezonetest.h

Christian Mollekopf mollekopf at kolabsys.com
Wed Nov 13 14:16:11 CET 2013


 conversion/commonconversion.cpp |   17 +++++++++++------
 conversion/kabcconversion.cpp   |    4 +++-
 kolabformat/formathelpers.cpp   |    8 +++++++-
 kolabformat/formathelpers.h     |    1 +
 kolabformat/kolabdefinitions.h  |    2 ++
 tests/testutils.h               |    1 +
 tests/timezonetest.cpp          |    8 ++++++++
 tests/timezonetest.h            |    1 +
 8 files changed, 34 insertions(+), 8 deletions(-)

New commits:
commit 3f9174df3f7b1e3e75e213fa3a929ab1757e1c52
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Wed Nov 13 14:07:38 2013 +0100

    Convert utc offset date times to utc.

diff --git a/conversion/commonconversion.cpp b/conversion/commonconversion.cpp
index 3546395..7accd22 100644
--- a/conversion/commonconversion.cpp
+++ b/conversion/commonconversion.cpp
@@ -88,6 +88,13 @@ cDateTime fromDate(const KDateTime &dt)
         date.setTime(t.hour(), t.minute(), t.second());
         if (dt.timeType() == KDateTime::UTC) { //UTC
             date.setUTC(true);
+        } else if (dt.timeType() == KDateTime::OffsetFromUTC) {
+            const KDateTime utcDate = dt.toUtc();
+            const QDate &d = utcDate.date();
+            date.setDate(d.year(), d.month(), d.day());
+            const QTime &t = utcDate.time();
+            date.setTime(t.hour(), t.minute(), t.second());
+            date.setUTC(true);
         } else if (dt.timeType() == KDateTime::TimeZone) { //Timezone
             //TODO handle local timezone?
             //Convert non-olson timezones if necessary
diff --git a/tests/timezonetest.cpp b/tests/timezonetest.cpp
index 92f09ce..f2c1963 100644
--- a/tests/timezonetest.cpp
+++ b/tests/timezonetest.cpp
@@ -17,6 +17,7 @@
 
 #include "timezonetest.h"
 #include <conversion/timezoneconverter.h>
+#include <conversion/commonconversion.h>
 #include <kolabformat/kolabobject.h>
 #include <kolabformat/errorhandler.h>
 #include "testutils.h"
@@ -165,6 +166,13 @@ void TimezoneTest::testTimezoneDaemonAvailable()
     QVERIFY(KSystemTimeZones::isTimeZoneDaemonAvailable());
 }
 
+void TimezoneTest::testUTCOffset()
+{
+    const Kolab::cDateTime expected(2013, 10, 23, 2, 0 ,0, true);
+    const KDateTime input(KDateTime::fromString("2013-10-23T04:00:00+02:00", KDateTime::RFC3339Date));
+    const Kolab::cDateTime result = Kolab::Conversion::fromDate(input);
+    QCOMPARE(result, expected);
+}
 
 QTEST_MAIN( TimezoneTest )
 
diff --git a/tests/timezonetest.h b/tests/timezonetest.h
index ed2f33f..fa518a6 100644
--- a/tests/timezonetest.h
+++ b/tests/timezonetest.h
@@ -35,6 +35,7 @@ private slots:
     void testKolabObjectReader();
     void testFindLegacyTimezone();
     void testTimezoneDaemonAvailable();
+    void testUTCOffset();
 };
 
 #endif // TIMEZONETEST_H


commit 493b409a21bcae1715a71b4408762b18c09f8ad5
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Tue Oct 29 15:50:49 2013 +0100

    The description is plural: File -> Files

diff --git a/kolabformat/formathelpers.cpp b/kolabformat/formathelpers.cpp
index bb7f633..b376b8c 100644
--- a/kolabformat/formathelpers.cpp
+++ b/kolabformat/formathelpers.cpp
@@ -16,7 +16,7 @@ static const struct {
   { KOLAB_FOLDER_TYPE_NOTE,    I18N_NOOP( "Notes" )    },
   { KOLAB_FOLDER_TYPE_CONFIGURATION, I18N_NOOP( "Configuration" )    },
   { KOLAB_FOLDER_TYPE_FREEBUSY,    I18N_NOOP( "Freebusy" ) },
-  { KOLAB_FOLDER_TYPE_FILE,    I18N_NOOP( "File" ) }
+  { KOLAB_FOLDER_TYPE_FILE,    I18N_NOOP( "Files" ) }
 };
 static const int numFolderTypeData = sizeof folderTypeData / sizeof *folderTypeData;
 


commit 7993cd34926573bf2d5c702aaa023ba4e63edf85
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Tue Oct 29 12:29:43 2013 +0100

    Added definitions for files and ensured that the files folder is recognized as kolab folder.

diff --git a/kolabformat/formathelpers.cpp b/kolabformat/formathelpers.cpp
index 4984365..bb7f633 100644
--- a/kolabformat/formathelpers.cpp
+++ b/kolabformat/formathelpers.cpp
@@ -15,7 +15,8 @@ static const struct {
   { KOLAB_FOLDER_TYPE_JOURNAL, I18N_NOOP( "Journal" )  },
   { KOLAB_FOLDER_TYPE_NOTE,    I18N_NOOP( "Notes" )    },
   { KOLAB_FOLDER_TYPE_CONFIGURATION, I18N_NOOP( "Configuration" )    },
-  { KOLAB_FOLDER_TYPE_FREEBUSY,    I18N_NOOP( "Freebusy" ) }
+  { KOLAB_FOLDER_TYPE_FREEBUSY,    I18N_NOOP( "Freebusy" ) },
+  { KOLAB_FOLDER_TYPE_FILE,    I18N_NOOP( "File" ) }
 };
 static const int numFolderTypeData = sizeof folderTypeData / sizeof *folderTypeData;
 
@@ -66,6 +67,11 @@ FolderType folderTypeFromString(const std::string& folderTypeName)
         return FreebusyType;
     }
 
+    if ( folderTypeName == KOLAB_FOLDER_TYPE_FILE ||
+        folderTypeName == KOLAB_FOLDER_TYPE_FILE KOLAB_FOLDER_TYPE_DEFAULT_SUFFIX ) {
+        return FileType;
+    }
+
     return MailType;
 }
 
diff --git a/kolabformat/formathelpers.h b/kolabformat/formathelpers.h
index 9334927..08a1fd4 100644
--- a/kolabformat/formathelpers.h
+++ b/kolabformat/formathelpers.h
@@ -16,6 +16,7 @@ enum FolderType {
     NoteType,
     ConfigurationType,
     FreebusyType,
+    FileType,
     LastType
 };
 
diff --git a/kolabformat/kolabdefinitions.h b/kolabformat/kolabdefinitions.h
index 0fc8307..4169aa1 100644
--- a/kolabformat/kolabdefinitions.h
+++ b/kolabformat/kolabdefinitions.h
@@ -28,6 +28,7 @@ namespace Kolab {
 #define KOLAB_FOLDER_TYPE_NOTE    "note"
 #define KOLAB_FOLDER_TYPE_CONFIGURATION "configuration"
 #define KOLAB_FOLDER_TYPE_FREEBUSY      "freebusy"
+#define KOLAB_FOLDER_TYPE_FILE    "file"
 
 #define KOLAB_FOLDER_TYPE_DEFAULT_SUFFIX ".default"
 #define KOLAB_FOLDER_TYPE_DRAFT_SUFFIX ".drafts"
@@ -60,6 +61,7 @@ namespace Kolab {
 #define KOLAB_TYPE_CONFIGURATION    "application/x-vnd.kolab.configuration"
 #define KOLAB_TYPE_DICT    "application/x-vnd.kolab.configuration.dictionary"
 #define KOLAB_TYPE_FREEBUSY    "application/x-vnd.kolab.freebusy"
+#define KOLAB_TYPE_FILE    "application/x-vnd.kolab.file"
 
 enum Version {
     KolabV2,


commit ea9951fa090104f9e151d0dbf4dfb0af7a5b68e9
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Oct 28 10:21:59 2013 +0100

    Only issue a warning on unknown timezone, and fallback to floating time.
    
    This way unknown timezones don't completely block the conversion of kolab objects.

diff --git a/conversion/commonconversion.cpp b/conversion/commonconversion.cpp
index 87b35c2..3546395 100644
--- a/conversion/commonconversion.cpp
+++ b/conversion/commonconversion.cpp
@@ -39,19 +39,17 @@ KDateTime::Spec getTimeSpec(bool isUtc, const std::string& timezone)
 
     //Convert non-olson timezones if necessary
     const QString normalizedTz = TimezoneConverter::normalizeTimezone(QString::fromStdString(timezone));
-    Debug() << "normalized " << normalizedTz;
     KTimeZone tz = KSystemTimeZones::zone(normalizedTz); //Needs ktimezoned (timezone daemon running) http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKSystemTimeZones.html
     if (!tz.isValid()) {
-        Error() << "timezone not found" << QString::fromStdString(timezone);
+        Warning() << "invalid timezone: " << QString::fromStdString(timezone) << ", assuming floating time";
         if (!KSystemTimeZones::isTimeZoneDaemonAvailable()) {
             Error() << "ktimezoned is not available and required for timezone interpretation";
         }
-        tz = KTimeZone::utc(); //Don't crash
+        return  KDateTime::Spec(KDateTime::ClockTime);
     }
     return KDateTime::Spec(tz);
 }
 
-        
 KDateTime toDate(const Kolab::cDateTime &dt)
 {
     KDateTime date;
@@ -97,11 +95,11 @@ cDateTime fromDate(const KDateTime &dt)
             if (!timezone.isEmpty()) {
                 date.setTimezone(toStdString(timezone));
             } else {
-                Error() << "invalid timezone: " << dt.timeZone().name() << " , assuming floating time";
+                Warning() << "invalid timezone: " << dt.timeZone().name() << ", assuming floating time";
                 return date;
             }
         } else if (dt.timeType() != KDateTime::ClockTime) {
-            Error() << "invalid timespec, assuming floating time" << dt.timeType();
+            Error() << "invalid timespec, assuming floating time. Type: " << dt.timeType() << "dt: " << dt.toString();
             return date;
         }
     }


commit b944a6a31953071199beef38a83b13e785a9f2c3
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Oct 28 10:19:29 2013 +0100

    Ignore the kolab version number in the tests.
    
    It changed from 3.0dev to 3.1.0.

diff --git a/tests/testutils.h b/tests/testutils.h
index 8f0dcbd..b118d86 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -105,6 +105,7 @@ void normalizeMimemessage(QString &content)
     content.replace(QRegExp("<uri>data:*</uri>", Qt::CaseSensitive, QRegExp::Wildcard), "<uri>data:</uri>");
     content.replace(QRegExp("<last-modification-date>*</last-modification-date>", Qt::CaseSensitive, QRegExp::Wildcard), "<last-modification-date></last-modification-date>");
     content.replace(QRegExp("<timestamp>*</timestamp>", Qt::CaseSensitive, QRegExp::Wildcard), "<timestamp></timestamp>");
+    content.replace(QRegExp("<x-kolab-version>*</x-kolab-version>", Qt::CaseSensitive, QRegExp::Wildcard), "<x-kolab-version></x-kolab-version>");
 
     content.replace(QRegExp("--nextPart\\S*", Qt::CaseSensitive), "--part");
     content.replace(QRegExp("\\bboundary=\"nextPart[^\\n]*", Qt::CaseSensitive), "boundary");


commit b5ccaaafcffddc9807f5a94a1a9f7efe28f7798f
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Tue Nov 12 11:22:31 2013 +0100

    Only set the affiliation if it is not empty.
    
    Otherwise we get lots of log messages from libkolabxml for skipping empty affiliations.

diff --git a/conversion/kabcconversion.cpp b/conversion/kabcconversion.cpp
index 566652f..76d9597 100644
--- a/conversion/kabcconversion.cpp
+++ b/conversion/kabcconversion.cpp
@@ -660,7 +660,9 @@ Kolab::Contact fromKABC(const KABC::Addressee &addressee)
     if (!relateds.empty()) {
         businessAff.setRelateds(relateds);
     }
-    c.setAffiliations(std::vector<Kolab::Affiliation>() << businessAff);
+    if (!(businessAff == Kolab::Affiliation())) {
+        c.setAffiliations(std::vector<Kolab::Affiliation>() << businessAff);
+    }
     
     std::vector<Kolab::Url> urls;
     if (!addressee.url().isEmpty()) {




More information about the commits mailing list