* [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error
@ 2012-12-21 16:25 Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 2/4] sap: Use btd_error_* functions Anderson Lizardo
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Anderson Lizardo @ 2012-12-21 16:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This will simplify changing interface name later (e.g. adding
versioning).
---
src/adapter.c | 4 ++--
src/agent.c | 5 +++--
src/device.c | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 6ff20e1..c1cb763 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -736,7 +736,7 @@ static void service_auth_cancel(struct service_auth *auth)
DBusError derr;
dbus_error_init(&derr);
- dbus_set_error_const(&derr, "org.bluez.Error.Canceled", NULL);
+ dbus_set_error_const(&derr, ERROR_INTERFACE ".Canceled", NULL);
auth->cb(&derr, auth->user_data);
@@ -3105,7 +3105,7 @@ static gboolean process_auth_queue(gpointer user_data)
adapter->auth_idle_id = 0;
dbus_error_init(&err);
- dbus_set_error_const(&err, "org.bluez.Error.Rejected", NULL);
+ dbus_set_error_const(&err, ERROR_INTERFACE ".Rejected", NULL);
while (!g_queue_is_empty(adapter->auths)) {
struct service_auth *auth = adapter->auths->head->data;
diff --git a/src/agent.c b/src/agent.c
index 71e13c2..9b3fd28 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -206,7 +206,8 @@ void agent_unref(struct agent *agent)
agent_cb cb;
dbus_error_init(&err);
- dbus_set_error_const(&err, "org.bluez.Error.Failed", "Canceled");
+ dbus_set_error_const(&err, ERROR_INTERFACE ".Failed",
+ "Canceled");
switch (agent->request->type) {
case AGENT_REQUEST_PINCODE:
@@ -439,7 +440,7 @@ static void pincode_reply(DBusPendingCall *call, void *user_data)
if (len > 16 || len < 1) {
error("Invalid PIN length (%zu) from agent", len);
- dbus_set_error_const(&err, "org.bluez.Error.InvalidArgs",
+ dbus_set_error_const(&err, ERROR_INTERFACE ".InvalidArgs",
"Invalid passkey length");
cb(agent, &err, NULL, req->user_data);
dbus_error_free(&err);
diff --git a/src/device.c b/src/device.c
index 3cfb816..17c6cf7 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3908,7 +3908,7 @@ static void cancel_authentication(struct authentication_req *auth)
auth->agent = NULL;
dbus_error_init(&err);
- dbus_set_error_const(&err, "org.bluez.Error.Canceled", NULL);
+ dbus_set_error_const(&err, ERROR_INTERFACE ".Canceled", NULL);
switch (auth->type) {
case AUTH_TYPE_PINCODE:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 2/4] sap: Use btd_error_* functions
2012-12-21 16:25 [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Anderson Lizardo
@ 2012-12-21 16:25 ` Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 3/4] obexd: Simplify org.bluez.Error.InvalidArguments handling Anderson Lizardo
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Anderson Lizardo @ 2012-12-21 16:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
These helper functions are available for plugins and simplify error
handling code.
---
profiles/sap/sap-dummy.c | 24 +++++++++---------------
profiles/sap/server.c | 14 +++-----------
2 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/profiles/sap/sap-dummy.c b/profiles/sap/sap-dummy.c
index ffaf847..f68e048 100644
--- a/profiles/sap/sap-dummy.c
+++ b/profiles/sap/sap-dummy.c
@@ -31,6 +31,7 @@
#include <stdint.h>
#include "dbus-common.h"
+#include "error.h"
#include "log.h"
#include "sap.h"
@@ -234,12 +235,6 @@ void sap_set_transport_protocol_req(void *sap_device,
sap_transport_protocol_rsp(sap_device, SAP_RESULT_NOT_SUPPORTED);
}
-static inline DBusMessage *invalid_args(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
- "Invalid arguments in method call");
-}
-
static DBusMessage *ongoing_call(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -247,7 +242,7 @@ static DBusMessage *ongoing_call(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BOOLEAN, &ongoing,
DBUS_TYPE_INVALID))
- return invalid_args(msg);
+ return btd_error_invalid_args(msg);
if (ongoing_call_status && !ongoing) {
/* An ongoing call has finished. Continue connection.*/
@@ -269,12 +264,12 @@ static DBusMessage *max_msg_size(DBusConnection *conn, DBusMessage *msg,
dbus_uint32_t size;
if (sim_card_conn_status == SIM_CONNECTED)
- return g_dbus_create_error(msg, "org.bluez.Error.Failed",
+ return btd_error_failed(msg,
"Can't change msg size when connected.");
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &size,
DBUS_TYPE_INVALID))
- return invalid_args(msg);
+ return btd_error_invalid_args(msg);
max_msg_size_supported = size;
@@ -287,8 +282,7 @@ static DBusMessage *disconnect_immediate(DBusConnection *conn, DBusMessage *msg,
void *data)
{
if (sim_card_conn_status == SIM_DISCONNECTED)
- return g_dbus_create_error(msg, "org.bluez.Error.Failed",
- "Already disconnected.");
+ return btd_error_failed(msg, "Already disconnected.");
sim_card_conn_status = SIM_DISCONNECTED;
sap_disconnect_ind(sap_data, SAP_DISCONNECTION_TYPE_IMMEDIATE);
@@ -304,12 +298,12 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
DBG("status %d", sim_card_conn_status);
if (sim_card_conn_status != SIM_CONNECTED)
- return g_dbus_create_error(msg, "org.bluez.Error.Failed",
+ return btd_error_failed(msg,
"Can't change msg size when not connected.");
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &status,
DBUS_TYPE_INVALID))
- return invalid_args(msg);
+ return btd_error_invalid_args(msg);
switch (status) {
case 0: /* card removed */
@@ -331,8 +325,8 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
break;
default:
- return g_dbus_create_error(msg, "org.bluez.Error.Failed",
- "Unknown card status. Use 0, 1 or 2.");
+ return btd_error_failed(msg,
+ "Unknown card status. Use 0, 1 or 2.");
}
DBG("Card status changed to %d", status);
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index 01caa33..0fa4e7c 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -1260,29 +1260,21 @@ static void connect_confirm_cb(GIOChannel *io, gpointer data)
DBG("Authorizing incoming SAP connection from %s", dstaddr);
}
-static inline DBusMessage *message_failed(DBusMessage *msg,
- const char *description)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s",
- description);
-}
-
static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct sap_server *server = data;
if (!server)
- return message_failed(msg, "Server internal error.");
+ return btd_error_failed(msg, "Server internal error.");
DBG("conn %p", server->conn);
if (!server->conn)
- return message_failed(msg, "Client already disconnected");
+ return btd_error_failed(msg, "Client already disconnected");
if (disconnect_req(server, SAP_DISCONNECTION_TYPE_GRACEFUL) < 0)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "There is no active connection");
+ return btd_error_failed(msg, "There is no active connection");
return dbus_message_new_method_return(msg);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 3/4] obexd: Simplify org.bluez.Error.InvalidArguments handling
2012-12-21 16:25 [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 2/4] sap: Use btd_error_* functions Anderson Lizardo
@ 2012-12-21 16:25 ` Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 4/4] build: Fix installing udev rules file when $(srcdir) != $(builddir) Anderson Lizardo
2012-12-21 22:17 ` [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Anderson Lizardo @ 2012-12-21 16:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Use a helper function to void code duplication.
---
obexd/plugins/bluetooth.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index 8985c83..e28a94f 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -104,6 +104,12 @@ drop:
return;
}
+static DBusMessage *invalid_args(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
+ "Invalid arguments in method call");
+}
+
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -115,26 +121,20 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
dbus_message_iter_init(msg, &args);
if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
- return g_dbus_create_error(msg,
- "org.bluez.Error.InvalidArguments",
- "Invalid arguments in method call");
+ return invalid_args(msg);
dbus_message_iter_get_basic(&args, &device);
dbus_message_iter_next(&args);
if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_UNIX_FD)
- return g_dbus_create_error(msg,
- "org.bluez.Error.InvalidArguments",
- "Invalid arguments in method call");
+ return invalid_args(msg);
dbus_message_iter_get_basic(&args, &fd);
io = g_io_channel_unix_new(fd);
if (io == NULL)
- return g_dbus_create_error(msg,
- "org.bluez.Error.InvalidArguments",
- "Invalid arguments in method call");
+ return invalid_args(msg);
DBG("device %s", device);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 4/4] build: Fix installing udev rules file when $(srcdir) != $(builddir)
2012-12-21 16:25 [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 2/4] sap: Use btd_error_* functions Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 3/4] obexd: Simplify org.bluez.Error.InvalidArguments handling Anderson Lizardo
@ 2012-12-21 16:25 ` Anderson Lizardo
2012-12-21 22:17 ` [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Anderson Lizardo @ 2012-12-21 16:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Path to files on source tree should be prefixed with $(srcdir),
otherwise they are not found if $(srcdir) != $(builddir).
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 350a9e8..8852e04 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -278,7 +278,7 @@ src/builtin.h: src/genbuiltin $(builtin_sources)
$(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@
tools/%.rules:
- $(AM_V_GEN)cp $(subst 97-,,$@) $@
+ $(AM_V_GEN)cp $(srcdir)/$(subst 97-,,$@) $@
$(lib_libbluetooth_la_OBJECTS): $(local_headers)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error
2012-12-21 16:25 [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Anderson Lizardo
` (2 preceding siblings ...)
2012-12-21 16:25 ` [PATCH BlueZ 4/4] build: Fix installing udev rules file when $(srcdir) != $(builddir) Anderson Lizardo
@ 2012-12-21 22:17 ` Johan Hedberg
3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2012-12-21 22:17 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Lizardo,
On Fri, Dec 21, 2012, Anderson Lizardo wrote:
> This will simplify changing interface name later (e.g. adding
> versioning).
> ---
> src/adapter.c | 4 ++--
> src/agent.c | 5 +++--
> src/device.c | 2 +-
> 3 files changed, 6 insertions(+), 5 deletions(-)
All four patches have been applied, though I removed the comment about
versioning in this one as I don't think anything like that will be done
for the errors.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-21 22:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21 16:25 [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 2/4] sap: Use btd_error_* functions Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 3/4] obexd: Simplify org.bluez.Error.InvalidArguments handling Anderson Lizardo
2012-12-21 16:25 ` [PATCH BlueZ 4/4] build: Fix installing udev rules file when $(srcdir) != $(builddir) Anderson Lizardo
2012-12-21 22:17 ` [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).