static void
do_constructed (GObject *object)
{
  EmpathyTpFile *self = (EmpathyTpFile *) object;

  g_signal_connect (self->priv->channel, "invalidated",
    G_CALLBACK (tp_file_invalidated_cb), self);

  self->priv->incoming = !tp_channel_get_requested (self->priv->channel);

  tp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed (
      self->priv->channel, tp_file_state_changed_cb, NULL, NULL, object, NULL);

  tp_cli_channel_type_file_transfer_connect_to_transferred_bytes_changed (
      self->priv->channel, tp_file_transferred_bytes_changed_cb,
      NULL, NULL, object, NULL);

  tp_cli_dbus_properties_call_get (self->priv->channel,
      -1, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "State", tp_file_get_state_cb,
      NULL, NULL, object);

  tp_cli_dbus_properties_call_get (self->priv->channel,
      -1, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "AvailableSocketTypes",
      tp_file_get_available_socket_types_cb, NULL, NULL, object);

  self->priv->state_change_reason =
      TP_FILE_TRANSFER_STATE_CHANGE_REASON_NONE;
}
static void
connection_ready_cb (TpConnection *connection,
				const GError *error,
				gpointer user_data)
{
	EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (user_data);
	EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);

	if (error != NULL)
		goto out;

	/* FIXME: This should be moved to TpContact */
	tp_cli_connection_interface_avatars_connect_to_avatar_updated (priv->connection,
								       tp_contact_factory_avatar_updated_cb,
								       NULL, NULL,
								       G_OBJECT (tp_factory),
								       NULL);
	tp_cli_connection_interface_avatars_connect_to_avatar_retrieved (priv->connection,
									 tp_contact_factory_avatar_retrieved_cb,
									 NULL, NULL,
									 G_OBJECT (tp_factory),
									 NULL);

	if (tp_proxy_has_interface_by_id (connection,
				TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_CAPABILITIES)) {
		priv->contact_caps_supported = TRUE;

		tp_cli_connection_interface_contact_capabilities_connect_to_contact_capabilities_changed (
			priv->connection, tp_contact_factory_contact_capabilities_changed_cb,
			NULL, NULL, G_OBJECT (tp_factory), NULL);
	}
	else {
		tp_cli_connection_interface_capabilities_connect_to_capabilities_changed (priv->connection,
											  tp_contact_factory_capabilities_changed_cb,
											  NULL, NULL,
											  G_OBJECT (tp_factory),
											  NULL);
	}

	tp_cli_connection_interface_avatars_call_get_avatar_requirements (priv->connection,
									  -1,
									  tp_contact_factory_got_avatar_requirements_cb,
									  NULL, NULL,
									  G_OBJECT (tp_factory));

	if (!priv->contact_caps_supported) {
		tp_cli_dbus_properties_call_get (priv->connection, -1,
			TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
			"RequestableChannelClasses",
			get_requestable_channel_classes_cb, NULL, NULL,
			G_OBJECT (tp_factory));
	}

