From 1676d621586bf6280cb2d37ac023c5588935c47c Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Wed, 16 Feb 2011 16:21:02 +0000 Subject: Added authentication function, and another minor fix to the sources iteration --- src/datetime-service.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/datetime-service.c b/src/datetime-service.c index 70a1ed5..cb383c1 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -42,6 +42,7 @@ with this program. If not, see . #include #include #include +#include // Other users of ecal seem to also include these, not sure why they should be included by the above #include #include @@ -418,6 +419,37 @@ update_timezone_menu_items(gpointer user_data) { return FALSE; } +// Authentication function taken from http://git.gnome.org/browse/evolution/tree/calendar/common/authentication.c +static gchar * +auth_func_cb (ECal *ecal, + const gchar *prompt, + const gchar *key, + gpointer user_data) +{ + gboolean remember; + gchar *password, *auth_domain; + ESource *source; + const gchar *component_name; + + source = e_cal_get_source (ecal); + auth_domain = e_source_get_duped_property (source, "auth-domain"); + component_name = auth_domain ? auth_domain : "Calendar"; + password = e_passwords_get_password (component_name, key); + + if (!password) + password = e_passwords_ask_password ( + _("Enter password"), + component_name, key, prompt, + E_PASSWORDS_REMEMBER_FOREVER | + E_PASSWORDS_SECRET | + E_PASSWORDS_ONLINE, + &remember, NULL); + + g_free (auth_domain); + + return password; +} + // Compare function for g_list_sort of ECalComponent objects static gint @@ -428,7 +460,9 @@ compare_appointment_items (ECalComponent *a, struct tm tm_a, tm_b; time_t t_a, t_b; gint retval = 0; - + + if (a == NULL || b == NULL) return retval; + ECalComponentVType vtype = e_cal_component_get_vtype (a); if (vtype == E_CAL_COMPONENT_EVENT) e_cal_component_get_dtstart (a, &datetime_a); @@ -513,13 +547,13 @@ update_appointment_menu_items (gpointer user_data) { for (s = e_source_group_peek_sources (group); s; s = s->next) { ESource *source = E_SOURCE (s->data); ECal *ecal = e_cal_new(source, E_CAL_SOURCE_TYPE_EVENT); - + e_cal_set_auth_func (ecal, (ECalAuthFunc) auth_func_cb, NULL); //icaltimezone * tzone; if (!e_cal_open(ecal, FALSE, &gerror)) { g_debug("Failed to get ecal sources %s", gerror->message); g_error_free(gerror); - gerror = NULL + gerror = NULL; continue; } -- cgit v1.2.3