summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@indt.org.br>2008-07-04 19:45:36 -0300
committerLuiz Augusto von Dentz <luiz.dentz@indt.org.br>2008-07-28 10:33:19 -0300
commit670eacd442dd0d7fbaecd552cfb5ca32eaccea0e (patch)
tree398c4da00db81da286d4ecd1717d95145a466163
parentc36942e998cd6187181df3033e53f1d624a5fd1a (diff)
Remove dbus-error.c dbus-error.h
-rw-r--r--hcid/Makefile.am2
-rw-r--r--hcid/adapter.c10
-rw-r--r--hcid/agent.c1
-rw-r--r--hcid/dbus-error.c91
-rw-r--r--hcid/dbus-error.h33
-rw-r--r--hcid/dbus-hci.c18
-rw-r--r--hcid/manager.c1
7 files changed, 17 insertions, 139 deletions
diff --git a/hcid/Makefile.am b/hcid/Makefile.am
index 9fdf75e5..857fff0c 100644
--- a/hcid/Makefile.am
+++ b/hcid/Makefile.am
@@ -19,7 +19,7 @@ libhciserver_a_SOURCES = hcid.h security.c storage.c \
parser.h parser.y lexer.l kword.c kword.h \
server.h server.c manager.h manager.c \
adapter.h adapter.c device.h device.c plugin.h plugin.c \
- dbus-common.c dbus-common.h dbus-error.c dbus-error.h \
+ dbus-common.c dbus-common.h \
dbus-database.c dbus-database.h dbus-service.c dbus-service.h \
dbus-hci.h dbus-hci.c \
telephony.h telephony.c agent.h agent.c
diff --git a/hcid/adapter.c b/hcid/adapter.c
index 6658f31a..434a428b 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -58,7 +58,6 @@
#include "dbus-common.h"
#include "dbus-hci.h"
#include "dbus-database.h"
-#include "dbus-error.h"
#include "error.h"
#include "glib-helper.h"
#include "logging.h"
@@ -810,8 +809,9 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
}
if (cond & G_IO_NVAL) {
- error_authentication_canceled(adapter->bonding->conn,
- adapter->bonding->msg);
+ DBusMessage *reply;
+ reply = new_authentication_return(adapter->bonding->msg, 0x09);
+ g_dbus_send_message(adapter->bonding->conn, reply);
goto cleanup;
}
@@ -860,8 +860,8 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
dd = hci_open_dev(adapter->dev_id);
if (dd < 0) {
- error_no_such_adapter(adapter->bonding->conn,
- adapter->bonding->msg);
+ DBusMessage *reply = no_such_adapter(adapter->bonding->msg);
+ g_dbus_send_message(adapter->bonding->conn, reply);
goto failed;
}
diff --git a/hcid/agent.c b/hcid/agent.c
index 8fa7c502..ab326789 100644
--- a/hcid/agent.c
+++ b/hcid/agent.c
@@ -43,7 +43,6 @@
#include "hcid.h"
#include "dbus-common.h"
-#include "dbus-error.h"
#include "error.h"
#include "adapter.h"
#include "dbus-hci.h"
diff --git a/hcid/dbus-error.c b/hcid/dbus-error.c
deleted file mode 100644
index 76d9f095..00000000
--- a/hcid/dbus-error.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2006-2007 Nokia Corporation
- * Copyright (C) 2004-2008 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 <stdio.h>
-#include <errno.h>
-
-#include <bluetooth/sdp.h>
-
-#include <dbus/dbus.h>
-#include <gdbus.h>
-
-#include "hcid.h"
-#include "dbus-common.h"
-#include "dbus-error.h"
-#include "error.h"
-
-static inline DBusHandlerResult send_message_and_unref(DBusConnection *conn,
- DBusMessage *msg)
-{
- if (msg) {
- dbus_connection_send(conn, msg, NULL);
- dbus_message_unref(msg);
- }
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg)
-{
- return send_message_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".NoSuchAdapter",
- "No such adapter"));
-}
-
-DBusHandlerResult error_authentication_canceled(DBusConnection *conn, DBusMessage *msg)
-{
- return send_message_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".AuthenticationCanceled",
- "Authentication Canceled"));
-}
-
-static const char *strsdperror(int err)
-{
- switch (err) {
- case SDP_INVALID_VERSION:
- return "Invalid/unsupported SDP version";
- case SDP_INVALID_RECORD_HANDLE:
- return "Invalid Service Record Handle";
- case SDP_INVALID_SYNTAX:
- return "Invalid request syntax";
- case SDP_INVALID_PDU_SIZE:
- return "Invalid PDU size";
- case SDP_INVALID_CSTATE:
- return "Invalid Continuation State";
- default:
- return "Undefined error";
- }
-}
-
-DBusHandlerResult error_sdp_failed(DBusConnection *conn, DBusMessage *msg, int err)
-{
- const char *str = strsdperror(err);
-
- return send_message_and_unref(conn,
- dbus_message_new_error(msg, ERROR_INTERFACE ".Failed", str));
-}
diff --git a/hcid/dbus-error.h b/hcid/dbus-error.h
deleted file mode 100644
index 6b3a22c4..00000000
--- a/hcid/dbus-error.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2006-2007 Nokia Corporation
- * Copyright (C) 2004-2008 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
- *
- */
-
-/*
- Please update dbus-api.txt in hcid folder when changes are made to this file.
- */
-
-DBusHandlerResult error_no_such_adapter(DBusConnection *conn, DBusMessage *msg);
-/* Used only for hcid device audit feature */
-DBusHandlerResult error_authentication_canceled(DBusConnection *conn, DBusMessage *msg);
-DBusHandlerResult error_auth_agent_does_not_exist(DBusConnection *conn, DBusMessage *msg);
-DBusHandlerResult error_sdp_failed(DBusConnection *conn, DBusMessage *msg, int err);
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c
index b4891c22..3f7178d6 100644
--- a/hcid/dbus-hci.c
+++ b/hcid/dbus-hci.c
@@ -53,7 +53,6 @@
#include "error.h"
#include "glib-helper.h"
#include "dbus-common.h"
-#include "dbus-error.h"
#include "agent.h"
#include "dbus-hci.h"
@@ -240,6 +239,7 @@ DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
case 0x09: /* connection limit */
case 0x0a: /* synchronous connection limit */
case 0x0d: /* limited resources */
+ case 0x13: /* user ended the connection */
case 0x14: /* terminated due to low resources */
return dbus_message_new_error(msg,
ERROR_INTERFACE ".AuthenticationCanceled",
@@ -307,14 +307,16 @@ static void adapter_mode_changed(struct adapter *adapter, uint8_t scan_enable)
*/
static void reply_pending_requests(const char *path, struct adapter *adapter)
{
+ DBusMessage *reply;
if (!path || !adapter)
return;
/* pending bonding */
if (adapter->bonding) {
- error_authentication_canceled(connection, adapter->bonding->msg);
-
+ reply = new_authentication_return(adapter->bonding->msg,
+ HCI_OE_USER_ENDED_CONNECTION);
+ g_dbus_send_message(connection, reply);
remove_pending_device(adapter);
g_dbus_remove_watch(adapter->bonding->conn,
@@ -329,7 +331,6 @@ static void reply_pending_requests(const char *path, struct adapter *adapter)
/* If there is a pending reply for discovery cancel */
if (adapter->discovery_cancel) {
- DBusMessage *reply;
reply = dbus_message_new_method_return(adapter->discovery_cancel);
dbus_connection_send(connection, reply, NULL);
dbus_message_unref(reply);
@@ -1144,7 +1145,9 @@ proceed:
if (bonding->cancel) {
/* reply authentication canceled */
- error_authentication_canceled(connection, bonding->msg);
+ reply = new_authentication_return(bonding->msg,
+ HCI_OE_USER_ENDED_CONNECTION);
+ g_dbus_send_message(connection, reply);
goto cleanup;
}
@@ -1839,8 +1842,9 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
if (adapter->bonding && (bacmp(&adapter->bonding->bdaddr, &dev->bdaddr) == 0)) {
if (adapter->bonding->cancel) {
/* reply authentication canceled */
- error_authentication_canceled(connection,
- adapter->bonding->msg);
+ reply = new_authentication_return(adapter->bonding->msg,
+ HCI_OE_USER_ENDED_CONNECTION);
+ g_dbus_send_message(connection, reply);
} else {
reply = new_authentication_return(adapter->bonding->msg,
HCI_AUTHENTICATION_FAILURE);
diff --git a/hcid/manager.c b/hcid/manager.c
index 20293e21..ef357e7f 100644
--- a/hcid/manager.c
+++ b/hcid/manager.c
@@ -50,7 +50,6 @@
#include "adapter.h"
#include "dbus-common.h"
#include "error.h"
-#include "dbus-error.h"
#include "dbus-hci.h"
#include "dbus-database.h"
#include "sdp-xml.h"