+2005-07-11 Chenthill Palanisamy <pchenthill@novell.com>
+
+ * idl/Evolution-DataServer-Calendar.idl: Interface for sending a request
+ for an attachment and notifying the attachment list.
+ * libecal/e-cal-listener.[ch]: (impl_notifyAttachmentListRequested),
+ (e_cal_listener_class_init): listens to the backend and Notifies the client.
+ * libecal/e-cal.[ch]: (cal_attachment_list_cb), (e_cal_init),
+ (e_cal_get_attachments_for_comp): API to retrieve the attachment
+ list for a calendar item.
+ * libedata-cal/e-cal-backend-sync.[ch]:
+ (e_cal_backend_sync_get_attachment_list),
+ (_e_cal_backend_get_attachment_list),
+ (e_cal_backend_sync_class_init): Methods to send request to corresponding
+ backends and send notifications to the client.
+ * libedata-cal/e-cal-backend.c:
+ (e_cal_backend_get_attachment_list):
+ * libedata-cal/e-cal-backend.h: Calls the sync implemention.
+ * libedata-cal/e-data-cal.[ch]: (impl_Cal_getAttachmentList),
+ (e_data_cal_class_init), (e_data_cal_notify_object_list),
+ (e_data_cal_notify_attachment_list): Implements the request and the
+ sends notification to the listener.
+ * backends/file/e-cal-backend-file.c:
+ (e_cal_backend_file_get_attachment_list),
+ (e_cal_backend_file_class_init):
+ * backends/groupwise/e-cal-backend-groupwise.c:
+ (e_cal_backend_groupwise_get_attachment_list),
+ (e_cal_backend_groupwise_class_init): Virtual methods to get
+ the attachment for a calendar object.
+
+
2005-07-10 Sankar P <psankar@novell.com>
* libecal/e-cal.c: (open_calendar)
return GNOME_Evolution_Calendar_Success;
}
+/* Gets the list of attachments */
+static ECalBackendSyncStatus
+e_cal_backend_file_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **list)
+{
+
+ /* TODO implement the function */
+ return GNOME_Evolution_Calendar_Success;
+}
+
/* get_query handler for the file backend */
static void
e_cal_backend_file_start_query (ECalBackend *backend, EDataCalView *query)
sync_class->get_default_object_sync = e_cal_backend_file_get_default_object;
sync_class->get_object_sync = e_cal_backend_file_get_object;
sync_class->get_object_list_sync = e_cal_backend_file_get_object_list;
+ sync_class->get_attachment_list_sync = e_cal_backend_file_get_attachment_list;
sync_class->get_timezone_sync = e_cal_backend_file_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_file_add_timezone;
sync_class->set_default_timezone_sync = e_cal_backend_file_set_default_timezone;
return GNOME_Evolution_Calendar_Success;
}
+/* Gets the list of attachments */
+static ECalBackendSyncStatus
+e_cal_backend_groupwise_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **list)
+{
+ /* TODO implement the function */
+ return GNOME_Evolution_Calendar_Success;
+}
+
/* Get_objects_in_range handler for the groupwise backend */
static ECalBackendSyncStatus
e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend, EDataCal *cal, const char *sexp, GList **objects)
sync_class->get_default_object_sync = e_cal_backend_groupwise_get_default_object;
sync_class->get_object_sync = e_cal_backend_groupwise_get_object;
sync_class->get_object_list_sync = e_cal_backend_groupwise_get_object_list;
+ sync_class->get_attachment_list_sync = e_cal_backend_groupwise_get_attachment_list;
sync_class->get_timezone_sync = e_cal_backend_groupwise_get_timezone;
sync_class->add_timezone_sync = e_cal_backend_groupwise_add_timezone;
sync_class->set_default_timezone_sync = e_cal_backend_groupwise_set_default_timezone;
oneway void modifyObject (in CalObj calobj, in CalObjModType mod);
oneway void removeObject (in CalObjUID uid, in CalRecurID rid, in CalObjModType mod);
+ /* get attachment list for an object */
+ oneway void getAttachmentList (in CalObjUID uid, in CalRecurID rid);
+
/* Methods for getting/sending iCalendar VCALENDARS via iTip/iMip */
oneway void receiveObjects (in CalObj calobj);
oneway void sendObjects (in CalObj calobj);
oneway void notifyChanges (in CallStatus status, in CalObjChangeSeq changes);
oneway void notifyFreeBusy (in CallStatus status, in CalObjSeq freebusy);
+ oneway void notifyAttachmentListRequested (in CallStatus status, in stringlist attachments);
+
/* Called from a Calendar when the mode is changed */
oneway void notifyCalSetMode (in SetModeStatus status, in CalMode mode);
DEFAULT_OBJECT,
OBJECT,
OBJECT_LIST,
+ ATTACHMENT_LIST,
GET_TIMEZONE,
ADD_TIMEZONE,
SET_DEFAULT_TIMEZONE,
g_list_free (object_list);
}
+static void
+impl_notifyAttachmentListRequested (PortableServer_Servant servant,
+ const GNOME_Evolution_Calendar_CallStatus status,
+ const GNOME_Evolution_Calendar_stringlist *attachments,
+ CORBA_Environment *ev)
+{
+ ECalListener *listener;
+ ECalListenerPrivate *priv;
+ GSList *a_list = NULL;
+ int i;
+
+ listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
+ priv = listener->priv;
+
+ if (!priv->notify)
+ return;
+
+ for (i = 0; i < attachments->_length; i++) {
+ a_list = g_slist_append (a_list, g_strdup (attachments->_buffer[i]));
+ }
+
+ g_signal_emit (G_OBJECT (listener), signals[ATTACHMENT_LIST], 0, convert_status (status), a_list);
+
+ g_slist_foreach (a_list, (GFunc) g_free, NULL);
+ g_slist_free (a_list);
+}
+
static void
impl_notifyTimezoneRequested (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CallStatus status,
klass->epv.notifyDefaultObjectRequested = impl_notifyDefaultObjectRequested;
klass->epv.notifyObjectRequested = impl_notifyObjectRequested;
klass->epv.notifyObjectListRequested = impl_notifyObjectListRequested;
+ klass->epv.notifyAttachmentListRequested = impl_notifyAttachmentListRequested;
klass->epv.notifyTimezoneRequested = impl_notifyTimezoneRequested;
klass->epv.notifyTimezoneAdded = impl_notifyTimezoneAdded;
klass->epv.notifyDefaultTimezoneSet = impl_notifyDefaultTimezoneSet;
G_STRUCT_OFFSET (ECalListenerClass, object_list),
NULL, NULL,
e_cal_marshal_VOID__INT_POINTER,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER);
+ signals[ATTACHMENT_LIST] =
+ g_signal_new ("attachment_list",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalListenerClass, attachment_list),
+ NULL, NULL,
+ e_cal_marshal_VOID__INT_POINTER,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER);
signals[GET_TIMEZONE] =
g_signal_new ("get_timezone",
void (*object) (ECalListener *listener, ECalendarStatus status, const char *object);
void (*object_list) (ECalListener *listener, ECalendarStatus status, GList **objects);
+ void (*attachment_list) (ECalListener *listener, ECalendarStatus status, GSList **objects);
+
void (*get_timezone) (ECalListener *listener, ECalendarStatus status, const char *object);
void (*add_timezone) (ECalListener *listener, ECalendarStatus status, const char *tzid);
void (*set_default_timezone) (ECalListener *listener, ECalendarStatus status, const char *tzid);
char *uid;
GList *list;
+ GSList *slist;
gboolean bool;
char *string;
}
static void
+cal_attachment_list_cb (ECalListener *listener, ECalendarStatus status, GSList *attachments, gpointer data)
+{
+ ECal *ecal = data;
+ ECalendarOp *op;
+
+ op = e_calendar_get_op (ecal);
+
+ if (op == NULL) {
+ g_warning (G_STRLOC ": Cannot find operation ");
+ return;
+ }
+
+ g_mutex_lock (op->mutex);
+
+ op->status = status;
+ op->slist = g_slist_copy (attachments);
+
+ g_cond_signal (op->cond);
+
+ g_mutex_unlock (op->mutex);
+}
+
+static void
cal_get_timezone_cb (ECalListener *listener, ECalendarStatus status, const char *object, gpointer data)
{
ECal *ecal = data;
g_signal_connect (G_OBJECT (priv->listener), "default_object", G_CALLBACK (cal_default_object_requested_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "object", G_CALLBACK (cal_object_requested_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "object_list", G_CALLBACK (cal_object_list_cb), ecal);
+ g_signal_connect (G_OBJECT (priv->listener), "attachment_list", G_CALLBACK (cal_attachment_list_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "get_timezone", G_CALLBACK (cal_get_timezone_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "add_timezone", G_CALLBACK (cal_add_timezone_cb), ecal);
g_signal_connect (G_OBJECT (priv->listener), "set_default_timezone", G_CALLBACK (cal_set_default_timezone_cb), ecal);
}
/**
+ * e_cal_get_attachments_for_comp:
+ * @ecal: A calendar client.
+ * @uid: Unique identifier for a calendar component.
+ * @rid: Recurrence identifier.
+ * @list: Return the list of attachment uris.
+ * @error: Placeholder for error information.
+ *
+ * Queries a calendar for a calendar component object based on its unique
+ * identifier and gets the attachments for the component.
+ *
+ * Return value: TRUE if the call was successful, FALSE otherwise.
+ **/
+gboolean
+e_cal_get_attachments_for_comp (ECal *ecal, const char *uid, const char *rid, GSList **list, GError **error)
+{
+ ECalPrivate *priv;
+ CORBA_Environment ev;
+ ECalendarStatus status;
+ ECalendarOp *our_op;
+
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+
+ priv = ecal->priv;
+
+ g_mutex_lock (ecal->priv->mutex);
+
+ if (ecal->priv->load_state != E_CAL_LOAD_LOADED) {
+ g_mutex_unlock (ecal->priv->mutex);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error);
+ }
+
+ if (ecal->priv->current_op != NULL) {
+ g_mutex_unlock (ecal->priv->mutex);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error);
+ }
+
+ our_op = e_calendar_new_op (ecal);
+
+ g_mutex_lock (our_op->mutex);
+
+ g_mutex_unlock (ecal->priv->mutex);
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Calendar_Cal_getAttachmentList (priv->cal, uid, rid ? rid : "", &ev);
+ if (BONOBO_EX (&ev)) {
+ e_calendar_remove_op (ecal, our_op);
+ g_mutex_unlock (our_op->mutex);
+ e_calendar_free_op (our_op);
+
+ CORBA_exception_free (&ev);
+
+ g_warning (G_STRLOC ": Unable to contact backend");
+
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
+ }
+
+ CORBA_exception_free (&ev);
+
+ /* wait for something to happen (both cancellation and a
+ successful response will notity us via our cv */
+ g_cond_wait (our_op->cond, our_op->mutex);
+
+ status = our_op->status;
+ if (status != E_CALENDAR_STATUS_OK){
+ *list = NULL;
+ } else {
+ *list = our_op->slist;
+ }
+
+ e_calendar_remove_op (ecal, our_op);
+ g_mutex_unlock (our_op->mutex);
+ e_calendar_free_op (our_op);
+
+ E_CALENDAR_CHECK_STATUS (status, error);
+}
+
+/**
* e_cal_get_object:
* @ecal: A calendar client.
* @uid: Unique identifier for a calendar component.
gboolean e_cal_get_sources (ESourceList **sources, ECalSourceType type, GError **error);
const char * e_cal_get_local_attachment_store (ECal *ecal);
gboolean e_cal_get_recurrences_no_master (ECal *ecal);
+gboolean e_cal_get_attachments_for_comp (ECal *ecal, const char *uid, const char *rid, GSList **list, GError **error);
+
G_END_DECLS
#endif
}
/**
+ * e_cal_backend_sync_get_attachment_list:
+ * @backend: An ECalBackendSync object.
+ * @cal: An EDataCal object.
+ * @uid: Unique id of the calendar object.
+ * @rid: Recurrence id of the calendar object.
+ * @attachments: Placeholder for list of returned attachment uris.
+ *
+ * Calls the get_attachment_list method on the given backend.
+ *
+ * Return value: Status code.
+ */
+ECalBackendSyncStatus
+e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **attachments)
+{
+ ECalBackendSyncStatus status;
+
+ g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+ g_return_val_if_fail (attachments, GNOME_Evolution_Calendar_OtherError);
+
+ LOCK_WRAPPER (get_attachment_list_sync, (backend, cal, uid, rid, attachments));
+
+ return status;
+}
+
+/**
* e_cal_backend_sync_get_timezone:
* @backend: An ECalBackendSync object.
* @cal: An EDataCal object.
}
static void
+_e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid)
+{
+ ECalBackendSyncStatus status;
+ GSList *list = NULL;
+
+ status = e_cal_backend_sync_get_attachment_list (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &list);
+
+ e_data_cal_notify_attachment_list (cal, status, list);
+
+ g_slist_foreach (list, (GFunc) g_free, NULL);
+ g_free (list);
+}
+
+static void
_e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const char *sexp)
{
ECalBackendSyncStatus status;
backend_class->get_default_object = _e_cal_backend_get_default_object;
backend_class->get_object = _e_cal_backend_get_object;
backend_class->get_object_list = _e_cal_backend_get_object_list;
+ backend_class->get_attachment_list = _e_cal_backend_get_attachment_list;
backend_class->get_timezone = _e_cal_backend_get_timezone;
backend_class->add_timezone = _e_cal_backend_add_timezone;
backend_class->set_default_timezone = _e_cal_backend_set_default_timezone;
ECalBackendSyncStatus (*get_object_sync) (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, char **object);
ECalBackendSyncStatus (*get_object_list_sync) (ECalBackendSync *backend, EDataCal *cal, const char *sexp, GList **objects);
+ ECalBackendSyncStatus (*get_attachment_list_sync) (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **attachments);
+
+
ECalBackendSyncStatus (*get_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object);
ECalBackendSyncStatus (*add_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tzobj);
ECalBackendSyncStatus (*set_default_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tzid);
CalObjModType mod,
char **old_object,
char **object);
+ECalBackendSyncStatus e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend,
+ EDataCal *cal,
+ const char *uid,
+ const char *rid,
+ GSList **attachments);
+
ECalBackendSyncStatus e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *auid);
ECalBackendSyncStatus e_cal_backend_sync_receive_objects (ECalBackendSync *backend,
}
/**
+ * e_cal_backend_get_attachment_list:
+ * @backend: A calendar backend.
+ * @cal: An #EDataCal object.
+ * @uid: Unique identifier for a calendar object.
+ * @rid: ID for the object's recurrence to get.
+ *
+ * Queries a calendar backend for attachments present in a calendar object based
+ * on its unique identifier and its recurrence ID (if a recurrent appointment).
+ */
+void
+e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid)
+{
+ g_return_if_fail (backend != NULL);
+ g_return_if_fail (E_IS_CAL_BACKEND (backend));
+ g_return_if_fail (uid != NULL);
+
+ g_assert (CLASS (backend)->get_object != NULL);
+ (* CLASS (backend)->get_attachment_list) (backend, cal, uid, rid);
+}
+
+/**
* e_cal_backend_get_free_busy:
* @backend: A calendar backend.
* @cal: An #EDataCal object.
void (* get_object) (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
void (* get_object_list) (ECalBackend *backend, EDataCal *cal, const char *sexp);
+ void (* get_attachment_list) (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
+
/* Timezone related virtual methods */
void (* get_timezone) (ECalBackend *backend, EDataCal *cal, const char *tzid);
void (* add_timezone) (ECalBackend *backend, EDataCal *cal, const char *object);
void e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
void e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const char *sexp);
+void e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
+
gboolean e_cal_backend_is_loaded (ECalBackend *backend);
void e_cal_backend_start_query (ECalBackend *backend, EDataCalView *query);
e_cal_backend_get_object_list (priv->backend, cal, sexp);
}
+/* Cal::getAttachmentList method */
+static void
+impl_Cal_getAttachmentList (PortableServer_Servant servant,
+ const CORBA_char *uid,
+ const CORBA_char *rid,
+ CORBA_Environment *ev)
+{
+ EDataCal *cal;
+ EDataCalPrivate *priv;
+
+ cal = E_DATA_CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
+
+ e_cal_backend_get_attachment_list (priv->backend, cal, uid, rid);
+}
+
/* Cal::getChanges method */
static void
impl_Cal_getChanges (PortableServer_Servant servant,
epv->addTimezone = impl_Cal_addTimezone;
epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
epv->getObjectList = impl_Cal_getObjectList;
+ epv->getAttachmentList = impl_Cal_getAttachmentList;
epv->getChanges = impl_Cal_getChanges;
epv->getFreeBusy = impl_Cal_getFreeBusy;
epv->discardAlarm = impl_Cal_discardAlarm;
}
/**
+ * e_data_cal_notify_attachment_list:
+ * @cal: A calendar client interface.
+ * @status: Status code.
+ * @attachments: List of retrieved attachment uri's.
+ *
+ * Notifies listeners of the completion of the get_attachment_list method call.
+ */
+void
+e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GSList *attachments)
+{
+ EDataCalPrivate *priv;
+ CORBA_Environment ev;
+ GNOME_Evolution_Calendar_stringlist seq;
+ GSList *l;
+ int i;
+
+ g_return_if_fail (cal != NULL);
+ g_return_if_fail (E_IS_DATA_CAL (cal));
+
+ priv = cal->priv;
+ g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
+
+ CORBA_exception_init (&ev);
+
+ seq._maximum = g_slist_length (attachments);
+ seq._length = 0;
+ seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
+
+ for (l = attachments, i = 0; l; l = l->next, i++) {
+ seq._buffer[i] = CORBA_string_dup (l->data);
+ seq._length++;
+ }
+
+ GNOME_Evolution_Calendar_CalListener_notifyAttachmentListRequested (priv->listener, status, &seq, &ev);
+
+ if (BONOBO_EX (&ev))
+ g_message (G_STRLOC ": could not notify the listener of object list");
+
+ CORBA_exception_free (&ev);
+
+ CORBA_free(seq._buffer);
+}
+
+/**
* e_data_cal_notify_query:
* @cal: A calendar client interface.
* @status: Status code.
void e_data_cal_notify_error (EDataCal *cal, const char *message);
+void e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GSList *objects);
G_END_DECLS