diff options
author | Veerapuram Varadhan <vvaradan@src.gnome.org> | 2005-12-06 16:39:46 +0800 |
---|---|---|
committer | Veerapuram Varadhan <vvaradan@src.gnome.org> | 2005-12-06 16:39:46 +0800 |
commit | 5c0967e294e835aa096e0a636232f7419323f4ff (patch) | |
tree | 84038fa5bdfc77be2543be82e303df3a0ab5e57a /calendar/conduits | |
parent | bd1f4fbcd820f34571df425769ede23f7318811f (diff) | |
download | gsoc2013-evolution-5c0967e294e835aa096e0a636232f7419323f4ff.tar.gz gsoc2013-evolution-5c0967e294e835aa096e0a636232f7419323f4ff.tar.zst gsoc2013-evolution-5c0967e294e835aa096e0a636232f7419323f4ff.zip |
Authenticate by reading the stored-password for calendar that has "auth"
* conduits/calendar/calendar-conduit.c (start_calendar_server):
Authenticate by reading the stored-password for calendar that has
"auth" property set.
(pre_sync): Moved setting of timezone to start_calendar_server as
per the current e-d-s requirements.
** Fixes #316315
svn path=/trunk/; revision=30728
Diffstat (limited to 'calendar/conduits')
-rw-r--r-- | calendar/conduits/calendar/calendar-conduit.c | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index f58d56c13d..531773ef08 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -28,6 +28,8 @@ #include <libecal/e-cal-types.h> #include <libecal/e-cal.h> #include <libecal/e-cal-time-util.h> +#include <libedataserver/e-url.h> +#include <libedataserverui/e-passwords.h> #include <pi-source.h> #include <pi-socket.h> #include <pi-dlp.h> @@ -426,21 +428,61 @@ static char *print_remote (GnomePilotRecord *remote) return buff; } +static char * +auth_func_cb (ECal *ecal, const char* prompt, const char *key, gpointer user_data) +{ + char *password; + ESource *source; + const gchar *auth_domain, *component_name; + + source = e_cal_get_source (ecal); + auth_domain = e_source_get_property (source, "auth-domain"); + component_name = auth_domain ? auth_domain : "Calendar"; + password = e_passwords_get_password (component_name, key); + + return password; +} + static int start_calendar_server (ECalConduitContext *ctxt) { + char *str_uri = NULL; + char *pass_key = NULL; + int retval = 0; + g_return_val_if_fail (ctxt != NULL, -2); if (ctxt->cfg->source) { ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_EVENT); + /* Set the default timezone on the backend. + As of Evo. 2.5.x, timezone should be set before + calling e_cal_open. + */ + + if (ctxt->timezone) { + if (!e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL)) + return -1; + } + + if (e_source_get_property (ctxt->cfg->source, "auth")) { + EUri *e_uri; + + LOG (g_message ("Authenticating calendar\n")); + str_uri = e_source_get_uri (ctxt->cfg->source); + e_uri = e_uri_new (str_uri); + pass_key = e_uri_to_string (e_uri, FALSE); + e_uri_free (e_uri); + if (ctxt->client) + e_cal_set_auth_func (ctxt->client, (ECalAuthFunc) auth_func_cb, NULL); + } if (!e_cal_open (ctxt->client, TRUE, NULL)) - return -1; + retval = -1; } else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_EVENT, NULL, NULL, NULL)) { - return -1; + retval = -1; } - - return 0; - + g_free (str_uri); + g_free (pass_key); + return retval; } /* Utility routines */ @@ -1373,22 +1415,16 @@ pre_sync (GnomePilotConduit *conduit, ctxt->dbi = dbi; ctxt->client = NULL; - if (start_calendar_server (ctxt) != 0) { - WARN(_("Could not start evolution-data-server")); - gnome_pilot_conduit_error (conduit, _("Could not start evolution-data-server")); - return -1; - } - /* Get the timezone */ ctxt->timezone = get_default_timezone (); if (ctxt->timezone == NULL) return -1; LOG (g_message ( " Using timezone: %s", icaltimezone_get_tzid (ctxt->timezone) )); - /* Set the default timezone on the backend. */ - if (ctxt->timezone) { - if (!e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL)) - return -1; + if (start_calendar_server (ctxt) != 0) { + WARN(_("Could not start evolution-data-server")); + gnome_pilot_conduit_error (conduit, _("Could not start evolution-data-server")); + return -1; } /* Get the default component */ |