aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util/cal-component.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-09-10 14:52:09 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-09-10 14:52:09 +0800
commit900a7ac710e0ce88bb3c8fa00673fe405a8ba668 (patch)
tree91c9d8f5f17674291993aecc076cdfb20d6896ae /calendar/cal-util/cal-component.c
parentd6080b277df35517afcc21b5b963e3e86389d66b (diff)
downloadgsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar
gsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar.gz
gsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar.bz2
gsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar.lz
gsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar.xz
gsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar.zst
gsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.zip
Use cal component pilot stuff properly (find_record_in_repository): Remove
2000-09-10 JP Rosevear <jpr@helixcode.com> * conduits/todo/todo-conduit.c (local_record_from_icalobject): Use cal component pilot stuff properly (find_record_in_repository): Remove cruft (ical_from_remote_record): Remove cruft (update_record): Set the vtype immediately after creation. Remove cruft * conduits/todo/todo-conduit.h: Remove iCalObject stuff * conduits/todo/todo-conduit-config.h: Move all the config stuff here, I need to kill the warnings at some point * conduits/todo/todo-conduit-control-applet.c (doRevertSettings): Set all the state variables correctly on a revert (doSaveSettings): Update original state (doHelp): Rename from about_cb (main): Destroy configurations when done * conduits/todo/Makefile.am: Tidy * pcs/cal-backend-file.c (cbf_pilot_hash): Function for hashing pilot ids (cbf_pilot_equal): For hash table of pilot ids (cal_backend_file_destroy): Destroy pilot id hash (add_component): Insert the uid into the pilot hash (remove_component): Remove the uid from the pilot hash (cal_backend_file_load): Create the pilot hash (cal_backend_file_create): ditto (cal_backend_file_get_uid_by_pilot_id): Implement using the pilot hash (cal_backend_file_update_pilot_id): ditto * cal-util/cal-component.h: Update prototypes * cal-util/cal-component.c (cal_component_get_pilot_id): Implement using ical X properties (cal_component_set_pilot_id): ditto (cal_component_get_pilot_status): ditto (cal_component_set_pilot_status): ditto (cal_component_free_pilot_id): Free a pilot id (cal_component_free_pilot_status): Free a pilot status svn path=/trunk/; revision=5298
Diffstat (limited to 'calendar/cal-util/cal-component.c')
-rw-r--r--calendar/cal-util/cal-component.c163
1 files changed, 150 insertions, 13 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 60e0a1bbd5..ff3bcd6d96 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -95,6 +95,9 @@ struct _CalComponentPrivate {
icalproperty *transparency;
icalproperty *url;
+ icalproperty *pilot_id;
+ icalproperty *pilot_status;
+
/* Whether we should increment the sequence number when piping the
* object over the wire.
*/
@@ -560,6 +563,13 @@ scan_property (CalComponent *comp, icalproperty *prop)
priv->url = prop;
break;
+ case ICAL_X_PROPERTY:
+ if (!strcmp (icalproperty_get_x_name (prop), "X-PILOT-ID"))
+ priv->pilot_id = prop;
+ if (!strcmp (icalproperty_get_x_name (prop), "X-PILOT-STATUS"))
+ priv->pilot_status = prop;
+ break;
+
default:
break;
}
@@ -2882,11 +2892,29 @@ cal_component_set_url (CalComponent *comp, const char *url)
* Queries the pilot id of a calendar component object, if any.
**/
void
-cal_component_get_pilot_id (CalComponent *comp, unsigned long *pilot_id)
+cal_component_get_pilot_id (CalComponent *comp, unsigned long **pilot_id)
{
- /* pilot_id maybe should be recordid_t */
- /* FIX ME */
- *pilot_id = 0;
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ /* Pilot id might want to be recordid_t */
+ if (priv->pilot_id) {
+ icalvalue *value;
+ char *text;
+
+ value = icalproperty_get_value (priv->pilot_id);
+ text = icalvalue_get_text (value);
+
+ *pilot_id = g_new (unsigned long, 1);
+ **pilot_id = strtoul (text, NULL, 0);
+ } else {
+ *pilot_id = NULL;
+ }
}
/**
@@ -2897,10 +2925,41 @@ cal_component_get_pilot_id (CalComponent *comp, unsigned long *pilot_id)
* Sets the pilot id of a clanedar component object.
**/
void
-cal_component_set_pilot_id (CalComponent *comp, unsigned long pilot_id)
+cal_component_set_pilot_id (CalComponent *comp, unsigned long *pilot_id)
{
+ CalComponentPrivate *priv;
+ icalvalue *value;
+ char text[256];
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
/* pilot_id maybe should be recordid_t */
- /* FIX ME */
+ if (!pilot_id) {
+ if (priv->pilot_id) {
+ icalcomponent_remove_property (priv->icalcomp,
+ priv->pilot_id);
+ icalproperty_free (priv->pilot_id);
+ priv->pilot_id = NULL;
+ }
+
+ return;
+ }
+
+ /* iCalendar spec does not support unsigned longs directly */
+ g_snprintf (text, 256, "%lu", *pilot_id);
+ value = icalvalue_new_text (text);
+
+ if (!priv->pilot_id) {
+ priv->pilot_id = icalproperty_new (ICAL_X_PROPERTY);
+ icalproperty_set_x_name (priv->pilot_id, "X-PILOT-ID");
+ icalcomponent_add_property (priv->icalcomp, priv->pilot_id);
+ }
+
+ icalproperty_set_value (priv->pilot_id, value);
}
/**
@@ -2911,11 +2970,30 @@ cal_component_set_pilot_id (CalComponent *comp, unsigned long pilot_id)
* Queries the pilot status of a calendar component object, if any.
**/
void
-cal_component_get_pilot_status (CalComponent *comp, unsigned long *pilot_status)
+cal_component_get_pilot_status (CalComponent *comp,
+ unsigned long **pilot_status)
{
- /* FIX ME */
- /* pilot_status should be iCalPilotState ? */
- *pilot_status = 0;
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ /* Pilot id might want to be recordid_t */
+ if (priv->pilot_status) {
+ icalvalue *value;
+ char *text;
+
+ value = icalproperty_get_value (priv->pilot_status);
+ text = icalvalue_get_text (value);
+
+ *pilot_status = g_new (unsigned long, 1);
+ **pilot_status = strtoul (text, NULL, 0);
+ } else {
+ *pilot_status = NULL;
+ }
}
/**
@@ -2926,10 +3004,41 @@ cal_component_get_pilot_status (CalComponent *comp, unsigned long *pilot_status)
* Sets the pilot id of a clanedar component object.
**/
void
-cal_component_set_pilot_status (CalComponent *comp, unsigned long pilot_status)
+cal_component_set_pilot_status (CalComponent *comp,
+ unsigned long *pilot_status)
{
- /* pilot_id maybe should be recordid_t */
- /* FIX ME */
+ CalComponentPrivate *priv;
+ icalvalue *value;
+ char text[256];
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+ g_return_if_fail (priv->icalcomp != NULL);
+
+ if (!pilot_status) {
+ if (priv->pilot_status) {
+ icalcomponent_remove_property (priv->icalcomp,
+ priv->pilot_status);
+ icalproperty_free (priv->pilot_status);
+ priv->pilot_status = NULL;
+ }
+
+ return;
+ }
+
+ /* iCalendar spec does not support unsigned longs directly */
+ g_snprintf (text, 256, "%lu", *pilot_status);
+ value = icalvalue_new_text (text);
+
+ if (!priv->pilot_status) {
+ priv->pilot_status = icalproperty_new (ICAL_X_PROPERTY);
+ icalproperty_set_x_name (priv->pilot_status, "X-PILOT-STATUS");
+ icalcomponent_add_property (priv->icalcomp, priv->pilot_status);
+ }
+
+ icalproperty_set_value (priv->pilot_status, value);
}
@@ -3112,6 +3221,34 @@ cal_component_free_sequence (int *sequence)
}
/**
+ * cal_component_free_pilot_id:
+ * @sequence: Sequence number value.
+ *
+ * Frees a sequence number value.
+ **/
+void
+cal_component_free_pilot_id (unsigned long *pilot_id)
+{
+ g_return_if_fail (pilot_id != NULL);
+
+ g_free (pilot_id);
+}
+
+/**
+ * cal_component_free_pilot_status:
+ * @sequence: Sequence number value.
+ *
+ * Frees a sequence number value.
+ **/
+void
+cal_component_free_pilot_status (unsigned long *pilot_status)
+{
+ g_return_if_fail (pilot_status != NULL);
+
+ g_free (pilot_status);
+}
+
+/**
* cal_component_free_text_list:
* @text_list: List of #CalComponentText structures.
*