aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-new-call-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk/empathy-new-call-dialog.c')
-rw-r--r--libempathy-gtk/empathy-new-call-dialog.c86
1 files changed, 67 insertions, 19 deletions
diff --git a/libempathy-gtk/empathy-new-call-dialog.c b/libempathy-gtk/empathy-new-call-dialog.c
index 3d51283b1..ab9a86a6f 100644
--- a/libempathy-gtk/empathy-new-call-dialog.c
+++ b/libempathy-gtk/empathy-new-call-dialog.c
@@ -31,7 +31,6 @@
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-call-factory.h>
-#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-utils.h>
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
@@ -50,6 +49,11 @@ G_DEFINE_TYPE(EmpathyNewCallDialog, empathy_new_call_dialog,
typedef struct _EmpathyNewCallDialogPriv EmpathyNewCallDialogPriv;
+typedef struct {
+ EmpathyAccountChooserFilterResultCallback callback;
+ gpointer user_data;
+} FilterCallbackData;
+
struct _EmpathyNewCallDialogPriv {
GtkWidget *check_video;
};
@@ -136,36 +140,80 @@ out:
gtk_widget_destroy (GTK_WIDGET (dialog));
}
-static gboolean
+static void
+conn_prepared_cb (GObject *conn,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ 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_STREAMED_MEDIA))
+ 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);
+ g_slice_free (FilterCallbackData, data);
+ return;
+ }
+
+out:
+ data->callback (FALSE, data->user_data);
+ g_slice_free (FilterCallbackData, data);
+}
+
+static void
empathy_new_call_dialog_account_filter (EmpathyContactSelectorDialog *dialog,
+ EmpathyAccountChooserFilterResultCallback callback,
+ gpointer callback_data,
TpAccount *account)
{
TpConnection *connection;
- EmpathyDispatcher *dispatcher;
- GList *classes;
+ FilterCallbackData *cb_data;
+ GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
if (tp_account_get_connection_status (account, NULL) !=
TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
+ {
+ callback (FALSE, callback_data);
+ return;
+ }
/* check if CM supports calls */
connection = tp_account_get_connection (account);
if (connection == NULL)
- return FALSE;
-
- dispatcher = empathy_dispatcher_dup_singleton ();
-
- classes = empathy_dispatcher_find_requestable_channel_classes
- (dispatcher, connection, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
- TP_HANDLE_TYPE_CONTACT, NULL);
-
- g_object_unref (dispatcher);
-
- if (classes == NULL)
- return FALSE;
+ {
+ callback (FALSE, callback_data);
+ return;
+ }
- g_list_free (classes);
- return TRUE;
+ 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);
}
static GObject *