9 commits - c++/lib c++/tests

Christian Mollekopf mollekopf at kolabsys.com
Mon Mar 5 16:05:24 CET 2012


 c++/lib/CMakeLists.txt           |    3 +
 c++/lib/incidence_p.h            |    4 -
 c++/lib/kcalkolabformat.cpp      |   55 -------------------
 c++/lib/kcalkolabformat.h        |   35 ------------
 c++/lib/kolabcontact.cpp         |   10 +++
 c++/lib/kolabcontact.h           |    6 +-
 c++/lib/kolabcontainers.cpp      |   17 +++++-
 c++/lib/kolabcontainers.h        |   30 ++++++----
 c++/lib/kolabcontainers.i        |   15 -----
 c++/lib/kolabevent.cpp           |    2 
 c++/lib/kolabevent.h             |    2 
 c++/lib/kolabformat.i            |   13 +++-
 c++/lib/kolabjournal.cpp         |    2 
 c++/lib/kolabjournal.h           |    2 
 c++/lib/kolabkcalconversion.cpp  |  109 ++++++++++++++++++++++++++-------------
 c++/lib/kolabtodo.cpp            |    5 +
 c++/lib/kolabtodo.h              |    2 
 c++/lib/xcalconversions.h        |   46 ++++++++--------
 c++/tests/bindingstest.cpp       |    6 +-
 c++/tests/kcalconversiontest.cpp |   41 ++++++++++++--
 20 files changed, 207 insertions(+), 198 deletions(-)

New commits:
commit 79bca1b0c7bce4197d8184315551f9b983b4f19d
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 16:05:16 2012 +0100

    fix tests after enum change, add a comment for the %rename statement

diff --git a/c++/lib/kolabformat.i b/c++/lib/kolabformat.i
index 3ed5531..48c4706 100644
--- a/c++/lib/kolabformat.i
+++ b/c++/lib/kolabformat.i
@@ -32,7 +32,7 @@ namespace std {
     %template(vectordatetime) vector<Kolab::DateTime>;
 };
 
-/*%apply const std::string& {std::string* foo};*/
+/* Avoid clashes with native php/python containers */
 %rename(KolabDateTime) Kolab::DateTime;
 
 %include "global_definitions.h"
diff --git a/c++/tests/bindingstest.cpp b/c++/tests/bindingstest.cpp
index 0a34988..fcc109a 100644
--- a/c++/tests/bindingstest.cpp
+++ b/c++/tests/bindingstest.cpp
@@ -30,7 +30,7 @@ void setIncidence(T &ev)
     ev.setUid("UID");
     ev.setCreated(Kolab::DateTime(2006,1,6,12,0,0)); //UTC
     ev.setSequence(1);
-    ev.setClassification(Kolab::Confidential);
+    ev.setClassification(Kolab::ClassConfidential);
     ev.addCategory("Category");
     ev.setStart(Kolab::DateTime("Europe/Zurich", 2006,1,6,12,0,0));
     
@@ -60,7 +60,7 @@ void setIncidence(T &ev)
     ev.setSummary("summary");
     ev.setDescription("description");
     ev.setPriority(3);
-    ev.setStatus(Kolab::Confirmed);
+    ev.setStatus(Kolab::StatusConfirmed);
     ev.setLocation("location");
     ev.setOrganizer("email","organizer");
     
@@ -237,7 +237,7 @@ void BindingsTest::journalCompletness()
     ev.setUid("UID");
     ev.setCreated(Kolab::DateTime(2006,1,6,12,0,0)); //UTC
     ev.setSequence(1);
-    ev.setClassification(Kolab::Confidential);
+    ev.setClassification(Kolab::ClassConfidential);
     ev.addCategory("Category");
     ev.setStart(Kolab::DateTime("Europe/Zurich", 2006,1,6,12,0,0));
     Kolab::Attendee attendee("email");
diff --git a/c++/tests/kcalconversiontest.cpp b/c++/tests/kcalconversiontest.cpp
index a955380..fa80510 100644
--- a/c++/tests/kcalconversiontest.cpp
+++ b/c++/tests/kcalconversiontest.cpp
@@ -325,7 +325,7 @@ void KCalConversionTest::testConversion_data()
         kolab.setCreated(date);
         kolab.setLastModified(date);
         kolab.setSequence(3);
-        kolab.setClassification(Kolab::Confidential);
+        kolab.setClassification(Kolab::ClassConfidential);
         kolab.setCategories(stringVector);
         kolab.setStart(date);
         kolab.setEnd(date2);
@@ -352,7 +352,7 @@ void KCalConversionTest::testConversion_data()
         kolab.setSummary("summary");
         kolab.setDescription("description");
         kolab.setPriority(3);
-        kolab.setStatus(Kolab::Confirmed);
+        kolab.setStatus(Kolab::StatusConfirmed);
         kolab.setLocation("location");
         kolab.setOrganizer("organizer at email", "organizer");
         


