Branch 'kolab/integration/4.13.0' - 2 commits - akonadi/monitor_p.cpp kcalcore/freebusyperiod.cpp kcalcore/freebusyperiod.h kcalcore/icalformat_p.cpp

Christian Mollekopf mollekopf at kolabsys.com
Wed Oct 8 10:54:41 CEST 2014


 akonadi/monitor_p.cpp       |    8 ++--
 kcalcore/freebusyperiod.cpp |   22 ++++++++++--
 kcalcore/freebusyperiod.h   |   23 ++++++++++++
 kcalcore/icalformat_p.cpp   |   78 +++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 117 insertions(+), 14 deletions(-)

New commits:
commit ec5e53286a8394b1b81e5d38b49ba95d54539137
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Wed Oct 8 00:12:11 2014 +0200

    Monitor: Avoid fetching removed collections.
    
    This avoids a shitload of fetchjobs that fail anyways (If a bunch of collections
    is removed).

diff --git a/akonadi/monitor_p.cpp b/akonadi/monitor_p.cpp
index 7fa898c..0554734 100644
--- a/akonadi/monitor_p.cpp
+++ b/akonadi/monitor_p.cpp
@@ -432,6 +432,11 @@ bool MonitorPrivate::ensureDataAvailable(const NotificationMessageV3 &msg)
         return true;
     }
 
+    if (msg.operation() == NotificationMessageV2::Remove) {
+        // For both collection and item removals we don't require the parent collection, that may be gone already anyways. So let's avoid a failing fetchjob
+        return true;
+    }
+
     bool allCached = true;
     if (fetchCollection) {
         if (!collectionCache->ensureCached(msg.parentCollection(), mCollectionFetchScope)) {
@@ -441,9 +446,6 @@ bool MonitorPrivate::ensureDataAvailable(const NotificationMessageV3 &msg)
             allCached = false;
         }
     }
-    if (msg.operation() == NotificationMessageV2::Remove) {
-        return allCached; // the actual object is gone already, nothing to fetch there
-    }
 
     if (msg.type() == NotificationMessageV2::Items && !mItemFetchScope.isEmpty()) {
         ItemFetchScope scope(mItemFetchScope);


commit 8a4c6933faed8f2475a661e2cf6d61ec2a3ef730
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Wed Oct 1 23:06:46 2014 +0200

    Implement support for FBTYPE in VFREEBUSY in KCalCore

diff --git a/kcalcore/freebusyperiod.cpp b/kcalcore/freebusyperiod.cpp
index b9c9218..0f02d63 100644
--- a/kcalcore/freebusyperiod.cpp
+++ b/kcalcore/freebusyperiod.cpp
@@ -38,10 +38,13 @@ using namespace KCalCore;
 class KCalCore::FreeBusyPeriod::Private
 {
 public:
-    Private() {}
+    Private():
+       mType(Unknown)
+    {}
 
     QString mSummary;
     QString mLocation;
+    FreeBusyType mType;
 };
 //@endcond
 
@@ -106,11 +109,22 @@ void FreeBusyPeriod::setLocation(const QString &location)
     d->mLocation = location;
 }
 
+FreeBusyPeriod::FreeBusyType FreeBusyPeriod::type() const
+{
+    return d->mType;
+}
+
+void FreeBusyPeriod::setType(FreeBusyPeriod::FreeBusyType type)
+{
+    d->mType = type;
+}
+
+
 QDataStream &KCalCore::operator<<(QDataStream &stream, const KCalCore::FreeBusyPeriod &period)
 {
     KCalCore::Period periodParent = static_cast<KCalCore::Period>(period);
     stream << periodParent;
-    stream << period.summary() << period.location();
+    stream << period.summary() << period.location() << static_cast<int>(period.type());
     return stream;
 }
 
@@ -118,12 +132,14 @@ QDataStream &KCalCore::operator>>(QDataStream &stream, FreeBusyPeriod &period)
 {
     KCalCore::Period periodParent;
     QString summary, location;
+    int type;
 
-    stream >> periodParent >> summary >> location;
+    stream >> periodParent >> summary >> location >> type;
 
     period = periodParent;
     period.setLocation(location);
     period.setSummary(summary);
+    period.setType(static_cast<FreeBusyPeriod::FreeBusyType>(type));
     return stream;
 }
 
