Modify the pid and gid of bt-service to network_fw
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-obex-server.c
index a9cfb85..af30019 100644 (file)
@@ -1,13 +1,11 @@
 /*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *              http://www.apache.org/licenses/LICENSE-2.0
+ *             http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <stdio.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <dirent.h>
+#ifdef TIZEN_FEATURE_BT_DPM
+#include "bt-service-dpm.h"
+#endif
+
 #include <vconf.h>
 
+#include <gio/gio.h>
+
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 
 #include "bt-service-obex-server.h"
 #include "bt-service-agent.h"
 
+#define DBUS_TIMEOUT 20 * 1000 /* 20 Seconds */
 #define BT_OBEX_SERVER_AGENT_PATH "/org/obex/server_agent"
-#define BT_OBEX_SERVICE "org.openobex"
-#define BT_OBEX_MANAGER "org.openobex.Manager"
+
+#define BT_OBEX_SERVICE "org.bluez.obex"
+#define BT_OBEX_MANAGER "org.bluez.obex.AgentManager1"
+#define BT_OBEX_PATH "/org/bluez/obex"
+
+#define BT_OBEX_PATH_PREFIX "/opt/usr/media"
+#define BT_OBEX_DEFAULT_PATH "/opt/usr/home/owner/media"
+#define BT_OBEX_PATH_MAX_LENGTH 255
+
 
 typedef struct {
        char *filename;
+       char *file_path;
        char *path;
        char *type;
        char *device_name;
        int transfer_id;
        gint64 file_size;
+       gint64 progress;
+       char *address;
 } bt_transfer_info_t;
 
 typedef struct {
-       DBusGMethodInvocation *reply_context;
-       gint64 file_size;
+       GDBusMethodInvocation *reply_context;
+       guint64 file_size;
        char *filename;
+       char *file_path;
        char *device_name;
        char *transfer_path;
+       char *address;
+       unsigned char contact_auth_info[5];
 } bt_auth_info_t;
 
 typedef struct {
@@ -64,8 +80,7 @@ typedef struct {
 } bt_server_info_t;
 
 typedef struct {
-       BtObexAgent *obex_agent;
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        int server_type;
        int accept_id;
        bt_auth_info_t *auth_info;
@@ -73,8 +88,35 @@ typedef struct {
        bt_server_info_t *custom_server;
 } bt_obex_agent_info_t;
 
+typedef struct {
+       char *path;
+       char *address;
+       gboolean authorized;
+} bt_session_info_t;
+
 static GSList *transfers;
 static bt_obex_agent_info_t agent_info;
+static GSList *session_list = NULL;
+
+static bt_session_info_t *__bt_find_session_by_path(char *transfer_path)
+{
+       GSList *l;
+       bt_session_info_t *session;
+
+       retv_if(transfer_path == NULL, NULL);
+
+       for (l = session_list; l != NULL; l = l->next) {
+               session = l->data;
+
+               if (session == NULL)
+                       continue;
+
+               if (g_strcmp0(session->path, transfer_path) == 0)
+                       return session;
+       }
+
+       return NULL;
+}
 
 static GQuark __bt_obex_error_quark(void)
 {
@@ -103,6 +145,27 @@ static bt_transfer_info_t *__bt_find_transfer_by_id(int transfer_id)
        return NULL;
 }
 
+bt_transfer_info_t *__bt_find_transfer_by_address(const char *address)
+{
+       BT_DBG("+");
+       GSList *l;
+       bt_transfer_info_t *transfer;
+
+       retv_if(address == NULL, NULL);
+
+       for (l = transfers; l != NULL; l = l->next) {
+               transfer = l->data;
+
+               if (transfer == NULL)
+                       continue;
+
+               if (g_strcmp0(transfer->address, address) == 0)
+                       return transfer;
+       }
+       BT_DBG("-");
+       return NULL;
+}
+
 static bt_transfer_info_t *__bt_find_transfer_by_path(const char *transfer_path)
 {
        GSList *l;
@@ -139,6 +202,7 @@ static void __bt_free_auth_info(bt_auth_info_t *auto_info)
        g_free(auto_info->filename);
        g_free(auto_info->transfer_path);
        g_free(auto_info->device_name);
+       g_free(auto_info->address);
        g_free(auto_info);
 }
 
@@ -148,61 +212,181 @@ static void __bt_free_transfer_info(bt_transfer_info_t *transfer_info)
 
        g_free(transfer_info->path);
        g_free(transfer_info->filename);
+       g_free(transfer_info->file_path);
        g_free(transfer_info->type);
        g_free(transfer_info->device_name);
+       g_free(transfer_info->address);
        g_free(transfer_info);
 }
 
+void _bt_obex_check_pending_transfer(const char *address)
+{
+       BT_DBG("+");
+       GVariant *param = NULL;
+       bt_transfer_info_t *transfer_info = __bt_find_transfer_by_address(address);
+       if (transfer_info != NULL) {
+               int result = BLUETOOTH_ERROR_CANCEL;
+               param = g_variant_new("(issssstii)", result,
+                                       transfer_info->filename,
+                                       transfer_info->type,
+                                       transfer_info->device_name,
+                                       transfer_info->file_path,
+                                       transfer_info->address,
+                                       transfer_info->file_size,
+                                       transfer_info->transfer_id,
+                                       agent_info.server_type);
+               _bt_send_event(BT_OPP_SERVER_EVENT,
+                       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,
+                       param);
+               transfers = g_slist_remove(transfers, transfer_info);
+               __bt_free_transfer_info(transfer_info);
+       }
+       BT_DBG("-");
+}
+
 static char *__bt_get_remote_device_name(const char *bdaddress)
 {
-       GError *error = NULL;
        char *device_path = NULL;
        char *name = NULL;
-       GHashTable *hash = NULL;
-       GValue *value;
-       DBusGProxy *device_proxy;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
+       GVariant *value;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GDBusProxy *device_proxy;
+       GDBusConnection *conn;
 
        retv_if(bdaddress == NULL, NULL);
 
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, NULL);
+       device_path = _bt_get_device_object_path((char *)bdaddress);
+       retv_if(device_path == NULL, NULL);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, NULL);
+       BT_INFO("Device_path %s", device_path);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_BLUEZ_NAME,
+                                               device_path,
+                                               BT_PROPERTIES_INTERFACE,
+                                               NULL, &err);
 
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, bdaddress, G_TYPE_INVALID,
-                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
-
-       retv_if(device_path == NULL, NULL);
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_DEVICE_INTERFACE);
        g_free(device_path);
        retv_if(device_proxy == NULL, NULL);