commit f5ddf2e5187d14b37fad29c027c65936eaba60fc
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 16:04:32 2012 +0100

    remove old, unused files

diff --git a/c++/lib/kcalkolabformat.cpp b/c++/lib/kcalkolabformat.cpp
deleted file mode 100644
index 12eaba2..0000000
--- a/c++/lib/kcalkolabformat.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011  Christian Mollekopf <mollekopf at kolabsys.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "kolabformat.h"
-
-#include <kcalcore/event.h>
-#include <KDE/KCalCore/Todo>
-
-// #include "kcalconversions.h"
-
-namespace Kolab {
-    
-namespace KCal {
-
-KCalCore::Event::Ptr readEvent(const std::string& s, bool isUrl)
-{
-//      return deserializeIncidence< IncidenceTrait<KCalCore::Event> >(s, isUrl);
-    return KCalCore::Event::Ptr();
-}
-
-KCalCore::Todo::Ptr readTodo(const std::string& s, bool isUrl)
-{
-    return KCalCore::Todo::Ptr();
-}
-
-
-std::string writeEvent(KCalCore::Event::Ptr event)
-{
-//      return writeIncidence< IncidenceTrait<KCalCore::Event> >(*event);
-    return std::string();
-}
-
-std::string writeTodo(KCalCore::Todo::Ptr todo)
-{
-//     return writeIncidence< IncidenceTrait<KCalCore::Todo> >(*todo);
-    return std::string();
-}
-
-}
-
-}
\ No newline at end of file
diff --git a/c++/lib/kcalkolabformat.h b/c++/lib/kcalkolabformat.h
deleted file mode 100644
index 9afa7bd..0000000
--- a/c++/lib/kcalkolabformat.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2011  Christian Mollekopf <mollekopf at kolabsys.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef KCALKOLABFORMAT_H
-#define KCALKOLABFORMAT_H
-
-#include <string>
-#include <KDE/KCalCore/Event>
-#include <KDE/KCalCore/Todo>
-
-namespace Kolab {
-namespace KCal {
-KCalCore::Event::Ptr readEvent(const std::string& s, bool isUrl = true);
-KCalCore::Todo::Ptr readTodo(const std::string& s, bool isUrl = true);
-
-std::string writeEvent(KCalCore::Event::Ptr);
-std::string writeTodo(KCalCore::Todo::Ptr);
-}
-}
-
-#endif // KCALKOLABFORMAT_H
diff --git a/c++/lib/kolabcontainers.i b/c++/lib/kolabcontainers.i
deleted file mode 100644
index fef7f71..0000000
--- a/c++/lib/kolabcontainers.i
+++ /dev/null
@@ -1,15 +0,0 @@
-/* kolabformat.i */
- %module kolabcontainers
- %{
- /* Put header files here or function declarations like below */
-    #include "kolabcontainers.h"
-    #include "kolabtodo.h"
-    #include "kolabevent.h"
- %}
-%include "std_string.i"
-
-/*%apply const std::string& {std::string* foo};*/
-
-%include "kolabcontainers.h"
-%include "kolabtodo.h"
-%include "kolabevent.h"
\ No newline at end of file


commit fd266c019b6abda2322cb94520ab8cd9b2cfcb17
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 15:58:43 2012 +0100

    Added missing vector templates

diff --git a/c++/lib/kolabformat.i b/c++/lib/kolabformat.i
index fce5cae..3ed5531 100644
--- a/c++/lib/kolabformat.i
+++ b/c++/lib/kolabformat.i
@@ -20,8 +20,16 @@
 namespace std {
     %template(vectori) vector<int>;
     %template(vectors) vector<string>;
-    %template(vectordate) vector<Kolab::DateTime>;
     %template(vectordaypos) vector<Kolab::DayPos>;
+    %template(vectorcs) vector<Kolab::CustomProperty>;
+    %template(vectoraddress) vector<Kolab::Address>;
+    %template(vectoraffiliation) vector<Kolab::Affiliation>;
+    %template(vectoralarm) vector<Kolab::Alarm>;
+    %template(vectorattachment) vector<Kolab::Attachment>;
+    %template(vectorattendee) vector<Kolab::Attendee>;
+    %template(vectorrelated) vector<Kolab::Related>;
+    %template(vectortelephone) vector<Kolab::Telephone>;
+    %template(vectordatetime) vector<Kolab::DateTime>;
 };
 
 /*%apply const std::string& {std::string* foo};*/


commit f4da43d0684c903a226a507a9998004ac62c71f9
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 15:57:47 2012 +0100

    renamed DateTime to KolabDateTime for bindings because namespaces are not properly handled and DateTime is already used.

