Пример #1
0
static DBusMessage *input_device_set_report(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	DBusMessageIter iter;
	uint32_t rpt_type;
	const gchar *rpt;

	struct input_device *idev = data;
	tDTUN_DEVICE_METHOD method;

	if (!dbus_message_iter_init(msg, &iter))
		return btd_error_invalid_args(msg);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32)
		return btd_error_invalid_args(msg);
	dbus_message_iter_get_basic(&iter, &rpt_type);
	dbus_message_iter_next(&iter);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return btd_error_invalid_args(msg);
	dbus_message_iter_get_basic(&iter, &rpt);

	method.hh_set_rpt.hdr.id = DTUN_METHOD_HH_SET_RPT;
	method.hh_set_rpt.hdr.len = sizeof(tDTUN_METHOD_HH_SET_RPT) - sizeof(tDTUN_HDR);
	memcpy(&method.hh_set_rpt.bdaddr, &idev->dst, 6);
	method.hh_set_rpt.r_type = (uint8_t) rpt_type;
	strncpy(method.hh_set_rpt.data, rpt, 1023);
	method.hh_set_rpt.data[1023] = '\0';

	dtun_client_call_method(&method);
	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
Пример #2
0
static DBusMessage *input_device_disconnect(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
//+++ BRCM
#ifdef BT_ALT_STACK
	struct input_device *idev = data;
	tDTUN_DEVICE_METHOD method;

	method.hh_bdaddr.hdr.id = DTUN_METHOD_HH_CLOSE;
	method.hh_bdaddr.hdr.len = sizeof(tDTUN_METHOD_HH_BDADDR) - sizeof(tDTUN_HDR);
	memcpy(&method.hh_bdaddr.bdaddr, &idev->dst, 6);

	dtun_client_call_method(&method);
	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
#else
	struct input_device *idev = data;
	int err;

	err = disconnect(idev, 0);
	if (err < 0)
		return btd_error_failed(msg, strerror(-err));

	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
#endif
//--- BRCM
}
Пример #3
0
static DBusMessage *input_device_send_data(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	DBusMessageIter iter;
	const gchar *send_data;

	struct input_device *idev = data;
	tDTUN_DEVICE_METHOD method;

	if (!dbus_message_iter_init(msg, &iter))
		return btd_error_invalid_args(msg);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return btd_error_invalid_args(msg);
	dbus_message_iter_get_basic(&iter, &send_data);

	method.hh_send_data.hdr.id = DTUN_METHOD_HH_SEND_DATA;
	method.hh_send_data.hdr.len = sizeof(tDTUN_METHOD_HH_SEND_DATA) - sizeof(tDTUN_HDR);
	memcpy(&method.hh_send_data.bdaddr, &idev->dst, 6);
	strncpy(method.hh_send_data.data, send_data, 1023);
	method.hh_send_data.data[1023] = '\0';

	dtun_client_call_method(&method);
	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
static int add_xml_record(DBusConnection *conn, const char *sender,
            /*struct service_adapter *serv_adapter,*/
            const char *record)
{
    sdp_record_t *          sdp_record;
    uint16_t                total_size = sizeof(tDTUN_HDR);    
    uint8_t     *           method_buf = NULL;
    uint8_t     *           buf_ptr = NULL;
    tDTUN_METHOD_DM_ADD_SDP_REC_EX  * pmethod = NULL;    
    
    debug("%s", __FUNCTION__);    
    sdp_record = sdp_xml_parse_record(record, strlen(record));
    if (!sdp_record) {
        error("Parsing of XML service record failed");
        return -EIO;
    }

    method_buf = create_sdp_method_buf(sdp_record, &total_size);
    
    pmethod = (tDTUN_METHOD_DM_ADD_SDP_REC_EX *) method_buf;
    pmethod->hdr.id = DTUN_METHOD_SDP_ADD_RECORD;
    pmethod->hdr.len = total_size - sizeof(tDTUN_HDR);
    sdp_hex_dump("***FINAL PACKET***", method_buf + sizeof(tDTUN_HDR),total_size - sizeof(tDTUN_HDR), 0 );
    dtun_client_call_method((tDTUN_DEVICE_METHOD *)method_buf);   //wait for the signal now.
    //free method buf
    free(method_buf);
    
    return 0;
}
static DBusMessage *remove_sdp_record(DBusConnection *conn,
                        DBusMessage *msg, void *data)
{
    struct service_adapter *serv_adapter = data;   
    tDTUN_METHOD_DM_REMOVE_SDP_REC_EX       method;
    dbus_uint32_t handle;
    const char *sender;
    
    debug( "SDP: remove_sdp_record  conn=%p", conn );

    if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &handle,
                            DBUS_TYPE_INVALID) == FALSE)
        return NULL;

    sender = dbus_message_get_sender(msg);
    
    g_conn = dbus_connection_ref(conn);
    g_msg = dbus_message_ref(msg);
    
    memset(&method,0, sizeof(method));
    method.handle = handle;
    method.hdr.len= sizeof(handle);
    method.hdr.id = DTUN_METHOD_SDP_REMOVE_RECORD;
    dtun_client_call_method((tDTUN_DEVICE_METHOD *)&method);
    return NULL;

}
Пример #6
0
/*******************************************************************************
**
** Function         grantAccess
**
** Description      Function to send DTUN grantAccess method message
**
*******************************************************************************/
static DBusMessage *grantAccess (DBusConnection *conn, DBusMessage *msg, void *data)
{
    tDTUN_DEVICE_METHOD method;
    uint16_t operation, access;
    const char *file_path_name;

    debug( "Obex: grantAccess" );

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_UINT16, &operation,
                               DBUS_TYPE_UINT16, &access,
                               DBUS_TYPE_STRING, &file_path_name,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: operation:%d access:%d file:%s", __FUNCTION__, operation, access, file_path_name);

    method.op_grant_access.hdr.id = DTUN_METHOD_OP_GRANT_ACCESS;
    method.op_grant_access.hdr.len = sizeof(uint8_t) + sizeof(uint8_t) + DTUN_PATH_LEN;
    method.op_grant_access.operation = operation;
    method.op_grant_access.access = access;
    strncpy(method.op_grant_access.file_path_name, file_path_name, DTUN_PATH_LEN);
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #7
0
static DBusMessage *input_device_get_protocol_mode(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct input_device *idev = data;
	tDTUN_DEVICE_METHOD method;

	method.hh_bdaddr.hdr.id = DTUN_METHOD_HH_GET_PROTO;
	method.hh_bdaddr.hdr.len = sizeof(tDTUN_METHOD_HH_BDADDR) - sizeof(tDTUN_HDR);
	memcpy(&method.hh_bdaddr.bdaddr, &idev->dst, 6);

	dtun_client_call_method(&method);
	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
Пример #8
0
/*******************************************************************************
**
** Function         exchangeVcard
**
** Description      Function to send DTUN exchangeVcard method message
**
*******************************************************************************/
static DBusMessage *exchangeVcard (DBusConnection *conn, DBusMessage	*msg, void *data) {
    tDTUN_DEVICE_METHOD method;
    const char *peer_bd_address;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &peer_bd_address,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: BDAddr:%s", __FUNCTION__, peer_bd_address);

    method.opc_exch_vcard.hdr.id = DTUN_METHOD_OPC_EXCH_VCARD;
    method.opc_exch_vcard.hdr.len = sizeof(bdaddr_t);
    str2ba(peer_bd_address, (bdaddr_t *)&method.opc_exch_vcard.bdaddr);
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #9
0
/*******************************************************************************
**
** Function         setExchangeFolder
**
** Description      Function to send DTUN setExchangeFolder method message
**
*******************************************************************************/
static DBusMessage *setExchangeFolder (DBusConnection *conn, DBusMessage *msg, void *data)
{
    tDTUN_DEVICE_METHOD method;
    const char *path_name;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &path_name,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: path:%s", __FUNCTION__, path_name);

    method.op_set_exchange_folder.hdr.id = DTUN_METHOD_OP_SET_EXCHANGE_FOLDER;
    method.op_set_exchange_folder.hdr.len = DTUN_PATH_LEN;
    strncpy(method.op_set_exchange_folder.path_name, path_name, DTUN_PATH_LEN);
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #10
0
/*******************************************************************************
**
** Function         setOwnerVcard
**
** Description      Function to send DTUN setOwnerVcard method message
**
*******************************************************************************/
static DBusMessage *setOwnerVcard (DBusConnection *conn, DBusMessage *msg, void *data)
{
    tDTUN_DEVICE_METHOD method;
    const char *file_name;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &file_name,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: file:%s", __FUNCTION__, file_name);

    method.op_set_owner_vcard.hdr.id = DTUN_METHOD_OP_SET_OWNER_VCARD;
    method.op_set_owner_vcard.hdr.len = DTUN_PATH_LEN;
    strncpy(method.op_set_owner_vcard.file_name, file_name, DTUN_PATH_LEN);
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #11
0
/*******************************************************************************
**
** Function         createVcard
**
** Description      Function to send DTUN createVcard method message
**
*******************************************************************************/
static DBusMessage *createVcard (DBusConnection *conn, DBusMessage *msg, void *data)
{
    tDTUN_DEVICE_METHOD method;
    const char *vcard_uri, *file_path_name;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &vcard_uri,
                               DBUS_TYPE_STRING, &file_path_name,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: uri:%s file:%s", __FUNCTION__, vcard_uri, file_path_name);

    method.op_create_vcard.hdr.id = DTUN_METHOD_OP_CREATE_VCARD;
    method.op_create_vcard.hdr.len = sizeof(method.op_create_vcard.vcard_uri) + DTUN_PATH_LEN;
    strncpy(method.op_create_vcard.vcard_uri, vcard_uri, sizeof(method.op_create_vcard.vcard_uri));
    strncpy(method.op_create_vcard.file_path_name, file_path_name, DTUN_PATH_LEN);
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #12
0
/*******************************************************************************
**
** Function         pushObject
**
** Description      Function to send DTUN pushObject method message
**
*******************************************************************************/
static DBusMessage *pushObject (DBusConnection *conn, DBusMessage *msg, void *data)
{
    tDTUN_DEVICE_METHOD method;
    const char *peer_bd_address, *file_path_name;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &peer_bd_address,
                               DBUS_TYPE_STRING, &file_path_name,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: BDAddr:%s, file:%s", __FUNCTION__, peer_bd_address, file_path_name);

    method.opc_push_object.hdr.id = DTUN_METHOD_OPC_PUSH_OBJECT;
    method.opc_push_object.hdr.len = sizeof(bdaddr_t) + DTUN_PATH_LEN;
    str2ba(peer_bd_address, (bdaddr_t *)&method.opc_push_object.bdaddr);
    strncpy(method.opc_push_object.file_path_name, file_path_name, DTUN_PATH_LEN);
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #13
0
static DBusMessage *input_device_set_protocol_mode(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	DBusMessageIter iter;
	uint32_t proto_mode;

	struct input_device *idev = data;
	tDTUN_DEVICE_METHOD method;

	if (!dbus_message_iter_init(msg, &iter))
		return btd_error_invalid_args(msg);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32)
		return btd_error_invalid_args(msg);
	dbus_message_iter_get_basic(&iter, &proto_mode);

	method.hh_proto.hdr.id = DTUN_METHOD_HH_SET_PROTO;
	method.hh_proto.hdr.len = sizeof(tDTUN_METHOD_HH_PROTO) - sizeof(tDTUN_HDR);
	memcpy(&method.hh_proto.bdaddr, &idev->dst, 6);
	method.hh_proto.proto_mode = (uint8_t) proto_mode;

	dtun_client_call_method(&method);
	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
Пример #14
0
/*******************************************************************************
**
** Function         storeVcard
**
** Description      Function to send DTUN storeVcard method message
**
*******************************************************************************/
static DBusMessage *storeVcard (DBusConnection *conn, DBusMessage *msg, void *data)
{
    tDTUN_DEVICE_METHOD method;
    const char *file_path_name;
    uint16_t dup_action;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &file_path_name,
                               DBUS_TYPE_UINT16, &dup_action,
                               DBUS_TYPE_INVALID))
    {
        return NULL;
    }

    debug("%s: file:%s dup_action:%d", __FUNCTION__, file_path_name, dup_action);

    method.op_store_vcard.hdr.id = DTUN_METHOD_OP_STORE_VCARD;
    method.op_store_vcard.hdr.len = DTUN_PATH_LEN + sizeof(uint16_t);
    strncpy(method.op_store_vcard.file_path_name, file_path_name, DTUN_PATH_LEN);
    method.op_store_vcard.dup_action = dup_action;
    dtun_client_call_method(&method);

    return dbus_message_new_method_return(msg);
}
Пример #15
0
/*
 * Input Device methods
 */
static DBusMessage *input_device_connect(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
//+++ BRCM
#ifdef BT_ALT_STACK
	struct input_device *idev = data;
	tDTUN_DEVICE_METHOD method;

	method.hh_open.hdr.id = DTUN_METHOD_HH_OPEN;
	method.hh_open.hdr.len = sizeof(tDTUN_METHOD_HH_OPEN) - sizeof(tDTUN_HDR);
	memcpy(&method.hh_open.bdaddr, &idev->dst, 6);
	read_remote_class(&idev->src, &idev->dst, &method.hh_open.cod);

	dtun_client_call_method(&method);
	return NULL;
#else
	struct input_device *idev = data;
	struct input_conn *iconn;
	struct fake_input *fake;
	DBusMessage *reply;
	GError *err = NULL;

	iconn = find_connection(idev->connections, "HID");
	if (!iconn)
		return btd_error_not_supported(msg);

	if (iconn->pending_connect)
		return btd_error_in_progress(msg);

	if (is_connected(iconn))
		return btd_error_already_connected(msg);

	iconn->pending_connect = dbus_message_ref(msg);
	fake = iconn->fake;

	if (fake) {
		/* Fake input device */
		if (fake->connect(iconn, &err))
			fake->flags |= FI_FLAG_CONNECTED;
	} else {
		/* HID devices */
		GIOChannel *io;

		io = bt_io_connect(BT_IO_L2CAP, control_connect_cb, iconn,
					NULL, &err,
					BT_IO_OPT_SOURCE_BDADDR, &idev->src,
					BT_IO_OPT_DEST_BDADDR, &idev->dst,
					BT_IO_OPT_PSM, L2CAP_PSM_HIDP_CTRL,
					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
					BT_IO_OPT_POWER_ACTIVE, 0,
					BT_IO_OPT_INVALID);
		iconn->ctrl_io = io;
	}

	if (err == NULL)
		return NULL;

	error("%s", err->message);
	dbus_message_unref(iconn->pending_connect);
	iconn->pending_connect = NULL;
	reply = btd_error_failed(msg, err->message);
	g_error_free(err);
	return reply;
#endif
//--- BRCM
}