diff options
-rw-r--r-- | libempathy-gtk/empathy-protocol-chooser.c | 56 | ||||
-rw-r--r-- | libempathy-gtk/empathy-protocol-chooser.h | 5 | ||||
-rw-r--r-- | src/empathy-account-assistant.c | 59 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.c | 62 |
4 files changed, 68 insertions, 114 deletions
diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c index 0ac268015..c3cea3eb7 100644 --- a/libempathy-gtk/empathy-protocol-chooser.c +++ b/libempathy-gtk/empathy-protocol-chooser.c @@ -557,3 +557,59 @@ empathy_protocol_chooser_set_visible (EmpathyProtocolChooser *protocol_chooser, gtk_combo_box_set_active (GTK_COMBO_BOX (protocol_chooser), 0); } + +EmpathyAccountSettings * +empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self) +{ + EmpathyAccountSettings *settings; + gchar *str; + const gchar *display_name; + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; + gchar *service; + + cm = empathy_protocol_chooser_dup_selected (self, &proto, &service); + if (cm == NULL || proto == NULL) + return NULL; + + if (service != NULL) + display_name = empathy_service_name_to_display_name (service); + else + display_name = empathy_protocol_name_to_display_name (proto->name); + + /* Create account */ + /* To translator: %s is the name of the protocol, such as "Google Talk" or + * "Yahoo!" + */ + str = g_strdup_printf (_("New %s account"), display_name); + settings = empathy_account_settings_new (cm->name, proto->name, str); + + g_free (str); + + if (!tp_strdiff (service, "google-talk")) + { + gchar *fallback_servers[] = { + "talkx.l.google.com", + "talkx.l.google.com:443,oldssl", + "talkx.l.google.com:80", + NULL}; + + empathy_account_settings_set_icon_name_async (settings, "im-google-talk", + NULL, NULL); + + empathy_account_settings_set_strv (settings, "fallback-servers", + fallback_servers); + } + else if (!tp_strdiff (service, "facebook")) + { + empathy_account_settings_set_icon_name_async (settings, "im-facebook", + NULL, NULL); + + empathy_account_settings_set_string (settings, "server", + "chat.facebook.com"); + } + + g_object_unref (cm); + g_free (service); + return settings; +} diff --git a/libempathy-gtk/empathy-protocol-chooser.h b/libempathy-gtk/empathy-protocol-chooser.h index d5c59c26f..f3c577661 100644 --- a/libempathy-gtk/empathy-protocol-chooser.h +++ b/libempathy-gtk/empathy-protocol-chooser.h @@ -28,6 +28,8 @@ #include <telepathy-glib/connection-manager.h> +#include <libempathy/empathy-account-settings.h> + G_BEGIN_DECLS #define EMPATHY_TYPE_PROTOCOL_CHOOSER (empathy_protocol_chooser_get_type ()) @@ -75,5 +77,8 @@ void empathy_protocol_chooser_set_visible ( EmpathyProtocolChooserFilterFunc func, gpointer user_data); +EmpathyAccountSettings * empathy_protocol_chooser_create_account_settings ( + EmpathyProtocolChooser *self); + G_END_DECLS #endif /* __EMPATHY_PROTOCOL_CHOOSER_H__ */ diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c index 046e2377e..926f6e09a 100644 --- a/src/empathy-account-assistant.c +++ b/src/empathy-account-assistant.c @@ -381,69 +381,19 @@ static void account_assistant_protocol_changed_cb (GtkComboBox *chooser, EmpathyAccountAssistant *self) { - TpConnectionManager *cm; - TpConnectionManagerProtocol *proto; EmpathyAccountSettings *settings; EmpathyAccountAssistantPriv *priv; - char *str; GtkWidget *account_widget; EmpathyAccountWidget *widget_object = NULL; - gboolean is_gtalk = FALSE, is_facebook = FALSE; - gchar *service; - const gchar *display_name; priv = GET_PRIV (self); - cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (chooser), &proto, &service); + settings = empathy_protocol_chooser_create_account_settings ( + EMPATHY_PROTOCOL_CHOOSER (chooser)); - if (cm == NULL || proto == NULL) - /* we are not ready yet */ + if (settings == NULL) return; - /* Create account */ - if (!tp_strdiff (service, "google-talk")) - { - is_gtalk = TRUE; - } - else if (!tp_strdiff (service, "facebook")) - { - is_facebook = TRUE; - } - - if (service != NULL) - display_name = empathy_service_name_to_display_name (service); - else - display_name = empathy_protocol_name_to_display_name (proto->name); - - /* To translator: %s is the protocol name */ - str = g_strdup_printf (_("New %s account"), display_name); - - settings = empathy_account_settings_new (cm->name, proto->name, str); - - if (is_gtalk) - { - gchar *fallback_servers[] = { - "talkx.l.google.com", - "talkx.l.google.com:443,oldssl", - "talkx.l.google.com:80", - NULL}; - - empathy_account_settings_set_icon_name_async (settings, "im-google-talk", - NULL, NULL); - - empathy_account_settings_set_strv (settings, "fallback-servers", - fallback_servers); - } - else if (is_facebook) - { - empathy_account_settings_set_icon_name_async (settings, "im-facebook", - NULL, NULL); - - empathy_account_settings_set_string (settings, "server", - "chat.facebook.com"); - } - if (priv->first_resp == RESPONSE_CREATE_ACCOUNT) empathy_account_settings_set_boolean (settings, "register", TRUE); @@ -477,9 +427,6 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser, gtk_box_pack_start (GTK_BOX (priv->enter_or_create_page), account_widget, FALSE, FALSE, 0); gtk_widget_show (account_widget); - - g_free (str); - g_free (service); } static gboolean diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index fd6821368..55e21218e 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -584,63 +584,11 @@ accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog) { EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); EmpathyAccountSettings *settings; - gchar *str; - const gchar *display_name; - TpConnectionManager *cm; - TpConnectionManagerProtocol *proto; - gboolean is_gtalk = FALSE, is_facebook = FALSE; - gchar *service; - - cm = empathy_protocol_chooser_dup_selected ( - EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, &service); - if (cm == NULL) - return; - - if (!tp_strdiff (service, "google-talk")) - { - is_gtalk = TRUE; - } - else if (!tp_strdiff (service, "facebook")) - { - is_facebook = TRUE; - } - - if (service != NULL) - display_name = empathy_service_name_to_display_name (service); - else - display_name = empathy_protocol_name_to_display_name (proto->name); - - /* Create account */ - /* To translator: %s is the name of the protocol, such as "Google Talk" or - * "Yahoo!" - */ - str = g_strdup_printf (_("New %s account"), display_name); - settings = empathy_account_settings_new (cm->name, proto->name, str); - g_free (str); - - if (is_gtalk) - { - gchar *fallback_servers[] = { - "talkx.l.google.com", - "talkx.l.google.com:443,oldssl", - "talkx.l.google.com:80", - NULL}; - - empathy_account_settings_set_icon_name_async (settings, "im-google-talk", - NULL, NULL); - - empathy_account_settings_set_strv (settings, "fallback-servers", - fallback_servers); - } - else if (is_facebook) - { - empathy_account_settings_set_icon_name_async (settings, "im-facebook", - NULL, NULL); - - empathy_account_settings_set_string (settings, "server", - "chat.facebook.com"); - } + settings = empathy_protocol_chooser_create_account_settings ( + EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol)); + if (settings == NULL) + return; accounts_dialog_add (dialog, settings); accounts_dialog_model_set_selected (dialog, settings); @@ -648,8 +596,6 @@ accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog) gtk_widget_show_all (priv->hbox_protocol); g_object_unref (settings); - g_object_unref (cm); - g_free (service); } static void |