diff --git a/c++/lib/kolabformat.i b/c++/lib/kolabformat.i
index d4873e1..fce5cae 100644
--- a/c++/lib/kolabformat.i
+++ b/c++/lib/kolabformat.i
@@ -25,6 +25,7 @@ namespace std {
 };
 
 /*%apply const std::string& {std::string* foo};*/
+%rename(KolabDateTime) Kolab::DateTime;
 
 %include "global_definitions.h"
 %include "kolabcontainers.h"


commit ee363b092335339ef61eee650331acff4955be29
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 15:56:47 2012 +0100

    Changed enum names to avoid conflicts in bindings. Added default constructors which php bindings need.

diff --git a/c++/lib/incidence_p.h b/c++/lib/incidence_p.h
index 9c8bfce..3595c4b 100644
--- a/c++/lib/incidence_p.h
+++ b/c++/lib/incidence_p.h
@@ -26,10 +26,10 @@ namespace Kolab {
     {
         PrivateIncidence()
         : sequence(0),
-        classification(Public),
+        classification(ClassPublic),
         thisAndFuture(false),
         priority(0),
-        status(UndefinedStatus){}
+        status(StatusUndefined){}
         
         std::string uid;
         DateTime created;
diff --git a/c++/lib/kolabcontainers.cpp b/c++/lib/kolabcontainers.cpp
index 031770d..b458f94 100644
--- a/c++/lib/kolabcontainers.cpp
+++ b/c++/lib/kolabcontainers.cpp
@@ -189,7 +189,7 @@ bool DateTime::isValid() const
 struct RecurrenceRule::Private
 {
     Private()
-    : freq(None),
+    : freq(FreqNone),
     weekstart(Monday),
     count(-1),
     interval(1){};
@@ -384,7 +384,7 @@ std::vector< int > RecurrenceRule::bymonth() const
 
 bool RecurrenceRule::isValid() const
 {
-    if (d->freq == None) {
+    if (d->freq == FreqNone) {
         return false;
     }
     return true;
@@ -407,6 +407,12 @@ struct Attendee::Private
     bool rsvp;
 };
 
+Attendee::Attendee()
+:   d(new Attendee::Private)
+{
+
+}
+
 Attendee::Attendee(const std::string& email)
 :   d(new Attendee::Private)
 {
@@ -426,7 +432,7 @@ void Attendee::operator=(const Kolab::Attendee &other)
 
 Attendee::~Attendee()
 {
-    
+
 }
 
 bool Attendee::operator==(const Kolab::Attendee &other) const
@@ -442,6 +448,11 @@ bool Attendee::operator==(const Kolab::Attendee &other) const
     return false;
 }
 
+bool Attendee::isValid() const 
+{ 
+    return !d->email.empty();
+};
+
 std::string Attendee::email() const
 {
     return d->email;
diff --git a/c++/lib/kolabcontainers.h b/c++/lib/kolabcontainers.h
index 4ff7ea0..f55a78d 100644
--- a/c++/lib/kolabcontainers.h
+++ b/c++/lib/kolabcontainers.h
@@ -59,21 +59,21 @@ private:
 };
 
 enum Classification {
-    Public,
-    Private,
-    Confidential
+    ClassPublic,
+    ClassPrivate,
+    ClassConfidential
 };
 
 enum Status {
-    UndefinedStatus,
-    NeedsAction,
-    Completed,
-    InProcess,
-    Cancelled,
-    Tentative,
-    Confirmed,
-    Draft,
-    Final
+    StatusUndefined,
+    StatusNeedsAction,
+    StatusCompleted,
+    StatusInProcess,
+    StatusCancelled,
+    StatusTentative,
+    StatusConfirmed,
+    StatusDraft,
+    StatusFinal
 };
 
 enum Weekday {
@@ -227,7 +227,7 @@ public:
     bool operator==(const RecurrenceRule &other) const;
     
     enum Frequency {
-        None,
+        FreqNone,
         Yearly,
         Monthly,
         Weekly,
@@ -301,6 +301,7 @@ enum Role {
 
 class Attendee {
 public:
+    Attendee();
     Attendee(const std::string &email);
     Attendee(const Attendee &);
     ~Attendee();
@@ -308,6 +309,8 @@ public:
     void operator=(const Attendee &);
     bool operator==(const Attendee &) const;
 
+    bool isValid() const;
+
     std::string email() const;
 
     void setName(const std::string &);
@@ -330,6 +333,7 @@ private:
 };
 
 struct CustomProperty {
+    CustomProperty(){};
     CustomProperty(const std::string &i, const std::string &v)
     : identifier(i), value(v) {};
 
diff --git a/c++/lib/kolabkcalconversion.cpp b/c++/lib/kolabkcalconversion.cpp
index eb2ab09..f3efd02 100644
--- a/c++/lib/kolabkcalconversion.cpp
+++ b/c++/lib/kolabkcalconversion.cpp
@@ -122,11 +122,11 @@ Kolab::Duration fromDuration(const KCalCore::Duration &d)
 KCalCore::Incidence::Secrecy toSecrecy(Kolab::Classification c)
 {
     switch(c) {
-        case Kolab::Public:
+        case Kolab::ClassPublic:
             return KCalCore::Incidence::SecrecyPublic;
-        case Kolab::Private:
+        case Kolab::ClassPrivate:
             return KCalCore::Incidence::SecrecyPrivate;
-        case Kolab::Confidential:
+        case Kolab::ClassConfidential:
             return KCalCore::Incidence::SecrecyConfidential;
         default:
             qWarning() << "unhandled";
@@ -139,16 +139,16 @@ Kolab::Classification fromSecrecy(KCalCore::Incidence::Secrecy c)
 {
     switch(c) {
         case KCalCore::Incidence::SecrecyPublic:
-            return Kolab::Public;
+            return Kolab::ClassPublic;
         case KCalCore::Incidence::SecrecyPrivate:
-            return Kolab::Private;
+            return Kolab::ClassPrivate;
         case KCalCore::Incidence::SecrecyConfidential:
-            return Kolab::Confidential;
+            return Kolab::ClassConfidential;
         default:
             qWarning() << "unhandled";
             Q_ASSERT(0);
     }
-    return Kolab::Public;
+    return Kolab::ClassPublic;
 }
 
 int toPriority(int priority)
@@ -166,23 +166,23 @@ int fromPriority(int priority)
 KCalCore::Incidence::Status toStatus(Kolab::Status s)
 {
     switch (s) {
-        case UndefinedStatus:
+        case StatusUndefined:
             return  KCalCore::Incidence::StatusNone;
-        case NeedsAction:
+        case StatusNeedsAction:
             return  KCalCore::Incidence::StatusNeedsAction;
-        case Completed:
+        case StatusCompleted:
             return  KCalCore::Incidence::StatusCompleted;
-        case InProcess:
+        case StatusInProcess:
             return  KCalCore::Incidence::StatusInProcess;
-        case Cancelled:
+        case StatusCancelled:
             return  KCalCore::Incidence::StatusCanceled;
-        case Tentative:
+        case StatusTentative:
             return  KCalCore::Incidence::StatusTentative;
-        case Confirmed:
+        case StatusConfirmed:
             return  KCalCore::Incidence::StatusConfirmed;
-        case Draft:
+        case StatusDraft:
             return  KCalCore::Incidence::StatusDraft;
-        case Final:
+        case StatusFinal:
             return  KCalCore::Incidence::StatusFinal;
         default:
             qWarning() << "unhandled";
@@ -195,28 +195,28 @@ Kolab::Status fromStatus(KCalCore::Incidence::Status s)
 {
     switch (s) {
         case KCalCore::Incidence::StatusNone:
-            return UndefinedStatus;
+            return StatusUndefined;
         case KCalCore::Incidence::StatusNeedsAction:
-            return NeedsAction;
+            return StatusNeedsAction;
         case KCalCore::Incidence::StatusCompleted:
-            return Completed;
+            return StatusCompleted;
         case KCalCore::Incidence::StatusInProcess:
-            return InProcess;
+            return StatusInProcess;
         case KCalCore::Incidence::StatusCanceled:
-            return Cancelled;
+            return StatusCancelled;
         case KCalCore::Incidence::StatusTentative:
-            return Tentative;
+            return StatusTentative;
         case KCalCore::Incidence::StatusConfirmed:
-            return Confirmed;
+            return StatusConfirmed;
         case KCalCore::Incidence::StatusDraft:
-            return Draft;
+            return StatusDraft;
         case KCalCore::Incidence::StatusFinal:
-            return Final;
+            return StatusFinal;
         default:
             qWarning() << "unhandled";
             Q_ASSERT(0);
     }
-    return UndefinedStatus;
+    return StatusUndefined;
 }
 
 QStringList toStringList(const std::vector<std::string> &l)
@@ -449,7 +449,7 @@ Kolab::Weekday fromWeekDay(int wday)
 KCalCore::RecurrenceRule::PeriodType toRecurrenceType(Kolab::RecurrenceRule::Frequency freq)
 {
     switch(freq) {
-        case Kolab::RecurrenceRule::None:
+        case Kolab::RecurrenceRule::FreqNone:
             qWarning() << "no recurrence?";
             break;
         case Kolab::RecurrenceRule::Yearly:
@@ -497,7 +497,7 @@ Kolab::RecurrenceRule::Frequency fromRecurrenceType(KCalCore::RecurrenceRule::Pe
             qWarning() << "unhandled";
             Q_ASSERT(0);
     }
-    return Kolab::RecurrenceRule::None;
+    return Kolab::RecurrenceRule::FreqNone;
 }
 
 KCalCore::RecurrenceRule::WDayPos toWeekDayPos(const Kolab::DayPos &dp)
diff --git a/c++/lib/xcalconversions.h b/c++/lib/xcalconversions.h
index 55119b0..9ba9cb5 100644
--- a/c++/lib/xcalconversions.h
+++ b/c++/lib/xcalconversions.h
@@ -695,7 +695,7 @@ Role mapRole(const std::string &status)
             default:
                 ERROR("invalid unhandled recurrenc type" + freq);
         }
-        return RecurrenceRule::None;
+        return RecurrenceRule::FreqNone;
     }
     
     icalendar_2_0::RecurType::freq_type mapRecurrenceFrequency(RecurrenceRule::Frequency freq)
@@ -825,11 +825,11 @@ void setIncidenceProperties(I &inc, const T &prop)
     
     if (prop.class_()) {
         std::string string(toString(*prop.class_()));
-        Kolab::Classification sec = Public;
+        Kolab::Classification sec = ClassPublic;
         if (string == PRIVATE) {
-            sec = Private;
+            sec = ClassPrivate;
         } else if (string == CONFIDENTIAL) {
-            sec = Confidential;
+            sec = ClassConfidential;
         }
         inc.setClassification(sec);
     }
@@ -854,21 +854,21 @@ void setIncidenceProperties(I &inc, const T &prop)
     if (prop.status()) {
         const std::string &status =  toString(*prop.status());
         if (status == NEEDSACTION) {
-            inc.setStatus(NeedsAction);
+            inc.setStatus(StatusNeedsAction);
         } else if (status == COMPLETED) {
-            inc.setStatus(Completed);
+            inc.setStatus(StatusCompleted);
         } else if (status == INPROCESS) {
-            inc.setStatus(InProcess);
+            inc.setStatus(StatusInProcess);
         } else if (status == CANCELLED) {
-            inc.setStatus(Cancelled);
+            inc.setStatus(StatusCancelled);
         } else if (status == TENTATIVE) {
-            inc.setStatus(Tentative);
+            inc.setStatus(StatusTentative);
         } else if (status == CONFIRMED) {
-            inc.setStatus(Confirmed);
+            inc.setStatus(StatusConfirmed);
         } else if (status == DRAFT) {
-            inc.setStatus(Draft);
+            inc.setStatus(StatusDraft);
         } else if (status == FINAL) {
-            inc.setStatus(Final);
+            inc.setStatus(StatusFinal);
         } else {
             ERROR("Unhandled status");
         }
@@ -1068,10 +1068,10 @@ void getIncidenceProperties(T &prop, const I &inc)
     prop.sequence(fromInt<xml_schema::integer>(inc.sequence()));
     
     switch (inc.classification()) {
-        case Kolab::Confidential:
+        case Kolab::ClassConfidential:
             prop.class_(typename properties::class_type(CONFIDENTIAL));
             break;
-        case Kolab::Private:
+        case Kolab::ClassPrivate:
             prop.class_(typename properties::class_type(PRIVATE));
             break;
         default:
@@ -1095,30 +1095,30 @@ void getIncidenceProperties(T &prop, const I &inc)
         prop.description(typename properties::description_type(inc.description()));
     }
 
-    if (inc.status() != UndefinedStatus) {
+    if (inc.status() != StatusUndefined) {
         switch (inc.status()) {
-            case NeedsAction:
+            case StatusNeedsAction:
                 prop.status(typename properties::status_type(NEEDSACTION));
                 break;
-            case Completed:
+            case StatusCompleted:
                 prop.status(typename properties::status_type(COMPLETED));
                 break;
-            case InProcess:
+            case StatusInProcess:
                 prop.status(typename properties::status_type(INPROCESS));
                 break;
-            case Cancelled:
+            case StatusCancelled:
                 prop.status(typename properties::status_type(CANCELLED));
                 break;
-            case Tentative:
+            case StatusTentative:
                 prop.status(typename properties::status_type(TENTATIVE));
                 break;
-            case Confirmed:
+            case StatusConfirmed:
                 prop.status(typename properties::status_type(CONFIRMED));
                 break;
-            case Draft:
+            case StatusDraft:
                 prop.status(typename properties::status_type(DRAFT));
                 break;
-            case Final:
+            case StatusFinal:
                 prop.status(typename properties::status_type(FINAL));
                 break;
             default:


commit bb7c74fd08fd77d2b50dbafa41e60d6d487f15a0
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 14:06:11 2012 +0100

    handle date and datetime values

diff --git a/c++/lib/kolabkcalconversion.cpp b/c++/lib/kolabkcalconversion.cpp
index 2032fe1..eb2ab09 100644
--- a/c++/lib/kolabkcalconversion.cpp
+++ b/c++/lib/kolabkcalconversion.cpp
@@ -560,10 +560,20 @@ void setRecurrence(KCalCore::Incidence &e, const T &event)
         }
     }
     foreach (const Kolab::DateTime &dt, event.recurrenceDates()) {
-        e.recurrence()->addRDateTime(toDate(dt));//TODO date/datetime
+        const KDateTime &date = toDate(dt);
+        if (date.isDateOnly()) {
+            e.recurrence()->addRDate(date.date());
+        } else {
+            e.recurrence()->addRDateTime(date);
+        }
     }
     foreach (const Kolab::DateTime &dt, event.exceptionDates()) {
-        e.recurrence()->addExDateTime(toDate(dt));//TODO date/datetime
+        const KDateTime &date = toDate(dt);
+        if (date.isDateOnly()) {
+            e.recurrence()->addExDate(date.date());
+        } else {
+            e.recurrence()->addExDateTime(date);
+        }
     }
 
 }
@@ -612,15 +622,21 @@ void getRecurrence(T &i, const I &e)
     i.setRecurrenceRule(rrule);
     
     std::vector<Kolab::DateTime> rdates;
-    foreach (const KDateTime &dt, rec->rDateTimes()) { //TODO date/datetime
+    foreach (const KDateTime &dt, rec->rDateTimes()) {
         rdates.push_back(fromDate(dt));
     }
+    foreach (const QDate &dt, rec->rDates()) {
+        rdates.push_back(fromDate(KDateTime(dt)));
+    }
     i.setRecurrenceDates(rdates);
     
     std::vector<Kolab::DateTime> exdates;
-    foreach (const KDateTime &dt, rec->exDateTimes()) { //TODO date/datetime
+    foreach (const KDateTime &dt, rec->exDateTimes()) {
         exdates.push_back(fromDate(dt));
     }
+    foreach (const QDate &dt, rec->exDates()) {
+        exdates.push_back(fromDate(KDateTime(dt)));
+    }
     i.setExceptionDates(exdates);
     
     if (!rec->exRules().empty()) {
diff --git a/c++/tests/kcalconversiontest.cpp b/c++/tests/kcalconversiontest.cpp
index f5066c4..a955380 100644
--- a/c++/tests/kcalconversiontest.cpp
+++ b/c++/tests/kcalconversiontest.cpp
@@ -77,6 +77,28 @@ namespace QTest {
     }
     
     template<>
+    char *toString(const KCalCore::DateList &l)
+    {
+        QByteArray ba = "KCalCore::DateList(";
+        foreach(const QDate &i, l) {
+            ba += i.toString();
+        }
+        ba += ")";
+        return qstrdup(ba.data());
+    }
+    
+    template<>
+    char *toString(const KCalCore::DateTimeList &l)
+    {
+        QByteArray ba = "KCalCore::DateTimeList(";
+        foreach(const KDateTime &i, l) {
+            ba += toString(i);
+        }
+        ba += ")";
+        return qstrdup(ba.data());
+    }
+    
+    template<>
     char *toString(const KCalCore::Recurrence &at)
     {
         at.dump();
@@ -101,7 +123,12 @@ namespace QTest {
             ba += QByteArray(toString(r->byMonthDays())) + "\n";
             ba += QByteArray(toString(r->byYearDays())) + "\n";
             ba += QByteArray(toString(r->byMonths())) + "\n";
-            ba += ")";
+            ba += ")\n";
+            ba += QByteArray(toString(at.exDates())) + "\n";
+            ba += QByteArray(toString(at.exDateTimes())) + "\n";
+            ba += QByteArray(toString(at.rDates())) + "\n";
+            ba += QByteArray(toString(at.rDateTimes())) + "\n";
+            
         }
         return qstrdup(ba.data());
     }
@@ -261,7 +288,9 @@ void KCalConversionTest::testConversion_data()
         kcal.recurrence()->setDaily(3);
         kcal.recurrence()->setDuration(5);
         kcal.recurrence()->addRDateTime(toDate(date2));
+        kcal.recurrence()->addRDate(toDate(date2).date());
         kcal.recurrence()->addExDateTime(toDate(date3));
+        kcal.recurrence()->addExDate(toDate(date3).date());
         
         KCalCore::RecurrenceRule *rr = kcal.recurrence()->defaultRRule(true);
         QList<int> intList = QVector<int>::fromStdVector(intVector).toList();
@@ -317,8 +346,8 @@ void KCalConversionTest::testConversion_data()
         
         kolab.setRecurrenceRule(rrule);
         kolab.setRecurrenceID(date2, true);
-        kolab.setRecurrenceDates(std::vector<Kolab::DateTime>() << date2);
-        kolab.setExceptionDates(std::vector<Kolab::DateTime>() << date3);
+        kolab.setRecurrenceDates(std::vector<Kolab::DateTime>() << date2 << Kolab::DateTime(date2.year(), date2.month(), date2.day()));
+        kolab.setExceptionDates(std::vector<Kolab::DateTime>() << date3 << Kolab::DateTime(date3.year(), date3.month(), date3.day()));
         
         kolab.setSummary("summary");
         kolab.setDescription("description");


commit 338f85b186fddfd082daf2e3c24abaa471ab930e
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 13:38:50 2012 +0100

    fix day conversions

diff --git a/c++/lib/kolabkcalconversion.cpp b/c++/lib/kolabkcalconversion.cpp
index a681dbe..2032fe1 100644
--- a/c++/lib/kolabkcalconversion.cpp
+++ b/c++/lib/kolabkcalconversion.cpp
@@ -502,12 +502,12 @@ Kolab::RecurrenceRule::Frequency fromRecurrenceType(KCalCore::RecurrenceRule::Pe
 
 KCalCore::RecurrenceRule::WDayPos toWeekDayPos(const Kolab::DayPos &dp)
 {
-    return KCalCore::RecurrenceRule::WDayPos(dp.occurence(), toWeekDay(dp.weekday())-1); //Yes, we have a different day-int mapping here...
+    return KCalCore::RecurrenceRule::WDayPos(dp.occurence(), toWeekDay(dp.weekday()));
 }
 
 Kolab::DayPos fromWeekDayPos(const KCalCore::RecurrenceRule::WDayPos &dp)
 {
-    return Kolab::DayPos(dp.pos(), fromWeekDay(dp.day()+1)); //Yes, we have a different day-int mapping here...
+    return Kolab::DayPos(dp.pos(), fromWeekDay(dp.day()));
 }
 
 template <typename T>
diff --git a/c++/tests/kcalconversiontest.cpp b/c++/tests/kcalconversiontest.cpp
index 612da5d..f5066c4 100644
--- a/c++/tests/kcalconversiontest.cpp
+++ b/c++/tests/kcalconversiontest.cpp
@@ -268,7 +268,7 @@ void KCalConversionTest::testConversion_data()
         rr->setBySeconds(intList);
         rr->setByMinutes(intList);
         rr->setByHours(intList);
-        rr->setByDays(QList<KCalCore::RecurrenceRule::WDayPos>() << KCalCore::RecurrenceRule::WDayPos(3,0) << KCalCore::RecurrenceRule::WDayPos(5,3));
+        rr->setByDays(QList<KCalCore::RecurrenceRule::WDayPos>() << KCalCore::RecurrenceRule::WDayPos(3,1) << KCalCore::RecurrenceRule::WDayPos(5,4));
         rr->setByMonthDays(intList);
         rr->setByYearDays(intList);
         rr->setByMonths(intList);


commit ea8d2c25695dd704d7ce98cc0bb862a8b9138a0b
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Mon Mar 5 10:32:34 2012 +0100

    attendees/attachments

diff --git a/c++/lib/kolabkcalconversion.cpp b/c++/lib/kolabkcalconversion.cpp
index ec777ae..a681dbe 100644
--- a/c++/lib/kolabkcalconversion.cpp
+++ b/c++/lib/kolabkcalconversion.cpp
@@ -371,8 +371,29 @@ void getIncidence(T &i, const I &e)
     i.setSummary(e.summary().toStdString());
     i.setDescription(e.description().toStdString());
     i.setStatus(fromStatus(e.status()));
-    //TODO attendees
-    //TODO attachments
+    std::vector<Kolab::Attendee> attendees;
+    foreach (const KCalCore::Attendee::Ptr ptr, e.attendees()) {
+        Kolab::Attendee a(ptr->email().toStdString());
+        a.setName(ptr->name().toStdString());
+        a.setRSVP(ptr->RSVP());
+        a.setPartStat(fromPartStat(ptr->status()));
+        a.setRole(fromRole(ptr->role()));
+        a.setUid(ptr->uid().toStdString());
+        attendees.push_back(a);
+    }
+    i.setAttendees(attendees);
+    std::vector<Kolab::Attachment> attachments;
+    foreach (const KCalCore::Attachment::Ptr ptr, e.attachments()) {
+        Kolab::Attachment a;
+        if (ptr->isUri()) {
+            a.setUri(ptr->uri().toStdString(), ptr->mimeType().toStdString());
+        } else {
+            a.setData(std::string(ptr->decodedData().data(), ptr->decodedData().size()), ptr->mimeType().toStdString());
+        }
+        a.setLabel(ptr->label().toStdString());
+        attachments.push_back(a);
+    }
+    i.setAttachments(attachments);
     //TODO alarms
     //TODO custom properties
 }


commit b881a7c24a2c1802a3df9501b3071b8a77becb85
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Sat Mar 3 12:07:50 2012 +0100

    const isValid functions for all, install missing headers

diff --git a/c++/lib/CMakeLists.txt b/c++/lib/CMakeLists.txt
index e6303ed..cffaee2 100644
--- a/c++/lib/CMakeLists.txt
+++ b/c++/lib/CMakeLists.txt
@@ -23,7 +23,10 @@ install( FILES
   kolabformat.h
   kolabevent.h
   kolabtodo.h
+  kolabjournal.h
+  kolabcontact.h
   kolabcontainers.h
+  global_definitions.h
   DESTINATION include/kolab COMPONENT Devel)
 
 #----- The following makes sure libkolabxml is found in the install directory for installed files and not in the build directory (for libraries which link to libkolabxml)
diff --git a/c++/lib/kolabcontact.cpp b/c++/lib/kolabcontact.cpp
index 835955b..b4ee445 100644
--- a/c++/lib/kolabcontact.cpp
+++ b/c++/lib/kolabcontact.cpp
@@ -54,6 +54,11 @@ void DistList::operator=(const Kolab::DistList &other)
     *d = *other.d;
 }
 
+bool DistList::isValid() const
+{
+    return !d->uid.empty();
+}
+
 void DistList::setUid(const std::string &uid)
 {
     d->uid = uid;
@@ -173,6 +178,11 @@ void Contact::operator=(const Kolab::Contact &other)
     *d = *other.d;
 }
 
+bool Contact::isValid() const
+{
+    return !d->uid.empty();
+}
+
 void Contact::setUid(const std::string &uid)
 {
     d->uid = uid;
diff --git a/c++/lib/kolabcontact.h b/c++/lib/kolabcontact.h
index f1b2441..1c8800f 100644
--- a/c++/lib/kolabcontact.h
+++ b/c++/lib/kolabcontact.h
@@ -191,6 +191,8 @@ public:
     DistList(const DistList &);
     void operator=(const DistList &);
 
+    bool isValid() const;
+
     void setUid(const std::string &);
     std::string uid() const;
 
@@ -217,7 +219,9 @@ public:
     ~Contact();
     Contact(const Contact &);
     void operator=(const Contact &);
-    
+
+    bool isValid() const;
+
     void setUid(const std::string &);
     std::string uid() const;
     
diff --git a/c++/lib/kolabevent.cpp b/c++/lib/kolabevent.cpp
index 43caaad..85d06f5 100644
--- a/c++/lib/kolabevent.cpp
+++ b/c++/lib/kolabevent.cpp
@@ -55,7 +55,7 @@ void Event::operator=(const Kolab::Event &other)
     *d = *other.d;
 }
 
-bool Event::isValid()
+bool Event::isValid() const
 {
     return !d->uid.empty();
 }
diff --git a/c++/lib/kolabevent.h b/c++/lib/kolabevent.h
index 0c32867..2b7d267 100644
--- a/c++/lib/kolabevent.h
+++ b/c++/lib/kolabevent.h
@@ -31,7 +31,7 @@ public:
     Event(const Event &);
     void operator=(const Event &);
     
-    bool isValid();
+    bool isValid() const;
     
     void setUid(const std::string &);
     std::string uid() const;
diff --git a/c++/lib/kolabjournal.cpp b/c++/lib/kolabjournal.cpp
index 9b6b0f4..b4c441e 100644
--- a/c++/lib/kolabjournal.cpp
+++ b/c++/lib/kolabjournal.cpp
@@ -46,7 +46,7 @@ void Journal::operator=(const Kolab::Journal &other)
     *d = *other.d;
 }
 
-bool Journal::isValid()
+bool Journal::isValid() const
 {
     return !d->uid.empty();
 }
diff --git a/c++/lib/kolabjournal.h b/c++/lib/kolabjournal.h
index 025d6e4..dc887b1 100644
--- a/c++/lib/kolabjournal.h
+++ b/c++/lib/kolabjournal.h
@@ -31,7 +31,7 @@ public:
     Journal(const Journal &);
     void operator=(const Journal &);
     
-    bool isValid();
+    bool isValid() const;
     
     void setUid(const std::string &);
     std::string uid() const;
diff --git a/c++/lib/kolabtodo.cpp b/c++/lib/kolabtodo.cpp
index 1775895..1a5072c 100644
--- a/c++/lib/kolabtodo.cpp
+++ b/c++/lib/kolabtodo.cpp
@@ -53,6 +53,11 @@ void Todo::operator=(const Kolab::Todo &other)
     *d = *other.d;
 }
 
+bool Todo::isValid() const
+{
+    return !d->uid.empty();
+}
+
 void Todo::setUid(const std::string &uid)
 {
     d->uid = uid;
diff --git a/c++/lib/kolabtodo.h b/c++/lib/kolabtodo.h
index 8391621..4ef087c 100644
--- a/c++/lib/kolabtodo.h
+++ b/c++/lib/kolabtodo.h
@@ -32,6 +32,8 @@ public:
     Todo(const Todo &);
     void operator=(const Todo &);
     
+    bool isValid() const;
+
     void setUid(const std::string &);
     std::string uid() const;
     





More information about the commits mailing list