[california] Fix errors changing all-day event to timed event: Bug #731808



commit 87b73cc197ad22970e585cb9943f1dee922e6d75
Author: Jim Nelson <jim yorba org>
Date:   Wed Jun 18 14:01:03 2014 -0700

    Fix errors changing all-day event to timed event: Bug #731808
    
    is_all_day is now a read-only property with result generated by
    examining other properties, which is a better way to go (although
    it does mean losing notifications when it changes; may need to
    install a signal at some point).  Also, inspection of library code
    indicates libical doesn't consistently replace properties and may
    simpy add new ones, even if spec requires one and only one.  Going
    forward, need to enforce this manually.

 src/component/component-event.vala    |   19 ++++++++++++-------
 src/component/component-instance.vala |    6 +++---
 2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index 8b157f1..3d5960f 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -60,7 +60,11 @@ public class Event : Instance, Gee.Comparable<Event> {
     /**
      * Convenience property for determining if an all-day event or not.
      */
-    public bool is_all_day { get; private set; }
+    public bool is_all_day {
+        get {
+            return date_span != null && exact_time_span == null;
+        }
+    }
     
     /**
      * Convenience property for determining if { link Event} spans one or more full days.
@@ -131,9 +135,6 @@ public class Event : Instance, Gee.Comparable<Event> {
             set_event_date_span(date_span);
         }
         
-        // need to set this here because on_notify() doesn't update inside full update
-        is_all_day = (date_span != null);
-        
         location = ical_component.get_location();
         
         switch (ical_component.get_status()) {
@@ -160,10 +161,12 @@ public class Event : Instance, Gee.Comparable<Event> {
         bool altered = true;
         switch (pspec.name) {
             case PROP_SUMMARY:
+                remove_all_properties(iCal.icalproperty_kind.SUMMARY_PROPERTY);
                 ical_component.set_summary(summary);
             break;
             
             case PROP_DESCRIPTION:
+                remove_all_properties(iCal.icalproperty_kind.DESCRIPTION_PROPERTY);
                 ical_component.set_description(description);
             break;
             
@@ -186,18 +189,20 @@ public class Event : Instance, Gee.Comparable<Event> {
                 else
                     date_span_to_ical(date_span, false, &ical_dtstart, &ical_dtend);
                 
+                remove_all_properties(iCal.icalproperty_kind.DTSTART_PROPERTY);
                 ical_component.set_dtstart(ical_dtstart);
-                ical_component.set_dtend(ical_dtend);
                 
-                // updating here guarantees it's always accurate
-                is_all_day = (date_span != null);
+                remove_all_properties(iCal.icalproperty_kind.DTEND_PROPERTY);
+                ical_component.set_dtend(ical_dtend);
             break;
             
             case PROP_LOCATION:
+                remove_all_properties(iCal.icalproperty_kind.LOCATION_PROPERTY);
                 ical_component.set_location(location);
             break;
             
             case PROP_STATUS:
+                remove_all_properties(iCal.icalproperty_kind.STATUS_PROPERTY);
                 switch(status) {
                     case Status.TENTATIVE:
                         ical_component.set_status(iCal.icalproperty_status.TENTATIVE);
diff --git a/src/component/component-instance.vala b/src/component/component-instance.vala
index 16a9977..7ad5445 100644
--- a/src/component/component-instance.vala
+++ b/src/component/component-instance.vala
@@ -259,13 +259,13 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
         bool altered = true;
         switch (pspec.name) {
             case PROP_RID:
-                if (rid == null)
-                    remove_all_properties(iCal.icalproperty_kind.RECURRENCEID_PROPERTY);
-                else
+                remove_all_properties(iCal.icalproperty_kind.RECURRENCEID_PROPERTY);
+                if (rid != null)
                     ical_component.set_recurrenceid(rid.dt);
             break;
             
             case PROP_SEQUENCE:
+                remove_all_properties(iCal.icalproperty_kind.SEQUENCE_PROPERTY);
                 ical_component.set_sequence(sequence);
             break;
             


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]