Fix : Invalid GVariant format
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-hid.c
old mode 100755 (executable)
new mode 100644 (file)
index f0d967a..fb0dc54
@@ -19,9 +19,8 @@
 #include <gio/gio.h>
 #include <dlog.h>
 #include <string.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
+#include <vconf.h>
 #include "bluetooth-api.h"
 
 #include "bt-service-common.h"
@@ -30,6 +29,8 @@
 #include "bt-service-event.h"
 #include "bt-service-util.h"
 
+#define BT_HID_BARCODE_SUPPORT "file/bluetooth/hid/barcode_support"
+
 static void __bt_hid_connect_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
@@ -79,7 +80,7 @@ static void __bt_hid_connect_cb(GDBusProxy *proxy, GAsyncResult *res,
                        &device_addr, sizeof(bluetooth_device_address_t), TRUE, NULL, NULL);
 
        g_dbus_method_invocation_return_value(req_info->context,
-                       g_variant_new("iv", result, out_param1));
+                       g_variant_new("(iv)", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
        BT_DBG("HID Connected..");
@@ -91,7 +92,7 @@ done:
        }
 }
 
-static void __bt_hid_disconnect_cb(GDBusProxy *proxy,GAsyncResult *res,
+static void __bt_hid_disconnect_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
        GError *g_error = NULL;
@@ -138,7 +139,7 @@ static void __bt_hid_disconnect_cb(GDBusProxy *proxy,GAsyncResult *res,
                                                        &device_addr, sizeof(bluetooth_device_address_t), TRUE, NULL, NULL);
 
        g_dbus_method_invocation_return_value(req_info->context,
-                       g_variant_new("iv", result, out_param1));
+                       g_variant_new("(iv)", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
        BT_DBG("HID Disconnected..");
@@ -172,15 +173,12 @@ int _bt_hid_connect(int request_id,
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        */
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
        uuid = HID_UUID;
@@ -190,6 +188,8 @@ int _bt_hid_connect(int request_id,
 
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("_bt_connect_profile Error");
+               g_free(func_data->address);
+               g_free(func_data);
                return ret;
        }
        return BLUETOOTH_ERROR_NONE;
@@ -211,15 +211,12 @@ int _bt_hid_disconnect(int request_id,
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        */
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
@@ -228,8 +225,21 @@ int _bt_hid_disconnect(int request_id,
 
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("_bt_disconnect_profile Error");
+               g_free(func_data->address);
+               g_free(func_data);
                return ret;
        }
 
        return BLUETOOTH_ERROR_NONE;
 }
+
+int _bt_hid_enable_barcode_feature(void)
+{
+       if (vconf_set_bool(BT_HID_BARCODE_SUPPORT, true) != 0) {
+               BT_ERR("Set vconf failed\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+