aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-03-11 15:58:29 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-03-15 02:46:45 +0800
commit346c9fea2b79ea492d77f6948d24ad066493caba (patch)
tree4be8b9c0c7accb0160db649e6585c217cebcf43a
parentf16fe3be2d7ccbc1c2dc94e2f925371fcfb6ab10 (diff)
downloadgsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.tar
gsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.tar.gz
gsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.tar.bz2
gsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.tar.lz
gsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.tar.xz
gsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.tar.zst
gsoc2013-empathy-346c9fea2b79ea492d77f6948d24ad066493caba.zip
Add a Remember Password toggle which remembers the password
This feels a bit awkwardly implemented, for example, if you enter a password but uncheck the toggle, then the password will be removed from the dialog when the account connects (maybe this is the correct behaviour?). No one has really specced out the flow of this, maybe it can be sorted out properly when this code is made more generic.
-rw-r--r--libempathy-gtk/empathy-account-widget-skype.c44
-rw-r--r--libempathy-gtk/empathy-account-widget-skype.ui64
2 files changed, 69 insertions, 39 deletions
diff --git a/libempathy-gtk/empathy-account-widget-skype.c b/libempathy-gtk/empathy-account-widget-skype.c
index 32ee9c9e5..c263c9e2e 100644
--- a/libempathy-gtk/empathy-account-widget-skype.c
+++ b/libempathy-gtk/empathy-account-widget-skype.c
@@ -45,18 +45,21 @@ typedef struct
TpAccount *account;
TpChannel *channel;
char *password;
+ gboolean remember;
} ObserveChannelsData;
static ObserveChannelsData *
observe_channels_data_new (TpAccount *account,
TpChannel *channel,
- const char *password)
+ const char *password,
+ gboolean remember)
{
ObserveChannelsData *data = g_slice_new0 (ObserveChannelsData);
data->account = g_object_ref (account);
data->channel = g_object_ref (channel);
data->password = g_strdup (password);
+ data->remember = remember;
return data;
}
@@ -100,12 +103,12 @@ auth_observer_new_sasl_handler_cb (GObject *obj,
goto finally;
}
- DEBUG ("providing password");
+ DEBUG ("providing password, remember = %s", data->remember ? "yes" : "no");
g_signal_connect (sasl_handler, "invalidated",
G_CALLBACK (auth_observer_sasl_handler_invalidated), NULL);
empathy_server_sasl_handler_provide_password (sasl_handler,
- data->password, TRUE);
+ data->password, data->remember);
finally:
observe_channels_data_free (data);
@@ -148,6 +151,7 @@ auth_observer_observe_channels (TpSimpleObserver *auth_observer,
GStrv available_mechanisms;
GtkWidget *password_entry = user_data;
const char *password = NULL;
+ gboolean remember;
/* we only do this for Psyke */
if (tp_strdiff (
@@ -177,14 +181,15 @@ auth_observer_observe_channels (TpSimpleObserver *auth_observer,
if (tp_str_empty (password))
goto except;
+ /* do we want to remember it */
+ remember = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
+ g_object_get_data (G_OBJECT (password_entry), "remember-password")));
+
DEBUG ("claiming auth channel");
tp_channel_dispatch_operation_claim_async (dispatch_operation,
auth_observer_claim_cb,
- observe_channels_data_new (account, channel, password));
-
- tp_observe_channels_context_accept (context);
- return;
+ observe_channels_data_new (account, channel, password, remember));
except:
tp_observe_channels_context_accept (context);
@@ -443,6 +448,23 @@ account_widget_skype_forget_password (GtkEntry *entry,
}
static void
+account_widget_skype_remember_password_toggled (GtkToggleButton *button,
+ EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ TpAccount *account = empathy_account_settings_get_account (priv->settings);
+
+ /* we only forget the password if the toggle goes inactive */
+ if (gtk_toggle_button_get_active (button))
+ return;
+
+ DEBUG ("forgetting password");
+
+ emp_cli_account_interface_external_password_storage_call_forget_password (
+ TP_PROXY (account), -1, NULL, NULL, NULL, NULL);
+}
+
+static void
account_widget_build_skype_get_privacy_settings_cb (TpProxy *cm,
GHashTable *props,
const GError *in_error,
@@ -713,7 +735,7 @@ empathy_account_widget_build_skype (EmpathyAccountWidget *self,
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
TpAccount *account = empathy_account_settings_get_account (priv->settings);
- GtkWidget *password_entry;
+ GtkWidget *password_entry, *remember_password;
if (priv->simple || priv->creating_account)
{
@@ -725,6 +747,7 @@ empathy_account_widget_build_skype (EmpathyAccountWidget *self,
"vbox_skype_settings_setup", &self->ui_details->widget,
"skype-info-vbox", &skype_info,
"entry_password_setup", &password_entry,
+ "remember-password-setup", &remember_password,
NULL);
account_widget_build_skype_set_pixmap (self->ui_details->gui,
@@ -751,6 +774,7 @@ empathy_account_widget_build_skype (EmpathyAccountWidget *self,
"skype-info-vbox", &skype_info,
"edit-privacy-settings-button", &edit_privacy_settings_button,
"entry_password", &password_entry,
+ "remember-password", &remember_password,
NULL);
empathy_builder_connect (self->ui_details->gui, self,
@@ -758,6 +782,8 @@ empathy_account_widget_build_skype (EmpathyAccountWidget *self,
account_widget_skype_privacy_settings,
"entry_password", "icon-press",
account_widget_skype_forget_password,
+ "remember-password", "toggled",
+ account_widget_skype_remember_password_toggled,
NULL);
if (account != NULL)
@@ -785,6 +811,8 @@ empathy_account_widget_build_skype (EmpathyAccountWidget *self,
* tie the lifetime of the observer to the lifetime of the widget */
g_object_set_data_full (G_OBJECT (self->ui_details->widget), "auth-observer",
auth_observer_new (password_entry), g_object_unref);
+ g_object_set_data (G_OBJECT (password_entry), "remember-password",
+ remember_password);
/* find out if we know the password */
if (account != NULL && tp_proxy_has_interface_by_id (account,
diff --git a/libempathy-gtk/empathy-account-widget-skype.ui b/libempathy-gtk/empathy-account-widget-skype.ui
index 67fb50f5d..1a131d29a 100644
--- a/libempathy-gtk/empathy-account-widget-skype.ui
+++ b/libempathy-gtk/empathy-account-widget-skype.ui
@@ -11,27 +11,13 @@
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
- <property name="column_spacing">12</property>
+ <property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkLabel" id="label_password">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Pass_word:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="label_id">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Skype name:</property>
+ <property name="label" translatable="yes">_Skype name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">entry_id_setup</property>
</object>
@@ -93,6 +79,21 @@ Get one at &lt;a href="http://www.skype.com/go/register"&gt;Skype.com&lt;/a&gt;<
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="remember-password-setup">
+ <property name="label" translatable="yes">Remember pass_word:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
@@ -402,23 +403,9 @@ Get one at &lt;a href="http://www.skype.com/go/register"&gt;Skype.com&lt;/a&gt;<
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
- <property name="column_spacing">12</property>
+ <property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkLabel" id="label_password1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Pass_word:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="label_id1">
<property name="visible">True</property>
<property name="xalign">0</property>
@@ -480,6 +467,21 @@ Get one at &lt;a href="http://www.skype.com/go/register"&gt;Skype.com&lt;/a&gt;<
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="remember-password">
+ <property name="label" translatable="yes">Remember pass_word:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
</object>