aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Barisione <marco.barisione@collabora.co.uk>2013-05-06 21:39:09 +0800
committerMarco Barisione <marco.barisione@collabora.co.uk>2013-08-20 18:03:05 +0800
commit4e0f97a1942d1ae0b4b3846d43e3769fdb076b44 (patch)
treeef82dba3325ec71b80ed3deb7ed48fc130a36ddc
parent88819ece017f0693803f33bb560e4d01140174c1 (diff)
downloadgsoc2013-empathy-4e0f97a1942d1ae0b4b3846d43e3769fdb076b44.tar.gz
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
-rw-r--r--libempathy-gtk/empathy-protocol-chooser.c13
-rw-r--r--libempathy-gtk/empathy-theme-adium.c3
-rw-r--r--libempathy/empathy-utils.c86
-rw-r--r--libempathy/empathy-utils.h4
-rw-r--r--src/empathy-accounts-dialog.c2
-rw-r--r--tp-account-widgets/tpaw-account-settings.c3
-rw-r--r--tp-account-widgets/tpaw-account-widget.c2
-rw-r--r--tp-account-widgets/tpaw-utils.c89
-rw-r--r--tp-account-widgets/tpaw-utils.h5
9 files changed, 107 insertions, 100 deletions
diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c
index d2fec3041..f2414ad10 100644
--- a/libempathy-gtk/empathy-protocol-chooser.c
+++ b/libempathy-gtk/empathy-protocol-chooser.c
@@ -25,6 +25,7 @@
#include <glib/gi18n-lib.h>
#include <tp-account-widgets/tpaw-connection-managers.h>
+#include <tp-account-widgets/tpaw-utils.h>
#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 31715c305..d5b935681 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 <glib/gi18n-lib.h>
+#include <tp-account-widgets/tpaw-utils.h>
#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 b06edeb01..ee245d90f 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 1a86755c6..96d201d3e 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 bf3934502..42bf35d76 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 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__ */