diff options
author | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-05-06 21:39:09 +0800 |
---|---|---|
committer | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-08-20 18:03:05 +0800 |
commit | 4e0f97a1942d1ae0b4b3846d43e3769fdb076b44 (patch) | |
tree | ef82dba3325ec71b80ed3deb7ed48fc130a36ddc /tp-account-widgets | |
parent | 88819ece017f0693803f33bb560e4d01140174c1 (diff) | |
download | gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar.gz gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar.bz2 gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar.lz gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar.xz gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar.zst gsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.zip |
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
Diffstat (limited to 'tp-account-widgets')
-rw-r--r-- | tp-account-widgets/tpaw-account-settings.c | 3 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-account-widget.c | 2 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-utils.c | 89 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-utils.h | 5 |
4 files changed, 97 insertions, 2 deletions
diff --git a/tp-account-widgets/tpaw-account-settings.c b/tp-account-widgets/tpaw-account-settings.c index 5359cb7bd..23c2ab9d1 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 e2c8016a6..2cb41cbe5 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 8570658c3..3efc422b5 100644 --- a/tp-account-widgets/tpaw-utils.c +++ b/tp-account-widgets/tpaw-utils.c @@ -3,6 +3,7 @@ * * Authors: Marco Barisione <marco.barisione@collabora.co.uk> * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> + * Sjoerd Simons <sjoerd.simons@collabora.co.uk> * * 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 <glib/gi18n-lib.h> + #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 55d83d506..b11fa7670 100644 --- a/tp-account-widgets/tpaw-utils.h +++ b/tp-account-widgets/tpaw-utils.h @@ -3,6 +3,7 @@ * * Authors: Marco Barisione <marco.barisione@collabora.co.uk> * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> + * Sjoerd Simons <sjoerd.simons@collabora.co.uk> * * 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__ */ |