Initialize Tizen 2.3 2.3a_release submit/tizen_2.3/20140531.102454
authorSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 03:55:12 +0000 (12:55 +0900)
committerSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 03:55:12 +0000 (12:55 +0900)
27 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE.Flora [new file with mode: 0644]
NOTICE [new file with mode: 0644]
app.default.include [new file with mode: 0644]
images/tw_btn_delete_holo_dark.png [new file with mode: 0755]
images/tw_timepicker_dialbtn_minus_dim.png [new file with mode: 0755]
images/tw_timepicker_dialbtn_minus_normal.png [new file with mode: 0755]
images/tw_timepicker_dialbtn_minus_pressed.png [new file with mode: 0755]
include/bt-dbus-method.h [new file with mode: 0644]
include/bt-handler.h [new file with mode: 0644]
include/bt-main-view.h [new file with mode: 0644]
include/bt-main.h [new file with mode: 0644]
include/bt-popup.h [new file with mode: 0644]
include/bt-string.h [new file with mode: 0755]
include/bt-type-define.h [new file with mode: 0644]
include/bt-util.h [new file with mode: 0644]
org.tizen.bluetooth.manifest [new file with mode: 0644]
org.tizen.bluetooth.rule [new file with mode: 0644]
org.tizen.bluetooth.xml [new file with mode: 0644]
packaging/org.tizen.bluetooth.spec [new file with mode: 0644]
src/bt-dbus-method.c [new file with mode: 0644]
src/bt-handler.c [new file with mode: 0644]
src/bt-main-view.c [new file with mode: 0755]
src/bt-main.c [new file with mode: 0644]
src/bt-popup.c [new file with mode: 0644]
src/bt-util.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..1a599df
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+Hocheol Seo <hocheol.seo@samsung.com>
+Girish Ashok Joshi <girish.joshi@samsung.com>
+Chanyeol Park <chanyeol.park@samsung.com>
+DoHyun Pyun <dh79.pyun@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..55a4768
--- /dev/null
@@ -0,0 +1,88 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth C)
+
+SET(SRCS
+       src/bt-main.c
+       src/bt-main-view.c
+       src/bt-handler.c
+       src/bt-popup.c
+       src/bt-util.c
+       src/bt-dbus-method.c
+       )
+
+SET(VENDOR "tizen")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "org.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(INSTALL_DIR_APPS "/usr/apps/${PKGNAME}")
+SET(INSTALL_DIR_PRE "/usr")
+
+SET(BINDIR "${PREFIX}/bin")
+SET(RESDIR "${PREFIX}/res")
+SET(DATADIR "${PREFIX}/data")
+SET(ICONDIR "${RESDIR}/icons")
+SET(DESKTOPICONDIR "${ICONDIR}/default/small")
+SET(EDJDIR "${RESDIR}/edje")
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+
+SET(GC_SECTIONS_FLAGS "-fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_SECTIONS_FLAGS}")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       elementary
+       dlog
+       evas
+       edje
+       vconf
+       ecore-x
+       ecore
+       ecore-input
+       capi-appfw-application
+       efl-assist
+       appcore-efl
+       capi-network-bluetooth
+       syspopup-caller
+       dbus-glib-1
+       utilX
+       deviced
+)
+
+FIND_LIBRARY(LIB_M m)
+
+ADD_DEFINITIONS(${pkgs_CFLAGS})
+ADD_DEFINITIONS("-fpie")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSLP_PROF")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+ADD_DEFINITIONS("-DINSTALL_DIR_APPS=\"${INSTALL_DIR_APPS}\"")
+ADD_DEFINITIONS("-DBINDIR=\"${BINDIR}\"")
+ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-pie" ${LIB_M})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+
+# install application HOME directory
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
+
+# desktop icon
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.bluetooth.png DESTINATION /usr/share/icons/default/small)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.bluetooth.xml DESTINATION /usr/share/packages)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.bluetooth.rule DESTINATION  /etc/smack/accesses2.d/)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/images/ DESTINATION /usr/apps/org.tizen.bluetooth/res/images)
diff --git a/LICENSE.Flora b/LICENSE.Flora
new file mode 100644 (file)
index 0000000..64b1c1e
--- /dev/null
@@ -0,0 +1,205 @@
+Flora License
+
+Version 1.1, April, 2013
+
+http://floralicense.org/license/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by
+the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and
+all other entities that control, are controlled by, or are
+under common control with that entity. For the purposes of
+this definition, "control" means (i) the power, direct or indirect,
+to cause the direction or management of such entity,
+whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
+or more of the outstanding shares, or (iii) beneficial ownership of
+such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity
+exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but
+not limited to compiled object code, generated documentation,
+and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice
+that is included in or attached to the work (an example is provided
+in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent,
+as a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from,
+or merely link (or bind by name) to the interfaces of, the Work and
+Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner.
+For the purposes of this definition, "submitted" means any form of
+electronic, verbal, or written communication sent to the Licensor or
+its representatives, including but not limited to communication on
+electronic mailing lists, source code control systems, and issue
+tracking systems that are managed by, or on behalf of, the Licensor
+for the purpose of discussing and improving the Work, but excluding
+communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Tizen Compliance Specification
+and passes the Tizen Compliance Tests as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+2. Grant of Copyright License.  Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the
+Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License.  Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made,
+use, offer to sell, sell, import, and otherwise transfer the Work
+solely as incorporated into a Tizen Certified Platform, where such
+license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work solely
+as incorporated into a Tizen Certified Platform to which such
+Contribution(s) was submitted. If You institute patent litigation
+against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent infringement,
+then any patent licenses granted to You under this License for that
+Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution.  You may reproduce and distribute copies of the
+Work or Derivative Works thereof pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+  1. You must give any other recipients of the Work or Derivative Works
+     a copy of this License; and
+  2. You must cause any modified files to carry prominent notices stating
+     that You changed the files; and
+  3. You must retain, in the Source form of any Derivative Works that
+     You distribute, all copyright, patent, trademark, and attribution
+     notices from the Source form of the Work, excluding those notices
+     that do not pertain to any part of the Derivative Works; and
+  4. If the Work includes a "NOTICE" text file as part of its distribution,
+     then any Derivative Works that You distribute must include a readable
+     copy of the attribution notices contained within such NOTICE file,
+     excluding those notices that do not pertain to any part of
+     the Derivative Works, in at least one of the following places:
+     within a NOTICE text file distributed as part of the Derivative Works;
+     within the Source form or documentation, if provided along with the
+     Derivative Works; or, within a display generated by the Derivative Works,
+     if and wherever such third-party notices normally appear.
+     The contents of the NOTICE file are for informational purposes only
+     and do not modify the License.
+
+You may add Your own attribution notices within Derivative Works
+that You distribute, alongside or as an addendum to the NOTICE text
+from the Work, provided that such additional attribution notices
+cannot be construed as modifying the License. You may add Your own
+copyright statement to Your modifications and may provide additional or
+different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works
+as a whole, provided Your use, reproduction, and distribution of
+the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work
+by You to the Licensor shall be under the terms and conditions of
+this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify
+the terms of any separate license agreement you may have executed
+with Licensor regarding such Contributions.
+
+6. Trademarks.  This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+agreed to in writing, Licensor provides the Work (and each
+Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied, including, without limitation, any warranties or conditions
+of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+PARTICULAR PURPOSE. You are solely responsible for determining the
+appropriateness of using or redistributing the Work and assume any
+risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise,
+unless required by applicable law (such as deliberate and grossly
+negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a
+result of this License or out of the use or inability to use the
+Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all
+other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer,
+and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only
+on Your own behalf and on Your sole responsibility, not on behalf
+of any other Contributor, and only if You agree to indemnify,
+defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following
+boilerplate notice, with the fields enclosed by brackets "[]"
+replaced with your own identifying information. (Don't include
+the brackets!) The text should be enclosed in the appropriate
+comment syntax for the file format. We also recommend that a
+file or class name and description of purpose be included on the
+same "printed page" as the copyright notice for easier
+identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Flora License, Version 1.1 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://floralicense.org/license/
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..3969942
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.1.
+Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions.
+
diff --git a/app.default.include b/app.default.include
new file mode 100644 (file)
index 0000000..ffec15d
--- /dev/null
@@ -0,0 +1,7 @@
+$1 system::homedir rwxat
+$1 system::vconf rwxat
+$1 system::media rwxat
+$1 system::share rwxat
+$1 pulseaudio rwxat
+e17 $1 w
+$1 sys-assert::core rwxat
diff --git a/images/tw_btn_delete_holo_dark.png b/images/tw_btn_delete_holo_dark.png
new file mode 100755 (executable)
index 0000000..7c3ac62
Binary files /dev/null and b/images/tw_btn_delete_holo_dark.png differ
diff --git a/images/tw_timepicker_dialbtn_minus_dim.png b/images/tw_timepicker_dialbtn_minus_dim.png
new file mode 100755 (executable)
index 0000000..17a9ba1
Binary files /dev/null and b/images/tw_timepicker_dialbtn_minus_dim.png differ
diff --git a/images/tw_timepicker_dialbtn_minus_normal.png b/images/tw_timepicker_dialbtn_minus_normal.png
new file mode 100755 (executable)
index 0000000..d7a0064
Binary files /dev/null and b/images/tw_timepicker_dialbtn_minus_normal.png differ
diff --git a/images/tw_timepicker_dialbtn_minus_pressed.png b/images/tw_timepicker_dialbtn_minus_pressed.png
new file mode 100755 (executable)
index 0000000..f915470
Binary files /dev/null and b/images/tw_timepicker_dialbtn_minus_pressed.png differ
diff --git a/include/bt-dbus-method.h b/include/bt-dbus-method.h
new file mode 100644 (file)
index 0000000..042265c
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+* ug-setting-bluetooth-efl
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           GirishAshok Joshi <girish.joshi@samsung.com>
+*           DoHyun Pyun <dh79.pyun@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_DBUS_METHOD_H__
+#define __BT_DBUS_METHOD_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-bindings.h>
+
+#define BT_ADAPTER_PATH_LEN 50
+
+#define BLUEZ_DBUS_NAME "org.bluez"
+#define MANAGER_INTERFACE "org.bluez.Manager"
+#define ADAPTER_INTERFACE "org.bluez.Adapter"
+#define HID_INTERFACE "org.bluez.Input"
+#define HEADSET_INTERFACE "org.bluez.Headset"
+#define SYNK_INTERFACE "org.bluez.AudioSink"
+#define NETWORK_INTERFACE "org.bluez.Network"
+#define NETWORK_SERVER_INTERFACE "org.bluez.NetworkServer"
+
+#define AGENT_NAME "org.projectx.bt"
+#define AGENT_PATH "/org/tizen/adapter_agent"
+#define AGENT_INTERFACE "org.bluez.Agent"
+
+#define BT_CORE_NAME "org.projectx.bt_core"
+#define BT_CORE_PATH "/org/projectx/bt_core"
+#define BT_CORE_INTERFACE "org.projectx.btcore"
+
+DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn);
+
+gboolean _bt_is_profile_connected(int connected_type,
+                               DBusGConnection *conn,
+                               unsigned char *addr);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __BT_DBUS_METHOD_H__ */
diff --git a/include/bt-handler.h b/include/bt-handler.h
new file mode 100644 (file)
index 0000000..511aa76
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_HANDLER_H__
+#define __BT_HANDLER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "bt-main.h"
+
+gboolean _bt_send_result(bt_app_data_t *ad, bool result);
+gboolean _bt_init(void *data);
+void _bt_deinit(bt_app_data_t *ad);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/bt-main-view.h b/include/bt-main-view.h
new file mode 100644 (file)
index 0000000..6f042dd
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_VIEW_H__
+#define __BT_VIEW_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "bt-main.h"
+
+#ifndef PREFIX
+#define PREFIX "/usr/apps/org.tizen.bluetooth"
+#endif
+
+#define BT_IMAGE_PATH PREFIX"/res/images"
+#define IMAGE_UNPAIR_BUTTON BT_IMAGE_PATH"/tw_btn_delete_holo_dark.png"
+
+#define BT_MAX_EVENT_STR_LENGTH         50
+#define BT_AUTO_CONNECT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
+
+void _bt_connect_device(bt_app_data_t *ad, bt_dev_t *dev);
+void _bt_disconnect_device(bt_app_data_t *ad, bt_dev_t *dev);
+void _bt_create_group_title_item(bt_app_data_t *ad, const char *group);
+void _bt_remove_group_title_item(bt_app_data_t *ad, const char *group);
+void _bt_remove_paired_device_item(bt_app_data_t *ad, bt_dev_t *dev);
+void _bt_remove_searched_device_item(bt_app_data_t *ad, bt_dev_t *dev);
+void _bt_remove_all_searched_devices_item(bt_app_data_t *ad);
+Elm_Object_Item *_bt_add_paired_device_item(bt_app_data_t *ad, bt_dev_t *dev);
+Elm_Object_Item *_bt_add_searched_device_item(bt_app_data_t *ad, bt_dev_t *dev);
+
+bt_dev_t *_bt_create_paired_device_info(void *data);
+bt_dev_t *_bt_create_searched_device_info(void *data);
+gboolean _bt_is_matched_profile(unsigned int search_type,
+                                        unsigned int major_class,
+                                        unsigned int service_class);
+bt_dev_t *_bt_get_dev_info(Eina_List *list,
+                               Elm_Object_Item *genlist_item);
+bt_dev_t *_bt_get_dev_info_by_address(Eina_List *list, char *address);
+int _bt_check_and_update_device(Eina_List *list, char *addr, char *name);
+
+Evas_Object* _bt_create_win(const char *name);
+void _bt_show_no_devices(bt_app_data_t *ad);
+void _bt_hide_no_devices(bt_app_data_t *ad);
+int _bt_initialize_view(bt_app_data_t *ad);
+void _bt_get_paired_devices(bt_app_data_t *ad);
+int _bt_get_paired_device_count(bt_app_data_t *ad);
+void _bt_update_genlist_item(Elm_Object_Item *item);
+void _bt_update_device_list(bt_app_data_t *ad);
+int _bt_check_and_update_device(Eina_List *list, char *addr, char *name);
+int _bt_check_paired_device_list(bt_app_data_t *ad);
+Evas_Object *_bt_create_list_view(bt_app_data_t *ad);
+void _bt_clean_app(bt_app_data_t *ad);
+void _bt_destroy_app(bt_app_data_t *ad);
+
+void _bt_create_autoconnect_popup(bt_dev_t *dev);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/bt-main.h b/include/bt-main.h
new file mode 100644 (file)
index 0000000..7e671d4
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_MAIN_H__
+#define __BT_MAIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <dlog.h>
+#include <app_service.h>
+#include <Elementary.h>
+#include <appcore-efl.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <app.h>
+#include <efl_assist.h>
+#include <Ecore_X.h>
+#include <bluetooth.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <utilX.h>
+
+#include "bt-type-define.h"
+
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "BLUETOOTH"
+#define DBG(format, args...) SLOGD(format, ##args)
+#define ERR(format, args...) SLOGE(format, ##args)
+#define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
+
+#define        FN_START DBG("[ENTER FUNC]");
+#define        FN_END DBG("[EXIT FUNC]");
+
+#define ret_if(expr) \
+       do { \
+               if (expr) { \
+                       return; \
+               } \
+       } while (0);
+
+#define retv_if(expr, val) \
+       do { \
+               if (expr) { \
+                       return (val); \
+               } \
+       } while (0);
+
+#define retm_if(expr, fmt, arg...) \
+       do { \
+               if (expr) { \
+                       ERR(fmt, ##arg); \
+                       return; \
+               } \
+       } while (0);
+
+
+#define retvm_if(expr, val, fmt, arg...) \
+       do { \
+               if (expr) { \
+                       ERR(fmt, ##arg); \
+                       return (val); \
+               } \
+       } while (0);
+
+
+#define DLL_DEFAULT __attribute__((visibility ("default")))
+
+#ifndef PACKAGE
+#define PACKAGE "bluetooth"
+#endif
+
+#define BT_COMMON_PKG "bt-connection-popup"
+#define LOCALEDIR "/usr/apps/org.tizen.bt-connection-popup/res/locale/"
+#define GROUP_PAIR "Pair"
+#define GROUP_SEARCH "Search"
+
+typedef struct {
+       Evas_Object *window;
+       Evas_Object *bg;
+       Evas_Object *layout_main;
+       Evas_Object *layout_btn;
+       Evas_Object *navi;
+       Evas_Object *main_genlist;
+
+       Evas_Object *popup;
+       Ecore_Timer *timer;
+       Evas_Object *scan_btn;
+
+       /* Dbus connection / proxy */
+       void *conn;
+
+       /* Request timer */
+       Ecore_Timer *request_timer;
+
+       service_h service;
+       unsigned int launch_mode;
+
+       /* Paired / Searched device list */
+       Eina_List *paired_device;
+       Eina_List *searched_device;
+
+       /* Selected device's genlist items */
+       Elm_Object_Item *paired_item;
+       Elm_Object_Item *searched_item;
+
+       /* Genlist Item class */
+       Elm_Genlist_Item_Class *paired_title_itc;
+       Elm_Genlist_Item_Class *searched_group_itc;
+       Elm_Genlist_Item_Class *searched_itc;
+       Elm_Genlist_Item_Class *searched_pairing_itc;
+       Elm_Genlist_Item_Class *device_itc;
+
+       /* Genlist Items */
+       Elm_Object_Item *navi_item;
+       Elm_Object_Item *searched_title_item;
+       Elm_Object_Item *paired_title_item;
+
+       /*************************
+       *                  Status Variables
+       ************************ */
+       bool waiting_service_response;
+       bool connect_req;
+       bool search_req;
+       bool a2dp_connected;
+       unsigned int op_status;
+       unsigned int search_type;
+
+} bt_app_data_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/bt-popup.h b/include/bt-popup.h
new file mode 100644 (file)
index 0000000..6301cf4
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_POPUP_H__
+#define __BT_POPUP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "bt-main.h"
+
+void _bt_create_disconnection_query_popup(bt_dev_t *ad);
+void _bt_create_unpair_query_popup(bt_dev_t *ad);
+void _bt_destroy_popup(bt_app_data_t *ad);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/bt-string.h b/include/bt-string.h
new file mode 100755 (executable)
index 0000000..cb9a402
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_STRING_H__
+#define __BT_STRING_H__
+
+#include "bt-main.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef N_
+#undef N_
+#endif
+#define N_(str)                        gettext_noop(str)
+
+#ifdef _
+#undef _
+#endif
+#define _(str)                 gettext(str)
+
+#define STR_SCAN _("IDS_BT_SK_SCAN")
+#define STR_STOP _("IDS_BT_SK_STOP")
+#define STR_NO_DEV _("IDS_ST_BODY_NO_NEARBY_BLUETOOTH_DEVICES_FOUND")
+#define STR_PAIRED_DEV _("IDS_BT_BODY_PAIRED_DEVICES")
+#define STR_AVAILABLE_DEV _("IDS_BT_BODY_AVAILABLE_DEVICES")
+#define STR_SCANNING _("IDS_BT_BODY_SCANNING_ING")
+#define STR_PAIRED _("IDS_BT_BODY_PAIRED")
+#define STR_PAIRING _("IDS_BT_BODY_PAIRING_ING")
+#define STR_SERVICE_SEARCHING ""
+#define STR_CONNECTED _("IDS_BT_POP_CONNECTED")
+#define STR_CONNECTING _("IDS_BT_BODY_CONNECTING")
+#define STR_DISCONNECTING _("IDS_BT_BODY_DISCONNECTING")
+#define STR_TITLE_DISCONNECT_Q _("IDS_BT_POP_DISCONNECT")
+#define STR_TITLE_UNPAIR_Q _("IDS_BT_OPT_UNPAIR")
+#define STR_DISCONNECT_DEV_Q _("IDS_WMGR_POP_THIS_WILL_END_YOUR_CONNECTION_WITH_PS")
+#define STR_AUTOCONNECT_DEV _("IDS_BT_POP_CONNECTING_TO_BLUETOOTH_STEREO_HEADSET_ING")
+#define STR_UNPAIR_DEV_Q _("IDS_ST_POP_PS_WILL_BE_UNPAIRED")
+
+/* System string */
+#define STR_OK                 _("IDS_MP_SK_OK")
+#define STR_CANCEL             _("IDS_MUSIC_SK_CANCEL")
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BT_STRING_H__ */
diff --git a/include/bt-type-define.h b/include/bt-type-define.h
new file mode 100644 (file)
index 0000000..f1d8467
--- /dev/null
@@ -0,0 +1,588 @@
+/*
+* ug-setting-bluetooth-efl
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           GirishAshok Joshi <girish.joshi@samsung.com>
+*           DoHyun Pyun <dh79.pyun@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_TYPE_DEFINE_H__
+#define __BT_TYPE_DEFINE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <glib.h>
+
+
+/**************************************************
+*                             Constant Value
+***************************************************/
+
+#define BT_GLOBALIZATION_STR_LENGTH 256
+#define BT_MAX_CHARS_IN_FTP_TITLE 12
+#define BT_MAX_MENU_NAME_LEN 64
+#define BT_MAX_SERVICE_LIST 9
+#define BT_DEVICE_NAME_LENGTH_MAX 32 /* UX guideline */
+#define BT_ADDRESS_LENGTH_MAX 6
+#define BT_ADDRESS_STR_LEN 18
+#define BT_FILE_NAME_LEN_MAX 255
+#define BT_IMG_PATH_MAX 256
+#define BT_HTML_EXTRA_TAG_LENGTH 20
+#define BT_SERVICE_NAME_LENGTH 30
+#define BT_SERVICE_CONTENT_LENGTH 256
+#define BT_PHONE_NUM_LEN 50
+#define BT_EXTRA_STR_LEN 10
+#define BT_BUFFER_LEN 256
+#define BT_TIMEOUT_MAX 3600
+#define BT_MAX_TIMEOUT_ITEMS 5
+#define BT_GLOBALIZATION_TEXT_LENGTH \
+       (BT_GLOBALIZATION_STR_LENGTH+BT_EXTRA_STR_LEN)
+#define BT_POPUP_TEXT_LENGTH \
+               ((2*BT_GLOBALIZATION_STR_LENGTH)+BT_DEVICE_NAME_LENGTH_MAX)
+#define BT_SERVICE_TEXT_LENGTH \
+       (BT_SERVICE_CONTENT_LENGTH+BT_HTML_EXTRA_TAG_LENGTH)* \
+       BT_MAX_SERVICE_LIST
+#define BT_UG_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
+
+/* Timeout Value */
+#define BT_SEARCH_SERVICE_TIMEOUT 5
+#define BT_SELECTED_TIMEOUT 5
+#define BT_DELETED_TIMEOUT 2
+#define BT_VISIBILITY_TIMEOUT  1000
+#define BT_HELP_TIMEOUT        3000
+
+/* Define Error type */
+#define BT_APP_FAIL -1
+#define BT_APP_ERROR_NONE 0
+
+#define BT_TWO_MINUTES 120
+#define BT_FIVE_MINUTES 300
+#define BT_ONE_HOUR 3600
+#define BT_ZERO 0
+#define BT_ALWAYS_ON -1
+
+#define BT_RESULT_STR_MAX 256
+
+#define BT_GENLIST_FONT_32_INC 32
+
+/**************************************************
+*                              String define
+***************************************************/
+
+#define BT_SET_FONT_SIZE \
+"<font_size=%d>%s</font_size>"
+
+#define BT_SET_FONT_SIZE_COLOR \
+"<font_size=%d><color=%s>%s</color></font_size>"
+
+/* GENLIST_TEXT_COLOR_LIST_SUB_TEXT_SETTINGS 42 137 194 255 */
+#define BT_GENLIST_SUBTEXT_COLOR "#2A89C2FF"
+#define BT_GENLIST_WHITE_SUBTEXT_COLOR "#FFFFFFFF"
+
+#define BT_RESULT_SUCCESS "success"
+#define BT_RESULT_FAIL "fail"
+
+#define BT_DEFAULT_PHONE_NAME "Fraser"
+
+#define BT_SYSPOPUP_REQUEST_NAME "app-confirm-request"
+#define BT_SYSPOPUP_TWO_BUTTON_TYPE "twobtn"
+#define BT_SYSPOPUP_ONE_BUTTON_TYPE "onebtn"
+
+#define BT_VCONF_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
+
+/* AppControl Operation */
+#define BT_APPCONTROL_PICK_OPERATION "http://tizen.org/appcontrol/operation/bluetooth/pick"
+
+#define BT_APPCONTROL_VISIBILITY_OPERATION "http://tizen.org/appcontrol/operation/configure/bluetooth/visibility"
+
+/* AppControl Output */
+#define BT_APPCONTROL_ADDRESS "http://tizen.org/appcontrol/data/bluetooth/address"
+#define BT_APPCONTROL_NAME "http://tizen.org/appcontrol/data/bluetooth/name"
+#define BT_APPCONTROL_RSSI "http://tizen.org/appcontrol/data/bluetooth/rssi"
+#define BT_APPCONTROL_IS_PAIRED "http://tizen.org/appcontrol/data/bluetooth/is_paired"
+#define BT_APPCONTROL_MAJOR_CLASS "http://tizen.org/appcontrol/data/bluetooth/major_class"
+#define BT_APPCONTROL_MINOR_CLASS "http://tizen.org/appcontrol/data/bluetooth/minor_class"
+#define BT_APPCONTROL_SERVICE_CLASS "http://tizen.org/appcontrol/data/bluetooth/service_class"
+#define BT_APPCONTROL_SERVICE_TYPE "http://tizen.org/appcontrol/data/bluetooth/service_type"
+#define BT_APPCONTROL_UUID_LIST "http://tizen.org/appcontrol/data/bluetooth/uuid_list"
+#define BT_APPCONTROL_VISIBILITY "http://tizen.org/appcontrol/data/bluetooth/visibility"
+
+/* Access information */
+#define BT_STR_ACCES_INFO_MAX_LEN 512
+#define BT_STR_ACC_ICON "Icon"
+
+/**************************************************
+*                                  Enum type
+***************************************************/
+
+typedef enum {
+       BT_CONNECTION_REQ,
+       BT_PAIRING_REQ,
+       BT_NONE_REQ,
+} bt_confirm_req_t;
+
+/* Visible timout value (sec)*/
+typedef enum {
+       BT_2MIN = 120,
+       BT_5MIN = 300,
+       BT_1HOUR = 3600,
+       BT_NO_TIMEOUT = 0,
+} bt_visible_time_t;
+
+typedef enum {
+       BT_VISIBLE_OFF = 0,
+       BT_VISIBLE_ALWAYS = 1,
+       BT_VISIBLE_TIME_LIMITED = 2,
+} bt_visible_result_t;
+
+typedef enum {
+       BT_SEARCH_ALL_DEVICE = 0,
+       BT_SEARCH_PHONE,
+       BT_SEARCH_HEADSET,
+       BT_SEARCH_PC,
+       BT_SEARCH_HID,
+} bt_search_option_t;
+
+typedef enum {
+       BT_CONNECT_MENU = 1,
+       BT_SEND_MENU,
+       BT_RENAME_MENU,
+       BT_DELETE_MENU,
+       BT_SERVICE_LIST_MENU,
+} bt_menu_index_t;
+
+typedef enum {
+       BT_PAIRED_DEVICE_DISABLE,
+       BT_PAIRED_DEVICE_ENABLE,
+} bt_app_paired_device_status_t;
+
+typedef enum {
+       BT_STATUS_OFF         = 0x0000,
+       BT_STATUS_ON          = 0x0001,
+       BT_STATUS_BT_VISIBLE  = 0x0002,
+       BT_STATUS_TRANSFER    = 0x0004,
+} bt_status_t;
+
+typedef enum {
+       BT_LAUNCH_NORMAL = 0x00,
+       BT_LAUNCH_SEND_FILE = 0x01,
+       BT_LAUNCH_PRINT_IMAGE = 0x02,
+       BT_LAUNCH_CONNECT_HEADSET = 0x03,
+       BT_LAUNCH_USE_NFC = 0x04,
+       BT_LAUNCH_PICK = 0x05,
+       BT_LAUNCH_VISIBILITY = 0x06,
+       BT_LAUNCH_SHARE_CONTACT = 0x07,
+       BT_LAUNCH_HELP = 0x08,
+       BT_LAUNCH_SETTING = 0x09,
+       BT_LAUNCH_SPP = 0x0A,
+} bt_launch_mode_t;
+
+typedef enum {
+       BT_HELP_VIEW_NONE = 0x00,
+       BT_HELP_VIEW_1 = 0x01,
+       BT_HELP_VIEW_2 = 0x02,
+       BT_HELP_VIEW_3 = 0x03,
+       BT_HELP_VIEW_4 = 0x04,
+} bt_help_view_t;
+
+typedef enum {
+       BT_CONTROL_BAR_DISABLE,
+       BT_CONTROL_BAR_ENABLE,
+} bt_control_bar_status_t;
+
+typedef enum {
+       BT_NOCONTENT_HIDE,
+       BT_NOCONTNET_SHOW,
+} bt_nocontent_mode_t;
+
+typedef enum {
+       BT_STORE_BOOLEAN,
+       BT_STORE_INT,
+       BT_STORE_STRING,
+} bt_store_type_t;
+
+typedef enum {
+       BT_ROTATE_PORTRAIT = 0,
+       BT_ROTATE_LANDSCAPE,
+       BT_ROTATE_PORTRAIT_UPSIDEDOWN,
+       BT_ROTATE_LANDSCAPE_UPSIDEDOWN,
+} bt_rotate_mode_t;
+
+typedef enum {
+       BT_ACTIVATED = 0,
+       BT_ACTIVATING,
+       BT_DEACTIVATED,
+       BT_DEACTIVATING,
+       BT_SEARCHING,
+       BT_PAIRING,
+       BT_UNPAIRING
+} bt_oper_t;
+
+typedef enum {
+       BT_UG_CREATE = 0,
+       BT_UG_START,
+       BT_UG_PAUSE,
+       BT_UG_RESUME,
+       BT_UG_DESTORY
+} bt_ug_status_t;
+
+
+typedef enum {
+       BT_IDLE = 0,
+       BT_DEV_PAIRING,
+       BT_CONNECTING,
+       BT_DISCONNECTING,
+       BT_SERVICE_SEARCHING
+} bt_dev_status_t;
+
+typedef enum {
+       BT_RUN_STATUS_NO_CHANGE = 0x00, /* No Change BT status*/
+       BT_RUN_STATUS_ACTIVATE = 0x01,  /* BT Activate*/
+       BT_RUN_STATUS_DEACTIVATE = 0x02,        /* BT Deactivate*/
+       BT_RUN_STATUS_SEARCH_TEST = 0x03,       /* BT Search Test*/
+       BT_RUN_STATUS_TERMINATE = 0x04, /* BT Terminate*/
+       BT_RUN_STATUS_MAX = 0x05,               /* Max val*/
+} bt_run_status_t;
+
+typedef enum {
+       BT_ON_CURRENTVIEW = 0x00,       /* Run BT on current view*/
+       BT_ON_FOREGROUND = 0x01,        /* Run BT on foreground*/
+       BT_ON_BACKGROUND = 0x02,        /* Run BT on background*/
+} bt_on_t;
+
+typedef enum {
+       BT_HEADSET_CONNECTED = 0x01,
+       BT_STEREO_HEADSET_CONNECTED = 0x02,
+       BT_HID_CONNECTED = 0x04,
+       BT_NETWORK_CONNECTED = 0x08,
+       BT_NETWORK_SERVER_CONNECTED = 0x10,
+} bt_connected_mask_t;
+
+/**
+ * This enum indicates  Device states.
+ */
+
+typedef enum {
+       BT_DEVICE_NONE,        /** < None*/
+       BT_DEVICE_PAIRED,     /** < Device Paired*/
+       BT_DEVICE_CONNECTED/** <Device Connected*/
+} bt_device_state_t;
+
+typedef enum {
+       BT_ITEM_NO_TYPE,
+       BT_ITEM_TOP,
+       BT_ITEM_CENTER,
+       BT_ITEM_BOTTOM,
+} bt_item_type_t;
+
+typedef enum {
+       BT_ITEM_NONE,
+       BT_ITEM_NAME,
+       BT_ITEM_UNPAIR,
+       BT_ITEM_CALL,
+       BT_ITEM_MEDIA,
+       BT_ITEM_HID,
+       BT_ITEM_NETWORK,
+} bt_profile_view_item_type_t;
+
+typedef enum {
+       BT_DEVICE_MAJOR_MASK_MISC = 0x00,
+       BT_DEVICE_MAJOR_MASK_COMPUTER = 0x0001,
+       BT_DEVICE_MAJOR_MASK_PHONE = 0x0002,
+       BT_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004,
+       BT_DEVICE_MAJOR_MASK_AUDIO = 0x0008,
+       BT_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010,
+       BT_DEVICE_MAJOR_MASK_IMAGING = 0x0020,
+       BT_DEVICE_MAJOR_MASK_WEARABLE = 0x0040,
+       BT_DEVICE_MAJOR_MASK_TOY = 0x0080,
+       BT_DEVICE_MAJOR_MASK_HEALTH = 0x0100,
+} bt_device_major_mask_t;
+
+
+/**
+ * This enum indicates Service class Type.
+ */
+typedef enum {
+       BT_SC_NONE = 0,
+       BT_SC_RES_SERVICE_MASK = 0x00000001,
+       BT_SC_SPP_SERVICE_MASK = 0x00000002,
+       BT_SC_DUN_SERVICE_MASK = 0x00000004,
+       BT_SC_FAX_SERVICE_MASK = 0x00000008,
+       BT_SC_LAP_SERVICE_MASK = 0x00000010,
+       BT_SC_HSP_SERVICE_MASK = 0x00000020,
+       BT_SC_HFP_SERVICE_MASK = 0x00000040,
+       BT_SC_OPP_SERVICE_MASK = 0x00000080,
+       BT_SC_FTP_SERVICE_MASK = 0x00000100,
+       BT_SC_CTP_SERVICE_MASK = 0x00000200,
+       BT_SC_ICP_SERVICE_MASK = 0x00000400,
+       BT_SC_SYNC_SERVICE_MASK = 0x00000800,
+       BT_SC_BPP_SERVICE_MASK = 0x00001000,
+       BT_SC_BIP_SERVICE_MASK = 0x00002000,
+       BT_SC_PANU_SERVICE_MASK = 0x00004000,
+       BT_SC_NAP_SERVICE_MASK = 0x00008000,
+       BT_SC_GN_SERVICE_MASK = 0x00010000,
+       BT_SC_SAP_SERVICE_MASK = 0x00020000,
+       BT_SC_A2DP_SERVICE_MASK = 0x00040000,
+       BT_SC_AVRCP_SERVICE_MASK = 0x00080000,
+       BT_SC_PBAP_SERVICE_MASK = 0x00100000,
+       BT_SC_HID_SERVICE_MASK = 0x00200000,
+       BT_SC_ALL_SERVICE_MASK = 0x00FFFFFF,
+       BT_SC_MAX
+} bt_service_class_t;
+
+/*
+ * Major device class (part of Class of Device)
+ */
+typedef enum {
+       BT_MAJOR_DEV_CLS_MISC = 0x00,/**<miscellaneous */
+       BT_MAJOR_DEV_CLS_COMPUTER = 0x01, /**<Computer */
+       BT_MAJOR_DEV_CLS_PHONE = 0x02, /**<Phone */
+       BT_MAJOR_DEV_CLS_LAN_ACCESS_POINT = 0x03,/**<LAN access point */
+       BT_MAJOR_DEV_CLS_AUDIO = 0x04,/**<AudioDevice */
+       BT_MAJOR_DEV_CLS_PERIPHERAL = 0x05,/**<Peripheral Device  */
+       BT_MAJOR_DEV_CLS_IMAGING = 0x06,/**<Imaging Device */
+       BT_MAJOR_DEV_CLS_WEARABLE = 0x07,/**<Wearable Device */
+       BT_MAJOR_DEV_CLS_TOY = 0x08,/**<Toy Device */
+       BT_MAJOR_DEV_CLS_HEALTH = 0x09,/**<Health Device */
+       BT_MAJOR_DEV_CLS_UNCLASSIFIED = 0x1F/**<Unclassified device  */
+} bt_major_class_t;
+
+/*
+ * Minoor device class (part of Class of Device)
+ */
+typedef enum {
+       BTAPP_MIN_DEV_CLS_UNCLASSIFIED = 0x00,
+       BTAPP_MIN_DEV_CLS_DESKTOP_WORKSTATION = 0x04,
+       BTAPP_MIN_DEV_CLS_SERVER_CLASS_COMPUTER = 0x08,
+       BTAPP_MIN_DEV_CLS_LAPTOP = 0x0C,
+       BTAPP_MIN_DEV_CLS_HANDHELD_PC_OR_PDA = 0x10,
+       BTAPP_MIN_DEV_CLS_PALM_SIZED_PC_OR_PDA = 0x14,
+       BTAPP_MIN_DEV_CLS_WEARABLE_COMPUTER = 0x18,
+
+       BTAPP_MIN_DEV_CLS_CELLULAR = 0x04,
+       BTAPP_MIN_DEV_CLS_CORDLESS = 0x08,
+       BTAPP_MIN_DEV_CLS_SMART_PHONE = 0x0C,
+       BTAPP_MIN_DEV_CLS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
+       BTAPP_MIN_DEV_CLS_COMMON_ISDN_ACCESS = 0x14,
+       BTAPP_MIN_DEV_CLS_SIM_CARD_READER = 0x18,
+       BTAPP_MID_DEV_CLS_PRINTER = 0x80,
+
+       BTAPP_MIN_DEV_CLS_FULLY_AVAILABLE = 0x04,
+       BTAPP_MIN_DEV_CLS_1_TO_17_PERCENT_UTILIZED = 0x20,
+       BTAPP_MIN_DEV_CLS_17_TO_33_PERCENT_UTILIZED = 0x40,
+       BTAPP_MIN_DEV_CLS_33_TO_50_PERCENT_UTILIZED = 0x60,
+       BTAPP_MIN_DEV_CLS_50_to_67_PERCENT_UTILIZED = 0x80,
+       BTAPP_MIN_DEV_CLS_67_TO_83_PERCENT_UTILIZED = 0xA0,
+       BTAPP_MIN_DEV_CLS_83_TO_99_PERCENT_UTILIZED = 0xC0,
+       BTAPP_MIN_DEV_CLS_NO_SERVICE_AVAILABLE = 0xE0,
+
+       BTAPP_MIN_DEV_CLS_HEADSET_PROFILE = 0x04,
+       BTAPP_MIN_DEV_CLS_HANDSFREE = 0x08,
+       BTAPP_MIN_DEV_CLS_MICROPHONE = 0x10,
+       BTAPP_MIN_DEV_CLS_LOUD_SPEAKER = 0x14,
+       BTAPP_MIN_DEV_CLS_HEADPHONES = 0x18,
+       BTAPP_MIN_DEV_CLS_PORTABLE_AUDIO = 0x1C,
+       BTAPP_MIN_DEV_CLS_CAR_AUDIO = 0x20,
+       BTAPP_MIN_DEV_CLS_SET_TOP_BOX = 0x24,
+       BTAPP_MIN_DEV_CLS_HIFI_AUDIO_DEVICE = 0x28,
+       BTAPP_MIN_DEV_CLS_VCR = 0x2C,
+       BTAPP_MIN_DEV_CLS_VIDEO_CAMERA = 0x30,
+       BTAPP_MIN_DEV_CLS_CAM_CORDER = 0x34,
+       BTAPP_MIN_DEV_CLS_VIDEO_MONITOR = 0x38,
+       BTAPP_MIN_DEV_CLS_VIDEO_DISPLAY_AND_LOUD_SPEAKER = 0x3C,
+       BTAPP_MIN_DEV_CLS_VIDEO_CONFERENCING = 0x40,
+       BTAPP_MIN_DEV_CLS_GAMING_OR_TOY = 0x48,
+
+       BTAPP_MIN_DEV_CLS_KEY_BOARD = 0x40,
+       BTAPP_MIN_DEV_CLS_POINTING_DEVICE = 0x80,
+       BTAPP_MIN_DEV_CLS_COMBO_KEYBOARD_OR_POINTING_DEVICE = 0xC0,
+
+       BTAPP_MIN_DEV_CLS_JOYSTICK = 0x04,
+       BTAPP_MIN_DEV_CLS_GAME_PAD = 0x08,
+       BTAPP_MIN_DEV_CLS_REMOTE_CONTROL = 0x0C,
+       BTAPP_MIN_DEV_CLS_SENSING_DEVICE = 0x10,
+       BTAPP_MIN_DEV_CLS_DIGITIZER_TABLET = 0x14,
+       BTAPP_MIN_DEV_CLS_CARD_READER = 0x18,
+
+       BTAPP_MIN_DEV_CLS_DISPLAY = 0x10,
+       BTAPP_MIN_DEV_CLS_CAMERA = 0x20,
+       BTAPP_MIN_DEV_CLS_SCANNER = 0x40,
+       BTAPP_MIN_DEV_CLS_PRINTER = 0x80,
+
+       BTAPP_MIN_DEV_CLS_WRIST_WATCH = 0x04,
+       BTAPP_MIN_DEV_CLS_PAGER = 0x08,
+       BTAPP_MIN_DEV_CLS_JACKET = 0x0C,
+       BTAPP_MIN_DEV_CLS_HELMET = 0x10,
+       BTAPP_MIN_DEV_CLS_GLASSES = 0x14,
+
+       BTAPP_MIN_DEV_CLS_ROBOT = 0x04,
+       BTAPP_MIN_DEV_CLS_VEHICLE = 0x08,
+       BTAPP_MIN_DEV_CLS_DOLL_OR_ACTION = 0x0C,
+       BTAPP_MIN_DEV_CLS_CONTROLLER = 0x10,
+       BTAPP_MIN_DEV_CLS_GAME = 0x14,
+
+       BTAPP_MIN_DEV_CLS_BLOOD_PRESSURE_MONITOR = 0x04,
+       BTAPP_MIN_DEV_CLS_THERMOMETER = 0x08,
+       BTAPP_MIN_DEV_CLS_WEIGHING_SCALE = 0x0C,
+       BTAPP_MIN_DEV_CLS_GLUCOSE_METER = 0x10,
+       BTAPP_MIN_DEV_CLS_PULSE_OXIMETER = 0x14,
+       BTAPP_MIN_DEV_CLS_HEART_OR_PULSE_RATE_MONITOR = 0x18,
+       BTAPP_MIN_DEV_CLS_MEDICAL_DATA_DISPLAY = 0x1C,
+} bt_minor_class_t;
+
+
+/*
+ * Service class part of class of device returned from device discovery
+ */
+
+/**
+  * This enum indicates  Service calls part  of device returned from device discovery.
+  */
+typedef enum {
+       BT_COD_SC_ALL = 0x000000, /**< ALL*/
+       BT_COD_SC_LIMITED_DISCOVERABLE_MODE = 0x002000,
+       BT_COD_SC_POSITIONING = 0x010000,/**< POSITIONING*/
+       BT_COD_SC_NETWORKING = 0x020000,/**< NETWORKING*/
+       BT_COD_SC_RENDERING = 0x040000,/**< RENDERING*/
+       BT_COD_SC_CAPTURING = 0x080000,/**< CAPTURING*/
+       BT_COD_SC_OBJECT_TRANSFER = 0x100000,/**< OBJECT_TRANSFER*/
+       BT_COD_SC_AUDIO = 0x200000,/**< AUDIO*/
+       BT_COD_SC_TELEPHONY = 0x400000,/**< TELEPHONY*/
+       BT_COD_SC_INFORMATION = 0x800000,/**< INFORMATION*/
+       BT_COD_SC_UNKNOWN = 0x1FF000/**< UNKNOWN */
+} bt_cod_service_class_t;
+
+typedef enum {
+       BT_SPP_PROFILE_UUID = ((unsigned short)0x1101),                 /**<SPP*/
+       BT_LAP_PROFILE_UUID = ((unsigned short)0x1102),                 /**<LAP*/
+       BT_DUN_PROFILE_UUID = ((unsigned short)0x1103),                 /**<DUN*/
+       BT_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104),     /**<OBEX IR MC SYNC*/
+       BT_OBEX_OBJECT_PUSH_SERVICE_UUID = ((unsigned short)0x1105),    /**<OPP*/
+       BT_OBEX_FILE_TRANSFER_UUID = ((unsigned short)0x1106),          /**<FTP*/
+       BT_IRMC_SYNC_COMMAND_UUID = ((unsigned short)0x1107),           /**<IRMC SYNC COMMAND*/
+       BT_HS_PROFILE_UUID = ((unsigned short)0x1108),                  /**<HS*/
+       BT_CTP_PROFILE_UUID = ((unsigned short)0x1109),                 /**<CTP*/
+       BT_AUDIO_SOURCE_UUID = ((unsigned short)0x110A),                        /**<AUDIO SOURCE*/
+       BT_AUDIO_SINK_UUID = ((unsigned short)0x110B),                  /**<AUDIO SINK*/
+       BT_AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C),    /**<AV REMOTE CONTROL
+                                                                               TARGET*/
+       BT_ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D),      /**<A2DP*/
+       BT_AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E),           /**<AV REMOTE CONTROL UUID*/
+       BT_AV_REMOTE_CONTROL_CONTROLLER_UUID = ((unsigned short)0x110F),        /**<AV REMOTE CONTROLLER UUID*/
+       BT_ICP_PROFILE_UUID = ((unsigned short)0x1110),                 /**<ICP*/
+       BT_FAX_PROFILE_UUID = ((unsigned short)0x1111),                 /**<FAX*/
+       BT_HEADSET_AG_SERVICE_UUID = ((unsigned short)0x1112),          /**<HS AG */
+       BT_PAN_PANU_PROFILE_UUID = ((unsigned short)0x1115),            /**<PAN*/
+       BT_PAN_NAP_PROFILE_UUID = ((unsigned short)0x1116),             /**<PAN*/
+       BT_PAN_GN_PROFILE_UUID = ((unsigned short)0x1117),              /**<PAN*/
+       BT_DIRECT_PRINTING = ((unsigned short)0x1118),
+       BT_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118),           /**<OBEX BPPS*/ /* Will be removed */
+       BT_REFERENCE_PRINTING = ((unsigned short)0x1119),
+       BT_OBEX_IMAGING_UUID = ((unsigned short)0x111A),                        /**<OBEX_IMAGING*/
+       BT_OBEX_IMAGING_RESPONDER_UUID = ((unsigned short)0x111B),      /**<OBEX_IMAGING
+                                                                               RESPONDER*/
+       BT_IMAGING_AUTOMATIC_ARCHIVE_UUID = ((unsigned short)0x111C),   /**<IMAGING AUTOMATIC ARCHIVE*/
+       BT_IMAGING_REFERENCED_OBJECTS_UUID = ((unsigned short)0x111D),  /**<IMAGING REFERENCED OBJECTS*/
+       BT_HF_PROFILE_UUID = ((unsigned short)0x111E),                  /**<HF*/
+       BT_HFG_PROFILE_UUID = ((unsigned short)0x111F),                 /**<HFG*/
+       BT_DIRECT_PRINTING_REFERENCE_OBJ_UUID = ((unsigned short)0x1120),
+                                                                       /**<DIRECT PRINTING*/
+       BT_REFLECTED_UI = ((unsigned short)0x1121),             /**<REFLECTED UI*/
+       BT_BASIC_PRINTING = ((unsigned short)0x1122),           /**<BASIC PRINTING*/
+       BT_PRINTING_STATUS = ((unsigned short)0x1123),          /**<PRINTING  STATUS*/
+       BT_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123),        /**<OBEX PRINTING STATUS*/ /* Will be removed */
+       BT_HID_PROFILE_UUID = ((unsigned short)0x1124),         /**<HID*/
+       BT_HCR_PROFILE_UUID = ((unsigned short)0x1125),         /**<HCRP*/
+       BT_HCR_PRINT_UUID = ((unsigned short)0x1126),           /**<HCR PRINT*/
+       BT_HCR_SCAN_UUID = ((unsigned short)0x1127),            /**<HCR SCAN*/
+       BT_SIM_ACCESS_PROFILE_UUID = ((unsigned short)0x112D),  /**<SIM ACCESS PROFILE*/
+       BT_PBAP_PCE_UUID = ((unsigned short)0x112E),            /**<PBAP - PCE*/
+       BT_PBAP_PSE_UUID = ((unsigned short)0x112F),            /**<OBEX PBA*/
+       BT_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F),    /**<OBEX PBA*/ /* Will be removed */
+       BT_OBEX_PBAP_UUID = ((unsigned short)0x1130),           /**<OBEX PBA*/
+       BT_HEADSET_HS_UUID = ((unsigned short)0x1131),          /**<HEADSET HS*/
+       BT_MESSAGE_ACCESS_SERVER_UUID = ((unsigned short)0x1132),/**<MESSAGE ACCESS SERVER*/
+       BT_MESSAGE_NOTIFICATION_SERVER_UUID = ((unsigned short)0x1133),/**<MESSAGE NOTIFICATION SERVER*/
+       BT_MESSAGE_ACCESS_PROFILE_UUID = ((unsigned short)0x1134),/**<MESSAGE ACCESS PROFILE*/
+       BT_PNP_INFORMATION_UUID = ((unsigned short)0x1200),     /**<PNP*/
+       BT_GENERIC_NETWORKING_UUID = ((unsigned short)0x1201),  /**<GENERIC NETWORKING*/
+       BT_GENERIC_FILE_TRANSFER_UUID = ((unsigned short)0x1202),/**<GENERIC FILE TRANSFER*/
+       BT_GENERIC_AUDIO_UUID = ((unsigned short)0x1203),       /**<GENERIC AUDIO*/
+       BT_GENERIC_TELEPHONY_UUID = ((unsigned short)0x1204),   /**<GENERIC TELEPHONY*/
+       BT_VIDEO_SOURCE_UUID = ((unsigned short)0x1303),        /**<VEDIO SOURCE*/
+       BT_VIDEO_SINK_UUID = ((unsigned short)0x1304),          /**<VEDIO SINK*/
+       BT_VIDEO_DISTRIBUTION_UUID = ((unsigned short)0x1305),  /**<VEDIO DISTRIBUTION*/
+       BT_HDP_UUID = ((unsigned short)0x1400),                 /**<HDP*/
+       BT_HDP_SOURCE_UUID = ((unsigned short)0x1401),          /**<HDP SOURCE*/
+       BT_HDP_SINK_UUID = ((unsigned short)0x1402),            /**<HDP SINK*/
+       BT_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000) /**<OBEX_SYNC*/ /* Will be removed */
+} bluetooth_service_uuid_list_t;
+
+
+/**************************************************
+*                             Struct define
+***************************************************/
+
+typedef struct {
+       unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
+       char addr_str[BT_ADDRESS_STR_LEN + 1];
+       char name[BT_DEVICE_NAME_LENGTH_MAX + 1];/**<  Device Name */
+       bt_service_class_t service_list;  /**< type of service */
+       bt_major_class_t major_class; /**< major class of the device */
+       bt_minor_class_t minor_class; /**< minor class of the device */
+       int authorized;    /**< authorized ? */
+       bt_cod_service_class_t service_class; /**< service class of device */
+       int rssi;        /**< Received signal strength indicator */
+       int connected_mask;
+       int status;
+       int item_type;
+       int uuid_count;
+       char **uuids;
+       void *layout;
+       void *entry;
+       void *genlist_item;
+       void *net_profile;
+       gboolean is_bonded;
+       gboolean call_checked;
+       gboolean media_checked;
+       gboolean hid_checked;
+       gboolean network_checked;
+       gboolean highlighted;
+       void *ad;
+} bt_dev_t;
+
+typedef struct {
+       unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
+} bt_address_t;
+
+
+/**************************************************
+*                              Callback type
+***************************************************/
+
+typedef void (*bt_app_back_cb)(void *, void *, void *);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BT_TYPE_DEFINE_H__ */
diff --git a/include/bt-util.h b/include/bt-util.h
new file mode 100644 (file)
index 0000000..ce978c6
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+* ug-setting-bluetooth-efl
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           GirishAshok Joshi <girish.joshi@samsung.com>
+*           DoHyun Pyun <dh79.pyun@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#ifndef __BT_UTIL_H__
+#define __BT_UTIL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <bundle.h>
+#include <Elementary.h>
+
+#include "bt-type-define.h"
+
+/* Major Device Mask */
+#define MISCELLANEOUS_MAJOR_DEVICE_MASK (0x000000)
+#define COMPUTER_MAJOR_DEVICE_MASK (0x000100)
+#define PHONE_MAJOR_DEVICE_MASK (0x000200)
+#define LAN_MAJOR_DEVICE_MASK (0x000300)
+#define AV_MAJOR_DEVICE_MASK (0x000400)
+#define PERIPHERAL_MAJOR_DEVICE_MASK (0x000500)
+#define IMAGING_MAJOR_DEVICE_MASK (0x000600)
+#define WEARABLE_MAJOR_DEVICE_MASK (0x000700)
+#define TOY_MAJOR_DEVICE_MASK (0x000800)
+#define UNCLASSIFIED_MAJOR_DEVICE_MASK (0x001F00)
+#define OBJECT_TRANSFER_MAJOR_SERVICE_MASK (0x100000)
+
+
+void _bt_lock_display(void);
+
+void _bt_unlock_display(void);
+
+
+gboolean _bt_util_get_service_mask_from_uuid_list(char **uuids,
+                                             int no_of_service,
+                                     bt_service_class_t *service_mask_list);
+
+gboolean _bt_util_update_class_of_device_by_service_list(bt_service_class_t service_list,
+                                                bt_major_class_t *major_class,
+                                                bt_minor_class_t *minor_class);
+
+void _bt_util_set_value(const char *req, unsigned int *search_type,
+                       unsigned int *op_mode);
+
+gboolean _bt_util_store_get_value(const char *key,
+                             bt_store_type_t store_type,
+                             unsigned int size, void *value);
+
+void _bt_util_launch_no_event(void *data, void *obj, void *event);
+
+void _bt_util_set_list_disabled(Evas_Object *genlist, Eina_Bool disable);
+
+void _bt_util_set_phone_name(void);
+
+int _bt_util_get_phone_name(char *phone_name, int size);
+
+char * _bt_util_get_timeout_string(int timeout);
+
+int _bt_util_get_timeout_value(int index);
+
+int _bt_util_get_timeout_index(int timeout);
+
+gboolean _bt_util_is_battery_low(void);
+
+gboolean _bt_util_is_flight_mode(void);
+
+void _bt_util_addr_type_to_addr_string(char *address,
+                                              unsigned char *addr);
+
+void _bt_util_addr_type_to_addr_result_string(char *address,
+                                              unsigned char *addr);
+
+void _bt_util_addr_type_to_addr_net_string(char *address,
+                                              unsigned char *addr);
+
+void _bt_util_addr_string_to_addr_type(unsigned char *addr,
+                                                 const char *address);
+
+void _bt_util_convert_time_to_string(unsigned int remain_time,
+                                       char *buf, int size);
+
+void _bt_util_free_device_uuids(bt_dev_t *item);
+
+void _bt_util_free_device_item(bt_dev_t *item);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __BT_UTIL_H__ */
diff --git a/org.tizen.bluetooth.manifest b/org.tizen.bluetooth.manifest
new file mode 100644 (file)
index 0000000..a1b4bd4
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest>
+       <define>
+               <domain name="org.tizen.bluetooth" />
+       <request>
+               <smack request="aul::launch" type="x"/>
+               <smack request="syspopup::db" type="rwx"/>
+       </request>
+       </define>
+       <assign>
+               <filesystem path="/usr/share/locale/*" label="_" />
+       </assign>
+</manifest>
diff --git a/org.tizen.bluetooth.rule b/org.tizen.bluetooth.rule
new file mode 100644 (file)
index 0000000..8043d03
--- /dev/null
@@ -0,0 +1,20 @@
+#default include
+org.tizen.bluetooth app.default include
+
+org.tizen.bluetooth org.tizen.indicator rw
+org.tizen.bluetooth sound_server rw
+org.tizen.bluetooth dbus r
+org.tizen.bluetooth org.tizen.clock rx
+org.tizen.bluetooth ail::db rw
+org.tizen.bluetooth sound_server r
+org.tizen.bluetooth svi-data rx
+org.tizen.bluetooth xorg rw
+org.tizen.bluetooth system::use_internet r
+org.tizen.bluetooth syspopup::db rl
+org.tizen.bluetooth isf rwx
+org.tizen.bluetooth immvibed rw
+org.tizen.bluetooth tts-server rx
+org.tizen.app-tray org.tizen.bluetooth rx
+org.tizen.bluetooth org.tizen.setting::system r
+org.tizen.bluetooth org.tizen.bt-connection-popup x
+org.tizen.bluetooth org.tizen.clocksetting rw
diff --git a/org.tizen.bluetooth.xml b/org.tizen.bluetooth.xml
new file mode 100644 (file)
index 0000000..26705ed
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.bluetooth" version="0.0.1" install-location="internal-only">
+       <label>W bluetooth</label>
+       <author email="ty-ace.lee@samsung.com" href="www.samsung.com">Taeyang Lee</author>
+       <description>W bluetooth</description>
+       <ui-application appid="org.tizen.bluetooth" exec="/usr/apps/org.tizen.bluetooth/bin/bluetooth" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+               <icon></icon>
+               <label>BT Connection Popup</label>
+               <label xml:lang="en-us">BT Connection Popup</label>
+       </ui-application>
+</manifest>
diff --git a/packaging/org.tizen.bluetooth.spec b/packaging/org.tizen.bluetooth.spec
new file mode 100644 (file)
index 0000000..d161c4a
--- /dev/null
@@ -0,0 +1,75 @@
+%define PREFIX /usr/apps/org.tizen.bluetooth
+Name: org.tizen.bluetooth
+Version:    0.0.20
+Release:    0
+Summary: Tizen W BT connect error application
+URL: http://slp-source.sec.samsung.net
+Source: %{name}-%{version}.tar.gz
+License: Flora Software License, Version 1.1
+Group: Samsung/Application
+
+BuildRequires: cmake
+BuildRequires: gettext-tools
+BuildRequires: efl-assist-devel
+BuildRequires: pkgconfig(embryo)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(appcore-common)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(syspopup-caller)
+BuildRequires: pkgconfig(capi-network-bluetooth)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(utilX)
+BuildRequires: pkgconfig(deviced)
+#BUildRequires: pkgconfig()
+
+BuildRequires: efl-assist-devel
+BuildRequires: embryo-bin
+
+%description
+W bt connect error popup application
+
+%prep
+%setup -q
+
+%build
+export CFLAGS="${CFLAGS} -fPIC -fvisibility=hidden"
+#CFLAGS+=" -fvisibility=hidden"; export CFLAGS
+CXXFLAGS+=" -fvisibility=hidden"; export CXXFLAGS
+FFLAGS+=" -fvisibility=hidden"; export FFLAGS
+
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS+=" -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE"
+export FFLAGS+=" -DTIZEN_ENGINEER_MODE"
+%endif
+
+LDFLAGS+="-Wl,--rpath=%{PREFIX}/lib -Wl,--as-needed -Wl,--hash-style=both"; export LDFLAGS
+cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+
+%make_install
+install -D -m 0644 LICENSE.Flora %{buildroot}%{_datadir}/license/org.tizen.bluetooth
+mkdir -p %{buildroot}/opt/usr/apps/org.tizen.bluetooth
+
+%post
+/sbin/ldconfig
+
+%files
+%manifest org.tizen.bluetooth.manifest
+/etc/smack/accesses2.d/org.tizen.bluetooth.rule
+
+%defattr(-,root,root,-)
+%attr(-,inhouse,inhouse)
+%{PREFIX}/bin/*
+%{PREFIX}/res/images/*.png
+/usr/share/packages/*
+#/usr/share/icons/default/small/*
+/usr/share/packages/%{name}.xml
+%{_datadir}/license/org.tizen.bluetooth
diff --git a/src/bt-dbus-method.c b/src/bt-dbus-method.c
new file mode 100644 (file)
index 0000000..83af8be
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+* ug-setting-bluetooth-efl
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           GirishAshok Joshi <girish.joshi@samsung.com>
+*           DoHyun Pyun <dh79.pyun@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-bindings.h>
+
+#include "bt-main.h"
+#include "bt-type-define.h"
+#include "bt-util.h"
+#include "bt-dbus-method.h"
+
+
+/**********************************************************************
+*                                                 Static Functions
+***********************************************************************/
+
+int __bt_get_adapter_path(DBusGConnection *GConn, char *path)
+{
+       FN_START;
+
+       GError *error = NULL;
+       DBusGProxy *manager_proxy = NULL;
+       char *adapter_path = NULL;
+       int ret = BT_APP_ERROR_NONE;
+       gsize len = 0;
+
+       retv_if(GConn == NULL, -1);
+       retv_if(path == NULL, -1);
+
+       manager_proxy = dbus_g_proxy_new_for_name(GConn, BLUEZ_DBUS_NAME, "/",
+                       "org.bluez.Manager");
+
+       retv_if(manager_proxy == NULL, -1);
+
+       dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &error,
+                       G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &adapter_path,
+                       G_TYPE_INVALID);
+
+       if (error != NULL) {
+               DBG("Getting DefaultAdapter failed: [%s]", error->message);
+               g_error_free(error);
+               g_object_unref(manager_proxy);
+               return -1;
+       }
+
+       if (adapter_path == NULL) {
+               g_object_unref(manager_proxy);
+               return -1;
+       }
+
+       len = g_strlcpy(path, adapter_path, BT_ADAPTER_PATH_LEN);
+
+       if (len >= BT_ADAPTER_PATH_LEN) {
+               DBG("The copied len is too large");
+               ret = -1;
+       }
+
+       g_object_unref(manager_proxy);
+       g_free(adapter_path);
+
+       FN_END;
+       return ret;
+}
+
+
+/**********************************************************************
+*                                                Common Functions
+***********************************************************************/
+
+DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn)
+{
+       FN_START;
+       DBusGProxy *adapter = NULL;
+       char adapter_path[BT_ADAPTER_PATH_LEN] = { 0 };
+
+       retv_if(conn == NULL, NULL);
+
+       if (__bt_get_adapter_path(conn, adapter_path) < 0) {
+               DBG("Could not get adapter path");
+               return NULL;
+       }
+
+       adapter = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME,
+                                                               adapter_path, ADAPTER_INTERFACE);
+
+       FN_END;
+       return adapter;
+}
+
+gboolean _bt_is_profile_connected(int connected_type,
+                               DBusGConnection *conn,
+                               unsigned char *addr)
+{
+       FN_START;
+       char *object_path = NULL;
+       char addr_str[BT_ADDRESS_STR_LEN + 1] = { 0 };
+       gboolean connected = FALSE;
+       DBusGProxy *proxy = NULL;
+       DBusGProxy *adapter = NULL;
+       GError *error = NULL;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       char *interface = NULL;
+       char path[BT_ADAPTER_PATH_LEN + 1] = {0};
+
+       retv_if(conn == NULL, FALSE);
+       retv_if(addr == NULL, FALSE);
+
+       _bt_util_addr_type_to_addr_string(addr_str, addr);
+
+       if (connected_type == BT_NETWORK_SERVER_CONNECTED) {
+               if (__bt_get_adapter_path(conn, path) != BT_APP_ERROR_NONE)
+                       return FALSE;
+
+               object_path = g_strdup(path);
+       } else {
+               adapter = _bt_get_adapter_proxy(conn);
+
+               retv_if(adapter == NULL, FALSE);
+
+               dbus_g_proxy_call(adapter, "FindDevice",
+                                 &error, G_TYPE_STRING, addr_str,
+                                 G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
+                                 &object_path, G_TYPE_INVALID);
+
+               g_object_unref(adapter);
+
+               if (error != NULL) {
+                       DBG("Failed to Find device: %s", error->message);
+                       g_error_free(error);
+                       return FALSE;
+               }
+       }
+
+       retv_if(object_path == NULL, FALSE);
+
+       switch (connected_type) {
+       case BT_HEADSET_CONNECTED:
+               interface = HEADSET_INTERFACE;
+               break;
+       case BT_STEREO_HEADSET_CONNECTED:
+               interface = SYNK_INTERFACE;
+               break;
+       case BT_HID_CONNECTED:
+               interface = HID_INTERFACE;
+               break;
+       case BT_NETWORK_CONNECTED:
+               interface = NETWORK_INTERFACE;
+               break;
+       case BT_NETWORK_SERVER_CONNECTED:
+               interface = NETWORK_SERVER_INTERFACE;
+               break;
+       default:
+               DBG("Unknown type!");
+               g_free(object_path);
+               return FALSE;
+       }
+
+       DBG("Interface: %s", interface);
+
+       proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, object_path, interface);
+
+       g_free(object_path);
+
+       retv_if(proxy == NULL, FALSE);
+
+       if (connected_type == BT_NETWORK_SERVER_CONNECTED) {
+               dbus_g_proxy_call(proxy, "GetProperties", &error,
+                                       G_TYPE_STRING, addr_str,
+                                       G_TYPE_INVALID,
+                                       dbus_g_type_get_map("GHashTable",
+                                               G_TYPE_STRING, G_TYPE_VALUE),
+                                       &hash, G_TYPE_INVALID);
+
+       } else {
+
+               dbus_g_proxy_call(proxy, "GetProperties", &error,
+                                       G_TYPE_INVALID,
+                                       dbus_g_type_get_map("GHashTable",
+                                               G_TYPE_STRING, G_TYPE_VALUE),
+                                       &hash, G_TYPE_INVALID);
+       }
+
+       if (error != NULL) {
+               DBG("Failed to get properties: %s", error->message);
+               g_error_free(error);
+               g_object_unref(proxy);
+               return FALSE;
+       }
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Connected");
+               connected = value ? g_value_get_boolean(value) : FALSE;
+       }
+
+       g_object_unref(proxy);
+       FN_END;
+       return connected;
+}
diff --git a/src/bt-handler.c b/src/bt-handler.c
new file mode 100644 (file)
index 0000000..bd00c0f
--- /dev/null
@@ -0,0 +1,718 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <bluetooth.h>
+#include <aul.h>
+
+#include "bt-main.h"
+#include "bt-main-view.h"
+#include "bt-handler.h"
+#include "bt-string.h"
+#include "bt-util.h"
+#include "bt-popup.h"
+
+static void __bt_ipc_update_connected_status(bt_app_data_t *ad,
+                                       int connected_type,
+                                       bool connected, int result,
+                                       bt_address_t *addr)
+{
+       FN_START;
+
+       bt_dev_t *item = NULL;
+       char addr_str[BT_ADDRESS_STR_LEN + 1] = { 0 };
+
+       _bt_util_addr_type_to_addr_string(addr_str, addr->bd_addr);
+
+       item = _bt_get_dev_info_by_address(ad->paired_device, addr_str);
+
+       ad->connect_req = FALSE;
+
+       if (item == NULL)
+               item = _bt_get_dev_info(ad->paired_device, ad->paired_item);
+
+       retm_if(item == NULL, "fail to get dev info!");
+
+       item->status = BT_IDLE;
+
+       if (connected == TRUE) {
+               item->connected_mask |= (result == BT_APP_ERROR_NONE) ? \
+                       connected_type : 0x00;
+       } else {
+               item->connected_mask &= (result == BT_APP_ERROR_NONE) ? \
+                       ~connected_type : 0xFF;
+       }
+
+       _bt_destroy_popup(ad);
+       if (ad->main_genlist)
+               _bt_update_genlist_item((Elm_Object_Item *)item->genlist_item);
+
+       FN_END;
+}
+
+static void __bt_adapter_state_changed(int result,
+                       bt_adapter_state_e adapter_state, void *user_data)
+{
+       retm_if (!user_data, "Invalid param");
+       bt_app_data_t *ad = (bt_app_data_t *)user_data;
+       retm_if (result != BT_ERROR_NONE, "BT Adapter operation is failed : %d", result);
+
+       DBG("BT Adapter is %s", adapter_state == BT_ADAPTER_ENABLED ?
+                       "enabled" : "disabled");
+       if (adapter_state == BT_ADAPTER_ENABLED) {
+               ad->op_status = BT_ACTIVATED;
+               if (ad->scan_btn)
+                       elm_object_disabled_set(ad->scan_btn, EINA_FALSE);
+               if(!_bt_create_list_view(ad))
+                       ERR("_bt_create_list_view fail!");
+       }
+}
+
+static bool __bt_cb_match_discovery_type(unsigned int major_class,
+                                               unsigned int service_class,
+                                               unsigned int mask)
+{
+       bt_device_major_mask_t major_mask = BT_DEVICE_MAJOR_MASK_MISC;
+
+       if (mask == 0x000000)
+               return TRUE;
+
+       DBG("mask:[%x] service_class:[%x]", mask, service_class);
+
+       /* Check the service_class */
+       if (service_class & mask)
+               return TRUE;
+
+       /* Check the major class */
+       switch (major_class) {
+               case BT_MAJOR_DEV_CLS_COMPUTER:
+                       major_mask = BT_DEVICE_MAJOR_MASK_COMPUTER;
+                       break;
+               case BT_MAJOR_DEV_CLS_PHONE:
+                       major_mask = BT_DEVICE_MAJOR_MASK_PHONE;
+                       break;
+               case BT_MAJOR_DEV_CLS_LAN_ACCESS_POINT:
+                       major_mask = BT_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT;
+                       break;
+               case BT_MAJOR_DEV_CLS_AUDIO:
+                       major_mask = BT_DEVICE_MAJOR_MASK_AUDIO;
+                       break;
+               case BT_MAJOR_DEV_CLS_PERIPHERAL:
+                       major_mask = BT_DEVICE_MAJOR_MASK_PERIPHERAL;
+                       break;
+               case BT_MAJOR_DEV_CLS_IMAGING:
+                       major_mask = BT_DEVICE_MAJOR_MASK_IMAGING;
+                       break;
+               case BT_MAJOR_DEV_CLS_WEARABLE:
+                       major_mask = BT_DEVICE_MAJOR_MASK_WEARABLE;
+                       break;
+               case BT_MAJOR_DEV_CLS_TOY:
+                       major_mask = BT_DEVICE_MAJOR_MASK_TOY;
+                       break;
+               case BT_MAJOR_DEV_CLS_HEALTH:
+                       major_mask = BT_DEVICE_MAJOR_MASK_HEALTH;
+                       break;
+               default:
+                       major_mask = BT_DEVICE_MAJOR_MASK_MISC;
+                       break;
+       }
+
+       DBG("major_mask: %x", major_mask);
+
+       if (mask & major_mask)
+               return TRUE;
+
+       return FALSE;
+}
+
+static void __bt_cb_new_device_found(bt_adapter_device_discovery_info_s *info,
+                                    void *data)
+{
+       FN_START;
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *dev = NULL;
+
+       ret_if(info == NULL);
+       ret_if(data == NULL);
+
+       ad = (bt_app_data_t *)data;
+
+       /* Check the service_class */
+       if (__bt_cb_match_discovery_type(
+                               info->bt_class.major_device_class,
+                               info->bt_class.major_service_class_mask,
+                               ad->search_type) == FALSE) {
+               DBG("No matched device type");
+               return;
+       }
+
+       /* mono headset should not be displayed when BT app is launching in BT_LAUNCH_CONNECT_HEADSET */
+       ret_if (!(info->bt_class.major_service_class_mask & BT_COD_SC_RENDERING));
+
+       if (info->is_bonded == TRUE) {
+               DBG("Bonded device");
+               if (_bt_check_and_update_device(ad->paired_device,
+                                       info->remote_address,
+                                       info->remote_name) >= 0)
+                       return;
+       }
+
+       if (_bt_check_and_update_device(ad->searched_device,
+                                       info->remote_address,
+                                       info->remote_name) >= 0) {
+               _bt_update_device_list(ad);
+       } else {
+               dev = _bt_create_searched_device_info((void *)info);
+               if (dev == NULL) {
+                       ERR("Create new device item failed \n");
+                       return;
+               }
+
+               if (_bt_is_matched_profile(ad->search_type,
+                                               dev->major_class,
+                                               dev->service_class) == TRUE) {
+                       if (_bt_add_searched_device_item(ad, dev) == NULL) {
+                               ERR("Fail to add the searched device");
+                               return;
+                       }
+
+                       ad->searched_device =
+                           eina_list_append(ad->searched_device, dev);
+
+               } else {
+                       ERR("Searched device does not match the profile");
+                       free(dev);
+               }
+       }
+       FN_END;
+}
+
+static void __bt_cb_search_completed(int result, void *data)
+{
+       FN_START;
+
+       bt_app_data_t *ad = (bt_app_data_t *)data;
+
+       _bt_unlock_display();
+       ret_if(data == NULL);
+
+       if (ad->op_status == BT_SEARCHING)
+               ad->op_status = BT_ACTIVATED;
+
+       elm_object_text_set(ad->scan_btn, STR_SCAN);
+
+       if (ad->searched_device == NULL ||
+               eina_list_count(ad->searched_device) == 0) {
+               _bt_remove_group_title_item(ad, GROUP_SEARCH);
+               if (ad->paired_device == NULL) {
+                       _bt_show_no_devices(ad);
+               }
+       } else
+               _bt_update_genlist_item(ad->searched_title_item);
+
+       FN_END;
+}
+
+static void _bt_cb_discovery_state_changed(int result,
+                       bt_adapter_device_discovery_state_e discovery_state,
+                       bt_adapter_device_discovery_info_s *discovery_info,
+                       void *user_data)
+{
+       ret_if(user_data == NULL);
+
+       if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND)
+               __bt_cb_new_device_found(discovery_info, user_data);
+       else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED)
+               __bt_cb_search_completed(result, user_data);
+
+}
+
+void _bt_cb_bonding_created(int result, bt_device_info_s *dev_info,
+                               void *user_data)
+{
+       FN_START;
+
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *dev = NULL;
+
+       _bt_unlock_display();
+
+       ret_if(dev_info == NULL);
+       ret_if(user_data == NULL);
+
+       ad = (bt_app_data_t *)user_data;
+
+       if (ad->op_status == BT_PAIRING)
+               ad->op_status = BT_ACTIVATED;
+
+       _bt_hide_no_devices(ad);
+
+       dev = _bt_get_dev_info_by_address(ad->searched_device,
+                                       dev_info->remote_address);
+
+       if (dev == NULL)
+               dev = _bt_get_dev_info(ad->searched_device, ad->searched_item);
+
+       if (result != BT_ERROR_NONE) {
+               DBG("Failed to pair with device : Error Cause[%d]", result);
+               elm_object_disabled_set(ad->scan_btn, EINA_FALSE);
+               if (dev == NULL)
+                       return;
+
+               dev->status = BT_IDLE;
+
+               elm_genlist_item_item_class_update(dev->genlist_item,
+                                               ad->searched_itc);
+               _bt_update_genlist_item((Elm_Object_Item *)dev->genlist_item);
+
+               if (result != BT_ERROR_CANCELLED) {
+                       if (_bt_util_is_battery_low() == TRUE) {
+                               // TODO : make a warning popup
+                       }
+               }
+       } else {
+               bt_dev_t *new_dev = NULL;
+               Elm_Object_Item *item = NULL;
+
+               if (_bt_check_and_update_device(ad->paired_device,
+                                       dev_info->remote_address,
+                                       dev_info->remote_name) >= 0) {
+                       _bt_update_device_list(ad);
+               } else {
+                       if (dev != NULL) {
+                               /* Remove the item in searched dialogue */
+                               _bt_remove_searched_device_item(ad, dev);
+                       }
+
+                       /* Add the item in paired group */
+                       new_dev = _bt_create_paired_device_info(dev_info);
+                       if (new_dev == NULL) {
+                               ERR("Create new device item failed");
+                               return;
+                       }
+                       new_dev->ad = ad;
+
+                       item = _bt_add_paired_device_item(ad, new_dev);
+                       if (item == NULL) {
+                               ERR("Fail to add the paired device");
+                               return;
+                       }
+
+                       ad->paired_device =
+                               eina_list_append(ad->paired_device, new_dev);
+
+                       _bt_connect_device(ad, new_dev);
+                       ad->paired_item = item;
+               }
+       }
+
+       ad->searched_item = NULL;
+
+       elm_object_disabled_set(ad->scan_btn, EINA_FALSE);
+
+       FN_END;
+}
+
+
+void _bt_cb_bonding_destroyed(int result, char *remote_address,
+                                       void *user_data)
+{
+       FN_START;
+
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *new_item = NULL;
+       bt_dev_t *item = NULL;
+       Eina_List *l = NULL;
+       int i;
+
+       retm_if(remote_address == NULL, "Invalid argument: param is NULL\n");
+       retm_if(user_data == NULL, "Invalid argument: param is NULL\n");
+
+       ad = (bt_app_data_t *)user_data;
+
+       if (ad->op_status == BT_UNPAIRING)
+               ad->op_status = BT_ACTIVATED;
+
+       if (result != BT_ERROR_NONE) {
+               DBG("Failed to unbond: [%d]", result);
+               return;
+       }
+
+       EINA_LIST_FOREACH(ad->paired_device, l, item) {
+               if (item == NULL)
+                       break;
+
+               if (g_strcmp0(item->addr_str, remote_address) == 0) {
+                       new_item = calloc(1, sizeof(bt_dev_t));
+                       if (new_item == NULL)
+                               break;
+                       item->connected_mask = 0x00;
+
+                       memcpy(new_item, item, sizeof(bt_dev_t));
+
+                       if (item->uuids && item->uuid_count > 0) {
+                               new_item->uuids = g_new0(char *, item->uuid_count + 1);
+
+                               for (i = 0; i < item->uuid_count; i++) {
+                                       new_item->uuids[i] = g_strdup(item->uuids[i]);
+                               }
+                       }
+
+                       new_item->uuid_count = item->uuid_count;
+
+                       _bt_remove_paired_device_item(ad, item);
+                       _bt_update_device_list(ad);
+
+                       if (_bt_add_searched_device_item(ad, new_item) != NULL) {
+                               ad->searched_device = eina_list_append(
+                                               ad->searched_device, new_item);
+                               _bt_update_device_list(ad);
+                       }
+
+                       break;
+               }
+       }
+
+       FN_END;
+}
+
+void _bt_cb_service_searched(int result, bt_device_sdp_info_s *sdp_info,
+                               void* user_data)
+{
+       FN_START;
+
+       int i;
+       bt_app_data_t *ad = NULL;
+       bt_service_class_t service_mask = 0;
+       bt_dev_t *item = NULL;
+
+       ret_if(user_data == NULL);
+
+       ad = (bt_app_data_t *)user_data;
+
+       ad->op_status = BT_ACTIVATED;
+
+       DBG("Result: %d", result);
+
+       item = _bt_get_dev_info_by_address(ad->paired_device,
+                                       sdp_info->remote_address);
+
+       if (item == NULL)
+               item = _bt_get_dev_info(ad->paired_device, ad->paired_item);
+
+       if (item == NULL) {
+               ad->waiting_service_response = FALSE;
+               return;
+       }
+
+       item->status = BT_IDLE;
+       _bt_update_genlist_item((Elm_Object_Item *)item->genlist_item);
+
+       if (result == BT_ERROR_NONE) {
+               _bt_util_get_service_mask_from_uuid_list(
+                                               sdp_info->service_uuid,
+                                               sdp_info->service_count,
+                                               &service_mask);
+
+               if (sdp_info->service_uuid != NULL && sdp_info->service_count > 0) {
+
+                       _bt_util_free_device_uuids(item);
+                       item->uuids = g_new0(char *, sdp_info->service_count + 1);
+
+                       for (i = 0; i < sdp_info->service_count; i++) {
+                               item->uuids[i] = g_strdup(sdp_info->service_uuid[i]);
+                       }
+
+                       item->uuid_count = sdp_info->service_count;
+               }
+
+               item->service_list = service_mask;
+
+               if (ad->waiting_service_response == TRUE) {
+                       _bt_connect_device(ad, item);
+               }
+       } else {
+               DBG("Failed to get the service list [%d]", result);
+#if 0
+               if (ad->waiting_service_response == TRUE) {
+                       if (ad->popup) {
+                               evas_object_del(ad->popup);
+                               ad->popup = NULL;
+                       }
+
+                       ad->popup = _bt_create_popup(ad->win_main, BT_STR_ERROR,
+                                       BT_STR_UNABLE_TO_GET_THE_SERVICE_LIST,
+                                       _bt_popup_del_cb, ad, 2);
+                       ad->back_cb = _bt_util_launch_no_event;
+
+                       btn = elm_button_add(ad->popup);
+                       elm_object_style_set(btn, "popup");
+                       elm_object_text_set(btn, BT_STR_CANCEL);
+                       elm_object_part_content_set(ad->popup, "button1", btn);
+                       evas_object_smart_callback_add(btn, "clicked",
+                               (Evas_Smart_Cb)_bt_popup_del_cb, ad);
+                       ea_object_event_callback_add(ad->popup, EA_CALLBACK_BACK,
+                                       _bt_popup_del_cb, ad);
+
+                       evas_object_show(ad->popup);
+
+               }
+#endif
+       }
+
+       ad->waiting_service_response = FALSE;
+
+       FN_END;
+}
+
+
+void _bt_cb_hid_state_changed(int result, bool connected,
+                       const char *remote_address,
+                       void *user_data)
+{
+       DBG("");
+}
+
+void _bt_cb_audio_state_changed(int result, bool connected,
+                               const char *remote_address,
+                               bt_audio_profile_type_e type,
+                               void *user_data)
+{
+       FN_START;
+
+       bt_address_t address = { { 0 } };
+       int connected_type;
+       bt_app_data_t *ad = NULL;
+
+       ret_if(user_data == NULL);
+
+       ad = (bt_app_data_t *)user_data;
+
+       _bt_unlock_display();
+       DBG("Bluetooth Audio Event [%d] : %s", result,
+                       connected ? "Connected" : "Disconnected");
+
+       if (type == BT_AUDIO_PROFILE_TYPE_AG) {
+               DBG("Not to handle the AG connection status");
+               return;
+       }
+
+       if (type == BT_AUDIO_PROFILE_TYPE_A2DP) {
+               connected_type = BT_STEREO_HEADSET_CONNECTED;
+               if (connected && result == BT_APP_ERROR_NONE)
+                       ad->a2dp_connected = true;
+       } else {
+               connected_type = BT_HEADSET_CONNECTED;
+       }
+
+       if (ad->launch_mode == BT_LAUNCH_CONNECT_HEADSET) {
+               if (connected && result == BT_APP_ERROR_NONE) {
+                       _bt_destroy_app(ad);
+                       return;
+               }
+
+               if (ad->main_genlist == NULL) {
+                       if (_bt_initialize_view(ad) < 0) {
+                               ERR("_bt_initialize_view failed");
+                               _bt_destroy_app(ad);
+                       }
+                       return;
+               }
+
+       }
+
+       DBG("remote_address : %s", remote_address);
+       _bt_util_addr_string_to_addr_type(address.bd_addr, remote_address);
+
+       __bt_ipc_update_connected_status(user_data, connected_type,
+                                       connected, result, &address);
+       FN_END;
+}
+
+
+void _bt_cb_adapter_name_changed(char *device_name, void *user_data)
+{
+       DBG("");
+}
+
+gboolean _bt_send_result(bt_app_data_t *ad, bool result)
+{
+       if (ad == NULL)
+               return FALSE;
+
+       int ret;
+       service_h service = NULL;
+       int reply = SERVICE_RESULT_FAILED;
+
+       DBG("");
+
+       if (ad->service == NULL) {
+               ERR("Invalid param");
+               return FALSE;
+       }
+
+       service_create(&service);
+       if (service == NULL) {
+               ERR("Service create failed");
+               return FALSE;
+       }
+
+       if (result)
+               reply = SERVICE_RESULT_SUCCEEDED;
+
+       ret = service_reply_to_launch_request(service, ad->service, reply);
+       if (ret != SERVICE_ERROR_NONE) {
+               ERR("service_reply_to_launch_request() failed");
+               service_destroy(service);
+               return FALSE;
+       }
+
+       DBG("Send result : %d", reply);
+
+       service_destroy(service);
+
+       return TRUE;
+}
+
+gboolean _bt_init(void *data)
+{
+       int ret;
+       bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED;
+       bt_app_data_t *ad = (bt_app_data_t *)data;
+       retv_if(!ad, FALSE);
+
+       ret = bt_initialize();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_initialize is failed : %d", ret);
+
+       ret = bt_audio_initialize();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_audio_initialize() failed");
+
+       ret = bt_adapter_set_state_changed_cb(__bt_adapter_state_changed, data);
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_adapter_set_state_changed_cb failed");
+
+       ret =  bt_adapter_set_device_discovery_state_changed_cb(
+                       _bt_cb_discovery_state_changed, data);
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_adapter_set_device_discovery_state_changed_cb failed : %d", ret);
+
+       ret = bt_device_set_bond_created_cb(_bt_cb_bonding_created, data);
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_device_set_bond_created_cb failed");
+
+       ret = bt_device_set_bond_destroyed_cb(_bt_cb_bonding_destroyed,
+                                             data);
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_device_set_bond_destroyed_cb failed");
+
+       ret = bt_device_set_service_searched_cb(_bt_cb_service_searched,
+                                               data);
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_device_set_service_searched_cb failed");
+
+       ret = bt_adapter_set_name_changed_cb(_bt_cb_adapter_name_changed,
+                                            data);
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_adapter_set_name_changed_cb failed");
+
+       ret =
+           bt_audio_set_connection_state_changed_cb(_bt_cb_audio_state_changed,
+                                                    data);
+       if (ret != BT_ERROR_NONE)
+               ERR("audio set connection state callback failed");
+
+
+       ret = bt_adapter_get_state(&adapter_state);
+       if (ret != BT_ERROR_NONE) {
+               ERR("bt_adapter_get_state is failed : %d", ret);
+               return FALSE;
+       }
+
+       if (adapter_state == BT_ADAPTER_ENABLED) {
+               DBG("Aleady BT enabled");
+               return TRUE;
+       } else {
+               DBG("Enable BT adapter");
+               ret = bt_adapter_enable();
+               ad->op_status = BT_ACTIVATING;
+               if (ret != BT_ERROR_NONE) {
+                       ERR("bt_adapter_enable is failed : %d", ret);
+                       return FALSE;
+               }
+       }
+
+       if (ret != BT_ERROR_NONE)
+               return FALSE;
+       else
+               return TRUE;
+}
+
+void _bt_deinit(bt_app_data_t *ad)
+{
+       FN_START;
+       int ret;
+
+       if (ad && ad->op_status == BT_SEARCHING) {
+               ret = bt_adapter_stop_device_discovery();
+               if (ret != BT_ERROR_NONE)
+                       ERR("Stop device discovery failed: %d", ret);
+       }
+
+       ret = bt_adapter_unset_state_changed_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_adapter_unset_state_changed_cb is failed : %d\n", ret);
+
+       ret = bt_adapter_unset_device_discovery_state_changed_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_adapter_unset_device_discovery_state_changed_cb is failed : %d\n", ret);
+
+       ret = bt_device_unset_bond_created_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_device_unset_bond_created_cb is failed : %d\n", ret);
+
+       ret = bt_device_unset_bond_destroyed_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_device_unset_bond_destroyed_cb is failed : %d\n", ret);
+
+       ret = bt_device_unset_service_searched_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_device_unset_service_searched_cb is failed : %d\n", ret);
+
+       ret = bt_adapter_unset_name_changed_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_adapter_unset_name_changed_cb is failed : %d\n", ret);
+
+       ret = bt_audio_unset_connection_state_changed_cb();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_audio_unset_connection_state_changed_cb is failed : %d\n", ret);
+
+       ret = bt_deinitialize();
+       if (ret != BT_ERROR_NONE)
+               ERR("bt_deinitialize is failed : %d\n", ret);
+
+       FN_END;
+       return;
+}
+
+
diff --git a/src/bt-main-view.c b/src/bt-main-view.c
new file mode 100755 (executable)
index 0000000..bda58ca
--- /dev/null
@@ -0,0 +1,1585 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+
+#include "bt-main.h"
+#include "bt-main-view.h"
+#include "bt-string.h"
+#include "bt-handler.h"
+#include "bt-util.h"
+#include "bt-type-define.h"
+#include "bt-dbus-method.h"
+#include "bt-popup.h"
+#include <syspopup_caller.h>
+
+#define BT_AUTO_CONNECT_SYSPOPUP_MAX_ATTEMPT 3
+
+static Eina_Bool __pop_cb(void *data, Elm_Object_Item *it)
+{
+       FN_START;
+       _bt_destroy_app(data);
+       FN_END;
+       return EINA_FALSE;
+}
+
+static void __destory_app_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       FN_START;
+       _bt_destroy_app(data);
+       FN_END;
+}
+
+Evas_Object* _bt_create_win(const char *name)
+{
+       FN_START;
+       Evas_Object *eo;
+       int w;
+       int h;
+
+       eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+       if (eo) {
+               elm_win_title_set(eo, name);
+               elm_win_borderless_set(eo, EINA_TRUE);
+               ecore_x_window_size_get(ecore_x_window_root_first_get(),
+                                       &w, &h);
+               evas_object_resize(eo, w, h);
+       }
+
+       FN_END;
+       return eo;
+}
+
+static Evas_Object* __create_bg(Evas_Object *parent)
+{
+       Evas_Object *bg;
+
+       retv_if(parent == NULL, NULL);
+
+       bg = elm_bg_add(parent);
+       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(parent, bg);
+       evas_object_show(bg);
+
+       return bg;
+}
+
+static void __bt_scan_btn_cb(void *data, Evas_Object *obj,
+                                       void *event_info)
+{
+       FN_START;
+
+       int ret;
+       bt_app_data_t *ad = NULL;
+
+       retm_if(data == NULL, "Invalid argument: bt_ug_data is NULL");
+
+       ad = (bt_app_data_t *)data;
+
+       if (ad->op_status == BT_SEARCHING) {
+               ret = bt_adapter_stop_device_discovery();
+               if (ret != BT_ERROR_NONE) {
+                       ERR("Discovery Stop failed");
+                       return;
+               }
+               ad->op_status = BT_ACTIVATED;
+               elm_object_text_set(ad->scan_btn, STR_SCAN);
+
+       } else {
+               _bt_hide_no_devices(ad);
+
+               ret = bt_adapter_start_discover_devices
+                       (BT_ADAPTER_DEVICE_DISCOVERY_BREDR);
+               if (ret != BT_ERROR_NONE && ret != BT_ERROR_NOW_IN_PROGRESS){
+                       ERR("Discovery start failed");
+                       return;
+               }
+               ad->op_status = BT_SEARCHING;
+               _bt_lock_display();
+               elm_object_text_set(ad->scan_btn, STR_STOP);
+
+               _bt_remove_all_searched_devices_item(ad);
+
+               if (ad->searched_title_item == NULL)
+                       _bt_create_group_title_item(ad, GROUP_SEARCH);
+
+               _bt_update_genlist_item(ad->searched_title_item);
+       }
+
+       FN_END;
+}
+
+static Evas_Object * __bt_create_scan_btn(bt_app_data_t *ad)
+{
+       retvm_if(!ad, NULL, "Invalid parameter!");
+       retvm_if(!ad->layout_btn, NULL, "Invalid parameter!");
+
+       Evas_Object *btn;
+
+       btn = elm_button_add(ad->layout_btn);
+       retvm_if(!btn, NULL, "elm_button_add fail!");
+       elm_object_text_set(btn, STR_SCAN);
+       evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_smart_callback_add(btn, "clicked", __bt_scan_btn_cb, ad);
+       evas_object_show(btn);
+       elm_object_part_content_set(ad->layout_btn, "elm.icon", btn);
+
+       return btn;
+}
+
+static Evas_Object* __create_nocontents_button_layout(Evas_Object* parent)
+{
+       Evas_Object *ly;
+
+       retv_if(parent == NULL, NULL);
+
+       ly = elm_layout_add(parent);
+       elm_layout_theme_set(ly, "layout", "nocontents_button", "default");
+       evas_object_size_hint_weight_set (ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       return ly;
+}
+
+static Evas_Object* __create_layout_main(Evas_Object* parent)
+{
+       Evas_Object *layout;
+
+       retv_if(parent == NULL, NULL);
+
+       layout = elm_layout_add(parent);
+       retv_if(layout == NULL, NULL);
+
+       elm_layout_theme_set(layout, "layout", "application", "default");
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_part_content_set(parent, "elm.swallow.content", layout);
+       evas_object_show(layout);
+
+       return layout;
+}
+
+static char *__bt_search_title_text_get(void *data, Evas_Object *obj,
+                                           const char *part)
+{
+       bt_app_data_t *ad = data;
+
+       if (g_strcmp0(part, "elm.text") != 0) {
+               ERR("It is not in elm.text part");
+               return NULL;
+       }
+
+       if (ad->op_status == BT_SEARCHING) {
+               if (ad->searched_device == NULL ||
+                       eina_list_count(ad->searched_device) == 0) {
+                       return g_strdup(STR_SCANNING);
+               }
+       }
+       return g_strdup(STR_AVAILABLE_DEV);
+}
+
+static char *__bt_paired_title_text_get(void *data, Evas_Object *obj,
+                                           const char *part)
+{
+       retv_if(!part, NULL);
+       DBG("part : %s", part);
+
+       if (g_strcmp0(part, "elm.text") != 0) {
+               ERR("It is not in elm.text part");
+               return NULL;
+       }
+       return g_strdup(STR_PAIRED_DEV);
+}
+
+static Evas_Object *__bt_search_title_icon_get(void *data, Evas_Object *obj,
+                                           const char *part)
+{
+       bt_app_data_t *ad;
+       Evas_Object *progressbar;
+
+       retv_if(data == NULL, NULL);
+
+       if (g_strcmp0(part, "elm.icon") != 0)
+               return NULL;
+
+       ad = (bt_app_data_t *)data;
+       DBG("op_status : %d", ad->op_status);
+       if (ad->op_status == BT_SEARCHING) {
+               progressbar = elm_progressbar_add(obj);
+               elm_object_style_set(progressbar, "process/groupindex");
+               evas_object_size_hint_align_set(progressbar,
+                               EVAS_HINT_FILL, 0.5);
+               evas_object_size_hint_weight_set(progressbar,
+                               EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_progressbar_pulse(progressbar, EINA_TRUE);
+               return progressbar;
+       }
+
+       return NULL;
+}
+
+static void __bt_unpair_icon_sel_cb(void *data, Evas_Object *obj,
+                                    void *event_info)
+{
+       FN_START
+
+       bt_dev_t *dev = NULL;
+       bt_app_data_t *ad;
+
+       if (data == NULL)
+               return;
+
+       dev = (bt_dev_t *)data;
+       ad = dev->ad;
+
+       if (ad == NULL)
+               return;
+
+       DBG("op_status : %d", ad->op_status);
+       if (ad->op_status == BT_UNPAIRING) {
+               DBG("Unpairing... Skip the click event");
+               return;
+       }
+
+       if (dev->name)
+               DBG("Selected dev : %s", dev->name);
+       DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
+              dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
+              dev->bd_addr[4], dev->bd_addr[5]);
+
+       _bt_create_unpair_query_popup(dev);
+
+       FN_END
+}
+
+static Evas_Object *__bt_dev_item_icon_get(void *data, Evas_Object *obj,
+                                           const char *part)
+{
+       FN_START;
+
+       Evas_Object *btn = NULL;
+       Evas_Object *icon = NULL;
+       bt_dev_t *dev = NULL;
+
+       retv_if(data == NULL, NULL);
+
+       dev = (bt_dev_t *)data;
+
+       DBG("status : %d", dev->status);
+       DBG("part : %s", part);
+
+       if (g_strcmp0(part, "elm.icon") != 0)
+               return NULL;
+
+       btn = elm_button_add(obj);
+       elm_object_style_set(btn, "naviframe/title_icon");
+       icon = elm_image_add(btn);
+       elm_image_file_set(icon, IMAGE_UNPAIR_BUTTON, NULL);
+       evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+       elm_image_resizable_set(icon, EINA_FALSE, EINA_FALSE);
+
+       if (dev->status == BT_CONNECTING || dev->status == BT_DISCONNECTING) {
+               elm_object_disabled_set(btn, EINA_TRUE);
+       }
+       elm_object_part_content_set(btn, "icon", icon);
+       evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       evas_object_smart_callback_add(btn, "clicked",
+                                          (Evas_Smart_Cb)
+                                          __bt_unpair_icon_sel_cb,
+                                          (void *)dev);
+       evas_object_propagate_events_set(btn, EINA_FALSE);
+
+
+       FN_END;
+       return btn;
+}
+
+static gboolean __bt_is_connectable_device(bt_dev_t *dev)
+{
+       FN_START;
+
+       bt_device_info_s *device_info = NULL;
+       retv_if(dev == NULL, FALSE);
+
+       if (dev->service_list == 0) {
+               if (bt_adapter_get_bonded_device_info
+                   ((const char *)dev->addr_str,
+                    &device_info) != BT_ERROR_NONE) {
+                       if (device_info)
+                               bt_adapter_free_device_info(device_info);
+
+                       return FALSE;
+               }
+               _bt_util_get_service_mask_from_uuid_list
+                   (device_info->service_uuid, device_info->service_count,
+                    &dev->service_list);
+
+               bt_adapter_free_device_info(device_info);
+
+               if (dev->service_list == 0) {
+                       DBG("No service list");
+                       return FALSE;
+               }
+       }
+
+       if ((dev->service_list & BT_SC_HFP_SERVICE_MASK) ||
+           (dev->service_list & BT_SC_HSP_SERVICE_MASK) ||
+           (dev->service_list & BT_SC_A2DP_SERVICE_MASK) ||
+           (dev->service_list & BT_SC_HID_SERVICE_MASK) ||
+           (dev->service_list & BT_SC_NAP_SERVICE_MASK)) {
+               /* Connectable device */
+               return TRUE;
+       }
+
+       FN_END;
+       return FALSE;
+}
+
+static char *__bt_dev_item_text_get(void *data, Evas_Object *obj,
+                                         const char *part)
+{
+       char buf[BT_GLOBALIZATION_STR_LENGTH] = { 0 };
+       bt_dev_t *dev = NULL;
+       char *str = NULL;
+
+       if (data == NULL)
+               return NULL;
+
+       dev = (bt_dev_t *)data;
+       DBG("part : %s", part);
+
+       if (!strcmp(part, "elm.text") || !strcmp(part, "elm.text.1")) {
+               g_strlcpy(buf, dev->name, BT_GLOBALIZATION_STR_LENGTH);
+               DBG("label : %s", buf);
+       } else if (!strcmp(part, "elm.text.2")) {
+               DBG("status : %d", dev->status);
+               if (dev->status == BT_IDLE) {
+                       if (__bt_is_connectable_device(dev) == FALSE)
+                               str = STR_PAIRED;
+                       else {
+                               if (dev->connected_mask > 0)
+                                       str = STR_CONNECTED;
+                               else
+                                       str = STR_PAIRED;
+                       }
+               } else if (dev->status == BT_DEV_PAIRING)
+                       str = STR_PAIRING;
+               else if (dev->status == BT_CONNECTING || dev->status == BT_SERVICE_SEARCHING)
+                       str = STR_CONNECTING;
+               else if (dev->status == BT_DISCONNECTING)
+                       str = STR_DISCONNECTING;
+
+               snprintf(buf, sizeof(buf)-1, "<font_size=24><color=#FF9000>%s</color></font_size>", str);
+       }
+       return strdup(buf);
+}
+
+static void __bt_set_genlist_itc(bt_app_data_t *ad)
+{
+       FN_START;
+
+       /* Paired device group title */
+       ad->paired_title_itc = elm_genlist_item_class_new();
+       ad->paired_title_itc->item_style = "groupindex";
+       ad->paired_title_itc->func.text_get = __bt_paired_title_text_get;
+       ad->paired_title_itc->func.content_get = NULL;
+       ad->paired_title_itc->func.state_get = NULL;
+       ad->paired_title_itc->func.del = NULL;
+
+       /* Available device group title */
+       ad->searched_group_itc = elm_genlist_item_class_new();
+       ad->searched_group_itc->item_style = "groupindex";
+       ad->searched_group_itc->func.text_get = __bt_search_title_text_get;
+       ad->searched_group_itc->func.content_get = __bt_search_title_icon_get;
+       ad->searched_group_itc->func.state_get = NULL;
+       ad->searched_group_itc->func.del = NULL;
+
+       /* Set item class for paired device */
+       ad->device_itc = elm_genlist_item_class_new();
+       ad->device_itc->item_style = "2text.1icon.divider";
+       ad->device_itc->func.text_get = __bt_dev_item_text_get;
+       ad->device_itc->func.content_get = __bt_dev_item_icon_get;
+       ad->device_itc->func.state_get = NULL;
+       ad->device_itc->func.del = NULL;
+
+       /* Searched device */
+       ad->searched_itc = elm_genlist_item_class_new();
+       ad->searched_itc->item_style = "1text";
+       ad->searched_itc->func.text_get = __bt_dev_item_text_get;
+       ad->searched_itc->func.content_get = NULL;
+       ad->searched_itc->func.state_get = NULL;
+       ad->searched_itc->func.del = NULL;
+
+       /* Searched device while pairing */
+       ad->searched_pairing_itc = elm_genlist_item_class_new();
+       ad->searched_pairing_itc->item_style = "2text";
+       ad->searched_pairing_itc->func.text_get = __bt_dev_item_text_get;
+       ad->searched_pairing_itc->func.content_get = NULL;
+       ad->searched_pairing_itc->func.state_get = NULL;
+       ad->searched_pairing_itc->func.del = NULL;
+
+       FN_END;
+}
+
+static void __bt_release_genlist_itc(bt_app_data_t *ad)
+{
+       ret_if(!ad);
+       if (ad->paired_title_itc) {
+               elm_genlist_item_class_free(ad->paired_title_itc);
+               ad->paired_title_itc = NULL;
+       }
+
+       if (ad->searched_group_itc) {
+               elm_genlist_item_class_free(ad->searched_group_itc);
+               ad->searched_group_itc = NULL;
+       }
+
+       if (ad->device_itc) {
+               elm_genlist_item_class_free(ad->device_itc);
+               ad->device_itc = NULL;
+       }
+
+       if (ad->searched_itc) {
+               elm_genlist_item_class_free(ad->searched_itc);
+               ad->searched_itc = NULL;
+       }
+
+       if (ad->searched_pairing_itc) {
+               elm_genlist_item_class_free(ad->searched_pairing_itc);
+               ad->searched_pairing_itc = NULL;
+       }
+}
+
+static Evas_Object *__bt_create_genlist(bt_app_data_t *ad)
+{
+       FN_START;
+       retv_if(!ad, NULL);
+       retv_if(!ad->layout_btn, NULL);
+       Evas_Object *gl = NULL;
+
+       gl = elm_genlist_add(ad->layout_btn);
+       elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
+       __bt_set_genlist_itc(ad);
+       elm_object_part_content_set(ad->layout_btn, "elm.swallow.content", gl);
+
+       return gl;
+}
+
+static void __bt_clear_genlist(bt_app_data_t *ad)
+{
+       FN_START;
+       ret_if(!ad);
+       ret_if(!ad->main_genlist);
+
+       _bt_remove_group_title_item(ad, GROUP_SEARCH);
+       _bt_remove_group_title_item(ad, GROUP_PAIR);
+
+       __bt_release_genlist_itc(ad);
+
+       elm_genlist_clear(ad->main_genlist);
+       evas_object_del(ad->main_genlist);
+       ad->main_genlist = NULL;
+
+}
+
+void _bt_show_no_devices(bt_app_data_t *ad)
+{
+       FN_START;
+       retm_if(ad == NULL, "ad is NULL!");
+       retm_if(ad->layout_btn == NULL, "ad->layout_btn is NULL!");
+
+       __bt_clear_genlist(ad);
+
+       elm_object_part_content_set(ad->layout_btn, "elm.swallow.content", NULL);
+       elm_object_part_text_set(ad->layout_btn, "elm.text", STR_NO_DEV);
+       FN_END;
+}
+
+void _bt_hide_no_devices(bt_app_data_t *ad)
+{
+       FN_START;
+       retm_if(ad == NULL, "ad is NULL!");
+       retm_if(ad->layout_btn == NULL, "ad->layout_btn is NULL!");
+       ret_if(ad->paired_device || ad->searched_device);
+       ret_if(elm_object_part_text_get(ad->layout_btn, "elm.text") == NULL);
+
+       elm_object_part_text_set(ad->layout_btn, "elm.text", NULL);
+
+       if(!_bt_create_list_view(ad))
+               ERR("_bt_create_list_view fail!");
+       FN_END;
+}
+
+int _bt_initialize_view(bt_app_data_t *ad)
+{
+       FN_START;
+       Elm_Object_Item *navi_it;
+
+       retvm_if(ad == NULL, -1,  "ad is NULL!");
+       retvm_if(ad->window == NULL, -1,  "->window is NULL!");
+
+       ad->bg = __create_bg(ad->window);
+       retvm_if(ad->bg == NULL, -1,  "fail to create bg!");
+
+       ad->layout_main = __create_layout_main(ad->bg);
+       retvm_if(ad->layout_main == NULL, -1,  "fail to create layout_main!");
+
+       ad->navi = elm_naviframe_add(ad->layout_main);
+       retvm_if(ad->navi == NULL, -1,  "fail to create naviframe!");
+       elm_object_part_content_set(ad->layout_main, "elm.swallow.content", ad->navi);
+       ea_object_event_callback_add(ad->navi, EA_CALLBACK_BACK,
+               __destory_app_cb, ad);
+       evas_object_show(ad->navi);
+
+       ad->layout_btn = __create_nocontents_button_layout(ad->layout_main);
+       retvm_if(ad->layout_btn == NULL, -1,  "fail to create layout_btn!");
+
+       ad->scan_btn = __bt_create_scan_btn(ad);
+       retvm_if(ad->scan_btn == NULL, -1,  "fail to create scan_btn!");
+
+       if (ad->op_status == BT_ACTIVATING) {
+               _bt_show_no_devices(ad);
+               elm_object_disabled_set(ad->scan_btn, EINA_TRUE);
+       } else {
+               ad->main_genlist = _bt_create_list_view(ad);
+               elm_object_part_content_set(ad->layout_btn, "elm.swallow.content",
+                                       ad->main_genlist);
+               evas_object_data_set(ad->main_genlist, "appdata", ad);
+       }
+
+       evas_object_show(ad->window);
+
+       navi_it = elm_naviframe_item_push(ad->navi, NULL, NULL, NULL, ad->layout_btn, NULL);
+       ad->navi_item = navi_it;
+       elm_naviframe_item_title_enabled_set(navi_it, EINA_FALSE, EINA_FALSE);
+       elm_naviframe_item_pop_cb_set(navi_it, __pop_cb, ad);
+
+       FN_END;
+       return 0;
+}
+
+static void __bt_free_device_info(bt_dev_t *dev)
+{
+       ret_if(!dev);
+
+       int i;
+
+       if (dev->uuids) {
+               for (i = 0; i < dev->uuid_count ; i++) {
+                       if (dev->uuids[i]) {
+                               g_free(dev->uuids[i]);
+                               dev->uuids[i] = NULL;
+                       }
+               }
+               g_free(dev->uuids);
+               dev->uuids = NULL;
+       }
+
+       free(dev);
+       dev = NULL;
+}
+
+static void __bt_free_paired_device(bt_app_data_t *ad)
+{
+       FN_START;
+       retm_if(!ad, "ad is NULL!");
+       retm_if(!ad->paired_device, "paired_device is NULL!");
+
+       Eina_List *l = NULL;
+       Eina_List *l_next = NULL;
+       bt_dev_t *dev = NULL;
+
+       EINA_LIST_FOREACH_SAFE(ad->paired_device, l, l_next, dev) {
+               __bt_free_device_info(dev);
+       }
+
+       eina_list_free(ad->paired_device);
+       ad->paired_device = NULL;
+       FN_END;
+}
+
+static bool __bt_cb_adapter_bonded_device(bt_device_info_s *device_info,
+                                         void *user_data)
+{
+       FN_START;
+       bt_dev_t *dev = NULL;
+       gboolean connected = FALSE;
+       bt_app_data_t *ad = NULL;
+       unsigned int service_class;
+
+       ad = (bt_app_data_t *)user_data;
+       retv_if(ad == NULL, false);
+
+       dev = _bt_create_paired_device_info(device_info);
+       retv_if (!dev, false);
+
+       dev->ad = (void *)ad;
+
+       service_class = dev->service_class;
+
+       if (_bt_is_matched_profile(ad->search_type,
+                                       dev->major_class,
+                                       service_class) == TRUE) {
+               if (dev->service_list & BT_SC_HFP_SERVICE_MASK ||
+                   dev->service_list & BT_SC_HSP_SERVICE_MASK ||
+                   dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
+                       connected = _bt_is_profile_connected(BT_HEADSET_CONNECTED,
+                                                            ad->conn, dev->bd_addr);
+                       dev->connected_mask |= connected ? BT_HEADSET_CONNECTED : 0x00;
+
+                       connected =
+                           _bt_is_profile_connected(BT_STEREO_HEADSET_CONNECTED,
+                                                    ad->conn, dev->bd_addr);
+                       dev->connected_mask |=
+                           connected ? BT_STEREO_HEADSET_CONNECTED : 0x00;
+               }
+
+               if (_bt_add_paired_device_item(ad, dev) != NULL) {
+                       ad->paired_device =
+                               eina_list_append(ad->paired_device, dev);
+                       _bt_update_device_list(ad);
+               }
+       } else {
+               ERR("Device class and search type do not match");
+               free(dev);
+       }
+
+       FN_END;
+       return true;
+}
+
+static bool __bt_cb_adapter_create_paired_device_list
+                       (bt_device_info_s *device_info, void *user_data)
+{
+       FN_START;
+       bt_dev_t *dev = NULL;
+       gboolean connected = FALSE;
+       bt_app_data_t *ad = NULL;
+       unsigned int service_class;
+
+
+       ad = (bt_app_data_t *)user_data;
+       retv_if(ad == NULL, false);
+
+       dev = _bt_create_paired_device_info(device_info);
+       retv_if (!dev, false);
+
+       dev->ad = (void *)ad;
+
+       service_class = dev->service_class;
+
+       if (_bt_is_matched_profile(ad->search_type,
+                                       dev->major_class,
+                                       service_class) == TRUE) {
+               if (dev->service_list & BT_SC_HFP_SERVICE_MASK ||
+                   dev->service_list & BT_SC_HSP_SERVICE_MASK ||
+                   dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
+                       connected = _bt_is_profile_connected(BT_HEADSET_CONNECTED,
+                                                            ad->conn, dev->bd_addr);
+                       dev->connected_mask |= connected ? BT_HEADSET_CONNECTED : 0x00;
+
+                       connected =
+                           _bt_is_profile_connected(BT_STEREO_HEADSET_CONNECTED,
+                                                    ad->conn, dev->bd_addr);
+                       dev->connected_mask |=
+                           connected ? BT_STEREO_HEADSET_CONNECTED : 0x00;
+               }
+
+               dev->status = BT_IDLE;
+               dev->ad = (void *)ad;
+               dev->is_bonded = TRUE;
+               ad->paired_device =
+                       eina_list_append(ad->paired_device, dev);
+               _bt_update_device_list(ad);
+       } else {
+               ERR("Device class and search type do not match");
+               free(dev);
+       }
+
+       FN_END;
+       return true;
+}
+
+static void __bt_draw_paired_devices_items(bt_app_data_t *ad)
+{
+       FN_START;
+
+       ret_if(ad == NULL);
+       __bt_free_paired_device(ad);
+       if (bt_adapter_foreach_bonded_device(__bt_cb_adapter_bonded_device,
+                                            (void *)ad) != BT_ERROR_NONE) {
+               ERR("bt_adapter_foreach_bonded_device() failed");
+               return;
+       }
+
+       FN_END;
+       return;
+}
+
+void _bt_get_paired_devices(bt_app_data_t *ad)
+{
+       FN_START;
+
+       ret_if(ad == NULL);
+       __bt_free_paired_device(ad);
+       if (bt_adapter_foreach_bonded_device(
+                       __bt_cb_adapter_create_paired_device_list,
+                       (void *)ad) != BT_ERROR_NONE) {
+               ERR("bt_adapter_foreach_bonded_device() failed");
+       }
+
+       FN_END;
+       return;
+}
+
+static int __bt_service_request_cb(void *data)
+{
+       FN_START;
+
+       bt_app_data_t *ad = NULL;
+
+       retvm_if(data == NULL, BT_APP_FAIL,
+                "Invalid argument: bt_app_data_t is NULL");
+
+       ad = (bt_app_data_t *)data;
+
+       if (ad->request_timer) {
+               ecore_timer_del(ad->request_timer);
+               ad->request_timer = NULL;
+       }
+
+       /* Need to modify API: Address parameter */
+       if (ad->waiting_service_response == TRUE) {
+               bt_dev_t *dev = NULL;
+
+               ad->waiting_service_response = FALSE;
+               bt_device_cancel_service_search();
+
+               dev =
+                   _bt_get_dev_info(ad->paired_device, ad->paired_item);
+               retvm_if(dev == NULL, -1, "dev is NULL");
+
+               dev->status = BT_IDLE;
+               _bt_update_genlist_item(ad->paired_item);
+
+               _bt_connect_device(ad, dev);
+       } else {
+               ad->paired_item = NULL;
+       }
+
+       FN_END;
+       return BT_APP_ERROR_NONE;
+}
+
+static void __bt_paired_item_sel_cb(void *data, Evas_Object *obj,
+                                        void *event_info)
+{
+       FN_START;
+       retm_if(data == NULL, "Invalid argument: data is NULL");
+       retm_if(event_info == NULL, "Invalid argument: event_info is NULL");
+
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *dev = NULL;
+       Elm_Object_Item *item = NULL;
+       int ret;
+
+       elm_genlist_item_selected_set((Elm_Object_Item *) event_info,
+                                     EINA_FALSE);
+
+       ad = (bt_app_data_t *)data;
+       item = (Elm_Object_Item *)event_info;
+
+       ret_if(ad->waiting_service_response == TRUE);
+       ret_if(ad->op_status == BT_PAIRING);
+
+       if (ad->op_status == BT_SEARCHING) {
+               ret = bt_adapter_stop_device_discovery();
+               if (ret != BT_ERROR_NONE) {
+                       ERR("Fail to stop discovery");
+                       return;
+               }
+       }
+
+       dev = _bt_get_dev_info(ad->paired_device, item);
+       retm_if(dev == NULL, "Invalid argument: device info is NULL");
+       retm_if(dev->status != BT_IDLE,
+               "Connecting / Disconnecting is in progress");
+
+       if ((ad->waiting_service_response) && (dev->service_list == 0)) {
+               ERR("No service");
+
+               ad->paired_item = item;
+       }
+
+       ad->paired_item = item;
+
+       if (dev->service_list == 0) {
+               DBG("Need to get service list");
+
+               if (bt_device_start_service_search
+                   ((const char *)dev->addr_str) == BT_ERROR_NONE) {
+
+                       dev->status = BT_SERVICE_SEARCHING;
+                       ad->waiting_service_response = TRUE;
+                       ad->request_timer =
+                           ecore_timer_add(BT_SEARCH_SERVICE_TIMEOUT,
+                                           (Ecore_Task_Cb)
+                                           __bt_service_request_cb,
+                                           ad);
+
+                       _bt_update_genlist_item(ad->paired_item);
+                       return;
+               } else {
+                       ERR("service search error");
+                       return;
+               }
+       }
+
+       if (dev->connected_mask == 0) {
+               /* Not connected case */
+               _bt_connect_device(ad, dev);
+       } else {
+               /* connected case */
+               DBG("Disconnect ??");
+
+               _bt_create_disconnection_query_popup(dev);
+       }
+
+       FN_END;
+}
+
+static void __bt_searched_item_sel_cb(void *data, Evas_Object *obj,
+                                          void *event_info)
+{
+       FN_START;
+
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *dev = NULL;
+       Elm_Object_Item *item = NULL;
+       int ret;
+
+       elm_genlist_item_selected_set((Elm_Object_Item *) event_info,
+                                     EINA_FALSE);
+
+       retm_if(data == NULL, "Invalid argument: bt_app_data_t is NULL");
+
+       ad = (bt_app_data_t *)data;
+
+       ret_if(ad->op_status == BT_PAIRING);
+
+       item = (Elm_Object_Item *) event_info;
+
+       dev = _bt_get_dev_info(ad->searched_device,
+                                   (Elm_Object_Item *) event_info);
+       retm_if(dev == NULL, "Invalid argument: device info is NULL");
+
+       ad->searched_item = item;
+
+       if (_bt_util_is_battery_low() == TRUE) {
+               /* Battery is critical low */
+               // TODO : Make a warning popup
+               DBG("Critical Low battery");
+       }
+
+       if (ad->op_status == BT_SEARCHING) {
+               ret = bt_adapter_stop_device_discovery();
+               if (ret != BT_ERROR_NONE)
+                       ERR("Fail to stop discovery");
+       }
+
+       if (bt_device_create_bond(dev->addr_str) == BT_ERROR_NONE) {
+               dev->status = BT_DEV_PAIRING;
+               ad->op_status = BT_PAIRING;
+               _bt_lock_display();
+               elm_genlist_item_item_class_update(dev->genlist_item,
+                               ad->searched_pairing_itc);
+               _bt_update_genlist_item(item);
+               elm_object_disabled_set(ad->scan_btn, EINA_TRUE);
+       }
+
+       FN_END;
+}
+
+void _bt_connect_device(bt_app_data_t *ad, bt_dev_t *dev)
+{
+       FN_START;
+
+       retm_if(ad == NULL, "ad is NULL");
+       retm_if(dev == NULL, "dev is NULL");
+
+       if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
+               if (bt_audio_connect(dev->addr_str,
+                                    BT_AUDIO_PROFILE_TYPE_A2DP) ==
+                   BT_ERROR_NONE) {
+                       ad->connect_req = TRUE;
+                       dev->status = BT_CONNECTING;
+                       _bt_lock_display();
+               } else {
+                       ERR("Fail to connect Headset device");
+               }
+       }
+       if (dev->genlist_item)
+       _bt_update_genlist_item((Elm_Object_Item *) dev->genlist_item);
+
+       FN_END;
+}
+
+void _bt_disconnect_device(bt_app_data_t *ad, bt_dev_t *dev)
+{
+       FN_START;
+
+       ret_if(ad == NULL);
+       ret_if(dev == NULL);
+
+       if (_bt_is_profile_connected
+               (BT_STEREO_HEADSET_CONNECTED, ad->conn,
+                dev->bd_addr) == TRUE) {
+               DBG("Disconnecting AV service");
+               if (bt_audio_disconnect(dev->addr_str,
+                                       BT_AUDIO_PROFILE_TYPE_A2DP) ==
+                   BT_ERROR_NONE) {
+                       ad->connect_req = TRUE;
+                       dev->status = BT_DISCONNECTING;
+               } else {
+                       ERR("Fail to connect Headset device");
+               }
+       }
+
+       _bt_update_genlist_item((Elm_Object_Item *) dev->genlist_item);
+
+       FN_END;
+}
+
+void _bt_create_group_title_item(bt_app_data_t *ad, const char *group)
+{
+       FN_START;
+
+       retm_if(ad == NULL, "Invalid argument: ad is NULL");
+
+       Elm_Object_Item *git = NULL;
+
+        if (g_strcmp0(group, GROUP_SEARCH) == 0) {
+               git = elm_genlist_item_append(ad->main_genlist,
+                               ad->searched_group_itc, ad, NULL,
+                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               ad->searched_title_item = git;
+       } else if (g_strcmp0(group, GROUP_PAIR) == 0) {
+               if (ad->searched_title_item == NULL) {
+                       git = elm_genlist_item_append(ad->main_genlist,
+                               ad->paired_title_itc, ad, NULL,
+                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               } else {
+                       git = elm_genlist_item_insert_before(ad->main_genlist,
+                               ad->paired_title_itc, ad, NULL,
+                               ad->searched_title_item,
+                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               }
+               ad->paired_title_item = git;
+       } else {
+               ERR("Invalid group");
+               return;
+       }
+
+       elm_genlist_item_select_mode_set(git,
+                       ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+       FN_END;
+}
+
+void _bt_remove_group_title_item(bt_app_data_t *ad, const char *group)
+{
+       FN_START;
+
+       retm_if(ad == NULL, "Invalid argument: ad is NULL");
+       retm_if(group == NULL, "Invalid argument: group is NULL");
+
+        if (g_strcmp0(group, GROUP_SEARCH) == 0) {
+               if (ad->searched_title_item) {
+                       elm_object_item_del(ad->searched_title_item);
+                       ad->searched_title_item = NULL;
+               }
+       } else if (g_strcmp0(group, GROUP_PAIR) == 0) {
+               if (ad->paired_title_item) {
+                       elm_object_item_del(ad->paired_title_item);
+                       ad->paired_title_item = NULL;
+               }
+       } else {
+               ERR("Invalid group");
+               return;
+       }
+
+       FN_END;
+}
+
+void _bt_remove_paired_device_item(bt_app_data_t *ad, bt_dev_t *dev)
+{
+       FN_START;
+
+       bt_dev_t *item = NULL;
+       Eina_List *l = NULL;
+       Eina_List *l_next = NULL;
+
+       retm_if(ad == NULL, "Invalid argument: ad is NULL");
+       retm_if(dev == NULL, "Invalid argument: dev is NULL");
+
+       EINA_LIST_FOREACH_SAFE(ad->paired_device, l, l_next, item) {
+               if (item && (item == dev)) {
+                       if (item->genlist_item)
+                               elm_object_item_del(item->genlist_item);
+                       ad->paired_device =
+                           eina_list_remove_list(ad->paired_device, l);
+                       _bt_util_free_device_item(item);
+               }
+       }
+
+       if (ad->paired_device == NULL ||
+               eina_list_count(ad->paired_device) == 0) {
+               if (ad->paired_title_item) {
+                       elm_object_item_del(ad->paired_title_item);
+                       ad->paired_title_item = NULL;
+               }
+       }
+
+       FN_END;
+       return;
+}
+void _bt_remove_searched_device_item(bt_app_data_t *ad, bt_dev_t *dev)
+{
+       FN_START;
+
+       bt_dev_t *item = NULL;
+       Eina_List *l = NULL;
+       Eina_List *l_next = NULL;
+
+       ret_if(ad == NULL);
+       ret_if(dev == NULL);
+
+       EINA_LIST_FOREACH_SAFE(ad->searched_device, l, l_next, item) {
+               if (item && (item == dev)) {
+                       if (dev->genlist_item) {
+                               elm_object_item_del(dev->genlist_item);
+                               dev->genlist_item = NULL;
+                       }
+                       ad->searched_device =
+                           eina_list_remove_list(ad->searched_device, l);
+                       _bt_util_free_device_item(item);
+               }
+       }
+
+       if (ad->searched_device == NULL ||
+           eina_list_count(ad->searched_device) == 0) {
+               _bt_remove_group_title_item(ad, GROUP_SEARCH);
+
+       }
+
+       FN_END;
+       return;
+}
+
+void _bt_remove_all_searched_devices_item(bt_app_data_t *ad)
+{
+       FN_START;
+
+       bt_dev_t *dev = NULL;
+       Eina_List *l = NULL;
+       Eina_List *l_next = NULL;
+       Elm_Object_Item *item;
+       Elm_Object_Item *next;
+
+       ret_if(ad == NULL);
+
+       if (ad->searched_title_item) {
+               item = elm_genlist_item_next_get(ad->searched_title_item);
+
+               while (item != NULL) {
+                       next = elm_genlist_item_next_get(item);
+                       elm_object_item_del(item);
+                       item = next;
+               }
+       }
+
+       EINA_LIST_FOREACH_SAFE(ad->searched_device, l, l_next, dev) {
+               ad->searched_device =
+                   eina_list_remove_list(ad->searched_device, l);
+               _bt_util_free_device_item(dev);
+       }
+
+       FN_END;
+       return;
+}
+
+Elm_Object_Item *_bt_add_paired_device_item(bt_app_data_t *ad, bt_dev_t *dev)
+{
+       FN_START;
+
+       Elm_Object_Item *git;
+
+       retvm_if(ad == NULL, NULL, "Invalid argument: ad is NULL");
+       retvm_if(dev == NULL, NULL, "Invalid argument: dev is NULL");
+
+       if (ad->paired_title_item == NULL)
+               _bt_create_group_title_item(ad, GROUP_PAIR);
+
+       /* Add the device item in the list */
+       git = elm_genlist_item_insert_after(ad->main_genlist, ad->device_itc,
+                                           dev, NULL, ad->paired_title_item,
+                                           ELM_GENLIST_ITEM_NONE,
+                                           __bt_paired_item_sel_cb, ad);
+
+       dev->genlist_item = git;
+       dev->status = BT_IDLE;
+       dev->ad = (void *)ad;
+       dev->is_bonded = TRUE;
+
+       FN_END;
+
+       return git;
+}
+
+Elm_Object_Item *_bt_add_searched_device_item(bt_app_data_t *ad, bt_dev_t *dev)
+{
+       FN_START;
+
+       Elm_Object_Item *git = NULL;
+
+       retvm_if(ad == NULL, NULL, "Invalid argument: ad is NULL");
+       retvm_if(dev == NULL, NULL, "Invalid argument: dev is NULL");
+
+       if (ad->searched_title_item == NULL)
+               _bt_create_group_title_item(ad, GROUP_SEARCH);
+
+       git = elm_genlist_item_append(ad->main_genlist,
+                               ad->searched_itc, dev, NULL,
+                               ELM_GENLIST_ITEM_NONE,
+                               __bt_searched_item_sel_cb, ad);
+
+       dev->genlist_item = git;
+       dev->status = BT_IDLE;
+       dev->ad = (void *)ad;
+       dev->is_bonded = FALSE;
+
+       _bt_update_genlist_item(ad->searched_title_item);
+       FN_END;
+
+       return git;
+}
+
+bt_dev_t *_bt_create_paired_device_info(void *data)
+{
+       int i;
+       unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
+       bt_dev_t *dev = NULL;
+       bt_device_info_s *dev_info = NULL;
+
+       retv_if(data == NULL, NULL);
+
+       dev_info = (bt_device_info_s *) data;
+
+       if (strlen(dev_info->remote_name) == 0)
+               return NULL;
+
+       dev = malloc(sizeof(bt_dev_t));
+       retv_if(dev == NULL, NULL);
+
+       memset(dev, 0, sizeof(bt_dev_t));
+       g_strlcpy(dev->name, dev_info->remote_name,
+                 BT_DEVICE_NAME_LENGTH_MAX + 1);
+
+       dev->major_class = dev_info->bt_class.major_device_class;
+       dev->minor_class = dev_info->bt_class.minor_device_class;
+       dev->service_class = dev_info->bt_class.major_service_class_mask;
+
+       if (dev_info->service_uuid != NULL && dev_info->service_count > 0) {
+               dev->uuids = g_new0(char *, dev_info->service_count + 1);
+
+               for (i = 0; i < dev_info->service_count; i++) {
+                       dev->uuids[i] = g_strdup(dev_info->service_uuid[i]);
+               }
+
+               dev->uuid_count = dev_info->service_count;
+       }
+
+       _bt_util_addr_string_to_addr_type(bd_addr, dev_info->remote_address);
+
+       memcpy(dev->addr_str, dev_info->remote_address, BT_ADDRESS_STR_LEN);
+
+       memcpy(dev->bd_addr, bd_addr, BT_ADDRESS_LENGTH_MAX);
+
+       _bt_util_get_service_mask_from_uuid_list(dev_info->service_uuid,
+                                                dev_info->service_count,
+                                                &dev->service_list);
+
+       DBG_SECURE("device name [%s]", dev->name);
+       DBG_SECURE("device major class [%x]", dev->major_class);
+       DBG_SECURE("device minor class [%x]", dev->minor_class);
+       DBG_SECURE("device service class [%x]", dev->service_class);
+       DBG_SECURE("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
+              dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
+              dev->bd_addr[4], dev->bd_addr[5]);
+
+       if (dev->major_class == BT_MAJOR_DEV_CLS_MISC &&
+               dev->service_list != BT_SC_NONE) {
+               _bt_util_update_class_of_device_by_service_list(dev->service_list,
+                                &dev->major_class, &dev->minor_class);
+       }
+
+       return dev;
+}
+
+bt_dev_t *_bt_create_searched_device_info(void *data)
+{
+       int i;
+       unsigned char bd_addr[BT_ADDRESS_LENGTH_MAX];
+       bt_dev_t *dev = NULL;
+       bt_adapter_device_discovery_info_s *dev_info = NULL;
+
+       retv_if(data == NULL, NULL);
+
+       dev_info = (bt_adapter_device_discovery_info_s *) data;
+
+       if (strlen(dev_info->remote_name) == 0)
+               return NULL;
+
+       dev = calloc(1, sizeof(bt_dev_t));
+       retv_if(dev == NULL, NULL);
+
+       strncpy(dev->name, dev_info->remote_name, BT_DEVICE_NAME_LENGTH_MAX);
+
+       dev->major_class = dev_info->bt_class.major_device_class;
+       dev->minor_class = dev_info->bt_class.minor_device_class;
+       dev->service_class = dev_info->bt_class.major_service_class_mask;
+       dev->rssi = dev_info->rssi;
+
+       if (dev_info->service_uuid != NULL && dev_info->service_count > 0) {
+               dev->uuids = g_new0(char *, dev_info->service_count + 1);
+
+               for (i = 0; i < dev_info->service_count; i++) {
+                       dev->uuids[i] = g_strdup(dev_info->service_uuid[i]);
+               }
+
+               dev->uuid_count = dev_info->service_count;
+       }
+
+       _bt_util_addr_string_to_addr_type(bd_addr, dev_info->remote_address);
+
+       memcpy(dev->addr_str, dev_info->remote_address, BT_ADDRESS_STR_LEN);
+
+       memcpy(dev->bd_addr, bd_addr, BT_ADDRESS_LENGTH_MAX);
+
+       DBG("device name [%s]", dev->name);
+       DBG("device major class [%x]", dev->major_class);
+       DBG("device minor class [%x]", dev->minor_class);
+       DBG("device service class [%x]", dev->service_class);
+       DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", dev->bd_addr[0],
+              dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3],
+              dev->bd_addr[4], dev->bd_addr[5]);
+
+       return dev;
+}
+
+gboolean _bt_is_matched_profile(unsigned int search_type,
+                                    unsigned int major_class,
+                                    unsigned int service_class)
+{
+       bt_device_major_mask_t major_mask = BT_DEVICE_MAJOR_MASK_MISC;
+
+       if (search_type == 0x000000)
+               return TRUE;
+
+       DBG("search_type: %x", search_type);
+       DBG("service_class: %x", service_class);
+
+       /* Check the major class */
+       switch (major_class) {
+       case BT_MAJOR_DEV_CLS_COMPUTER:
+               major_mask = BT_DEVICE_MAJOR_MASK_COMPUTER;
+               break;
+       case BT_MAJOR_DEV_CLS_PHONE:
+               major_mask = BT_DEVICE_MAJOR_MASK_PHONE;
+               break;
+       case BT_MAJOR_DEV_CLS_LAN_ACCESS_POINT:
+               major_mask = BT_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT;
+               break;
+       case BT_MAJOR_DEV_CLS_AUDIO:
+               major_mask = BT_DEVICE_MAJOR_MASK_AUDIO;
+               break;
+       case BT_MAJOR_DEV_CLS_PERIPHERAL:
+               major_mask = BT_DEVICE_MAJOR_MASK_PERIPHERAL;
+               break;
+       case BT_MAJOR_DEV_CLS_IMAGING:
+               major_mask = BT_DEVICE_MAJOR_MASK_IMAGING;
+               break;
+       case BT_MAJOR_DEV_CLS_WEARABLE:
+               major_mask = BT_DEVICE_MAJOR_MASK_WEARABLE;
+               break;
+       case BT_MAJOR_DEV_CLS_TOY:
+               major_mask = BT_DEVICE_MAJOR_MASK_TOY;
+               break;
+       case BT_MAJOR_DEV_CLS_HEALTH:
+               major_mask = BT_DEVICE_MAJOR_MASK_HEALTH;
+               break;
+       default:
+               major_mask = BT_DEVICE_MAJOR_MASK_MISC;
+               break;
+       }
+
+       DBG("major_mask: %x", major_mask);
+
+       if (search_type & major_mask)
+               return TRUE;
+
+       return FALSE;
+}
+
+bt_dev_t *_bt_get_dev_info(Eina_List *list,
+                               Elm_Object_Item *genlist_item)
+{
+       bt_dev_t *item = NULL;
+       Eina_List *l = NULL;
+
+       retvm_if(list == NULL, NULL, "Invalid argument: list is NULL");
+       retvm_if(genlist_item == NULL, NULL, "Invalid argument: obj is NULL");
+
+       EINA_LIST_FOREACH(list, l, item) {
+               if (item) {
+                       if (item->genlist_item == genlist_item)
+                               return item;
+               }
+       }
+
+       return NULL;
+}
+
+bt_dev_t *_bt_get_dev_info_by_address(Eina_List *list, char *address)
+{
+       bt_dev_t *item = NULL;
+       Eina_List *l = NULL;
+
+       retvm_if(list == NULL, NULL, "Invalid argument: list is NULL");
+       retvm_if(address == NULL, NULL, "Invalid argument: addr is NULL");
+
+       EINA_LIST_FOREACH(list, l, item) {
+               if (item) {
+                       if (memcmp(item->addr_str, address, BT_ADDRESS_STR_LEN)
+                           == 0)
+                               return item;
+               }
+       }
+
+       return NULL;
+}
+
+int _bt_check_and_update_device(Eina_List *list, char *addr, char *name)
+{
+       bt_dev_t *item = NULL;
+       Eina_List *l = NULL;
+
+       retv_if(list == NULL, -1);
+       retv_if(addr == NULL, -1);
+       retv_if(name == NULL, -1);
+
+       EINA_LIST_FOREACH(list, l, item) {
+               if (item) {
+                       if (memcmp(item->addr_str, addr, BT_ADDRESS_STR_LEN) ==
+                           0) {
+                               memset(item->name, 0x00,
+                                      BT_DEVICE_NAME_LENGTH_MAX);
+                               g_strlcpy(item->name, name,
+                                         BT_DEVICE_NAME_LENGTH_MAX);
+                               return 0;
+                       }
+               }
+       }
+
+       return -1;
+}
+
+
+void _bt_update_genlist_item(Elm_Object_Item *item)
+{
+       FN_START;
+       ret_if(!item);
+       elm_genlist_item_update(item);
+       FN_END;
+}
+
+void _bt_update_device_list(bt_app_data_t *ad)
+{
+       Eina_List *l = NULL;
+       bt_dev_t *dev = NULL;
+
+       ret_if(ad == NULL);
+
+       EINA_LIST_FOREACH(ad->paired_device, l, dev) {
+               if (dev)
+                       _bt_update_genlist_item((Elm_Object_Item *)
+                                               dev->genlist_item);
+       }
+
+       EINA_LIST_FOREACH(ad->searched_device, l, dev) {
+               if (dev)
+                       _bt_update_genlist_item((Elm_Object_Item *)
+                                               dev->genlist_item);
+       }
+}
+
+Evas_Object *_bt_create_list_view(bt_app_data_t *ad)
+{
+       FN_START;
+       retv_if(!ad, NULL);
+       retv_if(!ad->layout_btn, NULL);
+
+       int ret;
+
+       __bt_clear_genlist(ad);
+
+       ad->main_genlist = __bt_create_genlist(ad);
+
+       __bt_draw_paired_devices_items(ad);
+
+       if(ad->paired_device == NULL) {
+               if (ad->searched_title_item == NULL)
+                       _bt_create_group_title_item(ad, GROUP_SEARCH);
+               if (ad->op_status == BT_ACTIVATED) {
+                       ret = bt_adapter_start_discover_devices
+                                       (BT_ADAPTER_DEVICE_DISCOVERY_BREDR);
+                       if (ret == BT_ERROR_NONE || ret == BT_ERROR_NOW_IN_PROGRESS) {
+                               ad->op_status = BT_SEARCHING;
+                               _bt_lock_display();
+                               _bt_update_genlist_item(ad->searched_title_item);
+                               elm_object_text_set(ad->scan_btn, STR_STOP);
+                       }
+               }
+       }
+
+       evas_object_show(ad->main_genlist);
+
+       FN_END;
+       return ad->main_genlist;
+}
+
+int _bt_get_paired_device_count(bt_app_data_t *ad)
+{
+       FN_START;
+       retvm_if(!ad, 0, "ad is NULL!");
+       _bt_get_paired_devices(ad);
+       retvm_if(!ad->paired_device, 0, "paired_device is NULL!");
+       int count = eina_list_count(ad->paired_device);
+       DBG("paired device count : %d", count);
+       return count;
+}
+
+static gboolean __bt_auto_connect_system_popup_timer_cb(gpointer user_data)
+{
+       retv_if(user_data == NULL, FALSE);
+       int ret;
+       static int retry_count = 0;
+       bundle *b = (bundle *)user_data;
+
+       ++retry_count;
+
+       ret = syspopup_launch("bt-syspopup", b);
+       if (ret < 0) {
+               ERR("Sorry! Can't launch popup, ret=%d, Re-try[%d] time..",
+                                                       ret, retry_count);
+               if (retry_count >= BT_AUTO_CONNECT_SYSPOPUP_MAX_ATTEMPT) {
+                       ERR("Sorry!! Max retry %d reached", retry_count);
+                       bundle_free(b);
+                       retry_count = 0;
+                       return FALSE;
+               }
+       } else {
+               DBG("Finally Popup launched");
+               retry_count = 0;
+               bundle_free(b);
+       }
+
+       return (ret < 0) ? TRUE : FALSE;
+}
+
+void _bt_create_autoconnect_popup(bt_dev_t *dev)
+{
+       FN_START;
+
+       int ret;
+       bundle *b;
+       b = bundle_create();
+       retm_if (!b, "Unable to create bundle");
+
+       bundle_add(b, "event-type", "music-auto-connect-request");
+
+       ret = syspopup_launch("bt-syspopup", b);
+       if (0 > ret) {
+               DBG("Popup launch failed...retry %d", ret);
+
+               g_timeout_add(BT_AUTO_CONNECT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS,
+                                 (GSourceFunc)__bt_auto_connect_system_popup_timer_cb, b);
+       } else {
+               bundle_free(b);
+       }
+
+       FN_END;
+}
+
+void _bt_clean_app(bt_app_data_t *ad)
+{
+       FN_START;
+       if (ad == NULL)
+               return;
+
+       __bt_release_genlist_itc(ad);
+
+       if (ad->timer) {
+               ecore_timer_del(ad->timer);
+               ad->timer = NULL;
+       }
+
+       if (ad->popup) {
+               evas_object_del(ad->popup);
+               ad->popup = NULL;
+       }
+
+       if (ad->window) {
+               evas_object_del(ad->window);
+               ad->window = NULL;
+       }
+       FN_END;
+}
+
+void _bt_destroy_app(bt_app_data_t *ad)
+{
+       FN_START;
+       _bt_unlock_display();
+
+       if (ad) {
+               _bt_send_result(ad, ad->a2dp_connected);
+
+               /* Unref the Dbus connections */
+               if (ad->conn)
+                       dbus_g_connection_unref(ad->conn);
+
+               _bt_clean_app(ad);
+               _bt_deinit(ad);
+       }
+       elm_exit();
+}
+
diff --git a/src/bt-main.c b/src/bt-main.c
new file mode 100644 (file)
index 0000000..4d155af
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <app.h>
+#include <efl_assist.h>
+
+#include "bt-main.h"
+#include "bt-main-view.h"
+#include "bt-handler.h"
+#include "bt-util.h"
+#include "bt-string.h"
+
+static bool app_create(void *data)
+{
+       FN_START;
+
+       bt_app_data_t *ad;
+       ad = (bt_app_data_t *)data;
+       ad->window = _bt_create_win(PACKAGE);
+       if (ad->window == NULL)
+               return FALSE;
+
+       bindtextdomain(BT_COMMON_PKG, LOCALEDIR);
+       textdomain(BT_COMMON_PKG);
+
+       /* Handle rotation */
+       if (elm_win_wm_rotation_supported_get(ad->window)) {
+               int rots[4] = {0, 90, 180, 270};
+               elm_win_wm_rotation_available_rotations_set(ad->window, (const int *)(&rots), 4);
+       }
+
+       ad->conn = (void *)dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       _bt_init(ad);
+       FN_END;
+       return TRUE;
+}
+
+static void app_terminate(void *data)
+{
+       DBG("");
+       return;
+}
+
+static void app_pause(void *data)
+{
+       DBG("");
+       return;
+}
+
+static void app_resume(void *data)
+{
+       DBG("");
+       return;
+}
+
+static void app_service(service_h service, void *data)
+{
+       FN_START;
+
+       int ret;
+       char *value = NULL;
+       bt_app_data_t *ad;
+       ad = (bt_app_data_t *)data;
+       if (ad == NULL)
+               return;
+
+       if (ad->main_genlist != NULL) {
+               DBG("Window raise");
+               elm_win_raise(ad->window);
+               return;
+       }
+
+       service_clone(&ad->service, service);
+
+       ret = service_get_extra_data(service, "launch-type", &value);
+       retm_if (ret != SERVICE_ERROR_NONE, "service failed [%d]", ret);
+
+       _bt_util_set_value(value, &ad->search_type, &ad->launch_mode);
+
+       if (ad->launch_mode == BT_LAUNCH_CONNECT_HEADSET) {
+               if (_bt_get_paired_device_count(ad) == 1) {
+                       DBG("Launch mode is Headset");
+                       bt_dev_t *dev = eina_list_nth(ad->paired_device, 0);
+                       if(dev != NULL) {
+                               /* Check whether the only paired device is Headset */
+                               if (dev->major_class == BT_MAJOR_DEV_CLS_AUDIO &&
+                                       (dev->service_list & BT_SC_A2DP_SERVICE_MASK) > 0) {
+                                       DBG("Paired Item is Headset");
+                                       if ((dev->connected_mask & BT_STEREO_HEADSET_CONNECTED) == 0) {
+                                               DBG("Paired device count is 1. Autoconnecting [%s]",
+                                                       dev->name);
+                                               _bt_connect_device(ad, dev);
+                                               DBG("dev->status : %d", dev->status);
+                                               if (dev->status == BT_CONNECTING) {
+                                                       _bt_create_autoconnect_popup(dev);
+                                                       return;
+                                               }
+                                       }
+                               }
+                       }
+                       _bt_destroy_app(ad);
+                       return;
+               }
+       }
+
+       if (_bt_initialize_view(ad) < 0) {
+               ERR("_bt_initialize_view failed");
+               _bt_destroy_app(ad);
+       }
+
+       FN_END;
+       return;
+}
+
+static void app_lang_changed(void *data)
+{
+       FN_START;
+       ret_if(!data);
+       bt_app_data_t *ad = (bt_app_data_t *)data;
+       if (ad->scan_btn) {
+               if (ad->op_status == BT_SEARCHING)
+                       elm_object_text_set(ad->scan_btn, STR_STOP);
+               else
+                       elm_object_text_set(ad->scan_btn, STR_SCAN);
+       }
+       FN_END;
+       return;
+}
+
+static void app_regeion_changed(void *data)
+{
+       return;
+}
+
+/**
+* @describe
+*   The entry of the program
+*
+* @param    argc
+* @param    argv
+* @param    int
+* @exception
+*/
+DLL_DEFAULT int main(int argc, char *argv[])
+{
+       bt_app_data_t ad;
+       app_event_callback_s event_callback;
+
+       event_callback.create = app_create;
+       event_callback.terminate = app_terminate;
+       event_callback.pause = app_pause;
+       event_callback.resume = app_resume;
+       event_callback.service = app_service;
+       event_callback.low_memory = NULL;
+       event_callback.low_battery = NULL;
+       event_callback.device_orientation = NULL;
+       event_callback.language_changed = app_lang_changed;
+       event_callback.region_format_changed = app_regeion_changed;
+
+       memset(&ad, 0x0, sizeof(bt_app_data_t));
+       setenv("EVAS_NO_DRI_SWAPBUF", "1", 1);
+
+       return app_efl_main(&argc, &argv, &event_callback, &ad);
+
+}
diff --git a/src/bt-popup.c b/src/bt-popup.c
new file mode 100644 (file)
index 0000000..cdc5ebf
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+* bluetooth
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           Injun Yang <injun.yang@samsung.com>
+*           Seungyoun Ju <sy39.ju@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+
+#include "bt-main.h"
+#include "bt-main-view.h"
+#include "bt-string.h"
+#include "bt-handler.h"
+#include "bt-popup.h"
+
+
+static void __bt_draw_popup(bt_app_data_t *ad,
+                       const char *title, const char *msg, char *btn1_text,
+                       char *btn2_text, void (*func) (void *data,
+                       Evas_Object *obj, void *event_info), void *data)
+{
+       FN_START;
+       Evas_Object *btn1;
+       Evas_Object *btn2;
+       Evas_Object *scroller;
+       Evas_Object *label;
+       char *txt;
+
+       ad->popup = elm_popup_add(ad->window);
+       evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+
+       if (title != NULL)
+               elm_object_part_text_set(ad->popup, "title,text", title);
+
+       if (msg != NULL) {
+               scroller = elm_scroller_add(ad->popup);
+               elm_object_style_set(scroller, "effect");
+               evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
+                               EVAS_HINT_EXPAND);
+               elm_object_content_set(ad->popup, scroller);
+               evas_object_show(scroller);
+
+               label = elm_label_add(scroller);
+               elm_object_style_set(label, "popup/default");
+               elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+
+               txt = elm_entry_utf8_to_markup(msg);
+               elm_object_text_set(label, txt);
+               free(txt);
+
+               evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
+                               EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(label, EVAS_HINT_FILL,
+                               EVAS_HINT_FILL);
+               elm_object_content_set(scroller, label);
+       }
+
+       if ((btn1_text != NULL) && (btn2_text != NULL)) {
+               btn1 = elm_button_add(ad->popup);
+               elm_object_style_set(btn1, "popup");
+               elm_object_text_set(btn1, btn1_text);
+               elm_object_part_content_set(ad->popup, "button1", btn1);
+               evas_object_smart_callback_add(btn1, "clicked", func, data);
+
+               btn2 = elm_button_add(ad->popup);
+               elm_object_style_set(btn2, "popup");
+               elm_object_text_set(btn2, btn2_text);
+               elm_object_part_content_set(ad->popup, "button2", btn2);
+               evas_object_smart_callback_add(btn2, "clicked", func, data);
+       } else if (btn1_text != NULL) {
+               btn1 = elm_button_add(ad->popup);
+               elm_object_style_set(btn1, "popup");
+               elm_object_text_set(btn1, btn1_text);
+               elm_object_part_content_set(ad->popup, "button1", btn1);
+               evas_object_smart_callback_add(btn1, "clicked", func, data);
+       }
+
+       evas_object_show(ad->popup);
+       evas_object_show(ad->window);
+       elm_object_focus_set(ad->popup, EINA_TRUE);
+
+       FN_END;
+}
+
+static void __bt_unpair_confirm_cb(void *data,
+                                        Evas_Object *obj, void *event_info)
+{
+       FN_START;
+       if (obj == NULL || data == NULL)
+               return;
+
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *dev = (bt_dev_t *)data;
+
+       ret_if(dev->ad == NULL);
+       ad = dev->ad;
+       const char *event = elm_object_text_get(obj);
+
+       if (!g_strcmp0(event, STR_OK)) {
+               DBG("+ OK");
+               DBG("op_status : %d", ad->op_status);
+               if (ad->op_status == BT_UNPAIRING) {
+                       _bt_destroy_popup(ad);
+                       return;
+               }
+
+               ad->op_status = BT_UNPAIRING;
+               elm_object_item_disabled_set(dev->genlist_item, EINA_TRUE);
+               if (bt_device_destroy_bond(dev->addr_str) != BT_ERROR_NONE) {
+                       DBG("Fail to unpair");
+                       ad->op_status = BT_ACTIVATED;
+               }
+       }
+       _bt_destroy_popup(ad);
+       FN_END;
+}
+
+static void __bt_disconnection_confirm_cb(void *data,
+                                        Evas_Object *obj, void *event_info)
+{
+       FN_START;
+       if (obj == NULL || data == NULL)
+               return;
+
+       bt_app_data_t *ad = NULL;
+       bt_dev_t *dev = (bt_dev_t *)data;
+
+       ret_if(dev->ad == NULL);
+       ad = dev->ad;
+       const char *event = elm_object_text_get(obj);
+
+       if (!g_strcmp0(event, STR_OK)) {
+               DBG("+ OK");
+/*             dev = _bt_get_dev_info(ad->paired_device, ad->paired_item);*/
+               _bt_disconnect_device(ad, dev);
+       } else {
+               DBG("+ Cancel");
+       }
+
+       _bt_destroy_popup(ad);
+       FN_END;
+}
+
+void _bt_create_disconnection_query_popup(bt_dev_t *dev)
+{
+       FN_START;
+       bt_app_data_t *ad = NULL;
+       char message[BT_POPUP_TEXT_LENGTH] = { 0 };
+
+       ret_if(dev->ad == NULL);
+       ad = dev->ad;
+
+       _bt_destroy_popup(ad);
+       snprintf(message, BT_POPUP_TEXT_LENGTH,
+                        STR_DISCONNECT_DEV_Q, dev->name);
+
+       __bt_draw_popup(ad, STR_TITLE_DISCONNECT_Q,
+                       message,
+                       STR_CANCEL, STR_OK,
+                       __bt_disconnection_confirm_cb, dev);
+
+       FN_END;
+}
+
+void _bt_create_unpair_query_popup(bt_dev_t *dev)
+{
+       FN_START;
+       bt_app_data_t *ad = NULL;
+       char message[BT_POPUP_TEXT_LENGTH] = { 0 };
+
+       ret_if(dev->ad == NULL);
+       ad = dev->ad;
+
+       _bt_destroy_popup(ad);
+
+       snprintf(message, BT_POPUP_TEXT_LENGTH,
+                        STR_UNPAIR_DEV_Q, dev->name);
+
+       __bt_draw_popup(ad, STR_TITLE_UNPAIR_Q,
+                       message,
+                       STR_CANCEL, STR_OK,
+                       __bt_unpair_confirm_cb, dev);
+
+       FN_END;
+}
+
+void _bt_destroy_popup(bt_app_data_t *ad)
+{
+       FN_START;
+       ret_if(ad == NULL);
+
+       if (ad->popup) {
+               evas_object_del(ad->popup);
+               ad->popup = NULL;
+       }
+       FN_END;
+}
+
diff --git a/src/bt-util.c b/src/bt-util.c
new file mode 100644 (file)
index 0000000..a18be83
--- /dev/null
@@ -0,0 +1,648 @@
+/*
+* ug-setting-bluetooth-efl
+*
+* Copyright 2012 Samsung Electronics Co., Ltd
+*
+* Contact: Hocheol Seo <hocheol.seo@samsung.com>
+*           GirishAshok Joshi <girish.joshi@samsung.com>
+*           DoHyun Pyun <dh79.pyun@samsung.com>
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+#include <bluetooth.h>
+#include <vconf.h>
+#include <aul.h>
+#include <dd-display.h>
+
+#include "bt-main.h"
+#include "bt-main-view.h"
+#include "bt-util.h"
+/**********************************************************************
+*                                                Common Functions
+***********************************************************************/
+void _bt_lock_display()
+{
+       /* LCD Lock on */
+       int ret = display_lock_state(LCD_NORMAL, GOTO_STATE_NOW | HOLD_KEY_BLOCK, 0);
+       if (ret < 0)
+               ERR("LCD Lock failed");
+}
+
+void _bt_unlock_display()
+{
+       /* LCD Lock off */
+       int ret = display_unlock_state(LCD_NORMAL, PM_RESET_TIMER);
+       if (ret < 0)
+               ERR("LCD Unlock failed");
+}
+
+
+
+gboolean _bt_util_get_service_mask_from_uuid_list(char **uuids,
+                                     int no_of_service,
+                                     bt_service_class_t *service_mask_list)
+{
+       FN_START;
+
+       int i = 0;
+       unsigned int service = 0;
+       char **parts = NULL;
+       bt_service_class_t service_mask = 0;
+
+       retvm_if(uuids == NULL, FALSE,
+                "Invalid argument: service_list_array is NULL");
+
+       DBG("no_of_service = %d", no_of_service);
+
+       for (i = 0; i < no_of_service; i++) {
+               parts = g_strsplit(uuids[i], "-", -1);
+
+               if (parts == NULL || parts[0] == NULL) {
+                       g_strfreev(parts);
+                       continue;
+               }
+
+               service = g_ascii_strtoull(parts[0], NULL, 16);
+               g_strfreev(parts);
+
+               switch (service) {
+               case BT_SPP_PROFILE_UUID:
+                       service_mask |= BT_SC_SPP_SERVICE_MASK;
+                       break;
+
+               case BT_LAP_PROFILE_UUID:
+                       service_mask |= BT_SC_LAP_SERVICE_MASK;
+                       break;
+
+               case BT_DUN_PROFILE_UUID:
+                       service_mask |= BT_SC_DUN_SERVICE_MASK;
+                       break;
+
+               case BT_OBEX_IR_MC_SYNC_SERVICE_UUID:
+                       service_mask |= BT_SC_SYNC_SERVICE_MASK;
+                       break;
+
+               case BT_OBEX_OBJECT_PUSH_SERVICE_UUID:
+                       service_mask |= BT_SC_OPP_SERVICE_MASK;
+                       break;
+
+               case BT_OBEX_FILE_TRANSFER_UUID:
+                       service_mask |= BT_SC_FTP_SERVICE_MASK;
+                       break;
+
+               case BT_HS_PROFILE_UUID:
+                       service_mask |= BT_SC_HSP_SERVICE_MASK;
+                       break;
+
+               case BT_CTP_PROFILE_UUID:
+                       service_mask |= BT_SC_CTP_SERVICE_MASK;
+                       break;
+
+               case BT_AUDIO_SOURCE_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_AUDIO_SINK_UUID:
+                       service_mask |= BT_SC_A2DP_SERVICE_MASK;
+                       break;
+
+               case BT_VIDEO_SOURCE_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_VIDEO_SINK_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_AV_REMOTE_CONTROL_TARGET_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_ADVANCED_AUDIO_PROFILE_UUID:
+                       service_mask |= BT_SC_A2DP_SERVICE_MASK;
+                       break;
+
+               case BT_AV_REMOTE_CONTROL_UUID:
+                       service_mask |= BT_SC_AVRCP_SERVICE_MASK;
+                       break;
+
+               case BT_ICP_PROFILE_UUID:
+                       service_mask |= BT_SC_ICP_SERVICE_MASK;
+                       break;
+
+               case BT_FAX_PROFILE_UUID:
+                       service_mask |= BT_SC_FAX_SERVICE_MASK;
+                       break;
+
+               case BT_HEADSET_AG_SERVICE_UUID:
+                       service_mask |= BT_SC_NONE; /* BT_SC_HSP_SERVICE_MASK */
+                       break;
+
+               case BT_PAN_PANU_PROFILE_UUID:
+                       service_mask |= BT_SC_PANU_SERVICE_MASK;
+                       break;
+
+               case BT_PAN_NAP_PROFILE_UUID:
+                       service_mask |= BT_SC_NAP_SERVICE_MASK;
+                       break;
+
+               case BT_PAN_GN_PROFILE_UUID:
+                       service_mask |= BT_SC_GN_SERVICE_MASK;
+                       break;
+
+               case BT_REFERENCE_PRINTING:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_OBEX_IMAGING_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_OBEX_IMAGING_RESPONDER_UUID:
+                       service_mask |= BT_SC_BIP_SERVICE_MASK;
+                       break;
+
+               case BT_HF_PROFILE_UUID:
+                       service_mask |= BT_SC_HFP_SERVICE_MASK;
+                       break;
+
+               case BT_HFG_PROFILE_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_DIRECT_PRINTING_REFERENCE_OBJ_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_BASIC_PRINTING:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_HID_PROFILE_UUID:
+                       service_mask |= BT_SC_HID_SERVICE_MASK;
+                       break;
+
+               case BT_SIM_ACCESS_PROFILE_UUID:
+                       service_mask |= BT_SC_SAP_SERVICE_MASK;
+                       break;
+
+               case BT_OBEX_PBA_PROFILE_UUID:
+                       service_mask |= BT_SC_PBAP_SERVICE_MASK;
+                       break;
+
+               case BT_OBEX_BPPS_PROFILE_UUID:
+                       service_mask |= BT_SC_BPP_SERVICE_MASK;
+                       break;
+
+               case BT_PNP_INFORMATION_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_OBEX_PRINTING_STATUS_UUID:
+                       service_mask |= BT_SC_BPP_SERVICE_MASK;
+                       break;
+
+               case BT_HCR_PROFILE_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               case BT_OBEX_SYNCML_TRANSFER_UUID:
+                       service_mask |= BT_SC_NONE;
+                       break;
+
+               default:
+                       break;
+               }
+
+       }
+
+       *service_mask_list = service_mask;
+       DBG("service_mask = %x, service_mask_list = %x", service_mask,
+              service_mask_list);
+
+       FN_END;
+       return TRUE;
+}
+
+gboolean _bt_util_update_class_of_device_by_service_list(bt_service_class_t service_list,
+                                                bt_major_class_t *major_class,
+                                                bt_minor_class_t *minor_class)
+{
+       FN_START;
+
+       retvm_if(service_list == BT_SC_NONE, FALSE,
+                "Invalid argument: service_list is NULL");
+
+       /* set Major class */
+       if (service_list & BT_SC_HFP_SERVICE_MASK ||
+               service_list & BT_SC_HSP_SERVICE_MASK ||
+               service_list & BT_SC_A2DP_SERVICE_MASK) /* Handsfree device */
+               *major_class = BT_MAJOR_DEV_CLS_AUDIO;
+
+       /* set Minor class */
+       if (service_list & BT_SC_HFP_SERVICE_MASK ||
+               service_list & BT_SC_HSP_SERVICE_MASK)
+                       *minor_class = BTAPP_MIN_DEV_CLS_HEADSET_PROFILE;
+       else if (service_list & BT_SC_A2DP_SERVICE_MASK)
+                       *minor_class = BTAPP_MIN_DEV_CLS_HEADPHONES;
+
+       DBG("Updated major_class = %x, minor_class = %x", *major_class,
+              *minor_class);
+
+       FN_END;
+       return TRUE;
+}
+
+void _bt_util_set_value(const char *req, unsigned int *search_type,
+                       unsigned int *op_mode)
+{
+       FN_START;
+       ret_if(req == NULL);
+       ret_if(search_type == NULL);
+       ret_if(op_mode == NULL);
+
+       if (!strcasecmp(req, "send") || !strcasecmp(req, "browse")) {
+               *search_type = BT_COD_SC_OBJECT_TRANSFER;
+               *op_mode = BT_LAUNCH_SEND_FILE;
+       } else if (!strcasecmp(req, "print")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_IMAGING;
+               *op_mode = BT_LAUNCH_PRINT_IMAGE;
+       } else if (!strcasecmp(req, "call") || !strcasecmp(req, "sound")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_AUDIO;
+               *op_mode = BT_LAUNCH_CONNECT_HEADSET;
+       } else if (!strcasecmp(req, "nfc")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_MISC;
+               *op_mode = BT_LAUNCH_USE_NFC;
+       } else if (!strcasecmp(req, "pick")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_MISC;
+               *op_mode = BT_LAUNCH_PICK;
+       } else if (!strcasecmp(req, "visibility")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_MISC;
+               *op_mode = BT_LAUNCH_VISIBILITY;
+       } else if (!strcasecmp(req, "contact")) {
+               *search_type = BT_COD_SC_OBJECT_TRANSFER;
+               *op_mode = BT_LAUNCH_SHARE_CONTACT;
+       } else if (!strcasecmp(req, "help")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_MISC;
+               *op_mode = BT_LAUNCH_HELP;
+       } else if (!strcasecmp(req, "setting")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_AUDIO;
+               *op_mode = BT_LAUNCH_SETTING;
+       } else if (!strcasecmp(req, "spp")) {
+               *search_type = BT_DEVICE_MAJOR_MASK_PHONE;
+               *op_mode = BT_LAUNCH_SPP;
+       } else {
+               *search_type = BT_DEVICE_MAJOR_MASK_MISC;
+               *op_mode = BT_LAUNCH_NORMAL;
+       }
+
+       FN_END;
+
+       return;
+}
+
+gboolean _bt_util_store_get_value(const char *key, bt_store_type_t store_type,
+                             unsigned int size, void *value)
+{
+       FN_START;
+       retv_if(value == NULL, FALSE);
+
+       int ret = 0;
+       int int_value = 0;
+       int *intval = NULL;
+       gboolean *boolean = FALSE;
+       char *str = NULL;
+
+       switch (store_type) {
+       case BT_STORE_BOOLEAN:
+               boolean = (gboolean *)value;
+               ret = vconf_get_bool(key, &int_value);
+               if (ret != 0) {
+                       DBG("Get bool is failed");
+                       *boolean = FALSE;
+                       return FALSE;
+               }
+               *boolean = (int_value != FALSE);
+               break;
+       case BT_STORE_INT:
+               intval = (int *)value;
+               ret = vconf_get_int(key, intval);
+               if (ret != 0) {
+                       DBG("Get int is failed");
+                       *intval = 0;
+                       return FALSE;
+               }
+               break;
+       case BT_STORE_STRING:
+               str = vconf_get_str(key);
+               if (str == NULL) {
+                       DBG("Get string is failed");
+                       return FALSE;
+               }
+               if (size > 1)
+                       strncpy((char *)value, str, size - 1);
+
+               free(str);
+               break;
+       default:
+               DBG("Unknown Store Type");
+               return FALSE;
+       }
+
+       FN_END;
+       return TRUE;
+}
+
+void _bt_util_set_phone_name(void)
+{
+       char *phone_name = NULL;
+       char *ptr = NULL;
+
+       phone_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
+       if (!phone_name)
+               return;
+
+       if (strlen(phone_name) != 0) {
+                if (!g_utf8_validate(phone_name, -1, (const char **)&ptr))
+                        *ptr = '\0';
+
+               bt_adapter_set_name(phone_name);
+       }
+
+       free(phone_name);
+}
+
+int _bt_util_get_phone_name(char *phone_name, int size)
+{
+       FN_START;
+       retv_if(phone_name == NULL, BT_APP_FAIL);
+
+       if (_bt_util_store_get_value(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
+                                BT_STORE_STRING, size,
+                                (void *)phone_name) < 0) {
+               g_strlcpy(phone_name, BT_DEFAULT_PHONE_NAME, size);
+       }
+
+       FN_END;
+       return BT_APP_ERROR_NONE;
+}
+
+int _bt_util_get_timeout_value(int index)
+{
+       FN_START;
+
+       int timeout;
+
+       switch (index) {
+       case 0:
+               timeout = BT_ZERO;
+               break;
+       case 1:
+               timeout = BT_TWO_MINUTES;
+               break;
+       case 2:
+               timeout = BT_FIVE_MINUTES;
+               break;
+       case 3:
+               timeout = BT_ONE_HOUR;
+               break;
+       case 4:
+               timeout = BT_ALWAYS_ON;
+               break;
+       default:
+               timeout = BT_ZERO;
+               break;
+       }
+
+       FN_END;
+       return timeout;
+}
+
+int _bt_util_get_timeout_index(int timeout)
+{
+       FN_START;
+
+       int index = 0;
+
+       switch (timeout) {
+       case BT_ZERO:
+               index = 0;
+               break;
+       case BT_TWO_MINUTES:
+               index = 1;
+               break;
+       case BT_FIVE_MINUTES:
+               index = 2;
+               break;
+       case BT_ONE_HOUR:
+               index = 3;
+               break;
+       case BT_ALWAYS_ON:
+               index = 4;
+               break;
+       default:
+               index = 0;
+               break;
+       }
+
+       DBG("index: %d", index);
+
+       FN_END;
+       return index;
+}
+
+gboolean _bt_util_is_battery_low(void)
+{
+       FN_START;
+
+       int value = 0;
+       int charging = 0;
+
+       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, (void *)&charging))
+               DBG("Get the battery charging status fail");
+
+       if (charging == 1)
+               return FALSE;
+
+       DBG("charging: %d", charging);
+
+       if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, (void *)&value)) {
+               DBG("Get the battery low status fail");
+               return FALSE;
+       }
+
+       if (value <= VCONFKEY_SYSMAN_BAT_POWER_OFF)
+               return TRUE;
+
+       FN_END;
+       return FALSE;
+}
+
+gboolean _bt_util_is_flight_mode(void)
+{
+       FN_START;
+
+       int mode = 0;
+
+       if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &mode)) {
+               DBG("Get the flight mode fail");
+               return FALSE;
+       }
+
+       DBG("flight mode: %d", mode);
+
+       FN_END;
+       return mode ? TRUE : FALSE;
+}
+
+void _bt_util_addr_type_to_addr_string(char *address,
+                                              unsigned char *addr)
+{
+       FN_START;
+
+       ret_if(address == NULL);
+       ret_if(addr == NULL);
+
+       snprintf(address, BT_ADDRESS_STR_LEN, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr[0],
+               addr[1], addr[2], addr[3], addr[4], addr[5]);
+       FN_END;
+}
+
+void _bt_util_addr_type_to_addr_result_string(char *address,
+                                              unsigned char *addr)
+{
+       FN_START;
+
+       ret_if(address == NULL);
+       ret_if(addr == NULL);
+
+       snprintf(address, BT_ADDRESS_STR_LEN, "%2.2X-%2.2X-%2.2X-%2.2X-%2.2X-%2.2X", addr[0],
+               addr[1], addr[2], addr[3], addr[4], addr[5]);
+
+       FN_END;
+}
+
+void _bt_util_addr_type_to_addr_net_string(char *address,
+                                              unsigned char *addr)
+{
+       FN_START;
+
+       ret_if(address == NULL);
+       ret_if(addr == NULL);
+
+       snprintf(address, BT_ADDRESS_STR_LEN, "%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X", addr[0],
+               addr[1], addr[2], addr[3], addr[4], addr[5]);
+
+       FN_END;
+}
+
+void _bt_util_addr_string_to_addr_type(unsigned char *addr,
+                                                 const char *address)
+{
+       FN_START
+
+        int i;
+        char *ptr = NULL;
+
+        ret_if(!address || !addr);
+
+        for (i = 0; i < BT_ADDRESS_LENGTH_MAX; i++) {
+                addr[i] = strtol(address, &ptr, 16);
+               DBG("ptr[0] : %c", ptr[0]);
+                if (ptr[0] != '\0') {
+                        retm_if(ptr[0] != ':', "Unexpected string");
+                        address = ptr + 1;
+                }
+        }
+
+       FN_END;
+}
+
+void _bt_util_convert_time_to_string(unsigned int remain_time,
+                                       char *buf, int size)
+{
+       FN_START;
+       int minute;
+       int second;
+
+       ret_if(remain_time > BT_TIMEOUT_MAX);
+       ret_if(size < BT_EXTRA_STR_LEN);
+       ret_if(buf == NULL);
+
+       /* Get seconds */
+       second = remain_time % 60;
+
+       /* Get minutes */
+       minute = remain_time / 60;
+
+       snprintf(buf, size, "%d:%02d", minute, second);
+
+       FN_END;
+}
+
+void _bt_util_launch_no_event(void *data, void *obj, void *event)
+{
+       FN_START;
+       DBG
+           ("End key is pressed. But there is no action to process in popup");
+       FN_END;
+}
+
+void _bt_util_set_list_disabled(Evas_Object *genlist, Eina_Bool disable)
+{
+       FN_START;
+       Elm_Object_Item *item = NULL;
+       Elm_Object_Item *next = NULL;
+
+       item = elm_genlist_first_item_get(genlist);
+
+       while (item != NULL) {
+               next = elm_genlist_item_next_get(item);
+               if(item)
+                       elm_object_item_disabled_set(item, disable);
+
+               _bt_update_genlist_item(item);
+               item = next;
+       }
+       FN_END;
+}
+
+void _bt_util_free_device_uuids(bt_dev_t *item)
+{
+       int i;
+
+       ret_if(item == NULL);
+
+       if(item->uuids) {
+               for (i = 0; item->uuids[i] != NULL; i++)
+                       g_free(item->uuids[i]);
+
+               g_free(item->uuids);
+               item->uuids = NULL;
+       }
+}
+
+void _bt_util_free_device_item(bt_dev_t *item)
+{
+       ret_if(item == NULL);
+
+       _bt_util_free_device_uuids(item);
+
+//     if (item->net_profile)
+//             _bt_unset_profile_state_changed_cb(item->net_profile);
+
+       free(item);
+}
+