aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
authorJP Rosevear <jpr@src.gnome.org>2003-03-05 03:52:37 +0800
committerJP Rosevear <jpr@src.gnome.org>2003-03-05 03:52:37 +0800
commit6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62 (patch)
treebba07b5f28966c10a90de8f550af895014b0b9bb /calendar/pcs
parentcd4477930e72b1be069d5c97b90d96e989645bfc (diff)
downloadgsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.gz
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.bz2
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.lz
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.xz
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.tar.zst
gsoc2013-evolution-6b4c3984d52cfbf88ae84ee0102f4aa0c17a2a62.zip
If only the pipe wouldn't break.
svn path=/trunk/; revision=20143
Diffstat (limited to 'calendar/pcs')
-rw-r--r--calendar/pcs/cal-backend-file.c75
-rw-r--r--calendar/pcs/cal-backend.c40
-rw-r--r--calendar/pcs/cal-backend.h19
-rw-r--r--calendar/pcs/cal.c74
4 files changed, 189 insertions, 19 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index a0d9453b3b..7310df2e4f 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -79,6 +79,8 @@ static void cal_backend_file_finalize (GObject *object);
static const char *cal_backend_file_get_uri (CalBackend *backend);
static gboolean cal_backend_file_is_read_only (CalBackend *backend);
static const char *cal_backend_file_get_email_address (CalBackend *backend);
+static const char *cal_backend_file_get_alarm_email_address (CalBackend *backend);
+static const char *cal_backend_file_get_static_capabilities (CalBackend *backend);
static CalBackendOpenStatus cal_backend_file_open (CalBackend *backend,
const char *uristr,
gboolean only_if_exists);
@@ -91,6 +93,7 @@ static CalMode cal_backend_file_get_mode (CalBackend *backend);
static void cal_backend_file_set_mode (CalBackend *backend, CalMode mode);
static int cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type);
+static char *cal_backend_file_get_default_object (CalBackend *backend, CalObjType type);
static CalComponent *cal_backend_file_get_object_component (CalBackend *backend, const char *uid);
static char *cal_backend_file_get_timezone_object (CalBackend *backend, const char *tzid);
static GList *cal_backend_file_get_uids (CalBackend *backend, CalObjType type);
@@ -108,8 +111,9 @@ static GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_file_get_alarms_
time_t start, time_t end, gboolean *object_found);
static CalBackendResult cal_backend_file_update_objects (CalBackend *backend,
- const char *calobj);
-static CalBackendResult cal_backend_file_remove_object (CalBackend *backend, const char *uid);
+ const char *calobj,
+ CalObjModType mod);
+static CalBackendResult cal_backend_file_remove_object (CalBackend *backend, const char *uid, CalObjModType mod);
static CalBackendSendResult cal_backend_file_send_object (CalBackend *backend,
const char *calobj, gchar **new_calobj,
@@ -175,12 +179,15 @@ cal_backend_file_class_init (CalBackendFileClass *class)
backend_class->get_uri = cal_backend_file_get_uri;
backend_class->is_read_only = cal_backend_file_is_read_only;
backend_class->get_email_address = cal_backend_file_get_email_address;
+ backend_class->get_alarm_email_address = cal_backend_file_get_alarm_email_address;
+ backend_class->get_static_capabilities = cal_backend_file_get_static_capabilities;
backend_class->open = cal_backend_file_open;
backend_class->is_loaded = cal_backend_file_is_loaded;
backend_class->get_query = cal_backend_file_get_query;
backend_class->get_mode = cal_backend_file_get_mode;
backend_class->set_mode = cal_backend_file_set_mode;
backend_class->get_n_objects = cal_backend_file_get_n_objects;
+ backend_class->get_default_object = cal_backend_file_get_default_object;
backend_class->get_object_component = cal_backend_file_get_object_component;
backend_class->get_timezone_object = cal_backend_file_get_timezone_object;
backend_class->get_uids = cal_backend_file_get_uids;
@@ -237,7 +244,7 @@ save (CalBackendFile *cbfile)
CalBackendFilePrivate *priv;
GnomeVFSURI *uri, *backup_uri;
GnomeVFSHandle *handle = NULL;
- GnomeVFSResult result;
+ GnomeVFSResult result = GNOME_VFS_ERROR_BAD_FILE;
GnomeVFSFileSize out;
gchar *tmp, *backup_uristr;
char *buf;
@@ -433,6 +440,21 @@ cal_backend_file_get_email_address (CalBackend *backend)
return NULL;
}
+static const char *
+cal_backend_file_get_alarm_email_address (CalBackend *backend)
+{
+ /* A file backend has no particular email address associated
+ * with it (although that would be a useful feature some day).
+ */
+ return NULL;
+}
+
+static const char *
+cal_backend_file_get_static_capabilities (CalBackend *backend)
+{
+ return "no-email-alarms";
+}
+
/* Idle handler; we save the calendar since it is dirty */
static gboolean
save_idle (gpointer data)
@@ -870,6 +892,40 @@ cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type)
return n;
}
+static char *
+cal_backend_file_get_default_object (CalBackend *backend, CalObjType type)
+{
+ CalBackendFile *cbfile;
+ CalBackendFilePrivate *priv;
+ CalComponent *comp;
+ char *calobj;
+
+ cbfile = CAL_BACKEND_FILE (backend);
+ priv = cbfile->priv;
+
+ comp = cal_component_new ();
+
+ switch (type) {
+ case CALOBJ_TYPE_EVENT:
+ cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
+ break;
+ case CALOBJ_TYPE_TODO:
+ cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO);
+ break;
+ case CALOBJ_TYPE_JOURNAL:
+ cal_component_set_new_vtype (comp, CAL_COMPONENT_JOURNAL);
+ break;
+ default:
+ g_object_unref (comp);
+ return NULL;
+ }
+
+ calobj = cal_component_get_as_string (comp);
+ g_object_unref (comp);
+
+ return calobj;
+}
+
/* Get_object_component handler for the file backend */
static CalComponent *
cal_backend_file_get_object_component (CalBackend *backend, const char *uid)
@@ -1393,6 +1449,8 @@ cal_backend_file_get_alarms_in_range (CalBackend *backend,
GSList *comp_alarms;
GSList *l;
int i;
+ CalAlarmAction omit[] = {-1};
+
GNOME_Evolution_Calendar_CalComponentAlarmsSeq *seq;
cbfile = CAL_BACKEND_FILE (backend);
@@ -1408,11 +1466,11 @@ cal_backend_file_get_alarms_in_range (CalBackend *backend,
n_comp_alarms = 0;
comp_alarms = NULL;
- n_comp_alarms += cal_util_generate_alarms_for_list (priv->events, start, end,
+ n_comp_alarms += cal_util_generate_alarms_for_list (priv->events, start, end, omit,
&comp_alarms, resolve_tzid,
priv->icalcomp,
priv->default_zone);
- n_comp_alarms += cal_util_generate_alarms_for_list (priv->todos, start, end,
+ n_comp_alarms += cal_util_generate_alarms_for_list (priv->todos, start, end, omit,
&comp_alarms, resolve_tzid,
priv->icalcomp,
priv->default_zone);
@@ -1455,6 +1513,7 @@ cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid,
char *comp_str;
GNOME_Evolution_Calendar_CalComponentAlarms *corba_alarms;
CalComponentAlarms *alarms;
+ CalAlarmAction omit[] = {-1};
cbfile = CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
@@ -1480,7 +1539,7 @@ cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid,
corba_alarms->calobj = CORBA_string_dup (comp_str);
g_free (comp_str);
- alarms = cal_util_generate_alarms_for_comp (comp, start, end, resolve_tzid, priv->icalcomp, priv->default_zone);
+ alarms = cal_util_generate_alarms_for_comp (comp, start, end, omit, resolve_tzid, priv->icalcomp, priv->default_zone);
if (alarms) {
cal_backend_util_fill_alarm_instances_seq (&corba_alarms->alarms, alarms->alarms);
cal_component_alarms_free (alarms);
@@ -1562,7 +1621,7 @@ cal_backend_file_cancel_object (CalBackendFile *cbfile,
/* Update_objects handler for the file backend. */
static CalBackendResult
-cal_backend_file_update_objects (CalBackend *backend, const char *calobj)
+cal_backend_file_update_objects (CalBackend *backend, const char *calobj, CalObjModType mod)
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
@@ -1667,7 +1726,7 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj)
/* Remove_object handler for the file backend */
static CalBackendResult
-cal_backend_file_remove_object (CalBackend *backend, const char *uid)
+cal_backend_file_remove_object (CalBackend *backend, const char *uid, CalObjModType mod)
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index f738399380..5e2074bad1 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -175,6 +175,8 @@ cal_backend_class_init (CalBackendClass *class)
class->get_uri = NULL;
class->get_email_address = NULL;
+ class->get_alarm_email_address = NULL;
+ class->get_static_capabilities = NULL;
class->open = NULL;
class->is_loaded = NULL;
class->is_read_only = NULL;
@@ -281,6 +283,26 @@ cal_backend_get_email_address (CalBackend *backend)
return (* CLASS (backend)->get_email_address) (backend);
}
+const char *
+cal_backend_get_alarm_email_address (CalBackend *backend)
+{
+ g_return_val_if_fail (backend != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
+
+ g_assert (CLASS (backend)->get_alarm_email_address != NULL);
+ return (* CLASS (backend)->get_alarm_email_address) (backend);
+}
+
+const char *
+cal_backend_get_static_capabilities (CalBackend *backend)
+{
+ g_return_val_if_fail (backend != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
+
+ g_assert (CLASS (backend)->get_static_capabilities != NULL);
+ return (* CLASS (backend)->get_static_capabilities) (backend);
+}
+
/* Callback used when a Cal is destroyed */
static void
cal_destroy_cb (gpointer data, GObject *where_cal_was)
@@ -501,6 +523,16 @@ get_object (CalBackend *backend, const char *uid)
return cal_component_get_as_string (comp);
}
+char *
+cal_backend_get_default_object (CalBackend *backend, CalObjType type)
+{
+ g_return_val_if_fail (backend != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
+
+ g_assert (CLASS (backend)->get_default_object != NULL);
+ return (* CLASS (backend)->get_default_object) (backend, type);
+}
+
/**
* cal_backend_get_object:
* @backend: A calendar backend.
@@ -795,14 +827,14 @@ cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid,
* result of the operation.
**/
CalBackendResult
-cal_backend_update_objects (CalBackend *backend, const char *calobj)
+cal_backend_update_objects (CalBackend *backend, const char *calobj, CalObjModType mod)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (calobj != NULL, FALSE);
g_assert (CLASS (backend)->update_objects != NULL);
- return (* CLASS (backend)->update_objects) (backend, calobj);
+ return (* CLASS (backend)->update_objects) (backend, calobj, mod);
}
/**
@@ -817,14 +849,14 @@ cal_backend_update_objects (CalBackend *backend, const char *calobj)
* result of the operation.
**/
CalBackendResult
-cal_backend_remove_object (CalBackend *backend, const char *uid)
+cal_backend_remove_object (CalBackend *backend, const char *uid, CalObjModType mod)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
g_assert (CLASS (backend)->remove_object != NULL);
- return (* CLASS (backend)->remove_object) (backend, uid);
+ return (* CLASS (backend)->remove_object) (backend, uid, mod);
}
CalBackendSendResult
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index b20e04bdb6..ee11354252 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -96,7 +96,10 @@ struct _CalBackendClass {
const char *(* get_uri) (CalBackend *backend);
const char *(* get_email_address) (CalBackend *backend);
-
+ const char *(* get_alarm_email_address) (CalBackend *backend);
+
+ const char *(* get_static_capabilities) (CalBackend *backend);
+
CalBackendOpenStatus (* open) (CalBackend *backend, const char *uristr,
gboolean only_if_exists);
@@ -113,6 +116,7 @@ struct _CalBackendClass {
/* General object acquirement and information related virtual methods */
int (* get_n_objects) (CalBackend *backend, CalObjType type);
+ char *(* get_default_object) (CalBackend *backend, CalObjType type);
char *(* get_object) (CalBackend *backend, const char *uid);
CalComponent *(* get_object_component) (CalBackend *backend, const char *uid);
char *(* get_timezone_object) (CalBackend *backend, const char *tzid);
@@ -134,8 +138,8 @@ struct _CalBackendClass {
time_t start, time_t end, gboolean *object_found);
/* Object manipulation virtual methods */
- CalBackendResult (* update_objects) (CalBackend *backend, const char *calobj);
- CalBackendResult (* remove_object) (CalBackend *backend, const char *uid);
+ CalBackendResult (* update_objects) (CalBackend *backend, const char *calobj, CalObjModType mod);
+ CalBackendResult (* remove_object) (CalBackend *backend, const char *uid, CalObjModType mod);
CalBackendSendResult (* send_object) (CalBackend *backend, const char *calobj, char **new_calobj,
GNOME_Evolution_Calendar_UserList **user_list,
@@ -152,6 +156,9 @@ GType cal_backend_get_type (void);
const char *cal_backend_get_uri (CalBackend *backend);
const char *cal_backend_get_email_address (CalBackend *backend);
+const char *cal_backend_get_alarm_email_address (CalBackend *backend);
+
+const char *cal_backend_get_static_capabilities (CalBackend *backend);
void cal_backend_add_cal (CalBackend *backend, Cal *cal);
@@ -171,6 +178,8 @@ void cal_backend_set_mode (CalBackend *backend, CalMode mode);
int cal_backend_get_n_objects (CalBackend *backend, CalObjType type);
+char *cal_backend_get_default_object (CalBackend *backend, CalObjType type);
+
char *cal_backend_get_object (CalBackend *backend, const char *uid);
CalComponent *cal_backend_get_object_component (CalBackend *backend, const char *uid);
@@ -200,9 +209,9 @@ GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_get_alarms_for_object (
CalBackendGetAlarmsForObjectResult *result);
-CalBackendResult cal_backend_update_objects (CalBackend *backend, const char *calobj);
+CalBackendResult cal_backend_update_objects (CalBackend *backend, const char *calobj, CalObjModType mod);
-CalBackendResult cal_backend_remove_object (CalBackend *backend, const char *uid);
+CalBackendResult cal_backend_remove_object (CalBackend *backend, const char *uid, CalObjModType mod);
CalBackendSendResult cal_backend_send_object (CalBackend *backend, const char *calobj, char **new_calobj,
GNOME_Evolution_Calendar_UserList **user_list,
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 0d089b5096..8171af4922 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -101,6 +101,49 @@ impl_Cal_getEmailAddress (PortableServer_Servant servant,
return str_email_address_copy;
}
+
+/* Cal::get_alarm_email_address method */
+static CORBA_char *
+impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ const char *str_email_address;
+ CORBA_char *str_email_address_copy;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ str_email_address = cal_backend_get_alarm_email_address (priv->backend);
+ if (str_email_address == NULL) {
+ bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_NotFound);
+ return CORBA_OBJECT_NIL;
+ }
+
+ str_email_address_copy = CORBA_string_dup (str_email_address);
+
+ return str_email_address_copy;
+}
+
+/* Cal::getSchedulingInformation method */
+static CORBA_char *
+impl_Cal_getStaticCapabilities (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ const char *cap;
+ CORBA_char *cap_copy;
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ cap = cal_backend_get_static_capabilities (priv->backend);
+ cap_copy = CORBA_string_dup (cap == NULL ? "" : cap);
+
+ return cap_copy;
+}
/* Converts a calendar object type from its CORBA representation to our own
* representation.
@@ -147,6 +190,27 @@ impl_Cal_countObjects (PortableServer_Servant servant,
return n;
}
+static GNOME_Evolution_Calendar_CalObj
+impl_Cal_getDefaultObject (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjType type,
+ CORBA_Environment *ev)
+{
+ Cal *cal;
+ CalPrivate *priv;
+ GNOME_Evolution_Calendar_CalObj calobj_copy;
+ char *calobj;
+
+
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ calobj = cal_backend_get_default_object (priv->backend, type);
+ calobj_copy = CORBA_string_dup (calobj);
+ g_free (calobj);
+
+ return calobj_copy;
+}
+
/* Cal::getObject method */
static GNOME_Evolution_Calendar_CalObj
impl_Cal_getObject (PortableServer_Servant servant,
@@ -291,6 +355,7 @@ build_fb_seq (GList *obj_list)
seq = GNOME_Evolution_Calendar_CalObjSeq__alloc ();
CORBA_sequence_set_release (seq, TRUE);
+ seq->_maximum = n;
seq->_length = n;
seq->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n);
@@ -428,6 +493,7 @@ impl_Cal_getAlarmsForObject (PortableServer_Servant servant,
static void
impl_Cal_updateObjects (PortableServer_Servant servant,
const CORBA_char *calobj,
+ const GNOME_Evolution_Calendar_CalObjModType mod,
CORBA_Environment *ev)
{
Cal *cal;
@@ -437,7 +503,7 @@ impl_Cal_updateObjects (PortableServer_Servant servant,
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
- result = cal_backend_update_objects (priv->backend, calobj);
+ result = cal_backend_update_objects (priv->backend, calobj, mod);
switch (result) {
case CAL_BACKEND_RESULT_INVALID_OBJECT :
bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject);
@@ -457,6 +523,7 @@ impl_Cal_updateObjects (PortableServer_Servant servant,
static void
impl_Cal_removeObject (PortableServer_Servant servant,
const CORBA_char *uid,
+ const GNOME_Evolution_Calendar_CalObjModType mod,
CORBA_Environment *ev)
{
Cal *cal;
@@ -466,7 +533,7 @@ impl_Cal_removeObject (PortableServer_Servant servant,
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
- result = cal_backend_remove_object (priv->backend, uid);
+ result = cal_backend_remove_object (priv->backend, uid, mod);
switch (result) {
case CAL_BACKEND_RESULT_INVALID_OBJECT :
bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject);
@@ -749,8 +816,11 @@ cal_class_init (CalClass *klass)
epv->_get_uri = impl_Cal_get_uri;
epv->isReadOnly = impl_Cal_isReadOnly;
epv->getEmailAddress = impl_Cal_getEmailAddress;
+ epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress;
+ epv->getStaticCapabilities = impl_Cal_getStaticCapabilities;
epv->setMode = impl_Cal_setMode;
epv->countObjects = impl_Cal_countObjects;
+ epv->getDefaultObject = impl_Cal_getDefaultObject;
epv->getObject = impl_Cal_getObject;
epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
epv->getTimezoneObject = impl_Cal_getTimezoneObject;