From 4e0f97a1942d1ae0b4b3846d43e3769fdb076b44 Mon Sep 17 00:00:00 2001 From: Marco Barisione Date: Mon, 6 May 2013 14:39:09 +0100 Subject: [PATCH] tpaw-utils: move functions for protocol and service display information The following functions were moved from empathy to tp-aw and renamed accordingly: * empathy_protocol_icon_name; * empathy_protocol_name_to_display_name; * empathy_service_name_to_display_name. This commit also changes the licence of the moved code (all copyrighted by Collabora Ltd.) from GPL to LGPL. https://bugzilla.gnome.org/show_bug.cgi?id=699492 --- libempathy-gtk/empathy-protocol-chooser.c | 13 ++-- libempathy-gtk/empathy-theme-adium.c | 3 +- libempathy/empathy-utils.c | 86 --------------------- libempathy/empathy-utils.h | 4 - src/empathy-accounts-dialog.c | 2 +- tp-account-widgets/tpaw-account-settings.c | 3 +- tp-account-widgets/tpaw-account-widget.c | 2 +- tp-account-widgets/tpaw-utils.c | 89 ++++++++++++++++++++++ tp-account-widgets/tpaw-utils.h | 5 ++ 9 files changed, 107 insertions(+), 100 deletions(-) diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c index d2fec304..f2414ad1 100644 --- a/libempathy-gtk/empathy-protocol-chooser.c +++ b/libempathy-gtk/empathy-protocol-chooser.c @@ -25,6 +25,7 @@ #include #include +#include #include "empathy-ui-utils.h" #include "empathy-utils.h" @@ -229,10 +230,10 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser, g_hash_table_insert (priv->protocols, g_strdup (proto_name), g_strdup (cm_name)); - icon_name = empathy_protocol_icon_name (proto_name); + icon_name = tpaw_protocol_icon_name (proto_name); pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); - display_name = empathy_protocol_name_to_display_name (proto_name); + display_name = tpaw_protocol_name_to_display_name (proto_name); gtk_list_store_insert_with_values (priv->store, NULL, 0, @@ -247,7 +248,7 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser, if (!tp_strdiff (proto_name, "jabber") && !tp_strdiff (cm_name, "gabble")) { - display_name = empathy_service_name_to_display_name ("google-talk"); + display_name = tpaw_service_name_to_display_name ("google-talk"); pixbuf = empathy_pixbuf_from_icon_name ("im-google-talk", GTK_ICON_SIZE_BUTTON); @@ -262,7 +263,7 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser, g_clear_object (&pixbuf); - display_name = empathy_service_name_to_display_name ("facebook"); + display_name = tpaw_service_name_to_display_name ("facebook"); pixbuf = empathy_pixbuf_from_icon_name ("im-facebook", GTK_ICON_SIZE_BUTTON); @@ -591,9 +592,9 @@ empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self) goto out; if (service != NULL) - display_name = empathy_service_name_to_display_name (service); + display_name = tpaw_service_name_to_display_name (service); else - display_name = empathy_protocol_name_to_display_name ( + display_name = tpaw_protocol_name_to_display_name ( tp_protocol_get_name (proto)); /* Create account */ diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index 31715c30..d5b93568 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -23,6 +23,7 @@ #include "empathy-theme-adium.h" #include +#include #include "empathy-gsettings.h" #include "empathy-images.h" @@ -901,7 +902,7 @@ theme_adium_add_message (EmpathyThemeAdium *self, /* Get information */ sender = empathy_message_get_sender (msg); account = empathy_contact_get_account (sender); - service_name = empathy_protocol_name_to_display_name + service_name = tpaw_protocol_name_to_display_name (tp_account_get_protocol_name (account)); if (service_name == NULL) service_name = tp_account_get_protocol_name (account); diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index b06edeb0..ee245d90 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -428,21 +428,6 @@ empathy_uint_compare (gconstpointer a, return *(guint *) a - *(guint *) b; } -gchar * -empathy_protocol_icon_name (const gchar *protocol) -{ - if (!tp_strdiff (protocol, "yahoojp")) - /* Yahoo Japan uses the same icon as Yahoo */ - protocol = "yahoo"; - else if (!tp_strdiff (protocol, "simple")) - /* SIMPLE uses the same icon as SIP */ - protocol = "sip"; - else if (!tp_strdiff (protocol, "sms")) - return g_strdup ("phone"); - - return g_strdup_printf ("im-%s", protocol); -} - GType empathy_type_dbus_ao (void) { @@ -454,77 +439,6 @@ empathy_type_dbus_ao (void) return t; } -const char * -empathy_protocol_name_to_display_name (const gchar *proto_name) -{ - int i; - static struct { - const gchar *proto; - const gchar *display; - gboolean translated; - } names[] = { - { "jabber", "Jabber", FALSE }, - { "msn", "Windows Live (MSN)", FALSE, }, - { "local-xmpp", N_("People Nearby"), TRUE }, - { "irc", "IRC", FALSE }, - { "icq", "ICQ", FALSE }, - { "aim", "AIM", FALSE }, - { "yahoo", "Yahoo!", FALSE }, - { "yahoojp", N_("Yahoo! Japan"), TRUE }, - { "groupwise", "GroupWise", FALSE }, - { "sip", "SIP", FALSE }, - { "gadugadu", "Gadu-Gadu", FALSE }, - { "mxit", "Mxit", FALSE }, - { "myspace", "Myspace", FALSE }, - { "sametime", "Sametime", FALSE }, - { "skype-dbus", "Skype (D-BUS)", FALSE }, - { "skype-x11", "Skype (X11)", FALSE }, - { "zephyr", "Zephyr", FALSE }, - { NULL, NULL } - }; - - for (i = 0; names[i].proto != NULL; i++) - { - if (!tp_strdiff (proto_name, names[i].proto)) - { - if (names[i].translated) - return gettext (names[i].display); - else - return names[i].display; - } - } - - return proto_name; -} - -const char * -empathy_service_name_to_display_name (const gchar *service_name) -{ - int i; - static struct { - const gchar *service; - const gchar *display; - gboolean translated; - } names[] = { - { "google-talk", N_("Google Talk"), FALSE }, - { "facebook", N_("Facebook Chat"), TRUE }, - { NULL, NULL } - }; - - for (i = 0; names[i].service != NULL; i++) - { - if (!tp_strdiff (service_name, names[i].service)) - { - if (names[i].translated) - return gettext (names[i].display); - else - return names[i].display; - } - } - - return service_name; -} - gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting) { diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 1a86755c..96d201d3 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -66,10 +66,6 @@ gint empathy_uint_compare (gconstpointer a, const gchar * empathy_account_get_error_message (TpAccount *account, gboolean *user_requested); -gchar *empathy_protocol_icon_name (const gchar *protocol); -const gchar *empathy_protocol_name_to_display_name (const gchar *proto_name); -const gchar *empathy_service_name_to_display_name (const gchar *proto_name); - #define EMPATHY_ARRAY_TYPE_OBJECT (empathy_type_dbus_ao ()) GType empathy_type_dbus_ao (void); diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index bf393450..42bf35d7 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -729,7 +729,7 @@ account_dialog_create_dialog_content (EmpathyAccountsDialog *dialog, gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type), icon_name, GTK_ICON_SIZE_DIALOG); gtk_widget_set_tooltip_text (priv->image_type, - empathy_protocol_name_to_display_name + tpaw_protocol_name_to_display_name (tpaw_account_settings_get_protocol (settings))); gtk_widget_show (priv->image_type); diff --git a/tp-account-widgets/tpaw-account-settings.c b/tp-account-widgets/tpaw-account-settings.c index 5359cb7b..23c2ab9d 100644 --- a/tp-account-widgets/tpaw-account-settings.c +++ b/tp-account-widgets/tpaw-account-settings.c @@ -25,6 +25,7 @@ #include "tpaw-keyring.h" #include "empathy-presence-manager.h" #include "empathy-utils.h" +#include "tpaw-utils.h" #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT #include "empathy-debug.h" @@ -231,7 +232,7 @@ tpaw_account_settings_constructed (GObject *object) } else { - priv->icon_name = empathy_protocol_icon_name (priv->protocol); + priv->icon_name = tpaw_protocol_icon_name (priv->protocol); } g_assert (priv->cm_name != NULL && priv->protocol != NULL); diff --git a/tp-account-widgets/tpaw-account-widget.c b/tp-account-widgets/tpaw-account-widget.c index e2c8016a..2cb41cbe 100644 --- a/tp-account-widgets/tpaw-account-widget.c +++ b/tp-account-widgets/tpaw-account-widget.c @@ -2271,7 +2271,7 @@ tpaw_account_widget_get_default_display_name (TpawAccountWidget *self) return default_display_name; } - if ((p = empathy_protocol_name_to_display_name (protocol)) != NULL) + if ((p = tpaw_protocol_name_to_display_name (protocol)) != NULL) protocol = p; if (protocol != NULL) diff --git a/tp-account-widgets/tpaw-utils.c b/tp-account-widgets/tpaw-utils.c index 8570658c..3efc422b 100644 --- a/tp-account-widgets/tpaw-utils.c +++ b/tp-account-widgets/tpaw-utils.c @@ -3,6 +3,7 @@ * * Authors: Marco Barisione * Guillaume Desmottes + * Sjoerd Simons * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,6 +23,8 @@ #include "config.h" #include "tpaw-utils.h" +#include + #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include "empathy-debug.h" @@ -67,3 +70,89 @@ tpaw_connect_new_account (TpAccount *account, break; } } + +gchar * +tpaw_protocol_icon_name (const gchar *protocol) +{ + if (!tp_strdiff (protocol, "yahoojp")) + /* Yahoo Japan uses the same icon as Yahoo */ + protocol = "yahoo"; + else if (!tp_strdiff (protocol, "simple")) + /* SIMPLE uses the same icon as SIP */ + protocol = "sip"; + else if (!tp_strdiff (protocol, "sms")) + return g_strdup ("phone"); + + return g_strdup_printf ("im-%s", protocol); +} + +const char * +tpaw_protocol_name_to_display_name (const gchar *proto_name) +{ + int i; + static struct { + const gchar *proto; + const gchar *display; + gboolean translated; + } names[] = { + { "jabber", "Jabber", FALSE }, + { "msn", "Windows Live (MSN)", FALSE, }, + { "local-xmpp", N_("People Nearby"), TRUE }, + { "irc", "IRC", FALSE }, + { "icq", "ICQ", FALSE }, + { "aim", "AIM", FALSE }, + { "yahoo", "Yahoo!", FALSE }, + { "yahoojp", N_("Yahoo! Japan"), TRUE }, + { "groupwise", "GroupWise", FALSE }, + { "sip", "SIP", FALSE }, + { "gadugadu", "Gadu-Gadu", FALSE }, + { "mxit", "Mxit", FALSE }, + { "myspace", "Myspace", FALSE }, + { "sametime", "Sametime", FALSE }, + { "skype-dbus", "Skype (D-BUS)", FALSE }, + { "skype-x11", "Skype (X11)", FALSE }, + { "zephyr", "Zephyr", FALSE }, + { NULL, NULL } + }; + + for (i = 0; names[i].proto != NULL; i++) + { + if (!tp_strdiff (proto_name, names[i].proto)) + { + if (names[i].translated) + return gettext (names[i].display); + else + return names[i].display; + } + } + + return proto_name; +} + +const char * +tpaw_service_name_to_display_name (const gchar *service_name) +{ + int i; + static struct { + const gchar *service; + const gchar *display; + gboolean translated; + } names[] = { + { "google-talk", N_("Google Talk"), FALSE }, + { "facebook", N_("Facebook Chat"), TRUE }, + { NULL, NULL } + }; + + for (i = 0; names[i].service != NULL; i++) + { + if (!tp_strdiff (service_name, names[i].service)) + { + if (names[i].translated) + return gettext (names[i].display); + else + return names[i].display; + } + } + + return service_name; +} diff --git a/tp-account-widgets/tpaw-utils.h b/tp-account-widgets/tpaw-utils.h index 55d83d50..b11fa767 100644 --- a/tp-account-widgets/tpaw-utils.h +++ b/tp-account-widgets/tpaw-utils.h @@ -3,6 +3,7 @@ * * Authors: Marco Barisione * Guillaume Desmottes + * Sjoerd Simons * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,6 +31,10 @@ G_BEGIN_DECLS void tpaw_connect_new_account (TpAccount *account, TpAccountManager *account_manager); +gchar *tpaw_protocol_icon_name (const gchar *protocol); +const gchar *tpaw_protocol_name_to_display_name (const gchar *proto_name); +const gchar *tpaw_service_name_to_display_name (const gchar *proto_name); + G_END_DECLS #endif /* __TPAW_UTILS_H__ */ -- 2.39.2