[evolution-kolab/ek-wip-porting] EBookBackendKolab: improved handling of online state switching
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] EBookBackendKolab: improved handling of online state switching
- Date: Tue, 20 Mar 2012 14:24:31 +0000 (UTC)
commit f627853934f8a4c1118cb68704a1140483ace18e
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Tue Mar 20 15:20:25 2012 +0100
EBookBackendKolab: improved handling of online state switching
* force authentication if password is missing
* kolab_util_backend_deploy_mode_by_backend()
may return FALSE with no GError set
src/addressbook/e-book-backend-kolab.c | 70 ++++++++++++++++++++------------
1 files changed, 44 insertions(+), 26 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-kolab.c b/src/addressbook/e-book-backend-kolab.c
index 93801b3..2ec0f50 100644
--- a/src/addressbook/e-book-backend-kolab.c
+++ b/src/addressbook/e-book-backend-kolab.c
@@ -73,6 +73,16 @@ struct _EBookBackendKolabPrivate
G_DEFINE_TYPE (EBookBackendKolab, e_book_backend_kolab, E_TYPE_BOOK_BACKEND_SYNC)
/*----------------------------------------------------------------------------*/
+/* forward declarations */
+
+static void
+e_book_backend_kolab_open (EBookBackendSync *backend,
+ EDataBook *book,
+ GCancellable *cancellable,
+ gboolean only_if_exists,
+ GError **error);
+
+/*----------------------------------------------------------------------------*/
/* internal statics */
static void
@@ -128,19 +138,18 @@ book_backend_kolab_signal_online_cb (GObject *object)
*
*/
- if (priv->mode_switch_err != NULL) {
- g_warning ("%s()[%u]: Online mode switching error pending (%s)",
- __func__, __LINE__, priv->mode_switch_err->message);
- g_error_free (priv->mode_switch_err);
- priv->mode_switch_err = NULL;
- }
(void) kolab_util_backend_deploy_mode_by_backend (priv->book_koma,
online,
NULL, /* GCancellable (see above )*/
&(priv->mode_switch_err));
if (priv->mode_switch_err) {
- g_warning ("%s()[%u]: Online mode switching error pending (%s)",
- __func__, __LINE__, priv->mode_switch_err->message);
+ g_warning ("%s()[%u]: Online mode switching error pending, (%s), Domain %s Code %i",
+ __func__, __LINE__,
+ priv->mode_switch_err->message,
+ g_quark_to_string (priv->mode_switch_err->domain),
+ priv->mode_switch_err->code);
+ g_error_free (priv->mode_switch_err);
+ priv->mode_switch_err = NULL;
}
}
@@ -165,7 +174,7 @@ book_backend_kolab_notify_opened (EBookBackendKolab *self,
return FALSE;
}
e_book_backend_notify_online (bbackend,
- tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE ? TRUE : FALSE);
+ tmp_mode == KOLAB_MAIL_ACCESS_OPMODE_ONLINE ? TRUE : FALSE);
e_book_backend_notify_readonly (bbackend, FALSE);
e_book_backend_notify_opened (bbackend, NULL);
@@ -286,6 +295,8 @@ e_book_backend_kolab_open (EBookBackendSync *backend,
(gpointer *) &tmp_key,
(gpointer *) &tmp_koma);
if (ok) {
+ gchar *passwd = NULL;
+
/* There already is a KoMA instance for user_at_server.
* Use it and return
*/
@@ -302,19 +313,26 @@ e_book_backend_kolab_open (EBookBackendSync *backend,
NULL,
sourcename,
&sync_value);
- g_object_unref (ksettings);
- /* We should have received authentication data (password)
- * at this point, since it was requested and stored when
- * the KolabMailAccess object was initially created.
- * We can just skip the AuthenticationRequested part here
- * and move along...
+
+ /* We may find that we do not yet have a password set.
+ * In case we're requested to go online, we will need
+ * one, so we need to get authentication data first.
*/
- online = e_backend_get_online (E_BACKEND (backend));
- ok = kolab_util_backend_deploy_mode_by_backend (priv->book_koma,
- online,
- cancellable,
- &tmp_err);
- if (! ok) {
+ passwd = g_strdup (kolab_settings_handler_get_char_field (ksettings,
+ KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD,
+ NULL));
+ g_object_unref (ksettings);
+ if (passwd == NULL) {
+ e_book_backend_notify_auth_required (E_BOOK_BACKEND (self), TRUE, NULL);
+ return;
+ }
+ g_free (passwd);
+
+ (void) kolab_util_backend_deploy_mode_by_backend (priv->book_koma,
+ online,
+ cancellable,
+ &tmp_err);
+ if (tmp_err != NULL) {
kolab_util_contact_err_to_edb_err (error, tmp_err, __func__, __LINE__);
g_error_free (tmp_err);
return;
@@ -1005,11 +1023,11 @@ e_book_backend_kolab_authenticate_user (EBookBackendSync *backend,
priv->auth_received = TRUE;
online = e_backend_get_online (E_BACKEND (backend));
- ok = kolab_util_backend_deploy_mode_by_backend (priv->book_koma,
- online,
- cancellable,
- &tmp_err);
- if (! ok) {
+ (void) kolab_util_backend_deploy_mode_by_backend (priv->book_koma,
+ online,
+ cancellable,
+ &tmp_err);
+ if (tmp_err != NULL) {
kolab_util_contact_err_to_edb_err (error, tmp_err, __func__, __LINE__);
g_error_free (tmp_err);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]