aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-account-chooser.c
diff options
context:
space:
mode:
authorChandni Verma <chandniverma2112@gmail.com>2011-01-03 23:55:43 +0800
committerChandni Verma <chandniverma2112@gmail.com>2011-01-03 23:55:43 +0800
commit98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13 (patch)
tree8f99ad647fc286c54b3afd7707a490376c5b5ac8 /libempathy-gtk/empathy-account-chooser.c
parentceff90e7c349418ed74c3bc2346fdb9270d534c0 (diff)
downloadgsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.tar
gsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.tar.gz
gsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.tar.bz2
gsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.tar.lz
gsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.tar.xz
gsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.tar.zst
gsoc2013-empathy-98b73f3620f3b2f94e7d2ce3cfd2cd07cc637d13.zip
Skip accounts which don't support rooms in "Manage Favorites" dialog
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=603027
Diffstat (limited to 'libempathy-gtk/empathy-account-chooser.c')
-rw-r--r--libempathy-gtk/empathy-account-chooser.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index f1c0ec6b4..809c2933a 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -957,6 +957,77 @@ empathy_account_chooser_filter_is_connected (
callback (is_connected, callback_data);
}
+typedef struct {
+ EmpathyAccountChooserFilterResultCallback callback;
+ gpointer user_data;
+} FilterCallbackData;
+
+static void
+conn_prepared_cb (GObject *conn,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ FilterCallbackData *data = user_data;
+ GError *myerr = NULL;
+ TpCapabilities *caps;
+
+ if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
+ data->callback (FALSE, data->user_data);
+ g_slice_free (FilterCallbackData, data);
+ return;
+ }
+
+ caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
+ data->callback (tp_capabilities_supports_text_chatrooms (caps),
+ data->user_data);
+
+ g_slice_free (FilterCallbackData, data);
+}
+
+/**
+ * empathy_account_chooser_filter_supports_multichat:
+ * @account: a #TpAccount
+ * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
+ * @callback_data: data passed to the @callback
+ * @user_data: user data or %NULL
+ *
+ * An #EmpathyAccountChooserFilterFunc that returns accounts that both
+ * support multiuser text chat and are connected.
+ *
+ * Returns (via the callback) TRUE if @account both supports muc and is connected
+ */
+void
+empathy_account_chooser_filter_supports_chatrooms (
+ TpAccount *account,
+ EmpathyAccountChooserFilterResultCallback callback,
+ gpointer callback_data,
+ gpointer user_data)
+{
+ TpConnection *connection;
+ FilterCallbackData *cb_data;
+ GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
+
+ if (tp_account_get_connection_status (account, NULL) !=
+ TP_CONNECTION_STATUS_CONNECTED) {
+ callback (FALSE, callback_data);
+ return;
+ }
+
+ /* check if CM supports multiuser text chat */
+ connection = tp_account_get_connection (account);
+ if (connection == NULL) {
+ callback (FALSE, callback_data);
+ return;
+ }
+
+ cb_data = g_slice_new0 (FilterCallbackData);
+ cb_data->callback = callback;
+ cb_data->user_data = callback_data;
+
+ tp_proxy_prepare_async (connection, features, conn_prepared_cb,
+ cb_data);
+}
+
gboolean
empathy_account_chooser_is_ready (EmpathyAccountChooser *self)
{