-       if (!dbus_g_proxy_call(device_proxy, "GetProperties", &error,
-                       G_TYPE_INVALID,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       &hash, G_TYPE_INVALID)) {
-               if (error) {
-                       BT_ERR( "error in GetBasicProperties [%s]\n", error->message);
-                       g_error_free(error);
-               }
-               g_object_unref(device_proxy);
+
+       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
+                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
+       if (result == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
                return NULL;
        }
+       g_variant_get(result, "(@a{sv})", &value);
+
+       if (value) {
+               GVariant *temp_value = g_variant_lookup_value(value, "Alias",
+                       G_VARIANT_TYPE_STRING);
+               g_variant_get(temp_value, "s", &name);
+               if (temp_value)
+                       g_variant_unref(temp_value);
+
+               if (name != NULL)
+                       DBG_SECURE("Alias Name [%s]", name);
+               else {
+                       temp_value = g_variant_lookup_value(value, "Name", G_VARIANT_TYPE_STRING);
+                       g_variant_get(temp_value, "s", &name);
+                       if (temp_value)
+                               g_variant_unref(temp_value);
+                       DBG_SECURE("Name = %s", name);
+               }
+       }
+       g_variant_unref(result);
+       g_object_unref(device_proxy);
+       return name;
+}
+
+static void __bt_get_remote_device_name_authinfo(const char *bdaddress,
+                                       char **device_name, unsigned char *auth_info)
+{
+       char *device_path = NULL;
+       char *name = NULL;
+       gboolean is_alias_set;
+       GVariant *value;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GDBusProxy *device_proxy;
+       GDBusConnection *conn;
+
+       ret_if(bdaddress == NULL);
+
+       device_path = _bt_get_device_object_path((char *)bdaddress);
+       ret_if(device_path == NULL);
+
+       conn = _bt_gdbus_get_system_gconn();
+       ret_if(conn == NULL);
+       BT_INFO("Device_path %s", device_path);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_BLUEZ_NAME,
+                                               device_path,
+                                               BT_PROPERTIES_INTERFACE,
+                                               NULL, &err);
 
-       if (hash != NULL) {
-               value = g_hash_table_lookup(hash, "Alias");
-               name = value ? g_value_dup_string(value) : NULL;
-               g_hash_table_destroy(hash);
+       g_free(device_path);
+       ret_if(device_proxy == NULL);
+
+       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
+                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               return;
+       }
+       if (result == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               return;
        }
+       g_variant_get(result, "(@a{sv})", &value);
+
+       if (value) {
+               GVariant *temp_value = g_variant_lookup_value(value, "Alias",
+                       G_VARIANT_TYPE_STRING);
+               g_variant_get(temp_value, "s", &name);
+               if (temp_value)
+                       g_variant_unref(temp_value);
+
+               if (name != NULL)
+                       DBG_SECURE("Alias Name [%s]", name);
+               else {
+                       temp_value = g_variant_lookup_value(value, "Name", G_VARIANT_TYPE_STRING);
+                       g_variant_get(temp_value, "s", &name);
+                       if (temp_value)
+                               g_variant_unref(temp_value);
+                       DBG_SECURE("Name = %s", name);
+               }
+               temp_value = g_variant_lookup_value(value, "IsAliasSet", G_VARIANT_TYPE_BOOLEAN);
+               if (temp_value) {
+                       is_alias_set = g_variant_get_boolean(temp_value);
+                       g_variant_unref(temp_value);
+               } else {
+                       is_alias_set = FALSE;
+               }
 
+               if (is_alias_set == FALSE)
+                       __bt_get_auth_info(value, (char *)auth_info);
+       }
+       g_variant_unref(result);
        g_object_unref(device_proxy);
 
-       return name;
+       *device_name = g_strdup(name);
+       g_free(name);
+       return;
 }
 
 static int __bt_get_transfer_id(const char *path)
@@ -217,95 +401,224 @@ static int __bt_get_transfer_id(const char *path)
        return atoi(tmp);
 }
 
-static DBusGProxy *__bt_get_transfer_proxy(const char *transfer_path)
+static GDBusProxy *__bt_get_transfer_proxy(const char *transfer_path)
 {
-       DBusGConnection *conn;
-       DBusGProxy *proxy;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
 
-       conn = _bt_get_session_gconn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, NULL);
 
