From b1a60391b1ca744b3bd5c3218488ccd4cab9b86c Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 09:32:06 +0000 Subject: account-settings: store the TpProtocol object and notify::ready when it's prepared Signed-off-by: Jonny Lamb --- libempathy/empathy-account-settings.c | 50 ++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index e5191a96c..c5c1be8b1 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -59,6 +59,7 @@ struct _EmpathyAccountSettingsPriv TpAccountManager *account_manager; TpConnectionManager *manager; + TpProtocol *protocol_obj; TpAccount *account; gchar *cm_name; @@ -80,6 +81,7 @@ struct _EmpathyAccountSettingsPriv GList *required_params; gulong managers_ready_id; + gboolean preparing_protocol; GSimpleAsyncResult *apply_result; }; @@ -336,6 +338,10 @@ empathy_account_settings_dispose (GObject *object) g_object_unref (priv->account); priv->account = NULL; + if (priv->protocol_obj != NULL) + g_object_unref (priv->protocol_obj); + priv->protocol_obj = NULL; + /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_account_settings_parent_class)->dispose) G_OBJECT_CLASS (empathy_account_settings_parent_class)->dispose (object); @@ -384,11 +390,30 @@ empathy_account_settings_finalize (GObject *object) G_OBJECT_CLASS (empathy_account_settings_parent_class)->finalize (object); } +static void +empathy_account_settings_protocol_obj_prepared_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyAccountSettings *self = user_data; + GError *error = NULL; + + if (!tp_proxy_prepare_finish (source, result, &error)) + { + DEBUG ("Failed to prepare protocol object: %s", error->message); + g_clear_error (&error); + return; + } + + empathy_account_settings_check_readyness (self); +} + static void empathy_account_settings_check_readyness (EmpathyAccountSettings *self) { EmpathyAccountSettingsPriv *priv = GET_PRIV (self); const TpConnectionManagerProtocol *tp_protocol; + GQuark features[] = { TP_PROTOCOL_FEATURE_CORE, 0 }; if (priv->ready) return; @@ -400,12 +425,17 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) if (!empathy_connection_managers_is_ready (priv->managers)) return; - priv->manager = empathy_connection_managers_get_cm ( - priv->managers, priv->cm_name); + if (priv->manager == NULL) + { + priv->manager = empathy_connection_managers_get_cm ( + priv->managers, priv->cm_name); + } if (priv->manager == NULL) return; + g_object_ref (priv->manager); + if (priv->account != NULL) { g_free (priv->display_name); @@ -440,7 +470,21 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) } } - g_object_ref (priv->manager); + if (priv->protocol_obj == NULL) + { + priv->protocol_obj = g_object_ref ( + tp_connection_manager_get_protocol_object (priv->manager, + priv->protocol)); + } + + if (!tp_proxy_is_prepared (priv->protocol_obj, TP_PROTOCOL_FEATURE_CORE) + && !priv->preparing_protocol) + { + priv->preparing_protocol = TRUE; + tp_proxy_prepare_async (priv->protocol_obj, features, + empathy_account_settings_protocol_obj_prepared_cb, self); + return; + } priv->ready = TRUE; g_object_notify (G_OBJECT (self), "ready"); -- cgit v1.2.3 From 5f2776557174cf952c465c9b13960238574c8481 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 12:01:53 +0000 Subject: account-settings: add support for saving the password in the keyring ourselves Only do this if the CM supports popping up SASL-enabled auth channels. Signed-off-by: Jonny Lamb --- libempathy/empathy-account-settings.c | 164 +++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 3 deletions(-) diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index c5c1be8b1..abfc8f0ec 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -29,6 +29,7 @@ #include "empathy-account-settings.h" #include "empathy-connection-managers.h" +#include "empathy-keyring.h" #include "empathy-utils.h" #include "empathy-idle.h" @@ -70,6 +71,15 @@ struct _EmpathyAccountSettingsPriv gboolean display_name_overridden; gboolean ready; + gboolean supports_sasl; + gboolean password_changed; + + gchar *password; + gchar *password_original; + + gboolean password_retrieved; + gboolean password_requested; + /* Parameter name (gchar *) -> parameter value (GValue) */ GHashTable *parameters; /* Keys are parameter names from the hash above (gchar *). @@ -373,6 +383,8 @@ empathy_account_settings_finalize (GObject *object) g_free (priv->service); g_free (priv->display_name); g_free (priv->icon_name); + g_free (priv->password); + g_free (priv->password_original); if (priv->required_params != NULL) { @@ -408,6 +420,39 @@ empathy_account_settings_protocol_obj_prepared_cb (GObject *source, empathy_account_settings_check_readyness (self); } +static void +empathy_account_settings_get_password_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyAccountSettings *self = user_data; + EmpathyAccountSettingsPriv *priv = GET_PRIV (self); + const gchar *password; + GError *error = NULL; + + password = empathy_keyring_get_password_finish (TP_ACCOUNT (source), + result, &error); + + if (error != NULL) + { + DEBUG ("Failed to get password: %s", error->message); + g_clear_error (&error); + } + + /* It doesn't really matter if getting the password failed; that + * just means that it's not there, or let's act like that at + * least. */ + + g_assert (priv->password == NULL); + + priv->password = g_strdup (password); + priv->password_original = g_strdup (password); + + priv->password_retrieved = TRUE; + + empathy_account_settings_check_readyness (self); +} + static void empathy_account_settings_check_readyness (EmpathyAccountSettings *self) { @@ -485,6 +530,25 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) empathy_account_settings_protocol_obj_prepared_cb, self); return; } + else + { + if (tp_strv_contains (tp_protocol_get_authentication_types ( + priv->protocol_obj), + TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION)) + { + priv->supports_sasl = TRUE; + } + } + + if (priv->supports_sasl && !priv->password_retrieved + && !priv->password_requested) + { + priv->password_requested = TRUE; + + empathy_keyring_get_password_async (priv->account, + empathy_account_settings_get_password_cb, self); + return; + } priv->ready = TRUE; g_object_notify (G_OBJECT (self), "ready"); @@ -745,6 +809,14 @@ empathy_account_settings_unset (EmpathyAccountSettings *settings, if (empathy_account_settings_is_unset (settings, param)) return; + if (priv->supports_sasl && !tp_strdiff (param, "password")) + { + g_free (priv->password); + priv->password = NULL; + priv->password_changed = TRUE; + return; + } + v = g_strdup (param); g_array_append_val (priv->unset_parameters, v); @@ -758,14 +830,24 @@ empathy_account_settings_discard_changes (EmpathyAccountSettings *settings) g_hash_table_remove_all (priv->parameters); empathy_account_settings_free_unset_parameters (settings); + + priv->password_changed = FALSE; + g_free (priv->password); + priv->password = g_strdup (priv->password_original); } const gchar * empathy_account_settings_get_string (EmpathyAccountSettings *settings, const gchar *param) { + EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); const GValue *v; + if (!tp_strdiff (param, "password") && priv->supports_sasl) + { + return priv->password; + } + v = empathy_account_settings_get (settings, param); if (v == NULL || !G_VALUE_HOLDS_STRING (v)) @@ -960,7 +1042,16 @@ empathy_account_settings_set_string (EmpathyAccountSettings *settings, g_return_if_fail (param != NULL); g_return_if_fail (value != NULL); - tp_asv_set_string (priv->parameters, g_strdup (param), value); + if (!tp_strdiff (param, "password") && priv->supports_sasl) + { + g_free (priv->password); + priv->password = g_strdup (value); + priv->password_changed = TRUE; + } + else + { + tp_asv_set_string (priv->parameters, g_strdup (param), value); + } account_settings_remove_from_unset (settings, param); } @@ -1195,6 +1286,55 @@ empathy_account_settings_set_icon_name_finish ( return TRUE; } +static void +empathy_account_settings_processed_password (GObject *source, + GAsyncResult *result, + gpointer user_data, + gpointer finish_func) +{ + EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (user_data); + EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); + GSimpleAsyncResult *r; + GError *error = NULL; + gboolean (*func) (TpAccount *source, GAsyncResult *result, GError **error) = + finish_func; + + g_free (priv->password_original); + priv->password_original = g_strdup (priv->password); + + if (!func (TP_ACCOUNT (source), result, &error)) + { + g_simple_async_result_set_from_error (priv->apply_result, error); + g_error_free (error); + } + + empathy_account_settings_discard_changes (settings); + + r = priv->apply_result; + priv->apply_result = NULL; + + g_simple_async_result_complete (r); + g_object_unref (r); +} + +static void +empathy_account_settings_set_password_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + empathy_account_settings_processed_password (source, result, user_data, + empathy_keyring_set_password_finish); +} + +static void +empathy_account_settings_delete_password_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + empathy_account_settings_processed_password (source, result, user_data, + empathy_keyring_delete_password_finish); +} + static void empathy_account_settings_account_updated (GObject *source, GAsyncResult *result, @@ -1210,12 +1350,30 @@ empathy_account_settings_account_updated (GObject *source, { g_simple_async_result_set_from_error (priv->apply_result, error); g_error_free (error); + goto out; } - else + + /* Only set the password in the keyring if the CM supports SASL and + * it's changed. */ + if (priv->supports_sasl && priv->password_changed) { - empathy_account_settings_discard_changes (settings); + if (priv->password != NULL) + { + empathy_keyring_set_password_async (priv->account, priv->password, + empathy_account_settings_set_password_cb, settings); + } + else + { + empathy_keyring_delete_password_async (priv->account, + empathy_account_settings_delete_password_cb, settings); + } + + return; } +out: + empathy_account_settings_discard_changes (settings); + r = priv->apply_result; priv->apply_result = NULL; -- cgit v1.2.3 From b2d04d8965c6fa63c6aa10a4c2197619f5234ef5 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 12:42:36 +0000 Subject: account-widget: hook up the remember password toggle button Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-widget.c | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index d96de2b34..5035ea7dd 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -1989,6 +1989,24 @@ add_register_buttons (EmpathyAccountWidget *self, } #endif /* HAVE_MEEGO */ +static void +remember_password_toggled_cb (GtkToggleButton *button, + EmpathyAccountWidget *self) +{ + EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + + if (gtk_toggle_button_get_active (button)) + { + gtk_widget_set_sensitive (priv->param_password_widget, TRUE); + } + else + { + gtk_widget_set_sensitive (priv->param_password_widget, FALSE); + gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), ""); + empathy_account_settings_unset (priv->settings, "password"); + } +} + static void do_constructed (GObject *obj) { @@ -2074,6 +2092,26 @@ do_constructed (GObject *obj) NULL); } + /* remember password */ + if (priv->param_password_widget != NULL) + { + GObject *button; + + button = gtk_builder_get_object ( + self->ui_details->gui, "remember_password"); + + if (button != NULL) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + !EMP_STR_EMPTY (empathy_account_settings_get_string ( + priv->settings, "password"))); + + g_signal_connect (button, "toggled", + G_CALLBACK (remember_password_toggled_cb), self); + remember_password_toggled_cb (GTK_TOGGLE_BUTTON (button), self); + } + } + /* dup and init the account-manager */ priv->account_manager = tp_account_manager_dup (); -- cgit v1.2.3 From e1db9121d3018495f97bcb41caa3805b3672afbc Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 12:44:44 +0000 Subject: password-dialog: re-enable showing the Remember password check button Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-password-dialog.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libempathy-gtk/empathy-password-dialog.c b/libempathy-gtk/empathy-password-dialog.c index 3c514ee82..5608bb035 100644 --- a/libempathy-gtk/empathy-password-dialog.c +++ b/libempathy-gtk/empathy-password-dialog.c @@ -264,15 +264,8 @@ empathy_password_dialog_constructed (GObject *object) /* remember password ticky box */ priv->ticky = gtk_check_button_new_with_label (_("Remember password")); - /* Don't add this to the dialog yet because we haven't set up - * everything in the UI properly yet and the MC transition isn't - * ready etc. so we'll just force it to never remember a - * password. */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->ticky), FALSE); - /* gtk_box_pack_start (box, priv->ticky, FALSE, FALSE, 0); gtk_widget_show (priv->ticky); - */ g_signal_connect (dialog, "response", G_CALLBACK (password_dialog_response_cb), dialog); -- cgit v1.2.3 From 373bf0d7ca7373a45a71e46f161695cc951a7316 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 12:57:45 +0000 Subject: account-settings: don't call TpAccount functions if we've not created it yet We're creating the account so the account isn't around yet. Signed-off-by: Jonny Lamb --- libempathy/empathy-account-settings.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index abfc8f0ec..e0a24b4d6 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -238,8 +238,12 @@ empathy_account_settings_constructed (GObject *object) TP_ACCOUNT_FEATURE_STORAGE, 0 }; - tp_proxy_prepare_async (priv->account, features, - empathy_account_settings_account_ready_cb, self); + if (priv->account != NULL) + { + tp_proxy_prepare_async (priv->account, features, + empathy_account_settings_account_ready_cb, self); + } + tp_g_signal_connect_object (priv->managers, "notify::ready", G_CALLBACK (empathy_account_settings_managers_ready_cb), object, 0); } @@ -540,8 +544,10 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) } } + /* priv->account won't be a proper account if it's the account + * assistant showing this widget. */ if (priv->supports_sasl && !priv->password_retrieved - && !priv->password_requested) + && !priv->password_requested && priv->account != NULL) { priv->password_requested = TRUE; -- cgit v1.2.3 From c98f95bcef9336d82d303fc10b4c60ff90270885 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 12:58:54 +0000 Subject: account-widget: handle the remember password widget with the simple widget Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-widget-yahoo.ui | 34 +++++++++++++++++++++++- libempathy-gtk/empathy-account-widget.c | 36 +++++++++++++++++--------- 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/libempathy-gtk/empathy-account-widget-yahoo.ui b/libempathy-gtk/empathy-account-widget-yahoo.ui index acc60de74..16044f3c8 100644 --- a/libempathy-gtk/empathy-account-widget-yahoo.ui +++ b/libempathy-gtk/empathy-account-widget-yahoo.ui @@ -16,7 +16,7 @@ True - 3 + 4 2 12 6 @@ -91,6 +91,25 @@ 2 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + @@ -357,5 +376,18 @@ 3 + + + Remember password + True + True + False + True + True + + + 4 + + diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index 5035ea7dd..27cb882bb 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -109,6 +109,8 @@ typedef struct { GtkWidget *param_account_widget; GtkWidget *param_password_widget; + GtkWidget *remember_password_widget; + /* Used only for IRC accounts */ EmpathyIrcNetworkChooser *irc_network_chooser; @@ -1603,6 +1605,9 @@ account_widget_build_yahoo (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); } else { @@ -1622,6 +1627,9 @@ account_widget_build_yahoo (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); } } @@ -2093,23 +2101,27 @@ do_constructed (GObject *obj) } /* remember password */ - if (priv->param_password_widget != NULL) + if (priv->param_password_widget != NULL + && priv->remember_password_widget != NULL) { - GObject *button; - - button = gtk_builder_get_object ( - self->ui_details->gui, "remember_password"); - - if (button != NULL) + if (priv->simple) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (priv->remember_password_widget), TRUE); + } + else + { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (priv->remember_password_widget), !EMP_STR_EMPTY (empathy_account_settings_get_string ( priv->settings, "password"))); - - g_signal_connect (button, "toggled", - G_CALLBACK (remember_password_toggled_cb), self); - remember_password_toggled_cb (GTK_TOGGLE_BUTTON (button), self); } + + g_signal_connect (priv->remember_password_widget, "toggled", + G_CALLBACK (remember_password_toggled_cb), self); + + remember_password_toggled_cb ( + GTK_TOGGLE_BUTTON (priv->remember_password_widget), self); } /* dup and init the account-manager */ -- cgit v1.2.3 From d180fb24e4039659e5f731bbbf80a827aefe517f Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 16:04:00 +0000 Subject: event-manager: add the account to the EmpathyEvent struct Signed-off-by: Jonny Lamb --- src/empathy-event-manager.c | 35 ++++++++++++++++++++++------------- src/empathy-event-manager.h | 1 + 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 5516328cc..2f947478b 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -170,6 +170,11 @@ event_free (EventPriv *event) g_object_unref (event->public.contact); } + if (event->public.account) + { + g_object_unref (event->public.account); + } + g_slice_free (EventPriv, event); } @@ -212,6 +217,7 @@ display_notify_area (EmpathyEventManager *self) static void event_manager_add (EmpathyEventManager *manager, + TpAccount *account, EmpathyContact *contact, EmpathyEventType type, const gchar *icon_name, @@ -225,6 +231,7 @@ event_manager_add (EmpathyEventManager *manager, EventPriv *event; event = g_slice_new0 (EventPriv); + event->public.account = account != NULL ? g_object_ref (account) : NULL; event->public.contact = contact ? g_object_ref (contact) : NULL; event->public.type = type; event->public.icon_name = g_strdup (icon_name); @@ -549,9 +556,9 @@ event_manager_chat_message_received_cb (EmpathyTpChat *tp_chat, event_update (approval->manager, event, EMPATHY_IMAGE_NEW_MESSAGE, header, msg); else - event_manager_add (approval->manager, sender, EMPATHY_EVENT_TYPE_CHAT, - EMPATHY_IMAGE_NEW_MESSAGE, header, msg, approval, - event_text_channel_process_func, NULL); + event_manager_add (approval->manager, NULL, sender, + EMPATHY_EVENT_TYPE_CHAT, EMPATHY_IMAGE_NEW_MESSAGE, header, msg, + approval, event_text_channel_process_func, NULL); empathy_sound_manager_play (priv->sound_mgr, window, EMPATHY_SOUND_CONVERSATION_NEW); @@ -625,8 +632,8 @@ event_manager_media_channel_got_contact (EventManagerApproval *approval) video ? _("Incoming video call from %s") :_("Incoming call from %s"), empathy_contact_get_alias (approval->contact)); - event_manager_add (approval->manager, approval->contact, - EMPATHY_EVENT_TYPE_VOIP, + event_manager_add (approval->manager, NULL, + approval->contact, EMPATHY_EVENT_TYPE_VOIP, video ? EMPATHY_IMAGE_VIDEO_CALL : EMPATHY_IMAGE_VOIP, header, NULL, approval, event_channel_process_voip_func, NULL); @@ -758,9 +765,10 @@ display_invite_room_dialog (EventManagerApproval *approval) tp_channel_get_identifier (approval->main_channel)); } - event_manager_add (approval->manager, approval->contact, - EMPATHY_EVENT_TYPE_INVITATION, EMPATHY_IMAGE_GROUP_MESSAGE, msg, - invite_msg, approval, event_room_channel_process_func, NULL); + event_manager_add (approval->manager, NULL, + approval->contact, EMPATHY_EVENT_TYPE_INVITATION, + EMPATHY_IMAGE_GROUP_MESSAGE, msg, invite_msg, approval, + event_room_channel_process_func, NULL); empathy_sound_manager_play (priv->sound_mgr, window, EMPATHY_SOUND_CONVERSATION_NEW); @@ -807,8 +815,9 @@ event_manager_ft_got_contact_cb (TpConnection *connection, header = g_strdup_printf (_("Incoming file transfer from %s"), empathy_contact_get_alias (approval->contact)); - event_manager_add (approval->manager, approval->contact, - EMPATHY_EVENT_TYPE_TRANSFER, EMPATHY_IMAGE_DOCUMENT_SEND, header, NULL, + event_manager_add (approval->manager, NULL, + approval->contact, EMPATHY_EVENT_TYPE_TRANSFER, + EMPATHY_IMAGE_DOCUMENT_SEND, header, NULL, approval, event_channel_process_func, NULL); /* FIXME better sound for incoming file transfers ?*/ @@ -1023,7 +1032,7 @@ event_manager_pendings_changed_cb (EmpathyContactList *list, else event_msg = NULL; - event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_SUBSCRIPTION, + event_manager_add (manager, NULL, contact, EMPATHY_EVENT_TYPE_SUBSCRIPTION, GTK_STOCK_DIALOG_QUESTION, header, event_msg, NULL, event_pending_subscribe_func, NULL); @@ -1066,7 +1075,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact, header = g_strdup_printf (_("%s is now offline."), empathy_contact_get_alias (contact)); - event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE, + event_manager_add (manager, NULL, contact, EMPATHY_EVENT_TYPE_PRESENCE, EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL); } } @@ -1087,7 +1096,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact, header = g_strdup_printf (_("%s is now online."), empathy_contact_get_alias (contact)); - event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE, + event_manager_add (manager, NULL, contact, EMPATHY_EVENT_TYPE_PRESENCE, EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL); } } diff --git a/src/empathy-event-manager.h b/src/empathy-event-manager.h index cc81d2ddb..d2d1597e1 100644 --- a/src/empathy-event-manager.h +++ b/src/empathy-event-manager.h @@ -58,6 +58,7 @@ typedef enum { } EmpathyEventType; typedef struct { + TpAccount *account; EmpathyContact *contact; EmpathyEventType type; gchar *icon_name; -- cgit v1.2.3 From 071992a0704d43baa2a72b576401ea1f68b44de6 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 18:24:21 +0000 Subject: event-manager: become an approver for auth channels Signed-off-by: Jonny Lamb --- src/empathy-event-manager.c | 90 ++++++++++++++++++++++++++++++++++++++++++--- src/empathy-event-manager.h | 1 + 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 2f947478b..9ab20b769 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -76,6 +76,7 @@ typedef struct { typedef struct { TpBaseClient *approver; + TpBaseClient *auth_approver; EmpathyContactManager *contact_manager; GSList *events; /* Ongoing approvals */ @@ -427,12 +428,47 @@ out: g_object_unref (user_data); } +static void +reject_auth_channel_claim_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + TpChannelDispatchOperation *cdo = TP_CHANNEL_DISPATCH_OPERATION (source); + GError *error = NULL; + + if (!tp_channel_dispatch_operation_claim_finish (cdo, result, &error)) + { + DEBUG ("Failed to claim channel: %s", error->message); + + g_error_free (error); + return; + } + + tp_cli_channel_call_close (TP_CHANNEL (user_data), -1, + NULL, NULL, NULL, NULL); +} + static void reject_approval (EventManagerApproval *approval) { /* We have to claim the channel before closing it */ - tp_channel_dispatch_operation_claim_async (approval->operation, - reject_channel_claim_cb, g_object_ref (approval->handler_instance)); + + /* Unfortunately, we need to special case the auth channels for the + * time being as they don't have a wrapper object handler in + * approval->handler_instance as they're not actually handled by + * this process, so we can just use a noddy callback to call Close() + * directly. */ + if (approval->handler_instance != NULL) + { + tp_channel_dispatch_operation_claim_async (approval->operation, + reject_channel_claim_cb, g_object_ref (approval->handler_instance)); + } + else if (tp_channel_get_channel_type_id (approval->main_channel) + == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION) + { + tp_channel_dispatch_operation_claim_async (approval->operation, + reject_auth_channel_claim_cb, approval->main_channel); + } } static void @@ -828,8 +864,13 @@ event_manager_ft_got_contact_cb (TpConnection *connection, g_object_unref (window); } -/* If there is a file-transfer or media channel consider it as the - * main one. */ +static void +dummy_process_func (EventPriv *event) +{ +} + +/* If there is a file-transfer, media, or auth channel consider it as + * the main one. */ static TpChannel * find_main_channel (GList *channels) { @@ -847,7 +888,8 @@ find_main_channel (GList *channels) channel_type = tp_channel_get_channel_type_id (channel); if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA || - channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) + channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER || + channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION) return channel; else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT) @@ -971,6 +1013,13 @@ approve_channels (TpSimpleApprover *approver, empathy_tp_contact_factory_get_from_handle (connection, handle, event_manager_ft_got_contact_cb, approval, NULL, G_OBJECT (self)); } + else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION) + { + /* We need a process function or this will time out after + * NOTIFICATION_TIMEOUT seconds, which is undesirable. */ + event_manager_add (approval->manager, account, NULL, EMPATHY_EVENT_TYPE_AUTH, + NULL, NULL, NULL, approval, dummy_process_func, NULL); + } else { GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, @@ -1159,6 +1208,7 @@ event_manager_finalize (GObject *object) g_slist_free (priv->approvals); g_object_unref (priv->contact_manager); g_object_unref (priv->approver); + g_object_unref (priv->auth_approver); g_object_unref (priv->gsettings_notif); g_object_unref (priv->gsettings_ui); g_object_unref (priv->sound_mgr); @@ -1200,7 +1250,6 @@ empathy_event_manager_class_init (EmpathyEventManagerClass *klass) g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - g_type_class_add_private (object_class, sizeof (EmpathyEventManagerPriv)); } @@ -1271,12 +1320,41 @@ empathy_event_manager_init (EmpathyEventManager *manager) TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, NULL)); + /* I don't feel good about doing this, and I'm sorry, but the + * capabilities connection feature is added earlier because it's + * needed for EmpathyTpChat. If the capabilities feature is required + * then preparing an auth channel (which of course appears in the + * CONNECTING state) will never be prepared. So the options are + * either to create another approver like I've done, or to port + * EmpathyTpChat and its users to not depend on the connection being + * prepared with capabilities. I chose the former, obviously. :-) */ + + priv->auth_approver = tp_simple_approver_new (dbus, + "Empathy.AuthEventManager", FALSE, approve_channels, manager, + NULL); + + /* SASL auth channels */ + tp_base_client_take_approver_filter (priv->auth_approver, + tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION, + TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION_AUTHENTICATION_METHOD, + G_TYPE_STRING, + TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION, + NULL)); + if (!tp_base_client_register (priv->approver, &error)) { DEBUG ("Failed to register Approver: %s", error->message); g_error_free (error); } + if (!tp_base_client_register (priv->auth_approver, &error)) + { + DEBUG ("Failed to register auth Approver: %s", error->message); + g_error_free (error); + } + g_object_unref (dbus); } diff --git a/src/empathy-event-manager.h b/src/empathy-event-manager.h index d2d1597e1..16d97c6df 100644 --- a/src/empathy-event-manager.h +++ b/src/empathy-event-manager.h @@ -55,6 +55,7 @@ typedef enum { EMPATHY_EVENT_TYPE_SUBSCRIPTION, EMPATHY_EVENT_TYPE_PRESENCE, EMPATHY_EVENT_TYPE_INVITATION, + EMPATHY_EVENT_TYPE_AUTH, } EmpathyEventType; typedef struct { -- cgit v1.2.3 From 1a85f1ae21dd6be86f6e15e424ece5302c8faa4d Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 18:24:47 +0000 Subject: notifications-approver: don't show notifications for auth events Signed-off-by: Jonny Lamb --- src/empathy-notifications-approver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/empathy-notifications-approver.c b/src/empathy-notifications-approver.c index 0bfe03274..e0d540cdc 100644 --- a/src/empathy-notifications-approver.c +++ b/src/empathy-notifications-approver.c @@ -314,7 +314,11 @@ event_added_cb (EmpathyEventManager *manager, if (self->priv->event != NULL) return; + if (event->type == EMPATHY_EVENT_TYPE_AUTH) + return; + self->priv->event = event; + update_notification (self); } @@ -326,6 +330,9 @@ event_removed_cb (EmpathyEventManager *manager, if (event != self->priv->event) return; + if (event->type == EMPATHY_EVENT_TYPE_AUTH) + return; + self->priv->event = empathy_event_manager_get_top_event ( self->priv->event_mgr); @@ -340,6 +347,9 @@ event_updated_cb (EmpathyEventManager *manager, if (event != self->priv->event) return; + if (event->type == EMPATHY_EVENT_TYPE_AUTH) + return; + if (empathy_notify_manager_notification_is_enabled (self->priv->notify_mgr)) update_notification (self); } -- cgit v1.2.3 From db9e0a4a2394977b62f1034864365b1cae6f4714 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 8 Dec 2010 18:34:26 +0000 Subject: main-window: display an info bar approving or rejecting the auth channel Signed-off-by: Jonny Lamb --- src/empathy-main-window.c | 148 +++++++++++++++++++++++++++++++++++++++++++++ src/empathy-main-window.ui | 14 ++++- 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index db5818c0c..e04a6bb21 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -122,6 +122,7 @@ struct _EmpathyMainWindowPriv { GtkWidget *presence_toolbar; GtkWidget *presence_chooser; GtkWidget *errors_vbox; + GtkWidget *auth_vbox; GtkWidget *search_bar; GtkWidget *notebook; GtkWidget *no_entry_label; @@ -143,6 +144,7 @@ struct _EmpathyMainWindowPriv { guint size_timeout_id; GHashTable *errors; + GHashTable *auths; /* stores a mapping from TpAccount to Handler ID to prevent * to listen more than once to the status-changed signal */ @@ -285,6 +287,138 @@ main_window_flash_start (EmpathyMainWindow *window) main_window_flash_cb (window); } +static void +main_window_remove_auth (EmpathyMainWindow *window, + EmpathyEvent *event) +{ + EmpathyMainWindowPriv *priv = GET_PRIV (window); + GtkWidget *error_widget; + + error_widget = g_hash_table_lookup (priv->auths, event); + if (error_widget != NULL) { + gtk_widget_destroy (error_widget); + g_hash_table_remove (priv->auths, event); + } +} + +static void +main_window_auth_add_clicked_cb (GtkButton *button, + EmpathyMainWindow *window) +{ + EmpathyEvent *event; + + event = g_object_get_data (G_OBJECT (button), "event"); + + empathy_event_approve (event); + + main_window_remove_auth (window, event); +} + +static void +main_window_auth_close_clicked_cb (GtkButton *button, + EmpathyMainWindow *window) +{ + EmpathyEvent *event; + + event = g_object_get_data (G_OBJECT (button), "event"); + + empathy_event_decline (event); + main_window_remove_auth (window, event); +} + +static void +main_window_auth_display (EmpathyMainWindow *window, + EmpathyEvent *event) +{ + EmpathyMainWindowPriv *priv = GET_PRIV (window); + TpAccount *account = event->account; + GtkWidget *info_bar; + GtkWidget *content_area; + GtkWidget *image; + GtkWidget *label; + GtkWidget *add_button; + GtkWidget *close_button; + GtkWidget *action_area; + GtkWidget *action_table; + const gchar *icon_name; + gchar *str; + + if (g_hash_table_lookup (priv->auths, event) != NULL) { + return; + } + + info_bar = gtk_info_bar_new (); + gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION); + + gtk_widget_set_no_show_all (info_bar, TRUE); + gtk_box_pack_start (GTK_BOX (priv->auth_vbox), info_bar, FALSE, TRUE, 0); + gtk_widget_show (info_bar); + + icon_name = tp_account_get_icon_name (account); + image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_show (image); + + str = g_markup_printf_escaped ("%s\n%s", + tp_account_get_display_name (account), + _("Password required")); + + label = gtk_label_new (str); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_widget_show (label); + + g_free (str); + + content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)); + gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0); + + image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); + add_button = gtk_button_new (); + gtk_button_set_image (GTK_BUTTON (add_button), image); + gtk_widget_set_tooltip_text (add_button, _("Provide Password")); + gtk_widget_show (add_button); + + image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON); + close_button = gtk_button_new (); + gtk_button_set_image (GTK_BUTTON (close_button), image); + gtk_widget_set_tooltip_text (close_button, _("Cancel")); + gtk_widget_show (close_button); + + action_table = gtk_table_new (1, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (action_table), 6); + gtk_widget_show (action_table); + + action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar)); + gtk_box_pack_start (GTK_BOX (action_area), action_table, FALSE, FALSE, 0); + + gtk_table_attach (GTK_TABLE (action_table), add_button, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_SHRINK), + (GtkAttachOptions) (GTK_SHRINK), 0, 0); + gtk_table_attach (GTK_TABLE (action_table), close_button, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_SHRINK), + (GtkAttachOptions) (GTK_SHRINK), 0, 0); + + g_object_set_data_full (G_OBJECT (info_bar), + "event", event, NULL); + g_object_set_data_full (G_OBJECT (add_button), + "event", event, NULL); + g_object_set_data_full (G_OBJECT (close_button), + "event", event, NULL); + + g_signal_connect (add_button, "clicked", + G_CALLBACK (main_window_auth_add_clicked_cb), + window); + g_signal_connect (close_button, "clicked", + G_CALLBACK (main_window_auth_close_clicked_cb), + window); + + gtk_widget_show (priv->auth_vbox); + + g_hash_table_insert (priv->auths, event, info_bar); +} + static void main_window_event_added_cb (EmpathyEventManager *manager, EmpathyEvent *event, @@ -292,6 +426,8 @@ main_window_event_added_cb (EmpathyEventManager *manager, { if (event->contact) { main_window_flash_start (window); + } else if (event->type == EMPATHY_EVENT_TYPE_AUTH) { + main_window_auth_display (window, event); } } @@ -303,6 +439,11 @@ main_window_event_removed_cb (EmpathyEventManager *manager, EmpathyMainWindowPriv *priv = GET_PRIV (window); FlashForeachData data; + if (event->type == EMPATHY_EVENT_TYPE_AUTH) { + main_window_remove_auth (window, event); + return; + } + if (!event->contact) { return; } @@ -711,6 +852,7 @@ empathy_main_window_finalize (GObject *window) g_object_unref (priv->contact_manager); g_object_unref (priv->sound_mgr); g_hash_table_destroy (priv->errors); + g_hash_table_destroy (priv->auths); /* disconnect all handlers of status-changed signal */ g_hash_table_iter_init (&iter, priv->status_changed_handlers); @@ -1591,6 +1733,7 @@ empathy_main_window_init (EmpathyMainWindow *window) gui = empathy_builder_get_file (filename, "main_vbox", &priv->main_vbox, "errors_vbox", &priv->errors_vbox, + "auth_vbox", &priv->auth_vbox, "ui_manager", &priv->ui_manager, "view_show_offline", &show_offline_widget, "view_show_protocols", &priv->show_protocols, @@ -1660,6 +1803,11 @@ empathy_main_window_init (EmpathyMainWindow *window) g_object_unref, NULL); + priv->auths = g_hash_table_new_full (g_direct_hash, + g_direct_equal, + NULL, + NULL); + priv->status_changed_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, diff --git a/src/empathy-main-window.ui b/src/empathy-main-window.ui index 8356a1af7..e684c6bdf 100644 --- a/src/empathy-main-window.ui +++ b/src/empathy-main-window.ui @@ -308,6 +308,18 @@ 2 + + + + + + + + False + False + 3 + + True @@ -340,7 +352,7 @@ - 3 + 4 -- cgit v1.2.3 From d7293eb2b362224a70ad1c8402691c987b1caf1c Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 9 Dec 2010 11:14:16 +0000 Subject: auth-factory: become an Observer and claim auth channels where necessary Signed-off-by: Jonny Lamb --- data/Empathy.Auth.client | 6 +- libempathy/empathy-auth-factory.c | 274 ++++++++++++++++++++++++++++++-------- libempathy/empathy-auth-factory.h | 6 +- 3 files changed, 229 insertions(+), 57 deletions(-) diff --git a/data/Empathy.Auth.client b/data/Empathy.Auth.client index 1fbf10368..7fb5bba33 100644 --- a/data/Empathy.Auth.client +++ b/data/Empathy.Auth.client @@ -1,5 +1,5 @@ [org.freedesktop.Telepathy.Client] -Interfaces=org.freedesktop.Telepathy.Client.Handler +Interfaces=org.freedesktop.Telepathy.Client.Handler;org.freedesktop.Telepathy.Client.Observer [org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 0] org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.ServerTLSConnection @@ -8,3 +8,7 @@ org.freedesktop.Telepathy.Channel.TargetHandleType u=0 [org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 1] org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.ServerAuthentication org.freedesktop.Telepathy.Channel.Type.ServerAuthentication s=org.freedesktop.Telepathy.Channel.Interface.SASLAuthentication + +[org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 0] +org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.ServerAuthentication +org.freedesktop.Telepathy.Channel.Type.ServerAuthentication s=org.freedesktop.Telepathy.Channel.Interface.SASLAuthentication diff --git a/libempathy/empathy-auth-factory.c b/libempathy/empathy-auth-factory.c index 578b6d6cd..59c256e7a 100644 --- a/libempathy/empathy-auth-factory.c +++ b/libempathy/empathy-auth-factory.c @@ -26,17 +26,16 @@ #define DEBUG_FLAG EMPATHY_DEBUG_TLS #include "empathy-debug.h" +#include "empathy-keyring.h" #include "empathy-server-sasl-handler.h" #include "empathy-server-tls-handler.h" #include "empathy-utils.h" #include "extensions/extensions.h" -G_DEFINE_TYPE (EmpathyAuthFactory, empathy_auth_factory, G_TYPE_OBJECT); +G_DEFINE_TYPE (EmpathyAuthFactory, empathy_auth_factory, TP_TYPE_BASE_CLIENT); typedef struct { - TpBaseClient *handler; - /* Keep a ref here so the auth client doesn't have to mess with * refs. It will be cleared when the channel (and so the handler) * gets invalidated. */ @@ -79,7 +78,9 @@ handler_context_data_new (EmpathyAuthFactory *self, data = g_slice_new0 (HandlerContextData); data->self = g_object_ref (self); - data->context = g_object_ref (context); + + if (context != NULL) + data->context = g_object_ref (context); return data; } @@ -145,13 +146,16 @@ server_sasl_handler_ready_cb (GObject *source, { DEBUG ("Failed to create a server SASL handler; error %s", error->message); - tp_handle_channels_context_fail (data->context, error); + + if (data->context != NULL) + tp_handle_channels_context_fail (data->context, error); g_error_free (error); } else { - tp_handle_channels_context_accept (data->context); + if (data->context != NULL) + tp_handle_channels_context_accept (data->context); g_signal_connect (priv->sasl_handler, "invalidated", G_CALLBACK (sasl_handler_invalidated_cb), data->self); @@ -163,26 +167,17 @@ server_sasl_handler_ready_cb (GObject *source, handler_context_data_free (data); } -static void -handle_channels_cb (TpSimpleHandler *handler, - TpAccount *account, - TpConnection *connection, +static gboolean +common_checks (EmpathyAuthFactory *self, GList *channels, - GList *requests_satisfied, - gint64 user_action_time, - TpHandleChannelsContext *context, - gpointer user_data) + gboolean must_be_sasl, + GError **error) { - TpChannel *channel; - const GError *dbus_error; - GError *error = NULL; - EmpathyAuthFactory *self = user_data; EmpathyAuthFactoryPriv *priv = GET_PRIV (self); - HandlerContextData *data; + TpChannel *channel; GHashTable *props; const gchar * const *available_mechanisms; - - DEBUG ("Handle TLS or SASL carrier channels."); + const GError *dbus_error; /* there can't be more than one ServerTLSConnection or * ServerAuthentication channels at the same time, for the same @@ -190,35 +185,38 @@ handle_channels_cb (TpSimpleHandler *handler, */ if (g_list_length (channels) != 1) { - g_set_error_literal (&error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + g_set_error_literal (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Can't handle more than one ServerTLSConnection or ServerAuthentication " "channel for the same connection."); - goto error; + return FALSE; } channel = channels->data; if (tp_channel_get_channel_type_id (channel) != - EMP_IFACE_QUARK_CHANNEL_TYPE_SERVER_TLS_CONNECTION - && tp_channel_get_channel_type_id (channel) != TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION) { - g_set_error (&error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "Can only handle ServerTLSConnection or ServerAuthentication channels, " - "this was a %s channel", tp_channel_get_channel_type (channel)); - - goto error; + if (must_be_sasl + || tp_channel_get_channel_type_id (channel) != + EMP_IFACE_QUARK_CHANNEL_TYPE_SERVER_TLS_CONNECTION) + { + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + "Can only handle ServerTLSConnection or ServerAuthentication channels, " + "this was a %s channel", tp_channel_get_channel_type (channel)); + + return FALSE; + } } if (tp_channel_get_channel_type_id (channel) == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION && priv->sasl_handler != NULL) { - g_set_error_literal (&error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + g_set_error_literal (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Can't handle more than one ServerAuthentication channel at one time"); - goto error; + return FALSE; } props = tp_channel_borrow_immutable_properties (channel); @@ -230,20 +228,50 @@ handle_channels_cb (TpSimpleHandler *handler, TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION && !tp_strv_contains (available_mechanisms, "X-TELEPATHY-PASSWORD")) { - g_set_error_literal (&error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + g_set_error_literal (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "Only the X-TELEPATHY-PASSWORD SASL mechanism is supported"); - goto error; + return FALSE; } dbus_error = tp_proxy_get_invalidated (channel); if (dbus_error != NULL) { - error = g_error_copy (dbus_error); - goto error; + *error = g_error_copy (dbus_error); + return FALSE; } + return TRUE; +} + +static void +handle_channels (TpBaseClient *handler, + TpAccount *account, + TpConnection *connection, + GList *channels, + GList *requests_satisfied, + gint64 user_action_time, + TpHandleChannelsContext *context) +{ + TpChannel *channel; + GError *error = NULL; + EmpathyAuthFactory *self = EMPATHY_AUTH_FACTORY (handler); + HandlerContextData *data; + + DEBUG ("Handle TLS or SASL carrier channels."); + + if (!common_checks (self, channels, FALSE, &error)) + { + DEBUG ("Failed checks: %s", error->message); + tp_handle_channels_context_fail (context, error); + g_clear_error (&error); + return; + } + + /* The common checks above have checked this is fine. */ + channel = channels->data; + data = handler_context_data_new (self, context); tp_handle_channels_context_delay (context); @@ -260,11 +288,125 @@ handle_channels_cb (TpSimpleHandler *handler, empathy_server_sasl_handler_new_async (account, channel, server_sasl_handler_ready_cb, data); } - return; +} + +typedef struct +{ + EmpathyAuthFactory *self; + TpObserveChannelsContext *context; + TpChannelDispatchOperation *dispatch_operation; + TpAccount *account; + TpChannel *channel; +} ObserveChannelsData; + +static void +observe_channels_data_free (ObserveChannelsData *data) +{ + g_object_unref (data->context); + g_object_unref (data->account); + g_object_unref (data->channel); + g_object_unref (data->dispatch_operation); + g_slice_free (ObserveChannelsData, data); +} + +static void +claim_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + ObserveChannelsData *data = user_data; + GError *error = NULL; + + if (!tp_channel_dispatch_operation_claim_finish ( + TP_CHANNEL_DISPATCH_OPERATION (source), result, &error)) + { + DEBUG ("Failed to call Claim: %s", error->message); + g_clear_error (&error); + } + else + { + HandlerContextData *h_data; + + DEBUG ("Claim called successfully"); + + h_data = handler_context_data_new (data->self, NULL); + + empathy_server_sasl_handler_new_async (TP_ACCOUNT (data->account), + data->channel, server_sasl_handler_ready_cb, h_data); + } - error: - tp_handle_channels_context_fail (context, error); - g_clear_error (&error); + observe_channels_data_free (data); +} + +static void +get_password_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + ObserveChannelsData *data = user_data; + + if (empathy_keyring_get_password_finish (TP_ACCOUNT (source), result, NULL) == NULL) + { + /* We don't actually mind if this fails, just let the approver + * go ahead and take the channel. */ + + DEBUG ("We don't have a password for account %s, letting the event " + "manager approver take it", tp_proxy_get_object_path (source)); + + tp_observe_channels_context_accept (data->context); + observe_channels_data_free (data); + } + else + { + DEBUG ("We have a password for account %s, calling Claim", + tp_proxy_get_object_path (source)); + + tp_channel_dispatch_operation_claim_async (data->dispatch_operation, + claim_cb, data); + + tp_observe_channels_context_accept (data->context); + } +} + +static void +observe_channels (TpBaseClient *client, + TpAccount *account, + TpConnection *connection, + GList *channels, + TpChannelDispatchOperation *dispatch_operation, + GList *requests, + TpObserveChannelsContext *context) +{ + EmpathyAuthFactory *self = EMPATHY_AUTH_FACTORY (client); + TpChannel *channel; + GError *error = NULL; + ObserveChannelsData *data; + + DEBUG ("New auth channel to observe"); + + if (!common_checks (self, channels, TRUE, &error)) + { + DEBUG ("Failed checks: %s", error->message); + tp_observe_channels_context_fail (context, error); + g_clear_error (&error); + return; + } + + /* We're now sure this is a server auth channel using the SASL auth + * type and X-TELEPATHY-PASSWORD is available. Great. */ + + channel = channels->data; + + data = g_slice_new0 (ObserveChannelsData); + data->self = self; + data->context = g_object_ref (context); + data->dispatch_operation = g_object_ref (dispatch_operation); + data->account = g_object_ref (account); + data->channel = g_object_ref (channel); + + empathy_keyring_get_password_async (account, get_password_cb, data); + + tp_observe_channels_context_delay (context); } static GObject * @@ -293,14 +435,20 @@ empathy_auth_factory_constructor (GType type, static void empathy_auth_factory_init (EmpathyAuthFactory *self) { - EmpathyAuthFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_AUTH_FACTORY, EmpathyAuthFactoryPriv); - TpDBusDaemon *bus; +} + +static void +empathy_auth_factory_constructed (GObject *obj) +{ + EmpathyAuthFactory *self = EMPATHY_AUTH_FACTORY (obj); + TpBaseClient *client = TP_BASE_CLIENT (self); GError *error = NULL; - self->priv = priv; + /* chain up to TpBaseClient first */ + G_OBJECT_CLASS (empathy_auth_factory_parent_class)->constructed (obj); - bus = tp_dbus_daemon_dup (&error); if (error != NULL) { g_critical ("Failed to get TpDBusDaemon: %s", error->message); @@ -308,10 +456,9 @@ empathy_auth_factory_init (EmpathyAuthFactory *self) return; } - priv->handler = tp_simple_handler_new (bus, FALSE, FALSE, "Empathy.Auth", - FALSE, handle_channels_cb, self, NULL); + tp_base_client_set_handler_bypass_approval (client, FALSE); - tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( + tp_base_client_take_handler_filter (client, tp_asv_new ( /* ChannelType */ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, EMP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION, @@ -319,7 +466,7 @@ empathy_auth_factory_init (EmpathyAuthFactory *self) TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_NONE, NULL)); - tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( + tp_base_client_take_handler_filter (client, tp_asv_new ( /* ChannelType */ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION, @@ -328,7 +475,14 @@ empathy_auth_factory_init (EmpathyAuthFactory *self) G_TYPE_STRING, TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION, NULL)); - g_object_unref (bus); + tp_base_client_take_observer_filter (client, tp_asv_new ( + /* ChannelType */ + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION, + /* AuthenticationMethod */ + TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION_AUTHENTICATION_METHOD, + G_TYPE_STRING, TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION, + NULL)); } static void @@ -341,7 +495,6 @@ empathy_auth_factory_dispose (GObject *object) priv->dispose_run = TRUE; - tp_clear_object (&priv->handler); tp_clear_object (&priv->sasl_handler); G_OBJECT_CLASS (empathy_auth_factory_parent_class)->dispose (object); @@ -351,10 +504,15 @@ static void empathy_auth_factory_class_init (EmpathyAuthFactoryClass *klass) { GObjectClass *oclass = G_OBJECT_CLASS (klass); + TpBaseClientClass *base_client_cls = TP_BASE_CLIENT_CLASS (klass); oclass->constructor = empathy_auth_factory_constructor; + oclass->constructed = empathy_auth_factory_constructed; oclass->dispose = empathy_auth_factory_dispose; + base_client_cls->handle_channels = handle_channels; + base_client_cls->observe_channels = observe_channels; + g_type_class_add_private (klass, sizeof (EmpathyAuthFactoryPriv)); signals[NEW_SERVER_TLS_HANDLER] = @@ -379,14 +537,22 @@ empathy_auth_factory_class_init (EmpathyAuthFactoryClass *klass) EmpathyAuthFactory * empathy_auth_factory_dup_singleton (void) { - return g_object_new (EMPATHY_TYPE_AUTH_FACTORY, NULL); + EmpathyAuthFactory *out = NULL; + TpDBusDaemon *bus; + + bus = tp_dbus_daemon_dup (NULL); + out = g_object_new (EMPATHY_TYPE_AUTH_FACTORY, + "dbus-daemon", bus, + "name", "Empathy.Auth", + NULL); + g_object_unref (bus); + + return out; } gboolean empathy_auth_factory_register (EmpathyAuthFactory *self, GError **error) { - EmpathyAuthFactoryPriv *priv = GET_PRIV (self); - - return tp_base_client_register (priv->handler, error); + return tp_base_client_register (TP_BASE_CLIENT (self), error); } diff --git a/libempathy/empathy-auth-factory.h b/libempathy/empathy-auth-factory.h index 507f69b95..6f62a7a86 100644 --- a/libempathy/empathy-auth-factory.h +++ b/libempathy/empathy-auth-factory.h @@ -23,17 +23,19 @@ #include +#include + G_BEGIN_DECLS typedef struct _EmpathyAuthFactory EmpathyAuthFactory; typedef struct _EmpathyAuthFactoryClass EmpathyAuthFactoryClass; struct _EmpathyAuthFactoryClass { - GObjectClass parent_class; + TpBaseClientClass parent_class; }; struct _EmpathyAuthFactory { - GObject parent; + TpBaseClient parent; gpointer priv; }; -- cgit v1.2.3 From 41dd635842b27268454435c557b74ea32245c7ae Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 9 Dec 2010 17:32:13 +0000 Subject: status-icon: blink when we get a password request Signed-off-by: Jonny Lamb --- src/empathy-event-manager.c | 9 +++++---- src/empathy-status-icon.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 9ab20b769..f657cae35 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -865,8 +865,9 @@ event_manager_ft_got_contact_cb (TpConnection *connection, } static void -dummy_process_func (EventPriv *event) +event_manager_auth_process_func (EventPriv *event) { + empathy_event_approve ((EmpathyEvent *) event); } /* If there is a file-transfer, media, or auth channel consider it as @@ -1015,10 +1016,10 @@ approve_channels (TpSimpleApprover *approver, } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION) { - /* We need a process function or this will time out after - * NOTIFICATION_TIMEOUT seconds, which is undesirable. */ event_manager_add (approval->manager, account, NULL, EMPATHY_EVENT_TYPE_AUTH, - NULL, NULL, NULL, approval, dummy_process_func, NULL); + GTK_STOCK_DIALOG_AUTHENTICATION, tp_account_get_display_name (account), + _("Password required"), approval, + event_manager_auth_process_func, NULL); } else { diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index 0c834a670..38a68d433 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -159,7 +159,7 @@ status_icon_event_added_cb (EmpathyEventManager *manager, DEBUG ("New event %p", event); priv->event = event; - if (event->must_ack) { + if (event->must_ack || event->type == EMPATHY_EVENT_TYPE_AUTH) { priv->showing_event_icon = TRUE; status_icon_update_icon (icon); status_icon_update_tooltip (icon); -- cgit v1.2.3 From e52ae339c601c4173b011ad28bcdca816649fd4c Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 10 Dec 2010 12:02:17 +0000 Subject: account-settings: don't block notify::ready on getting a password The account widget acts a little more synchronously, so we can't wait for the keyring to give us the password. We can signal later about it though. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-widget.c | 36 +++++++++++++++++++++++++++++++++ libempathy/empathy-account-settings.c | 25 +++++++++++++++++------ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index 27cb882bb..9cbddd316 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -109,6 +109,7 @@ typedef struct { GtkWidget *param_account_widget; GtkWidget *param_password_widget; + gboolean automatic_change; GtkWidget *remember_password_widget; /* Used only for IRC accounts */ @@ -313,6 +314,11 @@ static void account_widget_entry_changed_cb (GtkEditable *entry, EmpathyAccountWidget *self) { + EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + + if (priv->automatic_change) + return; + account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE); empathy_account_widget_changed (self); } @@ -2015,6 +2021,30 @@ remember_password_toggled_cb (GtkToggleButton *button, } } +static void +account_settings_password_retrieved_cb (GObject *object, + gpointer user_data) +{ + EmpathyAccountWidget *self = user_data; + EmpathyAccountWidgetPriv *priv = GET_PRIV (self); + const gchar *password = empathy_account_settings_get_string ( + priv->settings, "password"); + + if (password != NULL) + { + /* We have to do this so that when we call gtk_entry_set_text, + * the ::changed callback doesn't think the user made the + * change. */ + priv->automatic_change = TRUE; + gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), password); + priv->automatic_change = FALSE; + } + + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (priv->remember_password_widget), + !EMP_STR_EMPTY (password)); +} + static void do_constructed (GObject *obj) { @@ -2115,6 +2145,12 @@ do_constructed (GObject *obj) GTK_TOGGLE_BUTTON (priv->remember_password_widget), !EMP_STR_EMPTY (empathy_account_settings_get_string ( priv->settings, "password"))); + + /* The password might not have been retrieved from the + * keyring yet. We should update the remember password + * toggle button and the password entry when/if it is. */ + g_signal_connect (priv->settings, "password-retrieved", + G_CALLBACK (account_settings_password_retrieved_cb), self); } g_signal_connect (priv->remember_password_widget, "toggled", diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index e0a24b4d6..75538e26e 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -50,6 +50,13 @@ enum { PROP_READY }; +enum { + PASSWORD_RETRIEVED = 1, + LAST_SIGNAL +}; + +static gulong signals[LAST_SIGNAL] = { 0, }; + /* private structure */ typedef struct _EmpathyAccountSettingsPriv EmpathyAccountSettingsPriv; @@ -319,6 +326,13 @@ empathy_account_settings_class_init ( "Whether this account is ready to be used", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + signals[PASSWORD_RETRIEVED] = + g_signal_new ("password-retrieved", + G_TYPE_FROM_CLASS (empathy_account_settings_class), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -452,9 +466,7 @@ empathy_account_settings_get_password_cb (GObject *source, priv->password = g_strdup (password); priv->password_original = g_strdup (password); - priv->password_retrieved = TRUE; - - empathy_account_settings_check_readyness (self); + g_signal_emit (self, signals[PASSWORD_RETRIEVED], 0); } static void @@ -546,14 +558,15 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) /* priv->account won't be a proper account if it's the account * assistant showing this widget. */ - if (priv->supports_sasl && !priv->password_retrieved - && !priv->password_requested && priv->account != NULL) + if (priv->supports_sasl && !priv->password_requested + && priv->account != NULL) { priv->password_requested = TRUE; + /* Make this call but don't block on its readiness. We'll signal + * if it's updated later with ::password-retrieved. */ empathy_keyring_get_password_async (priv->account, empathy_account_settings_get_password_cb, self); - return; } priv->ready = TRUE; -- cgit v1.2.3 From cf79884338c1a83eb3c7a18da9674f3563ed1829 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 10 Dec 2010 12:23:08 +0000 Subject: account-settings: add _supports_sasl function Signed-off-by: Jonny Lamb --- libempathy/empathy-account-settings.c | 8 ++++++++ libempathy/empathy-account-settings.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index 75538e26e..c1452ac68 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -1672,3 +1672,11 @@ empathy_account_settings_get_tp_protocol (EmpathyAccountSettings *self) return tp_connection_manager_get_protocol (priv->manager, priv->protocol); } + +gboolean +empathy_account_settings_supports_sasl (EmpathyAccountSettings *self) +{ + EmpathyAccountSettingsPriv *priv = GET_PRIV (self); + + return priv->supports_sasl; +} diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h index 8f3634a19..4d5f6ddc9 100644 --- a/libempathy/empathy-account-settings.h +++ b/libempathy/empathy-account-settings.h @@ -189,6 +189,8 @@ gboolean empathy_account_settings_is_valid (EmpathyAccountSettings *settings); const TpConnectionManagerProtocol * empathy_account_settings_get_tp_protocol ( EmpathyAccountSettings *settings); +gboolean empathy_account_settings_supports_sasl (EmpathyAccountSettings *self); + G_END_DECLS #endif /* #ifndef __EMPATHY_ACCOUNT_SETTINGS_H__*/ -- cgit v1.2.3 From 40791c62c791c6ec697b494b421b1e68c8384769 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 10 Dec 2010 12:24:40 +0000 Subject: account-widget: only show Remember Password ticky box if the CM supports SASL Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-widget.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index 9cbddd316..cf60a498a 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -2132,7 +2132,8 @@ do_constructed (GObject *obj) /* remember password */ if (priv->param_password_widget != NULL - && priv->remember_password_widget != NULL) + && priv->remember_password_widget != NULL + && empathy_account_settings_supports_sasl (priv->settings)) { if (priv->simple) { @@ -2159,6 +2160,11 @@ do_constructed (GObject *obj) remember_password_toggled_cb ( GTK_TOGGLE_BUTTON (priv->remember_password_widget), self); } + else if (priv->remember_password_widget != NULL + && !empathy_account_settings_supports_sasl (priv->settings)) + { + gtk_widget_set_visible (priv->remember_password_widget, FALSE); + } /* dup and init the account-manager */ priv->account_manager = tp_account_manager_dup (); -- cgit v1.2.3 From a2dd862e0f2a262f61b4976148f6cc1e988ec66f Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 10 Dec 2010 12:28:09 +0000 Subject: account-widget: add Remember Password widgets for all the other protocols ...and link these widgets up nicely. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-widget-aim.ui | 34 ++++++++++- libempathy-gtk/empathy-account-widget-groupwise.ui | 40 +++++++++++-- libempathy-gtk/empathy-account-widget-icq.ui | 34 ++++++++++- libempathy-gtk/empathy-account-widget-jabber.ui | 70 ++++++++++++++++++---- libempathy-gtk/empathy-account-widget-msn.ui | 40 +++++++++++-- libempathy-gtk/empathy-account-widget-sip.ui | 40 +++++++++++-- libempathy-gtk/empathy-account-widget.c | 47 +++++++++++++++ 7 files changed, 281 insertions(+), 24 deletions(-) diff --git a/libempathy-gtk/empathy-account-widget-aim.ui b/libempathy-gtk/empathy-account-widget-aim.ui index b590eea99..fb2e5181d 100644 --- a/libempathy-gtk/empathy-account-widget-aim.ui +++ b/libempathy-gtk/empathy-account-widget-aim.ui @@ -15,7 +15,7 @@ True - 3 + 4 2 12 6 @@ -90,6 +90,25 @@ 2 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + @@ -273,5 +292,18 @@ 3 + + + Remember Password + True + True + False + True + True + + + 4 + + diff --git a/libempathy-gtk/empathy-account-widget-groupwise.ui b/libempathy-gtk/empathy-account-widget-groupwise.ui index 1629a0175..1cf2ea790 100644 --- a/libempathy-gtk/empathy-account-widget-groupwise.ui +++ b/libempathy-gtk/empathy-account-widget-groupwise.ui @@ -14,7 +14,7 @@ True - 3 + 4 2 12 6 @@ -74,9 +74,6 @@ 2 - - - True @@ -90,6 +87,28 @@ 3 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + + + + False @@ -270,5 +289,18 @@ 3 + + + Remember Password + True + True + False + True + True + + + 4 + + diff --git a/libempathy-gtk/empathy-account-widget-icq.ui b/libempathy-gtk/empathy-account-widget-icq.ui index 654174f8e..4d9597886 100644 --- a/libempathy-gtk/empathy-account-widget-icq.ui +++ b/libempathy-gtk/empathy-account-widget-icq.ui @@ -15,7 +15,7 @@ True - 3 + 4 2 12 6 @@ -90,6 +90,25 @@ 2 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + @@ -301,5 +320,18 @@ 3 + + + Remember Password + True + True + False + True + True + + + 4 + + diff --git a/libempathy-gtk/empathy-account-widget-jabber.ui b/libempathy-gtk/empathy-account-widget-jabber.ui index 3136f51b4..ca476e536 100644 --- a/libempathy-gtk/empathy-account-widget-jabber.ui +++ b/libempathy-gtk/empathy-account-widget-jabber.ui @@ -21,7 +21,7 @@ True - 3 + 4 2 12 6 @@ -46,8 +46,6 @@ 1 2 - 0 - 1 @@ -60,10 +58,6 @@ GTK_FILL - 0 - 1 - 0 - 1 @@ -76,11 +70,9 @@ entry_password - GTK_FILL - 0 - 1 2 3 + GTK_FILL @@ -140,6 +132,25 @@ Use <a href="http://www.facebook.com/username/">this page</a> to cho 2 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + @@ -508,6 +519,19 @@ Use <a href="http://www.facebook.com/username/">this page</a> to cho 5 + + + Remember Password + True + True + False + True + True + + + 6 + + True @@ -598,6 +622,19 @@ Use <a href="http://www.facebook.com/username/">this page</a> to cho 3 + + + Remember Password + True + True + False + True + True + + + 4 + + True @@ -690,5 +727,18 @@ Use <a href="http://www.facebook.com/username/">this page</a> to cho 3 + + + Remember Password + True + True + False + True + True + + + 4 + + diff --git a/libempathy-gtk/empathy-account-widget-msn.ui b/libempathy-gtk/empathy-account-widget-msn.ui index 133ce487d..6665133f4 100644 --- a/libempathy-gtk/empathy-account-widget-msn.ui +++ b/libempathy-gtk/empathy-account-widget-msn.ui @@ -14,7 +14,7 @@ True - 3 + 4 2 12 6 @@ -74,9 +74,6 @@ 2 - - - True @@ -90,6 +87,28 @@ 3 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + + + + False @@ -270,5 +289,18 @@ 3 + + + Remember Password + True + True + False + True + True + + + 4 + + diff --git a/libempathy-gtk/empathy-account-widget-sip.ui b/libempathy-gtk/empathy-account-widget-sip.ui index b00eda944..98a8f2c17 100644 --- a/libempathy-gtk/empathy-account-widget-sip.ui +++ b/libempathy-gtk/empathy-account-widget-sip.ui @@ -13,7 +13,7 @@ True - 3 + 4 2 12 6 @@ -74,9 +74,6 @@ 2 - - - True @@ -89,6 +86,28 @@ 3 + + + Remember Password + True + True + False + True + True + + + 1 + 2 + 3 + 4 + + + + + + + + False @@ -583,6 +602,19 @@ 3 + + + Remember Password + True + True + False + True + True + + + 4 + + 65535 diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index cf60a498a..d2a1c56f4 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -1228,6 +1228,17 @@ account_widget_build_sip (EmpathyAccountWidget *self, EmpathyAccountWidgetPriv *priv = GET_PRIV (self); empathy_account_widget_sip_build (self, filename, &priv->table_common_settings); + + if (priv->simple) + { + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); + } + else + { + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); + } } static void @@ -1251,6 +1262,9 @@ account_widget_build_msn (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); } else { @@ -1267,6 +1281,9 @@ account_widget_build_msn (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); } } @@ -1409,6 +1426,9 @@ account_widget_build_jabber (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); } else if (priv->simple && service == GTALK_SERVICE) { @@ -1423,6 +1443,9 @@ account_widget_build_jabber (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id_g_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_g_simple")); } else if (priv->simple && service == FACEBOOK_SERVICE) { @@ -1439,6 +1462,9 @@ account_widget_build_jabber (EmpathyAccountWidget *self, setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com"); self->ui_details->default_focus = g_strdup ("entry_id_fb_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_fb_simple")); } else { @@ -1484,6 +1510,9 @@ account_widget_build_jabber (EmpathyAccountWidget *self, self->ui_details->default_focus = g_strdup ("entry_id"); priv->spinbutton_port = spinbutton_port; + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); + g_signal_connect (checkbutton_ssl, "toggled", G_CALLBACK (account_widget_jabber_ssl_toggled_cb), self); @@ -1530,6 +1559,9 @@ account_widget_build_icq (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_uin_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); } else { @@ -1548,6 +1580,9 @@ account_widget_build_icq (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_uin"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); } } @@ -1570,6 +1605,9 @@ account_widget_build_aim (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_screenname_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); } else { @@ -1587,6 +1625,9 @@ account_widget_build_aim (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_screenname"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); } } @@ -1657,6 +1698,9 @@ account_widget_build_groupwise (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id_simple"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password_simple")); } else { @@ -1673,6 +1717,9 @@ account_widget_build_groupwise (EmpathyAccountWidget *self, NULL); self->ui_details->default_focus = g_strdup ("entry_id"); + + priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object ( + self->ui_details->gui, "remember_password")); } } -- cgit v1.2.3 From b51c1db854b9c367ea50d0a301fddca917486372 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Mon, 13 Dec 2010 09:41:34 +0000 Subject: configure: depend on the newest tp-glib for the new auth types stuff Signed-off-by: Jonny Lamb --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4ed8d9e24..b0ef0edca 100644 --- a/configure.ac +++ b/configure.ac @@ -39,7 +39,7 @@ KEYRING_REQUIRED=2.26.0 LIBCANBERRA_GTK_REQUIRED=0.25 LIBNOTIFY_REQUIRED=0.7.0 TELEPATHY_FARSIGHT_REQUIRED=0.0.14 -TELEPATHY_GLIB_REQUIRED=0.13.7 +TELEPATHY_GLIB_REQUIRED=0.13.9 TELEPATHY_LOGGER=0.1.5 # Optional deps -- cgit v1.2.3 From 6093afb467c0c2ae855d8635d9a10e9bc5f072c4 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 16:30:41 +0000 Subject: account-settings: use tp_clear_object in dispose Signed-off-by: Jonny Lamb --- libempathy/empathy-account-settings.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index c1452ac68..fe08f52c0 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -350,25 +350,11 @@ empathy_account_settings_dispose (GObject *object) g_signal_handler_disconnect (priv->managers, priv->managers_ready_id); priv->managers_ready_id = 0; - if (priv->managers != NULL) - g_object_unref (priv->managers); - priv->managers = NULL; - - if (priv->manager != NULL) - g_object_unref (priv->manager); - priv->manager = NULL; - - if (priv->account_manager != NULL) - g_object_unref (priv->account_manager); - priv->account_manager = NULL; - - if (priv->account != NULL) - g_object_unref (priv->account); - priv->account = NULL; - - if (priv->protocol_obj != NULL) - g_object_unref (priv->protocol_obj); - priv->protocol_obj = NULL; + tp_clear_object (&priv->managers); + tp_clear_object (&priv->manager); + tp_clear_object (&priv->account_manager); + tp_clear_object (&priv->account); + tp_clear_object (&priv->protocol_obj); /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_account_settings_parent_class)->dispose) -- cgit v1.2.3 From 483c580a8b6aa2c0b4205e3cb2c674e80abe5ba7 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 16:31:57 +0000 Subject: auth-factory: add a comment as to why we're also an approver Signed-off-by: Jonny Lamb --- libempathy/empathy-auth-factory.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libempathy/empathy-auth-factory.c b/libempathy/empathy-auth-factory.c index 59c256e7a..443962a7c 100644 --- a/libempathy/empathy-auth-factory.c +++ b/libempathy/empathy-auth-factory.c @@ -475,6 +475,12 @@ empathy_auth_factory_constructed (GObject *obj) G_TYPE_STRING, TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION, NULL)); + /* We are also an observer so that we can see new auth channels + * popping up and if we have the password already saved to one + * account where an auth channel has just appeared we can call + * Claim() on the CDO so the approver won't get it, which makes + * sense. */ + tp_base_client_take_observer_filter (client, tp_asv_new ( /* ChannelType */ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, -- cgit v1.2.3 From 05e14d747fd88a260996c406a938a1bfdfbaca8f Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 16:33:46 +0000 Subject: event-manager: use tp_clear_object Signed-off-by: Jonny Lamb --- src/empathy-event-manager.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index f657cae35..93656c3a9 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -166,15 +166,8 @@ event_free (EventPriv *event) if (event->autoremove_timeout_id != 0) g_source_remove (event->autoremove_timeout_id); - if (event->public.contact) - { - g_object_unref (event->public.contact); - } - - if (event->public.account) - { - g_object_unref (event->public.account); - } + tp_clear_object (&(event->public.contact)); + tp_clear_object (&(event->public.account)); g_slice_free (EventPriv, event); } -- cgit v1.2.3 From 932835ccd42c55d77017d6ffc77773db40385a27 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 16:37:18 +0000 Subject: main-window: document what the key and value types are for hash tables Signed-off-by: Jonny Lamb --- src/empathy-main-window.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index e04a6bb21..d1dfc2942 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -143,7 +143,11 @@ struct _EmpathyMainWindowPriv { GtkWidget *edit_context_separator; guint size_timeout_id; + + /* reffed TpAccount* => visible GtkInfoBar* */ GHashTable *errors; + + /* EmpathyEvent* => visible GtkInfoBar* */ GHashTable *auths; /* stores a mapping from TpAccount to Handler ID to prevent -- cgit v1.2.3 From 01e02a165d271a155a4af0e79dd94c210b584cfa Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 16:38:19 +0000 Subject: main-window: don't use _full functions where not necessary Signed-off-by: Jonny Lamb --- src/empathy-main-window.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index d1dfc2942..6907a12ef 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -1807,10 +1807,7 @@ empathy_main_window_init (EmpathyMainWindow *window) g_object_unref, NULL); - priv->auths = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - NULL, - NULL); + priv->auths = g_hash_table_new (NULL, NULL); priv->status_changed_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, -- cgit v1.2.3 From 225ca2e12b053a6c8ece18179d470f01ed1d6fb7 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 16:38:48 +0000 Subject: main-window: s/Cancel/Disconnect/ when not giving a password Signed-off-by: Jonny Lamb --- src/empathy-main-window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 6907a12ef..ce2f78042 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -387,7 +387,7 @@ main_window_auth_display (EmpathyMainWindow *window, image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON); close_button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (close_button), image); - gtk_widget_set_tooltip_text (close_button, _("Cancel")); + gtk_widget_set_tooltip_text (close_button, _("Disconnect")); gtk_widget_show (close_button); action_table = gtk_table_new (1, 2, FALSE); -- cgit v1.2.3