From f448e25de6f7d9bb1dfe943a9f82d4e4da747c5d Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Mon, 10 Jan 2005 02:36:41 +0000 Subject: handle calendar:// uris 2005-01-09 JP Rosevear * gui/calendar-component.c (impl_handleURI): handle calendar:// uris svn path=/trunk/; revision=28303 --- calendar/gui/calendar-component.c | 66 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'calendar/gui/calendar-component.c') diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 2c408c94e7..942325a234 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "e-pub-utils.h" #include "e-calendar-view.h" #include "calendar-config-keys.h" @@ -617,9 +618,71 @@ conf_changed_callback (GConfClient *client, e_pub_publish (TRUE); } +/* Evolution::Component CORBA methods. */ +static void +impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environment *ev) +{ + CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant)); + CalendarComponentPrivate *priv; + priv = calendar_component->priv; -/* Evolution::Component CORBA methods. */ + if (!strncmp (uri, "calendar:", 9)) { + EUri *euri = e_uri_new (uri); + const char *p; + char *header, *content; + size_t len, clen; + time_t start = -1, end = -1; + + p = euri->query; + while (*p) { + len = strcspn (p, "=&"); + + /* If it's malformed, give up. */ + if (p[len] != '=') + break; + + header = (char *) p; + header[len] = '\0'; + p += len + 1; + + clen = strcspn (p, "&"); + + content = g_strndup (p, clen); + + if (!g_ascii_strcasecmp (header, "startdate")) { + start = time_from_isodate (content); + } else if (!g_ascii_strcasecmp (header, "enddate")) { + end = time_from_isodate (content); + } + + g_free (content); + + p += clen; + if (*p == '&') { + p++; + if (!strcmp (p, "amp;")) + p += 4; + } + } + + if (start != -1) { + GList *l; + + if (end == -1) + end = start; + + l = g_list_last (priv->views); + if (l) { + CalendarComponentView *view = l->data; + + gnome_calendar_set_selected_time_range (view->calendar, start, end); + } + } + + e_uri_free (euri); + } +} static void impl_upgradeFromVersion (PortableServer_Servant servant, @@ -1378,6 +1441,7 @@ calendar_component_class_init (CalendarComponentClass *class) epv->createControls = impl_createControls; epv->_get_userCreatableItems = impl__get_userCreatableItems; epv->requestCreateItem = impl_requestCreateItem; + epv->handleURI = impl_handleURI; object_class->dispose = impl_dispose; object_class->finalize = impl_finalize; -- cgit