-       proxy = dbus_g_proxy_new_for_name(conn,
-                                       BT_OBEXD_INTERFACE,
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL, BT_OBEX_SERVICE_NAME,
                                        transfer_path,
-                                       BT_OBEXD_TRANSFER_INTERFACE);
+                                       BT_OBEX_TRANSFER_INTERFACE,
+                                       NULL, &err);
+
+       if (err) {
+               BT_ERR("Error : %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
 
        return proxy;
 }
 
+static GDBusProxy *__bt_get_transfer_properties_proxy(const char *transfer_path)
+{
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, NULL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL, BT_OBEX_SERVICE_NAME,
+                                       transfer_path,
+                                       BT_PROPERTIES_INTERFACE,
+                                       NULL, &err);
+       if (err) {
+               BT_ERR("Error : %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
+       return proxy;
+}
+
 static int __bt_get_transfer_properties(bt_transfer_info_t *transfer_info,
                                        const char *transfer_path)
 {
-       GHashTable *hash = NULL;
-       GValue *value;
-       DBusGProxy *transfer_proxy;
-
-       BT_CHECK_PARAMETER(transfer_info);
-       BT_CHECK_PARAMETER(transfer_path);
+       GDBusProxy *transfer_proxy;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GVariantIter *iter = NULL;
+       BT_CHECK_PARAMETER(transfer_info, return);
+       BT_CHECK_PARAMETER(transfer_path, return);
 
-       transfer_proxy = __bt_get_transfer_proxy(transfer_path);
+       transfer_proxy = __bt_get_transfer_properties_proxy(transfer_path);
 
        retv_if(transfer_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(transfer_proxy, "GetProperties", NULL,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(transfer_proxy, "GetAll",
+                       g_variant_new("(s)", BT_OBEX_TRANSFER_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
 
-       if (hash == NULL) {
-               g_object_unref(transfer_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               goto fail;
+       }
+       if (result == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               goto fail;
        }
 
-       value = g_hash_table_lookup(hash, "Operation");
-       transfer_info->type = value ? g_strdup(g_value_get_string(value)) : NULL;
-
-       value = g_hash_table_lookup(hash, "Filename");
-       transfer_info->filename = value ? g_strdup(g_value_get_string(value)) : NULL;
-
-       value = g_hash_table_lookup(hash, "Size");
-       transfer_info->file_size  = value ? g_value_get_uint64(value) : 0;
+       g_variant_get(result, "(a{sv})", &iter);
+       g_variant_unref(result);
+       if (iter) {
+               const gchar *key;
+               GVariant *val;
+               gsize len = 0;
+               while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
+                       if (g_strcmp0(key, "Operation") == 0) {
+                               transfer_info->type = g_variant_dup_string(val, &len);
+                       } else if (g_strcmp0(key, "Name") == 0) {
+                               transfer_info->filename = g_variant_dup_string(val, &len);
+                       } else if (g_strcmp0(key, "Size") == 0) {
+                               transfer_info->file_size = g_variant_get_uint64(val);
+                       } else if (g_strcmp0(key, "Address") == 0) {
+                               transfer_info->address = g_variant_dup_string(val, &len);
+                               BT_INFO("addressss %s", transfer_info->address);
+                       } else if (g_strcmp0(key, "Filename") == 0) {
+                               transfer_info->file_path = g_variant_dup_string(val, &len);
+                               if (!transfer_info->file_path)
+                                       transfer_info->file_path = g_strdup(transfer_info->filename);
+                       }
+               }
+               g_variant_iter_free(iter);
 
-       transfer_info->path = g_strdup(transfer_path);
-       transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
+               if (transfer_info->address == NULL)
+                       goto fail;
+               transfer_info->device_name = __bt_get_remote_device_name(transfer_info->address);
+               transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
+               if (!transfer_info->device_name)
+                       transfer_info->device_name = g_strdup(transfer_info->address);
 
-       transfer_info->device_name = g_strdup("");
+               if (transfer_info->type == NULL)
+                       goto fail;
 
-       g_hash_table_destroy(hash);
+               transfer_info->path = g_strdup(transfer_path);
+       }
 
+       g_object_unref(transfer_proxy);
        return BLUETOOTH_ERROR_NONE;
+
+fail:
+       g_object_unref(transfer_proxy);
+       return BLUETOOTH_ERROR_INTERNAL;
 }
 
-static gboolean __bt_authorize_cb(DBusGMethodInvocation *context,
+static gboolean __bt_authorize_cb(GDBusMethodInvocation *context,
                                        const char *path,
-                                       const char *bdaddress,
-                                       const char *name,
-                                       const char *type,
-                                       gint length,
-                                       gint time,
                                        gpointer user_data)
 {
        char *device_name = NULL;
+       unsigned char auth_info[5] = {0, };
        int result = BLUETOOTH_ERROR_NONE;
-
-       BT_DBG(" File name [%s] Address [%s] Type [%s] length [%d] path [%s] \n",
-           name, bdaddress, type, length, path);
+       GDBusProxy *transfer_properties_proxy;
+       char * bdaddress = NULL;
+       GVariant *ret;
+       GVariantIter *iter;
+       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);
+
+       transfer_properties_proxy = __bt_get_transfer_properties_proxy(path);
+
+       retv_if(transfer_properties_proxy == NULL, FALSE);
+
+       ret = g_dbus_proxy_call_sync(transfer_properties_proxy, "GetAll",
+                       g_variant_new("(s)", BT_OBEX_TRANSFER_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               return FALSE;
+       }
+       if (ret == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               return FALSE;
+       }
+       g_variant_get(ret, "(a{sv})", &iter);
+       g_variant_unref(ret);
+       if (iter == NULL) {
+               g_object_unref(transfer_properties_proxy);
+               return FALSE;
+       }
 
        __bt_free_auth_info(agent_info.auth_info);
 
        agent_info.auth_info = g_malloc(sizeof(bt_auth_info_t));
 
+       memset(agent_info.auth_info, 0, sizeof(bt_auth_info_t));
+
        agent_info.auth_info->reply_context = context;
-       agent_info.auth_info->filename = g_strdup(name);
-       agent_info.auth_info->file_size = length;
+
        agent_info.auth_info->transfer_path = g_strdup(path);
 
-       device_name = __bt_get_remote_device_name(bdaddress);
+#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;
+       }
+#endif
+       if (iter) {
+               const gchar *key;
+               GVariant *val;
+               gsize len = 0;
+               while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
+                       if (g_strcmp0(key, "Name") == 0)
+                               agent_info.auth_info->filename = g_variant_dup_string(val, &len);
+                       else if (g_strcmp0(key, "Address") == 0)
+                               bdaddress = g_variant_dup_string(val, &len);
+                       else if (g_strcmp0(key, "Size") == 0)
+                               agent_info.auth_info->file_size = g_variant_get_uint64(val);
+               }
+               g_variant_iter_free(iter);
+       }
+
+       __bt_get_remote_device_name_authinfo(bdaddress, &device_name, auth_info);
 
        if (!device_name)
                device_name = g_strdup(bdaddress);
 
+       agent_info.auth_info->address = g_strdup(bdaddress);
        agent_info.auth_info->device_name = device_name;
+       memcpy(agent_info.auth_info->contact_auth_info, auth_info, 5);
+
+       session_info = __bt_find_session_by_path((char *)path);
+       if (NULL == session_info) {
+               session_info = g_malloc0(sizeof(bt_session_info_t));
+               session_info->path = g_strdup(path);
+               session_info->address = g_strdup(bdaddress);
+               session_info->authorized = FALSE;
+               session_list = g_slist_append(session_list, session_info);
+       }
+
+       g_object_unref(transfer_properties_proxy);
+       g_free(bdaddress);
 
        if (agent_info.server_type == BT_CUSTOM_SERVER) {
                /* No need to send the event */
@@ -313,12 +626,19 @@ static gboolean __bt_authorize_cb(DBusGMethodInvocation *context,
                return TRUE;
        }
 
-       _bt_send_event(BT_OPP_SERVER_EVENT,
-               BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &agent_info.auth_info->filename,
-               DBUS_TYPE_UINT64, &agent_info.auth_info->file_size,
-               DBUS_TYPE_INVALID);
+       if (session_info->authorized == FALSE) {
+               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);
+               _bt_send_event(BT_OPP_SERVER_EVENT,
+                               BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE, param);
+       }
 
        return TRUE;
 }
@@ -327,9 +647,11 @@ void _bt_obex_transfer_started(const char *transfer_path)
 {
        bt_transfer_info_t *transfer_info;
        request_info_t *req_info;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *param = NULL;
+       GVariantBuilder *builder = NULL;
        int result = BLUETOOTH_ERROR_NONE;
+       int i = 0;
 
        BT_DBG("%s", transfer_path);
 
@@ -343,23 +665,23 @@ void _bt_obex_transfer_started(const char *transfer_path)
                transfer_info->path = g_strdup(agent_info.auth_info->transfer_path);
                transfer_info->device_name = g_strdup(agent_info.auth_info->device_name);
                transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
+               transfer_info->file_path = agent_info.auth_info->file_path;
+               transfer_info->address = g_strdup(agent_info.auth_info->address);
+
        } else {
                if (__bt_get_transfer_properties(transfer_info, transfer_path) < 0) {
                        BT_ERR("Get Properties failed");
-                       __bt_free_auth_info(agent_info.auth_info);
                        __bt_free_transfer_info(transfer_info);
-                       agent_info.auth_info = NULL;
                        return;
                }
                agent_info.server_type = BT_FTP_SERVER;
        }
 
-       __bt_free_auth_info(agent_info.auth_info);
-       agent_info.auth_info = NULL;
-
        if (agent_info.server_type == BT_CUSTOM_SERVER) {
                if (agent_info.custom_server == NULL) {
                        __bt_free_transfer_info(transfer_info);
+                       __bt_free_auth_info(agent_info.auth_info);
+                       agent_info.auth_info = NULL;
                        return;
                }
 
@@ -371,129 +693,252 @@ void _bt_obex_transfer_started(const char *transfer_path)
 
                agent_info.accept_id = 0;
                result = BLUETOOTH_ERROR_NONE;
+               GArray *g_out_param1 = NULL;
+               g_out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
+               if (out_param1 == NULL) {
+                       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                                       g_out_param1->data, g_out_param1->len,
+                                       TRUE, NULL, NULL);
+               }
 
-               out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-               out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-               g_array_append_vals(out_param2, &result, sizeof(int));
-
-               dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-               g_array_free(out_param1, TRUE);
-               g_array_free(out_param2, TRUE);
-
+               g_dbus_method_invocation_return_value(req_info->context,
+                               g_variant_new("(iv)", result, out_param1));
+               g_array_free(g_out_param1, TRUE);
                _bt_delete_request_list(req_info->req_id);
        }
 done:
        transfers = g_slist_append(transfers, transfer_info);
 
-       BT_DBG("Transfer id %d\n", transfer_info->transfer_id);
+       BT_DBG("Transfer id %d", transfer_info->transfer_id);
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+       for (i = 0; i < 5; i++) {
+               if (agent_info.auth_info)
+                       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->address,
+                               transfer_info->file_size,
+                               transfer_info->transfer_id,
+                               agent_info.server_type,
+                               builder);
+
+       __bt_free_auth_info(agent_info.auth_info);
+       agent_info.auth_info = NULL;
+
+       g_variant_builder_unref(builder);
 
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &transfer_info->filename,
-               DBUS_TYPE_STRING, &transfer_info->type,
-               DBUS_TYPE_UINT64, &transfer_info->file_size,
-               DBUS_TYPE_INT32, &transfer_info->transfer_id,
-               DBUS_TYPE_INT32, &agent_info.server_type,
-               DBUS_TYPE_INVALID);
+               param);
 }
 
 void _bt_obex_transfer_progress(const char *transfer_path,
-                                       int total,
-                                       int transferred)
+                                       guint64 transferred)
 {
+       BT_DBG("+");
        bt_transfer_info_t *transfer_info;
-       int progress = 0;
+       int current_progress = 0;
+       int previous_progress;
+       GVariant *param = NULL;
        int result = BLUETOOTH_ERROR_NONE;
 
        transfer_info = __bt_find_transfer_by_path(transfer_path);
        ret_if(transfer_info == NULL);
 
-       progress = (int)(((gdouble)transferred /(gdouble)total) * 100);
+       current_progress = (int)(((gdouble)transferred /
+                       (gdouble)transfer_info->file_size) * 100);
 
+       previous_progress = (int)(((gdouble)transfer_info->progress /
+                       (gdouble)transfer_info->file_size) * 100);
+
+       if (current_progress == previous_progress) {
+               BT_DBG("Same Percentage Value: Do not emit Signal");
+               return;
+       }
+
+       transfer_info->progress = transferred;
+       param = g_variant_new("(isssstiii)", result,
+                               transfer_info->filename,
+                               transfer_info->type,
+                               transfer_info->device_name,
+                               transfer_info->address,
+                               transfer_info->file_size,
+                               transfer_info->transfer_id,
+                               current_progress,
+                               agent_info.server_type);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &transfer_info->filename,
-               DBUS_TYPE_STRING, &transfer_info->type,
-               DBUS_TYPE_UINT64, &transfer_info->file_size,
-               DBUS_TYPE_INT32, &transfer_info->transfer_id,
-               DBUS_TYPE_INT32, &progress,
-               DBUS_TYPE_INT32, &agent_info.server_type,
-               DBUS_TYPE_INVALID);
+               param);
+       BT_DBG("-");
 }
 
 void _bt_obex_transfer_completed(const char *transfer_path, gboolean success)
 {
        bt_transfer_info_t *transfer_info;
+       GVariantBuilder *builder = NULL;
+       GVariant *param = NULL;
        int result;
+       int i = 0;
        BT_DBG("Transfer [%s] Success [%d] \n", transfer_path, success);
 
        result = (success == TRUE) ? BLUETOOTH_ERROR_NONE
                                : BLUETOOTH_ERROR_CANCEL;
 
        transfer_info = __bt_find_transfer_by_path(transfer_path);
-       ret_if(transfer_info == NULL);
 
+       if (transfer_info == NULL) {
+               BT_DBG("Very small files receiving case, did not get Active status from obexd");
+               if (agent_info.auth_info == NULL ||
+                               g_strcmp0(transfer_path,
+                               agent_info.auth_info->transfer_path) != 0) {
+                       BT_ERR("auth_info is NULL, returning");
+                       return;
+               }
+
+               transfer_info = g_new0(bt_transfer_info_t, 1);
+
+               transfer_info->filename = g_strdup(agent_info.auth_info->filename);
+               transfer_info->file_size = agent_info.auth_info->file_size;
+               transfer_info->type = g_strdup(TRANSFER_PUT);
+               transfer_info->path = g_strdup(agent_info.auth_info->transfer_path);
+               transfer_info->device_name = g_strdup(agent_info.auth_info->device_name);
+               transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
+               transfer_info->file_path = agent_info.auth_info->file_path;
+               transfer_info->address = g_strdup(agent_info.auth_info->address);
+
+               builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+               for (i = 0; i < 5; i++)
+                       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->address,
+                                       transfer_info->file_size,
+                                       transfer_info->transfer_id,
+                                       agent_info.server_type,
+                                       builder);
+               _bt_send_event(BT_OPP_SERVER_EVENT,
+                       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED,
+                       param);
+               g_variant_builder_unref(builder);
+       }
+       param = g_variant_new("(issssstii)", result,
+                               transfer_info->filename,
+                               transfer_info->type,
+                               transfer_info->device_name,
+                               transfer_info->file_path,
+                               transfer_info->address,
+                               transfer_info->file_size,
+                               transfer_info->transfer_id,
+                               agent_info.server_type);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &transfer_info->filename,
-               DBUS_TYPE_STRING, &transfer_info->type,
-               DBUS_TYPE_STRING, &transfer_info->device_name,
-               DBUS_TYPE_UINT64, &transfer_info->file_size,
-               DBUS_TYPE_INT32, &transfer_info->transfer_id,
-               DBUS_TYPE_INT32, &agent_info.server_type,
-               DBUS_TYPE_INVALID);
-
+               param);
        transfers = g_slist_remove(transfers, transfer_info);
        __bt_free_transfer_info(transfer_info);
 }
 
