From d307f848466360929125c738c35bb7491da21ba8 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 4 Dec 2012 14:42:05 +0200 Subject: [PATCH] agent: Rename Authorize to AuthorizeService --- doc/agent-api.txt | 2 +- src/adapter.c | 2 +- src/agent.c | 25 +++++++++++-------------- src/agent.h | 6 +++--- test/agent.c | 10 ++++++---- test/simple-agent | 4 ++-- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/doc/agent-api.txt b/doc/agent-api.txt index cf80519eb..3928312f4 100644 --- a/doc/agent-api.txt +++ b/doc/agent-api.txt @@ -101,7 +101,7 @@ Methods void Release() Possible errors: org.bluez.Error.Rejected org.bluez.Error.Canceled - void Authorize(object device, string uuid) + void AuthorizeService(object device, string uuid) This method gets called when the service daemon needs to authorize a connection/service request. diff --git a/src/adapter.c b/src/adapter.c index 3c67f8a45..3c5d27723 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3466,7 +3466,7 @@ static gboolean process_auth_queue(gpointer user_data) dev_path = device_get_path(device); - if (agent_authorize(auth->agent, dev_path, auth->uuid, + if (agent_authorize_service(auth->agent, dev_path, auth->uuid, agent_auth_cb, adapter, NULL) < 0) { auth->cb(&err, auth->user_data); goto next; diff --git a/src/agent.c b/src/agent.c index e206c5624..bb4b61925 100644 --- a/src/agent.c +++ b/src/agent.c @@ -53,7 +53,7 @@ typedef enum { AGENT_REQUEST_PASSKEY, AGENT_REQUEST_CONFIRMATION, AGENT_REQUEST_PINCODE, - AGENT_REQUEST_AUTHORIZE, + AGENT_REQUEST_AUTHORIZE_SERVICE, AGENT_REQUEST_CONFIRM_MODE, AGENT_REQUEST_DISPLAY_PINCODE, } agent_request_type_t; @@ -293,14 +293,14 @@ done: agent_request_free(req, TRUE); } -static int agent_call_authorize(struct agent_request *req, - const char *device_path, - const char *uuid) +static int agent_call_authorize_service(struct agent_request *req, + const char *device_path, + const char *uuid) { struct agent *agent = req->agent; req->msg = dbus_message_new_method_call(agent->name, agent->path, - "org.bluez.Agent", "Authorize"); + "org.bluez.Agent", "AuthorizeService"); if (!req->msg) { error("Couldn't allocate D-Bus message"); return -ENOMEM; @@ -322,12 +322,9 @@ static int agent_call_authorize(struct agent_request *req, return 0; } -int agent_authorize(struct agent *agent, - const char *path, - const char *uuid, - agent_cb cb, - void *user_data, - GDestroyNotify destroy) +int agent_authorize_service(struct agent *agent, const char *path, + const char *uuid, agent_cb cb, + void *user_data, GDestroyNotify destroy) { struct agent_request *req; int err; @@ -335,10 +332,10 @@ int agent_authorize(struct agent *agent, if (agent->request) return -EBUSY; - req = agent_request_new(agent, AGENT_REQUEST_AUTHORIZE, cb, + req = agent_request_new(agent, AGENT_REQUEST_AUTHORIZE_SERVICE, cb, user_data, destroy); - err = agent_call_authorize(req, path, uuid); + err = agent_call_authorize_service(req, path, uuid); if (err < 0) { agent_request_free(req, FALSE); return -ENOMEM; @@ -346,7 +343,7 @@ int agent_authorize(struct agent *agent, agent->request = req; - DBG("authorize request was sent for %s", path); + DBG("authorize service request was sent for %s", path); return 0; } diff --git a/src/agent.h b/src/agent.h index 8fb475825..3b817d466 100644 --- a/src/agent.h +++ b/src/agent.h @@ -41,9 +41,9 @@ struct agent *agent_create(struct btd_adapter *adapter, const char *name, void agent_free(struct agent *agent); -int agent_authorize(struct agent *agent, const char *path, - const char *uuid, agent_cb cb, void *user_data, - GDestroyNotify destroy); +int agent_authorize_service(struct agent *agent, const char *path, + const char *uuid, agent_cb cb, + void *user_data, GDestroyNotify destroy); int agent_request_pincode(struct agent *agent, struct btd_device *device, agent_pincode_cb cb, gboolean secure, diff --git a/test/agent.c b/test/agent.c index 5cdeeb4ec..1713ec3e7 100644 --- a/test/agent.c +++ b/test/agent.c @@ -211,7 +211,7 @@ send: return DBUS_HANDLER_RESULT_HANDLED; } -static DBusHandlerResult authorize_message(DBusConnection *conn, +static DBusHandlerResult authorize_service_message(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessage *reply; @@ -220,7 +220,8 @@ static DBusHandlerResult authorize_message(DBusConnection *conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID)) { - fprintf(stderr, "Invalid arguments for Authorize method"); + fprintf(stderr, + "Invalid arguments for AuthorizeService method"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -320,8 +321,9 @@ static DBusHandlerResult agent_message(DBusConnection *conn, "RequestConfirmation")) return request_confirmation_message(conn, msg, data); - if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Authorize")) - return authorize_message(conn, msg, data); + if (dbus_message_is_method_call(msg, "org.bluez.Agent", + "AuthorizeService")) + return authorize_service_message(conn, msg, data); if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Cancel")) return cancel_message(conn, msg, data); diff --git a/test/simple-agent b/test/simple-agent index 465857b83..0ca2ce097 100755 --- a/test/simple-agent +++ b/test/simple-agent @@ -48,8 +48,8 @@ class Agent(dbus.service.Object): @dbus.service.method("org.bluez.Agent", in_signature="os", out_signature="") - def Authorize(self, device, uuid): - print("Authorize (%s, %s)" % (device, uuid)) + def AuthorizeService(self, device, uuid): + print("AuthorizeService (%s, %s)" % (device, uuid)) authorize = ask("Authorize connection (yes/no): ") if (authorize == "yes"): return -- 2.47.3