aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
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/pcs
parentd6080b277df35517afcc21b5b963e3e86389d66b (diff)
downloadgsoc2013-evolution-900a7ac710e0ce88bb3c8fa00673fe405a8ba668.tar.gz
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/pcs')
-rw-r--r--calendar/pcs/cal-backend-file.c63
1 files changed, 54 insertions, 9 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index c60c0c118a..5b03150001 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -44,6 +44,13 @@ struct _CalBackendFilePrivate {
*/
GHashTable *comp_uid_hash;
+ /* All the uids in the calendar, hashed by pilot ID. The
+ * hash key *is* the pilot id returned by cal_component_get_pilot_id();
+ * it is not copied, so don't free it when you remove an object from
+ * the hash table.
+ */
+ GHashTable *comp_pilot_hash;
+
/* All event, to-do, and journal components in the calendar; they are
* here just for easy access (i.e. so that you don't have to iterate
* over the comp_uid_hash). If you need *all* the components in the
@@ -173,6 +180,20 @@ free_cal_component (gpointer key, gpointer value, gpointer data)
gtk_object_unref (GTK_OBJECT (comp));
}
+/* For hashing pilot id's */
+/* FIX ME, these are not unique */
+static guint
+cbf_pilot_hash (gconstpointer v)
+{
+ return *(const guint*) v;
+}
+
+static gint
+cbf_pilot_equal (gconstpointer v1, gconstpointer v2)
+{
+ return *((const unsigned long*) v1) == *((const unsigned long*) v2);
+}
+
/* Saves the calendar data */
static void
save (CalBackendFile *cbfile)
@@ -250,11 +271,17 @@ cal_backend_file_destroy (GtkObject *object)
}
if (priv->comp_uid_hash) {
- g_hash_table_foreach (priv->comp_uid_hash, free_cal_component, NULL);
+ g_hash_table_foreach (priv->comp_uid_hash,
+ free_cal_component, NULL);
g_hash_table_destroy (priv->comp_uid_hash);
priv->comp_uid_hash = NULL;
}
+ if (priv->comp_pilot_hash) {
+ g_hash_table_destroy (priv->comp_pilot_hash);
+ priv->comp_pilot_hash = NULL;
+ }
+
g_list_free (priv->events);
g_list_free (priv->todos);
g_list_free (priv->journals);
@@ -445,7 +472,8 @@ add_component (CalBackendFile *cbfile, CalComponent *comp, gboolean add_to_tople
CalBackendFilePrivate *priv;
GList **list;
const char *uid;
-
+ unsigned long *pilot_id;
+
priv = cbfile->priv;
switch (cal_component_get_vtype (comp)) {
@@ -471,8 +499,14 @@ add_component (CalBackendFile *cbfile, CalComponent *comp, gboolean add_to_tople
*/
check_dup_uid (cbfile, comp);
cal_component_get_uid (comp, &uid);
-
g_hash_table_insert (priv->comp_uid_hash, (char *) uid, comp);
+
+ /* Update the pilot list, if there is a pilot id */
+ cal_component_get_pilot_id (comp, &pilot_id);
+ if (pilot_id)
+ g_hash_table_insert (priv->comp_pilot_hash,
+ pilot_id, (char *)uid);
+
*list = g_list_prepend (*list, comp);
/* Put the object in the toplevel component if required */
@@ -497,6 +531,7 @@ remove_component (CalBackendFile *cbfile, CalComponent *comp)
CalBackendFilePrivate *priv;
icalcomponent *icalcomp;
const char *uid;
+ unsigned long *pilot_id;
GList **list, *l;
priv = cbfile->priv;
@@ -511,8 +546,10 @@ remove_component (CalBackendFile *cbfile, CalComponent *comp)
/* Remove it from our mapping */
cal_component_get_uid (comp, &uid);
+ cal_component_get_pilot_id (comp, &pilot_id);
g_hash_table_remove (priv->comp_uid_hash, uid);
-
+ g_hash_table_remove (priv->comp_pilot_hash, pilot_id);
+
switch (cal_component_get_vtype (comp)) {
case CAL_COMPONENT_EVENT:
list = &priv->events;
@@ -642,6 +679,7 @@ cal_backend_file_load (CalBackend *backend, GnomeVFSURI *uri)
priv->icalcomp = icalcomp;
priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->comp_pilot_hash = g_hash_table_new (cbf_pilot_hash, cbf_pilot_equal);
scan_vcalendar (cbfile);
/* Clean up */
@@ -687,6 +725,7 @@ cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri)
g_assert (priv->comp_uid_hash == NULL);
priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->comp_pilot_hash = g_hash_table_new (cbf_pilot_hash, cbf_pilot_equal);
/* Done */
@@ -1074,14 +1113,14 @@ cal_backend_file_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pil
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
+ char *uid;
cbfile = CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- g_return_val_if_fail (priv->icalcomp != NULL, FALSE);
+ uid = g_hash_table_lookup (priv->comp_pilot_hash, &pilot_id);
- /* FIXME */
- return NULL;
+ return uid;
}
/* Update_pilot_id handler for the file backend */
@@ -1093,13 +1132,19 @@ cal_backend_file_update_pilot_id (CalBackend *backend,
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
+ CalComponent *comp;
cbfile = CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
g_return_if_fail (priv->icalcomp != NULL);
-
g_return_if_fail (uid != NULL);
- /* FIXME */
+ comp = lookup_component (cbfile, uid);
+ if (!comp)
+ return;
+
+ cal_component_set_pilot_id (comp, &pilot_id);
+ cal_component_set_pilot_status (comp, &pilot_status);
}
+