From: fabchevalier@free.fr
To: BlueZ development <bluez-devel@lists.sourceforge.net>,
Marcel Holtmann <marcel@holtmann.org>
Cc: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] [PATCH 1/3] move common exceptions to common/ directory
Date: Sun, 28 Oct 2007 19:15:13 +0100 [thread overview]
Message-ID: <1193595313.4724d1b17e3bf@imp.free.fr> (raw)
In-Reply-To: <1193595382.5096.15.camel@aeonflux>
[-- Attachment #1: Type: text/plain, Size: 531 bytes --]
Hi Marcel
> I like to have org.bluez.Error only. There is no need to get an extra
> hierarchy level.
>
That's basically how things are today... however if have no objection if you
want to change that...
Btw did you have a look at the send_message_and_unref ==>
dbus_connection_send_and_unref patch ? Is it ok for you ? (Aven't tested but i
think those three patches may depend on it)
Please find attached an updated patchset moving everything to org.bluez.Error...
as usual, any more comments are welcomed :-)
Cheers,
Fabien
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: exceptions-rework-common.diff --]
[-- Type: text/x-patch; name="exceptions-rework-common.diff", Size: 9966 bytes --]
diff -x Entries -x Makefile.in -u -r -N utils/common/common-error.c utils2/common/common-error.c
--- utils/common/common-error.c 1970-01-01 00:00:00.000000000 +0000
+++ utils2/common/common-error.c 2007-10-28 17:51:53.000000000 +0000
@@ -0,0 +1,138 @@
+/*
+ *
+ * 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 <string.h>
+#include <errno.h>
+
+#include "dbus-helper.h"
+#include "common-error.h"
+
+DBusHandlerResult error_device_unreachable(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".DeviceUnreachable",
+ "Device Unreachable");
+}
+
+DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn, DBusMessage *msg, int err)
+{
+ return error_common_reply(conn, msg,
+ ERROR_INTERFACE ".ConnectionAttemptFailed",
+ err ? strerror(err) : "Connection attempt failed");
+}
+
+DBusHandlerResult error_already_connected(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_common_reply(conn, msg,
+ ERROR_INTERFACE ".AlreadyConnected",
+ "Already connected to a device");
+}
+
+DBusHandlerResult error_in_progress(DBusConnection *conn, DBusMessage *msg,
+ const char *str)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".InProgress", str);
+}
+
+DBusHandlerResult error_invalid_arguments(DBusConnection *conn, DBusMessage *msg,
+ const char *descr)
+{
+ return error_common_reply(conn, msg,
+ ERROR_INTERFACE ".InvalidArguments",
+ descr ? descr : "Invalid arguments in method call");
+}
+
+DBusHandlerResult error_out_of_memory(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".OutOfMemory",
+ "Out of memory");
+}
+
+DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".NotAvailable",
+ "Not available");
+}
+
+DBusHandlerResult error_not_supported(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".NotSupported",
+ "Not supported");
+}
+
+DBusHandlerResult error_not_connected(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".NotConnected",
+ "Not connected");
+}
+
+DBusHandlerResult error_already_exists(DBusConnection *conn, DBusMessage *msg, const char *str)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".AlreadyExists", str);
+}
+
+DBusHandlerResult error_does_not_exist(DBusConnection *conn, DBusMessage *msg, const char *str)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".DoesNotExist", str);
+}
+
+DBusHandlerResult error_device_does_not_exist(DBusConnection *conn, DBusMessage *msg)
+{
+ return error_does_not_exist(conn, msg, "Device does not exist");
+}
+
+DBusHandlerResult error_canceled(DBusConnection *conn, DBusMessage *msg, const char *str)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".Canceled", str);
+}
+
+DBusHandlerResult error_failed(DBusConnection *conn, DBusMessage *msg, const char * desc)
+{
+ return error_common_reply(conn, msg, ERROR_INTERFACE ".Failed", desc);
+}
+
+DBusHandlerResult error_failed_errno(DBusConnection *conn, DBusMessage *msg, int err)
+{
+ const char *desc = strerror(err);
+
+ return error_failed(conn, msg, desc);
+}
+
+DBusHandlerResult error_common_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)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ return dbus_connection_send_and_unref(conn, derr);
+}
diff -x Entries -x Makefile.in -u -r -N utils/common/common-error.h utils2/common/common-error.h
--- utils/common/common-error.h 1970-01-01 00:00:00.000000000 +0000
+++ utils2/common/common-error.h 2007-10-28 17:48:02.000000000 +0000
@@ -0,0 +1,148 @@
+/*
+ *
+ * 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
+ *
+ */
+
+#include <dbus/dbus.h>
+
+#define ERROR_INTERFACE "org.bluez.core.Error"
+
+/**
+ org.bluez.Error.DeviceUnreachable:
+
+ The remote device is either powered down or out of reach.
+*/
+DBusHandlerResult error_device_unreachable(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.ConnectionAttemptFailed:
+
+ An unexpected error (other than DeviceUnreachable) error has occured while
+ attempting a connection to a device
+*/
+DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn, DBusMessage *msg, int err);
+
+/**
+ org.bluez.Error.AlreadyConnected:
+
+ A connection request has been received on an already connected device.
+*/
+DBusHandlerResult error_already_connected(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.NotConnected:
+
+ The remote device is not connected, while the method call
+ would expect it to be, or is not in the expected state to
+ perform the action
+*/
+DBusHandlerResult error_not_connected(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.InProgress:
+
+ The request is already in progress.
+*/
+DBusHandlerResult error_in_progress(DBusConnection *conn, DBusMessage *msg, const char *str);
+
+/**
+ org.bluez.Error.InvalidArguments:
+
+ The DBUS request does not contain the right number of
+ arguments with the right type, or the arguments are there but
+ their value is wrong.
+*/
+DBusHandlerResult error_invalid_arguments(DBusConnection *conn, DBusMessage *msg, const char *str);
+
+/**
+ org.bluez.Error.OutOfMemory:
+
+ Not much to add
+*/
+DBusHandlerResult error_out_of_memory(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.NotAvailable:
+
+ The requested information is not there.
+ Examples of use: Adapter object when remote info is not available, or Database
+ object record is not found
+*/
+DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.NotSupported:
+
+ The remote device does not supopt the expected feature.
+ Examples of use: trying to connect to audio device while audio is not
+ declared in device sdp record.
+*/
+DBusHandlerResult error_not_supported(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.AlreadyExists:
+
+ One of the requested elements already exists
+ Examples of use: Bonding, record, passkey agent, auth agent... already exists
+*/
+DBusHandlerResult error_already_exists(DBusConnection *conn, DBusMessage *msg, const char *str);
+
+/**
+ org.bluez.Error.DoesNotExist:
+
+ One of the requested elements does not exist
+ Examples of use: Bonding, record, passkey agent, auth agent, bluetooth device ... does
+ not exist.
+*/
+DBusHandlerResult error_does_not_exist(DBusConnection *conn, DBusMessage *msg, const char *str);
+
+/**
+ org.bluez.Error.DoesNotExist:
+
+ Same as error_does_not_exist, but with device error message
+*/
+DBusHandlerResult error_device_does_not_exist(DBusConnection *conn, DBusMessage *msg);
+
+/**
+ org.bluez.Error.Canceled:
+*/
+DBusHandlerResult error_canceled(DBusConnection *conn, DBusMessage *msg, const char *str);
+
+/**
+ org.bluez.Error.Failed:
+
+ This is a the most generic error.
+ desc filed is MANDATORY
+*/
+DBusHandlerResult error_failed(DBusConnection *conn, DBusMessage *msg, const char *desc);
+
+/**
+ org.bluez.Error.Failed:
+
+ This is a the most generic error, instantiated form a UNIX errno number.
+*/
+DBusHandlerResult error_failed_errno(DBusConnection *conn, DBusMessage *msg, int err);
+
+
+/* Helper function */
+DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
+ const char *name, const char *descr);
diff -x Entries -x Makefile.in -u -r -N utils/common/Makefile.am utils2/common/Makefile.am
--- utils/common/Makefile.am 2007-03-20 14:48:01.000000000 +0000
+++ utils2/common/Makefile.am 2007-10-27 15:53:23.000000000 +0000
@@ -26,6 +26,7 @@
libhelper_a_SOURCES = oui.h oui.c dbus.h dbus.c \
textfile.h textfile.c logging.h logging.c \
dbus-helper.h dbus-helper.c \
+ common-error.h common-error.c \
sdp-xml.h sdp-xml.c $(sdp_sources) \
hal.h $(hal_sources) notify.h $(notify_sources)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: exceptions-rework-hcid.diff --]
[-- Type: text/x-patch; name="exceptions-rework-hcid.diff", Size: 60275 bytes --]
diff -x Entries -x Makefile.in -u -r -N utils/hcid/adapter.c utils2/hcid/adapter.c
--- utils/hcid/adapter.c 2007-10-27 14:32:54.000000000 +0000
+++ utils2/hcid/adapter.c 2007-10-27 20:53:59.000000000 +0000
@@ -60,6 +60,7 @@
#include "dbus-hci.h"
#include "dbus-sdp.h"
#include "dbus-error.h"
+#include "common-error.h"
#define NUM_ELEMENTS(table) (sizeof(table)/sizeof(const char *))
@@ -365,7 +366,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-database.c utils2/hcid/dbus-database.c
--- utils/hcid/dbus-database.c 2007-10-27 14:32:54.000000000 +0000
+++ utils2/hcid/dbus-database.c 2007-10-27 20:53:59.000000000 +0000
@@ -50,6 +50,7 @@
#include "dbus-hci.h"
#include "dbus-common.h"
#include "dbus-error.h"
+#include "common-error.h"
#include "dbus-service.h"
#include "dbus-security.h"
#include "dbus-database.h"
@@ -109,7 +110,7 @@
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 @@
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 @@
&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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-error.c utils2/hcid/dbus-error.c
--- utils/hcid/dbus-error.c 2007-10-27 14:54:10.000000000 +0000
+++ utils2/hcid/dbus-error.c 2007-10-27 21:39:25.000000000 +0000
@@ -37,14 +37,7 @@
#include "dbus-helper.h"
#include "dbus-common.h"
#include "dbus-error.h"
-
-DBusHandlerResult error_failed(DBusConnection *conn, DBusMessage *msg, int err)
-{
- const char *str = strerror(err);
-
- return dbus_connection_send_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".Failed", str));
-}
+#include "common-error.h"
DBusHandlerResult error_not_ready(DBusConnection *conn, DBusMessage *msg)
{
@@ -52,13 +45,6 @@
dbus_message_new_error(msg, ERROR_INTERFACE ".NotReady", "Adapter is not ready"));
}
-DBusHandlerResult error_invalid_arguments(DBusConnection *conn, DBusMessage *msg)
-{
- return dbus_connection_send_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 @@
"Rejected"));
}
-DBusHandlerResult error_out_of_memory(DBusConnection *conn, DBusMessage *msg)
-{
- return dbus_connection_send_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".OutOfMemory",
- "Out of memory"));
-}
-
DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg)
{
return dbus_connection_send_and_unref(conn,
@@ -109,20 +88,6 @@
"No such service"));
}
-DBusHandlerResult error_not_available(DBusConnection *conn, DBusMessage *msg)
-{
- return dbus_connection_send_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".NotAvailable",
- "Not available"));
-}
-
-DBusHandlerResult error_not_supported(DBusConnection *conn, DBusMessage *msg)
-{
- return dbus_connection_send_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".NotSupported",
- "Not supported"));
-}
-
DBusHandlerResult error_request_deferred(DBusConnection *conn, DBusMessage *msg)
{
return dbus_connection_send_and_unref(conn,
@@ -130,13 +95,6 @@
"Request Deferred"));
}
-DBusHandlerResult error_not_connected(DBusConnection *conn, DBusMessage *msg)
-{
- return dbus_connection_send_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".NotConnected",
- "Not connected"));
-}
-
DBusHandlerResult error_unsupported_major_class(DBusConnection *conn, DBusMessage *msg)
{
return dbus_connection_send_and_unref(conn,
@@ -144,48 +102,12 @@
"Unsupported Major Class"));
}
-DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn, DBusMessage *msg, int err)
-{
- return dbus_connection_send_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 dbus_connection_send_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 dbus_connection_send_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 dbus_connection_send_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".InProgress", str));
-}
-
-DBusHandlerResult error_canceled(DBusConnection *conn, DBusMessage *msg, const char *str)
-{
- return dbus_connection_send_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 dbus_connection_send_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 @@
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 @@
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 @@
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");
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-error.h utils2/hcid/dbus-error.h
--- utils/hcid/dbus-error.h 2007-10-23 17:49:52.000000000 +0000
+++ utils2/hcid/dbus-error.h 2007-10-28 17:47:49.000000000 +0000
@@ -22,47 +22,30 @@
*
*/
-#define ERROR_INTERFACE "org.bluez.Error"
-
-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);
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-hci.c utils2/hcid/dbus-hci.c
--- utils/hcid/dbus-hci.c 2007-10-27 14:32:54.000000000 +0000
+++ utils2/hcid/dbus-hci.c 2007-10-28 17:54:17.000000000 +0000
@@ -50,6 +50,7 @@
#include "textfile.h"
#include "manager.h"
#include "adapter.h"
+#include "common-error.h"
#include "dbus-helper.h"
#include "dbus-common.h"
#include "dbus-error.h"
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-sdp.c utils2/hcid/dbus-sdp.c
--- utils/hcid/dbus-sdp.c 2007-10-27 14:32:54.000000000 +0000
+++ utils2/hcid/dbus-sdp.c 2007-10-27 20:54:00.000000000 +0000
@@ -57,6 +57,7 @@
#include "dbus-hci.h"
#include "dbus-common.h"
#include "dbus-error.h"
+#include "common-error.h"
#include "dbus-sdp.h"
#include "sdp-xml.h"
@@ -438,7 +439,7 @@
failed:
if (err) {
- error_failed(ctxt->conn, ctxt->rq, err);
+ error_failed_errno(ctxt->conn, ctxt->rq, err);
transaction_context_free(ctxt, FALSE);
}
@@ -463,12 +464,12 @@
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;
}
@@ -480,7 +481,7 @@
/* 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;
}
@@ -535,12 +536,12 @@
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;
}
@@ -552,7 +553,7 @@
/* 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;
}
@@ -609,12 +610,12 @@
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;
}
@@ -626,7 +627,7 @@
/* 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;
}
@@ -741,12 +742,12 @@
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;
}
@@ -758,7 +759,7 @@
/* 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;
}
@@ -1016,7 +1017,7 @@
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);
@@ -1028,7 +1029,7 @@
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;
@@ -1089,13 +1090,13 @@
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);
}
}
@@ -1105,7 +1106,7 @@
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;
@@ -1123,7 +1124,7 @@
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);
@@ -1131,7 +1132,7 @@
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;
@@ -1149,7 +1150,7 @@
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)
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-security.c utils2/hcid/dbus-security.c
--- utils/hcid/dbus-security.c 2007-10-27 14:32:54.000000000 +0000
+++ utils2/hcid/dbus-security.c 2007-10-27 20:54:00.000000000 +0000
@@ -50,6 +50,7 @@
#include "dbus-common.h"
#include "dbus-service.h"
#include "dbus-error.h"
+#include "common-error.h"
#include "dbus-security.h"
#include "dbus-hci.h"
@@ -259,7 +260,7 @@
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));
@@ -314,7 +315,7 @@
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));
@@ -354,7 +355,7 @@
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);
@@ -395,7 +396,7 @@
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);
@@ -570,7 +571,7 @@
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);
@@ -611,7 +612,7 @@
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);
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-service.c utils2/hcid/dbus-service.c
--- utils/hcid/dbus-service.c 2007-10-27 14:32:54.000000000 +0000
+++ utils2/hcid/dbus-service.c 2007-10-27 20:54:00.000000000 +0000
@@ -49,6 +49,7 @@
#include "server.h"
#include "dbus-common.h"
#include "dbus-error.h"
+#include "common-error.h"
#include "manager.h"
#include "adapter.h"
#include "dbus-service.h"
@@ -326,7 +327,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
diff -x Entries -x Makefile.in -u -r -N utils/hcid/dbus-test.c utils2/hcid/dbus-test.c
--- utils/hcid/dbus-test.c 2007-10-27 14:32:55.000000000 +0000
+++ utils2/hcid/dbus-test.c 2007-10-27 20:54:00.000000000 +0000
@@ -45,6 +45,7 @@
#include "adapter.h"
#include "dbus-hci.h"
#include "dbus-error.h"
+#include "common-error.h"
#include "dbus-test.h"
#define L2INFO_TIMEOUT (2 * 1000)
@@ -424,11 +425,11 @@
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 @@
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 @@
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 @@
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);
diff -x Entries -x Makefile.in -u -r -N utils/hcid/manager.c utils2/hcid/manager.c
--- utils/hcid/manager.c 2007-10-27 14:32:55.000000000 +0000
+++ utils2/hcid/manager.c 2007-10-27 20:54:00.000000000 +0000
@@ -49,6 +49,7 @@
#include "dbus.h"
#include "dbus-helper.h"
#include "dbus-common.h"
+#include "common-error.h"
#include "dbus-error.h"
#include "dbus-hci.h"
#include "dbus-service.h"
@@ -67,7 +68,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
next prev parent reply other threads:[~2007-10-28 18:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-28 17:06 [Bluez-devel] [PATCH 1/3] move common exceptions to common/ directory fabchevalier
2007-10-28 18:16 ` Marcel Holtmann
2007-10-28 18:01 ` fabchevalier
2007-10-28 18:15 ` fabchevalier [this message]
2007-10-28 19:40 ` Marcel Holtmann
2007-10-28 19:06 ` fabchevalier
2007-10-28 20:46 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1193595313.4724d1b17e3bf@imp.free.fr \
--to=fabchevalier@free.fr \
--cc=bluez-devel@lists.sourceforge.net \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox