mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 01:04:40 +08:00
Update services to new error codes and helper functions
This commit is contained in:
parent
4392fbd3d9
commit
7e88afe4f8
@ -12,7 +12,7 @@ service_PROGRAMS = bluetoothd-service-audio
|
||||
|
||||
bluetoothd_service_audio_SOURCES = main.c \
|
||||
manager.h manager.c headset.h headset.c ipc.h ipc.c unix.h unix.c \
|
||||
error.h error.c device.h device.c gateway.h gateway.c \
|
||||
device.h device.c gateway.h gateway.c \
|
||||
sink.c sink.h avdtp.c avdtp.h a2dp.c a2dp.h control.c control.h
|
||||
|
||||
bluetoothd_service_audio_LDADD = $(top_builddir)/common/libhelper.a \
|
||||
|
109
audio/error.c
109
audio/error.c
@ -1,109 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2006-2007 Nokia Corporation
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "dbus.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define AUDIO_ERROR_INTERFACE "org.bluez.audio.Error"
|
||||
|
||||
/* FIXME: Remove these once global error functions exist */
|
||||
static DBusHandlerResult error_reply(DBusConnection *conn, DBusMessage *msg,
|
||||
const char *name, const char *descr)
|
||||
{
|
||||
DBusMessage *derr;
|
||||
|
||||
if (!conn || !msg)
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
|
||||
derr = dbus_message_new_error(msg, name, descr);
|
||||
if (!derr) {
|
||||
error("Unable to allocate new error return");
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
}
|
||||
|
||||
return send_message_and_unref(conn, derr);
|
||||
}
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *descr)
|
||||
{
|
||||
return error_reply(conn, msg,
|
||||
AUDIO_ERROR_INTERFACE ".InvalidArguments",
|
||||
descr ? descr : "Invalid arguments in method call");
|
||||
}
|
||||
|
||||
DBusHandlerResult err_already_connected(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_reply(conn, msg,
|
||||
AUDIO_ERROR_INTERFACE ".AlreadyConnected",
|
||||
"Already connected to a device");
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_connected(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_reply(conn, msg,
|
||||
AUDIO_ERROR_INTERFACE ".NotConnected",
|
||||
"Not connected to any device");
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_reply(conn, msg,
|
||||
AUDIO_ERROR_INTERFACE ".NotSupported",
|
||||
"The service is not supported by the remote device");
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connect_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *err)
|
||||
{
|
||||
return error_reply(conn, msg,
|
||||
AUDIO_ERROR_INTERFACE ".ConnectFailed", err);
|
||||
}
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_reply(conn, msg,
|
||||
AUDIO_ERROR_INTERFACE ".DoesNotExist",
|
||||
"Does not exist");
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_available(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_reply(conn, msg, AUDIO_ERROR_INTERFACE ".NotAvailable",
|
||||
"Not available");
|
||||
}
|
||||
|
||||
DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *dsc)
|
||||
{
|
||||
return error_reply(conn, msg, AUDIO_ERROR_INTERFACE ".Failed", dsc);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2006-2007 Nokia Corporation
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *descr);
|
||||
DBusHandlerResult err_already_connected(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult err_not_connected(DBusConnection *conn, DBusMessage * msg);
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult err_connect_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *err);
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult err_not_available(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *dsc);
|
@ -384,7 +384,7 @@ static gboolean finalize_stream_setup(struct device *dev)
|
||||
static void pending_connect_failed(struct pending_connect *c, struct device *dev)
|
||||
{
|
||||
if (c->msg)
|
||||
err_connect_failed(dev->conn, c->msg, strerror(c->err));
|
||||
error_connection_attempt_failed(dev->conn, c->msg, c->err);
|
||||
if (c->cb)
|
||||
c->cb(NULL, c->cb_data);
|
||||
pending_connect_free(c);
|
||||
@ -680,7 +680,7 @@ static void get_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
failed_not_supported:
|
||||
if (c->msg) {
|
||||
err_not_supported(device->conn, c->msg);
|
||||
error_not_supported(device->conn, c->msg);
|
||||
dbus_message_unref(c->msg);
|
||||
c->msg = NULL;
|
||||
}
|
||||
@ -721,10 +721,10 @@ static void get_handles_reply(DBusPendingCall *call, void *data)
|
||||
if (c->msg) {
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connect_failed(device->conn, c->msg,
|
||||
strerror(EHOSTDOWN));
|
||||
error_connection_attempt_failed(device->conn, c->msg,
|
||||
EHOSTDOWN);
|
||||
else
|
||||
err_not_supported(device->conn, c->msg);
|
||||
error_not_supported(device->conn, c->msg);
|
||||
}
|
||||
dbus_error_free(&derr);
|
||||
goto failed;
|
||||
@ -738,21 +738,21 @@ static void get_handles_reply(DBusPendingCall *call, void *data)
|
||||
error("Unable to get args from reply: %s", derr.message);
|
||||
dbus_error_free(&derr);
|
||||
if (c->msg)
|
||||
err_not_supported(device->conn, c->msg);
|
||||
error_not_supported(device->conn, c->msg);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (!array) {
|
||||
error("get_handles_reply: Unable to get handle array from reply");
|
||||
if (c->msg)
|
||||
err_not_supported(device->conn, c->msg);
|
||||
error_not_supported(device->conn, c->msg);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (array_len < 1) {
|
||||
debug("No record handles found");
|
||||
if (c->msg)
|
||||
err_not_supported(device->conn, c->msg);
|
||||
error_not_supported(device->conn, c->msg);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ static void get_handles_reply(DBusPendingCall *call, void *data)
|
||||
if (!msg) {
|
||||
error("Unable to allocate new method call");
|
||||
if (c->msg)
|
||||
err_connect_failed(device->conn, c->msg, strerror(ENOMEM));
|
||||
error_out_of_memory(device->conn, c->msg);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -780,7 +780,7 @@ static void get_handles_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_connection_send_with_reply(device->conn, msg, &pending, -1)) {
|
||||
error("Sending GetRemoteServiceRecord failed");
|
||||
if (c->msg)
|
||||
err_connect_failed(device->conn, c->msg, strerror(EIO));
|
||||
error_connection_attempt_failed(device->conn, c->msg, EIO);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -945,7 +945,7 @@ static DBusHandlerResult hs_stop(DBusConnection *conn, DBusMessage *msg,
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
|
||||
if (hs->state < HEADSET_STATE_PLAY_IN_PROGRESS)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
headset_set_state(device, HEADSET_STATE_CONNECTED);
|
||||
send_message_and_unref(conn, reply);
|
||||
@ -988,7 +988,7 @@ static DBusHandlerResult hs_disconnect(DBusConnection *conn, DBusMessage *msg,
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
|
||||
if (hs->state == HEADSET_STATE_DISCONNECTED)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
headset_set_state(device, HEADSET_STATE_DISCONNECTED);
|
||||
ba2str(&device->dst, hs_address);
|
||||
@ -1030,7 +1030,7 @@ static DBusHandlerResult hs_connect(DBusConnection *conn, DBusMessage *msg,
|
||||
int err;
|
||||
|
||||
if (hs->state > HEADSET_STATE_DISCONNECTED)
|
||||
return err_already_connected(conn, msg);
|
||||
return error_already_connected(conn, msg);
|
||||
|
||||
c = g_try_new0(struct pending_connect, 1);
|
||||
if (!c) {
|
||||
@ -1048,7 +1048,7 @@ static DBusHandlerResult hs_connect(DBusConnection *conn, DBusMessage *msg,
|
||||
|
||||
error:
|
||||
pending_connect_free(c);
|
||||
return err_connect_failed(conn, msg, strerror(-err));
|
||||
return error_connection_attempt_failed(conn, msg, -err);
|
||||
}
|
||||
|
||||
static gboolean ring_timer_cb(gpointer data)
|
||||
@ -1069,7 +1069,7 @@ static DBusHandlerResult hs_ring(DBusConnection *conn, DBusMessage *msg,
|
||||
DBusMessage *reply = NULL;
|
||||
|
||||
if (hs->state < HEADSET_STATE_CONNECTED)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1082,7 +1082,7 @@ static DBusHandlerResult hs_ring(DBusConnection *conn, DBusMessage *msg,
|
||||
|
||||
if (headset_send(device->headset, "\r\nRING\r\n") != G_IO_ERROR_NONE) {
|
||||
dbus_message_unref(reply);
|
||||
return err_failed(conn, msg, "Failed");
|
||||
return error_failed(conn, msg, "Failed");
|
||||
}
|
||||
|
||||
hs->ring_timer = g_timeout_add(RING_INTERVAL, ring_timer_cb, device);
|
||||
@ -1102,7 +1102,7 @@ static DBusHandlerResult hs_cancel_ringing(DBusConnection *conn,
|
||||
DBusMessage *reply = NULL;
|
||||
|
||||
if (hs->state < HEADSET_STATE_CONNECTED)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1131,10 +1131,10 @@ static DBusHandlerResult hs_play(DBusConnection *conn, DBusMessage *msg,
|
||||
int err;
|
||||
|
||||
if (hs->state < HEADSET_STATE_CONNECTED)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
if (hs->state >= HEADSET_STATE_PLAY_IN_PROGRESS)
|
||||
return err_already_connected(conn, msg);
|
||||
return error_already_connected(conn, msg);
|
||||
|
||||
c = g_try_new0(struct pending_connect, 1);
|
||||
if (!c)
|
||||
@ -1145,7 +1145,7 @@ static DBusHandlerResult hs_play(DBusConnection *conn, DBusMessage *msg,
|
||||
err = sco_connect(device, c);
|
||||
if (err < 0) {
|
||||
pending_connect_free(c);
|
||||
return err_failed(conn, msg, strerror(-err));
|
||||
return error_failed(conn, msg, strerror(-err));
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
@ -1161,7 +1161,7 @@ static DBusHandlerResult hs_get_speaker_gain(DBusConnection *conn,
|
||||
dbus_uint16_t gain;
|
||||
|
||||
if (hs->state < HEADSET_STATE_CONNECTED || hs->sp_gain < 0)
|
||||
return err_not_available(conn, msg);
|
||||
return error_not_available(conn, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1187,7 +1187,7 @@ static DBusHandlerResult hs_get_mic_gain(DBusConnection *conn,
|
||||
dbus_uint16_t gain;
|
||||
|
||||
if (hs->state < HEADSET_STATE_CONNECTED || hs->mic_gain < 0)
|
||||
return err_not_available(conn, msg);
|
||||
return error_not_available(conn, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1215,20 +1215,20 @@ static DBusHandlerResult hs_set_gain(DBusConnection *conn,
|
||||
char str[13];
|
||||
|
||||
if (hs->state < HEADSET_STATE_CONNECTED)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
dbus_error_init(&derr);
|
||||
dbus_message_get_args(msg, &derr, DBUS_TYPE_UINT16, &gain,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
if (dbus_error_is_set(&derr)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (gain > 15)
|
||||
return err_invalid_args(conn, msg,
|
||||
return error_invalid_arguments(conn, msg,
|
||||
"Must be less than or equal to 15");
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
@ -1242,7 +1242,7 @@ static DBusHandlerResult hs_set_gain(DBusConnection *conn,
|
||||
|
||||
if (headset_send(device->headset, str) != G_IO_ERROR_NONE) {
|
||||
dbus_message_unref(reply);
|
||||
return err_failed(conn, msg, "Unable to send to headset");
|
||||
return error_failed(conn, msg, "Unable to send to headset");
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -327,7 +327,7 @@ static void finish_sdp(struct audio_sdp_data *data, gboolean success)
|
||||
if (dbus_error_is_set(&derr)) {
|
||||
error("Unable to get message args");
|
||||
success = FALSE;
|
||||
err_failed(connection, data->msg, derr.message);
|
||||
error_failed(connection, data->msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
goto done;
|
||||
}
|
||||
@ -336,14 +336,14 @@ static void finish_sdp(struct audio_sdp_data *data, gboolean success)
|
||||
if (!data->records) {
|
||||
debug("No audio audio related service records were found");
|
||||
success = FALSE;
|
||||
err_not_supported(connection, data->msg);
|
||||
error_not_supported(connection, data->msg);
|
||||
goto done;
|
||||
}
|
||||
|
||||
reply = dbus_message_new_method_return(data->msg);
|
||||
if (!reply) {
|
||||
success = FALSE;
|
||||
err_failed(connection, data->msg, "Out of memory");
|
||||
error_failed(connection, data->msg, "Out of memory");
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -392,13 +392,14 @@ static void get_record_reply(DBusPendingCall *call,
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : forward error message as is */
|
||||
error("GetRemoteServiceRecord failed: %s", derr.message);
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connect_failed(connection, data->msg,
|
||||
strerror(EHOSTDOWN));
|
||||
error_connection_attempt_failed(connection, data->msg,
|
||||
EHOSTDOWN);
|
||||
else
|
||||
err_failed(connection, data->msg, derr.message);
|
||||
error_failed(connection, data->msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
goto failed;
|
||||
}
|
||||
@ -406,7 +407,7 @@ static void get_record_reply(DBusPendingCall *call,
|
||||
if (!dbus_message_get_args(reply, NULL,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &array, &array_len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_failed(connection, data->msg,
|
||||
error_failed(connection, data->msg,
|
||||
"Unable to get args from GetRecordReply");
|
||||
goto failed;
|
||||
}
|
||||
@ -452,7 +453,7 @@ static void get_next_record(struct audio_sdp_data *data)
|
||||
"GetRemoteServiceRecord");
|
||||
if (!msg) {
|
||||
error("Unable to allocate new method call");
|
||||
err_connect_failed(connection, data->msg, strerror(ENOMEM));
|
||||
error_out_of_memory(connection, data->msg);
|
||||
finish_sdp(data, FALSE);
|
||||
return;
|
||||
}
|
||||
@ -471,7 +472,7 @@ static void get_next_record(struct audio_sdp_data *data)
|
||||
|
||||
if (!dbus_connection_send_with_reply(connection, msg, &pending, -1)) {
|
||||
error("Sending GetRemoteServiceRecord failed");
|
||||
err_connect_failed(connection, data->msg, strerror(EIO));
|
||||
error_connection_attempt_failed(connection, data->msg, EIO);
|
||||
finish_sdp(data, FALSE);
|
||||
return;
|
||||
}
|
||||
@ -506,12 +507,14 @@ static void get_handles_reply(DBusPendingCall *call,
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : forward error message as is */
|
||||
error("GetRemoteServiceHandles failed: %s", derr.message);
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connect_failed(connection, data->msg, strerror(EHOSTDOWN));
|
||||
error_connection_attempt_failed(connection, data->msg,
|
||||
EHOSTDOWN);
|
||||
else
|
||||
err_failed(connection, data->msg, derr.message);
|
||||
error_failed(connection, data->msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
goto failed;
|
||||
}
|
||||
@ -520,7 +523,7 @@ static void get_handles_reply(DBusPendingCall *call,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
|
||||
&array, &array_len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_failed(connection, data->msg,
|
||||
error_failed(connection, data->msg,
|
||||
"Unable to get args from reply");
|
||||
goto failed;
|
||||
}
|
||||
@ -571,7 +574,7 @@ static DBusHandlerResult get_handles(const char *uuid,
|
||||
"org.bluez.Adapter",
|
||||
"GetRemoteServiceHandles");
|
||||
if (!msg) {
|
||||
err_failed(connection, data->msg,
|
||||
error_failed(connection, data->msg,
|
||||
"Could not create a new dbus message");
|
||||
goto failed;
|
||||
}
|
||||
@ -583,7 +586,7 @@ static DBusHandlerResult get_handles(const char *uuid,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
if (!dbus_connection_send_with_reply(connection, msg, &pending, -1)) {
|
||||
err_failed(connection, data->msg,
|
||||
error_failed(connection, data->msg,
|
||||
"Sending GetRemoteServiceHandles failed");
|
||||
goto failed;
|
||||
}
|
||||
@ -736,7 +739,7 @@ static DBusHandlerResult am_create_device(DBusConnection *conn,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
if (dbus_error_is_set(&derr)) {
|
||||
err_invalid_args(connection, msg, derr.message);
|
||||
error_invalid_arguments(connection, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -826,18 +829,18 @@ static DBusHandlerResult am_remove_device(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(connection, msg, derr.message);
|
||||
error_invalid_arguments(connection, msg, derr.message);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
if (dbus_error_is_set(&derr)) {
|
||||
err_invalid_args(connection, msg, derr.message);
|
||||
error_invalid_arguments(connection, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
match = g_slist_find_custom(devices, path, device_path_cmp);
|
||||
if (!match)
|
||||
return err_does_not_exist(connection, msg);
|
||||
return error_device_does_not_exist(connection, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -907,7 +910,7 @@ static DBusHandlerResult am_find_by_addr(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID);
|
||||
if (dbus_error_is_set(&derr)) {
|
||||
err_invalid_args(connection, msg, derr.message);
|
||||
error_invalid_arguments(connection, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -916,7 +919,7 @@ static DBusHandlerResult am_find_by_addr(DBusConnection *conn,
|
||||
device = manager_find_device(&bda, NULL, FALSE);
|
||||
|
||||
if (!device)
|
||||
return err_does_not_exist(conn, msg);
|
||||
return error_device_does_not_exist(conn, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -935,12 +938,12 @@ static DBusHandlerResult am_default_device(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!default_dev)
|
||||
return err_does_not_exist(connection, msg);
|
||||
return error_device_does_not_exist(connection, msg);
|
||||
|
||||
if (default_dev->headset == NULL &&
|
||||
dbus_message_is_method_call(msg, AUDIO_MANAGER_INTERFACE,
|
||||
"DefaultHeadset"))
|
||||
return err_does_not_exist(connection, msg);
|
||||
return error_device_does_not_exist(connection, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -966,18 +969,18 @@ static DBusHandlerResult am_change_default_device(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(connection, msg, derr.message);
|
||||
error_invalid_arguments(connection, msg, derr.message);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
if (dbus_error_is_set(&derr)) {
|
||||
err_invalid_args(connection, msg, derr.message);
|
||||
error_invalid_arguments(connection, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
match = g_slist_find_custom(devices, path, device_path_cmp);
|
||||
if (!match)
|
||||
return err_does_not_exist(connection, msg);
|
||||
return error_device_does_not_exist(connection, msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -999,7 +1002,7 @@ static DBusHandlerResult am_change_default_device(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &device->path,
|
||||
DBUS_TYPE_INVALID);
|
||||
else
|
||||
return err_does_not_exist(connection, msg);
|
||||
return error_device_does_not_exist(connection, msg);
|
||||
|
||||
default_dev = device;
|
||||
device_store(device, TRUE);
|
||||
|
19
audio/sink.c
19
audio/sink.c
@ -148,7 +148,7 @@ static gboolean stream_setup_retry(gpointer user_data)
|
||||
send_message_and_unref(pending->conn, reply);
|
||||
} else {
|
||||
debug("Stream setup failed, after XCASE connect:connect");
|
||||
err_failed(pending->conn, pending->msg, "Stream setup failed");
|
||||
error_failed(pending->conn, pending->msg, "Stream setup failed");
|
||||
}
|
||||
|
||||
sink->connect = NULL;
|
||||
@ -183,7 +183,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
|
||||
stream_setup_retry, sink);
|
||||
} else {
|
||||
sink->connect = NULL;
|
||||
err_failed(pending->conn, pending->msg, "Stream setup failed");
|
||||
error_failed(pending->conn, pending->msg, "Stream setup failed");
|
||||
pending_request_free(pending);
|
||||
debug("Stream setup failed : %s", avdtp_strerror(err));
|
||||
}
|
||||
@ -202,14 +202,14 @@ static DBusHandlerResult sink_connect(DBusConnection *conn,
|
||||
sink->session = avdtp_get(&dev->src, &dev->dst);
|
||||
|
||||
if (!sink->session)
|
||||
return err_connect_failed(conn, msg,
|
||||
return error_failed(conn, msg,
|
||||
"Unable to get a session");
|
||||
|
||||
if (sink->connect || sink->disconnect)
|
||||
return err_connect_failed(conn, msg, "Connect in progress");
|
||||
return error_in_progress(conn, msg, "Device connection already in progress");
|
||||
|
||||
if (sink->state >= AVDTP_STATE_OPEN)
|
||||
return err_already_connected(conn, msg);
|
||||
return error_already_connected(conn, msg);
|
||||
|
||||
pending = g_new0(struct pending_request, 1);
|
||||
pending->conn = dbus_connection_ref(conn);
|
||||
@ -224,8 +224,7 @@ static DBusHandlerResult sink_connect(DBusConnection *conn,
|
||||
sink->connect = NULL;
|
||||
avdtp_unref(sink->session);
|
||||
sink->session = NULL;
|
||||
return err_connect_failed(conn, msg,
|
||||
"Failed to request a stream");
|
||||
return error_failed(conn, msg, "Failed to request a stream");
|
||||
}
|
||||
|
||||
debug("stream creation in progress");
|
||||
@ -244,10 +243,10 @@ static DBusHandlerResult sink_disconnect(DBusConnection *conn,
|
||||
int err;
|
||||
|
||||
if (!sink->session)
|
||||
return err_not_connected(conn, msg);
|
||||
return error_not_connected(conn, msg);
|
||||
|
||||
if (sink->connect || sink->disconnect)
|
||||
return err_failed(conn, msg, strerror(EBUSY));
|
||||
return error_failed(conn, msg, strerror(EBUSY));
|
||||
|
||||
if (sink->state < AVDTP_STATE_OPEN) {
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
@ -260,7 +259,7 @@ static DBusHandlerResult sink_disconnect(DBusConnection *conn,
|
||||
|
||||
err = avdtp_close(sink->session, sink->stream);
|
||||
if (err < 0)
|
||||
return err_failed(conn, msg, strerror(-err));
|
||||
return error_failed(conn, msg, strerror(-err));
|
||||
|
||||
pending = g_new0(struct pending_request, 1);
|
||||
pending->conn = dbus_connection_ref(conn);
|
||||
|
229
hcid/adapter.c
229
hcid/adapter.c
@ -60,6 +60,7 @@
|
||||
#include "dbus-hci.h"
|
||||
#include "dbus-sdp.h"
|
||||
#include "dbus-error.h"
|
||||
#include "error.h"
|
||||
|
||||
#define NUM_ELEMENTS(table) (sizeof(table)/sizeof(const char *))
|
||||
|
||||
@ -365,7 +366,7 @@ static DBusHandlerResult adapter_get_address(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -386,11 +387,11 @@ static DBusHandlerResult adapter_get_version(DBusConnection *conn,
|
||||
int err;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
err = get_device_version(adapter->dev_id, str, sizeof(str));
|
||||
if (err < 0)
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -411,11 +412,11 @@ static DBusHandlerResult adapter_get_revision(DBusConnection *conn,
|
||||
int err;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
err = get_device_revision(adapter->dev_id, str, sizeof(str));
|
||||
if (err < 0)
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -436,11 +437,11 @@ static DBusHandlerResult adapter_get_manufacturer(DBusConnection *conn,
|
||||
int err;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
err = get_device_manufacturer(adapter->dev_id, str, sizeof(str));
|
||||
if (err < 0)
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -461,11 +462,11 @@ static DBusHandlerResult adapter_get_company(DBusConnection *conn,
|
||||
int err;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
err = get_device_company(adapter->dev_id, str, sizeof(str));
|
||||
if (err < 0)
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -487,7 +488,7 @@ static DBusHandlerResult adapter_list_modes(DBusConnection *conn,
|
||||
int i;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -513,7 +514,7 @@ static DBusHandlerResult adapter_get_mode(DBusConnection *conn,
|
||||
const char *mode;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -542,10 +543,10 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &mode,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (!mode)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
new_mode = str2mode(adapter->address, mode);
|
||||
switch(new_mode) {
|
||||
@ -560,7 +561,7 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
|
||||
scan_enable = (SCAN_PAGE | SCAN_INQUIRY);
|
||||
break;
|
||||
default:
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
/* Do reverse resolution in case of "on" mode */
|
||||
@ -584,7 +585,7 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
|
||||
adapter->dev_id, strerror(errno), errno);
|
||||
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,7 +593,7 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
|
||||
hcid.offmode == HCID_OFFMODE_DEVDOWN) {
|
||||
if (ioctl(dd, HCIDEVDOWN, adapter->dev_id) < 0) {
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, errno);
|
||||
return error_failed_errno(conn, msg, errno);
|
||||
}
|
||||
|
||||
goto done;
|
||||
@ -602,7 +603,7 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
|
||||
err = set_limited_discoverable(dd, adapter->class, limited);
|
||||
if (err < 0) {
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
}
|
||||
|
||||
if (current_scan != scan_enable) {
|
||||
@ -623,14 +624,14 @@ static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
|
||||
error("Sending write scan enable command failed: %s (%d)",
|
||||
strerror(errno), errno);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
if (status) {
|
||||
error("Setting scan enable failed with status 0x%02x",
|
||||
status);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, bt_error(status));
|
||||
return error_failed_errno(conn, msg, bt_error(status));
|
||||
}
|
||||
} else {
|
||||
/* discoverable or limited */
|
||||
@ -673,7 +674,7 @@ static DBusHandlerResult adapter_get_discoverable_to(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -700,7 +701,7 @@ static DBusHandlerResult adapter_set_discoverable_to(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_UINT32, &timeout,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -739,7 +740,7 @@ static DBusHandlerResult adapter_is_connectable(DBusConnection *conn,
|
||||
dbus_bool_t connectable = FALSE;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (scan_enable & SCAN_PAGE)
|
||||
connectable = TRUE;
|
||||
@ -763,7 +764,7 @@ static DBusHandlerResult adapter_is_discoverable(DBusConnection *conn,
|
||||
dbus_bool_t discoverable = FALSE;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (scan_enable & SCAN_INQUIRY)
|
||||
discoverable = TRUE;
|
||||
@ -793,10 +794,10 @@ static DBusHandlerResult adapter_is_connected(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &peer_addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(peer_addr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(peer_addr, &peer_bdaddr);
|
||||
|
||||
@ -824,7 +825,7 @@ static DBusHandlerResult adapter_list_connections(DBusConnection *conn,
|
||||
GSList *l = adapter->active_conn;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -860,7 +861,7 @@ static DBusHandlerResult adapter_get_major_class(DBusConnection *conn,
|
||||
const char *str_ptr = "computer";
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -888,7 +889,7 @@ static DBusHandlerResult adapter_list_minor_classes(DBusConnection *conn,
|
||||
int size, i;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
major_class = adapter->class[1] & 0x1F;
|
||||
|
||||
@ -930,7 +931,7 @@ static DBusHandlerResult adapter_get_minor_class(DBusConnection *conn,
|
||||
uint8_t minor_class;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* FIXME: Currently, only computer major class is supported */
|
||||
if ((adapter->class[1] & 0x1f) != 1)
|
||||
@ -970,10 +971,10 @@ static DBusHandlerResult adapter_set_minor_class(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &minor,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (!minor)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
dd = hci_open_dev(adapter->dev_id);
|
||||
if (dd < 0)
|
||||
@ -994,7 +995,7 @@ static DBusHandlerResult adapter_set_minor_class(DBusConnection *conn,
|
||||
/* Check if it's a valid minor class */
|
||||
if (dev_class == 0xFFFFFFFF) {
|
||||
hci_close_dev(dd);
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
/* set the service class and major class */
|
||||
@ -1005,7 +1006,7 @@ static DBusHandlerResult adapter_set_minor_class(DBusConnection *conn,
|
||||
error("Can't write class of device on hci%d: %s(%d)",
|
||||
adapter->dev_id, strerror(errno), errno);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
dbus_connection_emit_signal(conn, dbus_message_get_path(msg),
|
||||
@ -1035,7 +1036,7 @@ static DBusHandlerResult adapter_get_service_classes(DBusConnection *conn,
|
||||
return error_not_ready(conn, msg);
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1069,7 +1070,7 @@ static DBusHandlerResult adapter_get_name(DBusConnection *conn,
|
||||
bdaddr_t ba;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(adapter->address, &ba);
|
||||
|
||||
@ -1080,7 +1081,7 @@ static DBusHandlerResult adapter_get_name(DBusConnection *conn,
|
||||
|
||||
err = get_device_name(adapter->dev_id, str, sizeof(str));
|
||||
if (err < 0)
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
}
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
@ -1105,11 +1106,11 @@ static DBusHandlerResult adapter_set_name(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &str_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (!g_utf8_validate(str_ptr, -1, NULL)) {
|
||||
error("Name change failed: the supplied name isn't valid UTF-8");
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
str2ba(adapter->address, &bdaddr);
|
||||
@ -1121,7 +1122,7 @@ static DBusHandlerResult adapter_set_name(DBusConnection *conn,
|
||||
|
||||
ecode = set_device_name(adapter->dev_id, str_ptr);
|
||||
if (ecode < 0)
|
||||
return error_failed(conn, msg, -ecode);
|
||||
return error_failed_errno(conn, msg, -ecode);
|
||||
|
||||
done:
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
@ -1151,10 +1152,10 @@ static DBusHandlerResult adapter_get_remote_info(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1333,10 +1334,10 @@ static DBusHandlerResult adapter_get_remote_version(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
"manufacturers");
|
||||
@ -1405,10 +1406,10 @@ static DBusHandlerResult adapter_get_remote_revision(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1448,10 +1449,10 @@ static DBusHandlerResult adapter_get_remote_manufacturer(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
"manufacturers");
|
||||
@ -1485,7 +1486,7 @@ static DBusHandlerResult adapter_get_remote_company(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &str_bdaddr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(str_bdaddr, &bdaddr);
|
||||
ba2oui(&bdaddr, oui);
|
||||
@ -1519,12 +1520,12 @@ static int get_remote_class(DBusConnection *conn, DBusMessage *msg, void *data,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_peer,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
error_invalid_arguments(conn, msg);
|
||||
error_invalid_arguments(conn, msg, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (check_address(addr_peer) < 0) {
|
||||
error_invalid_arguments(conn, msg);
|
||||
error_invalid_arguments(conn, msg, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1657,10 +1658,10 @@ static DBusHandlerResult adapter_get_remote_features(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "features");
|
||||
|
||||
@ -1711,10 +1712,10 @@ static DBusHandlerResult adapter_get_remote_name(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &peer_addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(peer_addr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* check if it is in the cache */
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "names");
|
||||
@ -1762,10 +1763,10 @@ static DBusHandlerResult adapter_get_remote_alias(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(addr_ptr, &bdaddr);
|
||||
|
||||
@ -1796,18 +1797,18 @@ static DBusHandlerResult adapter_set_remote_alias(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &addr,
|
||||
DBUS_TYPE_STRING, &alias,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if ((strlen(alias) == 0) || (check_address(addr) < 0)) {
|
||||
error("Alias change failed: Invalid parameter");
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
str2ba(addr, &bdaddr);
|
||||
|
||||
ecode = set_device_alias(adapter->dev_id, &bdaddr, alias);
|
||||
if (ecode < 0)
|
||||
return error_failed(conn, msg, -ecode);
|
||||
return error_failed_errno(conn, msg, -ecode);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1834,11 +1835,11 @@ static DBusHandlerResult adapter_clear_remote_alias(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0) {
|
||||
error("Alias clear failed: Invalid parameter");
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
str2ba(addr_ptr, &bdaddr);
|
||||
@ -1849,7 +1850,7 @@ static DBusHandlerResult adapter_clear_remote_alias(DBusConnection *conn,
|
||||
|
||||
ecode = set_device_alias(adapter->dev_id, &bdaddr, NULL);
|
||||
if (ecode < 0)
|
||||
return error_failed(conn, msg, -ecode);
|
||||
return error_failed_errno(conn, msg, -ecode);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -1876,10 +1877,10 @@ static DBusHandlerResult adapter_last_seen(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
"lastseen");
|
||||
@ -1913,10 +1914,10 @@ static DBusHandlerResult adapter_last_used(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
"lastused");
|
||||
@ -1962,7 +1963,7 @@ gboolean dc_pending_timeout_handler(void *data)
|
||||
500) < 0) {
|
||||
int err = errno;
|
||||
error("Disconnect failed");
|
||||
error_failed(pending_dc->conn, pending_dc->msg, err);
|
||||
error_failed_errno(pending_dc->conn, pending_dc->msg, err);
|
||||
} else {
|
||||
reply = dbus_message_new_method_return(pending_dc->msg);
|
||||
if (!reply)
|
||||
@ -1999,10 +2000,10 @@ static DBusHandlerResult adapter_dc_remote_device(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &peer_addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(peer_addr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(peer_addr, &peer_bdaddr);
|
||||
|
||||
@ -2097,7 +2098,7 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
|
||||
if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) {
|
||||
error("Can't get socket error: %s (%d)",
|
||||
strerror(errno), errno);
|
||||
error_failed(adapter->bonding->conn, adapter->bonding->rq,
|
||||
error_failed_errno(adapter->bonding->conn, adapter->bonding->rq,
|
||||
errno);
|
||||
goto failed;
|
||||
}
|
||||
@ -2116,7 +2117,7 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
|
||||
if (getsockopt(sk, SOL_L2CAP, L2CAP_CONNINFO, &cinfo, &len) < 0) {
|
||||
error("Can't get connection info: %s (%d)",
|
||||
strerror(errno), errno);
|
||||
error_failed(adapter->bonding->conn, adapter->bonding->rq,
|
||||
error_failed_errno(adapter->bonding->conn, adapter->bonding->rq,
|
||||
errno);
|
||||
goto failed;
|
||||
}
|
||||
@ -2145,7 +2146,7 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
|
||||
if (hci_send_req(dd, &rq, 500) < 0) {
|
||||
error("Unable to send HCI request: %s (%d)",
|
||||
strerror(errno), errno);
|
||||
error_failed(adapter->bonding->conn, adapter->bonding->rq,
|
||||
error_failed_errno(adapter->bonding->conn, adapter->bonding->rq,
|
||||
errno);
|
||||
hci_close_dev(dd);
|
||||
goto failed;
|
||||
@ -2154,7 +2155,7 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
|
||||
if (rp.status) {
|
||||
error("HCI_Authentication_Requested failed with status 0x%02x",
|
||||
rp.status);
|
||||
error_failed(adapter->bonding->conn, adapter->bonding->rq,
|
||||
error_failed_errno(adapter->bonding->conn, adapter->bonding->rq,
|
||||
bt_error(rp.status));
|
||||
hci_close_dev(dd);
|
||||
goto failed;
|
||||
@ -2200,10 +2201,10 @@ static DBusHandlerResult adapter_create_bonding(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &peer_addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(peer_addr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(peer_addr, &peer_bdaddr);
|
||||
|
||||
@ -2266,10 +2267,10 @@ static DBusHandlerResult adapter_cancel_bonding(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &peer_addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(peer_addr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(peer_addr, &peer_bdaddr);
|
||||
|
||||
@ -2337,10 +2338,10 @@ static DBusHandlerResult adapter_remove_bonding(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
dd = hci_open_dev(adapter->dev_id);
|
||||
if (dd < 0)
|
||||
@ -2362,7 +2363,7 @@ static DBusHandlerResult adapter_remove_bonding(DBusConnection *conn,
|
||||
if (textfile_casedel(filename, addr_ptr) < 0) {
|
||||
int err = errno;
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
str2ba(addr_ptr, &bdaddr);
|
||||
@ -2381,7 +2382,7 @@ static DBusHandlerResult adapter_remove_bonding(DBusConnection *conn,
|
||||
int err = errno;
|
||||
error("Disconnect failed");
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2409,10 +2410,10 @@ static DBusHandlerResult adapter_has_bonding(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
"linkkeys");
|
||||
@ -2448,7 +2449,7 @@ static DBusHandlerResult adapter_list_bondings(DBusConnection *conn,
|
||||
char filename[PATH_MAX + 1];
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
"linkkeys");
|
||||
@ -2481,10 +2482,10 @@ static DBusHandlerResult adapter_get_pin_code_length(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(adapter->address, &local);
|
||||
|
||||
@ -2518,16 +2519,16 @@ static DBusHandlerResult adapter_get_encryption_key_size(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &addr_ptr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(addr_ptr) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(addr_ptr, &bdaddr);
|
||||
|
||||
val = get_encryption_key_size(adapter->dev_id, &bdaddr);
|
||||
if (val < 0)
|
||||
return error_failed(conn, msg, -val);
|
||||
return error_failed_errno(conn, msg, -val);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
|
||||
@ -2554,7 +2555,7 @@ static DBusHandlerResult adapter_start_periodic(DBusConnection *conn,
|
||||
return error_not_ready(conn, msg);
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (adapter->discov_active || adapter->pdiscov_active)
|
||||
return error_discover_in_progress(conn, msg);
|
||||
@ -2586,14 +2587,14 @@ static DBusHandlerResult adapter_start_periodic(DBusConnection *conn,
|
||||
error("Unable to start periodic inquiry: %s (%d)",
|
||||
strerror(errno), errno);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
if (status) {
|
||||
error("HCI_Periodic_Inquiry_Mode failed with status 0x%02x",
|
||||
status);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, bt_error(status));
|
||||
return error_failed_errno(conn, msg, bt_error(status));
|
||||
}
|
||||
|
||||
adapter->pdiscov_requestor = g_strdup(dbus_message_get_sender(msg));
|
||||
@ -2627,7 +2628,7 @@ static DBusHandlerResult adapter_stop_periodic(DBusConnection *conn,
|
||||
return error_not_ready(conn, msg);
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (!adapter->pdiscov_active)
|
||||
return error_not_authorized(conn, msg);
|
||||
@ -2641,7 +2642,7 @@ static DBusHandlerResult adapter_stop_periodic(DBusConnection *conn,
|
||||
if (err == -ENODEV)
|
||||
return error_no_such_adapter(conn, msg);
|
||||
else
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
}
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
@ -2676,7 +2677,7 @@ static DBusHandlerResult adapter_set_pdiscov_resolve(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_BOOLEAN, &resolve,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -2706,7 +2707,7 @@ static DBusHandlerResult adapter_get_pdiscov_resolve(DBusConnection *conn,
|
||||
dbus_bool_t resolve = adapter->pdiscov_resolve_names;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -2734,7 +2735,7 @@ static DBusHandlerResult adapter_discover_devices(DBusConnection *conn,
|
||||
return error_not_ready(conn, msg);
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (adapter->discov_active)
|
||||
return error_discover_in_progress(conn, msg);
|
||||
@ -2767,14 +2768,14 @@ static DBusHandlerResult adapter_discover_devices(DBusConnection *conn,
|
||||
error("Unable to start inquiry: %s (%d)",
|
||||
strerror(errno), errno);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
if (rp.status) {
|
||||
error("HCI_Inquiry command failed with status 0x%02x",
|
||||
rp.status);
|
||||
hci_close_dev(dd);
|
||||
return error_failed(conn, msg, bt_error(rp.status));
|
||||
return error_failed_errno(conn, msg, bt_error(rp.status));
|
||||
}
|
||||
|
||||
method = dbus_message_get_member(msg);
|
||||
@ -2807,7 +2808,7 @@ static DBusHandlerResult adapter_cancel_discovery(DBusConnection *conn,
|
||||
return error_not_ready(conn, msg);
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* is there discover pending? or discovery cancel was requested
|
||||
* previously */
|
||||
@ -2828,7 +2829,7 @@ static DBusHandlerResult adapter_cancel_discovery(DBusConnection *conn,
|
||||
if (err == -ENODEV)
|
||||
return error_no_such_adapter(conn, msg);
|
||||
else
|
||||
return error_failed(conn, msg, -err);
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
}
|
||||
|
||||
/* Reply before send DiscoveryCompleted */
|
||||
@ -2881,7 +2882,7 @@ static DBusHandlerResult adapter_list_remote_devices(DBusConnection *conn,
|
||||
struct remote_device_list_t param = { NULL, 0 };
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* Add Bonded devices to the list */
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "linkkeys");
|
||||
@ -2940,12 +2941,12 @@ static DBusHandlerResult adapter_list_recent_remote_devices(DBusConnection *conn
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &string,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* Date format is "YYYY-MM-DD HH:MM:SS GMT" */
|
||||
len = strlen(string);
|
||||
if (len && (strptime(string, "%Y-%m-%d %H:%M:%S", &date) == NULL))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* Bonded and trusted: mandatory entries(no matter the date/time) */
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "linkkeys");
|
||||
@ -2997,10 +2998,10 @@ static DBusHandlerResult adapter_set_trusted(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -3031,10 +3032,10 @@ static DBusHandlerResult adapter_is_trusted(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(adapter->address, &local);
|
||||
|
||||
@ -3063,10 +3064,10 @@ static DBusHandlerResult adapter_remove_trust(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -3138,7 +3139,7 @@ static DBusHandlerResult list_devices(DBusConnection *conn,
|
||||
return error_unknown_method(conn, msg);
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -3168,10 +3169,10 @@ static DBusHandlerResult create_device(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -3198,7 +3199,7 @@ static DBusHandlerResult remove_device(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "dbus-hci.h"
|
||||
#include "dbus-common.h"
|
||||
#include "dbus-error.h"
|
||||
#include "error.h"
|
||||
#include "dbus-service.h"
|
||||
#include "dbus-security.h"
|
||||
#include "dbus-database.h"
|
||||
@ -109,7 +110,7 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
|
||||
|
||||
dbus_message_iter_get_fixed_array(&array, &record, &len);
|
||||
if (len <= 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
user_record = g_new0(struct record_data, 1);
|
||||
|
||||
@ -118,21 +119,21 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
|
||||
if (!sdp_record) {
|
||||
error("Parsing of service record failed");
|
||||
g_free(user_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
if (scanned != len) {
|
||||
error("Size mismatch of service record");
|
||||
g_free(user_record);
|
||||
sdp_record_free(sdp_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
if (add_record_to_server(sdp_record) < 0) {
|
||||
error("Failed to register service record");
|
||||
g_free(user_record);
|
||||
sdp_record_free(sdp_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
user_record->handle = sdp_record->handle;
|
||||
@ -143,7 +144,7 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
|
||||
&user_record->handle) < 0) {
|
||||
error("Failed to register service record");
|
||||
g_free(user_record);
|
||||
return error_failed(conn, msg, errno);
|
||||
return error_failed_errno(conn, msg, errno);
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +176,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &record, DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
user_record = g_new0(struct record_data, 1);
|
||||
|
||||
@ -183,7 +184,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
|
||||
if (!sdp_record) {
|
||||
error("Parsing of XML service record failed");
|
||||
g_free(user_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
if (sdp_server_enable) {
|
||||
@ -191,7 +192,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
|
||||
error("Failed to register service record");
|
||||
g_free(user_record);
|
||||
sdp_record_free(sdp_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
user_record->handle = sdp_record->handle;
|
||||
@ -200,7 +201,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
|
||||
error("Failed to register service record");
|
||||
g_free(user_record);
|
||||
sdp_record_free(sdp_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
user_record->handle = sdp_record->handle;
|
||||
@ -243,7 +244,7 @@ static DBusHandlerResult update_record(DBusConnection *conn, DBusMessage *msg,
|
||||
if (err < 0) {
|
||||
sdp_record_free(sdp_record);
|
||||
error("Failed to update the service record");
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
} else {
|
||||
sdp_data_t *d = sdp_data_alloc(SDP_UINT32, &handle);
|
||||
@ -253,7 +254,7 @@ static DBusHandlerResult update_record(DBusConnection *conn, DBusMessage *msg,
|
||||
sdp_record_free(sdp_record);
|
||||
if (err < 0) {
|
||||
error("Failed to update the service record");
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,7 +279,7 @@ static DBusHandlerResult update_service_record(DBusConnection *conn,
|
||||
|
||||
dbus_message_iter_get_fixed_array(&array, &bin_record, &size);
|
||||
if (size <= 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
user_record = find_record(handle, dbus_message_get_sender(msg));
|
||||
if (!user_record)
|
||||
@ -287,13 +288,13 @@ static DBusHandlerResult update_service_record(DBusConnection *conn,
|
||||
sdp_record = sdp_extract_pdu(bin_record, &scanned);
|
||||
if (!sdp_record) {
|
||||
error("Parsing of service record failed");
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
if (scanned != size) {
|
||||
error("Size mismatch of service record");
|
||||
sdp_record_free(sdp_record);
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
return update_record(conn, msg, handle, sdp_record);
|
||||
@ -312,11 +313,11 @@ static DBusHandlerResult update_service_record_from_xml(DBusConnection *conn,
|
||||
DBUS_TYPE_UINT32, &handle,
|
||||
DBUS_TYPE_STRING, &record,
|
||||
DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
len = (record ? strlen(record) : 0);
|
||||
if (len == 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
user_record = find_record(handle, dbus_message_get_sender(msg));
|
||||
if (!user_record)
|
||||
@ -326,7 +327,7 @@ static DBusHandlerResult update_service_record_from_xml(DBusConnection *conn,
|
||||
if (!sdp_record) {
|
||||
error("Parsing of XML service record failed");
|
||||
sdp_record_free(sdp_record);
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
}
|
||||
|
||||
return update_record(conn, msg, handle, sdp_record);
|
||||
@ -342,7 +343,7 @@ static DBusHandlerResult remove_service_record(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_UINT32, &handle, DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
sender = dbus_message_get_sender(msg);
|
||||
|
||||
@ -380,12 +381,12 @@ static DBusHandlerResult register_service(DBusConnection *conn,
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
|
||||
DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &desc,
|
||||
DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
sender = dbus_message_get_sender(msg);
|
||||
|
||||
if (service_register(conn, sender, ident, name, desc) < 0)
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -403,7 +404,7 @@ static DBusHandlerResult unregister_service(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
|
||||
DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
sender = dbus_message_get_sender(msg);
|
||||
|
||||
@ -415,7 +416,7 @@ static DBusHandlerResult unregister_service(DBusConnection *conn,
|
||||
return error_not_authorized(conn, msg);
|
||||
|
||||
if (service_unregister(conn, service) < 0)
|
||||
return error_failed(conn, msg, EIO);
|
||||
return error_failed_errno(conn, msg, EIO);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -435,7 +436,7 @@ static DBusHandlerResult request_authorization(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
sender = dbus_message_get_sender(msg);
|
||||
|
||||
@ -478,7 +479,7 @@ static DBusHandlerResult cancel_authorization_request(DBusConnection *conn,
|
||||
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) == FALSE)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
sender = dbus_message_get_sender(msg);
|
||||
|
||||
|
@ -37,14 +37,7 @@
|
||||
#include "dbus.h"
|
||||
#include "dbus-common.h"
|
||||
#include "dbus-error.h"
|
||||
|
||||
DBusHandlerResult error_failed(DBusConnection *conn, DBusMessage *msg, int err)
|
||||
{
|
||||
const char *str = strerror(err);
|
||||
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".Failed", str));
|
||||
}
|
||||
#include "error.h"
|
||||
|
||||
DBusHandlerResult error_not_ready(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
@ -52,13 +45,6 @@ DBusHandlerResult error_not_ready(DBusConnection *conn, DBusMessage *msg)
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".NotReady", "Adapter is not ready"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_invalid_arguments(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".InvalidArguments",
|
||||
"Invalid arguments"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_unknown_method(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
char error[128];
|
||||
@ -88,13 +74,6 @@ DBusHandlerResult error_rejected(DBusConnection *conn, DBusMessage *msg)
|
||||
"Rejected"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_out_of_memory(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".OutOfMemory",
|
||||
"Out of memory"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
@ -109,20 +88,6 @@ DBusHandlerResult error_no_such_service(DBusConnection *conn, DBusMessage *msg)
|
||||
"No such service"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".NotAvailable",
|
||||
"Not available"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_not_supported(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".NotSupported",
|
||||
"Not supported"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_request_deferred(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
@ -130,13 +95,6 @@ DBusHandlerResult error_request_deferred(DBusConnection *conn, DBusMessage *msg)
|
||||
"Request Deferred"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_not_connected(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".NotConnected",
|
||||
"Not connected"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_unsupported_major_class(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
@ -144,48 +102,12 @@ DBusHandlerResult error_unsupported_major_class(DBusConnection *conn, DBusMessag
|
||||
"Unsupported Major Class"));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn, DBusMessage *msg, int err)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".ConnectionAttemptFailed",
|
||||
err ? strerror(err) : "Connection attempt failed"));
|
||||
}
|
||||
|
||||
static DBusHandlerResult error_already_exists(DBusConnection *conn, DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".AlreadyExists", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_does_not_exist(DBusConnection *conn, DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".DoesNotExist", str));
|
||||
}
|
||||
|
||||
static DBusHandlerResult error_in_progress(DBusConnection *conn, DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".InProgress", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_canceled(DBusConnection *conn, DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".Canceled", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_not_in_progress(DBusConnection *conn, DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg, ERROR_INTERFACE ".NotInProgress", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult error_connect_canceled(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_canceled(conn, msg, "Connection creation was canceled");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_bonding_already_exists(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_already_exists(conn, msg, "Bonding already exists");
|
||||
@ -218,16 +140,6 @@ DBusHandlerResult error_discover_in_progress(DBusConnection *conn, DBusMessage *
|
||||
return error_in_progress(conn, msg, "Discover in progress");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_connect_in_progress(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_in_progress(conn, msg, "Connection creation in progress");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_connect_not_in_progress(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_not_in_progress(conn, msg, "Connection creation not in progress");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_record_does_not_exist(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_does_not_exist(conn, msg, "Record does not exist");
|
||||
@ -253,16 +165,6 @@ DBusHandlerResult error_auth_agent_does_not_exist(DBusConnection *conn, DBusMess
|
||||
return error_does_not_exist(conn, msg, "Authorization agent does not exist");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_binding_does_not_exist(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_does_not_exist(conn, msg, "Binding does not exist");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_service_already_exists(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_already_exists(conn, msg, "Service already exists");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_service_does_not_exist(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_does_not_exist(conn, msg, "Service does not exist");
|
||||
@ -278,16 +180,6 @@ DBusHandlerResult error_audit_already_exists(DBusConnection *conn, DBusMessage *
|
||||
return error_already_exists(conn, msg, "Audit already performed");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_trusted_device_already_exists(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_already_exists(conn, msg, "Trusted device already exists");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_trusted_device_does_not_exists(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_does_not_exist(conn, msg, "Trusted device does not exist");
|
||||
}
|
||||
|
||||
DBusHandlerResult error_disconnect_in_progress(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return error_in_progress(conn, msg, "Disconnection in progress");
|
||||
|
@ -22,47 +22,34 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define ERROR_INTERFACE "org.bluez.Error"
|
||||
/*
|
||||
Please update dbus-api.txt in hcid folder when changes are made to this file.
|
||||
*/
|
||||
|
||||
DBusHandlerResult error_failed(DBusConnection *conn, DBusMessage *msg, int err);
|
||||
DBusHandlerResult error_not_ready(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_invalid_arguments(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_unknown_method(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_not_authorized(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_rejected(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_out_of_memory(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_no_such_service(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_not_supported(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_request_deferred(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_not_connected(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_does_not_exist(DBusConnection *conn, DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult error_canceled(DBusConnection *conn, DBusMessage *msg, const char *str);
|
||||
/* Used only for hcid device audit feature */
|
||||
DBusHandlerResult error_not_in_progress(DBusConnection *conn, DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult error_unsupported_major_class(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn, DBusMessage *msg, int err);
|
||||
DBusHandlerResult error_bonding_already_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_bonding_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_bonding_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_bonding_not_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_authentication_canceled(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_discover_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_connect_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_connect_not_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_record_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_passkey_agent_already_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_passkey_agent_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_auth_agent_already_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_auth_agent_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_binding_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_service_already_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_service_does_not_exist(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_service_search_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_connect_canceled(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_sdp_failed(DBusConnection *conn, DBusMessage *msg, int err);
|
||||
DBusHandlerResult error_audit_already_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_trusted_device_already_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_trusted_device_does_not_exists(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_disconnect_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult error_service_start_in_progress(DBusConnection *conn, DBusMessage *msg);
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "textfile.h"
|
||||
#include "manager.h"
|
||||
#include "adapter.h"
|
||||
#include "error.h"
|
||||
#include "dbus-helper.h"
|
||||
#include "dbus-common.h"
|
||||
#include "dbus-error.h"
|
||||
@ -217,7 +218,7 @@ DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
|
||||
"Authentication Timeout");
|
||||
case 0x17: /* too frequent pairing attempts */
|
||||
return dbus_message_new_error(msg,
|
||||
ERROR_INTERFACE ".RepeatedAttemps",
|
||||
ERROR_INTERFACE ".RepeatedAttempts",
|
||||
"Repeated Attempts");
|
||||
|
||||
case 0x06:
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "dbus-hci.h"
|
||||
#include "dbus-common.h"
|
||||
#include "dbus-error.h"
|
||||
#include "error.h"
|
||||
#include "dbus-sdp.h"
|
||||
#include "sdp-xml.h"
|
||||
|
||||
@ -436,7 +437,7 @@ static gboolean search_process_cb(GIOChannel *chan,
|
||||
|
||||
failed:
|
||||
if (err) {
|
||||
error_failed(ctxt->conn, ctxt->rq, err);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, err);
|
||||
transaction_context_free(ctxt, FALSE);
|
||||
}
|
||||
|
||||
@ -461,12 +462,12 @@ static void remote_svc_rec_completed_cb(uint8_t type, uint16_t err,
|
||||
int sdp_err = sdp_get_error(ctxt->session);
|
||||
if (sdp_err < 0) {
|
||||
error("search failed: Invalid session!");
|
||||
error_failed(ctxt->conn, ctxt->rq, EINVAL);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EINVAL);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
error("search failed: %s (%d)", strerror(sdp_err), sdp_err);
|
||||
error_failed(ctxt->conn, ctxt->rq, sdp_err);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, sdp_err);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -478,7 +479,7 @@ static void remote_svc_rec_completed_cb(uint8_t type, uint16_t err,
|
||||
/* check response PDU ID */
|
||||
if (type != SDP_SVC_ATTR_RSP) {
|
||||
error("SDP error: %s (%d)", strerror(EPROTO), EPROTO);
|
||||
error_failed(ctxt->conn, ctxt->rq, EPROTO);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EPROTO);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -533,12 +534,12 @@ static void remote_svc_rec_completed_xml_cb(uint8_t type, uint16_t err,
|
||||
int sdp_err = sdp_get_error(ctxt->session);
|
||||
if (sdp_err < 0) {
|
||||
error("search failed: Invalid session!");
|
||||
error_failed(ctxt->conn, ctxt->rq, EINVAL);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EINVAL);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
error("search failed: %s (%d)", strerror(sdp_err), sdp_err);
|
||||
error_failed(ctxt->conn, ctxt->rq, sdp_err);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, sdp_err);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -550,7 +551,7 @@ static void remote_svc_rec_completed_xml_cb(uint8_t type, uint16_t err,
|
||||
/* check response PDU ID */
|
||||
if (type != SDP_SVC_ATTR_RSP) {
|
||||
error("SDP error: %s (%d)", strerror(EPROTO), EPROTO);
|
||||
error_failed(ctxt->conn, ctxt->rq, EPROTO);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EPROTO);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -607,12 +608,12 @@ static void remote_svc_handles_completed_cb(uint8_t type, uint16_t err,
|
||||
int sdp_err = sdp_get_error(ctxt->session);
|
||||
if (sdp_err < 0) {
|
||||
error("search failed: Invalid session!");
|
||||
error_failed(ctxt->conn, ctxt->rq, EINVAL);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EINVAL);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
error("search failed: %s (%d)", strerror(sdp_err), sdp_err);
|
||||
error_failed(ctxt->conn, ctxt->rq, sdp_err);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, sdp_err);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -624,7 +625,7 @@ static void remote_svc_handles_completed_cb(uint8_t type, uint16_t err,
|
||||
/* check response PDU ID */
|
||||
if (type != SDP_SVC_SEARCH_RSP) {
|
||||
error("SDP error: %s (%d)", strerror(EPROTO), EPROTO);
|
||||
error_failed(ctxt->conn, ctxt->rq, EPROTO);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EPROTO);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -739,12 +740,12 @@ static void remote_svc_identifiers_completed_cb(uint8_t type, uint16_t err,
|
||||
int sdp_err = sdp_get_error(ctxt->session);
|
||||
if (sdp_err < 0) {
|
||||
error("search failed: Invalid session!");
|
||||
error_failed(ctxt->conn, ctxt->rq, EINVAL);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EINVAL);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
error("search failed: %s (%d)", strerror(sdp_err), sdp_err);
|
||||
error_failed(ctxt->conn, ctxt->rq, sdp_err);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, sdp_err);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -756,7 +757,7 @@ static void remote_svc_identifiers_completed_cb(uint8_t type, uint16_t err,
|
||||
/* Check response PDU ID */
|
||||
if (type != SDP_SVC_SEARCH_ATTR_RSP) {
|
||||
error("SDP error: %s (%d)", strerror(EPROTO), EPROTO);
|
||||
error_failed(ctxt->conn, ctxt->rq, EPROTO);
|
||||
error_failed_errno(ctxt->conn, ctxt->rq, EPROTO);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -1014,7 +1015,7 @@ DBusHandlerResult get_remote_svc_rec(DBusConnection *conn, DBusMessage *msg,
|
||||
DBUS_TYPE_STRING, &dst,
|
||||
DBUS_TYPE_UINT32, &handle,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (find_pending_connect(dst))
|
||||
return error_service_search_in_progress(conn, msg);
|
||||
@ -1026,7 +1027,7 @@ DBusHandlerResult get_remote_svc_rec(DBusConnection *conn, DBusMessage *msg,
|
||||
if (!connect_request(conn, msg, adapter->dev_id,
|
||||
dst, cb, &err)) {
|
||||
error("Search request failed: %s (%d)", strerror(err), err);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
@ -1087,13 +1088,13 @@ DBusHandlerResult get_remote_svc_handles(DBusConnection *conn, DBusMessage *msg,
|
||||
DBUS_TYPE_STRING, &dst,
|
||||
DBUS_TYPE_STRING, &svc,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (strlen(svc) > 0) {
|
||||
/* Check if it is a service name string */
|
||||
if (str2uuid(&uuid, svc) < 0) {
|
||||
error("Invalid service class name");
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1103,7 +1104,7 @@ DBusHandlerResult get_remote_svc_handles(DBusConnection *conn, DBusMessage *msg,
|
||||
if (!connect_request(conn, msg, adapter->dev_id,
|
||||
dst, remote_svc_handles_conn_cb, &err)) {
|
||||
error("Search request failed: %s (%d)", strerror(err), err);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
@ -1121,7 +1122,7 @@ DBusHandlerResult get_remote_svc_identifiers(DBusConnection *conn, DBusMessage *
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &dst,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (find_pending_connect(dst))
|
||||
return error_service_search_in_progress(conn, msg);
|
||||
@ -1129,7 +1130,7 @@ DBusHandlerResult get_remote_svc_identifiers(DBusConnection *conn, DBusMessage *
|
||||
if (!connect_request(conn, msg, adapter->dev_id,
|
||||
dst, remote_svc_identifiers_conn_cb, &err)) {
|
||||
error("Search request failed: %s (%d)", strerror(err), err);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
@ -1147,7 +1148,7 @@ DBusHandlerResult finish_remote_svc_transact(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "dbus-common.h"
|
||||
#include "dbus-service.h"
|
||||
#include "dbus-error.h"
|
||||
#include "error.h"
|
||||
#include "dbus-security.h"
|
||||
#include "dbus-hci.h"
|
||||
|
||||
@ -259,10 +260,10 @@ static DBusHandlerResult register_passkey_agent(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_STRING, &addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if ((check_address(addr) < 0) || (path[0] != '/'))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
memset(&ref, 0, sizeof(ref));
|
||||
|
||||
@ -317,7 +318,7 @@ static DBusHandlerResult unregister_passkey_agent(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_STRING, &addr,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
memset(&ref, 0, sizeof(ref));
|
||||
|
||||
@ -357,7 +358,7 @@ static DBusHandlerResult register_default_passkey_agent(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
default_agent = passkey_agent_new(NULL, conn, dbus_message_get_sender(msg),
|
||||
path, NULL);
|
||||
@ -398,7 +399,7 @@ static DBusHandlerResult unregister_default_passkey_agent(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
name = dbus_message_get_sender(msg);
|
||||
|
||||
@ -573,7 +574,7 @@ static DBusHandlerResult register_default_auth_agent(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
default_auth_agent = auth_agent_new(conn,
|
||||
dbus_message_get_sender(msg), path);
|
||||
@ -614,7 +615,7 @@ static DBusHandlerResult unregister_default_auth_agent(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
name = dbus_message_get_sender(msg);
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "server.h"
|
||||
#include "dbus-common.h"
|
||||
#include "dbus-error.h"
|
||||
#include "error.h"
|
||||
#include "manager.h"
|
||||
#include "adapter.h"
|
||||
#include "dbus-service.h"
|
||||
@ -326,7 +327,7 @@ static void abort_startup(struct service *service, DBusConnection *conn, int eco
|
||||
|
||||
if (service->action) {
|
||||
if (conn)
|
||||
error_failed(conn, service->action, ecode);
|
||||
error_failed_errno(conn, service->action, ecode);
|
||||
dbus_message_unref(service->action);
|
||||
service->action = NULL;
|
||||
}
|
||||
@ -467,10 +468,10 @@ static DBusHandlerResult start(DBusConnection *conn,
|
||||
struct service *service = data;
|
||||
|
||||
if (service->external || service->pid)
|
||||
return error_failed(conn, msg, EALREADY);
|
||||
return error_failed_errno(conn, msg, EALREADY);
|
||||
|
||||
if (service_start(service, conn) < 0)
|
||||
return error_failed(conn, msg, ENOEXEC);
|
||||
return error_failed_errno(conn, msg, ENOEXEC);
|
||||
|
||||
service->action = dbus_message_ref(msg);
|
||||
|
||||
@ -483,7 +484,7 @@ static DBusHandlerResult stop(DBusConnection *conn,
|
||||
struct service *service = data;
|
||||
|
||||
if (service->external || !service->bus_name)
|
||||
return error_failed(conn, msg, EPERM);
|
||||
return error_failed_errno(conn, msg, EPERM);
|
||||
|
||||
stop_service(service, FALSE);
|
||||
|
||||
@ -539,10 +540,10 @@ static DBusHandlerResult set_trusted(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -600,10 +601,10 @@ static DBusHandlerResult is_trusted(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
trusted = read_trust(BDADDR_ANY, address, service->ident);
|
||||
|
||||
@ -628,10 +629,10 @@ static DBusHandlerResult remove_trust(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "adapter.h"
|
||||
#include "dbus-hci.h"
|
||||
#include "dbus-error.h"
|
||||
#include "error.h"
|
||||
#include "dbus-test.h"
|
||||
|
||||
#define L2INFO_TIMEOUT (2 * 1000)
|
||||
@ -424,11 +425,11 @@ static DBusHandlerResult audit_remote_device(DBusConnection *conn,
|
||||
if (dbus_error_is_set(&err)) {
|
||||
error("Can't extract message arguments:%s", err.message);
|
||||
dbus_error_free(&err);
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(address, &peer);
|
||||
str2ba(adapter->address, &local);
|
||||
@ -507,11 +508,11 @@ static DBusHandlerResult cancel_audit_remote_device(DBusConnection *conn,
|
||||
if (dbus_error_is_set(&err)) {
|
||||
error("Can't extract message arguments:%s", err.message);
|
||||
dbus_error_free(&err);
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(address, &peer);
|
||||
str2ba(adapter->address, &local);
|
||||
@ -567,11 +568,11 @@ static DBusHandlerResult get_l2cap_feature_mask(DBusConnection *conn,
|
||||
if (dbus_error_is_set(&err)) {
|
||||
error("Can't extract message arguments:%s", err.message);
|
||||
dbus_error_free(&err);
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(address, &peer);
|
||||
str2ba(adapter->address, &local);
|
||||
@ -609,11 +610,11 @@ static DBusHandlerResult get_l2cap_mtu_size(DBusConnection *conn,
|
||||
if (dbus_error_is_set(&err)) {
|
||||
error("Can't extract message arguments:%s", err.message);
|
||||
dbus_error_free(&err);
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
}
|
||||
|
||||
if (check_address(address) < 0)
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
str2ba(address, &peer);
|
||||
str2ba(adapter->address, &local);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "dbus.h"
|
||||
#include "dbus-helper.h"
|
||||
#include "dbus-common.h"
|
||||
#include "error.h"
|
||||
#include "dbus-error.h"
|
||||
#include "dbus-hci.h"
|
||||
#include "dbus-service.h"
|
||||
@ -67,7 +68,7 @@ static DBusHandlerResult interface_version(DBusConnection *conn,
|
||||
dbus_uint32_t version = 0;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -86,7 +87,7 @@ static DBusHandlerResult default_adapter(DBusConnection *conn,
|
||||
char path[MAX_PATH_LENGTH], *path_ptr = path;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
if (default_adapter_id < 0)
|
||||
return error_no_such_adapter(conn, msg);
|
||||
@ -159,7 +160,7 @@ static DBusHandlerResult find_adapter(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
/* hci_devid() would make sense to use here, except it
|
||||
is restricted to devices which are up */
|
||||
@ -200,11 +201,11 @@ static DBusHandlerResult list_adapters(DBusConnection *conn,
|
||||
int i, sk;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
||||
if (sk < 0)
|
||||
return error_failed(conn, msg, errno);
|
||||
return error_failed_errno(conn, msg, errno);
|
||||
|
||||
dl = g_malloc0(HCI_MAX_DEV * sizeof(*dr) + sizeof(*dl));
|
||||
|
||||
@ -215,7 +216,7 @@ static DBusHandlerResult list_adapters(DBusConnection *conn,
|
||||
int err = errno;
|
||||
close(sk);
|
||||
g_free(dl);
|
||||
return error_failed(conn, msg, err);
|
||||
return error_failed_errno(conn, msg, err);
|
||||
}
|
||||
|
||||
dr = dl->dev_req;
|
||||
@ -267,7 +268,7 @@ static DBusHandlerResult find_service(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
service = search_service(conn, pattern);
|
||||
if (!service)
|
||||
@ -291,7 +292,7 @@ static DBusHandlerResult list_services(DBusConnection *conn,
|
||||
DBusMessageIter array_iter;
|
||||
|
||||
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -317,7 +318,7 @@ static DBusHandlerResult activate_service(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, NULL,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID))
|
||||
return error_invalid_arguments(conn, msg);
|
||||
return error_invalid_arguments(conn, msg, NULL);
|
||||
|
||||
service = search_service(conn, pattern);
|
||||
if (!service)
|
||||
@ -341,7 +342,7 @@ static DBusHandlerResult activate_service(DBusConnection *conn,
|
||||
return error_service_start_in_progress(conn, msg);
|
||||
|
||||
if (service_start(service, conn) < 0)
|
||||
return error_failed(conn, msg, ENOEXEC);
|
||||
return error_failed_errno(conn, msg, ENOEXEC);
|
||||
|
||||
service->action = dbus_message_ref(msg);
|
||||
|
||||
|
@ -11,7 +11,7 @@ servicedir = $(libdir)/bluetooth
|
||||
service_PROGRAMS = bluetoothd-service-input
|
||||
|
||||
bluetoothd_service_input_SOURCES = main.c \
|
||||
manager.h manager.c error.h error.c \
|
||||
manager.h manager.c \
|
||||
server.h server.c device.h device.c storage.h storage.c
|
||||
|
||||
LDADD = $(top_builddir)/common/libhelper.a \
|
||||
|
@ -434,8 +434,8 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan,
|
||||
return FALSE;
|
||||
|
||||
failed:
|
||||
err_connection_failed(idev->conn,
|
||||
idev->pending_connect, strerror(err));
|
||||
error_connection_attempt_failed(idev->conn,
|
||||
idev->pending_connect, err);
|
||||
dbus_message_unref(idev->pending_connect);
|
||||
idev->pending_connect = NULL;
|
||||
|
||||
@ -684,8 +684,8 @@ static gboolean interrupt_connect_cb(GIOChannel *chan,
|
||||
|
||||
goto cleanup;
|
||||
failed:
|
||||
err_connection_failed(idev->conn,
|
||||
idev->pending_connect, strerror(err));
|
||||
error_connection_attempt_failed(idev->conn,
|
||||
idev->pending_connect, err);
|
||||
if (isk > 0)
|
||||
close(isk);
|
||||
close(idev->ctrl_sk);
|
||||
@ -751,8 +751,8 @@ failed:
|
||||
close(csk);
|
||||
|
||||
idev->ctrl_sk = -1;
|
||||
err_connection_failed(idev->conn,
|
||||
idev->pending_connect, strerror(err));
|
||||
error_connection_attempt_failed(idev->conn,
|
||||
idev->pending_connect, err);
|
||||
dbus_message_unref(idev->pending_connect);
|
||||
idev->pending_connect = NULL;
|
||||
|
||||
@ -871,21 +871,24 @@ static DBusHandlerResult device_connect(DBusConnection *conn,
|
||||
struct device *idev = data;
|
||||
|
||||
if (idev->pending_connect)
|
||||
return err_connection_failed(conn, msg, "Connection in progress");
|
||||
return error_in_progress(conn, msg,
|
||||
"Device connection already in progress");
|
||||
|
||||
if (is_connected(idev))
|
||||
return err_already_connected(conn, msg);
|
||||
return error_already_connected(conn, msg);
|
||||
|
||||
idev->pending_connect = dbus_message_ref(msg);
|
||||
|
||||
/* Fake input device */
|
||||
if (idev->fake) {
|
||||
if (rfcomm_connect(idev) < 0) {
|
||||
const char *str = strerror(errno);
|
||||
error("RFCOMM connect failed: %s(%d)", str, errno);
|
||||
int err = errno;
|
||||
const char *str = strerror(err);
|
||||
error("RFCOMM connect failed: %s(%d)", str, err);
|
||||
dbus_message_unref(idev->pending_connect);
|
||||
idev->pending_connect = NULL;
|
||||
return err_connection_failed(conn, msg, str);
|
||||
return error_connection_attempt_failed(conn,
|
||||
msg, err);
|
||||
}
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -898,7 +901,7 @@ static DBusHandlerResult device_connect(DBusConnection *conn,
|
||||
error("L2CAP connect failed: %s(%d)", strerror(err), err);
|
||||
dbus_message_unref(idev->pending_connect);
|
||||
idev->pending_connect = NULL;
|
||||
return err_connection_failed(conn, msg, strerror(err));
|
||||
return error_connection_attempt_failed(conn, msg, err);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
@ -910,7 +913,7 @@ static DBusHandlerResult device_disconnect(DBusConnection *conn,
|
||||
struct device *idev = data;
|
||||
|
||||
if (disconnect(idev, 0) < 0)
|
||||
return err_failed(conn, msg, strerror(errno));
|
||||
return error_failed_errno(conn, msg, errno);
|
||||
|
||||
/* Replying to the requestor */
|
||||
return send_message_and_unref(conn,
|
||||
|
108
input/error.c
108
input/error.c
@ -1,108 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <dbus.h>
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#define INPUT_ERROR_INTERFACE "org.bluez.input.Error"
|
||||
|
||||
DBusHandlerResult err_unknown_device(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".UnknownDevice",
|
||||
"Invalid device"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_failed(DBusConnection *conn, DBusMessage *msg,
|
||||
const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".Failed", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE".ConnectionAttemptFailed",
|
||||
str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_already_connected(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".AlreadyConnected",
|
||||
"Already connected to this device"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_authentication_failed(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE".AuthenticationFailed",
|
||||
"Authentication failed"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_already_exists(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".AlreadyExists", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".DoesNotExist", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".NotSupported",
|
||||
"The service is not supported by the remote device"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
INPUT_ERROR_INTERFACE ".InvalidArguments", str));
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
DBusHandlerResult err_unknown_device(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
|
||||
DBusHandlerResult err_failed(DBusConnection *conn, DBusMessage *msg,
|
||||
const char *str);
|
||||
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
|
||||
DBusHandlerResult err_already_connected(DBusConnection *conn, DBusMessage *msg);
|
||||
|
||||
DBusHandlerResult err_authentication_failed(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
|
||||
DBusHandlerResult err_already_exists(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn, DBusMessage *msg);
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
121
input/manager.c
121
input/manager.c
@ -326,7 +326,7 @@ static gboolean interrupt_connect_cb(GIOChannel *chan,
|
||||
|
||||
if (input_device_register(pr->conn, &pr->src,
|
||||
&pr->dst, &hidp, &path) < 0) {
|
||||
err_failed(pr->conn, pr->msg, "path registration failed");
|
||||
error_failed(pr->conn, pr->msg, "path registration failed");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ static gboolean interrupt_connect_cb(GIOChannel *chan,
|
||||
|
||||
goto cleanup;
|
||||
failed:
|
||||
err_connection_failed(pr->conn, pr->msg, strerror(err));
|
||||
error_connection_attempt_failed(pr->conn, pr->msg, err);
|
||||
|
||||
cleanup:
|
||||
if (isk >= 0)
|
||||
@ -415,7 +415,7 @@ failed:
|
||||
if (csk >= 0)
|
||||
close(csk);
|
||||
|
||||
err_connection_failed(pr->conn, pr->msg, strerror(err));
|
||||
error_connection_attempt_failed(pr->conn, pr->msg, err);
|
||||
pending_req_free(pr);
|
||||
|
||||
return FALSE;
|
||||
@ -431,7 +431,7 @@ static void create_bonding_reply(DBusPendingCall *call, void *data)
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
error("CreateBonding failed: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
err_authentication_failed(pr->conn, pr->msg);
|
||||
error_failed(pr->conn, pr->msg, "Authentication failed (CreateBonding)");
|
||||
dbus_error_free(&derr);
|
||||
dbus_message_unref(reply);
|
||||
pending_req_free(pr);
|
||||
@ -443,7 +443,7 @@ static void create_bonding_reply(DBusPendingCall *call, void *data)
|
||||
if (l2cap_connect(&pr->src, &pr->dst, L2CAP_PSM_HIDP_CTRL,
|
||||
(GIOFunc) control_connect_cb, pr) < 0) {
|
||||
int err = errno;
|
||||
err_connection_failed(pr->conn, pr->msg, strerror(err));
|
||||
error_connection_attempt_failed(pr->conn, pr->msg, err);
|
||||
error("L2CAP connect failed:%s (%d)", strerror(err), err);
|
||||
pending_req_free(pr);
|
||||
}
|
||||
@ -520,11 +520,14 @@ static void hid_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : to not try to be clever about
|
||||
hcid error but forward as is to the user */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn,
|
||||
pr->msg, EIO);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceRecord failed: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -536,20 +539,20 @@ static void hid_record_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &rec_bin, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Invalid HID service record length");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pr->hid_rec = sdp_extract_pdu(rec_bin, &scanned);
|
||||
if (!pr->hid_rec) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -563,7 +566,8 @@ static void hid_record_reply(DBusPendingCall *call, void *data)
|
||||
if (d && (d->val.uint8 & 0x40) &&
|
||||
!has_bonding(&pr->src, &pr->dst)) {
|
||||
if (create_bonding(pr) < 0) {
|
||||
err_authentication_failed(pr->conn, pr->msg);
|
||||
error_failed(pr->conn, pr->msg,
|
||||
"Unable to initialize bonding process");
|
||||
goto fail;
|
||||
}
|
||||
/* Wait bonding reply */
|
||||
@ -578,7 +582,7 @@ static void hid_record_reply(DBusPendingCall *call, void *data)
|
||||
(GIOFunc) control_connect_cb, pr) < 0) {
|
||||
int err = errno;
|
||||
error("L2CAP connect failed:%s (%d)", strerror(err), err);
|
||||
err_connection_failed(pr->conn, pr->msg, strerror(err));
|
||||
error_connection_attempt_failed(pr->conn, pr->msg, err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -600,11 +604,14 @@ static void hid_handle_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : to not try to be clever about
|
||||
hcid error but forward as is to the user */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn,
|
||||
pr->msg, EIO);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceHandles: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -614,19 +621,19 @@ static void hid_handle_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &phandle, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("HID record handle not found");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (get_record(pr, *phandle, hid_record_reply) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("HID service attribute request failed");
|
||||
goto fail;
|
||||
} else {
|
||||
@ -652,11 +659,14 @@ static void pnp_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : to not try to be clever about
|
||||
hcid error but forward as is to the user */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn, pr->msg,
|
||||
EIO);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceRecord: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -666,20 +676,20 @@ static void pnp_record_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &rec_bin, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Invalid PnP service record length");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pr->pnp_rec = sdp_extract_pdu(rec_bin, &scanned);
|
||||
if (get_handles(pr, hid_uuid, hid_handle_reply) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("HID service search request failed");
|
||||
goto fail;
|
||||
} else {
|
||||
@ -705,11 +715,14 @@ static void pnp_handle_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : to not try to be clever about
|
||||
hcid error but forward as is to the user */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn, pr->msg,
|
||||
EIO);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceHandles: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -719,7 +732,7 @@ static void pnp_handle_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &phandle, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
@ -727,14 +740,14 @@ static void pnp_handle_reply(DBusPendingCall *call, void *data)
|
||||
if (len == 0) {
|
||||
/* PnP is optional: Ignore it and request the HID handle */
|
||||
if (get_handles(pr, hid_uuid, hid_handle_reply) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("HID service search request failed");
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
/* Request PnP record */
|
||||
if (get_record(pr, *phandle, pnp_record_reply) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("PnP service attribute request failed");
|
||||
goto fail;
|
||||
}
|
||||
@ -766,11 +779,14 @@ static void headset_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : to not try to be clever about
|
||||
hcid error but forward as is to the user */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn, pr->msg,
|
||||
EIO);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceRecord: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -780,25 +796,25 @@ static void headset_record_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &rec_bin, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Invalid headset service record length");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
rec = sdp_extract_pdu(rec_bin, &scanned);
|
||||
if (!rec) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (sdp_get_access_protos(rec, &protos) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -808,7 +824,7 @@ static void headset_record_reply(DBusPendingCall *call, void *data)
|
||||
sdp_record_free(rec);
|
||||
|
||||
if (ch <= 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Invalid RFCOMM channel");
|
||||
goto fail;
|
||||
}
|
||||
@ -817,7 +833,7 @@ static void headset_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
if (fake_input_register(pr->conn, &pr->src, &pr->dst, ch, &path) < 0) {
|
||||
error("D-Bus path registration failed:%s", path);
|
||||
err_failed(pr->conn, pr->msg, "Path registration failed");
|
||||
error_failed(pr->conn, pr->msg, "Path registration failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -852,11 +868,14 @@ static void headset_handle_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : to not try to be clever about
|
||||
hcid error but forward as is to the user */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn, pr->msg,
|
||||
EIO);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceHandles: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -866,19 +885,19 @@ static void headset_handle_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &phandle, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Headset record handle not found");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (get_record(pr, *phandle, headset_record_reply) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Headset service attribute request failed");
|
||||
goto fail;
|
||||
} else {
|
||||
@ -908,7 +927,7 @@ static DBusHandlerResult create_device(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &addr,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -917,21 +936,21 @@ static DBusHandlerResult create_device(DBusConnection *conn,
|
||||
dev_id = hci_get_route(NULL);
|
||||
if (dev_id < 0) {
|
||||
error("Bluetooth adapter not available");
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
}
|
||||
|
||||
if (hci_devba(dev_id, &src) < 0) {
|
||||
error("Can't get local adapter device info");
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
}
|
||||
|
||||
str2ba(addr, &dst);
|
||||
if (input_device_is_registered(&src, &dst))
|
||||
return err_already_exists(conn, msg, "Input Already exists");
|
||||
return error_already_exists(conn, msg, "Input Already exists");
|
||||
|
||||
if (read_device_class(&src, &dst, &cls) < 0) {
|
||||
error("Device class not available");
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
|
||||
pr = pending_req_new(conn, msg, &src, &dst);
|
||||
@ -943,19 +962,19 @@ static DBusHandlerResult create_device(DBusConnection *conn,
|
||||
case 0x0200: /* Phone */
|
||||
if (get_handles(pr, pnp_uuid, pnp_handle_reply) < 0) {
|
||||
pending_req_free(pr);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
break;
|
||||
case 0x0400: /* Fake input */
|
||||
if (get_handles(pr, headset_uuid,
|
||||
headset_handle_reply) < 0) {
|
||||
pending_req_free(pr);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pending_req_free(pr);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
@ -974,14 +993,14 @@ static DBusHandlerResult remove_device(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
l = g_slist_find_custom(device_paths, path, (GCompareFunc) strcmp);
|
||||
if (!l)
|
||||
return err_does_not_exist(conn, msg, "Input doesn't exist");
|
||||
return error_does_not_exist(conn, msg, "Input doesn't exist");
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -990,7 +1009,7 @@ static DBusHandlerResult remove_device(DBusConnection *conn,
|
||||
err = input_device_unregister(conn, path);
|
||||
if (err < 0) {
|
||||
dbus_message_unref(reply);
|
||||
return err_failed(conn, msg, strerror(-err));
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
}
|
||||
|
||||
g_free(l->data);
|
||||
|
@ -11,7 +11,7 @@ servicedir = $(libdir)/bluetooth
|
||||
service_PROGRAMS = bluetoothd-service-network
|
||||
|
||||
bluetoothd_service_network_SOURCES = main.c \
|
||||
manager.h manager.c error.h error.c \
|
||||
manager.h manager.c \
|
||||
server.h server.c bridge.h bridge.c \
|
||||
connection.h connection.c common.h common.c
|
||||
|
||||
|
@ -181,7 +181,7 @@ static gboolean bnep_connect_cb(GIOChannel *chan, GIOCondition cond,
|
||||
failed:
|
||||
if (nc->state != DISCONNECTED) {
|
||||
nc->state = DISCONNECTED;
|
||||
err_connection_failed(connection, nc->msg, "bnep failed");
|
||||
error_connection_attempt_failed(connection, nc->msg, EIO);
|
||||
g_io_channel_close(chan);
|
||||
}
|
||||
return FALSE;
|
||||
@ -254,7 +254,7 @@ static gboolean l2cap_connect_cb(GIOChannel *chan,
|
||||
return FALSE;
|
||||
failed:
|
||||
nc->state = DISCONNECTED;
|
||||
err_connection_failed(connection, nc->msg, strerror(errno));
|
||||
error_connection_attempt_failed(connection, nc->msg, errno);
|
||||
g_io_channel_close(chan);
|
||||
return FALSE;
|
||||
}
|
||||
@ -383,7 +383,7 @@ static DBusHandlerResult get_name(DBusConnection *conn, DBusMessage *msg,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!nc->name) {
|
||||
err_failed(conn, msg, "Cannot find service name");
|
||||
error_failed(conn, msg, "Cannot find service name");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ static DBusHandlerResult get_description(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (!nc->desc) {
|
||||
err_failed(conn, msg, "Cannot find service description");
|
||||
error_failed(conn, msg, "Cannot find service description");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ static DBusHandlerResult get_interface(DBusConnection *conn, DBusMessage *msg,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (nc->state != CONNECTED) {
|
||||
err_failed(conn, msg, "Device not connected");
|
||||
error_failed(conn, msg, "Device not connected");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -449,14 +449,14 @@ static DBusHandlerResult connection_connect(DBusConnection *conn,
|
||||
DBusError derr;
|
||||
|
||||
if (nc->state != DISCONNECTED) {
|
||||
err_failed(conn, msg, "Device already connected");
|
||||
error_failed(conn, msg, "Device already connected");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -482,7 +482,7 @@ fail:
|
||||
nc->msg = NULL;
|
||||
}
|
||||
nc->state = DISCONNECTED;
|
||||
err_connection_failed(conn, msg, strerror(errno));
|
||||
error_connection_attempt_failed(conn, msg, errno);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ static DBusHandlerResult connection_cancel(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (nc->state != CONNECTING) {
|
||||
err_failed(conn, msg, "Device has no pending connect");
|
||||
error_failed(conn, msg, "Device has no pending connect");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ static DBusHandlerResult connection_disconnect(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (nc->state != CONNECTED) {
|
||||
err_failed(conn, msg, "Device not connected");
|
||||
error_failed(conn, msg, "Device not connected");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "dbus.h"
|
||||
#include "error.h"
|
||||
|
||||
#define NETWORK_ERROR_INTERFACE "org.bluez.network.Error"
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn, DBusMessage *msg,
|
||||
const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
NETWORK_ERROR_INTERFACE ".DoesNotExist", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_failed(DBusConnection *conn, DBusMessage *msg,
|
||||
const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
NETWORK_ERROR_INTERFACE ".Failed", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
NETWORK_ERROR_INTERFACE".ConnectionAttemptFailed",
|
||||
str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
NETWORK_ERROR_INTERFACE ".InvalidArguments", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
NETWORK_ERROR_INTERFACE ".NotSupported",
|
||||
"The service is not supported by the remote device"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_already_exists(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
NETWORK_ERROR_INTERFACE ".AlreadyExists", str));
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_failed(DBusConnection *conn, DBusMessage *msg,
|
||||
const char *str);
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn, DBusMessage *msg);
|
||||
DBusHandlerResult err_already_exists(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
@ -171,19 +171,19 @@ static DBusHandlerResult remove_path(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
l = g_slist_find_custom(*list, path, (GCompareFunc) strcmp);
|
||||
if (!l)
|
||||
return err_does_not_exist(conn, msg, "Path doesn't exist");
|
||||
return error_does_not_exist(conn, msg, "Path doesn't exist");
|
||||
|
||||
/* Remove references from the storage */
|
||||
if (*list == connection_paths) {
|
||||
if (connection_has_pending(path))
|
||||
return err_failed(conn, msg, "Connection is Busy");
|
||||
return error_failed(conn, msg, "Connection is Busy");
|
||||
|
||||
connection_remove_stored(path);
|
||||
/* Reset default connection */
|
||||
@ -226,11 +226,13 @@ static void pan_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME: forward error as is */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn, pr->msg,
|
||||
EINVAL);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceRecord failed: %s(%s)", derr.name,
|
||||
derr.message);
|
||||
@ -240,13 +242,13 @@ static void pan_record_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &rec_bin, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("Invalid PAN service record length");
|
||||
goto fail;
|
||||
}
|
||||
@ -276,7 +278,7 @@ static void pan_record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
if (connection_register(pr->path, &pr->src, &pr->dst, pr->id, name,
|
||||
desc) < 0) {
|
||||
err_failed(pr->conn, pr->msg, "D-Bus path registration failed");
|
||||
error_failed(pr->conn, pr->msg, "D-Bus path registration failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -334,11 +336,13 @@ static void pan_handle_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : forward error as is */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pr->conn, pr->msg, derr.message);
|
||||
error_connection_attempt_failed(pr->conn, pr->msg,
|
||||
EINVAL);
|
||||
else
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
|
||||
error("GetRemoteServiceHandles: %s(%s)", derr.name,
|
||||
derr.message);
|
||||
@ -348,18 +352,18 @@ static void pan_handle_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &phandle,
|
||||
&len, DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!len) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (get_record(pr, *phandle, pan_record_reply) < 0) {
|
||||
err_not_supported(pr->conn, pr->msg);
|
||||
error_not_supported(pr->conn, pr->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -420,7 +424,7 @@ static DBusHandlerResult find_server(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -432,7 +436,7 @@ static DBusHandlerResult find_server(DBusConnection *conn,
|
||||
}
|
||||
|
||||
if (list == NULL) {
|
||||
err_failed(conn, msg, "No such server");
|
||||
error_does_not_exist(conn, msg, "No such server");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -483,7 +487,7 @@ static DBusHandlerResult find_connection(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -491,7 +495,7 @@ static DBusHandlerResult find_connection(DBusConnection *conn,
|
||||
list = find_connection_pattern(conn, pattern);
|
||||
|
||||
if (list == NULL) {
|
||||
err_failed(conn, msg, "No such connection");
|
||||
error_does_not_exist(conn, msg, "No such connection");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -579,21 +583,21 @@ static DBusHandlerResult create_connection(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &addr,
|
||||
DBUS_TYPE_STRING, &str,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
id = bnep_service_id(str);
|
||||
if (id != BNEP_SVC_GN && id != BNEP_SVC_NAP && id != BNEP_SVC_PANU)
|
||||
return err_invalid_args(conn, msg, "Not supported");
|
||||
return error_invalid_arguments(conn, msg, "Not supported");
|
||||
|
||||
snprintf(key, 32, "%s#%s", addr, bnep_name(id));
|
||||
|
||||
/* Checks if the connection was already been made */
|
||||
for (l = connection_paths; l; l = l->next) {
|
||||
if (connection_find_data(l->data, key) == 0) {
|
||||
err_already_exists(conn, msg,
|
||||
error_already_exists(conn, msg,
|
||||
"Connection Already exists");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -602,14 +606,14 @@ static DBusHandlerResult create_connection(DBusConnection *conn,
|
||||
bacpy(&src, BDADDR_ANY);
|
||||
dev_id = hci_get_route(&src);
|
||||
if (dev_id < 0 || hci_devba(dev_id, &src) < 0)
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
|
||||
pr = g_new0(struct pending_reply, 1);
|
||||
|
||||
pr->adapter_path = find_adapter(conn, &src);
|
||||
if (!pr->adapter_path) {
|
||||
pending_reply_free (pr);
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
}
|
||||
|
||||
pr->conn = dbus_connection_ref(conn);
|
||||
@ -623,7 +627,7 @@ static DBusHandlerResult create_connection(DBusConnection *conn,
|
||||
NETWORK_PATH"/connection%d", net_uid++);
|
||||
|
||||
if (get_handles(pr, pan_handle_reply) < 0)
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
@ -642,7 +646,7 @@ static DBusHandlerResult last_connection(DBusConnection *conn,
|
||||
|
||||
if (connection_paths == NULL ||
|
||||
g_slist_length (connection_paths) == 0) {
|
||||
err_does_not_exist(conn, msg, "No such connection");
|
||||
error_does_not_exist(conn, msg, "No such connection");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -666,7 +670,7 @@ static DBusHandlerResult default_connection(DBusConnection *conn,
|
||||
|
||||
if (connection_paths == NULL ||
|
||||
g_slist_length (connection_paths) == 0) {
|
||||
err_does_not_exist(conn, msg, "No such connection");
|
||||
error_does_not_exist(conn, msg, "No such connection");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -700,14 +704,14 @@ static DBusHandlerResult change_default_connection(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (connection_paths == NULL ||
|
||||
g_slist_length (connection_paths) == 0) {
|
||||
err_does_not_exist(conn, msg, "No such connection");
|
||||
error_does_not_exist(conn, msg, "No such connection");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
@ -718,7 +722,7 @@ static DBusHandlerResult change_default_connection(DBusConnection *conn,
|
||||
list = find_connection_pattern(conn, pattern);
|
||||
|
||||
if (list == NULL) {
|
||||
err_failed(conn, msg, "No such connection");
|
||||
error_does_not_exist(conn, msg, "No such connection");
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
else
|
||||
|
@ -849,14 +849,14 @@ static DBusHandlerResult enable(DBusConnection *conn,
|
||||
DBusMessage *reply;
|
||||
|
||||
if (ns->enable)
|
||||
return err_already_exists(conn, msg, "Server already enabled");
|
||||
return error_already_exists(conn, msg, "Server already enabled");
|
||||
|
||||
if (bacmp(&ns->src, BDADDR_ANY) == 0) {
|
||||
int dev_id;
|
||||
|
||||
dev_id = hci_get_route(&ns->src);
|
||||
if ((dev_id < 0) || (hci_devba(dev_id, &ns->src) < 0))
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
|
||||
/* Store the server info */
|
||||
server_store(ns->path);
|
||||
@ -870,7 +870,7 @@ static DBusHandlerResult enable(DBusConnection *conn,
|
||||
ns->record_id = add_server_record(ns);
|
||||
if (!ns->record_id) {
|
||||
dbus_message_unref(reply);
|
||||
return err_failed(conn, msg,
|
||||
return error_failed(conn, msg,
|
||||
"service record registration failed");
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ static DBusHandlerResult disable(DBusConnection *conn,
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
|
||||
if (!ns->enable)
|
||||
return err_failed(conn, msg, "Not enabled");
|
||||
return error_failed(conn, msg, "Not enabled");
|
||||
|
||||
/* Remove the service record */
|
||||
if (ns->record_id) {
|
||||
@ -956,13 +956,13 @@ static DBusHandlerResult set_name(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &name,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (!name || (strlen(name) == 0))
|
||||
return err_invalid_args(conn, msg, "Invalid name");
|
||||
return error_invalid_arguments(conn, msg, "Invalid name");
|
||||
|
||||
if (ns->name)
|
||||
g_free(ns->name);
|
||||
@ -971,7 +971,7 @@ static DBusHandlerResult set_name(DBusConnection *conn,
|
||||
if (ns->enable) {
|
||||
if (update_server_record(ns) < 0) {
|
||||
dbus_message_unref(reply);
|
||||
return err_failed(conn, msg,
|
||||
return error_failed(conn, msg,
|
||||
"Service record attribute update failed");
|
||||
}
|
||||
}
|
||||
@ -1022,14 +1022,14 @@ static DBusHandlerResult set_routing(DBusConnection *conn, DBusMessage *msg,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &iface,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
/* FIXME: Check if the interface is valid/UP */
|
||||
if (!iface || (strlen(iface) == 0))
|
||||
return err_invalid_args(conn, msg, "Invalid interface");
|
||||
return error_invalid_arguments(conn, msg, "Invalid interface");
|
||||
|
||||
if (ns->iface)
|
||||
g_free(ns->iface);
|
||||
|
@ -12,7 +12,7 @@ service_PROGRAMS = bluetoothd-service-serial
|
||||
|
||||
bluetoothd_service_serial_SOURCES = main.c \
|
||||
manager.h manager.c port.h port.c \
|
||||
error.h error.c storage.h storage.c
|
||||
storage.h storage.c
|
||||
|
||||
LDADD = $(top_builddir)/common/libhelper.a \
|
||||
@GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
|
||||
|
109
serial/error.c
109
serial/error.c
@ -1,109 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "dbus.h"
|
||||
#include "error.h"
|
||||
|
||||
#define SERIAL_ERROR_INTERFACE "org.bluez.serial.Error"
|
||||
|
||||
DBusHandlerResult err_connection_canceled(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionCanceled",
|
||||
"Connection creation canceled"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionAttemptFailed", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionInProgress",
|
||||
"Connection creation in progress"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_connection_not_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE".ConnectionNotInProgress",
|
||||
"Connection creation not in progress"));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_already_exists(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".AlreadyExists", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".DoesNotExist", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".Failed", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".InvalidArguments", str));
|
||||
}
|
||||
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
return send_message_and_unref(conn,
|
||||
dbus_message_new_error(msg,
|
||||
SERIAL_ERROR_INTERFACE ".NotSupported",
|
||||
"The service is not supported by the remote device"));
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2004-2007 Marcel Holtmann <marcel@holtmann.org>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
DBusHandlerResult err_connection_canceled(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_connection_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_connection_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_connection_not_in_progress(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
||||
DBusHandlerResult err_already_exists(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_does_not_exist(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_failed(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_invalid_args(DBusConnection *conn,
|
||||
DBusMessage *msg, const char *str);
|
||||
DBusHandlerResult err_not_supported(DBusConnection *conn,
|
||||
DBusMessage *msg);
|
143
serial/manager.c
143
serial/manager.c
@ -217,13 +217,13 @@ static void open_notify(int fd, int err, struct pending_connect *pc)
|
||||
if (err) {
|
||||
/* Max tries exceeded */
|
||||
rfcomm_release(pc->id);
|
||||
err_connection_failed(pc->conn, pc->msg, strerror(err));
|
||||
error_connection_attempt_failed(pc->conn, pc->msg, err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pc->canceled) {
|
||||
rfcomm_release(pc->id);
|
||||
err_connection_canceled(pc->conn, pc->msg);
|
||||
error_canceled(pc->conn, pc->msg, "Connection canceled");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan,
|
||||
socklen_t len;
|
||||
|
||||
if (pc->canceled) {
|
||||
err_connection_canceled(pc->conn, pc->msg);
|
||||
error_canceled(pc->conn, pc->msg, "Connection canceled");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan,
|
||||
/* Avoid close invalid file descriptor */
|
||||
g_io_channel_unref(pc->io);
|
||||
pc->io = NULL;
|
||||
err_connection_canceled(pc->conn, pc->msg);
|
||||
error_canceled(pc->conn, pc->msg, "Connection canceled");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -370,14 +370,13 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan,
|
||||
err = errno;
|
||||
error("getsockopt(SO_ERROR): %s (%d)",
|
||||
strerror(err), err);
|
||||
err_connection_failed(pc->conn,
|
||||
pc->msg, strerror(err));
|
||||
error_connection_attempt_failed(pc->conn, pc->msg, err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
error("connect(): %s (%d)", strerror(ret), ret);
|
||||
err_connection_failed(pc->conn, pc->msg, strerror(ret));
|
||||
error_connection_attempt_failed(pc->conn, pc->msg, ret);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -394,7 +393,7 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan,
|
||||
if (pc->id < 0) {
|
||||
err = errno;
|
||||
error("ioctl(RFCOMMCREATEDEV): %s (%d)", strerror(err), err);
|
||||
err_connection_failed(pc->conn, pc->msg, strerror(err));
|
||||
error_connection_attempt_failed(pc->conn, pc->msg, err);
|
||||
goto fail;
|
||||
}
|
||||
pc->dev = g_new0(char, 16);
|
||||
@ -483,17 +482,19 @@ static void record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
pc = data;
|
||||
if (pc->canceled) {
|
||||
err_connection_canceled(pc->conn, pc->msg);
|
||||
error_canceled(pc->conn, pc->msg, "Connection canceled");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : forward error as is */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pc->conn, pc->msg, derr.message);
|
||||
error_connection_attempt_failed(pc->conn, pc->msg,
|
||||
EIO);
|
||||
else
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
|
||||
error("GetRemoteServiceRecord: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -504,14 +505,14 @@ static void record_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &rec_bin, &len,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
error("Invalid service record length");
|
||||
goto fail;
|
||||
}
|
||||
@ -519,12 +520,12 @@ static void record_reply(DBusPendingCall *call, void *data)
|
||||
rec = sdp_extract_pdu(rec_bin, &scanned);
|
||||
if (!rec) {
|
||||
error("Can't extract SDP record.");
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len != scanned || (sdp_get_access_protos(rec, &protos) < 0)) {
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -534,7 +535,7 @@ static void record_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
if (ch < 1 || ch > 30) {
|
||||
error("Channel out of range: %d", ch);
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
goto fail;
|
||||
}
|
||||
if (dbus_message_has_member(pc->msg, "CreatePort")) {
|
||||
@ -548,7 +549,7 @@ static void record_reply(DBusPendingCall *call, void *data)
|
||||
str2ba(pc->bda, &dst);
|
||||
err = rfcomm_bind(&pc->src, &dst, -1, ch);
|
||||
if (err < 0) {
|
||||
err_failed(pc->conn, pc->msg, strerror(-err));
|
||||
error_failed_errno(pc->conn, pc->msg, -err);
|
||||
goto fail;
|
||||
}
|
||||
snprintf(port_name, sizeof(port_name), "/dev/rfcomm%d", err);
|
||||
@ -585,7 +586,8 @@ static void record_reply(DBusPendingCall *call, void *data)
|
||||
err = rfcomm_connect(pc);
|
||||
if (err < 0) {
|
||||
error("RFCOMM connection failed");
|
||||
err_connection_failed(pc->conn, pc->msg, strerror(-err));
|
||||
error_connection_attempt_failed(pc->conn,
|
||||
pc->msg, -err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -646,17 +648,19 @@ static void handles_reply(DBusPendingCall *call, void *data)
|
||||
|
||||
pc = data;
|
||||
if (pc->canceled) {
|
||||
err_connection_canceled(pc->conn, pc->msg);
|
||||
error_canceled(pc->conn, pc->msg, "Connection canceled");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (dbus_set_error_from_message(&derr, reply)) {
|
||||
/* FIXME : forward error as is */
|
||||
if (dbus_error_has_name(&derr,
|
||||
"org.bluez.Error.ConnectionAttemptFailed"))
|
||||
err_connection_failed(pc->conn, pc->msg, derr.message);
|
||||
error_connection_attempt_failed(pc->conn,
|
||||
pc->msg, EIO);
|
||||
else
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
|
||||
error("GetRemoteServiceHandles: %s(%s)",
|
||||
derr.name, derr.message);
|
||||
@ -667,19 +671,19 @@ static void handles_reply(DBusPendingCall *call, void *data)
|
||||
if (!dbus_message_get_args(reply, &derr,
|
||||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &phandle,
|
||||
&len, DBUS_TYPE_INVALID)) {
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
error("%s: %s", derr.name, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (get_record(pc, *phandle, record_reply) < 0) {
|
||||
err_not_supported(pc->conn, pc->msg);
|
||||
error_not_supported(pc->conn, pc->msg);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -780,18 +784,18 @@ static DBusHandlerResult create_port(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &bda,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
pending = find_pending_connect_by_pattern(bda, pattern);
|
||||
if (pending)
|
||||
return err_connection_in_progress(conn, msg);
|
||||
return error_in_progress(conn, msg, "Connection in progress");
|
||||
|
||||
dev_id = hci_get_route(NULL);
|
||||
if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0))
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
|
||||
pc = g_new0(struct pending_connect, 1);
|
||||
bacpy(&pc->src, &src);
|
||||
@ -809,7 +813,7 @@ static DBusHandlerResult create_port(DBusConnection *conn,
|
||||
if (pattern2uuid128(pattern, uuid, sizeof(uuid)) == 0) {
|
||||
if (get_handles(pc, uuid, handles_reply) < 0) {
|
||||
pending_connect_free(pc);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
pending_connects = g_slist_append(pending_connects, pc);
|
||||
name_listener_add(conn, dbus_message_get_sender(msg),
|
||||
@ -821,20 +825,20 @@ static DBusHandlerResult create_port(DBusConnection *conn,
|
||||
err = pattern2long(pattern, &val);
|
||||
if (err < 0) {
|
||||
pending_connect_free(pc);
|
||||
return err_invalid_args(conn, msg, "invalid pattern");
|
||||
return error_invalid_arguments(conn, msg, "invalid pattern");
|
||||
}
|
||||
|
||||
/* Record handle: starts at 0x10000 */
|
||||
if (strncasecmp("0x", pattern, 2) == 0) {
|
||||
if (val < 0x10000) {
|
||||
pending_connect_free(pc);
|
||||
return err_invalid_args(conn, msg,
|
||||
return error_invalid_arguments(conn, msg,
|
||||
"invalid record handle");
|
||||
}
|
||||
|
||||
if (get_record(pc, val, record_reply) < 0) {
|
||||
pending_connect_free(pc);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
pending_connects = g_slist_append(pending_connects, pc);
|
||||
name_listener_add(conn, dbus_message_get_sender(msg),
|
||||
@ -845,13 +849,13 @@ static DBusHandlerResult create_port(DBusConnection *conn,
|
||||
pending_connect_free(pc);
|
||||
/* RFCOMM Channel range: 1 - 30 */
|
||||
if (val < 1 || val > 30)
|
||||
return err_invalid_args(conn, msg,
|
||||
return error_invalid_arguments(conn, msg,
|
||||
"invalid RFCOMM channel");
|
||||
|
||||
str2ba(bda, &dst);
|
||||
err = rfcomm_bind(&src, &dst, -1, val);
|
||||
if (err < 0)
|
||||
return err_failed(conn, msg, strerror(-err));
|
||||
return error_failed_errno(conn, msg, -err);
|
||||
|
||||
snprintf(port_name, sizeof(port_name), "/dev/rfcomm%d", err);
|
||||
port_store(&src, &dst, err, val, NULL);
|
||||
@ -919,21 +923,21 @@ static DBusHandlerResult remove_port(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (sscanf(path, SERIAL_MANAGER_PATH"/rfcomm%hd", &id) != 1)
|
||||
return err_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
return error_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
|
||||
di.id = id;
|
||||
if (ioctl(rfcomm_ctl, RFCOMMGETDEVINFO, &di) < 0)
|
||||
return err_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
return error_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
port_delete(&di.src, &di.dst, id);
|
||||
|
||||
if (port_unregister(path) < 0)
|
||||
return err_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
return error_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
|
||||
send_message_and_unref(conn,
|
||||
dbus_message_new_method_return(msg));
|
||||
@ -1391,7 +1395,7 @@ static DBusHandlerResult proxy_enable(DBusConnection *conn,
|
||||
int sk;
|
||||
|
||||
if (prx->listen_watch)
|
||||
return err_failed(conn, msg, "Already enabled");
|
||||
return error_failed(conn, msg, "Already enabled");
|
||||
|
||||
/* Listen */
|
||||
/* FIXME: missing options */
|
||||
@ -1399,7 +1403,7 @@ static DBusHandlerResult proxy_enable(DBusConnection *conn,
|
||||
if (sk < 0) {
|
||||
const char *strerr = strerror(errno);
|
||||
error("RFCOMM listen socket failed: %s(%d)", strerr, errno);
|
||||
return err_failed(conn, msg, strerr);
|
||||
return error_failed(conn, msg, strerr);
|
||||
}
|
||||
|
||||
/* Create the record */
|
||||
@ -1409,7 +1413,7 @@ static DBusHandlerResult proxy_enable(DBusConnection *conn,
|
||||
prx->record_id = add_proxy_record(conn, &buf);
|
||||
if (!prx->record_id) {
|
||||
close(sk);
|
||||
return err_failed(conn, msg, "Service registration failed");
|
||||
return error_failed(conn, msg, "Service registration failed");
|
||||
}
|
||||
|
||||
/* Add incomming connection watch */
|
||||
@ -1430,7 +1434,7 @@ static DBusHandlerResult proxy_disable(DBusConnection *conn,
|
||||
struct proxy *prx = data;
|
||||
|
||||
if (!prx->listen_watch)
|
||||
return err_failed(conn, msg, "Not enabled");
|
||||
return error_failed(conn, msg, "Not enabled");
|
||||
|
||||
/* Remove the watches and unregister the record: see watch notify */
|
||||
g_source_remove(prx->listen_watch);
|
||||
@ -1597,7 +1601,7 @@ static DBusHandlerResult proxy_set_serial_params(DBusConnection *conn,
|
||||
|
||||
/* Don't allow change TTY settings if it is open */
|
||||
if (prx->local_watch)
|
||||
return err_failed(conn, msg, "Not allowed");
|
||||
return error_failed(conn, msg, "Not allowed");
|
||||
|
||||
dbus_error_init(&derr);
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
@ -1606,23 +1610,23 @@ static DBusHandlerResult proxy_set_serial_params(DBusConnection *conn,
|
||||
DBUS_TYPE_BYTE, &stopbits,
|
||||
DBUS_TYPE_STRING, &paritystr,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (str2speed(ratestr, &speed) == B0)
|
||||
return err_invalid_args(conn, msg, "Invalid baud rate");
|
||||
return error_invalid_arguments(conn, msg, "Invalid baud rate");
|
||||
|
||||
ctrl = prx->proxy_ti.c_cflag;
|
||||
if (set_databits(databits, &ctrl) < 0)
|
||||
return err_invalid_args(conn, msg, "Invalid data bits");
|
||||
return error_invalid_arguments(conn, msg, "Invalid data bits");
|
||||
|
||||
if (set_stopbits(stopbits, &ctrl) < 0)
|
||||
return err_invalid_args(conn, msg, "Invalid stop bits");
|
||||
return error_invalid_arguments(conn, msg, "Invalid stop bits");
|
||||
|
||||
if (set_parity(paritystr, &ctrl) < 0)
|
||||
return err_invalid_args(conn, msg, "Invalid parity");
|
||||
return error_invalid_arguments(conn, msg, "Invalid parity");
|
||||
|
||||
prx->proxy_ti.c_cflag = ctrl;
|
||||
prx->proxy_ti.c_cflag |= (CLOCAL | CREAD);
|
||||
@ -1802,27 +1806,27 @@ static DBusHandlerResult create_proxy(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &uuid128,
|
||||
DBUS_TYPE_STRING, &address,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (str2uuid(&uuid, uuid128) < 0)
|
||||
return err_invalid_args(conn, msg, "Invalid UUID");
|
||||
return error_invalid_arguments(conn, msg, "Invalid UUID");
|
||||
|
||||
type = addr2type(address);
|
||||
if (type == UNKNOWN_PROXY_TYPE)
|
||||
return err_invalid_args(conn, msg, "Invalid address");
|
||||
return error_invalid_arguments(conn, msg, "Invalid address");
|
||||
|
||||
/* Only one proxy per address(TTY or unix socket) is allowed */
|
||||
if (g_slist_find_custom(proxies_paths,
|
||||
address, (GCompareFunc) proxycmp))
|
||||
return err_already_exists(conn, msg, "Proxy already exists");
|
||||
return error_already_exists(conn, msg, "Proxy already exists");
|
||||
|
||||
dev_id = hci_get_route(NULL);
|
||||
if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) {
|
||||
error("Adapter not available");
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
}
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
@ -1838,7 +1842,7 @@ static DBusHandlerResult create_proxy(DBusConnection *conn,
|
||||
|
||||
if (ret < 0) {
|
||||
dbus_message_unref(reply);
|
||||
return err_failed(conn, msg, "Create object path failed");
|
||||
return error_failed(conn, msg, "Create object path failed");
|
||||
}
|
||||
|
||||
dbus_connection_emit_signal(connection, SERIAL_MANAGER_PATH,
|
||||
@ -1879,14 +1883,14 @@ static DBusHandlerResult remove_proxy(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
l = g_slist_find_custom(proxies_paths, path, (GCompareFunc) strcmp);
|
||||
if (!l)
|
||||
return err_does_not_exist(conn, msg, "Invalid proxy path");
|
||||
return error_does_not_exist(conn, msg, "Invalid proxy path");
|
||||
|
||||
/* Remove from storage */
|
||||
if (dbus_connection_get_object_user_data(conn,
|
||||
@ -1923,18 +1927,18 @@ static DBusHandlerResult connect_service(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &bda,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
pending = find_pending_connect_by_pattern(bda, pattern);
|
||||
if (pending)
|
||||
return err_connection_in_progress(conn, msg);
|
||||
return error_in_progress(conn, msg, "Connection in progress");
|
||||
|
||||
dev_id = hci_get_route(NULL);
|
||||
if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0))
|
||||
return err_failed(conn, msg, "Adapter not available");
|
||||
return error_failed(conn, msg, "Adapter not available");
|
||||
|
||||
pc = g_new0(struct pending_connect, 1);
|
||||
bacpy(&pc->src, &src);
|
||||
@ -1952,7 +1956,7 @@ static DBusHandlerResult connect_service(DBusConnection *conn,
|
||||
if (pattern2uuid128(pattern, uuid, sizeof(uuid)) == 0) {
|
||||
if (get_handles(pc, uuid, handles_reply) < 0) {
|
||||
pending_connect_free(pc);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
pending_connects = g_slist_append(pending_connects, pc);
|
||||
goto done;
|
||||
@ -1962,20 +1966,20 @@ static DBusHandlerResult connect_service(DBusConnection *conn,
|
||||
err = pattern2long(pattern, &val);
|
||||
if (err < 0) {
|
||||
pending_connect_free(pc);
|
||||
return err_invalid_args(conn, msg, "invalid pattern");
|
||||
return error_invalid_arguments(conn, msg, "invalid pattern");
|
||||
}
|
||||
|
||||
/* Record handle: starts at 0x10000 */
|
||||
if (strncasecmp("0x", pattern, 2) == 0) {
|
||||
if (val < 0x10000) {
|
||||
pending_connect_free(pc);
|
||||
return err_invalid_args(conn, msg,
|
||||
return error_invalid_arguments(conn, msg,
|
||||
"invalid record handle");
|
||||
}
|
||||
|
||||
if (get_record(pc, val, record_reply) < 0) {
|
||||
pending_connect_free(pc);
|
||||
return err_not_supported(conn, msg);
|
||||
return error_not_supported(conn, msg);
|
||||
}
|
||||
pending_connects = g_slist_append(pending_connects, pc);
|
||||
goto done;
|
||||
@ -1984,7 +1988,7 @@ static DBusHandlerResult connect_service(DBusConnection *conn,
|
||||
/* RFCOMM Channel range: 1 - 30 */
|
||||
if (val < 1 || val > 30) {
|
||||
pending_connect_free(pc);
|
||||
return err_invalid_args(conn, msg,
|
||||
return error_invalid_arguments(conn, msg,
|
||||
"invalid RFCOMM channel");
|
||||
}
|
||||
|
||||
@ -1998,7 +2002,7 @@ static DBusHandlerResult connect_service(DBusConnection *conn,
|
||||
error("RFCOMM connect failed: %s(%d)", strerr, -err);
|
||||
pending_connects = g_slist_remove(pending_connects, pc);
|
||||
pending_connect_free(pc);
|
||||
return err_connection_failed(conn, msg, strerr);
|
||||
return error_connection_attempt_failed(conn, msg, -err);
|
||||
}
|
||||
done:
|
||||
name_listener_add(conn, dbus_message_get_sender(msg),
|
||||
@ -2018,17 +2022,17 @@ static DBusHandlerResult disconnect_service(DBusConnection *conn,
|
||||
if (!dbus_message_get_args(msg, &derr,
|
||||
DBUS_TYPE_STRING, &name,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (sscanf(name, "/dev/rfcomm%d", &id) != 1)
|
||||
return err_invalid_args(conn, msg, "invalid RFCOMM node");
|
||||
return error_invalid_arguments(conn, msg, "invalid RFCOMM node");
|
||||
|
||||
err = port_remove_listener(dbus_message_get_sender(msg), name);
|
||||
if (err < 0)
|
||||
return err_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
return error_does_not_exist(conn, msg, "Invalid RFCOMM node");
|
||||
|
||||
send_message_and_unref(conn,
|
||||
dbus_message_new_method_return(msg));
|
||||
@ -2054,14 +2058,15 @@ static DBusHandlerResult cancel_connect_service(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &bda,
|
||||
DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
err_invalid_args(conn, msg, derr.message);
|
||||
error_invalid_arguments(conn, msg, derr.message);
|
||||
dbus_error_free(&derr);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
pending = find_pending_connect_by_pattern(bda, pattern);
|
||||
if (!pending)
|
||||
return err_connection_not_in_progress(conn, msg);
|
||||
return error_does_not_exist(conn, msg,
|
||||
"No such connection request");
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
|
Loading…
Reference in New Issue
Block a user