diff --git a/kcalcore/freebusyperiod.h b/kcalcore/freebusyperiod.h
index 4a42e6e..e4aa00c 100644
--- a/kcalcore/freebusyperiod.h
+++ b/kcalcore/freebusyperiod.h
@@ -46,6 +46,14 @@ namespace KCalCore {
 class KCALCORE_EXPORT FreeBusyPeriod : public Period
 {
 public:
+    enum FreeBusyType {
+        Free,
+        Busy,
+        BusyUnavailable,
+        BusyTentative,
+        Unknown
+    };
+
     /**
        List of periods.
      */
@@ -126,6 +134,21 @@ public:
     */
     QString location() const;
 
+    /**
+      Sets the free/busy type.
+      @param type is the type of free/busy period
+      @see type().
+      @since 4.15
+    */
+    void setType(FreeBusyType type);
+
+    /**
+      Returns free/busy type
+      @see setType().
+      @since 4.15
+    */
+    FreeBusyType type() const;
+
 private:
     //@cond PRIVATE
     class Private;
diff --git a/kcalcore/icalformat_p.cpp b/kcalcore/icalformat_p.cpp
index 0f54e39..41a833c 100644
--- a/kcalcore/icalformat_p.cpp
+++ b/kcalcore/icalformat_p.cpp
@@ -371,17 +371,54 @@ icalcomponent *ICalFormatImpl::writeFreeBusy(const FreeBusy::Ptr &freebusy,
 #endif
 
     //Loops through all the periods in the freebusy object
-    Period::List list = freebusy->busyPeriods();
+    FreeBusyPeriod::List list = freebusy->fullBusyPeriods();
     icalperiodtype period = icalperiodtype_null_period();
     for (int i = 0, count = list.count(); i < count; ++i) {
-        period.start = writeICalUtcDateTime(list[i].start());
-        if (list[i].hasDuration()) {
-            period.duration = writeICalDuration(list[i].duration());
+        const FreeBusyPeriod fbPeriod = list[i];
+        period.start = writeICalUtcDateTime(fbPeriod.start());
+        if (fbPeriod.hasDuration()) {
+            period.duration = writeICalDuration(fbPeriod.duration());
         } else {
-            period.end = writeICalUtcDateTime(list[i].end());
+            period.end = writeICalUtcDateTime(fbPeriod.end());
         }
-        icalcomponent_add_property(
-            vfreebusy, icalproperty_new_freebusy(period));
+
+        icalproperty *property = icalproperty_new_freebusy(period);
+
+        icalparameter_fbtype fbType;
+        switch (fbPeriod.type()) {
+          case FreeBusyPeriod::Free:
+              fbType = ICAL_FBTYPE_FREE;
+              break;
+          case FreeBusyPeriod::Busy:
+              fbType = ICAL_FBTYPE_BUSY;
+              break;
+          case FreeBusyPeriod::BusyTentative:
+              fbType = ICAL_FBTYPE_BUSYTENTATIVE;
+              break;
+          case FreeBusyPeriod::BusyUnavailable:
+              fbType = ICAL_FBTYPE_BUSYUNAVAILABLE;
+              break;
+          case FreeBusyPeriod::Unknown:
+              fbType = ICAL_FBTYPE_X;
+              break;
+          default:
+              fbType = ICAL_FBTYPE_NONE;
+              break;
+        }
+        icalproperty_set_parameter(property, icalparameter_new_fbtype(fbType));
+
+        if (!fbPeriod.summary().isEmpty()) {
+            icalparameter *param = icalparameter_new_x("X-SUMMARY");
+            icalparameter_set_xvalue(param, KCodecs::base64Encode(fbPeriod.summary().toUtf8()));
+            icalproperty_set_parameter(property, param);
+        }
+        if (!fbPeriod.location().isEmpty()) {
+            icalparameter *param = icalparameter_new_x("X-LOCATION");
+            icalparameter_set_xvalue(param, KCodecs::base64Encode(fbPeriod.location().toUtf8()));
+            icalproperty_set_parameter(property, param);
+        }
+
+        icalcomponent_add_property(vfreebusy, property);
     }
 
     return vfreebusy;
@@ -1332,7 +1369,32 @@ FreeBusy::Ptr ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy)
                 period = FreeBusyPeriod(period_start, duration);
             }
 
-            icalparameter *param = icalproperty_get_first_parameter(p, ICAL_X_PARAMETER);
+            icalparameter *param = icalproperty_get_first_parameter(p, ICAL_FBTYPE_PARAMETER);
+            if (param) {
+                icalparameter_fbtype fbType = icalparameter_get_fbtype(param);
+                switch (fbType) {
+                case ICAL_FBTYPE_FREE:
+                    period.setType(FreeBusyPeriod::Free);
+                    break;
+                case ICAL_FBTYPE_BUSY:
+                    period.setType(FreeBusyPeriod::Busy);
+                    break;
+                case ICAL_FBTYPE_BUSYTENTATIVE:
+                    period.setType(FreeBusyPeriod::BusyTentative);
+                    break;
+                case ICAL_FBTYPE_BUSYUNAVAILABLE:
+                    period.setType(FreeBusyPeriod::BusyUnavailable);
+                    break;
+                case ICAL_FBTYPE_X:
+                    period.setType(FreeBusyPeriod::Unknown);
+                    break;
+                case ICAL_FBTYPE_NONE:
+                    period.setType(FreeBusyPeriod::Free);
+                    break;
+                }
+            }
+
+            param = icalproperty_get_first_parameter(p, ICAL_X_PARAMETER);
             while (param) {
                 if (strncmp(icalparameter_get_xname(param), "X-SUMMARY", 9) == 0) {
                     period.setSummary(QString::fromUtf8(




More information about the commits mailing list