aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client/cal-client.c
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-06-08 03:59:48 +0800
committerSeth Alves <alves@src.gnome.org>2000-06-08 03:59:48 +0800
commit35c55267f22a30cccd78e1f45efdd2e4b353fd94 (patch)
tree880acbc384eec12469bb2e8a41eae9c7dd997164 /calendar/cal-client/cal-client.c
parentf0e9a692608d04c14f2060f32b18c91bf8b2982d (diff)
downloadgsoc2013-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
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r--calendar/cal-client/cal-client.c61
1 files changed, 48 insertions, 13 deletions
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;
}
/**