Add param fd into authorize service 41/23641/1
authorGu Chaojie <chao.jie.gu@intel.com>
Tue, 1 Jul 2014 02:51:59 +0000 (10:51 +0800)
committerGu Chaojie <chao.jie.gu@intel.com>
Tue, 1 Jul 2014 02:52:49 +0000 (10:52 +0800)
Change-Id: I138b1a9f1e8fca2530d443d461d961a13727bafa
Signed-off-by: Gu Chaojie <chao.jie.gu@intel.com>
profiles/audio/avctp.c
profiles/audio/avdtp.c
profiles/input/server.c
profiles/network/server.c
profiles/sap/server.c
src/adapter.c
src/adapter.h
src/agent.c
src/agent.h
src/profile.c

index 74d351263a92ade1234e7e512f380969e2c6f2cc..1879ae2c0379dc5154e967969d16eeb6de5498b4 100644 (file)
@@ -1339,8 +1339,8 @@ static void avctp_control_confirm(struct avctp *session, GIOChannel *chan,
        dst = device_get_address(dev);
 
        session->auth_id = btd_request_authorization(src, dst,
-                                                       AVRCP_REMOTE_UUID,
-                                                       auth_cb, session);
+                                               AVRCP_REMOTE_UUID,
+                                               auth_cb, session, 0);
        if (session->auth_id == 0)
                goto drop;
 
index 8a7d1c0e76b05a33eb72a586cf2b24fde164a87a..8bd7f5abd2875ab45ba4b7b67433a24d4280be93 100644 (file)
@@ -2507,8 +2507,8 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
                                        (GIOFunc) session_cb, session);
 
        session->auth_id = btd_request_authorization(&src, &dst,
-                                                       ADVANCED_AUDIO_UUID,
-                                                       auth_cb, session);
+                                               ADVANCED_AUDIO_UUID,
+                                               auth_cb, session, 0);
        if (session->auth_id == 0) {
                avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
                goto drop;
index 772a605fba4193ee3c69fc19736931164da7ac24..8c64f875e04d99239f2d32fcd62cad97f366c203 100644 (file)
@@ -266,7 +266,7 @@ static void confirm_event_cb(GIOChannel *chan, gpointer user_data)
        server->confirm = g_io_channel_ref(chan);
 
        ret = btd_request_authorization(&src, &dst, HID_UUID,
-                                       auth_callback, server);
+                               auth_callback, server, 0);
        if (ret != 0)
                return;
 
index 902783f5830ec12d078d0593100dee146d98ef1e..0db9e6fce9382c6475b4a5dfc75b2514bb970594 100644 (file)
@@ -537,7 +537,7 @@ static void confirm_event(GIOChannel *chan, gpointer user_data)
        na->setup->io = g_io_channel_ref(chan);
 
        ret = btd_request_authorization(&src, &dst, BNEP_SVC_UUID,
-                                       auth_cb, na);
+                                       auth_cb, na, 0);
        if (ret == 0) {
                error("Refusing connect from %s", address);
                setup_destroy(na);
index 20c6cab7cd7ca21cc87dfc7e9c1f50f82d68fb05..20af81ffa4152a7605250e5027eb7892e1e768e4 100644 (file)
@@ -1253,7 +1253,7 @@ static void connect_confirm_cb(GIOChannel *io, gpointer data)
        ba2str(&dst, dstaddr);
 
        ret = btd_request_authorization(&src, &dst, SAP_UUID, connect_auth_cb,
-                                                               server);
+                                                       server, 0);
        if (ret == 0) {
                error("Authorization failure");
                sap_server_remove_conn(server);
index f5f8c8c5f010476f926dacf5debef10f3ff35d89..a83f82713ab5849f4574a71bfc0b3f2eb09263db 100644 (file)
@@ -139,6 +139,7 @@ struct service_auth {
        struct btd_device *device;
        struct btd_adapter *adapter;
        struct agent *agent;            /* NULL for queued auths */
+       int fd;
 };
 
 struct btd_adapter_pin_cb_iter {
@@ -4642,7 +4643,7 @@ static gboolean process_auth_queue(gpointer user_data)
                dev_path = device_get_path(device);
 
                if (agent_authorize_service(auth->agent, dev_path, auth->uuid,
-                                       agent_auth_cb, adapter, NULL) < 0) {
+                               agent_auth_cb, adapter, NULL, auth->fd) < 0) {
                        auth->cb(&err, auth->user_data);
                        goto next;
                }
@@ -4681,7 +4682,7 @@ static void svc_complete(struct btd_device *dev, int err, void *user_data)
 
 static int adapter_authorize(struct btd_adapter *adapter, const bdaddr_t *dst,
                                        const char *uuid, service_auth_cb cb,
-                                       void *user_data)
+                                       void *user_data, int fd)
 {
        struct service_auth *auth;
        struct btd_device *device;
@@ -4705,6 +4706,7 @@ static int adapter_authorize(struct btd_adapter *adapter, const bdaddr_t *dst,
        auth->device = device;
        auth->adapter = adapter;
        auth->id = ++id;
+       auth->fd = fd;
        auth->svc_id = device_wait_for_svc_complete(device, svc_complete, auth);
 
        g_queue_push_tail(adapter->auths, auth);
@@ -4714,7 +4716,7 @@ static int adapter_authorize(struct btd_adapter *adapter, const bdaddr_t *dst,
 
 guint btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
                                        const char *uuid, service_auth_cb cb,
-                                       void *user_data)
+                                       void *user_data, int fd)
 {
        struct btd_adapter *adapter;
        GSList *l;
@@ -4724,7 +4726,8 @@ guint btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
                if (!adapter)
                        return 0;
 
-               return adapter_authorize(adapter, dst, uuid, cb, user_data);
+               return adapter_authorize(adapter, dst, uuid, cb,
+                                                       user_data, fd);
        }
 
        for (l = adapters; l != NULL; l = g_slist_next(l)) {
@@ -4732,7 +4735,8 @@ guint btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
 
                adapter = l->data;
 
-               id = adapter_authorize(adapter, dst, uuid, cb, user_data);
+               id = adapter_authorize(adapter, dst, uuid, cb,
+                                                       user_data, fd);
                if (id != 0)
                        return id;
        }
index f88c339180746388bcfa8dc8d94a39ca493d007f..a5c080106d1833c8e32bced1469f7663165a9fc8 100644 (file)
@@ -120,7 +120,7 @@ void adapter_remove_profile(struct btd_adapter *adapter, gpointer p);
 int btd_register_adapter_driver(struct btd_adapter_driver *driver);
 void btd_unregister_adapter_driver(struct btd_adapter_driver *driver);
 guint btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
-               const char *uuid, service_auth_cb cb, void *user_data);
+       const char *uuid, service_auth_cb cb, void *user_data, int fd);
 int btd_cancel_authorization(guint id);
 
 int btd_adapter_restore_powered(struct btd_adapter *adapter);
