Fix the build warnings and typo error
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / bt-request-handler.c
index c47990c..28a950a 100644 (file)
@@ -229,6 +229,7 @@ static gboolean __bt_is_sync_function(int service_function)
                        || service_function == BT_GATT_GET_INCLUDED_SERVICES
                        || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
                        || service_function == BT_GATT_WATCH_CHARACTERISTIC
+                       || service_function == BT_GATT_ACQUIRE_WRITE
 #endif
                        || service_function == BT_AUDIO_SELECT_ROLE
                        || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION)
@@ -2256,6 +2257,72 @@ int __bt_bluez_request(int function_name,
 
                break;
        }
+       case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
+
+               bluetooth_gatt_server_acquire_response_params_t param;
+               char *app;
+               GDBusMessage *msg;
+               msg = g_dbus_method_invocation_get_message(context);
+               GUnixFDList *fd_list;
+               int fd  = -1;;
+               int *fd_list_array;
+               int len;
+
+               BT_ERR("sending acquire write  respose \n");
+
+               fd_list = g_dbus_message_get_unix_fd_list(msg);
+
+               memset(&param, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
+
+               app = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1, &param,
+                               sizeof(bluetooth_gatt_server_acquire_response_params_t));
+
+               BT_ERR("sending acquire write  respose sent \n  ");
+
+               fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
+               BT_INFO("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
+               fd = fd_list_array[0];
+
+               param.fd = fd;
+               result = _bt_gatt_server_acquire_send_response(app, &param, fd_list);
+
+               break;
+       }
+       case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
+
+               bluetooth_gatt_server_acquire_response_params_t param;
+               char *app;
+               GDBusMessage *msg;
+               msg = g_dbus_method_invocation_get_message(context);
+               GUnixFDList *fd_list;
+               int fd  = -1;
+               int *fd_list_array;
+               int len;
+
+               BT_ERR("sending acquire write  respose \n");
+
+               fd_list = g_dbus_message_get_unix_fd_list(msg);
+
+               memset(&param, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
+
+               app = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1, &param,
+                               sizeof(bluetooth_gatt_server_acquire_response_params_t));
+
+               BT_ERR("sending acquire write  respose sent \n  ");
+
+               fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
+               BT_INFO("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
+               fd = fd_list_array[0];
+
+               param.fd = fd;
+               result = _bt_gatt_server_acquire_send_response(app, &param, fd_list);
+
+               break;
+       }
        case BT_GATT_SERVER_SEND_INDICATION: {
                bluetooth_gatt_server_indication_params_t param;
                bluetooth_gatt_att_data_t data;
@@ -2348,6 +2415,47 @@ int __bt_bluez_request(int function_name,
        }
 
        /* Async: Remote Interaction  */
+       case BT_GATT_ACQUIRE_WRITE: {
+
+               int fd = -1;
+               int mtu = -1;
+               bluetooth_gatt_client_char_prop_info_t param;
+
+               BT_INFO("GATT Client ACQUIRE WRITE recived");
+
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1, &param,
+                                       sizeof(bluetooth_gatt_client_char_prop_info_t));
+
+
+               result   = _bt_gatt_acquire_write(&param , &fd, &mtu);
+
+               g_array_append_vals(*out_param1, &mtu, sizeof(int));
+
+               if (BLUETOOTH_ERROR_NONE == result)
+                       BT_INFO("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
+               else {
+                       BT_ERR("Gatt Client Acqure Write");
+                       break;
+               }
+
+               GUnixFDList *fd_list = NULL;
+               GError *error = NULL;
+
+               /* Add socket fd to unix_fd_list */
+               fd_list = g_unix_fd_list_new();
+               g_unix_fd_list_append(fd_list, fd, &error);
+
+               _bt_service_method_return_with_unix_fd_list(
+                               context, *out_param1, result, fd_list);
+
+               close(fd);
+               g_object_unref(fd_list);
+
+               break;
+       }
+       /* Async: Remote Interaction  */
        case BT_CONNECT_LE: {
                bluetooth_device_address_t address = { {0} };
                gboolean auto_connect;
@@ -2579,6 +2687,10 @@ int __bt_bluez_request(int function_name,
                bluetooth_gatt_client_char_prop_info_t param;
                int client_id;
                gboolean is_notify;
+               int fd = -1;
+               int mtu = 0;
+               gboolean is_indicate;
+
 
                memset(&param, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
 
@@ -2590,15 +2702,40 @@ int __bt_bluez_request(int function_name,
                                sizeof(int));
                __bt_service_get_parameters(in_param3, &is_notify,
                                sizeof(gboolean));
+               __bt_service_get_parameters(in_param4, &is_indicate,
+                               sizeof(gboolean));
 
-               result = _bt_gatt_watch_characteristic(&param , client_id, is_notify);
-               if (BLUETOOTH_ERROR_NONE == result) {
-                       BT_INFO("GATT Client: Save Invocation data for characteristic props app[%s]", sender);
+               if (is_indicate == false) {
+                       result   = _bt_gatt_acquire_notify(&param , &fd, &mtu);
+                       if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
+                               BT_INFO("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
+
+                               GUnixFDList *fd_list = NULL;
+                               GError *error = NULL;
+
+                               g_array_append_vals(*out_param1, &mtu, sizeof(int));
+                               /* Add socket fd to unix_fd_list */
+                               fd_list = g_unix_fd_list_new();
+                               g_unix_fd_list_append(fd_list, fd, &error);
+                               g_assert_no_error(error);
+                               close(fd);
+                               _bt_service_method_return_with_unix_fd_list(
+                               context, *out_param1, result, fd_list);
+
+                               g_object_unref(fd_list);
+                       } else
+                               goto normal;
+               } else {
 
-                       /* Save the informations to invocation */
-                       _bt_save_invocation_context(context, result, sender,
-                                       function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+normal:
+                       result = _bt_gatt_watch_characteristic(&param , client_id, is_notify);
+                       if (BLUETOOTH_ERROR_NONE == result) {
+                               BT_INFO("GATT Client: Save Invocation data for characteristic props app[%s]", sender);
+
+                               /* Save the informations to invocation */
+                               _bt_save_invocation_context(context, result, sender, function_name,
+                                        (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+                       }
                }
                break;
        }
@@ -3546,6 +3683,7 @@ gboolean __bt_service_check_privilege(int function_name,
 #ifdef TIZEN_GATT_CLIENT
        case BT_GATT_READ_DESCRIPTOR_VALUE:              /* GATT Client */
        case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
+       case BT_GATT_ACQUIRE_WRITE:
        case BT_GATT_WRITE_DESCRIPTOR_VALUE:             /* GATT Client */
        case BT_GATT_WATCH_CHARACTERISTIC:               /* GATT Client */
        case BT_GATT_CLIENT_REGISTER:                    /* GATT Client */
@@ -3564,6 +3702,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GATT_SERVER_STOP_SERVICE:
        case BT_GATT_SERVER_DELETE_SERVICE:
        case BT_GATT_SERVER_SEND_RESPONSE:
+       case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
+       case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
        case BT_GATT_SERVER_SEND_INDICATION:
        case BT_GATT_SERVER_UPDATE_VALUE:
        case BT_GATT_SERVER_DEREGISTER: