diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-09-17 21:55:45 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-09-29 18:54:37 +0800 |
commit | 9cd957b56a67984b4fd3d89aec3e6606372462d7 (patch) | |
tree | 5e5f8ded50056f32076912e30f5ba5db1edb9e83 /src | |
parent | fc4059e17da2a94a3864f396b5de12d93865090d (diff) | |
download | gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.tar gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.tar.gz gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.tar.bz2 gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.tar.lz gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.tar.xz gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.tar.zst gsoc2013-empathy-9cd957b56a67984b4fd3d89aec3e6606372462d7.zip |
factor out empathy_protocol_chooser_create_account_settings()
No need to keep this code duplicated.
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-account-assistant.c | 59 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.c | 62 |
2 files changed, 7 insertions, 114 deletions
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 |