aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-03-03 10:35:45 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-03-03 10:40:52 +0800
commit60b1c56a90020621eaddcfcf064957ac748955cd (patch)
tree342a9dff54a68e70948f52281068434978b27ca8
parentfb03f35e9a0a0a4bf73ffe789e659c770a1d75ba (diff)
downloadgsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.tar
gsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.tar.gz
gsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.tar.bz2
gsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.tar.lz
gsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.tar.xz
gsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.tar.zst
gsoc2013-empathy-60b1c56a90020621eaddcfcf064957ac748955cd.zip
Only show the "Remember password" tickybox if we can do that
-rw-r--r--libempathy-gtk/empathy-password-dialog.c5
-rw-r--r--libempathy/empathy-server-sasl-handler.c37
-rw-r--r--libempathy/empathy-server-sasl-handler.h3
3 files changed, 44 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-password-dialog.c b/libempathy-gtk/empathy-password-dialog.c
index b07932ee2..fc789b741 100644
--- a/libempathy-gtk/empathy-password-dialog.c
+++ b/libempathy-gtk/empathy-password-dialog.c
@@ -294,7 +294,10 @@ empathy_password_dialog_constructed (GObject *object)
priv->ticky = gtk_check_button_new_with_label (_("Remember password"));
gtk_box_pack_start (box, priv->ticky, FALSE, FALSE, 0);
- gtk_widget_show (priv->ticky);
+
+ /* only show it if we actually support it */
+ if (empathy_server_sasl_handler_can_save_response_somewhere (priv->handler))
+ gtk_widget_show (priv->ticky);
g_signal_connect (dialog, "response",
G_CALLBACK (password_dialog_response_cb), dialog);
diff --git a/libempathy/empathy-server-sasl-handler.c b/libempathy/empathy-server-sasl-handler.c
index eb59429cc..b35c18136 100644
--- a/libempathy/empathy-server-sasl-handler.c
+++ b/libempathy/empathy-server-sasl-handler.c
@@ -498,3 +498,40 @@ empathy_server_sasl_handler_has_password (EmpathyServerSASLHandler *handler)
return (priv->password != NULL);
}
+
+/**
+ * empathy_server_sasl_handler_can_save_response_somewhere:
+ * @self:
+ *
+ * Returns: %TRUE if the response can be saved somewhere, either the keyring
+ * or via Ch.I.CredentialsStorage
+ */
+gboolean
+empathy_server_sasl_handler_can_save_response_somewhere (
+ EmpathyServerSASLHandler *self)
+{
+ EmpathyServerSASLHandlerPriv *priv;
+ gboolean may_save_response, may_save_response_valid;
+ gboolean has_storage_iface;
+
+ g_return_val_if_fail (EMPATHY_IS_SERVER_SASL_HANDLER (self), FALSE);
+
+ priv = self->priv;
+
+ /* determine if we are permitted to save the password locally */
+ may_save_response = tp_asv_get_boolean (
+ tp_channel_borrow_immutable_properties (priv->channel),
+ TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE,
+ &may_save_response_valid);
+
+ if (!may_save_response_valid)
+ {
+ DEBUG ("MaySaveResponse unknown, assuming TRUE");
+ may_save_response = TRUE;
+ }
+
+ has_storage_iface = tp_proxy_has_interface_by_id (priv->channel,
+ EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE);
+
+ return may_save_response || has_storage_iface;
+}
diff --git a/libempathy/empathy-server-sasl-handler.h b/libempathy/empathy-server-sasl-handler.h
index 1eedc5b27..d89a4064f 100644
--- a/libempathy/empathy-server-sasl-handler.h
+++ b/libempathy/empathy-server-sasl-handler.h
@@ -77,6 +77,9 @@ TpAccount * empathy_server_sasl_handler_get_account (
gboolean empathy_server_sasl_handler_has_password (
EmpathyServerSASLHandler *handler);
+gboolean empathy_server_sasl_handler_can_save_response_somewhere (
+ EmpathyServerSASLHandler *self);
+
G_END_DECLS
#endif /* #ifndef __EMPATHY_SERVER_SASL_HANDLER_H__*/