Hi,
Here is a patch that checks if VEVENTS and/or VTODO components are
present in the webcal and adds the source to the appropriate group.
Please let me know if this is ok.
This patch requires:
http://lists.ximian.com/archives/public/evolution-patches/2004-March/004832.html
Thanks,
Jon
------------------------------------------------------------------------
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-webcal/ChangeLog,v
retrieving revision 1.6
diff -p -u -r1.6 ChangeLog
--- ChangeLog 25 Mar 2004 00:14:22 -0000 1.6
+++ ChangeLog 25 Mar 2004 03:17:22 -0000
@@ -1,3 +1,10 @@
+2004-03-24 William Jon McCann <mccann jhu edu>
+
+ * src/evolution-webcal-notify.[ch] (e_webcal_query_user):
+ * src/evolution-webcal-main.c (e_webcal_has_kind, e_webcal_load):
+ Determine if tasks and/or events are present and add to appropriate
+ source group.
+
2004-03-24 Rodney Dawes <dobey ximian com>
* src/e-webcal-main.c (e_webcal_load): Use a SoupUri to get at the
Index: src/evolution-webcal-main.c
===================================================================
RCS file: /cvs/gnome/evolution-webcal/src/evolution-webcal-main.c,v
retrieving revision 1.4
diff -p -u -r1.4 evolution-webcal-main.c
--- src/evolution-webcal-main.c 25 Mar 2004 00:14:23 -0000 1.4
+++ src/evolution-webcal-main.c 25 Mar 2004 03:17:22 -0000
@@ -26,12 +26,21 @@ static void e_webcal_open_cal_http (cons
static SoupSession * session;
-static void e_webcal_load (const gchar * body, const gchar * uri) {
+static gboolean e_webcal_has_kind (icalcomponent * comp, icalcomponent_kind kind)
+{
+ g_return_val_if_fail (comp != NULL, FALSE);
+
+ return (icalcomponent_get_first_component (comp, kind) != NULL);
+}
+
+static void e_webcal_load (const gchar * body, const gchar * uri)
+{
icalcomponent * comp;
icalproperty * prop;
gint i, numprops;
gchar * tmpname;
const gchar * name = NULL, * desc = NULL;
+ gboolean has_events, has_tasks;
comp = icalparser_parse_string (body);
if (comp == NULL) {
@@ -79,9 +88,12 @@ static void e_webcal_load (const gchar *
}
}
+ has_tasks = e_webcal_has_kind (comp, ICAL_VTODO_COMPONENT);
+ has_events = e_webcal_has_kind (comp, ICAL_VEVENT_COMPONENT);
+
icalcomponent_free (comp);
- e_webcal_query_user (name, desc, uri);
+ e_webcal_query_user (name, desc, uri, has_events, has_tasks);
bonobo_main_quit ();
}
Index: src/evolution-webcal-notify.c
===================================================================
RCS file: /cvs/gnome/evolution-webcal/src/evolution-webcal-notify.c,v
retrieving revision 1.5
diff -p -u -r1.5 evolution-webcal-notify.c
--- src/evolution-webcal-notify.c 25 Mar 2004 00:14:23 -0000 1.5
+++ src/evolution-webcal-notify.c 25 Mar 2004 03:17:23 -0000
@@ -22,6 +22,10 @@
#include "evolution-webcal-notify.h"
+#define WEBCAL_BASE_URI "webcal://"
+#define CALENDAR_SOURCES_KEY "/apps/evolution/calendar/sources"
+#define TASKS_SOURCES_KEY "/apps/evolution/tasks/sources"
+
typedef struct {
GtkWidget * dialog;
GtkWidget * image;
@@ -165,7 +169,8 @@ void e_webcal_display_error (const gchar
}
void e_webcal_query_user (const gchar * name, const gchar * desc,
- const gchar * caluri) {
+ const gchar * caluri,
+ gboolean has_events, gboolean has_tasks) {
EIcalShareDialog * dialog;
GtkObject * spinadj;
GtkWidget * tspinb, * toption;
@@ -177,20 +182,42 @@ void e_webcal_query_user (const gchar *
gchar * icofile, * mrkname, * ref_str;
gint ref_timeout, ref_multi;
ESource * source;
- ESourceGroup * group;
- ESourceList * sources;
+ ESourceGroup * events_group = NULL;
+ ESourceGroup * tasks_group = NULL;
+ ESourceList * events_sources, * tasks_sources;
GSList * l;
- sources = e_source_list_new_for_gconf_default ("/apps/evolution/calendar/sources");
+ events_sources = e_source_list_new_for_gconf_default (CALENDAR_SOURCES_KEY);
+
+ for (l = e_source_list_peek_groups (events_sources); l != NULL; l = l->next) {
+ if (!strcmp (e_source_group_peek_base_uri (l->data), WEBCAL_BASE_URI)) {
+ events_group = l->data;
+ break;
+ }
+ }
+
+ if (!events_group) {
+ /* Create the Webcal source group */
+ events_group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
+ e_source_list_add_group (events_sources, events_group, -1);
+ }
- for (l = e_source_list_peek_groups (sources); l != NULL; l = l->next) {
- group = l->data;
+ tasks_sources = e_source_list_new_for_gconf_default (TASKS_SOURCES_KEY);
- if (!strcmp (e_source_group_peek_base_uri (group), "webcal://")) {
+ for (l = e_source_list_peek_groups (tasks_sources); l != NULL; l = l->next) {
+ if (!strcmp (e_source_group_peek_base_uri (l->data), WEBCAL_BASE_URI)) {
+ tasks_group = l->data;
break;
}
}
+ if (!tasks_group) {
+ /* Create the Webcal source group */
+ tasks_group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
+ e_source_list_add_group (tasks_sources, tasks_group, -1);
+ }
+
+
tmpuri = soup_uri_new (caluri);
tmpname = g_path_get_basename (tmpuri->path);
@@ -390,20 +417,28 @@ void e_webcal_query_user (const gchar *
e_source_set_property (source, "refresh", ref_str);
g_free (ref_str);
- if (!strncmp (caluri, "webcal://", 9)) {
+ if (!strncmp (caluri, WEBCAL_BASE_URI, 9)) {
e_source_set_relative_uri (source, caluri + 9);
} else if (!strncmp (caluri, "http://", 7)) {
e_source_set_relative_uri (source, caluri + 7);
}
- e_source_group_add_source (group, source, -1);
- e_source_list_sync (sources, NULL);
+ if (has_events) {
+ e_source_group_add_source (events_group, source, -1);
+ e_source_list_sync (events_sources, NULL);
+ }
+
+ if (has_tasks) {
+ e_source_group_add_source (tasks_group, source, -1);
+ e_source_list_sync (tasks_sources, NULL);
+ }
/* We fall through to the CANCEL/default cases to handle all the unreffing
and widget destruction */
case GTK_RESPONSE_CANCEL:
default:
- g_object_unref (sources);
+ g_object_unref (events_sources);
+ g_object_unref (tasks_sources);
g_object_unref (source);
g_object_unref (dialog->theme);
Index: src/evolution-webcal-notify.h
===================================================================
RCS file: /cvs/gnome/evolution-webcal/src/evolution-webcal-notify.h,v
retrieving revision 1.3
diff -p -u -r1.3 evolution-webcal-notify.h
--- src/evolution-webcal-notify.h 25 Mar 2004 00:14:23 -0000 1.3
+++ src/evolution-webcal-notify.h 25 Mar 2004 03:17:23 -0000
@@ -29,7 +29,9 @@
void e_webcal_display_error (const gchar * title, const gchar * message,
GtkWidget * parent);
+
void e_webcal_query_user (const gchar * name, const gchar * desc,
- const gchar * caluri);
+ const gchar * caluri,
+ gboolean has_event, gboolean has_todo);
#endif