+void _bt_obex_transfer_connected(const char *obj_path)
+{
+       BT_DBG("+");
+
+       int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
+       bt_transfer_info_t *transfer_info = NULL;
+
+       transfer_info = g_new0(bt_transfer_info_t, 1);
+       __bt_get_transfer_properties(transfer_info, obj_path);
+       INFO_SECURE("Address[%s] Name[%s] TransferID[%d] ", transfer_info->address,
+                       transfer_info->device_name, transfer_info->transfer_id);
+
+       param = g_variant_new("(issi)", result, transfer_info->address,
+                       transfer_info->device_name, transfer_info->transfer_id);
+
+       _bt_send_event(BT_OPP_SERVER_EVENT,
+               BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED,
+               param);
+
+       __bt_free_transfer_info(transfer_info);
+       BT_DBG("-");
+}
+
+void _bt_obex_transfer_disconnected(char * obj_path)
+{
+       BT_DBG("+");
+
+       int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
+       bt_session_info_t *session = NULL;
+       int transfer_id = -1;
+
+       session = __bt_find_session_by_path(obj_path);
+       ret_if(session == NULL);
+
+       transfer_id = __bt_get_transfer_id(obj_path);
+       DBG_SECURE("transfer_id: [%d]", transfer_id);
+
+       DBG_SECURE("%s", session->address);
+       param = g_variant_new("(isi)", result, session->address, transfer_id);
+       _bt_send_event(BT_OPP_SERVER_EVENT,
+               BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED,
+               param);
+       session_list = g_slist_remove(session_list, session);
+       g_free(session->address);
+       g_free(session->path);
+       g_free(session);
+       BT_DBG("-");
+}
+
 int _bt_register_obex_server(void)
 {
-       DBusGConnection *g_conn;
-       DBusGProxy *manager_proxy;
+       GDBusConnection *g_conn;
+       GDBusProxy *manager_proxy;
+       GVariant *result = NULL;
        GError *g_error = NULL;
 
        /* Get the session bus. */
-       g_conn = _bt_get_session_gconn();
+       g_conn = _bt_gdbus_get_system_gconn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!agent_info.obex_agent) {
-               agent_info.obex_agent = _bt_obex_agent_new();
+       _bt_obex_agent_new(BT_OBEX_SERVER_AGENT_PATH);
 
-               retv_if(agent_info.obex_agent == NULL, BLUETOOTH_ERROR_INTERNAL);
+       _bt_obex_setup(BT_OBEX_SERVER_AGENT_PATH);
 
-               _bt_obex_setup(agent_info.obex_agent, BT_OBEX_SERVER_AGENT_PATH);
-
-               _bt_obex_set_authorize_cb(agent_info.obex_agent,
+       _bt_obex_set_authorize_cb(BT_OBEX_SERVER_AGENT_PATH,
                                        __bt_authorize_cb, NULL);
-       }
 
-       manager_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE,
-                                               "/", BT_OBEX_MANAGER);
+       manager_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_OBEX_SERVICE,
+                                               BT_OBEX_PATH,
+                                               BT_OBEX_MANAGER,
+                                               NULL, &g_error);
 
