aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/caldav/caldav-source.c365
-rw-r--r--plugins/calendar-file/Makefile.am1
-rw-r--r--plugins/calendar-file/calendar-file.c134
-rw-r--r--plugins/calendar-http/Makefile.am1
-rw-r--r--plugins/calendar-http/calendar-http.c413
-rw-r--r--plugins/calendar-weather/calendar-weather.c209
-rw-r--r--plugins/default-source/Makefile.am1
-rw-r--r--plugins/default-source/default-source.c67
-rw-r--r--plugins/google-account-setup/google-source.c145
-rw-r--r--plugins/google-account-setup/org-gnome-evolution-google.eplug.xml4
-rw-r--r--plugins/webdav-account-setup/Makefile.am1
-rw-r--r--plugins/webdav-account-setup/webdav-contacts-source.c117
12 files changed, 201 insertions, 1257 deletions
diff --git a/plugins/caldav/caldav-source.c b/plugins/caldav/caldav-source.c
index 4821cbf2f4..d2bc2f6a16 100644
--- a/plugins/caldav/caldav-source.c
+++ b/plugins/caldav/caldav-source.c
@@ -31,8 +31,8 @@
#include <e-util/e-config.h>
#include <e-util/e-plugin.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
-#include <libedataserver/e-url.h>
#include <libedataserver/e-account-list.h>
#include <libecal/e-cal.h>
@@ -81,228 +81,66 @@ e_plugin_lib_enable (EPlugin *ep, gint enable)
return 0;
}
-/* replaces all '@' with '%40' in str; returns newly allocated string */
-static gchar *
-replace_at_sign (const gchar *str)
-{
- gchar *res, *at;
-
- if (!str)
- return NULL;
-
- res = g_strdup (str);
- while (at = strchr (res, '@'), at) {
- gchar *tmp = g_malloc0 (sizeof (gchar) * (1 + strlen (res) + 2));
-
- strncpy (tmp, res, at - res);
- strcat (tmp, "%40");
- strcat (tmp, at + 1);
-
- g_free (res);
- res = tmp;
- }
-
- return res;
-}
-
/*****************************************************************************/
-/* the location field for caldav sources */
-
-/* stolen from calendar-weather eplugin */
-static gchar *
-print_uri_noproto (EUri *uri)
-{
- gchar *uri_noproto, *user, *pass;
-
- if (uri->user)
- user = replace_at_sign (uri->user);
- else
- user = NULL;
-
- if (uri->passwd)
- pass = replace_at_sign (uri->passwd);
- else
- pass = NULL;
-
- if (uri->port != 0)
- uri_noproto = g_strdup_printf (
- "%s%s%s%s%s%s%s:%d%s%s%s",
- user ? user : "",
- uri->authmech ? ";auth=" : "",
- uri->authmech ? uri->authmech : "",
- pass ? ":" : "",
- pass ? pass : "",
- 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",
- user ? user : "",
- uri->authmech ? ";auth=" : "",
- uri->authmech ? uri->authmech : "",
- pass ? ":" : "",
- pass ? pass : "",
- user ? "@" : "",
- uri->host ? uri->host : "",
- uri->path ? uri->path : "",
- uri->query ? "?" : "",
- uri->query ? uri->query : "");
-
- g_free (user);
- g_free (pass);
-
- return uri_noproto;
-}
static void
-location_changed (GtkEntry *editable, ESource *source)
+location_changed_cb (GtkEntry *editable, ESource *source)
{
- EUri *euri;
+ SoupURI *suri;
gchar *ruri;
const gchar *uri, *username;
- uri = gtk_entry_get_text (GTK_ENTRY (editable));
+ uri = gtk_entry_get_text (editable);
- euri = e_uri_new (uri);
- g_return_if_fail (euri != NULL);
+ suri = soup_uri_new (uri);
+ if (!suri)
+ return;
username = e_source_get_property (source, "username");
if (username && !*username)
username = NULL;
- if ((!euri->user && username) || (euri->user && username && !g_str_equal (euri->user, username))) {
- g_free (euri->user);
- euri->user = g_strdup (username);
- }
+ soup_uri_set_user (suri, username);
- ruri = print_uri_noproto (euri);
+ ruri = e_plugin_util_uri_no_proto (suri);
e_source_set_relative_uri (source, ruri);
g_free (ruri);
- e_uri_free (euri);
+ soup_uri_free (suri);
}
static void
-ssl_changed (GtkToggleButton *button, ESource *source)
+user_changed_cb (GtkEntry *editable, ESource *source)
{
- e_source_set_property(source, "ssl",
- gtk_toggle_button_get_active(button) ? "1" : "0");
-}
-
-static void
-user_changed (GtkEntry *editable, ESource *source)
-{
- EUri *euri;
- gchar *uri;
- gchar *ruri;
+ SoupURI *suri;
+ gchar *uri, *ruri;
const gchar *user;
uri = e_source_get_uri (source);
- user = gtk_entry_get_text (GTK_ENTRY (editable));
+ user = gtk_entry_get_text (editable);
- if (uri == NULL) {
- g_free (uri);
+ if (uri == NULL)
+ return;
+
+ suri = soup_uri_new (uri);
+ g_free (uri);
+
+ if (suri == NULL)
return;
- }
- euri = e_uri_new (uri);
- g_free (euri->user);
- euri->user = NULL;
+ soup_uri_set_user (suri, NULL);
if (user != NULL && *user) {
- euri->user = g_strdup (user);
+ soup_uri_set_user (suri, user);
e_source_set_property (source, "auth", "1");
} else {
e_source_set_property (source, "auth", NULL);
}
e_source_set_property (source, "username", user);
- ruri = print_uri_noproto (euri);
+ ruri = e_plugin_util_uri_no_proto (suri);
e_source_set_relative_uri (source, ruri);
g_free (ruri);
- e_uri_free (euri);
-}
-
-static void
-set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox)
-{
- gint time;
- gint item_num = 0;
- const gchar *refresh_str = e_source_get_property (source, "refresh");
- time = refresh_str ? atoi (refresh_str) : 30;
-
- if (time && !(time % 10080)) {
- /* weeks */
- item_num = 3;
- time /= 10080;
- } else if (time && !(time % 1440)) {
- /* days */
- item_num = 2;
- time /= 1440;
- } else if (time && !(time % 60)) {
- /* hours */
- item_num = 1;
- time /= 60;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time);
-}
-
-static gchar *
-get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox)
-{
- gint setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) {
- case 0:
- /* minutes */
- break;
- case 1:
- /* hours */
- setting *= 60;
- break;
- case 2:
- /* days */
- setting *= 1440;
- break;
- case 3:
- /* weeks - is this *really* necessary? */
- setting *= 10080;
- break;
- default:
- g_warning ("Time unit out of range");
- break;
- }
-
- return g_strdup_printf ("%d", setting);
-}
-
-static void
-spin_changed (GtkSpinButton *spin, ESource *source)
-{
- gchar *refresh_str;
- GtkWidget *combobox;
-
- combobox = g_object_get_data (G_OBJECT (spin), "combobox");
-
- refresh_str = get_refresh_minutes ((GtkWidget *) spin, combobox);
- e_source_set_property (source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-combobox_changed (GtkComboBox *combobox, ESource *source)
-{
- gchar *refresh_str;
- GtkWidget *spin;
-
- spin = g_object_get_data (G_OBJECT (combobox), "spin");
-
- refresh_str = get_refresh_minutes (spin, (GtkWidget *) combobox);
- e_source_set_property (source, "refresh", refresh_str);
- g_free (refresh_str);
+ soup_uri_free (suri);
}
static void
@@ -344,168 +182,59 @@ oge_caldav (EPlugin *epl,
{
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
ESource *source;
- ESourceGroup *group;
- EUri *euri;
- GtkWidget *parent;
- GtkWidget *lurl;
- GtkWidget *cssl;
- GtkWidget *location;
- GtkWidget *widget;
- GtkWidget *luser;
- GtkWidget *user;
- GtkWidget *browse_cal;
- GtkWidget *label, *hbox, *spin, *combobox;
- gchar *uri;
- gchar *username;
- const gchar *ssl_prop;
- gboolean ssl_enabled;
- gint row;
+ SoupURI *suri;
+ GtkWidget *parent, *location, *ssl, *user, *browse_cal, *refresh;
+ gchar *uri, *username;
source = t->source;
- group = e_source_peek_group (source);
-
- widget = NULL;
- if (!g_str_has_prefix (e_source_group_peek_base_uri (group),
- "caldav")) {
+ if (!e_plugin_util_is_group_proto (e_source_peek_group (source), "caldav")) {
return NULL;
}
/* Extract the username from the uri so we can prefill the
* dialog right, remove the username from the url then */
uri = e_source_get_uri (source);
- euri = e_uri_new (uri);
+ suri = soup_uri_new (uri);
g_free (uri);
- if (euri == NULL) {
- return NULL;
+ if (suri) {
+ soup_uri_set_user (suri, NULL);
+ soup_uri_set_password (suri, NULL);
+ uri = soup_uri_to_string (suri, FALSE);
+ soup_uri_free (suri);
+ } else {
+ uri = g_strdup ("");
}
- g_free (euri->user);
- euri->user = NULL;
- uri = e_uri_to_string (euri, FALSE);
-
username = e_source_get_duped_property (source, "username");
- ssl_prop = e_source_get_property (source, "ssl");
- if (ssl_prop && ssl_prop[0] == '1') {
- ssl_enabled = TRUE;
- } else {
- ssl_enabled = FALSE;
- }
-
/* Build up the UI */
parent = data->parent;
- row = GTK_TABLE (parent)->nrows;
-
- lurl = gtk_label_new_with_mnemonic (_("_URL:"));
- gtk_widget_show (lurl);
- gtk_misc_set_alignment (GTK_MISC (lurl), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent),
- lurl, 0, 1,
- row, row+1,
- GTK_FILL, 0, 0, 0);
-
- location = gtk_entry_new ();
- gtk_widget_show (location);
+ location = e_plugin_util_add_entry (parent, _("_URL:"), NULL, NULL);
gtk_entry_set_text (GTK_ENTRY (location), uri);
- gtk_table_attach (GTK_TABLE (parent), location,
- 1, 2, row, row+1,
- GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (lurl), location);
-
- g_signal_connect (G_OBJECT (location),
- "changed",
- G_CALLBACK (location_changed),
- source);
-
- row++;
-
- cssl = gtk_check_button_new_with_mnemonic (_("Use _SSL"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cssl), ssl_enabled);
- gtk_widget_show (cssl);
- gtk_table_attach (GTK_TABLE (parent),
- cssl, 1, 2,
- row , row + 1,
- GTK_FILL, 0, 0, 0);
-
- g_signal_connect (G_OBJECT (cssl),
- "toggled",
- G_CALLBACK (ssl_changed),
- source);
-
- row++;
-
- luser = gtk_label_new_with_mnemonic (_("User_name:"));
- gtk_widget_show (luser);
- gtk_misc_set_alignment (GTK_MISC (luser), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent),
- luser, 0, 1,
- row, row + 1,
- GTK_FILL, 0, 0, 0);
-
- user = gtk_entry_new ();
- gtk_widget_show (user);
- gtk_entry_set_text (GTK_ENTRY (user), username ? username : "");
- gtk_table_attach (GTK_TABLE (parent), user,
- 1, 2, row, row + 1,
- GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (luser), user);
+ g_signal_connect (G_OBJECT (location), "changed", G_CALLBACK (location_changed_cb), source);
- g_signal_connect (G_OBJECT (user),
- "changed",
- G_CALLBACK (user_changed),
- source);
+ ssl = e_plugin_util_add_check (parent, _("Use _SSL"), source, "ssl", "1", "0");
- row++;
+ user = e_plugin_util_add_entry (parent, _("User_name:"), NULL, NULL);
+ gtk_entry_set_text (GTK_ENTRY (user), username ? username : "");
+ g_signal_connect (G_OBJECT (user), "changed", G_CALLBACK (user_changed_cb), source);
g_free (uri);
g_free (username);
browse_cal = gtk_button_new_with_mnemonic (_("Brows_e server for a calendar"));
gtk_widget_show (browse_cal);
- gtk_table_attach (GTK_TABLE (parent), browse_cal, 1, 2, row, row + 1, GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (parent), browse_cal, 1, 2, GTK_TABLE (parent)->nrows, GTK_TABLE (parent)->nrows + 1, GTK_FILL, 0, 0, 0);
g_object_set_data (G_OBJECT (browse_cal), "caldav-url", location);
g_object_set_data (G_OBJECT (browse_cal), "caldav-username", user);
- g_object_set_data (G_OBJECT (browse_cal), "caldav-ssl", cssl);
+ g_object_set_data (G_OBJECT (browse_cal), "caldav-ssl", ssl);
g_signal_connect (G_OBJECT (browse_cal), "clicked", G_CALLBACK (browse_cal_clicked_cb), GINT_TO_POINTER (t->source_type));
- row++;
-
- /* add refresh option */
- label = gtk_label_new_with_mnemonic (_("Re_fresh:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
-
- spin = gtk_spin_button_new_with_range (0, 100, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin);
- gtk_widget_show (spin);
- gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
+ refresh = e_plugin_util_add_refresh (parent, _("Re_fresh:"), source, "refresh");
- combobox = gtk_combo_box_new_text ();
- gtk_widget_show (combobox);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("minutes"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("hours"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("days"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("weeks"));
- set_refresh_time (source, spin, combobox);
- gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, TRUE, 0);
-
- g_object_set_data (G_OBJECT (combobox), "spin", spin);
- g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (combobox_changed), source);
- g_object_set_data (G_OBJECT (spin), "combobox", combobox);
- g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), source);
-
- gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
- return widget;
+ return location;
}
-
diff --git a/plugins/calendar-file/Makefile.am b/plugins/calendar-file/Makefile.am
index ba8af51ad4..a4577e5019 100644
--- a/plugins/calendar-file/Makefile.am
+++ b/plugins/calendar-file/Makefile.am
@@ -16,6 +16,7 @@ liborg_gnome_calendar_file_la_SOURCES = calendar-file.c
liborg_gnome_calendar_file_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
liborg_gnome_calendar_file_la_LIBADD = \
+ $(top_builddir)/e-util/libeutil.la \
$(EVOLUTION_CALENDAR_LIBS) \
$(GNOME_PLATFORM_LIBS)
diff --git a/plugins/calendar-file/calendar-file.c b/plugins/calendar-file/calendar-file.c
index b5fe2c23ff..e82feaa11a 100644
--- a/plugins/calendar-file/calendar-file.c
+++ b/plugins/calendar-file/calendar-file.c
@@ -21,9 +21,9 @@
#include <gtk/gtk.h>
#include <e-util/e-config.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-url.h>
#include <glib/gi18n.h>
#include <string.h>
@@ -41,85 +41,6 @@ location_changed (GtkFileChooserButton *widget, ESource *source)
}
static void
-set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox)
-{
- gint time;
- gint item_num = 0;
- const gchar *refresh_str = e_source_get_property (source, "refresh");
- time = refresh_str ? atoi (refresh_str) : 30;
-
- if (time && !(time % 10080)) {
- /* weeks */
- item_num = 3;
- time /= 10080;
- } else if (time && !(time % 1440)) {
- /* days */
- item_num = 2;
- time /= 1440;
- } else if (time && !(time % 60)) {
- /* hours */
- item_num = 1;
- time /= 60;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time);
-}
-
-static gchar *
-get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox)
-{
- gint setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) {
- case 0:
- /* minutes */
- break;
- case 1:
- /* hours */
- setting *= 60;
- break;
- case 2:
- /* days */
- setting *= 1440;
- break;
- case 3:
- /* weeks - is this *really* necessary? */
- setting *= 10080;
- break;
- default:
- g_warning ("Time unit out of range");
- break;
- }
-
- return g_strdup_printf ("%d", setting);
-}
-
-static void
-spin_changed (GtkSpinButton *spin, ESource *source)
-{
- gchar *refresh_str;
- GtkWidget *combobox;
-
- combobox = g_object_get_data (G_OBJECT (spin), "combobox");
-
- refresh_str = get_refresh_minutes ((GtkWidget *) spin, combobox);
- e_source_set_property (source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-combobox_changed (GtkComboBox *combobox, ESource *source)
-{
- gchar *refresh_str;
- GtkWidget *spin;
-
- spin = g_object_get_data (G_OBJECT (combobox), "spin");
-
- refresh_str = get_refresh_minutes (spin, (GtkWidget *) combobox);
- e_source_set_property (source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
maincheck_toggled (GtkToggleButton *check, ESource *source)
{
GtkWidget *w;
@@ -147,34 +68,25 @@ maincheck_toggled (GtkToggleButton *check, ESource *source)
static void
refresh_type_changed (GtkComboBox *refresh_type, ESource *source)
{
- GtkWidget *spin, *combobox;
+ GtkWidget *refresh_hbox;
gint active = gtk_combo_box_get_active (refresh_type);
gchar buff[2] = {0};
- spin = g_object_get_data (G_OBJECT (refresh_type), "spin");
- combobox = g_object_get_data (G_OBJECT (refresh_type), "combobox");
+ refresh_hbox = g_object_get_data (G_OBJECT (refresh_type), "refresh-hbox");
if (active < 0 || active > 2)
active = 0;
if (active == 2) {
- gtk_widget_show (spin);
- gtk_widget_show (combobox);
+ gtk_widget_show (refresh_hbox);
} else {
- gtk_widget_hide (spin);
- gtk_widget_hide (combobox);
+ gtk_widget_hide (refresh_hbox);
}
buff [0] = '0' + active;
e_source_set_property (source, "refresh-type", buff);
}
-static void
-force_readonly_toggled (GtkToggleButton *check, ESource *source)
-{
- e_source_set_property (source, "custom-file-readonly", gtk_toggle_button_get_active (check) ? "1" : NULL);
-}
-
GtkWidget *e_calendar_file_customs (EPlugin *epl, EConfigHookItemFactoryData *data);
GtkWidget *
@@ -182,23 +94,15 @@ e_calendar_file_customs (EPlugin *epl, EConfigHookItemFactoryData *data)
{
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
ESource *source = t->source;
- gchar *uri_text;
const gchar *relative_uri, *value;
- GtkWidget *w1, *w2, *w3, *box1, *box2, *mainbox, *maincheck;
-
- uri_text = e_source_get_uri (source);
- if (strncmp (uri_text, "file", 4)) {
- g_free (uri_text);
+ GtkWidget *w1, *w2, *box1, *box2, *mainbox, *maincheck;
+ if (!e_plugin_util_is_source_proto (source, "file"))
return NULL;
- }
relative_uri = e_source_peek_relative_uri (source);
-
- if (relative_uri && g_str_equal (relative_uri, "system")) {
- g_free (uri_text);
+ if (relative_uri && g_str_equal (relative_uri, "system"))
return NULL;
- }
e_source_set_relative_uri (source, e_source_peek_uid (source));
@@ -286,29 +190,14 @@ e_calendar_file_customs (EPlugin *epl, EConfigHookItemFactoryData *data)
gtk_combo_box_set_active ((GtkComboBox *)w2, (value && *value && !value[1] && value [0] >= '0' && value [0] <= '2') ? value [0] - '0' : 0);
w1 = w2;
- w2 = gtk_spin_button_new_with_range (1, 100, 1);
+ w2 = e_plugin_util_add_refresh (NULL, NULL, source, "refresh");
gtk_box_pack_start (GTK_BOX (box2), w2, FALSE, TRUE, 0);
- w3 = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (w3), _("minutes"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (w3), _("hours"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (w3), _("days"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (w3), _("weeks"));
- set_refresh_time (source, w2, w3);
- gtk_box_pack_start (GTK_BOX (box2), w3, FALSE, TRUE, 0);
-
- g_object_set_data (G_OBJECT (w1), "spin", w2);
- g_object_set_data (G_OBJECT (w1), "combobox", w3);
- g_object_set_data (G_OBJECT (w2), "combobox", w3);
+ g_object_set_data (G_OBJECT (w1), "refresh-hbox", w2);
g_signal_connect (G_OBJECT (w1), "changed", G_CALLBACK (refresh_type_changed), source);
- g_signal_connect (G_OBJECT (w2), "value-changed", G_CALLBACK (spin_changed), source);
- g_signal_connect (G_OBJECT (w3), "changed", G_CALLBACK (combobox_changed), source);
- w2 = gtk_check_button_new_with_mnemonic (_("Force read _only"));
- value = e_source_get_property (source, "custom-file-readonly");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w2), value && g_str_equal (value, "1"));
- g_signal_connect (G_OBJECT (w2), "toggled", G_CALLBACK (force_readonly_toggled), source);
+ w2 = e_plugin_util_add_check (NULL, _("Force read _only"), source, "custom-file-readonly", "1", NULL);
gtk_box_pack_start ((GtkBox *)box1, w2, TRUE, TRUE, 2);
gtk_widget_show_all (mainbox);
@@ -316,7 +205,6 @@ e_calendar_file_customs (EPlugin *epl, EConfigHookItemFactoryData *data)
/* w1 is a refresh-type combobox, and it hides widgets,
thus should be called after show_all call */
refresh_type_changed (GTK_COMBO_BOX (w1), source);
- g_free (uri_text);
return mainbox;
}
diff --git a/plugins/calendar-http/Makefile.am b/plugins/calendar-http/Makefile.am
index 2e2a49ba0c..54457c3c8b 100644
--- a/plugins/calendar-http/Makefile.am
+++ b/plugins/calendar-http/Makefile.am
@@ -16,6 +16,7 @@ liborg_gnome_calendar_http_la_SOURCES = calendar-http.c
liborg_gnome_calendar_http_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
liborg_gnome_calendar_http_la_LIBADD = \
+ $(top_builddir)/e-util/libeutil.la \
$(EVOLUTION_CALENDAR_LIBS) \
$(GNOME_PLATFORM_LIBS)
diff --git a/plugins/calendar-http/calendar-http.c b/plugins/calendar-http/calendar-http.c
index d2e8f903c6..1137d0617e 100644
--- a/plugins/calendar-http/calendar-http.c
+++ b/plugins/calendar-http/calendar-http.c
@@ -21,9 +21,10 @@
#include <gtk/gtk.h>
#include <e-util/e-config.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-url.h>
+#include <libsoup/soup.h>
#include <glib/gi18n.h>
#include <string.h>
@@ -33,88 +34,18 @@ gboolean e_calendar_http_check (EPlugin *epl, EConfigHookPageCheckData *data);
GtkWidget * e_calendar_http_secure (EPlugin *epl, EConfigHookItemFactoryData *data);
GtkWidget *e_calendar_http_auth (EPlugin *epl, EConfigHookItemFactoryData *data);
-/* replaces all '@' with '%40' in str; returns newly allocated string */
-static gchar *
-replace_at_sign (const gchar *str)
-{
- gchar *res, *at;
-
- if (!str)
- return NULL;
-
- res = g_strdup (str);
- while (at = strchr (res, '@'), at) {
- gchar *tmp = g_malloc0 (sizeof (gchar) * (1 + strlen (res) + 2));
-
- strncpy (tmp, res, at - res);
- strcat (tmp, "%40");
- strcat (tmp, at + 1);
-
- g_free (res);
- res = tmp;
- }
-
- return res;
-}
-
-static gchar *
-print_uri_noproto (EUri *uri)
-{
- gchar *uri_noproto, *user, *pass;
-
- if (uri->user)
- user = replace_at_sign (uri->user);
- else
- user = NULL;
-
- if (uri->passwd)
- pass = replace_at_sign (uri->passwd);
- else
- pass = NULL;
-
- if (uri->port != 0)
- uri_noproto = g_strdup_printf (
- "%s%s%s%s%s%s%s:%d%s%s%s",
- user ? user : "",
- uri->authmech ? ";auth=" : "",
- uri->authmech ? uri->authmech : "",
- pass ? ":" : "",
- pass ? pass : "",
- 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",
- user ? user : "",
- uri->authmech ? ";auth=" : "",
- uri->authmech ? uri->authmech : "",
- pass ? ":" : "",
- pass ? pass : "",
- user ? "@" : "",
- uri->host ? uri->host : "",
- uri->path ? uri->path : "",
- uri->query ? "?" : "",
- uri->query ? uri->query : "");
-
- g_free (user);
- g_free (pass);
-
- return uri_noproto;
-}
-
static void
url_changed (GtkEntry *entry, ESource *source)
{
- EUri *uri;
+ SoupURI *uri;
gchar *relative_uri;
- uri = e_uri_new (gtk_entry_get_text (GTK_ENTRY (entry)));
+ uri = soup_uri_new (gtk_entry_get_text (GTK_ENTRY (entry)));
+
+ if (!uri)
+ return;
- if (strncmp (uri->protocol, "https", sizeof ("https") - 1) == 0) {
+ if (uri->scheme && strncmp (uri->scheme, "https", sizeof ("https") - 1) == 0) {
gpointer secure_checkbox;
secure_checkbox = g_object_get_data (G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (entry))),
@@ -123,261 +54,79 @@ url_changed (GtkEntry *entry, ESource *source)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (secure_checkbox), TRUE);
}
- g_free (uri->user);
- uri->user = g_strdup (e_source_get_property (source, "username"));
- relative_uri = print_uri_noproto (uri);
+ soup_uri_set_user (uri, e_source_get_property (source, "username"));
+ relative_uri = e_plugin_util_uri_no_proto (uri);
e_source_set_relative_uri (source, relative_uri);
g_free (relative_uri);
- e_uri_free (uri);
+ soup_uri_free (uri);
}
GtkWidget *
e_calendar_http_url (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- static GtkWidget *label;
- GtkWidget *entry, *parent;
- gint row;
+ GtkWidget *entry;
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- EUri *uri;
+ SoupURI *uri;
gchar *uri_text;
- static GtkWidget *hidden = NULL;
- if (!hidden)
- hidden = gtk_label_new ("");
-
- if (data->old)
- gtk_widget_destroy (label);
-
- uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- if ((strcmp (uri->protocol, "http") &&
- strcmp (uri->protocol, "https") &&
- strcmp (uri->protocol, "webcal"))) {
- e_uri_free (uri);
- g_free (uri_text);
- return hidden;
+ if ((!e_plugin_util_is_source_proto (t->source, "http") &&
+ !e_plugin_util_is_source_proto (t->source, "https") &&
+ !e_plugin_util_is_source_proto (t->source, "webcal"))) {
+ return NULL;
}
- g_free (uri->user);
- uri->user = NULL;
+ uri_text = e_source_get_uri (t->source);
+ uri = soup_uri_new (uri_text);
g_free (uri_text);
- uri_text = e_uri_to_string (uri, FALSE);
- e_uri_free (uri);
-
- parent = data->parent;
- row = ((GtkTable*)parent)->nrows;
+ if (uri) {
+ soup_uri_set_user (uri, NULL);
+ soup_uri_set_password (uri, NULL);
- label = gtk_label_new_with_mnemonic (_("_URL:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
+ uri_text = soup_uri_to_string (uri, FALSE);
+ soup_uri_free (uri);
+ } else {
+ uri_text = g_strdup ("");
+ }
- entry = gtk_entry_new ();
- gtk_widget_show (entry);
+ entry = e_plugin_util_add_entry (data->parent, _("_URL:"), NULL, NULL);
gtk_entry_set_text (GTK_ENTRY (entry), uri_text);
- gtk_table_attach (GTK_TABLE (parent), entry, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (url_changed), t->source);
-
g_free (uri_text);
- return entry;
-}
-
-static void
-set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox)
-{
- gint time;
- gint item_num = 0;
- const gchar *refresh_str = e_source_get_property (source, "refresh");
- time = refresh_str ? atoi (refresh_str) : 30;
-
- if (time && !(time % 10080)) {
- /* weeks */
- item_num = 3;
- time /= 10080;
- } else if (time && !(time % 1440)) {
- /* days */
- item_num = 2;
- time /= 1440;
- } else if (time && !(time % 60)) {
- /* hours */
- item_num = 1;
- time /= 60;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time);
-}
-
-static gchar *
-get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox)
-{
- gint setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) {
- case 0:
- /* minutes */
- break;
- case 1:
- /* hours */
- setting *= 60;
- break;
- case 2:
- /* days */
- setting *= 1440;
- break;
- case 3:
- /* weeks - is this *really* necessary? */
- setting *= 10080;
- break;
- default:
- g_warning ("Time unit out of range");
- break;
- }
-
- return g_strdup_printf ("%d", setting);
-}
-
-static void
-spin_changed (GtkSpinButton *spin, ECalConfigTargetSource *t)
-{
- gchar *refresh_str;
- GtkWidget *combobox;
-
- combobox = g_object_get_data (G_OBJECT (spin), "combobox");
-
- refresh_str = get_refresh_minutes ((GtkWidget *) spin, combobox);
- e_source_set_property (t->source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-combobox_changed (GtkComboBox *combobox, ECalConfigTargetSource *t)
-{
- gchar *refresh_str;
- GtkWidget *spin;
- spin = g_object_get_data (G_OBJECT (combobox), "spin");
-
- refresh_str = get_refresh_minutes (spin, (GtkWidget *) combobox);
- e_source_set_property (t->source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-secure_setting_changed (GtkWidget *widget, ESource *source)
-{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- e_source_set_property (source, "use_ssl", "1");
- else
- e_source_set_property (source, "use_ssl", "0");
+ return entry;
}
GtkWidget *
e_calendar_http_refresh (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- static GtkWidget *label;
- GtkWidget *combobox, *spin, *hbox, *parent;
- gint row;
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- ESource *source = t->source;
- EUri *uri;
- gchar * uri_text;
- static GtkWidget *hidden = NULL;
- if (!hidden)
- hidden = gtk_label_new ("");
-
- if (data->old)
- gtk_widget_destroy (label);
-
- uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- g_free (uri_text);
- if ((strcmp (uri->protocol, "http") &&
- strcmp (uri->protocol, "https") &&
- strcmp (uri->protocol, "webcal"))) {
- e_uri_free (uri);
- return hidden;
+ if ((!e_plugin_util_is_source_proto (t->source, "http") &&
+ !e_plugin_util_is_source_proto (t->source, "https") &&
+ !e_plugin_util_is_source_proto (t->source, "webcal"))) {
+ return NULL;
}
- e_uri_free (uri);
- parent = data->parent;
-
- row = ((GtkTable*)parent)->nrows;
-
- label = gtk_label_new_with_mnemonic (_("Re_fresh:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
-
- spin = gtk_spin_button_new_with_range (0, 100, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin);
- gtk_widget_show (spin);
- gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
-
- combobox = gtk_combo_box_new_text ();
- gtk_widget_show (combobox);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("minutes"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("hours"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("days"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("weeks"));
- set_refresh_time (source, spin, combobox);
- gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, TRUE, 0);
-
- g_object_set_data (G_OBJECT (combobox), "spin", spin);
- g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (combobox_changed), t);
- g_object_set_data (G_OBJECT (spin), "combobox", combobox);
- g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), t);
-
- gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
- return hbox;
+ return e_plugin_util_add_refresh (data->parent, _("Re_fresh:"), t->source, "refresh");
}
GtkWidget *
e_calendar_http_secure (EPlugin *epl, EConfigHookItemFactoryData *data)
{
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- GtkWidget *secure_setting, *parent;
- const gchar *secure_prop;
- gint row;
- EUri *uri;
- gchar * uri_text;
- static GtkWidget *hidden = NULL;
-
- if (!hidden)
- hidden = gtk_label_new ("");
+ GtkWidget *secure_setting;
- uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- g_free (uri_text);
- if ((strcmp (uri->protocol, "http") &&
- strcmp (uri->protocol, "https") &&
- strcmp (uri->protocol, "webcal"))) {
- e_uri_free (uri);
- return hidden;
+ if ((!e_plugin_util_is_source_proto (t->source, "http") &&
+ !e_plugin_util_is_source_proto (t->source, "https") &&
+ !e_plugin_util_is_source_proto (t->source, "webcal"))) {
+ return NULL;
}
- e_uri_free (uri);
-
- parent = data->parent;
-
- row = ((GtkTable*)parent)->nrows;
-
- secure_setting = gtk_check_button_new_with_mnemonic (_("_Secure connection"));
-
- secure_prop = e_source_get_property (t->source, "use_ssl");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (secure_setting), (secure_prop && g_str_equal (secure_prop, "1")) ? TRUE : FALSE);
-
- g_signal_connect (secure_setting, "toggled", G_CALLBACK (secure_setting_changed), t->source);
- gtk_widget_show (secure_setting);
- gtk_table_attach (GTK_TABLE (parent), secure_setting, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ secure_setting = e_plugin_util_add_check (data->parent, _("_Secure connection"), t->source, "use_ssl", "1", "0");
/* Store pointer to secure checkbox so we can retrieve it in url_changed() */
- g_object_set_data (G_OBJECT (parent), "secure_checkbox", (gpointer)secure_setting);
+ g_object_set_data (G_OBJECT (data->parent), "secure_checkbox", (gpointer)secure_setting);
return secure_setting;
}
@@ -396,24 +145,24 @@ username_changed (GtkEntry *entry, ESource *source)
} else {
e_source_set_property (source, "auth", NULL);
e_source_set_property (source, "username", NULL);
+ username = NULL;
}
uri = e_source_get_uri (source);
if (uri != NULL) {
- EUri *euri;
+ SoupURI *suri;
gchar *ruri;
- if (username && !*username)
- username = NULL;
+ suri = soup_uri_new (uri);
+ if (!suri)
+ return;
- euri = e_uri_new (uri);
+ soup_uri_set_user (suri, username);
+ soup_uri_set_password (suri, NULL);
- g_free (euri->user);
- euri->user = g_strdup (username);
-
- ruri = print_uri_noproto (euri);
+ ruri = e_plugin_util_uri_no_proto (suri);
e_source_set_relative_uri (source, ruri);
- e_uri_free (euri);
+ soup_uri_free (suri);
g_free (ruri);
g_free (uri);
}
@@ -422,51 +171,22 @@ username_changed (GtkEntry *entry, ESource *source)
GtkWidget *
e_calendar_http_auth (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- static GtkWidget *label;
- GtkWidget *entry, *parent;
- gint row;
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- EUri *uri;
- gchar *uri_text;
+ GtkWidget *entry;
const gchar *username;
- static GtkWidget *hidden = NULL;
-
- if (!hidden)
- hidden = gtk_label_new ("");
- if (data->old)
- gtk_widget_destroy (label);
-
- uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- g_free (uri_text);
- if ((strcmp (uri->protocol, "http") &&
- strcmp (uri->protocol, "https") &&
- strcmp (uri->protocol, "webcal"))) {
- e_uri_free (uri);
- return hidden;
+ if ((!e_plugin_util_is_source_proto (t->source, "http") &&
+ !e_plugin_util_is_source_proto (t->source, "https") &&
+ !e_plugin_util_is_source_proto (t->source, "webcal"))) {
+ return NULL;
}
- e_uri_free (uri);
-
- parent = data->parent;
-
- row = ((GtkTable*)parent)->nrows;
-
- label = gtk_label_new_with_mnemonic (_("Userna_me:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, GTK_SHRINK, 0, 0);
username = e_source_get_property (t->source, "username");
- entry = gtk_entry_new ();
- gtk_widget_show (entry);
+ entry = e_plugin_util_add_entry (data->parent, _("Userna_me:"), NULL, NULL);
gtk_entry_set_text (GTK_ENTRY (entry), username ? username : "");
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (username_changed), t->source);
- gtk_table_attach (GTK_TABLE (parent), entry, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
return entry;
}
@@ -475,27 +195,18 @@ e_calendar_http_check (EPlugin *epl, EConfigHookPageCheckData *data)
{
/* FIXME - check pageid */
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- EUri *uri;
gboolean ok = FALSE;
- ESourceGroup *group = e_source_peek_group (t->source);
- gchar *uri_text;
- if (strncmp (e_source_group_peek_base_uri (group), "webcal", 6))
+ if (!e_plugin_util_is_group_proto (e_source_peek_group (t->source), "webcal"))
return TRUE;
- uri_text = e_source_get_uri (t->source);
- if (!strncmp (uri_text, "file:", 5)) {
- g_free (uri_text);
+ if (e_plugin_util_is_source_proto (t->source, "file"))
return FALSE;
- }
- uri = e_uri_new (uri_text);
- ok = ((!strcmp (uri->protocol, "webcal")) ||
- (!strcmp (uri->protocol, "http")) ||
- (!strcmp (uri->protocol, "https")) ||
- (!strcmp (uri->protocol, "file")) );
- e_uri_free (uri);
- g_free (uri_text);
+ ok = e_plugin_util_is_source_proto (t->source, "webcal") ||
+ e_plugin_util_is_source_proto (t->source, "http") ||
+ e_plugin_util_is_source_proto (t->source, "https") ||
+ e_plugin_util_is_source_proto (t->source, "file");
return ok;
}
diff --git a/plugins/calendar-weather/calendar-weather.c b/plugins/calendar-weather/calendar-weather.c
index ad2c273baf..50c698da28 100644
--- a/plugins/calendar-weather/calendar-weather.c
+++ b/plugins/calendar-weather/calendar-weather.c
@@ -21,11 +21,11 @@
#include <gtk/gtk.h>
#include <e-util/e-config.h>
-#include "e-util/e-icon-factory.h"
+#include <e-util/e-icon-factory.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <calendar/gui/e-cal-event.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-url.h>
#include <libedataserver/e-categories.h>
#include <glib/gi18n.h>
#include <libxml/parser.h>
@@ -211,7 +211,7 @@ create_source_selector (ESource *source)
GtkCellRenderer *text;
GtkTreeSelection *selection;
gchar *uri_text;
- EUri *uri;
+ SoupURI *suri;
/* FIXME - should show an error here if it fails*/
if (store == NULL)
@@ -238,8 +238,8 @@ create_source_selector (ESource *source)
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
uri_text = e_source_get_uri (source);
- uri = e_uri_new (uri_text);
- if (uri->path && strlen (uri->path)) {
+ suri = soup_uri_new (uri_text);
+ if (suri && suri->path && *suri->path) {
GtkTreeIter *iter = find_location (store, uri_text + 10);
GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (treeview), path);
@@ -247,7 +247,8 @@ create_source_selector (ESource *source)
gtk_tree_path_free (path);
}
g_free (uri_text);
- e_uri_free (uri);
+ if (suri)
+ soup_uri_free (suri);
g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (selection_changed), dialog);
g_object_set_data (G_OBJECT (dialog), "treeview", treeview);
@@ -332,30 +333,21 @@ location_clicked (GtkButton *button, ESource *source)
GtkWidget *
e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- static GtkWidget *label;
- GtkWidget *button, *parent, *text;
+ GtkWidget *button, *parent, *text, *label;
gint row;
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
ESource *source = t->source;
- EUri *uri;
+ SoupURI *suri;
gchar *uri_text;
- static GtkWidget *hidden;
+
+ if (!e_plugin_util_is_source_proto (t->source, "weather"))
+ return NULL;
if (store == NULL)
store = gweather_xml_load_locations ();
- if (!hidden)
- hidden = gtk_label_new ("");
-
- if (data->old)
- gtk_widget_destroy (label);
-
uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- if (strcmp ((const gchar *)uri->protocol, "weather")) {
- e_uri_free (uri);
- return hidden;
- }
+ suri = soup_uri_new (uri_text);
parent = data->parent;
@@ -370,7 +362,7 @@ e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data)
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (location_clicked), source);
gtk_widget_show (button);
- if (uri->path && strlen (uri->path)) {
+ if (suri && suri->path && *suri->path) {
GtkTreeIter *iter = find_location (store, uri_text + 10);
gchar *location = build_location_path (iter);
text = gtk_label_new (location);
@@ -381,7 +373,8 @@ e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data)
gtk_widget_show (text);
gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ELLIPSIZE_START);
gtk_container_add (GTK_CONTAINER (button), text);
- e_uri_free (uri);
+ if (suri)
+ soup_uri_free (suri);
g_free (uri_text);
gtk_table_attach (GTK_TABLE (parent), button, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
@@ -389,145 +382,15 @@ e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data)
return button;
}
-static void
-set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox)
-{
- gint time;
- gint item_num = 0;
- const gchar *refresh_str = e_source_get_property (source, "refresh");
- time = refresh_str ? atoi (refresh_str) : 30;
-
- if (time && !(time % 10080)) {
- /* weeks */
- item_num = 3;
- time /= 10080;
- } else if (time && !(time % 1440)) {
- /* days */
- item_num = 2;
- time /= 1440;
- } else if (time && !(time % 60)) {
- /* hours */
- item_num = 1;
- time /= 60;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time);
-}
-
-static gchar *
-get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox)
-{
- gint setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) {
- case 0:
- /* minutes */
- break;
- case 1:
- /* hours */
- setting *= 60;
- break;
- case 2:
- /* days */
- setting *= 1440;
- break;
- case 3:
- /* weeks - is this *really* necessary? */
- setting *= 10080;
- break;
- default:
- g_warning ("Time unit out of range");
- break;
- }
- return g_strdup_printf ("%d", setting);
-}
-
-static void
-spin_changed (GtkSpinButton *spin, ECalConfigTargetSource *t)
-{
- gchar *refresh_str;
- GtkWidget *combobox;
-
- combobox = g_object_get_data (G_OBJECT (spin), "combobox");
-
- refresh_str = get_refresh_minutes ((GtkWidget *) spin, combobox);
- e_source_set_property (t->source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-combobox_changed (GtkComboBox *combobox, ECalConfigTargetSource *t)
-{
- gchar *refresh_str;
- GtkWidget *spin;
-
- spin = g_object_get_data (G_OBJECT (combobox), "spin");
-
- refresh_str = get_refresh_minutes (spin, (GtkWidget *) combobox);
- e_source_set_property (t->source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
GtkWidget *
e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- static GtkWidget *label;
- GtkWidget *spin, *combobox, *hbox, *parent;
- gint row;
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- ESource *source = t->source;
- EUri *uri;
- gchar *uri_text;
- static GtkWidget *hidden = NULL;
-
- if (!hidden)
- hidden = gtk_label_new ("");
-
- if (data->old)
- gtk_widget_destroy (label);
-
- uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- g_free (uri_text);
- if (strcmp ((const gchar *)uri->protocol, "weather")) {
- e_uri_free (uri);
- return hidden;
- }
- e_uri_free (uri);
-
- parent = data->parent;
-
- row = ((GtkTable*)parent)->nrows;
-
- label = gtk_label_new_with_mnemonic (_("Re_fresh:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
-
- spin = gtk_spin_button_new_with_range (0, 100, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin);
- gtk_widget_show (spin);
- gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
-
- combobox = gtk_combo_box_new_text ();
- gtk_widget_show (combobox);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("minutes"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("hours"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("days"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("weeks"));
- set_refresh_time (source, spin, combobox);
- gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, TRUE, 0);
-
- g_object_set_data (G_OBJECT (combobox), "spin", spin);
- g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (combobox_changed), t);
- g_object_set_data (G_OBJECT (spin), "combobox", combobox);
- g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), t);
-
- gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ if (!e_plugin_util_is_source_proto (t->source, "weather"))
+ return NULL;
- return hbox;
+ return e_plugin_util_add_refresh (data->parent, _("Re_fresh:"), t->source, "refresh");
}
static void
@@ -568,29 +431,13 @@ units_changed (GtkComboBox *combobox, ECalConfigTargetSource *t)
GtkWidget *
e_calendar_weather_units (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- static GtkWidget *label;
- GtkWidget *combobox, *parent;
+ GtkWidget *combobox, *parent, *label;
gint row;
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
ESource *source = t->source;
- EUri *uri;
- gchar *uri_text;
- static GtkWidget *hidden = NULL;
-
- if (!hidden)
- hidden = gtk_label_new ("");
- if (data->old)
- gtk_widget_destroy (label);
-
- uri_text = e_source_get_uri (t->source);
- uri = e_uri_new (uri_text);
- g_free (uri_text);
- if (strcmp ((const gchar *)uri->protocol, "weather")) {
- e_uri_free (uri);
- return hidden;
- }
- e_uri_free (uri);
+ if (!e_plugin_util_is_source_proto (t->source, "weather"))
+ return NULL;
parent = data->parent;
@@ -618,18 +465,18 @@ e_calendar_weather_check (EPlugin *epl, EConfigHookPageCheckData *data)
{
/* FIXME - check pageid */
ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target;
- EUri *uri;
+ SoupURI *suri;
gboolean ok = FALSE;
- ESourceGroup *group = e_source_peek_group (t->source);
/* always return TRUE if this isn't a weather source */
- if (strncmp (e_source_group_peek_base_uri (group), "weather", 7))
+ if (!e_plugin_util_is_group_proto (e_source_peek_group (t->source), "weather"))
return TRUE;
- uri = e_uri_new (e_source_get_uri (t->source));
+ suri = soup_uri_new (e_source_get_uri (t->source));
/* make sure that the protocol is weather:// and that the path isn't empty */
- ok = (uri->path && strlen (uri->path));
- e_uri_free (uri);
+ ok = suri && suri->path && *suri->path;
+ if (suri)
+ soup_uri_free (suri);
return ok;
}
diff --git a/plugins/default-source/Makefile.am b/plugins/default-source/Makefile.am
index 6f4a9043d1..8afa604ec4 100644
--- a/plugins/default-source/Makefile.am
+++ b/plugins/default-source/Makefile.am
@@ -17,6 +17,7 @@ liborg_gnome_default_source_la_SOURCES = default-source.c
liborg_gnome_default_source_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
liborg_gnome_default_source_la_LIBADD = \
+ $(top_builddir)/e-util/libeutil.la \
$(EVOLUTION_CALENDAR_LIBS) \
$(EVOLUTION_ADDRESSBOOK_LIBS) \
$(GNOME_PLATFORM_LIBS)
diff --git a/plugins/default-source/default-source.c b/plugins/default-source/default-source.c
index 1d8a7e0299..db8423aec6 100644
--- a/plugins/default-source/default-source.c
+++ b/plugins/default-source/default-source.c
@@ -22,12 +22,12 @@
#include <gtk/gtk.h>
#include <e-util/e-config.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <libedataserver/e-source.h>
#include <addressbook/gui/widgets/eab-config.h>
#include <libebook/e-book.h>
#include <libecal/e-cal.h>
-#include <libedataserver/e-source.h>
#include <glib/gi18n.h>
#include <string.h>
@@ -62,71 +62,30 @@ commit_default_book (EPlugin *epl, EConfigTarget *target)
}
-static void
-default_source_changed (GtkWidget *check_box, ESource *source)
-{
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box)))
- e_source_set_property (source, "default", "true");
- else
- e_source_set_property (source, "default", NULL);
-}
-
-static void
-autocomplete_book_changed (GtkWidget *check_box, ESource *source)
-{
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box)))
- e_source_set_property (source, "completion", "true");
- else
- e_source_set_property (source, "completion", NULL);
-}
-
GtkWidget *
org_gnome_default_book (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- GtkWidget *widget;
- ESource *source;
EABConfigTargetSource *book_target;
if (data->old)
return data->old;
- widget = gtk_check_button_new_with_mnemonic (_("Mark as _default address book"));
+
book_target = (EABConfigTargetSource *) data->target;
- source = book_target->source;
- if (e_source_get_property (source, "default"))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
- gtk_container_add (GTK_CONTAINER (data->parent), widget);
-
- g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (default_source_changed), source);
- gtk_widget_show (widget);
- return widget;
+ return e_plugin_util_add_check (data->parent, _("Mark as _default address book"), book_target->source, "default", "true", NULL);
}
GtkWidget *
org_gnome_autocomplete_book (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- GtkWidget *widget;
- ESource *source;
EABConfigTargetSource *book_target;
if (data->old)
return data->old;
- widget = gtk_check_button_new_with_mnemonic (_("A_utocomplete with this address book"));
book_target = (EABConfigTargetSource *) data->target;
- source = book_target->source;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), e_source_get_property (source, "completion") && g_str_equal (e_source_get_property (source, "completion"), "true"));
- gtk_container_add (GTK_CONTAINER (data->parent), widget);
-
- g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (autocomplete_book_changed), source);
- gtk_widget_show (widget);
-
- return widget;
+ return e_plugin_util_add_check (data->parent, _("A_utocomplete with this address book"), book_target->source, "completion", "true", NULL);
}
static const gchar *
@@ -149,26 +108,12 @@ GtkWidget *org_gnome_default_cal (EPlugin *epl, EConfigHookItemFactoryData *data
GtkWidget *
org_gnome_default_cal (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- GtkWidget *widget;
- ESource *source;
ECalConfigTargetSource *cal_target;
- gint i;
if (data->old)
return data->old;
- cal_target = (ECalConfigTargetSource *) data->target;
- source = cal_target->source;
- widget = gtk_check_button_new_with_mnemonic (get_calendar_option_caption (cal_target->source_type));
- if (e_source_get_property (source, "default"))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
-
- i = ((GtkTable *)data->parent)->nrows;
- gtk_table_attach((GtkTable *)data->parent, widget, 1, 2, i, i+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ cal_target = (ECalConfigTargetSource *) data->target;
- g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (default_source_changed), source);
- gtk_widget_show (widget);
- return widget;
+ return e_plugin_util_add_check (data->parent, get_calendar_option_caption (cal_target->source_type), cal_target->source, "default", "true", NULL);
}
diff --git a/plugins/google-account-setup/google-source.c b/plugins/google-account-setup/google-source.c
index 9452422902..26b80f0ec8 100644
--- a/plugins/google-account-setup/google-source.c
+++ b/plugins/google-account-setup/google-source.c
@@ -34,6 +34,7 @@
#include <e-util/e-config.h>
#include <e-util/e-plugin.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <calendar/gui/e-cal-event.h>
@@ -303,85 +304,6 @@ user_changed (GtkEntry *editable, ESource *source)
init_combo_values (GTK_COMBO_BOX (g_object_get_data (G_OBJECT (editable), "CalendarCombo")), _("Default"), NULL);
}
-static gchar *
-get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox)
-{
- gint setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
- switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) {
- case 0:
- /* minutes */
- break;
- case 1:
- /* hours */
- setting *= 60;
- break;
- case 2:
- /* days */
- setting *= 1440;
- break;
- case 3:
- /* weeks - is this *really* necessary? */
- setting *= 10080;
- break;
- default:
- g_warning ("Time unit out of range");
- break;
- }
-
- return g_strdup_printf ("%d", setting);
-}
-
-static void
-spin_changed (GtkSpinButton *spin, ECalConfigTargetSource *t)
-{
- gchar *refresh_str;
- GtkWidget *combobox;
-
- combobox = g_object_get_data (G_OBJECT(spin), "combobox");
-
- refresh_str = get_refresh_minutes ((GtkWidget *)spin, combobox);
- e_source_set_property (t->source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-combobox_changed (GtkComboBox *combobox, ECalConfigTargetSource *t)
-{
- gchar *refresh_str;
- GtkWidget *spin;
-
- spin = g_object_get_data (G_OBJECT(combobox), "spin");
-
- refresh_str = get_refresh_minutes (spin, (GtkWidget *)combobox);
- e_source_set_property (t->source, "refresh", refresh_str);
- g_free (refresh_str);
-}
-
-static void
-set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox)
-{
- gint time;
- gint item_num = 0;
- const gchar *refresh_str = e_source_get_property (source, "refresh");
- time = refresh_str ? atoi (refresh_str) : 30;
-
- if (time && !(time % 10080)) {
- /* weeks */
- item_num = 3;
- time /= 10080;
- } else if (time && !(time % 1440)) {
- /* days */
- item_num = 2;
- time /= 1440;
- } else if (time && !(time % 60)) {
- /* hours */
- item_num = 1;
- time /= 60;
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time);
-}
-
enum {
COL_COLOR = 0, /* GDK_TYPE_COLOR */
COL_TITLE, /* G_TYPE_STRING */
@@ -656,7 +578,6 @@ plugin_google (EPlugin *epl,
EUri *euri;
GtkWidget *parent;
GtkWidget *widget;
- GtkWidget *luser;
GtkWidget *user;
GtkWidget *label;
GtkWidget *combo;
@@ -666,7 +587,7 @@ plugin_google (EPlugin *epl,
GtkCellRenderer *renderer;
GtkListStore *store;
- GtkWidget *combobox, *spin, *hbox;
+ GtkWidget *hbox;
source = t->source;
group = e_source_peek_group (source);
@@ -695,70 +616,22 @@ plugin_google (EPlugin *epl,
/* Build up the UI */
parent = data->parent;
- row = GTK_TABLE (parent)->nrows;
-
- luser = gtk_label_new_with_mnemonic (_("User_name:"));
- gtk_widget_show (luser);
- gtk_misc_set_alignment (GTK_MISC (luser), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent),
- luser, 0, 1,
- row + 1, row + 2,
- GTK_FILL, 0, 0, 0);
- user = gtk_entry_new ();
- gtk_widget_show (user);
+ user = e_plugin_util_add_entry (parent, _("User_name:"), NULL, NULL);
gtk_entry_set_text (GTK_ENTRY (user), username ? username : "");
- gtk_table_attach (GTK_TABLE (parent), user,
- 1, 2, row + 1, row + 2,
- GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (luser), user);
-
- label = gtk_label_new_with_mnemonic (_("Re_fresh:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (parent),
- label,
- 0, 1,
- row + 2, row + 3,
- GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
-
- spin = gtk_spin_button_new_with_range (1, 100, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL(label), spin);
- gtk_widget_show (spin);
- gtk_box_pack_start (GTK_BOX(hbox), spin, FALSE, TRUE, 0);
-
- if (!e_source_get_property (source, "refresh"))
- e_source_set_property (source, "refresh", "30");
-
- combobox = gtk_combo_box_new_text ();
- gtk_widget_show (combobox);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("minutes"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("hours"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("days"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("weeks"));
- set_refresh_time (source, spin, combobox);
- gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, TRUE, 0);
-
- g_object_set_data (G_OBJECT (combobox), "spin", spin);
- g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (combobox_changed), t);
- g_object_set_data (G_OBJECT (spin), "combobox", combobox);
- g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), t);
-
- gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row + 2, row + 3, GTK_EXPAND | GTK_FILL, 0, 0, 0);
-
g_signal_connect (G_OBJECT (user),
"changed",
G_CALLBACK (user_changed),
source);
+ e_plugin_util_add_refresh (parent, _("Re_fresh:"), source, "refresh");
+
+ row = GTK_TABLE (parent)->nrows;
+
label = gtk_label_new_with_mnemonic (_("Cal_endar:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row + 3, row + 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
store = gtk_list_store_new (
NUM_COLUMNS,
@@ -798,7 +671,7 @@ plugin_google (EPlugin *epl,
gtk_widget_set_sensitive (label, username && *username);
gtk_widget_show_all (hbox);
- gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row + 3, row + 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
return widget;
}
diff --git a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
index afccbd3fb7..8eefe3dfce 100644
--- a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
+++ b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml
@@ -8,7 +8,7 @@
<hook class="org.gnome.evolution.calendar.config:1.0">
<group target="source" id="org.gnome.evolution.calendar.calendarProperties">
- <item type="item_table" path="00.general/00.source/15.google" factory="plugin_google"/>
+ <item type="item_table" path="00.general/00.source/99.google" factory="plugin_google"/>
</group>
</hook>
<hook class="org.gnome.evolution.calendar.events:1.0">
@@ -17,7 +17,7 @@
<hook class="org.gnome.evolution.addressbook.config:1.0">
<group target="source" id="com.novell.evolution.addressbook.config.accountEditor">
- <item type="item" path="00.general/10.display/00.google" factory="plugin_google_contacts"/>
+ <item type="item" path="00.general/10.display/99.google" factory="plugin_google_contacts"/>
</group>
</hook>
</e-plugin>
diff --git a/plugins/webdav-account-setup/Makefile.am b/plugins/webdav-account-setup/Makefile.am
index f1096df75f..305d4ff06d 100644
--- a/plugins/webdav-account-setup/Makefile.am
+++ b/plugins/webdav-account-setup/Makefile.am
@@ -15,6 +15,7 @@ liborg_gnome_evolution_webdav_la_SOURCES = \
webdav-contacts-source.c
liborg_gnome_evolution_webdav_la_LIBADD = \
+ $(top_builddir)/e-util/libeutil.la \
$(EPLUGIN_LIBS) \
$(EVOLUTION_ADDRESSBOOK_LIBS) \
$(GNOME_PLATFORM_LIBS)
diff --git a/plugins/webdav-account-setup/webdav-contacts-source.c b/plugins/webdav-account-setup/webdav-contacts-source.c
index 990a541cc9..9f35d0bd54 100644
--- a/plugins/webdav-account-setup/webdav-contacts-source.c
+++ b/plugins/webdav-account-setup/webdav-contacts-source.c
@@ -31,11 +31,11 @@
#include <e-util/e-config.h>
#include <e-util/e-plugin.h>
+#include <e-util/e-plugin-util.h>
#include <addressbook/gui/widgets/eab-config.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
-#include <libedataserver/e-url.h>
#include <libedataserver/e-account-list.h>
#define BASE_URI "webdav://"
@@ -96,48 +96,12 @@ remove_webdav_contacts_source_group(void)
g_object_unref(source_list);
}
-/* stolen from caldav plugin which stole it from calendar-weather eplugin */
-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 void
set_ui_from_source(ui_data *data)
{
ESource *source = data->source;
const gchar *url = e_source_get_uri(source);
- EUri *uri = e_uri_new(url);
+ SoupURI *suri = soup_uri_new (url);
gchar *url_ui;
const gchar *property;
gboolean use_ssl;
@@ -159,75 +123,66 @@ set_ui_from_source(ui_data *data)
gtk_toggle_button_set_active(data->avoid_ifmatch_toggle, avoid_ifmatch);
/* it's really a http or https protocol */
- g_free(uri->protocol);
- uri->protocol = g_strdup(use_ssl ? "https" : "http");
+ if (suri)
+ soup_uri_set_scheme (suri, use_ssl ? "https" : "http");
/* remove user/username and set user field */
- if (uri->user != NULL) {
- gtk_entry_set_text(data->username_entry, uri->user);
- g_free(uri->user);
- uri->user = NULL;
+ if (suri && suri->user != NULL) {
+ gtk_entry_set_text (data->username_entry, suri->user);
+ soup_uri_set_user (suri, NULL);
} else {
gtk_entry_set_text(data->username_entry, "");
}
- url_ui = e_uri_to_string(uri, TRUE);
- gtk_entry_set_text(data->url_entry, url_ui);
+ if (suri)
+ url_ui = soup_uri_to_string (suri, FALSE);
+ else
+ url_ui = g_strdup ("");
+ gtk_entry_set_text (data->url_entry, url_ui);
+ g_free (url_ui);
- g_free(url_ui);
- e_uri_free(uri);
+ if (suri)
+ soup_uri_free (suri);
}
static void
-set_source_from_ui(ui_data *data)
+set_source_from_ui (ui_data *data)
{
ESource *source = data->source;
gboolean avoid_ifmatch = gtk_toggle_button_get_active(data->avoid_ifmatch_toggle);
const gchar *url = gtk_entry_get_text(data->url_entry);
- EUri *uri = e_uri_new(url);
+ SoupURI *suri = soup_uri_new (url);
gchar *url_noprotocol;
gboolean use_ssl;
+ if (!suri)
+ return;
+
e_source_set_property(source, "avoid_ifmatch", avoid_ifmatch ? "1" : "0");
/* put username into uri */
- g_free(uri->user);
- uri->user = g_strdup(gtk_entry_get_text(data->username_entry));
+ soup_uri_set_user (suri, gtk_entry_get_text (data->username_entry));
- if (uri->user[0] != '\0') {
+ if (suri->user && *suri->user) {
e_source_set_property(source, "auth", "plain/password");
- e_source_set_property(source, "username", uri->user);
+ e_source_set_property(source, "username", suri->user);
} else {
e_source_set_property(source, "auth", NULL);
e_source_set_property(source, "username", NULL);
}
/* set use_ssl based on protocol in URL */
- if (strcmp(uri->protocol, "https") == 0) {
+ if (suri->scheme && g_str_equal (suri->scheme, "https")) {
use_ssl = TRUE;
} else {
use_ssl = FALSE;
}
e_source_set_property(source, "use_ssl", use_ssl ? "1" : "0");
- url_noprotocol = print_uri_noproto(uri);
- e_source_set_relative_uri(source, url_noprotocol);
- g_free(url_noprotocol);
- e_uri_free(uri);
-}
-
-static void
-on_entry_changed(GtkEntry *entry, gpointer user_data)
-{
- (void) entry;
- set_source_from_ui(user_data);
-}
-
-static void
-on_toggle_changed(GtkToggleButton *tb, gpointer user_data)
-{
- (void) tb;
- set_source_from_ui(user_data);
+ url_noprotocol = e_plugin_util_uri_no_proto (suri);
+ e_source_set_relative_uri (source, url_noprotocol);
+ g_free (url_noprotocol);
+ soup_uri_free (suri);
}
static void
@@ -246,8 +201,6 @@ plugin_webdav_contacts(EPlugin *epl, EConfigHookItemFactoryData *data)
{
EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
ESource *source;
- ESourceGroup *group;
- const gchar *base_uri;
GtkWidget *parent;
GtkWidget *vbox;
@@ -261,13 +214,10 @@ plugin_webdav_contacts(EPlugin *epl, EConfigHookItemFactoryData *data)
ui_data *uidata;
source = t->source;
- group = e_source_peek_group (source);
-
- base_uri = e_source_group_peek_base_uri (group);
g_object_set_data (G_OBJECT (epl), "wwidget", NULL);
- if (strcmp(base_uri, BASE_URI) != 0) {
+ if (!e_plugin_util_is_group_proto (e_source_peek_group (source), BASE_URI)) {
return NULL;
}
@@ -330,12 +280,9 @@ plugin_webdav_contacts(EPlugin *epl, EConfigHookItemFactoryData *data)
g_object_set_data_full(G_OBJECT(epl), "wwidget", uidata, destroy_ui_data);
g_signal_connect (uidata->box, "destroy", G_CALLBACK (gtk_widget_destroyed), &uidata->box);
- g_signal_connect(G_OBJECT(uidata->username_entry), "changed",
- G_CALLBACK(on_entry_changed), uidata);
- g_signal_connect(G_OBJECT(uidata->url_entry), "changed",
- G_CALLBACK(on_entry_changed), uidata);
- g_signal_connect(G_OBJECT(uidata->avoid_ifmatch_toggle), "toggled",
- G_CALLBACK(on_toggle_changed), uidata);
+ g_signal_connect_swapped (G_OBJECT(uidata->username_entry), "changed", G_CALLBACK (set_source_from_ui), uidata);
+ g_signal_connect_swapped (G_OBJECT(uidata->url_entry), "changed", G_CALLBACK (set_source_from_ui), uidata);
+ g_signal_connect_swapped (G_OBJECT(uidata->avoid_ifmatch_toggle), "toggled", G_CALLBACK (set_source_from_ui), uidata);
return NULL;
}