static void
validate_connection(TpConnection* connection, gpointer user_data)
{
	UT_DEBUGMSG(("validate_connection()\n"));
	UT_return_if_fail(connection);

	// check if this connection supports MUC tubes
	TpCapabilities* caps = tp_connection_get_capabilities(connection);
	UT_return_if_fail(caps);

	if (!tp_capabilities_supports_dbus_tubes(caps, TP_HANDLE_TYPE_ROOM, NULL))
	{
		UT_DEBUGMSG(("Connection does not support MUC text channels\n"));
		return;
	}
	UT_DEBUGMSG(("Connection supports tube MUC rooms!\n"));

	// update the list of contacts for this connection
	tp_connection_get_contact_list_attributes(connection,
						-1,
						NULL,
						TRUE,
						tp_connection_get_contact_list_attributes_cb,
						user_data,
						NULL,
						NULL);
}
static void
list_connection_names_cb (const gchar * const *bus_names,
							gsize n,
							const gchar * const * cms,
							const gchar * const * protocols,
							const GError *error,
							gpointer user_data,
							GObject * /*unused*/)
{
	UT_DEBUGMSG(("list_connection_names_cb()\n"));
	TelepathyAccountHandler* pHandler = reinterpret_cast<TelepathyAccountHandler*>(user_data);
	UT_return_if_fail(pHandler);

	if (error != NULL)
	{
		UT_DEBUGMSG(("List connectiones failed: %s", error->message));
		UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
		return;
	}

	TpDBusDaemon* dbus = tp_dbus_daemon_dup(NULL);
	UT_return_if_fail(dbus);

	UT_DEBUGMSG(("Got %d connections:\n", (int)n));

	for (UT_uint32 i = 0; i < n; i++)
	{
		UT_DEBUGMSG(("%d: Bus name %s, connection manager %s, protocol %s\n", i+1, bus_names[i], cms[i], protocols[i]));
		TpConnection* connection = tp_connection_new (dbus, bus_names[i], NULL, NULL);
		UT_continue_if_fail(connection);

		TpCapabilities* caps = tp_connection_get_capabilities(connection);
		if (!caps)
		{
			GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
			tp_proxy_prepare_async(connection, features, prepare_connection_cb, pHandler);
		}
		else
		{
			validate_connection(connection, pHandler);
		}
	}

	g_object_unref(dbus);
}
Ejemplo n.º 3
0
static void
check_hashing (CallbacksData *data)
{
  EmpathyFTHandler *handler = data->handler;
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
  GError *myerr = NULL;
  TpCapabilities *caps;
  GPtrArray *classes;
  TpConnection *conn;

  conn = empathy_contact_get_connection (priv->contact);

  caps = tp_connection_get_capabilities (conn);
  if (caps == NULL)
    {
      data->callback (handler, NULL, data->user_data);
      goto out;
    }

  classes = tp_capabilities_get_channel_classes (caps);

  /* set whether we support hash and the type of it */
  if (!set_content_hash_type_from_classes (handler, classes))
    {
      g_set_error_literal (&myerr, EMPATHY_FT_ERROR_QUARK,
          EMPATHY_FT_ERROR_NOT_SUPPORTED,
          _("File transfer not supported by remote contact"));

      if (!g_cancellable_is_cancelled (priv->cancellable))
        g_cancellable_cancel (priv->cancellable);

      data->callback (handler, myerr, data->user_data);
      g_clear_error (&myerr);
    }
  else
    {
      /* get back to the caller now */
      data->callback (handler, NULL, data->user_data);
    }

out:
  callbacks_data_free (data);
}
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);
}
Ejemplo n.º 5
0
/**
 * 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;
  gboolean supported = FALSE;
  TpCapabilities *caps;

  /* check if CM supports multiuser text chat */
  connection = tp_account_get_connection (account);
  if (connection == NULL)
    goto out;

  caps = tp_connection_get_capabilities (connection);
  if (caps == NULL)
    goto out;

  supported = tp_capabilities_supports_text_chatrooms (caps);

out:
  callback (supported, callback_data);
}
static void
new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
					EmpathyNewChatroomDialog *dialog)
{
	EmpathyAccountChooser *account_chooser;
	gboolean               listing = FALSE;
	gboolean               expanded = FALSE;
	TpConnection          *connection;
	TpCapabilities *caps;

	if (dialog->room_list) {
		g_object_unref (dialog->room_list);
		dialog->room_list = NULL;
	}

	gtk_spinner_stop (GTK_SPINNER (dialog->throbber));
	gtk_widget_hide (dialog->throbber);
	new_chatroom_dialog_model_clear (dialog);

	if (dialog->account != NULL) {
		g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
		g_object_unref (dialog->account);
	}

	account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
	dialog->account = empathy_account_chooser_dup_account (account_chooser);
	connection = empathy_account_chooser_get_connection (account_chooser);
	if (dialog->account == NULL)
		goto out;

	dialog->status_changed_id = g_signal_connect (dialog->account,
		      "status-changed", G_CALLBACK (account_status_changed_cb), dialog);

	/* empathy_account_chooser_filter_supports_chatrooms ensures that the
	* account has a connection and CAPABILITIES has been prepared. */
	g_assert (connection != NULL);
	g_assert (tp_proxy_is_prepared (connection,
		TP_CONNECTION_FEATURE_CAPABILITIES));
	caps = tp_connection_get_capabilities (connection);

	if (tp_capabilities_supports_room_list (caps, NULL)) {
		/* Roomlist channels are supported */
		dialog->room_list = empathy_tp_roomlist_new (dialog->account);
	}
	else {
		dialog->room_list = NULL;
	}

	if (dialog->room_list) {
		g_signal_connect (dialog->room_list, "destroy",
				  G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb),
				  dialog);
		g_signal_connect (dialog->room_list, "new-room",
				  G_CALLBACK (new_chatroom_dialog_new_room_cb),
				  dialog);
		g_signal_connect (dialog->room_list, "notify::is-listing",
				  G_CALLBACK (new_chatroom_dialog_listing_cb),
				  dialog);
		g_signal_connect (dialog->room_list, "error::start",
				  G_CALLBACK (start_listing_error_cb),
				  dialog);
		g_signal_connect (dialog->room_list, "error::stop",
				  G_CALLBACK (stop_listing_error_cb),
				  dialog);

		expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse));
		if (expanded) {
			gtk_widget_hide (dialog->viewport_error);
			gtk_widget_set_sensitive (dialog->treeview, TRUE);
			new_chatroom_dialog_browse_start (dialog);
		}

		listing = empathy_tp_roomlist_is_listing (dialog->room_list);
		if (listing) {
			gtk_spinner_start (GTK_SPINNER (dialog->throbber));
			gtk_widget_show (dialog->throbber);
		}
	}

	gtk_widget_set_sensitive (dialog->expander_browse, dialog->room_list != NULL);

out:
	new_chatroom_dialog_update_widgets (dialog);
}