bt-api: Fix incorrect macro expansion for service function 36/101736/1
authorSyam Sidhardhan <s.syam@samsung.com>
Wed, 30 Nov 2016 12:35:00 +0000 (18:05 +0530)
committerSyam Sidhardhan <s.syam@samsung.com>
Thu, 1 Dec 2016 07:35:31 +0000 (13:05 +0530)
The _bt_send_request() and _bt_send_request_async() macros are
designed in such a way that we should always pass a "#define value"
or "enum type" as the first two params. Otherwise it will just print
the variable name.

Change-Id: I137c59a780ffd0000cd79dbafe0379389405d5ce
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
bt-api/bt-audio.c
bt-api/bt-obex-server.c
bt-api/bt-rfcomm-client.c
bt-api/include/bt-request-sender.h

index 33a0df2..c944e6d 100644 (file)
@@ -128,9 +128,18 @@ BT_EXPORT_API int bluetooth_audio_connect(bluetooth_device_address_t *remote_add
 
        g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t));
 
-       result = _bt_send_request_async(BT_BLUEZ_SERVICE, service_function,
-               in_param1, in_param2, in_param3, in_param4,
-               user_info->cb, user_info->user_data);
+       if (service_function == BT_AV_CONNECT)
+               result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_CONNECT,
+                               in_param1, in_param2, in_param3, in_param4,
+                               user_info->cb, user_info->user_data);
+       else if (service_function == BT_AG_CONNECT)
+               result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AG_CONNECT,
+                               in_param1, in_param2, in_param3, in_param4,
+                               user_info->cb, user_info->user_data);
+       else /* default case - with or without DPM enabled */
+               result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AUDIO_CONNECT,
+                               in_param1, in_param2, in_param3, in_param4,
+                               user_info->cb, user_info->user_data);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
index 1204d4a..c679d0e 100755 (executable)
@@ -348,7 +348,6 @@ BT_EXPORT_API int bluetooth_obex_server_cancel_transfer(int transfer_id)
 {
        int result;
        int server_type;
-       int service_function = BT_OBEX_SERVER_CANCEL_TRANSFER;
 
        BT_CHECK_ENABLED(return);
 
@@ -356,16 +355,18 @@ BT_EXPORT_API int bluetooth_obex_server_cancel_transfer(int transfer_id)
 
        if (server_type == BT_NO_SERVER)
                return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
-       else if (server_type == BT_CUSTOM_SERVER)
-               service_function = BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS;
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
        g_array_append_vals(in_param1, &transfer_id, sizeof(int));
 
-       result = _bt_send_request(BT_OBEX_SERVICE, service_function,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
+       if (server_type == BT_CUSTOM_SERVER)
+               result = _bt_send_request(BT_OBEX_SERVICE, BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
+       else
+               result = _bt_send_request(BT_OBEX_SERVICE, BT_OBEX_SERVER_CANCEL_TRANSFER,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
index 6fcf16e..21b3fea 100644 (file)
@@ -881,7 +881,6 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd)
        return BLUETOOTH_ERROR_NONE;
 #else
        int result;
-       int service_function;
 
        BT_CHECK_ENABLED(return);
 
@@ -891,15 +890,14 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd)
        /* Support the OSP */
        if (socket_fd == -1) {
                /* Cancel connect */
-               service_function = BT_RFCOMM_CLIENT_CANCEL_CONNECT;
+               result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_CLIENT_CANCEL_CONNECT,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
        } else {
                g_array_append_vals(in_param1, &socket_fd, sizeof(int));
-               service_function = BT_RFCOMM_SOCKET_DISCONNECT;
+               result = _bt_send_request(BT_BLUEZ_SERVICE, BT_RFCOMM_SOCKET_DISCONNECT,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
        }
 
-       result = _bt_send_request(BT_BLUEZ_SERVICE, service_function,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
-
        BT_DBG("result: %x", result);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
index 9c40c3b..e26ee49 100644 (file)
@@ -39,6 +39,7 @@ int _bt_sync_send_request(int service_type, int service_function,
                        GArray *in_param3, GArray *in_param4,
                        GArray **out_param1);
 
+/* The caller of this should pass #define macro/enum types as the first two params */
 #define _bt_send_request(a, b, format ...) ( \
        { \
        if ((a != BT_CHECK_PRIVILEGE && (a == BT_BLUEZ_SERVICE || a == BT_OBEX_SERVICE)) && \
@@ -57,6 +58,7 @@ int _bt_async_send_request(int service_type, int service_function,
                        GArray *in_param3, GArray *in_param4,
                        void *callback, void *user_data);
 
+/* The caller of this should pass #define macro/enum types as the first two params */
 #define _bt_send_request_async(a, b, format ...) ( \
        { \
        if ((a != BT_CHECK_PRIVILEGE && (a == BT_BLUEZ_SERVICE || a == BT_OBEX_SERVICE)) && \