Debug message cleanup
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-request-sender.c
old mode 100755 (executable)
new mode 100644 (file)
index 202bdf0..2a00c51
@@ -1,11 +1,5 @@
 /*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
+ * 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.
@@ -36,9 +30,6 @@
 #include "bt-event-handler.h"
 #include "bluetooth-media-control.h"
 
-/* auto generated header by bt-request-service.xml*/
-#include "bt-request-service.h"
-
 static GSList *sending_requests;
 
 static GDBusProxy *service_gproxy;
@@ -49,8 +40,6 @@ static GDBusProxy *__bt_gdbus_init_service_proxy(void)
        GDBusProxy *proxy;
        GError *err = NULL;
 
-       g_type_init();
-
        service_gconn = _bt_gdbus_get_system_gconn();
 
        if (!service_gconn)
@@ -94,7 +83,9 @@ static void __bt_get_event_info(int service_function, GArray *output,
 {
        ret_if(event == NULL);
 
-       BT_DBG("service_function : %x", service_function);
+       BT_DBG("service_function : %s (0x%x)",
+               _bt_convert_service_function_to_string(service_function),
+               service_function);
        switch (service_function) {
        case BT_BOND_DEVICE:
        case BT_BOND_DEVICE_BY_TYPE:
@@ -167,8 +158,8 @@ static void __bt_get_event_info(int service_function, GArray *output,
        case BT_AV_SOURCE_DISCONNECT:
                *event_type = BT_A2DP_SOURCE_EVENT;
                *event = BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED;
-               ret_if (output == NULL);
-               *param_data = &g_array_index (output, char, 0);
+               ret_if(output == NULL);
+               *param_data = &g_array_index(output, char, 0);
                break;
        case BT_HF_CONNECT:
                *event_type = BT_HF_AGENT_EVENT;
@@ -215,6 +206,13 @@ static void __bt_get_event_info(int service_function, GArray *output,
                ret_if(output == NULL);
                *param_data = &g_array_index(output, char, 0);
                break;
+       case BT_REQ_ATT_MTU:
+               *event_type = BT_DEVICE_EVENT;
+               *event = BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED;
+               ret_if(output == NULL);
+               *param_data = &g_array_index(output,
+                               bluetooth_device_address_t, 0);
+               break;
        case BT_CONNECT_LE:
                *event_type = BT_DEVICE_EVENT;
                *event = BLUETOOTH_EVENT_GATT_CONNECTED;
@@ -229,6 +227,27 @@ static void __bt_get_event_info(int service_function, GArray *output,
                *param_data = &g_array_index(output,
                                bluetooth_device_address_t, 0);
                break;
+       case BT_TDS_READ_TRANSPORT_DATA:
+               *event_type = BT_TDS_EVENT;
+               *event = BLUETOOTH_EVENT_TDS_TRANSPORT_DATA_RECEIVED;
+               ret_if(output == NULL);
+               *param_data = &g_array_index(output,
+                       bluetooth_device_address_t, 0);
+               break;
+       case BT_TDS_ENABLE_CONTROL_POINT:
+               *event_type = BT_TDS_EVENT;
+               *event = BLUETOOTH_EVENT_TDS_CONTROL_POINT_ENABLED;
+               ret_if(output == NULL);
+               *param_data = &g_array_index(output,
+                       bluetooth_device_address_t, 0);
+               break;
+       case BT_TDS_ACTIVATE_CONTROL_POINT:
+               *event_type = BT_TDS_EVENT;
+               *event = BLUETOOTH_EVENT_TDS_ACTIVATION_INDICATION;
+               ret_if(output == NULL);
+               *param_data = &g_array_index(output,
+                       bluetooth_device_address_t, 0);
+               break;
        default:
                BT_ERR("Unknown function");
                return;
@@ -255,8 +274,8 @@ static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
 }
 
 static void __send_request_cb(GDBusProxy *proxy,
-                     GAsyncResult *res,
-                     gpointer      user_data)
+                               GAsyncResult *res,
+                               gpointer user_data)
 {
        bluetooth_event_param_t bt_event;
        bt_req_info_t *cb_data = user_data;
@@ -314,16 +333,36 @@ static void __send_request_cb(GDBusProxy *proxy,
                                &bt_event.event, &event_type,
                                &bt_event.param_data);
 
+               BT_DBG("service_function [%d]", cb_data->service_function);
                if (result == BLUETOOTH_ERROR_NONE && out_param1) {
                        if (cb_data->service_function == BT_OPP_PUSH_FILES) {
                                request_id = g_array_index(out_param1, int, 0);
                                BT_DBG("request_id : %d", request_id);
                                _bt_add_push_request_id(request_id);
+                       } else if (cb_data->service_function == BT_MAP_LIST_FOLDERS) {
+                               request_id = g_array_index(out_param1, int, 0);
+                               BT_DBG("request_id : %d", request_id);
+                               _bt_add_push_request_id(request_id);
+                       } else if (cb_data->service_function == BT_MAP_LIST_FILTER_FIELDS) {
+                               request_id = g_array_index(out_param1, int, 0);
+                               BT_DBG("request_id : %d", request_id);
+                               _bt_add_push_request_id(request_id);
+                       } else if (cb_data->service_function == BT_MAP_LIST_MESSAGES) {
+                               request_id = g_array_index(out_param1, int, 0);
+                               BT_DBG("request_id : %d", request_id);
+                               _bt_add_push_request_id(request_id);
+                       } else if (cb_data->service_function == BT_MAP_GET_MESSAGE) {
+                               request_id = g_array_index(out_param1, int, 0);
+                               BT_DBG("request_id : %d", request_id);
+                               _bt_add_push_request_id(request_id);
+                       } else if (cb_data->service_function == BT_MAP_PUSH_MESSAGE) {
+                               request_id = g_array_index(out_param1, int, 0);
+                               BT_DBG("request_id : %d", request_id);
+                               _bt_add_push_request_id(request_id);
                        }
 
                        goto done;
                }
-
        }
 
        if (cb_data->cb == NULL)
@@ -331,7 +370,8 @@ static void __send_request_cb(GDBusProxy *proxy,
 
        /* Only if fail case, call the callback function*/
        bt_event.result = result;
-       BT_INFO("event_type[%d], result=[%d]", event_type, result);
+       BT_INFO("event_type[%d], result= %s [0x%x]", event_type,
+               _bt_convert_error_to_string(result), result);
 
        if (event_type == BT_ADAPTER_EVENT || event_type == BT_RFCOMM_CLIENT_EVENT) {
                ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
@@ -361,6 +401,10 @@ static void __send_request_cb(GDBusProxy *proxy,
                ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
                                &bt_event,
                                cb_data->user_data);
+       } else if (event_type == BT_TDS_EVENT) {
+               ((bluetooth_cb_func_ptr)cb_data->cb)(bt_event.event,
+                               &bt_event,
+                               cb_data->user_data);
        } else {
                BT_INFO("Not handled event type : %d", event_type);
        }
@@ -418,7 +462,7 @@ int _bt_sync_send_request(int service_type, int service_function,
                                        in_param4->data, in_param4->len,
                                        TRUE, NULL, NULL);
                param5 = g_variant_new_from_data((const GVariantType *)"ay",
-                                       in_param5->data,        in_param5->len,
+                                       in_param5->data, in_param5->len,
                                        TRUE, NULL, NULL);
 
                ret = g_dbus_proxy_call_sync(proxy, "service_request",
@@ -497,7 +541,9 @@ int _bt_async_send_request(int service_type, int service_function,
        GVariant *param4;
        GVariant *param5;
 
-       BT_DBG("service_function : %x", service_function);
+       BT_DBG("service_function : %s (0x%x)",
+                       _bt_convert_service_function_to_string(service_function),
+                       service_function);
 
        cb_data = g_new0(bt_req_info_t, 1);
 
@@ -554,6 +600,9 @@ int _bt_async_send_request(int service_type, int service_function,
 
                g_array_free(in_param5, TRUE);
                break;
+       default:
+               g_free(cb_data);
+               break;
        }
 
        return BLUETOOTH_ERROR_NONE;