diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2001-09-19 04:16:39 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2001-09-19 04:16:39 +0800 |
commit | 2b78b5294a6a047a971446595c9e7f5f32f583a2 (patch) | |
tree | 6b74cd7376bb1ab8024871a5e2b059d669ebf6d8 /calendar/cal-client/cal-client.c | |
parent | 3e079da9b69b8f5c47c79bcbb269ac17cc094c6e (diff) | |
download | gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.gz gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.bz2 gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.lz gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.xz gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.zst gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.zip |
new class for managing multiple calendars, with an API very similar to the
2001-09-18 Rodrigo Moya <rodrigo@ximian.com>
* cal-client/cal-client-multi.[ch]: new class for managing multiple
calendars, with an API very similar to the CalClient one,
for ease of transition from one to the other
* gui/component-factory.c (xfer_folder, remove_folder, create_folder):
reworked to be able to manage folders for any calendar backend, and
not only the file: one
2001-09-18 Rodrigo Moya <rodrigo@ximian.com>
* idl/evolution-calendar.idl: changed signature for the getFreeBusy
method, to return a sequence of CalObj's, and added sequence of users
as a new parameter to that method
* cal-client/cal-client.c (cal_client_get_free_busy): adapted to new
IDL method signature, by adding a new "GList *users" parameter, for
callers to be able to specify a list of users
* pcs/cal-backend.[ch] (cal_backend_get_free_busy):
* pcs/cal-backend-file.c (cal_backend_file_get_free_busy): add the
"GList *users" parameter. In cal_backend_file_get_free_busy, call
lookup_component to get the CalComponent for each uid, instead
of calling cal_backend_get_object, which meant converting the
component to a string and then parsing it again.
* cal-client/client-test.c (cal_opened_cb):
* gui/e-itip-control.c (send_freebusy):
* gui/calendar-commands.c (publish_freebusy_cmd): adapted to
new getFreeBusy method signature
svn path=/trunk/; revision=12951
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r-- | calendar/cal-client/cal-client.c | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index f0519057d6..e0a37159f5 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -1224,56 +1224,86 @@ cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t star /** * cal_client_get_free_busy * @client:: A calendar client. + * @users: List of users to retrieve free/busy information for. * @start: Start time for query. * @end: End time for query. * - * Gets free/busy information from the calendar server + * Gets free/busy information from the calendar server. + * + * Returns: a GList of VFREEBUSY CalComponents */ -CalClientGetStatus -cal_client_get_free_busy (CalClient *client, time_t start, time_t end, CalComponent **comp) +GList * +cal_client_get_free_busy (CalClient *client, GList *users, + time_t start, time_t end) { CalClientPrivate *priv; CORBA_Environment ev; - CORBA_char *calobj; - icalcomponent *icalcomp; + GNOME_Evolution_Calendar_UserList *corba_list; + GNOME_Evolution_Calendar_CalObjSeq *calobj_list; + GList *l; + GList *comp_list = NULL; + int len, i; - g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND); - g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_NOT_FOUND); + g_return_val_if_fail (client != NULL, NULL); + g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); priv = client->priv; - g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_GET_NOT_FOUND); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); - g_return_val_if_fail (start != -1 && end != -1, CAL_CLIENT_GET_NOT_FOUND); - g_return_val_if_fail (start <= end, CAL_CLIENT_GET_NOT_FOUND); - g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND); + g_return_val_if_fail (start != -1 && end != -1, NULL); + g_return_val_if_fail (start <= end, NULL); - *comp = NULL; + /* create the CORBA user list to be passed to the backend */ + len = g_list_length (users); + corba_list = GNOME_Evolution_Calendar_UserList__alloc (); + CORBA_sequence_set_release (corba_list, TRUE); + corba_list->_length = len; + corba_list->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (len); + + for (l = g_list_first (users), i = 0; l; l = l->next, i++) + corba_list->_buffer[i] = CORBA_string_dup ((CORBA_char *) l->data); + + /* call the method on the backend */ CORBA_exception_init (&ev); - calobj = GNOME_Evolution_Calendar_Cal_getFreeBusy (priv->cal, start, end, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { + calobj_list = GNOME_Evolution_Calendar_Cal_getFreeBusy (priv->cal, corba_list, + start, end, &ev); + CORBA_free (corba_list); + if (ev._major != CORBA_NO_EXCEPTION || !calobj_list) { g_message ("cal_client_get_free_busy(): could not get the objects"); CORBA_exception_free (&ev); - return CAL_CLIENT_GET_NOT_FOUND; + return NULL; } - CORBA_exception_free (&ev); - icalcomp = icalparser_parse_string (calobj); - CORBA_free (calobj); - if (!icalcomp) { - return CAL_CLIENT_GET_SYNTAX_ERROR; - } + for (i = 0; i < calobj_list->_length; i++) { + CalComponent *comp; + icalcomponent *icalcomp; + icalcomponent_kind kind; - *comp = cal_component_new (); - if (!cal_component_set_icalcomponent (*comp, icalcomp)) { - icalcomponent_free (icalcomp); - gtk_object_unref (GTK_OBJECT (*comp)); - *comp = NULL; - return CAL_CLIENT_GET_SYNTAX_ERROR; + icalcomp = icalparser_parse_string (calobj_list->_buffer[i]); + if (!icalcomp) + continue; + + kind = icalcomponent_isa (icalcomp); + if (kind == ICAL_VFREEBUSY_COMPONENT) { + comp = cal_component_new (); + if (!cal_component_set_icalcomponent (comp, icalcomp)) { + icalcomponent_free (icalcomp); + gtk_object_unref (GTK_OBJECT (comp)); + continue; + } + + comp_list = g_list_append (comp_list, comp); + } + else + icalcomponent_free (icalcomp); } - return CAL_CLIENT_GET_SUCCESS; + CORBA_exception_free (&ev); + CORBA_free (calobj_list); + + return comp_list; } /* Callback used when an object is updated and we must update the copy we have */ |