aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-account-chooser.c32
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.c33
-rw-r--r--src/empathy-new-chatroom-dialog.c38
3 files changed, 37 insertions, 66 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index f077827fb..f1c0ec6b4 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -80,6 +80,30 @@ typedef struct {
GtkTreeIter *iter;
} FilterResultCallbackData;
+static FilterResultCallbackData *
+filter_result_callback_data_new (EmpathyAccountChooser *chooser,
+ TpAccount *account,
+ GtkTreeIter *iter)
+{
+ FilterResultCallbackData *data;
+
+ data = g_slice_new0 (FilterResultCallbackData);
+ data->chooser = g_object_ref (chooser);
+ data->account = g_object_ref (account);
+ data->iter = gtk_tree_iter_copy (iter);
+
+ return data;
+}
+
+static void
+filter_result_callback_data_free (FilterResultCallbackData *data)
+{
+ g_object_unref (data->chooser);
+ g_object_unref (data->account);
+ gtk_tree_iter_free (data->iter);
+ g_slice_free (FilterResultCallbackData, data);
+}
+
/* Distinguishes between store entries which are actually accounts, and special
* items like the "All" entry and the separator below it, so they can be sorted
* correctly. Higher-numbered entries will sort earlier.
@@ -765,8 +789,7 @@ account_chooser_filter_ready_cb (gboolean is_enabled,
}
g_object_unref (account);
- g_free (iter);
- g_slice_free (FilterResultCallbackData, fr_data);
+ filter_result_callback_data_free (fr_data);
}
static void
@@ -792,10 +815,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser,
if (account == NULL)
return;
- data = g_slice_new0 (FilterResultCallbackData);
- data->chooser = chooser;
- data->account = account;
- data->iter = g_memdup (iter, sizeof (GtkTreeIter));
+ data = filter_result_callback_data_new (chooser, account, iter);
if (priv->filter)
priv->filter (account, account_chooser_filter_ready_cb,
diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c
index 8249b8693..4747dfbb9 100644
--- a/libempathy-gtk/empathy-new-message-dialog.c
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -90,40 +90,17 @@ conn_prepared_cb (GObject *conn,
FilterCallbackData *data = user_data;
GError *myerr = NULL;
TpCapabilities *caps;
- GPtrArray *classes;
- guint i;
if (!tp_proxy_prepare_finish (conn, result, &myerr))
- goto out;
-
- caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
- classes = tp_capabilities_get_channel_classes (caps);
-
- for (i = 0; i < classes->len; i++)
{
- GHashTable *fixed;
- GStrv allowed;
- const gchar *chan_type;
-
- tp_value_array_unpack (g_ptr_array_index (classes, i), 2,
- &fixed, &allowed);
-
- chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
-
- if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
- continue;
-
- if (tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL) !=
- TP_HANDLE_TYPE_CONTACT)
- continue;
-
- data->callback (TRUE, data->user_data);
+ data->callback (FALSE, data->user_data);
g_slice_free (FilterCallbackData, data);
- return;
}
-out:
- data->callback (FALSE, data->user_data);
+ caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
+ data->callback (tp_capabilities_supports_text_chats (caps),
+ data->user_data);
+
g_slice_free (FilterCallbackData, data);
}
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index 6cf45ad83..58690d139 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -146,42 +146,16 @@ conn_prepared_cb (GObject *conn,
FilterCallbackData *data = user_data;
GError *myerr = NULL;
TpCapabilities *caps;
- GPtrArray *classes;
- guint i;
- if (!tp_proxy_prepare_finish (conn, result, &myerr))
- goto out;
-
- caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
- classes = tp_capabilities_get_channel_classes (caps);
-
- for (i = 0; i < classes->len; i++) {
- GHashTable *fixed;
- GStrv allowed;
- const gchar *chan_type;
-
- tp_value_array_unpack (g_ptr_array_index (classes, i), 2,
- &fixed, &allowed);
-
- chan_type = tp_asv_get_string (fixed,
- TP_PROP_CHANNEL_CHANNEL_TYPE);
-
- if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
- continue;
-
- if (tp_asv_get_uint32 (fixed,
- TP_PROP_CHANNEL_TARGET_HANDLE_TYPE,
- NULL) !=
- TP_HANDLE_TYPE_ROOM)
- continue;
-
- data->callback (TRUE, data->user_data);
+ if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
+ data->callback (FALSE, data->user_data);
g_slice_free (FilterCallbackData, data);
- return;
}
-out:
- data->callback (FALSE, data->user_data);
+ caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
+ data->callback (tp_capabilities_supports_text_chatrooms (caps),
+ data->user_data);
+
g_slice_free (FilterCallbackData, data);
}