diff options
author | Seth Alves <alves@src.gnome.org> | 2000-06-08 03:59:48 +0800 |
---|---|---|
committer | Seth Alves <alves@src.gnome.org> | 2000-06-08 03:59:48 +0800 |
commit | 35c55267f22a30cccd78e1f45efdd2e4b353fd94 (patch) | |
tree | 880acbc384eec12469bb2e8a41eae9c7dd997164 | |
parent | f0e9a692608d04c14f2060f32b18c91bf8b2982d (diff) | |
download | gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.tar gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.tar.gz gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.tar.bz2 gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.tar.lz gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.tar.xz gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.tar.zst gsoc2013-evolution-35c55267f22a30cccd78e1f45efdd2e4b353fd94.zip |
instead of returning a text representation, decode the text and return an
* cal-client/cal-client.c (cal_client_get_object): instead of
returning a text representation, decode the text and return an
iCalObject. Also added CalClientGetStatus which indicates
success or type of failure.
* cal-util/calobj.c (ical_object_find_in_string): #ifed out
ical_object_find_in_string since it is unused now.
* cal-client/client-test.c (list_uids): track get_object change
* gui/calendar-commands.c (calendar_iterate): same
* gui/e-day-view.c (e_day_view_update_event): same
* gui/e-week-view.c (e_week_view_update_event): same
* gui/print.c (print_day_details): same
(print_day_summary): same
(print_todo_details): same
* gui/gnome-cal.c (trigger_alarm_cb): same
* gui/gncal-todo.c (gncal_todo_update): same
svn path=/trunk/; revision=3463
-rw-r--r-- | calendar/ChangeLog | 20 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 61 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.h | 11 | ||||
-rw-r--r-- | calendar/cal-client/client-test.c | 24 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 6 | ||||
-rw-r--r-- | calendar/cal-util/calobj.h | 2 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 29 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 13 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 13 | ||||
-rw-r--r-- | calendar/gui/gncal-todo.c | 22 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 22 | ||||
-rw-r--r-- | calendar/gui/print.c | 69 |
12 files changed, 151 insertions, 141 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 97302ab6c3..940b367c53 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,23 @@ +2000-06-07 Seth Alves <alves@hungry.com> + + * cal-client/cal-client.c (cal_client_get_object): instead of + returning a text representation, decode the text and return an + iCalObject. Also added CalClientGetStatus which indicates + success or type of failure. + + * cal-util/calobj.c (ical_object_find_in_string): #ifed out + ical_object_find_in_string since it is unused now. + + * cal-client/client-test.c (list_uids): track get_object change + * gui/calendar-commands.c (calendar_iterate): same + * gui/e-day-view.c (e_day_view_update_event): same + * gui/e-week-view.c (e_week_view_update_event): same + * gui/print.c (print_day_details): same + (print_day_summary): same + (print_todo_details): same + * gui/gnome-cal.c (trigger_alarm_cb): same + * gui/gncal-todo.c (gncal_todo_update): same + 2000-06-06 Seth Alves <alves@hungry.com> * cal-util/icalendar.c, icalendar-save.c: fixed a bunch of problems diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 97dda85acb..23ab9bc003 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -32,6 +32,9 @@ #include "cal-client.h" #include "cal-listener.h" +#include "cal-util/icalendar-save.h" +#include "cal-util/icalendar.h" + /* Loading state for the calendar client */ @@ -559,41 +562,73 @@ cal_client_create_calendar (CalClient *client, const char *str_uri) * sought object, or NULL if no object had the specified UID. A complete * calendar is returned because you also need the timezone data. **/ -char * -cal_client_get_object (CalClient *client, const char *uid) +CalClientGetStatus cal_client_get_object (CalClient *client, + const char *uid, + iCalObject **ico) { CalClientPrivate *priv; CORBA_Environment ev; Evolution_Calendar_CalObj calobj; - char *retval; + char *obj_str = NULL; - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); + icalcomponent* comp = NULL; + icalcomponent *subcomp; + iCalObject *ical; + + g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_SYNTAX_ERROR); + g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_SYNTAX_ERROR); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); + g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, CAL_CLIENT_GET_SYNTAX_ERROR); - g_return_val_if_fail (uid != NULL, NULL); + g_return_val_if_fail (uid != NULL, CAL_CLIENT_GET_SYNTAX_ERROR); - retval = NULL; + obj_str = NULL; CORBA_exception_init (&ev); calobj = Evolution_Calendar_Cal_get_object (priv->cal, uid, &ev); if (ev._major == CORBA_USER_EXCEPTION && strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0) - goto out; + goto decode; else if (ev._major != CORBA_NO_EXCEPTION) { g_message ("cal_client_get_object(): could not get the object"); - goto out; + goto decode; } - retval = g_strdup (calobj); + obj_str = g_strdup (calobj); CORBA_free (calobj); - out: + decode: CORBA_exception_free (&ev); - return retval; + + /* convert the string into an iCalObject */ + (*ico) = NULL; + if (obj_str == NULL) return CAL_CLIENT_GET_SYNTAX_ERROR; + comp = icalparser_parse_string (obj_str); + free (obj_str); + if (!comp) return CAL_CLIENT_GET_SYNTAX_ERROR; + subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT); + if (!subcomp) return CAL_CLIENT_GET_SYNTAX_ERROR; + + while (subcomp) { + ical = ical_object_create_from_icalcomponent (subcomp); + if (ical->type != ICAL_EVENT && + ical->type != ICAL_TODO && + ical->type != ICAL_JOURNAL) { + g_warning ("Skipping unsupported iCalendar component"); + } else { + if (strcasecmp (ical->uid, uid) == 0) { + (*ico) = ical; + (*ico)->ref_count = 1; + return CAL_CLIENT_GET_SUCCESS; + } + } + subcomp = icalcomponent_get_next_component (comp, + ICAL_ANY_COMPONENT); + } + + return CAL_CLIENT_GET_NOT_FOUND; } /** diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index 12cbcc7c87..755b005f74 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -47,6 +47,13 @@ typedef enum { CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED } CalClientLoadStatus; +typedef enum { + CAL_CLIENT_GET_SUCCESS, + CAL_CLIENT_GET_NOT_FOUND, + CAL_CLIENT_GET_SYNTAX_ERROR +} CalClientGetStatus; + + struct _CalClient { GtkObject object; @@ -74,7 +81,9 @@ CalClient *cal_client_new (void); gboolean cal_client_load_calendar (CalClient *client, const char *str_uri); gboolean cal_client_create_calendar (CalClient *client, const char *str_uri); -char *cal_client_get_object (CalClient *client, const char *uid); +CalClientGetStatus cal_client_get_object (CalClient *client, + const char *uid, + iCalObject **ico); GList *cal_client_get_uids (CalClient *client, CalObjType type); diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c index f4b847eb65..f8741f4539 100644 --- a/calendar/cal-client/client-test.c +++ b/calendar/cal-client/client-test.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ #include <config.h> #include <bonobo.h> #include <gnome.h> @@ -48,17 +49,22 @@ list_uids (gpointer data) for (l = uids; l; l = l->next) { char *uid; - char *calobj; + iCalObject *ico; + CalClientGetStatus status; uid = l->data; - calobj = cal_client_get_object (client, uid); - - printf ("------------------------------\n%s", calobj); - printf ("------------------------------\n"); - - cal_client_update_object (client, uid, calobj); - - g_free (calobj); + status = cal_client_get_object (client, uid, &ico); + + if (status == CAL_CLIENT_GET_SUCCESS) { + printf ("------------------------------\n"); + dump_icalobject (ico); + printf ("------------------------------\n"); + } else { + printf ("FAILED: %d\n", status); + } + + // cal_client_update_object (client, uid, calobj); + // g_free (calobj); } } diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 3c1e10689b..8c87aafe32 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -26,6 +26,7 @@ static gint compare_exdates (gconstpointer a, gconstpointer b); static void ical_object_normalize_summary (iCalObject *ico); +static void list_free (GList *list); @@ -1552,6 +1553,8 @@ alarm_compute_offset (CalendarAlarm *a) return a->offset; } + +#if 0 /** * ical_object_find_in_string: * @uid: Unique identifier of the sought object. @@ -1674,7 +1677,9 @@ ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **i return status; #endif /* 0 */ } +#endif /* 0 */ +#if 0 /* Creates a VObject with the base information of a calendar */ static VObject * get_calendar_base_vobject (void) @@ -1703,6 +1708,7 @@ get_calendar_base_vobject (void) return vobj; } +#endif /* 0 */ /** * ical_object_to_string: diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h index 57514250e5..9ac1964e7f 100644 --- a/calendar/cal-util/calobj.h +++ b/calendar/cal-util/calobj.h @@ -250,7 +250,7 @@ typedef enum { CAL_OBJ_FIND_NOT_FOUND } CalObjFindStatus; -CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico); +//CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico); char *ical_object_to_string (iCalObject *ico); diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 49bb023875..0a4d12f93a 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -383,15 +383,15 @@ show_month_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path gtk_widget_grab_focus (gcal->month_view); } +#if 0 static void show_year_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) { -#if 0 GnomeCalendar *gcal = GNOME_CALENDAR (user_data); gnome_calendar_set_view (gcal, "yearview"); gtk_widget_grab_focus (gcal->year_view); -#endif } +#endif static void new_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) @@ -893,9 +893,9 @@ calendar_iterate (GnomeCalendar *cal, { GList *l, *cois; GHashTable *cache; - CalObjFindStatus status; + CalClientGetStatus status; CalObjInstance *coi; - char *uid, *obj_string; + char *uid; iCalObject *ico; cois = cal_client_get_events_in_range (cal->client, start, end); @@ -910,26 +910,17 @@ calendar_iterate (GnomeCalendar *cal, ico = g_hash_table_lookup (cache, uid); if (!ico) { - obj_string = cal_client_get_object (cal->client, uid); - - status = ical_object_find_in_string (uid, obj_string, - &ico); - g_free (obj_string); + status = cal_client_get_object (cal->client, uid, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: g_hash_table_insert (cache, ico->uid, ico); - break; - case CAL_OBJ_FIND_SYNTAX_ERROR: - printf ("calendar_iterate: syntax error uid=%s\n", - uid); - ico = NULL; + case CAL_CLIENT_GET_SYNTAX_ERROR: + printf ("calendar_iterate: syntax error uid=%s\n", uid); break; - case CAL_OBJ_FIND_NOT_FOUND: - printf ("calendar_iterate: obj not found uid=%s\n", - uid); - ico = NULL; + case CAL_CLIENT_GET_NOT_FOUND: + printf ("calendar_iterate: obj not found uid=%s\n", uid); break; } } diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index fde159dab1..8508d08a56 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -1085,9 +1085,8 @@ e_day_view_update_event (EDayView *day_view, const gchar *uid) { EDayViewEvent *event; - gchar *obj_string; iCalObject *ico; - CalObjFindStatus status; + CalClientGetStatus status; gint day, event_num; g_return_if_fail (E_IS_DAY_VIEW (day_view)); @@ -1107,18 +1106,16 @@ e_day_view_update_event (EDayView *day_view, return; /* Get the event from the server. */ - obj_string = cal_client_get_object (day_view->calendar->client, uid); - status = ical_object_find_in_string (uid, obj_string, &ico); - g_free (obj_string); + status = cal_client_get_object (day_view->calendar->client, uid, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: /* Do nothing. */ break; - case CAL_OBJ_FIND_SYNTAX_ERROR: + case CAL_CLIENT_GET_SYNTAX_ERROR: g_warning ("syntax error uid=%s\n", uid); return; - case CAL_OBJ_FIND_NOT_FOUND: + case CAL_CLIENT_GET_NOT_FOUND: g_warning ("obj not found uid=%s\n", uid); return; } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index c09d3fc541..7f5eb7b15f 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -966,9 +966,8 @@ e_week_view_update_event (EWeekView *week_view, { EWeekViewEvent *event; gint event_num, num_days; - gchar *obj_string; iCalObject *ico; - CalObjFindStatus status; + CalClientGetStatus status; g_return_if_fail (E_IS_WEEK_VIEW (week_view)); @@ -982,18 +981,16 @@ e_week_view_update_event (EWeekView *week_view, return; /* Get the event from the server. */ - obj_string = cal_client_get_object (week_view->calendar->client, uid); - status = ical_object_find_in_string (uid, obj_string, &ico); - g_free (obj_string); + status = cal_client_get_object (week_view->calendar->client, uid, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: /* Do nothing. */ break; - case CAL_OBJ_FIND_SYNTAX_ERROR: + case CAL_CLIENT_GET_SYNTAX_ERROR: g_warning ("syntax error uid=%s\n", uid); return; - case CAL_OBJ_FIND_NOT_FOUND: + case CAL_CLIENT_GET_NOT_FOUND: g_warning ("obj not found uid=%s\n", uid); return; } diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c index 1f7fd3bb59..e3c25b9e53 100644 --- a/calendar/gui/gncal-todo.c +++ b/calendar/gui/gncal-todo.c @@ -800,8 +800,7 @@ void gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags) { GSList *current_list; - - CalObjFindStatus st; + CalClientGetStatus status; GList *l, *uids; g_return_if_fail (todo != NULL); @@ -864,15 +863,16 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags) CALOBJ_TYPE_TODO); for (l = uids; l; l = l->next){ char *uid = l->data; - char *obj_string = - cal_client_get_object (todo->calendar->client, uid); - iCalObject *obj = NULL; - - st = ical_object_find_in_string (uid, obj_string, &obj); - g_free (obj_string); - - insert_in_clist (todo, obj); - ical_object_unref (obj); + iCalObject *obj; + + status = cal_client_get_object (todo->calendar->client, uid, &ico); + + if (status == CAL_CLIENT_GET_SUCCESS) { + insert_in_clist (todo, obj); + ical_object_unref (obj); + } +#warning "FIX ME" + /* else? */ g_free (uid); } g_list_free (uids); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index e6e7082666..6f05c7ec60 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -619,9 +619,8 @@ static void trigger_alarm_cb (gpointer alarm_id, time_t trigger, gpointer data) { struct trigger_alarm_closure *c; - char *str_ico; iCalObject *ico; - CalObjFindStatus status; + CalClientGetStatus status; ObjectAlarms *oa; GList *l; @@ -629,27 +628,16 @@ trigger_alarm_cb (gpointer alarm_id, time_t trigger, gpointer data) /* Fetch the object */ - str_ico = cal_client_get_object (c->gcal->client, c->uid); - if (!str_ico) { - g_message ("trigger_alarm_cb(): could not fetch object `%s'", c->uid); - return; - } - - status = ical_object_find_in_string (c->uid, str_ico, &ico); - g_free (str_ico); + status = cal_client_get_object (c->gcal->client, c->uid, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: /* Go on */ break; - - case CAL_OBJ_FIND_SYNTAX_ERROR: + case CAL_CLIENT_GET_SYNTAX_ERROR: + case CAL_CLIENT_GET_NOT_FOUND: g_message ("trigger_alarm_cb(): syntax error in fetched object"); return; - - case CAL_OBJ_FIND_NOT_FOUND: - g_message ("trigger_alarm_cb(): could not find fetched object"); - return; } g_assert (ico != NULL); diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 436221ebc6..3b4f2c4a18 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -567,33 +567,20 @@ print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, for (i = 0, l = events; l != NULL; l = l->next, i++) { CalObjInstance *coi; - char *str_ico; iCalObject *ico; - CalObjFindStatus status; + CalClientGetStatus status; coi = l->data; - str_ico = cal_client_get_object (gcal->client, coi->uid); - - if (!str_ico) { - /* The object could have disappeared from the server */ - continue; - } - - status = ical_object_find_in_string (coi->uid, str_ico, &ico); - g_free (str_ico); + status = cal_client_get_object (gcal->client, coi->uid, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: /* Go on */ break; - - case CAL_OBJ_FIND_SYNTAX_ERROR: + case CAL_CLIENT_GET_SYNTAX_ERROR: + case CAL_CLIENT_GET_NOT_FOUND: g_message ("print_day_details(): syntax error in fetched object"); continue; - - case CAL_OBJ_FIND_NOT_FOUND: - g_message ("print_day_details(): could not find fetched object"); - continue; } y = top - (top - bottom) * (coi->start - start) / (end - start) - 1; @@ -676,33 +663,20 @@ print_day_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, for (i=0, l = events; l != NULL; l = l->next, i++) { CalObjInstance *coi; - char *str_ico; iCalObject *ico; - CalObjFindStatus status; + CalClientGetStatus status; coi = l->data; - str_ico = cal_client_get_object (gcal->client, coi->uid); - - if (!str_ico) { - /* The object could have disappeared from the server */ - continue; - } - - status = ical_object_find_in_string (coi->uid, str_ico, &ico); - g_free (str_ico); + status = cal_client_get_object (gcal->client, coi->uid, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: /* Go on */ break; - - case CAL_OBJ_FIND_SYNTAX_ERROR: + case CAL_CLIENT_GET_SYNTAX_ERROR: + case CAL_CLIENT_GET_NOT_FOUND: g_message ("print_day_summary(): syntax error in fetched object"); continue; - - case CAL_OBJ_FIND_NOT_FOUND: - g_message ("print_day_summary(): could not find fetched object"); - continue; } x = left + incsmall; @@ -898,32 +872,19 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t start, ti yend = bottom - 2; for (i = 0, l = todos; l != NULL; l = l->next, i++) { - char *str_ico; iCalObject *ico; - CalObjFindStatus status; - - str_ico = cal_client_get_object (gcal->client, l->data); - - if (!str_ico) { - /* The object could have disappeared from the server */ - continue; - } + CalClientGetStatus status; - status = ical_object_find_in_string (l->data, str_ico, &ico); - g_free (str_ico); + status = cal_client_get_object (gcal->client, l->data, &ico); switch (status) { - case CAL_OBJ_FIND_SUCCESS: + case CAL_CLIENT_GET_SUCCESS: /* Go on */ break; - - case CAL_OBJ_FIND_SYNTAX_ERROR: + case CAL_CLIENT_GET_NOT_FOUND: + case CAL_CLIENT_GET_SYNTAX_ERROR: g_message ("print_todo_details(): syntax error in fetched object"); continue; - - case CAL_OBJ_FIND_NOT_FOUND: - g_message ("print_todo_details(): could not find fetched object"); - continue; } x = left; |