index 8c1211c339a31ac5dd9d87af18295755686e6477..9f9e076538c909655b358bcfbcd3456c4478a26d 100644 (file)
@@ -377,8 +377,10 @@ done:
 
 static int agent_call_authorize_service(struct agent_request *req,
                                                const char *device_path,
-                                               const char *uuid)
+                                               const char *uuid,
+                                               const int fd)
 {
+       DBusMessageIter iter, dict;
        struct agent *agent = req->agent;
 
        req->msg = dbus_message_new_method_call(agent->owner, agent->path,
@@ -388,10 +390,14 @@ static int agent_call_authorize_service(struct agent_request *req,
                return -ENOMEM;
        }
 
-       dbus_message_append_args(req->msg,
-                               DBUS_TYPE_OBJECT_PATH, &device_path,
-                               DBUS_TYPE_STRING, &uuid,
-                               DBUS_TYPE_INVALID);
+       dbus_message_iter_init_append(req->msg, &iter);
+
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+                                               &device_path);
+
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uuid);
+
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_UNIX_FD, &fd);
 
        if (g_dbus_send_message_with_reply(btd_get_dbus_connection(),
                                                req->msg, &req->call,
@@ -405,8 +411,8 @@ static int agent_call_authorize_service(struct agent_request *req,
 }
 
 int agent_authorize_service(struct agent *agent, const char *path,
-                               const char *uuid, agent_cb cb,
-                               void *user_data, GDestroyNotify destroy)
+                       const char *uuid, agent_cb cb,
+                       void *user_data, GDestroyNotify destroy, int fd)
 {
        struct agent_request *req;
        int err;
@@ -417,7 +423,7 @@ int agent_authorize_service(struct agent *agent, const char *path,
        req = agent_request_new(agent, AGENT_REQUEST_AUTHORIZE_SERVICE, cb,
                                                        user_data, destroy);
 
-       err = agent_call_authorize_service(req, path, uuid);
+       err = agent_call_authorize_service(req, path, uuid, fd);
        if (err < 0) {
                agent_request_free(req, FALSE);
                return -ENOMEM;
index 1e46920368db12d27560b9a4fb7f08bae9f1bfe4..bab6db096a7d86ff9730a8ec042154ac93d412b7 100644 (file)
@@ -39,8 +39,8 @@ void agent_unref(struct agent *agent);
 struct agent *agent_get(const char *owner);
 
 int agent_authorize_service(struct agent *agent, const char *path,
-                               const char *uuid, agent_cb cb,
-                               void *user_data, GDestroyNotify destroy);
+                       const char *uuid, agent_cb cb,
+                       void *user_data, GDestroyNotify destroy, int fd);
 
 int agent_request_pincode(struct agent *agent, struct btd_device *device,
                                agent_pincode_cb cb, gboolean secure,
index f30f4f6affeffc61a286d656447f38b9387b2cd4..3d562ce79f3380e43697aa92785d9c6934057ecc 100644 (file)
@@ -1100,6 +1100,7 @@ static void ext_confirm(GIOChannel *io, gpointer user_data)
        GError *gerr = NULL;
        bdaddr_t src, dst;
        char addr[18];
+       int fd;
 
        bt_io_get(io, &gerr,
                        BT_IO_OPT_SOURCE_BDADDR, &src,
@@ -1119,8 +1120,9 @@ static void ext_confirm(GIOChannel *io, gpointer user_data)
        if (conn == NULL)
                return;
 
+       fd = g_io_channel_unix_get_fd(conn->io);
        conn->auth_id = btd_request_authorization(&src, &dst, uuid, ext_auth,
-                                                                       conn);
+                                                               conn, fd);
        if (conn->auth_id == 0) {
                error("%s authorization failure", ext->name);
                ext_io_destroy(conn);