Fix the memset size errors
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-obex-server.c
index e46d1f8..af30019 100644 (file)
@@ -20,7 +20,7 @@
 #include <dlog.h>
 #include <string.h>
 #include <dirent.h>
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
 #include "bt-service-dpm.h"
 #endif
 
@@ -407,7 +407,7 @@ static GDBusProxy *__bt_get_transfer_proxy(const char *transfer_path)
        GDBusProxy *proxy;
        GError *err = NULL;
 
-       conn = _bt_gdbus_get_session_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, NULL);
 
        proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
@@ -430,7 +430,7 @@ static GDBusProxy *__bt_get_transfer_properties_proxy(const char *transfer_path)
        GDBusConnection *conn;
        GDBusProxy *proxy;
        GError *err = NULL;
-       conn = _bt_gdbus_get_session_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, NULL);
 
        proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
@@ -535,6 +535,9 @@ static gboolean __bt_authorize_cb(GDBusMethodInvocation *context,
        GVariant *param = NULL;
        GError *err = NULL;
        bt_session_info_t *session_info = NULL;
+#ifdef TIZEN_FEATURE_BT_DPM
+       int value = DPM_BT_ERROR;
+#endif
 
        BT_DBG(" path [%s] \n", path);
 
@@ -573,8 +576,9 @@ static gboolean __bt_authorize_cb(GDBusMethodInvocation *context,
 
        agent_info.auth_info->transfer_path = g_strdup(path);
 
-#ifdef TIZEN_DPM_ENABLE
-       if (_bt_dpm_get_allow_bluetooth_mode() == DPM_BT_HANDSFREE_ONLY) {
+#ifdef TIZEN_FEATURE_BT_DPM
+       _bt_dpm_get_allow_bluetooth_mode(&value);
+       if (value == DPM_BT_HANDSFREE_ONLY) {
                /* Free auth info in next function */
                _bt_obex_server_reject_authorize();
                return FALSE;
@@ -585,13 +589,12 @@ static gboolean __bt_authorize_cb(GDBusMethodInvocation *context,
                GVariant *val;
                gsize len = 0;
                while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
-                       if (g_strcmp0(key, "Name") == 0) {
+                       if (g_strcmp0(key, "Name") == 0)
                                agent_info.auth_info->filename = g_variant_dup_string(val, &len);
-                       } else if (g_strcmp0(key, "Address") == 0) {
+                       else if (g_strcmp0(key, "Address") == 0)
                                bdaddress = g_variant_dup_string(val, &len);
-                       } else if (g_strcmp0(key, "Size") == 0) {
+                       else if (g_strcmp0(key, "Size") == 0)
                                agent_info.auth_info->file_size = g_variant_get_uint64(val);
-                       }
                }
                g_variant_iter_free(iter);
        }
@@ -624,16 +627,17 @@ static gboolean __bt_authorize_cb(GDBusMethodInvocation *context,
        }
 
        if (session_info->authorized == FALSE) {
-               _bt_launch_system_popup(BT_AGENT_EVENT_EXCHANGE_REQUEST, device_name,
+               if (headed_plugin_info->plugin_headed_enabled)
+                       headed_plugin_info->headed_plugin->bt_launch_system_popup(BT_AGENT_EVENT_EXCHANGE_REQUEST, device_name,
                                        auth_info, NULL, NULL, BT_OBEX_SERVER_AGENT_PATH);
        } else {
                param = g_variant_new("(istss)", result,
-                       agent_info.auth_info->filename,
-                       agent_info.auth_info->file_size,
-                       agent_info.auth_info->address,
-                       agent_info.auth_info->device_name);
+                               agent_info.auth_info->filename,
+                               agent_info.auth_info->file_size,
+                               agent_info.auth_info->address,
+                               agent_info.auth_info->device_name);
                _bt_send_event(BT_OPP_SERVER_EVENT,
-                       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE, param);
+                               BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE, param);
        }
 
        return TRUE;
@@ -812,9 +816,9 @@ void _bt_obex_transfer_completed(const char *transfer_path, gboolean success)
                        g_variant_builder_add(builder, "y", agent_info.auth_info->contact_auth_info[i]);
 
                param = g_variant_new("(isssstii(ay))", result,
+                                       transfer_info->device_name,
                                        transfer_info->filename,
                                        transfer_info->type,
-                                       transfer_info->device_name,
                                        transfer_info->address,
                                        transfer_info->file_size,
                                        transfer_info->transfer_id,
@@ -900,7 +904,7 @@ int _bt_register_obex_server(void)
        GError *g_error = NULL;
 
        /* Get the session bus. */
-       g_conn = _bt_gdbus_get_session_gconn();
+       g_conn = _bt_gdbus_get_system_gconn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_obex_agent_new(BT_OBEX_SERVER_AGENT_PATH);
@@ -916,9 +920,8 @@ int _bt_register_obex_server(void)
                                                BT_OBEX_MANAGER,
                                                NULL, &g_error);
 
-       if (manager_proxy == NULL) {
+       if (manager_proxy == NULL)
                return BLUETOOTH_ERROR_INTERNAL;
-       }
 
        result = g_dbus_proxy_call_sync(manager_proxy, "RegisterAgent",
                                g_variant_new("(o)", BT_OBEX_SERVER_AGENT_PATH),
@@ -990,11 +993,10 @@ gboolean __bt_check_folder_path(const char *dest_path)
 char *__bt_transfer_folder_path(char *dest_path)
 {
        char *dst_path = (char *)g_malloc0(BT_OBEX_PATH_MAX_LENGTH);
-       if (g_str_has_prefix(dest_path, BT_OBEX_PATH_PREFIX)) {
+       if (g_str_has_prefix(dest_path, BT_OBEX_PATH_PREFIX))
                snprintf(dst_path, BT_OBEX_PATH_MAX_LENGTH, BT_OBEX_DEFAULT_PATH"%s", dest_path + strlen(BT_OBEX_PATH_PREFIX));
-       } else {
+       else
                snprintf(dst_path, BT_OBEX_PATH_MAX_LENGTH, "%s", dest_path);
-       }
 
        BT_INFO("obex transfed path : %s", dst_path);
        return dst_path;
@@ -1302,11 +1304,10 @@ int _bt_obex_server_is_activated(gboolean *activated)
 {
        BT_CHECK_PARAMETER(activated, return);
 
-       if (agent_info.custom_server) {
+       if (agent_info.custom_server)
                *activated = TRUE;
-       } else {
+       else
                *activated = FALSE;
-       }
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1315,11 +1316,10 @@ int _bt_obex_server_check_allocation(gboolean *allocation)
 {
        BT_CHECK_PARAMETER(allocation, return);
 
-       if (agent_info.native_server || agent_info.custom_server) {
+       if (agent_info.native_server || agent_info.custom_server)
                *allocation = TRUE;
-       } else {
+       else
                *allocation = FALSE;
-       }
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1349,11 +1349,10 @@ int _bt_obex_server_is_receiving(gboolean *receiving)
 {
        BT_CHECK_PARAMETER(receiving, return);
 
-       if (transfers == NULL || g_slist_length(transfers) == 0) {
+       if (transfers == NULL || g_slist_length(transfers) == 0)
                *receiving = FALSE;
-       } else {
+       else
                *receiving = TRUE;
-       }
 
        return BLUETOOTH_ERROR_NONE;
 }