static void conn_ready_cb (TpConnection *connection, const GError *error, gpointer data) { EmpathyTpContactList *list = data; EmpathyTpContactListPriv *priv = GET_PRIV (list); GHashTable *request; if (error != NULL) { DEBUG ("failed: %s", error->message); goto out; } /* Look for existing group channels */ tp_cli_dbus_properties_call_get (connection, -1, TP_IFACE_CONNECTION_INTERFACE_REQUESTS, "Channels", got_channels_cb, NULL, NULL, G_OBJECT (list)); request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_LIST, NULL); /* Watch the NewChannels signal so if ensuring list channels fails (for * example because the server is slow and the D-Bus call timeouts before CM * fetches the roster), we have a chance to get them later. */ tp_cli_connection_interface_requests_connect_to_new_channels ( priv->connection, new_channels_cb, NULL, NULL, G_OBJECT (list), NULL); /* Request the 'stored' list. */ tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "stored"); tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); /* Request the 'publish' list. */ tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "publish"); tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); /* Request the 'subscribe' list. */ tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "subscribe"); tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); g_hash_table_unref (request); out: g_object_unref (list); }
static void conn_ready (TpConnection *conn, const GError *in_error, gpointer user_data) { char **argv = (char **) user_data; GError *error = NULL; g_print (" > conn_ready\n"); handle_error (in_error); /* check if the Requests interface is available */ if (tp_proxy_has_interface_by_id (conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS)) { /* we need to ensure a contact list */ GHashTable *props = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_LIST, TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, "subscribe", NULL); tp_cli_connection_interface_requests_call_ensure_channel ( conn, -1, props, create_contact_list_channel_cb, argv, NULL, NULL); g_hash_table_destroy (props); } }