Seperate GATT unregister instance function
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-opp-client.c
index d749aea..3e83f72 100644 (file)
@@ -18,6 +18,8 @@
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
+#include <mime_type.h>
+#include <aul.h>
 #include <glib.h>
 #include <gio/gio.h>
 
@@ -267,7 +269,7 @@ gboolean _bt_obex_client_started(const char *transfer_path)
        }
 
        /* Get the session bus. */
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_gdbus_get_session_gconn();
        retv_if(g_conn == NULL, FALSE);
        properties_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
                                                NULL, BT_OBEXD_DBUS_NAME,
@@ -405,7 +407,7 @@ static int _bt_remove_session()
        GDBusProxy *session_proxy;
        GError *err = NULL;
 
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_gdbus_get_session_gconn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
        retv_if(sending_info->session_path == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
 
@@ -573,13 +575,13 @@ void _bt_sending_files(void)
        GError *err = NULL;
        GDBusConnection *g_conn;
        GDBusProxy *client_proxy;
-       char *mime_type = NULL;
+       char mime_type[BT_MIME_TYPE_MAX_LEN + 1] = { 0 };
 
        if (sending_info == NULL)
                return;
        if (file_offset < sending_info->file_count) {
                /* Get the session bus. */
-               g_conn = _bt_gdbus_get_system_gconn();
+               g_conn = _bt_gdbus_get_session_gconn();
                ret_if(g_conn == NULL);
 
                client_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
@@ -588,9 +590,8 @@ void _bt_sending_files(void)
                                                BT_OBEX_OBJECT_PUSH_INTERFACE,
                                                NULL, &err);
                ret_if(client_proxy == NULL);
-               if (headed_plugin_info->plugin_headed_enabled) {
-                       if (headed_plugin_info->headed_plugin->bt_get_mime_type(sending_info->file_name_array[file_offset],
-                                       &mime_type) == BLUETOOTH_ERROR_NONE) {
+               if (aul_get_mime_from_file(sending_info->file_name_array[file_offset],
+                               mime_type, BT_MIME_TYPE_MAX_LEN) == AUL_R_OK) {
                                BT_DBG("MLME type = %s", mime_type);
 
                                /* For IOPT compliance, change "text/x-iMelody" to "audio/imelody"
@@ -604,7 +605,6 @@ void _bt_sending_files(void)
                                        strncpy(mime_type, "text/x-vcard", BT_MIME_TYPE_MAX_LEN);
                                        BT_DBG("over writing mime type to  = %s", mime_type);
                                }
-                       }
                }
 
                BT_DBG("Calling SendFile");
@@ -618,7 +618,6 @@ void _bt_sending_files(void)
                if (err != NULL) {
                        BT_ERR("Calling SendFile failed: [%s]\n", err->message);
                        g_clear_error(&err);
-                       g_free(mime_type);
                        return;
                }
 
@@ -627,7 +626,6 @@ void _bt_sending_files(void)
                __bt_sending_release();
        }
 
-       g_free(mime_type);
        BT_DBG("-");
 }
 
@@ -720,7 +718,7 @@ static int __bt_opp_client_start_sending(int request_id, char *address,
        BT_CHECK_PARAMETER(file_name_array, return);
 
        /* Get the session bus. */
-       g_conn = _bt_gdbus_get_system_gconn();
+       g_conn = _bt_gdbus_get_session_gconn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        client_proxy =  g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
@@ -814,6 +812,9 @@ int _bt_opp_client_push_files(int request_id, GDBusMethodInvocation *context,
        } else {
                /* Insert data in the queue */
                data = g_malloc0(sizeof(bt_sending_data_t));
+               if (data == NULL)
+                       return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+
                data->file_path = g_new0(char *, file_count + 1);
                data->address = g_strdup(address);
                data->file_count = file_count;