aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/pcs')
-rw-r--r--calendar/pcs/cal-backend-imc.c69
-rw-r--r--calendar/pcs/cal-backend.c23
-rw-r--r--calendar/pcs/cal-backend.h10
-rw-r--r--calendar/pcs/cal.c53
4 files changed, 155 insertions, 0 deletions
diff --git a/calendar/pcs/cal-backend-imc.c b/calendar/pcs/cal-backend-imc.c
index 7999d97d6e..3e079218cf 100644
--- a/calendar/pcs/cal-backend-imc.c
+++ b/calendar/pcs/cal-backend-imc.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Evolution calendar - Internet Mail Consortium formats backend
*
* Copyright (C) 2000 Helix Code, Inc.
@@ -86,6 +87,12 @@ static gboolean cal_backend_imc_get_alarms_for_object (CalBackend *backend, cons
static gboolean cal_backend_imc_update_object (CalBackend *backend, const char *uid,
const char *calobj);
static gboolean cal_backend_imc_remove_object (CalBackend *backend, const char *uid);
+static char *cal_backend_imc_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id);
+static void cal_backend_imc_update_pilot_id (CalBackend *backend,
+ const char *uid,
+ unsigned long int pilot_id,
+ unsigned long int pilot_status);
+
static CalBackendClass *parent_class;
@@ -147,6 +154,8 @@ cal_backend_imc_class_init (CalBackendIMCClass *class)
backend_class->get_alarms_for_object = cal_backend_imc_get_alarms_for_object;
backend_class->update_object = cal_backend_imc_update_object;
backend_class->remove_object = cal_backend_imc_remove_object;
+ backend_class->get_uid_by_pilot_id = cal_backend_imc_get_uid_by_pilot_id;
+ backend_class->update_pilot_id = cal_backend_imc_update_pilot_id;
object_class->destroy = cal_backend_imc_destroy;
}
@@ -969,6 +978,65 @@ cal_backend_imc_get_uids (CalBackend *backend, CalObjType type)
return c.uid_list;
}
+
+
+static char *
+cal_backend_imc_get_uid_by_pilot_id (CalBackend *backend,
+ unsigned long int pilot_id)
+{
+ CalBackendIMC *cbimc;
+ IMCPrivate *priv;
+ GList *l;
+ iCalObject *obj = NULL;
+
+ g_return_val_if_fail (backend != NULL, NULL);
+ cbimc = CAL_BACKEND_IMC (backend);
+ priv = cbimc->priv;
+ g_return_val_if_fail (priv->loaded, NULL);
+
+ for (l = priv->events; l; l = l->next){
+ obj = l->data;
+ if (obj->pilot_id == pilot_id)
+ goto done;
+ }
+
+ for (l = priv->todos; l; l = l->next){
+ obj = l->data;
+ if (obj->pilot_id == pilot_id)
+ goto done;
+ }
+
+ done:
+ if (!obj || obj->pilot_id != pilot_id)
+ return NULL;
+
+ return g_strdup (obj->uid);
+}
+
+
+void
+cal_backend_imc_update_pilot_id (CalBackend *backend,
+ const char *uid,
+ unsigned long int pilot_id,
+ unsigned long int pilot_status)
+{
+ CalBackendIMC *cbimc;
+ IMCPrivate *priv;
+ iCalObject *obj;
+
+ g_return_if_fail (backend != NULL);
+ cbimc = CAL_BACKEND_IMC (backend);
+ priv = cbimc->priv;
+ g_return_if_fail (priv->loaded);
+
+ obj = lookup_object (cbimc, uid);
+
+ obj->pilot_id = pilot_id;
+ obj->pilot_status = pilot_status;
+}
+
+
+
/* Allocates and fills in a new CalObjInstance structure */
static CalObjInstance *
build_cal_obj_instance (iCalObject *ico, time_t start, time_t end)
@@ -1310,6 +1378,7 @@ cal_backend_imc_update_object (CalBackend *backend, const char *uid, const char
remove_object (cbimc, ico);
add_object (cbimc, new_ico);
+ new_ico->pilot_status = ICAL_PILOT_SYNC_MOD;
save (cbimc);
/* FIXME: do the notification asynchronously */
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index 7956f77473..658f55012b 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -314,6 +314,29 @@ cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid,
return (* CLASS (backend)->get_alarms_for_object) (backend, uid, start, end, alarms);
}
+
+char *cal_backend_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
+ g_assert (CLASS(backend)->get_uid_by_pilot_id != NULL);
+ return (* CLASS(backend)->get_uid_by_pilot_id) (backend, pilot_id);
+}
+
+
+void cal_backend_update_pilot_id (CalBackend *backend, const char *uid,
+ unsigned long int pilot_id,
+ unsigned long int pilot_status)
+{
+ g_return_if_fail (backend != NULL);
+ g_return_if_fail (IS_CAL_BACKEND (backend));
+ g_assert (CLASS(backend)->update_pilot_id != NULL);
+ (* CLASS(backend)->update_pilot_id) (backend, uid,
+ pilot_id, pilot_status);
+}
+
+
+
/**
* cal_backend_update_object:
* @backend: A calendar backend.
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index 57f3acf18e..2daa4ad56b 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Evolution calendar - generic backend class
*
* Copyright (C) 2000 Helix Code, Inc.
@@ -75,6 +76,8 @@ struct _CalBackendClass {
GList **alarms);
gboolean (* update_object) (CalBackend *backend, const char *uid, const char *calobj);
gboolean (* remove_object) (CalBackend *backend, const char *uid);
+ char *(* get_uid_by_pilot_id) (CalBackend *backend, unsigned long int pilot_id);
+ void (* update_pilot_id) (CalBackend *backend, const char *uid, unsigned long int pilot_id, unsigned long int pilot_status);
};
GtkType cal_backend_get_type (void);
@@ -101,12 +104,19 @@ gboolean cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid
time_t start, time_t end,
GList **alarms);
+
gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const char *calobj);
gboolean cal_backend_remove_object (CalBackend *backend, const char *uid);
void cal_backend_last_client_gone (CalBackend *backend);
+char *cal_backend_get_uid_by_pilot_id (CalBackend *backend, unsigned long int pilot_id);
+
+void cal_backend_update_pilot_id (CalBackend *backend, const char *uid,
+ unsigned long int pilot_id,
+ unsigned long int pilot_status);
+
END_GNOME_DECLS
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index a01c0ce8dc..35677c6cac 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -517,6 +517,57 @@ Cal_remove_object (PortableServer_Servant servant,
NULL);
}
+
+
+/* Cal::get_uid_by_pilot_id method */
+static Evolution_Calendar_CalObjUID
+Cal_get_uid_by_pilot_id (PortableServer_Servant servant,
+ const Evolution_Calendar_PilotID pilot_id,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ char *uid;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ uid = cal_backend_get_uid_by_pilot_id (priv->backend, pilot_id);
+
+ if (uid) {
+ CORBA_char *uid_copy;
+
+ uid_copy = CORBA_string_dup (uid);
+ g_free (uid);
+ return uid_copy;
+ } else {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_Evolution_Calendar_Cal_NotFound,
+ NULL);
+ return NULL;
+ }
+}
+
+
+/* Cal::update_pilot_id method */
+static void
+Cal_update_pilot_id (PortableServer_Servant servant,
+ const Evolution_Calendar_CalObjUID uid,
+ const Evolution_Calendar_PilotID pilot_id,
+ const CORBA_unsigned_long pilot_status,
+ CORBA_Environment * ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ cal_backend_update_pilot_id (priv->backend, uid,
+ pilot_id, pilot_status);
+}
+
+
/**
* cal_get_epv:
* @void:
@@ -540,6 +591,8 @@ cal_get_epv (void)
epv->get_alarms_for_object = Cal_get_alarms_for_object;
epv->update_object = Cal_update_object;
epv->remove_object = Cal_remove_object;
+ epv->get_uid_by_pilot_id = Cal_get_uid_by_pilot_id;
+ epv->update_pilot_id = Cal_update_pilot_id;
return epv;
}