[evolution-kolab] KolabMailAccess: added API function to make (in)visible the password
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] KolabMailAccess: added API function to make (in)visible the password
- Date: Tue, 11 Sep 2012 15:47:10 +0000 (UTC)
commit 15b55fdc446aa4a5ca4a4d4a901d2d628ea8c231
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Tue Sep 11 17:35:42 2012 +0200
KolabMailAccess: added API function to make (in)visible the password
* added a function to (un)expose the password used for IMAP
authentication by KolabMailImapClient via the KolabSettingsHandler
instance
* the KolabSettingsHandler instance is passed on to all major
sub-objects in KolabMailAccess, so if set visible, these
instances can read the password from KolabSettingsHandler
* once unset, the password is removed from the KolabSettingsHandler
(can be set again)
src/libekolab/kolab-mail-access.c | 49 +++++++++++++++++++++++++++++++++++++
src/libekolab/kolab-mail-access.h | 4 +++
2 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/kolab-mail-access.c b/src/libekolab/kolab-mail-access.c
index 6ae7c49..f07069e 100644
--- a/src/libekolab/kolab-mail-access.c
+++ b/src/libekolab/kolab-mail-access.c
@@ -1950,6 +1950,55 @@ kolab_mail_access_get_opmode (KolabMailAccess *self,
/*----------------------------------------------------------------------------*/
+/* password handling */
+
+/**
+ * kolab_mail_access_password_set_visible:
+ * @self: a #KolabMailAccess instance
+ * @visible: whether or not to make the password visible
+ *
+ * A password will be known to the #CamelService which is part of
+ * our #KolabMailImapClient instance, once authentication with the
+ * Kolab IMAP server was successful (online mode required).
+ * Call this function with @visible set to TRUE to make this
+ * password accessible via the #KolabSettingsHandler. If called
+ * with @visible set to FALSE, the password will be removed
+ * from the #KolabSettingsHandler instance.
+ *
+ * Since: 3.6
+ */
+void
+kolab_mail_access_password_set_visible (KolabMailAccess *self,
+ gboolean visible)
+{
+ KolabMailAccessPrivate *priv = NULL;
+ gchar *passwd = NULL;
+ GError *tmp_err = NULL;
+
+ g_assert (KOLAB_IS_MAIL_ACCESS (self));
+
+ priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
+ g_return_if_fail (priv->client != NULL);
+
+ g_mutex_lock (&(priv->big_lock));
+
+ if (visible)
+ passwd = g_strdup (kolab_mail_imap_client_get_password (priv->client));
+
+ kolab_settings_handler_set_char_field (priv->ksettings,
+ KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD,
+ passwd,
+ &tmp_err);
+ if (tmp_err != NULL) {
+ g_warning ("%s()[%u]: %s",
+ __func__, __LINE__, tmp_err->message);
+ g_error_free (tmp_err);
+ }
+
+ g_mutex_unlock (&(priv->big_lock));
+}
+
+/*----------------------------------------------------------------------------*/
/* UID/KolabMailHandle API functions */
/**
diff --git a/src/libekolab/kolab-mail-access.h b/src/libekolab/kolab-mail-access.h
index 163d399..8c0a62f 100644
--- a/src/libekolab/kolab-mail-access.h
+++ b/src/libekolab/kolab-mail-access.h
@@ -165,6 +165,10 @@ KolabMailAccessOpmodeID
kolab_mail_access_get_opmode (KolabMailAccess *self,
GError **err);
+void
+kolab_mail_access_password_set_visible (KolabMailAccess *self,
+ gboolean visible);
+
GList*
kolab_mail_access_query_sources (KolabMailAccess *self,
GError **err);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]