コード例 #1
0
ファイル: session.c プロジェクト: BirdAndEarth/RPi
static void transport_func(GIOChannel *io, GError *err, gpointer user_data)
{
    struct callback_data *callback = user_data;
    struct obc_session *session = callback->session;
    struct obc_driver *driver = session->driver;
    struct obc_transport *transport = session->transport;
    GObex *obex;
    GObexTransportType type;
    int tx_mtu = -1;
    int rx_mtu = -1;

    DBG("");

    if (err != NULL) {
        error("%s", err->message);
        goto done;
    }

    g_io_channel_set_close_on_unref(io, FALSE);

    if (transport->getpacketopt &&
            transport->getpacketopt(io, &tx_mtu, &rx_mtu) == 0)
        type = G_OBEX_TRANSPORT_PACKET;
    else
        type = G_OBEX_TRANSPORT_STREAM;

    obex = g_obex_new(io, type, tx_mtu, rx_mtu);
    if (obex == NULL)
        goto done;

    g_io_channel_set_close_on_unref(io, TRUE);

    if (driver->target != NULL)
        g_obex_connect(obex, connect_cb, callback, &err,
                       G_OBEX_HDR_TARGET, driver->target, driver->target_len,
                       G_OBEX_HDR_INVALID);
    else
        g_obex_connect(obex, connect_cb, callback, &err,
                       G_OBEX_HDR_INVALID);

    if (err != NULL) {
        error("%s", err->message);
        g_obex_unref(obex);
        goto done;
    }

    session->obex = obex;
    sessions = g_slist_prepend(sessions, session);

    g_obex_set_disconnect_function(obex, session_disconnected, session);

    return;
done:
    callback->func(callback->session, NULL, err, callback->data);
    obc_session_unref(callback->session);
    g_free(callback);
}
コード例 #2
0
ファイル: util.c プロジェクト: KpuBopy4ka/obexd-map
GObex *create_gobex(int fd, GObexTransportType transport_type,
						gboolean close_on_unref)
{
	GIOChannel *io;
	GObex *obex;

	io = g_io_channel_unix_new(fd);
	g_assert(io != NULL);

	g_io_channel_set_close_on_unref(io, close_on_unref);

	obex = g_obex_new(io, transport_type, -1, -1);
	g_io_channel_unref(io);

	return obex;
}
コード例 #3
0
ファイル: obex-client-tool.c プロジェクト: ghent360/bluez
static void transport_connect(GIOChannel *io, GObexTransportType transport)
{
	GIOChannel *input;
	GIOCondition events;

	g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL);
	g_io_channel_set_close_on_unref(io, TRUE);

	obex = g_obex_new(io, transport, option_imtu, option_omtu);
	g_obex_set_disconnect_function(obex, disconn_func, NULL);

	input = g_io_channel_unix_new(STDIN_FILENO);
	g_io_channel_set_close_on_unref(input, TRUE);
	events = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
	g_io_add_watch(input, events, prompt_read, NULL);
	g_io_channel_unref(input);
	rl_callback_handler_install("client> ", parse_line);
}
コード例 #4
0
ファイル: obex-server-tool.c プロジェクト: DaisyPi/sensortag
static void transport_accept(GIOChannel *io)
{
	GObex *obex;
	GObexTransportType transport;

	g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL);
	g_io_channel_set_close_on_unref(io, TRUE);

	if (option_packet)
		transport = G_OBEX_TRANSPORT_PACKET;
	else
		transport = G_OBEX_TRANSPORT_STREAM;

	obex = g_obex_new(io, transport, option_imtu, option_omtu);
	g_obex_set_disconnect_function(obex, disconn_func, NULL);
	g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put, NULL);
	g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, NULL);
	g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_connect,
									NULL);
	clients = g_slist_append(clients, obex);
}
コード例 #5
0
ファイル: session.c プロジェクト: AlanApter/steamlink-sdk
static void transport_func(GIOChannel *io, GError *err, gpointer user_data)
{
	struct callback_data *callback = user_data;
	struct obc_session *session = callback->session;
	struct obc_driver *driver = session->driver;
	struct obc_transport *transport = session->transport;
	GObex *obex;
	GObexApparam *apparam;
	GObexTransportType type;
	int tx_mtu = -1;
	int rx_mtu = -1;

	DBG("");

	if (err != NULL) {
		error("%s", err->message);
		goto done;
	}

	g_io_channel_set_close_on_unref(io, FALSE);

	if (transport->getpacketopt &&
			transport->getpacketopt(io, &tx_mtu, &rx_mtu) == 0)
		type = G_OBEX_TRANSPORT_PACKET;
	else
		type = G_OBEX_TRANSPORT_STREAM;

	obex = g_obex_new(io, type, tx_mtu, rx_mtu);
	if (obex == NULL)
		goto done;

	g_io_channel_set_close_on_unref(io, TRUE);

	apparam = NULL;

	if (driver->supported_features)
		apparam = driver->supported_features(session);

	if (apparam) {
		uint8_t buf[1024];
		ssize_t len;

		len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
		if (driver->target)
			g_obex_connect(obex, connect_cb, callback, &err,
					G_OBEX_HDR_TARGET,
					driver->target, driver->target_len,
					G_OBEX_HDR_APPARAM,
					buf, len,
					G_OBEX_HDR_INVALID);
		else
			g_obex_connect(obex, connect_cb, callback, &err,
					G_OBEX_HDR_APPARAM, buf, len,
					G_OBEX_HDR_INVALID);
		g_obex_apparam_free(apparam);
	} else if (driver->target)
		g_obex_connect(obex, connect_cb, callback, &err,
			G_OBEX_HDR_TARGET, driver->target, driver->target_len,
			G_OBEX_HDR_INVALID);
	else
		g_obex_connect(obex, connect_cb, callback, &err,
							G_OBEX_HDR_INVALID);

	if (err != NULL) {
		error("%s", err->message);
		g_obex_unref(obex);
		goto done;
	}

	session->obex = obex;
	sessions = g_slist_prepend(sessions, session);

	g_obex_set_disconnect_function(obex, session_disconnected, session);

	return;
done:
	callback_destroy(callback, err);
}