aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-09-17 21:55:45 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-09-29 18:54:37 +0800
commit9cd957b56a67984b4fd3d89aec3e6606372462d7 (patch)
tree5e5f8ded50056f32076912e30f5ba5db1edb9e83 /libempathy-gtk
parentfc4059e17da2a94a3864f396b5de12d93865090d (diff)
downloadgsoc2013-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 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-protocol-chooser.c56
-rw-r--r--libempathy-gtk/empathy-protocol-chooser.h5
2 files changed, 61 insertions, 0 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__ */