Merge branch 'tizen' into tizen_5.5
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / include / bt-service-common.h
index a5fec2a..27953b6 100644 (file)
@@ -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.
@@ -54,12 +48,22 @@ extern "C" {
 #define LOG_COLOR_BLUE          "\033[36m"
 #define LOG_COLOR_PURPLE   "\033[35m"
 
+
+#ifndef TIZEN_TV
+#define BT_DBG(fmt, args...) \
+       SLOGD(fmt, ##args)
+#define BT_INFO(fmt, args...) \
+       SLOGI(fmt, ##args)
+#define BT_ERR(fmt, args...) \
+       SLOGE(fmt, ##args)
+#else
 #define BT_DBG(fmt, args...) \
-        SLOGD(fmt, ##args)
+       LOGI(fmt, ##args)
 #define BT_INFO(fmt, args...) \
-        SLOGI(fmt, ##args)
+       LOGI(fmt, ##args)
 #define BT_ERR(fmt, args...) \
-        SLOGE(fmt, ##args)
+       LOGE(fmt, ##args)
+#endif
 
 #define BT_INFO_C(fmt, arg...) \
        SLOGI_IF(TRUE,  LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg)
@@ -67,6 +71,7 @@ extern "C" {
        SLOGI_IF(TRUE,  LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg)
 
 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
+#define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args)
 #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
 
 #define ret_if(expr) \
@@ -87,8 +92,7 @@ extern "C" {
 
 #define BT_CHECK_PARAMETER(arg, func) \
        do { \
-               if (arg == NULL) \
-               { \
+               if (arg == NULL) { \
                        BT_ERR("%s is NULL", #arg); \
                        func BLUETOOTH_ERROR_INVALID_PARAM; \
                } \
@@ -111,6 +115,8 @@ extern "C" {
 #endif
 #define BT_DISCOVERY_FINISHED_DELAY 200
 
+#define BT_SESSION_BUS_GET_TIMEOUT 200 /* 200 ms */
+
 #define MANAGER_EVENT_MATCH_RULE \
                        "type='signal'," \
                        "interface='%s'," \
@@ -128,6 +134,8 @@ extern "C" {
                        "the reply timeout expired, or the network connection " \
                        "was broken."
 
+#define BT_DBUS_TIMEOUT_MESSAGE "Timeout was reached"
+
 #define BT_BLUEZ_NAME "org.bluez"
 
 #define BT_BLUEZ_PATH "/org/bluez"
@@ -167,10 +175,11 @@ extern "C" {
 #define BT_OBEXD_MANAGER_INTERFACE "org.openobex.Manager"
 #define BT_OBEXD_TRANSFER_INTERFACE "org.openobex.Transfer"
 #define BT_A2DP_SOURCE_INTERFACE "org.bluez.AudioSource"
+#define BT_PROXIMITY_MONITOR_INTERFACE "org.bluez.ProximityMonitor1"
+#define BT_PROXIMITY_REPORTER_INTERFACE "org.bluez.ProximityReporter1"
 
 #define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
 
-
 #define BT_OBEX_SERVICE_NAME "org.bluez.obex"
 #define BT_OBEX_CLIENT_PATH "/org/bluez/obex"
 #define BT_OBEX_CLIENT_INTERFACE "org.bluez.obex.Client1"
@@ -190,6 +199,24 @@ extern "C" {
 #define BT_FREEDESKTOP_PATH "/org/freedesktop/DBus"
 
 
+#define BT_DUMP_SERVICE_NAME "org.tizen.system.dumpservice"
+#define BT_DUMP_SERVICE_PATH "/Org/Tizen/System/DumpService"
+#define BT_DUMP_SERVICE_INTERFACE BT_DUMP_SERVICE_NAME
+
+#define BT_DUMP_SERVICE_SIGNAL "Dump"
+#define BT_DUMP_SERVICE_START_SIGNAL "Start"
+#define BT_DUMP_SERVICE_FINISH_SIGNAL "Finish"
+
+
+#define BT_DEVICED_POWEROFF_INTERFACE "org.tizen.system.deviced.PowerOff"
+#define BT_DEVICED_POWEROFF_OBJECT_PATH "/Org/Tizen/System/DeviceD/PowerOff"
+
+#define BT_DEVICED_POWEROFF_SIGNAL "ChangeState"
+#define BT_DEVICED_POWEROFF_SIGNAL_POWEROFF_POPUP (1)
+#define BT_DEVICED_POWEROFF_SIGNAL_POWEROFF (2)
+#define BT_DEVICED_POWEROFF_SIGNAL_REBOOT (3)
+
+
 #define BT_INTERFACES_ADDED "InterfacesAdded"
 #define BT_INTERFACES_REMOVED "InterfacesRemoved"
 #define BT_NAME_OWNER_CHANGED "NameOwnerChanged"
@@ -205,33 +232,35 @@ extern "C" {
 /* UUID */
 #define GENERIC_AUDIO_UUID      "00001203-0000-1000-8000-00805f9b34fb"
 
-#define OBEX_OPP_UUID          "00001105-0000-1000-8000-00805f9b34fb"
-
-#define HSP_HS_UUID             "00001108-0000-1000-8000-00805f9b34fb"
-#define HSP_AG_UUID             "00001112-0000-1000-8000-00805f9b34fb"
+#define AVRCP_TARGET_UUID       "0000110c-0000-1000-8000-00805f9b34fb"
+#define AVRCP_REMOTE_UUID       "0000110e-0000-1000-8000-00805f9b34fb"
+#define ADVANCED_AUDIO_UUID     "0000110d-0000-1000-8000-00805f9b34fb"
+#define A2DP_SINK_UUID          "0000110b-0000-1000-8000-00805f9b34fb"
+#define A2DP_SOURCE_UUID        "0000110a-0000-1000-8000-00805f9b34fb"
 
 #define HFP_HS_UUID             "0000111e-0000-1000-8000-00805f9b34fb"
 #define HFP_AG_UUID             "0000111f-0000-1000-8000-00805f9b34fb"
 
-#define ADVANCED_AUDIO_UUID     "0000110d-0000-1000-8000-00805f9b34fb"
-
-#define A2DP_SOURCE_UUID        "0000110a-0000-1000-8000-00805f9b34fb"
-#define A2DP_SINK_UUID          "0000110b-0000-1000-8000-00805f9b34fb"
-
-#define AVRCP_REMOTE_UUID       "0000110e-0000-1000-8000-00805f9b34fb"
-#define AVRCP_TARGET_UUID       "0000110c-0000-1000-8000-00805f9b34fb"
+#define HSP_HS_UUID             "00001108-0000-1000-8000-00805f9b34fb"
+#define HSP_AG_UUID             "00001112-0000-1000-8000-00805f9b34fb"
 
+#define RFCOMM_UUID_STR                        "00000003-0000-1000-8000-00805f9b34fb"
+#define HID_DEVICE_UUID                        "00001124-0000-1000-8000-00805f9b43bf"
 #define HID_UUID                "00001124-0000-1000-8000-00805f9b34fb"
+#define PANU_UUID                              "00001115-0000-1000-8000-00805f9b34fb"
+#define NAP_UUID                               "00001116-0000-1000-8000-00805f9b34fb"
 #define PNP_UUID                "00001200-0000-1000-8000-00805f9b34fb"
-#define RFCOMM_UUID_STR                "00000003-0000-1000-8000-00805f9b34fb"
-#define PANU_UUID              "00001115-0000-1000-8000-00805f9b34fb"
-#define NAP_UUID               "00001116-0000-1000-8000-00805f9b34fb"
-#define OBEX_PSE_UUID          "0000112f-0000-1000-8000-00805f9b34fb"
-#define GATT_UUID              "00001801-0000-1000-8000-00805f9b34fb"
+#define PBAP_UUID               "0000112f-0000-1000-8000-00805f9b34fb"
+
+#define OBEX_OPP_UUID                  "00001105-0000-1000-8000-00805f9b34fb"
+#define OBEX_PSE_UUID                  "0000112f-0000-1000-8000-00805f9b34fb"
+
+#define GATT_UUID                              "00001801-0000-1000-8000-00805f9b34fb"
 
 /* Privilege */
 #define BT_PRIVILEGE_PUBLIC "http://tizen.org/privilege/bluetooth"
 #define BT_PRIVILEGE_PLATFORM "http://tizen.org/privilege/bluetooth.admin"
+#define MEDIASTORAGE_PRIVILEGE "http://tizen.org/privilege/mediastorage"
 
 /* BD Address type */
 #define BDADDR_BREDR           0x00
@@ -260,16 +289,17 @@ typedef enum {
 } bt_le_device_info_type_t;
 
 typedef enum {
-       BT_PROFILE_CONN_RFCOMM= 0x01,
-       BT_PROFILE_CONN_A2DP= 0x02,
-       BT_PROFILE_CONN_HSP= 0x04,
-       BT_PROFILE_CONN_HID= 0x08,
-       BT_PROFILE_CONN_NAP= 0x10,
-       BT_PROFILE_CONN_HFG= 0x20,
-       BT_PROFILE_CONN_GATT= 0x40,
+       BT_PROFILE_CONN_RFCOMM = 0x01,
+       BT_PROFILE_CONN_A2DP = 0x02,
+       BT_PROFILE_CONN_HSP = 0x04,
+       BT_PROFILE_CONN_HID = 0x08,
+       BT_PROFILE_CONN_NAP = 0x10,
+       BT_PROFILE_CONN_HFG = 0x20,
+       BT_PROFILE_CONN_GATT = 0x40,
        BT_PROGILE_CONN_NAP = 0x80,
-       BT_PROFILE_CONN_A2DP_SINK= 0x100,
-       BT_PROFILE_CONN_ALL= 0xffffffff,
+       BT_PROFILE_CONN_A2DP_SINK = 0x100,
+       BT_PROFILE_CONN_PBAP = 0x200,
+       BT_PROFILE_CONN_ALL = 0xffffffff,
 } bt_profile_type_t;
 
 typedef struct {
@@ -283,6 +313,19 @@ typedef struct {
 } bt_remote_le_dev_info_t;
 
 typedef struct {
+       char *address;
+       int addr_type;
+       int rssi;
+       int adv_type;
+       int company_id;
+       int ibeacon_type;
+       int major_id;
+       int minor_id;
+       int measured_power;
+       char *uuid;
+} bt_remote_ibeacon_dev_info_t;
+
+typedef struct {
        int rssi;
        int class;
        char *address;
@@ -292,6 +335,7 @@ typedef struct {
        gboolean paired;
        bluetooth_connected_link_t connected;
        gboolean trust;
+       gboolean is_alias_set;
        char *manufacturer_data;
        int manufacturer_data_len;
        guchar addr_type;
@@ -315,11 +359,9 @@ typedef struct {
        char *address;
 } bt_function_data_t;
 
-GDBusConnection *_bt_get_system_conn(void);
+GDBusConnection *_bt_gdbus_get_system_gconn(void);
 
-GDBusConnection *_bt_get_system_gconn(void);
-
-GDBusConnection *_bt_get_session_gconn(void);
+GDBusConnection *_bt_gdbus_get_session_gconn(void);
 
 void *_bt_get_net_conn(void);
 
@@ -333,9 +375,15 @@ char *_bt_get_device_object_path(char *address);
 
 char *_bt_get_profile_uuid128(bt_profile_type_t profile_type);
 
-char *_bt_convert_error_to_string(int error);
+const char *_bt_convert_uuid_to_string(const char *uuid);
+
+const char *_bt_convert_error_to_string(int error);
 
-char * _bt_convert_disc_reason_to_string(int reason);
+const char *_bt_convert_disc_reason_to_string(int reason);
+
+const char *_bt_convert_profile_state_to_string(bt_profile_state_t state);
+
+const char *_bt_convert_service_function_to_string(int function);
 
 void _bt_logging_connection(gboolean connect, int addr_type);
 
@@ -349,6 +397,9 @@ void _bt_convert_device_path_to_address(const char *device_path,
 void _bt_convert_addr_string_to_type(unsigned char *addr,
                                        const char *address);
 
+void _bt_convert_addr_string_to_secure_string(char *addr,
+                                       const char *address);
+
 void _bt_convert_addr_type_to_string(char *address,
                                unsigned char *addr);
 
@@ -381,9 +432,13 @@ int _bt_set_socket_non_blocking(int socket_fd);
 int _bt_set_non_blocking_tty(int sk);
 
 void _bt_deinit_bluez_proxy(void);
-#if 0
+
 int _bt_eventsystem_set_value(const char *event, const char *key, const char *value);
-#endif
+
+void __bt_get_auth_info(GVariant *reply,  char *auth_info);
+
+int _bt_convert_gerror(GError *g_error);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */