From: DoHyun Pyun Date: Fri, 24 Aug 2012 07:12:28 +0000 (+0900) Subject: Re-merge the codes X-Git-Tag: 2.0_alpha~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b81f3fd18273d9c1ff056d82ec54aea8744f342;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Re-merge the codes [Comment] There was some missed codes in previous patchset --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fca953f6..39b2ba64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) # API library ADD_SUBDIRECTORY(lib) +# Bluetooth Telephony API library +ADD_SUBDIRECTORY(bluetooth-telephony) + +# API library +ADD_SUBDIRECTORY(bluetooth-media-control) + # Bluetooth FW Agent ADD_SUBDIRECTORY(bluetooth-frwk-agent) @@ -11,3 +17,6 @@ ADD_SUBDIRECTORY(bluetooth-pb-agent) # Message FW Agent ADD_SUBDIRECTORY(bluetooth-map-agent) + +# Bluetooth HFP Agent +ADD_SUBDIRECTORY(bluetooth-hfp-agent) diff --git a/bluetooth-frwk-agent/CMakeLists.txt b/bluetooth-frwk-agent/CMakeLists.txt index 4fc9b046..330be5e7 100644 --- a/bluetooth-frwk-agent/CMakeLists.txt +++ b/bluetooth-frwk-agent/CMakeLists.txt @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-agent C) SET(SRCS bluetooth-agent.c bluetooth-agent-cb.c marshal.c sc_core_agent.c) -SET(APP_VENDOR samsung) +SET(APP_VENDOR tizen) SET(APP_NAME bluetooth-agent) SET(APP_DIR /usr/bin) SET(APP_LOCALEDIR /usr/share/locale) @@ -15,7 +15,8 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED vconf aul syspopup-caller contacts-service dbus-glib-1 msg-service email-service) +pkg_check_modules(pkgs REQUIRED vconf aul syspopup-caller contacts-service dbus-glib-1 msg-service +email-service) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/bluetooth-frwk-agent/bluetooth-agent-cb.c b/bluetooth-frwk-agent/bluetooth-agent-cb.c index 5e60a195..192aea59 100644 --- a/bluetooth-frwk-agent/bluetooth-agent-cb.c +++ b/bluetooth-frwk-agent/bluetooth-agent-cb.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "bluetooth-agent.h" #include "sc_core_agent.h" @@ -38,6 +39,17 @@ extern struct bt_agent_appdata *app_data; #define HFP_AUDIO_GATEWAY_UUID "0000111f-0000-1000-8000-00805f9b34fb" #define A2DP_UUID "0000110D-0000-1000-8000-00805F9B34FB" +#define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb" +#define FTP_UUID "00001106-0000-1000-8000-00805f9b34fb" +#define SPP_UUID "00001101-0000-1000-8000-00805f9b34fb" + +#define BT_MEMORY_OBEX_NO_AGENT "memory/private/libbluetooth-frwk-0/obex_no_agent" +#define BT_MEMORY_RFCOMM_UUID "memory/private/libbluetooth-frwk-0/uuid" + +#define BT_AGENT_OBJECT "/org/projectx/bt_agent" +#define BT_AGENT_INTERFACE "User.Bluetooth.agent" +#define BT_AGENT_SIGNAL_AUTHORIZE "Authorize" +#define BT_AGENT_SIGNAL_OBEX_AUTHORIZE "ObexAuthorize" #define BT_PIN_MAX_LENGTH 16 #define BT_PASSKEY_MAX_LENGTH 6 @@ -87,14 +99,13 @@ static gboolean __bt_agent_system_popup_timer_cb(gpointer user_data) } ret = syspopup_launch("bt-syspopup", b); - if (0 > ret) { + if (0 > ret) DBG("Sorry Can not launch popup\n"); - return TRUE; - } else { + else DBG("Hurray Popup launched \n"); - bundle_free(b); - return FALSE; - } + + bundle_free(b); + return FALSE; } int _bt_agent_launch_system_popup(bt_agent_event_type_t event_type, const char *device_name, @@ -149,8 +160,11 @@ int _bt_agent_launch_system_popup(bt_agent_event_type_t event_type, const char * strncpy(event_str, "terminate", BT_MAX_EVENT_STR_LENGTH); break; - default: + case BT_AGENT_EVENT_EXCHANGE_REQUEST: + strncpy(event_str, "exchange-request", BT_MAX_EVENT_STR_LENGTH); + break; + default: break; } @@ -175,7 +189,8 @@ static gboolean __pincode_request(DBusGProxy *device) uint32_t device_class; GHashTable *hash = NULL; GValue *value; - const gchar *address, *name; + const gchar *address = NULL; + const gchar *name = NULL; GError *error = NULL; DBG("+\n"); @@ -204,6 +219,9 @@ static gboolean __pincode_request(DBusGProxy *device) __bt_agent_generate_passkey(str_passkey, sizeof(str_passkey)); + sc_core_agent_reply_pin_code(_sc_core_agent_get_proxy(), + SC_CORE_AGENT_ACCEPT, str_passkey, NULL); + if (name) _bt_agent_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, (const char *)name, str_passkey, NULL); @@ -243,9 +261,11 @@ static gboolean __pincode_request(DBusGProxy *device) static gboolean __passkey_request(DBusGProxy *device) { + uint32_t device_class; GHashTable *hash = NULL; GValue *value; - const gchar *address, *name; + const gchar *address = NULL; + const gchar *name = NULL; GError *error = NULL; DBG("+\n"); @@ -256,6 +276,9 @@ static gboolean __passkey_request(DBusGProxy *device) &hash, G_TYPE_INVALID); if (hash != NULL) { + value = g_hash_table_lookup(hash, "Class"); + device_class = value ? g_value_get_uint(value) : 0; + value = g_hash_table_lookup(hash, "Address"); address = value ? g_value_get_string(value) : NULL; @@ -323,9 +346,11 @@ static gboolean __display_request(DBusGProxy *device, guint passkey, guint enter static gboolean __confirm_request(DBusGProxy *device, guint passkey) { + uint32_t device_class; GHashTable *hash = NULL; GValue *value; - const gchar *address, *name; + const gchar *address = NULL; + const gchar *name = NULL; GError *error = NULL; char str_passkey[7] = { 0 }; @@ -339,6 +364,9 @@ static gboolean __confirm_request(DBusGProxy *device, guint passkey) &hash, G_TYPE_INVALID); if (hash != NULL) { + value = g_hash_table_lookup(hash, "Class"); + device_class = value ? g_value_get_uint(value) : 0; + value = g_hash_table_lookup(hash, "Address"); address = value ? g_value_get_string(value) : NULL; @@ -382,13 +410,59 @@ static gboolean __pairing_cancel_request(const char *address) return TRUE; } +static void __bt_send_autorize_message(char *address, char *name, char *signal) +{ + DBG("+"); + + DBusMessage *msg = NULL; + DBusGConnection *conn = NULL; + DBusConnection *connecton = NULL; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + if (conn == NULL) { + DBG("conn is NULL\n"); + return; + } + + connecton = dbus_g_connection_get_connection(conn); + + msg = dbus_message_new_signal(BT_AGENT_OBJECT, + BT_AGENT_INTERFACE, + signal); + + DBG("address: %s, name: %s", address, name); + + if (!dbus_message_append_args(msg, + DBUS_TYPE_STRING, &address, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) { + DBG("Authorize sending failed\n"); + dbus_message_unref(msg); + dbus_g_connection_unref(conn); + return; + } + + dbus_connection_send(connecton, msg, NULL); + dbus_message_unref(msg); + dbus_g_connection_unref(conn); + + DBG("-"); + + return; +} + static gboolean __authorize_request(DBusGProxy *device, const char *uuid) { GHashTable *hash = NULL; - GValue *value; - const gchar *address, *name; + GValue *value = NULL; + const gchar *address = NULL; + const gchar *name = NULL; gboolean trust = FALSE; + gboolean paired = FALSE; GError *error = NULL; + char *rfcomm_uuid = NULL; + int val = 0; + int request_type = BT_AGENT_EVENT_AUTHORIZE_REQUEST; DBG("+\n"); @@ -414,21 +488,57 @@ static gboolean __authorize_request(DBusGProxy *device, const char *uuid) value = g_hash_table_lookup(hash, "Trusted"); trust = value ? g_value_get_boolean(value) : 0; + value = g_hash_table_lookup(hash, "Paired"); + paired = value ? g_value_get_boolean(value) : 0; + + if (paired == FALSE) { + DBG("No paired device"); + sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(), + SC_CORE_AGENT_REJECT, NULL); + return TRUE; + } + DBG("Authorization request for device [%s] Service:[%s]\n", address, uuid); + vconf_get_int(BT_MEMORY_OBEX_NO_AGENT, (void *)&val); + + if (val == 1 && !strcasecmp(uuid, OPP_UUID)) { + /* Send dbus signal to FRWK */ + __bt_send_autorize_message((char *)address, + (char *)name, + BT_AGENT_SIGNAL_OBEX_AUTHORIZE); + + return TRUE; + } + + rfcomm_uuid = vconf_get_str(BT_MEMORY_RFCOMM_UUID); + + if (rfcomm_uuid && !strcasecmp(uuid, rfcomm_uuid)) { + DBG("rfcomm_uuid: %s, uuid: %s", rfcomm_uuid, uuid); + /* Send dbus signal to FRWK */ + __bt_send_autorize_message((char *)address, + (char *)name, + BT_AGENT_SIGNAL_AUTHORIZE); + return TRUE; + } + + if (!strcasecmp(uuid, OPP_UUID)) + request_type = BT_AGENT_EVENT_EXCHANGE_REQUEST; + if (trust) { DBG("Trusted device, so authorize\n"); sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(), SC_CORE_AGENT_ACCEPT, NULL); - } else if (name != NULL) - _bt_agent_launch_system_popup(BT_AGENT_EVENT_AUTHORIZE_REQUEST, + } else if (name != NULL) { + _bt_agent_launch_system_popup(request_type, (const char *)name, NULL, NULL); - else if (address != NULL) - _bt_agent_launch_system_popup(BT_AGENT_EVENT_AUTHORIZE_REQUEST, + } else if (address != NULL) { + _bt_agent_launch_system_popup(request_type, (const char *)address, NULL, NULL); - else + } else { sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(), SC_CORE_AGENT_REJECT, NULL); + } } else { DBG("error in GetBasicProperties [%s]\n", error->message); g_error_free(error); @@ -512,13 +622,11 @@ void _bt_agent_register(DBusGProxy *adapter_proxy) func_cb.ignore_auto_pairing_func = __ignore_auto_pairing_request; if (_sc_core_agent_add(adapter_proxy, &func_cb) < 0) { - if (adapter_proxy == NULL) { - return; - } - ERR("Agent register failed, Agent finish.\n"); + ERR("Agent not registered"); + return; } - DBG("Agent registered.\n"); + DBG("Agent registered"); } static const int __bt_agent_is_hid_keyboard(uint32_t dev_class) @@ -589,6 +697,7 @@ static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address) static int __bt_agent_generate_passkey(char *passkey, int size) { int i = 0; + ssize_t len; int random_fd = 0; unsigned int value = 0; @@ -604,7 +713,7 @@ static int __bt_agent_generate_passkey(char *passkey, int size) return -1; for (i = 0; i < size - 1; i++) { - read(random_fd, &value, sizeof(value)); + len = read(random_fd, &value, sizeof(value)); passkey[i] = '0' + (value % 10); } diff --git a/bluetooth-frwk-agent/bluetooth-agent.c b/bluetooth-frwk-agent/bluetooth-agent.c index 04a252ae..7542ba00 100644 --- a/bluetooth-frwk-agent/bluetooth-agent.c +++ b/bluetooth-frwk-agent/bluetooth-agent.c @@ -25,33 +25,37 @@ #include #include #include +#include #include "bluetooth-agent.h" +#include "sc_core_agent.h" + struct bt_agent_appdata *app_data = NULL; +static GMainLoop *main_loop = NULL; -/* status - 0 : No operation, 1 : Activate , 2 : Deactivate, 3 : Search Test*/ -/* run_type - No window change, 1 : Top window, 2 : Background*/ -static void __agent_launch_bt_service(int status, int run_type) -{ - bundle *kb; - char status_val[5] = { 0, }; - char run_type_val[5] = { 0, }; +static void __bt_agent_release_service(void); +static void __bt_agent_terminate(void); - snprintf(status_val, sizeof(status_val), "%d", status); - snprintf(run_type_val, sizeof(run_type_val), "%d", run_type); +bt_status_t _bt_agent_bt_status_get() +{ + return app_data->bt_status; +} - DBG("status: %s, run_type: %s", status_val, run_type_val); +void _bt_agent_bt_status_set(bt_status_t status) +{ + app_data->bt_status = status; +} - kb = bundle_create(); +int _bt_agent_destroy() +{ + DBG("_bt_agent_destroy"); - bundle_add(kb, "launch-type", "setstate"); - bundle_add(kb, "status", status_val); - bundle_add(kb, "run-type", run_type_val); + __bt_agent_release_service(); - aul_launch_app("org.tizen.bluetooth", kb); + __bt_agent_terminate(); - bundle_free(kb); + return BT_AGENT_ERROR_NONE; } static int __agent_check_bt_service(void *data) @@ -63,15 +67,19 @@ static int __agent_check_bt_service(void *data) if (bt_status != VCONFKEY_BT_STATUS_OFF) { DBG("Previous session was enabled."); + /* Enable the BT */ + _sc_core_agent_mode_change(BT_AGENT_CHANGED_MODE_ENABLE); + } else { + DBG("State: %d", _bt_agent_bt_status_get()); - /*check BT service*/ - if (!aul_app_is_running("org.tizen.bluetooth")) { - __agent_launch_bt_service(BT_AGENT_RUN_STATUS_ACTIVATE, - BT_AGENT_ON_BACKGROUND); + if (_bt_agent_bt_status_get() != BT_ACTIVATING) { + /* Destroy the agent */ + _sc_core_agent_remove(); + _bt_agent_destroy(); } } - return 0; + return BT_AGENT_ERROR_NONE; } static void __agent_adapter_added_cb(DBusGProxy *manager_proxy, const char *adapter_path, @@ -85,13 +93,10 @@ static void __agent_adapter_added_cb(DBusGProxy *manager_proxy, const char *adap adapter_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", adapter_path, "org.bluez.Adapter"); - if (adapter_proxy) + if (adapter_proxy) { _bt_agent_register(adapter_proxy); - - /*check BT service*/ - if (!aul_app_is_running("org.tizen.bluetooth")) - __agent_launch_bt_service(BT_AGENT_RUN_STATUS_NO_CHANGE, - BT_AGENT_ON_CURRENTVIEW); + g_object_unref(adapter_proxy); + } /* Update Bluetooth Status to notify other modules */ if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0) @@ -99,6 +104,8 @@ static void __agent_adapter_added_cb(DBusGProxy *manager_proxy, const char *adap if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0) DBG("Set vconf failed\n"); + + _bt_agent_bt_status_set(BT_ACTIVATED); } static void __agent_adapter_removed_cb(DBusGProxy *manager_proxy, const char *adapter_path, @@ -118,40 +125,37 @@ static void __bt_agent_flight_mode_cb(keynode_t *node, void *data) DBG("value=%d\n", flight_mode); - if (flight_mode == TRUE && aul_app_is_running("org.tizen.bluetooth")) { + if (flight_mode == TRUE) { DBG("Deactivate Bluetooth Service\n"); - __agent_launch_bt_service(BT_AGENT_RUN_STATUS_DEACTIVATE, - BT_AGENT_ON_CURRENTVIEW); + _sc_core_agent_mode_change(BT_AGENT_CHANGED_MODE_DISABLE); } } } - -static int __agent_init(void *data) +static gboolean __agent_init(gpointer data) { - struct bt_agent_appdata *ad = (struct bt_agent_appdata *)data; - static DBusGConnection *connection = NULL; - static DBusGProxy *manager_proxy = NULL; + struct bt_agent_appdata *ad = data; + DBusGConnection *connection = NULL; + DBusGProxy *manager_proxy = NULL; DBusGProxy *adapter_proxy = NULL; GError *error = NULL; const char *adapter_path = NULL; - if (connection == NULL) - connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); + _bt_agent_bt_status_set(BT_DEACTIVATED); + + connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); if (error != NULL) { ERR("ERROR: Can't get on system bus [%s]", error->message); g_error_free(error); - return 1; + return TRUE; } - ad->g_connection = (void *)connection; + ad->g_connection = connection; - if (manager_proxy == NULL) - manager_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", "/", + manager_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", "/", "org.bluez.Manager"); - if (manager_proxy == NULL) { ERR("ERROR: Can't make dbus proxy"); - return 1; + return TRUE; } if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &error, @@ -164,26 +168,63 @@ static int __agent_init(void *data) _bt_agent_register(NULL); - dbus_g_proxy_add_signal(manager_proxy, "AdapterAdded", - DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(manager_proxy, "AdapterAdded", - G_CALLBACK(__agent_adapter_added_cb), ad, NULL); } else { DBG("DefaultAdapter [%s]", adapter_path); adapter_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", adapter_path, "org.bluez.Adapter"); - if (adapter_proxy) + if (adapter_proxy) { + _bt_agent_bt_status_set(BT_ACTIVATED); _bt_agent_register(adapter_proxy); + g_object_unref(adapter_proxy); + } } + dbus_g_proxy_add_signal(manager_proxy, "AdapterAdded", + DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(manager_proxy, "AdapterAdded", + G_CALLBACK(__agent_adapter_added_cb), ad, NULL); + dbus_g_proxy_add_signal(manager_proxy, "AdapterRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); dbus_g_proxy_connect_signal(manager_proxy, "AdapterRemoved", - G_CALLBACK(__agent_adapter_removed_cb), NULL, NULL); + G_CALLBACK(__agent_adapter_removed_cb), ad, NULL); - g_idle_add((GSourceFunc) __agent_check_bt_service, NULL); + ad->manager_proxy = manager_proxy; - return 0; + vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, __bt_agent_flight_mode_cb, ad); + + g_idle_add((GSourceFunc) __agent_check_bt_service, ad); + + return FALSE; +} + +static void __bt_agent_terminate(void) +{ + if (main_loop != NULL) + g_main_loop_quit(main_loop); + else + exit(0); +} + +static void __bt_agent_release_service(void) +{ + struct bt_agent_appdata *ad = app_data; + + if (ad->manager_proxy) { + dbus_g_proxy_disconnect_signal(ad->manager_proxy, "AdapterAdded", + G_CALLBACK(__agent_adapter_added_cb), + NULL); + + dbus_g_proxy_disconnect_signal(ad->manager_proxy, "AdapterRemoved", + G_CALLBACK(__agent_adapter_removed_cb), + NULL); + + g_object_unref(ad->manager_proxy); + ad->manager_proxy = NULL; + } + + vconf_ignore_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, + __bt_agent_flight_mode_cb); } static int __bt_agent_create(void *data) @@ -192,15 +233,11 @@ static int __bt_agent_create(void *data) DBG("__bt_agent_create() start.\n"); - g_idle_add((GSourceFunc) __agent_init, ad); + __agent_init(ad); - vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, __bt_agent_flight_mode_cb, ad); - - return 0; + return BT_AGENT_ERROR_NONE; } -GMainLoop *main_loop = NULL; - int main(int argc, char *argv[]) { struct bt_agent_appdata ad = { 0 }; @@ -214,9 +251,8 @@ int main(int argc, char *argv[]) g_main_loop_run(main_loop); - if (main_loop != NULL) { + if (main_loop != NULL) g_main_loop_unref(main_loop); - } return 0; } diff --git a/bluetooth-frwk-agent/bluetooth-agent.h b/bluetooth-frwk-agent/bluetooth-agent.h index 1949ce11..170afaf0 100644 --- a/bluetooth-frwk-agent/bluetooth-agent.h +++ b/bluetooth-frwk-agent/bluetooth-agent.h @@ -37,15 +37,36 @@ #define BT_AGENT_PADDING_SIZE 4096 #define BT_MAX_SERVICES_FOR_DEVICE 20 /**< This specifies maximum number of services a + device can support */ #define BT_MAX_EVENT_STR_LENGTH 50 #define BT_AGENT_ADDR_SIZE 18 +#define BT_TEMINATING_WAIT_TIME 200 + +/* Define Error type */ +#define BT_AGENT_FAIL -1 +#define BT_AGENT_ERROR_NONE 0 + +#define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time" + +/* Need to covert to design ID */ +#define BT_STR_HANDS_FREE_RESTRICTS \ + "Security policy restricts use of Bluletooth connection to hands-free features only" + +typedef enum { + BT_DEACTIVATING = 0x00, /* BT Deactivating */ + BT_DEACTIVATED = 0x01, /* BT Deactivated */ + BT_ACTIVATING = 0x02, /* BT Activating */ + BT_ACTIVATED = 0x03, /* BT Activated */ +} bt_status_t; struct bt_agent_appdata { - void *g_connection; + DBusGConnection *g_connection; + DBusGProxy *manager_proxy; int ignore_auto_pairing; char bonding_addr[BT_AGENT_ADDR_SIZE + 1]; /*bluetooth device address which currently bonding is requested to */ + bt_status_t bt_status; }; typedef enum { @@ -68,7 +89,9 @@ typedef enum { BT_AGENT_EVENT_APP_CONFIRM_REQUEST = 0x0040, BT_AGENT_EVENT_FILE_RECIEVED = 0x0080, BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST = 0x0100, - BT_AGENT_EVENT_TERMINATE = 0x0200, + BT_AGENT_EVENT_SECURITY = 0x0200, + BT_AGENT_EVENT_TERMINATE = 0x0400, + BT_AGENT_EVENT_EXCHANGE_REQUEST = 0x0800, } bt_agent_event_type_t; typedef enum { @@ -100,4 +123,10 @@ int _bt_agent_launch_system_popup(bt_agent_event_type_t event_type, const char * char *passkey, const char *filename); void _bt_agent_register(DBusGProxy *adapter_proxy); +bt_status_t _bt_agent_bt_status_get(); + +void _bt_agent_bt_status_set(bt_status_t status); + +int _bt_agent_destroy(); + #endif /* __DEF_BT_AGENT_H_ */ diff --git a/bluetooth-frwk-agent/sc_core_agent.c b/bluetooth-frwk-agent/sc_core_agent.c index 89edf196..f2e2792a 100644 --- a/bluetooth-frwk-agent/sc_core_agent.c +++ b/bluetooth-frwk-agent/sc_core_agent.c @@ -58,7 +58,7 @@ struct _ScCoreAgentPrivate { char authorize_addr[18]; guint timeout_id; - unsigned int timeout; + int timeout; SC_CORE_AGENT_FUNC_CB cb; }; @@ -91,7 +91,7 @@ static gboolean sc_core_agent_ignore_auto_pairing(ScCoreAgent *agent, const char DBusGMethodInvocation *context); static gboolean sc_core_agent_set_discoverable_timer(ScCoreAgent *agent, - const guint timeout, + const gint timeout, DBusGMethodInvocation *context); static gboolean sc_core_agent_get_discoverable_timeout(ScCoreAgent *agent, @@ -101,10 +101,6 @@ static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *n const char *prev, const char *new, gpointer user_data); -static void __sc_core_agent_mode_change(int changed_mode); - -static gboolean __sc_cre_core_agent_readd(gpointer data); - #include "sc_core_agent_glue.h" typedef enum { @@ -139,21 +135,12 @@ static void sc_core_agent_init(ScCoreAgent *agent) static void sc_core_agent_finalize(GObject *agent) { ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); - SC_CORE_AGENT_FUNC_CB *cb_ptr = NULL; DBG("Free agent %p\n", agent); g_free(priv->path); g_free(priv->busname); - cb_ptr = (SC_CORE_AGENT_FUNC_CB *) malloc(sizeof(SC_CORE_AGENT_FUNC_CB)); - if (cb_ptr) { - memcpy(cb_ptr, &priv->cb, sizeof(SC_CORE_AGENT_FUNC_CB)); - g_idle_add(__sc_cre_core_agent_readd, (void *)cb_ptr); - } else { - DBG("Error copy callback pointer\n"); - } - G_OBJECT_CLASS(sc_core_agent_parent_class)->finalize(agent); } @@ -518,7 +505,7 @@ static gboolean sc_core_agent_confirm_mode(ScCoreAgent *agent, const char *mode, if (need_asking && dbus_g_proxy_call(priv->dbus_proxy, "GetConnectionUnixProcessID", NULL, G_TYPE_STRING, - "org.tizen.SplusA.bluetooth.BluetoothService", + "com.samsung.SplusA.bluetooth.BluetoothService", G_TYPE_INVALID, G_TYPE_UINT, &inhouse_pid, G_TYPE_INVALID)) { if (inhouse_pid > 0 && (sender_pid > 0 || @@ -623,12 +610,6 @@ static gboolean sc_core_agent_release(ScCoreAgent *agent, DBusGMethodInvocation memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr)); memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr)); - /* Check blocking this part */ - g_signal_handlers_disconnect_by_func(priv->dbus_proxy, - G_CALLBACK(__sc_core_agent_name_owner_changed), NULL); - g_object_unref(agent); - gap_agent = NULL; - g_free(sender); return TRUE; } @@ -675,8 +656,13 @@ static gboolean __sc_core_agent_timeout_handler(gpointer user_data) priv->timeout--; - if (priv->timeout == 0) { + if (priv->timeout <= 0) { + g_source_remove(priv->timeout_id); priv->timeout_id = 0; + + if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0) + DBG("Set vconf failed\n"); + return FALSE; } @@ -685,7 +671,7 @@ static gboolean __sc_core_agent_timeout_handler(gpointer user_data) } static gboolean sc_core_agent_set_discoverable_timer(ScCoreAgent *agent, - const guint timeout, + const gint timeout, DBusGMethodInvocation *context) { DBG("+\n"); @@ -702,7 +688,10 @@ static gboolean sc_core_agent_set_discoverable_timer(ScCoreAgent *agent, priv->timeout = timeout; - if (timeout == 0) + if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0) + DBG("Set vconf failed\n"); + + if (timeout <= 0) return TRUE; priv->timeout_id = g_timeout_add_seconds(1, @@ -848,6 +837,8 @@ gboolean sc_core_agent_reply_confirmation(ScCoreAgent *agent, const guint accept gboolean sc_core_agent_reply_authorize(ScCoreAgent *agent, const guint accept, DBusGMethodInvocation *context) { + gboolean ret = TRUE; + DBG("+\n"); ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); @@ -872,6 +863,19 @@ gboolean sc_core_agent_reply_authorize(ScCoreAgent *agent, const guint accept, dbus_g_method_return_error(priv->reply_context, error); g_error_free(error); } + + if (context) + dbus_g_method_return(context); + } else { + GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT, + "No context"); + DBG("No context"); + + if (context) + dbus_g_method_return_error(context, error); + + g_error_free(error); + ret = FALSE; } priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION; @@ -880,7 +884,7 @@ gboolean sc_core_agent_reply_authorize(ScCoreAgent *agent, const guint accept, DBG("-\n"); - return TRUE; + return ret; } gboolean sc_core_agent_reply_adapter_enable(ScCoreAgent *agent, const guint changed_mode, @@ -891,7 +895,7 @@ gboolean sc_core_agent_reply_adapter_enable(ScCoreAgent *agent, const guint chan ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); if (accept == SC_CORE_AGENT_ACCEPT) { - __sc_core_agent_mode_change(changed_mode); + _sc_core_agent_mode_change(changed_mode); dbus_g_method_return(priv->reply_context); } else { GError *error = NULL; @@ -915,17 +919,26 @@ gboolean sc_core_agent_reply_adapter_enable(ScCoreAgent *agent, const guint chan return TRUE; } -static void __sc_core_agent_mode_change(int changed_mode) +void _sc_core_agent_mode_change(int changed_mode) { int ret = 0; + bt_status_t bt_up_status; switch (changed_mode) { case BT_AGENT_CHANGED_MODE_ENABLE: /* Run BT intiate script */ + bt_up_status = _bt_agent_bt_status_get(); + if (bt_up_status == BT_ACTIVATING || bt_up_status == BT_ACTIVATED) { + DBG("BT is activating or already activated.\n"); + break; + } + + _bt_agent_bt_status_set(BT_ACTIVATING); + if ((ret = system("/usr/etc/bluetooth/bt-stack-up.sh &")) < 0) { DBG("running script failed"); ret = system("/usr/etc/bluetooth/bt-dev-end.sh &"); - + _bt_agent_bt_status_set(BT_DEACTIVATED); sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode, SC_CORE_AGENT_REJECT, NULL); return; @@ -934,9 +947,17 @@ static void __sc_core_agent_mode_change(int changed_mode) case BT_AGENT_CHANGED_MODE_DISABLE: /* Run BT terminate script */ + bt_up_status = _bt_agent_bt_status_get(); + if (bt_up_status == BT_DEACTIVATING || bt_up_status == BT_DEACTIVATED) { + DBG("BT is deactivating or already deactivated.\n"); + break; + } + + _bt_agent_bt_status_set(BT_DEACTIVATING); + if ((ret = system("/usr/etc/bluetooth/bt-stack-down.sh &")) < 0) { DBG("running script failed"); - + _bt_agent_bt_status_set(BT_ACTIVATED); sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode, SC_CORE_AGENT_REJECT, NULL); return; @@ -951,77 +972,46 @@ static void __sc_core_agent_mode_change(int changed_mode) } } -static gboolean __sc_core_agent_register_on_adapter(ScCoreAgent *agent, DBusGProxy *adapter, - SC_CORE_AGENT_FUNC_CB *func_cb) +static gboolean __sc_core_agent_register_on_adapter(ScCoreAgent *agent, DBusGProxy *adapter) { ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); DBusGProxy *proxy; - GObject *object; GError *error = NULL; DBG("agent %p\n", agent); - if (priv->adapter != NULL) + if (adapter == NULL) return FALSE; - /* DBUS method call install */ - if (priv->path == NULL) { - priv->path = g_strdup_printf("/org/bluez/agent/frwk_agent"); - - DBG("%s \n", priv->path); - - object = dbus_g_connection_lookup_g_object(connection, priv->path); - if (object != NULL) - g_object_unref(object); - - dbus_g_connection_register_g_object(connection, priv->path, G_OBJECT(agent)); - } - - if (func_cb) { - priv->cb.pincode_func = func_cb->pincode_func; - priv->cb.display_func = func_cb->display_func; - priv->cb.passkey_func = func_cb->passkey_func; - priv->cb.confirm_func = func_cb->confirm_func; - priv->cb.authorize_func = func_cb->authorize_func; - priv->cb.pairing_cancel_func = func_cb->pairing_cancel_func; - priv->cb.authorization_cancel_func = func_cb->authorization_cancel_func; - priv->cb.confirm_mode_func = func_cb->confirm_mode_func; - priv->cb.ignore_auto_pairing_func = func_cb->ignore_auto_pairing_func; - } - priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION; memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr)); memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr)); priv->reply_context = NULL; /* Adapter agent register */ - if (adapter) { - priv->adapter = g_object_ref(adapter); - - proxy = dbus_g_proxy_new_for_name_owner(connection, - dbus_g_proxy_get_bus_name(priv->adapter), - dbus_g_proxy_get_path(priv->adapter), - dbus_g_proxy_get_interface(priv->adapter), - NULL); + priv->adapter = g_object_ref(adapter); - if (priv->busname) - g_free(priv->busname); + proxy = dbus_g_proxy_new_for_name_owner(connection, + dbus_g_proxy_get_bus_name(priv->adapter), + dbus_g_proxy_get_path(priv->adapter), + dbus_g_proxy_get_interface(priv->adapter), + NULL); - if (proxy != NULL) { - priv->busname = g_strdup(dbus_g_proxy_get_bus_name(proxy)); - g_object_unref(proxy); - } else - priv->busname = g_strdup(dbus_g_proxy_get_bus_name(adapter)); + g_free(priv->busname); - dbus_g_proxy_call(priv->adapter, "RegisterAgent", &error, - DBUS_TYPE_G_OBJECT_PATH, priv->path, - G_TYPE_STRING, "DisplayYesNo", G_TYPE_INVALID, G_TYPE_INVALID); + if (proxy != NULL) { + priv->busname = g_strdup(dbus_g_proxy_get_bus_name(proxy)); + g_object_unref(proxy); + } else + priv->busname = g_strdup(dbus_g_proxy_get_bus_name(adapter)); - if (error != NULL) { - DBG("Agent registration failed: %s\n", error->message); - g_error_free(error); - return FALSE; - } + dbus_g_proxy_call(priv->adapter, "RegisterAgent", &error, + DBUS_TYPE_G_OBJECT_PATH, priv->path, + G_TYPE_STRING, "DisplayYesNo", G_TYPE_INVALID, G_TYPE_INVALID); + if (error != NULL) { + DBG("Agent registration failed: %s\n", error->message); + g_error_free(error); + return FALSE; } return TRUE; @@ -1039,7 +1029,6 @@ static gboolean __sc_core_agent_unregister(ScCoreAgent *agent) dbus_g_proxy_call(priv->adapter, "UnregisterAgent", &error, DBUS_TYPE_G_OBJECT_PATH, priv->path, G_TYPE_INVALID, G_TYPE_INVALID); - if (error != NULL) { g_printerr("Agent unregistration failed: %s\n", error->message); g_error_free(error); @@ -1048,12 +1037,20 @@ static gboolean __sc_core_agent_unregister(ScCoreAgent *agent) g_object_unref(priv->adapter); priv->adapter = NULL; - g_free(priv->path); - priv->path = NULL; - return TRUE; } +static gboolean __sc_core_agent_destroy_cb(gpointer user_data) +{ + if (_bt_agent_bt_status_get() != BT_ACTIVATING) { + /* Destroy the agent */ + _bt_agent_destroy(); + } else + DBG("Now activating!!!"); + + return FALSE; +} + static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *name, const char *prev, const char *new, gpointer user_data) { @@ -1066,15 +1063,25 @@ static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *n if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0) DBG("Set vconf failed\n"); + + __sc_core_agent_unregister(gap_agent); + _bt_agent_bt_status_set(BT_DEACTIVATED); + + /* Wait some miliseconds, + because it is possible that anyone try to BT on. + So we need to yield the calling turn to dbus method */ + g_timeout_add(BT_TEMINATING_WAIT_TIME, + (GSourceFunc)__sc_core_agent_destroy_cb, NULL); } } -static void __sc_core_setup_dbus(ScCoreAgent *agent) +static void __sc_core_setup_dbus(ScCoreAgent *agent, SC_CORE_AGENT_FUNC_CB *func_cb) { guint result; GError *error = NULL; gchar *agent_name = NULL; ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); + GObject *object; agent_name = g_strdup_printf("org.bluez.frwk_agent"); @@ -1102,6 +1109,16 @@ static void __sc_core_setup_dbus(ScCoreAgent *agent) g_free(agent_name); + priv->path = g_strdup_printf("/org/bluez/agent/frwk_agent"); + + object = dbus_g_connection_lookup_g_object(connection, priv->path); + if (object != NULL) + g_object_unref(object); + + dbus_g_connection_register_g_object(connection, priv->path, G_OBJECT(agent)); + + memcpy(&priv->cb, func_cb, sizeof(SC_CORE_AGENT_FUNC_CB)); + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); @@ -1113,36 +1130,30 @@ static void __sc_core_reset_dbus(ScCoreAgent *agent) { ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent); + dbus_g_proxy_disconnect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(__sc_core_agent_name_owner_changed), + NULL); + g_object_unref(priv->dbus_proxy); priv->dbus_proxy = NULL; - priv->adapter = NULL; + + g_free(priv->path); + priv->path = NULL; } int _sc_core_agent_add(DBusGProxy *adapter_proxy, SC_CORE_AGENT_FUNC_CB *func_cb) { if (gap_agent == NULL) { gap_agent = sc_core_agent_new(); - __sc_core_setup_dbus(gap_agent); + __sc_core_setup_dbus(gap_agent, func_cb); } - if (__sc_core_agent_register_on_adapter(gap_agent, adapter_proxy, func_cb)) + if (__sc_core_agent_register_on_adapter(gap_agent, adapter_proxy)) return 0; return -1; } -static gboolean __sc_cre_core_agent_readd(gpointer data) -{ - SC_CORE_AGENT_FUNC_CB *cb_ptr = (SC_CORE_AGENT_FUNC_CB *) data; - - _sc_core_agent_add(NULL, cb_ptr); - - if (cb_ptr) { - free(cb_ptr); - } - return 0; -} - void _sc_core_agent_remove(void) { __sc_core_agent_unregister(gap_agent); diff --git a/bluetooth-frwk-agent/sc_core_agent.h b/bluetooth-frwk-agent/sc_core_agent.h index 7617df67..6e607a40 100644 --- a/bluetooth-frwk-agent/sc_core_agent.h +++ b/bluetooth-frwk-agent/sc_core_agent.h @@ -86,6 +86,9 @@ struct _ScCoreAgentClass { int _sc_core_agent_add(DBusGProxy *adapter_proxy, SC_CORE_AGENT_FUNC_CB *func_cb); void _sc_core_agent_remove(void); + +void _sc_core_agent_mode_change(int changed_mode); + ScCoreAgent *_sc_core_agent_get_proxy(void); gboolean sc_core_agent_reply_pin_code(ScCoreAgent *agent, const guint accept, const char *pin_code, diff --git a/bluetooth-frwk-agent/sc_core_agent.xml b/bluetooth-frwk-agent/sc_core_agent.xml index d26ac07f..ae656483 100644 --- a/bluetooth-frwk-agent/sc_core_agent.xml +++ b/bluetooth-frwk-agent/sc_core_agent.xml @@ -53,7 +53,7 @@ - + diff --git a/bluetooth-map-agent/CMakeLists.txt b/bluetooth-map-agent/CMakeLists.txt index 0c1bdd23..aad720bd 100644 --- a/bluetooth-map-agent/CMakeLists.txt +++ b/bluetooth-map-agent/CMakeLists.txt @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-map-agent C) SET(SRCS bluetooth_map_agent.c) -SET(APP_VENDOR samsung) +SET(APP_VENDOR tizen) SET(APP_NAME bluetooth-map-agent) SET(APP_DIR /usr/bin) SET(APP_LOCALEDIR /usr/share/locale) diff --git a/bluetooth-map-agent/bluetooth_map_agent.c b/bluetooth-map-agent/bluetooth_map_agent.c index 9630d0d0..2a6c1b41 100644 --- a/bluetooth-map-agent/bluetooth_map_agent.c +++ b/bluetooth-map-agent/bluetooth_map_agent.c @@ -29,20 +29,27 @@ #include #include #include -#include #include "vconf.h" #include "vconf-keys.h" #include -#include #include /*Messaging Header Files*/ -#include "MapiTransport.h" -#include "MapiMessage.h" +#include "msg.h" +#include "msg_storage.h" +#include "msg_storage_types.h" +#include "msg_transport.h" +#include "msg_transport_types.h" +#include "msg_types.h" /*Email Header Files*/ #include "email-types.h" +#include "email-api-init.h" +#include "email-api-account.h" +#include "email-api-mailbox.h" +#include "email-api-mail.h" +#include "email-api-network.h" #include @@ -52,7 +59,7 @@ #define DBUS_STRUCT_MESSAGE_LIST (dbus_g_type_get_struct("GValueArray", \ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)) -static MSG_HANDLE_T g_msg_handle = NULL; +static msg_handle_t g_msg_handle = NULL; #define BT_MAP_NEW_MESSAGE "NewMessage" #define BT_MAP_STATUS_CB "sent status callback" #define BT_MAP_MSG_CB "sms message callback" @@ -61,6 +68,7 @@ static MSG_HANDLE_T g_msg_handle = NULL; #define BT_MAP_EMAIL "_e" #define BT_MAP_MSG_INFO_MAX 256 #define BT_MAP_MSG_HANDLE_MAX 16 +#define BT_MAP_TIMESTAMP_MAX_LEN 16 #define BT_MNS_OBJECT_PATH "/org/bluez/mns" #define BT_MNS_INTERFACE "org.bluez.mns" #define BT_MSG_UPDATE 0 @@ -156,12 +164,16 @@ static GError *__bt_map_agent_error(bt_map_agent_error_t error, return g_error_new(BT_MAP_AGENT_ERROR, error, err_msg); } -static void __bluetooth_map_msg_incoming_status_cb(MSG_HANDLE_T handle, - msg_message_t msg, void *user_param) +static void __bluetooth_map_msg_incoming_status_cb(msg_handle_t handle, + msg_struct_t msg, void *user_param) { DBusMessage *message = NULL; char *message_type = NULL; DBusConnection *conn; + int msg_id = 0; + int msg_type = 0; + char msg_handle[BT_MAP_MSG_HANDLE_MAX] = {0,}; + int ret = MSG_SUCCESS; DBG("+\n"); @@ -177,21 +189,36 @@ static void __bluetooth_map_msg_incoming_status_cb(MSG_HANDLE_T handle, return; } - switch (msg_get_message_type(msg)) { + + ret = msg_get_int_value(msg, + MSG_MESSAGE_ID_INT, &msg_id); + if (ret != MSG_SUCCESS) + return; + + snprintf(msg_handle, sizeof(msg_handle), "%d%s", + msg_id, + BT_MAP_SMS); + + ret = msg_get_int_value(msg, + MSG_MESSAGE_TYPE_INT, &msg_type); + if (ret != MSG_SUCCESS) + return; + + switch (msg_type) { case MSG_TYPE_SMS: - message_type = g_strdup("SMS_GSM"); + message_type = g_strdup("SMS_GSM"); break; case MSG_TYPE_MMS: - message_type = g_strdup("MMS"); + message_type = g_strdup("MMS"); break; default: - message_type = g_strdup("UNKNOWN"); + message_type = g_strdup("UNKNOWN"); break; } dbus_message_append_args(message, DBUS_TYPE_STRING, &message_type, - DBUS_TYPE_INT32, &handle, + DBUS_TYPE_INT32, &msg_handle, DBUS_TYPE_INVALID); dbus_message_set_no_reply(message, TRUE); @@ -203,23 +230,21 @@ static void __bluetooth_map_msg_incoming_status_cb(MSG_HANDLE_T handle, static gboolean __bluetooth_map_start_service() { - MSG_ERROR_T err = MSG_SUCCESS; - int email_err = EMF_ERROR_NONE; - bool msg_ret = TRUE; - bool email_ret = TRUE; + msg_error_t err = MSG_SUCCESS; + int email_err = EMAIL_ERROR_NONE; + gboolean msg_ret = TRUE; + gboolean email_ret = TRUE; err = msg_open_msg_handle(&g_msg_handle); - if (err != MSG_SUCCESS) { ERR("msg_open_msg_handle error = %d\n", err); msg_ret = FALSE; - goto email; + goto email; } err = msg_reg_sms_message_callback(g_msg_handle, __bluetooth_map_msg_incoming_status_cb, 0, (void *)BT_MAP_MSG_CB); - if (err != MSG_SUCCESS) { ERR("msg_reg_sms_message_callback error = %d\n", err); msg_ret = FALSE; @@ -227,8 +252,7 @@ static gboolean __bluetooth_map_start_service() email: email_err = email_service_begin(); - - if (email_err != EMF_ERROR_NONE) { + if (email_err != EMAIL_ERROR_NONE) { ERR("email_service_begin fail error = %d\n", email_err); email_ret = FALSE; } @@ -246,30 +270,67 @@ static void __bluetooth_map_stop_service() g_msg_handle = NULL; - if (EMF_ERROR_NONE != email_service_end()) + if (EMAIL_ERROR_NONE != email_service_end()) ERR("email_service_end fail \n"); return; } +static void __get_msg_timestamp(time_t *ltime, char *timestamp) +{ + struct tm local_time; + int year; + int month; + + if (!localtime_r(ltime, &local_time)) + return; + + year = local_time.tm_year + 1900; /* years since 1900 */ + month = local_time.tm_mon + 1; /* months since January */ + snprintf(timestamp, 16, "%04d%02d%02dT%02d%02d%02d", + year, month, + local_time.tm_mday, local_time.tm_hour, + local_time.tm_min, local_time.tm_sec); + + return; +} + +gboolean static __bt_msg_is_mms(int msg_type) +{ + gboolean result = FALSE; + + switch (msg_type) { + case MSG_TYPE_MMS_NOTI: + case MSG_TYPE_MMS_JAVA: + case MSG_TYPE_MMS: + result = TRUE; + break; + default: + break; + } + + return result; +} + static gboolean bluetooth_map_get_folder_tree(BluetoothMapAgent *agent, DBusGMethodInvocation *context) { GPtrArray *array = g_ptr_array_new(); - MSG_FOLDER_LIST_S g_folderList; - int i = 0; + GValue value; + GError *error = NULL; + char name[BT_MAP_MSG_INFO_MAX] = {0,}; - int vconf_err = 0; + char folder_name[BT_MAP_MSG_INFO_MAX] = {0,}; + int i; + int j; int account_id = 0; - emf_mailbox_t *mailbox_list = NULL; int mailbox_count = 0; - bool flag = FALSE; - int j = 0; - GValue *value = NULL; - GError *error = NULL; - bool msg_ret = TRUE; + int ret = MSG_SUCCESS; + gboolean flag = FALSE; + gboolean msg_ret = TRUE; - if (__bluetooth_map_start_service() == FALSE) - goto fail; + msg_struct_list_s g_folderList; + msg_struct_t p_folder; + email_mailbox_t *mailbox_list = NULL; if (g_msg_handle == NULL) { msg_ret = FALSE; @@ -281,75 +342,86 @@ static gboolean bluetooth_map_get_folder_tree(BluetoothMapAgent *agent, goto email; } - value = g_new0(GValue, 1); - for (i = 0; i < g_folderList.nCount; i++) { - g_strlcpy(name, g_folderList.folderInfo[i].folderName, - sizeof(name)); - - memset(value, 0, sizeof(GValue)); - g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(value, dbus_g_type_specialized_construct( + p_folder = g_folderList.msg_struct_info[i]; + memset(folder_name, 0x00, BT_MAP_MSG_INFO_MAX); + + ret = msg_get_str_value(p_folder, MSG_FOLDER_INFO_NAME_STR, + folder_name, BT_MAP_MSG_INFO_MAX); + if (ret != MSG_SUCCESS) + continue; + + g_strlcpy(name, folder_name, sizeof(name)); + memset(&value, 0, sizeof(GValue)); + g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); + g_value_take_boxed(&value, dbus_g_type_specialized_construct( DBUS_STRUCT_STRING_STRING_UINT)); - dbus_g_type_struct_set(value, 0, name, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); + dbus_g_type_struct_set(&value, 0, name, G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(&value)); } email: - vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id); - if (vconf_err == -1) { - if (!msg_ret) - goto fail; - } + if (EMAIL_ERROR_NONE != email_load_default_account_id(&account_id)) + goto done; - if (EMF_ERROR_NONE != email_get_mailbox_list(account_id, - EMF_MAILBOX_ALL, + if (EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, + EMAIL_MAILBOX_ALL, &mailbox_list, &mailbox_count)) { - if (!msg_ret) - goto fail; + goto done; } + msg_ret = TRUE; + for (i = 0; i < mailbox_count; i++) { flag = FALSE; for (j = 0; j < g_folderList.nCount; j++) { - if (!g_ascii_strncasecmp( - mailbox_list[i].name, - g_folderList.folderInfo[j].folderName, - strlen(mailbox_list[i].name))) { + + p_folder = g_folderList.msg_struct_info[j]; + memset(folder_name, 0x00, BT_MAP_MSG_INFO_MAX); + + ret = msg_get_str_value(p_folder, MSG_FOLDER_INFO_NAME_STR, + folder_name, BT_MAP_MSG_INFO_MAX); + if (ret != MSG_SUCCESS) + continue; + + if (!g_ascii_strncasecmp(mailbox_list[i].alias, + folder_name, strlen(mailbox_list[i].alias))) { flag = TRUE; break; } } + if (!flag) { - g_strlcpy(name, mailbox_list[i].name, sizeof(name)); - memset(value, 0, sizeof(GValue)); - g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(value, + g_strlcpy(name, mailbox_list[i].alias, sizeof(name)); + memset(&value, 0, sizeof(GValue)); + g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); + g_value_take_boxed(&value, dbus_g_type_specialized_construct( DBUS_STRUCT_STRING_STRING_UINT)); - dbus_g_type_struct_set(value, 0, name, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); + dbus_g_type_struct_set(&value, 0, name, G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(&value)); } } if (mailbox_list != NULL) email_free_mailbox(&mailbox_list, mailbox_count); - g_free(value); - dbus_g_method_return(context, array); - g_ptr_array_free(array, TRUE); - return TRUE; -fail: - if (mailbox_list != NULL) - email_free_mailbox(&mailbox_list, mailbox_count); - g_free(value); - g_ptr_array_free(array, TRUE); - error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL, - "InternalError"); - dbus_g_method_return_error(context, error); - g_error_free(error); - return FALSE; +done: + + if (msg_ret == FALSE) { + g_ptr_array_free(array, TRUE); + + error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL, + "InternalError"); + dbus_g_method_return_error(context, error); + g_error_free(error); + return FALSE; + } else { + dbus_g_method_return(context, array); + g_ptr_array_free(array, TRUE); + return TRUE; + } } static gboolean bluetooth_map_get_message_list(BluetoothMapAgent *agent, @@ -357,144 +429,203 @@ static gboolean bluetooth_map_get_message_list(BluetoothMapAgent *agent, DBusGMethodInvocation *context) { GPtrArray *array = g_ptr_array_new(); - MSG_FOLDER_ID_T folder_id = 0; - int i = 0; - MSG_FOLDER_LIST_S g_folderList; - MSG_SORT_RULE_S sortRule; - MSG_LIST_S msg_list; - GValue *value = NULL; + GValue value; + GError *error = NULL; + char msg_handle[BT_MAP_MSG_HANDLE_MAX] = {0,}; char msg_type[BT_MAP_MSG_INFO_MAX] = {0,}; - char msg_datetime[BT_MAP_MSG_INFO_MAX] = {0,}; + char msg_datetime[BT_MAP_TIMESTAMP_MAX_LEN] = {0,}; char *folder = NULL; - int vconf_err = 0; + char *type = NULL; + int i = 0; int account_id = 0; - emf_mailbox_t *mailbox_list = NULL; int mailbox_count = 0; - emf_mail_list_item_t *mail_list = NULL; int mail_count = 0; - emf_mailbox_t mailbox; int total = 0; - int unseen = 0; - bool msg_ret = TRUE; - GError *error = NULL; + gboolean msg_ret = TRUE; + int ret = 0; + int folder_id = 0; + + msg_struct_list_s g_folderList; + msg_struct_list_s msg_list; + + email_mailbox_t *mailbox_list = NULL; + email_mail_list_item_t *mail_list = NULL; + email_list_filter_t *filter_list = NULL; + email_list_sorting_rule_t *sorting_rule_list = NULL; if (g_msg_handle == NULL) { msg_ret = FALSE; goto email; } - value = g_new0(GValue, 1); - folder = strrchr(folder_name, '/'); - if (NULL == folder) folder = folder_name; else folder++; - if (msg_get_folder_list(g_msg_handle, &g_folderList) != MSG_SUCCESS) { + ret = msg_get_folder_list(g_msg_handle, &g_folderList); + if (ret != MSG_SUCCESS) { msg_ret = FALSE; goto email; } - for (i = 0; i < g_folderList.nCount; i++) - if (!g_ascii_strncasecmp(folder, - g_folderList.folderInfo[i].folderName, - strlen(folder))) - folder_id = g_folderList.folderInfo[i].folderId; + for (i = 0; i < g_folderList.nCount; i++) { + msg_struct_t pFolder = g_folderList.msg_struct_info[i]; + char folderName[BT_MAP_MSG_INFO_MAX] = {0, }; + + ret = msg_get_str_value(pFolder, MSG_FOLDER_INFO_NAME_STR, + folderName, BT_MAP_MSG_INFO_MAX); + if (ret != MSG_SUCCESS) + continue; + + if (!g_ascii_strncasecmp(folder, folderName, strlen(folder))) { + ret = msg_get_int_value(pFolder, MSG_FOLDER_INFO_ID_INT, &folder_id); + if (ret != MSG_SUCCESS) { + msg_ret = FALSE; + } else { + DBG("folder_id %d \n", folder_id); + } + break; + } + } + if (msg_ret == FALSE) + goto email; + + /* Need to apply filter on the code based on remote request */ if (MSG_SUCCESS != msg_get_folder_view_list(g_msg_handle, - folder_id, &sortRule, &msg_list)) { + folder_id, NULL, &msg_list)) { msg_ret = FALSE; goto email; } for (i = 0; i < msg_list.nCount; i++) { - time_t *time = NULL; - struct tm local_time = {0,}; + int dptime; + int m_id = 0; + int m_type = 0; - memset(value, 0, sizeof(GValue)); - g_value_init(value, DBUS_STRUCT_MESSAGE_LIST); - g_value_take_boxed(value, dbus_g_type_specialized_construct( + memset(&value, 0, sizeof(GValue)); + g_value_init(&value, DBUS_STRUCT_MESSAGE_LIST); + g_value_take_boxed(&value, dbus_g_type_specialized_construct( DBUS_STRUCT_MESSAGE_LIST)); + ret = msg_get_int_value(msg_list.msg_struct_info[i], + MSG_MESSAGE_ID_INT, &m_id); + if (ret != MSG_SUCCESS) + continue; + snprintf(msg_handle, sizeof(msg_handle), "%d%s", - msg_get_message_id(msg_list.msgInfo[i]), + m_id, BT_MAP_SMS); - time = msg_get_time(msg_list.msgInfo[i]); + ret = msg_get_int_value(msg_list.msg_struct_info[i], + MSG_MESSAGE_DISPLAY_TIME_INT, &dptime); + if (ret == MSG_SUCCESS) + __get_msg_timestamp((time_t *)&dptime, msg_datetime); - if (NULL != time) - localtime_r(time, &local_time); + msg_get_int_value(msg_list.msg_struct_info[i], + MSG_MESSAGE_TYPE_INT, &m_type); - snprintf(msg_datetime, sizeof(msg_datetime), "%d%d%dT%d%d%d", - local_time.tm_year, local_time.tm_mon, - local_time.tm_mday, local_time.tm_hour, - local_time.tm_min, local_time.tm_sec); - - switch (msg_get_message_type(msg_list.msgInfo[i])) { + switch (m_type) { case MSG_TYPE_SMS: - g_strlcpy(msg_type, "SMS_GSM", sizeof(msg_type)); + g_strlcpy(msg_type, "SMS_GSM", sizeof(msg_type)); break; case MSG_TYPE_MMS: - g_strlcpy(msg_type, "MMS", sizeof(msg_type)); + g_strlcpy(msg_type, "MMS", sizeof(msg_type)); break; default: - g_strlcpy(msg_type, "UNKNOWN", sizeof(msg_type)); + g_strlcpy(msg_type, "UNKNOWN", sizeof(msg_type)); break; } - dbus_g_type_struct_set(value, 0, msg_handle, + + dbus_g_type_struct_set(&value, 0, msg_handle, 1, msg_type, 2, msg_datetime, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); + g_ptr_array_add(array, g_value_get_boxed(&value)); } email: - vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id); - if (vconf_err == -1) { + if (EMAIL_ERROR_NONE != email_load_default_account_id(&account_id)) { if (!msg_ret) - goto fail; + goto fail; } - if (EMF_ERROR_NONE != email_get_mailbox_list(account_id, - EMF_MAILBOX_ALL, + if (EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, + EMAIL_MAILBOX_ALL, &mailbox_list, &mailbox_count)) { if (!msg_ret) - goto fail; + goto fail; } - for (i = 0; i < mailbox_count; i++) - if (!g_ascii_strncasecmp(mailbox_list[i].name, folder, - strlen(mailbox_list[i].name))) - folder_id = mailbox_list[i].account_id; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - mailbox.account_id = folder_id; - mailbox.name = strdup(folder); - if (EMF_ERROR_NONE != email_count_message(&mailbox, &total, &unseen)) { - if (!msg_ret) + if (mailbox_list == NULL) goto fail; - } - if (mailbox.name != NULL) - free(mailbox.name); + for (i = 0; i < mailbox_count; i++) { + DBG("mailbox alias = %s \n", mailbox_list[i].alias); + if (!g_ascii_strncasecmp(mailbox_list[i].alias, folder, + strlen(mailbox_list[i].alias))) { + total = mailbox_list[i].total_mail_count_on_server; + DBG("Total mail on sever : %d \n", total); + DBG("mailbox name : %s \n", mailbox_list[i].mailbox_name); + + break; + } - if (EMF_ERROR_NONE != email_get_mail_list_ex(folder_id, folder, - EMF_LIST_TYPE_NORMAL, - 0, total - 1, EMF_SORT_DATETIME_HIGH, - &mail_list, &mail_count)) { if (!msg_ret) - goto fail; + goto fail; + else + goto done; + } + + /* Need to modify the filter code, have to make it dynamic based on remote device request*/ + /* Also to check whether it needs to be done in agent or in obexd */ + + filter_list = g_new0(email_list_filter_t, 3); + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[0].list_filter_item.rule.key_value.integer_type_value = account_id; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + type = g_strdup(mailbox_list[i].mailbox_name); + filter_list[2].list_filter_item.rule.key_value.string_type_value = type; + filter_list[2].list_filter_item.rule.case_sensitivity = true; + + sorting_rule_list = g_new0(email_list_sorting_rule_t, 1); + sorting_rule_list->target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME; + sorting_rule_list->sort_order = EMAIL_SORT_ORDER_ASCEND; + + ret = email_get_mail_list_ex(filter_list, 3, + sorting_rule_list, 1, 0, total - 1, + &mail_list, &mail_count); + + DBG("email API ret %d \n", ret); + if (ret != EMAIL_ERROR_NONE) { + if (!msg_ret) { + g_free(type); + g_free(filter_list); + g_free(sorting_rule_list); + goto fail; + } else + goto done; } for (i = 0; i < mail_count; ++i) { - memset(value, 0, sizeof(GValue)); - g_value_init(value, DBUS_STRUCT_MESSAGE_LIST); - g_value_take_boxed(value, dbus_g_type_specialized_construct( + time_t time = {0,}; + memset(&value, 0, sizeof(GValue)); + g_value_init(&value, DBUS_STRUCT_MESSAGE_LIST); + g_value_take_boxed(&value, dbus_g_type_specialized_construct( DBUS_STRUCT_MESSAGE_LIST)); snprintf(msg_handle, sizeof(msg_handle), "%d%s", @@ -502,21 +633,25 @@ email: BT_MAP_EMAIL); g_strlcpy(msg_type, "EMAIL", sizeof(msg_type)); - /*Dummy for testing purpose*/ - snprintf(msg_datetime, sizeof(msg_datetime), "%dT%d", 2011, 12); - dbus_g_type_struct_set(value, 0, msg_handle, + time = mail_list[i].date_time; + __get_msg_timestamp(&time, msg_datetime); + + dbus_g_type_struct_set(&value, 0, msg_handle, 1, msg_type, 2, msg_datetime, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); + g_ptr_array_add(array, g_value_get_boxed(&value)); } +done: if (mailbox_list != NULL) email_free_mailbox(&mailbox_list, mailbox_count); if (mail_list != NULL) g_free(mail_list); dbus_g_method_return(context, array); g_ptr_array_free(array, TRUE); - g_free(value); + g_free(type); + g_free(filter_list); + g_free(sorting_rule_list); return TRUE; fail: @@ -525,7 +660,6 @@ fail: if (mail_list != NULL) g_free(mail_list); g_ptr_array_free(array, TRUE); - g_free(value); error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL, "InternalError"); dbus_g_method_return_error(context, error); @@ -542,18 +676,14 @@ static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent, char *last = NULL; int message_id = 0; FILE *body_file = NULL; - GValue *value = NULL; - int vconf_err = 0; + GValue value = { 0, }; int account_id = 0; GPtrArray *array = g_ptr_array_new(); - emf_mailbox_t mailbox; - emf_mail_data_t *mail_data = NULL; + email_mail_data_t *mail_data = NULL; int nread = 0; char *buf = NULL; long l_size = 0; - msg_message_t msg; - MSG_ERROR_T msg_err = MSG_SUCCESS; - MSG_SENDINGOPT_S sendOpt = { 0 }; + GError *error = NULL; if (message_name != NULL) { @@ -562,41 +692,57 @@ static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent, goto fail; message_id = atoi(pch); + DBG("message_id %d \n", message_id); pch = strtok_r(NULL, "_", &last); } else goto fail; - value = g_new0(GValue, 1); - - g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(value, dbus_g_type_specialized_construct( + g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); + g_value_take_boxed(&value, dbus_g_type_specialized_construct( DBUS_STRUCT_STRING_STRING_UINT)); if (!g_ascii_strncasecmp(pch, "s", 1)) { if (g_msg_handle == NULL) goto fail; - msg = msg_new_message(); + int msg_size = 0; + msg_error_t msg_err = MSG_SUCCESS; + msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t send_opt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_err = msg_get_message(g_msg_handle, - (MSG_MESSAGE_ID_T)message_id, - msg, &sendOpt); - if (msg_err == MSG_SUCCESS) { - dbus_g_type_struct_set(value, 0, - msg_sms_get_message_body(msg), - G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(value)); + (msg_message_id_t)message_id, msg, send_opt); + if (msg_err != MSG_SUCCESS) + goto fail; + + msg_err = msg_get_int_value(msg, + MSG_MESSAGE_DATA_SIZE_INT, &msg_size); + if (msg_err != MSG_SUCCESS) { + msg_release_struct(&msg); + goto fail; } - msg_release_message(&msg); - } else if (!g_ascii_strncasecmp(pch, "e", 1)) { - vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, - &account_id); - if (vconf_err == -1) + + buf = (char *)calloc(msg_size, sizeof(char)); + if (NULL == buf) goto fail; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - mailbox.account_id = account_id; + msg_err = msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, + buf, msg_size); + if (msg_err != MSG_SUCCESS) { + msg_release_struct(&msg); + goto fail; + } + + dbus_g_type_struct_set(&value, 0, + buf, G_MAXUINT); + g_ptr_array_add(array, g_value_get_boxed(&value)); - if (EMF_ERROR_NONE == email_get_mail_data(message_id, &mail_data)) { + msg_release_struct(&msg); + } else if (!g_ascii_strncasecmp(pch, "e", 1)) { + if (EMAIL_ERROR_NONE != email_load_default_account_id(&account_id)) + goto fail; + + if (EMAIL_ERROR_NONE == email_get_mail_data(message_id, &mail_data)) { body_file = fopen(mail_data->file_path_plain, "r"); if (body_file == NULL) body_file = fopen(mail_data->file_path_html, "rb"); @@ -611,20 +757,18 @@ static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent, goto fail; nread = fread(buf, 1, l_size, body_file); - if (nread != l_size) goto fail; - dbus_g_type_struct_set(value, 0, buf, + dbus_g_type_struct_set(&value, 0, buf, G_MAXUINT); g_ptr_array_add(array, - g_value_get_boxed(value)); + g_value_get_boxed(&value)); } } } dbus_g_method_return(context, array); - g_free(value); g_ptr_array_free(array, TRUE); if (body_file != NULL) fclose(body_file); @@ -634,7 +778,6 @@ static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent, email_free_mail_data(&mail_data, 1); return TRUE; fail: - g_free(value); g_ptr_array_free(array, TRUE); if (body_file != NULL) fclose(body_file); @@ -642,6 +785,7 @@ fail: free(buf); if (mail_data) email_free_mail_data(&mail_data, 1); + error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL, "InternalError"); dbus_g_method_return_error(context, error); @@ -653,18 +797,18 @@ static gboolean bluetooth_map_update_message(BluetoothMapAgent *agent, DBusGMethodInvocation *context) { unsigned handle = 0; - int err = EMF_ERROR_NONE; + int err; err = email_sync_header_for_all_account(&handle); - if (err == EMF_ERROR_NONE) { + if (err == EMAIL_ERROR_NONE) { DBG("Handle to stop download = %d \n", handle); } else { ERR("Message Update failed \n"); } dbus_g_method_return(context, err); - return (err == EMF_ERROR_NONE) ? TRUE : FALSE; + return (err == EMAIL_ERROR_NONE) ? TRUE : FALSE; } static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, @@ -675,13 +819,9 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, char *pch = NULL; char *last = NULL; int message_id = 0; - emf_mailbox_t mailbox; - emf_mail_data_t *mail_data = NULL; - msg_message_t msg; - MSG_ERROR_T err = MSG_SUCCESS; - MSG_SENDINGOPT_S sendOpt = { 0 }; + email_mail_data_t *mail_data = NULL; int ret = 0; - bool flag = FALSE; + gboolean flag = FALSE; GError *error = NULL; DBG("bluetooth_map_message_status"); @@ -701,21 +841,42 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, if (!g_ascii_strncasecmp(pch, "s", 1)) { switch (indicator) { case BT_MSG_UPDATE:{ - msg = msg_new_message(); - err = msg_get_message(g_msg_handle, - (MSG_MESSAGE_ID_T)message_id, msg, - &sendOpt); - if (err != MSG_SUCCESS) { - msg_release_message(&msg); + msg_error_t msg_err = MSG_SUCCESS; + msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t send_opt = msg_create_struct(MSG_STRUCT_SENDOPT); + int msg_type = 0; + bool read_status = true; + + + msg_err = msg_get_message(g_msg_handle, + (msg_message_id_t)message_id, msg, + send_opt); + if (msg_err != MSG_SUCCESS) { + msg_release_struct(&msg); goto done; } - if (!msg_is_read(msg)) { + msg_err = msg_get_bool_value(msg, MSG_MESSAGE_READ_BOOL, + &read_status); + if (msg_err != MSG_SUCCESS) { + msg_release_struct(&msg); + goto done; + } + + msg_err = msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, + &msg_type); + if (msg_err != MSG_SUCCESS) { + msg_release_struct(&msg); + goto done; + } + + + if (read_status == false) { DBG(" Message is UNREAD \n"); ret = msg_update_read_status( g_msg_handle, message_id, TRUE); - if (msg_is_mms(msg)) { + if (__bt_msg_is_mms(msg_type)) { ret = msg_mms_send_read_report( g_msg_handle, message_id, @@ -727,16 +888,18 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, g_msg_handle, message_id, FALSE); - if (msg_is_mms(msg)) { + if (__bt_msg_is_mms(msg_type)) { ret = msg_mms_send_read_report( g_msg_handle, message_id, MSG_READ_REPORT_NONE); } } + if (ret == MSG_SUCCESS) flag = TRUE; - msg_release_message(&msg); + + msg_release_struct(&msg); break; } @@ -758,34 +921,34 @@ static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent, } else if (!g_ascii_strncasecmp(pch, "e", 1)) { switch (indicator) { case 0: { - emf_mail_flag_t newflag; - memset(&newflag, 0x00, sizeof(emf_mail_flag_t)); - newflag.seen = !newflag.seen; - newflag.answered = 0; - newflag.sticky = 1; - - if (email_modify_mail_flag(message_id, newflag, - 1) < 0) { - ERR("email_modify_mail_flag failed \n"); + if (email_get_mail_data(message_id, &mail_data) != EMAIL_ERROR_NONE) { + ERR("email_get_mail_data failed\n"); + flag = FALSE; + break; + } + + if (email_set_flags_field(mail_data->account_id, &message_id, 1, + EMAIL_FLAGS_SEEN_FIELD, 1, 0) != EMAIL_ERROR_NONE) { + + ERR("email_set_flags_field failed \n"); flag = FALSE; } else { - DBG("email_modify_mail_flag success \n"); + DBG("email_set_flags_field success \n"); flag = TRUE; } break; } case 1: { - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - if (email_get_mail_data(message_id, &mail_data) < 0) { + if (email_get_mail_data(message_id, &mail_data) != EMAIL_ERROR_NONE) { ERR("email_get_mail failed\n"); } else { DBG("email_get_mail success\n"); - if (email_delete_message(&mailbox, &message_id, - 1, 1) >= 9) { - DBG("\n email_delete_message success"); + if (email_delete_mail(mail_data->mailbox_id, &message_id, + 1, 1) == EMAIL_ERROR_NONE) { + DBG("\n email_delete_mail success"); flag = TRUE; } else { - ERR("\n email_delete_message failed"); + ERR("\n email_delete_mail failed"); flag = FALSE; } email_free_mail_data(&mail_data, 1); @@ -803,7 +966,7 @@ done: dbus_g_method_return(context, ret); else { error = __bt_map_agent_error(BT_MAP_AGENT_ERROR_INTERNAL, - "InternalError"); + "InternalError"); dbus_g_method_return_error(context, error); g_error_free(error); } @@ -872,6 +1035,9 @@ int main(int argc, char **argv) BT_MAP_SERVICE_OBJECT_PATH, G_OBJECT(bluetooth_map_obj)); + if (__bluetooth_map_start_service() == FALSE) + goto failure; + g_main_loop_run(mainloop); failure: diff --git a/bluetooth-pb-agent/CMakeLists.txt b/bluetooth-pb-agent/CMakeLists.txt index c1bb0f22..78bb4dbf 100644 --- a/bluetooth-pb-agent/CMakeLists.txt +++ b/bluetooth-pb-agent/CMakeLists.txt @@ -1,8 +1,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-pb-agent C) -SET(SRCS bluetooth_pb_agent.c) -SET(APP_VENDOR samsung) +SET(SRCS bluetooth_pb_agent.c bluetooth_pb_vcard.c) +SET(APP_VENDOR tizen) SET(APP_NAME bluetooth-pb-agent) SET(APP_DIR /usr/bin) SET(APP_LOCALEDIR /usr/share/locale) diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.c b/bluetooth-pb-agent/bluetooth_pb_agent.c index 2ad492e4..cc8b2c3e 100644 --- a/bluetooth-pb-agent/bluetooth_pb_agent.c +++ b/bluetooth-pb-agent/bluetooth_pb_agent.c @@ -6,6 +6,7 @@ * Contact: Hocheol Seo * Girishashok Joshi * Chanyeol Park + * Jaekyun Lee * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,53 +26,26 @@ #include #include #include +#include #include #include -#include #include -#include "vconf.h" -#include "vconf-keys.h" - #include #include #include #include "bluetooth_pb_agent.h" +#include "bluetooth_pb_vcard.h" -#define CALL_LOG_VCARD "BEGIN:VCARD\r\n" \ - "VERSION:2.1\r\n" \ - "N:%s;%s\r\n" \ - "TEL:%s\r\n" \ - "X-IRMC-CALL-DATETIME;%s:%s\r\n" \ - "END:VCARD\r\n" - -#define PBAP_OWNER_VCARD "BEGIN:VCARD\r\n" \ - "VERSION:2.1\r\n" \ - "TEL:%s\r\n" \ - "END:VCARD\r\n" - -#define PBAP_EMPTY_VCARD "BEGIN:VCARD\r\n" \ - "VERSION:2.1\r\n" \ - "END:VCARD\r\n" - -#define VCARD_NO_NAME "Noname" -#define MAX_CONTACT_NAME_LEN 256 -#define MAX_CONTACT_NUM_LEN 20 -#define PBAP_OWNER_VCARD_MAX_LEN 255 -#define VCARD_MAX_LEN 3000 - -#define DBUS_STRUCT_STRING_STRING_UINT (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \ - G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)) - -enum PhoneBookObject { +typedef enum { TELECOM_NONE = 0, TELECOM_PB, TELECOM_ICH, TELECOM_OCH, TELECOM_MCH, - TELECOM_CCH, -}; + TELECOM_CCH +} PhoneBookType; typedef struct { GObject parent; @@ -79,8 +53,16 @@ typedef struct { typedef struct { GObjectClass parent; + + void (*clear) (BluetoothPbAgent *agent); } BluetoothPbAgentClass; + +enum { + CLEAR, + LAST_SIGNAL +}; + GType bluetooth_pb_agent_get_type(void); #define BLUETOOTH_PB_TYPE_AGENT (bluetooth_pb_agent_get_type()) @@ -91,10 +73,10 @@ GType bluetooth_pb_agent_get_type(void); #define BLUETOOTH_PB_AGENT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), \ BLUETOOTH_PB_TYPE_AGENT , BluetoothPbAgentClass)) -#define BLUETOOTH_PB_IS_AGENT(object) \ +#define BLUETOOTH_IS_PB_AGENT(object) \ (G_TYPE_CHECK_INSTANCE_TYPE((object), \ BLUETOOTH_PB_TYPE_AGENT)) -#define BLUETOOTH_PB_IS_AGENT_CLASS(klass) \ +#define BLUETOOTH_IS_PB_AGENT_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass), \ BLUETOOTH_PB_TYPE_AGENT)) #define BLUETOOTH_PB_AGENT_GET_CLASS(obj) \ @@ -103,762 +85,572 @@ GType bluetooth_pb_agent_get_type(void); G_DEFINE_TYPE(BluetoothPbAgent, bluetooth_pb_agent, G_TYPE_OBJECT) -GMainLoop *mainloop = NULL; +#define DBUS_STRUCT_STRING_STRING_UINT (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \ + G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)) + +static guint signals[LAST_SIGNAL] = { 0 }; +static GMainLoop *mainloop = NULL; + +static GHashTable *contact_list_hash = NULL; + +static PhoneBookType g_current_pb_type = TELECOM_NONE; + +static void bluetooth_pb_agent_finalize(GObject *obj); + +static void bluetooth_pb_agent_clear(BluetoothPbAgent *agent); + +/* Dbus messages */ static gboolean bluetooth_pb_get_phonebook(BluetoothPbAgent *agent, - gushort max_list, - gushort offset, + const char *name, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset, DBusGMethodInvocation *context); -static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, - gushort max_list, - gushort offset, - gchar *call_type, - DBusGMethodInvocation *context); - static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, const char *name, DBusGMethodInvocation *context); -static gboolean bluetooth_pb_get_total_object_count(BluetoothPbAgent *agent, - gchar *path, +static gboolean bluetooth_pb_get_phonebook_list(BluetoothPbAgent *agent, + const char *name, DBusGMethodInvocation *context); -static gboolean bluetooth_pb_get_phonebook_list(BluetoothPbAgent *agent, +static gboolean bluetooth_pb_get_phonebook_entry(BluetoothPbAgent *agent, + const gchar *folder, + const gchar *id, + guint64 filter, + guint8 format, DBusGMethodInvocation *context); -static gboolean bluetooth_pb_get_calls_list(BluetoothPbAgent *agent, - gchar *call_type, - DBusGMethodInvocation *context); +static gboolean bluetooth_pb_get_phonebook_size_at(BluetoothPbAgent *agent, + const gchar *command, + DBusGMethodInvocation *context); -static gboolean bluetooth_pb_get_phonebook_entry(BluetoothPbAgent *agent, - gchar *id, - DBusGMethodInvocation *context); +static gboolean bluetooth_pb_get_phonebook_entries_at(BluetoothPbAgent *agent, + const gchar *command, + gint32 start_index, + gint32 end_index, + DBusGMethodInvocation *context); + +static gboolean bluetooth_pb_get_phonebook_entries_find_at(BluetoothPbAgent *agent, + const gchar *command, + const gchar *find_text, + DBusGMethodInvocation *context); -static gboolean bluetooth_pb_get_calls_entry(BluetoothPbAgent *agent, - gchar *id, - DBusGMethodInvocation *context); +static gboolean bluetooth_pb_get_total_object_count(BluetoothPbAgent *agent, + gchar *path, + DBusGMethodInvocation *context); static gboolean bluetooth_pb_add_contact (BluetoothPbAgent *agent, const char *filename, - GError **error); + GError **error); +static void __bluetooth_pb_dbus_return_error(DBusGMethodInvocation *context, + gint code, + const gchar *message); -static unsigned int __bluetooth_pb_get_call_size(const enum PhoneBookObject pb_oject); +static PhoneBookType __bluetooth_pb_get_pb_type(const char *name); -#include "bluetooth_pb_agent_glue.h" +static PhoneBookType __bluetooth_pb_get_storage_pb_type(const char *name); -static void bluetooth_pb_agent_init(BluetoothPbAgent *obj) -{ - DBG("+\n"); - g_assert(obj != NULL); -} +static unsigned int __bluetooth_pb_get_contact_size(void); -static void bluetooth_pb_agent_finalize(GObject *obj) -{ - DBG("+\n"); +static unsigned int __bluetooth_pb_get_incoming_call_size(void); - G_OBJECT_CLASS(bluetooth_pb_agent_parent_class)->finalize(obj); -} +static unsigned int __bluetooth_pb_get_outgoing_call_size(void); -static void bluetooth_pb_agent_class_init(BluetoothPbAgentClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; +static unsigned int __bluetooth_pb_get_missed_call_size(void); - g_assert(klass != NULL); +static unsigned int __bluetooth_pb_get_combined_call_size(void); - object_class->finalize = bluetooth_pb_agent_finalize; - dbus_g_object_type_install_info(BLUETOOTH_PB_TYPE_AGENT, - &dbus_glib_bluetooth_pb_object_info); -} +static GPtrArray *__bluetooth_pb_get_contact_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset); -static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, - const char *name, - DBusGMethodInvocation *context) -{ - unsigned int phonebook_size = 0; +static GPtrArray *__bluetooth_pb_get_incoming_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset); - DBG("%s() %d\n", __FUNCTION__, __LINE__); +static GPtrArray *__bluetooth_pb_get_outgoing_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset); - if (name == NULL) { - GError *error = NULL; - GQuark quark; +static GPtrArray *__bluetooth_pb_get_missed_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset); - quark = g_type_qname(bluetooth_pb_agent_get_type()); - error = g_error_new(quark, -1, "No name defined"); +static GPtrArray *__bluetooth_pb_get_combined_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset); - DBG("no name defined\n"); +static void __bluetooth_pb_create_contact_index(PhoneBookType pb_type); - dbus_g_method_return_error(context, error); +static void __bluetooth_pb_create_call_index(PhoneBookType pb_type); - g_error_free(error); +static void __bluetooth_pb_get_contact_list(PhoneBookType pb_type, + GPtrArray *ptr_array, + gint start_index, + gint end_index, + gboolean formatted_name); - return FALSE; - } +static void __bluetooth_pb_get_call_list(PhoneBookType pb_type, + GPtrArray *ptr_array, + gint start_index, + gint end_index, + gboolean formatted_name); - if (g_strcmp0(name, "/telecom/pb.vcf") == 0) { - contacts_svc_connect(); +static void __bluetooth_pb_get_contact_list_by_name(PhoneBookType pb_type, + GPtrArray *ptr_array, + const gchar *find_text, + gboolean formatted_name, + gboolean owner); - phonebook_size = contacts_svc_count(CTS_GET_ALL_CONTACT); - DBG("Number of contacts is %d\n", phonebook_size); +static void __bluetooth_pb_get_call_list_by_name(PhoneBookType pb_type, + GPtrArray *ptr_array, + const gchar *find_text, + gboolean formatted_name); - contacts_svc_disconnect(); +static int __bluetooth_get_calllog_type(int call_type); - /* add count for owner (0.vcf) */ - phonebook_size++; - } else if (g_strcmp0(name, "/telecom/ich.vcf") == 0) { - phonebook_size = __bluetooth_pb_get_call_size(TELECOM_ICH); - } else if (g_strcmp0(name, "/telecom/och.vcf") == 0) { - phonebook_size = __bluetooth_pb_get_call_size(TELECOM_OCH); - } else if (g_strcmp0(name, "/telecom/mch.vcf") == 0) { - phonebook_size = __bluetooth_pb_get_call_size(TELECOM_MCH); - } else if (g_strcmp0(name, "/telecom/cch.vcf") == 0) { - phonebook_size = __bluetooth_pb_get_call_size(TELECOM_CCH); - } +static unsigned int __get_call_log_count(unsigned int call_log_type); - dbus_g_method_return(context, phonebook_size); - return TRUE; -} +static void __bluetooth_pb_list_hash_reset(void); +static gboolean __bluetooth_pb_list_hash_insert(gint handle, + gint id); -static int __bluetooth_get_calllog_type(int call_type) -{ - int val = CTS_PLOG_TYPE_NONE; - switch (call_type) { - case CTS_PLOG_TYPE_VOICE_INCOMMING: - case CTS_PLOG_TYPE_VIDEO_INCOMMING: - val = CTS_PLOG_TYPE_VOICE_INCOMMING; - break; +static gint __bluetooth_pb_list_hash_lookup_id(gint handle); - case CTS_PLOG_TYPE_VOICE_OUTGOING: - case CTS_PLOG_TYPE_VIDEO_OUTGOING: - val = CTS_PLOG_TYPE_VOICE_OUTGOING; - break; +static guint __bluetooth_pb_list_hash_size(void); - case CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN: - case CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN: - case CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN: - case CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN: - val = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; - break; - default: - break; - } +static void __bluetooth_pb_list_ptr_array_add(GPtrArray *ptr_array, + const gchar *name, + const gchar *number, + gint handle); - return val; -} +static void __bluetooth_pb_list_ptr_array_free(gpointer data); -static unsigned int __get_call_log_count(unsigned int call_log_type) -{ - CTSiter *iter = NULL; - unsigned int count = 0; +static void __bluetooth_pb_agent_signal_handler(int signum); - contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter); - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { - CTSvalue *plog = NULL; +static void __bluetooth_pb_contact_changed(void *user_data); - plog = contacts_svc_iter_get_info(iter); - if (plog) { - int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); - DBG("type: %d\n", type); - int log_type = __bluetooth_get_calllog_type(type); - - if ((call_log_type == 0xFF || call_log_type == log_type) && - (log_type != CTS_PLOG_TYPE_NONE)) { - count++; - } - } - } - return count; +static void __bluetooth_pb_call_changed(void *user_data); + + +#include "bluetooth_pb_agent_glue.h" + +static void bluetooth_pb_agent_init(BluetoothPbAgent *obj) +{ } -static gboolean bluetooth_pb_get_total_object_count(BluetoothPbAgent *agent, - gchar *path, DBusGMethodInvocation *context) + +static void bluetooth_pb_agent_class_init(BluetoothPbAgentClass *klass) { - unsigned int nr_contact = 0; + GObjectClass *object_class = (GObjectClass *) klass; - DBG("%s() %d\n", __FUNCTION__, __LINE__); - contacts_svc_connect(); + klass->clear = bluetooth_pb_agent_clear; - if ((g_strcmp0(path, "SM") == 0) || (g_strcmp0(path, "ME") == 0)) { - nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT); - } else if (g_strcmp0(path, "DC") == 0) { - nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_OUTGOING); - } else if (g_strcmp0(path, "MC") == 0) { - nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN); - } else if (g_strcmp0(path, "RC") == 0) { - nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_INCOMMING); - } - DBG("Number of contacts is %d\n", nr_contact); + object_class->finalize = bluetooth_pb_agent_finalize; - contacts_svc_disconnect(); + signals[CLEAR] = g_signal_new("clear", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(BluetoothPbAgentClass, clear), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); - DBG("%s() %d\n", __FUNCTION__, __LINE__); + dbus_g_object_type_install_info(BLUETOOTH_PB_TYPE_AGENT, + &dbus_glib_bluetooth_pb_object_info); +} - dbus_g_method_return(context, nr_contact); +static void bluetooth_pb_agent_finalize(GObject *obj) +{ + DBG("+\n"); - return TRUE; + G_OBJECT_CLASS(bluetooth_pb_agent_parent_class)->finalize(obj); } -static void __get_vcard_from_contact(int id, int *vcard_total_len, char **vcard) +static void bluetooth_pb_agent_clear(BluetoothPbAgent *agent) { - int ret; - int vcard_len; - char *vcard_stream; - CTSstruct *contact = NULL; - - contacts_svc_get_contact(id, &contact); - - ret = contacts_svc_get_vcard_from_contact(contact, &vcard_stream); - if (CTS_SUCCESS == ret) { - vcard_len = strlen(vcard_stream); - *vcard_total_len += vcard_len; - DBG("len:%d total:%d\n", vcard_len, *vcard_total_len); - *vcard = strdup(vcard_stream); - free(vcard_stream); + DBG("+\n"); + + if (contact_list_hash) { + g_hash_table_destroy(contact_list_hash); + contact_list_hash = NULL; } - contacts_svc_struct_free(contact); + g_current_pb_type = TELECOM_NONE; } static gboolean bluetooth_pb_get_phonebook(BluetoothPbAgent *agent, - gushort max_list, gushort offset, + const char *name, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset, DBusGMethodInvocation *context) { - int i = 0; - int nr_contact = 0; - int vcard_total_len = 0; - - CTSiter *iter = NULL; - static int *contact_id = NULL; - static int index = 0; - int last_part = 0; - - char **vcard; - - DBG("max_list:%d offset:%d\n", max_list, offset); - - contacts_svc_connect(); - - nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT); - DBG("Number of contacts is %d\n", nr_contact); - - vcard = g_new0(char *, nr_contact + 1); - - /* first request */ - if (!contact_id) { - contact_id = (int *)malloc(nr_contact * sizeof(int)); - if (!contact_id) { - DBG("malloc error\n"); - contacts_svc_disconnect(); - g_strfreev(vcard); - - return FALSE; - } - - contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter); + PhoneBookType pb_type = TELECOM_NONE; + GPtrArray *vcards = NULL; + gchar **vcards_str = NULL; - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { - CTSvalue *row_info = NULL; - int id; + gint new_missed_calls = 0; - row_info = contacts_svc_iter_get_info(iter); - id = contacts_svc_value_get_int(row_info, - CTS_LIST_CONTACT_ID_INT); - contact_id[i] = id; + DBG("\n"); - if (vcard_total_len < VCARD_MAX_LEN) { - __get_vcard_from_contact(id, &vcard_total_len, - &vcard[i]); - DBG("vcard:%s\n", vcard[i]); - index++; - - if (index >= max_list) { - DBG("Over max list%d\n", max_list); - break; - } - } - - contacts_svc_value_free(row_info); - i++; - } - if( NULL != iter ) { - contacts_svc_iter_remove(iter); - } - } else { /* subsequent request */ - while (vcard_total_len < VCARD_MAX_LEN) { - __get_vcard_from_contact(contact_id[index], - &vcard_total_len, &vcard[i]); - DBG("vcard:%s\n", vcard[i]); - - index++; - i++; + pb_type = __bluetooth_pb_get_pb_type(name); - if (index >= nr_contact || index >= max_list) { - DBG("Complete\n"); - break; - } - } - } - contacts_svc_disconnect(); + switch (pb_type) { + case TELECOM_PB: + vcards = __bluetooth_pb_get_contact_vcards(agent, + filter, format, + max_list_count, list_start_offset); + break; + case TELECOM_ICH: + vcards = __bluetooth_pb_get_incoming_call_vcards(agent, + filter, format, + max_list_count, list_start_offset); + break; + case TELECOM_OCH: + vcards = __bluetooth_pb_get_outgoing_call_vcards(agent, + filter, format, + max_list_count, list_start_offset); + break; + case TELECOM_MCH: + vcards = __bluetooth_pb_get_missed_call_vcards(agent, + filter, format, + max_list_count, list_start_offset); + break; + case TELECOM_CCH: + vcards = __bluetooth_pb_get_combined_call_vcards(agent, + filter, format, + max_list_count, list_start_offset); + break; + default: { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); + return FALSE; + } - if (index >= nr_contact || index >= max_list) { - free(contact_id); - contact_id = NULL; - index = 0; - last_part = 1; } - dbus_g_method_return(context, last_part, vcard); + if (vcards) + vcards_str = (gchar **) g_ptr_array_free(vcards, FALSE); + + /* TODO : new_missed_calls need to implement */ + dbus_g_method_return(context, vcards_str, new_missed_calls); - g_strfreev(vcard); + g_strfreev(vcards_str); - return TRUE; + return TRUE; } -static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, gushort max_list, gushort offset, - gchar *call_type, DBusGMethodInvocation *context) +static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, + const char *name, + DBusGMethodInvocation *context) { - int call_log_type; - int i = 0; - char **vcard; - char vcard_buffer[256] = {0,}; - CTSiter *iter = NULL; - - DBG("%s() %d\n", __FUNCTION__, __LINE__); - contacts_svc_connect(); - - if (strncmp(call_type, "incoming", 8) == 0) - call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING; - else if (strncmp(call_type, "outgoing", 8) == 0) - call_log_type = CTS_PLOG_TYPE_VOICE_OUTGOING; - else if (strncmp(call_type, "missed", 6) == 0) - call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; - else - call_log_type = 0xFF; - - vcard = g_new0(char *, max_list + 1); - - contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter); - - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { - CTSvalue *plog = NULL; - - plog = contacts_svc_iter_get_info(iter); - if (plog) { - struct tm timeinfo; - char log_time_stamp[32] = {0,}; - char calllog_type[10] = {0,}; - int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); - DBG("type: %d\n", type); - int log_type = __bluetooth_get_calllog_type(type); - - const char *number = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_NUMBER_STR); - const char *first_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_FIRST_NAME_STR); - const char *last_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_LAST_NAME_STR); - - time_t time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT); - - if (!number) { - contacts_svc_value_free(plog); - continue; - } - if (!first_name) - first_name = ""; - if (!last_name) - last_name = ""; - - localtime_r(&time, &timeinfo); - - strftime(log_time_stamp, sizeof(log_time_stamp), - "%Y%m%dT%H%M%S", &timeinfo); - - if (log_type == CTS_PLOG_TYPE_VOICE_INCOMMING) - strncpy(calllog_type, "RECEIVED", strlen("RECEIVED")); - else if (log_type == CTS_PLOG_TYPE_VOICE_OUTGOING) - strncpy(calllog_type, "DIALED", strlen("DIALED")); - else if (log_type == CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN) - strncpy(calllog_type, "MISSED", strlen("MISSED")); - else { - DBG("no log type found \n"); - } - - if ((call_log_type == 0xFF || call_log_type == log_type) && - (log_type != CTS_PLOG_TYPE_NONE)) { - - snprintf(vcard_buffer, sizeof(vcard_buffer), CALL_LOG_VCARD, - last_name, first_name, number, calllog_type, log_time_stamp); + PhoneBookType pb_type = TELECOM_NONE; + unsigned int phonebook_size = 0; - vcard[i] = strdup((char *)vcard_buffer); - DBG("%s() %d [%d] %s\n", __FUNCTION__, __LINE__, i, vcard[i]); - i++; - } + DBG("\n"); - contacts_svc_value_free(plog); + pb_type = __bluetooth_pb_get_pb_type(name); - if (i >= max_list) { - DBG("Over max list count %d\n", max_list); - break; - } - } + switch (pb_type) { + case TELECOM_PB: + phonebook_size = __bluetooth_pb_get_contact_size(); + break; + case TELECOM_ICH: + phonebook_size = __bluetooth_pb_get_incoming_call_size(); + break; + case TELECOM_OCH: + phonebook_size = __bluetooth_pb_get_outgoing_call_size(); + break; + case TELECOM_MCH: + phonebook_size = __bluetooth_pb_get_missed_call_size(); + break; + case TELECOM_CCH: + phonebook_size = __bluetooth_pb_get_combined_call_size(); + break; + default: { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); + return FALSE; } - if( NULL != iter ) { - contacts_svc_iter_remove(iter); } - contacts_svc_disconnect(); - - DBG("%s() %d\n", __FUNCTION__, __LINE__); - dbus_g_method_return(context, vcard); - g_strfreev(vcard); + dbus_g_method_return(context, phonebook_size); return TRUE; } + static gboolean bluetooth_pb_get_phonebook_list(BluetoothPbAgent *agent, + const char *name, DBusGMethodInvocation *context) { - unsigned int nr_contact = 0; - guint ret = 0; - CTSiter *iter = NULL; - GPtrArray *array = g_ptr_array_new(); - char *subscriber_number = NULL; - - DBG("%s() %d\n", __FUNCTION__, __LINE__); + PhoneBookType pb_type = TELECOM_NONE; - GValue owner_value = {0, }; + GPtrArray *ptr_array; - /* owner's vcard 0.vcf */ - g_value_init(&owner_value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(&owner_value, - dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT)); + DBG("\n"); - subscriber_number = vconf_get_str(VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER); - if (NULL == subscriber_number) { - DBG("vconf_get_int failed for VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER \n"); + pb_type = __bluetooth_pb_get_pb_type(name); - dbus_g_type_struct_set(&owner_value, 0, " ", 1, " ", 2, 0, G_MAXUINT); - } else { - dbus_g_type_struct_set(&owner_value, 0, subscriber_number, 1, - subscriber_number, 2, 0, G_MAXUINT); + if (pb_type == TELECOM_NONE) { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); + return FALSE; } - g_ptr_array_add(array, g_value_get_boxed(&owner_value)); - - if (subscriber_number) - free(subscriber_number); + ptr_array = g_ptr_array_new_with_free_func(__bluetooth_pb_list_ptr_array_free); - contacts_svc_connect(); + if (pb_type == TELECOM_PB) + __bluetooth_pb_get_contact_list(pb_type, ptr_array, 0, G_MAXINT, FALSE); + else + __bluetooth_pb_get_call_list(pb_type, ptr_array, 0, G_MAXINT, FALSE); - nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT); - DBG("Number of contacts is %d\n", nr_contact); + dbus_g_method_return(context, ptr_array); - contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter); + if (ptr_array) + g_ptr_array_free(ptr_array, TRUE); - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { - int index_num; - char name[MAX_CONTACT_NAME_LEN + 2] = { 0 }; - const char *first = NULL; - const char *last = NULL; - const char *default_num = NULL; + return TRUE; +} - CTSvalue *row_info = NULL; - CTSvalue *number = NULL; - GValue value = {0, }; - row_info = contacts_svc_iter_get_info(iter); +static gboolean bluetooth_pb_get_phonebook_entry(BluetoothPbAgent *agent, + const gchar *folder, + const gchar *id, + guint64 filter, + guint8 format, + DBusGMethodInvocation *context) +{ + PhoneBookType pb_type = TELECOM_NONE; - if (!row_info) { - DBG("contacts_svc_iter_get_info failed \n"); - break; - } + gint handle = 0; + gint cid = -1; + gchar *str = NULL; - first = contacts_svc_value_get_str(row_info, CTS_LIST_CONTACT_FIRST_STR); - last = contacts_svc_value_get_str(row_info, CTS_LIST_CONTACT_LAST_STR); - - if (first && last) { - g_strlcpy(name, last, sizeof(name) / 2); - g_strlcat(name, ";", sizeof(name)); - g_strlcat(name, first, sizeof(name)); - } else if (first) { - g_strlcpy(name, first, sizeof(name)); - } else if (last) { - g_strlcpy(name, last, sizeof(name)); - } else { - g_strlcpy(name, VCARD_NO_NAME, sizeof(name)); - } + DBG("\n"); - index_num = contacts_svc_value_get_int(row_info, CTS_LIST_CONTACT_ID_INT); + if (!g_str_has_suffix(id, ".vcf")) { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "invalid vcf file"); + return FALSE; + } - ret = contacts_svc_get_contact_value(CTS_GET_DEFAULT_NUMBER_VALUE, index_num, - &number); + handle = (gint)g_ascii_strtoll(id, NULL, 10); + cid = __bluetooth_pb_list_hash_lookup_id(handle); - if (CTS_SUCCESS != ret) { - DBG("contacts_svc_get_contact_value() Failed(%d)\n", ret); - } else { - default_num = contacts_svc_value_get_str(number, CTS_NUM_VAL_NUMBER_STR); - DBG("The default Number is %s\n", default_num); - } + DBG("id %s handle%d, cid %d\n", id, handle, cid ); - g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(&value, - dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT)); - dbus_g_type_struct_set(&value, 0, name, 1, default_num, 2, index_num, G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(&value)); + pb_type = __bluetooth_pb_get_pb_type(folder); + switch (pb_type) { + case TELECOM_PB: + __bluetooth_pb_create_contact_index(pb_type); + str = _bluetooth_pb_vcard_contact(cid, filter, format); + break; + case TELECOM_ICH: + __bluetooth_pb_create_call_index(pb_type); + str = _bluetooth_pb_vcard_call(cid, filter, format, "RECEIVED"); + break; + case TELECOM_OCH: + __bluetooth_pb_create_call_index(pb_type); + str = _bluetooth_pb_vcard_call(cid, filter, format, "DIALED"); + break; + case TELECOM_MCH: + __bluetooth_pb_create_call_index(pb_type); + str = _bluetooth_pb_vcard_call(cid, filter, format, "MISSED"); + break; + case TELECOM_CCH: { + char *attr = NULL; - if (number) - contacts_svc_value_free(number); + if (_bluetooth_pb_is_incoming_call(cid)) + attr = "RECEIVED"; + else if (_bluetooth_pb_is_outgoing_call(cid)) + attr = "DIALED"; + else if (_bluetooth_pb_is_missed_call(cid)) + attr = "MISSED"; - if (row_info) - contacts_svc_value_free(row_info); + __bluetooth_pb_create_call_index(pb_type); + str = _bluetooth_pb_vcard_call(cid, filter, format, attr); + break; } - - if( NULL != iter ) { - contacts_svc_iter_remove(iter); + default: { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); + return FALSE; } - contacts_svc_disconnect(); - - DBG("%s() %d\n", __FUNCTION__, __LINE__); - - dbus_g_method_return(context, array); + } - g_ptr_array_foreach(array, (GFunc)g_value_array_free, NULL); - g_ptr_array_free(array, TRUE); + dbus_g_method_return(context, str); + g_free(str); return TRUE; } -static gboolean bluetooth_pb_get_calls_list(BluetoothPbAgent *agent, gchar *call_type, - DBusGMethodInvocation *context) +static gboolean bluetooth_pb_get_phonebook_size_at(BluetoothPbAgent *agent, + const gchar *command, + DBusGMethodInvocation *context) { - int call_log_type; - char name[256] = {0,}; - GPtrArray *array = g_ptr_array_new(); - - CTSiter *iter = NULL; - - DBG("%s() %d call_type:%s\n", __FUNCTION__, __LINE__, call_type); + PhoneBookType pb_type = TELECOM_NONE; + unsigned int phonebook_size = 0; - if (strncmp(call_type, "incoming", 8) == 0) - call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING; - else if (strncmp(call_type, "outgoing", 8) == 0) - call_log_type = CTS_PLOG_TYPE_VOICE_OUTGOING; - else if (strncmp(call_type, "missed", 6) == 0) - call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; - else - call_log_type = 0xFF; + DBG("\n"); - contacts_svc_connect(); + pb_type = __bluetooth_pb_get_storage_pb_type(command); - contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter); - - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { - CTSvalue *plog = NULL; - - plog = contacts_svc_iter_get_info(iter); - if (plog) { - int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT); - int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); - int log_type = __bluetooth_get_calllog_type(type); - const char *number = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_NUMBER_STR); - const char *first_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_FIRST_NAME_STR); - const char *last_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_LAST_NAME_STR); - - if (!number) { - DBG("number is NULL\n"); - contacts_svc_value_free(plog); - continue; - } - DBG("number: %s\n", number); - - if (first_name && last_name) - snprintf(name, sizeof(name), "%s;%s;", last_name, first_name); - else if (first_name) - snprintf(name, sizeof(name), ";%s", first_name); - else if (last_name) - snprintf(name, sizeof(name), "%s;", last_name); - else - strncpy(name, number, sizeof(name) - 1); - - if ((call_log_type == 0xFF || call_log_type == log_type) && - (log_type != CTS_PLOG_TYPE_NONE)) { - - GValue value = {0, }; - g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); - g_value_take_boxed(&value, - dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT)); - dbus_g_type_struct_set(&value, 0, name, 1, number, 2, (guint) index, - G_MAXUINT); - g_ptr_array_add(array, g_value_get_boxed(&value)); - } - - contacts_svc_value_free(plog); - } + switch (pb_type) { + case TELECOM_PB: + phonebook_size = __bluetooth_pb_get_contact_size(); + break; + case TELECOM_ICH: + phonebook_size = __bluetooth_pb_get_incoming_call_size(); + break; + case TELECOM_OCH: + phonebook_size = __bluetooth_pb_get_outgoing_call_size(); + break; + case TELECOM_MCH: + phonebook_size = __bluetooth_pb_get_missed_call_size(); + break; + default: { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); + return FALSE; } - if( NULL != iter ) { - contacts_svc_iter_remove(iter); } - contacts_svc_disconnect(); - - DBG("%s() %d\n", __FUNCTION__, __LINE__); - - dbus_g_method_return(context, array); - - g_ptr_array_foreach(array, (GFunc)g_value_array_free, NULL); - g_ptr_array_free(array, TRUE); + dbus_g_method_return(context, phonebook_size); return TRUE; } -static gboolean bluetooth_pb_get_phonebook_entry(BluetoothPbAgent *agent, gchar *id, - DBusGMethodInvocation *context) +static gboolean bluetooth_pb_get_phonebook_entries_at(BluetoothPbAgent *agent, + const gchar *command, + gint start_index, + gint end_index, + DBusGMethodInvocation *context) { + PhoneBookType pb_type = TELECOM_NONE; - int ret = -1; - int index; - CTSstruct *contact = NULL; - char *phonebook_entry = NULL; - - DBG("%s() %d\n", __FUNCTION__, __LINE__); - - if (sscanf(id, "%d.vcf", &index) != 1) { - DBG("Failed to get index\n"); - return FALSE; - } + GPtrArray *ptr_array = NULL; - if (index != 0) { - contacts_svc_connect(); + DBG("command %s, start_index %d, end_index %d %s %d\n", + command, start_index, end_index, __FILE__, __LINE__); - DBG("Get %dth phonebook entry\n", index); - ret = contacts_svc_get_contact(index, &contact); - if (CTS_SUCCESS == ret) { - ret = contacts_svc_get_vcard_from_contact(contact, &phonebook_entry); - if (CTS_SUCCESS == ret) { - DBG("[%s]\n", phonebook_entry); + pb_type = __bluetooth_pb_get_storage_pb_type(command); - dbus_g_method_return(context, phonebook_entry); - } - contacts_svc_struct_free(contact); - } - contacts_svc_disconnect(); + if (pb_type == TELECOM_NONE || pb_type == TELECOM_CCH) { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); + return FALSE; } - if (index == 0 || ret != CTS_SUCCESS) { - DBG("Get owner vcard\n"); - char *subscriber_number = NULL; - - subscriber_number = vconf_get_str(VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER); - if (NULL == subscriber_number) { - DBG("vconf_get_int failed for VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER \n"); - - phonebook_entry = strdup(PBAP_EMPTY_VCARD); - dbus_g_method_return(context, phonebook_entry); - } else { - char vcard_buffer[PBAP_OWNER_VCARD_MAX_LEN + 1] = {0,}; - - if (strlen(subscriber_number) > MAX_CONTACT_NUM_LEN) { - char temp[MAX_CONTACT_NUM_LEN + 1] = {0,}; - strncpy(temp, subscriber_number, MAX_CONTACT_NUM_LEN); - snprintf(vcard_buffer, sizeof(vcard_buffer), PBAP_OWNER_VCARD, - temp); - } else { - snprintf(vcard_buffer, sizeof(vcard_buffer), PBAP_OWNER_VCARD, - subscriber_number); - DBG(" Owner vcard \n %s \n", vcard_buffer); - } + ptr_array = g_ptr_array_new_with_free_func(__bluetooth_pb_list_ptr_array_free); - dbus_g_method_return(context, vcard_buffer); + if (pb_type == TELECOM_PB) + __bluetooth_pb_get_contact_list(pb_type, ptr_array, start_index, end_index, TRUE); + else + __bluetooth_pb_get_call_list(pb_type, ptr_array, start_index, end_index, TRUE); - free(subscriber_number); - } - } + dbus_g_method_return(context, ptr_array); - if (phonebook_entry) - free(phonebook_entry); + if (ptr_array) + g_ptr_array_free(ptr_array, TRUE); return TRUE; } -static gboolean bluetooth_pb_get_calls_entry(BluetoothPbAgent *agent, gchar *id, - DBusGMethodInvocation *context) +static gboolean bluetooth_pb_get_phonebook_entries_find_at(BluetoothPbAgent *agent, + const gchar *command, + const gchar *find_text, + DBusGMethodInvocation *context) { - int calls_index; - char *calls_entry; - char vcard_buffer[256]; - CTSiter *iter = NULL; + PhoneBookType pb_type = TELECOM_NONE; - DBG("%s() %d\n", __FUNCTION__, __LINE__); - contacts_svc_connect(); + GPtrArray *ptr_array = NULL; + + pb_type = __bluetooth_pb_get_storage_pb_type(command); - if (sscanf(id, "%d.vcf", &calls_index) != 1) { - DBG("Failed to get index\n"); + if (pb_type == TELECOM_NONE || pb_type == TELECOM_CCH) { + __bluetooth_pb_dbus_return_error(context, + G_FILE_ERROR_INVAL, + "unsupported name defined"); return FALSE; } - contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter); + ptr_array = g_ptr_array_new_with_free_func(__bluetooth_pb_list_ptr_array_free); - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { - CTSvalue *plog = NULL; + if (pb_type == TELECOM_PB) + __bluetooth_pb_get_contact_list_by_name(pb_type, ptr_array, find_text, TRUE, FALSE); + else + __bluetooth_pb_get_call_list_by_name(pb_type, ptr_array, find_text, TRUE); - plog = contacts_svc_iter_get_info(iter); - if (plog) { - int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT); - const char *number = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_NUMBER_STR); - const char *first_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_FIRST_NAME_STR); - const char *last_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_LAST_NAME_STR); - const char *display_name = contacts_svc_value_get_str(plog, - CTS_LIST_PLOG_DISPLAY_NAME_STR); - - if (!number) - number = ""; - if (!first_name) - first_name = ""; - if (!last_name) - last_name = ""; - if (display_name) { - DBG("display_name: %s\n", display_name); - } + dbus_g_method_return(context, ptr_array); - if (calls_index == index) { - snprintf(vcard_buffer, sizeof(vcard_buffer), CALL_LOG_VCARD, - last_name, first_name, number); - calls_entry = vcard_buffer; - } + if (ptr_array) + g_ptr_array_free(ptr_array, TRUE); - contacts_svc_value_free(plog); - } - } + return TRUE; +} - if( NULL != iter ) { - contacts_svc_iter_remove(iter); +static gboolean bluetooth_pb_get_total_object_count(BluetoothPbAgent *agent, + gchar *path, DBusGMethodInvocation *context) +{ + unsigned int nr_contact = 0; + + DBG("%s() %d\n", __FUNCTION__, __LINE__); + contacts_svc_connect(); + + if ((g_strcmp0(path, "SM") == 0) || (g_strcmp0(path, "ME") == 0)) { + nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT); + } else if (g_strcmp0(path, "DC") == 0) { + nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_OUTGOING); + } else if (g_strcmp0(path, "MC") == 0) { + nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN); + } else if (g_strcmp0(path, "RC") == 0) { + nr_contact = __get_call_log_count(CTS_PLOG_TYPE_VOICE_INCOMMING); } + DBG("Number of contacts is %d\n", nr_contact); contacts_svc_disconnect(); DBG("%s() %d\n", __FUNCTION__, __LINE__); - dbus_g_method_return(context, calls_entry); + dbus_g_method_return(context, nr_contact); return TRUE; } + static int __bluetooth_pb_agent_read_file(const char *file_path, char **stream) { FILE *fp = NULL; @@ -983,146 +775,1081 @@ static gboolean bluetooth_pb_add_contact(BluetoothPbAgent *agent, const char *fi return TRUE; } +static void __bluetooth_pb_dbus_return_error(DBusGMethodInvocation *context, + gint code, + const gchar *message) +{ + GQuark quark; + GError *error = NULL; + + quark = g_type_qname(bluetooth_pb_agent_get_type()); + error = g_error_new_literal(quark, code, message); + + dbus_g_method_return_error(context, error); + g_error_free(error); +} + +static PhoneBookType __bluetooth_pb_get_pb_type(const char *name) +{ + gchar *suffix = ".vcf"; + gint len; + + if (name == NULL) + return TELECOM_NONE; + + len = strlen(name); + + if (g_str_has_suffix(name, suffix)) + len -= strlen(suffix); + + if (len < 0) + return TELECOM_NONE; + + if (strncmp(name, "/telecom/pb", len) == 0) + return TELECOM_PB; + + if (strncmp(name, "/telecom/ich", len) == 0) + return TELECOM_ICH; + + if (strncmp(name, "/telecom/och", len) == 0) + return TELECOM_OCH; + + if (strncmp(name, "/telecom/mch", len) == 0) + return TELECOM_MCH; + + if (strncmp(name, "/telecom/cch", len) == 0) + return TELECOM_CCH; + + return TELECOM_NONE; +} + +static PhoneBookType __bluetooth_pb_get_storage_pb_type(const char *name) +{ + if (name == NULL) + return TELECOM_NONE; + + if (g_strcmp0(name, "\"ME\"") == 0 ) + return TELECOM_PB; + + if (g_strcmp0(name, "\"RC\"") == 0) + return TELECOM_ICH; + + if (g_strcmp0(name, "\"DC\"") == 0) + return TELECOM_OCH; + + if (g_strcmp0(name, "\"MC\"") == 0) + return TELECOM_MCH; + + return TELECOM_NONE; +} + +static unsigned int __bluetooth_pb_get_contact_size(void) +{ + unsigned int phonebook_size = 0; + + phonebook_size = contacts_svc_count(CTS_GET_ALL_CONTACT); + DBG("Number of contacts is %d\n", phonebook_size); + + /* add count for owner (0.vcf) */ + phonebook_size++; + + return phonebook_size; +} -static unsigned int __bluetooth_pb_get_call_size(const enum PhoneBookObject pb_object) +static unsigned int __bluetooth_pb_get_incoming_call_size(void) { CTSiter *iter = NULL; + unsigned int call_size = 0; - int err = 0; + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); - err = contacts_svc_connect(); - if (err != CTS_SUCCESS) { - DBG("contacts_svc_connect fucntion call [error] = %d \n", err); - return call_size; + while (contacts_svc_iter_next(iter) == CTS_SUCCESS) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + if (_bluetooth_pb_is_incoming_call(phonelog_id)) + call_size++; + + contacts_svc_value_free(value); } - contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + if (iter) + contacts_svc_iter_remove(iter); - while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { + return call_size; +} + +static unsigned int __bluetooth_pb_get_outgoing_call_size(void) +{ + CTSiter *iter = NULL; + + unsigned int call_size = 0; + + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + while (contacts_svc_iter_next(iter) == CTS_SUCCESS) { CTSvalue *value = NULL; - int type = 0; + gint phonelog_id = 0; value = contacts_svc_iter_get_info(iter); if (value == NULL) continue; - type = contacts_svc_value_get_int(value, CTS_LIST_PLOG_LOG_TYPE_INT); + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); - DBG("type : %d\n", type); + if (_bluetooth_pb_is_outgoing_call(phonelog_id)) + call_size++; - switch (pb_object) { - case TELECOM_ICH: - if (CTS_PLOG_TYPE_VOICE_INCOMMING == type || - CTS_PLOG_TYPE_VIDEO_INCOMMING == type) { - call_size++; - } - break; - case TELECOM_OCH: - if (CTS_PLOG_TYPE_VOICE_OUTGOING == type || - CTS_PLOG_TYPE_VIDEO_OUTGOING == type) { - call_size++; - } - break; - case TELECOM_MCH: - if (CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN == type || - CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN == type || - CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN == type || - CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN) { - call_size++; - } - break; - case TELECOM_CCH: - if (CTS_PLOG_TYPE_VOICE_INCOMMING == type || - CTS_PLOG_TYPE_VIDEO_INCOMMING == type || - CTS_PLOG_TYPE_VOICE_OUTGOING == type || - CTS_PLOG_TYPE_VIDEO_OUTGOING == type || - CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN == type || - CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN == type || - CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN == type || - CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN) { - call_size++; - } - break; - default: - break; - } + contacts_svc_value_free(value); } if (iter) contacts_svc_iter_remove(iter); - err = contacts_svc_disconnect(); - if (err != CTS_SUCCESS) - DBG("contacts_svc_disconnect fucntion call [error] = %d \n", err); - return call_size; } - -int main(int argc, char **argv) +static unsigned int __bluetooth_pb_get_missed_call_size(void) { - BluetoothPbAgent *bluetooth_pb_obj = NULL; - DBusGConnection *bus = NULL; - DBusGProxy *bus_proxy = NULL; - guint result = 0; - GError *error = NULL; + CTSiter *iter = NULL; - g_type_init(); + unsigned int call_size = 0; - mainloop = g_main_loop_new(NULL, FALSE); - if (mainloop == NULL) { - DBG("Couldn't create GMainLoop\n"); - return EXIT_FAILURE; - } + contacts_svc_get_list(CTS_LIST_ALL_MISSED_CALL, &iter); - bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - if (error != NULL) { - DBG("Couldn't connect to system bus[%s]\n", error->message); - g_error_free(error); - return EXIT_FAILURE; + while (contacts_svc_iter_next(iter) == CTS_SUCCESS) { + call_size++; } - bus_proxy = dbus_g_proxy_new_for_name(bus, DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - if (bus_proxy == NULL) { - DBG("Failed to get a proxy for D-Bus\n"); - goto failure; - } + if (iter) + contacts_svc_iter_remove(iter); - if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING, - BT_PB_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID, - G_TYPE_UINT, &result, G_TYPE_INVALID)) { - if (error != NULL) { - DBG("RequestName RPC failed[%s]\n", error->message); - g_error_free(error); - } - goto failure; + return call_size; +} + +static unsigned int __bluetooth_pb_get_combined_call_size(void) +{ + CTSiter *iter = NULL; + + unsigned int call_size = 0; + + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + + while (contacts_svc_iter_next(iter) == CTS_SUCCESS) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + if (_bluetooth_pb_is_incoming_call(phonelog_id) || + _bluetooth_pb_is_outgoing_call(phonelog_id) || + _bluetooth_pb_is_missed_call(phonelog_id)) + call_size++; + + contacts_svc_value_free(value); } - DBG("result : %d %d\n", result, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER); - if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - DBG("Failed to get the primary well-known name.\n"); - goto failure; + + if (iter) + contacts_svc_iter_remove(iter); + + return call_size; +} + +static GPtrArray *__bluetooth_pb_get_contact_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset) +{ + GPtrArray *vcards = NULL; + + gint i = 1; + gboolean unrestricted = FALSE; + + CTSiter *iter = NULL; + + vcards = g_ptr_array_new(); + + if (max_list_count == 65535) + unrestricted = TRUE; + + /* for owner */ + if (list_start_offset == 0) { + gchar *vcard = NULL; + vcard = _bluetooth_pb_vcard_contact(0, filter, format); + + g_ptr_array_add(vcards, vcard); } - g_object_unref(bus_proxy); - bus_proxy = NULL; + contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter); + while ((contacts_svc_iter_next(iter) == CTS_SUCCESS) && + (unrestricted || (i < list_start_offset + max_list_count))) { + CTSvalue *value = NULL; + gchar *vcard = NULL; + gint id = 0; - bluetooth_pb_obj = g_object_new(BLUETOOTH_PB_TYPE_AGENT, NULL); - if (bluetooth_pb_obj == NULL) { - DBG("Failed to create one BluetoothPbAgent instance.\n"); - goto failure; + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ID_INT); + vcard = _bluetooth_pb_vcard_contact(id, filter, format); + + contacts_svc_value_free(value); + + if (vcard == NULL) + continue; + + if ( i >= list_start_offset) + g_ptr_array_add(vcards, vcard); + + i++; } - /* Registering it on the D-Bus */ - dbus_g_connection_register_g_object(bus, BT_PB_SERVICE_OBJECT_PATH, - G_OBJECT(bluetooth_pb_obj)); + g_ptr_array_add(vcards, NULL); - g_main_loop_run(mainloop); + if (iter) + contacts_svc_iter_remove(iter); + + return vcards; +} + +static GPtrArray *__bluetooth_pb_get_incoming_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset) +{ + GPtrArray *vcards = NULL; + + gint i = 1; + guint16 offset = list_start_offset; + + gboolean unrestricted = FALSE; + + CTSiter *iter = NULL; + + vcards = g_ptr_array_new(); + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + + if (max_list_count == 65535) + unrestricted = TRUE; + + if (offset == 0) + offset = 1; + + DBG("i %d offset %d max_list_count %d\n", i, offset, max_list_count); + + while ((contacts_svc_iter_next(iter) == CTS_SUCCESS) && + (unrestricted || (i < offset + max_list_count))) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + gchar *vcard = NULL; + + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + if (_bluetooth_pb_is_incoming_call(phonelog_id)) { + vcard = _bluetooth_pb_vcard_call(phonelog_id, filter, format, + "RECEIVED"); + + if (vcard == NULL) + continue; + + if ( i >= offset) + g_ptr_array_add(vcards, vcard); + i++; + } + + contacts_svc_value_free(value); + } + + g_ptr_array_add(vcards, NULL); + + if (iter) + contacts_svc_iter_remove(iter); + + return vcards; +} + +static GPtrArray *__bluetooth_pb_get_outgoing_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset) +{ + GPtrArray *vcards = NULL; + + gint i = 1; + guint16 offset = list_start_offset; + + gboolean unrestricted = FALSE; + + CTSiter *iter = NULL; + + vcards = g_ptr_array_new(); + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + + if (max_list_count == 65535) + unrestricted = TRUE; + + if (offset == 0) + offset = 1; + + while ((contacts_svc_iter_next(iter) == CTS_SUCCESS) && + (unrestricted || (i < offset + max_list_count))) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + gchar *vcard = NULL; + + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + if (_bluetooth_pb_is_outgoing_call(phonelog_id)) { + vcard = _bluetooth_pb_vcard_call(phonelog_id, filter, format, + "DIALED"); + + if (vcard == NULL) + continue; + + if (i >= offset) + g_ptr_array_add(vcards, vcard); + i++; + } + + contacts_svc_value_free(value); + } + + g_ptr_array_add(vcards, NULL); + + if (iter) + contacts_svc_iter_remove(iter); + + return vcards; +} + +static GPtrArray *__bluetooth_pb_get_missed_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset) +{ + GPtrArray *vcards = NULL; + + gint i = 1; + guint16 offset = list_start_offset; + + gboolean unrestricted = FALSE; + + CTSiter *iter = NULL; + + vcards = g_ptr_array_new(); + contacts_svc_get_list(CTS_LIST_ALL_MISSED_CALL, &iter); + + if (max_list_count == 65535) + unrestricted = TRUE; + + if (offset == 0) + offset = 1; + + while ((contacts_svc_iter_next(iter) == CTS_SUCCESS) && + (unrestricted || (i < offset + max_list_count))) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + gchar *vcard = NULL; + + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + if (_bluetooth_pb_is_missed_call(phonelog_id)) { + vcard = _bluetooth_pb_vcard_call(phonelog_id, filter, format, + "MISSED"); + + if (vcard == NULL) + continue; + + if (i >= offset) + g_ptr_array_add(vcards, vcard); + i++; + } + + contacts_svc_value_free(value); + } + + g_ptr_array_add(vcards, NULL); + + if (iter) + contacts_svc_iter_remove(iter); + + return vcards; +} + +static GPtrArray *__bluetooth_pb_get_combined_call_vcards(BluetoothPbAgent *agent, + guint64 filter, + guint8 format, + guint16 max_list_count, + guint16 list_start_offset) +{ + GPtrArray *vcards = NULL; + + gint i = 1; + guint16 offset = list_start_offset; + + gboolean unrestricted = FALSE; + + CTSiter *iter = NULL; + + vcards = g_ptr_array_new(); + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + + if (max_list_count == 65535) + unrestricted = TRUE; + + if (offset == 0) + offset = 1; + + while ((contacts_svc_iter_next(iter) == CTS_SUCCESS) && + (unrestricted || (i < offset + max_list_count))) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + gchar *vcard = NULL; + + gchar *attr = NULL; + + value = contacts_svc_iter_get_info(iter); + if(value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + if (_bluetooth_pb_is_incoming_call(phonelog_id)) + attr = "RECEIVED"; + else if (_bluetooth_pb_is_outgoing_call(phonelog_id)) + attr = "DIALED"; + else if (_bluetooth_pb_is_missed_call(phonelog_id)) + attr = "MISSED"; + + vcard = _bluetooth_pb_vcard_call(phonelog_id, filter, format, + attr); + + if (vcard == NULL) + continue; + + if (i >= offset) + g_ptr_array_add(vcards, vcard); + i++; + + contacts_svc_value_free(value); + } + + g_ptr_array_add(vcards, NULL); + + if (iter) + contacts_svc_iter_remove(iter); + + return vcards; +} + +static void __bluetooth_pb_create_contact_index(PhoneBookType pb_type) +{ + CTSiter *iter = NULL; + gint i = 1; + + + if (g_current_pb_type == pb_type) + return; + + /* create cache */ + g_current_pb_type = pb_type; + __bluetooth_pb_list_hash_reset(); + + contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter); + + while (contacts_svc_iter_next(iter) == CTS_SUCCESS) { + CTSvalue *value = NULL; + gint contact_id = 0; + + value = contacts_svc_iter_get_info(iter); + if (value == NULL) + continue; + + contact_id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ID_INT); + __bluetooth_pb_list_hash_insert(i, contact_id); + + + i++; + } +} + +static void __bluetooth_pb_create_call_index(PhoneBookType pb_type) +{ + CTSiter *iter = NULL; + gint i = 1; + + if (g_current_pb_type == pb_type) + return; + + /* create cache */ + g_current_pb_type = pb_type; + __bluetooth_pb_list_hash_reset(); + + contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter); + + while(contacts_svc_iter_next(iter) == CTS_SUCCESS) { + CTSvalue *value = NULL; + gint phonelog_id = 0; + + value = contacts_svc_iter_get_info(iter); + if(value == NULL) + continue; + + phonelog_id = contacts_svc_value_get_int(value, CTS_LIST_PLOG_ID_INT); + + switch (pb_type) { + case TELECOM_ICH: { + if(_bluetooth_pb_is_incoming_call(phonelog_id)) { + __bluetooth_pb_list_hash_insert(i, phonelog_id); + i++; + } + } + break; + case TELECOM_OCH: { + if(_bluetooth_pb_is_outgoing_call(phonelog_id)) { + __bluetooth_pb_list_hash_insert(i, phonelog_id); + i++; + } + } + break; + case TELECOM_MCH: { + if(_bluetooth_pb_is_missed_call(phonelog_id)) { + __bluetooth_pb_list_hash_insert(i, phonelog_id); + i++; + } + } + break; + case TELECOM_CCH: { + if(_bluetooth_pb_is_incoming_call(phonelog_id) || + _bluetooth_pb_is_outgoing_call(phonelog_id) || + _bluetooth_pb_is_missed_call(phonelog_id)) { + __bluetooth_pb_list_hash_insert(i, phonelog_id); + i++; + } + } + break; + default : + return; + } + + contacts_svc_value_free(value); + } +} + + +static void __bluetooth_pb_get_contact_list(PhoneBookType pb_type, + GPtrArray *ptr_array, + gint start_index, + gint end_index, + gboolean formatted_name) +{ + gint i; + guint hash_size; + + if (ptr_array == NULL) + return; + + __bluetooth_pb_create_contact_index(pb_type); + + if (end_index < 0 || end_index < start_index) + end_index = start_index; + + if (start_index <= 0) { + /* owner */ + gchar *name = NULL; + gchar *number = NULL; + + if (formatted_name) + name = _bluetooth_pb_name_owner(); + else + name = _bluetooth_pb_fn_owner(); + + number = _bluetooth_pb_number_owner(); + + __bluetooth_pb_list_ptr_array_add(ptr_array, name, number, 0); + + g_free(name); + g_free(number); + + start_index = 1; + } + + hash_size = __bluetooth_pb_list_hash_size(); + if (hash_size < end_index) + end_index = hash_size; + + for (i = start_index; i <= end_index; i++) { + gint contact_id; + + gchar *name = NULL; + gchar *number = NULL; + + contact_id = __bluetooth_pb_list_hash_lookup_id(i); + + if (formatted_name) + name = _bluetooth_pb_fn_from_contact_id(contact_id); + else + name = _bluetooth_pb_name_from_contact_id(contact_id); + + number = _bluetooth_pb_number_from_contact_id(contact_id); + + __bluetooth_pb_list_ptr_array_add(ptr_array, name, number, i); + + g_free(name); + g_free(number); + } +} + +static void __bluetooth_pb_get_call_list(PhoneBookType pb_type, + GPtrArray *ptr_array, + gint start_index, + gint end_index, + gboolean formatted_name) +{ + gint i; + guint hash_size; + + if (ptr_array == NULL) + return; + + __bluetooth_pb_create_call_index(pb_type); + + if (end_index < 0 || end_index < start_index) + end_index = start_index; + + if (start_index <= 0) + start_index = 1; + + hash_size = __bluetooth_pb_list_hash_size(); + if (hash_size < end_index) + end_index = hash_size; + + DBG("start_index: %d end_index %d\n", start_index, end_index); + + for (i = start_index; i <= end_index; i++) { + gint phonelog_id; + + gchar *name = NULL; + gchar *number = NULL; + + phonelog_id = __bluetooth_pb_list_hash_lookup_id(i); + + if (formatted_name) + name = _bluetooth_pb_fn_from_phonelog_id(phonelog_id); + else + name = _bluetooth_pb_name_from_phonelog_id(phonelog_id); + + number = _bluetooth_pb_number_from_phonelog_id(phonelog_id); + + __bluetooth_pb_list_ptr_array_add(ptr_array, name, number, i); + + g_free(name); + g_free(number); + } +} + +static void __bluetooth_pb_get_contact_list_by_name(PhoneBookType pb_type, + GPtrArray *ptr_array, + const gchar *find_text, + gboolean formatted_name, + gboolean owner) +{ + DBG("%s %d\n", __FILE__, __LINE__); + guint i; + guint hash_size; + + if (ptr_array == NULL) + return; + + __bluetooth_pb_create_contact_index(pb_type); + + if (owner) { + /* owner */ + gchar *name; + + if (formatted_name) + name = _bluetooth_pb_name_owner(); + else + name = _bluetooth_pb_fn_owner(); + + if (g_str_has_prefix(name, find_text)) { + gchar *number; + + number = _bluetooth_pb_number_owner(); + + __bluetooth_pb_list_ptr_array_add(ptr_array, name, number, 0); + + g_free(number); + } + + g_free(name); + } + + hash_size = __bluetooth_pb_list_hash_size(); + + for (i = 1; i <= hash_size; i++) { + gint contact_id; + gchar *name; + + contact_id = __bluetooth_pb_list_hash_lookup_id(i); + + if (formatted_name) + name = _bluetooth_pb_fn_from_contact_id(contact_id); + else + name = _bluetooth_pb_name_from_contact_id(contact_id); + + if(g_str_has_prefix(name , find_text)) { + gchar *number; + + number = _bluetooth_pb_number_from_contact_id(contact_id); + + __bluetooth_pb_list_ptr_array_add(ptr_array, name, number, i); + + g_free(number); + } + + g_free(name); + } +} + +static void __bluetooth_pb_get_call_list_by_name(PhoneBookType pb_type, + GPtrArray *ptr_array, + const gchar *find_text, + gboolean formatted_name) +{ + guint i; + guint hash_size; + + if (ptr_array == NULL) + return; + + __bluetooth_pb_create_call_index(pb_type); + + hash_size = __bluetooth_pb_list_hash_size(); + + for (i = 1; i <= hash_size; i++) { + gint phonelog_id; + gchar *name; + + phonelog_id = __bluetooth_pb_list_hash_lookup_id(i); + + if (formatted_name) + name = _bluetooth_pb_fn_from_phonelog_id(phonelog_id); + else + name = _bluetooth_pb_name_from_phonelog_id(phonelog_id); + + if(g_str_has_prefix(name , find_text)) { + gchar *number; + + number = _bluetooth_pb_number_from_phonelog_id(phonelog_id); + + __bluetooth_pb_list_ptr_array_add(ptr_array, name, number, i); + + g_free(number); + } + + g_free(name); + } +} + +static int __bluetooth_get_calllog_type(int call_type) +{ + int val = CTS_PLOG_TYPE_NONE; + + switch (call_type) { + case CTS_PLOG_TYPE_VOICE_INCOMMING: + case CTS_PLOG_TYPE_VIDEO_INCOMMING: + val = CTS_PLOG_TYPE_VOICE_INCOMMING; + break; + + case CTS_PLOG_TYPE_VOICE_OUTGOING: + case CTS_PLOG_TYPE_VIDEO_OUTGOING: + val = CTS_PLOG_TYPE_VOICE_OUTGOING; + break; + + case CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN: + case CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN: + case CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN: + case CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN: + val = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN; + break; + + default: + break; + } + + return val; +} + +static unsigned int __get_call_log_count(unsigned int call_log_type) +{ + CTSiter *iter = NULL; + unsigned int count = 0; + + contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter); + while (CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue *plog = NULL; + + plog = contacts_svc_iter_get_info(iter); + if(plog == NULL) + continue; + + int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT); + DBG("type: %d\n", type); + int log_type = __bluetooth_get_calllog_type(type); + + if ((call_log_type == 0xFF || call_log_type == log_type) && + (log_type != CTS_PLOG_TYPE_NONE)) { + count++; + } + } + return count; +} + +static void __bluetooth_pb_list_hash_reset(void) +{ + if (contact_list_hash) + g_hash_table_destroy(contact_list_hash); + + contact_list_hash = g_hash_table_new(g_direct_hash, g_direct_equal); +} + +static gboolean __bluetooth_pb_list_hash_insert(gint handle, + gint id) +{ + if (contact_list_hash == NULL) + return FALSE; + + g_hash_table_insert(contact_list_hash, + GINT_TO_POINTER(handle), GINT_TO_POINTER(id)); + + return TRUE; +} + +static gint __bluetooth_pb_list_hash_lookup_id(gint handle) +{ + gint id; + if (contact_list_hash == NULL) + return 0; + + id = GPOINTER_TO_INT(g_hash_table_lookup(contact_list_hash, + GINT_TO_POINTER(handle))); + + return id; +} + +static guint __bluetooth_pb_list_hash_size (void) +{ + if (contact_list_hash == NULL) + return 0; + + return g_hash_table_size(contact_list_hash); +} + +static void __bluetooth_pb_list_ptr_array_add(GPtrArray *ptr_array, + const gchar *name, + const gchar *number, + gint handle) +{ + GValue value = { 0, }; + + g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); + g_value_take_boxed(&value, + dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT)); + + dbus_g_type_struct_set(&value, + 0, g_strdup(name), + 1, g_strdup(number), + 2, handle, + G_MAXUINT); + + g_ptr_array_add(ptr_array, g_value_get_boxed(&value)); +} + +static void __bluetooth_pb_list_ptr_array_free(gpointer data) +{ + GValue value = { 0, }; + + gchar *name = NULL; + gchar *number = NULL; + + if(data == NULL) + return; + + g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT); + g_value_set_boxed(&value, data); + + dbus_g_type_struct_get(&value, + 0, &name, + 1, &number, + G_MAXUINT); + + g_free(name); + g_free(number); +} + +static void __bluetooth_pb_agent_signal_handler(int signum) +{ + if (mainloop) + g_main_loop_quit(mainloop); + else + exit(0); +} + +static void __bluetooth_pb_contact_changed(void *user_data) +{ + BluetoothPbAgent *agent; + + g_return_if_fail(BLUETOOTH_IS_PB_AGENT(user_data)); + agent = BLUETOOTH_PB_AGENT(user_data); + + g_signal_emit(agent, signals[CLEAR], 0); +} + +static void __bluetooth_pb_call_changed(void *user_data) +{ + BluetoothPbAgent *agent; + + g_return_if_fail(BLUETOOTH_IS_PB_AGENT(user_data)); + agent = BLUETOOTH_PB_AGENT(user_data); + + g_signal_emit(agent, signals[CLEAR], 0); +} + +int main(int argc, char **argv) +{ + BluetoothPbAgent *bluetooth_pb_obj = NULL; + + DBusGConnection *bus = NULL; + DBusGProxy *bus_proxy = NULL; + + guint result = 0; + + gint ret = EXIT_SUCCESS; + struct sigaction sa; + + GError *error = NULL; + + cts_error status; + + g_type_init(); + + mainloop = g_main_loop_new(NULL, FALSE); + if (mainloop == NULL) { + DBG("Couldn't create GMainLoop\n"); + return EXIT_FAILURE; + } + + bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); + if (error != NULL) { + DBG("Couldn't connect to system bus[%s]\n", error->message); + g_error_free(error); + return EXIT_FAILURE; + } + + bus_proxy = dbus_g_proxy_new_for_name(bus, DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + if (bus_proxy == NULL) { + DBG("Failed to get a proxy for D-Bus\n"); + ret = EXIT_FAILURE; + goto failure; + } + + if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING, + BT_PB_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID, + G_TYPE_UINT, &result, G_TYPE_INVALID)) { + if (error != NULL) { + DBG("RequestName RPC failed[%s]\n", error->message); + g_error_free(error); + } + ret = EXIT_FAILURE; + goto failure; + } + DBG("result : %d %d\n", result, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER); + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + DBG("Failed to get the primary well-known name.\n"); + ret = EXIT_FAILURE; + goto failure; + } + + g_object_unref(bus_proxy); + bus_proxy = NULL; + + bluetooth_pb_obj = g_object_new(BLUETOOTH_PB_TYPE_AGENT, NULL); + if (bluetooth_pb_obj == NULL) { + DBG("Failed to create one BluetoothPbAgent instance.\n"); + ret = EXIT_FAILURE; + goto failure; + } + + /* Registering it on the D-Bus */ + dbus_g_connection_register_g_object(bus, BT_PB_SERVICE_OBJECT_PATH, + G_OBJECT(bluetooth_pb_obj)); + + /* connect contact */ + status = (cts_error)contacts_svc_connect(); + if (status != CTS_SUCCESS) { + DBG("Can not connect contacts server\n"); + ret = EXIT_FAILURE; + goto failure; + } + + contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, + __bluetooth_pb_contact_changed, + bluetooth_pb_obj); + contacts_svc_subscribe_change(CTS_SUBSCRIBE_PLOG_CHANGE, + __bluetooth_pb_call_changed, + bluetooth_pb_obj); + + /* set signal */ + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = __bluetooth_pb_agent_signal_handler; + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + + g_main_loop_run(mainloop); + + failure: + DBG("Terminate the bluetooth-pb-agent\n"); + + /* disconnect contact */ + contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, + __bluetooth_pb_contact_changed); + contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_PLOG_CHANGE, + __bluetooth_pb_call_changed); + + contacts_svc_disconnect(); + + g_signal_emit(bluetooth_pb_obj, signals[CLEAR], 0); - failure: - DBG("Terminate the bluetooth-pb-agent\n"); if (bluetooth_pb_obj) g_object_unref(bluetooth_pb_obj); @@ -1132,5 +1859,5 @@ int main(int argc, char **argv) if (bus) dbus_g_connection_unref(bus); - return EXIT_FAILURE; + return ret; } diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.xml b/bluetooth-pb-agent/bluetooth_pb_agent.xml index 64d3fe81..16b4b8eb 100644 --- a/bluetooth-pb-agent/bluetooth_pb_agent.xml +++ b/bluetooth-pb-agent/bluetooth_pb_agent.xml @@ -5,18 +5,13 @@ - - - - - - - - - - - + + + + + + @@ -25,37 +20,55 @@ - - - - - - + - - - - - - + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-telephony/bluetooth-telephony-api.c b/bluetooth-telephony/bluetooth-telephony-api.c index 4baca2da..b7cafb18 100644 --- a/bluetooth-telephony/bluetooth-telephony-api.c +++ b/bluetooth-telephony/bluetooth-telephony-api.c @@ -99,8 +99,7 @@ static void __bluetooth_telephony_adapter_added_cb(DBusGProxy *manager_proxy, const char *adapter_path, gpointer user_data); static int __bluetooth_telephony_proxy_init(void); static void __bluetooth_telephony_proxy_deinit(void); -static int __bluetooth_telephony_register(bt_telephony_func_ptr cb, - void *user_data); +static int __bluetooth_telephony_register(void); static int __bluetooth_telephony_unregister(void); static int __bluetooth_get_default_adapter_path(DBusGConnection *GConn, char *path); @@ -292,7 +291,7 @@ static gboolean bluetooth_telephony_method_answer( call_data.callid = callid; - error = __bt_telephony_event_cb(BLUETOOTH_EVENT_AG_ANSWER, + error = __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL, BLUETOOTH_TELEPHONY_ERROR_NONE, (void *)&call_data); @@ -323,7 +322,7 @@ static gboolean bluetooth_telephony_method_release( call_data.callid = callid; - error = __bt_telephony_event_cb(BLUETOOTH_EVENT_AG_RELEASE, + error = __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL, BLUETOOTH_TELEPHONY_ERROR_NONE, (void *)&call_data); @@ -355,7 +354,7 @@ static gboolean bluetooth_telephony_method_reject( call_data.callid = callid; - error = __bt_telephony_event_cb(BLUETOOTH_EVENT_AG_REJECT, + error = __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL, BLUETOOTH_TELEPHONY_ERROR_NONE, (void *)&call_data); @@ -387,19 +386,19 @@ static gboolean bluetooth_telephony_method_threeway( if (value >= 0) { switch (value) { case 0: - event = BLUETOOTH_EVENT_AG_CALL_HOLD_RELEASE_ALL; + event = BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL; break; case 1: - event = BLUETOOTH_EVENT_AG_CALL_HOLD_RELEASE_ACTIVE; + event = BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL; break; case 2: - event = BLUETOOTH_EVENT_AG_CALL_HOLD_HOLD_ACTIVE; + event = BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL; break; case 3: - event = BLUETOOTH_EVENT_AG_CALL_HOLD_ADD_NEW; + event = BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL; break; case 4: - event = BLUETOOTH_EVENT_AG_CALL_HOLD_TRANSFER; + event = BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER; break; default: DBG("Invalid CHLD command\n"); @@ -462,7 +461,7 @@ static gboolean bluetooth_telephony_method_send_dtmf( call_data.dtmf = g_strdup(dtmf); - error = __bt_telephony_event_cb(BLUETOOTH_EVENT_AG_DTMF, + error = __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF, BLUETOOTH_TELEPHONY_ERROR_NONE, (void *)&call_data); if (error != BLUETOOTH_TELEPHONY_ERROR_NONE) { @@ -557,6 +556,10 @@ static DBusHandlerResult __bluetooth_telephony_event_filter( __bluetooth_telephony_get_connected_device_proxy(); DBG("Headset Connected\n"); + + __bt_telephony_event_cb( + BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED, + BLUETOOTH_TELEPHONY_ERROR_NONE, NULL); } } else { /*Device disconnected*/ memset(telephony_info.address, 0x00, @@ -568,11 +571,52 @@ static DBusHandlerResult __bluetooth_telephony_event_filter( g_object_unref(telephony_dbus_info.proxy); telephony_dbus_info.proxy = NULL; } + DBG("Headset Disconnected\n"); + + __bt_telephony_event_cb( + BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED, + BLUETOOTH_TELEPHONY_ERROR_NONE, NULL); } return DBUS_HANDLER_RESULT_HANDLED; } + if (g_strcmp0(property, "SpeakerGain") == 0) { + unsigned int spkr_gain; + guint16 gain; + dbus_message_iter_next(&item_iter); + dbus_message_iter_recurse(&item_iter, &value_iter); + dbus_message_iter_get_basic(&value_iter, &gain); + + spkr_gain = (unsigned int)gain; + DBG("spk_gain[%d]\n", spkr_gain); + + __bt_telephony_event_cb( + BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN, + BLUETOOTH_TELEPHONY_ERROR_NONE, + (void *)&spkr_gain); + + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (g_strcmp0(property, "MicrophoneGain") == 0) { + unsigned int mic_gain; + guint16 gain; + dbus_message_iter_next(&item_iter); + dbus_message_iter_recurse(&item_iter, &value_iter); + dbus_message_iter_get_basic(&value_iter, &gain); + + mic_gain = (unsigned int)gain; + DBG("mic_gain[%d]\n", mic_gain); + + __bt_telephony_event_cb( + BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN, + BLUETOOTH_TELEPHONY_ERROR_NONE, + (void *)&mic_gain); + + return DBUS_HANDLER_RESULT_HANDLED; + } + if (g_strcmp0(property, "Playing") == 0) { gboolean audio_sink_playing = FALSE; dbus_message_iter_next(&item_iter); @@ -588,7 +632,7 @@ static DBusHandlerResult __bluetooth_telephony_event_filter( } telephony_info.headset_state = BLUETOOTH_STATE_PLAYING; __bt_telephony_event_cb( - BLUETOOTH_EVENT_AUDIO_CONNECTED, + BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED, BLUETOOTH_TELEPHONY_ERROR_NONE, NULL); } else { if (!vconf_set_bool(VCONFKEY_BT_HEADSET_SCO, FALSE)) { @@ -600,7 +644,7 @@ static DBusHandlerResult __bluetooth_telephony_event_filter( telephony_info.headset_state = BLUETOOTH_STATE_CONNECTED; __bt_telephony_event_cb( - BLUETOOTH_EVENT_AUDIO_DISCONNECTED, + BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED, BLUETOOTH_TELEPHONY_ERROR_NONE, NULL); } @@ -619,8 +663,6 @@ static void __bluetooth_telephony_name_owner_changed(DBusGProxy *dbus_proxy, DBG("BlueZ is terminated and flag need to be reset"); is_active = FALSE; DBG("Send disabled to application\n"); - __bt_telephony_event_cb(BLUETOOTH_EVENT_BT_DISABLED, - BLUETOOTH_TELEPHONY_ERROR_NONE, NULL); } } @@ -628,14 +670,40 @@ static void __bluetooth_telephony_name_owner_changed(DBusGProxy *dbus_proxy, static void __bluetooth_telephony_adapter_added_cb(DBusGProxy *manager_proxy, const char *adapter_path, gpointer user_data) { + int ret; + DBusError dbus_error; + DBusConnection *conn; + DBG("Adapter added [%s] \n", adapter_path); if (strstr(adapter_path, "hci0")) { DBG("BlueZ is Activated and flag need to be reset"); is_active = TRUE; DBG("Send enabled to application\n"); - __bt_telephony_event_cb(BLUETOOTH_EVENT_BT_ENABLED, - BLUETOOTH_TELEPHONY_ERROR_NONE, NULL); + + ret = __bluetooth_telephony_register(); + if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) { + DBG("__bluetooth_telephony_register failed\n"); + return; + } + + dbus_error_init(&dbus_error); + conn = dbus_g_connection_get_connection(telephony_dbus_info.conn); + dbus_connection_add_filter(conn, __bluetooth_telephony_event_filter, + NULL, NULL); + + dbus_bus_add_match(conn, + "type='signal',interface='" BLUEZ_HEADSET_INTERFACE + "',member='PropertyChanged'", &dbus_error); + + if (dbus_error_is_set(&dbus_error)) { + DBG("Fail to add dbus filter signal\n"); + dbus_error_free(&dbus_error); + __bluetooth_telephony_unregister(); + dbus_connection_remove_filter(dbus_g_connection_get_connection( + telephony_dbus_info.conn), + __bluetooth_telephony_event_filter, NULL); + } } } @@ -643,40 +711,10 @@ static int __bluetooth_telephony_proxy_init(void) { DBG("__bluetooth_audio_proxy_init +\n"); - telephony_dbus_info.dbus_proxy = dbus_g_proxy_new_for_name( - telephony_dbus_info.conn, DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - if (NULL == telephony_dbus_info.dbus_proxy) - return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; - - /*Add Signal callback for BT disabled*/ - dbus_g_proxy_add_signal(telephony_dbus_info.dbus_proxy, - "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(telephony_dbus_info.dbus_proxy, - "NameOwnerChanged", - G_CALLBACK(__bluetooth_telephony_name_owner_changed), - NULL, NULL); - - /*Add Signal callback for BT enabled*/ - - dbus_g_proxy_add_signal(telephony_dbus_info.manager_proxy, - "AdapterAdded", - DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(telephony_dbus_info.manager_proxy, - "AdapterAdded", - G_CALLBACK(__bluetooth_telephony_adapter_added_cb), - NULL, NULL); - object = (GObject *)__bluetooth_telephony_method_new(); - if (NULL == object) { - g_object_unref(telephony_dbus_info.dbus_proxy); - telephony_dbus_info.dbus_proxy = NULL; + if (NULL == object) return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; - } DBG("telephony_object = %d\n", object); @@ -691,46 +729,23 @@ static void __bluetooth_telephony_proxy_deinit(void) { DBG("__bluetooth_telephony_proxy_deinit +\n"); - - /*Remove BT disabled signal*/ - dbus_g_proxy_disconnect_signal(telephony_dbus_info.dbus_proxy , - "NameOwnerChanged", - G_CALLBACK(__bluetooth_telephony_name_owner_changed), - NULL); - - g_object_unref(telephony_dbus_info.dbus_proxy); - - /*Remove BT enabled signal*/ - dbus_g_proxy_disconnect_signal( - telephony_dbus_info.manager_proxy, - "AdapterAdded", - G_CALLBACK(__bluetooth_telephony_adapter_added_cb), - NULL); - dbus_g_connection_unregister_g_object(telephony_dbus_info.conn, G_OBJECT(object)); g_object_unref(object); object = NULL; - g_object_unref(telephony_dbus_info.proxy); - telephony_dbus_info.proxy = NULL; - DBG("__bluetooth_telephony_proxy_deinit -\n"); return; } -static int __bluetooth_telephony_register(bt_telephony_func_ptr cb, - void *user_data) +static int __bluetooth_telephony_register(void) { char *path = g_strdup(telephony_info.call_path); int ret; DBG("bluetooth_telephony_register +\n"); - telephony_info.cb = cb; - telephony_info.user_data = user_data; - ret = __bluetooth_telephony_dbus_method_send( HFP_AGENT_PATH, HFP_AGENT_INTERFACE, "RegisterApplication", DBUS_TYPE_STRING, &path, @@ -747,10 +762,6 @@ static int __bluetooth_telephony_unregister(void) DBG("bluetooth_telephony_unregister +\n"); - telephony_info.cb = NULL; - telephony_info.user_data = NULL; - telephony_info.call_count = 0; - ret = __bluetooth_telephony_dbus_method_send( HFP_AGENT_PATH, HFP_AGENT_INTERFACE, "UnregisterApplication", DBUS_TYPE_STRING, &path, @@ -1045,6 +1056,19 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb, return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; } + /* Call Path */ + snprintf(telephony_info.call_path, sizeof(telephony_info.call_path), + CSD_CALL_APP_PATH, getpid()); + DBG("Call Path = %s \n", telephony_info.call_path); + memset(telephony_info.address, 0x00, sizeof(telephony_info.address)); + + if (__bluetooth_telephony_proxy_init()) { + DBG("__bluetooth_telephony_proxy_init failed\n"); + dbus_g_connection_unref(telephony_dbus_info.conn); + telephony_dbus_info.conn = NULL; + return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; + } + telephony_dbus_info.manager_proxy = dbus_g_proxy_new_for_name( telephony_dbus_info.conn, BLUEZ_SERVICE_NAME, @@ -1057,44 +1081,54 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb, return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; } + telephony_dbus_info.dbus_proxy = dbus_g_proxy_new_for_name( + telephony_dbus_info.conn, DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - /*Check for BT status*/ - ret = __bluetooth_get_default_adapter_path(telephony_dbus_info.conn, - object_path); - if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) { + if (NULL == telephony_dbus_info.dbus_proxy) { dbus_g_connection_unref(telephony_dbus_info.conn); telephony_dbus_info.conn = NULL; g_object_unref(telephony_dbus_info.manager_proxy); telephony_dbus_info.manager_proxy = NULL; - return BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED; + return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; } - /*Bluetooth is active, therefore set the flag */ - is_active = TRUE; - /* Call Path */ - snprintf(telephony_info.call_path, sizeof(telephony_info.call_path), - CSD_CALL_APP_PATH, getpid()); - DBG("Call Path = %s \n", telephony_info.call_path); - memset(telephony_info.address, 0x00, sizeof(telephony_info.address)); + /*Add Signal callback for BT disabled*/ + dbus_g_proxy_add_signal(telephony_dbus_info.dbus_proxy, + "NameOwnerChanged", G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - if (__bluetooth_telephony_proxy_init()) { - DBG("__bluetooth_telephony_proxy_init failed\n"); - dbus_g_connection_unref(telephony_dbus_info.conn); - telephony_dbus_info.conn = NULL; - g_object_unref(telephony_dbus_info.manager_proxy); - telephony_dbus_info.manager_proxy = NULL; - return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; - } + dbus_g_proxy_connect_signal(telephony_dbus_info.dbus_proxy, + "NameOwnerChanged", G_CALLBACK( + __bluetooth_telephony_name_owner_changed), + NULL, NULL); + + /*Add Signal callback for BT enabled*/ + dbus_g_proxy_add_signal(telephony_dbus_info.manager_proxy, + "AdapterAdded", + DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(telephony_dbus_info.manager_proxy, + "AdapterAdded", + G_CALLBACK(__bluetooth_telephony_adapter_added_cb), + NULL, NULL); + + /*Callback and user applicaton data*/ + telephony_info.cb = cb; + telephony_info.user_data = user_data; + + /*Check for BT status*/ + ret = __bluetooth_get_default_adapter_path(telephony_dbus_info.conn, + object_path); + if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) + return BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED; - ret = __bluetooth_telephony_register(cb, user_data); + /*Bluetooth is active, therefore set the flag */ + is_active = TRUE; + + ret = __bluetooth_telephony_register(); if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE) { DBG("__bluetooth_telephony_register failed\n"); - __bluetooth_telephony_proxy_deinit(); - dbus_g_connection_unref(telephony_dbus_info.conn); - telephony_dbus_info.conn = NULL; - g_object_unref(telephony_dbus_info.manager_proxy); - telephony_dbus_info.manager_proxy = NULL; - return ret; + goto fail; } dbus_error_init(&dbus_error); @@ -1110,19 +1144,43 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb, DBG("Fail to add dbus filter signal\n"); dbus_error_free(&dbus_error); __bluetooth_telephony_unregister(); - __bluetooth_telephony_proxy_deinit(); dbus_connection_remove_filter(dbus_g_connection_get_connection( telephony_dbus_info.conn), __bluetooth_telephony_event_filter, NULL); - dbus_g_connection_unref(telephony_dbus_info.conn); - telephony_dbus_info.conn = NULL; - g_object_unref(telephony_dbus_info.manager_proxy); - telephony_dbus_info.manager_proxy = NULL; - return BLUETOOTH_TELEPHONY_ERROR_INTERNAL; + goto fail; } DBG("bluetooth_telephony_init -\n"); return ret; +fail: + telephony_info.cb = NULL; + telephony_info.user_data = NULL; + telephony_info.call_count = 0; + + __bluetooth_telephony_proxy_deinit(); + + /*Remove BT disabled signal*/ + dbus_g_proxy_disconnect_signal(telephony_dbus_info.dbus_proxy , + "NameOwnerChanged", + G_CALLBACK(__bluetooth_telephony_name_owner_changed), + NULL); + + g_object_unref(telephony_dbus_info.dbus_proxy); + + /*Remove BT enabled signal*/ + dbus_g_proxy_disconnect_signal( + telephony_dbus_info.manager_proxy, + "AdapterAdded", + G_CALLBACK(__bluetooth_telephony_adapter_added_cb), + NULL); + + dbus_g_connection_unref(telephony_dbus_info.conn); + telephony_dbus_info.conn = NULL; + g_object_unref(telephony_dbus_info.manager_proxy); + telephony_dbus_info.manager_proxy = NULL; + g_object_unref(telephony_dbus_info.dbus_proxy); + telephony_dbus_info.dbus_proxy = NULL; + return ret; } BT_EXPORT_API int bluetooth_telephony_deinit(void) @@ -1141,12 +1199,34 @@ BT_EXPORT_API int bluetooth_telephony_deinit(void) __bluetooth_telephony_unregister(); __bluetooth_telephony_proxy_deinit(); + telephony_info.cb = NULL; + telephony_info.user_data = NULL; + telephony_info.call_count = 0; + + /*Remove BT disabled signal*/ + dbus_g_proxy_disconnect_signal(telephony_dbus_info.dbus_proxy , + "NameOwnerChanged", + G_CALLBACK(__bluetooth_telephony_name_owner_changed), + NULL); + + g_object_unref(telephony_dbus_info.dbus_proxy); + + /*Remove BT enabled signal*/ + dbus_g_proxy_disconnect_signal( + telephony_dbus_info.manager_proxy, + "AdapterAdded", + G_CALLBACK(__bluetooth_telephony_adapter_added_cb), + NULL); + g_object_unref(telephony_dbus_info.manager_proxy); telephony_dbus_info.manager_proxy = NULL; dbus_g_connection_unref(telephony_dbus_info.conn); telephony_dbus_info.conn = NULL; + g_object_unref(telephony_dbus_info.dbus_proxy); + telephony_dbus_info.dbus_proxy = NULL; + DBG("bluetooth_telephony_deinit -\n"); return BLUETOOTH_TELEPHONY_ERROR_NONE; } diff --git a/bluetooth-telephony/bluetooth-telephony-api.h b/bluetooth-telephony/bluetooth-telephony-api.h index 30c1becb..182215d0 100644 --- a/bluetooth-telephony/bluetooth-telephony-api.h +++ b/bluetooth-telephony/bluetooth-telephony-api.h @@ -132,19 +132,21 @@ typedef enum { #define BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE (unsigned int)(0x00100) typedef enum { - BLUETOOTH_EVENT_AG_ANSWER = BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE, - BLUETOOTH_EVENT_AG_RELEASE, - BLUETOOTH_EVENT_AG_REJECT, - BLUETOOTH_EVENT_AG_CALL_HOLD_RELEASE_ALL, - BLUETOOTH_EVENT_AG_CALL_HOLD_RELEASE_ACTIVE, - BLUETOOTH_EVENT_AG_CALL_HOLD_HOLD_ACTIVE, - BLUETOOTH_EVENT_AG_CALL_HOLD_ADD_NEW, - BLUETOOTH_EVENT_AG_CALL_HOLD_TRANSFER, - BLUETOOTH_EVENT_AG_DTMF, - BLUETOOTH_EVENT_BT_ENABLED, - BLUETOOTH_EVENT_BT_DISABLED, - BLUETOOTH_EVENT_AUDIO_CONNECTED, - BLUETOOTH_EVENT_AUDIO_DISCONNECTED, + BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL = BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE, + BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL, + BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL, + BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL, + BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL, + BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL, + BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL, + BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER, + BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF, + BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED, + BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED, + BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED, + BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED, + BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN, + BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN, } bluetooth_telephony_event_type; typedef enum { diff --git a/debian/changelog b/debian/changelog index 653480b3..148a2aea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,199 @@ +bluetooth-frwk (0.1.80) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.80 + + -- DoHyun Pyun Fri, 17 Aug 2012 13:02:55 +0900 + +bluetooth-frwk (0.1.79) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.79 + + -- DoHyun Pyun Thu, 16 Aug 2012 17:11:17 +0900 + +bluetooth-frwk (0.1.78) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.78 + + -- DoHyun Pyun Wed, 08 Aug 2012 17:01:37 +0900 + +bluetooth-frwk (0.1.77) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.77 + + -- DoHyun Pyun Wed, 08 Aug 2012 12:16:50 +0900 + +bluetooth-frwk (0.1.76) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.76 + + -- Sunil Kumar Behera Tue, 07 Aug 2012 15:58:21 +0530 + +bluetooth-frwk (0.1.75) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.75 + + -- Sunil Kumar Behera Tue, 07 Aug 2012 09:29:55 +0530 + +bluetooth-frwk (0.1.74) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.74 + + -- DoHyun Pyun Mon, 06 Aug 2012 18:01:12 +0900 + +bluetooth-frwk (0.1.73) unstable; urgency=low + + * Replace deprecated APIs about glib-2.3.0 + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.73 + + -- DoHyun Pyun Wed, 01 Aug 2012 13:50:43 +0900 + +bluetooth-frwk (0.1.72) unstable; urgency=low + + * Taging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.72 + + -- Chethan T N Tue, 31 Jul 2012 18:09:09 +0530 + +bluetooth-frwk (0.1.71) unstable; urgency=low + + * Re-upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.71 + + -- DoHyun Pyun Thu, 26 Jul 2012 08:34:33 +0900 + +bluetooth-frwk (0.1.70) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.70 + + -- DoHyun Pyun Wed, 25 Jul 2012 10:56:30 +0900 + +bluetooth-frwk (0.1.69) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.69 + + -- DoHyun Pyun Fri, 20 Jul 2012 14:07:19 +0900 + +bluetooth-frwk (0.1.68) unstable; urgency=low + + * Tagging and upload the package + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.68 + + -- DoHyun Pyun Thu, 19 Jul 2012 16:59:27 +0900 + +bluetooth-frwk (0.1.67) unstable; urgency=low + + * Upload package for changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.67 + + -- DoHyun Pyun Wed, 18 Jul 2012 12:44:25 +0900 + +bluetooth-frwk (0.1.66) unstable; urgency=low + + * Upload package for changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.66 + + -- DoHyun Pyun Tue, 10 Jul 2012 17:56:58 +0900 + +bluetooth-frwk (0.1.65) unstable; urgency=low + + * Upload package for changes. + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.65 + + -- Sunil Kumar Behera Wed, 20 Jun 2012 13:02:11 +0530 + +bluetooth-frwk (0.1.64) unstable; urgency=low + + * Implement the requirements from OSP + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.64 + + -- DoHyun Pyun Wed, 13 Jun 2012 09:12:44 +0900 + +bluetooth-frwk (0.1.63) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.63 + + -- Chethan T N Tue, 22 May 2012 11:26:43 +0530 + +bluetooth-frwk (0.1.62) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.62 + + -- DoHyun Pyun Mon, 21 May 2012 11:05:02 +0900 + +bluetooth-frwk (0.1.61) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.61 + + -- DoHyun Pyun Fri, 18 May 2012 17:44:58 +0900 + +bluetooth-frwk (0.1.60) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.60 + + -- DoHyun Pyun Mon, 14 May 2012 08:59:54 +0900 + +bluetooth-frwk (0.1.59) unstable; urgency=low + + * Use the MDM system popup + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.59 + + -- DoHyun Pyun Tue, 08 May 2012 08:58:56 +0900 + +bluetooth-frwk (0.1.58) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.58 + + -- Sunil Kumar Behera Thu, 26 Apr 2012 12:03:49 +0530 + +bluetooth-frwk (0.1.57) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.57 + + -- DoHyun Pyun Tue, 24 Apr 2012 11:43:25 +0900 + bluetooth-frwk (0.1.56) unstable; urgency=low * Upload the changes - * Git: pkgs/b/bluetooth-frwk + * Git: slp/pkgs/b/bluetooth-frwk * Tag: bluetooth-frwk_0.1.56 -- DoHyun Pyun Thu, 19 Apr 2012 08:57:02 +0900 @@ -9,7 +201,7 @@ bluetooth-frwk (0.1.56) unstable; urgency=low bluetooth-frwk (0.1.55) unstable; urgency=low * Implement the MDM handsfree mode - * Git: pkgs/b/bluetooth-frwk + * Git: slp/pkgs/b/bluetooth-frwk * Tag: bluetooth-frwk_0.1.55 -- DoHyun Pyun Tue, 10 Apr 2012 08:36:02 +0900 @@ -17,7 +209,7 @@ bluetooth-frwk (0.1.55) unstable; urgency=low bluetooth-frwk (0.1.54) unstable; urgency=low * Add the authorize API to support BADA - * Git: pkgs/b/bluetooth-frwk + * Git: slp/pkgs/b/bluetooth-frwk * Tag: bluetooth-frwk_0.1.54 -- DoHyun Pyun Fri, 30 Mar 2012 16:43:59 +0900 @@ -25,7 +217,7 @@ bluetooth-frwk (0.1.54) unstable; urgency=low bluetooth-frwk (0.1.53) unstable; urgency=low * Revert session bus (agent) to system bus - * Git: pkgs/b/bluetooth-frwk + * Git: slp/pkgs/b/bluetooth-frwk * Tag: bluetooth-frwk_0.1.53 -- Chanyeol Park Sun, 25 Mar 2012 16:51:41 +0900 @@ -33,51 +225,1170 @@ bluetooth-frwk (0.1.53) unstable; urgency=low bluetooth-frwk (0.1.52) unstable; urgency=low * fixed dbus bus type to session bus - * Git: pkgs/b/bluetooth-frwk + * Git: slp/pkgs/b/bluetooth-frwk * Tag: bluetooth-frwk_0.1.52 -- Jaekyun Lee Sat, 24 Mar 2012 16:35:23 +0900 bluetooth-frwk (0.1.51) unstable; urgency=low - * Release Tizen 1.0 - * Git: pkgs/b/bluetooth-frwk + * Set the agent timer + * Git: slp/pkgs/b/bluetooth-frwk * Tag: bluetooth-frwk_0.1.51 - -- DoHyun Pyun Tue, 20 Mar 2012 17:23:57 +0900 + -- DoHyun Pyun Tue, 20 Mar 2012 14:53:10 +0900 + +bluetooth-frwk (0.1.50) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.50 + + -- DoHyun Pyun Fri, 24 Feb 2012 09:50:40 +0900 + +bluetooth-frwk (0.1.49) unstable; urgency=low + + * Upload the changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.49 + + -- DoHyun Pyun Tue, 14 Feb 2012 13:23:45 +0900 + +bluetooth-frwk (0.1.48) unstable; urgency=low + + * Fix the cancel discovery issue + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.48 + + -- DoHyun Pyun Wed, 01 Feb 2012 15:22:45 +0900 + +bluetooth-frwk (0.1.47) unstable; urgency=low + + * Add the code to get MDM service / release MDM service + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.47 + + -- DoHyun Pyun Tue, 31 Jan 2012 17:01:18 +0900 + +bluetooth-frwk (0.1.46) unstable; urgency=low -bluetooth-frwk (0.1.48-2) unstable; urgency=low + * Remove bluetooth-frwk-test dpkg + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.46 - * Change SAMSUNG -> TIZEN - * Git: pkgs/b/bluetooth-frwk - * Tag: bluetooth-frwk_0.1.48-2 + -- Chanyeol Park Thu, 26 Jan 2012 16:39:08 +0900 - -- DoHyun Pyun Tue, 21 Feb 2012 18:08:53 +0900 +bluetooth-frwk (0.1.45) unstable; urgency=low -bluetooth-frwk (0.1.48-1) unstable; urgency=low + * Restrict BT enable, if mdm_get_allow_bluetooth_mode is MDM_BT_RESTRICTED + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.45 - * Merge with lastest private git - * Git: pkgs/b/bluetooth-frwk - * Tag: bluetooth-frwk_0.1.48-1 + -- DoHyun Pyun Mon, 16 Jan 2012 15:36:42 +0900 - -- DoHyun Pyun Thu, 09 Feb 2012 14:06:25 +0900 +bluetooth-frwk (0.1.44) unstable; urgency=low -bluetooth-frwk (0.1.41-1) unstable; urgency=low + * Fix the spelling of API name (sessioin -> session) + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.44 - * change "com.samsung" -> "org.tizen" - * Git: pkgs/b/bluetooth-frwk - * Tag: bluetooth-frwk_0.1.41-1 + -- DoHyun Pyun Thu, 05 Jan 2012 17:53:01 +0900 - -- DoHyun Pyun Thu, 22 Dec 2011 17:57:59 +0900 +bluetooth-frwk (0.1.43) unstable; urgency=low + + * Increase the version number to upload + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.43 + + -- DoHyun Pyun Mon, 02 Jan 2012 10:32:04 +0900 + +bluetooth-frwk (0.1.42) unstable; urgency=low + + * Upload the package to changes + * Git: slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.42 + + -- DoHyun Pyun Fri, 30 Dec 2011 07:59:59 +0900 bluetooth-frwk (0.1.41) unstable; urgency=low - * Update Version for build + * Remove the input parameter of get_transfers dbus method for obexd + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.41 + + -- DoHyun Pyun Mon, 21 Nov 2011 18:07:12 +0900 + +bluetooth-frwk (0.1.40) unstable; urgency=low + + * Modify the bluetooth_is_supported API + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.40 + + -- DoHyun Pyun Mon, 14 Nov 2011 17:16:28 +0900 + +bluetooth-frwk (0.1.39) unstable; urgency=low + + * Add the 2 APIs for the MDM service + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.39 + + -- DoHyun Pyun Fri, 11 Nov 2011 08:35:55 +0900 + +bluetooth-frwk (0.1.38) unstable; urgency=low + + * Add the full values of the uuid in service list information (Support the CAPI) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.38 + + -- DoHyun Pyun Tue, 08 Nov 2011 15:08:35 +0900 + +bluetooth-frwk (0.1.37) unstable; urgency=low + + * Fix the prevent defect (CID: 57479) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.37 + + -- DoHyun Pyun Fri, 28 Oct 2011 14:50:31 +0900 + +bluetooth-frwk (0.1.36) unstable; urgency=low + + * Change bluetooth_set_discoverable_mode API to sync call (Support the CAPI) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.36 + + -- DoHyun Pyun Wed, 26 Oct 2011 17:21:32 +0900 + +bluetooth-frwk (0.1.35) unstable; urgency=low + + * Modify the error types + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.35 + + -- DoHyun Pyun Tue, 25 Oct 2011 10:18:24 +0900 + +bluetooth-frwk (0.1.34) unstable; urgency=low + + * Modify bluetooth_set_local_name / bluetooth_get_local_name API + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.34 + + -- DoHyun Pyun Wed, 19 Oct 2011 12:57:12 +0900 + +bluetooth-frwk (0.1.33) unstable; urgency=low + + * Change the bluetooth_set_local_name to synchronous call (Support BADA / CAPI) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.33 + + -- DoHyun Pyun Wed, 12 Oct 2011 14:47:55 +0900 + +bluetooth-frwk (0.1.32) unstable; urgency=low - -- Chanyeol Park Thu, 15 Dec 2011 12:56:57 +0900 + * Arrange the error type (Support the CAPI) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.32 + + -- DoHyun Pyun Wed, 12 Oct 2011 13:48:15 +0900 + +bluetooth-frwk (0.1.31) unstable; urgency=low + + * Fix the bug about device name (CQ H0100134651) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.31 + + -- DoHyun Pyun Thu, 06 Oct 2011 19:32:56 +0900 + +bluetooth-frwk (0.1.30) unstable; urgency=low + + * Don't call the AUL, if the beat-bluetooth process is not running + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.30 + + -- DoHyun Pyun Thu, 06 Oct 2011 18:56:01 +0900 + +bluetooth-frwk (0.1.29) unstable; urgency=low + + * Return the paired device only in bluetooth_get_bonded_device_list + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.29 + + -- DoHyun Pyun Tue, 04 Oct 2011 08:38:03 +0900 + +bluetooth-frwk (0.1.28) unstable; urgency=low + + * Modify the contact-service API + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.28 + + -- DoHyun Pyun Mon, 26 Sep 2011 17:21:23 +0900 + +bluetooth-frwk (0.1.27) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.27 + + -- DoHyun Pyun Wed, 07 Sep 2011 16:34:10 +0900 + +bluetooth-frwk (0.1.26) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.26 + + -- DoHyun Pyun Wed, 07 Sep 2011 08:54:01 +0900 + +bluetooth-frwk (0.1.25) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.25 + + -- DoHyun Pyun Tue, 06 Sep 2011 08:30:18 +0900 + +bluetooth-frwk (0.1.24) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.24 + + -- DoHyun Pyun Fri, 02 Sep 2011 08:37:37 +0900 + +bluetooth-frwk (0.1.23) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.23 + + -- DoHyun Pyun Mon, 29 Aug 2011 19:17:05 +0900 + +bluetooth-frwk (0.1.22) unstable; urgency=low + + * Upload package for changes + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.22 + + -- DoHyun Pyun Fri, 12 Aug 2011 15:57:26 +0900 + +bluetooth-frwk (0.1.21) unstable; urgency=low + + * Upload package for changes + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.21 + + -- DoHyun Pyun Tue, 09 Aug 2011 08:33:57 +0900 + +bluetooth-frwk (0.1.20) unstable; urgency=low + + * Remove the system popup when the remote device cancel the event (H0100131180) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.20 + + -- DoHyun Pyun Mon, 01 Aug 2011 08:27:40 +0900 + +bluetooth-frwk (0.1.19) unstable; urgency=low + + * Upload package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.19 + + -- Jaganath K Thu, 07 Jul 2011 13:16:30 +0530 + +bluetooth-frwk (0.1.18) unstable; urgency=low + + * Fix the bus in stop discoverying + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.18 + + -- DoHyun Pyun Thu, 07 Jul 2011 15:29:07 +0900 + +bluetooth-frwk (0.1.17) unstable; urgency=low + + * Add the bluetooth_get_bonded_device API + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.17 + + -- DoHyun Pyun Tue, 28 Jun 2011 15:44:17 +0900 + +bluetooth-frwk (0.1.16) unstable; urgency=low + + * Upload package for changes + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.16 + + -- Sunil Kumar Behera Fri, 24 Jun 2011 17:40:21 +0530 + +bluetooth-frwk (0.1.15) unstable; urgency=low + + * Fix dbus system bus double unref problem + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.15 + + -- Chanyeol Park Wed, 22 Jun 2011 21:56:17 +0900 + +bluetooth-frwk (0.1.14) unstable; urgency=low + + * Add the network API for BT tethering + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.14 + + -- DoHyun Pyun Fri, 17 Jun 2011 13:26:44 +0900 + +bluetooth-frwk (0.1.13) unstable; urgency=low + + * Add the NULL check routine + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.13 + + -- DoHyun Pyun Fri, 10 Jun 2011 11:16:56 +0900 + +bluetooth-frwk (0.1.12) unstable; urgency=low + + * Fix de-init session bug + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.12 + + -- Chanyeol Park Thu, 09 Jun 2011 21:57:11 +0900 + +bluetooth-frwk (0.1.11) unstable; urgency=low + + * Upload package for changes + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.11 + + -- Sunil Kumar Behera Tue, 07 Jun 2011 19:19:13 +0530 + +bluetooth-frwk (0.1.10) stable; urgency=low + + * Modify the 'BT enable' check routine + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.10 + + -- DoHyun Pyun Mon, 30 May 2011 16:36:11 +0900 + +bluetooth-frwk (0.1.9) unstable; urgency=low + + * Fix the BS when the process is terminated without deleting the g_timer. (Defect H0100127300) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.9 + + -- DoHyun Pyun Fri, 27 May 2011 13:58:01 +0900 + +bluetooth-frwk (0.1.8) unstable; urgency=low + + * Add the uuid values for developers + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.8 + + -- DoHyun Pyun Wed, 25 May 2011 11:07:33 +0900 + +bluetooth-frwk (0.1.7) unstable; urgency=low + + * Add the 'user_data' parameter in bluetooth_register_callback + * Modify the DTS makefile to sbs + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.7 + + -- DoHyun Pyun Fri, 20 May 2011 09:01:34 +0900 + +bluetooth-frwk (0.1.6) unstable; urgency=low + + * Fix Crash while receive image + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.6 + + -- Chanyeol Park Thu, 19 May 2011 20:19:04 +0900 + +bluetooth-frwk (0.1.5) unstable; urgency=low + + * Show the ticker noti when the file recieved (Defect H0100126544) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.5 + + -- DoHyun Pyun Fri, 13 May 2011 17:35:58 +0900 + +bluetooth-frwk (0.1.4) unstable; urgency=low + + * Correct the code about variable memory. + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.4 + + -- DoHyun Pyun Wed, 04 May 2011 11:00:59 +0900 + +bluetooth-frwk (0.1.3) unstable; urgency=low + + * Add the event signal of the authorized (Requested by CAPI part) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.3 + -- DoHyun Pyun Mon, 02 May 2011 18:11:50 +0900 + +bluetooth-frwk (0.1.2) unstable; urgency=low + + * Remove the obex-agent.h file in install + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.2 + + -- DoHyun Pyun Thu, 28 Apr 2011 11:39:33 +0900 + +bluetooth-frwk (0.1.1) unstable; urgency=low + + * Increase the version + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.1 + + -- DoHyun Pyun Thu, 28 Apr 2011 11:23:53 +0900 bluetooth-frwk (0.1.0) unstable; urgency=low + * Release ug-obexd init dpkg + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.1.0 + + -- DoHyun Pyun Tue, 26 Apr 2011 11:24:07 +0900 + +bluetooth-frwk (0.0.94) unstable; urgency=low + + * Add the package dependency of the dbus-glib-1 + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.94 + + -- DoHyun Pyun Wed, 06 Apr 2011 13:16:52 +0900 + +bluetooth-frwk (0.0.93) unstable; urgency=low + + * Fix the build break + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.93 + + -- DoHyun Pyun Wed, 06 Apr 2011 13:01:04 +0900 + +bluetooth-frwk (0.0.92) unstable; urgency=low + + * Re-upload package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.92 + + -- DoHyun Pyun Mon, 07 Mar 2011 15:33:50 +0900 + +bluetooth-frwk (0.0.91) unstable; urgency=low + + * Upload package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.91 + + -- DoHyun Pyun Mon, 07 Mar 2011 10:07:43 +0900 + +bluetooth-frwk (0.0.90) unstable; urgency=low + + * Modify the API and test case + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.90 + + -- DoHyun Pyun Fri, 04 Mar 2011 17:22:45 +0900 + +bluetooth-frwk (0.0.89) unstable; urgency=low + + * Modify the headset check-routin in auto-pairing + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.89 + + -- DoHyun Pyun Thu, 03 Mar 2011 11:16:27 +0900 + +bluetooth-frwk (0.0.88) unstable; urgency=low + + * Uploading Package + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.88 + + -- Jaganath Tue, 22 Feb 2011 13:05:13 +0530 + +bluetooth-frwk (0.0.87) unstable; urgency=low + + * Remove the authorizing popup in enable / diable adapter + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.87 + + -- DoHyun Pyun Fri, 11 Feb 2011 10:54:00 +0900 + +bluetooth-frwk (0.0.86) unstable; urgency=low + + * Fix the prevent defect (FOWARD NULL / BUFFER OVERFLOW) + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.86 + + -- DoHyun Pyun Thu, 10 Feb 2011 09:33:29 +0900 + +bluetooth-frwk (0.0.85) unstable; urgency=low + + * Implement bt_get_bonded_device_list API + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.85 + + -- DoHyun Pyun Thu, 20 Jan 2011 19:10:41 +0900 + +bluetooth-frwk (0.0.84) unstable; urgency=low + + * Move the popup UI to bt-syspopup + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.84 + + -- DoHyun Pyun Thu, 06 Jan 2011 14:38:09 +0900 + +bluetooth-frwk (0.0.83) unstable; urgency=low + + * BT name request fucntion returns error, when BT is not activated + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.83 + + -- ChanYeol Park Tue, 04 Jan 2011 14:03:28 +0900 + +bluetooth-frwk (0.0.82) unstable; urgency=low + + * Made the Adapter.GetProperties Sync during device enable + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.82 + + -- Syam Sidhardhan Fri, 24 Dec 2010 15:36:19 +0530 + +bluetooth-frwk (0.0.81) unstable; urgency=low + + * Block the elm_exit when END key press + * Git: 165.213.180.234:slp/pkgs/b/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.81 + + -- DoHyun Pyun Thu, 09 Dec 2010 16:24:25 +0900 + +bluetooth-frwk (0.0.80) unstable; urgency=low + + * Enable the auto-pairing in headset case + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.80 + + -- DoHyun Pyun Fri, 26 Nov 2010 13:59:34 +0900 + +bluetooth-frwk (0.0.79) unstable; urgency=low + + * Add auto-pairing code in headset case + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.79 + + -- DoHyun Pyun Wed, 24 Nov 2010 19:02:16 +0900 + +bluetooth-frwk (0.0.78) unstable; urgency=low + + * Change the AUL name + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.78 + + -- DoHyun Pyun Wed, 24 Nov 2010 13:18:10 +0900 + +bluetooth-frwk (0.0.77) unstable; urgency=low + + * Pop the navigation bar when the passkey view destroy + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.77 + + -- DoHyun Pyun Mon, 22 Nov 2010 19:59:09 +0900 + +bluetooth-frwk (0.0.76) unstable; urgency=low + + * Focus in the entry view + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.76 + + -- DoHyun Pyun Wed, 17 Nov 2010 20:37:56 +0900 + +bluetooth-frwk (0.0.75) unstable; urgency=low + + * Fixed Get Bonded device list end of indication, updated the doxygen PG + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.75 + + -- Syam Sidhardhan Wed, 17 Nov 2010 15:54:34 +0530 + +bluetooth-frwk (0.0.74) unstable; urgency=low + + * Modify the condition value about flight mode + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.74 + + -- DoHyun Pyun Wed, 10 Nov 2010 09:49:55 +0900 + +bluetooth-frwk (0.0.73) unstable; urgency=low + + * Upload package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.73 + + -- DoHyun Pyun Tue, 09 Nov 2010 17:29:38 +0900 + +bluetooth-frwk (0.0.72) unstable; urgency=low + + * Rollback codes + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.72 + + -- DoHyun Pyun Tue, 09 Nov 2010 16:36:52 +0900 + +bluetooth-frwk (0.0.71) unstable; urgency=low + + * Remove evas_object_del after elm_navigationbar_pop + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.71 + + -- DoHyun Pyun Tue, 09 Nov 2010 15:19:12 +0900 + +bluetooth-frwk (0.0.70) unstable; urgency=low + + * Set the intial timeout value to zero + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.70 + + -- DoHyun Pyun Mon, 08 Nov 2010 13:44:37 +0900 + +bluetooth-frwk (0.0.69) unstable; urgency=low + + * Display the indicator + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.69 + + -- DoHyun Pyun Fri, 05 Nov 2010 14:12:31 +0900 + +bluetooth-frwk (0.0.68) unstable; urgency=low + + * Implemented the get bonded device list through DBUS + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.68 + + -- Syam Sidhardhan Thu, 04 Nov 2010 12:50:06 +0530 + +bluetooth-frwk (0.0.67) unstable; urgency=low + + * Move the popup over lock screen + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.67 + + -- DoHyun Pyun Wed, 03 Nov 2010 20:54:43 +0900 + +bluetooth-frwk (0.0.66) unstable; urgency=low + + * Add the homepage in control file + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.66 + + -- DoHyun Pyun Fri, 29 Oct 2010 17:13:06 +0900 + +bluetooth-frwk (0.0.65) unstable; urgency=low + + * Moved the sc_core_agent from btstack + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.65 + + -- DoHyun Pyun Fri, 29 Oct 2010 11:00:30 +0900 + +bluetooth-frwk (0.0.64) unstable; urgency=low + + * Modify / Add files about LiMo Contribution + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.64 + + -- DoHyun Pyun Mon, 25 Oct 2010 21:35:37 +0900 + +bluetooth-frwk (0.0.63) unstable; urgency=low + + * Show the IME when the passkey input + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.63 + + -- DoHyun Pyun Thu, 21 Oct 2010 17:48:55 +0900 + +bluetooth-frwk (0.0.62) unstable; urgency=low + + * Fix Device Property Changed UUIDs signal call back bug + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.62 + + -- DoHyun Pyun Thu, 21 Oct 2010 11:25:34 +0900 + +bluetooth-frwk (0.0.61) unstable; urgency=low + + * Upload package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.61 + + -- Hye-Jin Kim Wed, 20 Oct 2010 16:48:47 +0900 + +bluetooth-frwk (0.0.60) unstable; urgency=low + + * Modified the rfcomm connect API + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.60 + + -- Syam Sidhardhan Tue, 19 Oct 2010 11:13:38 +0530 + +bluetooth-frwk (0.0.59) unstable; urgency=low + + * Reupload the package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.59 + + -- DoHyun Pyun Wed, 13 Oct 2010 20:25:41 +0900 + +bluetooth-frwk (0.0.58) unstable; urgency=low + + * Move the bt-agent script to rc.5 + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.58 + + -- DoHyun Pyun Wed, 13 Oct 2010 18:11:18 +0900 + +bluetooth-frwk (0.0.57) unstable; urgency=low + + * Implemented bluetooth_get_bonded_device_list API + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.57 + + -- Syam Sidhardhan Fri, 08 Oct 2010 18:32:51 +0530 + +bluetooth-frwk (0.0.56) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.56 + + -- DoHyun Pyun Wed, 06 Oct 2010 16:41:39 +0900 + +bluetooth-frwk (0.0.55) unstable; urgency=low + + * Modify the TETware code + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.55 + + -- DoHyun Pyun Wed, 06 Oct 2010 16:08:56 +0900 + +bluetooth-frwk (0.0.54) unstable; urgency=low + + * Update the Programming Guide + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.54 + + -- DoHyun Pyun Fri, 01 Oct 2010 15:22:54 +0900 + +bluetooth-frwk (0.0.53) unstable; urgency=low + + * Modify the visibility + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.53 + + -- DoHyun Pyun Fri, 01 Oct 2010 13:42:02 +0900 + +bluetooth-frwk (0.0.52) unstable; urgency=low + + * Modify the BT aul to the backgroud mode + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.52 + + -- DoHyun Pyun Fri, 01 Oct 2010 09:00:45 +0900 + +bluetooth-frwk (0.0.51) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.51 + + -- Syam Sidhardhan Thu, 30 Sep 2010 18:20:43 +0530 + +bluetooth-frwk (0.0.50) unstable; urgency=low + + * Upload the package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.50 + + -- DoHyun Pyun Fri, 17 Sep 2010 19:39:58 +0900 + +bluetooth-frwk (0.0.49) unstable; urgency=low + + * Fix the TETware code + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.49 + + -- DoHyun Pyun Fri, 17 Sep 2010 19:02:30 +0900 + +bluetooth-frwk (0.0.48) unstable; urgency=low + + * Add the TETware code + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.48 + + -- DoHyun Pyun Fri, 17 Sep 2010 10:47:01 +0900 + +bluetooth-frwk (0.0.47) unstable; urgency=low + + * Upload package + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.47 + + -- DoHyun Pyun Thu, 16 Sep 2010 09:35:21 +0900 + +bluetooth-frwk (0.0.46) unstable; urgency=low + + * Added the Connected event and made connect Async + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.46 + + -- Syam Sidhardhan Tue, 14 Sep 2010 12:48:33 +0530 + +bluetooth-frwk (0.0.45) unstable; urgency=low + + * Modify the GAP API + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.45 + + -- DoHyun Pyun Tue, 14 Sep 2010 16:02:42 +0900 + +bluetooth-frwk (0.0.44) unstable; urgency=low + + * Apply new font guide + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.44 + + -- DoHyun Pyun Sat, 11 Sep 2010 10:16:37 +0900 + +bluetooth-frwk (0.0.43) unstable; urgency=low + + * Repacke for EFL upgrade + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.43 + + -- DoHyun Pyun Fri, 10 Sep 2010 19:09:14 +0900 + +bluetooth-frwk (0.0.42) unstable; urgency=low + + * Added the support for Rfcomm api's multiple server and client with in + single process + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.42 + + -- Syam Sidhardhan Mon, 06 Sep 2010 18:50:55 +0530 + +bluetooth-frwk (0.0.41) unstable; urgency=low + + * Fixed the socket fd leak during the ACL link break when the client is connected + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.41 + + -- Syam Sidhardhan Tue, 31 Aug 2010 21:36:19 +0530 + +bluetooth-frwk (0.0.40) unstable; urgency=low + + * Added device address to the connection status structure + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.40 + + -- Syam Sidhardhan Tue, 31 Aug 2010 14:30:32 +0530 + +bluetooth-frwk (0.0.39) unstable; urgency=low + + * Added rfcomm API's + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.39 + + -- Syam Sidhardhan Mon, 30 Aug 2010 21:37:52 +0530 + +bluetooth-frwk (0.0.38) unstable; urgency=low + + * Code cleanup + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.38 + + -- DoHyun Pyun Mon, 30 Aug 2010 14:23:28 +0900 + +bluetooth-frwk (0.0.37) unstable; urgency=low + + * Add the SLP-DevGuide files + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.37 + + -- DoHyun Pyun Thu, 26 Aug 2010 08:25:20 +0900 + +bluetooth-frwk (0.0.36) unstable; urgency=low + + * Fix the prevent defect + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.36 + + -- DoHyun Pyun Tue, 24 Aug 2010 21:04:28 +0900 + +bluetooth-frwk (0.0.35) unstable; urgency=low + + * Modify the doxygen comments + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.35 + + -- DoHyun Pyun Fri, 20 Aug 2010 18:15:04 +0900 + +bluetooth-frwk (0.0.34) unstable; urgency=low + + * Apply the beat winset + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.34 + + -- DoHyun Pyun Fri, 20 Aug 2010 09:53:49 +0900 + +bluetooth-frwk (0.0.33) unstable; urgency=low + + * Apply the beat winset + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.33 + + -- DoHyun Pyun Tue, 17 Aug 2010 16:38:31 +0900 + +bluetooth-frwk (0.0.32) unstable; urgency=low + + * Chane elm_notify APIs to elm_popup APIs + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.32 + + -- Hye-Jin Kim Tue, 10 Aug 2010 10:04:18 +0900 + +bluetooth-frwk (0.0.31) unstable; urgency=low + + * Call the AUL message when agent start + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.31 + + -- DoHyun Pyun Fri, 06 Aug 2010 18:16:42 +0900 + +bluetooth-frwk (0.0.30) unstable; urgency=low + + * Apply new appcore + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.30 + + -- DoHyun Pyun Thu, 05 Aug 2010 22:05:49 +0900 + +bluetooth-frwk (0.0.29) unstable; urgency=low + + * Fix disabled event code + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.29 + + -- Seung-Woo Kim Tue, 03 Aug 2010 16:35:28 +0900 + +bluetooth-frwk (0.0.28) unstable; urgency=low + + * Fix the bug about discovering (Adjust the range of unsigned int) + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.28 + + -- DoHyun Pyun Fri, 30 Jul 2010 15:30:25 +0900 + +bluetooth-frwk (0.0.27) unstable; urgency=low + + * Fix print log format + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.27 + + -- Seung-Woo Kim Fri, 30 Jul 2010 09:41:25 +0900 + +bluetooth-frwk (0.0.25) unstable; urgency=low + + * Fix password entry in input view to show the last inputed value + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.25 + + -- Seung-Woo Kim Fri, 23 Jul 2010 19:50:35 +0900 + +bluetooth-frwk (0.0.24) unstable; urgency=low + + * Add missing major class enum and fix wrong discoverable mode value in + visibility changed event + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.24 + + -- Seung-Woo Kim Thu, 22 Jul 2010 22:23:04 +0900 + +bluetooth-frwk (0.0.23) unstable; urgency=low + + * Fix theme setting envrionment string + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.23 + + -- Seung-Woo Kim Thu, 22 Jul 2010 19:58:50 +0900 + +bluetooth-frwk (0.0.22) unstable; urgency=low + + * Fix to send proper device information after pairing + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.22 + + -- Seung-Woo Kim Tue, 20 Jul 2010 20:44:54 +0900 + +bluetooth-frwk (0.0.21) unstable; urgency=low + + * Fix doxygen group for SDK document + * Git: 165.213.180.234:/git/slp/pkgs/bluetooth-frwk + * Tag: bluetooth-frwk_0.0.21 + + -- Seung-Woo Kim Thu, 15 Jul 2010 14:10:23 +0900 + +bluetooth-frwk (0.0.20) unstable; urgency=low + + * Fix to show IME on paring by adding focusing option + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.20 + + -- Seung-Woo Kim Tue, 13 Jul 2010 11:39:37 +0900 + +bluetooth-frwk (0.0.19) unstable; urgency=low + + * Add window layer lower API to hide function + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.19 + + -- Seung-Woo Kim Mon, 12 Jul 2010 19:25:21 +0900 + +bluetooth-frwk (0.0.18) unstable; urgency=low + + * Fix PIN code length display in agent as scalable UI + * Fix input method framework API to new version + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.18 + + -- Seung-Woo Kim Mon, 12 Jul 2010 14:58:55 +0900 + +bluetooth-frwk (0.0.17) unstable; urgency=low + + * Fix set local name after enabling + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.17 + + -- Seung-Woo Kim Thu, 08 Jul 2010 19:45:40 +0900 + +bluetooth-frwk (0.0.16) unstable; urgency=low + + * Fix set discoverable mode with no timeout + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.16 + + -- Seung-Woo Kim Thu, 08 Jul 2010 19:18:47 +0900 + +bluetooth-frwk (0.0.15) unstable; urgency=low + + * Modify the maintainer list + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.15 + + -- DoHyun Pyun Thu, 08 Jul 2010 10:52:24 +0900 + +bluetooth-frwk (0.0.14) unstable; urgency=low + + * Fix struct for doc + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.14 + + -- Seung-Woo Kim Mon, 05 Jul 2010 19:06:41 +0900 + +bluetooth-frwk (0.0.13) unstable; urgency=low + + * Enable SDP API, Add GAP API implementation + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.13 + + -- chanyeol.park Thu, 24 Jun 2010 13:57:12 +0900 + +bluetooth-frwk (0.0.12) unstable; urgency=low + + * Add func,line info in dlog + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.12 + + -- chanyeol.park Wed, 16 Jun 2010 20:59:12 +0900 + +bluetooth-frwk (0.0.11) unstable; urgency=low + + * Dlog api changes applied + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.11 + + -- Shriram Joshi Tue, 15 Jun 2010 19:44:16 +0530 + +bluetooth-frwk (0.0.10) unstable; urgency=low + + * Add show/hide win_main evas object + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.10 + + -- chanyeol.park Tue, 15 Jun 2010 17:34:49 +0900 + +bluetooth-frwk (0.0.9) unstable; urgency=low + + * Fix Window Show/Hide operation + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.9 + + -- chanyeol.park Tue, 15 Jun 2010 15:15:24 +0900 + +bluetooth-frwk (0.0.8) unstable; urgency=low + + * Hide Agent during booting time with BT activation state + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.8 + + -- chanyeol.park Tue, 15 Jun 2010 12:15:52 +0900 + +bluetooth-frwk (0.0.7) unstable; urgency=low + + * Modify bool as gboolean + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.7 + + -- chanyeol.park Mon, 14 Jun 2010 18:34:36 +0900 + +bluetooth-frwk (0.0.6) unstable; urgency=low + + * Fix debug dpkg option + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.6 + + -- chanyeol.park Sat, 12 Jun 2010 15:20:57 +0900 + +bluetooth-frwk (0.0.5) unstable; urgency=low + + * Add agent activation/deactivation mechanism + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.5 + + -- chanyeol.park Thu, 10 Jun 2010 21:49:46 +0900 + +bluetooth-frwk (0.0.4) unstable; urgency=low + + * Temporarily Remove Adapter Signal Handle + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.4 + + -- chanyeol.park Wed, 09 Jun 2010 13:55:31 +0900 + +bluetooth-frwk (0.0.3) unstable; urgency=low + + * Add more APIs for GAP + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.3 + + -- Seung-Woo Kim Mon, 31 May 2010 22:56:59 +0900 + +bluetooth-frwk (0.0.2) unstable; urgency=low + + * Add Doxygen generate flag in control + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.2 + + -- Seung-Woo Kim Mon, 31 May 2010 11:21:26 +0900 + +bluetooth-frwk (0.0.1) unstable; urgency=low + * Initial Release. + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/bluetooth-frwk-0 + * Tag: bluetooth-frwk_0.0.1 - -- Chanyeol Park Wed, 07 Dec 2011 13:00:03 +0900 + -- Seung-Woo Kim Sat, 29 May 2010 18:44:49 +0900 diff --git a/debian/rules b/debian/rules index 9ddb186e..3315059e 100755 --- a/debian/rules +++ b/debian/rules @@ -4,7 +4,7 @@ #export DH_VERBOSE=1 CFLAGS ?= -Wall -g -LDFLAGS ?= +LDFLAGS ?= PREFIX ?= /usr DATADIR ?= /opt @@ -78,7 +78,7 @@ clean: rm -f bluetooth-map-agent/Makefile rm -f bluetooth-frwk-agent/po/Makefile rm -f lib/test/Makefile - + rm -f lib/*.pc rm -f lib/marshal.c rm -f lib/marshal.h @@ -86,17 +86,25 @@ clean: rm -f bluetooth-frwk-agent/marshal.c rm -f bluetooth-frwk-agent/marshal.h + rm -f bluetooth-telephony/marshal.c + rm -f bluetooth-telephony/marshal.h + rm -f bluetooth-frwk-agent/sc_core_agent_glue.h rm -f bluetooth-frwk-agent/bluetooth_obex_agent_glue.h rm -f bluetooth-pb-agent/bluetooth_pb_agent_glue.h rm -f bluetooth-map-agent/bluetooth_map_agent_glue.h - - dh_clean + rm -f bluetooth-telephony/bluetooth-telephony-glue.h + + rm -f bluetooth-media-control/Makefile + rm -f bluetooth-media-control/bluetooth-media-control.pc + rm -f bluetooth-media-control/test/Makefile + + dh_clean install: build dh_testdir dh_testroot - dh_clean -k + dh_clean -k dh_installdirs # Add here commands to install the package into debian/wavplayer. @@ -116,12 +124,12 @@ binary-indep: build install binary-arch: build install dh_testdir dh_testroot - dh_installchangelogs + dh_installchangelogs dh_installdocs dh_installexamples dh_install --sourcedir=debian/tmp # dh_installmenu -# dh_installdebconf +# dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 59897317..4e7e96f1 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,9 +1,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-api C) -SET(SRCS bluetooth-api-common.c marshal.c bluetooth-gap-api.c bluetooth-sdp-api.c bluetooth-rfcomm-api.c bluetooth-network-api.c bluetooth-hdp-api.c obex-agent.c bluetooth-opc-api.c -bluetooth-obex-server-api.c bluetooth-hid-api.c) -SET(HEADERS bluetooth-api.h bluetooth-hid-api.h) +SET(SRCS bluetooth-api-common.c marshal.c bluetooth-gap-api.c bluetooth-sdp-api.c bluetooth-rfcomm-api.c bluetooth-network-api.c bluetooth-hdp-api.c obex-agent.c bluetooth-opc-api.c bluetooth-obex-server-api.c bluetooth-hid-api.c bluetooth-audio-api.c bluetooth-control-api.c bluetooth-le/bluetooth-gatt-api.c) +SET(HEADERS bluetooth-api.h bluetooth-hid-api.h bluetooth-audio-api.h bluetooth-control-api.h) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") @@ -15,7 +14,7 @@ SET(VERSION ${VERSION_MAJOR}.0.0) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE(FindPkgConfig) -pkg_check_modules(packages REQUIRED dlog dbus-glib-1 gobject-2.0 gmodule-2.0 vconf +pkg_check_modules(packages REQUIRED dlog dbus-glib-1 gobject-2.0 gmodule-2.0 vconf libxml-2.0 syspopup-caller) FOREACH(flag ${packages_CFLAGS}) @@ -40,6 +39,7 @@ EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR} FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool) EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=obex_agent ${CMAKE_CURRENT_SOURCE_DIR}/obex-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/obex-agent-glue.h") +EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bluetooth_gatt ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-le/bluetooth-gatt.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-le/bluetooth-gatt-glue.h") #SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") @@ -56,4 +56,3 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkg FOREACH(hfile ${HEADERS}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-api) ENDFOREACH(hfile) - diff --git a/lib/bluetooth-api-common.c b/lib/bluetooth-api-common.c index a7b47b3c..2cb74cac 100644 --- a/lib/bluetooth-api-common.c +++ b/lib/bluetooth-api-common.c @@ -122,7 +122,11 @@ int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path) DBG("+\n"); - manager_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", "/", "org.bluez.Manager"); + if (conn == NULL) + return BLUETOOTH_ERROR_INTERNAL; + + manager_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, + BLUEZ_MANAGER_OBJ_PATH, BLUEZ_MANAGER_INTERFACE); if (manager_proxy == NULL) { DBG("Could not create a dbus proxy\n"); @@ -154,6 +158,54 @@ int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path) return BLUETOOTH_ERROR_NONE; } +DBusGProxy *_bluetooth_internal_get_adapter_proxy(DBusGConnection *conn) +{ + GError *err = NULL; + DBusGProxy *manager_proxy = NULL; + DBusGProxy *adapter_proxy = NULL; + char *adapter_path = NULL; + + DBG("+\n"); + + if (conn == NULL) + return NULL; + + manager_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, + BLUEZ_MANAGER_OBJ_PATH, BLUEZ_MANAGER_INTERFACE); + + if (manager_proxy == NULL) { + DBG("Could not create a dbus proxy\n"); + return NULL; + } + + if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &err, + G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &adapter_path, + G_TYPE_INVALID)) { + if (err != NULL) { + DBG("Getting DefaultAdapter failed: [%s]\n", err->message); + g_error_free(err); + } + g_object_unref(manager_proxy); + return NULL; + } + + if (adapter_path == NULL || strlen(adapter_path) >= BT_ADAPTER_OBJECT_PATH_MAX) { + DBG("Adapter path is inproper\n"); + g_object_unref(manager_proxy); + return NULL; + } + + adapter_proxy = dbus_g_proxy_new_for_name(conn, + BLUEZ_SERVICE_NAME, + adapter_path, + BLUEZ_ADAPTER_INTERFACE); + + g_object_unref(manager_proxy); + + return adapter_proxy; +} + + void _bluetooth_internal_convert_addr_string_to_addr_type(bluetooth_device_address_t *addr, const char *address) { @@ -203,36 +255,6 @@ void _bluetooth_internal_divide_device_class(bluetooth_device_class_t *device_cl } } -static int __bluetooth_internal_store_set_value(const char *key, bt_store_type_t store_type, - void *value) -{ - int ret = 0; - int int_vlaue = 0; - - if (value == NULL) { - return -1; - } - - switch (store_type) { - case BT_STORE_BOOLEAN: - int_vlaue = *((gboolean *) value); - ret = vconf_set_bool(key, int_vlaue); - break; - case BT_STORE_INT: - int_vlaue = *((int *)value); - ret = vconf_set_int(key, int_vlaue); - break; - case BT_STORE_STRING: - ret = vconf_set_str(key, (char *)value); - break; - default: - DBG("Unknown Store Type"); - return -1; - } - - return ret; -} - static int __bluetooth_internal_store_get_value(const char *key, bt_store_type_t store_type, unsigned int size, void *value) @@ -494,8 +516,8 @@ DBusGProxy *_bluetooth_internal_add_device(const char *path) { DBusGProxy *device_proxy = NULL; - device_proxy = dbus_g_proxy_new_for_name(bt_info.conn, "org.bluez", - path, "org.bluez.Device"); + device_proxy = dbus_g_proxy_new_for_name(bt_info.conn, BLUEZ_SERVICE_NAME, + path, BLUEZ_DEVICE_INTERFACE); if (device_proxy) { bt_info.device_proxy_list = g_list_append(bt_info.device_proxy_list, device_proxy); @@ -632,7 +654,6 @@ static void __bluetooth_internal_adapter_property_changed(DBusGProxy *adapter, GValue *value, gpointer user_data) { - int ret = 0; DBG("+ property[%s]", property); if (g_strcmp0(property, "Name") == 0) { @@ -735,8 +756,9 @@ static void __bluetooth_internal_remote_device_found(DBusGProxy *adapter, paired); } else { _bluetooth_internal_remote_device_found_cb(address, + rssi, remote_class, - rssi, paired); + paired); } } @@ -899,8 +921,8 @@ int bluetooth_internal_set_adapter_path(const char *adapter_path) g_strlcpy(bt_info.adapter_path, adapter_path, BT_ADAPTER_OBJECT_PATH_MAX); bt_info.adapter_proxy = - dbus_g_proxy_new_for_name(bt_info.conn, "org.bluez", bt_info.adapter_path, - "org.bluez.Adapter"); + dbus_g_proxy_new_for_name(bt_info.conn, BLUEZ_SERVICE_NAME, bt_info.adapter_path, + BLUEZ_ADAPTER_INTERFACE); if (!bt_info.adapter_proxy) { AST("Could not create a dbus proxy"); return BLUETOOTH_ERROR_INTERNAL; @@ -981,7 +1003,7 @@ static void __bluetooth_internal_name_owner_changed(DBusGProxy *dbus_proxy, cons DBG("Name str = %s", name); - if (g_strcmp0(name, "org.bluez") == 0 && *new == '\0') { + if (g_strcmp0(name, BLUEZ_SERVICE_NAME) == 0 && *new == '\0') { DBG("BlueZ is terminated"); bt_info.bt_adapter_state = BLUETOOTH_ADAPTER_DISABLED; @@ -1007,6 +1029,11 @@ static void __bluetooth_internal_mode_changed_cb(DBusGProxy *object, const char void *param_data = NULL; int scanEnable = 0; + if (changed_mode == NULL) { + ERR("changed_mode is NULL"); + return; + } + DBG("Mode changed [%s]\n", changed_mode); if (strlen(changed_mode) == 0) { @@ -1076,7 +1103,6 @@ void _bluetooth_internal_session_init(void) { GError *err = NULL; const char *adapter_path = NULL; - int ret = 0; DBG("+\n"); if (bt_info.application_pid == 0) { @@ -1106,8 +1132,8 @@ void _bluetooth_internal_session_init(void) NULL, NULL); } - bt_info.manager_proxy = dbus_g_proxy_new_for_name(bt_info.conn, "org.bluez", "/", - "org.bluez.Manager"); + bt_info.manager_proxy = dbus_g_proxy_new_for_name(bt_info.conn, BLUEZ_SERVICE_NAME, + BLUEZ_MANAGER_OBJ_PATH, BLUEZ_MANAGER_INTERFACE); if (!bt_info.manager_proxy) { AST("Could not create a dbus proxy"); return; @@ -1266,24 +1292,6 @@ BT_EXPORT_API int bluetooth_is_supported(void) return is_supported; } -BT_EXPORT_API int bluetooth_allow_service(gboolean allow) -{ - DBG("+\n"); - - /* Vconf value 1: Restrict to use BT service - Vconf value 0: Allow to use BT service */ - if (vconf_set_bool(BT_MEMORY_KEY_RESTRICTION, !allow)) - return BLUETOOTH_ERROR_ACCESS_DENIED; - - if (allow == FALSE) - bluetooth_disable_adapter(); - - DBG("-\n"); - - return BLUETOOTH_ERROR_NONE; -} - - BT_EXPORT_API int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data) { _bluetooth_internal_session_init(); diff --git a/lib/bluetooth-api-common.h b/lib/bluetooth-api-common.h index 77862fba..0abce12f 100644 --- a/lib/bluetooth-api-common.h +++ b/lib/bluetooth-api-common.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -56,18 +57,19 @@ #define AST(fmt, args...) \ SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args) -#define BT_STORE_PREFIX "db/bluetooth/" -#define BT_STORE_VISIBILITY_PATH BT_STORE_PREFIX"visibility" -#define BT_STORE_VISIBILITY_TIME_PATH BT_STORE_PREFIX"visibility_time" -#define BT_MEMORY_KEY_RESTRICTION "memory/bluetooth/restriction" #define BT_SETTING_DEVICE_NAME "db/setting/device_name" +#define BT_MEMORY_OBEX_NO_AGENT "memory/private/libbluetooth-frwk-0/obex_no_agent" +#define BT_MEMORY_RFCOMM_UUID "memory/private/libbluetooth-frwk-0/uuid" +#define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time" -#define BT_SYSPOPUP_NAME "bt-syspopup" -#define BT_SECURITY_EVENT "bt-security" -#define BT_SECURITY_DISABLED "disabled" +#define BLUEZ_SERVICE_NAME "org.bluez" +#define BLUEZ_MANAGER_OBJ_PATH "/" +#define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager" -#define BLUEZ_NAME "org.bluez" -#define BLUEZ_ADAPTER_NAME "org.bluez.Adapter" +#define BLUEZ_ADAPTER_INTERFACE "org.bluez.Adapter" +#define BLUEZ_DEVICE_INTERFACE "org.bluez.Device" + +#define BT_AGENT_INTERFACE "User.Bluetooth.agent" #define HCI_SCAN_ENABLE_NO_SCAN 0x00 #define HCI_SCAN_ENABLE_INQUIRY_ONLY 0x01 @@ -82,11 +84,22 @@ #define BLUETOOTH_UUID_POSTFIX "0000-1000-8000-00805f9b34fb" +#define BT_COMMON_PKG "ug-setting-bluetooth-efl" + +#define BT_STR_DISABLED_RESTRICTS \ + dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SECURITY_POLICY_RESTRICTS_USE_OF_BLUETOOTH_CONNECTION") + +#define BT_STR_HANDS_FREE_RESTRICTS \ + dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SECURITY_POLICY_RESTRICTS_USE_OF_BLUETOOTH_CONNECTION_TO_HANDS_FREE_FEATURES_ONLY") + #define RFKILL_EVENT_SIZE 8 #define BT_PHONE_NUM_LEN 50 #define BT_FILE_BUFFER_MAX 256 +#define SLEEP_TIME 50000 /* 50 ms */ +#define BLOCK_MAX_TIMEOUT 2000000 /* 2 seconds */ + typedef enum { BT_STORE_BOOLEAN, BT_STORE_INT, @@ -111,6 +124,13 @@ typedef enum { NUM_RFKILL_TYPES, } rfkill_type; +typedef enum { + BT_ACCEPT, + BT_REJECT, + BT_CANCEL, + BT_TIMEOUT, +} bt_accept_type_t; + typedef struct { unsigned int idx; unsigned char type; @@ -149,7 +169,9 @@ typedef struct { DBusGProxy *adapter_proxy; /**< bluez adapter ipc proxy */ DBusGProxy *agent_proxy; /**< Agent ipc proxy */ DBusGProxy *network_server_proxy; + DBusGProxy *rfcomm_proxy; char adapter_path[BT_ADAPTER_OBJECT_PATH_MAX]; /*bluez adapter path*/ + char *connecting_uuid; GList *device_proxy_list; /**< bluez device ipc proxy list */ bluetooth_adapter_state_t bt_adapter_state; /*Current bluetooth state*/ @@ -200,13 +222,11 @@ void _bluetooth_internal_divide_device_class(bluetooth_device_class_t *device_cl void _bluetooth_internal_device_path_to_address(const char *device_path, char *device_address); -int _bluetooth_internal_get_value(bt_store_key_t key); -int _bluetooth_internal_set_value(bt_store_key_t key); - int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size); int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path); +DBusGProxy *_bluetooth_internal_get_adapter_proxy(DBusGConnection *conn); #ifdef __cplusplus extern "C" { diff --git a/lib/bluetooth-api.h b/lib/bluetooth-api.h index e1294176..e704d7d8 100644 --- a/lib/bluetooth-api.h +++ b/lib/bluetooth-api.h @@ -198,6 +198,13 @@ typedef enum { /**< Base ID for OPC events */ #define BLUETOOTH_EVENT_OBEX_SERVER_BASE ((int)(BLUETOOTH_EVENT_OPC_BASE + 0x0020)) /**< Base ID for Obex Server events */ +#define BLUETOOTH_EVENT_GATT_BASE ((int)(BLUETOOTH_EVENT_OBEX_SERVER_BASE + 0x0020)) + /**< Base ID for GATT events */ + +#define BLUETOOTH_EVENT_AUDIO_BASE ((int)(BLUETOOTH_EVENT_GATT_BASE + 0x0020)) + /**< Base ID for Audio events */ +#define BLUETOOTH_EVENT_HID_BASE ((int)(BLUETOOTH_EVENT_AUDIO_BASE + 0x0020)) + /**< Base ID for Audio events */ /** * Bluetooth event type */ @@ -231,6 +238,8 @@ typedef enum { BLUETOOTH_EVENT_RFCOMM_CONNECTED, /**< Rfcomm server incomming connection */ BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, /**< Rfcomm server/client disconnect */ + BLUETOOTH_EVENT_RFCOMM_AUTHORIZE, + BLUETOOTH_EVENT_DEVICE_CONNECTED, /**< Bluetooth event device connected */ BLUETOOTH_EVENT_DEVICE_DISCONNECTED, /**< Bluetooth event device disconnected */ @@ -244,10 +253,8 @@ typedef enum { BLUETOOTH_EVENT_NETWORK_CONNECTED, /**< Network connected event in client*/ BLUETOOTH_EVENT_NETWORK_DISCONNECTED, /**< Network disconnected evnet in client*/ - BLUETOOTH_EVENT_HDP_ACTIVATED - = BLUETOOTH_EVENT_HDP_BASE, /***/ - BLUETOOTH_EVENT_HDP_DEACTIVATED, /***/ - BLUETOOTH_EVENT_HDP_CONNECTED, /***/ + BLUETOOTH_EVENT_HDP_CONNECTED + = BLUETOOTH_EVENT_HDP_BASE, /***/ BLUETOOTH_EVENT_HDP_DISCONNECTED, /***/ BLUETOOTH_EVENT_HDP_DATA_RECEIVED, /***/ @@ -263,8 +270,23 @@ typedef enum { BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED, /* Obex Server transfer started event*/ BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,/* Obex Server transfer progress event*/ BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,/* Obex Server transfer complete event*/ - - BLUETOOTH_EVENT_MAX, /**< Bluetooth event Max value */ + BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE, + + BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED = BLUETOOTH_EVENT_GATT_BASE, + /**param_data; + + printf("\nConnected from %s", name); + + bluetooth_rfcomm_accept_connection(); + } + } + } + + ... + + int ret = 0; + fd = bluetooth_rfcomm_create_socket(rfcomm_test_uuid); + ret = bluetooth_rfcomm_listen(fd, 1); + + @endcode + */ +int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection); + +/** + * @fn int bluetooth_rfcomm_accept_connection() + * @brief Accepts the authorization request indicated by the event + * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal error \n + * + * @param[in] the socket fd of the server + * @param[out] the socket fd of the client + * + * @exception None + * @remark None + * @see bluetooth_rfcomm_reject_connection + */ +int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd); + +/** + * @fn int bluetooth_rfcomm_reject_connection() + * @brief Rejects the authorization request indicated by the event + * BLUETOOTH_EVENT_RFCOMM_AUTHORIZE. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal error \n + * + * @param[in] the socket fd of the server + * + * @exception None + * @remark None + * @see bluetooth_rfcomm_accept_connection + */ +int bluetooth_rfcomm_reject_connection(int server_fd); + /** * @fn gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid) * @brief Informs whether rfcomm server uuid is available or not. @@ -2208,11 +2406,11 @@ int bluetooth_network_disconnect(const bluetooth_device_address_t *device_addres /** * @fn int bluetooth_hdp_activate(unsigned short data_type, * bt_hdp_role_type_t role, - * bt_hdp_qos_type_t channel_type) + * bt_hdp_qos_type_t channel_type, + * char **app_handle) * @brief Activate the HDP service for a particular data type * - * This function is a asynchronous call. - * The HDP activate is responded by BLUETOOTH_EVENT_HDP_ACTIVATED event. + * This function is a synchronous call. * * @return BLUETOOTH_ERROR_NONE - Success \n * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n @@ -2226,18 +2424,19 @@ int bluetooth_network_disconnect(const bluetooth_device_address_t *device_addres * HDP_QOS_RELIABLE/HDP_QOS_STREAMING/HDP_QOS_ANY. * For role = HDP_ROLE_SINK, the channel_type * should be HDP_QOS_ANY. + * @param[out] app_handle The application handler against corresponding service * @remark None * @see bluetooth_hdp_deactivate */ int bluetooth_hdp_activate(unsigned short data_type, bt_hdp_role_type_t role, - bt_hdp_qos_type_t channel_type); + bt_hdp_qos_type_t channel_type, + char **app_handle); /** * @fn int bluetooth_hdp_deactivate(const char *app_handle) * @brief Deactivate the HDP service for a particular service using the handler * - * This function is a asynchronous call. - * The HDP activate is responded by BLUETOOTH_EVENT_HDP_DEACTIVATED event. + * This function is a synchronous call. * * @return BLUETOOTH_ERROR_NONE - Success \n * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n @@ -2333,6 +2532,7 @@ int bluetooth_hdp_disconnect(unsigned int channel_id, * No event corresponding to this api * * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n * BLUETOOTH_ERROR_INTERNAL - Internal Error \n * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n @@ -2352,8 +2552,8 @@ int bluetooth_opc_init(void); * No event corresponding to this api * * @return BLUETOOTH_ERROR_NONE - Success \n - * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n - * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n + * BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n * * @exception None * @@ -2364,18 +2564,19 @@ int bluetooth_opc_init(void); int bluetooth_opc_deinit(void); /** - * @fn int bluetooth_opc_push_files(bluetooth_device_address_t *device_address, - unsigned char **file_name_array) + * @fn int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address, + char **file_name_array) * @brief Send multiple files to a remote device. * * This function is a asynchronous call. * This api is responded by BLUETOOTH_EVENT_OPC_CONNECTED event. * * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n * BLUETOOTH_ERROR_INTERNAL - Internal Error \n * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n - * BLUETOOTH_ERROR_IN_PROGRESS -Already one push in progress \n + * BLUETOOTH_ERROR_IN_PROGRESS -Already one push in progress \n * * @exception None * @param[in] device_address The remote device Bd address. @@ -2397,8 +2598,8 @@ int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address, * BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETED event. * * @return BLUETOOTH_ERROR_NONE - Success \n - * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n - * BLUETOOTH_ERROR_ACCESS_DENIED - No push in progress \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n + * BLUETOOTH_ERROR_ACCESS_DENIED - No push in progress \n * * @exception None * @@ -2427,22 +2628,24 @@ gboolean bluetooth_opc_session_is_exist(void); /** - * @fn int bluetooth_obex_server_init(char *dst_path) + * @fn int bluetooth_obex_server_init(const char *dst_path) * @brief Initialize OPP and FTP server. * * This function is a synchronous call. * No event corresponding to this api * * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n - * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n + * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n * * @exception None * @param[in] dst_path OPS destination file path. * @remark None * @see bluetooth_obex_server_deinit */ -int bluetooth_obex_server_init(char *dst_path); +int bluetooth_obex_server_init(const char *dst_path); /** @@ -2453,7 +2656,7 @@ int bluetooth_obex_server_init(char *dst_path); * No event corresponding to this api * * @return BLUETOOTH_ERROR_NONE - Success \n - * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n * * @exception None @@ -2461,7 +2664,6 @@ int bluetooth_obex_server_init(char *dst_path); * @remark None * @see bluetooth_obex_server_init */ - int bluetooth_obex_server_deinit(void); @@ -2483,7 +2685,84 @@ gboolean bluetooth_obex_server_is_activated(void); /** - * @fn int bluetooth_obex_server_accept_authorize(char *filename) + * @fn int bluetooth_obex_server_init_without_agent(const char *dst_path) + * @brief Initialize OPP and FTP server without the conneciton authorization of the agent + * + * This function is a synchronous call. + * No event corresponding to this api + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n + * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n + * BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n + * + * + * @exception None + * @param[in] dst_path OPS destination file path. + * @remark None + * @see bluetooth_obex_server_deinit_without_agent + */ +int bluetooth_obex_server_init_without_agent(const char *dst_path); + + +/** + * @fn int bluetooth_obex_server_deinit_without_agent(void) + * @brief Deinitialize OPP and FTP server without the conneciton authorization of the agent + * + * This function is a synchronous call. + * No event corresponding to this api + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n + * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n + * + * @exception None + * + * @remark None + * @see bluetooth_obex_server_init_without_agent + */ +int bluetooth_obex_server_deinit_without_agent(void); + + +/** + * @fn int bluetooth_obex_server_accept_connection(void) + * @brief Accepts the authorization request indicated by the event + * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n + * BLUETOOTH_ERROR_INTERNAL - Internal error \n + * + * @exception None + * @remark None + * @see bluetooth_obex_server_reject_authorize + */ +int bluetooth_obex_server_accept_connection(void); + + +/** + * @fn int bluetooth_obex_server_reject_connection(void) + * @brief Rejects the authorization request indicated by the event + * BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n + * BLUETOOTH_ERROR_INTERNAL - Internal error \n + * + * @exception None + * @remark None + * @see bluetooth_obex_server_reject_authorize + */ +int bluetooth_obex_server_reject_connection(void); + + +/** + * @fn int bluetooth_obex_server_accept_authorize(const char *filename) * @brief Accepts the authorization request indicated by the event * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE. * @@ -2491,7 +2770,8 @@ gboolean bluetooth_obex_server_is_activated(void); * This api will be responded with the event BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED. * * @return BLUETOOTH_ERROR_NONE - Success \n - * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n * * @exception None @@ -2501,7 +2781,7 @@ gboolean bluetooth_obex_server_is_activated(void); * @see bluetooth_obex_server_reject_authorize */ -int bluetooth_obex_server_accept_authorize(char *filename); +int bluetooth_obex_server_accept_authorize(const char *filename); /** * @fn int bluetooth_obex_server_reject_authorize(void) @@ -2512,7 +2792,7 @@ int bluetooth_obex_server_accept_authorize(char *filename); * No event for this api.. * * @return BLUETOOTH_ERROR_NONE - Success \n - * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n * * @exception None @@ -2524,7 +2804,7 @@ int bluetooth_obex_server_accept_authorize(char *filename); int bluetooth_obex_server_reject_authorize(void); /** - * @fn int bluetooth_obex_server_set_destination_path(char *dst_path) + * @fn int bluetooth_obex_server_set_destination_path(const char *dst_path) * @brief Set the OPS destination file path.. * * This function is a asynchronous call. @@ -2533,7 +2813,7 @@ int bluetooth_obex_server_reject_authorize(void); * @return BLUETOOTH_ERROR_NONE - Success \n * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n - * BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n * * @exception None * @param[in] dst_path OPS destination file path. @@ -2542,19 +2822,21 @@ int bluetooth_obex_server_reject_authorize(void); * @see None */ -int bluetooth_obex_server_set_destination_path(char *dst_path); +int bluetooth_obex_server_set_destination_path(const char *dst_path); /** - * @fn int bluetooth_obex_server_set_root(char *root) + * @fn int bluetooth_obex_server_set_root(const char *root) * @brief Set the FTS root folder.. * * This function is a asynchronous call. * No event for this api.. * * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n * BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n - * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n - * BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n + * BLUETOOTH_ERROR_ACCESS_DENIED - Operation not allowed \n + * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n * * @exception None * @param[in] root FTS root folder. @@ -2563,14 +2845,14 @@ int bluetooth_obex_server_set_destination_path(char *dst_path); * @see None */ -int bluetooth_obex_server_set_root(char *root); +int bluetooth_obex_server_set_root(const char *root); /** * @fn int bluetooth_obex_server_cancel_transfer(int transfer_id) * @brief Cancel the transfer on server * - * This function is a asynchronous call. - * If the call is success to cancel transfering then the application will receive + * This function is an asynchronous call. + * If the function call that cancels transfer is successful, the application would recieve * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure * the error code will be BLUETOOTH_ERROR_NONE @@ -2587,10 +2869,33 @@ int bluetooth_obex_server_set_root(char *root); * @remark None * @see None */ - int bluetooth_obex_server_cancel_transfer(int transfer_id); +/** + * @fn int bluetooth_obex_server_cancel_all_transfers(void) + * @brief Cancel the transfer on server + * + * This function is an asynchronous call. + * If the function call that cancels transfer is successful, the application would recieve + * BLUETOOTH_EVENT_TRANSFER_COMPLETED event through registered callback + * function with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure + * the error code will be BLUETOOTH_ERROR_NONE + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n + * BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n + * BLUETOOTH_ERROR_INTERNAL - internal error (proxy does not exist) \n + * BLUETOOTH_ERROR_NOT_FOUND - The transfer is not found \n + * + * @exception None + * + * @remark None + * @see None + */ +int bluetooth_obex_server_cancel_all_transfers(void); + + /** * @fn int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data) * @brief Read the local Hash and Randmizer. @@ -2657,6 +2962,222 @@ int bluetooth_oob_add_remote_data( int bluetooth_oob_remove_remote_data( const bluetooth_device_address_t *remote_device_address); +/** + * @fn int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address, + * bt_gatt_handle_info_t *prim_svc); + * + * @brief Gets the GATT based primary services handle supported by remote device + * + * This function is a synchronous call. + * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services() + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] address - Remote device address + * @param[out] prim_svc - Structure containing remote service count and handle list. + * + * @remark None + * @see bluetooth_gatt_free_primary_services() + */ +int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address, + bt_gatt_handle_info_t *prim_svc); + +/** + * @fn int bluetooth_gatt_discover_service_characteristics(const char *service_handle) + * + * @brief Discovers the characteristics of GATT based service of remote device + * + * This function is an asynchronous call. + * This API is responded with BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] service_handle - Handle for remote service. + * + * @remark None + * @see None + */ +int bluetooth_gatt_discover_service_characteristics(const char *service_handle); + +/** + * @fn int bluetooth_gatt_get_service_property(const char *service_handle, + * bt_gatt_service_property_t *service); + * + * @brief Gets the properties of GATT based service of remote device + * + * This function is a synchronous call. + * The output parameter needs to be freed by calling bluetooth_gatt_free_primary_services() + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] service_handle - Handle for remote service. + * @param[out] service - Structure containing remote service property. + * + * @remark None + * @see bluetooth_gatt_free_service_property() + */ +int bluetooth_gatt_get_service_property(const char *service_handle, + bt_gatt_service_property_t *service); + +/** + * @fn int bluetooth_gatt_watch_characteristics(const char *service_handle) + * + * @brief Register to GATT based service to receive value change notification/indication. + * + * This function is a synchronous call. + * No event for this api. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] service_handle - Handle for remote service. + * + * @remark None + * @see None + */ +int bluetooth_gatt_watch_characteristics(const char *service_handle); + +/** + * @fn int bluetooth_gatt_unwatch_characteristics(const char *service_handle) + * + * @brief Unregister GATT based service to receive value change notification/indication. + * + * This function is a synchronous call. + * No event for this api. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] service_handle - Handle for remote service. + * + * @remark None + * @see None + */ +int bluetooth_gatt_unwatch_characteristics(const char *service_handle); + +/** + * @fn int bluetooth_gatt_get_characteristics_property(const char *char_handle, + * bt_gatt_char_property_t *characteristic); + * + * @brief Provides characteristic value along with properties. + * + * This function is a synchronous call. + * The output parameter needs to be freed by calling bluetooth_gatt_free_char_property() + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] char_handle - Handle for Characteristic property. + * @param[out] characteristic - Structure containing remote characteristic property. + * + * @remark None + * @see bluetooth_gatt_free_char_property() + */ +int bluetooth_gatt_get_characteristics_property(const char *char_handle, + bt_gatt_char_property_t *characteristic); + +/** + * @fn int bluetooth_gatt_set_characteristics_value(const char *char_handle, + * const guint8 *value, int length) + * + * @brief Set characteristic value. + * + * This function is a synchronous call. + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INTERNAL - Internal Error \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n + * + * @exception None + * @param[in] char_handle - Handle for Characteristic property. + * @param[in] value - New value to set for characteristic property. + * @param[in] length - Length of the value to be set. + * + * @remark None + * @see None + */ +int bluetooth_gatt_set_characteristics_value(const char *char_handle, + const guint8 *value, int length); + +/** + * @fn int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc); + * + * @brief Releases the memory allocated by bluetooth_gatt_get_primary_services() + * + * This function is a synchronous call. + * The input parameter is obtained by calling bluetooth_gatt_get_primary_services() + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * + * @exception None + * @param[in] prim_svc - GATT handle info structure + * + * @remark None + * @see bluetooth_gatt_get_primary_services() + */ +int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc); + +/** + * @fn int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty); + * + * @brief Releases the memory allocated by bluetooth_gatt_get_service_property() + * + * This function is a synchronous call. + * The input parameter is obtained by calling bluetooth_gatt_get_service_property() + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * + * @exception None + * @param[in] svc_pty - GATT service property structure. + * + * @remark None + * @see bluetooth_gatt_get_service_property() + */ +int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty); + +/** + * @fn int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty); + * + * @brief Provides characteristic value along with properties. + * + * This function is a synchronous call. + * The input parameter is obtained by calling bluetooth_gatt_get_characteristics_property() + * + * @return BLUETOOTH_ERROR_NONE - Success \n + * BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n + * + * @exception None + * @param[in] char_pty - GATT characteristics property structure. + * + * @remark None + * @see bluetooth_gatt_get_characteristics_property() + */ + int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty); + /** * @} */ diff --git a/lib/bluetooth-api.pc.in b/lib/bluetooth-api.pc.in index 4a1eda5c..9689d8c1 100644 --- a/lib/bluetooth-api.pc.in +++ b/lib/bluetooth-api.pc.in @@ -4,7 +4,7 @@ libdir=@LIBDIR@ includedir=@INCLUDEDIR@ Name: bluetooth-api -Description: SAMSUNG Linux platform Bluetooth framework API +Description: Tizen Linux platform Bluetooth framework API Version: @VERSION@ Requires: dlog dbus-glib-1 vconf Libs: -L${libdir} -lbluetooth-api diff --git a/lib/bluetooth-gap-api.c b/lib/bluetooth-gap-api.c index 92eac5e1..438e1be8 100644 --- a/lib/bluetooth-gap-api.c +++ b/lib/bluetooth-gap-api.c @@ -32,6 +32,28 @@ static bluetooth_discovery_option_t discovery_option = { 0 }; static int __bluetooth_internal_bonding_req(void); static void __bluetooth_internal_get_service_list(GValue *value, bluetooth_device_info_t *dev); +static int __bt_launch_terminate_popup(void) +{ + int ret = 0; + bundle *b = NULL; + + b = bundle_create(); + + if (b == NULL) + return BLUETOOTH_ERROR_INTERNAL; + + bundle_add(b, "event-type", "terminate"); + + ret = syspopup_launch("bt-syspopup", b); + + if (ret < 0) + DBG("Popup launch failed: %d\n", ret); + + bundle_free(b); + + return ret; +} + BT_EXPORT_API int bluetooth_check_adapter(void) { int adapter_state = BLUETOOTH_ADAPTER_DISABLED; @@ -182,7 +204,6 @@ static int __bluetooth_internal_enable_adapter(void *data) BT_EXPORT_API int bluetooth_enable_adapter(void) { bt_info_t *bt_internal_info = NULL; - int value; DBG("+\n"); @@ -418,11 +439,74 @@ BT_EXPORT_API int bluetooth_set_local_name(const bluetooth_device_name_t *local_ return ret; } +BT_EXPORT_API int bluetooth_is_service_used(const char *service_uuid, + gboolean *used) +{ + bt_info_t *bt_internal_info = NULL; + char **uuids = NULL; + int i = 0; + GHashTable *hash = NULL; + GValue *value = NULL; + + if (service_uuid == NULL) { + ERR("wrong parameter"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + if (used == NULL) { + ERR("wrong parameter"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + bt_internal_info = _bluetooth_internal_get_information(); + + if (_bluetooth_internal_is_adapter_enabled() == FALSE) { + DBG("Currently not enabled"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + if (bt_internal_info->adapter_proxy == NULL) { + DBG("adapter_proxy is NULL"); + return BLUETOOTH_ERROR_INTERNAL; + } + + dbus_g_proxy_call(bt_internal_info->adapter_proxy, "GetProperties", NULL, + G_TYPE_INVALID, + dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), + &hash, G_TYPE_INVALID); + + if (hash == NULL) { + DBG("hash is NULL"); + return BLUETOOTH_ERROR_INTERNAL; + } + + value = g_hash_table_lookup(hash, "UUIDs"); + uuids = g_value_get_boxed(value); + + if (uuids == NULL) { + *used = FALSE; + return BLUETOOTH_ERROR_NONE; + } + + for (i = 0; uuids[i] != NULL; i++) { + DBG("UUIDs %s ", uuids[i]); + if (strcasecmp(uuids[i], service_uuid) == 0) { + *used = TRUE; + return BLUETOOTH_ERROR_NONE; + } + } + + *used = FALSE; + + return BLUETOOTH_ERROR_NONE; +} + BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t * discoverable_mode_ptr) { DBG("+"); bt_info_t *bt_internal_info = NULL; + int timeout = 0; GHashTable *hash = NULL; GValue *value = NULL; GValue *timeout_value = NULL; @@ -436,7 +520,18 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t if (_bluetooth_internal_is_adapter_enabled() == FALSE) { DBG("Currently not enabled"); - return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) { + DBG("Fail to get the timeout value"); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (timeout == -1) { + *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE; + } else { + *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; + } + + return BLUETOOTH_ERROR_NONE; } if (bt_internal_info->adapter_proxy != NULL) { @@ -514,12 +609,6 @@ BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t } - /* Set discoverable Timer in agent */ - dbus_g_proxy_call_no_reply(bt_internal_info->agent_proxy, "SetDiscoverableTimer", - G_TYPE_UINT, timeout, - G_TYPE_INVALID, - G_TYPE_INVALID); - g_value_set_boolean(&connectable, pg_scan); g_value_set_boolean(&discoverable, inq_scan); g_value_set_uint(&val_timeout, timeout); @@ -531,7 +620,7 @@ BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t if (error != NULL) { DBG("Powered set err:[%s]", error->message); g_error_free(error); - ret = BLUETOOTH_ERROR_INTERNAL; + return BLUETOOTH_ERROR_INTERNAL; } dbus_g_proxy_call(bt_internal_info->adapter_proxy, "SetProperty", &error, @@ -541,7 +630,7 @@ BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t if (error != NULL) { DBG("Discoverable set err:[%s]", error->message); g_error_free(error); - ret = BLUETOOTH_ERROR_INTERNAL; + return BLUETOOTH_ERROR_INTERNAL; } dbus_g_proxy_call(bt_internal_info->adapter_proxy, "SetProperty", &error, @@ -551,9 +640,18 @@ BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t if (error != NULL) { DBG("Timeout set err:[%s]", error->message); g_error_free(error); - ret = BLUETOOTH_ERROR_INTERNAL; + return BLUETOOTH_ERROR_INTERNAL; } + /* Set discoverable Timer in agent */ + if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) + timeout = -1; + + dbus_g_proxy_call_no_reply(bt_internal_info->agent_proxy, "SetDiscoverableTimer", + G_TYPE_INT, timeout, + G_TYPE_INVALID, + G_TYPE_INVALID); + g_value_unset(&val_timeout); g_value_unset(&connectable); g_value_unset(&discoverable); @@ -617,36 +715,36 @@ static bool __bluetooth_match_discovery_option(bluetooth_device_class_t device_c /* Check the major class */ switch (device_class.major_class) { - case BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_PHONE; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_TOY: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_TOY; - break; - case BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH; - break; - default: - major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_MISC; - break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_PHONE; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_TOY: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_TOY; + break; + case BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH; + break; + default: + major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_MISC; + break; } DBG("major_mask: %x", major_mask); @@ -673,6 +771,9 @@ void _bluetooth_internal_remote_device_name_updated_cb(const char *address, discovery_option.classOfDeviceMask) == FALSE) return; + if (name == NULL || address == NULL) + return; + _bluetooth_internal_convert_addr_string_to_addr_type(&dev_info.device_address, address); if (strlen(name) <= BLUETOOTH_DEVICE_NAME_LENGTH_MAX) { memcpy(&dev_info.device_name, name, strlen(name)); @@ -731,6 +832,7 @@ BT_EXPORT_API int bluetooth_start_discovery(unsigned short max_response, DBG("+"); bt_info_t *bt_internal_info = NULL; + DBusGProxy *adapter_proxy; _bluetooth_internal_session_init(); @@ -759,15 +861,20 @@ BT_EXPORT_API int bluetooth_start_discovery(unsigned short max_response, bt_internal_info = _bluetooth_internal_get_information(); - if (bt_internal_info->adapter_proxy == NULL) + adapter_proxy = _bluetooth_internal_get_adapter_proxy(bt_internal_info->conn); + + if (adapter_proxy == NULL) return BLUETOOTH_ERROR_INTERNAL; - if (!dbus_g_proxy_call(bt_internal_info->adapter_proxy, "StartDiscovery", NULL, + if (!dbus_g_proxy_call(adapter_proxy, "StartDiscovery", NULL, G_TYPE_INVALID, G_TYPE_INVALID)) { DBG("Discover start failed"); + g_object_unref(adapter_proxy); return BLUETOOTH_ERROR_INTERNAL; } + g_object_unref(adapter_proxy); + if (bt_internal_info->bt_discovery_req_timer != 0) { g_source_remove(bt_internal_info->bt_discovery_req_timer); bt_internal_info->bt_discovery_req_timer = 0; @@ -786,6 +893,7 @@ BT_EXPORT_API int bluetooth_cancel_discovery(void) bt_info_t *bt_internal_info = NULL; GError *error = NULL; int ret = BLUETOOTH_ERROR_NONE; + DBusGProxy *adapter_proxy; DBG("+"); @@ -798,13 +906,16 @@ BT_EXPORT_API int bluetooth_cancel_discovery(void) bt_internal_info = _bluetooth_internal_get_information(); - if (bt_internal_info->adapter_proxy == NULL) { + adapter_proxy = _bluetooth_internal_get_adapter_proxy(bt_internal_info->conn); + + if (adapter_proxy == NULL) return BLUETOOTH_ERROR_INTERNAL; - } - dbus_g_proxy_call(bt_internal_info->adapter_proxy, "StopDiscovery", &error, + dbus_g_proxy_call(adapter_proxy, "StopDiscovery", &error, G_TYPE_INVALID, G_TYPE_INVALID); + g_object_unref(adapter_proxy); + if (error) { DBG("error in StopDiscovery [%s]\n", error->message); @@ -831,6 +942,7 @@ BT_EXPORT_API int bluetooth_is_discovering(void) GHashTable *hash = NULL; GValue *value = NULL; int is_discovering = 0; + DBusGProxy *adapter_proxy; _bluetooth_internal_session_init(); @@ -841,18 +953,23 @@ BT_EXPORT_API int bluetooth_is_discovering(void) bt_internal_info = _bluetooth_internal_get_information(); - if (bt_internal_info->adapter_proxy != NULL) { - dbus_g_proxy_call(bt_internal_info->adapter_proxy, "GetProperties", NULL, - G_TYPE_INVALID, - dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), - &hash, G_TYPE_INVALID); + adapter_proxy = _bluetooth_internal_get_adapter_proxy(bt_internal_info->conn); - if (hash != NULL) { - value = g_hash_table_lookup(hash, "Discovering"); + if (adapter_proxy == NULL) + return is_discovering; - if (value) - is_discovering = g_value_get_boolean(value); - } + dbus_g_proxy_call(adapter_proxy, "GetProperties", NULL, + G_TYPE_INVALID, + dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), + &hash, G_TYPE_INVALID); + + g_object_unref(adapter_proxy); + + if (hash != NULL) { + value = g_hash_table_lookup(hash, "Discovering"); + + if (value) + is_discovering = (g_value_get_boolean(value) == FALSE) ? 0 : 1; } return is_discovering; @@ -960,7 +1077,8 @@ static void __bluetooth_internal_bonding_req_reply_cb(int error_type, bt_internal_info->is_headset_pin_req = TRUE; bt_internal_info->is_bonding_req = FALSE; bt_internal_info->is_headset_bonding = FALSE; - memset(bt_internal_info->bt_bonding_req_addrstr, 0x00, 18); + memset(bt_internal_info->bt_bonding_req_addrstr, + 0x00, BT_ADDRESS_STRING_SIZE); bluetooth_bond_device(&device_address); return; @@ -971,7 +1089,7 @@ static void __bluetooth_internal_bonding_req_reply_cb(int error_type, bt_internal_info->is_headset_pin_req = FALSE; bt_internal_info->is_bonding_req = FALSE; bt_internal_info->is_headset_bonding = FALSE; - memset(bt_internal_info->bt_bonding_req_addrstr, 0x00, 18); + memset(bt_internal_info->bt_bonding_req_addrstr, 0x00, BT_ADDRESS_STRING_SIZE); _bluetooth_internal_event_cb(BLUETOOTH_EVENT_BONDING_FINISHED, error_type, (void *)device_info); @@ -983,7 +1101,7 @@ void _bluetooth_internal_bonding_created_cb(const char *bond_address, gpointer u int remote_class = 0; gboolean trust = FALSE; - DBusGProxy *device_proxy = (DBusGProxy *) user_data; + DBusGProxy *device_proxy = (DBusGProxy *)user_data; GHashTable *hash = NULL; GValue *value = NULL; GValue *uuid_value = NULL; @@ -1187,6 +1305,9 @@ static void __bluetooth_internal_bonding_req_finish_cb(DBusGProxy *proxy, DBusGP (gpointer)device_proxy); } + /* Terminate the BT system popup (In the keyboard case) */ + __bt_launch_terminate_popup(); + DBG("-"); } @@ -1220,12 +1341,12 @@ BT_EXPORT_API int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data) bt_internal_info->conn); } - msg = dbus_message_new_method_call("org.bluez", + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, bt_internal_info->adapter_path, "org.bluez.OutOfBand", "ReadLocalData"); - if(msg == NULL) + if (msg == NULL) return BLUETOOTH_ERROR_INTERNAL; dbus_error_init(&err); @@ -1296,7 +1417,7 @@ BT_EXPORT_API int bluetooth_oob_add_remote_data( _bluetooth_internal_addr_type_to_addr_string(address, remote_device_address); - msg = dbus_message_new_method_call("org.bluez", + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, bt_internal_info->adapter_path, "org.bluez.OutOfBand", "AddRemoteData"); @@ -1368,7 +1489,7 @@ BT_EXPORT_API int bluetooth_oob_remove_remote_data( const char *dev_addr = g_strdup(address); DBG("dev_addr = [%s]\n", dev_addr); - msg = dbus_message_new_method_call("org.bluez", + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, bt_internal_info->adapter_path, "org.bluez.OutOfBand", "RemoveRemoteData"); @@ -1537,7 +1658,7 @@ static void __bluetooth_internal_unbond_request_complete_cb(DBusGProxy *proxy, D dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID); - device_address = (bluetooth_device_address_t *) user_data; + device_address = (bluetooth_device_address_t *)user_data; if (err != NULL) { DBG("Error occured in RemoveBonding [%s]\n", err->message); @@ -1583,9 +1704,9 @@ BT_EXPORT_API int bluetooth_unbond_device(const bluetooth_device_address_t *devi _bluetooth_internal_addr_type_to_addr_string(address, device_address); - /*allocate user data so that it can be retrieved in callback */ + /* allocate user data so that it can be retrieved in callback */ bluetooth_address = - (bluetooth_device_address_t *) malloc(sizeof(bluetooth_device_address_t)); + (bluetooth_device_address_t *)malloc(sizeof(bluetooth_device_address_t)); if (bluetooth_address == NULL) { DBG("Out of memory"); return BLUETOOTH_ERROR_INTERNAL; @@ -1600,7 +1721,7 @@ BT_EXPORT_API int bluetooth_unbond_device(const bluetooth_device_address_t *devi if (device_path != NULL) { if (!dbus_g_proxy_begin_call(bt_internal_info->adapter_proxy, "RemoveDevice", (DBusGProxyCallNotify) __bluetooth_internal_unbond_request_complete_cb, - (gpointer) bluetooth_address, NULL, DBUS_TYPE_G_OBJECT_PATH, device_path, + (gpointer)bluetooth_address, NULL, DBUS_TYPE_G_OBJECT_PATH, device_path, G_TYPE_INVALID)) { DBG("RemoveBonding begin failed\n"); return BLUETOOTH_ERROR_INTERNAL; @@ -1730,8 +1851,9 @@ static int __bluetooth_internal_get_bonded_device_list_details(gchar *device_pat _bluetooth_internal_convert_addr_string_to_addr_type(&dev->device_address, address); - strncpy(dev->device_name.name, name, strlen(name)); - dev->device_name.name[strlen(name)] = '\0'; + g_strlcpy(dev->device_name.name, name, + BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1); + dev->rssi = rssi; dev->trust = trust; dev->paired = paired; diff --git a/lib/bluetooth-hdp-api.c b/lib/bluetooth-hdp-api.c index 7d265140..cd58261b 100644 --- a/lib/bluetooth-hdp-api.c +++ b/lib/bluetooth-hdp-api.c @@ -31,7 +31,8 @@ ***********************************************************************/ static int __bt_hdp_internal_create_application(unsigned int data_type, bool role, - bt_hdp_qos_type_t channel_type); + bt_hdp_qos_type_t channel_type, + char **app_handle); static DBusHandlerResult __bt_hdp_internal_event_filter(DBusConnection *sys_conn, DBusMessage *msg, @@ -59,10 +60,9 @@ static void __bt_hdp_internal_remove_filter(void); static hdp_app_list_t *__bt_hdp_internal_gslist_find_app_handler(void *app_handle); -static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_fd(int fd); +static hdp_obj_info_t *__bt_hdp_internal_gslist_obj_find_using_fd(int fd); -static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_obj_channel( - const char *obj_channel_path); +static hdp_obj_info_t *__bt_hdp_internal_gslist_obj_find_using_path(const char *obj_channel_path); /*Global Variables*/ static DBusConnection *g_hdp_dus_conn; @@ -75,7 +75,8 @@ static GSList *g_app_list = NULL; BT_EXPORT_API int bluetooth_hdp_activate(unsigned short data_type, bt_hdp_role_type_t role, - bt_hdp_qos_type_t channel_type) + bt_hdp_qos_type_t channel_type, + char **app_handle) { DBG("+\n"); int result = BLUETOOTH_ERROR_NONE; @@ -97,27 +98,24 @@ BT_EXPORT_API int bluetooth_hdp_activate(unsigned short data_type, } result = __bt_hdp_internal_create_application(data_type, role, - channel_type); + channel_type, app_handle); - return BLUETOOTH_ERROR_NONE; + return result; } - -static gboolean __bt_hdp_internal_create_application_cb(gpointer data) +static void __bt_hdp_obj_info_free(hdp_obj_info_t *info) { - DBG(" +\n"); - hdp_app_list_t *list = (hdp_app_list_t *)data; - bt_hdp_activate_t act_cfm; - act_cfm.app_handle = list->app_handle; - - _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_ACTIVATED, - BLUETOOTH_ERROR_NONE, &act_cfm); - DBG(" -\n"); - return FALSE; + if (info) { + close(info->fd); + g_free(info->obj_channel_path); + g_free(info); + } } + static int __bt_hdp_internal_create_application(unsigned int data_type, bool role, - bt_hdp_qos_type_t channel_type) + bt_hdp_qos_type_t channel_type, + char **app_handle) { DBG(" +\n"); DBusMessage *msg, *reply; @@ -132,7 +130,7 @@ static int __bt_hdp_internal_create_application(unsigned int data_type, bt_internal_info = _bluetooth_internal_get_information(); - msg = dbus_message_new_method_call("org.bluez", "/org/bluez", + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, "/org/bluez", BLUEZ_HDP_MANAGER_INTERFACE, "CreateApplication"); @@ -244,23 +242,12 @@ static int __bt_hdp_internal_create_application(unsigned int data_type, return ret; } - hdp_app_list_t *list = malloc(sizeof(hdp_app_list_t)); - if (NULL == list) { - DBG("Malloc list failed"); - return BLUETOOTH_ERROR_MEMORY_ALLOCATION; - } - + hdp_app_list_t *list = g_new0(hdp_app_list_t, 1); list->app_handle = (void *)g_strdup(app_path); - - list->obj_channel_path = NULL; - - list->fd = -1; + *app_handle = list->app_handle; g_app_list = g_slist_append(g_app_list, list); - - g_idle_add(__bt_hdp_internal_create_application_cb, (gpointer)list); - return BLUETOOTH_ERROR_NONE; } @@ -363,6 +350,7 @@ static void __bt_hdp_internal_handle_disconnect(DBusMessage *msg) char address[BT_ADDRESS_STRING_SIZE] = { 0, }; bluetooth_device_address_t device_addr = { {0} }; bt_hdp_disconnected_t dis_ind; + hdp_obj_info_t *info; DBG("Path = %s\n", path); @@ -374,38 +362,27 @@ static void __bt_hdp_internal_handle_disconnect(DBusMessage *msg) DBG("Channel Deleted, Path = %s\n", obj_channel_path); + info = __bt_hdp_internal_gslist_obj_find_using_path(obj_channel_path); + if (!info) { + DBG("No obj info for ob_channel_path [%s]\n", obj_channel_path); + return; + } + /*Since bluetoothd is not sending the ChannelDeleted signal */ _bluetooth_internal_device_path_to_address(path, address); _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, address); - hdp_app_list_t *list = __bt_hdp_internal_gslist_find_using_obj_channel( - obj_channel_path); - if (NULL == list) { - DBG("** Could not locate the list for ob_channel_path %s****\n", - obj_channel_path); - } else { - - if (list->fd == -1) { - DBG("******* Warning! FD already deleted******\n"); - } + dis_ind.channel_id = info->fd; + dis_ind.device_address = device_addr; - dis_ind.channel_id = list->fd; - dis_ind.device_address = device_addr; + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED, + BLUETOOTH_ERROR_NONE, &dis_ind); - _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED, - BLUETOOTH_ERROR_NONE, &dis_ind); - - close(list->fd); - list->fd = -1; - g_free(list->obj_channel_path); - list->obj_channel_path = NULL; - - DBG(" Removed fd and obj_channel_path from the list\n"); - } + DBG(" Removed connection from list\n"); - DBG("-*************\n\n"); + __bt_hdp_obj_info_free(info); } @@ -466,11 +443,11 @@ static int __bt_hdp_internal_acquire_fd(const char *path) bt_info_t *bt_internal_info = NULL; bt_hdp_connected_t conn_ind; DBusError err; - int fdd = -1; + int fd; bt_internal_info = _bluetooth_internal_get_information(); - msg = dbus_message_new_method_call("org.bluez", path, + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, path, BLUEZ_HDP_CHANNEL_INTERFACE, "Acquire"); if (!msg) { @@ -497,7 +474,7 @@ static int __bt_hdp_internal_acquire_fd(const char *path) return BLUETOOTH_ERROR_INTERNAL; } - if (!dbus_message_get_args(reply, &err, DBUS_TYPE_UNIX_FD, &fdd, + if (!dbus_message_get_args(reply, &err, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID)) { DBG(" HDP:dbus Can't get reply arguments"); @@ -510,9 +487,9 @@ static int __bt_hdp_internal_acquire_fd(const char *path) dbus_message_unref(reply); - DBG("File Descriptor = %d, Dev_path = %s \n", fdd, path); + DBG("File Descriptor = %d, Dev_path = %s \n", fd, path); - msg = dbus_message_new_method_call("org.bluez", path, + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, path, BLUEZ_HDP_CHANNEL_INTERFACE, "GetProperties"); if (!msg) { DBG(" HDP:dbus Can't allocate new method call"); @@ -600,9 +577,12 @@ static int __bt_hdp_internal_acquire_fd(const char *path) goto error; } - list->obj_channel_path = g_strdup(path); + hdp_obj_info_t *info = g_new0(hdp_obj_info_t, 1); + info->fd = fd; + info->obj_channel_path = g_strdup(path); + list->obj_info = g_slist_append(list->obj_info, info); - __bt_hdp_internal_watch_fd(fdd, list->obj_channel_path); + __bt_hdp_internal_watch_fd(fd, info->obj_channel_path); _bluetooth_internal_device_path_to_address(path, address); @@ -611,7 +591,7 @@ static int __bt_hdp_internal_acquire_fd(const char *path) conn_ind.app_handle = app_handle; - conn_ind.channel_id = fdd; + conn_ind.channel_id = fd; conn_ind.device_address = device_addr; @@ -621,16 +601,10 @@ static int __bt_hdp_internal_acquire_fd(const char *path) DBG("Going to give callback\n"); _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED, - BLUETOOTH_ERROR_NONE, &conn_ind); + BLUETOOTH_ERROR_NONE, &conn_ind); dbus_message_unref(reply); - if (list->fd != -1) { - DBG("Warning! FD already updated(%d).Duplication!\n", list->fd); - } - - list->fd = fdd; - DBG("Updated fd in the list*\n"); DBG("-\n"); @@ -654,6 +628,38 @@ static void __bt_hdp_internal_watch_fd(int file_desc, const char *path) DBG("-\n"); } + +static void __bt_hdp_internal_handle_disconnect_cb(int sk, const char *path) +{ + DBG("******** Socket Error ******\n\n"); + char address[BT_ADDRESS_STRING_SIZE] = { 0, }; + bluetooth_device_address_t device_addr = { {0} }; + bt_hdp_disconnected_t dis_ind; + hdp_obj_info_t *info; + + info = __bt_hdp_internal_gslist_obj_find_using_path(path); + if (!info) { + DBG("No obj info for ob_channel_path [%s]\n", path); + return; + } + + /*Since bluetoothd is not sending the ChannelDeleted signal */ + _bluetooth_internal_device_path_to_address(path, address); + + _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, + address); + + dis_ind.channel_id = sk; + dis_ind.device_address = device_addr; + + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED, + BLUETOOTH_ERROR_NONE, &dis_ind); + + DBG(" Removed connection from list\n"); + + __bt_hdp_obj_info_free(info); +} + static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, GIOCondition cond, gpointer data) { @@ -669,9 +675,7 @@ static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { DBG("GIOCondition %d.............path = %s\n", cond, path); - /* We should simply return from here. Proper disconnection - * happens during ChannelDeleted signal. - */ + __bt_hdp_internal_handle_disconnect_cb(sk, path); return FALSE; } @@ -692,7 +696,7 @@ static gboolean __bt_hdp_internal_data_received(GIOChannel *gio, data_ind.size = act_read; _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_DATA_RECEIVED, - BLUETOOTH_ERROR_NONE, &data_ind); + BLUETOOTH_ERROR_NONE, &data_ind); return TRUE; @@ -743,34 +747,51 @@ static hdp_app_list_t *__bt_hdp_internal_gslist_find_app_handler(void *app_handl return NULL; } -static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_fd(int fd) +static hdp_obj_info_t *__bt_hdp_internal_gslist_obj_find_using_fd(int fd) { GSList *l; + GSList *iter; DBG("List length = %d\n", g_slist_length(g_app_list)); for (l = g_app_list; l != NULL; l = l->next) { hdp_app_list_t *list = l->data; + if (!list) + return NULL; - if (list) { - if (fd == list->fd) - return list; + for (iter = list->obj_info; iter != NULL; iter = iter->next) { + hdp_obj_info_t *info = iter->data; + if (!info) + return NULL; + + if (fd == info->fd) + return info; } } return NULL; } -static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_obj_channel( - const char *obj_channel_path) +static hdp_obj_info_t *__bt_hdp_internal_gslist_obj_find_using_path(const char *obj_channel_path) { GSList *l; + GSList *iter; + hdp_obj_info_t *info = NULL; + DBG("List length = %d\n", g_slist_length(g_app_list)); for (l = g_app_list; l != NULL; l = l->next) { hdp_app_list_t *list = l->data; - if (list) { - if (0 == g_strcmp0((char *)list->obj_channel_path, - obj_channel_path)) - return list; + if (!list) + return NULL; + + for (iter = list->obj_info; iter != NULL; iter = iter->next) { + info = iter->data; + if (!info) + return NULL; + + if (0 == g_strcmp0(info->obj_channel_path, obj_channel_path)) { + list->obj_info = g_slist_remove(list->obj_info, info); + return info; + } } } return NULL; @@ -779,26 +800,21 @@ static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_obj_channel( static gboolean __bt_hdp_internal_destroy_application_cb(gpointer data) { DBG(" +\n"); - bt_hdp_deactivate_t deact_cfm; + const char *app_handle; hdp_app_list_t *list = NULL; - deact_cfm.app_handle = (const char *)data; - _bluetooth_internal_event_cb(BLUETOOTH_EVENT_HDP_DEACTIVATED, - BLUETOOTH_ERROR_NONE, &deact_cfm); + app_handle = (const char *)data; - list = __bt_hdp_internal_gslist_find_app_handler((void *)deact_cfm.app_handle); + list = __bt_hdp_internal_gslist_find_app_handler((void *)app_handle); if (NULL == list) { - DBG("***** Could not locate the list for %s*****\n", - deact_cfm.app_handle); + DBG("**** list not found for %s ******\n", app_handle); return FALSE; } g_app_list = g_slist_remove(g_app_list, list); - if (list != NULL) { - g_free(list->app_handle); - g_free(list->obj_channel_path); - g_free(list); - } + g_free(list->app_handle); + g_slist_foreach(list->obj_info, (GFunc)__bt_hdp_obj_info_free, NULL); + g_free(list); DBG("List length = %d\n", g_slist_length(g_app_list)); @@ -810,14 +826,13 @@ static gboolean __bt_hdp_internal_destroy_application_cb(gpointer data) static int __bt_hdp_internal_destroy_application(const char *app_handle) { - DBusMessage *msg, *reply; DBusError err; bt_info_t *bt_internal_info = NULL; bt_internal_info = _bluetooth_internal_get_information(); - msg = dbus_message_new_method_call("org.bluez", "/org/bluez", + msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, "/org/bluez", BLUEZ_HDP_MANAGER_INTERFACE, "DestroyApplication"); if (!msg) { @@ -833,7 +848,6 @@ static int __bt_hdp_internal_destroy_application(const char *app_handle) reply = dbus_connection_send_with_reply_and_block( dbus_g_connection_get_connection(bt_internal_info->conn), msg, -1, &err); - dbus_message_unref(msg); if (!reply) { DBG(" HDP:dbus Can't Destroy application"); @@ -842,7 +856,7 @@ static int __bt_hdp_internal_destroy_application(const char *app_handle) DBG("%s", err.message); dbus_error_free(&err); } - DBG(" 5\n"); + return BLUETOOTH_ERROR_INTERNAL; } @@ -915,6 +929,31 @@ BT_EXPORT_API int bluetooth_hdp_send_data(unsigned int channel_id, return BLUETOOTH_ERROR_NONE; } + +static void __bt_hdp_connect_request_cb(DBusGProxy *hdp_proxy, DBusGProxyCall *call, + gpointer user_data) +{ + GError *g_error = NULL; + char *obj_connect_path = NULL; + DBusGConnection *conn = NULL; + + conn = (DBusGConnection *) user_data; + + dbus_g_proxy_end_call(hdp_proxy, call, &g_error, + DBUS_TYPE_G_OBJECT_PATH, &obj_connect_path, G_TYPE_INVALID); + + g_object_unref(hdp_proxy); + dbus_g_connection_unref(conn); + + if (g_error != NULL) { + DBG("HDP connection Dbus Call Error: %s\n", g_error->message); + g_error_free(g_error); + } else { + DBG("Obj Path returned = %s\n", obj_connect_path); + } +} + + BT_EXPORT_API int bluetooth_hdp_connect(const char *app_handle, bt_hdp_qos_type_t channel_type, const bluetooth_device_address_t *device_address) @@ -987,7 +1026,7 @@ BT_EXPORT_API int bluetooth_hdp_connect(const char *app_handle, DBG("path %s\n", dev_path); - hdp_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dev_path, + hdp_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, dev_path, BLUEZ_HDP_DEVICE_INTERFACE); if (hdp_proxy == NULL) { @@ -998,31 +1037,44 @@ BT_EXPORT_API int bluetooth_hdp_connect(const char *app_handle, } DBG("app path %s\n", app_handle); - - if (!dbus_g_proxy_call(hdp_proxy, "CreateChannel", NULL, - DBUS_TYPE_G_OBJECT_PATH, app_handle, G_TYPE_STRING, - role, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, - &obj_connect_path, G_TYPE_INVALID)) { - - DBG("HDP client connection Dbus Call Error"); - + if (!dbus_g_proxy_begin_call(hdp_proxy, "CreateChannel", + (DBusGProxyCallNotify) __bt_hdp_connect_request_cb, + conn, /*user_data*/ + NULL, /*destroy*/ + DBUS_TYPE_G_OBJECT_PATH, app_handle, + G_TYPE_STRING, role, + G_TYPE_INVALID)) { + DBG("HDP connection Dbus Call Error"); g_free(dev_path); - g_object_unref(hdp_proxy); - dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_INTERNAL; } - DBG("Obj Path returned = %s\n", obj_connect_path); - g_free(dev_path); + return BLUETOOTH_ERROR_NONE; +} - g_object_unref(hdp_proxy); +static void __bt_hdp_disconnect_request_cb(DBusGProxy *hdp_proxy, DBusGProxyCall *call, + gpointer user_data) +{ + GError *g_error = NULL; + DBusGConnection *conn = NULL; + + conn = (DBusGConnection *) user_data; + + dbus_g_proxy_end_call(hdp_proxy, call, &g_error, G_TYPE_INVALID); + + g_object_unref(hdp_proxy); dbus_g_connection_unref(conn); - return BLUETOOTH_ERROR_NONE; + if (g_error != NULL) { + DBG("HDP disconnection Dbus Call Error: %s\n", g_error->message); + g_error_free(g_error); + } else { + DBG("HDP disconnection Dbus Call is done\n"); + } } BT_EXPORT_API int bluetooth_hdp_disconnect(unsigned int channel_id, @@ -1051,8 +1103,8 @@ BT_EXPORT_API int bluetooth_hdp_disconnect(unsigned int channel_id, return BLUETOOTH_ERROR_INVALID_PARAM; } - hdp_app_list_t *list = __bt_hdp_internal_gslist_find_using_fd(channel_id); - if (NULL == list) { + hdp_obj_info_t *info = __bt_hdp_internal_gslist_obj_find_using_fd(channel_id); + if (NULL == info) { DBG("*** Could not locate the list for %d*****\n", channel_id); return BLUETOOTH_ERROR_INVALID_PARAM; } @@ -1087,7 +1139,7 @@ BT_EXPORT_API int bluetooth_hdp_disconnect(unsigned int channel_id, DBG("path %s\n", dev_path); - hdp_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dev_path, + hdp_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, dev_path, BLUEZ_HDP_DEVICE_INTERFACE); if (hdp_proxy == NULL) { @@ -1097,23 +1149,20 @@ BT_EXPORT_API int bluetooth_hdp_disconnect(unsigned int channel_id, return BLUETOOTH_ERROR_NOT_PAIRED; } - if (!dbus_g_proxy_call(hdp_proxy, "DestroyChannel", NULL, - DBUS_TYPE_G_OBJECT_PATH, list->obj_channel_path, - G_TYPE_INVALID, G_TYPE_INVALID)) { - DBG("HDP client connection Dbus Call Error"); + if (!dbus_g_proxy_begin_call(hdp_proxy, "DestroyChannel", + (DBusGProxyCallNotify) __bt_hdp_disconnect_request_cb, + conn, /*user_data*/ + NULL, /*destroy*/ + DBUS_TYPE_G_OBJECT_PATH, info->obj_channel_path, + G_TYPE_INVALID)) { + DBG("HDP connection Dbus Call Error"); g_free(dev_path); g_object_unref(hdp_proxy); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_INTERNAL; } - DBG("Destroyed Obj Path = %s\n", list->obj_channel_path); - g_free(dev_path); - g_object_unref(hdp_proxy); - - dbus_g_connection_unref(conn); - return BLUETOOTH_ERROR_NONE; } diff --git a/lib/bluetooth-hdp-api.h b/lib/bluetooth-hdp-api.h index a3252da4..62bf1783 100644 --- a/lib/bluetooth-hdp-api.h +++ b/lib/bluetooth-hdp-api.h @@ -36,9 +36,13 @@ extern "C" { #define BLUEZ_HDP_CHANNEL_INTERFACE "org.bluez.HealthChannel" typedef struct { - void *app_handle; - void *obj_channel_path; + char *obj_channel_path; int fd; +} hdp_obj_info_t; + +typedef struct { + void *app_handle; + GSList *obj_info; } hdp_app_list_t; diff --git a/lib/bluetooth-hid-api.c b/lib/bluetooth-hid-api.c index 6274f93f..e5dd3c00 100644 --- a/lib/bluetooth-hid-api.c +++ b/lib/bluetooth-hid-api.c @@ -316,8 +316,8 @@ BT_EXPORT_API int bluetooth_hid_connect(hid_device_address_t *device_address) return HID_ERROR_NOT_ENABLED; } - adapter_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, - adapter_path, BLUEZ_ADAPTER_NAME); + adapter_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_SERVICE_NAME, + adapter_path, BLUEZ_ADAPTER_INTERFACE); if (adapter_proxy == NULL) { DBG("dbus_g_proxy_new_for_name() failed\n"); @@ -339,7 +339,7 @@ BT_EXPORT_API int bluetooth_hid_connect(hid_device_address_t *device_address) return HID_ERROR_NOT_PAIRED; } - hid_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, + hid_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_SERVICE_NAME, hid_dev_path, BLUEZ_INPUT_NAME); if (hid_proxy == NULL) { @@ -393,8 +393,8 @@ BT_EXPORT_API int bluetooth_hid_disconnect(hid_device_address_t *device_address) return HID_ERROR_NOT_ENABLED; } - adapter_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, - adapter_path, BLUEZ_ADAPTER_NAME); + adapter_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_SERVICE_NAME, + adapter_path, BLUEZ_ADAPTER_INTERFACE); if (adapter_proxy == NULL) { DBG("dbus_g_proxy_new_for_name() failed\n"); @@ -416,7 +416,7 @@ BT_EXPORT_API int bluetooth_hid_disconnect(hid_device_address_t *device_address) return HID_ERROR_NOT_PAIRED; } - hid_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_NAME, + hid_proxy = dbus_g_proxy_new_for_name(bt_hid_info.conn, BLUEZ_SERVICE_NAME, hid_dev_path, BLUEZ_INPUT_NAME); if (hid_proxy == NULL) { diff --git a/lib/bluetooth-hid-api.h b/lib/bluetooth-hid-api.h index e6d924bf..fbffc409 100644 --- a/lib/bluetooth-hid-api.h +++ b/lib/bluetooth-hid-api.h @@ -42,14 +42,6 @@ extern "C" { #define HID_ERROR_NOT_ENABLED ((int)HID_ERROR_BASE - 0x05) #define HID_ERROR_CONNECTION_FAILED ((int)HID_ERROR_BASE - 0x06) -/** - * Bluetooth event type - */ -typedef enum { - BLUETOOTH_HID_CONNECTED, - BLUETOOTH_HID_DISCONNECTED -} hid_event_t; - typedef struct { int event; int result; diff --git a/lib/bluetooth-network-api.c b/lib/bluetooth-network-api.c index 262849fc..dce43307 100644 --- a/lib/bluetooth-network-api.c +++ b/lib/bluetooth-network-api.c @@ -28,10 +28,6 @@ * Static Functions declaration * ***********************************************************************/ -static void __bluetooth_network_activate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, - gpointer user_data); -static void __bluetooth_network_deactivate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, - gpointer user_data); static void __bluetooth_network_connect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data); static void __bluetooth_network_disconnect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, @@ -54,6 +50,7 @@ BT_EXPORT_API int bluetooth_network_activate_server(void) GError *err = NULL; DBusGConnection *conn = NULL; DBusGProxy *proxy_net_server = NULL; + int ret = BLUETOOTH_ERROR_NONE; char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 }; conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); @@ -65,14 +62,15 @@ BT_EXPORT_API int bluetooth_network_activate_server(void) } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, + default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; } - proxy_net_server = dbus_g_proxy_new_for_name(conn, "org.bluez", - default_adapter_path, BLUEZ_NET_SERVER_PATH); + proxy_net_server = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, + default_adapter_path, BLUEZ_NET_SERVER_PATH); if (proxy_net_server == NULL) { DBG("Failed to get the network server proxy\n"); @@ -80,24 +78,21 @@ BT_EXPORT_API int bluetooth_network_activate_server(void) return BLUETOOTH_ERROR_INTERNAL; } - if (!dbus_g_proxy_begin_call(proxy_net_server, "Register", - (DBusGProxyCallNotify) __bluetooth_network_activate_request_cb, - conn,/*user data*/ - NULL, /*destroy*/ - G_TYPE_STRING, - NAP_UUID_NAME,/*first_arg_type*/ - G_TYPE_STRING, - NET_BRIDGE_INTERFACE,/*second_arg_type*/ + if (!dbus_g_proxy_call(proxy_net_server, "Register", &err, + G_TYPE_STRING, NAP_UUID_NAME, /*first_arg */ + G_TYPE_STRING, NET_BRIDGE_INTERFACE,/*second_arg */ G_TYPE_INVALID)) { - DBG("Network server register Dbus Call Error"); - g_object_unref(proxy_net_server); - dbus_g_connection_unref(conn); - return BLUETOOTH_ERROR_INTERNAL; + DBG("Network server register Error: %s\n", err->message); + g_error_free(err); + ret = BLUETOOTH_ERROR_INTERNAL; } + g_object_unref(proxy_net_server); + dbus_g_connection_unref(conn); + DBG("-\n"); - return BLUETOOTH_ERROR_NONE; + return ret; } BT_EXPORT_API int bluetooth_network_deactivate_server(void) @@ -107,6 +102,7 @@ BT_EXPORT_API int bluetooth_network_deactivate_server(void) GError *err = NULL; DBusGConnection *conn = NULL; DBusGProxy *proxy_net_server = NULL; + int ret = BLUETOOTH_ERROR_NONE; char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 }; conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); @@ -118,14 +114,15 @@ BT_EXPORT_API int bluetooth_network_deactivate_server(void) } /* If the adapter path is wrong, we can think the BT is not enabled. */ - if (_bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) { + if (_bluetooth_internal_get_adapter_path(conn, + default_adapter_path) < 0) { DBG("Could not get adapter path\n"); dbus_g_connection_unref(conn); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; } - proxy_net_server = dbus_g_proxy_new_for_name(conn, "org.bluez", - default_adapter_path, BLUEZ_NET_SERVER_PATH); + proxy_net_server = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, + default_adapter_path, BLUEZ_NET_SERVER_PATH); if (proxy_net_server == NULL) { DBG("Failed to get the network server proxy\n"); @@ -133,75 +130,20 @@ BT_EXPORT_API int bluetooth_network_deactivate_server(void) return BLUETOOTH_ERROR_INTERNAL; } - if (!dbus_g_proxy_begin_call(proxy_net_server, "Unregister", - (DBusGProxyCallNotify) __bluetooth_network_deactivate_request_cb, - conn, /*user_data*/ - NULL, /*destroy*/ - G_TYPE_STRING, NAP_UUID_NAME, /*first_arg_type*/ - G_TYPE_INVALID)) { - DBG("Network server deregister Dbus Call Error"); - g_object_unref(proxy_net_server); - dbus_g_connection_unref(conn); - return BLUETOOTH_ERROR_INTERNAL; - } - - DBG("-\n"); - - return BLUETOOTH_ERROR_NONE; -} - -static void __bluetooth_network_activate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, - gpointer user_data) -{ - GError *g_error = NULL; - int result = BLUETOOTH_ERROR_NONE; - DBusGConnection *conn = NULL; - - conn = (DBusGConnection *) user_data; - - dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID); - - g_object_unref(proxy); - dbus_g_connection_unref(conn); - - if (g_error != NULL) { - DBG("Network server register Dbus Call Error: %s\n", g_error->message); - g_error_free(g_error); - result = BLUETOOTH_ERROR_INTERNAL; - } else { - DBG("Network server register Dbus Call is done\n"); + if (!dbus_g_proxy_call(proxy_net_server, "Unregister", &err, + G_TYPE_STRING, NAP_UUID_NAME, /*first_arg */ + G_TYPE_INVALID)) { + DBG("Network server unregister Error: %s\n", err->message); + g_error_free(err); + ret = BLUETOOTH_ERROR_INTERNAL; } - _bluetooth_internal_event_cb(BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED, - result, NULL); - -} - -static void __bluetooth_network_deactivate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call, - gpointer user_data) -{ - GError *g_error = NULL; - int result = BLUETOOTH_ERROR_NONE; - DBusGConnection *conn = NULL; - - conn = (DBusGConnection *) user_data; - - dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID); - - g_object_unref(proxy); + g_object_unref(proxy_net_server); dbus_g_connection_unref(conn); - if (g_error != NULL) { - DBG("Network server unregister Dbus Call Error: %s\n", g_error->message); - g_error_free(g_error); - result = BLUETOOTH_ERROR_INTERNAL; - } else { - DBG("Network server unregister Dbus Call is done\n"); - } - - _bluetooth_internal_event_cb(BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED, - result, NULL); + DBG("-\n"); + return ret; } void _bluetooth_network_server_add_signal(void) @@ -225,7 +167,7 @@ void _bluetooth_network_server_add_signal(void) /* Add the network server signal */ bt_internal_info->network_server_proxy = - dbus_g_proxy_new_for_name(bt_internal_info->conn, "org.bluez", + dbus_g_proxy_new_for_name(bt_internal_info->conn, BLUEZ_SERVICE_NAME, bt_internal_info->adapter_path, BLUEZ_NET_SERVER_PATH); dbus_g_proxy_add_signal(bt_internal_info->network_server_proxy, "PeerConnected", @@ -360,7 +302,7 @@ BT_EXPORT_API int bluetooth_network_connect(const bluetooth_device_address_t *de g_strdelimit(path, ":", '_'); DBG("path %s\n", path); - proxy_net_client = dbus_g_proxy_new_for_name(conn, "org.bluez", + proxy_net_client = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, path, BLUEZ_NET_CLIENT_PATH); if (proxy_net_client == NULL) { @@ -451,7 +393,7 @@ BT_EXPORT_API int bluetooth_network_disconnect(const bluetooth_device_address_t g_strdelimit(path, ":", '_'); DBG("path %s\n", path); - proxy_net_client = dbus_g_proxy_new_for_name(conn, "org.bluez", + proxy_net_client = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, path, BLUEZ_NET_CLIENT_PATH); if (proxy_net_client == NULL) { diff --git a/lib/bluetooth-obex-server-api.c b/lib/bluetooth-obex-server-api.c index dde53910..ac775cf7 100644 --- a/lib/bluetooth-obex-server-api.c +++ b/lib/bluetooth-obex-server-api.c @@ -26,10 +26,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -37,9 +37,13 @@ #include "bluetooth-obex-server-api.h" #include "obex-agent.h" +#define BT_AGENT_SIGNAL_OBEX_AUTHORIZE "ObexAuthorize" + static GSList *transfers = NULL; char *g_dst_path = NULL; obex_server_info_t g_obex_server_info; +gboolean obex_connected; +gboolean auto_authorize; static gboolean __bt_authorize_callback(DBusGMethodInvocation *context, const char *path, @@ -118,7 +122,142 @@ static void __bt_send_deinit_message(void) return; } -BT_EXPORT_API int bluetooth_obex_server_init(char *dst_path) +/* To support the BOT */ +static DBusHandlerResult __obex_authorize_event_filter(DBusConnection *sys_conn, + DBusMessage *msg, void *data) +{ + DBG("+"); + + char *member; + const char *path = dbus_message_get_path(msg); + const char *addr = NULL; + const char *name = NULL; + bluetooth_device_address_t device_addr = { {0} }; + int event; + + if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (path == NULL || strcmp(path, "/") == 0) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + member = (char *)dbus_message_get_member(msg); + DBG("member (%s)\n", member); + + if (dbus_message_is_signal(msg, BT_AGENT_INTERFACE, + BT_AGENT_SIGNAL_OBEX_AUTHORIZE)) { + dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &addr, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + DBG("Obex Authorize request [%s], [%s]", addr, name); + + if (addr == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + event = BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE; + + _bluetooth_internal_convert_addr_string_to_addr_type( + &device_addr, addr); + + _bluetooth_internal_event_cb(event, + BLUETOOTH_ERROR_NONE, &device_addr); + } else { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + DBG("-"); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +/* To support the BOT */ +static int __register_agent_authorize_signal( + obex_server_info_t *obex_server_info) +{ + DBG("+"); + + DBusGConnection *conn = NULL; + DBusConnection *dbus_connection = NULL; + DBusError dbus_error; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + + if (conn == NULL) { + DBG("conn is NULL\n"); + return BLUETOOTH_ERROR_NO_RESOURCES; + } + + dbus_connection = dbus_g_connection_get_connection(conn); + + /* Add the filter for authorize functions */ + dbus_error_init(&dbus_error); + dbus_connection_add_filter(dbus_connection, + __obex_authorize_event_filter, + NULL, NULL); + + dbus_bus_add_match(dbus_connection, + "type=signal,interface=" BT_AGENT_INTERFACE + ",member=ObexAuthorize", &dbus_error); + if (dbus_error_is_set(&dbus_error)) { + ERR("Fail to add dbus filter signal\n"); + dbus_error_free(&dbus_error); + dbus_connection_remove_filter(dbus_connection, + __obex_authorize_event_filter, + NULL); + dbus_g_connection_unref(conn); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (vconf_set_int(BT_MEMORY_OBEX_NO_AGENT, 1) != 0) { + DBG("Set vconf failed"); + dbus_connection_remove_filter(dbus_connection, + __obex_authorize_event_filter, + NULL); + dbus_g_connection_unref(conn); + return BLUETOOTH_ERROR_INTERNAL; + } + + obex_server_info->system_bus = conn; + + DBG("-"); + return BLUETOOTH_ERROR_NONE; +} + +/* To support the BOT */ +static void __unregister_agent_authorize_signal( + obex_server_info_t *obex_server_info) +{ + DBG("+"); + + DBusConnection *dbus_connection = NULL; + + if (obex_server_info == NULL) { + DBG("info is NULL"); + return; + } + + if (obex_server_info->system_bus == NULL) { + DBG("connection is NULL"); + return; + } + + dbus_connection = dbus_g_connection_get_connection( + obex_server_info->system_bus); + + dbus_connection_remove_filter(dbus_connection, + __obex_authorize_event_filter, + NULL); + + dbus_g_connection_unref(obex_server_info->system_bus); + obex_server_info->system_bus = NULL; + + if (vconf_set_int(BT_MEMORY_OBEX_NO_AGENT, 0) != 0) + DBG("Set vconf failed"); + + DBG("-"); +} + +BT_EXPORT_API int bluetooth_obex_server_init(const char *dst_path) { DBG("+\n"); @@ -160,9 +299,13 @@ BT_EXPORT_API int bluetooth_obex_server_init(char *dst_path) if (ret != BLUETOOTH_ERROR_NONE) { g_free(g_dst_path); dbus_g_connection_unref(conn); + g_obex_server_info.bus = NULL; g_dst_path = NULL; } + if (vconf_set_int(BT_MEMORY_OBEX_NO_AGENT, 0) != 0) + DBG("Set vconf failed"); + DBG("- \n"); return ret; @@ -193,15 +336,105 @@ BT_EXPORT_API int bluetooth_obex_server_deinit(void) return BLUETOOTH_ERROR_NONE; } +/* To support the BOT */ +BT_EXPORT_API int bluetooth_obex_server_init_without_agent(const char *dst_path) +{ + DBG("+\n"); + + int ret = BLUETOOTH_ERROR_NONE; + DBusGConnection *conn = NULL; + + _bluetooth_internal_session_init(); + + if (FALSE == _bluetooth_internal_is_adapter_enabled()) { + DBG("Adapter not enabled"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + if (g_obex_server_info.obex_server_agent) { + DBG("Agent already registered"); + return BLUETOOTH_ERROR_AGENT_ALREADY_EXIST; + } + + if (NULL == dst_path) { + DBG("Invalid Param"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + /* Get the session bus. This bus reff will be unref during deinit */ + conn = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + + if (conn == NULL) { + DBG("conn is NULL\n"); + return BLUETOOTH_ERROR_NO_RESOURCES; + } + + /* Send deinit signal (To deinit the native Obex server) */ + __bt_send_deinit_message(); + + g_dst_path = g_strdup(dst_path); + + ret = __bt_obex_agent_register(&g_obex_server_info, conn); + + if (ret != BLUETOOTH_ERROR_NONE) { + g_free(g_dst_path); + dbus_g_connection_unref(conn); + g_obex_server_info.bus = NULL; + g_dst_path = NULL; + } else { + ret = __register_agent_authorize_signal(&g_obex_server_info); + } + + DBG("- \n"); + + return ret; +} + +/* To support the BOT */ +BT_EXPORT_API int bluetooth_obex_server_deinit_without_agent(void) +{ + DBG("+\n"); + + _bluetooth_internal_session_init(); + + if (FALSE == _bluetooth_internal_is_adapter_enabled()) { + DBG("Adapter not enabled"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + if (NULL == g_obex_server_info.obex_server_agent) { + DBG("Agent not registered"); + return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST; + } + + __bt_obex_agent_unregister(&g_obex_server_info); + + __unregister_agent_authorize_signal(&g_obex_server_info); + + g_free(g_dst_path); + g_dst_path = NULL; + + DBG("- \n"); + return BLUETOOTH_ERROR_NONE; +} + BT_EXPORT_API gboolean bluetooth_obex_server_is_activated(void) { gboolean exist = FALSE; DBusGConnection *conn = NULL; DBusGProxy *obex_proxy = NULL; GError *error = NULL; + int value = 0; DBG("+"); + if (vconf_get_bool(BT_VCONF_OPP_SERVER_INIT, &value) == 0) { + if (value == TRUE) { + /* Nativate Obex server is activated */ + return FALSE; + } + } + conn = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); if (conn == NULL) return FALSE; @@ -228,6 +461,10 @@ BT_EXPORT_API gboolean bluetooth_obex_server_is_activated(void) g_error_free(error); } + dbus_g_proxy_call(obex_proxy, "UnregisterAgent", NULL, + DBUS_TYPE_G_OBJECT_PATH, BT_INVALID_PATH, + G_TYPE_INVALID, G_TYPE_INVALID); + g_object_unref(obex_proxy); dbus_g_connection_unref(conn); @@ -236,6 +473,108 @@ BT_EXPORT_API gboolean bluetooth_obex_server_is_activated(void) return exist; } +/* To support the BOT */ +BT_EXPORT_API int bluetooth_obex_server_accept_connection(void) +{ + DBG("+"); + + int ret = BLUETOOTH_ERROR_NONE; + unsigned long block_time = 0; + DBusGConnection *conn = NULL; + DBusGProxy *agent_proxy = NULL; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + + if (conn == NULL) { + DBG("conn is NULL\n"); + return BLUETOOTH_ERROR_NO_RESOURCES; + } + + agent_proxy = dbus_g_proxy_new_for_name(conn, + "org.bluez.frwk_agent", + "/org/bluez/agent/frwk_agent", + "org.bluez.Agent"); + + if (agent_proxy == NULL) { + DBG("agent proxy is NULL"); + dbus_g_connection_unref(conn); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (!dbus_g_proxy_call(agent_proxy, "ReplyAuthorize", NULL, + G_TYPE_UINT, BT_ACCEPT, + G_TYPE_INVALID, G_TYPE_INVALID)) { + DBG("Fail to ReplyAuthorize"); + ret = BLUETOOTH_ERROR_INTERNAL; + goto done; + } + + obex_connected = FALSE; + auto_authorize = TRUE; + + /* Block until recieve the event (Requirement from BADA) */ + while (obex_connected == FALSE) { + g_main_context_iteration(NULL, TRUE); + usleep(SLEEP_TIME); /* Sleep 50ms */ + block_time += SLEEP_TIME; + + if (block_time >= BLOCK_MAX_TIMEOUT) + return BLUETOOTH_ERROR_TIMEOUT; + } + + obex_connected = FALSE; + auto_authorize = FALSE; + +done: + g_object_unref(agent_proxy); + dbus_g_connection_unref(conn); + + DBG("-"); + + return ret; +} + +/* To support the BOT */ +BT_EXPORT_API int bluetooth_obex_server_reject_connection(void) +{ + DBG("+"); + + int ret = BLUETOOTH_ERROR_NONE; + DBusGConnection *conn = NULL; + DBusGProxy *agent_proxy = NULL; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + + if (conn == NULL) { + DBG("conn is NULL\n"); + return BLUETOOTH_ERROR_NO_RESOURCES; + } + + agent_proxy = dbus_g_proxy_new_for_name(conn, + "org.bluez.frwk_agent", + "/org/bluez/agent/frwk_agent", + "org.bluez.Agent"); + + if (agent_proxy == NULL) { + DBG("agent proxy is NULL"); + dbus_g_connection_unref(conn); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (!dbus_g_proxy_call(agent_proxy, "ReplyAuthorize", NULL, + G_TYPE_UINT, BT_REJECT, + G_TYPE_INVALID, G_TYPE_INVALID)) { + DBG("Fail to ReplyAuthorize"); + ret = BLUETOOTH_ERROR_INTERNAL; + } + + g_object_unref(agent_proxy); + dbus_g_connection_unref(conn); + + DBG("-"); + return ret; +} + static transfer_info_t *_bt_find_transfer(const char *transfer_path) { GSList *l; @@ -326,7 +665,7 @@ static int __bt_obex_server_reply_authorize(const guint accept, } -BT_EXPORT_API int bluetooth_obex_server_accept_authorize(char *filename) +BT_EXPORT_API int bluetooth_obex_server_accept_authorize(const char *filename) { DBG("+\n"); @@ -381,27 +720,38 @@ BT_EXPORT_API int bluetooth_obex_server_reject_authorize(void) &g_obex_server_info); } -BT_EXPORT_API int bluetooth_obex_server_set_destination_path(char *dst_path) +BT_EXPORT_API int bluetooth_obex_server_set_destination_path(const char *dst_path) { DBG("+\n"); + DIR *dp = NULL; + _bluetooth_internal_session_init(); - if (FALSE == _bluetooth_internal_is_adapter_enabled()) { + if (_bluetooth_internal_is_adapter_enabled() == FALSE) { DBG("Adapter not enabled"); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; } - if (NULL == g_obex_server_info.obex_server_agent) { + if (g_obex_server_info.obex_server_agent == NULL) { DBG("Agent not registered"); return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST; } - if (NULL == dst_path) { + if (dst_path == NULL) { DBG("Invalid Param"); return BLUETOOTH_ERROR_INVALID_PARAM; } + dp = opendir(dst_path); + + if (dp == NULL) { + DBG("The directory does not exist"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + closedir(dp); + g_free(g_dst_path); g_dst_path = g_strdup(dst_path); @@ -409,22 +759,23 @@ BT_EXPORT_API int bluetooth_obex_server_set_destination_path(char *dst_path) return BLUETOOTH_ERROR_NONE; } -BT_EXPORT_API int bluetooth_obex_server_set_root(char *root) +BT_EXPORT_API int bluetooth_obex_server_set_root(const char *root) { GError *error = NULL; GValue folder = { 0 }; + DIR *dp = NULL; obex_server_info_t *obex_server_info = &g_obex_server_info; DBG("+\n"); _bluetooth_internal_session_init(); - if (FALSE == _bluetooth_internal_is_adapter_enabled()) { + if (_bluetooth_internal_is_adapter_enabled() == FALSE) { DBG("Adapter not enabled"); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; } - if (NULL == obex_server_info->obex_server_agent) { + if (obex_server_info->obex_server_agent == NULL) { DBG("Agent not registered"); return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST; } @@ -440,6 +791,15 @@ BT_EXPORT_API int bluetooth_obex_server_set_root(char *root) return BLUETOOTH_ERROR_INVALID_PARAM; } + dp = opendir(root); + + if (dp == NULL) { + DBG("The directory does not exist"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + closedir(dp); + DBG("Set Root Foler: %s", root); g_value_init(&folder, G_TYPE_STRING); @@ -499,12 +859,50 @@ BT_EXPORT_API int bluetooth_obex_server_cancel_transfer(int transfer_id) return BLUETOOTH_ERROR_NONE; } +BT_EXPORT_API int bluetooth_obex_server_cancel_all_transfers(void) +{ + obex_server_info_t *obex_server_info = &g_obex_server_info; + GSList *l; + + DBG("+\n"); + + _bluetooth_internal_session_init(); + + if (FALSE == _bluetooth_internal_is_adapter_enabled()) { + DBG("Adapter not enabled"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + if (NULL == obex_server_info->obex_server_agent) { + DBG("Agent not registered"); + return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST; + } + + if (obex_server_info->obex_proxy == NULL) { + DBG("obex_proxy is NULL \n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + for (l = transfers; l != NULL; l = l->next) { + transfer_info_t *transfer = l->data; + + if (transfer && transfer->transfer_proxy) { + dbus_g_proxy_call_no_reply(transfer->transfer_proxy, + "Cancel", G_TYPE_INVALID, + G_TYPE_INVALID); + } + } + + DBG("+\n"); + + return BLUETOOTH_ERROR_NONE; +} + static char *__bt_get_remote_device_name(const char *bdaddress) { GError *error = NULL; char *device_path = NULL; char *name = NULL; - DBusGProxy *device = NULL; GHashTable *hash = NULL; GValue *value; DBusGProxy *device_proxy = NULL; @@ -584,6 +982,12 @@ static gboolean __bt_authorize_callback(DBusGMethodInvocation *context, auth_info.filename = obex_server_info->filename; auth_info.length = length; + if (auto_authorize == TRUE) { + /* No need to send the event */ + bluetooth_obex_server_accept_authorize(obex_server_info->filename); + return TRUE; + } + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE, BLUETOOTH_ERROR_NONE, &auth_info); @@ -732,6 +1136,12 @@ static void __bt_transfer_started_cb(DBusGProxy *object, transfer_info->path = g_strdup(transfer_path); } + if (auto_authorize == TRUE) { + /* Unblock the connection accept function */ + obex_connected = TRUE; + auto_authorize = FALSE; + } + transfers = g_slist_append(transfers, transfer_info); app_transfer_info.filename = transfer_info->filename; @@ -878,5 +1288,3 @@ static void __bt_obex_agent_unregister(obex_server_info_t *obex_server_info) g_object_unref(obex_server_info->obex_server_agent); obex_server_info->obex_server_agent = NULL; } - - diff --git a/lib/bluetooth-obex-server-api.h b/lib/bluetooth-obex-server-api.h index 296aed53..ebaffba9 100644 --- a/lib/bluetooth-obex-server-api.h +++ b/lib/bluetooth-obex-server-api.h @@ -32,6 +32,8 @@ extern "C" { #define FILE_PATH_LEN (4096 + 10) +#define BT_VCONF_OPP_SERVER_INIT "memory/private/bluetooth-share/opp_server_init" + #define OBEX_SERVER_SERVICE "org.openobex" #define OBEX_SERVER_MANAGER "org.openobex.Manager" #define BT_OBEX_SERVICE_INTERFACE "org.openobex.Agent" @@ -52,13 +54,14 @@ typedef enum { typedef struct { DBusGConnection *bus; + DBusGConnection *system_bus; void *obex_server_agent; DBusGProxy *obex_proxy; DBusGMethodInvocation *reply_context; char *filename; char *transfer_path; char *device_name; - int file_size; + int file_size; } obex_server_info_t; typedef enum { diff --git a/lib/bluetooth-opc-api.c b/lib/bluetooth-opc-api.c index 9579fac4..76671e1a 100644 --- a/lib/bluetooth-opc-api.c +++ b/lib/bluetooth-opc-api.c @@ -21,17 +21,17 @@ * */ -#include "bluetooth-api-common.h" -#include "bluetooth-opc-api.h" - -#include "obex-agent.h" -#include #include #include #include +#include "bluetooth-api-common.h" +#include "bluetooth-opc-api.h" +#include "obex-agent.h" + static ObexAgent *opc_obex_agent = NULL; static DBusGProxy *client_proxy = NULL; +static DBusGProxyCall *call_proxy = NULL; static DBusGProxy *current_transfer = NULL; static gboolean cancel_sending_files = FALSE; @@ -140,9 +140,10 @@ BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_ad char address[BT_BD_ADDR_MAX_LEN] = { 0 }; char agent_path[100] = {0}; - if (remote_address == NULL || file_name_array == NULL) + if ((NULL == remote_address) || (NULL == file_name_array)) { + DBG("Invalid Param\n"); return BLUETOOTH_ERROR_INVALID_PARAM; - + } _bluetooth_internal_session_init(); if (FALSE == _bluetooth_internal_is_adapter_enabled()) { @@ -160,11 +161,6 @@ BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_ad return BLUETOOTH_ERROR_IN_PROGRESS; } - if ((NULL == remote_address) || (NULL == file_name_array)) { - DBG("Invalid Param\n"); - return BLUETOOTH_ERROR_INVALID_PARAM; - } - snprintf(agent_path, sizeof(agent_path), OBEX_CLIENT_AGENT_PATH, getpid(), g_counter++); @@ -174,7 +170,7 @@ BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_ad } hash = g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, (GDestroyNotify) __bt_value_free); + NULL, (GDestroyNotify)__bt_value_free); _bluetooth_internal_print_bluetooth_device_address_t(remote_address); @@ -187,24 +183,52 @@ BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_ad cancel_sending_files = FALSE; - if (!dbus_g_proxy_begin_call(client_proxy, "SendFiles", + call_proxy = dbus_g_proxy_begin_call(client_proxy, "SendFiles", __bt_send_files_cb, NULL, NULL, dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), hash, G_TYPE_STRV, file_name_array, DBUS_TYPE_G_OBJECT_PATH, agent_path, - G_TYPE_INVALID)) { - DBG("SendFiles failed \n"); - g_object_unref(opc_obex_agent); - opc_obex_agent = NULL; - return BLUETOOTH_ERROR_INTERNAL; + G_TYPE_INVALID); + if (call_proxy == NULL) { + DBG("SendFiles failed \n"); + g_object_unref(opc_obex_agent); + opc_obex_agent = NULL; + g_hash_table_destroy(hash); + return BLUETOOTH_ERROR_INTERNAL; } + g_free(opc_current_transfer.address); + opc_current_transfer.address = g_strdup(address); + + g_hash_table_destroy(hash); + DBG("- \n"); return BLUETOOTH_ERROR_NONE; } +static gboolean cancel_connect_cb(gpointer data) +{ + bluetooth_device_address_t device_addr = { {0} }; + DBG("+"); + + _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, + opc_current_transfer.address); + + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OPC_CONNECTED, + BLUETOOTH_ERROR_CANCEL_BY_USER, &device_addr); + + g_object_unref(opc_obex_agent); + opc_obex_agent = NULL; + + g_free(opc_current_transfer.address); + opc_current_transfer.address = NULL; + + DBG("-"); + return FALSE; +} + BT_EXPORT_API int bluetooth_opc_cancel_push(void) { DBG("+"); @@ -223,9 +247,17 @@ BT_EXPORT_API int bluetooth_opc_cancel_push(void) cancel_sending_files = TRUE; - if (current_transfer) - dbus_g_proxy_call_no_reply(current_transfer, "Cancel", G_TYPE_INVALID, - G_TYPE_INVALID); + if (current_transfer) { + dbus_g_proxy_call_no_reply(current_transfer, "Cancel", + G_TYPE_INVALID, G_TYPE_INVALID); + } else { + if (call_proxy) { + dbus_g_proxy_cancel_call(client_proxy, call_proxy); + call_proxy = NULL; + + g_idle_add(cancel_connect_cb, NULL); + } + } DBG("-"); return BLUETOOTH_ERROR_NONE; @@ -292,30 +324,35 @@ static void __bt_send_files_cb(DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) { GError *error = NULL; + bluetooth_device_address_t device_addr = { {0} }; int result = BLUETOOTH_ERROR_NONE; DBG("+"); + _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, + opc_current_transfer.address); + if (dbus_g_proxy_end_call(proxy, call, &error, - G_TYPE_INVALID) == FALSE) { + G_TYPE_INVALID) == FALSE) { DBG("%s", error->message); g_error_free(error); - result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND; - } - - if (TRUE == cancel_sending_files) - result = BLUETOOTH_ERROR_CANCEL_BY_USER; - - if (result != BLUETOOTH_ERROR_NONE) { g_object_unref(opc_obex_agent); opc_obex_agent = NULL; + + g_free(opc_current_transfer.address); + opc_current_transfer.address = NULL; + + result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND; } _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OPC_CONNECTED, - result, NULL); + result, &device_addr); + + call_proxy = NULL; + DBG("-"); } @@ -325,7 +362,7 @@ static gboolean __bt_progress_callback(DBusGMethodInvocation *context, gpointer user_data) { gdouble percentage_progress = 0; - int percentage_int = 0; + bt_opc_transfer_info_t info; DBG("+"); DBG("transferred:[%ld] \n", transferred); @@ -337,10 +374,12 @@ static gboolean __bt_progress_callback(DBusGMethodInvocation *context, else percentage_progress = 0; - percentage_int = percentage_progress; + info.filename = opc_current_transfer.name; + info.size = opc_current_transfer.size; + info.percentage = percentage_progress; _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS, - BLUETOOTH_ERROR_NONE, &percentage_int); + BLUETOOTH_ERROR_NONE, &info); DBG("-"); @@ -396,6 +435,7 @@ static gboolean __bt_request_callback(DBusGMethodInvocation *context, { g_assert(current_transfer == NULL); bt_opc_transfer_info_t info; + bluetooth_device_address_t device_addr = { {0} }; GHashTable *hash = NULL; GError *error; @@ -409,10 +449,19 @@ static gboolean __bt_request_callback(DBusGMethodInvocation *context, error = __bt_opc_agent_error(BT_OBEX_AGENT_ERROR_CANCEL, "CancelledByUser"); dbus_g_method_return_error(context, error); g_error_free(error); + + _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, + opc_current_transfer.address); + g_object_unref(opc_obex_agent); opc_obex_agent = NULL; + + g_free(opc_current_transfer.address); + opc_current_transfer.address = NULL; + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OPC_DISCONNECTED, - BLUETOOTH_ERROR_CANCEL_BY_USER, NULL); + BLUETOOTH_ERROR_CANCEL_BY_USER, &device_addr); + return TRUE; } else { dbus_g_method_return(context, ""); @@ -456,6 +505,8 @@ static gboolean __bt_release_callback(DBusGMethodInvocation *context, { DBG("+"); + bluetooth_device_address_t device_addr = { {0} }; + dbus_g_method_return(context); if (current_transfer) { @@ -463,14 +514,23 @@ static gboolean __bt_release_callback(DBusGMethodInvocation *context, current_transfer = NULL; } - g_object_unref(opc_obex_agent); + _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, + opc_current_transfer.address); + + /* + here opc_obex_agent is just assigned to NULL, since it is being freed at + obex_agent_release() + */ opc_obex_agent = NULL; + g_free(opc_current_transfer.address); + opc_current_transfer.address = NULL; + /*release */ __bt_free_obexd_transfer_hierarchy(&opc_current_transfer); _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OPC_DISCONNECTED, - BLUETOOTH_ERROR_NONE, NULL); + BLUETOOTH_ERROR_NONE, &device_addr); DBG("-"); return TRUE; @@ -483,6 +543,7 @@ static gboolean __bt_error_callback(DBusGMethodInvocation *context, { int result = BLUETOOTH_ERROR_NONE; bt_opc_transfer_info_t info; + bluetooth_device_address_t device_addr = { {0} }; DBG("+ \n"); DBG("message:[%s] \n", message); @@ -517,11 +578,18 @@ static gboolean __bt_error_callback(DBusGMethodInvocation *context, if (TRUE == cancel_sending_files) { /* User cancelled or Remote device is switched off / memory full*/ + + _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, + opc_current_transfer.address); + g_object_unref(opc_obex_agent); opc_obex_agent = NULL; + g_free(opc_current_transfer.address); + opc_current_transfer.address = NULL; + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_OPC_DISCONNECTED, - result, NULL); + result, &device_addr); } DBG("- \n"); diff --git a/lib/bluetooth-opc-api.h b/lib/bluetooth-opc-api.h index c99b13ce..06ce87e1 100644 --- a/lib/bluetooth-opc-api.h +++ b/lib/bluetooth-opc-api.h @@ -47,6 +47,7 @@ struct obexd_transfer_hierarchy { char *name; char *file_name; gint64 size; + gchar *address; }; diff --git a/lib/bluetooth-rfcomm-api.c b/lib/bluetooth-rfcomm-api.c index b288e7ef..f6a45ccd 100644 --- a/lib/bluetooth-rfcomm-api.c +++ b/lib/bluetooth-rfcomm-api.c @@ -33,20 +33,15 @@ #include #include #include -#include #include #include -#include +#include #include "bluetooth-rfcomm-api.h" #include -#define BLUEZ_SERVICE_NAME "org.bluez" #define BLUEZ_SERIAL_CLIENT_INTERFACE "org.bluez.Serial" -#define BLUEZ_MANAGER_OBJ_PATH "/" -#define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager" - #define BLUEZ_SERIAL_MANAGER_INTERFACE "org.bluez.SerialProxyManager" #define BLUEZ_SERIAL_PROXY_INTERFACE "org.bluez.SerialProxy" @@ -55,6 +50,11 @@ #define RFCOMM_DEV_PATH "/dev/rfcomm" #define RFCOMM_SER_DEV_PATH "x00/bluez/rfcomm" +#define BT_AGENT_SIGNAL_AUTHORIZE "Authorize" + +gboolean rfcomm_connected; +int connected_fd; +int requested_server_fd; static DBusConnection *connection = NULL; static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond, gpointer data); @@ -85,6 +85,9 @@ static int __bluetooth_internal_set_non_blocking(int sk); static int __bluetooth_internal_set_non_blocking_tty(int sk); +/* To support the BOT */ +static void __unregister_agent_authorize_signal(DBusGConnection *conn, void *user_data); + /*Get the free index channel for server */ static int __bluetooth_rfcomm_internal_server_get_free_index(void) { @@ -103,6 +106,22 @@ static int __bluetooth_rfcomm_internal_server_get_free_index(void) return ind; } +/*Get the index channel from server socket */ +static int __bluetooth_rfcomm_internal_server_get_index_from_client_socket(int client_fd) +{ + int ind = -1; + int i = 0; + for (; i < RFCOMM_MAX_CONN; i++) { + if (rfcomm_server[i].client_sock_fd == client_fd) { + ind = i; + break; + } + } + DBG("Index from fd %d is index(%d)\n", client_fd, ind); + return ind; +} + + /*Get the index channel from server socket */ static int __bluetooth_rfcomm_internal_server_get_index_from_socket(int fd) { @@ -215,12 +234,17 @@ static int __rfcomm_internal_terminate_server(rfcomm_server_t *server_info) return -1; } + dbus_message_unref(reply); + disconnection_ind.socket_fd = rfcomm_server[index].client_sock_fd; disconnection_ind.device_addr = rfcomm_server[index].device_addr; + disconnection_ind.uuid = g_strdup(rfcomm_server[index].uuid); + disconnection_ind.device_role = RFCOMM_ROLE_SERVER; _bluetooth_internal_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, BLUETOOTH_ERROR_NONE, &disconnection_ind); + g_free(disconnection_ind.uuid); if (rfcomm_server[index].client_sock_fd != -1) { g_source_remove(rfcomm_server[index].client_event_src_id); @@ -232,6 +256,16 @@ static int __rfcomm_internal_terminate_server(rfcomm_server_t *server_info) DBG(" g_source_remove \n"); if (rfcomm_server[index].is_listen) g_source_remove(rfcomm_server[index].server_event_src_id); + + if (rfcomm_server[index].sys_conn) { + __unregister_agent_authorize_signal( + rfcomm_server[index].sys_conn, + &rfcomm_server[index].server_sock_fd); + + dbus_g_connection_unref(rfcomm_server[index].sys_conn); + rfcomm_server[index].sys_conn = NULL; + } + close(rfcomm_server[index].server_sock_fd); rfcomm_server[index].server_sock_fd = -1; rfcomm_server[index].is_listen = FALSE; @@ -251,10 +285,14 @@ static int __rfcomm_internal_terminate_client(int index) DBG("+\n"); bluetooth_rfcomm_disconnection_t disconnection_ind; + memset(&disconnection_ind, 0x00, + sizeof(bluetooth_rfcomm_disconnection_t)); + __bluetooth_rfcomm_internal_disconnect(index); disconnection_ind.socket_fd = rfcomm_client[index].sock_fd; disconnection_ind.device_addr = rfcomm_client[index].device_addr; + disconnection_ind.device_role = RFCOMM_ROLE_CLIENT; _bluetooth_internal_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, BLUETOOTH_ERROR_NONE, &disconnection_ind); @@ -320,7 +358,7 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond } - if(__bluetooth_internal_set_non_blocking_tty(client_sock) < 0) { + if (__bluetooth_internal_set_non_blocking_tty(client_sock) < 0) { /* Even if setting the tty fails we will continue */ DBG("Warning!!Setting the tty properties failed(%d)\n", client_sock); } @@ -329,6 +367,10 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond rfcomm_server[index].client_io_channel = g_io_channel_unix_new(client_sock); + g_io_channel_set_encoding(rfcomm_server[index].client_io_channel, NULL, NULL); + g_io_channel_set_flags(rfcomm_server[index].client_io_channel, + G_IO_FLAG_NONBLOCK, NULL); + g_io_channel_set_close_on_unref(rfcomm_server[index].client_io_channel, TRUE); rfcomm_server[index].client_event_src_id = @@ -345,7 +387,7 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond if (msg == NULL) { DBG("dbus method call is not allocated."); - return -1; + return FALSE; } dbus_error_init(&error); @@ -359,15 +401,14 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond ERR("%s\n", error.message); dbus_error_free(&error); } - return -1; + return FALSE; } dbus_message_iter_init(reply, &reply_iter); if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) { ERR("Can't get reply arguments - DBUS_TYPE_ARRAY\n"); - dbus_message_unref(reply); - return -1; + goto done; } dbus_message_iter_recurse(&reply_iter, &reply_iter_entry); @@ -412,60 +453,71 @@ static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond DBG("Value bool = %d", value); + if (value == FALSE) + goto done; + /*Parsing the address */ - if (value == TRUE) { - dbus_message_iter_next(&reply_iter_entry); - dbus_message_iter_recurse(&reply_iter_entry, &dict_entry); - dbus_message_iter_get_basic(&dict_entry, &property); /*get key - value*/ - DBG("String received...... = %s\n", property); - - if (g_strcmp0("address", property) == 0) { - if (!dbus_message_iter_next(&dict_entry)) { - DBG("Failed getting next dict entry\n"); - return -1; - } - - if (dbus_message_iter_get_arg_type(&dict_entry) != - DBUS_TYPE_VARIANT) { - DBG("Failed get arg type varient\n"); - return -1; - } - /*Getting the value of the varient*/ - dbus_message_iter_recurse(&dict_entry, - &dict_entry_val); - - if (dbus_message_iter_get_arg_type(&dict_entry_val) - != DBUS_TYPE_STRING) { - DBG("Failed get arg type string\n"); - return -1; - } - /*get value string address*/ - dbus_message_iter_get_basic(&dict_entry_val, &property); - - DBG("String received >>> = %s\n", property); - _bluetooth_internal_convert_addr_string_to_addr_type( - &rfcomm_server[index].device_addr, property); + dbus_message_iter_next(&reply_iter_entry); + dbus_message_iter_recurse(&reply_iter_entry, &dict_entry); + dbus_message_iter_get_basic(&dict_entry, &property); + DBG("String received...... = %s\n", property); + + if (g_strcmp0("address", property) == 0) { + if (!dbus_message_iter_next(&dict_entry)) { + DBG("Failed getting next dict entry\n"); + goto done; + } + if (dbus_message_iter_get_arg_type(&dict_entry) != + DBUS_TYPE_VARIANT) { + DBG("Failed get arg type varient\n"); + goto done; } + /*Getting the value of the varient*/ + dbus_message_iter_recurse(&dict_entry, + &dict_entry_val); + + if (dbus_message_iter_get_arg_type(&dict_entry_val) != + DBUS_TYPE_STRING) { + DBG("Failed get arg type string\n"); + goto done; + } + /*get value string address*/ + dbus_message_iter_get_basic(&dict_entry_val, &property); - } else - return -1; + DBG("String received >>> = %s\n", property); + _bluetooth_internal_convert_addr_string_to_addr_type( + &rfcomm_server[index].device_addr, property); + + } } dbus_message_iter_next(&reply_iter_entry); } + dbus_message_unref(reply); + bluetooth_rfcomm_connection_t con_ind; con_ind.device_role = RFCOMM_ROLE_SERVER; con_ind.device_addr = rfcomm_server[index].device_addr; con_ind.socket_fd = rfcomm_server[index].client_sock_fd; + con_ind.uuid = g_strdup(rfcomm_server[index].uuid); + + /* Unblock the connection accept function */ + connected_fd = rfcomm_server[index].client_sock_fd; + rfcomm_connected = TRUE; _bluetooth_internal_event_cb(BLUETOOTH_EVENT_RFCOMM_CONNECTED, BLUETOOTH_ERROR_NONE, &con_ind); + + g_free(con_ind.uuid); + DBG("-\n"); return TRUE; +done: + dbus_message_unref(reply); + return FALSE; } /*Internal: data indication*/ @@ -486,7 +538,7 @@ static gboolean __rfcomm_server_data_received_cb(GIOChannel *chan, GIOCondition memset(buf, 0, sizeof(buf)); - if (g_io_channel_read(chan, buf, sizeof(buf), &len) != G_IO_ERROR_NONE) { + if (g_io_channel_read_chars(chan, buf, sizeof(buf), &len, NULL) == G_IO_STATUS_ERROR) { DBG("IO Channel read error server"); __rfcomm_internal_terminate_server(rfcomm_server_info); @@ -533,7 +585,7 @@ static gboolean __rfcomm_client_data_received_cb(GIOChannel *chan, GIOCondition return FALSE; } - if (g_io_channel_read(chan, buf, sizeof(buf), &len) != G_IO_ERROR_NONE) { + if (g_io_channel_read_chars(chan, buf, sizeof(buf), &len, NULL) == G_IO_STATUS_ERROR) { DBG("IO Channel read error client"); __rfcomm_internal_terminate_client(index); @@ -605,6 +657,7 @@ static int __get_default_adapter_path(char **adapter_path) DBG("%s\n", error.message); dbus_error_free(&error); } + dbus_message_unref(reply); return -1; } @@ -660,6 +713,7 @@ static int __get_rfcomm_proxy_list(char ***proxy_list, int *len) DBG("%s\n", error.message); dbus_error_free(&error); } + dbus_message_unref(reply); return -1; } @@ -701,8 +755,10 @@ static gboolean __get_rfcomm_is_match_uuid(char *proxy, const char *uuid) conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); - if (conn == NULL) + if (conn == NULL) { + dbus_message_unref(msg); return FALSE; + } dbus_error_init(&error); @@ -723,9 +779,7 @@ static gboolean __get_rfcomm_is_match_uuid(char *proxy, const char *uuid) if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) { ERR("Can't get reply arguments - DBUS_TYPE_ARRAY\n"); - dbus_message_unref(reply); - dbus_connection_unref(conn); - return FALSE; + goto done; } dbus_message_iter_recurse(&reply_iter, &reply_iter_entry); @@ -759,7 +813,7 @@ static gboolean __get_rfcomm_is_match_uuid(char *proxy, const char *uuid) DBG("uuid = %s", value); - if (g_strcasecmp(uuid, value) == 0) { + if (g_ascii_strcasecmp(uuid, value) == 0) { dbus_message_unref(reply); dbus_connection_unref(conn); return TRUE; @@ -769,7 +823,7 @@ static gboolean __get_rfcomm_is_match_uuid(char *proxy, const char *uuid) dbus_message_iter_next(&reply_iter_entry); } - +done: dbus_message_unref(reply); dbus_connection_unref(conn); @@ -868,6 +922,7 @@ BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid) DBG("%s\n", error.message); dbus_error_free(&error); } + dbus_message_unref(reply); return BLUETOOTH_ERROR_INTERNAL; } @@ -945,8 +1000,10 @@ BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid) close(sk); return BLUETOOTH_ERROR_INTERNAL; } - else - return sk; + + DBG("Set the uuid"); + rfcomm_server[index].uuid = g_strdup(uuid); + return sk; } BT_EXPORT_API gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uuid) @@ -965,17 +1022,17 @@ BT_EXPORT_API gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uui /*Get all proxies */ if (__get_rfcomm_proxy_list(&proxy_list, &len) < 0) { DBG("Fail to RFCOMM List Proxy\n"); - return TRUE; + return FALSE; } DBG("Proxy count = %d\n", len); for (i = 0; i < len; i++) { if (__get_rfcomm_is_match_uuid(proxy_list[i], uuid) == TRUE) - return FALSE; + return TRUE; } - return TRUE; + return FALSE; } @@ -1017,9 +1074,16 @@ BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pend return BLUETOOTH_ERROR_CONNECTION_ERROR; } + if (vconf_set_str(BT_MEMORY_RFCOMM_UUID, "") != 0) + DBG("\vconf set failed.."); + rfcomm_server[index].server_io_channel = g_io_channel_unix_new(socket_fd); g_io_channel_set_close_on_unref(rfcomm_server[index].server_io_channel, TRUE); + g_io_channel_set_encoding(rfcomm_server[index].server_io_channel, NULL, NULL); + g_io_channel_set_flags(rfcomm_server[index].server_io_channel, + G_IO_FLAG_NONBLOCK, NULL); + rfcomm_server[index].server_event_src_id = g_io_add_watch(rfcomm_server[index].server_io_channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, __rfcomm_server_connected_cb, @@ -1031,13 +1095,300 @@ BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pend } +/* To support the BOT */ +static DBusHandlerResult __rfcomm_authorize_event_filter(DBusConnection *sys_conn, + DBusMessage *msg, void *data) +{ + const char *path = dbus_message_get_path(msg); + bluetooth_rfcomm_connection_request_t req_ind = { 0 }; + const char *addr = NULL; + const char *name = NULL; + int socket_fd = *((int *)data); + + if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (path == NULL || strcmp(path, "/") == 0) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (dbus_message_is_signal(msg, BT_AGENT_INTERFACE, BT_AGENT_SIGNAL_AUTHORIZE)) { + dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &addr, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + DBG("Rfcomm Authorize request [%s], [%s]", addr, name); + + if (addr == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + DBG("socket_fd: %d", socket_fd); + + req_ind.socket_fd = socket_fd; + requested_server_fd = socket_fd; + _bluetooth_internal_convert_addr_string_to_addr_type(&req_ind.device_addr, addr); + _bluetooth_internal_print_bluetooth_device_address_t(&req_ind.device_addr); + + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_RFCOMM_AUTHORIZE, + BLUETOOTH_ERROR_NONE, &req_ind); + + } else { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + return DBUS_HANDLER_RESULT_HANDLED; +} + +/* To support the BOT */ +DBusGConnection *__register_agent_authorize_signal(void *user_data) +{ + DBG("+\n"); + DBusGConnection *conn = NULL; + DBusConnection *dbus_connection = NULL; + GError *err = NULL; + DBusError dbus_error; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); + if (!conn) { + DBG(" DBUS get failed\n"); + g_error_free(err); + return NULL; + } + + dbus_connection = dbus_g_connection_get_connection(conn); + + /* Add the filter for network client functions */ + dbus_error_init(&dbus_error); + dbus_connection_add_filter(dbus_connection, + __rfcomm_authorize_event_filter, + user_data, NULL); + dbus_bus_add_match(dbus_connection, + "type=signal,interface=" BT_AGENT_INTERFACE + ",member=Authorize", &dbus_error); + if (dbus_error_is_set(&dbus_error)) { + ERR("Fail to add dbus filter signal\n"); + dbus_error_free(&dbus_error); + } + + DBG("-\n"); + return conn; +} + +/* To support the BOT */ +static void __unregister_agent_authorize_signal(DBusGConnection *conn, void *user_data) +{ + DBG("+"); + + DBusConnection *dbus_connection = NULL; + + if (conn == NULL) { + DBG("conn is NULL"); + return; + } + + dbus_connection = dbus_g_connection_get_connection(conn); + + dbus_connection_remove_filter(dbus_connection, + __rfcomm_authorize_event_filter, + user_data); + + if (vconf_set_str(BT_MEMORY_RFCOMM_UUID, "") != 0 ) + DBG("\vconf set failed.."); + + DBG("-"); +} + +/* To support the BOT */ +BT_EXPORT_API int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection) +{ + DBG("+\n"); + int is_success; + int index; + static char *default_adapter_obj_path = NULL; + + if (socket_fd <= 0) { + DBG("\nInvalid fd.."); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + if (__get_default_adapter_path(&default_adapter_obj_path) < 0) { + DBG("Fail to get default hci adapter path\n"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + index = __bluetooth_rfcomm_internal_server_get_index_from_socket(socket_fd); + if (index < 0) { + DBG("Invalid index %d", index); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + rfcomm_server[index].sys_conn = __register_agent_authorize_signal( + &rfcomm_server[index].server_sock_fd); + + if (rfcomm_server[index].sys_conn == NULL) { + DBG("Fail to get the dbus connection"); + return BLUETOOTH_ERROR_INTERNAL; + } + + /* Store the uuid info to vconf */ + if (rfcomm_server[index].uuid) { + DBG("Set vconf: %s", rfcomm_server[index].uuid); + + if (vconf_set_str(BT_MEMORY_RFCOMM_UUID, + rfcomm_server[index].uuid) != 0) + DBG("\vconf set failed.."); + } + + is_success = listen(socket_fd, max_pending_connection); + + if (is_success == 0) + rfcomm_server[index].is_listen = TRUE; + else { + rfcomm_server[index].is_listen = FALSE; + DBG("\nListen failed.."); + return BLUETOOTH_ERROR_CONNECTION_ERROR; + } + + rfcomm_server[index].server_io_channel = g_io_channel_unix_new(socket_fd); + g_io_channel_set_close_on_unref(rfcomm_server[index].server_io_channel, TRUE); + + g_io_channel_set_flags(rfcomm_server[index].server_io_channel, + G_IO_FLAG_NONBLOCK, NULL); + + rfcomm_server[index].server_event_src_id = + g_io_add_watch(rfcomm_server[index].server_io_channel, + G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, __rfcomm_server_connected_cb, + &rfcomm_server[index]); + g_io_channel_unref(rfcomm_server[index].server_io_channel); + + DBG(" -\n is success = %d\n", is_success); + return is_success; +} + +/* To support the BOT */ +BT_EXPORT_API int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd) +{ + DBG("+"); + + int ret = BLUETOOTH_ERROR_NONE; + unsigned long block_time = 0; + DBusGConnection *conn = NULL; + DBusGProxy *agent_proxy = NULL; + + if (server_fd != requested_server_fd) { + DBG("Not requested fd"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + requested_server_fd = 0; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + + if (conn == NULL) { + DBG("conn is NULL\n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + agent_proxy = dbus_g_proxy_new_for_name(conn, + "org.bluez.frwk_agent", + "/org/bluez/agent/frwk_agent", + "org.bluez.Agent"); + + if (agent_proxy == NULL) { + DBG("agent proxy is NULL"); + dbus_g_connection_unref(conn); + return BLUETOOTH_ERROR_INTERNAL; + } + + rfcomm_connected = FALSE; + connected_fd = 0; + + if (!dbus_g_proxy_call(agent_proxy, "ReplyAuthorize", NULL, + G_TYPE_UINT, BT_ACCEPT, + G_TYPE_INVALID, G_TYPE_INVALID)) { + DBG("Fail to ReplyAuthorize"); + ret = BLUETOOTH_ERROR_INTERNAL; + goto done; + } + + /* Block until recieve the event (Requirement from BADA) */ + while (rfcomm_connected == FALSE) { + g_main_context_iteration(NULL, TRUE); + usleep(SLEEP_TIME); /* Sleep 50ms */ + block_time += SLEEP_TIME; + + if (block_time >= BLOCK_MAX_TIMEOUT) + return BLUETOOTH_ERROR_TIMEOUT; + } + + *client_fd = connected_fd; + rfcomm_connected = FALSE; + + DBG("-"); + return BLUETOOTH_ERROR_NONE; + +done: + g_object_unref(agent_proxy); + dbus_g_connection_unref(conn); + + DBG("-"); + + return ret; +} + +/* To support the BOT */ +BT_EXPORT_API int bluetooth_rfcomm_reject_connection(int server_fd) +{ + DBG("+"); + + int ret = BLUETOOTH_ERROR_NONE; + DBusGConnection *conn = NULL; + DBusGProxy *agent_proxy = NULL; + + if (server_fd != requested_server_fd) { + DBG("Not requested fd"); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + requested_server_fd = 0; + + conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + + if (conn == NULL) { + DBG("conn is NULL\n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + agent_proxy = dbus_g_proxy_new_for_name(conn, + "org.bluez.frwk_agent", + "/org/bluez/agent/frwk_agent", + "org.bluez.Agent"); + + if (agent_proxy == NULL) { + DBG("agent proxy is NULL"); + dbus_g_connection_unref(conn); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (!dbus_g_proxy_call(agent_proxy, "ReplyAuthorize", NULL, + G_TYPE_UINT, BT_REJECT, + G_TYPE_INVALID, G_TYPE_INVALID)) { + DBG("Fail to ReplyAuthorize"); + ret = BLUETOOTH_ERROR_INTERNAL; + } + + g_object_unref(agent_proxy); + dbus_g_connection_unref(conn); + + DBG("-"); + return ret; +} + /* * SLP 2.0 Bluetooth RFCOMM API - * bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid) + * bluetooth_rfcomm_remove_socket(int socket_fd) * */ -BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid) +BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd) { DBG("+\n"); DBusMessage *msg, *reply; @@ -1115,13 +1466,20 @@ BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid return BLUETOOTH_ERROR_INTERNAL; } + dbus_message_unref(reply); + if (rfcomm_server[index].client_sock_fd) { bluetooth_rfcomm_disconnection_t disconnection_ind; disconnection_ind.socket_fd = rfcomm_server[index].client_sock_fd; disconnection_ind.device_addr = rfcomm_server[index].device_addr; + disconnection_ind.device_role = RFCOMM_ROLE_SERVER; + disconnection_ind.uuid = g_strdup(rfcomm_server[index].uuid); + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, BLUETOOTH_ERROR_NONE, &disconnection_ind); + g_free(disconnection_ind.uuid); + g_source_remove(rfcomm_server[index].client_event_src_id); close(rfcomm_server[index].client_sock_fd); rfcomm_server[index].client_sock_fd = -1; @@ -1130,6 +1488,15 @@ BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid if (rfcomm_server[index].is_listen) g_source_remove(rfcomm_server[index].server_event_src_id); + if (rfcomm_server[index].sys_conn) { + __unregister_agent_authorize_signal( + rfcomm_server[index].sys_conn, + &rfcomm_server[index].server_sock_fd); + + dbus_g_connection_unref(rfcomm_server[index].sys_conn); + rfcomm_server[index].sys_conn = NULL; + } + close(rfcomm_server[index].server_sock_fd); rfcomm_server[index].server_sock_fd = -1; @@ -1137,6 +1504,9 @@ BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid g_free(rfcomm_server[index].uds_name); rfcomm_server[index].uds_name = NULL; + g_free(rfcomm_server[index].uuid); + rfcomm_server[index].uuid = NULL; + /*Resetting the connection */ rfcomm_server[index].id = 0; @@ -1144,6 +1514,52 @@ BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid return BLUETOOTH_ERROR_NONE; } +BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd) +{ + DBG("+\n"); + + bluetooth_rfcomm_disconnection_t disconnection_ind; + static char *default_adapter_obj_path = NULL; + bt_info_t *bt_internal_info = NULL; + int index = 0; + int ret = BLUETOOTH_ERROR_NONE; + + if (socket_fd <= 0) + return BLUETOOTH_ERROR_INVALID_PARAM; + + if (__get_default_adapter_path(&default_adapter_obj_path) < 0) { + DBG("Fail to get default hci adapter path\n"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } + + bt_internal_info = _bluetooth_internal_get_information(); + + index = __bluetooth_rfcomm_internal_server_get_index_from_client_socket(socket_fd); + if (index < 0) { + DBG("Invalid index %d for socket %d\n", index, socket_fd); + return BLUETOOTH_ERROR_INVALID_PARAM; + } + + disconnection_ind.socket_fd = rfcomm_server[index].client_sock_fd; + disconnection_ind.device_addr = rfcomm_server[index].device_addr; + disconnection_ind.device_role = RFCOMM_ROLE_SERVER; + disconnection_ind.uuid = g_strdup(rfcomm_server[index].uuid); + _bluetooth_internal_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, + BLUETOOTH_ERROR_NONE, &disconnection_ind); + + g_free(disconnection_ind.uuid); + + g_source_remove(rfcomm_server[index].client_event_src_id); + close(rfcomm_server[index].client_sock_fd); + rfcomm_server[index].client_sock_fd = -1; + + DBG("-\n"); + + return ret; + +} + + /* Asynchrous implementation */ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) @@ -1173,6 +1589,7 @@ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call G_TYPE_STRING, &rfcomm_device_node, G_TYPE_INVALID); g_object_unref(proxy); + bt_internal_info->rfcomm_proxy = NULL; if (err != NULL) { DBG("Error occured in connecting port [%s]", err->message); @@ -1217,7 +1634,7 @@ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call DBG("\n/dev/rfcomm fd = %d\n", dev_node_fd); - if(__bluetooth_internal_set_non_blocking_tty(dev_node_fd) < 0) { + if (__bluetooth_internal_set_non_blocking_tty(dev_node_fd) < 0) { DBG("\nWarning! Unable to set the tty /dev/rfcomm fd = %d\n", dev_node_fd); /* Even if setting the tty fails we will continue */ @@ -1229,22 +1646,24 @@ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call memcpy(&rfcomm_client[index].device_addr, remote_address, BLUETOOTH_ADDRESS_LENGTH); rfcomm_client[index].io_channel = g_io_channel_unix_new(dev_node_fd); - g_io_channel_set_close_on_unref(rfcomm_client[index].io_channel, TRUE); + g_io_channel_set_flags(rfcomm_client[index].io_channel, + G_IO_FLAG_NONBLOCK, NULL); + rfcomm_client[index].event_src_id = g_io_add_watch(rfcomm_client[index].io_channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, __rfcomm_client_data_received_cb, &rfcomm_client[index]); done: + memset(&con_ind, 0x00, sizeof(bluetooth_rfcomm_connection_t)); + memcpy(&con_ind.device_addr, remote_address, BLUETOOTH_ADDRESS_LENGTH); if (result == BLUETOOTH_ERROR_NONE) { con_ind.socket_fd = rfcomm_client[index].sock_fd; - con_ind.device_addr = rfcomm_client[index].device_addr; } else { con_ind.socket_fd = -1; - memcpy(&con_ind.device_addr, remote_address, BLUETOOTH_ADDRESS_LENGTH); /* We are freeing dev_node in error case only. Success case * will be handled during disconnection */ @@ -1252,6 +1671,7 @@ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call } con_ind.device_role = RFCOMM_ROLE_CLIENT; + con_ind.uuid = bt_internal_info->connecting_uuid; bt_event.event = BLUETOOTH_EVENT_RFCOMM_CONNECTED; bt_event.result = result; bt_event.param_data = (void *)&con_ind; @@ -1261,13 +1681,14 @@ static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data); } + g_free(bt_internal_info->connecting_uuid); + bt_internal_info->connecting_uuid = NULL; + free(remote_address); DBG("-\n"); } -DBusGProxy *proxy_rfcomm_client = NULL; - BT_EXPORT_API int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address, const char *remote_uuid) { @@ -1275,9 +1696,11 @@ BT_EXPORT_API int bluetooth_rfcomm_connect(const bluetooth_device_address_t *rem gchar *address_up; gchar *remote_device_path; char str_addr[20]; + DBusGProxy *proxy = NULL; bluetooth_device_address_t *remote_address; GError *err = NULL; DBusGConnection *conn; + bt_info_t *bt_internal_info = NULL; static char *default_adapter_obj_path = NULL; memset(str_addr, 0, 20); @@ -1310,12 +1733,12 @@ BT_EXPORT_API int bluetooth_rfcomm_connect(const bluetooth_device_address_t *rem return BLUETOOTH_ERROR_CONNECTION_ERROR; } - proxy_rfcomm_client = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, + proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, remote_device_path, BLUEZ_SERIAL_CLIENT_INTERFACE); g_free(remote_device_path); - if (proxy_rfcomm_client == NULL) { + if (proxy == NULL) { DBG("Failed to get the rfcomm proxy\n"); return BLUETOOTH_ERROR_NOT_PAIRED; } @@ -1327,7 +1750,13 @@ BT_EXPORT_API int bluetooth_rfcomm_connect(const bluetooth_device_address_t *rem remote_address->addr[1], remote_address->addr[2], remote_address->addr[3], remote_address->addr[4], remote_address->addr[5]); - if (!dbus_g_proxy_begin_call(proxy_rfcomm_client, "Connect", + bt_internal_info = _bluetooth_internal_get_information(); + + bt_internal_info->connecting_uuid = g_strdup(remote_uuid); + + bt_internal_info->rfcomm_proxy = proxy; + + if (!dbus_g_proxy_begin_call(proxy, "Connect", (DBusGProxyCallNotify)__rfcomm_client_connected_cb, (gpointer)remote_address, /*user_data*/ NULL, /*destroy*/ @@ -1335,6 +1764,10 @@ BT_EXPORT_API int bluetooth_rfcomm_connect(const bluetooth_device_address_t *rem G_TYPE_INVALID)) { DBG("Network server register Dbus Call Error"); free(remote_address); + g_free(bt_internal_info->connecting_uuid); + g_object_unref(proxy); + bt_internal_info->connecting_uuid = NULL; + bt_internal_info->rfcomm_proxy = NULL; return BLUETOOTH_ERROR_INTERNAL; } @@ -1418,22 +1851,79 @@ static int __bluetooth_rfcomm_internal_disconnect(int index) } +static int __bluetooth_cancel_connecting(DBusGProxy *proxy) +{ + + DBG("+\n"); + + bt_info_t *bt_internal_info = NULL; + GError *error = NULL; + + bt_internal_info = _bluetooth_internal_get_information(); + + if (bt_internal_info->connecting_uuid == NULL) { + DBG("uuid is NULL"); + return BLUETOOTH_ERROR_INTERNAL; + } + + if (!dbus_g_proxy_call(proxy, + "Disconnect", + &error, + G_TYPE_STRING, bt_internal_info->connecting_uuid, + G_TYPE_INVALID, G_TYPE_INVALID)) { + DBG("Disconnect Dbus Call Error, %s", error->message); + g_error_free(error); + return BLUETOOTH_ERROR_INTERNAL; + } + + g_free(bt_internal_info->connecting_uuid); + bt_internal_info->connecting_uuid = NULL; + + DBG("-\n"); + return BLUETOOTH_ERROR_NONE; +} + + BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd) { DBG("+\n"); static char *default_adapter_obj_path = NULL; + bt_info_t *bt_internal_info = NULL; int index = 0; + int ret = BLUETOOTH_ERROR_NONE; if (__get_default_adapter_path(&default_adapter_obj_path) < 0) { DBG("Fail to get default hci adapter path\n"); return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; } + bt_internal_info = _bluetooth_internal_get_information(); + + if (socket_fd <= 0) { + /* Cancel connecting request */ + if (bt_internal_info->rfcomm_proxy == NULL) { + DBG("No connecting request"); + return BLUETOOTH_ERROR_NOT_IN_OPERATION; + } + + if (__bluetooth_cancel_connecting( + bt_internal_info->rfcomm_proxy) != + BLUETOOTH_ERROR_NONE) { + return BLUETOOTH_ERROR_INTERNAL; + } + + g_object_unref(bt_internal_info->rfcomm_proxy); + bt_internal_info->rfcomm_proxy = NULL; + return BLUETOOTH_ERROR_NONE; + } + index = __bluetooth_rfcomm_internal_client_get_index_from_socket(socket_fd); if (index < 0) { DBG("Invalid index %d for socket %d\n", index, socket_fd); - return BLUETOOTH_ERROR_INVALID_PARAM; + + /* Try to disconnect server socket */ + return bluetooth_rfcomm_server_disconnect(socket_fd); } if (!(socket_fd && (socket_fd == rfcomm_client[index].sock_fd)) || @@ -1442,20 +1932,14 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd) return BLUETOOTH_ERROR_INVALID_PARAM; } - __bluetooth_rfcomm_internal_disconnect(index); - - g_source_remove(rfcomm_client[index].event_src_id); - close(rfcomm_client[index].sock_fd); - rfcomm_client[index].sock_fd = -1; + ret = __bluetooth_rfcomm_internal_disconnect(index); - if (rfcomm_client[index].dev_node_name != NULL) - g_free(rfcomm_client[index].dev_node_name); - rfcomm_client[index].dev_node_name = NULL; + if (ret == BLUETOOTH_ERROR_NONE) + __rfcomm_internal_terminate_client(index); - rfcomm_client[index].id = -1; DBG("-\n"); - return BLUETOOTH_ERROR_NONE; + return ret; } @@ -1482,6 +1966,11 @@ BT_EXPORT_API int bluetooth_rfcomm_write(int fd, const char *buf, int length) DBG("write failed..\n"); return BLUETOOTH_ERROR_NOT_IN_OPERATION; } + + /* Synchronize the sending buffer */ + sync(); + fsync(fd); + wbytes += written; } @@ -1521,7 +2010,7 @@ static gboolean __is_rfcomm_connected(DBusGConnection *conn, DBusGProxy *adapter if (object_path == NULL) return FALSE; - proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_NAME, object_path, + proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, object_path, BLUEZ_SERIAL_CLIENT_INTERFACE); if (proxy == NULL) @@ -1578,8 +2067,8 @@ BT_EXPORT_API gboolean bluetooth_rfcomm_is_client_connected() goto done; } - adapter = dbus_g_proxy_new_for_name(conn, BLUEZ_NAME, - adapter_path, BLUEZ_ADAPTER_NAME); + adapter = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME, + adapter_path, BLUEZ_ADAPTER_INTERFACE); g_free(adapter_path); @@ -1676,4 +2165,3 @@ static int __bluetooth_internal_set_non_blocking_tty(int sk) return 0; } - diff --git a/lib/bluetooth-rfcomm-api.h b/lib/bluetooth-rfcomm-api.h index 7347e028..da8778a4 100644 --- a/lib/bluetooth-rfcomm-api.h +++ b/lib/bluetooth-rfcomm-api.h @@ -40,11 +40,13 @@ typedef struct { gboolean is_listen; /*server listen*/ char *uds_name; /*proxy name*/ char *file_name; /*device name*/ + char *uuid; /*uuid*/ int client_sock_fd; bluetooth_device_address_t device_addr; GIOChannel *client_io_channel; guint client_event_src_id; + DBusGConnection *sys_conn; } rfcomm_server_t; static rfcomm_server_t rfcomm_server[RFCOMM_MAX_CONN]; diff --git a/lib/bluetooth-sdp-api.c b/lib/bluetooth-sdp-api.c index 51272216..36c9e654 100644 --- a/lib/bluetooth-sdp-api.c +++ b/lib/bluetooth-sdp-api.c @@ -74,8 +74,6 @@ static void __bluetooth_internal_get_remote_device_uuids_cb(DBusGProxy *proxy, D GHashTable *hash; GValue *value = { 0 }; int result = BLUETOOTH_ERROR_NONE; - bluetooth_event_param_t bt_event = { 0, }; - bt_info_t *bt_internal_info = NULL; DBG("+\n"); @@ -132,7 +130,7 @@ static void __bluetooth_internal_get_remote_device_uuids_cb(DBusGProxy *proxy, D g_strfreev(array_list); done: - + if (0 > ret) { result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR; device_uuids.service_index = 0x00; @@ -177,208 +175,6 @@ static void __bluetooth_internal_device_created_for_sdp_cb(DBusGProxy *proxy, DB return; } -static int __bluetooth_internal_parse_sdp_xml(const char *buf_name, int size, - bt_sdp_info_t *xml_parsed_sdp); - -static gboolean __bluetooth_internal_get_service_rec_handle_from_node(xmlNodePtr xml_node, - unsigned int *record_handle); -static gboolean __bluetooth_internal_get_service_class_id_list_from_node(xmlNodePtr xml_node, - bt_sdp_info_t *sdp_info); - -static gboolean __bluetooth_internal_get_service_class_id_list_from_node(xmlNodePtr xml_node, - bt_sdp_info_t *sdp_info) -{ - xmlNodePtr local_node; - xmlAttr *uuid_attr; - xmlNodePtr uuid_node; - - if (xml_node == NULL || sdp_info == NULL) - return FALSE; - - local_node = xml_node->next; - - while (local_node) { - if (!strcmp((char *)local_node->name, "sequence")) { - DBG("\t\t %s\n", local_node->name); - uuid_node = local_node->xmlChildrenNode; - uuid_node = uuid_node->next; - - if (uuid_node) { - uuid_attr = uuid_node->properties; - DBG("\t\t\t%s, %s\n", uuid_node->name, - uuid_attr->children->content); - - if (sdp_info->service_index < BLUETOOTH_MAX_SERVICES_FOR_DEVICE) { - DBG("sdp_info->service_index %d", sdp_info->service_index); - g_strlcpy(sdp_info->uuids[sdp_info->service_index], - (const gchar *)uuid_attr->children->content, - BLUETOOTH_UUID_STRING_MAX); - - sdp_info->service_list_array[sdp_info->service_index] = - strtol((char *)uuid_attr->children->content, - NULL, 0); - sdp_info->service_index++; - } else { - DBG("service index(%d) is more than" - "BLUETOOTH_MAX_SERVICES_FOR_DEVICE", - sdp_info->service_index); - } - - } - } - local_node = local_node->next; - } - return TRUE; -} - -static gboolean __bluetooth_internal_get_service_rec_handle_from_node(xmlNodePtr xml_node, - unsigned int *record_handle) { - xmlNodePtr local_node; - xmlAttr *local_attr; - - if (xml_node == NULL || record_handle == NULL) - return FALSE; - - local_node = xml_node->next; - - if (local_node) { - if (!strcmp((char *)local_node->name, "uint32")) { - local_attr = local_node->properties; - DBG("\t\t%s, %s\n", local_node->name, local_attr->children->content); - *record_handle = strtol((char *)local_attr->children->content, NULL, 0); - } - } - return TRUE; -} - -static int __bluetooth_internal_parse_xml_parse_record(xmlNodePtr cur, - bt_sdp_info_t *xml_parsed_sdp_data) -{ - xmlNodePtr icur; - - icur = cur; - icur = icur->xmlChildrenNode; - xmlAttr *attr = NULL; - - unsigned int attribute_value = 0; - unsigned int record_handle = 0; - - while (icur) { - attr = icur->properties; - - if (strcmp((char *)icur->name, "attribute")) { - icur = icur->next; - continue; - } - - DBG("%s\n", icur->name); - while (attr) { - if (strcmp((char *)attr->name, "id")) { - attr = attr->next; - continue; - } - DBG("\t%s, %s\n", attr->name, attr->children->content); - attribute_value = strtol((char *)attr->children->content, NULL, 0); - - switch (attribute_value) { - case SERVICE_RECORD_HANDLE: - DBG("\tSERVICE_RECORD_HANDLE:\n"); - __bluetooth_internal_get_service_rec_handle_from_node - (icur->xmlChildrenNode, &record_handle); - DBG("\tRecord Handle 0x%04x \n", record_handle); - break; - - case SERVICE_CLASS_ID_LIST: - DBG("\tSERVICE_CLASS_ID_LIST:\n"); - __bluetooth_internal_get_service_class_id_list_from_node - (icur->xmlChildrenNode, xml_parsed_sdp_data); - break; - - case PROTOCOL_DESCRIPOTR_LIST: - break; - - case BLUETOOTH_PROFILE_DESCRIPTOR_LIST: - break; - - default: - break; - - } - attr = attr->next; - } - icur = icur->next; - } - return TRUE; -} - -static int __bluetooth_internal_parse_sdp_xml(const char *buf_name, int size, - bt_sdp_info_t *xml_parsed_sdp) -{ - xmlDocPtr doc; - xmlNodePtr first; - xmlNodePtr base; - xmlInitParser(); - - char *check = NULL; - - DBG("+\n"); - - /*Below check is done for proper parsing of BPP service UUID, in case of BPP '&' gets - appended to text value parameter of service list, when '&' containing data is passed - to function "xmlParseMemory()" parse error occurs. so '&' is replaced with blank space ' '*/ - if (buf_name != NULL) { - check = strchr(buf_name, '&'); - if (check != NULL) { - *check = ' '; - } - } - - if (size != 0) { - doc = xmlParseMemory(buf_name, size); - } else - return -1; - - if (doc == NULL) { - DBG("Document not parsed successfully.\n"); - return -1; - } - - DBG("Document parsed successfully.\n"); - - first = xmlDocGetRootElement(doc); - - if (first == NULL) { - DBG("Root element = NULL \n"); - xmlFreeDoc(doc); - return -1; - } - - base = first; - if (base == NULL) { - DBG("empty document\n"); - xmlFreeDoc(doc); - - xmlCleanupParser(); - return -1; - } else { - DBG("Root - %s\n", first->name); - } - while (base != NULL) { - DBG(" Main While %s\n", base->name); - - __bluetooth_internal_parse_xml_parse_record(base, xml_parsed_sdp); - base = base->next; - - } - - xmlFreeDoc(doc); - - xmlCleanupParser(); - DBG("-\n"); - - return 0; -} - static void __bluetooth_internal_discover_services_cb(DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data) { @@ -460,7 +256,7 @@ static void __bluetooth_internal_discover_services_cb(DBusGProxy *proxy, DBusGPr result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR; sdp_data.service_index = 0; } else if (sdp_data.service_index == 0) { - /*This is for some carkit, printer.*/ + /*This is for some carkit, printer.*/ __bluetooth_internal_request_search_supported_services( &bt_info_for_searching_support_service->remote_device_addr); return; diff --git a/packaging/bluetooth-frwk.spec b/packaging/bluetooth-frwk.spec index ecd44ba8..fa2d5f26 100644 --- a/packaging/bluetooth-frwk.spec +++ b/packaging/bluetooth-frwk.spec @@ -1,9 +1,9 @@ Name: bluetooth-frwk Summary: Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework based on BlueZ and Obexd stack. -Version: 0.1.56 +Version: 0.1.80 Release: 1 Group: TO_BE/FILLED_IN -License: Apache-2.0 +License: TO BE FILLED IN Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig(aul) @@ -14,12 +14,12 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(syspopup-caller) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(libxml-2.0) -BuildRequires: pkgconfig(bluez) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(utilX) -BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(msg-service) BuildRequires: pkgconfig(email-service) +BuildRequires: pkgconfig(appcore-efl) +BuildRequires: pkgconfig(appsvc) BuildRequires: cmake Requires(post): /sbin/ldconfig @@ -31,12 +31,12 @@ Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework bas %package devel -Summary: Bluetooth framework for BlueZ +Summary: Bluetooth framework for BlueZ and Obexd Group: TO_BE/FILLED Requires: %{name} = %{version}-%{release} %description devel -This package is development files for Bluetooth framework based on BlueZ stack. +This package is development files for Bluetooth framework based on BlueZ and Obexd stack. This package contains API set for BT GAP, BT SDP, and BT RFCOMM. @@ -61,35 +61,55 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr make %install +rm -rf %{buildroot} %make_install -%post -/sbin/ldconfig -# Set vconf values with -g/-u options -# 0 is root user id -vconftool set -t bool memory/bluetooth/allow "0" -u 0 - -%postun -p /sbin/ldconfig +mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d/ +mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d/ +ln -s %{_sysconfdir}/rc.d/init.d/bluetooth-frwk-agent %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S80bluetooth-frwk-agent +ln -s %{_sysconfdir}/rc.d/init.d/bluetooth-frwk-agent %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S80bluetooth-frwk-agent -%post agent +%post +vconftool set -t int db/bluetooth/status "0" -g 6520 +vconftool set -t int memory/private/libbluetooth-frwk-0/obex_no_agent "0" -g 6520 -i +vconftool set -t string memory/private/libbluetooth-frwk-0/uuid "" -g 6520 -i +vconftool set -t string memory/bluetooth/sco_headset_name "" -g 6520 -i -ln -s ../init.d/bluetooth-frwk-agent /etc/rc.d/rc3.d/S80bluetooth-frwk-agent -ln -s ../init.d/bluetooth-frwk-agent /etc/rc.d/rc5.d/S80bluetooth-frwk-agent +%postun -p /sbin/ldconfig %files -/usr/lib/*.so.* +%defattr(-, root, root) +%{_libdir}/libbluetooth-api.so.* +%{_libdir}/libbluetooth-media-control.so.* +%{_libdir}/libbluetooth-telephony.so.* %files devel -/usr/lib/*.so -/usr/include/* -/usr/lib/pkgconfig/* +%defattr(-, root, root) +%{_includedir}/bluetooth-media-control/bluetooth-media-control.h +%{_includedir}/bluetooth-api/bluetooth-hid-api.h +%{_includedir}/bluetooth-api/bluetooth-audio-api.h +%{_includedir}/bluetooth-api/bluetooth-control-api.h +%{_includedir}/bluetooth-api/bluetooth-api.h +%{_includedir}/bluetooth-telephony/bluetooth-telephony-api.h +%{_libdir}/pkgconfig/bluetooth-media-control.pc +%{_libdir}/pkgconfig/bluetooth-api.pc +%{_libdir}/pkgconfig/bluetooth-telephony.pc +%{_libdir}/libbluetooth-api.so +%{_libdir}/libbluetooth-media-control.so +%{_libdir}/libbluetooth-telephony.so + %files agent -/usr/bin/bluetooth-agent -/usr/bin/bluetooth-pb-agent -/etc/* -#/usr/share/process-info/bluetooth-agent.ini -/usr/share/dbus-1/services/org.bluez.frwk_agent.service -/usr/share/dbus-1/services/org.bluez.pb_agent.service -/usr/bin/bluetooth-map-agent -/usr/share/dbus-1/services/org.bluez.map_agent.service +%defattr(-, root, root) +%{_sysconfdir}/rc.d/init.d/bluetooth-frwk-agent +%{_sysconfdir}/rc.d/rc3.d/S80bluetooth-frwk-agent +%{_sysconfdir}/rc.d/rc5.d/S80bluetooth-frwk-agent +%{_datadir}/dbus-1/services/org.bluez.pb_agent.service +%{_datadir}/dbus-1/services/org.bluez.frwk_agent.service +%{_datadir}/dbus-1/services/org.bluez.map_agent.service +%{_datadir}/dbus-1/services/org.bluez.hfp_agent.service +%{_bindir}/bluetooth-agent +%{_bindir}/bluetooth-map-agent +%{_bindir}/bluetooth-pb-agent +%{_bindir}/bluetooth-hfp-agent +