[california/wip/725788-recurring] Simplify Component's class heirarchy
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725788-recurring] Simplify Component's class heirarchy
- Date: Sat, 8 Mar 2014 03:44:11 +0000 (UTC)
commit 2a746ff630eac44a6fcca285299f720a09f27bda
Author: Jim Nelson <jim yorba org>
Date: Fri Mar 7 19:29:55 2014 -0800
Simplify Component's class heirarchy
By removing expections of handling free/busy components (for now)
it allows for more functionality to be moved into Instance.
src/Makefile.am | 2 -
src/component/component-event.vala | 12 +----
src/component/component-instance.vala | 81 +++++++++++++++++++----------
src/component/component-recurrable.vala | 67 ------------------------
src/component/component-sequenceable.vala | 48 -----------------
5 files changed, 54 insertions(+), 156 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fc98016..fd2c362 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,8 +57,6 @@ california_VALASOURCES = \
component/component-error.vala \
component/component-event.vala \
component/component-instance.vala \
- component/component-recurrable.vala \
- component/component-sequenceable.vala \
component/component-uid.vala \
component/component-vtype.vala \
\
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index 334227c..3aea5fd 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -12,7 +12,7 @@ namespace California.Component {
* See [[https://tools.ietf.org/html/rfc5545#section-3.6.1]]
*/
-public class Event : Instance, Sequenceable, Recurrable, Gee.Comparable<Event> {
+public class Event : Instance, Gee.Comparable<Event> {
public const string PROP_SUMMARY = "summary";
public const string PROP_DESCRIPTION = "description";
public const string PROP_EXACT_TIME_SPAN = "exact-time-span";
@@ -55,16 +55,6 @@ public class Event : Instance, Sequenceable, Recurrable, Gee.Comparable<Event> {
public bool is_all_day { get; private set; }
/**
- * For { link Recurrable}.
- */
- public Component.DateTime? rid { get; set; default = null; }
-
- /**
- * For { link Sequenceable}.
- */
- public int sequence { get; set; default = 0; }
-
- /**
* Create an { link Event} { link Component} from an EDS CalComponent object.
*
* Throws a BackingError if the E.CalComponent's VTYPE is not VEVENT.
diff --git a/src/component/component-instance.vala b/src/component/component-instance.vala
index 6226fce..df827c4 100644
--- a/src/component/component-instance.vala
+++ b/src/component/component-instance.vala
@@ -9,8 +9,9 @@ namespace California.Component {
/**
* A mutable iCalendar component that has a definitive instance within a calendar.
*
- * By "instance", this means { link Event}s, To-Do's, and Journals, and Free/Busy components. In
- * other words, components which allocate a specific amount of time within a calendar.
+ * By "instance", this means { link Event}s, To-do's, and Journal components. In other words,
+ * components which allocate a specific amount of time within a calendar. (Free/Busy does allow
+ * for time to be published/reserved, but this implementation doesn't deal with that component.)
*
* Mutability is achieved two separate ways. One is to call { link full_update} supplying a new
* iCal component to update an existing one (verified by UID). This will update all fields.
@@ -28,6 +29,8 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
public const string PROP_DTSTAMP = "dtstamp";
public const string PROP_UID = "uid";
public const string PROP_ICAL_COMPONENT = "ical-component";
+ public const string PROP_RID = "rid";
+ public const string PROP_SEQUENCE = "sequence";
protected const string PROP_IN_FULL_UPDATE = "in-full-update";
@@ -58,6 +61,27 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
public UID uid { get; private set; }
/**
+ * The RECURRENCE-ID of a recurring component.
+ *
+ * See [[https://tools.ietf.org/html/rfc5545#section-3.8.4.4]]
+ */
+ public Component.DateTime? rid { get; set; default = null; }
+
+ /**
+ * Returns true if the { link Recurrable} is in fact a recurring instance.
+ *
+ * @see rid
+ */
+ public bool is_recurring { get { return rid != null; } }
+
+ /**
+ * The SEQUENCE of a VEVENT, VTODO, or VJOURNAL.
+ *
+ * See [[https://tools.ietf.org/html/rfc5545#section-3.8.7.4]]
+ */
+ public int sequence { get; set; default = 0; }
+
+ /**
* The iCal component being represented by this { link Instance}.
*/
private iCal.icalcomponent _ical_component;
@@ -189,17 +213,17 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
if (!dt_stamp.is_date)
dtstamp = dt_stamp.to_exact_time();
- //
- // Interface hooks
- //
-
- Recurrable? recurrable = this as Recurrable;
- if (recurrable != null)
- recurrable.update_from_component(ical_component);
+ try {
+ rid = new DateTime(ical_component, iCal.icalproperty_kind.RECURRENCEID_PROPERTY);
+ } catch (ComponentError comperr) {
+ // ignore if unavailable
+ if (!(comperr is ComponentError.UNAVAILABLE))
+ throw comperr;
+
+ rid = null;
+ }
- Sequenceable? sequenceable = this as Sequenceable;
- if (sequenceable != null)
- sequenceable.update_from_component(ical_component);
+ sequence = ical_component.get_sequence();
// save own copy of component; no ownership transferrance w/ current bindings
if (_ical_component != ical_component)
@@ -211,22 +235,23 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
if (in_full_update)
return;
- bool altered = false;
-
- //
- // Interface hooks
- //
-
- Recurrable? recurrable = this as Recurrable;
- if (recurrable != null)
- altered = recurrable.on_notify(pspec) || altered;
-
- Sequenceable? sequenceable = this as Sequenceable;
- if (sequenceable != null)
- altered = sequenceable.on_notify(pspec) || altered;
-
- // Instance currently has no properties of its own which may be updated except dtstamp,
- // which is a special case
+ bool altered = true;
+ switch (pspec.name) {
+ case PROP_RID:
+ if (rid == null)
+ remove_all_properties(iCal.icalproperty_kind.RECURRENCEID_PROPERTY);
+ else
+ ical_component.set_recurrenceid(rid.dt);
+ break;
+
+ case PROP_SEQUENCE:
+ ical_component.set_sequence(sequence);
+ break;
+
+ default:
+ altered = false;
+ break;
+ }
if (altered)
notify_altered(false);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]