aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-08-02 19:27:13 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-08-02 19:27:13 +0800
commit48fd13dde6d5bee784a2ae32fde6a0664597b820 (patch)
treec0f98cae92495a5f5c2bcc2906f055aa07d87e7e
parent6796f373b5b2a157351a2e36c06732ba4332a463 (diff)
downloadgsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.tar
gsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.tar.gz
gsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.tar.bz2
gsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.tar.lz
gsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.tar.xz
gsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.tar.zst
gsoc2013-empathy-48fd13dde6d5bee784a2ae32fde6a0664597b820.zip
Adding new empathy_strdiff API stolen from telepathy-glib. It check if
2007-08-02 Xavier Claessens <xclaesse@gmail.com> * libempathy-gtk/empathy-accounts-dialog.c: * libempathy/empathy-utils.c: * libempathy/empathy-utils.h: Adding new empathy_strdiff API stolen from telepathy-glib. It check if strings are != NULL before using strcmp. Using that API to fix bug #461886. Should be used in more places. svn path=/trunk/; revision=224
-rw-r--r--ChangeLog8
-rw-r--r--libempathy-gtk/empathy-accounts-dialog.c4
-rw-r--r--libempathy/empathy-utils.c135
-rw-r--r--libempathy/empathy-utils.h14
4 files changed, 26 insertions, 135 deletions
diff --git a/ChangeLog b/ChangeLog
index 9497443c5..3bd6b3288 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2007-08-02 Xavier Claessens <xclaesse@gmail.com>
+ * libempathy-gtk/empathy-accounts-dialog.c:
+ * libempathy/empathy-utils.c:
+ * libempathy/empathy-utils.h: Adding new empathy_strdiff API stolen from
+ telepathy-glib. It check if strings are != NULL before using strcmp.
+ Using that API to fix bug #461886. Should be used in more places.
+
+2007-08-02 Xavier Claessens <xclaesse@gmail.com>
+
* libempathy-gtk/empathy-status-icon.c: Click on the tray icon shows the
window if it's not active and hide if it is. Fixes bug #462057
(Olivier Valentin).
diff --git a/libempathy-gtk/empathy-accounts-dialog.c b/libempathy-gtk/empathy-accounts-dialog.c
index 94a569730..151922e27 100644
--- a/libempathy-gtk/empathy-accounts-dialog.c
+++ b/libempathy-gtk/empathy-accounts-dialog.c
@@ -281,11 +281,11 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
config_ui = mc_profile_get_configuration_ui (profile);
g_object_unref (profile);
- if (strcmp (config_ui, "jabber") == 0) {
+ if (!empathy_strdiff (config_ui, "jabber")) {
dialog->settings_widget =
empathy_account_widget_jabber_new (account);
}
- else if (strcmp (config_ui, "msn") == 0) {
+ else if (!empathy_strdiff (config_ui, "msn")) {
dialog ->settings_widget =
empathy_account_widget_msn_new (account);
}
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 2bb171976..a1404f403 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -289,128 +289,6 @@ empathy_xml_node_find_child_prop_value (xmlNodePtr node,
return found;
}
-GType
-empathy_dbus_type_to_g_type (const gchar *dbus_type_string)
-{
- if (dbus_type_string == NULL)
- return G_TYPE_NONE;
-
- if (dbus_type_string[0] == 's') {
- return G_TYPE_STRING;
- }
- else if (dbus_type_string[0] == 'b') {
- return G_TYPE_BOOLEAN;
- }
- else if (dbus_type_string[0] == 'q') {
- return G_TYPE_UINT;
- }
- else if (dbus_type_string[0] == 'n') {
- return G_TYPE_INT;
- }
-
- g_assert_not_reached ();
- return G_TYPE_NONE;
-}
-
-const gchar *
-empathy_g_type_to_dbus_type (GType g_type)
-{
- switch (g_type) {
- case G_TYPE_STRING:
- return "s";
- case G_TYPE_BOOLEAN:
- return "b";
- case G_TYPE_UINT:
- return "q";
- case G_TYPE_INT:
- return "n";
- default:
- g_assert_not_reached ();
- }
-
- return NULL;
-}
-
-gchar *
-empathy_g_value_to_string (const GValue *value)
-{
- gchar *return_string = NULL;
- GValue string_g_value = {0, };
-
- g_value_init (&string_g_value, G_TYPE_STRING);
- g_value_transform (value, &string_g_value);
- return_string = g_value_dup_string (&string_g_value);
- g_value_unset (&string_g_value);
-
- return return_string;
-}
-
-GValue *
-empathy_string_to_g_value (const gchar *str, GType type)
-{
- GValue *g_value;
-
- g_value = g_new0 (GValue, 1);
- g_value_init (g_value, type);
-
- switch (type) {
- case G_TYPE_STRING:
- g_value_set_string (g_value, str);
- break;
- case G_TYPE_BOOLEAN:
- g_value_set_boolean (g_value, (str[0] == 'y' || str[0] == 'T'));
- break;
- case G_TYPE_UINT:
- g_value_set_uint (g_value, atoi (str));
- break;
- case G_TYPE_INT:
- g_value_set_int (g_value, atoi (str));
- break;
- default:
- g_assert_not_reached ();
- }
-
- return g_value;
-}
-
-gboolean
-empathy_g_value_equal (const GValue *value1,
- const GValue *value2)
-{
- GType type;
-
- g_return_val_if_fail (value1 != NULL, FALSE);
- g_return_val_if_fail (value2 != NULL, FALSE);
-
- type = G_VALUE_TYPE (value1);
- if (type != G_VALUE_TYPE (value2)) {
- return FALSE;
- }
-
- switch (type)
- {
- case G_TYPE_STRING: {
- const gchar *str1;
- const gchar *str2;
-
- str1 = g_value_get_string (value1);
- str2 = g_value_get_string (value2);
- return (str1 && str2 && strcmp (str1, str2) == 0) ||
- (G_STR_EMPTY (str1) && G_STR_EMPTY (str2));
- }
- case G_TYPE_BOOLEAN:
- return g_value_get_boolean (value1) == g_value_get_boolean (value2);
- case G_TYPE_UINT:
- return g_value_get_uint (value1) == g_value_get_uint (value2);
- case G_TYPE_INT:
- return g_value_get_int (value1) == g_value_get_int (value2);
- default:
- g_warning ("Unsupported GType in value comparaison");
- }
-
- return FALSE;
-}
-
guint
empathy_account_hash (gconstpointer key)
{
@@ -507,4 +385,17 @@ empathy_inspect_handle (McAccount *account,
return name;
}
+/* Stolen from telepathy-glib */
+gboolean
+empathy_strdiff (const gchar *left, const gchar *right)
+{
+ if ((NULL == left) != (NULL == right))
+ return TRUE;
+
+ else if (left == right)
+ return FALSE;
+
+ else
+ return (0 != strcmp (left, right));
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index da56174bd..5669d33d1 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -78,16 +78,7 @@ xmlNodePtr empathy_xml_node_find_child_prop_value (xmlNodePtr node,
const gchar *prop_name,
const gchar *prop_value);
-
-/* GValue/GType */
-GType empathy_dbus_type_to_g_type (const gchar *dbus_type_string);
-const gchar *empathy_g_type_to_dbus_type (GType g_type);
-gchar * empathy_g_value_to_string (const GValue *value);
-GValue * empathy_string_to_g_value (const gchar *str,
- GType type);
-gboolean empathy_g_value_equal (const GValue *value1,
- const GValue *value2);
-
+/* Others */
guint empathy_account_hash (gconstpointer key);
gboolean empathy_account_equal (gconstpointer a,
gconstpointer b);
@@ -97,7 +88,8 @@ gchar * empathy_inspect_handle (McAccount *account,
guint handle_type);
gchar * empathy_inspect_channel (McAccount *account,
TpChan *tp_chan);
-
+gboolean empathy_strdiff (const gchar *left,
+ const gchar *right);
G_END_DECLS
#endif /* __EMPATHY_UTILS_H__ */