out:
	g_object_unref (tp_factory);
}
NS_IMETHODIMP
csTpChannelInterfaceGroup::GetPropertyRemotePendingMembers(csITpChannelInterfaceGroupRemotePendingMembersCB *cb)
{
  if (!m_Proxy)
    return NS_ERROR_NOT_INITIALIZED;

  NS_IF_ADDREF(cb);
  tp_cli_dbus_properties_call_get(m_Proxy, -1,
      "org.freedesktop.Telepathy.Channel.Interface.Group",
      "RemotePendingMembers",
      cb? RemotePendingMembersResponse: NULL, cb? cb: NULL, NULL, NULL);

  return NS_OK;
}
NS_IMETHODIMP
csTpChannelInterfaceGroup::GetPropertySelfHandle(csITpChannelInterfaceGroupSelfHandleCB *cb)
{
  if (!m_Proxy)
    return NS_ERROR_NOT_INITIALIZED;

  NS_IF_ADDREF(cb);
  tp_cli_dbus_properties_call_get(m_Proxy, -1,
      "org.freedesktop.Telepathy.Channel.Interface.Group",
      "SelfHandle",
      cb? SelfHandleResponse: NULL, cb? cb: NULL, NULL, NULL);

  return NS_OK;
}
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);
}
NS_IMETHODIMP
csTpChannelTypeStreamTube::GetPropertySupportedSocketTypes(csITpChannelTypeStreamTubeSupportedSocketTypesCB *cb)
{
    if (!m_Proxy)
        return NS_ERROR_NOT_INITIALIZED;

    NS_IF_ADDREF(cb);
    tp_cli_dbus_properties_call_get(m_Proxy, -1,
                                    "org.freedesktop.Telepathy.Channel.Type.StreamTube",
                                    "SupportedSocketTypes",
                                    cb? SupportedSocketTypesResponse: NULL, cb? cb: NULL, NULL, NULL);

    return NS_OK;
}
NS_IMETHODIMP
csTpChannelTypeStreamedMedia::GetPropertyImmutableStreams(csITpChannelTypeStreamedMediaImmutableStreamsCB *cb)
{
  if (!m_Proxy)
    return NS_ERROR_NOT_INITIALIZED;

  NS_IF_ADDREF(cb);
  tp_cli_dbus_properties_call_get(m_Proxy, -1,
      "org.freedesktop.Telepathy.Channel.Type.StreamedMedia",
      "ImmutableStreams",
      cb? ImmutableStreamsResponse: NULL, cb? cb: NULL, NULL, NULL);

  return NS_OK;
}
NS_IMETHODIMP
csTpChannelInterfaceMessages::GetPropertySupportedContentTypes(csITpChannelInterfaceMessagesSupportedContentTypesCB *cb)
{
  if (!m_Proxy)
    return NS_ERROR_NOT_INITIALIZED;

  NS_IF_ADDREF(cb);
  tp_cli_dbus_properties_call_get(m_Proxy, -1,
      "org.freedesktop.Telepathy.Channel.Interface.Messages",
      "SupportedContentTypes",
      cb? SupportedContentTypesResponse: NULL, cb? cb: NULL, NULL, NULL);

  return NS_OK;
}
NS_IMETHODIMP
csTpChannelInterfaceMessages::GetPropertyDeliveryReportingSupport(csITpChannelInterfaceMessagesDeliveryReportingSupportCB *cb)
{
  if (!m_Proxy)
    return NS_ERROR_NOT_INITIALIZED;

  NS_IF_ADDREF(cb);
  tp_cli_dbus_properties_call_get(m_Proxy, -1,
      "org.freedesktop.Telepathy.Channel.Interface.Messages",
      "DeliveryReportingSupport",
      cb? DeliveryReportingSupportResponse: NULL, cb? cb: NULL, NULL, NULL);

  return NS_OK;
}
NS_IMETHODIMP
csTpConnectionInterfaceLocation::GetPropertyLocationAccessControl(csITpConnectionInterfaceLocationLocationAccessControlCB *cb)
{
  if (!m_Proxy)
    return NS_ERROR_NOT_INITIALIZED;

  NS_IF_ADDREF(cb);
  tp_cli_dbus_properties_call_get(m_Proxy, -1,
      "org.freedesktop.Telepathy.Connection.Interface.Location",
      "LocationAccessControl",
      cb? LocationAccessControlResponse: NULL, cb? cb: NULL, NULL, NULL);

  return NS_OK;
}
static void remmina_tp_channel_handler_accept(TpChannel *channel, const GValue *address, const GError *error,
		gpointer user_data, GObject *weak_object)
{
	RemminaTpChannelHandler *chandler = (RemminaTpChannelHandler *) user_data;

	if (error != NULL)
	{
		g_print("remmina_tp_channel_handler_accept: %s", error->message);
		remmina_tp_channel_handler_free(chandler);
		return;
	}

	dbus_g_type_struct_get(address, 0, &chandler->host, 1, &chandler->port, G_MAXUINT);

	tp_cli_dbus_properties_call_get(channel, -1, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, "Service",
			remmina_tp_channel_handler_get_service, chandler, NULL, NULL);
}
static void
service_point_interface_check (TpConnection *tp_conn,
    const gchar **interfaces,
    const GError *error,
    gpointer data,
    GObject *connection)
{
  const gchar *interface;
  gboolean found = FALSE;
  gboolean watch = GPOINTER_TO_UINT (data);
  guint i = 0;

  if (interfaces == NULL)
    return;

  for (interface = interfaces[0];
       !found && !tp_str_empty (interface);
       interface = interfaces[++i])
    {
      if (!tp_strdiff (interface, TP_IFACE_CONNECTION_INTERFACE_SERVICE_POINT))
        found = TRUE;
    }

  if (!found)
    return;

  /* so we know if/when the service points change (eg the SIM might not be
   * accessible yet, in which case the call below won't return any entries)
   * check the flag though as we only want to do this once per connection:
   */
  if (watch)
    tp_cli_connection_interface_service_point_connect_to_service_points_changed
      (tp_conn, service_points_changed_cb, NULL, NULL, connection, NULL);

  /* fetch the current list to initialise our state */
  tp_cli_dbus_properties_call_get (tp_conn, -1,
      TP_IFACE_CONNECTION_INTERFACE_SERVICE_POINT,
      "KnownServicePoints", service_points_fetched_cb,
      NULL, NULL, connection);
}
static void
_connection_ready (TpConnection *conn,
                   const GError *error,
                   gpointer      self)
{
  if (error != NULL)
    {
      g_warning ("%s", error->message);
      return;
    }

  if (tp_proxy_has_interface (conn,
        TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE))
    {
      /* request the Statuses property */
      tp_cli_dbus_properties_call_get (conn, -1,
          TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
          "Statuses",
          _get_property_statuses,
          NULL, NULL, G_OBJECT (self));
    }
}