aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-07-07 10:38:52 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-07-07 10:38:52 +0800
commit3b62a242bf8ff7e5542bedc42112587840f780e4 (patch)
treebc3fc9f30593480e3972b8b7c96d2a18984dda68
parent540bde0aff7cc2b29f90a29e974e09fd400ae7ba (diff)
downloadgsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.tar
gsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.tar.gz
gsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.tar.bz2
gsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.tar.lz
gsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.tar.xz
gsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.tar.zst
gsoc2013-evolution-3b62a242bf8ff7e5542bedc42112587840f780e4.zip
Handle the LAST-MODIFIED property. (free_icalcomponent): Ditto.
2000-07-06 Federico Mena Quintero <federico@helixcode.com> * cal-util/cal-component.c (scan_property): Handle the LAST-MODIFIED property. (free_icalcomponent): Ditto. (cal_component_get_last_modified): Ditto. (cal_component_set_last_modified): Ditto. (get_icaltimetype): New function to get struct icaltimetype values. (cal_component_get_created): Use get_icaltimetype(). (set_icaltimetype): New function to set struct icaltimetype values. (cal_component_set_created): Use set_icaltimetype(). svn path=/trunk/; revision=3936
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/cal-util/cal-component.c123
-rw-r--r--calendar/cal-util/cal-component.h3
3 files changed, 118 insertions, 20 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index be092106d1..c8d721d972 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,17 @@
2000-07-06 Federico Mena Quintero <federico@helixcode.com>
+ * cal-util/cal-component.c (scan_property): Handle the
+ LAST-MODIFIED property.
+ (free_icalcomponent): Ditto.
+ (cal_component_get_last_modified): Ditto.
+ (cal_component_set_last_modified): Ditto.
+ (get_icaltimetype): New function to get struct icaltimetype
+ values.
+ (cal_component_get_created): Use get_icaltimetype().
+ (set_icaltimetype): New function to set struct icaltimetype
+ values.
+ (cal_component_set_created): Use set_icaltimetype().
+
* cal-util/cal-component.c (scan_property): Handle the CREATED
property.
(free_icalcomponent): Ditto.
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 8065dc298f..8bc74a846e 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -66,6 +66,8 @@ typedef struct {
struct datetime due;
+ icalproperty *last_modified;
+
struct {
icalproperty *prop;
icalparameter *altrep_param;
@@ -195,6 +197,8 @@ free_icalcomponent (CalComponent *comp)
priv->due.prop = NULL;
priv->due.tzid_param = NULL;
+ priv->last_modified = NULL;
+
priv->summary.prop = NULL;
priv->summary.altrep_param = NULL;
}
@@ -429,6 +433,10 @@ scan_property (CalComponent *comp, icalproperty *prop)
scan_datetime (comp, &priv->due, prop);
break;
+ case ICAL_LASTMODIFIED_PROPERTY:
+ priv->last_modified = prop;
+ break;
+
case ICAL_SUMMARY_PROPERTY:
scan_summary (comp, prop);
break;
@@ -1136,6 +1144,21 @@ cal_component_free_icaltimetype (struct icaltimetype *t)
g_free (t);
}
+/* Gets a struct icaltimetype value */
+static void
+get_icaltimetype (icalproperty *prop,
+ struct icaltimetype (* get_prop_func) (icalproperty *prop),
+ struct icaltimetype **t)
+{
+ if (!prop) {
+ *t = NULL;
+ return;
+ }
+
+ *t = g_new (struct icaltimetype, 1);
+ **t = (* get_prop_func) (prop);
+}
+
/**
* cal_component_get_created:
* @comp: A calendar component object.
@@ -1157,13 +1180,36 @@ cal_component_get_created (CalComponent *comp, struct icaltimetype **t)
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
- if (!priv->created) {
- *t = NULL;
+ get_icaltimetype (priv->created, icalproperty_get_created, t);
+}
+
+/* Sets a struct icaltimetype value */
+static void
+set_icaltimetype (CalComponent *comp, icalproperty **prop,
+ icalproperty *(* prop_new_func) (struct icaltimetype v),
+ void (* prop_set_func) (icalproperty *prop, struct icaltimetype v),
+ struct icaltimetype *t)
+{
+ CalComponentPrivate *priv;
+
+ priv = comp->priv;
+
+ if (!t) {
+ if (*prop) {
+ icalcomponent_remove_property (priv->icalcomp, *prop);
+ icalproperty_free (*prop);
+ *prop = NULL;
+ }
+
return;
}
- *t = g_new (struct icaltimetype, 1);
- **t = icalproperty_get_created (priv->created);
+ if (*prop)
+ (* prop_set_func) (*prop, *t);
+ else {
+ *prop = (* prop_new_func) (*t);
+ icalcomponent_add_property (priv->icalcomp, *prop);
+ }
}
/**
@@ -1186,22 +1232,10 @@ cal_component_set_created (CalComponent *comp, struct icaltimetype *t)
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
- if (!t) {
- if (priv->created) {
- icalcomponent_remove_property (priv->icalcomp, priv->created);
- icalproperty_free (priv->created);
- priv->created = NULL;
- }
-
- return;
- }
-
- if (priv->created)
- icalproperty_set_created (priv->created, *t);
- else {
- priv->created = icalproperty_new_created (*t);
- icalcomponent_add_property (priv->icalcomp, priv->created);
- }
+ set_icaltimetype (comp, &priv->created,
+ icalproperty_new_created,
+ icalproperty_set_created,
+ t);
}
/**
@@ -1534,6 +1568,55 @@ cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt)
}
/**
+ * cal_component_get_last_modified:
+ * @comp: A calendar component object.
+ * @t: Return value for the last modified time value.
+ *
+ * Queries the time at which a calendar component object was last modified in
+ * the calendar store.
+ **/
+void
+cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (t != NULL);
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ get_icaltimetype (priv->last_modified, icalproperty_get_lastmodified, t);
+}
+
+/**
+ * cal_component_set_last_modified:
+ * @comp: A calendar component object.
+ * @t: Value for the last time modified.
+ *
+ * Sets the time at which a calendar component object was last stored in the
+ * calendar store. This should not be called by plain calendar user agents.
+ **/
+void
+cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+ g_return_if_fail (t != NULL);
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ set_icaltimetype (comp, &priv->last_modified,
+ icalproperty_new_lastmodified,
+ icalproperty_set_lastmodified,
+ t);
+}
+
+/**
* cal_component_get_summary:
* @comp: A calendar component object.
* @summary: Return value for the summary property and its parameters.
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 5a66b42619..b9cc9da942 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -141,6 +141,9 @@ void cal_component_set_dtstart (CalComponent *comp, CalComponentDateTime *dt);
void cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt);
void cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt);
+void cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t);
+void cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t);
+
void cal_component_get_summary (CalComponent *comp, CalComponentText *summary);
void cal_component_set_summary (CalComponent *comp, CalComponentText *summary);