-       if (manager_proxy == NULL) {
-               g_object_unref(agent_info.obex_agent);
-               agent_info.obex_agent = NULL;
+       if (manager_proxy == NULL)
                return BLUETOOTH_ERROR_INTERNAL;
-       }
 
-       dbus_g_proxy_call(manager_proxy, "RegisterAgent", &g_error,
-                         DBUS_TYPE_G_OBJECT_PATH, BT_OBEX_SERVER_AGENT_PATH,
-                         G_TYPE_INVALID, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(manager_proxy, "RegisterAgent",
+                               g_variant_new("(o)", BT_OBEX_SERVER_AGENT_PATH),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &g_error);
+
        if (g_error != NULL) {
                BT_ERR("Agent registration failed: %s\n", g_error->message);
-               g_object_unref(agent_info.obex_agent);
-               agent_info.obex_agent = NULL;
                g_object_unref(manager_proxy);
                g_error_free(g_error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       if (result)
+               g_variant_unref(result);
+
        agent_info.proxy = manager_proxy;
 
        return BLUETOOTH_ERROR_NONE;
@@ -501,28 +946,29 @@ int _bt_register_obex_server(void)
 
 int _bt_unregister_obex_server(void)
 {
+       GVariant *result = NULL;
        GError *g_error = NULL;
 
-       retv_if(agent_info.obex_agent == NULL,
-                               BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST);
-
        retv_if(agent_info.proxy == NULL,
                                BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(agent_info.proxy, "UnregisterAgent", &g_error,
-                         DBUS_TYPE_G_OBJECT_PATH, BT_OBEX_SERVER_AGENT_PATH,
-                         G_TYPE_INVALID, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(agent_info.proxy, "UnregisterAgent",
+                               g_variant_new("(o)", BT_OBEX_SERVER_AGENT_PATH),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &g_error);
        if (g_error != NULL) {
                BT_ERR("Agent unregistration failed: %s", g_error->message);
                g_error_free(g_error);
        }
 
+       if (result)
+               g_variant_unref(result);
+
+       _bt_obex_agent_destroy(BT_OBEX_SERVER_AGENT_PATH);
        g_object_unref(agent_info.proxy);
        agent_info.proxy = NULL;
 
-       g_object_unref(agent_info.obex_agent);
-       agent_info.obex_agent = NULL;
-
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -530,7 +976,7 @@ gboolean __bt_check_folder_path(const char *dest_path)
 {
        DIR *dp;
 
-       retv_if(dest_path == NULL, TRUE);
+       retv_if(dest_path == NULL, FALSE);
 
        dp = opendir(dest_path);
 
@@ -544,35 +990,62 @@ gboolean __bt_check_folder_path(const char *dest_path)
        return TRUE;
 }
 
+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))
+               snprintf(dst_path, BT_OBEX_PATH_MAX_LENGTH, BT_OBEX_DEFAULT_PATH"%s", dest_path + strlen(BT_OBEX_PATH_PREFIX));
+       else
+               snprintf(dst_path, BT_OBEX_PATH_MAX_LENGTH, "%s", dest_path);
+
+       BT_INFO("obex transfed path : %s", dst_path);
+       return dst_path;
+}
+
 int _bt_obex_server_allocate(char *sender, const char *dest_path, int app_pid, gboolean is_native)
 {
-       if (__bt_check_folder_path(dest_path) == FALSE)
+       BT_DBG("+");
+
+       char *dst_path;
+       dst_path = __bt_transfer_folder_path((char *)dest_path);
+
+       if (__bt_check_folder_path(dst_path) == FALSE) {
+               g_free(dst_path);
                return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
 
        if (is_native == TRUE) {
-               retv_if(agent_info.native_server,
-                               BLUETOOTH_ERROR_DEVICE_BUSY);
+               if (agent_info.native_server) {
+                       BT_ERR("obex native server busy");
+                       g_free(dst_path);
+                       return BLUETOOTH_ERROR_DEVICE_BUSY;
+               }
 
                /* Force to change the control to native */
                agent_info.native_server = g_malloc0(sizeof(bt_server_info_t));
-               agent_info.native_server->dest_path = g_strdup(dest_path);
+               agent_info.native_server->dest_path = g_strdup(dst_path);
                agent_info.native_server->sender = g_strdup(sender);
                agent_info.native_server->app_pid = app_pid;
                agent_info.server_type = BT_NATIVE_SERVER;
                _bt_unregister_osp_server_in_agent(BT_OBEX_SERVER, NULL);
        } else {
-               retv_if(agent_info.custom_server,
-                               BLUETOOTH_ERROR_DEVICE_BUSY);
+               if (agent_info.custom_server) {
+                       BT_ERR("obex custom server busy");
+                       g_free(dst_path);
+                       return BLUETOOTH_ERROR_DEVICE_BUSY;
+               }
 
                /* Force to change the control to custom */
                agent_info.custom_server = g_malloc0(sizeof(bt_server_info_t));
-               agent_info.custom_server->dest_path = g_strdup(dest_path);
+               agent_info.custom_server->dest_path = g_strdup(dst_path);
                agent_info.custom_server->sender = g_strdup(sender);
                agent_info.custom_server->app_pid = app_pid;
                agent_info.server_type = BT_CUSTOM_SERVER;
-               _bt_register_osp_server_in_agent(BT_OBEX_SERVER, NULL);
+               _bt_register_osp_server_in_agent(BT_OBEX_SERVER, NULL, NULL, -1);
        }
 
+       g_free(dst_path);
+       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -592,7 +1065,7 @@ int _bt_obex_server_deallocate(int app_pid, gboolean is_native)
                if (agent_info.custom_server) {
                        agent_info.server_type = BT_CUSTOM_SERVER;
                        _bt_register_osp_server_in_agent(BT_OBEX_SERVER,
-                                                       NULL);
+                                                       NULL, NULL, -1);
                }
        } else {
                retv_if(agent_info.custom_server == NULL,
@@ -619,7 +1092,7 @@ int _bt_obex_server_accept_authorize(const char *filename, gboolean is_native)
        char file_path[BT_FILE_PATH_MAX] = { 0 };
        bt_server_info_t *server_info;
 
-       BT_CHECK_PARAMETER(filename);
+       BT_CHECK_PARAMETER(filename, return);
 
        retv_if(agent_info.auth_info == NULL, BLUETOOTH_ERROR_INTERNAL);
 
@@ -639,14 +1112,37 @@ int _bt_obex_server_accept_authorize(const char *filename, gboolean is_native)
        else
                snprintf(file_path, sizeof(file_path), "%s", filename);
 
-       dbus_g_method_return(agent_info.auth_info->reply_context,
-                               file_path);
-
+       g_dbus_method_invocation_return_value(agent_info.auth_info->reply_context,
+               g_variant_new("(s)", &file_path));
        agent_info.auth_info->reply_context = NULL;
+       agent_info.auth_info->file_path = g_strdup(file_path);
+       g_free(agent_info.auth_info->filename);
+       agent_info.auth_info->filename = g_strdup(filename);
 
        return BLUETOOTH_ERROR_NONE;
 }
 
+void _bt_obex_server_reply_accept(void)
+{
+       GVariant *param = NULL;
+       bt_session_info_t *session_info = NULL;
+       int result = BLUETOOTH_ERROR_NONE;
+       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);
+       BT_INFO("Send Obex Authorize");
+       _bt_send_event(BT_OPP_SERVER_EVENT, BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE, param);
+
+       session_info = __bt_find_session_by_path(agent_info.auth_info->transfer_path);
+
+       if (NULL == session_info)
+               BT_ERR("Couldn't get the session info from the list");
+       else
+               session_info->authorized = TRUE;
+}
+
 int _bt_obex_server_reject_authorize(void)
 {
        GError *g_error;
@@ -658,8 +1154,8 @@ int _bt_obex_server_reject_authorize(void)
                        BT_OBEX_AGENT_ERROR_CANCEL,
                        "CancelledByUser");
 
-       dbus_g_method_return_error(agent_info.auth_info->reply_context,
-                               g_error);
+       g_dbus_method_invocation_return_gerror(agent_info.auth_info->reply_context,
+                       g_error);
        g_error_free(g_error);
 
        __bt_free_auth_info(agent_info.auth_info);
@@ -671,15 +1167,19 @@ int _bt_obex_server_reject_authorize(void)
 int _bt_obex_server_set_destination_path(const char *dest_path,
                                                gboolean is_native)
 {
-       DIR *dp = NULL;
        bt_server_info_t *server_info;
+       BT_CHECK_PARAMETER(dest_path, return);
 
-       BT_CHECK_PARAMETER(dest_path);
+       char *dst_path;
+       dst_path = __bt_transfer_folder_path((char *)dest_path);
 
-       dp = opendir(dest_path);
+       DIR *dp = NULL;
+
+       dp = opendir(dst_path);
 
        if (dp == NULL) {
                BT_ERR("The directory does not exist");
+               g_free(dst_path);
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
@@ -690,70 +1190,96 @@ int _bt_obex_server_set_destination_path(const char *dest_path,
        else
                server_info = agent_info.custom_server;
 
-       retv_if(server_info == NULL,
-                       BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST);
+       if (!server_info) {
+               BT_ERR("obex server info is NULL");
+               g_free(dst_path);
+               return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
+       }
 
        g_free(server_info->dest_path);
-       server_info->dest_path = g_strdup(dest_path);
+       server_info->dest_path = g_strdup(dst_path);
 
+       g_free(dst_path);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_obex_server_set_root(const char *root)
 {
+       GVariant *result = NULL;
        GError *g_error = NULL;
-       GValue folder = { 0 };
+       GVariant *folder = NULL;
+       char *string = "Root";
        DIR *dp = NULL;
 
-       BT_CHECK_PARAMETER(root);
+       BT_CHECK_PARAMETER(root, return);
 
-       retv_if(agent_info.proxy == NULL,
-                               BLUETOOTH_ERROR_INTERNAL);
+       char *dst_root;
+       dst_root = __bt_transfer_folder_path((char *)root);
+
+       if (!agent_info.proxy) {
+               BT_ERR("obex agent_info proxy error");
+               g_free(dst_root);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       dp = opendir(root);
+       dp = opendir(dst_root);
 
        if (dp == NULL) {
                BT_ERR("The directory does not exist");
+               g_free(dst_root);
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
        closedir(dp);
 
-       g_value_init(&folder, G_TYPE_STRING);
-       g_value_set_string(&folder, root);
-
-       dbus_g_proxy_call(agent_info.proxy, "SetProperty",
-                       &g_error, G_TYPE_STRING, "Root",
-                       G_TYPE_VALUE, &folder, G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_value_unset(&folder);
+       folder = g_variant_new_string(dst_root);
+       result = g_dbus_proxy_call_sync(agent_info.proxy, "SetProperty",
+                       g_variant_new("(sv)", string, folder),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &g_error);
 
        if (g_error) {
                BT_ERR("SetProperty Fail: %s", g_error->message);
                g_error_free(g_error);
+               g_free(dst_root);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       if (result)
+               g_variant_unref(result);
+
+       g_free(dst_root);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_obex_server_cancel_transfer(int transfer_id)
 {
        bt_transfer_info_t *transfer = NULL;
-       DBusGProxy *proxy;
-
+       GDBusProxy *proxy;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       BT_DBG("+");
        transfer = __bt_find_transfer_by_id(transfer_id);
-       retv_if(transfer == NULL, BLUETOOTH_ERROR_NOT_FOUND);
 
+       retv_if(transfer == NULL, BLUETOOTH_ERROR_NOT_FOUND);
        proxy = __bt_get_transfer_proxy(transfer->path);
 
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call_no_reply(proxy, "Cancel",
-                               G_TYPE_INVALID, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(proxy, "Cancel", NULL,
+               G_DBUS_CALL_FLAGS_NONE,
+               DBUS_TIMEOUT, NULL, &err);
+       if (err) {
+               BT_ERR("Dbus Err: %s", err->message);
+               g_clear_error(&err);
+       }
 
        g_object_unref(proxy);
 
+       if (result)
+               g_variant_unref(result);
+
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -776,33 +1302,31 @@ int _bt_obex_server_cancel_all_transfers(void)
 
 int _bt_obex_server_is_activated(gboolean *activated)
 {
-       BT_CHECK_PARAMETER(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;
 }
 
 int _bt_obex_server_check_allocation(gboolean *allocation)
 {
-       BT_CHECK_PARAMETER(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;
 }
 
 int _bt_obex_server_check_termination(char *sender)
 {
-       BT_CHECK_PARAMETER(sender);
+       BT_CHECK_PARAMETER(sender, return);
 
        if (agent_info.native_server) {
                if (g_strcmp0(sender, agent_info.native_server->sender) == 0) {
@@ -821,11 +1345,22 @@ int _bt_obex_server_check_termination(char *sender)
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_obex_server_is_receiving(gboolean *receiving)
+{
+       BT_CHECK_PARAMETER(receiving, return);
+
+       if (transfers == NULL || g_slist_length(transfers) == 0)
+               *receiving = FALSE;
+       else
+               *receiving = TRUE;
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
 gboolean __bt_obex_server_accept_timeout_cb(gpointer user_data)
 {
        request_info_t *req_info;
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1 = NULL;
        int result = BLUETOOTH_ERROR_TIMEOUT;
 
        /* Already reply in _bt_obex_transfer_started */
@@ -838,17 +1373,17 @@ gboolean __bt_obex_server_accept_timeout_cb(gpointer user_data)
        }
 
        agent_info.accept_id = 0;
+       GArray *g_out_param1 = NULL;
+       g_out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
+       if (out_param1 == NULL) {
+               out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                               g_out_param1->data, g_out_param1->len,
+                               TRUE, NULL, NULL);
+       }
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
+       g_array_free(g_out_param1, TRUE);
        _bt_delete_request_list(req_info->req_id);
 
        return FALSE;
@@ -878,3 +1413,18 @@ int _bt_obex_server_reject_connection(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_opp_get_server_progress(int transfer_id, guint8 *progress)
+{
+       bt_transfer_info_t *requested_transfer = NULL;
+       requested_transfer = __bt_find_transfer_by_id(transfer_id);
+       if (requested_transfer == NULL) {
+               BT_ERR("No Matching Inbound transfer");
+               return BLUETOOTH_ERROR_NOT_FOUND;
+       }
+
+       *progress = (int)(((double)requested_transfer->progress /
+                       requested_transfer->file_size) * 100);
+
+       BT_DBG("Percentage: %d", *progress);
+       return BLUETOOTH_ERROR_NONE;
+}