diff options
author | Hans Petter Jansson <hpj@ximian.com> | 2003-11-01 02:03:20 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2003-11-01 02:03:20 +0800 |
commit | dd09d630872427be423ac416340192a24e2d037e (patch) | |
tree | ee2a40b507516d82d5615ae04280d81604508354 /calendar/gui | |
parent | a7ac69cdc61b193cbc62fbe908652cebf1ee8f2d (diff) | |
download | gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.tar gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.tar.gz gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.tar.bz2 gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.tar.lz gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.tar.xz gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.tar.zst gsoc2013-evolution-dd09d630872427be423ac416340192a24e2d037e.zip |
Add the webcal source group.
2003-10-31 Hans Petter Jansson <hpj@ximian.com>
* gui/calendar-component.c (calendar_component_init): Add the webcal
source group.
* gui/dialogs/new-calendar.c (print_uri_noproto): Implement.
(group_is_remote): Implement.
(create_new_source_with_group): Implement webcal case.
(new_calendar_dialog): Get optional location from dialog.
* gui/dialogs/new-calendar.glade: Add location entry.
* pcs/Makefile.am: Build http backend.
* pcs/cal-backend-http.[ch]: Add skeleton based on cal-backend-file.
svn path=/trunk/; revision=23153
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar-component.c | 6 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-calendar.c | 152 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-calendar.glade | 102 |
3 files changed, 215 insertions, 45 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index e929e0db24..c9ed088e1c 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -355,7 +355,7 @@ calendar_component_init (CalendarComponent *component) ESource *source; char *base_uri, *new_dir; - /* create the source group */ + /* create the local source group */ base_uri = g_build_filename (g_get_home_dir (), "/.evolution/calendar/local/OnThisComputer/", NULL); @@ -381,6 +381,10 @@ calendar_component_init (CalendarComponent *component) } g_free (base_uri); + + /* create the remote source group */ + group = e_source_group_new (_("On The Web"), "webcal://"); + e_source_list_add_group (priv->source_list, group, -1); } component->priv = priv; diff --git a/calendar/gui/dialogs/new-calendar.c b/calendar/gui/dialogs/new-calendar.c index aa647b55b2..6f6b979b49 100644 --- a/calendar/gui/dialogs/new-calendar.c +++ b/calendar/gui/dialogs/new-calendar.c @@ -22,6 +22,7 @@ #include <config.h> #endif +#include <string.h> #include <bonobo/bonobo-i18n.h> #include <gtk/gtkdialog.h> #include <gtk/gtkentry.h> @@ -32,15 +33,69 @@ #include <glade/glade.h> #include <e-util/e-dialog-utils.h> #include <e-util/e-source-list.h> +#include <e-util/e-url.h> #include "new-calendar.h" +static gchar * +print_uri_noproto (EUri *uri) +{ + gchar *uri_noproto; + + if (uri->port != 0) + uri_noproto = g_strdup_printf ( + "%s%s%s%s%s%s%s:%d%s%s%s", + uri->user ? uri->user : "", + uri->authmech ? ";auth=" : "", + uri->authmech ? uri->authmech : "", + uri->passwd ? ":" : "", + uri->passwd ? uri->passwd : "", + uri->user ? "@" : "", + uri->host ? uri->host : "", + uri->port, + uri->path ? uri->path : "", + uri->query ? "?" : "", + uri->query ? uri->query : ""); + else + uri_noproto = g_strdup_printf ( + "%s%s%s%s%s%s%s%s%s%s", + uri->user ? uri->user : "", + uri->authmech ? ";auth=" : "", + uri->authmech ? uri->authmech : "", + uri->passwd ? ":" : "", + uri->passwd ? uri->passwd : "", + uri->user ? "@" : "", + uri->host ? uri->host : "", + uri->path ? uri->path : "", + uri->query ? "?" : "", + uri->query ? uri->query : ""); + + return uri_noproto; +} + +static gboolean +group_is_remote (ESourceGroup *group) +{ + EUri *uri; + gboolean is_remote = FALSE; + + uri = e_uri_new (e_source_group_peek_base_uri (group)); + if (!uri) + return FALSE; + + if (uri->protocol && strcmp (uri->protocol, "file")) + is_remote = TRUE; + + e_uri_free (uri); + return is_remote; +} + static gboolean create_new_source_with_group (GtkWindow *parent, ESourceGroup *group, - const char *source_name) + const char *source_name, + const char *source_location) { ESource *source; - char *new_dir; if (e_source_group_peek_source_by_name (group, source_name)) { e_notice (parent, GTK_MESSAGE_ERROR, @@ -49,21 +104,82 @@ create_new_source_with_group (GtkWindow *parent, return FALSE; } - /* create the new source */ - new_dir = g_build_filename (e_source_group_peek_base_uri (group), - source_name, NULL); - if (e_mkdir_hier (new_dir, 0700)) { + if (group_is_remote (group)) { + EUri *uri; + gchar *relative_uri; + char *cache_dir; + + /* Remote source */ + + if (!source_location || !strlen (source_location)) { + e_notice (parent, GTK_MESSAGE_ERROR, + _("The group '%s' is remote. You must specify a location " + "to get the calendar from"), + e_source_group_peek_name (group)); + return FALSE; + } + + uri = e_uri_new (source_location); + if (!uri) { + e_notice (parent, GTK_MESSAGE_ERROR, + _("The source location '%s' is not well-formed."), + source_location); + return FALSE; + } + + /* Make sure we're in agreement with the protocol. Note that EUri sets it + * to 'file' if none was specified in the input URI. We don't want to + * silently translate an explicit file:// into http:// though. */ + if (uri->protocol && + strcmp (uri->protocol, "http") && + strcmp (uri->protocol, "webcal")) { + e_uri_free (uri); + e_notice (parent, GTK_MESSAGE_ERROR, + _("The source location '%s' is not a webcal source."), + source_location); + return FALSE; + } + + /* Our relative_uri is everything but protocol, which is supplied by parent group */ + relative_uri = print_uri_noproto (uri); + e_uri_free (uri); + + /* Set up cache dir */ + cache_dir = g_build_filename (g_get_home_dir (), + "/.evolution/calendar/webcal/", + source_name, NULL); + if (e_mkdir_hier (cache_dir, 0700)) { + g_free (relative_uri); + g_free (cache_dir); + e_notice (parent, GTK_MESSAGE_ERROR, + _("Could not create cache for new calendar")); + return FALSE; + } + + /* Create source */ + source = e_source_new (source_name, relative_uri); + + g_free (relative_uri); + g_free (cache_dir); + } else { + char *new_dir; + + /* Local source */ + + new_dir = g_build_filename (e_source_group_peek_base_uri (group), + source_name, NULL); + if (e_mkdir_hier (new_dir, 0700)) { + g_free (new_dir); + e_notice (parent, GTK_MESSAGE_ERROR, + _("Could not create directory for new calendar")); + return FALSE; + } + + source = e_source_new (source_name, source_name); g_free (new_dir); - e_notice (parent, GTK_MESSAGE_ERROR, - _("Could not create directory for new calendar")); - return FALSE; } - source = e_source_new (source_name, source_name); e_source_group_add_source (group, source, -1); - - g_free (new_dir); - return TRUE; } @@ -75,7 +191,7 @@ create_new_source_with_group (GtkWindow *parent, gboolean new_calendar_dialog (GtkWindow *parent) { - GtkWidget *dialog, *cal_group, *cal_name; + GtkWidget *dialog, *cal_group, *cal_name, *cal_location; GladeXML *xml; ESourceList *source_list; GConfClient *gconf_client; @@ -92,6 +208,7 @@ new_calendar_dialog (GtkWindow *parent) dialog = glade_xml_get_widget (xml, "new-calendar-dialog"); cal_group = glade_xml_get_widget (xml, "calendar-group"); cal_name = glade_xml_get_widget (xml, "calendar-name"); + cal_location = glade_xml_get_widget (xml, "calendar-location"); /* set up widgets */ gconf_client = gconf_client_get_default (); @@ -120,14 +237,17 @@ new_calendar_dialog (GtkWindow *parent) /* run the dialog */ do { if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { - char *name; + const char *name; + const char *location; name = gtk_entry_get_text (GTK_ENTRY (cal_name)); + location = gtk_entry_get_text (GTK_ENTRY (cal_location)); sl = g_slist_nth (groups, gtk_option_menu_get_history (GTK_OPTION_MENU (cal_group))); if (sl) { if (create_new_source_with_group (GTK_WINDOW (dialog), sl->data, - name)) + name, + location)) retry = FALSE; } else { e_notice (dialog, GTK_MESSAGE_ERROR, diff --git a/calendar/gui/dialogs/new-calendar.glade b/calendar/gui/dialogs/new-calendar.glade index 42717a87a8..0a136ed7c8 100644 --- a/calendar/gui/dialogs/new-calendar.glade +++ b/calendar/gui/dialogs/new-calendar.glade @@ -2,7 +2,6 @@ <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> -<requires lib="gnome"/> <widget class="GtkDialog" id="new-calendar-dialog"> <property name="border_width">12</property> @@ -61,7 +60,7 @@ <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="n_rows">3</property> + <property name="n_rows">4</property> <property name="n_columns">3</property> <property name="homogeneous">False</property> <property name="row_spacing">6</property> @@ -93,31 +92,6 @@ </child> <child> - <widget class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes">Calendar Name</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_padding">6</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> <widget class="GtkOptionMenu" id="calendar-group"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -179,9 +153,81 @@ <property name="y_options"></property> </packing> </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Calendar Name</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_padding">6</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="calendar-source-label"> + <property name="visible">True</property> + <property name="label" translatable="yes">Calendar Location</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_padding">6</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="calendar-location"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char" translatable="yes">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_padding">6</property> + <property name="y_options"></property> + </packing> + </child> </widget> <packing> - <property name="padding">0</property> + <property name="padding">4</property> <property name="expand">True</property> <property name="fill">True</property> </packing> |