Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:44:03 +0000 (00:44 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:44:03 +0000 (00:44 +0900)
177 files changed:
.gitignore [new file with mode: 0755]
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
TC/_export_env.sh [new file with mode: 0644]
TC/_export_target_env.sh [new file with mode: 0644]
TC/bluetooth_TC/Makefile [new file with mode: 0644]
TC/bluetooth_TC/tslist [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_authorize_device.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_authorize_device.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_bond_device.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_bond_device.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_check_adapter.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_check_adapter.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_disable_adapter.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_disable_adapter.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_enable_adapter.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_enable_adapter.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_local_address.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_local_address.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_local_name.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_local_name.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_remote_device.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_get_remote_device.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_is_discovering.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_is_discovering.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_register_callback.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_register_callback.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_search_service.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_search_service.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_set_local_name.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_set_local_name.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_start_discovery.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_start_discovery.h [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_unbond_device.c [new file with mode: 0644]
TC/bluetooth_TC/uts_bluetooth_unbond_device.h [new file with mode: 0644]
TC/build.sh [new file with mode: 0644]
TC/clean.sh [new file with mode: 0644]
TC/execute.sh [new file with mode: 0755]
TC/making_new_tet_scen.py [new file with mode: 0755]
TC/tet_captured [new file with mode: 0644]
TC/tet_scen [new file with mode: 0644]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
TC/tslist.txt [new file with mode: 0644]
bluetooth-frwk-agent/CMakeLists.txt [new file with mode: 0644]
bluetooth-frwk-agent/bluetooth-agent-cb.c [new file with mode: 0644]
bluetooth-frwk-agent/bluetooth-agent.c [new file with mode: 0644]
bluetooth-frwk-agent/bluetooth-agent.edc [new file with mode: 0644]
bluetooth-frwk-agent/bluetooth-agent.h [new file with mode: 0644]
bluetooth-frwk-agent/bluetooth-agent.ini [new file with mode: 0644]
bluetooth-frwk-agent/bluetooth-frwk-agent [new file with mode: 0755]
bluetooth-frwk-agent/marshal.list [new file with mode: 0644]
bluetooth-frwk-agent/org.bluez.frwk_agent.service [new file with mode: 0644]
bluetooth-frwk-agent/po/CMakeLists.txt [new file with mode: 0644]
bluetooth-frwk-agent/po/POTFILES.in [new file with mode: 0644]
bluetooth-frwk-agent/po/bt-agent.pot [new file with mode: 0644]
bluetooth-frwk-agent/po/en_GB.po [new file with mode: 0644]
bluetooth-frwk-agent/po/en_US.po [new file with mode: 0644]
bluetooth-frwk-agent/po/ja.po [new file with mode: 0644]
bluetooth-frwk-agent/po/ko.po [new file with mode: 0644]
bluetooth-frwk-agent/po/update-po.sh [new file with mode: 0755]
bluetooth-frwk-agent/po/zh_CN.po [new file with mode: 0644]
bluetooth-frwk-agent/sc_core_agent.c [new file with mode: 0644]
bluetooth-frwk-agent/sc_core_agent.h [new file with mode: 0644]
bluetooth-frwk-agent/sc_core_agent.xml [new file with mode: 0644]
bluetooth-frwk-agent/stacktrim.h [new file with mode: 0644]
bluetooth-map-agent/CMakeLists.txt [new file with mode: 0644]
bluetooth-map-agent/bluetooth_map_agent.c [new file with mode: 0644]
bluetooth-map-agent/bluetooth_map_agent.h [new file with mode: 0644]
bluetooth-map-agent/bluetooth_map_agent.xml [new file with mode: 0644]
bluetooth-map-agent/org.bluez.map_agent.service [new file with mode: 0644]
bluetooth-media-control/CMakeLists.txt [new file with mode: 0644]
bluetooth-media-control/bluetooth-media-control-api.c [new file with mode: 0644]
bluetooth-media-control/bluetooth-media-control-api.h [new file with mode: 0644]
bluetooth-media-control/bluetooth-media-control.pc.in [new file with mode: 0644]
bluetooth-media-control/test/CMakeLists.txt [new file with mode: 0644]
bluetooth-media-control/test/bluetooth-media-control-test.c [new file with mode: 0644]
bluetooth-pb-agent/CMakeLists.txt [new file with mode: 0644]
bluetooth-pb-agent/bluetooth_pb_agent.c [new file with mode: 0644]
bluetooth-pb-agent/bluetooth_pb_agent.h [new file with mode: 0644]
bluetooth-pb-agent/bluetooth_pb_agent.xml [new file with mode: 0644]
bluetooth-pb-agent/org.bluez.pb_agent.service [new file with mode: 0644]
debian/bluetooth-frwk-0.postinst [new file with mode: 0644]
debian/bluetooth-frwk-agent.install.in [new file with mode: 0644]
debian/bluetooth-frwk-test.install.in [new file with mode: 0644]
debian/bluetooth-map-agent.install.in [new file with mode: 0644]
debian/bluetooth-pb-agent.install.in [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/libbluetooth-frwk-0.install.in [new file with mode: 0644]
debian/libbluetooth-frwk-dev.install.in [new file with mode: 0644]
debian/rules [new file with mode: 0755]
image/bluetooth_image001.png [new file with mode: 0644]
image/bluetooth_image002.png [new file with mode: 0644]
image/bluetooth_image003.png [new file with mode: 0644]
image/bluetooth_image004.png [new file with mode: 0644]
image/bluetooth_image005.png [new file with mode: 0644]
image/bluetooth_image006.png [new file with mode: 0644]
image/bluetooth_image007.png [new file with mode: 0644]
image/bluetooth_image008.png [new file with mode: 0644]
image/bluetooth_image009.png [new file with mode: 0644]
image/bluetooth_image010.png [new file with mode: 0644]
image/bluetooth_image011.png [new file with mode: 0644]
image/bluetooth_image012.png [new file with mode: 0644]
image/bluetooth_image013.png [new file with mode: 0644]
image/bluetooth_image014.png [new file with mode: 0644]
image/bluetooth_image015.png [new file with mode: 0644]
image/bluetooth_image016.png [new file with mode: 0644]
image/bluetooth_image017.png [new file with mode: 0644]
image/bluetooth_image018.png [new file with mode: 0644]
image/bluetooth_image019.png [new file with mode: 0644]
image/bluetooth_image020.png [new file with mode: 0644]
image/bluetooth_image021.png [new file with mode: 0644]
image/bluetooth_image022.png [new file with mode: 0644]
image/bluetooth_image023.png [new file with mode: 0644]
image/bluetooth_image024.png [new file with mode: 0644]
image/bluetooth_image025.png [new file with mode: 0644]
image/bluetooth_image026.png [new file with mode: 0644]
image/bluetooth_image027.png [new file with mode: 0644]
lib/CMakeLists.txt [new file with mode: 0644]
lib/SLP_BluetoothFW_PG.h [new file with mode: 0644]
lib/bluetooth-api-common.c [new file with mode: 0644]
lib/bluetooth-api-common.h [new file with mode: 0644]
lib/bluetooth-api.h [new file with mode: 0644]
lib/bluetooth-api.pc.in [new file with mode: 0644]
lib/bluetooth-gap-api.c [new file with mode: 0644]
lib/bluetooth-gap-api.h [new file with mode: 0644]
lib/bluetooth-hdp-api.c [new file with mode: 0644]
lib/bluetooth-hdp-api.h [new file with mode: 0644]
lib/bluetooth-network-api.c [new file with mode: 0644]
lib/bluetooth-network-api.h [new file with mode: 0644]
lib/bluetooth-obex-server-api.c [new file with mode: 0644]
lib/bluetooth-obex-server-api.h [new file with mode: 0644]
lib/bluetooth-opc-api.c [new file with mode: 0644]
lib/bluetooth-opc-api.h [new file with mode: 0644]
lib/bluetooth-rfcomm-api.c [new file with mode: 0644]
lib/bluetooth-rfcomm-api.h [new file with mode: 0644]
lib/bluetooth-sdp-api.c [new file with mode: 0644]
lib/bluetooth-sdp-api.h [new file with mode: 0644]
lib/marshal.list [new file with mode: 0644]
lib/obex-agent.c [new file with mode: 0644]
lib/obex-agent.h [new file with mode: 0644]
lib/obex-agent.xml [new file with mode: 0644]
lib/test/CMakeLists.txt [new file with mode: 0644]
lib/test/bluetooth-frwk-test.c [new file with mode: 0644]
packaging/bluetooth-frwk.spec [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100755 (executable)
index 0000000..6c53821
--- /dev/null
@@ -0,0 +1,12 @@
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
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..fca953f
--- /dev/null
@@ -0,0 +1,13 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+# API library
+ADD_SUBDIRECTORY(lib)
+
+# Bluetooth FW Agent
+ADD_SUBDIRECTORY(bluetooth-frwk-agent)
+
+# Phonebook FW Agent
+ADD_SUBDIRECTORY(bluetooth-pb-agent)
+
+# Message FW Agent
+ADD_SUBDIRECTORY(bluetooth-map-agent)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..a06208b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   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.
+
+   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,
+      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 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 in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) 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
+
+      (d) 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 Apache License to your work.
+
+      To apply the Apache 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 Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+   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/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100644 (file)
index 0000000..3c478e2
--- /dev/null
@@ -0,0 +1,15 @@
+export ARCH=target
+
+CURRENT_USER=`echo $HOME`
+export TET_INSTALL_PATH=$CURRENT_USER/sbs/TETware  # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100644 (file)
index 0000000..ad0b28f
--- /dev/null
@@ -0,0 +1,14 @@
+export ARCH=target
+
+export TET_INSTALL_PATH=/mnt/nfs/sbs/TETware  # path to mount
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+set $(pwd)
+export TET_SUITE_ROOT=$1
+
+set $(date +%s)
+FILE_NAME_EXTENSION=$1
diff --git a/TC/bluetooth_TC/Makefile b/TC/bluetooth_TC/Makefile
new file mode 100644 (file)
index 0000000..56fc34f
--- /dev/null
@@ -0,0 +1,71 @@
+PKG_CONFIG_PATH=/usr/lib/pkgconfig
+export PKG_CONFIG_PATH
+CC ?= gcc
+
+###################################################
+# add your TestCase List Here
+#
+# e.g.,
+# TC1 = utc_frameworkName_apiName_func
+# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
+TARGETS = uts_bluetooth_register_callback \
+uts_bluetooth_check_adapter \
+uts_bluetooth_enable_adapter \
+uts_bluetooth_authorize_device \
+uts_bluetooth_start_discovery \
+uts_bluetooth_cancel_discovery \
+uts_bluetooth_bond_device \
+uts_bluetooth_search_service \
+uts_bluetooth_cancel_service_search \
+uts_bluetooth_get_bonded_device_list \
+uts_bluetooth_unbond_device \
+uts_bluetooth_cancel_bonding \
+uts_bluetooth_get_discoverable_mode \
+uts_bluetooth_get_local_address \
+uts_bluetooth_get_local_name \
+uts_bluetooth_get_remote_device \
+uts_bluetooth_set_discoverable_mode \
+uts_bluetooth_set_local_name \
+uts_bluetooth_is_discovering \
+uts_bluetooth_rfcomm_create_socket \
+uts_bluetooth_rfcomm_remove_socket \
+uts_bluetooth_rfcomm_listen \
+uts_bluetooth_rfcomm_connect \
+uts_bluetooth_rfcomm_disconnect \
+uts_bluetooth_rfcomm_write \
+uts_bluetooth_disable_adapter
+       
+###################################################
+# add your Package Config Info Here
+#
+# e.g.,
+# PKGS=calendar
+PKGS=bluetooth-api glib-2.0
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+###################################################
+# Modify here 
+# depending on the Test Case you want to build
+# 
+# e.g.,
+# TCLIST = $(TC1) $(TC2)
+
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+       $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
+       rm -f tet_captured
+       rm -f tet_lock
+       rm -f *~
diff --git a/TC/bluetooth_TC/tslist b/TC/bluetooth_TC/tslist
new file mode 100644 (file)
index 0000000..d76baef
--- /dev/null
@@ -0,0 +1,26 @@
+uts_bluetooth_register_callback
+uts_bluetooth_check_adapter
+uts_bluetooth_enable_adapter
+uts_bluetooth_authorize_device
+uts_bluetooth_start_discovery
+uts_bluetooth_cancel_discovery
+uts_bluetooth_bond_device
+uts_bluetooth_search_service
+uts_bluetooth_cancel_service_search
+uts_bluetooth_get_bonded_device_list
+uts_bluetooth_unbond_device
+uts_bluetooth_cancel_bonding
+uts_bluetooth_get_discoverable_mode
+uts_bluetooth_get_local_address
+uts_bluetooth_get_local_name
+uts_bluetooth_get_remote_device
+uts_bluetooth_set_discoverable_mode
+uts_bluetooth_set_local_name
+uts_bluetooth_is_discovering
+uts_bluetooth_rfcomm_create_socket
+uts_bluetooth_rfcomm_remove_socket
+uts_bluetooth_rfcomm_listen
+uts_bluetooth_rfcomm_connect
+uts_bluetooth_rfcomm_disconnect
+uts_bluetooth_rfcomm_write
+uts_bluetooth_disable_adapter
diff --git a/TC/bluetooth_TC/uts_bluetooth_authorize_device.c b/TC/bluetooth_TC/uts_bluetooth_authorize_device.c
new file mode 100644 (file)
index 0000000..99837e4
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_authorize_device.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void utc_bluetooth_authorize_device_1(void)
+{
+       bluetooth_device_address_t device_address={{0}};
+       gboolean authorized;
+       int     return_17;
+               int ret_val;
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       authorized =TRUE;
+       return_17=bluetooth_authorize_device(NULL,authorized);
+       if(     return_17>=0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+void utc_bluetooth_authorize_device_2(void)
+{
+       bluetooth_device_address_t device_address={{0}};
+       gboolean authorized;
+       int     return_17;
+               int ret_val;
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       authorized=FALSE;
+       return_17=bluetooth_authorize_device(NULL,authorized);
+       if(     return_17>=0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+#if 0
+void utc_bluetooth_authorize_device_3(void)
+{
+       bluetooth_device_address_t* device_address;
+       gboolean authorized;
+       int     return_17;
+               int ret_val;
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       return_17=bluetooth_authorize_device(NULL, 0);
+       if(     return_17>=0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+#endif
diff --git a/TC/bluetooth_TC/uts_bluetooth_authorize_device.h b/TC/bluetooth_TC/uts_bluetooth_authorize_device.h
new file mode 100644 (file)
index 0000000..321bef3
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+//#include <dbus/dbus-glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_authorize_device_1(void);\r
+\r
+ void utc_bluetooth_authorize_device_2(void);\r
+\r
+ void utc_bluetooth_authorize_device_3(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_authorize_device_1,1},\r
+                               { utc_bluetooth_authorize_device_2,2},\r
+//                             { utc_bluetooth_authorize_device_3,3},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_bond_device.c b/TC/bluetooth_TC/uts_bluetooth_bond_device.c
new file mode 100644 (file)
index 0000000..0637a73
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_bond_device.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+
+                       g_main_loop_quit (main_loop);
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void utc_bluetooth_bond_device_1(void)
+{
+       //Replace the below BD address with the remote device BD address
+       bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}}; // SGH-W240(orange)
+
+       int return_12;
+       int ret_val;
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       return_12=bluetooth_bond_device(&device_address);
+       if(     return_12<0)
+       {
+       tet_printf("Api failed: %d", return_12);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(main_loop);
+       }
+}
+
+void utc_bluetooth_bond_device_2(void)
+{
+       bluetooth_device_address_t* device_address;
+       int return_12;
+       int ret_val;
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+       //device_address=NULL;
+       return_12=bluetooth_bond_device(NULL);
+       if(     return_12>=0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_bond_device.h b/TC/bluetooth_TC/uts_bluetooth_bond_device.h
new file mode 100644 (file)
index 0000000..96744ad
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+//#include <dbus/dbus-glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_bond_device_1(void);\r
+\r
+ void utc_bluetooth_bond_device_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_bond_device_1,1},\r
+                               { utc_bluetooth_bond_device_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c b/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.c
new file mode 100644 (file)
index 0000000..9bd1ba8
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_cancel_bonding.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void utc_bluetooth_cancel_bonding_1(void)
+{
+       int return_13;
+       int ret_val;
+
+       //Replace the below BD address with the remote device BD address
+       bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+       return_13=bluetooth_bond_device(&device_address);
+
+       return_13=bluetooth_cancel_bonding();
+       if(     return_13<0)
+       {
+       tet_printf("Api failed: %d", return_13);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+
+void utc_bluetooth_cancel_bonding_2(void)
+{
+
+       int return_13;
+       int ret_val;
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE) {
+               tet_printf("bluetooth_register_callback returned Success");
+       } else {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+       else
+               TC_PRT("BT state [0x%04x]", ret_val);
+
+       return_13 = bluetooth_cancel_bonding();
+
+       if (return_13 < 0) {
+               tet_printf("Api failed: %d", return_13);
+               tet_result(TET_FAIL);
+       } else {
+               tet_printf("Api passed");
+               tet_result(TET_PASS);
+       }
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h b/TC/bluetooth_TC/uts_bluetooth_cancel_bonding.h
new file mode 100644 (file)
index 0000000..055c8b0
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_cancel_bonding_1(void);\r
+\r
+ void utc_bluetooth_cancel_bonding_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_cancel_bonding_1,1},\r
+                               { utc_bluetooth_cancel_bonding_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c b/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.c
new file mode 100644 (file)
index 0000000..7c53ba4
--- /dev/null
@@ -0,0 +1,311 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_cancel_discovery.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+int thread_callback(void)\r
+{\r
+       int     return_10;\r
+       printf("thread_callback\n");\r
+       sleep(1);\r
+       return_10=bluetooth_cancel_discovery();\r
+       if(     return_10<0)\r
+       {\r
+       tet_printf("Api failedret_val=%d\nreturn_10=%d\n",return_10);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+        g_main_loop_quit (main_loop);\r
+       return 0;\r
+\r
+}\r
+\r
+\r
+void utc_bluetooth_cancel_discovery_1(void)\r
+{\r
+       unsigned max_response;\r
+       unsigned discovery_duration;\r
+       unsigned classOfDeviceMask;\r
+       int return_10;\r
+       int ret_val;\r
+       int ret = 0;\r
+       pthread_attr_t tattr;// = {0};\r
+       pthread_t thread_id;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       // Stop discovery if BT is in discovering.\r
+       bluetooth_cancel_discovery();\r
+\r
+       max_response =0;\r
+       discovery_duration =0;\r
+       classOfDeviceMask =0;\r
+       ret_val=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+\r
+       ret = pthread_attr_init(&tattr);\r
+       if (ret == 0)
+       {
+                       pthread_attr_setstacksize(&tattr, 131072);\r
+           ret = pthread_attr_setdetachstate(&tattr,  PTHREAD_CREATE_DETACHED);
+           if(ret == 0)
+           {
+                    ret = pthread_create(&thread_id, &tattr,\r
+                                                               thread_callback, NULL);\r
+                    if (ret != 0)
+                    {
+                               tet_printf( "Failed to create thread\n");\r
+                    }\r
+           }\r
+\r
+       }
+       else
+       {
+               tet_printf( "Failed to initialize thread attribute\n");\r
+       }\r
+\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+       g_main_loop_run(main_loop);\r
+}\r
+\r
+void utc_bluetooth_cancel_discovery_2(void)\r
+{\r
+\r
+       int return_10;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+\r
+       return_10=bluetooth_cancel_discovery();\r
+       if(     return_10 >= 0)\r
+       {\r
+       tet_printf("Api failed: %d", return_10);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h b/TC/bluetooth_TC/uts_bluetooth_cancel_discovery.h
new file mode 100644 (file)
index 0000000..736bf56
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_cancel_discovery_1(void);\r
+\r
+ void utc_bluetooth_cancel_discovery_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_cancel_discovery_1,1},\r
+                               { utc_bluetooth_cancel_discovery_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c b/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.c
new file mode 100644 (file)
index 0000000..b6d26b9
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_cancel_service_search.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+               case BLUETOOTH_EVENT_SERVICE_SEARCHED:
+               {
+                       printf("BLUETOOTH_EVENT_SERVICE_SEARCHED\n");
+                       break;
+               }
+               default:
+                       {
+                               TC_PRT("received event [0x%04x]", event);
+                               printf("received event [0x%04x]", event);
+                       }
+                       break;
+       }
+}
+
+int thread_callback(void)
+{
+       int     return_10;
+       printf("thread_callback\n");
+
+       return_10=bluetooth_cancel_service_search();
+
+       if(     return_10<0)
+       {
+       tet_printf("Api failedret_val=%d\n",return_10);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+               sleep(1);
+        g_main_loop_quit (main_loop);
+       return 0;
+
+}
+
+
+// Not proper case. The device is not general.
+// This will be always failed.
+/*How to test: pair devices . switch of BT in remote device . from native device initiate service search , as remote device is switch off native device will keep on searching for services,
+   then native device initiates cancel service search
+*/
+#if 0
+void utc_bluetooth_cancel_service_search_1(void)
+{
+        //Replace the below BD address with the device address of remote.
+       bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+       int     return_19;
+               int ret_val;
+               int ret=0;
+               pthread_attr_t tattr;// = {0};
+               pthread_t thread_id;
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       return_19=bluetooth_search_service(&device_address);
+       printf("bluetooth_search_service return=%d\n",return_19);
+
+       ret = pthread_attr_init(&tattr);
+       if (ret == 0)
+       {
+                       pthread_attr_setstacksize(&tattr, 131072);
+           ret = pthread_attr_setdetachstate(&tattr,  PTHREAD_CREATE_DETACHED);
+           if(ret == 0)
+           {
+                    ret = pthread_create(&thread_id, &tattr, thread_callback, NULL);
+                    if (ret != 0)
+                    {
+                               tet_printf( "Failed to create thread\n");
+                    }
+           }
+
+       }
+       else
+       {
+               tet_printf( "Failed to initialize thread attribute\n");
+       }
+       main_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(main_loop);
+
+}
+#endif
+
+void utc_bluetooth_cancel_service_search_1(void)
+{
+
+       int     return_19;
+               int ret_val;
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       return_19=bluetooth_cancel_service_search();
+       if(     return_19>=0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h b/TC/bluetooth_TC/uts_bluetooth_cancel_service_search.h
new file mode 100644 (file)
index 0000000..3d13312
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_cancel_service_search_1(void);\r
+\r
+ void utc_bluetooth_cancel_service_search_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_cancel_service_search_1,1},\r
+//                             { utc_bluetooth_cancel_service_search_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_check_adapter.c b/TC/bluetooth_TC/uts_bluetooth_check_adapter.c
new file mode 100644 (file)
index 0000000..6d0eba2
--- /dev/null
@@ -0,0 +1,334 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_check_adapter.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+pthread_t thread_t;\r
+pthread_attr_t tattr;// = {0};\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+//     {\r
+       //      g_main_loop_unref(main_loop);\r
+//     }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+int enable_thread_callback(void)\r
+{\r
+       int     return_3;\r
+       printf("thread_callback\n");\r
+       sleep(4);\r
+       printf("1\n");\r
+       return_3=bluetooth_check_adapter();\r
+       printf("2\n");\r
+       if(     return_3!=BLUETOOTH_ADAPTER_ENABLED)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+        g_main_loop_quit (main_loop);\r
+       return 0;\r
+\r
+}\r
+\r
+int disable_thread_callback(void)\r
+{\r
+       int     return_3;\r
+       printf("thread_callback\n");\r
+       sleep(4);\r
+       printf("1\n");\r
+       return_3=bluetooth_check_adapter();\r
+       printf("2\n");\r
+       if(     return_3!=BLUETOOTH_ADAPTER_DISABLED)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+        g_main_loop_quit (main_loop);\r
+       return 0;\r
+\r
+}\r
+\r
+\r
+void utc_bluetooth_check_adapter_1(void)\r
+{\r
+\r
+       int     return_3;\r
+               int ret_val;\r
+               int ret=0;\r
+               pthread_attr_t tattr;// = {0};\r
+               pthread_t thread_id;\r
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       return_3=bluetooth_check_adapter();\r
+\r
+       printf("2\n");\r
+       if(     return_3 < BLUETOOTH_ADAPTER_DISABLED || return_3 > BLUETOOTH_ADAPTER_CHANGING_DISABLE)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+\r
+/*\r
+       bluetooth_enable_adapter();\r
+\r
+       ret = pthread_attr_init(&tattr);\r
+       if (ret == 0)
+       {
+                       pthread_attr_setstacksize(&tattr, 131072);\r
+           ret = pthread_attr_setdetachstate(&tattr,  PTHREAD_CREATE_DETACHED);
+           if(ret == 0)
+           {
+                    ret = pthread_create(&thread_id, &tattr,\r
+                                                               enable_thread_callback, NULL);\r
+                    if (ret != 0)
+                    {
+                               tet_printf( "Failed to create thread\n");\r
+                    }\r
+           }\r
+\r
+       }
+       else
+       {
+               tet_printf( "Failed to initialize thread attribute\n");\r
+       }\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+       g_main_loop_run(main_loop);\r
+*/\r
+}\r
+\r
+void utc_bluetooth_check_adapter_2(void)\r
+{\r
+       int return_3;\r
+       int ret_val;\r
+       int ret=0;\r
+       pthread_attr_t tattr;// = {0};\r
+       pthread_t thread_id;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       bluetooth_disable_adapter();\r
+\r
+       ret = pthread_attr_init(&tattr);\r
+       if (ret == 0)
+       {
+                       pthread_attr_setstacksize(&tattr, 131072);\r
+           ret = pthread_attr_setdetachstate(&tattr,  PTHREAD_CREATE_DETACHED);
+           if(ret == 0)
+           {
+                    ret = pthread_create(&thread_id, &tattr,\r
+                                                               disable_thread_callback, NULL);\r
+                    if (ret != 0)
+                    {
+                               tet_printf( "Failed to create thread\n");\r
+                    }\r
+           }\r
+\r
+       }
+       else
+       {
+               tet_printf( "Failed to initialize thread attribute\n");\r
+       }\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+       g_main_loop_run(main_loop);\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_check_adapter.h b/TC/bluetooth_TC/uts_bluetooth_check_adapter.h
new file mode 100644 (file)
index 0000000..c73fa00
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+//#include <dbus/dbus-glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_check_adapter_1(void);\r
+\r
+ void utc_bluetooth_check_adapter_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_check_adapter_1,1},\r
+//                             { utc_bluetooth_check_adapter_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_disable_adapter.c b/TC/bluetooth_TC/uts_bluetooth_disable_adapter.c
new file mode 100644 (file)
index 0000000..516787c
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_disable_adapter.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+}
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       if( main_loop!= NULL)
+       {
+               g_main_loop_unref(main_loop);
+//             g_main_loop_quit(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       int return_2;
+
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               return_2=bluetooth_disable_adapter();
+
+
+                               if (main_loop)
+                                       g_main_loop_quit(main_loop);
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               return_2=bluetooth_disable_adapter();
+                               if(     return_2>=0)
+                               {
+                               tet_printf("Api Failed= %d\n",return_2);
+                               tet_result(TET_FAIL);
+                               }
+                               else
+                               {
+                               tet_printf("Api passed");
+                               tet_result(TET_PASS);
+                               }
+                       }
+
+                       if (main_loop)
+                               g_main_loop_quit(main_loop);
+
+                       if (main_loop)
+                               g_main_loop_quit(main_loop);
+
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+void bt_event_callback2(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       int return_2;
+
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               return_2=bluetooth_disable_adapter();
+                               if(     return_2>=0)
+                               {
+                               tet_printf("Api Failed= %d\n",return_2);
+                               tet_result(TET_FAIL);
+                               }
+                               else
+                               {
+                               tet_printf("Api passed");
+                               tet_result(TET_PASS);
+                               }
+                       }
+
+                       if (main_loop)
+                               g_main_loop_quit(main_loop);
+
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+void utc_bluetooth_disable_adapter_1(void)
+{
+       int return_2;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       if(bluetooth_enable_adapter()==BLUETOOTH_ERROR_NONE)
+       {
+
+       }
+       else
+               bluetooth_disable_adapter();
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+               g_main_loop_run(main_loop);
+
+//     if(main_loop != NULL)
+//     {
+//             g_main_loop_unref(main_loop);
+//     }
+
+
+//     return_2=bluetooth_enable_adapter();
+/*
+       return_2=bluetooth_disable_adapter();
+       if(     return_2<0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+*/
+}
+
+void utc_bluetooth_disable_adapter_2(void)
+{
+
+       int return_2;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback2, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       //bluetooth_disable_adapter();
+       return_2=bluetooth_disable_adapter();
+       if(     return_2>=0)
+       {
+       tet_printf("Api Failed= %d\n",return_2);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_disable_adapter.h b/TC/bluetooth_TC/uts_bluetooth_disable_adapter.h
new file mode 100644 (file)
index 0000000..1d18b1f
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_disable_adapter_1(void);\r
+\r
+ void utc_bluetooth_disable_adapter_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_disable_adapter_1,1},\r
+                               { utc_bluetooth_disable_adapter_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_enable_adapter.c b/TC/bluetooth_TC/uts_bluetooth_enable_adapter.c
new file mode 100644 (file)
index 0000000..9548932
--- /dev/null
@@ -0,0 +1,336 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_enable_adapter.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               tet_printf("Api passed");\r
+                               tet_result(TET_PASS);\r
+                       }\r
+                       else\r
+                       {\r
+                               tet_printf("Api failed");\r
+                               tet_result(TET_FAIL);\r
+                       }\r
+\r
+                       if (main_loop)\r
+                               g_main_loop_quit(main_loop);\r
+\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_enable_adapter();\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+void bt_event_callback2(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       int     return_1;\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               return_1=bluetooth_enable_adapter();\r
+                               if(return_1<0)\r
+                               {\r
+                                       tet_printf("Api passed");\r
+                                       tet_result(TET_PASS);\r
+                               }\r
+                               else\r
+                               {\r
+                                       tet_printf("Api failed");\r
+                                       tet_result(TET_FAIL);\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               tet_printf("Api failed");\r
+                               tet_result(TET_FAIL);\r
+                       }\r
+\r
+                       if (main_loop)\r
+                               g_main_loop_quit(main_loop);\r
+\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+void utc_bluetooth_enable_adapter_1(void)\r
+{\r
+       int return_1;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else if (ret_val == BLUETOOTH_ADAPTER_ENABLED)\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               tet_printf("Api passed");\r
+               tet_result(TET_PASS);\r
+       }\r
+\r
+       return_1=bluetooth_enable_adapter();\r
+\r
+       if(BLUETOOTH_ERROR_NONE!=return_1)\r
+       {\r
+               bluetooth_disable_adapter();\r
+       }\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+       g_main_loop_run(main_loop);\r
+/*\r
+       if(     return_1<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+*/\r
+}\r
+\r
+void utc_bluetooth_enable_adapter_2(void)\r
+{\r
+\r
+       int return_1;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback2, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       return_1=bluetooth_enable_adapter();\r
+       if(BLUETOOTH_ERROR_NONE!=return_1)\r
+       {\r
+               //bluetooth_disable_adapter();\r
+               tet_printf("Api passed");\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               main_loop = g_main_loop_new(NULL, FALSE);\r
+               g_main_loop_run(main_loop);\r
+       }\r
+\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_enable_adapter.h b/TC/bluetooth_TC/uts_bluetooth_enable_adapter.h
new file mode 100644 (file)
index 0000000..8ca28e3
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_enable_adapter_1(void);\r
+\r
+ void utc_bluetooth_enable_adapter_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_enable_adapter_1,1},\r
+                               { utc_bluetooth_enable_adapter_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c b/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.c
new file mode 100644 (file)
index 0000000..c5087eb
--- /dev/null
@@ -0,0 +1,139 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_get_bonded_device_list.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+       tet_printf("bluetooth framework TC cleanup");\r
+}\r
+\r
+void utc_bluetooth_get_bonded_device_list_1(void)\r
+{\r
+\r
+       int     return_15;\r
+       int ret_val;\r
+\r
+       GPtrArray *devinfo = NULL;\r
+\r
+       devinfo = g_ptr_array_new();\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_15=bluetooth_get_bonded_device_list(&devinfo);\r
+       if(return_15<BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("Api failed");\r
+               tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+               int i;\r
+               bluetooth_paired_device_info_t *ptr;\r
+               for(i=0; i<devinfo->len;i++)\r
+               {\r
+                       ptr = g_ptr_array_index(devinfo, i);\r
+                       if(ptr != NULL)\r
+                       {\r
+                               TC_PRT("Name [%s]", ptr->device_name.name);\r
+                               TC_PRT("Major Class [%d]", ptr->device_class.major_class);\r
+                               TC_PRT("Minor Class [%d]", ptr->device_class.minor_class);\r
+                               TC_PRT("Service Class [%d]", ptr->device_class.service_class);\r
+                               TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", ptr->device_address.addr[0], ptr->device_address.addr[1], ptr->device_address.addr[2], ptr->device_address.addr[3], ptr->device_address.addr[4], ptr->device_address.addr[5]);\r
+                               TC_PRT("\n");\r
+                       }\r
+               }\r
+               tet_printf("Api passed");\r
+               tet_result(TET_PASS);\r
+       }\r
+\r
+       g_ptr_array_free(devinfo, TRUE);\r
+}\r
+\r
+void utc_bluetooth_get_bonded_device_list_2(void)\r
+{\r
+       int     return_15;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_15=bluetooth_get_bonded_device_list(NULL);\r
+       if(return_15==BLUETOOTH_ERROR_INVALID_PARAM)\r
+       {\r
+               tet_printf("Api failed");\r
+               tet_result(TET_PASS);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("Api passed");\r
+               tet_result(TET_FAIL);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h b/TC/bluetooth_TC/uts_bluetooth_get_bonded_device_list.h
new file mode 100644 (file)
index 0000000..05a1f73
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <dbus/dbus-glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_get_bonded_device_list_1(void);\r
+\r
+ void utc_bluetooth_get_bonded_device_list_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_get_bonded_device_list_1,1},\r
+                               { utc_bluetooth_get_bonded_device_list_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c b/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.c
new file mode 100644 (file)
index 0000000..2a0533a
--- /dev/null
@@ -0,0 +1,267 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_get_discoverable_mode.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_get_discoverable_mode_1(void)\r
+{\r
+       bluetooth_discoverable_mode_t discoverable_mode_ptr;\r
+               bluetooth_discoverable_mode_t mode;\r
+       int     return_7;\r
+               int ret_val;\r
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+                mode = 3;\r
+\r
+       return_7=bluetooth_set_discoverable_mode(mode, 60); // 60 seconds\r
+\r
+       return_7=bluetooth_get_discoverable_mode(&discoverable_mode_ptr);\r
+       if(     return_7<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_get_discoverable_mode_2(void)\r
+{\r
+       bluetooth_discoverable_mode_t* discoverable_mode_ptr;\r
+       int     return_7;\r
+               int ret_val;\r
+               ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       discoverable_mode_ptr=NULL;\r
+       return_7=bluetooth_get_discoverable_mode(discoverable_mode_ptr);\r
+       if(     return_7>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h b/TC/bluetooth_TC/uts_bluetooth_get_discoverable_mode.h
new file mode 100644 (file)
index 0000000..e54f91f
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_get_discoverable_mode_1(void);\r
+\r
+ void utc_bluetooth_get_discoverable_mode_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_get_discoverable_mode_1,1},\r
+                               { utc_bluetooth_get_discoverable_mode_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_address.c b/TC/bluetooth_TC/uts_bluetooth_get_local_address.c
new file mode 100644 (file)
index 0000000..4fa4d8f
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_get_local_address.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void utc_bluetooth_get_local_address_1(void)
+{
+       bluetooth_device_address_t local_address;
+       //Replace the below BD address with the remote device BD address
+       bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       int return_4;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+
+       return_4=bluetooth_bond_device(&device_address);
+
+       return_4=bluetooth_get_local_address(&local_address);
+       if(     return_4<0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+void utc_bluetooth_get_local_address_2(void)
+{
+       bluetooth_device_address_t* local_address;
+       int return_4;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+       local_address=NULL;
+       return_4=bluetooth_get_local_address(local_address);
+       if(     return_4>=0)
+       {
+       tet_printf("Api failed");
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_address.h b/TC/bluetooth_TC/uts_bluetooth_get_local_address.h
new file mode 100644 (file)
index 0000000..8381438
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_get_local_address_1(void);\r
+\r
+ void utc_bluetooth_get_local_address_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_get_local_address_1,1},\r
+                               { utc_bluetooth_get_local_address_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_name.c b/TC/bluetooth_TC/uts_bluetooth_get_local_name.c
new file mode 100644 (file)
index 0000000..181b0b4
--- /dev/null
@@ -0,0 +1,269 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_get_local_name.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_get_local_name_1(void)\r
+{\r
+       bluetooth_device_name_t local_name={{"local Name"}};\r
+\r
+       int return_5;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_5=bluetooth_set_local_name(&local_name);\r
+\r
+       return_5=bluetooth_get_local_name(&local_name);\r
+       if(     return_5<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_get_local_name_2(void)\r
+{\r
+       bluetooth_device_name_t* local_name;\r
+       int return_5;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_5=bluetooth_get_local_name(NULL);\r
+       if(     return_5>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_local_name.h b/TC/bluetooth_TC/uts_bluetooth_get_local_name.h
new file mode 100644 (file)
index 0000000..8a4e912
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_get_local_name_1(void);\r
+\r
+ void utc_bluetooth_get_local_name_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_get_local_name_1,1},\r
+                               { utc_bluetooth_get_local_name_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_remote_device.c b/TC/bluetooth_TC/uts_bluetooth_get_remote_device.c
new file mode 100644 (file)
index 0000000..6a2d8fa
--- /dev/null
@@ -0,0 +1,311 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_get_remote_device.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+// Not support API\r
+#if 0\r
+void utc_bluetooth_get_remote_device_1(void)\r
+{\r
+       bluetooth_device_address_t device_address;\r
+       int return_16;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_16=bluetooth_get_remote_device(&device_address);\r
+       if(     return_16<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+#endif\r
+\r
+void utc_bluetooth_get_remote_device_1(void)\r
+{\r
+       const bluetooth_device_address_t device_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};\r
+       int return_16;\r
+       int ret_val;\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       //device_address=NULL;\r
+       return_16=bluetooth_get_remote_device(&device_address);\r
+       if(     return_16<0)\r
+       {\r
+       tet_printf("Api failed: %d", return_16);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_get_remote_device_2(void)\r
+{\r
+       bluetooth_device_address_t* device_address;\r
+       int return_16;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       device_address=NULL;\r
+       return_16=bluetooth_get_remote_device(device_address);\r
+       if(     return_16>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_get_remote_device.h b/TC/bluetooth_TC/uts_bluetooth_get_remote_device.h
new file mode 100644 (file)
index 0000000..e090941
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <dbus/dbus-glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_get_remote_device_1(void);\r
+\r
+ void utc_bluetooth_get_remote_device_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_get_remote_device_1,1},\r
+                               { utc_bluetooth_get_remote_device_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_is_discovering.c b/TC/bluetooth_TC/uts_bluetooth_is_discovering.c
new file mode 100644 (file)
index 0000000..695e510
--- /dev/null
@@ -0,0 +1,316 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_is_discovering.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+\r
+       if( main_loop!= NULL)\r
+       {\r
+               g_main_loop_unref(main_loop);\r
+               g_main_loop_quit(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       if (main_loop)\r
+                                       g_main_loop_quit(main_loop);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+int thread_callback(void)\r
+{\r
+       int     return_11;\r
+       printf("thread_callback\n");\r
+       sleep(1);\r
+       return_11=bluetooth_is_discovering();\r
+       if(     return_11==0)\r
+       {\r
+       tet_printf("Api failed,=%d\n",return_11);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+\r
+       // let the discovery stop before quit so that when utc_bluetooth_is_discovering_2 is called discovery should be off\r
+       bluetooth_cancel_discovery();\r
+\r
+       g_main_loop_quit (main_loop);\r
+       return 0;\r
+\r
+}\r
+\r
+\r
+void utc_bluetooth_is_discovering_1(void)\r
+{\r
+       int return_11;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_11=bluetooth_is_discovering();\r
+       if(     return_11==1)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_is_discovering_2(void)\r
+{\r
+       unsigned max_response;\r
+       unsigned discovery_duration;\r
+       unsigned classOfDeviceMask;\r
+       int return_11;\r
+       int ret_val;\r
+       int ret=0;\r
+       pthread_attr_t tattr;// = {0};\r
+       pthread_t thread_id;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       max_response =0;\r
+       discovery_duration =0;\r
+       classOfDeviceMask =0;\r
+       return_11=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+\r
+       ret = pthread_attr_init(&tattr);\r
+       if (ret == 0)
+       {
+                       pthread_attr_setstacksize(&tattr, 131072);\r
+           ret = pthread_attr_setdetachstate(&tattr,  PTHREAD_CREATE_DETACHED);
+           if(ret == 0)
+           {
+                    ret = pthread_create(&thread_id, &tattr,\r
+                                                               thread_callback, NULL);\r
+                    if (ret != 0)
+                    {
+                               tet_printf( "Failed to create thread\n");\r
+                    }\r
+           }\r
+\r
+       }
+       else
+       {
+               tet_printf( "Failed to initialize thread attribute\n");\r
+       }\r
+\r
+\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+       g_main_loop_run(main_loop);\r
+}\r
+\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_is_discovering.h b/TC/bluetooth_TC/uts_bluetooth_is_discovering.h
new file mode 100644 (file)
index 0000000..9f4e64e
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_is_discovering_1(void);\r
+\r
+ void utc_bluetooth_is_discovering_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_is_discovering_1,1},\r
+                               { utc_bluetooth_is_discovering_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_register_callback.c b/TC/bluetooth_TC/uts_bluetooth_register_callback.c
new file mode 100644 (file)
index 0000000..09be1a0
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_register_callback.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void utc_bluetooth_register_callback_1(void)
+{
+       bluetooth_cb_func_ptr callback_ptr;
+       int return_0;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+               tet_result(TET_PASS);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+               tet_result(TET_FAIL);
+               return 0;
+       }
+}
+
+void utc_bluetooth_register_callback_2(void)
+{
+       bluetooth_cb_func_ptr callback_ptr;
+       int return_0;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(NULL, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+               tet_result(TET_PASS);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+               tet_result(TET_FAIL);
+               return 0;
+       }
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_register_callback.h b/TC/bluetooth_TC/uts_bluetooth_register_callback.h
new file mode 100644 (file)
index 0000000..add468b
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_register_callback_1(void);\r
+\r
+ void utc_bluetooth_register_callback_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_register_callback_1,1},\r
+                               { utc_bluetooth_register_callback_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.c
new file mode 100644 (file)
index 0000000..1247d12
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_rfcomm_connect.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+int g_ret_client_fd1 = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data;
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result,
+                                                               con_ind->socket_fd,
+                                                               con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2],
+                                                               con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5],
+                                                               (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT");
+                       //tc_result(TC_PASS, 22);
+                       if(con_ind->device_role == RFCOMM_ROLE_CLIENT)
+                               g_ret_client_fd1 = con_ind->socket_fd;
+
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+void uts_bluetooth_rfcomm_connect_1(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+
+       //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+
+       //remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+       //remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       return_22= bluetooth_rfcomm_connect(&remote_address, NULL);
+       printf("sk=%x\n",sk);
+       if(     return_22>=0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+void uts_bluetooth_rfcomm_connect_2(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+       const bluetooth_device_address_t remote_address={{0}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+
+       //remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x00; remote_address.addr[2] = 0x00;
+       //remote_address.addr[3]= 0x00; remote_address.addr[4] = 0x00;  remote_address.addr[5]= 0x00;
+
+       return_22= bluetooth_rfcomm_connect(NULL, rfcomm_test_uuid_spp);
+       printf("sk=%x\n",sk);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+#if 0
+void uts_bluetooth_rfcomm_connect_3(void)
+{
+       int sk;
+       int max_pending_connection;
+       int     return_22;
+       int ret_val;
+       ret_val = bluetooth_register_callback(bt_event_callback);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+
+       return_22= bluetooth_rfcomm_connect(NULL, rfcomm_test_uuid_spp);
+       printf("sk=%x\n",sk);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+#endif
+void uts_bluetooth_rfcomm_connect_4(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+       //Replace the below BD address with the remote device BD address
+
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+
+       //remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x0D; remote_address.addr[2] = 0x18;
+       //remote_address.addr[3]= 0x01; remote_address.addr[4] = 0x24;  remote_address.addr[5]= 0x47;
+
+       return_22= bluetooth_rfcomm_connect(&remote_address, "00000000-0000-0000-0000-000000000000");
+       printf("sk=%x\n",sk);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+#if 0
+void uts_bluetooth_rfcomm_connect_5(void)
+{
+       int sk;
+       int max_pending_connection;
+       int     return_22;
+       int ret_val;
+       ret_val = bluetooth_register_callback(bt_event_callback);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+
+       return_22= bluetooth_rfcomm_connect(NULL, NULL);
+       printf("sk=%x\n",sk);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+#endif
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_connect.h
new file mode 100644 (file)
index 0000000..a9b2863
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include <bluetooth-api.h>
+#include <tet_api.h>
+
+static void startup();
+
+static void cleanup();
+
+
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+void uts_bluetooth_rfcomm_connect_1(void);
+void uts_bluetooth_rfcomm_connect_2(void);
+//void uts_bluetooth_rfcomm_connect_3(void);
+void uts_bluetooth_rfcomm_connect_4(void);
+//void uts_bluetooth_rfcomm_connect_5(void);
+
+
+ void uts_bluetooth_rfcomm_create_sock_2(void);
+
+ struct tet_testlist tet_testlist[] =  {
+                               { uts_bluetooth_rfcomm_connect_1,1},
+                               { uts_bluetooth_rfcomm_connect_2,2},
+//                             { uts_bluetooth_rfcomm_connect_3,3},
+                               { uts_bluetooth_rfcomm_connect_4,3},
+//                             { uts_bluetooth_rfcomm_connect_5,5},
+                               {NULL,0}
+                       };
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.c
new file mode 100644 (file)
index 0000000..228868e
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_rfcomm_create_socket.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void uts_bluetooth_rfcomm_create_sock_1(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       return_22= sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
+       printf("sk=%x\n",sk);
+       if(     return_22<0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+void uts_bluetooth_rfcomm_create_sock_2(void)
+{
+       int sk;
+       int max_pending_connection;
+       int  return_22;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       return_22=bluetooth_rfcomm_create_socket(NULL);
+       printf("sk=%x\n",sk);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_create_socket.h
new file mode 100644 (file)
index 0000000..bba8e9e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include <bluetooth-api.h>
+#include <tet_api.h>
+
+static void startup();
+
+static void cleanup();
+
+
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ void uts_bluetooth_rfcomm_create_sock_1(void);
+
+ void uts_bluetooth_rfcomm_create_sock_2(void);
+
+ struct tet_testlist tet_testlist[] =  {
+                               { uts_bluetooth_rfcomm_create_sock_1,1},
+                               { uts_bluetooth_rfcomm_create_sock_2,2},
+                               {NULL,0}
+                       };
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.c
new file mode 100644 (file)
index 0000000..b938b49
--- /dev/null
@@ -0,0 +1,304 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_rfcomm_disconnect.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+int g_ret_client_fd1 = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+//     main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       if( main_loop!= NULL)
+       {
+               g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       int     return_22;
+                       bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data;
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result,
+                                                               con_ind->socket_fd,
+                                                               con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2],
+                                                               con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5],
+                                                               (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT");
+                       //tc_result(TC_PASS, 22);
+                       tet_printf("g_ret_client_fd1=%d\nconn_ind->socket_fd %d\n",g_ret_client_fd1,con_ind->socket_fd);
+                       tet_printf("con_ind->device_role=%d\n",con_ind->device_role);
+                       if(con_ind->device_role == RFCOMM_ROLE_CLIENT)
+                               g_ret_client_fd1 = con_ind->socket_fd;
+
+                       return_22=bluetooth_rfcomm_disconnect( g_ret_client_fd1);
+                       if(     return_22<0)
+                       {
+                       tet_printf("BLUETOOTH_EVENT_RFCOMM_CONNECTED Api failed, return_22=%d\n",return_22);
+                       tet_result(TET_FAIL);
+                       }
+                       else
+                       {
+                       tet_printf("Api passed");
+                       tet_result(TET_PASS);
+                       }
+
+                        g_main_loop_quit (main_loop);
+//                     if( main_loop!= NULL)
+//                     {
+//                             g_main_loop_unref(main_loop);
+//                     }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+#if 0
+void uts_bluetooth_rfcomm_disconnect_1(void)
+{
+       int sk;
+       int max_pending_connection;
+       int     return_22;
+       int ret_val;
+        //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+       ret_val = bluetooth_register_callback(bt_event_callback);
+//     main_loop = g_main_loop_new(NULL, FALSE);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+//     remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+//     remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       return_22= bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp);
+       tet_printf(" bluetooth_rfcomm_connectApi , return_22=%d\n",return_22);
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(main_loop);
+}
+#endif
+
+void uts_bluetooth_rfcomm_disconnect_1(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+        //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+/*Mention bd address of device to which you want to connect*/
+//     remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+//     remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       //bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp);
+
+       return_22=bluetooth_rfcomm_disconnect( -1);
+       printf("sk=%x\n",sk);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_disconnect.h
new file mode 100644 (file)
index 0000000..7316f19
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include <bluetooth-api.h>
+#include <tet_api.h>
+
+static void startup();
+
+static void cleanup();
+
+
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ void uts_bluetooth_rfcomm_disconnect_1(void);
+
+ void uts_bluetooth_rfcomm_disconnect_2(void);
+
+ struct tet_testlist tet_testlist[] =  {
+                               { uts_bluetooth_rfcomm_disconnect_1,1},
+//                             { uts_bluetooth_rfcomm_disconnect_2,2},
+                               {NULL,0}
+                       };
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.c
new file mode 100644 (file)
index 0000000..fe784e6
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_rfcomm_listen.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       if( main_loop!= NULL)
+       {
+               g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED, result [0x%04x]", param->result);
+                       bluetooth_rfcomm_received_data_t *rx_data = param->param_data;
+                       printf("\n FD = %d \nBuffer len = %d ", rx_data->socket_fd, rx_data->buffer_size);
+
+                       printf("received data=%s\n",rx_data);
+                       tet_printf("Api passed");
+                       tet_result(TET_PASS);
+                       //tc_result(TC_PASS, 21);
+
+
+                        g_main_loop_quit (main_loop);
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void utc_bluetooth_rfcomm_listen_1(void)
+{
+       int sk;
+       int max_pending_connection;
+       int  return_22;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+       sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
+       printf("sk=%x\n",sk);
+//     return_22=bluetooth_rfcomm_listen(sk,max_pending_connection);
+       return_22= bluetooth_rfcomm_listen_and_accept(sk,1);
+       if(     return_22<0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+void utc_bluetooth_rfcomm_listen_2(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+       sk=-1;
+       max_pending_connection=1000000;
+
+       return_22= bluetooth_rfcomm_listen_and_accept(sk,max_pending_connection);
+
+       if(     return_22>=0)
+       {
+       tet_printf("Api failed result_22=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+#if 0
+void utc_bluetooth_rfcomm_listen_3(void)
+{
+       int sk;
+       int max_pending_connection;
+       int     return_22;
+               int ret_val;
+               ret_val = bluetooth_register_callback(bt_event_callback);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               //tc_result(TC_PASS, 3);
+       }
+       sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
+       printf("sk=%x\n",sk);
+//     return_22=bluetooth_rfcomm_listen(sk,max_pending_connection);
+       return_22= bluetooth_rfcomm_listen_and_accept(sk,1);
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(main_loop);
+}
+#endif
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_listen.h
new file mode 100644 (file)
index 0000000..46f2c04
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_rfcomm_listen_1(void);\r
+\r
+ void utc_bluetooth_rfcomm_listen_2(void);\r
+\r
+ void utc_bluetooth_rfcomm_listen_3(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_rfcomm_listen_1,1},\r
+                               { utc_bluetooth_rfcomm_listen_2,2},\r
+//                             { utc_bluetooth_rfcomm_listen_3,3},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.c
new file mode 100644 (file)
index 0000000..cc729cb
--- /dev/null
@@ -0,0 +1,265 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_rfcomm_remove_socket.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       //main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       //if( main_loop!= NULL)
+       {
+       //      g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+
+void uts_bluetooth_rfcomm_remove_socket_1(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       sk=bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
+       printf("sk=%x\n",sk);
+       return_22= bluetooth_rfcomm_remove_socket(sk, rfcomm_test_uuid_spp);
+       if(     return_22<0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+void uts_bluetooth_rfcomm_remove_socket_2(void)
+{
+       int sk;
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+       sk=-1;
+       printf("sk=%x\n",sk);
+       return_22= bluetooth_rfcomm_remove_socket(sk, rfcomm_test_uuid_spp);
+       if(     return_22>0)
+       {
+       tet_printf("Api failed,=%d\n",return_22);
+       tet_result(TET_FAIL);
+       }
+       else
+       {
+       tet_printf("Api passed");
+       tet_result(TET_PASS);
+       }
+}
+
+
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_remove_socket.h
new file mode 100644 (file)
index 0000000..7c64130
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include <bluetooth-api.h>
+#include <tet_api.h>
+
+static void startup();
+
+static void cleanup();
+
+
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ void uts_bluetooth_rfcomm_remove_socket_1(void);
+
+ void uts_bluetooth_rfcomm_remove_socket_2(void);
+
+ struct tet_testlist tet_testlist[] =  {
+                               { uts_bluetooth_rfcomm_remove_socket_1,1},
+                               { uts_bluetooth_rfcomm_remove_socket_2,2},
+                               {NULL,0}
+                       };
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.c
new file mode 100644 (file)
index 0000000..7579b92
--- /dev/null
@@ -0,0 +1,268 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_rfcomm_sock_deregister_with_uuid.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_rfcomm_sock_deregister_with_uuid_1(void)\r
+{\r
+       char uuid[]="id";\r
+       int return_21;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_21=bluetooth_rfcomm_sock_register_with_uuid(&uuid);\r
+\r
+       return_21=bluetooth_rfcomm_sock_deregister_with_uuid(uuid);\r
+       if(     return_21<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_rfcomm_sock_deregister_with_uuid_2(void)\r
+{\r
+       char* uuid;\r
+       int return_21;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       uuid=NULL;\r
+       return_21=bluetooth_rfcomm_sock_deregister_with_uuid(uuid);\r
+       if(     return_21>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_deregister_with_uuid.h
new file mode 100644 (file)
index 0000000..1d8f4e5
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_rfcomm_sock_deregister_with_uuid_1(void);\r
+\r
+ void utc_bluetooth_rfcomm_sock_deregister_with_uuid_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_rfcomm_sock_deregister_with_uuid_1,1},\r
+                               { utc_bluetooth_rfcomm_sock_deregister_with_uuid_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.c
new file mode 100644 (file)
index 0000000..b851d95
--- /dev/null
@@ -0,0 +1,266 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_rfcomm_sock_register_with_uuid.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_rfcomm_sock_register_with_uuid_1(void)\r
+{\r
+       char uuid[]="00000000-0000-1000-8000-00805F9B34FB";//"id";\r
+       int return_20;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       //uuid =NULL;//assign value over here\r
+       return_20=bluetooth_rfcomm_sock_register_with_uuid(&uuid);\r
+       if(     return_20<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_rfcomm_sock_register_with_uuid_2(void)\r
+{\r
+       char* uuid;\r
+       int return_20;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       uuid=NULL;\r
+       return_20=bluetooth_rfcomm_sock_register_with_uuid(uuid);\r
+       if(     return_20>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_sock_register_with_uuid.h
new file mode 100644 (file)
index 0000000..f3994ac
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_rfcomm_sock_register_with_uuid_1(void);\r
+\r
+ void utc_bluetooth_rfcomm_sock_register_with_uuid_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_rfcomm_sock_register_with_uuid_1,1},\r
+                               { utc_bluetooth_rfcomm_sock_register_with_uuid_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c b/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.c
new file mode 100644 (file)
index 0000000..8ced8f6
--- /dev/null
@@ -0,0 +1,391 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "uts_bluetooth_rfcomm_write.h"
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define TC_FAIL 0
+#define TC_PASS 1
+#define TC_PRT tet_printf
+//#define tc_result tet_result
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+int g_ret_client_fd1 = 0;
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);
+
+void startup()
+{
+       tet_printf("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+//     main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+
+void cleanup()
+{
+
+       //g_main_loop_run(main_loop);
+       tet_printf("bluetooth framework TC cleanup");
+       if( main_loop!= NULL)
+       {
+               g_main_loop_unref(main_loop);
+       }
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               //tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       //tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               //tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       int     return_22;
+                       char *buff = "abcdefghijklmnopqrstuvwxyz";
+                       bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data;
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result,
+                                                               con_ind->socket_fd,
+                                                               con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2],
+                                                               con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5],
+                                                               (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT");
+                       //tc_result(TC_PASS, 22);
+                       tet_printf("g_ret_client_fd1=%d\nconn_ind->socket_fd %d\n",g_ret_client_fd1,con_ind->socket_fd);
+                       tet_printf("con_ind->device_role=%d\n",con_ind->device_role);
+
+                       if(con_ind->device_role == RFCOMM_ROLE_CLIENT)
+                       g_ret_client_fd1 = con_ind->socket_fd;
+
+                       TC_PRT("\n Enter the channel: ");
+                       return_22= bluetooth_rfcomm_write(g_ret_client_fd1, buff, 26);
+                       if(     return_22<0)
+                       {
+                               tet_printf("BLUETOOTH_EVENT_RFCOMM_CONNECTED Api failed, return_22=%d\n",return_22);
+                               tet_result(TET_FAIL);
+                       }
+                       else
+                       {
+                               tet_printf("Api passed");
+                               tet_result(TET_PASS);
+                       }
+
+                        g_main_loop_quit (main_loop);
+//                     if( main_loop!= NULL)
+//                     {
+//                             g_main_loop_unref(main_loop);
+//                     }
+                       break;
+               }
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+}
+
+
+
+#if 0
+void uts_bluetooth_rfcomm_write_1(void)
+{
+       int max_pending_connection;
+       int     return_22;
+       int ret_val;
+        //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+       ret_val = bluetooth_register_callback(bt_event_callback);
+//     main_loop = g_main_loop_new(NULL, FALSE);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+//     remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+//     remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       return_22= bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp);
+       tet_printf(" bluetooth_rfcomm_connectApi , return_22=%d\n",return_22);
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(main_loop);
+}
+#endif
+
+void uts_bluetooth_rfcomm_write_1(void)
+{
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+       char *buff = "abcdefghijklmnopqrstuvwxyz";
+        //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+//             remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+//     remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       return_22= bluetooth_rfcomm_write(1, buff, -1);
+       if(     return_22>0)
+       {
+               tet_printf("Api failed =%d\n",return_22);
+               tet_result(TET_FAIL);
+       }
+       else
+       {
+               tet_printf("Api passed");
+               tet_result(TET_PASS);
+       }
+}
+
+
+void uts_bluetooth_rfcomm_write_2(void)
+{
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+       char *buff = "abcdefghijklmnopqrstuvwxyz";
+        //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+//             remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+//     remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       return_22= bluetooth_rfcomm_write(NULL, buff, 26);
+       if(     return_22>0)
+       {
+               tet_printf("Api failed =%d\n",return_22);
+               tet_result(TET_FAIL);
+       }
+       else
+       {
+               tet_printf("Api passed");
+               tet_result(TET_PASS);
+       }
+}
+
+void uts_bluetooth_rfcomm_write_3(void)
+{
+       int max_pending_connection;
+       int return_22;
+       int ret_val;
+       char *buff = "abcdefghijklmnopqrstuvwxyz";
+       //Replace the below BD address with the remote device BD address
+       const bluetooth_device_address_t remote_address={{0x00,0x80,0x98,0xE7,0x34,0x82}};
+
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               tet_printf("bluetooth_register_callback returned Success");
+       //      tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+       //      tc_result(TC_FAIL, 0);
+               return ;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               //tc_result(TC_FAIL, 3);
+       }
+//             remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+//     remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x82;
+
+       return_22= bluetooth_rfcomm_write(1, NULL, 26);
+       if(     return_22>0)
+       {
+               tet_printf("Api failed =%d\n",return_22);
+               tet_result(TET_FAIL);
+       }
+       else
+       {
+               tet_printf("Api passed");
+               tet_result(TET_PASS);
+       }
+}
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h b/TC/bluetooth_TC/uts_bluetooth_rfcomm_write.h
new file mode 100644 (file)
index 0000000..eff8999
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include <bluetooth-api.h>
+#include <tet_api.h>
+
+static void startup();
+
+static void cleanup();
+
+
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+ void uts_bluetooth_rfcomm_write_1(void);
+
+ void uts_bluetooth_rfcomm_write_2(void);
+
+  void uts_bluetooth_rfcomm_write_3(void);
+
+ struct tet_testlist tet_testlist[] =  {
+                               { uts_bluetooth_rfcomm_write_1,1},
+                               { uts_bluetooth_rfcomm_write_2,2},
+                               { uts_bluetooth_rfcomm_write_3,3},
+                               {NULL,0}
+                       };
+
diff --git a/TC/bluetooth_TC/uts_bluetooth_search_service.c b/TC/bluetooth_TC/uts_bluetooth_search_service.c
new file mode 100644 (file)
index 0000000..8ced3cc
--- /dev/null
@@ -0,0 +1,266 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_search_service.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_search_service_1(void)\r
+{\r
+       bluetooth_device_address_t device_address={{0}};\r
+       int return_18;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_18=bluetooth_search_service(&device_address);\r
+       if(     return_18<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_search_service_2(void)\r
+{\r
+       bluetooth_device_address_t device_address;\r
+       int return_18;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+//     device_address=NULL;\r
+       return_18=bluetooth_search_service(NULL);\r
+       if(     return_18>=0)\r
+       {\r
+       tet_printf("Api failed=%d\n",return_18);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_search_service.h b/TC/bluetooth_TC/uts_bluetooth_search_service.h
new file mode 100644 (file)
index 0000000..d770f64
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_search_service_1(void);\r
+\r
+ void utc_bluetooth_search_service_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_search_service_1,1},\r
+                               { utc_bluetooth_search_service_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c b/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.c
new file mode 100644 (file)
index 0000000..06c6ed1
--- /dev/null
@@ -0,0 +1,254 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_set_discoverable_mode.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+void utc_bluetooth_set_discoverable_mode_1(void)\r
+{\r
+       bluetooth_discoverable_mode_t discoverable_mode;\r
+       int return_8;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE) {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       } else {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+       else\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+\r
+       discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;\r
+\r
+       /* 60 seconds */\r
+       return_8 = bluetooth_set_discoverable_mode(discoverable_mode, 60);\r
+\r
+       if (return_8 < 0) {\r
+               tet_printf("Api failed");\r
+               tet_result(TET_FAIL);\r
+       } else {\r
+               tet_printf("Api passed");\r
+               tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_set_discoverable_mode_2(void)\r
+{\r
+       bluetooth_discoverable_mode_t discoverable_mode;\r
+       int return_8;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       discoverable_mode=-1;\r
+       return_8=bluetooth_set_discoverable_mode(discoverable_mode, 0);\r
+       if(     return_8>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h b/TC/bluetooth_TC/uts_bluetooth_set_discoverable_mode.h
new file mode 100644 (file)
index 0000000..9114aa9
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_set_discoverable_mode_1(void);\r
+\r
+ void utc_bluetooth_set_discoverable_mode_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_set_discoverable_mode_1,1},\r
+                               { utc_bluetooth_set_discoverable_mode_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_set_local_name.c b/TC/bluetooth_TC/uts_bluetooth_set_local_name.c
new file mode 100644 (file)
index 0000000..2cbaf07
--- /dev/null
@@ -0,0 +1,266 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_set_local_name.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_set_local_name_1(void)\r
+{\r
+       bluetooth_device_name_t local_name={{"local Name"}};\r
+       int     return_6;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_6=bluetooth_set_local_name(&local_name);\r
+       if(     return_6<0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_set_local_name_2(void)\r
+{\r
+       bluetooth_device_name_t* local_name;\r
+       int return_6;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       local_name=NULL;\r
+       return_6=bluetooth_set_local_name(local_name);\r
+       if(     return_6>=0)\r
+       {\r
+       tet_printf("Api failed");\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_set_local_name.h b/TC/bluetooth_TC/uts_bluetooth_set_local_name.h
new file mode 100644 (file)
index 0000000..a77d571
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_set_local_name_1(void);\r
+\r
+ void utc_bluetooth_set_local_name_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_set_local_name_1,1},\r
+                               { utc_bluetooth_set_local_name_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_start_discovery.c b/TC/bluetooth_TC/uts_bluetooth_start_discovery.c
new file mode 100644 (file)
index 0000000..60932d1
--- /dev/null
@@ -0,0 +1,378 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_start_discovery.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               //tc_result(TC_PASS, 12);\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 12);\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+void utc_bluetooth_start_discovery_1(void)\r
+{\r
+       unsigned max_response;\r
+       unsigned discovery_duration;\r
+       unsigned classOfDeviceMask;\r
+       int return_9;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       bluetooth_cancel_discovery();\r
+\r
+       max_response =0;\r
+       discovery_duration =0;\r
+       classOfDeviceMask =0;\r
+       return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+       if(     return_9<0)\r
+       {\r
+       tet_printf("Api failed: %d", return_9);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+\r
+\r
+void utc_bluetooth_start_discovery_2(void)\r
+{\r
+       unsigned short max_response;\r
+       unsigned short discovery_duration;\r
+       unsigned  classOfDeviceMask;\r
+       int return_9;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       max_response =0;//assign value over here\r
+       discovery_duration =0;//assign value over here\r
+       classOfDeviceMask=0x800001;//0x001000;\r
+       return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+       if(     return_9>=0)\r
+       {\r
+       tet_printf("Api failed=%d\n",return_9);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+\r
+// Not proper case!!\r
+// The API parameter types is unsigned!\r
+#if 0\r
+void utc_bluetooth_start_discovery_3(void)\r
+{\r
+       unsigned max_response;\r
+       unsigned discovery_duration;\r
+       unsigned classOfDeviceMask;\r
+       int     return_9;\r
+               int ret_val;\r
+               ret_val = bluetooth_register_callback(bt_event_callback);\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       max_response =0;//assign value over here\r
+       discovery_duration=-1;\r
+       classOfDeviceMask=0;\r
+       return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+       if(     return_9>=0)\r
+       {\r
+       tet_printf("Api failed=%d\n",return_9);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+\r
+void utc_bluetooth_start_discovery_4(void)\r
+{\r
+       unsigned max_response;\r
+       unsigned discovery_duration;\r
+       unsigned classOfDeviceMask;\r
+       int     return_9;\r
+               int ret_val;\r
+               ret_val = bluetooth_register_callback(bt_event_callback);\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       max_response=0;\r
+       discovery_duration=0;\r
+       classOfDeviceMask=-1;\r
+       return_9=bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+       if(     return_9>=0)\r
+       {\r
+       tet_printf("Api failed=%d\n",return_9);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
+#endif\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_start_discovery.h b/TC/bluetooth_TC/uts_bluetooth_start_discovery.h
new file mode 100644 (file)
index 0000000..3dd24e9
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_start_discovery_1(void);\r
+\r
+ void utc_bluetooth_start_discovery_2(void);\r
+\r
+ void utc_bluetooth_start_discovery_3(void);\r
+\r
+ void utc_bluetooth_start_discovery_4(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_start_discovery_1,1},\r
+                               { utc_bluetooth_start_discovery_2,2},\r
+//                             { utc_bluetooth_start_discovery_3,3},\r
+//                             { utc_bluetooth_start_discovery_4,4},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_unbond_device.c b/TC/bluetooth_TC/uts_bluetooth_unbond_device.c
new file mode 100644 (file)
index 0000000..3548bda
--- /dev/null
@@ -0,0 +1,290 @@
+\r
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include "uts_bluetooth_unbond_device.h"\r
+\r
+bluetooth_device_address_t searched_device = {{0}};\r
+\r
+#define TC_TIMEOUT     30000\r
+\r
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"\r
+#define DISCOVER_TIMEOUT 20\r
+#define DISCOVER_CANCEL_INTERVAL 3\r
+\r
+#define TC_FAIL 0\r
+#define TC_PASS 1\r
+#define TC_PRT tet_printf\r
+//#define tc_result tet_result\r
+\r
+GMainLoop *main_loop = NULL;\r
+static int timeout_status = 0;\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data);\r
+\r
+void startup()\r
+{\r
+       tet_printf("bluetooth framework TC startup");\r
+\r
+       if(!g_thread_supported())\r
+       {\r
+               g_thread_init(NULL);\r
+       }\r
+\r
+       dbus_g_thread_init();\r
+\r
+       g_type_init();\r
+       //main_loop = g_main_loop_new(NULL, FALSE);\r
+}\r
+\r
+\r
+void cleanup()\r
+{\r
+\r
+       //g_main_loop_run(main_loop);\r
+       tet_printf("bluetooth framework TC cleanup");\r
+       //if( main_loop!= NULL)\r
+       {\r
+       //      g_main_loop_unref(main_loop);\r
+       }\r
+}\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       TC_PRT("bt event callback 0x%04x", event);\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 1);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 1);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //tc_result(TC_PASS, 2);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 2);\r
+                       }\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:\r
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;\r
+                               //tc_result(TC_PASS, 6);\r
+                               TC_PRT("Changed Name : [%s]", local_name->name);\r
+                       }\r
+                       else\r
+                       {\r
+                               //tc_result(TC_FAIL, 6);\r
+                       }\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);\r
+                       break;\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       //tc_result(TC_PASS, 9);\r
+                       break;\r
+\r
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       int     return_14;\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       //tc_result(TC_PASS, 12);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+\r
+                       if (device_info == NULL)\r
+                       {\r
+                               tet_printf("param is NULL");\r
+                               tet_result(TET_FAIL);\r
+                               g_main_loop_quit (main_loop);\r
+                               return;\r
+                       }\r
+\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+\r
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \\r
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \\r
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);\r
+                       }\r
+\r
+                       return_14=bluetooth_unbond_device(&device_info->device_address);\r
+                       if( return_14<0)\r
+                       {\r
+                               tet_printf("Api failed: %d", return_14);\r
+                               tet_result(TET_FAIL);\r
+                       }\r
+                       else\r
+                       {\r
+                               tet_printf("Api passed");\r
+                               tet_result(TET_PASS);\r
+                       }\r
+\r
+                       g_main_loop_quit (main_loop);\r
+                       break;\r
+               }\r
+\r
+               default:\r
+                       TC_PRT("received event [0x%04x]", event);\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+void utc_bluetooth_unbond_device_1(void)\r
+{\r
+       bluetooth_device_address_t device_address={{0x00,0x02,0x78,0xDE,0x48,0x8F}}; // Samsung Stereo Headset\r
+\r
+       int return_14;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+\r
+       return_14=bluetooth_bond_device(&device_address);\r
+       if(     return_14<0)\r
+       {
+               tet_printf("bond failed: %d", return_14);\r
+               tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bonding is in progress");\r
+\r
+               main_loop = g_main_loop_new(NULL, FALSE);\r
+               g_main_loop_run(main_loop);\r
+       }\r
+}\r
+\r
+\r
+void utc_bluetooth_unbond_device_2(void)\r
+{\r
+       bluetooth_device_address_t* device_address;\r
+       int return_14;\r
+       int ret_val;\r
+\r
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);\r
+\r
+       if (ret_val >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               tet_printf("bluetooth_register_callback returned Success");\r
+       //      tc_result(TC_PASS, 0);\r
+       }\r
+       else\r
+       {\r
+               tet_printf("bluetooth_register_callback returned failiure [0x%04x]", ret_val);\r
+       //      tc_result(TC_FAIL, 0);\r
+               return 0;\r
+       }\r
+\r
+       ret_val = bluetooth_check_adapter();\r
+       if (ret_val < BLUETOOTH_ERROR_NONE)\r
+       {\r
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);\r
+               //tc_result(TC_FAIL, 3);\r
+       }\r
+       else\r
+       {\r
+               TC_PRT("BT state [0x%04x]", ret_val);\r
+               //tc_result(TC_PASS, 3);\r
+       }\r
+       device_address=NULL;\r
+       return_14=bluetooth_unbond_device(device_address);\r
+       if(     return_14>=0)\r
+       {\r
+       tet_printf("Api failed: %d", return_14);\r
+       tet_result(TET_FAIL);\r
+       }\r
+       else\r
+       {\r
+       tet_printf("Api passed");\r
+       tet_result(TET_PASS);\r
+       }\r
+}\r
diff --git a/TC/bluetooth_TC/uts_bluetooth_unbond_device.h b/TC/bluetooth_TC/uts_bluetooth_unbond_device.h
new file mode 100644 (file)
index 0000000..5acd2c6
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <glib.h>\r
+#include <pthread.h>\r
+\r
+#include <bluetooth-api.h>\r
+#include <tet_api.h>\r
+\r
+static void startup();\r
+\r
+static void cleanup();\r
+\r
+\r
+void (*tet_startup) () = startup;\r
+void (*tet_cleanup) () = cleanup;\r
+\r
+ void utc_bluetooth_unbond_device_1(void);\r
+\r
+ void utc_bluetooth_unbond_device_2(void);\r
+\r
+ struct tet_testlist tet_testlist[] =  {\r
+                               { utc_bluetooth_unbond_device_1,1},\r
+                               { utc_bluetooth_unbond_device_2,2},\r
+                               {NULL,0}\r
+                       };\r
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100644 (file)
index 0000000..7a69717
--- /dev/null
@@ -0,0 +1,17 @@
+. ./_export_env.sh                              # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+tcc -b -j $JOURNAL_RESULT -p ./            # executing tcc to build test cases (-b)
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT  # reporting the result
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100644 (file)
index 0000000..27fdcf3
--- /dev/null
@@ -0,0 +1,19 @@
+. ./_export_env.sh                              # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+
+rm -rf $RESULT_DIR
+rm -rf tet_tmp_dir
+rm -rf results
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..e1ed207
--- /dev/null
@@ -0,0 +1,17 @@
+. ./_export_target_env.sh                    # setting environment variables
+
+echo PATH=$PATH
+echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+echo TET_ROOT=$TET_ROOT
+echo TET_SUITE_ROOT=$TET_SUITE_ROOT
+echo ARCH=$ARCH
+
+RESULT_DIR=results-$ARCH
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./             # executing tcc, with \96e option
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result
+
diff --git a/TC/making_new_tet_scen.py b/TC/making_new_tet_scen.py
new file mode 100755 (executable)
index 0000000..6c5b845
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+#############################################
+# tet_scen  auto generator
+#
+# ** argv[1] = TC root
+#############################################
+
+import sys,string,os
+
+
+write_file = open("tet_scen", 'w')
+
+#
+# making new tet_scen
+#
+def making_tet_scen (filename):
+       #tmp_list = filename.strip().split('/')
+       n_filename = filename.replace(' ', '\\ ')
+       #print n_filename
+       #new_path = "/"+ sys.argv[1] +"/"+n_filename[2:-6]
+       new_path = "/"+n_filename[:-6]
+       #print new_path
+       file = open(filename, 'r')
+       lines = file.readlines()
+       for line in lines:
+               if len(line.strip()) > 1:
+                       list = line.strip().split('/')
+                       #print new_path + list[-1]
+                       write_file.write("\t"+new_path+list[-1]+"\n")
+
+#
+# usage()
+#
+def usage():
+       print(" ")
+       print("./making_new_tet_scen.py tc_root")
+       print("Put the Test Case's root directory.")
+       print("Do not include '/' at the end")
+       print(" ")
+
+#
+# main()
+#
+def main():
+       if len(sys.argv) < 2:
+               usage()
+               sys.exit(0)
+               
+       os.system('find '+ sys.argv[1] +' -name "tslist" > tslist.txt')
+       
+       #write_file = open("tetscen", w)
+       write_file.write("# auto generated tet_scen\n")
+       write_file.write("all\n")
+       write_file.write("\t\"Starting Full Test Suite\"\n")
+       
+       for file in open("tslist.txt", 'r'):
+               #print file.strip()
+               making_tet_scen(file.strip())
+                       
+       write_file.write("\t\"Completed Full Test Suite\"\n")
+       write_file.write("# EOF\n")
+       write_file.close()
+       print(" ")
+       print("==============================")
+       print("New tet_scen file is made~~~~")
+       print("==============================")
+       print(" ")
+main()
diff --git a/TC/tet_captured b/TC/tet_captured
new file mode 100644 (file)
index 0000000..9429e64
--- /dev/null
@@ -0,0 +1 @@
+Makefile:39: *** missing separator.  Stop.
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100644 (file)
index 0000000..b3da378
--- /dev/null
@@ -0,0 +1,31 @@
+# auto generated tet_scen
+all
+       "Starting Full Test Suite"
+       /bluetooth_TC/uts_bluetooth_register_callback
+       /bluetooth_TC/uts_bluetooth_check_adapter
+       /bluetooth_TC/uts_bluetooth_enable_adapter
+       /bluetooth_TC/uts_bluetooth_authorize_device
+       /bluetooth_TC/uts_bluetooth_start_discovery
+       /bluetooth_TC/uts_bluetooth_cancel_discovery
+       /bluetooth_TC/uts_bluetooth_bond_device
+       /bluetooth_TC/uts_bluetooth_cancel_bonding
+       /bluetooth_TC/uts_bluetooth_unbond_device
+       /bluetooth_TC/uts_bluetooth_search_service
+       /bluetooth_TC/uts_bluetooth_cancel_service_search
+       /bluetooth_TC/uts_bluetooth_get_bonded_device_list
+       /bluetooth_TC/uts_bluetooth_get_discoverable_mode
+       /bluetooth_TC/uts_bluetooth_get_local_address
+       /bluetooth_TC/uts_bluetooth_get_local_name
+       /bluetooth_TC/uts_bluetooth_get_remote_device
+       /bluetooth_TC/uts_bluetooth_set_discoverable_mode
+       /bluetooth_TC/uts_bluetooth_set_local_name
+       /bluetooth_TC/uts_bluetooth_is_discovering
+       /bluetooth_TC/uts_bluetooth_rfcomm_create_socket
+       /bluetooth_TC/uts_bluetooth_rfcomm_remove_socket
+       /bluetooth_TC/uts_bluetooth_rfcomm_listen
+       /bluetooth_TC/uts_bluetooth_rfcomm_connect
+       /bluetooth_TC/uts_bluetooth_rfcomm_disconnect
+       /bluetooth_TC/uts_bluetooth_rfcomm_write
+       /bluetooth_TC/uts_bluetooth_disable_adapter
+       "Completed Full Test Suite"
+# EOF
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..f7eda55
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..02d7030
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage 
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..ef3e452
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL=  # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE=   # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/TC/tslist.txt b/TC/tslist.txt
new file mode 100644 (file)
index 0000000..053e911
--- /dev/null
@@ -0,0 +1 @@
+bluetooth_TC/tslist
diff --git a/bluetooth-frwk-agent/CMakeLists.txt b/bluetooth-frwk-agent/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a1c29fc
--- /dev/null
@@ -0,0 +1,83 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-agent C)
+
+SET(SRCS bluetooth-agent.c bluetooth-agent-cb.c marshal.c sc_core_agent.c)
+SET(APP_VENDOR samsung)
+SET(APP_NAME bluetooth-agent)
+SET(APP_DIR /usr/bin)
+SET(APP_LOCALEDIR /usr/share/locale)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+#pkg_check_modules(pkgs REQUIRED elementary utilX appcore-efl pmapi vconf aul syspopup-caller)
+pkg_check_modules(pkgs REQUIRED vconf aul syspopup-caller contacts-service dbus-glib-1 msg-service email-service)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+FIND_PROGRAM(MARSHALTOOL NAMES glib-genmarshal)
+EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --header > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.h")
+EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --body > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.c")
+
+FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
+EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=sc_core_agent ${CMAKE_CURRENT_SOURCE_DIR}/sc_core_agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/sc_core_agent_glue.h")
+EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bluetooth_obex_agent ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_obex_agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_obex_agent_glue.h")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DVENDOR=\"${APP_VENDOR}\"")
+ADD_DEFINITIONS("-DAPPNAME=\"${APP_NAME}\"")
+ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
+ADD_DEFINITIONS("-DAPP_LOCALEDIR=\"${APP_LOCALEDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+#ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
+
+#ADD_CUSTOM_TARGET(bluetooth-agent.edj
+#              COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}
+#              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-agent.edc ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-agent.edj
+#              DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-agent.edc
+#)
+#ADD_DEPENDENCIES(${PROJECT_NAME} bluetooth-agent.edj)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-agent.edj DESTINATION share/edje)
+
+# install desktop file & icon
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+#CONFIGURE_FILE(${PROJECT_NAME}.desktop.in ${PROJECT_NAME}.desktop)
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop DESTINATION share/install-info/application/)
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/icon_bluetooth-agent.png DESTINATION share/icon)
+
+# install ini file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.ini DESTINATION share/process-info)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.frwk_agent.service DESTINATION share/dbus-1/services)
+
+# install booting script
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-agent DESTINATION /etc/rc.d/init.d)
+
+# i18n
+#ADD_SUBDIRECTORY(po)
+
diff --git a/bluetooth-frwk-agent/bluetooth-agent-cb.c b/bluetooth-frwk-agent/bluetooth-agent-cb.c
new file mode 100644 (file)
index 0000000..da99033
--- /dev/null
@@ -0,0 +1,617 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <malloc.h>
+#include <stacktrim.h>
+#include <syspopup_caller.h>
+
+#include "bluetooth-agent.h"
+#include "sc_core_agent.h"
+
+extern struct bt_agent_appdata *app_data;
+
+#define BT_APP_AUTHENTICATION_TIMEOUT          35
+#define BT_APP_AUTHORIZATION_TIMEOUT           15
+
+#define HFP_AUDIO_GATEWAY_UUID "0000111f-0000-1000-8000-00805f9b34fb"
+#define A2DP_UUID "0000110D-0000-1000-8000-00805F9B34FB"
+
+#define BT_PIN_MAX_LENGTH 16
+#define BT_PASSKEY_MAX_LENGTH 6
+
+#define BT_AGENT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
+
+static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address);
+static const int __bt_agent_is_hid_keyboard(uint32_t dev_class);
+
+static void __bt_agent_release_memory(void)
+{
+       /* Release Malloc Memory*/
+       malloc_trim(0);
+
+       /* Release Stack Memory*/
+       stack_trim();
+}
+
+static void __bt_agent_show_confirm_mode_request(const char *mode, const char *sender,
+                                              gboolean need_popup, void *data)
+{
+       bt_agent_changed_mode_type_t changed_mode = 0;
+
+       if (strcasecmp(mode, "enable") == 0) {
+               changed_mode = BT_AGENT_CHANGED_MODE_ENABLE;
+       } else if (strcasecmp(mode, "disable") == 0) {
+               changed_mode = BT_AGENT_CHANGED_MODE_DISABLE;
+       } else {
+               sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode,
+                                                  SC_CORE_AGENT_REJECT, NULL);
+               return;
+       }
+
+       sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode,
+                                          SC_CORE_AGENT_ACCEPT, NULL);
+}
+
+static gboolean __bt_agent_system_popup_timer_cb(gpointer user_data)
+{
+       int ret = 0;
+       bundle *b = (bundle *) user_data;
+
+       if (NULL == b) {
+               DBG("There is some problem with the user data..popup can not be created\n");
+               return FALSE;
+       }
+       ret = syspopup_launch("bt-syspopup", b);
+
+       if (0 > ret) {
+               DBG("Sorry Can not launch popup\n");
+               return TRUE;
+       } else {
+               DBG("Hurray Popup launched \n");
+               bundle_free(b);
+               return FALSE;
+       }
+}
+
+int _bt_agent_launch_system_popup(bt_agent_event_type_t event_type, const char *device_name,
+                                char *passkey, const char *filename)
+{
+       int ret = 0;
+       bundle *b = NULL;
+       char event_str[BT_MAX_EVENT_STR_LENGTH + 1] = { 0 };
+
+       DBG("_bt_agent_launch_system_popup +");
+
+       b = bundle_create();
+
+       bundle_add(b, "device-name", device_name);
+       bundle_add(b, "passkey", passkey);
+       bundle_add(b, "file", filename);
+
+       switch (event_type) {
+       case BT_AGENT_EVENT_PIN_REQUEST:
+               strncpy(event_str, "pin-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST:
+               strncpy(event_str, "passkey-confirm-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_PASSKEY_REQUEST:
+               strncpy(event_str, "passkey-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST:
+               strncpy(event_str, "passkey-display-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_AUTHORIZE_REQUEST:
+               strncpy(event_str, "authorize-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_CONFIRM_MODE_REQUEST:
+               strncpy(event_str, "confirm-mode-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_FILE_RECIEVED:
+               strncpy(event_str, "file-recieved", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST:
+               strncpy(event_str, "keyboard-passkey-request", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       case BT_AGENT_EVENT_TERMINATE:
+               strncpy(event_str, "terminate", BT_MAX_EVENT_STR_LENGTH);
+               break;
+
+       default:
+
+               break;
+
+       }
+
+       bundle_add(b, "event-type", event_str);
+
+       ret = syspopup_launch("bt-syspopup", b);
+       if (0 > ret) {
+               DBG("Popup launch failed...retry %d\n", ret);
+               g_timeout_add(BT_AGENT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS,
+                             (GSourceFunc) __bt_agent_system_popup_timer_cb, b);
+       } else {
+               bundle_free(b);
+       }
+
+       DBG("_bt_agent_launch_system_popup -%d", ret);
+       return 0;
+}
+
+static gboolean __pincode_request(DBusGProxy *device)
+{
+       uint32_t device_class;
+       GHashTable *hash = NULL;
+       GValue *value;
+       const gchar *address, *name;
+       GError *error = NULL;
+
+       DBG("+\n");
+
+       dbus_g_proxy_call(device, "GetProperties", &error,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Class");
+               device_class = value ? g_value_get_uint(value) : 0;
+
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_get_string(value) : NULL;
+
+               if (__bt_agent_is_auto_response(device_class, address)) {
+                       /* Use Fixed PIN "0000" for basic pairing*/
+                       sc_core_agent_reply_pin_code(_sc_core_agent_get_proxy(),
+                                                    SC_CORE_AGENT_ACCEPT, "0000", NULL);
+               } else if (__bt_agent_is_hid_keyboard(device_class)) {
+                       char str_passkey[7] = { 0 };
+
+                       bt_agent_generate_passkey(str_passkey, sizeof(str_passkey));
+
+                       if (name)
+                               _bt_agent_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
+                                                       (const char *)name, str_passkey, NULL);
+                       else
+                               _bt_agent_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
+                                                       (const char *)address, str_passkey, NULL);
+               } else {
+                       value = g_hash_table_lookup(hash, "Name");
+                       name = value ? g_value_get_string(value) : NULL;
+
+                       if (!name && !address)
+                               sc_core_agent_reply_pin_code(_sc_core_agent_get_proxy(),
+                                                            SC_CORE_AGENT_REJECT, "", NULL);
+
+                       if (name)
+                               _bt_agent_launch_system_popup(BT_AGENT_EVENT_PIN_REQUEST,
+                                                            (const char *)name, NULL, NULL);
+                       else
+                               _bt_agent_launch_system_popup(BT_AGENT_EVENT_PIN_REQUEST,
+                                                            (const char *)address, NULL, NULL);
+
+               }
+       } else {
+               DBG("error in GetBasicProperties [%s]\n", error->message);
+               g_error_free(error);
+               error = NULL;
+               sc_core_agent_reply_pin_code(_sc_core_agent_get_proxy(), SC_CORE_AGENT_REJECT, "",
+                                            NULL);
+       }
+
+       __bt_agent_release_memory();
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static gboolean __passkey_request(DBusGProxy *device)
+{
+       GHashTable *hash = NULL;
+       GValue *value;
+       const gchar *address, *name;
+       GError *error = NULL;
+
+       DBG("+\n");
+
+       dbus_g_proxy_call(device, "GetProperties", &error,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_get_string(value) : NULL;
+
+               if (!name && !address)
+                       sc_core_agent_reply_passkey(_sc_core_agent_get_proxy(),
+                                                   SC_CORE_AGENT_REJECT, "", NULL);
+
+               if (name)
+                       _bt_agent_launch_system_popup(BT_AGENT_EVENT_PASSKEY_REQUEST,
+                                                    (const char *)name, NULL, NULL);
+               else
+                       _bt_agent_launch_system_popup(BT_AGENT_EVENT_PASSKEY_REQUEST,
+                                                    (const char *)address, NULL, NULL);
+
+       } else {
+               DBG("error in GetBasicProperties [%s]\n", error->message);
+               g_error_free(error);
+               error = NULL;
+               sc_core_agent_reply_passkey(_sc_core_agent_get_proxy(), SC_CORE_AGENT_REJECT, "",
+                                           NULL);
+       }
+
+       __bt_agent_release_memory();
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static gboolean __display_request(DBusGProxy *device, guint passkey, guint entered)
+{
+       GHashTable *hash = NULL;
+       GValue *value;
+       const gchar *address, *name;
+       GError *error = NULL;
+
+       DBG("+\n");
+
+       dbus_g_proxy_call(device, "GetProperties", &error,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_get_string(value) : NULL;
+       } else {
+               DBG("error in GetBasicProperties [%s]\n", error->message);
+               g_error_free(error);
+               error = NULL;
+       }
+
+       __bt_agent_release_memory();
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static gboolean __confirm_request(DBusGProxy *device, guint passkey)
+{
+       GHashTable *hash = NULL;
+       GValue *value;
+       const gchar *address, *name;
+       GError *error = NULL;
+       char str_passkey[7] = { 0 };
+
+       DBG("+ passkey[%.6d]\n", passkey);
+
+       snprintf(str_passkey, sizeof(str_passkey), "%.6d", passkey);
+
+       dbus_g_proxy_call(device, "GetProperties", &error,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_get_string(value) : NULL;
+
+               if (name != NULL)
+                       _bt_agent_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST,
+                                                    (const char *)name, str_passkey, NULL);
+               else if (address != NULL)
+                       _bt_agent_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST,
+                                                    (const char *)address, str_passkey, NULL);
+               else
+                       sc_core_agent_reply_confirmation(_sc_core_agent_get_proxy(),
+                                                        SC_CORE_AGENT_REJECT, NULL);
+       } else {
+               DBG("error in GetBasicProperties [%s]\n", error->message);
+               g_error_free(error);
+               error = NULL;
+               sc_core_agent_reply_confirmation(_sc_core_agent_get_proxy(), SC_CORE_AGENT_REJECT,
+                                                NULL);
+       }
+
+       __bt_agent_release_memory();
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static gboolean __pairing_cancel_request(const char *address)
+{
+       DBG("On Going Pairing is cancelled by remote\n");
+
+       sc_core_agent_reply_pin_code(_sc_core_agent_get_proxy(), SC_CORE_AGENT_CANCEL, "", NULL);
+
+       _bt_agent_launch_system_popup(BT_AGENT_EVENT_TERMINATE, NULL, NULL, NULL);
+
+       __bt_agent_release_memory();
+
+       return TRUE;
+}
+
+static gboolean __authorize_request(DBusGProxy *device, const char *uuid)
+{
+       GHashTable *hash = NULL;
+       GValue *value;
+       const gchar *address, *name;
+       gboolean trust = FALSE;
+       GError *error = NULL;
+
+       DBG("+\n");
+
+       if (!strcasecmp(uuid, HFP_AUDIO_GATEWAY_UUID) || !strcasecmp(uuid, A2DP_UUID)) {
+               DBG("In case of audio device(HFP,A2DP), we authorize the request [%s]\n", uuid);
+               sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(), SC_CORE_AGENT_ACCEPT,
+                                             NULL);
+
+               return TRUE;
+       }
+
+       dbus_g_proxy_call(device, "GetProperties", &error, G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Trusted");
+               trust = value ? g_value_get_boolean(value) : 0;
+
+               DBG("Authorization request for device [%s] Service:[%s]\n", address, uuid);
+
+               if (trust) {
+                       DBG("Trusted device, so authorize\n");
+                       sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(),
+                                                     SC_CORE_AGENT_ACCEPT, NULL);
+               } else if (name != NULL)
+                       _bt_agent_launch_system_popup(BT_AGENT_EVENT_AUTHORIZE_REQUEST,
+                                                    (const char *)name, NULL, NULL);
+               else if (address != NULL)
+                       _bt_agent_launch_system_popup(BT_AGENT_EVENT_AUTHORIZE_REQUEST,
+                                                    (const char *)address, NULL, NULL);
+               else
+                       sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(),
+                                                     SC_CORE_AGENT_REJECT, NULL);
+       } else {
+               DBG("error in GetBasicProperties [%s]\n", error->message);
+               g_error_free(error);
+               error = NULL;
+               sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(), SC_CORE_AGENT_REJECT,
+                                             NULL);
+       }
+
+       __bt_agent_release_memory();
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static gboolean __authorization_cancel_request(const char *address)
+{
+       DBG("On Going Authorization is cancelled by remote\n");
+
+       sc_core_agent_reply_authorize(_sc_core_agent_get_proxy(), SC_CORE_AGENT_CANCEL, NULL);
+
+       _bt_agent_launch_system_popup(BT_AGENT_EVENT_TERMINATE, NULL, NULL, NULL);
+
+       __bt_agent_release_memory();
+
+       return TRUE;
+}
+
+static gboolean __confirm_mode_request(const char *mode, const char *sender, gboolean need_popup,
+                                    void *data)
+{
+       DBG("+\n");
+
+       if (mode != NULL) {
+               __bt_agent_show_confirm_mode_request(mode, sender, need_popup, data);
+       } else {
+               DBG("Wrong mode requested [%s]\n", mode);
+               sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(),
+                                                  BT_AGENT_CHANGED_MODE_ENABLE,
+                                                  SC_CORE_AGENT_REJECT, NULL);
+       }
+
+       __bt_agent_release_memory();
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static gboolean __ignore_auto_pairing_request(const char *address)
+{
+       DBG("+\n");
+
+       struct bt_agent_appdata *ad = (struct bt_agent_appdata *)app_data;
+
+       if (address == NULL)
+               return FALSE;
+
+       /* To input the pin code, if headset does not have '0000' pin code */
+       ad->ignore_auto_pairing = 1;
+       memset(ad->bonding_addr, 0x00, BT_AGENT_ADDR_SIZE + 1);
+       strncpy(ad->bonding_addr, address, BT_AGENT_ADDR_SIZE);
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+void _bt_agent_register(DBusGProxy *adapter_proxy)
+{
+       SC_CORE_AGENT_FUNC_CB func_cb = { 0 };
+
+       func_cb.pincode_func = __pincode_request;
+       func_cb.display_func = __display_request;
+       func_cb.passkey_func = __passkey_request;
+       func_cb.confirm_func = __confirm_request;
+       func_cb.authorize_func = __authorize_request;
+       func_cb.pairing_cancel_func = __pairing_cancel_request;
+       func_cb.authorization_cancel_func = __authorization_cancel_request;
+       func_cb.confirm_mode_func = __confirm_mode_request;
+       func_cb.ignore_auto_pairing_func = __ignore_auto_pairing_request;
+
+       if (_sc_core_agent_add(adapter_proxy, &func_cb) < 0) {
+               if (adapter_proxy == NULL) {
+                       return;
+               }
+               ERR("Agent register failed, Agent finish.\n");
+       }
+
+       DBG("Agent registered.\n");
+}
+
+static const int __bt_agent_is_hid_keyboard(uint32_t dev_class)
+{
+       int is_keyboard = 0;
+
+       switch ((dev_class & 0x1f00) >> 8) {
+       case 0x05:
+               switch ((dev_class & 0xc0) >> 6) {
+               case 0x01:
+                       /* input-keyboard";*/
+                       is_keyboard = 1;
+                       break;
+               }
+               break;
+       }
+
+       DBG("is_keyboard: %d\n", is_keyboard);
+
+       return is_keyboard;
+}
+
+static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address)
+{
+       DBG("bt_agent_is_headset_class, %d +", dev_class);
+
+       int is_headset = 0, ret = 0;
+       struct bt_agent_appdata *ad = (struct bt_agent_appdata *)app_data;
+
+       if (address == NULL)
+               return 0;
+
+       switch ((dev_class & 0x1f00) >> 8) {
+       case 0x04:
+               switch ((dev_class & 0xfc) >> 2) {
+               case 0x01:
+               case 0x02:
+                       /* Headset */
+                       is_headset = 1;
+                       break;
+               case 0x06:
+                       /* Headphone */
+                       is_headset = 1;
+                       break;
+               case 0x0b:      /* VCR */
+               case 0x0c:      /* Video Camera */
+               case 0x0d:      /* Camcorder */
+                       break;
+               default:
+                       /* Other audio device */
+                       is_headset = 1;
+                       break;
+               }
+               break;
+       }
+
+       if (is_headset) {
+               if (ad->ignore_auto_pairing == 0 || (strcmp(address, ad->bonding_addr) != 0))
+                       ret = 1;
+       }
+
+       ad->ignore_auto_pairing = 0;
+       memset(ad->bonding_addr, 0x00, BT_AGENT_ADDR_SIZE + 1);
+
+       return ret;
+}
+
+int bt_agent_generate_passkey(char *passkey, int size)
+{
+       int i = 0;
+       int random_fd = 0;
+       unsigned int value = 0;
+
+       if (passkey == NULL)
+               return -1;
+
+       if (size <= 0)
+               return -1;
+
+       random_fd = open("/dev/urandom", O_RDONLY);
+
+       if (random_fd < 0)
+               return -1;
+
+       for (i = 0; i < size - 1; i++) {
+               read(random_fd, &value, sizeof(value));
+               passkey[i] = '0' + (value % 10);
+       }
+
+       close(random_fd);
+
+       passkey[size - 1] = '\0';
+
+       DBG("passkey: %s", passkey);
+
+       return 0;
+}
diff --git a/bluetooth-frwk-agent/bluetooth-agent.c b/bluetooth-frwk-agent/bluetooth-agent.c
new file mode 100644 (file)
index 0000000..8f3a9ae
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <malloc.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <aul.h>
+
+#include "bluetooth-agent.h"
+
+struct bt_agent_appdata *app_data = NULL;
+
+/* status - 0 : No operation, 1 : Activate , 2 : Deactivate, 3 : Search Test*/
+/* run_type - No window change, 1 : Top window, 2 : Background*/
+static void __agent_launch_bt_service(int status, int run_type)
+{
+       bundle *kb;
+       char status_val[5] = { 0, };
+       char run_type_val[5] = { 0, };
+
+       snprintf(status_val, sizeof(status_val), "%d", status);
+       snprintf(run_type_val, sizeof(run_type_val), "%d", run_type);
+
+       DBG("status: %s, run_type: %s", status_val, run_type_val);
+
+       kb = bundle_create();
+
+       bundle_add(kb, "launch-type", "setstate");
+       bundle_add(kb, "status", status_val);
+       bundle_add(kb, "run-type", run_type_val);
+
+       aul_launch_app("org.tizen.bluetooth", kb);
+
+       bundle_free(kb);
+}
+
+static int __agent_check_bt_service(void *data)
+{
+       int bt_status = VCONFKEY_BT_STATUS_OFF;
+       if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0) {
+               DBG("no bluetooth device info, so BT was disabled at previous session");
+       }
+
+       if (bt_status != VCONFKEY_BT_STATUS_OFF) {
+               DBG("Previous session was enabled.");
+
+               /*check BT service*/
+               if (!aul_app_is_running("org.tizen.bluetooth")) {
+                       __agent_launch_bt_service(BT_AGENT_RUN_STATUS_ACTIVATE,
+                                               BT_AGENT_ON_BACKGROUND);
+               }
+       }
+
+       return 0;
+}
+
+static void __agent_adapter_added_cb(DBusGProxy *manager_proxy, const char *adapter_path,
+                                  gpointer user_data)
+{
+       struct bt_agent_appdata *ad = (struct bt_agent_appdata *)user_data;
+       DBusGConnection *connection = (DBusGConnection *) ad->g_connection;
+       DBusGProxy *adapter_proxy = NULL;
+
+       DBG("Adapter added [%s]", adapter_path);
+
+       adapter_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", adapter_path,
+                                               "org.bluez.Adapter");
+       if (adapter_proxy)
+               _bt_agent_register(adapter_proxy);
+
+       /*check BT service*/
+       if (!aul_app_is_running("org.tizen.bluetooth"))
+               __agent_launch_bt_service(BT_AGENT_RUN_STATUS_NO_CHANGE,
+                                       BT_AGENT_ON_CURRENTVIEW);
+}
+
+static void __agent_adapter_removed_cb(DBusGProxy *manager_proxy, const char *adapter_path,
+                                    gpointer user_data)
+{
+       DBG("Adapter [%s] removed", adapter_path);
+}
+
+static void __bt_agent_flight_mode_cb(keynode_t *node, void *data)
+{
+       gboolean flight_mode = FALSE;
+
+       DBG("key=%s\n", vconf_keynode_get_name(node));
+
+       if (vconf_keynode_get_type(node) == VCONF_TYPE_BOOL) {
+               flight_mode = vconf_keynode_get_bool(node);
+
+               DBG("value=%d\n", flight_mode);
+
+               if (flight_mode == TRUE && aul_app_is_running("org.tizen.bluetooth")) {
+                       DBG("Deactivate Bluetooth Service\n");
+                       __agent_launch_bt_service(BT_AGENT_RUN_STATUS_DEACTIVATE,
+                                               BT_AGENT_ON_CURRENTVIEW);
+               }
+       }
+}
+
+static int __agent_init(void *data)
+{
+       struct bt_agent_appdata *ad = (struct bt_agent_appdata *)data;
+       static DBusGConnection *connection = NULL;
+       static DBusGProxy *manager_proxy = NULL;
+       DBusGProxy *adapter_proxy = NULL;
+       GError *error = NULL;
+       const char *adapter_path = NULL;
+
+       if (connection == NULL)
+               connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+       if (error != NULL) {
+               ERR("ERROR: Can't get on system bus [%s]", error->message);
+               g_error_free(error);
+               return 1;
+       }
+
+       ad->g_connection = (void *)connection;
+
+       if (manager_proxy == NULL)
+               manager_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", "/",
+                                                                       "org.bluez.Manager");
+
+       if (manager_proxy == NULL) {
+               ERR("ERROR: Can't make dbus proxy");
+               return 1;
+       }
+
+       if (!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);
+               }
+
+               _bt_agent_register(NULL);
+
+               dbus_g_proxy_add_signal(manager_proxy, "AdapterAdded",
+                                       DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+               dbus_g_proxy_connect_signal(manager_proxy, "AdapterAdded",
+                                           G_CALLBACK(__agent_adapter_added_cb), ad, NULL);
+       } else {
+               DBG("DefaultAdapter [%s]", adapter_path);
+               adapter_proxy = dbus_g_proxy_new_for_name(connection, "org.bluez", adapter_path,
+                                                               "org.bluez.Adapter");
+               if (adapter_proxy)
+                       _bt_agent_register(adapter_proxy);
+       }
+
+       dbus_g_proxy_add_signal(manager_proxy, "AdapterRemoved",
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(manager_proxy, "AdapterRemoved",
+                                   G_CALLBACK(__agent_adapter_removed_cb), NULL, NULL);
+
+       g_idle_add((GSourceFunc) __agent_check_bt_service, NULL);
+
+       return 0;
+}
+
+static int __bt_agent_create(void *data)
+{
+       struct bt_agent_appdata *ad = (struct bt_agent_appdata *)data;
+
+       DBG("__bt_agent_create() start.\n");
+
+       g_idle_add((GSourceFunc) __agent_init, ad);
+
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, __bt_agent_flight_mode_cb, ad);
+
+       return 0;
+}
+
+GMainLoop *main_loop = NULL;
+
+int main(int argc, char *argv[])
+{
+       struct bt_agent_appdata ad = { 0 };
+       app_data = &ad;
+
+       g_type_init();
+
+       __bt_agent_create((void *)&ad);
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+
+       g_main_loop_run(main_loop);
+
+       if (main_loop != NULL) {
+               g_main_loop_unref(main_loop);
+       }
+
+       return 0;
+}
diff --git a/bluetooth-frwk-agent/bluetooth-agent.edc b/bluetooth-frwk-agent/bluetooth-agent.edc
new file mode 100644 (file)
index 0000000..d7a63ed
--- /dev/null
@@ -0,0 +1,158 @@
+#define MAIN_W 480
+#define MAIN_H 800
+#define TITLEBAR_H     ((48+50)/MAIN_H)
+#define SOFTKEY_START_Y        (722/MAIN_H)
+
+#define COLOR1 255 255 255 255;
+#define COLOR2 0 0 0 255;
+#define COLOR3 113 113 113 255;        /* Listline 1 */
+#define COLOR4 167 167 167 255;        /* Listline 3 */
+#define COLOR12        0 162 255 255;
+#define COLOR16        145 145 145 255;        /* disable text */
+#define COLOR17        255 252 0 255;          /* selected text */
+#define COLOR21        146 146 146 255         /* dialog list-editable text */
+#define COLOR25        186 255 255;            /* softkey text */
+#define COLOR83        153 153 153 255;        /* landscape main screen text */
+
+styles
+{
+       style { name: "edit_entry_text_style";
+               base: "font=SLP font_size=32 align=left color=#000000 wrap=char";
+               tag:  "br" "\n";
+               tag:  "tab" "\t";
+               tag:  "m" "+ font=SLP:style=Medium";
+               tag:  "b" "+ font=SLP:style=Bold";
+               tag:  "link" "+ color=#800 underline=on underline_color=#8008";
+               tag:  "hilight" "+ font=SLP:style=Bold";
+       }
+       
+       style { name: "edit_entry_description_style";
+               base: "font=SLP font_size=26 align=left color=#ffffff wrap=char";
+               tag:  "br" "\n";
+               tag:  "tab" "\t";
+               tag:  "m" "+ font=SLP:style=Medium";
+               tag:  "b" "+ font=SLP:style=Bold";
+               tag:  "link" "+ color=#800 underline=on underline_color=#8008";
+               tag:  "hilight" "+ font=SLP:style=Bold";
+       }       
+}
+
+collections {
+       group {
+               name: "main";
+               min: MAIN_W MAIN_H;
+
+               parts {
+                       part { name: "base";
+                               type: RECT;
+                               mouse_events: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; offset: 0 0; }
+                                       rel2 { relative: 1.0 1.0; offset: -1 -1; }
+                                       color: 0 0 0 128;
+                               }
+                       }
+
+               }       
+       }
+
+       group {
+               name: "entry_for_isf";
+               min: MAIN_W MAIN_H;
+       
+               parts {
+                       part { name: "rect";
+                               type: RECT;
+                               mouse_events: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 0.0; offset: 0 0; }
+                                       rel2 { relative: 1.0 1.0; offset: 0 0; }
+                               }
+                       }
+                       part { name: "background";
+                               type: RECT;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { to: "rect"; }
+                                       rel2 { to: "rect"; }
+                                       color: 0 0 0 128;
+                               }
+                       }
+                       part { name: "titlebar";
+                               type: SWALLOW;
+                               mouse_events: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 (48/800); offset: 0 0; to: "background"; }
+                                       rel2 { relative: 1.0 TITLEBAR_H; offset: 0 0; to: "background"; }
+                                       color: 0 0 0 0;
+                               }
+                       }
+                       part { name: "edit_entry_bg";
+                               type: RECT;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: (8/480) 1.0; offset: 0 8; to: "titlebar"; }
+                                       rel2 { relative: (472/480) 1.0; offset: 0 100; to: "titlebar"; }
+                                       color: 0 0 0 255;
+                               }
+                       }
+                       part { name: "edit_entry";
+                               type: SWALLOW;
+                               mouse_events: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: (10/480) 1.0; offset: 0 8; to: "titlebar"; }
+                                       rel2 { relative: (472/480) 1.0; offset: 0 100; to: "titlebar"; }
+                               }
+                       }
+                       part { name: "edit_entry_text_length";
+                               type: TEXTBLOCK;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: (20/480) (210/800); offset: 0 0; to: "background"; }
+                                       rel2 { relative: (50/480) (250/800); offset: 0 0; to: "background"; }
+                                       visible: 1;
+                                       text {
+                                               style: "edit_entry_description_style";
+                                               min: 1 1;
+                                       }
+                               }
+                       }
+                       part { name: "edit_entry_text_length_max";
+                               type: TEXTBLOCK;
+                               mouse_events: 0;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: (50/480) (210/800); offset: 0 0; to: "background"; }
+                                       rel2 { relative: (110/480) (250/800); offset: 0 0; to: "background"; }
+                                       visible: 1;
+                                       text {
+                                               style: "edit_entry_description_style";
+                                               min: 1 1;
+                                       }
+                               }
+                       }
+                       part { name: "softkey";
+                               type: SWALLOW;
+                               mouse_events: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 { relative: 0.0 (722/800); offset: 0 0; to: "background"; }
+                                       rel2 { relative: 1.0 1.0; offset: 0 0; to: "background"; }
+                                       color: 0 0 0 0;
+                               }
+                       }
+               }
+               programs {
+                       program {
+                       
+                       }
+               }
+       }
+}
diff --git a/bluetooth-frwk-agent/bluetooth-agent.h b/bluetooth-frwk-agent/bluetooth-agent.h
new file mode 100644 (file)
index 0000000..1949ce1
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __DEF_BT_AGENT_H_
+#define __DEF_BT_AGENT_H_
+
+#include <unistd.h>
+#include <dlog.h>
+
+#include <stdio.h>
+
+#include <dbus/dbus-glib.h>
+
+#define BT_AGENT       "BT_AGENT"
+#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_AGENT, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define ERR(fmt, args...) SLOG(LOG_ERROR, BT_AGENT, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+#define BT_AGENT_PADDING_SIZE 4096
+#define BT_MAX_SERVICES_FOR_DEVICE     20     /**< This specifies maximum number of services a
+                                               device can support */
+#define BT_MAX_EVENT_STR_LENGTH        50
+#define BT_AGENT_ADDR_SIZE     18
+
+struct bt_agent_appdata {
+       void *g_connection;
+       int ignore_auto_pairing;
+       char bonding_addr[BT_AGENT_ADDR_SIZE + 1];      /*bluetooth device address which currently
+                                                       bonding is requested to */
+};
+
+typedef enum {
+       HS_PROFILE_UUID = ((unsigned short)0x1108),             /**<HS*/
+       AUDIO_SOURCE_UUID = ((unsigned short)0x110A),           /**<AUDIO SOURCE*/
+       AUDIO_SINK_UUID = ((unsigned short)0x110B),             /**<AUDIO SINK*/
+       AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C),/**<AV REMOTE CONTROL TARGET*/
+       ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D), /**<A2DP*/
+       AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E),      /**<AV REMOTE CONTROL UUID*/
+       HF_PROFILE_UUID = ((unsigned short)0x111E),             /**<HF*/
+} bt_agent_service_uuid_list_t;
+
+typedef enum {
+       BT_AGENT_EVENT_PIN_REQUEST = 0x0001,
+       BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST = 0x0002,
+       BT_AGENT_EVENT_PASSKEY_REQUEST = 0x0004,
+       BT_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST = 0x0008,
+       BT_AGENT_EVENT_AUTHORIZE_REQUEST = 0x0010,
+       BT_AGENT_EVENT_CONFIRM_MODE_REQUEST = 0x0020,
+       BT_AGENT_EVENT_APP_CONFIRM_REQUEST = 0x0040,
+       BT_AGENT_EVENT_FILE_RECIEVED = 0x0080,
+       BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST = 0x0100,
+       BT_AGENT_EVENT_TERMINATE = 0x0200,
+} bt_agent_event_type_t;
+
+typedef enum {
+       BT_AGENT_CHANGED_MODE_ENABLE,
+       BT_AGENT_CHANGED_MODE_DISABLE,
+} bt_agent_changed_mode_type_t;
+
+typedef enum {
+       BT_AGENT_RUN_STATUS_NO_CHANGE = 0x00,   /* No Change BT status*/
+       BT_AGENT_RUN_STATUS_ACTIVATE = 0x01,    /* BT Activate*/
+       BT_AGENT_RUN_STATUS_DEACTIVATE = 0x02,  /* BT Deactivate*/
+       BT_AGENT_RUN_STATUS_SEARCH_TEST = 0x03, /* BT Search Test*/
+       BT_AGENT_RUN_STATUS_TERMINATE = 0x04,   /* BT Terminate*/
+       BT_AGENT_RUN_STATUS_MAX = 0x05, /* Max val*/
+} bt_agent_run_status_t;
+
+typedef enum {
+       BT_AGENT_ON_CURRENTVIEW = 0x00, /* Run BT on current view*/
+       BT_AGENT_ON_FOREGROUND = 0x01,  /* Run BT on foreground*/
+       BT_AGENT_ON_BACKGROUND = 0x02,  /* Run BT on background*/
+} bt_agent_on_t;
+
+typedef struct {
+       unsigned int service_list_array[BT_MAX_SERVICES_FOR_DEVICE];
+       int service_index;
+} bt_agent_sdp_info_t;
+
+int _bt_agent_launch_system_popup(bt_agent_event_type_t event_type, const char *device_name,
+                                char *passkey, const char *filename);
+void _bt_agent_register(DBusGProxy *adapter_proxy);
+
+#endif                         /* __DEF_BT_AGENT_H_ */
diff --git a/bluetooth-frwk-agent/bluetooth-agent.ini b/bluetooth-frwk-agent/bluetooth-agent.ini
new file mode 100644 (file)
index 0000000..4887e89
--- /dev/null
@@ -0,0 +1,3 @@
+[ProcessSetting]
+BG_SCHEDULE=true
+TASK_MANAGE=false
diff --git a/bluetooth-frwk-agent/bluetooth-frwk-agent b/bluetooth-frwk-agent/bluetooth-frwk-agent
new file mode 100755 (executable)
index 0000000..56a2081
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+#
+# Script for running Bluetooth framework agent during booting time
+#
+
+if [ -x /usr/bin/bluetooth-agent ]; then
+       /usr/bin/bluetooth-agent &
+fi
diff --git a/bluetooth-frwk-agent/marshal.list b/bluetooth-frwk-agent/marshal.list
new file mode 100644 (file)
index 0000000..75fb9e6
--- /dev/null
@@ -0,0 +1,22 @@
+# DBUS Signal argument converting list for DM lib
+VOID:STRING
+VOID:STRING,UINT,INT
+VOID:STRING,STRING
+VOID:STRING,STRING,INT
+VOID:UINT
+VOID:STRING,STRING,INT,UINT
+VOID:UINT, STRING
+
+# for BlueZ4
+VOID:STRING,BOXED
+
+# for obexd
+VOID:OBJECT,BOOLEAN
+#VOID:UINT64
+#VOID:STRING,UINT
+#VOID:STRING,BOOLEAN
+#VOID:STRING,STRING,BOOLEAN 
+#VOID:STRING,STRING,STRING
+#VOID:STRING,STRING,UINT64
+#VOID:STRING,STRING,STRING,STRING
+
diff --git a/bluetooth-frwk-agent/org.bluez.frwk_agent.service b/bluetooth-frwk-agent/org.bluez.frwk_agent.service
new file mode 100644 (file)
index 0000000..b24512c
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.bluez.frwk_agent
+Exec=/usr/bin/bluetooth-agent
diff --git a/bluetooth-frwk-agent/po/CMakeLists.txt b/bluetooth-frwk-agent/po/CMakeLists.txt
new file mode 100644 (file)
index 0000000..99518ab
--- /dev/null
@@ -0,0 +1,24 @@
+# for i18n
+
+SET(POFILES en_US.po en_GB.po ja.po ko.po zh_CN.po)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+       SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+       MESSAGE("PO: ${pofile}")
+       GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+       GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+       SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+       ADD_CUSTOM_COMMAND(
+                       OUTPUT ${moFile}
+                       COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+                       DEPENDS ${absPofile}
+       )
+       INSTALL(FILES ${moFile}
+                       DESTINATION share/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+       SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(agentpo ALL DEPENDS ${moFiles})
diff --git a/bluetooth-frwk-agent/po/POTFILES.in b/bluetooth-frwk-agent/po/POTFILES.in
new file mode 100644 (file)
index 0000000..de7d4ff
--- /dev/null
@@ -0,0 +1,4 @@
+# List of source files containing translatable strings.
+bluetooth-agent.c
+bluetooth-agent.h
+bluetooth-agent-cb.c
diff --git a/bluetooth-frwk-agent/po/bt-agent.pot b/bluetooth-frwk-agent/po/bt-agent.pot
new file mode 100644 (file)
index 0000000..f35f21a
--- /dev/null
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-05-18 10:02+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: bluetooth-agent.c:36 bluetooth-agent.c:37
+msgid "Bluetooth"
+msgstr ""
+
+#: bluetooth-agent.c:59
+msgid "system_content"
+msgstr ""
+
+#: bluetooth-agent-cb.c:174 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:440
+msgid "Done"
+msgstr ""
+
+#: bluetooth-agent-cb.c:175 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:447
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:572 bluetooth-agent-cb.c:597
+msgid "Cancel"
+msgstr ""
+
+#: bluetooth-agent-cb.c:474
+#, c-format
+msgid "Enter PIN (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:500
+#, c-format
+msgid "Enter Passkey displayed by (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:521 bluetooth-agent-cb.c:547
+msgid "Yes"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:525 bluetooth-agent-cb.c:547
+msgid "No"
+msgstr ""
+
+#: bluetooth-agent-cb.c:545
+#, c-format
+msgid "Do the Passkeys match with<br>%s?<br>%s"
+msgstr ""
+
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:568 bluetooth-agent-cb.c:597
+msgid "Ok"
+msgstr ""
+
+#: bluetooth-agent-cb.c:593
+#, c-format
+msgid "Connect serial port<br>with %s?"
+msgstr ""
+
+#: bluetooth-agent-cb.c:595
+#, c-format
+msgid "Allow %s<br>to connect?"
+msgstr ""
diff --git a/bluetooth-frwk-agent/po/en_GB.po b/bluetooth-frwk-agent/po/en_GB.po
new file mode 100644 (file)
index 0000000..4c626b5
--- /dev/null
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-05-18 10:02+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: bluetooth-agent.c:36 bluetooth-agent.c:37
+msgid "Bluetooth"
+msgstr ""
+
+#: bluetooth-agent.c:59
+msgid "system_content"
+msgstr ""
+
+#: bluetooth-agent-cb.c:174 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:440
+msgid "Done"
+msgstr ""
+
+#: bluetooth-agent-cb.c:175 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:447
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:572 bluetooth-agent-cb.c:597
+msgid "Cancel"
+msgstr ""
+
+#: bluetooth-agent-cb.c:474
+#, c-format
+msgid "Enter PIN (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:500
+#, c-format
+msgid "Enter Passkey displayed by (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:521 bluetooth-agent-cb.c:547
+msgid "Yes"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:525 bluetooth-agent-cb.c:547
+msgid "No"
+msgstr ""
+
+#: bluetooth-agent-cb.c:545
+#, c-format
+msgid "Do the Passkeys match with<br>%s?<br>%s"
+msgstr ""
+
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:568 bluetooth-agent-cb.c:597
+msgid "Ok"
+msgstr ""
+
+#: bluetooth-agent-cb.c:593
+#, c-format
+msgid "Connect serial port<br>with %s?"
+msgstr ""
+
+#: bluetooth-agent-cb.c:595
+#, c-format
+msgid "Allow %s<br>to connect?"
+msgstr ""
diff --git a/bluetooth-frwk-agent/po/en_US.po b/bluetooth-frwk-agent/po/en_US.po
new file mode 100644 (file)
index 0000000..4c626b5
--- /dev/null
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-05-18 10:02+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: bluetooth-agent.c:36 bluetooth-agent.c:37
+msgid "Bluetooth"
+msgstr ""
+
+#: bluetooth-agent.c:59
+msgid "system_content"
+msgstr ""
+
+#: bluetooth-agent-cb.c:174 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:440
+msgid "Done"
+msgstr ""
+
+#: bluetooth-agent-cb.c:175 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:447
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:572 bluetooth-agent-cb.c:597
+msgid "Cancel"
+msgstr ""
+
+#: bluetooth-agent-cb.c:474
+#, c-format
+msgid "Enter PIN (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:500
+#, c-format
+msgid "Enter Passkey displayed by (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:521 bluetooth-agent-cb.c:547
+msgid "Yes"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:525 bluetooth-agent-cb.c:547
+msgid "No"
+msgstr ""
+
+#: bluetooth-agent-cb.c:545
+#, c-format
+msgid "Do the Passkeys match with<br>%s?<br>%s"
+msgstr ""
+
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:568 bluetooth-agent-cb.c:597
+msgid "Ok"
+msgstr ""
+
+#: bluetooth-agent-cb.c:593
+#, c-format
+msgid "Connect serial port<br>with %s?"
+msgstr ""
+
+#: bluetooth-agent-cb.c:595
+#, c-format
+msgid "Allow %s<br>to connect?"
+msgstr ""
diff --git a/bluetooth-frwk-agent/po/ja.po b/bluetooth-frwk-agent/po/ja.po
new file mode 100644 (file)
index 0000000..4c626b5
--- /dev/null
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-05-18 10:02+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: bluetooth-agent.c:36 bluetooth-agent.c:37
+msgid "Bluetooth"
+msgstr ""
+
+#: bluetooth-agent.c:59
+msgid "system_content"
+msgstr ""
+
+#: bluetooth-agent-cb.c:174 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:440
+msgid "Done"
+msgstr ""
+
+#: bluetooth-agent-cb.c:175 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:447
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:572 bluetooth-agent-cb.c:597
+msgid "Cancel"
+msgstr ""
+
+#: bluetooth-agent-cb.c:474
+#, c-format
+msgid "Enter PIN (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:500
+#, c-format
+msgid "Enter Passkey displayed by (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:521 bluetooth-agent-cb.c:547
+msgid "Yes"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:525 bluetooth-agent-cb.c:547
+msgid "No"
+msgstr ""
+
+#: bluetooth-agent-cb.c:545
+#, c-format
+msgid "Do the Passkeys match with<br>%s?<br>%s"
+msgstr ""
+
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:568 bluetooth-agent-cb.c:597
+msgid "Ok"
+msgstr ""
+
+#: bluetooth-agent-cb.c:593
+#, c-format
+msgid "Connect serial port<br>with %s?"
+msgstr ""
+
+#: bluetooth-agent-cb.c:595
+#, c-format
+msgid "Allow %s<br>to connect?"
+msgstr ""
diff --git a/bluetooth-frwk-agent/po/ko.po b/bluetooth-frwk-agent/po/ko.po
new file mode 100644 (file)
index 0000000..46c9cc7
--- /dev/null
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-05-18 09:52+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: bluetooth-agent.c:36 bluetooth-agent.c:37
+msgid "Bluetooth"
+msgstr "블루투스"
+
+#: bluetooth-agent.c:59
+msgid "system_content"
+msgstr ""
+
+#: bluetooth-agent-cb.c:174 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:440
+msgid "Done"
+msgstr "완료"
+
+#: bluetooth-agent-cb.c:175 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:447
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:572 bluetooth-agent-cb.c:597
+msgid "Cancel"
+msgstr "취소"
+
+#: bluetooth-agent-cb.c:474
+#, c-format
+msgid "Enter PIN (%s)"
+msgstr "PIN을 입력하세요 (%s)"
+
+#: bluetooth-agent-cb.c:500
+#, c-format
+msgid "Enter Passkey displayed by (%s)"
+msgstr "%s 화면에 나타난 숫자를 입력하세요"
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:521 bluetooth-agent-cb.c:547
+msgid "Yes"
+msgstr "네"
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:525 bluetooth-agent-cb.c:547
+msgid "No"
+msgstr "아니오"
+
+#: bluetooth-agent-cb.c:545
+#, c-format
+msgid "Do the Passkeys match with<br>%s?<br>%s"
+msgstr "숫자가 %s와 일치합니까?<br>%s"
+
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:568 bluetooth-agent-cb.c:597
+msgid "Ok"
+msgstr "네"
+
+#: bluetooth-agent-cb.c:593
+#, c-format
+msgid "Connect serial port<br>with %s?"
+msgstr "시리얼 포트를 %s와 연결 하시겠습니까?"
+
+#: bluetooth-agent-cb.c:595
+#, c-format
+msgid "Allow %s<br>to connect?"
+msgstr "%s가 연결할 수 있도록 허락 하시겠습니까?"
diff --git a/bluetooth-frwk-agent/po/update-po.sh b/bluetooth-frwk-agent/po/update-po.sh
new file mode 100755 (executable)
index 0000000..f77e297
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+PACKAGE=bt-agent
+SRCROOT=..
+POTFILES=POTFILES.in
+
+#ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW
+ALL_LINGUAS="en_US en_GB ja ko zh_CN"
+
+XGETTEXT=/usr/bin/xgettext
+MSGMERGE=/usr/bin/msgmerge
+
+echo -n "Make ${PACKAGE}.pot  "
+if [ ! -e $POTFILES ] ; then
+       echo "$POTFILES not found"
+       exit 1
+fi
+
+$XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \
+               --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES \
+&& test ! -f ${PACKAGE}.po \
+       || (rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot)
+
+if [ $? -ne 0 ]; then
+       echo "error"
+       exit 1
+else
+       echo "done"
+fi
+
+for LANG in $ALL_LINGUAS; do 
+       echo "$LANG : "
+
+       if [ ! -e $LANG.po ] ; then
+               sed 's/CHARSET/UTF-8/g' ${PACKAGE}.pot > ${LANG}.po
+               echo "${LANG}.po created"
+       else
+               if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then
+                       if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then
+                               rm -f ${LANG}.new.po
+                       else
+                               if mv -f ${LANG}.new.po ${LANG}.po; then
+                                       echo "" 
+                               else
+                                       echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2
+                                       rm -f ${LANG}.new.po
+                                       exit 1
+                               fi
+                       fi
+               else
+                       echo "msgmerge for $LANG failed!"
+                       rm -f ${LANG}.new.po
+               fi
+       fi
+       echo ""
+done
+
diff --git a/bluetooth-frwk-agent/po/zh_CN.po b/bluetooth-frwk-agent/po/zh_CN.po
new file mode 100644 (file)
index 0000000..4c626b5
--- /dev/null
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-05-18 10:02+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: bluetooth-agent.c:36 bluetooth-agent.c:37
+msgid "Bluetooth"
+msgstr ""
+
+#: bluetooth-agent.c:59
+msgid "system_content"
+msgstr ""
+
+#: bluetooth-agent-cb.c:174 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:440
+msgid "Done"
+msgstr ""
+
+#: bluetooth-agent-cb.c:175 bluetooth-agent-cb.c:421 bluetooth-agent-cb.c:447
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:572 bluetooth-agent-cb.c:597
+msgid "Cancel"
+msgstr ""
+
+#: bluetooth-agent-cb.c:474
+#, c-format
+msgid "Enter PIN (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:500
+#, c-format
+msgid "Enter Passkey displayed by (%s)"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:521 bluetooth-agent-cb.c:547
+msgid "Yes"
+msgstr ""
+
+#: bluetooth-agent-cb.c:513 bluetooth-agent-cb.c:525 bluetooth-agent-cb.c:547
+msgid "No"
+msgstr ""
+
+#: bluetooth-agent-cb.c:545
+#, c-format
+msgid "Do the Passkeys match with<br>%s?<br>%s"
+msgstr ""
+
+#: bluetooth-agent-cb.c:560 bluetooth-agent-cb.c:568 bluetooth-agent-cb.c:597
+msgid "Ok"
+msgstr ""
+
+#: bluetooth-agent-cb.c:593
+#, c-format
+msgid "Connect serial port<br>with %s?"
+msgstr ""
+
+#: bluetooth-agent-cb.c:595
+#, c-format
+msgid "Allow %s<br>to connect?"
+msgstr ""
diff --git a/bluetooth-frwk-agent/sc_core_agent.c b/bluetooth-frwk-agent/sc_core_agent.c
new file mode 100644 (file)
index 0000000..7ea9166
--- /dev/null
@@ -0,0 +1,1071 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "bluetooth-agent.h"
+#include "sc_core_agent.h"
+
+static DBusGConnection *connection = NULL;
+#ifdef _SESSION_BUS_
+static DBusGConnection *session_connection = NULL;
+#endif
+static ScCoreAgent *gap_agent = NULL;
+
+typedef enum {
+       SC_CORE_AGENT_EXEC_NO_OPERATION,
+       SC_CORE_AGENT_EXEC_PAIRING,
+       SC_CORE_AGENT_EXEC_AUTHORZATION,
+       SC_CORE_AGENT_EXEC_CONFIRM_MODE,
+} ScCoreAgentExecType;
+
+typedef struct _ScCoreAgentPrivate ScCoreAgentPrivate;
+
+struct _ScCoreAgentPrivate {
+       gchar *busname;
+       gchar *path;
+       DBusGProxy *adapter;
+       DBusGProxy *dbus_proxy;
+
+       ScCoreAgentExecType exec_type;
+       DBusGMethodInvocation *reply_context;
+
+       char pairing_addr[18];
+       char authorize_addr[18];
+
+       SC_CORE_AGENT_FUNC_CB cb;
+};
+
+G_DEFINE_TYPE(ScCoreAgent, sc_core_agent, G_TYPE_OBJECT);
+
+static gboolean sc_core_agent_request_pin_code(ScCoreAgent *agent, const char *path,
+                                               DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_request_passkey(ScCoreAgent *agent, const char *path,
+                                               DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_display_passkey(ScCoreAgent *agent, const char *path, guint passkey,
+                                               guint8 entered, DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_request_confirmation(ScCoreAgent *agent, const char *path,
+                                               guint passkey, DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_authorize(ScCoreAgent *agent, const char *path, const char *uuid,
+                                               DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_confirm_mode(ScCoreAgent *agent, const char *mode,
+                                               DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_cancel(ScCoreAgent *agent, DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_release(ScCoreAgent *agent, DBusGMethodInvocation *context);
+
+static gboolean sc_core_agent_ignore_auto_pairing(ScCoreAgent *agent, const char *address,
+                                               DBusGMethodInvocation *context);
+
+static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *name,
+                                               const char *prev, const char *new,
+                                               gpointer user_data);
+
+static void __sc_core_agent_mode_change(int changed_mode);
+
+static gboolean __sc_cre_core_agent_readd(gpointer data);
+
+#include "sc_core_agent_glue.h"
+
+typedef enum {
+       SC_CORE_AGENT_ERROR_REJECT,
+       SC_CORE_AGENT_ERROR_CANCEL,
+       SC_CORE_AGENT_ERROR_TIMEOUT,
+} ScCoreAgentError;
+
+#define SC_CORE_AGENT_ERROR (sc_core_agent_error_quark())
+
+static GQuark sc_core_agent_error_quark(void)
+{
+       static GQuark quark = 0;
+       if (!quark)
+               quark = g_quark_from_static_string("agent");
+
+       return quark;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+static GError *sc_core_agent_error(ScCoreAgentError error, const char *err_msg)
+{
+       return g_error_new(SC_CORE_AGENT_ERROR, error, err_msg);
+}
+
+static void sc_core_agent_init(ScCoreAgent *agent)
+{
+       DBG("agent %p\n", agent);
+}
+
+static void sc_core_agent_finalize(GObject *agent)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       SC_CORE_AGENT_FUNC_CB *cb_ptr = NULL;
+
+       DBG("Free agent %p\n", agent);
+
+       g_free(priv->path);
+       g_free(priv->busname);
+
+       cb_ptr = (SC_CORE_AGENT_FUNC_CB *) malloc(sizeof(SC_CORE_AGENT_FUNC_CB));
+       if (cb_ptr) {
+               memcpy(cb_ptr, &priv->cb, sizeof(SC_CORE_AGENT_FUNC_CB));
+               g_idle_add(__sc_cre_core_agent_readd, (void *)cb_ptr);
+       } else {
+               DBG("Error copy callback pointer\n");
+       }
+
+       G_OBJECT_CLASS(sc_core_agent_parent_class)->finalize(agent);
+}
+
+static void sc_core_agent_class_init(ScCoreAgentClass *klass)
+{
+       GObjectClass *object_class = (GObjectClass *) klass;
+       GError *error = NULL;
+
+       DBG("class %p\n", klass);
+
+       g_type_class_add_private(klass, sizeof(ScCoreAgentPrivate));
+
+       object_class->finalize = sc_core_agent_finalize;
+
+       connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+
+       if (error != NULL) {
+               g_printerr("Connecting to system bus failed: %s\n", error->message);
+               g_error_free(error);
+       }
+#ifdef _SESSION_BUS_
+       session_connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+       if (error != NULL) {
+               g_printerr("Connecting to system bus failed: %s\n", error->message);
+               g_error_free(error);
+       }
+#endif
+
+       dbus_g_object_type_install_info(SC_CORE_TYPE_AGENT, &dbus_glib_sc_core_agent_object_info);
+}
+
+ScCoreAgent *sc_core_agent_new(void)
+{
+       ScCoreAgent *agent;
+
+       agent = SC_CORE_GET_AGENT(g_object_new(SC_CORE_TYPE_AGENT, NULL));
+
+       DBG("agent %p\n", agent);
+
+       return agent;
+}
+
+static gboolean sc_core_agent_request_pin_code(ScCoreAgent *agent,
+                                              const char *path, DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       DBusGProxy *device = NULL;
+       gboolean result = FALSE;
+
+       char *addr;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Request PIN : agent %p sender %s priv->busname %s Device Path :%s\n", agent, sender,
+           priv->busname, path);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       if (priv->cb.passkey_func) {
+               if (priv->adapter != NULL) {
+                       device = dbus_g_proxy_new_from_proxy(priv->adapter, BLUEZ_DEVICE_INTERFACE,
+                                                               path);
+               }
+
+               if (device == NULL) {
+                       GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "No proxy for device");
+                       DBG("Fail to make device proxy\n");
+                       dbus_g_method_return_error(context, error);
+                       g_error_free(error);
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               priv->exec_type = SC_CORE_AGENT_EXEC_PAIRING;
+               priv->reply_context = context;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       strncpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr) - 1);
+
+                       while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               result = priv->cb.pincode_func(device);
+
+               if (device != NULL)
+                       g_object_unref(device);
+       }
+
+       g_free(sender);
+       return result;
+}
+
+static gboolean sc_core_agent_request_passkey(ScCoreAgent *agent,
+                                             const char *path, DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       DBusGProxy *device = NULL;
+       gboolean result = FALSE;
+       char *addr;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Request passkey : agent %p sender %s priv->busname %s Device Path :%s\n", agent,
+           sender, priv->busname, path);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       if (priv->cb.passkey_func) {
+               if (priv->adapter != NULL) {
+                       device = dbus_g_proxy_new_from_proxy(priv->adapter, BLUEZ_DEVICE_INTERFACE,
+                                                               path);
+               }
+
+               if (device == NULL) {
+                       GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "No proxy for device");
+                       DBG("Fail to make device proxy\n");
+                       dbus_g_method_return_error(context, error);
+                       g_error_free(error);
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               priv->exec_type = SC_CORE_AGENT_EXEC_PAIRING;
+               priv->reply_context = context;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       strncpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr) - 1);
+
+                       while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               result = priv->cb.passkey_func(device);
+
+               if (device != NULL)
+                       g_object_unref(device);
+       }
+
+       g_free(sender);
+       return result;
+
+}
+
+static gboolean sc_core_agent_display_passkey(ScCoreAgent *agent, const char *path, guint passkey,
+                                               guint8 entered, DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       DBusGProxy *device = NULL;
+       gboolean result = FALSE;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Request passkey display : agent %p sender %s priv->busname %s Device Path :%s\n",
+           agent, sender, priv->busname, path);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       if (priv->cb.display_func) {
+               if (priv->adapter != NULL) {
+                       device = dbus_g_proxy_new_from_proxy(priv->adapter, BLUEZ_DEVICE_INTERFACE,
+                                                               path);
+               }
+
+               if (device == NULL) {
+                       GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "No proxy for device");
+                       DBG("Fail to make device proxy\n");
+                       dbus_g_method_return_error(context, error);
+                       g_error_free(error);
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               dbus_g_method_return(context);
+
+               result = priv->cb.display_func(device, passkey, entered);
+
+               if (device != NULL)
+                       g_object_unref(device);
+       }
+
+       g_free(sender);
+       return result;
+}
+
+static gboolean sc_core_agent_request_confirmation(ScCoreAgent *agent, const char *path,
+                                               guint passkey, DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       DBusGProxy *device = NULL;
+       gboolean result = FALSE;
+       char *addr;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Request passkey confirmation : agent %p sender %s priv->busname %s Device Path :%s\n",
+           agent, sender, priv->busname, path);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       if (priv->cb.confirm_func) {
+               if (priv->adapter != NULL) {
+                       device = dbus_g_proxy_new_from_proxy(priv->adapter, BLUEZ_DEVICE_INTERFACE,
+                                                               path);
+               }
+
+               if (device == NULL) {
+                       GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "No proxy for device");
+                       DBG("Fail to make device proxy\n");
+                       dbus_g_method_return_error(context, error);
+                       g_error_free(error);
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               priv->exec_type = SC_CORE_AGENT_EXEC_PAIRING;
+               priv->reply_context = context;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       strncpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr) - 1);
+
+                       while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               result = priv->cb.confirm_func(device, passkey);
+
+               if (device != NULL)
+                       g_object_unref(device);
+       }
+
+       g_free(sender);
+       return result;
+}
+
+static gboolean sc_core_agent_authorize(ScCoreAgent *agent, const char *path, const char *uuid,
+                                       DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       DBusGProxy *device = NULL;
+       gboolean result = FALSE;
+       char *addr;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Request authorization : agent %p sender %s priv->busname %s Device Path :%s\n", agent,
+           sender, priv->busname, path);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       if (priv->cb.authorize_func) {
+               if (priv->adapter != NULL) {
+                       device = dbus_g_proxy_new_from_proxy(priv->adapter, BLUEZ_DEVICE_INTERFACE,
+                                                               path);
+               }
+
+               if (device == NULL) {
+                       GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "No proxy for device");
+                       DBG("Fail to make device proxy\n");
+                       dbus_g_method_return_error(context, error);
+                       g_error_free(error);
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               priv->exec_type = SC_CORE_AGENT_EXEC_AUTHORZATION;
+               priv->reply_context = context;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       strncpy(priv->authorize_addr, addr, sizeof(priv->authorize_addr) - 1);
+
+                       while ((pos = strchr(priv->authorize_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               result = priv->cb.authorize_func(device, uuid);
+
+               if (device != NULL)
+                       g_object_unref(device);
+       }
+
+       g_free(sender);
+       return result;
+}
+
+static gboolean sc_core_agent_confirm_mode(ScCoreAgent *agent, const char *mode,
+                                               DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+       unsigned int inhouse_pid = 0, sender_pid = 0;
+       gboolean need_asking = TRUE;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Request confirm mode : agent %p sender %s mode %s\n", agent, sender, mode);
+
+       if (dbus_g_proxy_call(priv->dbus_proxy, "GetConnectionUnixProcessID", NULL,
+                             G_TYPE_STRING, "org.projectx.bluetooth", G_TYPE_INVALID,
+                             G_TYPE_UINT, &inhouse_pid, G_TYPE_INVALID)) {
+               if (inhouse_pid > 0 &&
+                       dbus_g_proxy_call(priv->dbus_proxy, "GetConnectionUnixProcessID", NULL,
+                                        G_TYPE_STRING, sender, G_TYPE_INVALID, G_TYPE_UINT,
+                                        &sender_pid, G_TYPE_INVALID)) {
+                       DBG("inhouse [%d] sender [%d]\n", inhouse_pid, sender_pid);
+                       if (sender_pid == inhouse_pid) {
+                               need_asking = FALSE;
+                       }
+                       inhouse_pid = 0;
+               }
+               DBG("inhouse [%d] sender [%d]\n", inhouse_pid, sender_pid);
+       }
+
+       if (need_asking && dbus_g_proxy_call(priv->dbus_proxy, "GetConnectionUnixProcessID", NULL,
+                                            G_TYPE_STRING,
+                                            "org.tizen.SplusA.bluetooth.BluetoothService",
+                                            G_TYPE_INVALID, G_TYPE_UINT, &inhouse_pid,
+                                            G_TYPE_INVALID)) {
+               if (inhouse_pid > 0 && (sender_pid > 0 ||
+                       dbus_g_proxy_call(priv->dbus_proxy, "GetConnectionUnixProcessID", NULL,
+                                            G_TYPE_STRING, sender, G_TYPE_INVALID, G_TYPE_UINT,
+                                            &sender_pid, G_TYPE_INVALID))) {
+                       DBG("SplusA [%d] sender [%d]\n", inhouse_pid, sender_pid);
+                       if (sender_pid == inhouse_pid) {
+                               need_asking = FALSE;
+                       }
+               }
+       }
+
+       if (priv->cb.confirm_mode_func) {
+               if (mode == NULL || strlen(mode) == 0) {
+                       GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "Wrong mode");
+                       DBG("mode is wrong\n");
+                       dbus_g_method_return_error(context, error);
+                       g_error_free(error);
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               priv->exec_type = SC_CORE_AGENT_EXEC_CONFIRM_MODE;
+               priv->reply_context = context;
+
+               result = priv->cb.confirm_mode_func(mode, sender, need_asking, (void *)context);
+       } else {
+               GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT, "No callback");
+               DBG("No callback for confirm mode\n");
+               dbus_g_method_return_error(context, error);
+               g_error_free(error);
+               g_free(sender);
+               return FALSE;
+       }
+
+       g_free(sender);
+       return TRUE;
+}
+
+static gboolean sc_core_agent_cancel(ScCoreAgent *agent, DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Cancelled : agent %p sender %s\n", agent, sender);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       if (priv->cb.authorization_cancel_func &&
+                                       priv->exec_type == SC_CORE_AGENT_EXEC_AUTHORZATION) {
+               result = priv->cb.authorization_cancel_func(priv->authorize_addr);
+               memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+       } else if (priv->cb.pairing_cancel_func && priv->exec_type == SC_CORE_AGENT_EXEC_PAIRING) {
+               result = priv->cb.pairing_cancel_func(priv->pairing_addr);
+               memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+       }
+
+       if (priv->exec_type != SC_CORE_AGENT_EXEC_CONFIRM_MODE &&
+           priv->exec_type != SC_CORE_AGENT_EXEC_NO_OPERATION && priv->reply_context != NULL) {
+               GError *error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                       "Rejected by remote cancel");
+               dbus_g_method_return_error(priv->reply_context, error);
+               g_error_free(error);
+       }
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       priv->reply_context = NULL;
+
+       g_free(sender);
+       return result;
+}
+
+static gboolean sc_core_agent_release(ScCoreAgent *agent, DBusGMethodInvocation *context)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+
+       if (sender == NULL)
+               return FALSE;
+
+       DBG("Released : agent %p sender %s\n", agent, sender);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       dbus_g_method_return(context);
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       priv->reply_context = NULL;
+
+       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+       memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+
+       /* Check blocking this part */
+       g_signal_handlers_disconnect_by_func(priv->dbus_proxy,
+                                            G_CALLBACK(__sc_core_agent_name_owner_changed), NULL);
+       g_object_unref(agent);
+       gap_agent = NULL;
+
+       g_free(sender);
+       return TRUE;
+}
+
+static gboolean sc_core_agent_ignore_auto_pairing(ScCoreAgent *agent, const char *address,
+                                                 DBusGMethodInvocation *context)
+{
+       DBG("+\n");
+
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       if (address == NULL || strlen(address) == 0) {
+               DBG("address is NULL\n");
+               g_free(sender);
+               return FALSE;
+       }
+
+       DBG("Request ignore auto pairing : agent %p sender %s address %s\n", agent, sender,
+           address);
+
+       if (priv->cb.ignore_auto_pairing_func) {
+               result = priv->cb.ignore_auto_pairing_func(address);
+       } else {
+               DBG("No callback for ignore_auto_pairing_func\n");
+               g_free(sender);
+               return FALSE;
+       }
+
+       DBG("-\n");
+       g_free(sender);
+       return TRUE;
+}
+
+gboolean sc_core_agent_reply_pin_code(ScCoreAgent *agent, const guint accept, const char *pin_code,
+                                     DBusGMethodInvocation *context)
+{
+       DBG("+\n");
+
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       if (priv->exec_type != SC_CORE_AGENT_EXEC_NO_OPERATION && priv->reply_context != NULL) {
+               if (accept == SC_CORE_AGENT_ACCEPT) {
+                       dbus_g_method_return(priv->reply_context, pin_code);
+               } else {
+                       GError *error = NULL;
+                       switch (accept) {
+                       case SC_CORE_AGENT_CANCEL:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_CANCEL,
+                                                               "CanceledbyUser");
+                               break;
+                       case SC_CORE_AGENT_TIMEOUT:
+                       case SC_CORE_AGENT_REJECT:
+                       default:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "Pairing request rejected");
+                               break;
+                       }
+                       dbus_g_method_return_error(priv->reply_context, error);
+                       g_error_free(error);
+               }
+       }
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       priv->reply_context = NULL;
+       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+gboolean sc_core_agent_reply_passkey(ScCoreAgent *agent, const guint accept, const char *passkey,
+                                    DBusGMethodInvocation *context)
+{
+       DBG("+\n");
+
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       if (priv->exec_type != SC_CORE_AGENT_EXEC_NO_OPERATION && priv->reply_context != NULL) {
+               if (accept == SC_CORE_AGENT_ACCEPT) {
+                       guint pass_key = atoi(passkey);
+                       dbus_g_method_return(priv->reply_context, pass_key);
+               } else {
+                       GError *error = NULL;
+                       switch (accept) {
+                       case SC_CORE_AGENT_CANCEL:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_CANCEL,
+                                                               "CanceledbyUser");
+                               break;
+                       case SC_CORE_AGENT_TIMEOUT:
+                       case SC_CORE_AGENT_REJECT:
+                       default:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "Passkey request rejected");
+                               break;
+                       }
+                       dbus_g_method_return_error(priv->reply_context, error);
+                       g_error_free(error);
+               }
+       }
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       priv->reply_context = NULL;
+       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+gboolean sc_core_agent_reply_confirmation(ScCoreAgent *agent, const guint accept,
+                                         DBusGMethodInvocation *context)
+{
+       DBG("+\n");
+
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       if (priv->exec_type != SC_CORE_AGENT_EXEC_NO_OPERATION && priv->reply_context != NULL) {
+               if (accept == SC_CORE_AGENT_ACCEPT) {
+                       dbus_g_method_return(priv->reply_context);
+               } else {
+                       GError *error = NULL;
+                       switch (accept) {
+                       case SC_CORE_AGENT_CANCEL:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_CANCEL,
+                                                               "CanceledbyUser");
+                               break;
+                       case SC_CORE_AGENT_TIMEOUT:
+                       case SC_CORE_AGENT_REJECT:
+                       default:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "Confirmation request rejected");
+                               break;
+                       }
+                       dbus_g_method_return_error(priv->reply_context, error);
+                       g_error_free(error);
+               }
+       }
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       priv->reply_context = NULL;
+       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+gboolean sc_core_agent_reply_authorize(ScCoreAgent *agent, const guint accept,
+                                      DBusGMethodInvocation *context)
+{
+       DBG("+\n");
+
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       if (priv->exec_type != SC_CORE_AGENT_EXEC_NO_OPERATION && priv->reply_context != NULL) {
+               if (accept == SC_CORE_AGENT_ACCEPT) {
+                       dbus_g_method_return(priv->reply_context);
+               } else {
+                       GError *error = NULL;
+                       switch (accept) {
+                       case SC_CORE_AGENT_CANCEL:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_CANCEL,
+                                                               "CanceledbyUser");
+                               break;
+                       case SC_CORE_AGENT_TIMEOUT:
+                       case SC_CORE_AGENT_REJECT:
+                       default:
+                               error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                               "Authorization request rejected");
+                               break;
+                       }
+                       dbus_g_method_return_error(priv->reply_context, error);
+                       g_error_free(error);
+               }
+       }
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       priv->reply_context = NULL;
+       memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+gboolean sc_core_agent_reply_adapter_enable(ScCoreAgent *agent, const guint changed_mode,
+                                           const guint accept, DBusGMethodInvocation *context)
+{
+       DBG("+\n");
+
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       if (accept == SC_CORE_AGENT_ACCEPT) {
+               __sc_core_agent_mode_change(changed_mode);
+               dbus_g_method_return(priv->reply_context);
+       } else {
+               GError *error = NULL;
+               switch (accept) {
+               case SC_CORE_AGENT_CANCEL:
+                       error = sc_core_agent_error(SC_CORE_AGENT_ERROR_CANCEL, "CanceledbyUser");
+                       break;
+               case SC_CORE_AGENT_TIMEOUT:
+               case SC_CORE_AGENT_REJECT:
+               default:
+                       error = sc_core_agent_error(SC_CORE_AGENT_ERROR_REJECT,
+                                                       "Confirming mode request rejected");
+                       break;
+               }
+               dbus_g_method_return_error(priv->reply_context, error);
+               g_error_free(error);
+       }
+
+       DBG("-\n");
+
+       return TRUE;
+}
+
+static void __sc_core_agent_mode_change(int changed_mode)
+{
+       int ret = 0;
+
+       switch (changed_mode) {
+       case BT_AGENT_CHANGED_MODE_ENABLE:
+               /* Run BT intiate script */
+               if ((ret = system("/usr/etc/bluetooth/bt-stack-up.sh &")) < 0) {
+                       DBG("running script failed");
+                       ret = system("/usr/etc/bluetooth/bt-dev-end.sh &");
+
+                       sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode,
+                                                          SC_CORE_AGENT_REJECT, NULL);
+                       return;
+               }
+               break;
+
+       case BT_AGENT_CHANGED_MODE_DISABLE:
+               /* Run BT terminate script */
+               if ((ret = system("/usr/etc/bluetooth/bt-stack-down.sh &")) < 0) {
+                       DBG("running script failed");
+
+                       sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode,
+                                                          SC_CORE_AGENT_REJECT, NULL);
+                       return;
+               }
+               break;
+
+       default:
+               ERR("Unknown mode [%#x]\n", changed_mode);
+               sc_core_agent_reply_adapter_enable(_sc_core_agent_get_proxy(), changed_mode,
+                                                  SC_CORE_AGENT_REJECT, NULL);
+               return;
+       }
+}
+
+static gboolean __sc_core_agent_register_on_adapter(ScCoreAgent *agent, DBusGProxy *adapter,
+                                                 SC_CORE_AGENT_FUNC_CB *func_cb)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       DBusGProxy *proxy;
+       GObject *object;
+       GError *error = NULL;
+
+       DBG("agent %p\n", agent);
+
+       if (priv->adapter != NULL)
+               return FALSE;
+
+       /* DBUS method call install */
+       if (priv->path == NULL) {
+               priv->path = g_strdup_printf("/org/bluez/agent/frwk_agent");
+
+               DBG("%s \n", priv->path);
+
+               object = dbus_g_connection_lookup_g_object(connection, priv->path);
+               if (object != NULL)
+                       g_object_unref(object);
+
+               dbus_g_connection_register_g_object(connection, priv->path, G_OBJECT(agent));
+       }
+
+       if (func_cb) {
+               priv->cb.pincode_func = func_cb->pincode_func;
+               priv->cb.display_func = func_cb->display_func;
+               priv->cb.passkey_func = func_cb->passkey_func;
+               priv->cb.confirm_func = func_cb->confirm_func;
+               priv->cb.authorize_func = func_cb->authorize_func;
+               priv->cb.pairing_cancel_func = func_cb->pairing_cancel_func;
+               priv->cb.authorization_cancel_func = func_cb->authorization_cancel_func;
+               priv->cb.confirm_mode_func = func_cb->confirm_mode_func;
+               priv->cb.ignore_auto_pairing_func = func_cb->ignore_auto_pairing_func;
+       }
+
+       priv->exec_type = SC_CORE_AGENT_EXEC_NO_OPERATION;
+       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+       memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+       priv->reply_context = NULL;
+
+       /* Adapter agent register */
+       if (adapter) {
+               priv->adapter = g_object_ref(adapter);
+
+               proxy = dbus_g_proxy_new_for_name_owner(connection,
+                                                       dbus_g_proxy_get_bus_name(priv->adapter),
+                                                       dbus_g_proxy_get_path(priv->adapter),
+                                                       dbus_g_proxy_get_interface(priv->adapter),
+                                                       NULL);
+
+               if (priv->busname)
+                       g_free(priv->busname);
+
+               if (proxy != NULL) {
+                       priv->busname = g_strdup(dbus_g_proxy_get_bus_name(proxy));
+                       g_object_unref(proxy);
+               } else
+                       priv->busname = g_strdup(dbus_g_proxy_get_bus_name(adapter));
+
+               dbus_g_proxy_call(priv->adapter, "RegisterAgent", &error,
+                                 DBUS_TYPE_G_OBJECT_PATH, priv->path,
+                                 G_TYPE_STRING, "DisplayYesNo", G_TYPE_INVALID, G_TYPE_INVALID);
+
+               if (error != NULL) {
+                       DBG("Agent registration failed: %s\n", error->message);
+                       g_error_free(error);
+                       return FALSE;
+               }
+       }
+
+       return TRUE;
+}
+
+static gboolean __sc_core_agent_unregister(ScCoreAgent *agent)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+       GError *error = NULL;
+
+       DBG("agent %p\n", agent);
+
+       if (priv->adapter == NULL)
+               return FALSE;
+
+       dbus_g_proxy_call(priv->adapter, "UnregisterAgent", &error,
+                         DBUS_TYPE_G_OBJECT_PATH, priv->path, G_TYPE_INVALID, G_TYPE_INVALID);
+
+       if (error != NULL) {
+               g_printerr("Agent unregistration failed: %s\n", error->message);
+               g_error_free(error);
+       }
+
+       g_object_unref(priv->adapter);
+       priv->adapter = NULL;
+
+       g_free(priv->path);
+       priv->path = NULL;
+
+       return TRUE;
+}
+
+static void __sc_core_agent_name_owner_changed(DBusGProxy *object, const char *name,
+                                            const char *prev, const char *new, gpointer user_data)
+{
+       if (g_strcmp0(name, "org.bluez") == 0 && *new == '\0') {
+               DBG("BlueZ is terminated\n");
+       }
+}
+
+static void __sc_core_setup_dbus(ScCoreAgent *agent)
+{
+       guint result;
+       GError *error = NULL;
+       gchar *agent_name = NULL;
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       agent_name = g_strdup_printf("org.bluez.frwk_agent");
+
+#ifdef _SESSION_BUS_
+       priv->dbus_proxy = dbus_g_proxy_new_for_name(session_connection, DBUS_SERVICE_DBUS,
+                                                    DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+#else
+       priv->dbus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS,
+                                                    DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+#endif
+       if (dbus_g_proxy_call(priv->dbus_proxy, "RequestName", &error,
+                             G_TYPE_STRING, agent_name, G_TYPE_UINT, 0, G_TYPE_INVALID,
+                             G_TYPE_UINT, &result, G_TYPE_INVALID) == FALSE) {
+               if (error != NULL) {
+                       DBG("Can't get unique name on session bus [%s]\n", error->message);
+                       g_error_free(error);
+               }
+               g_free(agent_name);
+               g_object_unref(priv->dbus_proxy);
+               priv->dbus_proxy = NULL;
+               return;
+       } else {
+               DBG("Reply of dbus name request [%d]\n", result);
+       }
+
+       g_free(agent_name);
+
+       dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged",
+                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+
+       dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
+                                   G_CALLBACK(__sc_core_agent_name_owner_changed), NULL, NULL);
+}
+
+static void __sc_core_reset_dbus(ScCoreAgent *agent)
+{
+       ScCoreAgentPrivate *priv = SC_CORE_AGENT_GET_PRIVATE(agent);
+
+       g_object_unref(priv->dbus_proxy);
+       priv->dbus_proxy = NULL;
+       priv->adapter = NULL;
+}
+
+int _sc_core_agent_add(DBusGProxy *adapter_proxy, SC_CORE_AGENT_FUNC_CB *func_cb)
+{
+       if (gap_agent == NULL) {
+               gap_agent = sc_core_agent_new();
+               __sc_core_setup_dbus(gap_agent);
+       }
+
+       if (__sc_core_agent_register_on_adapter(gap_agent, adapter_proxy, func_cb))
+               return 0;
+
+       return -1;
+}
+
+static gboolean __sc_cre_core_agent_readd(gpointer data)
+{
+       SC_CORE_AGENT_FUNC_CB *cb_ptr = (SC_CORE_AGENT_FUNC_CB *) data;
+
+       _sc_core_agent_add(NULL, cb_ptr);
+
+       if (cb_ptr) {
+               free(cb_ptr);
+       }
+       return 0;
+}
+
+void _sc_core_agent_remove(void)
+{
+       __sc_core_agent_unregister(gap_agent);
+
+       __sc_core_reset_dbus(gap_agent);
+}
+
+ScCoreAgent *_sc_core_agent_get_proxy(void)
+{
+       return gap_agent;
+}
diff --git a/bluetooth-frwk-agent/sc_core_agent.h b/bluetooth-frwk-agent/sc_core_agent.h
new file mode 100644 (file)
index 0000000..7617df6
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 SC_CORE_AGENT_H
+#define SC_CORE_AGENT_H
+
+#include <stdint.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#define BLUEZ_DEVICE_INTERFACE "org.bluez.Device"
+
+#define SC_CORE_TYPE_AGENT (sc_core_agent_get_type())
+#define SC_CORE_GET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SC_CORE_TYPE_AGENT, ScCoreAgent))
+#define SC_CORE_IS_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SC_CORE_TYPE_AGENT))
+
+#define SC_CORE_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), SC_CORE_TYPE_AGENT, \
+                                                                               ScCoreAgentClass))
+#define SC_CORE_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SC_CORE_TYPE_AGENT, \
+                                                                               ScCoreAgentClass))
+#define SC_CORE_IS_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), SC_CORE_TYPE_AGENT))
+
+#define SC_CORE_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), SC_CORE_TYPE_AGENT, \
+                                                                       ScCoreAgentPrivate))
+
+typedef struct _ScCoreAgent ScCoreAgent;
+typedef struct _ScCoreAgentClass ScCoreAgentClass;
+
+typedef gboolean(*ScCoreAgentPasskeyFunc) (DBusGProxy *device);
+typedef gboolean(*ScCoreAgentDisplayFunc) (DBusGProxy *device, guint passkey, guint entered);
+typedef gboolean(*ScCoreAgentConfirmFunc) (DBusGProxy *device, guint passkey);
+typedef gboolean(*ScCoreAgentAuthorizeFunc) (DBusGProxy *device, const char *uuid);
+typedef gboolean(*ScCoreAgentConfirmModeFunc) (const char *mode, const char *sender,
+                                              gboolean need_popup, void *data);
+typedef gboolean(*ScCoreAgentCancelFunc) (const char *address);
+typedef gboolean(*ScCoreAgentIgnoreAutoPairingFunc) (const char *address);
+typedef uint8_t bool_t;
+
+typedef struct {
+       ScCoreAgentPasskeyFunc pincode_func;
+       ScCoreAgentDisplayFunc display_func;
+       ScCoreAgentPasskeyFunc passkey_func;
+       ScCoreAgentConfirmFunc confirm_func;
+       ScCoreAgentAuthorizeFunc authorize_func;
+       ScCoreAgentCancelFunc pairing_cancel_func;
+       ScCoreAgentCancelFunc authorization_cancel_func;
+       ScCoreAgentConfirmModeFunc confirm_mode_func;
+       ScCoreAgentIgnoreAutoPairingFunc ignore_auto_pairing_func;
+} SC_CORE_AGENT_FUNC_CB;
+
+typedef enum {
+       SC_CORE_AGENT_ACCEPT,
+       SC_CORE_AGENT_REJECT,
+       SC_CORE_AGENT_CANCEL,
+       SC_CORE_AGENT_TIMEOUT,
+} SC_CORE_AGENT_ACCEPT_TYPE_T;
+
+struct _ScCoreAgent {
+       GObject parent;
+};
+
+struct _ScCoreAgentClass {
+       GObjectClass parent_class;
+};
+
+int _sc_core_agent_add(DBusGProxy *adapter_proxy, SC_CORE_AGENT_FUNC_CB *func_cb);
+void _sc_core_agent_remove(void);
+ScCoreAgent *_sc_core_agent_get_proxy(void);
+
+gboolean sc_core_agent_reply_pin_code(ScCoreAgent *agent, const guint accept, const char *pin_code,
+                                     DBusGMethodInvocation *context);
+gboolean sc_core_agent_reply_passkey(ScCoreAgent *agent, const guint accept, const char *passkey,
+                                    DBusGMethodInvocation *context);
+gboolean sc_core_agent_reply_confirmation(ScCoreAgent *agent, const guint accept,
+                                         DBusGMethodInvocation *context);
+gboolean sc_core_agent_reply_authorize(ScCoreAgent *agent, const guint accept,
+                                      DBusGMethodInvocation *context);
+gboolean sc_core_agent_reply_adapter_enable(ScCoreAgent *agent, const guint mode,
+                                           const guint accept, DBusGMethodInvocation *context);
+
+#endif
diff --git a/bluetooth-frwk-agent/sc_core_agent.xml b/bluetooth-frwk-agent/sc_core_agent.xml
new file mode 100644 (file)
index 0000000..c21bde3
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/">
+  <interface name="org.bluez.Agent">
+    <method name="RequestPinCode">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="device"/>
+      <arg type="s" name="pincode" direction="out"/>
+    </method>
+
+    <method name="RequestPasskey">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="device"/>
+      <arg type="u" name="passkey" direction="out"/>
+    </method>
+
+    <method name="DisplayPasskey">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="device"/>
+      <arg type="u" name="passkey"/>
+      <arg type="y" name="entered"/>
+    </method>
+
+    <method name="RequestConfirmation">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="device"/>
+      <arg type="u" name="passkey"/>
+    </method>
+
+    <method name="Authorize">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="device"/>
+      <arg type="s" name="uuid"/>
+    </method>
+
+    <method name="ConfirmMode">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="mode"/>
+    </method>
+
+    <method name="Cancel">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+    </method>
+
+    <method name="Release">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+    </method>
+
+    <method name="IgnoreAutoPairing">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+    </method>
+
+    <method name="ReplyPinCode">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="u" name="accept"/>
+      <arg type="s" name="pincode"/>
+    </method>
+
+    <method name="ReplyPasskey">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="u" name="accept"/>
+      <arg type="s" name="passkey"/>
+    </method>
+
+    <method name="ReplyConfirmation">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="u" name="accept"/>
+    </method>
+
+    <method name="ReplyAuthorize">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="u" name="accept"/>
+    </method>
+
+    <method name="ReplyAdapterEnable">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="u" name="mode"/>
+      <arg type="u" name="accept"/>
+    </method>
+  </interface>
+</node>
diff --git a/bluetooth-frwk-agent/stacktrim.h b/bluetooth-frwk-agent/stacktrim.h
new file mode 100644 (file)
index 0000000..07ca59d
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __STACKTRIM_H__
+#define __STACKTRIM_H__
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#define BUF_SIZE               256
+#define PAGE_SIZE              (1 << 12)
+#define _ALIGN_UP(addr, size)    (((addr)+((size)-1))&(~((size)-1)))
+#define _ALIGN_DOWN(addr, size)        ((addr)&(~((size)-1)))
+#define PAGE_ALIGN(addr)        _ALIGN_DOWN(addr, PAGE_SIZE)
+
+static inline void stack_trim(void)
+{
+#ifdef STACK_FLUSH
+       unsigned int sp;
+       char buf[BUF_SIZE];
+       FILE *file;
+       unsigned int stacktop;
+       int found = 0;
+
+       asm volatile ("mov %0,sp " : "=r"(sp));
+
+       sprintf(buf, "/proc/%d/maps", getpid());
+       file = fopen(buf, "r");
+       while (fgets(buf, BUF_SIZE, file) != NULL) {
+               if (strstr(buf, "[stack]")) {
+                       found = 1;
+                       break;
+               }
+       }
+       fclose(file);
+
+       if (found) {
+               sscanf(buf, "%x-", &stacktop);
+               if (madvise((void *)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp) - stacktop,
+                                                                               MADV_DONTNEED) < 0)
+                       perror("stack madvise fail");
+       }
+#endif
+}
+
+#endif                         /* __STACKTRIM_H__ */
diff --git a/bluetooth-map-agent/CMakeLists.txt b/bluetooth-map-agent/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0c1bdd2
--- /dev/null
@@ -0,0 +1,81 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-map-agent C)
+
+SET(SRCS bluetooth_map_agent.c)
+SET(APP_VENDOR samsung)
+SET(APP_NAME bluetooth-map-agent)
+SET(APP_DIR /usr/bin)
+SET(APP_LOCALEDIR /usr/share/locale)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED msg-service email-service vconf)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+#FIND_PROGRAM(MARSHALTOOL NAMES glib-genmarshal)
+#EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --header > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.h")
+#EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --body > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.c")
+
+FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
+EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bluetooth_map ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_map_agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_map_agent_glue.h")
+
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DVENDOR=\"${APP_VENDOR}\"")
+ADD_DEFINITIONS("-DAPPNAME=\"${APP_NAME}\"")
+ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
+ADD_DEFINITIONS("-DAPP_LOCALEDIR=\"${APP_LOCALEDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+#ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
+
+#ADD_CUSTOM_TARGET(bluetooth-agent.edj
+#              COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}
+#              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-agent.edc ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-agent.edj
+#              DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-agent.edc
+#)
+#ADD_DEPENDENCIES(${PROJECT_NAME} bluetooth-agent.edj)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-agent.edj DESTINATION share/edje)
+
+# install desktop file & icon
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+#CONFIGURE_FILE(${PROJECT_NAME}.desktop.in ${PROJECT_NAME}.desktop)
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop DESTINATION share/install-info/application/)
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/icon_bluetooth-agent.png DESTINATION share/icon)
+
+# install ini file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.map_agent.service DESTINATION share/dbus-1/services)
+
+# install booting script
+#INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-map-agent DESTINATION /etc/rc.d/init.d)
+
+# i18n
+#ADD_SUBDIRECTORY(po)
+
diff --git a/bluetooth-map-agent/bluetooth_map_agent.c b/bluetooth-map-agent/bluetooth_map_agent.c
new file mode 100644 (file)
index 0000000..63120e5
--- /dev/null
@@ -0,0 +1,712 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <time.h>
+#include <errno.h>
+#include "vconf.h"
+#include "vconf-keys.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/*Messaging Header Files*/
+#include "MsgTypes.h"
+#include "MapiStorage.h"
+#include "MapiControl.h"
+#include "MapiMessage.h"
+#include "MapiTransport.h"
+
+/*Email Header Files*/
+#include "Emf_Mapi_Init.h"
+#include "Emf_Mapi_Account.h"
+#include "Emf_Mapi_Message.h"
+#include "Emf_Mapi_Network.h"
+#include "Emf_Mapi_Mailbox.h"
+
+#include <bluetooth_map_agent.h>
+
+#define DBUS_STRUCT_STRING_STRING_UINT (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \
+                                               G_TYPE_STRING,  G_TYPE_STRING, G_TYPE_INVALID))
+
+#define DBUS_STRUCT_MESSAGE_LIST (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \
+                                               G_TYPE_STRING,  G_TYPE_STRING, G_TYPE_INVALID))
+static MSG_HANDLE_T msgHandle = NULL;
+#define BT_MAP_STATUS_CB "sent status callback"
+#define BT_MAP_MSG_CB "sms message callback"
+#define BT_MAP_EMAIL_DEFAULTACCOUNT "db/email/defaultaccount"
+#define BT_MAP_SMS "_s"
+#define BT_MAP_EMAIL "_e"
+#define BT_MAP_MSG_INFO_MAX 256
+#define BT_MAP_MSG_HANDLE_MAX 16
+
+typedef struct {
+       GObject parent;
+} BluetoothMapAgent;
+
+typedef struct {
+       GObjectClass parent;
+} BluetoothMapAgentClass;
+
+GType bluetooth_map_agent_get_type(void);
+
+#define BLUETOOTH_MAP_TYPE_AGENT (bluetooth_map_agent_get_type())
+
+#define BLUETOOTH_MAP_AGENT(object) \
+       (G_TYPE_CHECK_INSTANCE_CAST((object), \
+       BLUETOOTH_MAP_TYPE_AGENT , BluetoothMapAgent))
+#define BLUETOOTH_MAP_AGENT_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_CAST((klass), \
+       BLUETOOTH_MAP_TYPE_AGENT , BluetoothMapAgentClass))
+#define BLUETOOTH_MAP_IS_AGENT(object) \
+       (G_TYPE_CHECK_INSTANCE_TYPE((object), \
+       BLUETOOTH_MAP_TYPE_AGENT))
+#define BLUETOOTH_MAP_IS_AGENT_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_TYPE((klass), \
+       BLUETOOTH_MAP_TYPE_AGENT))
+#define BLUETOOTH_MAP_AGENT_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS((obj), \
+       BLUETOOTH_MAP_TYPE_AGENT , BluetoothMapAgentClass))
+
+G_DEFINE_TYPE(BluetoothMapAgent, bluetooth_map_agent, G_TYPE_OBJECT)
+
+GMainLoop *mainloop = NULL;
+
+static gboolean bluetooth_map_get_folder_tree(BluetoothMapAgent *agent,
+                                       DBusGMethodInvocation *context);
+static gboolean bluetooth_map_get_message_list(BluetoothMapAgent *agent,
+                                       gchar *folder_name,
+                                       DBusGMethodInvocation *context);
+static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent,
+                                       gchar *message_name,
+                                       DBusGMethodInvocation *context);
+static gboolean bluetooth_map_update_message(BluetoothMapAgent *agent,
+                                       DBusGMethodInvocation *context);
+static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent,
+                                       gchar *message_name,
+                                       int indicator, int value,
+                                       DBusGMethodInvocation *context);
+
+#include "bluetooth_map_agent_glue.h"
+
+static void bluetooth_map_agent_init(BluetoothMapAgent *obj)
+{
+       DBG("+\n");
+       g_assert(obj != NULL);
+}
+
+static void bluetooth_map_agent_finalize(GObject *obj)
+{
+       DBG("+\n");
+
+       G_OBJECT_CLASS(bluetooth_map_agent_parent_class)->finalize(obj);
+}
+
+static void bluetooth_map_agent_class_init(BluetoothMapAgentClass *klass)
+{
+       GObjectClass *object_class = (GObjectClass *) klass;
+
+       g_assert(klass != NULL);
+
+       object_class->finalize = bluetooth_map_agent_finalize;
+
+       dbus_g_object_type_install_info(BLUETOOTH_MAP_TYPE_AGENT,
+                                       &dbus_glib_bluetooth_map_object_info);
+}
+
+static void bluetooth_map_msg_sent_status_cb(MSG_HANDLE_T handle,
+                               MSG_SENT_STATUS_S *pStatus, void *pUserParam)
+{
+       if (NULL != pStatus) {
+               if (pStatus->status == MSG_NETWORK_SEND_SUCCESS)
+                       DBG("reqId : %d \n", pStatus->reqId);
+               else
+                       DBG("reqId : %d , status : %d \n",
+                                       pStatus->reqId, pStatus->status);
+       }
+}
+
+static void bluetooth_map_msg_incoming_status_cb(MSG_HANDLE_T Handle,
+                               msg_message_t msg, void *pUserParam)
+{
+
+}
+
+static void bluetooth_map_start_service()
+{
+       MSG_ERROR_T err = MSG_SUCCESS;
+
+       err = msg_open_msg_handle(&msgHandle);
+
+       if (err != MSG_SUCCESS) {
+               DBG("msg_open_msg_handle error = %d\n", err);
+       } else {
+               err =  msg_reg_sent_status_callback(msgHandle,
+                               bluetooth_map_msg_sent_status_cb,
+                               (void *)BT_MAP_STATUS_CB);
+
+               if (err != MSG_SUCCESS) {
+                       DBG("msg_reg_sent_status_callback error = %d \n", err);
+               } else {
+                       err = msg_reg_sms_message_callback(msgHandle,
+                                        bluetooth_map_msg_incoming_status_cb,
+                                        0, (void *)BT_MAP_MSG_CB);
+                       if (err != MSG_SUCCESS)
+                               DBG("msg_reg_sms_message_callback error  = %d\n", err);
+               }
+       }
+
+       if (email_service_begin() != EMF_ERROR_NONE)
+               DBG("email_service_begin fail \n");
+       return;
+}
+
+static void bluetooth_map_stop_service()
+{
+       if (NULL != msgHandle)
+               msg_close_msg_handle(&msgHandle);
+       if (EMF_ERROR_NONE != email_service_end())
+               DBG("email_service_end fail \n");
+       return;
+}
+
+static gboolean bluetooth_map_get_folder_tree(BluetoothMapAgent *agent,
+                                       DBusGMethodInvocation *context)
+{
+       GPtrArray *array = g_ptr_array_new();
+       int folder_count = 0;
+       MSG_FOLDER_LIST_S g_folderList;
+       int i = 0;
+       char name[BT_MAP_MSG_INFO_MAX] = {0,};
+       int vconf_err = 0;
+       int account_id = 0;
+       emf_mailbox_t *mailbox_list = NULL;
+       int mailbox_count = 0;
+       bool flag = FALSE;
+       int j = 0;
+       GValue *value;
+
+       bluetooth_map_start_service();
+
+       if (msg_get_folder_list(msgHandle, &g_folderList) == MSG_SUCCESS) {
+               for (i = 0; i < g_folderList.nCount; i++) {
+                       g_strlcpy(name, g_folderList.folderInfo[i].folderName,
+                                                       sizeof(name));
+
+                       value = g_new0(GValue, 1);
+                       g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT);
+                       g_value_take_boxed(value,
+                               dbus_g_type_specialized_construct(
+                                       DBUS_STRUCT_STRING_STRING_UINT));
+                       dbus_g_type_struct_set(value, 0, name, G_MAXUINT);
+                       g_ptr_array_add(array, g_value_get_boxed(value));
+                       g_free(value);
+               }
+       }
+
+       vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id);
+       if (vconf_err != -1) {
+               if (EMF_ERROR_NONE == email_get_mailbox_list(account_id,
+                                                               EMF_MAILBOX_ALL,
+                                                               &mailbox_list,
+                                                               &mailbox_count)) {
+                       for (i = 0; i < mailbox_count; i++) {
+                               flag = FALSE;
+                               for (j = 0; j < g_folderList.nCount; j++) {
+                                       if (!g_ascii_strncasecmp(
+                                               mailbox_list[i].name,
+                                               g_folderList.folderInfo[j].folderName,
+                                               strlen(mailbox_list[i].name))) {
+                                               flag = TRUE;
+                                               break;
+                                       }
+                               }
+                               if (!flag) {
+                                       g_strlcpy(name, mailbox_list[i].name,
+                                                       sizeof(name));
+                                       value = g_new0(GValue, 1);
+                                       g_value_init(value,
+                                               DBUS_STRUCT_STRING_STRING_UINT);
+                                       g_value_take_boxed(value,
+                                               dbus_g_type_specialized_construct(
+                                               DBUS_STRUCT_STRING_STRING_UINT));
+                                       dbus_g_type_struct_set(value, 0, name, G_MAXUINT);
+                                       g_ptr_array_add(array, g_value_get_boxed(value));
+                                       g_free(value);
+                               }
+                       }
+               }
+       }
+
+       dbus_g_method_return(context, array);
+       g_ptr_array_free(array, TRUE);
+
+       return TRUE;
+}
+
+static gboolean bluetooth_map_get_message_list(BluetoothMapAgent *agent,
+                                       gchar *folder_name,
+                                       DBusGMethodInvocation *context)
+{
+       GPtrArray *array = g_ptr_array_new();
+       MSG_FOLDER_ID_T folder_id = 0;
+       int i = 0;
+       MSG_FOLDER_LIST_S g_folderList;
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SORT_RULE_S sortRule;
+       MSG_LIST_S msg_list;
+       GValue *value;
+       char msg_handle[BT_MAP_MSG_HANDLE_MAX] = {0,};
+       char msg_type[BT_MAP_MSG_INFO_MAX] = {0,};
+       char msg_subject[BT_MAP_MSG_INFO_MAX] = {0,};
+       char msg_datetime[BT_MAP_MSG_INFO_MAX] = {0,};
+       char s_name[BT_MAP_MSG_INFO_MAX] = {0,};
+       char s_address[BT_MAP_MSG_INFO_MAX] = {0,};
+       char r_2_address[BT_MAP_MSG_INFO_MAX] = {0,};
+       char r_name[BT_MAP_MSG_INFO_MAX] = {0,};
+       char r_address[BT_MAP_MSG_INFO_MAX] = {0,};
+       char recp_status[BT_MAP_MSG_INFO_MAX] = {0,};
+       int msg_size = 0;
+       int att_size = 0;
+       gboolean text;
+       gboolean read;
+       gboolean sent;
+       gboolean protect;
+       gboolean priority;
+       char *folder;
+       int vconf_err = 0;
+       int account_id = 0;
+       emf_mailbox_t *mailbox_list = NULL;
+       int mailbox_count = 0;
+
+       emf_mail_list_item_t *mail_list = NULL;
+       int mail_count = 0;
+       int err_m;
+       emf_mailbox_t mailbox;
+       int total = 0;
+       int unseen = 0;
+
+       folder = strrchr(folder_name, '/');
+       if (NULL == folder)
+                       folder = folder_name;
+               else
+                       folder++;
+
+       if (msg_get_folder_list(msgHandle, &g_folderList) == MSG_SUCCESS)
+               for (i = 0; i < g_folderList.nCount; i++)
+                       if (!g_ascii_strncasecmp(folder,
+                                       g_folderList.folderInfo[i].folderName,
+                                       strlen(folder)))
+                               folder_id = g_folderList.folderInfo[i].folderId;
+
+       err = msg_get_folder_view_list(msgHandle, folder_id,
+                                    &sortRule, &msg_list);
+       /*SMS and MMS*/
+       if (err == MSG_SUCCESS) {
+               for (i = 0; i < msg_list.nCount; i++) {
+                       value = g_new0(GValue, 1);
+                       g_value_init(value, DBUS_STRUCT_MESSAGE_LIST);
+                       g_value_take_boxed(value, dbus_g_type_specialized_construct(
+                                       DBUS_STRUCT_MESSAGE_LIST));
+                       snprintf(msg_handle, sizeof(msg_handle), "%d%s",
+                               msg_get_message_id(msg_list.msgInfo[i]),
+                               BT_MAP_SMS);
+                       snprintf(msg_datetime, sizeof(msg_datetime), "%dT%d",
+                               (int)msg_get_time(msg_list.msgInfo[i]));
+
+                       DBG("date n time = %s \n ", msg_datetime);
+
+                       switch (msg_get_message_type(msg_list.msgInfo[i])) {
+                       case MSG_TYPE_SMS:
+                               g_strlcpy(msg_type,  "SMS_GSM",
+                                       sizeof(msg_type));
+                               break;
+
+                       case MSG_TYPE_MMS:
+                               g_strlcpy(msg_type,  "MMS",
+                                       sizeof(msg_type));
+                               break;
+
+                       default:
+                               g_strlcpy(msg_type,  "UNKNOWN",
+                                       sizeof(msg_type));
+                               break;
+                       }
+                       dbus_g_type_struct_set(value, 0, msg_handle,
+                                               1, msg_type,
+                                               2, msg_datetime,
+                                               G_MAXUINT);
+                       g_ptr_array_add(array, g_value_get_boxed(value));
+                       g_free(value);
+               }
+       }
+       /*Email*/
+       vconf_err = vconf_get_int(BT_MAP_EMAIL_DEFAULTACCOUNT, &account_id);
+       if (vconf_err != -1) {
+               if (EMF_ERROR_NONE == email_get_mailbox_list(account_id,
+                                                       EMF_MAILBOX_ALL,
+                                                       &mailbox_list,
+                                                       &mailbox_count))
+                       for (i = 0; i < mailbox_count; i++)
+                               if (!g_ascii_strncasecmp(mailbox_list[i].name, folder,
+                                       strlen(mailbox_list[i].name)))
+                                       folder_id = mailbox_list[i].account_id;
+               memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+               mailbox.account_id = folder_id;
+               mailbox.name = strdup(folder);
+               if (EMF_ERROR_NONE == email_count_message(&mailbox, &total,
+                                                       &unseen)) {
+                       DBG(" Total: %d, Unseen: %d \n", total, unseen);
+               }
+
+               if (mailbox.name != NULL)
+                       free(mailbox.name);
+
+               err_m = email_get_mail_list_ex(folder_id, folder,
+                                       EMF_LIST_TYPE_NORMAL,
+                                       0, total - 1, EMF_SORT_DATETIME_HIGH,
+                                       &mail_list, &mail_count);
+               if (err_m == EMF_ERROR_NONE) {
+                       for (i = 0; i < mail_count; ++i) {
+                               value = g_new0(GValue, 1);
+                               g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT);
+                               g_value_take_boxed(value, dbus_g_type_specialized_construct(
+                                       DBUS_STRUCT_STRING_STRING_UINT));
+                               snprintf(msg_handle, sizeof(msg_handle), "%d%s",
+                                                       mail_list[i].mail_id,
+                                                       BT_MAP_EMAIL);
+                               g_strlcpy(msg_type,  "EMAIL",
+                                               sizeof(msg_type));
+                               /*Dummy for testing purpose*/
+                               snprintf(msg_datetime, sizeof(msg_datetime), "%dT%d",
+                                                               12345);
+                               dbus_g_type_struct_set(value, 0, msg_handle,
+                                                       1, msg_type,
+                                                       2, msg_datetime, G_MAXUINT);
+                               g_ptr_array_add(array, g_value_get_boxed(value));
+                               g_free(value);
+                       }
+               }
+       }
+       dbus_g_method_return(context, array);
+       g_ptr_array_free(array, TRUE);
+}
+
+static gboolean bluetooth_map_get_message(BluetoothMapAgent *agent,
+                                       gchar *message_name,
+                                       DBusGMethodInvocation *context)
+{
+       GPtrArray *array = g_ptr_array_new();
+       char *pch, *last;
+       int message_id;
+       GValue *value;
+
+       if (message_name != NULL) {
+               pch = strtok_r(message_name, "_", &last);
+               if (pch == NULL)
+                       return -1;
+
+               message_id = atoi(pch);
+               pch = strtok_r(NULL, "_", &last);
+       }
+
+       value = g_new0(GValue, 1);
+       g_value_init(value, DBUS_STRUCT_STRING_STRING_UINT);
+       g_value_take_boxed(value, dbus_g_type_specialized_construct(
+                       DBUS_STRUCT_STRING_STRING_UINT));
+
+       if (!g_ascii_strncasecmp(pch, "s", 1)) {
+               msg_message_t msg ;
+               MSG_ERROR_T err = MSG_SUCCESS;
+               MSG_SENDINGOPT_S sendOpt = { 0 };
+
+               msg = msg_new_message();
+               err = msg_get_message(msgHandle, (MSG_MESSAGE_ID_T)message_id,
+                                                       msg,
+                                                       &sendOpt);
+               if (err == MSG_SUCCESS)
+                       DBG("Body =%s \n", msg_sms_get_message_body(msg));
+               dbus_g_type_struct_set(value, 0, msg_sms_get_message_body(msg),
+                                               G_MAXUINT);
+               g_ptr_array_add(array, g_value_get_boxed(value));
+               g_free(value);
+
+       } else if (!g_ascii_strncasecmp(pch, "e", 1)) {
+               emf_mailbox_t mailbox;
+               emf_mail_t *mail = NULL;
+               emf_mail_body_t *body = NULL;
+               FILE *body_file;
+               int nread = 0;
+               char *buf;
+               long lSize;
+
+               memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+               if (EMF_ERROR_NONE ==  email_get_mail(&mailbox, message_id, &mail)) {
+                       if (EMF_ERROR_NONE ==
+                                       email_get_body_from_mail(mail, &body)) {
+                               body_file = fopen(body->html, "r");
+                               if (body_file == NULL)
+                                       body_file = fopen(body->plain, "r");
+                               if (body_file != NULL) {
+                                       /* obtain file size */
+                                       fseek(body_file , 0 , SEEK_END);
+                                       lSize = ftell(body_file);
+                                       rewind(body_file);
+
+                                       nread = fread(buf, 1, lSize, body_file);
+                                       if (nread != lSize)
+                                               DBG("Read error email \n");
+                                       else {
+                                               dbus_g_type_struct_set(value, 0,
+                                                       buf,
+                                                       G_MAXUINT);
+                                               g_ptr_array_add(array, g_value_get_boxed(value));
+                                               g_free(value);
+                                       }
+                               }
+                       }
+               }
+       }
+       dbus_g_method_return(context, array);
+       g_ptr_array_free(array, TRUE);
+}
+
+static gboolean bluetooth_map_update_message(BluetoothMapAgent *agent,
+                                       DBusGMethodInvocation *context)
+{
+       unsigned handle;
+       int err;
+
+       DBG("bluetooth_map_update_message 123");
+
+       err = email_sync_header_for_all_account(&handle);
+       if (err == EMF_ERROR_NONE) {
+               DBG("Handle to stop download = %d \n", handle);
+       } else {
+               DBG("Message Update failed \n");
+       }
+       dbus_g_method_return(context, err);
+}
+
+static gboolean bluetooth_map_message_status(BluetoothMapAgent *agent,
+                                       gchar *message_name,
+                                       int indicator, int value,
+                                       DBusGMethodInvocation *context)
+{
+       char *pch, *last;
+       int message_id;
+       emf_mailbox_t mailbox;
+       emf_mail_t *mail = NULL;
+       msg_message_t msg;
+       MSG_ERROR_T err = MSG_SUCCESS;
+       MSG_SENDINGOPT_S sendOpt = { 0 };
+       int ret;
+
+       DBG("bluetooth_map_message_status");
+
+       if (message_name != NULL) {
+               pch = strtok_r(message_name, "_", &last);
+               if (pch == NULL)
+                       return -1;
+
+               message_id = atoi(pch);
+               pch = strtok_r(NULL, "_", &last);
+       }
+       DBG("Message handle = %d, i = %d, v = %d\n", message_id, indicator, value);
+
+       if (!g_ascii_strncasecmp(pch, "s", 1)) {
+               switch (indicator) {
+               case 0:{
+                       msg = msg_new_message();
+                       err = msg_get_message(msgHandle,
+                                           (MSG_MESSAGE_ID_T)message_id, msg,
+                                           &sendOpt);
+                       if (err == MSG_SUCCESS) {
+                               if (!msg_is_read(msg)) {
+                                       DBG(" Message is UNREAD \n");
+
+                                       ret = msg_update_read_status(msgHandle,
+                                                               message_id, TRUE);
+                                       if (msg_is_mms(msg)) {
+                                               ret = msg_mms_send_read_report(
+                                                       msgHandle,
+                                                       message_id,
+                                                       MSG_READ_REPORT_IS_READ);
+                                       }
+                               } else {
+                                       DBG("Message is READ \n");
+                                       ret = msg_update_read_status(msgHandle,
+                                                                  message_id,
+                                                                  FALSE);
+
+                                       if (msg_is_mms(msg)) {
+                                               ret = msg_mms_send_read_report(
+                                                       msgHandle,
+                                                       message_id,
+                                                       MSG_READ_REPORT_NONE);
+                                       }
+                               }
+                               msg_release_message(&msg);
+                       } else {
+                               DBG("Get message failed %d\n", err);
+                       }
+
+                       break;
+               }
+
+               case 1: {
+                       if (msg_delete_message(msgHandle, message_id) ==  MSG_SUCCESS) {
+                               DBG("Message delete success");
+                               ret = TRUE;
+                       } else {
+                               DBG("Message delete fail");
+                               ret = FALSE;
+                       }
+                       break;
+               }
+
+               default:
+                       break;
+               }
+       } else if (!g_ascii_strncasecmp(pch, "e", 1)) {
+               switch (indicator) {
+               case 0: {
+                       emf_mail_flag_t newflag;
+                       memset(&newflag, 0x00, sizeof(emf_mail_flag_t));
+                       newflag.seen = !newflag.seen;
+                       newflag.answered = 0;
+                       newflag.sticky = 1;
+
+                       if (email_modify_mail_flag(message_id, newflag, 1) < 0) {
+                               DBG("email_modify_mail_flag failed \n");
+                               ret = FALSE;
+                       } else {
+                               DBG("email_modify_mail_flag success \n");
+                               ret = TRUE;
+                       }
+                       break;
+               }
+               case 1: {
+                       memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+                       if (email_get_mail(&mailbox, message_id, &mail) < 0) {
+                               DBG("email_get_mail failed\n");
+                       } else {
+                               DBG("email_get_mail success\n");
+                               if (email_delete_message(&mailbox, &message_id, 1, 1) >= 9) {
+                                       DBG("\n email_delete_message success");
+                                       ret = TRUE;
+                               } else {
+                                       DBG("\n email_delete_message failed");
+                                       ret = FALSE;
+                               }
+                               email_free_mail(&mail, 1);
+                       }
+                       break;
+               }
+
+               default:
+                       break;
+               }
+       }
+       dbus_g_method_return(context, ret);
+}
+
+int main(int argc, char **argv)
+{
+       BluetoothMapAgent *bluetooth_map_obj = NULL;
+       DBusGConnection *bus = NULL;
+       DBusGProxy *bus_proxy = NULL;
+       guint result = 0;
+       GError *error = NULL;
+
+       g_type_init();
+       DBG("Map Agent\n");
+       mainloop = g_main_loop_new(NULL, FALSE);
+       if (mainloop == NULL) {
+               DBG("Couldn't create GMainLoop\n");
+               return EXIT_FAILURE;
+       }
+
+       bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+       if (error != NULL) {
+               DBG("Couldn't connect to system bus[%s]\n", error->message);
+               g_error_free(error);
+               return EXIT_FAILURE;
+       }
+
+       bus_proxy = dbus_g_proxy_new_for_name(bus, DBUS_SERVICE_DBUS,
+                                       DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+       if (bus_proxy == NULL) {
+               DBG("Failed to get a proxy for D-Bus\n");
+               goto failure;
+       }
+
+       if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING,
+                       BT_MAP_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
+                       G_TYPE_UINT, &result, G_TYPE_INVALID)) {
+               if (error != NULL) {
+                       DBG("RequestName RPC failed[%s]\n", error->message);
+                       g_error_free(error);
+               }
+               goto failure;
+       }
+       DBG("result : %d %d\n", result, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+               DBG("Failed to get the primary well-known name.\n");
+               goto failure;
+       }
+
+       g_object_unref(bus_proxy);
+       bus_proxy = NULL;
+
+       bluetooth_map_obj = g_object_new(BLUETOOTH_MAP_TYPE_AGENT, NULL);
+       if (bluetooth_map_obj == NULL) {
+               DBG("Failed to create one BluetoothMapAgent instance.\n");
+               goto failure;
+       }
+
+       /* Registering it on the D-Bus */
+       dbus_g_connection_register_g_object(bus, BT_MAP_SERVICE_OBJECT_PATH,
+                                               G_OBJECT(bluetooth_map_obj));
+
+       g_main_loop_run(mainloop);
+
+ failure:
+       DBG("Terminate the bluetooth-map-agent\n");
+       if (bus)
+               dbus_g_connection_unref(bus);
+       if (bus_proxy)
+               g_object_unref(bus_proxy);
+       if (bluetooth_map_obj)
+               g_object_unref(bluetooth_map_obj);
+
+       return EXIT_FAILURE;
+}
+
+
diff --git a/bluetooth-map-agent/bluetooth_map_agent.h b/bluetooth-map-agent/bluetooth_map_agent.h
new file mode 100644 (file)
index 0000000..b04abde
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __DEF_BT_PB_AGENT_H_
+#define __DEF_BT_PB_AGENT_H_
+
+#include <unistd.h>
+#include <dlog.h>
+
+#include <stdio.h>
+
+#include <dbus/dbus-glib.h>
+
+#define BT_MAP_SERVICE_OBJECT_PATH "/org/bluez/map_agent"
+#define BT_MAP_SERVICE_NAME "org.bluez.map_agent"
+#define BT_MAP_SERVICE_INTERFACE "org.bluez.MapAgent"
+
+#define BT_MAP_AGENT   "BT_MAP_AGENT"
+#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_MAP_AGENT, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define ERR(fmt, args...) SLOG(LOG_ERROR, BT_MAP_AGENT, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+#endif /* __DEF_BT_AGENT_H_ */
diff --git a/bluetooth-map-agent/bluetooth_map_agent.xml b/bluetooth-map-agent/bluetooth_map_agent.xml
new file mode 100644 (file)
index 0000000..0378630
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<node name="/">
+       <interface name="org.bluez.MapAgent">
+               <method name="GetFolderTree">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="a(s)" name="folder_list" direction="out"/>
+               </method>
+               <method name="GetMessageList">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="s" name="folder_name"/>
+                       <arg type="a(ss)" name="msg_list" direction="out"/>
+               </method>
+               <method name="GetMessage">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="s" name="messgae_name"/>
+                       <arg type="a(s)" name="msg_body" direction="out"/>
+               </method>
+               <method name="UpdateMessage">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="u" name="update_err" direction="out"/>
+               </method>
+               <method name="MessageStatus">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="s" name="message_name"/>
+                       <arg type="i" name="indicator"/>
+                       <arg type="i" name="value"/>
+                       <arg type="u" name="update_err" direction="out"/>
+               </method>
+       </interface>
+</node>
diff --git a/bluetooth-map-agent/org.bluez.map_agent.service b/bluetooth-map-agent/org.bluez.map_agent.service
new file mode 100644 (file)
index 0000000..3a5a867
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.bluez.map_agent
+Exec=/usr/bin/bluetooth-map-agent
diff --git a/bluetooth-media-control/CMakeLists.txt b/bluetooth-media-control/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bcc6d28
--- /dev/null
@@ -0,0 +1,50 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-media-control C)
+
+SET(SRCS bluetooth-media-control-api.c)
+SET(HEADERS bluetooth-media-control-api.h)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION_MAJOR 1)
+SET(VERSION ${VERSION_MAJOR}.0.0)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(packages REQUIRED dlog dbus-glib-1)
+
+FOREACH(flag ${packages_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g ")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${packages_LDFLAGS})
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+
+FOREACH(hfile ${HEADERS})
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-media-control)
+ENDFOREACH(hfile)
+
+ADD_SUBDIRECTORY(test)
+
diff --git a/bluetooth-media-control/bluetooth-media-control-api.c b/bluetooth-media-control/bluetooth-media-control-api.c
new file mode 100644 (file)
index 0000000..4b915d1
--- /dev/null
@@ -0,0 +1,633 @@
+/*
+ *   bluetooth-media-control
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:    Hocheol Seo <hocheol.seo@samsung.com>
+ *             Girishashok Joshi <girish.joshi@samsung.com>
+ *             Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <sys/types.h>
+#include <glib.h>
+#include <string.h>
+
+#include "bluetooth-media-control-api.h"
+
+#define BLUEZ_SERVICE  "org.bluez"
+#define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager"
+
+#define MEDIA_INTERFACE        "org.bluez.Media"
+#define MEDIA_PLAYER_OBJECT    "/Musicplayer"
+
+
+#define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer"
+
+
+static avrcp_dbus_info_t g_avrcp_dbus_info;
+static DBusConnection *g_avrcp_connection = NULL;
+
+struct player_settinngs_t  {
+       int key;
+       const char *property;
+};
+
+static struct player_settinngs_t equilizer_settings[] = {
+       { EQUILIZER_OFF, "off" },
+       { EQUILIZER_ON, "on" },
+       { EQUILIZER_INVALID, "" }
+};
+
+static struct player_settinngs_t repeat_settings[] = {
+       { REPEAT_MODE_OFF, "off" },
+       { REPEAT_SINGLE_TRACK, "singletrack" },
+       { REPEAT_ALL_TRACK, "alltracks" },
+       { REPEAT_GROUP, "group" },
+       { REPEAT_INVALID, "" }
+};
+
+static struct player_settinngs_t shuffle_settings[] = {
+       { SHUFFLE_MODE_OFF, "off" },
+       { SHUFFLE_ALL_TRACK, "alltracks" },
+       { SHUFFLE_GROUP, "group" },
+       { SHUFFLE_INVALID, "" }
+};
+
+static struct player_settinngs_t scan_settings[] = {
+       { SCAN_MODE_OFF, "off" },
+       { SCAN_ALL_TRACK, "alltracks" },
+       { SCAN_GROUP, "group" },
+       { SCAN_INVALID, "" }
+};
+
+static struct player_settinngs_t player_status[] = {
+       { STATUS_PLAYING, "playing" },
+       { STATUS_STOPPED, "stopped" },
+       { STATUS_PAUSED, "paused" },
+       { STATUS_FORWARD_SEEK, "forward-seek" },
+       { STATUS_REVERSE_SEEK, "reverse-seek" },
+       { STATUS_ERROR, "error" },
+       { STATUS_INVALID, "" }
+};
+
+static int __bluetooth_media_control_get_avrcp_adapter_path(
+               DBusGConnection *gconn, char *path)
+{
+       GError *err = NULL;
+       DBusGProxy *manager_proxy = NULL;
+       char *adapter_path = NULL;
+       int ret = 0;
+
+       DBG("+\n");
+
+       manager_proxy = dbus_g_proxy_new_for_name(gconn, BLUEZ_SERVICE, "/",
+                                       BLUEZ_MANAGER_INTERFACE);
+
+       if (manager_proxy == NULL) {
+               DBG("Could not create a dbus proxy\n");
+               ret = BT_MEDIA_CONTROL_ERROR;
+               goto done;
+       }
+
+       if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &err,
+                              G_TYPE_INVALID,DBUS_TYPE_G_OBJECT_PATH,
+                              &adapter_path,G_TYPE_INVALID)) {
+               DBG("Getting DefaultAdapter failed: [%s]\n", err->message);
+               g_error_free(err);
+               ret = BT_MEDIA_CONTROL_ERROR;
+               goto done;
+       }
+
+       if (adapter_path == NULL) {
+               ret = BT_MEDIA_CONTROL_ERROR;
+               DBG("Adapter path is NULL\n");
+               goto done;
+       }
+
+       if (strlen(adapter_path) >= MEDIA_OBJECT_PATH_LENGTH) {
+               DBG("Path too long.\n");
+               ret = BT_MEDIA_CONTROL_ERROR;
+               goto done;
+       }
+       DBG("path = %s\n", adapter_path);
+       g_strlcpy(path, adapter_path, MEDIA_OBJECT_PATH_LENGTH);
+
+ done:
+
+       if (manager_proxy != NULL) {
+               g_object_unref(manager_proxy);
+       }
+       if (adapter_path != NULL) {
+               free(adapter_path);
+       }
+       DBG("Adapter [%s]\n", path);
+
+       DBG("-\n");
+       return ret;
+}
+
+static void __bluetooth_media_control_append_variant(DBusMessageIter *iter,
+                       int type, void *val)
+{
+       DBusMessageIter value_iter;
+       const char *signature;
+
+       switch (type) {
+       case DBUS_TYPE_BOOLEAN:
+               signature = DBUS_TYPE_BOOLEAN_AS_STRING;
+               break;
+       case DBUS_TYPE_STRING:
+               signature = DBUS_TYPE_STRING_AS_STRING;
+               break;
+       case DBUS_TYPE_BYTE:
+               signature = DBUS_TYPE_BYTE_AS_STRING;
+               break;
+       case DBUS_TYPE_UINT16:
+               signature = DBUS_TYPE_UINT16_AS_STRING;
+               break;
+       case DBUS_TYPE_UINT32:
+               signature = DBUS_TYPE_UINT32_AS_STRING;
+               break;
+       case DBUS_TYPE_INT16:
+               signature = DBUS_TYPE_INT16_AS_STRING;
+               break;
+       case DBUS_TYPE_INT32:
+               signature = DBUS_TYPE_INT32_AS_STRING;
+               break;
+       case DBUS_TYPE_OBJECT_PATH:
+               signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
+               break;
+       default:
+               signature = DBUS_TYPE_VARIANT_AS_STRING;
+       }
+
+       dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, signature, &value_iter);
+       dbus_message_iter_append_basic(&value_iter, type, val);
+       dbus_message_iter_close_container(iter, &value_iter);
+}
+
+static void __bluetooth_media_control_append_dict_entry(DBusMessageIter *dict,
+                       const char *key, int type, void *property)
+{
+       DBusMessageIter entry;
+
+       if (type == DBUS_TYPE_STRING) {
+               const char *str_ptr = *((const char **)property);
+               if (str_ptr == NULL)
+                       return;
+       }
+
+       dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+                                                       NULL, &entry);
+
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+       __bluetooth_media_control_append_variant(&entry, type, property);
+
+       dbus_message_iter_close_container(dict, &entry);
+}
+
+BT_EXPORT_API int bluetooth_media_control_init(void)
+{
+       GError *err = NULL;
+       char default_obj_path[MEDIA_OBJECT_PATH_LENGTH] = {0,};
+
+       DBG("+\n");
+
+       g_avrcp_dbus_info.avrcp_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (!g_avrcp_dbus_info.avrcp_conn) {
+               DBG("Can not get DBUS Gconnection [%s]\n",err->message);
+               g_error_free(err);
+               return BT_MEDIA_CONTROL_ERROR;
+       }
+
+       g_avrcp_connection = (DBusConnection *)dbus_g_connection_get_connection(
+                                               g_avrcp_dbus_info.avrcp_conn);
+
+       if (__bluetooth_media_control_get_avrcp_adapter_path(
+               g_avrcp_dbus_info.avrcp_conn,
+                default_obj_path) < 0) {
+               DBG("Could not get adapter path\n");
+               goto error;
+       }
+
+       if (default_obj_path != NULL)
+               g_strlcpy(g_avrcp_dbus_info.avrcp_obj_path, default_obj_path,
+                       MEDIA_OBJECT_PATH_LENGTH);
+       else
+               goto error;
+
+       DBG("-\n");
+       return BT_MEDIA_CONTROL_SUCCESS;
+
+error:
+       dbus_g_connection_unref(g_avrcp_dbus_info.avrcp_conn);
+       g_avrcp_dbus_info.avrcp_conn = NULL;
+       g_avrcp_connection = NULL;
+       return BT_MEDIA_CONTROL_ERROR;
+}
+
+BT_EXPORT_API int bluetooth_media_control_register_player(
+                       media_player_settings_t player_settings,
+                       media_metadata_attributes_t metadata )
+{
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusMessageIter iter;
+       DBusMessageIter property_dict;
+       DBusMessageIter metadata_dict;
+       DBusError err;
+
+       const char *object = g_strdup(MEDIA_PLAYER_OBJECT);
+
+       DBG("+\n");
+
+       msg = dbus_message_new_method_call(
+                               BLUEZ_SERVICE,
+                               g_avrcp_dbus_info.avrcp_obj_path,
+                               MEDIA_INTERFACE,
+                               "RegisterPlayer");
+       if (!msg) {
+               DBG("dbus_message_new_method_call failed\n");
+               g_free((void *)object);
+               return BT_MEDIA_CONTROL_ERROR;
+       }
+
+       DBG("object = [%s] \n",object);
+
+       dbus_message_iter_init_append(msg, &iter);
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                       DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &property_dict);
+
+       if (player_settings.equilizer < EQUILIZER_INVALID) {
+               __bluetooth_media_control_append_dict_entry(&property_dict,
+                       "Equalizer",
+                       DBUS_TYPE_STRING,
+                       &equilizer_settings[player_settings.equilizer].property);
+       }
+
+       if (player_settings.repeat < REPEAT_INVALID) {
+               __bluetooth_media_control_append_dict_entry(&property_dict,
+                       "Repeat",
+                       DBUS_TYPE_STRING,
+                       &repeat_settings[player_settings.repeat].property);
+       }
+
+       if (player_settings.shuffle < SHUFFLE_INVALID) {
+               __bluetooth_media_control_append_dict_entry(&property_dict,
+                       "Shuffle",
+                       DBUS_TYPE_STRING,
+                       &shuffle_settings[player_settings.shuffle].property);
+       }
+
+       if (player_settings.scan < SCAN_INVALID) {
+               __bluetooth_media_control_append_dict_entry(&property_dict,
+                       "Scan",
+                       DBUS_TYPE_STRING,
+                       &scan_settings[player_settings.scan].property);
+       }
+
+       if (player_settings.status < STATUS_INVALID) {
+               __bluetooth_media_control_append_dict_entry(&property_dict,
+                       "Status",
+                       DBUS_TYPE_STRING,
+                       &player_status[player_settings.status].property);
+       }
+
+       if(0 != player_settings.position)
+               __bluetooth_media_control_append_dict_entry(&property_dict,
+                       "Position",
+                       DBUS_TYPE_UINT32, &player_settings.position);
+
+       dbus_message_iter_close_container(&iter, &property_dict);
+
+       dbus_message_iter_init_append(msg, &iter);
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                       DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &metadata_dict);
+
+       if (NULL != metadata.title) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Title",
+                       DBUS_TYPE_STRING, &metadata.title);
+       }
+
+       if (NULL != metadata.artist) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Artist",
+                       DBUS_TYPE_STRING, &metadata.artist);
+       }
+
+       if (NULL != metadata.album) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Album",
+                       DBUS_TYPE_STRING, &metadata.album);
+       }
+
+       if ( NULL != metadata.genre ) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Genre",
+                       DBUS_TYPE_STRING, &metadata.genre);
+       }
+
+       if (0 != metadata.total_tracks)
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "NumberOfTracks",
+                       DBUS_TYPE_UINT32, &metadata.total_tracks);
+
+       if (0 != metadata.number)
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Number",
+                       DBUS_TYPE_UINT32, &metadata.number);
+
+       if (0 != metadata.duration)
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Duration",
+                       DBUS_TYPE_UINT32, &metadata.duration);
+
+       dbus_message_iter_close_container(&iter, &metadata_dict);
+
+       dbus_error_init(&err);
+       reply = dbus_connection_send_with_reply_and_block(g_avrcp_connection,
+                               msg, -1, &err);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("Error in registering the Music Player \n");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+                       g_free((void *)object);
+                       return BT_MEDIA_CONTROL_ERROR;
+               }
+       }
+       g_free((void *)object);
+
+       DBG("-\n");
+
+       return BT_MEDIA_CONTROL_SUCCESS;
+}
+
+BT_EXPORT_API int bluetooth_media_control_unregister_player(void)
+{
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusError err;
+       const char *object = g_strdup(MEDIA_PLAYER_OBJECT);
+
+       DBG("+\n");
+
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE,
+                                       g_avrcp_dbus_info.avrcp_obj_path,
+                                       MEDIA_INTERFACE,
+                                       "UnregisterPlayer");
+
+       if (NULL == msg) {
+               g_free((void *)object);
+               return BT_MEDIA_CONTROL_ERROR;
+       }
+
+       dbus_message_append_args(msg,
+                               DBUS_TYPE_OBJECT_PATH, &object,
+                               DBUS_TYPE_INVALID);
+
+       dbus_error_init(&err);
+       reply = dbus_connection_send_with_reply_and_block(g_avrcp_connection,
+                               msg, -1, &err);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("Error in unregistering the Music Player \n");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+                       g_free((void *)object);
+                       return BT_MEDIA_CONTROL_ERROR;
+               }
+       }
+       g_free((void *)object);
+
+       DBG("-\n");
+       return BT_MEDIA_CONTROL_SUCCESS;
+}
+
+static dbus_bool_t __bluetooth_media_control_emit_property_changed(
+                               DBusConnection *conn,
+                               const char *path,
+                               const char *interface,
+                               const char *name,
+                               int type, void *value)
+{
+       DBusMessage *signal = NULL;
+       DBusMessageIter iter;
+       dbus_bool_t result;
+
+       signal = dbus_message_new_signal(path, interface, "PropertyChanged");
+
+       if (!signal) {
+               DBG("Unable to allocate new %s.PropertyChanged signal",
+                        interface);
+               return FALSE;
+       }
+
+       dbus_message_iter_init_append(signal, &iter);
+
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
+
+       __bluetooth_media_control_append_variant(&iter, type, value);
+
+       result = dbus_connection_send(conn, signal, NULL);
+       dbus_message_unref(signal);
+
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_media_control_player_property_changed(
+                       media_player_settings_t player_settings)
+{
+       DBG("+\n");
+
+       if (player_settings.equilizer < EQUILIZER_INVALID) {
+               if (!__bluetooth_media_control_emit_property_changed(
+                       g_avrcp_connection,
+                       MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE,
+                       "Equalizer",
+                       DBUS_TYPE_STRING,
+                       &equilizer_settings[player_settings.equilizer].property)) {
+                       DBG("Error sending the PropertyChanged signal \n");
+               }
+       }
+
+       if (player_settings.repeat < REPEAT_INVALID) {
+               if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection,
+                       MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE,
+                       "Repeat",
+                       DBUS_TYPE_STRING,
+                       &repeat_settings[player_settings.repeat].property)) {
+                       DBG("Error sending the PropertyChanged signal \n");
+               }
+       }
+
+       if (player_settings.shuffle < SHUFFLE_INVALID) {
+               if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection,
+                       MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE,
+                       "Shuffle",
+                       DBUS_TYPE_STRING,
+                       &shuffle_settings[player_settings.shuffle].property)) {
+                       DBG("Error sending the PropertyChanged signal \n");
+               }
+       }
+
+       if (player_settings.scan < SCAN_INVALID) {
+               if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection,
+                       MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE,
+                       "Scan",
+                       DBUS_TYPE_STRING,
+                       &scan_settings[player_settings.scan].property)) {
+                       DBG("Error sending the PropertyChanged signal \n");
+               }
+       }
+
+       if (player_settings.status < STATUS_INVALID) {
+               if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection,
+                       MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE,
+                       "Status",
+                       DBUS_TYPE_STRING,
+                       &player_status[player_settings.status].property)) {
+                       DBG("Error sending the PropertyChanged signal \n");
+               }
+       }
+
+       if (0 != player_settings.position) {
+               if (!__bluetooth_media_control_emit_property_changed(g_avrcp_connection,
+                       MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE,
+                       "Position",
+                       DBUS_TYPE_UINT32,
+                       &player_settings.position)) {
+                       DBG("Error sending the PropertyChanged signal \n");
+               }
+       }
+
+       DBG("-\n");
+       return BT_MEDIA_CONTROL_SUCCESS;
+}
+
+BT_EXPORT_API int bluetooth_media_control_player_track_changed(
+               media_metadata_attributes_t metadata)
+{
+       DBusMessage *signal= NULL;
+       DBusMessageIter iter;
+       DBusMessageIter metadata_dict;
+
+       DBG("+\n");
+
+       signal = dbus_message_new_signal(MEDIA_PLAYER_OBJECT,
+                       MEDIA_PLAYER_INTERFACE, "TrackChanged");
+       if (!signal) {
+               DBG("Unable to allocate TrackChanged signal\n");
+               return BT_MEDIA_CONTROL_ERROR;
+       }
+
+       dbus_message_iter_init_append(signal, &iter);
+
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                       DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &metadata_dict);
+
+       if (NULL != metadata.title) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Title",
+                       DBUS_TYPE_STRING, &metadata.title);
+       }
+
+       if (NULL != metadata.artist) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Artist",
+                       DBUS_TYPE_STRING, &metadata.artist);
+       }
+
+       if (NULL != metadata.album) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Album",
+                       DBUS_TYPE_STRING, &metadata.album);
+       }
+
+       if (NULL != metadata.genre) {
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Genre",
+                       DBUS_TYPE_STRING, &metadata.genre);
+       }
+
+       if (0 != metadata.total_tracks)
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "NumberOfTracks",
+                       DBUS_TYPE_UINT32, &metadata.total_tracks);
+
+       if (0 != metadata.number)
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Number",
+                       DBUS_TYPE_UINT32, &metadata.number);
+
+       if (0 != metadata.duration)
+               __bluetooth_media_control_append_dict_entry(&metadata_dict,
+                       "Duration",
+                       DBUS_TYPE_UINT32, &metadata.duration);
+
+       dbus_message_iter_close_container(&iter, &metadata_dict);
+
+       if (!dbus_connection_send(g_avrcp_connection, signal, NULL))
+               DBG("Unable to send TrackChanged signal\n");
+       dbus_message_unref(signal);
+
+       DBG("-\n");
+       return BT_MEDIA_CONTROL_SUCCESS;
+}
+
+BT_EXPORT_API int bluetooth_media_control_deinit(void)
+{
+       DBG("+\n");
+
+       if (g_avrcp_dbus_info.avrcp_conn) {
+               dbus_g_connection_unref(g_avrcp_dbus_info.avrcp_conn);
+               g_avrcp_dbus_info.avrcp_conn = NULL;
+       }
+
+       DBG("-\n");
+       return BT_MEDIA_CONTROL_SUCCESS;
+}
+
+
diff --git a/bluetooth-media-control/bluetooth-media-control-api.h b/bluetooth-media-control/bluetooth-media-control-api.h
new file mode 100644 (file)
index 0000000..27765b3
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ *   bluetooth-media-control
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:    Hocheol Seo <hocheol.seo@samsung.com>
+ *             Girishashok Joshi <girish.joshi@samsung.com>
+ *             Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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_MP_CONTROL_H_
+#define _BT_MP_CONTROL_H_
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /*__cplusplus*/
+
+#ifndef BT_EXPORT_API
+#define BT_EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#define BT_MEDIA_CONTROL "BT_MEDIA_CONTROL"
+#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_MEDIA_CONTROL, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define ERR(fmt, args...) SLOG(LOG_ERROR, BT_MEDIA_CONTROL, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+/* defines*/
+#define MEDIA_OBJECT_PATH_LENGTH       50
+
+#define BT_MEDIA_CONTROL_ERROR -1
+#define BT_MEDIA_CONTROL_SUCCESS       0
+
+typedef enum {
+       EQUILIZER_OFF = 0x00,
+       EQUILIZER_ON,
+       EQUILIZER_INVALID,
+} media_player_equilizer_status;
+
+typedef enum {
+       REPEAT_MODE_OFF = 0x00,
+       REPEAT_SINGLE_TRACK,
+       REPEAT_ALL_TRACK,
+       REPEAT_GROUP,
+       REPEAT_INVALID,
+} media_player_repeat_status;
+
+typedef enum {
+       SHUFFLE_MODE_OFF = 0x00,
+       SHUFFLE_ALL_TRACK,
+       SHUFFLE_GROUP,
+       SHUFFLE_INVALID,
+} media_player_shuffle_status;
+
+typedef enum {
+       SCAN_MODE_OFF = 0x00,
+       SCAN_ALL_TRACK,
+       SCAN_GROUP,
+       SCAN_INVALID,
+} media_player_scan_status;
+
+typedef enum {
+       STATUS_PLAYING  = 0x00,
+       STATUS_STOPPED,
+       STATUS_PAUSED,
+       STATUS_FORWARD_SEEK,
+       STATUS_REVERSE_SEEK,
+       STATUS_ERROR,
+       STATUS_INVALID
+} media_player_status;
+
+typedef struct {
+       media_player_equilizer_status equilizer;
+       media_player_repeat_status  repeat;
+       media_player_shuffle_status  shuffle;
+       media_player_scan_status scan;
+       media_player_status status;
+       unsigned int position;
+}media_player_settings_t;
+
+typedef struct {
+       const char *title;
+       const char *artist;
+       const char *album;
+       const char *genre;
+       unsigned int total_tracks;
+       unsigned int number;
+       unsigned int duration;
+}media_metadata_attributes_t;
+
+typedef struct {
+       DBusGConnection *avrcp_conn;
+       char avrcp_obj_path[MEDIA_OBJECT_PATH_LENGTH];
+} avrcp_dbus_info_t;
+
+/**
+ * @fn int bluetooth_media_control_init(void)
+ * @brief Initializes the Media interface to media service
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   0  - Success \n
+ *          -1 - On Failure\n
+ *
+ * @exception   None
+ * @param[in]  None.
+ *
+ * @remark       None
+ * @see         None
+ */
+int bluetooth_media_control_init(void);
+
+/**
+ * @fn int bluetooth_media_control_register_player(media_player_settings_t player_settings,
+ *                                                     media_metadata_attributes_t metadata )
+ * @brief Registers the Music player with its player settings and media attributes
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   0  - Success \n
+ *          -1 - On Failure\n
+ *
+ * @exception   None
+ * @param[in]   player_settings - Music player application settings,
+ *                      metadata -Meida attributes
+ *
+ * @remark       None
+ * @see         None
+ */
+int bluetooth_media_control_register_player(
+                               media_player_settings_t player_settings,
+                               media_metadata_attributes_t metadata );
+
+/**
+ * @fn int bluetooth_media_control_unregister_player(void )
+ * @brief Un-registers the Music player
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   0  - Success \n
+ *          -1 - On Failure\n
+ *
+ * @exception   None
+ * @param[in]   None
+ *
+ * @remark       None
+ * @see         None
+ */
+int bluetooth_media_control_unregister_player(void);
+
+/**
+ * @fn int bluetooth_media_control_player_property_changed(media_player_settings_t player_settings)
+ * @brief Notifies the remote bluetooth headset with change in music player settings
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   0  - Success \n
+ *          -1 - On Failure\n
+ *
+ * @exception   None
+ * @param[in]   player_settings - Music player application settings,
+ *
+ * @remark       None
+ * @see         None
+ */
+int bluetooth_media_control_player_property_changed(
+                       media_player_settings_t player_settings);
+
+
+/**
+ * @fn int bluetooth_media_control_player_track_changed(media_metadata_attributes_t metadata)
+ * @briefNotifies the remote bluetooth headset with change in media attributes of the track
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   0  - Success \n
+ *          -1 - On Failure\n
+ *
+ * @exception   None
+ * @param[in]    metadata -Meida attributes
+ *
+ * @remark       None
+ * @see         None
+ */
+int bluetooth_media_control_player_track_changed(
+                       media_metadata_attributes_t metadata);
+
+/**
+ * @fn int bluetooth_media_control_deinit(void)
+ * @brief deinitializes the Media interface to media service
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   0  - Success \n
+ *          -1 - On Failure\n
+ *
+ * @exception   None
+ * @param[in]  None.
+ *
+ * @remark       None
+ * @see         None
+ */
+int bluetooth_media_control_deinit(void);
+
+#ifdef __cplusplus
+}
+#endif /*__cplusplus*/
+
+#endif /*_BT_MP_CONTROL_H_*/
diff --git a/bluetooth-media-control/bluetooth-media-control.pc.in b/bluetooth-media-control/bluetooth-media-control.pc.in
new file mode 100644 (file)
index 0000000..5651f76
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: bluetooth-media-control
+Description: SAMSUNG Linux platform Bluetooth framework API
+Version: @VERSION@
+Requires: dlog dbus-glib-1 vconf
+Libs: -L${libdir}
+Cflags: -I${includedir} -I${includedir}/bluetooth-media-control
diff --git a/bluetooth-media-control/test/CMakeLists.txt b/bluetooth-media-control/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f0089d1
--- /dev/null
@@ -0,0 +1,34 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-media-control-test C)
+
+SET(SRCS bluetooth-media-control-test.c)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(package REQUIRED dlog dbus-glib-1 glib-2.0 gthread-2.0)
+
+FOREACH(flag ${package_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${package_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lbluetooth-media-control)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
diff --git a/bluetooth-media-control/test/bluetooth-media-control-test.c b/bluetooth-media-control/test/bluetooth-media-control-test.c
new file mode 100644 (file)
index 0000000..32e6fd8
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ *   bluetooth-media-control
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include "bluetooth-media-control-api.h"
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+media_player_settings_t player_settings = {0x00, 0x00, 0x00,0x00, 0x01, 1111 };
+media_metadata_attributes_t metadata = {"Test Track", "Chethan", "TNC", "Tumkur", 1, 1, 14400 };
+
+void static __choose_metadata_settings(void)
+{
+       int cmd;
+       media_metadata_attributes_t metadata = {0,};
+
+       while (1) {
+               printf("\nPlease choose metadata settings\n");
+               printf("\t0: return to main menu\n");
+               printf("\t1. Title\n");
+               printf("\t2. Artist\n");
+               printf("\t3. Album\n");
+               printf("\t4. Genre \n");
+               printf("\t5. NumberOfTracks \n");
+               printf("\t6.Track Number \n");
+               printf("\t7. Duration \n");
+               printf("\tEnter your choice [ ]\b\b");
+
+               scanf("%d", &cmd);
+
+               switch (cmd) {
+               case 0:
+                       return;
+               case 1: /* Title */
+                       metadata.title = calloc(1,256);
+                       printf("Enter the \"Track\" name\n");
+                       scanf("%s",(char*)metadata.title);
+
+                       break;
+               case 2: /*Artist */
+                       metadata.artist = calloc(1,256);
+                       printf(" Enter the \"Artist\" name\n");
+                       scanf("%s",(char*)metadata.artist);
+                       break;
+               case 3: /* Album */
+                       metadata.album = calloc(1,256);
+                       printf(" Enter the \"Album\" name\n");
+                       scanf("%s",(char*)metadata.album);
+                       break;
+               case 4: /* Genre */
+                       metadata.genre = calloc(1,256);
+                       printf(" Enter the \"Genre\" \n");
+                       scanf("%s",(char*)metadata.genre);
+                       break;
+               case 5: /* NumberOfTracks */
+                       printf(" Enter the \" Totol NumberOfTracks\" \n");
+                       scanf("%d",&metadata.total_tracks);
+                       break;
+               case 6: /*Track Number */
+                       printf(" Enter the \" Track Number\" \n");
+                       scanf("%d",&metadata.number);
+                       break;
+               case 7: /*Duration */
+                       printf(" Enter the \"Duration\" \n");
+                       scanf("%d",&metadata.duration);
+                       break;
+               default:
+                       break;
+               }
+               bluetooth_media_control_player_track_changed(metadata);
+
+               if(NULL !=  metadata.title) {
+                       free((void*)metadata.title);
+                       metadata.title = NULL;
+               }
+               if(NULL !=  metadata.artist) {
+                       free((void*)metadata.artist);
+                       metadata.artist= NULL;
+               }
+               if(NULL !=  metadata.album) {
+                       free((void*)metadata.album);
+                       metadata.album= NULL;
+               }
+               if(NULL !=  metadata.genre) {
+                       free((void*)metadata.genre);
+                       metadata.genre= NULL;
+               }
+       }
+}
+
+void static __choose_player_settings(void)
+{
+       int cmd;
+
+       while (1) {
+               printf("\nPlease choose player settings\n");
+               printf("\t0: return to main menu\n");
+               printf("\t1. Equilizer\n");
+               printf("\t2. Repeat\n");
+               printf("\t3. Shuffle\n");
+               printf("\t4. Scan \n");
+               printf("\t5. Status \n");
+               printf("\t6. Position \n");
+               printf("\tEnter your choice [ ]\b\b");
+
+               scanf("%d", &cmd);
+
+               switch (cmd) {
+               case 0:
+                       return;
+               case 1: /* Equilizer */
+                       printf("Possible Values - EQUALIZER_OFF = 0x00 and EQUALIZER_ON = 0x01,\n");
+                       scanf("%d",&player_settings.equilizer);
+                       break;
+               case 2: /*Repeat */
+                       printf(" Possible Values - REPEAT_MODE_OFF = 0x00, REPEAT_SINGLE_TRACK = 0x01 , \
+                                       REPEAT_ALL_TRACK = 0x02,        REPEAT_GROUP = 0x03\n");
+                       scanf("%d",&player_settings.repeat);
+                       break;
+               case 3: /* Shuffle */
+                       printf(" Possible Values - SHUFFLE_MODE_OFF = 0x00, SHUFFLE_ALL_TRACK = 0x01 , \
+                                       SHUFFLE_GROUP = 0x02\n");
+                       scanf("%d",&player_settings.shuffle);
+                       break;
+               case 4: /* Scan */
+                       printf(" Possible Values - SCAN_MODE_OFF = 0x00, SCAN_ALL_TRACK = 0x01 , \
+                                       SCAN_GROUP = 0x02\n");
+                       scanf("%s",&player_settings.scan);
+                       break;
+               case 5: /* Status */
+                       printf(" Possible Values - STATUS_PLAYING = 0x00, STATUS_STOPPED = 0x01 , \
+                                       STATUS_PAUSED = 0x02,STATUS_FORWARD_SEEK = 0x03 STATUS_REVERSE_SEEK = 0x04 \
+                                       STATUS_ERROR = 0x05\n");
+                       scanf("%d",&player_settings.status);
+                       break;
+               case 6: /* Position */
+                       printf("Enter the possible value: []");
+                       scanf("%d",&player_settings.position);
+                       break;
+               default:
+                       break;
+               }
+               bluetooth_media_control_player_property_changed(player_settings);
+       }
+}
+
+int main()
+{
+       GMainLoop *agent_loop;
+       int cmd;
+
+       g_type_init();
+       agent_loop = g_main_loop_new(NULL, FALSE);
+
+       printf("MP-AV test application started\n");
+       while (1) {
+               printf("\n\n\t0. Exit\n");
+               printf("\t1. bluetooth_media_control_init \n");
+               printf("\t2. bluetooth_media_control_register_palyer\n");
+               printf("\t3. bluetooth_media_control_player_property_changed\n");
+               printf("\t4. bluetooth_media_control_player_track_changed\n");
+               printf("\t5. bluetooth_media_control_unregister_palyer\n");
+               printf("\tEnter your choice [  ]\b\b");
+
+               scanf("%d", &cmd);
+
+               switch (cmd) {
+               case 0: /* exit the application */
+                       {
+                               exit(0);
+                               break;
+                       }
+               case 1:/*Initialization*/
+                       {
+                               bluetooth_media_control_init();
+                               break;
+                       }
+               case 2: /*Register new Player*/
+                       {
+                               bluetooth_media_control_register_player(player_settings, metadata);
+                               break;
+                       }
+               case 3:
+                       {
+                               __choose_player_settings();
+                               break;
+                       }
+               case 4:
+                       {
+                               __choose_metadata_settings();
+                               break;
+                       }
+               case 5: /*Unregister Player*/
+                       {
+                               bluetooth_media_control_unregister_player();
+                               break;
+                       }
+               }
+       }
+       printf("gmain loop enter\n");
+       g_main_loop_run(agent_loop);
+       printf("gmain loop leave\n");
+       return 0;
+}
diff --git a/bluetooth-pb-agent/CMakeLists.txt b/bluetooth-pb-agent/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b2b18e2
--- /dev/null
@@ -0,0 +1,83 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-pb-agent C)
+
+SET(SRCS bluetooth_pb_agent.c)
+SET(APP_VENDOR samsung)
+SET(APP_NAME bluetooth-pb-agent)
+SET(APP_DIR /usr/bin)
+SET(APP_LOCALEDIR /usr/share/locale)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+#pkg_check_modules(pkgs REQUIRED elementary utilX appcore-efl pmapi vconf aul syspopup-caller)
+#pkg_check_modules(pkgs REQUIRED vconf aul syspopup-caller contacts-service)
+pkg_check_modules(pkgs REQUIRED contacts-service vconf)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+#FIND_PROGRAM(MARSHALTOOL NAMES glib-genmarshal)
+#EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --header > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.h")
+#EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --body > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.c")
+
+FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
+EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bluetooth_pb ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_pb_agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_pb_agent_glue.h")
+
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DVENDOR=\"${APP_VENDOR}\"")
+ADD_DEFINITIONS("-DAPPNAME=\"${APP_NAME}\"")
+ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
+ADD_DEFINITIONS("-DAPP_LOCALEDIR=\"${APP_LOCALEDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+#ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
+
+#ADD_CUSTOM_TARGET(bluetooth-agent.edj
+#              COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}
+#              ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-agent.edc ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-agent.edj
+#              DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-agent.edc
+#)
+#ADD_DEPENDENCIES(${PROJECT_NAME} bluetooth-agent.edj)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-agent.edj DESTINATION share/edje)
+
+# install desktop file & icon
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+#CONFIGURE_FILE(${PROJECT_NAME}.desktop.in ${PROJECT_NAME}.desktop)
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop DESTINATION share/install-info/application/)
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/icon_bluetooth-agent.png DESTINATION share/icon)
+
+# install ini file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluez.pb_agent.service DESTINATION share/dbus-1/services)
+
+# install booting script
+#INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-pb-agent DESTINATION /etc/rc.d/init.d)
+
+# i18n
+#ADD_SUBDIRECTORY(po)
+
diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.c b/bluetooth-pb-agent/bluetooth_pb_agent.c
new file mode 100644 (file)
index 0000000..f27cddb
--- /dev/null
@@ -0,0 +1,961 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <time.h>
+#include <contacts-svc.h>
+
+#include "vconf.h"
+#include "vconf-keys.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "bluetooth_pb_agent.h"
+
+#define CALL_LOG_VCARD  "BEGIN:VCARD\r\n" \
+                                       "VERSION:2.1\r\n" \
+                                       "N:%s;%s\r\n" \
+                                       "TEL:%s\r\n" \
+                                       "X-IRMC-CALL-DATETIME;%s:%s\r\n" \
+                                       "END:VCARD\r\n"
+
+#define PBAP_OWNER_VCARD  "BEGIN:VCARD\r\n" \
+                                       "VERSION:2.1\r\n" \
+                                       "TEL:%s\r\n" \
+                                       "END:VCARD\r\n"
+
+#define PBAP_EMPTY_VCARD  "BEGIN:VCARD\r\n" \
+                                       "VERSION:2.1\r\n" \
+                                       "END:VCARD\r\n"
+
+#define VCARD_NO_NAME  "Noname"
+#define MAX_CONTACT_NAME_LEN  256
+#define MAX_CONTACT_NUM_LEN  20
+#define PBAP_OWNER_VCARD_MAX_LEN  255
+#define VCARD_MAX_LEN  3000
+
+#define DBUS_STRUCT_STRING_STRING_UINT (dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, \
+                                                       G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
+
+typedef struct {
+       GObject parent;
+} BluetoothPbAgent;
+
+typedef struct {
+       GObjectClass parent;
+} BluetoothPbAgentClass;
+
+GType bluetooth_pb_agent_get_type(void);
+
+#define BLUETOOTH_PB_TYPE_AGENT (bluetooth_pb_agent_get_type())
+
+#define BLUETOOTH_PB_AGENT(object) \
+       (G_TYPE_CHECK_INSTANCE_CAST((object), \
+       BLUETOOTH_PB_TYPE_AGENT , BluetoothPbAgent))
+#define BLUETOOTH_PB_AGENT_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_CAST((klass), \
+       BLUETOOTH_PB_TYPE_AGENT , BluetoothPbAgentClass))
+#define BLUETOOTH_PB_IS_AGENT(object) \
+       (G_TYPE_CHECK_INSTANCE_TYPE((object), \
+       BLUETOOTH_PB_TYPE_AGENT))
+#define BLUETOOTH_PB_IS_AGENT_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_TYPE((klass), \
+       BLUETOOTH_PB_TYPE_AGENT))
+#define BLUETOOTH_PB_AGENT_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS((obj), \
+       BLUETOOTH_PB_TYPE_AGENT , BluetoothPbAgentClass))
+
+G_DEFINE_TYPE(BluetoothPbAgent, bluetooth_pb_agent, G_TYPE_OBJECT)
+
+GMainLoop *mainloop = NULL;
+
+static gboolean bluetooth_pb_get_phonebook(BluetoothPbAgent *agent, gushort max_list,
+                                          gushort offset, DBusGMethodInvocation *context);
+static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, gushort max_list, gushort offset,
+                                      gchar *call_type, DBusGMethodInvocation *context);
+static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, gushort max_list,
+                                               gushort offset, DBusGMethodInvocation *context);
+
+static gboolean bluetooth_pb_get_phonebook_list(BluetoothPbAgent *agent,
+                                               DBusGMethodInvocation *context);
+static gboolean bluetooth_pb_get_calls_list(BluetoothPbAgent *agent, gchar *call_type,
+                                           DBusGMethodInvocation *context);
+
+static gboolean bluetooth_pb_get_phonebook_entry(BluetoothPbAgent *agent, gchar *id,
+                                                DBusGMethodInvocation *context);
+static gboolean bluetooth_pb_get_calls_entry(BluetoothPbAgent *agent, gchar *id,
+                                            DBusGMethodInvocation *context);
+
+static gboolean bluetooth_pb_add_contact(BluetoothPbAgent *agent, const char *filename,
+                                        GError **error);
+
+#include "bluetooth_pb_agent_glue.h"
+
+static void bluetooth_pb_agent_init(BluetoothPbAgent *obj)
+{
+       DBG("+\n");
+       g_assert(obj != NULL);
+}
+
+static void bluetooth_pb_agent_finalize(GObject *obj)
+{
+       DBG("+\n");
+
+       G_OBJECT_CLASS(bluetooth_pb_agent_parent_class)->finalize(obj);
+}
+
+static void bluetooth_pb_agent_class_init(BluetoothPbAgentClass *klass)
+{
+       GObjectClass *object_class = (GObjectClass *) klass;
+
+       g_assert(klass != NULL);
+
+       object_class->finalize = bluetooth_pb_agent_finalize;
+
+       dbus_g_object_type_install_info(BLUETOOTH_PB_TYPE_AGENT,
+                                       &dbus_glib_bluetooth_pb_object_info);
+}
+
+static gboolean bluetooth_pb_get_phonebook_size(BluetoothPbAgent *agent, gushort max_list,
+                                               gushort offset, DBusGMethodInvocation *context)
+{
+       unsigned int nr_contact = 0;
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+       contacts_svc_connect();
+
+       nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT);
+       DBG("Number of contacts is %d\n", nr_contact);
+
+       contacts_svc_disconnect();
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       dbus_g_method_return(context, nr_contact);
+
+       return TRUE;
+}
+
+static void __get_vcard_from_contact(int id, int *vcard_total_len, char **vcard)
+{
+       int ret;
+       int vcard_len;
+       char *vcard_stream;
+       CTSstruct *contact = NULL;
+
+       contacts_svc_get_contact(id, &contact);
+
+       ret = contacts_svc_get_vcard_from_contact(contact, &vcard_stream);
+       if (CTS_SUCCESS == ret) {
+               vcard_len = strlen(vcard_stream);
+               *vcard_total_len += vcard_len;
+               DBG("len:%d total:%d\n", vcard_len, *vcard_total_len);
+               *vcard = strdup(vcard_stream);
+               free(vcard_stream);
+       }
+
+       contacts_svc_struct_free(contact);
+}
+
+static gboolean bluetooth_pb_get_phonebook(BluetoothPbAgent *agent,
+                                       gushort max_list, gushort offset,
+                                       DBusGMethodInvocation *context)
+{
+       int i = 0;
+       int ret;
+       int nr_contact = 0;
+
+       CTSiter *iter = NULL;
+       CTSstruct *contact = NULL;
+
+       int vcard_len;
+       int vcard_total_len = 0;
+       char *vcard_stream;
+
+       static int *contact_id = NULL;
+       static int index = 0;
+       int last_part = 0;
+
+       char **vcard;
+
+       DBG("max_list:%d offset:%d\n", max_list, offset);
+
+       contacts_svc_connect();
+
+       nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT);
+       DBG("Number of contacts is %d\n", nr_contact);
+
+       vcard = g_new0(char *, nr_contact + 1);
+
+       /* first request */
+       if (!contact_id) {
+               contact_id = (int *)malloc(nr_contact * sizeof(int));
+               if (!contact_id) {
+                       DBG("malloc error\n");
+                       contacts_svc_disconnect();
+                       g_strfreev(vcard);
+
+                       return FALSE;
+               }
+
+                contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter);
+
+                while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+                       CTSvalue *row_info = NULL;
+                       int id;
+
+                       row_info = contacts_svc_iter_get_info(iter);
+                       id = contacts_svc_value_get_int(row_info,
+                                                       CTS_LIST_CONTACT_ID_INT);
+                       contact_id[i] = id;
+
+                       if (vcard_total_len < VCARD_MAX_LEN) {
+                               __get_vcard_from_contact(id, &vcard_total_len,
+                                                               &vcard[i]);
+                               DBG("vcard:%s\n", vcard[i]);
+                                index++;
+
+                               if (index >= max_list) {
+                                       DBG("Over max list%d\n", max_list);
+                                       break;
+                               }
+                       }
+
+                        contacts_svc_value_free(row_info);
+                       i++;
+               }
+               if( NULL != iter ) {
+                       contacts_svc_iter_remove(iter);
+               }
+        } else { /* subsequent request */
+                while (vcard_total_len < VCARD_MAX_LEN) {
+                       __get_vcard_from_contact(contact_id[index],
+                                               &vcard_total_len, &vcard[i]);
+                       DBG("vcard:%s\n", vcard[i]);
+
+                        index++;
+                       i++;
+
+                       if (index >= nr_contact || index >= max_list) {
+                               DBG("Complete\n");
+                               break;
+                       }
+                }
+        }
+       contacts_svc_disconnect();
+
+       if (index >= nr_contact || index >= max_list) {
+               free(contact_id);
+               contact_id = NULL;
+               index = 0;
+               last_part = 1;
+       }
+
+       dbus_g_method_return(context, last_part, vcard);
+
+       g_strfreev(vcard);
+
+        return TRUE;
+}
+
+static int __bluetooth_get_calllog_type(int call_type)
+{
+       int val = CTS_PLOG_TYPE_NONE;
+       switch (call_type) {
+       case CTS_PLOG_TYPE_VOICE_INCOMMING:
+       case CTS_PLOG_TYPE_VIDEO_INCOMMING:
+               val = CTS_PLOG_TYPE_VOICE_INCOMMING;
+               break;
+
+       case CTS_PLOG_TYPE_VOICE_OUTGOING:
+       case CTS_PLOG_TYPE_VIDEO_OUTGOING:
+               val = CTS_PLOG_TYPE_VOICE_OUTGOING;
+               break;
+
+       case CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN:
+       case CTS_PLOG_TYPE_VOICE_INCOMMING_SEEN:
+       case CTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN:
+       case CTS_PLOG_TYPE_VIDEO_INCOMMING_SEEN:
+               val = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN;
+               break;
+
+       default:
+               break;
+       }
+
+       return val;
+}
+static gboolean bluetooth_pb_get_calls(BluetoothPbAgent *agent, gushort max_list, gushort offset,
+                                      gchar *call_type, DBusGMethodInvocation *context)
+{
+       int call_log_type;
+       int i = 0;
+       char **vcard;
+       char vcard_buffer[256] = {0,};
+       CTSiter *iter = NULL;
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+       contacts_svc_connect();
+
+       if (strncmp(call_type, "incoming", 8) == 0)
+               call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING;
+       else if (strncmp(call_type, "outgoing", 8) == 0)
+               call_log_type = CTS_PLOG_TYPE_VOICE_OUTGOING;
+       else if (strncmp(call_type, "missed", 6) == 0)
+               call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN;
+       else
+               call_log_type = 0xFF;
+
+       vcard = g_new0(char *, max_list + 1);
+
+       contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter);
+
+       while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+               CTSvalue *plog = NULL;
+
+               plog = contacts_svc_iter_get_info(iter);
+               if (plog) {
+                       struct tm timeinfo;
+                       char log_time_stamp[32] = {0,};
+                       char calllog_type[10] = {0,};
+                       int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT);
+                       int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT);
+                       DBG("type: %d\n", type);
+                       int log_type = __bluetooth_get_calllog_type(type);
+
+                       const char *number = contacts_svc_value_get_str(plog,
+                                                                       CTS_LIST_PLOG_NUMBER_STR);
+                       const char *first_name = contacts_svc_value_get_str(plog,
+                                                                       CTS_LIST_PLOG_FIRST_NAME_STR);
+                       const char *last_name = contacts_svc_value_get_str(plog,
+                                                                       CTS_LIST_PLOG_LAST_NAME_STR);
+
+                       time_t time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT);
+
+                       if (!number) {
+                               contacts_svc_value_free(plog);
+                               continue;
+                       }
+                       if (!first_name)
+                               first_name = "";
+                       if (!last_name)
+                               last_name = "";
+
+                       localtime_r(&time, &timeinfo);
+
+                       strftime(log_time_stamp, sizeof(log_time_stamp),
+                                               "%Y%m%dT%H%M%S", &timeinfo);
+
+                       if (log_type == CTS_PLOG_TYPE_VOICE_INCOMMING)
+                               strncpy(calllog_type, "RECEIVED", strlen("RECEIVED"));
+                        else if (log_type == CTS_PLOG_TYPE_VOICE_OUTGOING)
+                               strncpy(calllog_type, "DIALED", strlen("DIALED"));
+                       else if (log_type == CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN)
+                               strncpy(calllog_type, "MISSED", strlen("MISSED"));
+                        else {
+                               DBG("no log type found \n");
+                       }
+
+                       if ((call_log_type == 0xFF || call_log_type == log_type) &&
+                                                               (log_type != CTS_PLOG_TYPE_NONE)) {
+
+                               snprintf(vcard_buffer, sizeof(vcard_buffer), CALL_LOG_VCARD,
+                                                        last_name, first_name, number, calllog_type, log_time_stamp);
+
+                               vcard[i] = strdup((char *)vcard_buffer);
+                               DBG("%s() %d [%d] %s\n", __FUNCTION__, __LINE__, i, vcard[i]);
+                               i++;
+                       }
+
+                       contacts_svc_value_free(plog);
+
+                       if (i >= max_list) {
+                               DBG("Over max list count %d\n", max_list);
+                               break;
+                       }
+               }
+       }
+
+       if( NULL != iter ) {
+               contacts_svc_iter_remove(iter);
+       }
+       contacts_svc_disconnect();
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       dbus_g_method_return(context, vcard);
+
+       g_strfreev(vcard);
+
+       return TRUE;
+}
+
+static gboolean bluetooth_pb_get_phonebook_list(BluetoothPbAgent *agent,
+                                               DBusGMethodInvocation *context)
+{
+       unsigned int nr_contact = 0;
+       guint ret = 0;
+       CTSiter *iter = NULL;
+       GPtrArray *array = g_ptr_array_new();
+       char *subscriber_number = NULL;
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       GValue owner_value = {0, };
+
+       /* owner's vcard 0.vcf */
+       g_value_init(&owner_value, DBUS_STRUCT_STRING_STRING_UINT);
+       g_value_take_boxed(&owner_value,
+               dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT));
+
+       subscriber_number = vconf_get_str(VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER);
+       if (NULL == subscriber_number) {
+               DBG("vconf_get_int failed for VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER \n");
+
+               dbus_g_type_struct_set(&owner_value, 0, " ", 1, " ", 2, 0, G_MAXUINT);
+       } else {
+               dbus_g_type_struct_set(&owner_value, 0, subscriber_number, 1,
+                                       subscriber_number, 2, 0, G_MAXUINT);
+       }
+
+       g_ptr_array_add(array, g_value_get_boxed(&owner_value));
+
+       if (subscriber_number)
+               free(subscriber_number);
+
+       contacts_svc_connect();
+
+       nr_contact = contacts_svc_count(CTS_GET_ALL_CONTACT);
+       DBG("Number of contacts is %d\n", nr_contact);
+
+       contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter);
+
+       while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+               int index_num;
+               char name[MAX_CONTACT_NAME_LEN + 2] = { 0 };
+               const char *first = NULL;
+               const char *last = NULL;
+               const char *default_num = NULL;
+
+               CTSvalue *row_info = NULL;
+               CTSvalue *number = NULL;
+               GValue value = {0, };
+
+               row_info = contacts_svc_iter_get_info(iter);
+
+               if (!row_info) {
+                       DBG("contacts_svc_iter_get_info failed \n");
+                       break;
+               }
+
+               first = contacts_svc_value_get_str(row_info, CTS_LIST_CONTACT_FIRST_STR);
+               last = contacts_svc_value_get_str(row_info, CTS_LIST_CONTACT_LAST_STR);
+
+               if (first && last) {
+                       g_strlcpy(name, last, sizeof(name) / 2);
+                       g_strlcat(name, ";", sizeof(name));
+                       g_strlcat(name, first, sizeof(name));
+               } else if (first) {
+                       g_strlcpy(name, first, sizeof(name));
+               } else if (last)  {
+                       g_strlcpy(name, last, sizeof(name));
+               } else {
+                       g_strlcpy(name, VCARD_NO_NAME, sizeof(name));
+               }
+
+               index_num = contacts_svc_value_get_int(row_info, CTS_LIST_CONTACT_ID_INT);
+
+               ret = contacts_svc_get_contact_value(CTS_GET_DEFAULT_NUMBER_VALUE, index_num,
+                                                       &number);
+
+               if (CTS_SUCCESS != ret) {
+                       DBG("contacts_svc_get_contact_value() Failed(%d)\n", ret);
+               } else {
+                       default_num = contacts_svc_value_get_str(number, CTS_NUM_VAL_NUMBER_STR);
+                       DBG("The default Number is %s\n", default_num);
+               }
+
+               g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT);
+               g_value_take_boxed(&value,
+                       dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT));
+               dbus_g_type_struct_set(&value, 0, name, 1, default_num, 2, index_num, G_MAXUINT);
+               g_ptr_array_add(array, g_value_get_boxed(&value));
+
+               if (number)
+                       contacts_svc_value_free(number);
+
+               if (row_info)
+                       contacts_svc_value_free(row_info);
+
+       }
+
+       if( NULL != iter ) {
+               contacts_svc_iter_remove(iter);
+       }
+
+       contacts_svc_disconnect();
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       dbus_g_method_return(context, array);
+
+       g_ptr_array_foreach(array, (GFunc)g_value_array_free, NULL);
+       g_ptr_array_free(array, TRUE);
+
+       return TRUE;
+}
+
+static gboolean bluetooth_pb_get_calls_list(BluetoothPbAgent *agent, gchar *call_type,
+                                           DBusGMethodInvocation *context)
+{
+       int call_log_type;
+       char name[256] = {0,};
+       GPtrArray *array = g_ptr_array_new();
+
+       CTSiter *iter = NULL;
+
+       DBG("%s() %d call_type:%s\n", __FUNCTION__, __LINE__, call_type);
+
+       if (strncmp(call_type, "incoming", 8) == 0)
+               call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING;
+       else if (strncmp(call_type, "outgoing", 8) == 0)
+               call_log_type = CTS_PLOG_TYPE_VOICE_OUTGOING;
+       else if (strncmp(call_type, "missed", 6) == 0)
+               call_log_type = CTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN;
+       else
+               call_log_type = 0xFF;
+
+       contacts_svc_connect();
+
+       contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter);
+
+       while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+               CTSvalue *plog = NULL;
+
+               plog = contacts_svc_iter_get_info(iter);
+               if (plog) {
+                       int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT);
+                       int num_type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_NUM_TYPE_INT);
+                       int time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT);
+                       int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT);
+
+                       int log_type = __bluetooth_get_calllog_type(type);
+                       int duration = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_DURATION_INT);
+                       const char *number = contacts_svc_value_get_str(plog,
+                                                                       CTS_LIST_PLOG_NUMBER_STR);
+                       const char *first_name = contacts_svc_value_get_str(plog,
+                                                               CTS_LIST_PLOG_FIRST_NAME_STR);
+                       const char *last_name = contacts_svc_value_get_str(plog,
+                                                               CTS_LIST_PLOG_LAST_NAME_STR);
+                       const char *display_name = contacts_svc_value_get_str(plog,
+                                                               CTS_LIST_PLOG_DISPLAY_NAME_STR);
+
+                       if (!number) {
+                               DBG("number is NULL\n");
+                               contacts_svc_value_free(plog);
+                               continue;
+                       }
+                       DBG("number: %s\n", number);
+
+                       if (first_name && last_name)
+                               snprintf(name, sizeof(name), "%s;%s;", last_name, first_name);
+                       else if (first_name)
+                               snprintf(name, sizeof(name), ";%s", first_name);
+                       else if (last_name)
+                               snprintf(name, sizeof(name), "%s;", last_name);
+                       else
+                               strncpy(name, number, sizeof(name) - 1);
+
+                       if ((call_log_type == 0xFF || call_log_type == log_type) &&
+                                       (log_type != CTS_PLOG_TYPE_NONE)) {
+
+                               GValue value = {0, };
+                               g_value_init(&value, DBUS_STRUCT_STRING_STRING_UINT);
+                               g_value_take_boxed(&value,
+                                       dbus_g_type_specialized_construct(DBUS_STRUCT_STRING_STRING_UINT));
+                               dbus_g_type_struct_set(&value, 0, name, 1, number, 2, (guint) index,
+                                                      G_MAXUINT);
+                               g_ptr_array_add(array, g_value_get_boxed(&value));
+                       }
+
+                       contacts_svc_value_free(plog);
+               }
+       }
+
+       if( NULL != iter ) {
+               contacts_svc_iter_remove(iter);
+       }
+
+       contacts_svc_disconnect();
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       dbus_g_method_return(context, array);
+
+       g_ptr_array_foreach(array, (GFunc)g_value_array_free, NULL);
+       g_ptr_array_free(array, TRUE);
+
+       return TRUE;
+}
+
+static gboolean bluetooth_pb_get_phonebook_entry(BluetoothPbAgent *agent, gchar *id,
+                                                DBusGMethodInvocation *context)
+{
+
+       int ret = -1;
+       int index;
+       CTSstruct *contact = NULL;
+       char *phonebook_entry = NULL;
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       if (sscanf(id, "%d.vcf", &index) != 1) {
+               DBG("Failed to get index\n");
+               return FALSE;
+       }
+
+       if (index != 0) {
+               contacts_svc_connect();
+
+               DBG("Get %dth phonebook entry\n", index);
+               ret = contacts_svc_get_contact(index, &contact);
+               if (CTS_SUCCESS == ret) {
+                       ret = contacts_svc_get_vcard_from_contact(contact, &phonebook_entry);
+                       if (CTS_SUCCESS == ret) {
+                               DBG("[%s]\n", phonebook_entry);
+
+                               dbus_g_method_return(context, phonebook_entry);
+                       }
+                       contacts_svc_struct_free(contact);
+               }
+               contacts_svc_disconnect();
+       }
+
+       if (index == 0 || ret != CTS_SUCCESS) {
+               DBG("Get owner vcard\n");
+               char *subscriber_number = NULL;
+
+               subscriber_number = vconf_get_str(VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER);
+               if (NULL == subscriber_number) {
+                       DBG("vconf_get_int failed for VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER \n");
+
+                       phonebook_entry = strdup(PBAP_EMPTY_VCARD);
+                       dbus_g_method_return(context, phonebook_entry);
+               } else {
+                       char vcard_buffer[PBAP_OWNER_VCARD_MAX_LEN + 1] = {0,};
+
+                       if (strlen(subscriber_number) > MAX_CONTACT_NUM_LEN) {
+                               char temp[MAX_CONTACT_NUM_LEN + 1] = {0,};
+                               strncpy(temp, subscriber_number, MAX_CONTACT_NUM_LEN);
+                               snprintf(vcard_buffer, sizeof(vcard_buffer), PBAP_OWNER_VCARD,
+                                               temp);
+                       } else {
+                               snprintf(vcard_buffer, sizeof(vcard_buffer), PBAP_OWNER_VCARD,
+                                                       subscriber_number);
+                               DBG(" Owner vcard \n %s  \n", vcard_buffer);
+                       }
+
+                       dbus_g_method_return(context, vcard_buffer);
+
+                       free(subscriber_number);
+               }
+       }
+
+       if (phonebook_entry)
+               free(phonebook_entry);
+
+       return TRUE;
+}
+
+static gboolean bluetooth_pb_get_calls_entry(BluetoothPbAgent *agent, gchar *id,
+                                            DBusGMethodInvocation *context)
+{
+       int calls_index;
+       char *calls_entry;
+       char vcard_buffer[256];
+       CTSiter *iter = NULL;
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+       contacts_svc_connect();
+
+       if (sscanf(id, "%d.vcf", &calls_index) != 1) {
+               DBG("Failed to get index\n");
+               return FALSE;
+       }
+
+       contacts_svc_get_list(CTS_LIST_GROUPING_PLOG, &iter);
+
+       while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+               CTSvalue *plog = NULL;
+
+               plog = contacts_svc_iter_get_info(iter);
+               if (plog) {
+                       int index = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT);
+                       int num_type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_NUM_TYPE_INT);
+                       int time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT);
+                       int type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT);
+                       int duration = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_DURATION_INT);
+                       const char *number = contacts_svc_value_get_str(plog,
+                                                                       CTS_LIST_PLOG_NUMBER_STR);
+                       const char *first_name = contacts_svc_value_get_str(plog,
+                                                               CTS_LIST_PLOG_FIRST_NAME_STR);
+                       const char *last_name = contacts_svc_value_get_str(plog,
+                                                               CTS_LIST_PLOG_LAST_NAME_STR);
+                       const char *display_name = contacts_svc_value_get_str(plog,
+                                                               CTS_LIST_PLOG_DISPLAY_NAME_STR);
+
+                       if (!number)
+                               number = "";
+                       if (!first_name)
+                               first_name = "";
+                       if (!last_name)
+                               last_name = "";
+                       if (display_name) {
+                               DBG("display_name: %s\n", display_name);
+                       }
+
+                       if (calls_index == index) {
+                               snprintf(vcard_buffer, sizeof(vcard_buffer), CALL_LOG_VCARD,
+                                        last_name, first_name, number);
+                               calls_entry = vcard_buffer;
+                       }
+
+                       contacts_svc_value_free(plog);
+               }
+       }
+
+       if( NULL != iter ) {
+               contacts_svc_iter_remove(iter);
+       }
+
+       contacts_svc_disconnect();
+
+       DBG("%s() %d\n", __FUNCTION__, __LINE__);
+
+       dbus_g_method_return(context, calls_entry);
+
+       return TRUE;
+}
+
+static int __bluetooth_pb_agent_read_file(const char *file_path, char **stream)
+{
+       FILE *fp = NULL;
+       int read_len = -1;
+       int received_file_size = 0;
+       struct stat file_attr;
+
+       if (file_path == NULL || stream == NULL) {
+               DBG("Invalid data \n");
+               return -1;
+       }
+
+       DBG("file_path = %s\n", file_path);
+
+       if ((fp = fopen(file_path, "r+")) == NULL) {
+               DBG("Cannot open %s\n", file_path);
+               return -1;
+       }
+
+       if (fstat(fileno(fp), &file_attr) == 0) {
+               received_file_size = file_attr.st_size;
+               DBG("file_attr.st_size = %d, size = %d\n", file_attr.st_size, received_file_size);
+
+               if (received_file_size <= 0) {
+                       DBG("Some problem in the file size [%s]  \n", file_path);
+                       fclose(fp);
+                       fp = NULL;
+                       return -1;
+               }
+
+               *stream = (char *)malloc(sizeof(char) * received_file_size);
+               if (NULL == *stream) {
+                       fclose(fp);
+                       fp = NULL;
+                       return -1;
+               }
+       } else {
+               DBG("Some problem in the file [%s]  \n", file_path);
+               fclose(fp);
+               fp = NULL;
+               return -1;
+       }
+
+       read_len = fread(*stream, 1, received_file_size, fp);
+
+       if (read_len == 0) {
+               if (fp != NULL) {
+                       fclose(fp);
+                       fp = NULL;
+               }
+               DBG("Cannot open %s\n", file_path);
+               return -1;
+       }
+
+       if (fp != NULL) {
+               fclose(fp);
+               fp = NULL;
+       }
+       return 0;
+}
+
+static gboolean bluetooth_pb_add_contact(BluetoothPbAgent *agent, const char *filename,
+                                        GError **error)
+{
+       CTSstruct *contact_record = NULL;
+       GSList *numbers_list = NULL, *cursor;
+       int is_success = 0;
+       int is_duplicated = 0;
+       int err = 0;
+       char *stream = NULL;
+
+       DBG("file_path = %s\n", filename);
+
+       err = contacts_svc_connect();
+       DBG("contact_db_service_connect fucntion call [error] = %d \n", error);
+
+       err = __bluetooth_pb_agent_read_file(filename, &stream);
+
+       if (err != 0) {
+               contacts_svc_disconnect();
+               DBG("contacts_svc_disconnect fucntion call [error] = %d \n", error);
+
+               if (NULL != stream) {
+                       free(stream);
+                       stream = NULL;
+               }
+               return FALSE;
+       }
+
+       is_success = contacts_svc_get_contact_from_vcard((const void *)stream, &contact_record);
+
+       DBG("contacts_svc_get_contact_from_vcard fucntion call [is_success] = %d \n", is_success);
+
+       if (0 == is_success) {
+               contacts_svc_struct_get_list(contact_record, CTS_CF_NUMBER_LIST, &numbers_list);
+               cursor = numbers_list;
+
+               for (; cursor; cursor = g_slist_next(cursor)) {
+                       if (contacts_svc_find_contact_by(CTS_FIND_BY_NUMBER,
+                                                       contacts_svc_value_get_str(cursor->data,
+                                                               CTS_NUM_VAL_NUMBER_STR)) > 0) {
+                               DBG("is_duplicated\n");
+                               is_duplicated = TRUE;
+                       }
+               }
+
+               if (is_duplicated == FALSE) {
+                       contacts_svc_insert_contact(0, contact_record);
+               }
+       } else {
+               DBG("Fail \n");
+       }
+
+       error = contacts_svc_disconnect();
+       DBG("contacts_svc_disconnect fucntion call [error] = %d \n", error);
+
+       if (NULL != stream) {
+               free(stream);
+               stream = NULL;
+       }
+
+       return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+       BluetoothPbAgent *bluetooth_pb_obj = NULL;
+       DBusGConnection *bus = NULL;
+       DBusGProxy *bus_proxy = NULL;
+       guint result = 0;
+       GError *error = NULL;
+
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+       if (mainloop == NULL) {
+               DBG("Couldn't create GMainLoop\n");
+               return EXIT_FAILURE;
+       }
+
+       bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+       if (error != NULL) {
+               DBG("Couldn't connect to system bus[%s]\n", error->message);
+               g_error_free(error);
+               return EXIT_FAILURE;
+       }
+
+       bus_proxy = dbus_g_proxy_new_for_name(bus, DBUS_SERVICE_DBUS,
+                                       DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+       if (bus_proxy == NULL) {
+               DBG("Failed to get a proxy for D-Bus\n");
+               goto failure;
+       }
+
+       if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING,
+                       BT_PB_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
+                       G_TYPE_UINT, &result, G_TYPE_INVALID)) {
+               if (error != NULL) {
+                       DBG("RequestName RPC failed[%s]\n", error->message);
+                       g_error_free(error);
+               }
+               goto failure;
+       }
+       DBG("result : %d %d\n", result, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+               DBG("Failed to get the primary well-known name.\n");
+               goto failure;
+       }
+
+       g_object_unref(bus_proxy);
+       bus_proxy = NULL;
+
+       bluetooth_pb_obj = g_object_new(BLUETOOTH_PB_TYPE_AGENT, NULL);
+       if (bluetooth_pb_obj == NULL) {
+               DBG("Failed to create one BluetoothPbAgent instance.\n");
+               goto failure;
+       }
+
+       /* Registering it on the D-Bus */
+       dbus_g_connection_register_g_object(bus, BT_PB_SERVICE_OBJECT_PATH,
+                                               G_OBJECT(bluetooth_pb_obj));
+
+       g_main_loop_run(mainloop);
+
+ failure:
+       DBG("Terminate the bluetooth-pb-agent\n");
+       if (bus)
+               dbus_g_connection_unref(bus);
+       if (bus_proxy)
+               g_object_unref(bus_proxy);
+       if (bluetooth_pb_obj)
+               g_object_unref(bluetooth_pb_obj);
+
+       return EXIT_FAILURE;
+}
diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.h b/bluetooth-pb-agent/bluetooth_pb_agent.h
new file mode 100644 (file)
index 0000000..ad1edb7
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __DEF_BT_PB_AGENT_H_
+#define __DEF_BT_PB_AGENT_H_
+
+#include <unistd.h>
+#include <dlog.h>
+
+#include <stdio.h>
+
+#include <dbus/dbus-glib.h>
+
+#define BT_PB_SERVICE_OBJECT_PATH      "/org/bluez/pb_agent"
+#define BT_PB_SERVICE_NAME             "org.bluez.pb_agent"
+#define BT_PB_SERVICE_INTERFACE                "org.bluez.PbAgent"
+
+#define BT_PB_AGENT    "BT_PB_AGENT"
+#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_PB_AGENT, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define ERR(fmt, args...) SLOG(LOG_ERROR, BT_PB_AGENT, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+#endif                         /* __DEF_BT_AGENT_H_ */
diff --git a/bluetooth-pb-agent/bluetooth_pb_agent.xml b/bluetooth-pb-agent/bluetooth_pb_agent.xml
new file mode 100644 (file)
index 0000000..31a0100
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/">
+       <interface name="org.bluez.PbAgent">
+
+               <method name="GetPhonebook">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="q" name="max_list"/>
+                       <arg type="q" name="offset"/>
+                       <arg type="i" name="last_part" direction="out"/>
+                       <arg type="as" name="phonebook" direction="out"/>
+               </method>
+
+               <method name="GetCalls">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="q" name="max_list"/>
+                       <arg type="q" name="offset"/>
+                       <arg type="s" name="call_type"/>
+                       <arg type="as" name="phonebook" direction="out"/>
+               </method>
+
+               <method name="GetPhonebookSize">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="q" name="max_list"/>
+                       <arg type="q" name="offset"/>
+                       <arg type="u" name="phonebook_size" direction="out"/>
+               </method>
+
+               <method name="GetPhonebookList">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="a(ssu)" name="phonebook_list" direction="out"/>
+               </method>
+
+               <method name="GetCallsList">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="s" name="call_type"/>
+                       <arg type="a(ssu)" name="calls_list" direction="out"/>
+               </method>
+
+               <method name="GetPhonebookEntry">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="s" name="id"/>
+                       <arg type="s" name="phonebook_entry" direction="out"/>
+               </method>
+
+               <method name="GetCallsEntry">
+                       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+                       <arg type="s" name="id"/>
+                       <arg type="s" name="phonebook_entry" direction="out"/>
+               </method>
+
+               <method name="AddContact">
+                       <arg type="s" name="filename"/>
+               </method>
+
+       </interface>
+</node>
diff --git a/bluetooth-pb-agent/org.bluez.pb_agent.service b/bluetooth-pb-agent/org.bluez.pb_agent.service
new file mode 100644 (file)
index 0000000..e890341
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.bluez.pb_agent
+Exec=/usr/bin/bluetooth-pb-agent
diff --git a/debian/bluetooth-frwk-0.postinst b/debian/bluetooth-frwk-0.postinst
new file mode 100644 (file)
index 0000000..99dd1be
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# root case
+if [ ${USER} == "root" ]
+then
+       # Set vconf values with -g/-u options
+       # 0 is root user id
+       vconftool set -t bool memory/bluetooth/allow "0" -u 0
+fi
+
diff --git a/debian/bluetooth-frwk-agent.install.in b/debian/bluetooth-frwk-agent.install.in
new file mode 100644 (file)
index 0000000..4e1c692
--- /dev/null
@@ -0,0 +1,9 @@
+@PREFIX@/bin/bluetooth-agent
+@PREFIX@/share/process-info/bluetooth-agent.ini
+@PREFIX@/share/dbus-1/services/org.bluez.frwk_agent.service
+/etc/*
+@PREFIX@/bin/bluetooth-pb-agent
+@PREFIX@/share/dbus-1/services/org.bluez.pb_agent.service
+
+@PREFIX@/bin/bluetooth-map-agent
+@PREFIX@/share/dbus-1/services/org.bluez.map_agent.service
diff --git a/debian/bluetooth-frwk-test.install.in b/debian/bluetooth-frwk-test.install.in
new file mode 100644 (file)
index 0000000..0473f37
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/bluetooth-frwk-test
diff --git a/debian/bluetooth-map-agent.install.in b/debian/bluetooth-map-agent.install.in
new file mode 100644 (file)
index 0000000..163ceb6
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/bin/bluetooth-map-agent
+@PREFIX@/share/dbus-1/services/org.bluez.map_agent.service
diff --git a/debian/bluetooth-pb-agent.install.in b/debian/bluetooth-pb-agent.install.in
new file mode 100644 (file)
index 0000000..aecabfd
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/bin/bluetooth-pb-agent
+@PREFIX@/share/dbus-1/services/org.bluez.pb_agent.service
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..3763ee7
--- /dev/null
@@ -0,0 +1,19 @@
+bluetooth-frwk (0.1.41-1) unstable; urgency=low
+
+  * change "com.samsung" -> "org.tizen"
+  * Git: pkgs/b/bluetooth-frwk
+  * Tag: bluetooth-frwk_0.1.41-1
+
+ -- DoHyun Pyun <dh79.pyun@samsung.com>  Thu, 22 Dec 2011 17:57:59 +0900
+
+bluetooth-frwk (0.1.41) unstable; urgency=low
+
+  * Update Version for build
+
+ -- Chanyeol Park <chanyeol.park@samsung.com>  Thu, 15 Dec 2011 12:56:57 +0900
+
+bluetooth-frwk (0.1.0) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Chanyeol Park <chanyeol.park@samsung.com>  Wed, 07 Dec 2011 13:00:03 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..42b6c7a
--- /dev/null
@@ -0,0 +1,52 @@
+Source: bluetooth-frwk
+Section: devel
+Priority: optional
+Maintainer: DoHyun Pyun <dh79.pyun@samsung.com>, Hocheol Seo <hocheol.seo@samsung.com>, ChanYeol Park <chanyeol.park@samsung.com>
+Uploaders: Girishashok Joshi <girish.joshi@samsung.com>, Sunil Behera <sunil.behera@samsung.com>, Syam Sidhardhan <s.syam@samsung.com>
+Build-Depends: debhelper (>= 5), libslp-setting-dev, dlog-dev,libxml2-dev, libaul-1-dev, syspopup-caller-dev, libcontacts-service-dev, libdbus-glib-1-dev, libglib2.0-dev, email-service-dev, libslp-msg-service-dev
+Standards-Version: 3.7.2
+Homepage: N/A
+
+Package: libbluetooth-frwk-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-frwk-agent (= ${Source-Version}), dbus, bluez
+Description: Bluetooth framework for BlueZ
+ This package is Bluetooth framework based on BlueZ stack.
+ This package contains API set for BT GAP, BT SDP, and BT RFCOMM.
+
+Package: libbluetooth-frwk-dev
+Section: devel
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libbluetooth-frwk-0 (= ${Source-Version}), libslp-setting-dev, dlog-dev, libxml2-dev, libdbus-glib-1-dev, libglib2.0-dev
+XB-Generate-Docs: yes
+Description: Bluetooth framework for BlueZ
+ This package is development files for Bluetooth framework based on BlueZ stack.
+ This package contains API set for BT GAP, BT SDP, and BT RFCOMM.
+
+Package: bluetooth-frwk-test
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libbluetooth-frwk-0 (= ${Source-Version})
+Description: Bluetooth framework test application
+ This package is a test application for bluetooth framework.
+
+Package: bluetooth-frwk-agent
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libappcore-efl-0, libslp-utilx-0, libaul-1
+Description: Bluetooth Agent for pairing and authorization
+ This package is Bluetooth useraction Agent to response pairing, authorization, and mode change with BlueZ.
+
+#Package: bluetooth-pb-agent
+#Architecture: any
+#Depends: ${shlibs:Depends}, ${misc:Depends}, libcontacts-service
+#Description: Bluetooth Phonebook Agent for PBAP,SYNC.
+# This package is Bluetooth Phonebook Agent to respond contact related request.
+
+Package: bluetooth-frwk-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libbluetooth-frwk-0 (= ${Source-Version})
+Description: Bluetooth framework (unstripped)
+ The package contains detached debugging symbols for the binary packages
+ produced by the bluetooth-frwk soruce.
+
diff --git a/debian/libbluetooth-frwk-0.install.in b/debian/libbluetooth-frwk-0.install.in
new file mode 100644 (file)
index 0000000..fef5120
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/lib*
diff --git a/debian/libbluetooth-frwk-dev.install.in b/debian/libbluetooth-frwk-dev.install.in
new file mode 100644 (file)
index 0000000..ceab20e
--- /dev/null
@@ -0,0 +1,2 @@
+/usr/include/*
+/usr/lib/pkgconfig/*
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..9ddb186
--- /dev/null
@@ -0,0 +1,147 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+LDFLAGS ?= 
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+       CFLAGS="$(CFLAGS) -fpie" LDFLAGS="$(LDFLAGS) -pie" \
+              cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) clean
+
+       for f in `find $(CURDIR)/ -name "CMakeCache.txt"`; do \
+               rm -f $${f}; \
+       done
+       for f in `find $(CURDIR)/ -name "CMakeFiles"`; do \
+               rm -rf $${f}; \
+       done
+       for f in `find $(CURDIR)/ -name "cmake_install.cmake"`; do \
+               rm -f $${f}; \
+       done
+#      for f in `find $(CURDIR)/ -name "Makefile"`; do \
+               rm -f $${f}; \
+       done
+       for f in `find $(CURDIR)/ -name "install_manifest.txt"`; do \
+               rm -f $${f}; \
+       done
+       for f in `find $(CURDIR)/ -name "*.edj"`; do \
+               rm -f $${f}; \
+       done
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       rm -f Makefile
+       rm -f lib/Makefile
+       rm -f bluetooth-frwk-agent/Makefile
+       rm -f bluetooth-pb-agent/Makefile
+       rm -f bluetooth-map-agent/Makefile
+       rm -f bluetooth-frwk-agent/po/Makefile
+       rm -f lib/test/Makefile
+       
+       rm -f lib/*.pc
+       rm -f lib/marshal.c
+       rm -f lib/marshal.h
+       rm -f lib/obex-agent-glue.h
+
+       rm -f bluetooth-frwk-agent/marshal.c
+       rm -f bluetooth-frwk-agent/marshal.h
+       rm -f bluetooth-frwk-agent/sc_core_agent_glue.h
+       rm -f bluetooth-frwk-agent/bluetooth_obex_agent_glue.h
+       rm -f bluetooth-pb-agent/bluetooth_pb_agent_glue.h
+       rm -f bluetooth-map-agent/bluetooth_map_agent_glue.h
+       
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+       # Booting script
+       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/
+       ln -s ../init.d/bluetooth-frwk-agent $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S80bluetooth-frwk-agent
+       ln -s ../init.d/bluetooth-frwk-agent $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S80bluetooth-frwk-agent
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=bluetooth-frwk-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/image/bluetooth_image001.png b/image/bluetooth_image001.png
new file mode 100644 (file)
index 0000000..f505094
Binary files /dev/null and b/image/bluetooth_image001.png differ
diff --git a/image/bluetooth_image002.png b/image/bluetooth_image002.png
new file mode 100644 (file)
index 0000000..3942352
Binary files /dev/null and b/image/bluetooth_image002.png differ
diff --git a/image/bluetooth_image003.png b/image/bluetooth_image003.png
new file mode 100644 (file)
index 0000000..775c846
Binary files /dev/null and b/image/bluetooth_image003.png differ
diff --git a/image/bluetooth_image004.png b/image/bluetooth_image004.png
new file mode 100644 (file)
index 0000000..80eae3f
Binary files /dev/null and b/image/bluetooth_image004.png differ
diff --git a/image/bluetooth_image005.png b/image/bluetooth_image005.png
new file mode 100644 (file)
index 0000000..beac065
Binary files /dev/null and b/image/bluetooth_image005.png differ
diff --git a/image/bluetooth_image006.png b/image/bluetooth_image006.png
new file mode 100644 (file)
index 0000000..533c847
Binary files /dev/null and b/image/bluetooth_image006.png differ
diff --git a/image/bluetooth_image007.png b/image/bluetooth_image007.png
new file mode 100644 (file)
index 0000000..71ee706
Binary files /dev/null and b/image/bluetooth_image007.png differ
diff --git a/image/bluetooth_image008.png b/image/bluetooth_image008.png
new file mode 100644 (file)
index 0000000..69c9457
Binary files /dev/null and b/image/bluetooth_image008.png differ
diff --git a/image/bluetooth_image009.png b/image/bluetooth_image009.png
new file mode 100644 (file)
index 0000000..3e9718c
Binary files /dev/null and b/image/bluetooth_image009.png differ
diff --git a/image/bluetooth_image010.png b/image/bluetooth_image010.png
new file mode 100644 (file)
index 0000000..7dcd5fe
Binary files /dev/null and b/image/bluetooth_image010.png differ
diff --git a/image/bluetooth_image011.png b/image/bluetooth_image011.png
new file mode 100644 (file)
index 0000000..eb899eb
Binary files /dev/null and b/image/bluetooth_image011.png differ
diff --git a/image/bluetooth_image012.png b/image/bluetooth_image012.png
new file mode 100644 (file)
index 0000000..b6ed48e
Binary files /dev/null and b/image/bluetooth_image012.png differ
diff --git a/image/bluetooth_image013.png b/image/bluetooth_image013.png
new file mode 100644 (file)
index 0000000..c92e3db
Binary files /dev/null and b/image/bluetooth_image013.png differ
diff --git a/image/bluetooth_image014.png b/image/bluetooth_image014.png
new file mode 100644 (file)
index 0000000..607fd3f
Binary files /dev/null and b/image/bluetooth_image014.png differ
diff --git a/image/bluetooth_image015.png b/image/bluetooth_image015.png
new file mode 100644 (file)
index 0000000..0a0ee7f
Binary files /dev/null and b/image/bluetooth_image015.png differ
diff --git a/image/bluetooth_image016.png b/image/bluetooth_image016.png
new file mode 100644 (file)
index 0000000..7145848
Binary files /dev/null and b/image/bluetooth_image016.png differ
diff --git a/image/bluetooth_image017.png b/image/bluetooth_image017.png
new file mode 100644 (file)
index 0000000..e40366c
Binary files /dev/null and b/image/bluetooth_image017.png differ
diff --git a/image/bluetooth_image018.png b/image/bluetooth_image018.png
new file mode 100644 (file)
index 0000000..5a830fb
Binary files /dev/null and b/image/bluetooth_image018.png differ
diff --git a/image/bluetooth_image019.png b/image/bluetooth_image019.png
new file mode 100644 (file)
index 0000000..adf6724
Binary files /dev/null and b/image/bluetooth_image019.png differ
diff --git a/image/bluetooth_image020.png b/image/bluetooth_image020.png
new file mode 100644 (file)
index 0000000..ab51d3f
Binary files /dev/null and b/image/bluetooth_image020.png differ
diff --git a/image/bluetooth_image021.png b/image/bluetooth_image021.png
new file mode 100644 (file)
index 0000000..59e43fb
Binary files /dev/null and b/image/bluetooth_image021.png differ
diff --git a/image/bluetooth_image022.png b/image/bluetooth_image022.png
new file mode 100644 (file)
index 0000000..589f14b
Binary files /dev/null and b/image/bluetooth_image022.png differ
diff --git a/image/bluetooth_image023.png b/image/bluetooth_image023.png
new file mode 100644 (file)
index 0000000..09575e9
Binary files /dev/null and b/image/bluetooth_image023.png differ
diff --git a/image/bluetooth_image024.png b/image/bluetooth_image024.png
new file mode 100644 (file)
index 0000000..6bf00f7
Binary files /dev/null and b/image/bluetooth_image024.png differ
diff --git a/image/bluetooth_image025.png b/image/bluetooth_image025.png
new file mode 100644 (file)
index 0000000..4125492
Binary files /dev/null and b/image/bluetooth_image025.png differ
diff --git a/image/bluetooth_image026.png b/image/bluetooth_image026.png
new file mode 100644 (file)
index 0000000..0cb781c
Binary files /dev/null and b/image/bluetooth_image026.png differ
diff --git a/image/bluetooth_image027.png b/image/bluetooth_image027.png
new file mode 100644 (file)
index 0000000..317591c
Binary files /dev/null and b/image/bluetooth_image027.png differ
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3d1230e
--- /dev/null
@@ -0,0 +1,59 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-api C)
+
+SET(SRCS bluetooth-api-common.c marshal.c bluetooth-gap-api.c bluetooth-sdp-api.c bluetooth-rfcomm-api.c bluetooth-network-api.c bluetooth-hdp-api.c obex-agent.c bluetooth-opc-api.c bluetooth-obex-server-api.c)
+SET(HEADERS bluetooth-api.h SLP_BluetoothFW_PG.h)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION_MAJOR 1)
+SET(VERSION ${VERSION_MAJOR}.0.0)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(packages REQUIRED dlog dbus-glib-1 gobject-2.0 gmodule-2.0 vconf libxml-2.0)
+
+FOREACH(flag ${packages_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g ")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+FIND_PROGRAM(MARSHALTOOL NAMES glib-genmarshal)
+EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --header > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.h")
+EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --body > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.c")
+
+FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
+EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=obex_agent ${CMAKE_CURRENT_SOURCE_DIR}/obex-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/obex-agent-glue.h")
+
+#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${packages_LDFLAGS})
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+
+FOREACH(hfile ${HEADERS})
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-api)
+ENDFOREACH(hfile)
+
+ADD_SUBDIRECTORY(test)
+
diff --git a/lib/SLP_BluetoothFW_PG.h b/lib/SLP_BluetoothFW_PG.h
new file mode 100644 (file)
index 0000000..a0dbba8
--- /dev/null
@@ -0,0 +1,2323 @@
+/*\r
+ * Bluetooth-frwk\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>\r
+ *              Girishashok Joshi <girish.joshi@samsung.com>\r
+ *              Chanyeol Park <chanyeol.park@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *             http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+/**\r
+ *\r
+ * @ingroup   SLP_PG\r
+ * @defgroup   BLUETOOTH BluetoothFW\r
+@{\r
+<h1 class="pg">Introduction</h1>\r
+       <h2 class="pg">Purpose of this document</h2>\r
+The purpose of this document is to describe how applications can use Bluetooth APIs for handling or working with Bluetooth. This document gives programming guidelines to application engineers.\r
+\r
+       <h2 class="pg">Scope</h2>\r
+The scope of this document is limited to Bluetooth API usage\r
+\r
+       <h2 class="pg">Abbreviations</h2>\r
+<table>\r
+       <tr>            <td>API</td>            <td>Application Programming Interface</td></tr>\r
+       <tr>            <td>SDK</td>            <td>Software Development Kit</td></tr>\r
+       <tr>            <td>RFCOMM</td>         <td>Radio Frequency Communication</td></tr>\r
+       <tr>            <td>L2CAP</td>          <td>Logical Link Control and adaptation Protocol</td></tr>\r
+       <tr>            <td>LM</td>             <td>Link Manager</td></tr>\r
+</table>\r
+\r
+<h1>Bluetooth Framework Architecture</h1>\r
+       <h2 class="pg">Architecture overview</h2>\r
+@image html bluetooth_image001.png\r
+\r
+<h1>Bluetooth Framework Features</h1>\r
+The Bluetooth API exposes a high level interface that is used by applications.\r
+\r
+Bluetooth API currently provides 3 kinds of APIs.\r
+@n GAP APIs: These APIs are used to perform operations related to the local device such as set device name, set visibility mode etc. It also exposes APIs to perform basic Bluetooth related operations like device search\r
+@n SDP APIs: These APIs are used to search service list supported by a specific device. A record in the service list gives a description of a service supported by the device. Specific records having a service ID assigned by Bluetooth SIG give a exact information of predefined service roles.\r
+@n RFCOMM APIs: In order to establish a serial connection between two Bluetooth devices, this SDK provides simple RFCOMM APIs. After receiving FD from SDK, developer can use regular system functions like read() write() poll() select() etc to send or receive data.\r
+\r
+Bluetooth can be shared among several applications, and the Bluetooth framework will supervise some of the important functionalities like pairing, configuration, and authorization. These functions will be confirmed by the user with use of a Bluetooth agent daemon.\r
+\r
+<h1>Using Bluetooth API</h1>\r
+You can use Bluetooth API to communication with other Bluetooth enabled device (mobile phone, PC etc) over RFCOMM interface. This SDK provides supporting Device management functions to find the device you want to connect with. You can refer to the following use cases as examples for writing your own Bluetooth based application.\r
+\r
+       <h2 class="pg">Listening for events</h2>\r
+In general, Bluetooth API provided to you is asynchronous in nature. Hence it becomes mandatory for Application to listen for the events which may be sent by Bluetooth API as per the data received. An application developer can call bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr type. This registered function will receive events of bluetooth_event_type_t type along with any any data.\r
+\r
+       <h2 class="pg">Managing Adapter</h2>\r
+Bluetooth Adaptor represents the Bluetooth Chip present in your device. The bluetooth_enable_adapter() API can be used to activate Bluetooth. This API sends a request to Bluetooth chip for activation. This will also initialize Bluetooth adaptor. Upon completion of the procedure, it will send BLUETOOTH_EVENT_ENABLED event. Bluetooth adapter should be disabled to switch off Bluetooth chip (and thereby saving power). bluetooth_disable_adapter() function will do that job for you. After switching off Bluetooth, BLUETOOTH_EVENT_DISABLED will be sent by SDK to application for confirmation.\r
+\r
+       <h2 class="pg">Getting local device information</h2>\r
+Every Bluetooth device has a unique 48 bit address assigned to it. You can read your Bluetooth device's address by using bluetooth_get_local_address() API. It is a synchronous function call. In its output parameter, you can receive bluetooth_device_address_t type of pointer which will contain Bluetooth address. Since its inconvenient for user to remember the address, Bluetooth provides a method to have a friendly name for each device. You can get or set the device name by bluetooth_get_local_name() and bluetooth_set_local_name() respectively. If you set the name, BLUETOOTH_EVENT_LOCAL_NAME_CHANGED event will be sent to application to inform result of requested operation. As per Bluetooth standard, maximum length of device name can be BLUETOOTH_DEVICE_NAME_MAX_LENGTH or 248 bytes. It should be in UTF-8 format.\r
+\r
+In order to be discoverable to other devices, your Bluetooth device should respond to inquiry scan requests. You can retrieve the mode of your device by calling bluetooth_get_discoverable_mode() API. It is a synchronous API which will give you current mode in bluetooth_discoverable_mode_t format. You can choose from the four different modes: connectable only (non discoverable), general discoverable, time limited discoverable (discoverable for limited time duration) and limited discoverable.\r
+\r
+       <h2 class="pg">Searching for peer Bluetooth device</h2>\r
+You can search for peer Bluetooth devices using the bluetooth_start_discovery() API. It is an asynchronous function call. You can receive the BLUETOOTH_EVENT_DISCOVERY_STARTED event when any discovery session is successfully started from the target, even if your application does not request discovery. After the opened discovery session is closed, you will get the BLUETOOTH_EVENT_DISCOVERY_FINISHED event. During the discovery session, you can get several BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND events and BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED events. The former event gives information of a device without its name and the latter event includes a friendly name for the device, and is delivered after the former event. The latter event can be delivered more than once for a device.\r
+@n Since only one discovery session is permitted at a time, a discovery request will return failure if there is a session already open.\r
+\r
+       <h2 class="pg">Serial communication in wireless way</h2>\r
+There are two roles in serial communication. One is server role which is waiting a connection from another device. The other role is client role which initiates a connection. For serial communication between your application in two targets.\r
+@n At first you should open server in one device. It can be done with bluetooth_rfcomm_create_socket() API and bluetooth_rfcomm_listen_and_accept() API. You can get a server socket file descriptor with the first API and can start waiting with the second API.\r
+@n At next, client device can connect with a waiting server with bluetooth_rfcomm_remote_connect() API. When a client is successfully connected with a server, you will receive the device node path for serial connection. With opening this path you can communicate with server device by reading and writing it.\r
+@n You should match UUID string with a server. You can use a UUID predefined by Bluetooth SIG if you want to use a specific Bluetooth profile role. Otherwise you should use your own UUID with 128bits hexa value formatted as like "#######-####-####-####-############" Format of Bluetooth SIG predefined UUID is "000####-0000-1000-8000-00805F9B34FB"\r
+\r
+       <h2 class="pg">Tips & Tricks</h2>\r
+You can connect with PC having Bluetooth adapter with Serial Port emulation Profile. For this, you should use SPP UUID string, "0001101-0000-1000-8000-00805F9B34FB" If the serial connection is established, you can use a serial port in PC side for communicating with your application in a device.\r
+\r
+<h1>API descriptions</h1>\r
+       <h2 class="pg">Defines</h2>\r
+               <h3 class="pg">General</h3>\r
+<table>\r
+       <tr>            <td>Macro Name</td>\r
+               <td>Value</td>\r
+               <td>Description</td></tr>\r
+       <tr>            <td>BLUETOOTH_ADDRESS_LENGTH</td>\r
+               <td>6</td>\r
+               <td>Bluetooth address is represented as 48 bits. This is defined in Bluetooth Core Specification document. This macro represents Bluetooth address length in bytes</td></tr>\r
+       <tr>            <td>BLUETOOTH_DEVICE_NAME_LENGTH_MAX</td>\r
+               <td>248</td>\r
+               <td>The Bluetooth device name can be up to 248 bytes maximum according to "Link Manager Protocol". It shall be encoded according to UTF-8</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">Error codes</h3>\r
+<table>\r
+       <tr>            <td>Macro Name</td>\r
+               <td>Value</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_BASE</td>\r
+               <td>0</td>\r
+               <td>Error code base</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NONE</td>\r
+               <td>BLUETOOTH_ERROR_BASE</td>\r
+               <td>No error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_CANCEL</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x01</td>\r
+               <td>Cancelled</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_INVALID_CALLBACK</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x02</td>\r
+               <td>Callback error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_INVALID_PARAM</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x03</td>\r
+               <td>invalid parameter</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_INVALID_DATA</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x04</td>\r
+               <td>invalid data error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_MEMORY_ALLOCATION</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x05</td>\r
+               <td>Memory allocation error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_OUT_OF_MEMORY</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x06</td>\r
+               <td>out of memory error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_TIMEOUT</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x07</td>\r
+               <td>timeout error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NO_RESOURCES</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x08</td>\r
+               <td>No resource error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_INTERNAL</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x09</td>\r
+               <td>internal error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NOT_SUPPORT</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x0A</td>\r
+               <td>Not supported error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_DEVICE_NOT_ENABLED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x0B</td>\r
+               <td>Operation is failed because of not enabled BT Adapter</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x0C</td>\r
+               <td>Enabling is failed because of already enabled BT Adapter</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_DEVICE_BUSY</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x0D</td>\r
+               <td>Operation is failed because of other on going operation</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_ACCESS_DENIED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x0E</td>\r
+               <td>access denied error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_MAX_CLIENT</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x0F</td>\r
+               <td>max client error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NOT_FOUND</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x10</td>\r
+               <td>not found error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x11</td>\r
+               <td>service search fail</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_PARING_FAILED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x12</td>\r
+               <td>pairing failed error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NOT_PAIRED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x13</td>\r
+               <td>Not paired error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_SERVICE_NOT_FOUND</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x14</td>\r
+               <td>no service error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NOT_CONNECTED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x15</td>\r
+               <td>no connection error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_ALREADY_CONNECT</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x16</td>\r
+               <td>already connected error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_CONNECTION_BUSY</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x17</td>\r
+               <td>connection busy error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_CONNECTION_ERROR</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x18</td>\r
+               <td>connection error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_MAX_CONNECTION</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x19</td>\r
+               <td>max connection error</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_NOT_IN_OPERATION</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x1A</td>\r
+               <td>Not in operation</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_CANCEL_BY_USER</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x1B</td>\r
+               <td>cancelled by user</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_REGISTRATION_FAILED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x1C</td>\r
+               <td>registration failed</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_IN_PROGRESS</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x1D</td>\r
+               <td>operation is in progress </td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_AUTHENTICATION_FAILED</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x1E</td>\r
+               <td>authentication failed</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ERROR_HOST_DOWN</td>\r
+               <td>BLUETOOTH_ERROR_BASE - 0x1F</td>\r
+               <td>Remote host is down</td></tr>\r
+\r
+\r
+</table>\r
+\r
+       <h2 class="pg">Enums</h2>\r
+               <h3 class="pg">bluetooth_adapter_state_t</h2>\r
+Adapter state\r
+<table>\r
+       <tr><td colspan="2">bluetooth_adapter_state_t</td></tr>\r
+\r
+       <tr>            <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ADAPTER_DISABLED</td>\r
+               <td>Bluetooth adapter is disabled</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ADAPTER_ENABLED</td>\r
+               <td>Bluetooth adapter is enabled</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ADAPTER_CHANGING_ENABLE</td>\r
+               <td>Bluetooth adapter is currently enabling</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_ADAPTER_CHANGING_DISABLE</td>\r
+               <td>Bluetooth adapter is currently disabling</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_discoverable_mode_t</h3>\r
+Discoverable mode\r
+<table>\r
+       <tr><td colspan="2">bluetooth_discoverable_mode_t</td></tr>\r
+\r
+       <tr>            <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE</td>\r
+               <td>Non discoverable mode, other device cannot search the device</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE</td>\r
+               <td>Discoverable mode, other device can search the device</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE</td>\r
+               <td>Discoverable mode with time limit, After specific timeout it is changed to non discoverable mode</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_event_type_t</h3>\r
+Bluetooth event type\r
+<table>\r
+       <tr><td colspan="2">bluetooth_event_type_t</td></tr>\r
+\r
+       <tr>            <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_NONE</td>\r
+               <td>No event</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_ENABLED</td>\r
+               <td>Bluetooth adapter enabled broadcasting event</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DISABLED</td>\r
+               <td>Bluetooth adapter disabled broadcasting event</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_LOCAL_NAME_CHANGED</td>\r
+               <td>Local friendly name changed broadcasting event</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_REQUESTED</td>\r
+               <td>When setting  local discoverable mode to BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE, this event comes to set timeout for bluetooth_get_discoverable_mode() API.</td></tr>\r
+@n Only the API caller receive this event.\r
+@n (Not supported yet)\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED</td>\r
+               <td>Bluetooth discoverable mode changed, parameter is pointer to changed mode</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DISCOVERY_OPTION_REQUESTED</td>\r
+               <td>(Not supported)</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DISCOVERY_STARTED</td>\r
+               <td>Discovery session started broadcasting event</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DISCOVERY_FINISHED</td>\r
+               <td>Discovery session finished broadcasting event</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND</td>\r
+               <td>During discovery session, found device is reported with this event.</td></tr>\r
+@n Only the API caller receives this event.\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED</td>\r
+               <td>During discovery session, friendly name information of found device is reported with this event.</td></tr>\r
+@n Only the API caller receives this event.\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_BONDING_FINISHED</td>\r
+               <td>Newly bonded device is reported with this event. This is broadcasting event.</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED</td>\r
+               <td>If bonded device is locally removed, this event reported. This is broadcasting event. Removing is not sent to a unbonded peer device because it means removing locally stored key for the device.</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_BONDED_DEVICE_FOUND</td>\r
+               <td>Bonded device is reported with this event if you uses bluetooth_get_bonded_device_list() API. Only the API caller receives this event.</td></tr>\r
+@n (Not supported yet)\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_REMOTE_DEVICE_READ</td>\r
+               <td>Information directly getting from peer device is reported with this event if you uses bluetooth_get_remote_device() API.</td></tr>\r
+@n Only the API caller receives this event.\r
+@n (Not supported yet)\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DEVICE_AUTHORIZED</td>\r
+               <td>This event reports the result of bluetooth_authorize_device() API.</td></tr>\r
+@n Only the API caller receives this event.\r
+@n (Not supported yet)\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED</td>\r
+               <td>This event reports the result of bluetooth_authorize_device() API.</td></tr>\r
+@n Only the API caller receives this event.\r
+@n (Not supported yet)\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_SERVICE_SEARCHED</td>\r
+               <td>This event reports the result of bluetooth_search_service() API.</td></tr>\r
+@n Only the API caller receives this event.\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_SERVICE_SEARCH_CANCELLED</td>\r
+               <td>During searching service, bluetooth_cancel_service_search() API is called, this event indicated the cancellation of searching without BLUETOOTH_EVENT_SERVICE_SEARCHED event.</td></tr>\r
+@n Only the API caller receives this event.\r
+@n (Not supported yet)\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED</td>\r
+               <td>This event is occured if RFCOMM data recieves from remote device.</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_RFCOMM_CONNECTED</td>\r
+               <td>If RFCOMM socket is connected, this event reported </td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_RFCOMM_DISCONNECTED</td>\r
+               <td>If RFCOMM socket is disconnected, this event reported </td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_EVENT_MAX</td>\r
+               <td>Max value</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_device_service_class_t</h3>\r
+Service class part of class of device returned from device discovery, all service which supported found devi   ce is masked. Each type is defined by Bluetooth SIG.\r
+<table>\r
+       <tr><td colspan="2">bluetooth_device_service_class_t</td></tr>\r
+\r
+       <tr>            <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE</td>\r
+               <td>device in limited discoverable mode</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_POSITIONING</td>\r
+               <td>Positioning service</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_NETWORKING</td>\r
+               <td>Networking service</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_RENDERING</td>\r
+               <td>Printing, Speaker</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_CAPTURING</td>\r
+               <td>Capturing (Scanner, Microphone)</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER</td>\r
+               <td>Object Transfer service</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_AUDIO</td>\r
+               <td>Audio service</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_TELEPHONY</td>\r
+               <td>Telephony service</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_SERVICE_CLASS_INFORMATION</td>\r
+               <td>WEB-server, WAP-server</td></tr>\r
+\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_device_major_class_t</h3>\r
+Major device class (part of Class of Device)\r
+<table>\r
+       <tr><td colspan="2">bluetooth_device_service_class_t</td></tr>\r
+\r
+       <tr>            <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_MISC</td>\r
+               <td>Miscellaneous major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER</td>\r
+               <td>Computer major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE</td>\r
+               <td>Phone major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT</td>\r
+               <td>LAN major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO</td>\r
+               <td>AUDIO major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL</td>\r
+               <td>Peripheral major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING</td>\r
+               <td>Imaging major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE</td>\r
+               <td>Wearable major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_TOY</td>\r
+               <td>Toy major device class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH</td>\r
+               <td>Health major device class</td></tr>\r
+\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_device_minor_class_t</h3>\r
+Minor device class (part of Class of Device)\r
+<table>\r
+       <tr><td colspan="2">bluetooth_device_service_class_t</td></tr>\r
+\r
+       <tr>            <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_UNCLASSIFIED</td>\r
+               <td>Not classified class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER, Desktop PC</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER, Desktop Server</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_LAPTOP</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER, Laptop</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER, PDA</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER, Desktop PDA</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER, wearable computer</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CELLULAR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE, cellular phone</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CORDLESS</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE, cordless phone</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_SMART_PHONE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE, Cellular phone, smart phone</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE, voice gateway</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE, ISDN</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_FULLY_AVAILABLE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT, indicating network performance</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HEADSET_PROFILE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Headset minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HANDSFREE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Handsfree minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_MICROPHONE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Microphone minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_LOUD_SPEAKER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Loud Speaker minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HEADPHONES</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Headphones minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_PORTABLE_AUDIO</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Portable Audio minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CAR_AUDIO</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Car Audio minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_SET_TOP_BOX</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Set top box minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Hifi audio device minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_VCR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, VCR minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CAMERA</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Video Camera minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CAM_CORDER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Camcorder minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_MONITOR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Video Monitor minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_DISPLAY_AND_LOUD_SPEAKER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Video Display and Loud Speaker minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CONFERENCING</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Video Conferencing minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_GAMING_OR_TOY</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO, Gaming or toy minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Key board minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Pointing Device minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_COMBO_KEYBOARD_OR_POINTING_DEVICE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Combo Keyboard or pointing device  minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_JOYSTICK</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, JoyStick minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_GAME_PAD</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Game Pad minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_REMOTE_CONTROL</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Remote Control minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_SENSING_DEVICE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Sensing Device minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_DIGITIZER_TABLET</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Digitizer minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CARD_READER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Card Reader minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_DIGITAL_PEN</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Digital pen minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_SCANNER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Handheld scanner minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_GESTURAL_INPUT_DEVICE\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL, Handheld gestural input device minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_DISPLAY</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING, Display minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CAMERA</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING, Camera minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_SCANNER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING, Scanner minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_PRINTER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING, Printer minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_WRIST_WATCH</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE, Wrist watch minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_PAGER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE, Pager minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_JACKET</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE, Jacket minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HELMET</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE, Helmet minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_GLASSES</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE, Glasses minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_ROBOT</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_TOY, Robot minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_VEHICLE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_TOY, Vehicle minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_DOLL_OR_ACTION</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_TOY, Doll or Action minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_CONTROLLER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_TOY, Controller minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_GAME</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_TOY, Game minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_BLOOD_PRESSURE_MONITOR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Blood Pressure minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_THERMOMETER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Thermometer minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_WEIGHING_SCALE</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Weighing Scale minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_GLUCOSE_METER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Glucose minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_PULSE_OXIMETER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Pulse Oximeter minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_HEART_OR_PULSE_RATE_MONITOR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Heart or pulse rate monitor minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_MEDICAL_DATA_DISPLAY</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Medical minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_MEDICAL_STEP_COUNTER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Step counter minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_BODY_COMPOSITION_ANALYZER</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Body composition analyzer minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_PEAK_FLOW_MONITOR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Peak flow monitor minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_MEDICATION_MONITOR</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Medication monitor minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_KNEE_PROSTHESIS</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Knee prosthesis minor class</td></tr>\r
+\r
+       <tr>            <td>BLUETOOTH_DEVICE_MINOR_CLASS_ANKLE_PROSTHESIS</td>\r
+               <td>Detailed class for BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH, Ankle prosthesis minor class</td></tr>\r
+</table>\r
+\r
+       <h2 class="pg">Structures</h2>\r
+               <h3 class="pg">bluetooth_device_address_t</h3>\r
+This is Bluetooth device address type, fixed to 6 bytes ##:##:##:##:##:##\r
+<table>\r
+       <tr><td colspan="3">bluetooth_device_service_class_t</td></tr>\r
+\r
+       <tr>            <td>Type</td>\r
+               <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>unsigned char [BLUETOOTH_ADDRESS_LENGTH]</td>\r
+               <td>addr</td>\r
+               <td>Address of Bluetooth device</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_device_name_t</h3>\r
+This is Bluetooth device name type, maximum size of Bluetooth device name is 248 bytes\r
+<table>\r
+       <tr><td colspan="3">bluetooth_device_service_class_t</td></tr>\r
+\r
+       <tr>            <td>Type</td>\r
+               <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>char [BLUETOOTH_DEVICE_NAME_LENGTH_MAX]</td>\r
+               <td>name</td>\r
+               <td>Name of Bluetooth device</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_device_class_t</h3>\r
+Structure to hold the device class information\r
+<table>\r
+       <tr><td colspan="3">bluetooth_device_class_t</td></tr>\r
+\r
+       <tr>            <td>Type</td>\r
+               <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>bluetooth_device_major_class_t</td>\r
+               <td>major_class;</td>\r
+               <td>major device class</td></tr>\r
+\r
+       <tr>            <td>bluetooth_device_minor_class_t</td>\r
+               <td>minor_class</td>\r
+               <td>minor device class</td></tr>\r
+\r
+       <tr>            <td>bluetooth_device_service_class_t</td>\r
+               <td>service_class</td>\r
+               <td>service device class</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_device_info_t</h3>\r
+Structure to hold the device information\r
+<table>\r
+       <tr><td colspan="3">bluetooth_device_info_t</td></tr>\r
+\r
+       <tr>            <td>Type</td>\r
+               <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>bluetooth_device_address_t</td>\r
+               <td>device_address</td>\r
+               <td>Device address</td></tr>\r
+\r
+       <tr>            <td>bluetooth_device_name_t</td>\r
+               <td>device_name</td>\r
+               <td>Device name</td></tr>\r
+\r
+       <tr>            <td>bluetooth_device_class_t</td>\r
+               <td>device_class</td>\r
+               <td>Device class</td></tr>\r
+\r
+       <tr>            <td>unsigned int</td>\r
+               <td>service_list_array</td>\r
+               <td>Service list array</td></tr>\r
+\r
+       <tr>            <td>int</td>\r
+               <td>service_index</td>\r
+               <td>Service list number</td></tr>\r
+\r
+       <tr>            <td>int</td>\r
+               <td>rssi</td>\r
+               <td>Received signal strength indicator</td></tr>\r
+\r
+       <tr>            <td>gboolean</td>\r
+               <td>paired</td>\r
+               <td>Paired status</td></tr>\r
+\r
+       <tr>            <td>gboolean</td>\r
+               <td>connected</td>\r
+               <td>Connected status</td></tr>\r
+\r
+       <tr>            <td>gboolean</td>\r
+               <td>trust</td>\r
+               <td>Authorized status</td></tr>\r
+</table>\r
+\r
+               <h3 class="pg">bluetooth_event_param_t</h3>\r
+Structure to hold event information\r
+<table>\r
+       <tr><td colspan="3">bluetooth_device_info_t</td></tr>\r
+\r
+       <tr>            <td>Type</td>\r
+               <td>Name</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>int</td>\r
+               <td>event</td>\r
+               <td>Event type</td></tr>\r
+\r
+       <tr>            <td>int</td>\r
+               <td>result</td>\r
+               <td>Success or error value</td></tr>\r
+\r
+       <tr>            <td>void *</td>\r
+               <td>param_data</td>\r
+               <td>Parameter data pointer</td></tr>\r
+\r
+       <tr>            <td>void *</td>\r
+               <td>user_data</td>\r
+               <td>User data pointer</td></tr>\r
+</table>\r
+\r
+       <h2 class="pg">Call back functions</h2>\r
+               <h3 class="pg">bluetooth_cb_func_ptr</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">Void(* bluetooth_cb_func_ptr)(int event, bluetooth_event_param_t* event_param, void *user_data)</td></tr>\r
+\r
+       <tr><td rowspan="3">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>event</td>\r
+               <td>int</td>\r
+               <td>Event type</td></tr>\r
+\r
+       <tr>            <td>event_param</td>\r
+               <td>bluetooth_event_param_t*</td>\r
+               <td>Event data</td></tr>\r
+\r
+       <tr>            <td>user_data</td>\r
+               <td>void *</td>\r
+               <td>User data</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">Void*</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This call back function will be used to pass asynchronous events to application</td></tr>\r
+</table>\r
+\r
+       <h2 class="pg">Functions</h2>\r
+               <h3 class="pg">bluetooth_register_callback</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>callback_ptr</td>\r
+               <td>bluetooth_cb_func_ptr</td>\r
+               <td>a pointer to callback function</td></tr>\r
+\r
+       <tr>            <td>user_data</td>\r
+               <td>void *</td>\r
+               <td>a pointer to user data</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function will register the callback function, to handle events received from Bluetooth framework. </td></tr>\r
+\r
+       <tr><td colspan="4">This is a synchronous call. No event is returned after this function call</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)\r
+{\r
+       GMainLoop *main_loop = (GMainLoop*) user_data;\r
+\r
+       switch(event)\r
+       {\r
+               // Code for each event\r
+               default:\r
+                       g_main_loop_quit(main_loop);\r
+                       break;\r
+       }\r
+}\r
+\r
+int main()\r
+{\r
+       GMainLoop *main_loop = NULL;\r
+       int ret = 0;\r
+       g_type_init();\r
+       main_loop = g_main_loop_new(NULL, FALSE);\r
+       ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);\r
+       if (ret >= BLUETOOTH_ERROR_NONE)\r
+       {\r
+               // bluetooth_register_callback returned Success\r
+       }\r
+       else\r
+       {\r
+               // bluetooth_register_callback returned failiure\r
+       }\r
+       g_main_loop_run(main_loop);\r
+}\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image002.png\r
+\r
+               <h3 class="pg">bluetooth_enable_adapter</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_enable_adapter(void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function initializes Bluetooth protocol stack for use. This function is typically called at startup or when Bluetooth services are required. This function must be called before calling any other API of Bluetooth operations.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n If the call is success then the application will receive BLUETOOTH_EVENT_ENABLED event through registered callback function.</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_ENABLED:\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               // Successfully Enabled\r
+                       }\r
+                       else\r
+                       {\r
+                               // Failed\r
+                       }\r
+                       break;\r
+       }\r
+}\r
+\r
+...\r
+\r
+int ret = 0;\r
+ret = bluetooth_enable_adapter();\r
+@endcode\r
+</table>\r
+\r
+ - Sequence flow\r
+@image html bluetooth_image003.png\r
+\r
+               <h3 class="pg">bluetooth_disable_adapter</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_disable_adapter(void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function disables Bluetooth protocol stack and hardware. This function should be called when Bluetooth is no longer used.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n If this call is successful then the application will receive BLUETOOTH_EVENT_DISABLED event through registered callback function.</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_DISABLED:\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               // Successfully disabled\r
+                       }\r
+                       else\r
+                       {\r
+                               // Failed\r
+                       }\r
+                       break;\r
+       }\r
+}\r
+\r
+...\r
+\r
+int ret = 0;\r
+ret = bluetooth_disable_adapter();\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image004.png\r
+\r
+               <h3 class="pg">bluetooth_check_adapter</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_check_adapter(void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">bluetooth_adapter_state_t - Adapter state\r
+@n or\r
+@n Negative value (Error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function checks whether the Bluetooth adapter is enabled or not.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is a synchronous call.</td></tr>\r
+\r
+@code\r
+\r
+bluetooth_device_address_t local_address={0,};\r
+int ret = 0;\r
+\r
+ret = bluetooth_get_local_address(&local_address);\r
+@endcode\r
+</table>\r
+\r
+\r
+- Sequence flow\r
+@image html bluetooth_image005.png\r
+\r
+               <h3 class="pg">bluetooth_get_local_address</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_get_local_address(bluetooth_device_address_t* local_address)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>local_address</td>\r
+               <td>bluetooth_device_address_t *</td>\r
+               <td>Device address of local Bluetooth adapter</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on Success, Negative value (Error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function is used to get the device address of the local Bluetooth adapter.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is a synchronous call.</td></tr>\r
+\r
+@code\r
+bluetooth_device_name_t local_name={0,}\r
+int ret = 0;\r
+ret = bluetooth_get_local_name (&local_name);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image006.png\r
+\r
+               <h3 class="pg">bluetooth_get_local_name</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_get_local_name(bluetooth_device_name_t* local_name)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>local_name</td>\r
+               <td>bluetooth_device_name_t*</td>\r
+               <td>Local device name</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value (error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function is used to get the local device name.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is a synchronous call.</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED :\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               // Successfully local name changed\r
+                       }\r
+                       else\r
+                       {\r
+                               // Failed\r
+                       }\r
+                       break;\r
+       }\r
+}\r
+\r
+bluetooth_device_name_t local_name={0,}\r
+int ret = 0;\r
+ret = bluetooth_set_local_name (&local_name);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image007.png\r
+\r
+               <h3 class="pg">bluetooth_set_local_name</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_set_local_name(const bluetooth_device_name_t* local_name)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>local_name</td>\r
+               <td>const bluetooth_device_name_t*</td>\r
+               <td>Local device name</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value (error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function is used to set the local device name.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an synchronous call.\r
+\r
+ @code\r
+ bluetooth_discoverable_mode_t discoverable_mode_ptr;\r
+ int ret = 0;\r
+ ret = bluetooth_get_discoverable_mode (&discoverable_mode_ptr);\r
+ @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image008.png\r
+\r
+               <h3 class="pg">bluetooth_get_discoverable_mode</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t* discoverable_mode_ptr)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>discoverable_mode_ptr</td>\r
+               <td>bluetooth_discoverable_mode_t*</td>\r
+               <td>current bluetooth discoverable mode</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value (error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function is used to get the discoverable mode (Visibility option)</td></tr>\r
+\r
+       <tr><td colspan="4">This function is a synchronous call.</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED :\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               // Successfully local name changed\r
+                       }\r
+                       else\r
+                       {\r
+                               // Failed\r
+                       }\r
+                       break;\r
+       }\r
+}\r
+\r
+bluetooth_discoverable_mode_t mode;\r
+int ret = 0;\r
+mode= BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;\r
+ret = bluetooth_set_discoverable_mode (mode, 180);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image009.png\r
+\r
+               <h3 class="pg">bluetooth_set_discoverable_mode</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode, int timeout)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>discoverable_mode</td>\r
+               <td>bluetooth_discoverable_mode_t</td>\r
+               <td>Local device name</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value (error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function is used to set the discoverable mode (Visibility option).</td></tr>\r
+\r
+       <tr><td colspan="4">If new discoverable mode is time limited discoverable mode then application will receive BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_REQUESTED event through registered callback function. Application can use default timeout, 180 seconds, by ignoring this event.\r
+@n This function is an synchronous call.\r
+\r
+@code\r
+\r
+bluetooth_discoverable_mode_t mode;\r
+int ret = 0;\r
+mode= BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;\r
+ret = bluetooth_set_discoverable_mode (mode, 180);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image010.png\r
+\r
+               <h3 class="pg">bluetooth_start_discovery</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_start_discovery(unsigned short max_response, unsigned short discovery_duration, unsigned int classOfDeviceMask)</td></tr>\r
+\r
+       <tr><td rowspan="4">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>max_response</td>\r
+               <td>unsigned short</td>\r
+               <td>the maximum response of the number of founded devices</td></tr>\r
+\r
+       <tr>            <td>Discovery_duration</td>\r
+               <td>unsigned short</td>\r
+               <td>Bluetooth discovery duration</td></tr>\r
+\r
+       <tr>            <td>ClassOfDeviceMask</td>\r
+               <td>unsigned int</td>\r
+               <td>Classes of the device mask which user wants</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value (error code) if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function searches for peer Bluetooth devices. It first performs an inquiry; for each device found from the inquiry it gets the remote name of the device.\r
+@n To decide searching options like device type, maximum duration, filtering option, application will receive BLUETOOTH_EVENT_DISCOVERY_OPTION_REQUESTED event through registered callback function. Application can use ignore this event for just using default options, all devices, 30 seconds duration, no filter, general discover option.\r
+@n The device discovery can be cancelled by calling bluetooth_stop_discovery().</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n If the call is success then the application will receive BLUETOOTH_EVENT_DISCOVERY_STARTED event through registered callback function.\r
+@n The discovery is responded by BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event for each device it finds and BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED event for each device name it finds. The completion or cancellation of the discovery is indicated by BLUETOOTH_EVENT_DISCOVERY_FINISHED event.</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       printf("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       printf("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+                   case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:\r
+               {\r
+                       bluetooth_device_info_t *device_info = NULL;\r
+                       printf("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);\r
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \\r
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \\r
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       printf("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);\r
+                       break;\r
+       }\r
+}\r
+\r
+unsigned short max_response;\r
+unsigned short discovery_duration;\r
+unsigned classOfDeviceMask;\r
+int ret = 0;\r
+\r
+max_response =0;\r
+discovery_duration =0;\r
+classOfDeviceMask =0;\r
+\r
+ret = bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image011.png\r
+\r
+               <h3 class="pg">bluetooth_cancel_discovery</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_cancel_discovery (void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">This function returns true on success or false on failure</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function stops the ongoing device discovery operation.\r
+@n * with an error code BLUETOOTH_ERROR_CANCEL</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n If the call is successful in canceling discovery then the application will receive BLUETOOTH_EVENT_DISCOVERY_FINISHED event through registered callback function.</td></tr>\r
+\r
+@code\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:\r
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);\r
+                       break;\r
+       }\r
+}\r
+\r
+..\r
+\r
+int ret = 0;\r
+\r
+ret = bluetooth_cancel_discovery();\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image012.png\r
+\r
+               <h3 class="pg">bluetooth_is_discovering</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_is_discovering(void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 if there is no device discovery, 1 if there is a device discovery, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function checks whether the device discovery is started or not.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is a synchronous call.</td></tr>\r
+\r
+@code\r
+int ret = 0;\r
+ret = bluetooth_is_discovering ();\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image013.png\r
+\r
+               <h3 class="pg">bluetooth_bond_device</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_bond_device(const bluetooth_device_address_t *device_address)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>device_address</td>\r
+               <td>bluetooth_device_address_t *</td>\r
+               <td>This indicates an address of the device with which the pairing should be initiated</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">This function returns true on success or false on failure</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function initiates a bonding procedure with a peer device. The bonding procedure enables authentication and optionally encryption on the Bluetooth link.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n Response will be received through BLUETOOTH_EVENT_BONDING_FINISHED event.</td></tr>\r
+\r
+@code\r
+bluetooth_device_address_t searched_device = {{0}};\r
+bluetooth_device_address_t bonded_device = {{0}};\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+        {\r
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                       memset(&searched_device, 0x00, sizeof(bluetooth_device_address_t));\r
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       break;\r
+               }
+\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               memset(&bonded_device, 0x00, sizeof(bluetooth_device_address_t));\r
+                               memcpy(&bonded_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       }\r
+                       else\r
+                       {\r
+                               //bonding failed\r
+                       }\r
+                       break;\r
+               }\r
+       }\r
+}\r
+\r
+...\r
+\r
+int ret = 0;\r
+\r
+// After running bluetooth_start_discovery API, call this API if you are in testing.\r
+// Because we try to bond to the lastest searched device for testing in under code.\r
+if (searched_device.addr[0] || searched_device.addr[1] || searched_device.addr[2] \\r
+       || searched_device.addr[3] || searched_device.addr[4] || searched_device.addr[5])\r
+{\r
+       ret = bluetooth_bond_device(&searched_device);\r
+}\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image014.png\r
+\r
+               <h3 class="pg">bluetooth_cancel_bonding</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_cancel_bonding(void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This API is called to cancel the on-going bonding procedure.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an synchronous call.\r
+@code\r
+...\r
+\r
+int ret = 0;\r
+\r
+ret = bluetooth_cancel_bonding();\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image015.png\r
+\r
+               <h3 class="pg">bluetooth_unbond_device</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>device_address</td>\r
+               <td>const bluetooth_device_address_t *</td>\r
+               <td>This indicates an address of the device to remove bonding</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">This function returns true on success or false on failure</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function removes the bonded device from the bonded list.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n The request to remove the specified device from the bonded list is responded by BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED event</td></tr>\r
+\r
+@code\r
+bluetooth_device_address_t bonded_device = {{0}};\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               memset(&bonded_device, 0x00, sizeof(bluetooth_device_address_t));\r
+                               memcpy(&bonded_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       }\r
+                       else\r
+                       {\r
+                               //bonding failed\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED:\r
+               {\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //Unbound scuccess\r
+                       }\r
+                       else\r
+                               //unbound failure\r
+               }\r
+       }\r
+}\r
+\r
+\r
+...\r
+\r
+int ret = 0;\r
+\r
+// After running bluetooth_bond_device API, call this API if you are in testing.\r
+// Because we try to unbond to the lastest bonded device for testing in under code.\r
+\r
+ret = bluetooth_unbond_device(bonded_device);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image016.png\r
+\r
+               <h3 class="pg">bluetooth_get_bonded_device_list </h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_get_bonded_device_list(GPtrArray **dev_list)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">This function returns true on success or false on failure</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function gets a list of all the bonded(paired) devices.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an synchronous call.\r
+@n Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not, there is no valid information in the dev_list.\r
+ * The len field in the dev_list represents the number of bonded devices. The data structure for bonded device information is bluetooth_paired_device_info_t.\r
+\r
+ @code\r
+void bt_get_bonded_devices(void)\r
+{\r
+...\r
+       int i;\r
+       GPtrArray *devinfo = NULL;\r
+       bluetooth_paired_device_info_t *ptr;\r
+\r
+       // allocate the g_pointer_array\r
+       devinfo = g_ptr_array_new();\r
+\r
+       ret = bluetooth_get_bonded_device_list(&devinfo);\r
+       if (ret != BLUETOOTH_ERROR_NONE)\r
+       {\r
+               printf("bluetooth_get_bonded_device_list failed with [%d]",ret);\r
+       }\r
+       else\r
+       {\r
+               printf("g pointer arrary count : [%d]", devinfo->len);\r
+               for(i=0; i<devinfo->len;i++)\r
+               {\r
+                       ptr = g_ptr_array_index(devinfo, i);\r
+                       if(ptr != NULL)\r
+                       {\r
+                               printf("Name [%s]\n", ptr->device_name.name);\r
+                               printf("Major Class [%d]\n", ptr->device_class.major_class);\r
+                               printf("Minor Class [%d]\n", ptr->device_class.minor_class);\r
+                               printf("Service Class [%d]\n", ptr->device_class.service_class);\r
+                               printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", ptr->device_address.addr[0], ptr->device_address.addr[1], ptr->device_address.addr[2], ptr->device_address.addr[3], ptr->device_address.addr[4], ptr->device_address.addr[5]);\r
+\r
+                               // handle\r
+                               ...\r
+                       }\r
+               }\r
+       }\r
+       // free g_pointer_array\r
+       g_ptr_array_free(devinfo, TRUE);\r
+}
+\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image017.png\r
+\r
+               <h3 class="pg">bluetooth_get_remote_device (Not supported yet)</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>device_address</td>\r
+               <td>const bluetooth_device_address_t *</td>\r
+               <td>This indicates an address of the remote device</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function gets specific remote device.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n This API is responded by BLUETOOTH_EVENT_REMOTE_DEVICE_READ event.</td></tr>\r
+\r
+@code\r
+int ret = 0;\r
+ret = bluetooth_get_remote_device(&remote_address);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image018.png\r
+\r
+               <h3 class="pg">bluetooth_authorize_device</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_authorize_device(const bluetooth_device_address_t *device_address, gboolean authorized)</td></tr>\r
+\r
+       <tr><td rowspan="3">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>device_address</td>\r
+               <td>const bluetooth_device_address_t *</td>\r
+               <td>This indicates an address of the device to authorize</td></tr>\r
+\r
+       <tr>            <td>authorized</td>\r
+               <td>gboolean</td>\r
+               <td>TRUE: authorized FALSE:unauthorized</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function authorizes a bonded device to be able to connect without user confirmation.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n Response will be received through BLUETOOTH_EVENT_DEVICE_AUTHORIZED event.</td></tr>\r
+\r
+@code\r
+bluetooth_device_address_t bonded_device = {{0}};\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               memset(&bonded_device, 0x00, sizeof(bluetooth_device_address_t));\r
+                               memcpy(&bonded_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       }\r
+                       else\r
+                       {\r
+                               //bonding failed\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_DEVICE_AUTHORIZED :\r
+               {\r
+                       if (param->result == BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               //Device authorized\r
+                       }\r
+                       //device authorization failed failure\r
+               }\r
+       }\r
+}\r
+\r
+...\r
+\r
+int ret = 0;\r
+gboolean authorized;\r
+\r
+authorized =TRUE;\r
+\r
+ret = bluetooth_authorize_device(&bonded_device,authorized);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image019.png\r
+\r
+               <h3 class="pg">bluetooth_search_service</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_search_service(const bluetooth_device_address_t *device_address)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>device_address</td>\r
+               <td>const bluetooth_device_address_t *</td>\r
+               <td>This indicates an address of the device whose services need to be found</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This API call initiates the search for the services supported by the specified device.</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an asynchronous call.\r
+@n The service search request is responded by BLUETOOTH_EVENT_SERVICE_SEARCHED event</td></tr>\r
+\r
+@code\r
+bluetooth_device_address_t bonded_device = {{0}};\r
+\r
+void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+{\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_BONDING_FINISHED:\r
+               {\r
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bluetooth_device_info_t *device_info = NULL;\r
+                               device_info  = (bluetooth_device_info_t *)param->param_data;\r
+                               memset(&bonded_device, 0x00, sizeof(bluetooth_device_address_t));\r
+                               memcpy(&bonded_device, &device_info->device_address, sizeof(bluetooth_device_address_t));\r
+                       }\r
+                       else\r
+                       {\r
+                               //bonding failed\r
+                       }\r
+                       break;\r
+               }\r
+\r
+               case BLUETOOTH_EVENT_SERVICE_SEARCHED:\r
+               {\r
+                       int i = 0;
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {
+                               bt_sdp_info_t * bt_sdp_info=param->param_data;\r
+\r
+                               for(i=0; i<bt_sdp_info->service_index; i++)\r
+                                       printf("[%#x]\n", bt_sdp_info->service_list_array[i]);\r
+                       }
+                       else
+                       {\r
+                               // service searched fail\r
+                       }
+               }\r
+       }\r
+}\r
+\r
+...\r
+\r
+int ret = 0;\r
+ret = bluetooth_search_service(&bonded_device);\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image020.png\r
+\r
+               <h3 class="pg">bluetooth_cancel_service_search</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_cancel_service_search(void)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">0 on success, negative value if failed</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function cancels the ongoing service search operation</td></tr>\r
+\r
+       <tr><td colspan="4">This function is an synchronous call.\r
+\r
+@code\r
+...\r
+\r
+int ret = 0;\r
+ret = bluetooth_cancel_service_search();\r
+@endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image021.png\r
+\r
+               <h3 class="pg">bluetooth_rfcomm_create_socket</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_rfcomm_create_socket(const char *uuid)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>uuid</td>\r
+               <td>const char*</td>\r
+               <td>UUID (128 bits)</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">socket FD</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function register rfcomm socket with the given UUID</td></tr>\r
+\r
+       <tr><td colspan="4">This is a synchronous operation</td></tr>\r
+ @code\r
+\r
+  int fd = 0;\r
+  const char * rfcomm_test_uuid="00001101-0000-1000-8000-00805F9B34FB";\r
+  fd  = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);\r
+\r
+ @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image022.png\r
+\r
+               <h3 class="pg">bluetooth_rfcomm_listen_and_accept</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection)</td></tr>\r
+\r
+       <tr><td rowspan="3">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>socket_fd</td>\r
+               <td>int</td>\r
+               <td>Server socket FD</td></tr>\r
+\r
+       <tr>            <td>max_pending_connection</td>\r
+               <td>int</td>\r
+               <td>Max pending connection.</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">success or not</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function make rfcomm socket listen with socket. When ever a remote device gets connected, BLUETOOTH_EVENT_RFCOMM_CONNECTED event will get generated. This API is not a blocking call.\r
+ Once the connection is sucessfull, BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED event will get generated when there is some incoming data.</td></tr>\r
+\r
+       <tr><td colspan="4">This is a synchronous operation</td></tr>\r
+  @code\r
+\r
+ void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+ {\r
+       Switch(event)\r
+       {\r
+           case BLUETOOTH_EVENT_RFCOMM_CONNECTED:\r
+           {\r
+                if (param->result == BLUETOOTH_ERROR_NONE)\r
+                {\r
+                    bluetooth_rfcomm_connection_t *con_ind =\r
+                      (bluetooth_rfcomm_connection_t *)param->param_data;\r
+\r
+                    if(con_ind->device_role == RFCOMM_ROLE_SERVER)\r
+                    {\r
+                        //A client has been connected to the sever\r
+                        printf("\nClient fd = %d", conn_ind->socket_fd;\r
+                    }\r
+                    else\r
+                    {\r
+\r
+                    }\r
+                }\r
+            }\r
+       }\r
+ }\r
+\r
+ int ret = 0;\r
+ int max_connect = 1;\r
+ const char * spp_uuid ="00001101-0000-1000-8000-00805F9B34FB";\r
+ int socket_fd = bluetooth_rfcomm_create_socket(spp_uuid);\r
+ ret = bluetooth_rfcomm_listen_and_accept(socket_fd, max_connect);\r
+\r
+ @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image024.png\r
+\r
+\r
+               <h3 class="pg">bluetooth_rfcomm_remove_socket</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)</td></tr>\r
+\r
+       <tr><td rowspan="3">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>socket_fd</td>\r
+               <td>int</td>\r
+               <td>Server socket FD</td></tr>\r
+\r
+       <tr>            <td>uuid</td>\r
+               <td>const char*</td>\r
+               <td>UUID (128 bits)</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">success or not</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">This function deregister rfcomm socket with the given socket descriptor and UUID. If a client connection exists, then BLUETOOTH_EVENT_RFCOMM_DISCONNECTED event will get generated to indicate that the client connection has been terminated.</td></tr>\r
+\r
+       <tr><td colspan="4">This is a synchronous operation</td></tr>\r
+ @code\r
+ void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+ {\r
+       Switch(event)\r
+       {\r
+           case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:\r
+           {\r
+                if (param->result == BLUETOOTH_ERROR_NONE)\r
+                {\r
+                            //A connection exists and it got disconnect\r
+                }\r
+            }\r
+       }\r
+ }\r
+\r
+\r
+ ...\r
+\r
+ int ret = 0;\r
+ int fd = 0;\r
+ const char * spp_uuid ="00001101-0000-1000-8000-00805F9B34FB";\r
+ fd  = bluetooth_rfcomm_create_socket(spp_uuid);\r
+ ret = bluetooth_rfcomm_listen_and_accept(fd, 1);\r
+ ....\r
+ ret = bluetooth_rfcomm_remove_socket(fd, spp_uuid);\r
+\r
+ @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image023.png\r
+\r
+               <h3 class="pg">bluetooth_rfcomm_connect</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_rfcomm_connect(const bluetooth_device_address_t  *remote_bt_address, const char * remote_uuid)</td></tr>\r
+\r
+       <tr><td rowspan="3">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>remote_bt_address</td>\r
+               <td>const bluetooth_device_address_t  *</td>\r
+               <td>Remote device?\99s Bluetooth address</td></tr>\r
+\r
+       <tr>            <td>remot_uuid</td>\r
+               <td>const char*</td>\r
+               <td>remote uuid</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">success or not</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">Connect to a specific RFCOMM based service on a remote device. It is advisible to do a service search before connecting. When ever the connection is successful, BLUETOOTH_EVENT_RFCOMM_CONNECTED event will gets generated.\r
+ Once the connection is sucessfull, BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED event will get generated when there is some incoming data.</td></tr>\r
+\r
+       <tr><td colspan="4">This is Asynchronous operation</td></tr>\r
+  @code\r
+\r
+ void bt_event_callback(int event, bluetooth_event_param_t* param)\r
+ {\r
+       switch(event)\r
+       {\r
+               case BLUETOOTH_EVENT_SERVICE_SEARCHED:\r
+               {\r
+                       if (param->result >= BLUETOOTH_ERROR_NONE)\r
+                       {\r
+                               bt_sdp_info_t * bt_sdp_info=param->param_data;\r
+\r
+                               printf("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",\r
+                                       bt_sdp_info->device_addr.addr[0], bt_sdp_info->device_addr.addr[1], bt_sdp_info->device_addr.addr[2], \\r
+                                       bt_sdp_info->device_addr.addr[3], bt_sdp_info->device_addr.addr[4], bt_sdp_info->device_addr.addr[5]);\r
+\r
+                                       printf("Supported service list:\n");\r
+                                       for(i=0; i<bt_sdp_info->service_index; i++)\r
+                                               printf("[%#x]\n", bt_sdp_info->service_list_array[i]);\r
+\r
+                               //Alternate method\r
+                               //ret = bluetooth_rfcomm_connect(bt_sdp_info->device_addr, rfcomm_test_uuid);\r
+                       }\r
+                       break;\r
+               }\r
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:\r
+               {\r
+                       bluetooth_rfcomm_connection_t *conn_ind = (bluetooth_rfcomm_connection_t *)param->param_data;\r
+\r
+                       printf("\nConnected from FD %d, Role = %s",  conn_ind->socket_fd,\r
+                                                               (conn_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT");\r
+               }\r
+       }\r
+ }\r
+\r
+  bluetooth_device_address_t remote_address = {{0},};\r
+  const char * spp_uuid ="00001101-0000-1000-8000-00805F9B34FB";\r
+  remote_address.addr[0] = 0x0; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A;\r
+  remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19;  remote_address.addr[5]= 0x36;\r
+  ret = bluetooth_search_service(&remote_address);\r
+ if (ret < 0)\r
+       printf("Seach failed, Reason = %d", ret);\r
+  else\r
+        printf("Search Success, Ret = %d", ret);\r
+\r
+  ret = bluetooth_rfcomm_connect(&remote_address, spp_uuid);\r
+  if (ret < 0)\r
+       printf("Connection failed, Reason = %d", ret);\r
+  else\r
+        printf("Connection Success, Ret = %d", ret);\r
+\r
+  @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image025.png\r
+\r
+               <h3 class="pg">bluetooth_rfcomm_disconnect</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_rfcomm_disconnect(int socket_fd)</td></tr>\r
+\r
+       <tr><td rowspan="2">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>socket_fd</td>\r
+               <td>int</td>\r
+               <td>Client socket FD</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">success or not</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">Disconnect a specific(remote address)  RFCOMM connection</td></tr>\r
+\r
+       <tr><td colspan="4">This is a synchronous operation</td></tr>\r
+ @code\r
+\r
+  ret = bluetooth_rfcomm_disconnect(g_ret_fd);\r
+  if (ret < 0)\r
+       printf("Disconnection failed");\r
+  else\r
+       printf("Disconnection Success");\r
+\r
+ @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image026.png\r
+\r
+               <h3 class="pg">bluetooth_rfcomm_write</h3>\r
+<table>\r
+       <tr>            <td>Function Prototype</td>\r
+<td colspan="3">int bluetooth_rfcomm_write(int fd, const char *buf, int length)</td></tr>\r
+\r
+       <tr><td rowspan="4">Input Parameters</td>\r
+               <td>Variable Name</td>\r
+               <td>Data Type</td>\r
+               <td>Description</td></tr>\r
+\r
+       <tr>            <td>fd</td>\r
+               <td>int</td>\r
+               <td>Socket descriptor</td></tr>\r
+\r
+       <tr>            <td>buf</td>\r
+               <td>const char*</td>\r
+               <td>Buffer data to send</td></tr>\r
+\r
+       <tr>            <td>length</td>\r
+               <td>int</td>\r
+               <td>Length of the buffer</td></tr>\r
+\r
+       <tr>            <td>Output Parameters</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td>\r
+               <td>n/a</td></tr>\r
+\r
+       <tr>            <td>Returns</td>\r
+<td colspan="3">success or not</td></tr>\r
+\r
+       <tr>            <td>Function Description</td>\r
+<td colspan="3">Send the data to the remote device. This API used by both the client and the sever to send the data.</td></tr>\r
+\r
+       <tr><td colspan="4">This is a synchronous operation</td></tr>\r
+ @code\r
+\r
+ int ret = 0;\r
+ char *buff = "abcdefghijklmnopqrstuvwxyz";\r
+ int len = 26;\r
+ ret = bluetooth_rfcomm_write(fd, buff, len);\r
+\r
+\r
+ @endcode\r
+</table>\r
+\r
+- Sequence flow\r
+@image html bluetooth_image027.png\r
+\r
+*/\r
+/**\r
+@}\r
+*/\r
diff --git a/lib/bluetooth-api-common.c b/lib/bluetooth-api-common.c
new file mode 100644 (file)
index 0000000..4054fc4
--- /dev/null
@@ -0,0 +1,1404 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+/*:Associate with "Bluetooth" */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "bluetooth-api-common.h"
+#include "bluetooth-gap-api.h"
+#include "bluetooth-network-api.h"
+
+#include "marshal.h"
+
+static void __bluetooth_internal_mode_changed_cb(DBusGProxy *object, const char *changed_mode,
+                                               gpointer user_data);
+static void __bluetooth_internal_connection_changed_cb(gboolean connected,
+                                                    const bluetooth_device_address_t *device_addr);
+static void __bluetooth_internal_authorized_cb(gboolean authorized,
+                                               const bluetooth_device_address_t *device_addr);
+
+/* Global session information*/
+static bt_info_t bt_info = { 0, };
+
+bt_info_t *_bluetooth_internal_get_information(void)
+{
+       bt_info_t *bt_internal_info = &bt_info;
+       return bt_internal_info;
+}
+
+bool _bluetooth_internal_is_adapter_enabled(void)
+{
+       GError *err = NULL;
+       const char *adapter_path = NULL;
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL");
+               return FALSE;
+       }
+
+       if (bt_internal_info->manager_proxy == NULL) {
+               DBG("manager_proxy is NULL");
+               return FALSE;
+       }
+
+       if (!dbus_g_proxy_call(bt_internal_info->manager_proxy, "DefaultAdapter", &err,
+                               G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &adapter_path,
+                               G_TYPE_INVALID)) {
+               if (err != NULL) {
+                       DBG("DefaultAdapter err:[%s]", err->message);
+                       g_error_free(err);
+               }
+               return FALSE;
+       }
+
+       if (adapter_path == NULL) {
+               DBG("adapter_path is NULL");
+               return FALSE;
+       }
+
+       DBG("adapter_path is %s", adapter_path);
+
+       return TRUE;
+}
+
+void bluetooth_internal_convert_uuid_num_to_string(const bluetooth_service_uuid_list_t uuid_num,
+                                                       char *uuid, int size)
+{
+       DBG("+");
+
+       if (!uuid)
+               return;
+
+       snprintf(uuid, size, "0000%x-%s", uuid_num, BLUETOOTH_UUID_POSTFIX);
+
+       DBG("uuid string is %s", uuid);
+
+       DBG("-");
+}
+
+int bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path)
+{
+       GError *err = NULL;
+       DBusGProxy *manager_proxy = NULL;
+       char *adapter_path = NULL;
+
+       DBG("+\n");
+
+       manager_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", "/", "org.bluez.Manager");
+
+       if (manager_proxy == NULL) {
+               DBG("Could not create a dbus proxy\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &err,
+                              G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &adapter_path,
+                               G_TYPE_INVALID)) {
+               if (err != NULL) {
+                       DBG("Getting DefaultAdapter failed: [%s]\n", err->message);
+                       g_error_free(err);
+               }
+               g_object_unref(manager_proxy);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (adapter_path == NULL || strlen(adapter_path) >= BT_ADAPTER_OBJECT_PATH_MAX) {
+               DBG("Adapter path is inproper\n");
+               g_object_unref(manager_proxy);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       strncpy(path, adapter_path, BT_ADAPTER_OBJECT_PATH_MAX);
+       DBG("path = %s\n", adapter_path);
+
+       g_object_unref(manager_proxy);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+void _bluetooth_internal_convert_addr_string_to_addr_type(bluetooth_device_address_t *addr,
+                                                                       const char *address)
+{
+       char *ptr1, *ptr2, *ptr3, *ptr4, *ptr5;
+
+       if (!address || !addr)
+               return;
+
+       addr->addr[0] = strtol(address, &ptr5, 16);
+       addr->addr[1] = strtol(ptr5 + 1, &ptr4, 16);
+       addr->addr[2] = strtol(ptr4 + 1, &ptr3, 16);
+       addr->addr[3] = strtol(ptr3 + 1, &ptr2, 16);
+       addr->addr[4] = strtol(ptr2 + 1, &ptr1, 16);
+       addr->addr[5] = strtol(ptr1 + 1, NULL, 16);
+}
+
+void _bluetooth_internal_print_bluetooth_device_address_t(const bluetooth_device_address_t *addr)
+{
+       DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", addr->addr[0], addr->addr[1], addr->addr[2],
+                               addr->addr[3], addr->addr[4], addr->addr[5]);
+}
+
+void _bluetooth_internal_addr_type_to_addr_string(char *address,
+                                               const bluetooth_device_address_t *addr)
+{
+       if (!address || !addr)
+               return;
+
+       snprintf(address, BT_ADDRESS_STRING_SIZE,
+               "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr->addr[0], addr->addr[1],
+                               addr->addr[2], addr->addr[3], addr->addr[4], addr->addr[5]);
+}
+
+void _bluetooth_internal_divide_device_class(bluetooth_device_class_t *device_class,
+                                                                       unsigned int cod)
+{
+       if (!device_class)
+               return;
+
+       device_class->major_class = (unsigned short)(cod & 0x00001F00) >> 8;
+       device_class->minor_class = (unsigned short)((cod & 0x000000FC));
+       device_class->service_class = (unsigned int)((cod & 0x00FF0000));
+
+       if (cod & 0x002000) {
+               device_class->service_class |=
+                                       BLUETOOTH_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE;
+       }
+}
+
+static int __bluetooth_internal_store_set_value(const char *key, bt_store_type_t store_type,
+                                               void *value)
+{
+       int ret = 0;
+       int int_vlaue = 0;
+
+       if (value == NULL) {
+               return -1;
+       }
+
+       switch (store_type) {
+       case BT_STORE_BOOLEAN:
+               int_vlaue = *((gboolean *) value);
+               ret = vconf_set_bool(key, int_vlaue);
+               break;
+       case BT_STORE_INT:
+               int_vlaue = *((int *)value);
+               ret = vconf_set_int(key, int_vlaue);
+               break;
+       case BT_STORE_STRING:
+               ret = vconf_set_str(key, (char *)value);
+               break;
+       default:
+               DBG("Unknown Store Type");
+               return -1;
+       }
+
+       return ret;
+}
+
+static int __bluetooth_internal_store_get_value(const char *key,
+                               bt_store_type_t store_type,
+                               unsigned int size, void *value)
+{
+       int ret = 0;
+       int int_value = 0;
+       int *intval = NULL;
+       gboolean *bool_value = FALSE;
+       char *str = NULL;
+       char *ptr = NULL;
+
+       if (value == NULL) {
+               return -1;
+       }
+
+       switch (store_type) {
+       case BT_STORE_BOOLEAN:
+               bool_value = (gboolean *) value;
+               ret = vconf_get_bool(key, &int_value);
+               if (ret < 0) {
+                       DBG("Get gboolean is failed");
+                       *bool_value = FALSE;
+                       return -1;
+               }
+               *bool_value = (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 -1;
+               }
+               break;
+       case BT_STORE_STRING:
+               str = vconf_get_str(key);
+               if (str == NULL || strlen(str) == 0) {
+                       DBG("Get string is failed");
+                       return -1;
+               }
+               if (size > 1) {
+                       if (!g_utf8_validate(str, -1, (const char **)&ptr))
+                               *ptr = '\0';
+
+                       g_strlcpy((char *)value, str, size - 1);
+               }
+
+               free(str);
+               break;
+       default:
+               DBG("Unknown Store Type");
+               return -1;
+       }
+
+       return ret;
+}
+
+int _bluetooth_internal_get_value(bt_store_key_t key)
+{
+       int ret = 0;
+
+       switch (key) {
+       case BT_STORE_NAME:
+               ret = __bluetooth_internal_store_get_value(BT_SETTING_DEVICE_NAME,
+                                                       BT_STORE_STRING,
+                                                        BLUETOOTH_DEVICE_NAME_LENGTH_MAX,
+                                                       bt_info.bt_local_name.name);
+               break;
+
+       case BT_STORE_DISCOVERABLE_MODE:
+               break;
+
+       default:
+               break;
+       }
+
+       return ret;
+}
+
+int _bluetooth_internal_set_value(bt_store_key_t key)
+{
+       int ret = 0;
+
+       switch (key) {
+       case BT_STORE_NAME:
+               ret = __bluetooth_internal_store_set_value(BT_STORE_LOCAL_NAME_PATH,
+                                                       BT_STORE_STRING,
+                                                        bt_info.bt_local_name.name);
+               break;
+
+       case BT_STORE_DISCOVERABLE_MODE:
+               break;
+
+       default:
+               break;
+       }
+
+       return ret;
+}
+
+DBusGProxy *_bluetooth_internal_find_device_by_path(const char *dev_path)
+{
+       GList *list = bt_info.device_proxy_list;
+       DBusGProxy *device_proxy = NULL;
+       const char *proxy_path = NULL;
+       int list_length, i;
+
+       if (list == NULL || dev_path == NULL) {
+               return NULL;
+       }
+
+       list_length = g_list_length(list);
+
+       for (i = 0; i < list_length; i++) {
+               device_proxy = (DBusGProxy *) g_list_nth_data(list, i);
+
+               if (device_proxy != NULL) {
+                       proxy_path = dbus_g_proxy_get_path(device_proxy);
+
+                       if (strcmp(proxy_path, dev_path) == 0) {
+                               return device_proxy;
+                       }
+               }
+       }
+
+       return NULL;
+}
+
+static void __change_uuids_to_bt_sdp_info(GValue *value, bt_sdp_info_t *sdp_data)
+{
+       char **uuids;
+       int i;
+       char **parts;
+
+       if (value == NULL || sdp_data == NULL)
+               return;
+
+       uuids = g_value_get_boxed(value);
+       if (uuids == NULL)
+               return;
+
+       sdp_data->service_index = 0;
+
+       for (i = 0; uuids[i] != NULL && i < BLUETOOTH_MAX_SERVICES_FOR_DEVICE; i++) {
+               g_strlcpy(sdp_data->uuids[i], uuids[i], BLUETOOTH_UUID_STRING_MAX);
+
+               parts = g_strsplit(uuids[i], "-", -1);
+
+               if (parts == NULL || parts[0] == NULL) {
+                       g_strfreev(parts);
+                       return;
+               }
+
+               sdp_data->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
+               g_strfreev(parts);
+
+               DBG("UUIDs %d UUID %x ", i, sdp_data->service_list_array[i]);
+
+               sdp_data->service_index++;
+       }
+}
+
+static void __bluetooth_internal_device_property_changed(DBusGProxy *device_proxy,
+                                                       const char *property,
+                                                      GValue *value,
+                                                       gpointer user_data)
+{
+       const char *dev_path = dbus_g_proxy_get_path(device_proxy);
+       GHashTable *hash = NULL;
+       GValue *property_value;
+
+       bt_info_t *bt_internal_info = NULL;
+       bt_internal_info = _bluetooth_internal_get_information();
+       bluetooth_event_param_t bt_event = { 0, };
+
+       DBG("+ remote device[%s] property[%s]\n", dev_path, property);
+
+       if (g_strcmp0(property, "Paired") == 0) {
+               gboolean paired = g_value_get_boolean(value);
+               char address[18] = { 0 };
+
+               _bluetooth_internal_device_path_to_address(dev_path, address);
+
+               if (paired == TRUE) {
+                       _bluetooth_internal_bonding_created_cb(address,
+                                                       (gpointer)device_proxy);
+               }
+       } else if (g_strcmp0(property, "Trusted") == 0) {
+               char address[18] = { 0 };
+               bluetooth_device_address_t device_addr = { {0} };
+               gboolean trusted = g_value_get_boolean(value);
+
+               DBG("Remote Device [%s] Trusted Changed [%d]\n", dev_path,
+                                                               trusted);
+
+               _bluetooth_internal_device_path_to_address(dev_path, address);
+               _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, address);
+               __bluetooth_internal_authorized_cb(trusted, &device_addr);
+       } else if (g_strcmp0(property, "Connected") == 0) {
+               char address[18] = { 0 };
+               bluetooth_device_address_t device_addr = { {0} };
+               gboolean connected = g_value_get_boolean(value);
+
+               _bluetooth_internal_device_path_to_address(dev_path, address);
+               _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr,
+                                                                       address);
+               __bluetooth_internal_connection_changed_cb(connected, &device_addr);
+
+       } else if (g_strcmp0(property, "Name") == 0) {
+               const gchar *name = g_value_get_string(value);
+               const char *address = NULL;
+               guint remote_class;
+               gboolean paired = FALSE;
+
+               dbus_g_proxy_call(device_proxy, "GetProperties", NULL,
+                                 G_TYPE_INVALID,
+                                 dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+               if (hash != NULL) {
+                       property_value = g_hash_table_lookup(hash, "Address");
+                       address = (char *)property_value ? g_value_get_string(property_value) : NULL;
+
+                       property_value = g_hash_table_lookup(hash, "Class");
+                       remote_class = property_value ? g_value_get_uint(property_value) : 0;
+
+                       property_value = g_hash_table_lookup(hash, "Paired");
+                       paired = property_value ? g_value_get_boolean(property_value) : FALSE;
+
+                       _bluetooth_internal_remote_device_name_updated_cb(address,
+                                               name, 0, remote_class, paired);
+               }
+       } else if (g_strcmp0(property, "UUIDs") == 0) {
+               bt_sdp_info_t sdp_data;
+               char address[18] = { 0 };
+
+               DBG("Device Property Changed (UUIDs )");
+
+               _bluetooth_internal_device_path_to_address(dev_path, address);
+
+               _bluetooth_internal_convert_addr_string_to_addr_type(&sdp_data.device_addr, address);
+
+               _bluetooth_internal_print_bluetooth_device_address_t(&sdp_data.device_addr);
+
+               __change_uuids_to_bt_sdp_info(value, &sdp_data);
+
+               /* Report UUID list as xml_parsed_sdp_data to the upper layer. */
+               if (bt_internal_info->bt_cb_ptr) {
+                       bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED;
+                       if (sdp_data.service_index <= 0 ||
+                               sdp_data.service_index >= BLUETOOTH_MAX_SERVICES_FOR_DEVICE) {
+                               bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR;
+                               sdp_data.service_index = 0;
+                               bt_event.param_data = &sdp_data;
+                       } else {
+                               bt_event.result = BLUETOOTH_ERROR_NONE;
+                               bt_event.param_data = &sdp_data;
+                       }
+
+                       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                               bt_internal_info->user_data);
+
+               }
+       }
+
+       DBG("-\n");
+
+}
+
+static void __bluetooth_internal_add_device_signal(DBusGProxy *device_proxy)
+{
+       if (device_proxy == NULL) {
+               return;
+       }
+
+       dbus_g_proxy_add_signal(device_proxy, "PropertyChanged", G_TYPE_STRING,
+                                               G_TYPE_VALUE, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(device_proxy, "PropertyChanged",
+                                   G_CALLBACK(__bluetooth_internal_device_property_changed),
+                                       NULL, NULL);
+}
+
+static void __bluetooth_internal_remove_device_signal(DBusGProxy *device_proxy)
+{
+       if (device_proxy == NULL) {
+               return;
+       }
+
+       dbus_g_proxy_disconnect_signal(device_proxy, "PropertyChanged",
+                                       G_CALLBACK(__bluetooth_internal_device_property_changed),
+                                       NULL);
+}
+
+DBusGProxy *_bluetooth_internal_add_device(const char *path)
+{
+       DBusGProxy *device_proxy = NULL;
+
+       device_proxy = dbus_g_proxy_new_for_name(bt_info.conn, "org.bluez",
+                                               path, "org.bluez.Device");
+       if (device_proxy) {
+               bt_info.device_proxy_list = g_list_append(bt_info.device_proxy_list,
+                                                               device_proxy);
+               __bluetooth_internal_add_device_signal(device_proxy);
+       }
+
+       return device_proxy;
+}
+
+static void __bluetooth_internal_device_created(DBusGProxy *adapter,
+                                       const char *path, gpointer user_data)
+{
+       DBG("+ device[%s]", path);
+
+       if (path != NULL) {
+               DBusGProxy *device_proxy = _bluetooth_internal_find_device_by_path(path);
+               if (device_proxy == NULL) {
+                       device_proxy = _bluetooth_internal_add_device(path);
+
+                       if (device_proxy) {
+                               DBG("Newly added device [%s]", path);
+                               bt_info.is_headset_bonding = _bluetooth_is_headset_device(device_proxy);
+                       }
+               } else {
+                       DBG("Newly added device, but it is stored in list");
+               }
+       }
+
+       DBG("-");
+}
+
+void _bluetooth_internal_device_path_to_address(const char *device_path,
+                                               char *device_address)
+{
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char *dev_addr = NULL;
+
+       if (!device_path || !device_address)
+               return;
+
+       dev_addr = strstr(device_path, "dev_");
+       if (dev_addr != NULL) {
+               char *pos = NULL;
+               dev_addr += 4;
+               g_strlcpy(address, dev_addr, sizeof(address));
+
+               while ((pos = strchr(address, '_')) != NULL) {
+                       *pos = ':';
+               }
+
+               g_strlcpy(device_address, address, BT_ADDRESS_STRING_SIZE);
+       }
+}
+
+static void __bluetooth_internal_device_removed(DBusGProxy *adapter,
+                                       const char *path, gpointer user_data)
+{
+       DBG("+ device[%s]", path);
+
+       if (path != NULL) {
+               DBusGProxy *device_proxy = _bluetooth_internal_find_device_by_path(path);
+               char address[18] = { 0 };
+
+               if (device_proxy == NULL) {
+                       return;
+               }
+
+               _bluetooth_internal_device_path_to_address(path, address);
+
+               _bluetooth_internal_bonding_removed_cb(address, (gpointer) device_proxy);
+
+               __bluetooth_internal_remove_device_signal(device_proxy);
+               bt_info.device_proxy_list = g_list_remove(bt_info.device_proxy_list,
+                                                       device_proxy);
+               g_object_unref(device_proxy);
+               device_proxy = NULL;
+       }
+
+       DBG("-");
+}
+
+static int __bluetooth_get_timeout_value(DBusGProxy *adapter)
+{
+       DBG("+");
+
+       int timeout = 0;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+
+       if (adapter == NULL)
+               return timeout;
+
+       dbus_g_proxy_call(adapter, "GetProperties", NULL,
+                         G_TYPE_INVALID,
+                         dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                         &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "DiscoverableTimeout");
+               timeout = g_value_get_uint(value);
+       }
+
+       DBG("-");
+       return timeout;
+}
+
+static bool __bluetooth_get_discoverable_value(DBusGProxy *adapter)
+{
+       DBG("+");
+
+       bool discoverable = FALSE;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+
+       if (adapter == NULL)
+               return discoverable;
+
+       dbus_g_proxy_call(adapter, "GetProperties", NULL,
+                         G_TYPE_INVALID,
+                         dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                         &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Discoverable");
+               discoverable = g_value_get_boolean(value);
+       }
+
+       DBG("-");
+       return discoverable;
+}
+
+static void __bluetooth_internal_adapter_property_changed(DBusGProxy *adapter,
+                                                       const char *property,
+                                                       GValue *value,
+                                                       gpointer user_data)
+{
+       int ret = 0;
+       DBG("+ property[%s]", property);
+
+       if (g_strcmp0(property, "Name") == 0) {
+               const gchar *name = g_value_get_string(value);
+               if (name && strlen(name)) {
+                       if (strlen(name) <= BLUETOOTH_DEVICE_NAME_LENGTH_MAX) {
+                               DBG("Changed Name [%s]", name);
+                               strncpy(bt_info.bt_local_name.name, name,
+                                                               BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+                               bt_info.bt_local_name.name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX] = '\0';
+
+                               ret = _bluetooth_internal_set_value(BT_STORE_NAME);
+                               _bluetooth_internal_adapter_name_changed_cb();
+                       } else {
+                               DBG("The name length[%d] is over than %d", strlen(name),
+                                   BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+                       }
+               }
+       } else if (g_strcmp0(property, "Discovering") == 0) {
+               gboolean discovering = g_value_get_boolean(value);
+
+               if (discovering == FALSE) {
+                       dbus_g_proxy_call_no_reply(adapter, "StopDiscovery",
+                                               G_TYPE_INVALID, G_TYPE_INVALID);
+                       bt_info.is_discovering = FALSE;
+                       _bluetooth_internal_discovery_completed_cb();
+               } else {
+                       bt_info.is_discovering = TRUE;
+                       bt_info.is_discovery_cancel = FALSE;
+                       _bluetooth_internal_discovery_started_cb();
+               }
+       } else if (g_strcmp0(property, "Discoverable") == 0) {
+               gboolean discoverable = g_value_get_boolean(value);
+               if (discoverable == FALSE) {
+                       GValue timeout = { 0 };
+                       g_value_init(&timeout, G_TYPE_UINT);
+                       g_value_set_uint(&timeout, 0);
+
+                       dbus_g_proxy_call_no_reply(adapter, "SetProperty",
+                                                  G_TYPE_STRING, "DiscoverableTimeout",
+                                                  G_TYPE_VALUE, &timeout,
+                                                  G_TYPE_INVALID);
+
+                       g_value_unset(&timeout);
+
+                       __bluetooth_internal_mode_changed_cb(adapter,
+                                               "connectable", user_data);
+               } else {
+                       if (__bluetooth_get_timeout_value(adapter) == 0)
+                               __bluetooth_internal_mode_changed_cb(adapter,
+                                                       "discoverable",
+                                                       user_data);
+               }
+       } else if (g_strcmp0(property, "DiscoverableTimeout") == 0) {
+               guint timeout = g_value_get_uint(value);
+               if (timeout == 0) {
+                       if (__bluetooth_get_discoverable_value(adapter) == TRUE)
+                               __bluetooth_internal_mode_changed_cb(adapter,
+                                                       "discoverable",
+                                                       user_data);
+                       else
+                               __bluetooth_internal_mode_changed_cb(adapter,
+                                                       "connectable",
+                                                       user_data);
+               } else {
+                       __bluetooth_internal_mode_changed_cb(adapter,
+                                               "limited_discoverable",
+                                               user_data);
+               }
+       }
+
+       DBG("-");
+}
+
+static void __bluetooth_internal_remote_device_found(DBusGProxy *adapter,
+                                                       const char *address,
+                                                       GHashTable *hash,
+                                                       gpointer user_data)
+{
+       GValue *value;
+       const gchar *name;
+       guint remote_class;
+       gint rssi;
+       gboolean is_name_include = FALSE;
+       gboolean paired = FALSE;
+
+       DBG("+ address[%s]", address);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Name");
+               is_name_include = value ? TRUE : FALSE;
+               name = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Class");
+               remote_class = value ? g_value_get_uint(value) : 0;
+
+               value = g_hash_table_lookup(hash, "RSSI");
+               rssi = value ? g_value_get_int(value) : 0;
+
+               value = g_hash_table_lookup(hash, "Paired");
+               paired = value ? g_value_get_boolean(value) : FALSE;
+
+               if (is_name_include) {
+                       _bluetooth_internal_remote_device_name_updated_cb(address,
+                                                                       name,
+                                                                       rssi,
+                                                                       remote_class,
+                                                                       paired);
+               } else {
+                       _bluetooth_internal_remote_device_found_cb(address,
+                                                               remote_class,
+                                                               rssi, paired);
+               }
+       }
+
+       DBG("-");
+}
+
+static int __bluetooth_internal_add_signal()
+{
+       GPtrArray *gp_array = NULL;
+       GError *error = NULL;
+
+       if (bt_info.adapter_proxy == NULL) {
+               ERR("Add Signal Failed!!!");
+               return -1;
+       }
+
+       dbus_g_object_register_marshaller(marshal_VOID__STRING, G_TYPE_NONE,
+                                               G_TYPE_STRING, G_TYPE_INVALID);
+       dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT,
+                                               G_TYPE_NONE, G_TYPE_STRING,
+                                               G_TYPE_UINT, G_TYPE_INT,
+                                               G_TYPE_INVALID);
+       dbus_g_object_register_marshaller(marshal_VOID__STRING_STRING,
+                                               G_TYPE_NONE, G_TYPE_STRING,
+                                               G_TYPE_STRING, G_TYPE_INVALID);
+       dbus_g_object_register_marshaller(marshal_VOID__UINT, G_TYPE_NONE,
+                                               G_TYPE_UINT, G_TYPE_INVALID);
+       dbus_g_object_register_marshaller(marshal_VOID__STRING_STRING_INT,
+                                               G_TYPE_NONE, G_TYPE_STRING,
+                                               G_TYPE_STRING, G_TYPE_INT,
+                                               G_TYPE_INVALID);
+       dbus_g_object_register_marshaller(marshal_VOID__STRING_STRING_INT_UINT,
+                                               G_TYPE_NONE, G_TYPE_STRING,
+                                               G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT,
+                                               G_TYPE_INVALID);
+
+       dbus_g_object_register_marshaller(marshal_VOID__STRING_BOXED,
+                                         G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+
+       dbus_g_proxy_add_signal(bt_info.adapter_proxy, "PropertyChanged",
+                               G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(bt_info.adapter_proxy, "PropertyChanged",
+                                   G_CALLBACK(__bluetooth_internal_adapter_property_changed),
+                                       NULL, NULL);
+
+       dbus_g_proxy_add_signal(bt_info.adapter_proxy, "DeviceFound",
+                               G_TYPE_STRING, dbus_g_type_get_map("GHashTable",
+                                               G_TYPE_STRING, G_TYPE_VALUE),
+                               G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(bt_info.adapter_proxy, "DeviceFound",
+                                   G_CALLBACK(__bluetooth_internal_remote_device_found),
+                                       NULL, NULL);
+
+       dbus_g_proxy_add_signal(bt_info.adapter_proxy, "DeviceCreated",
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(bt_info.adapter_proxy, "DeviceCreated",
+                                   G_CALLBACK(__bluetooth_internal_device_created),
+                                       NULL, NULL);
+
+       dbus_g_proxy_add_signal(bt_info.adapter_proxy, "DeviceRemoved",
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(bt_info.adapter_proxy, "DeviceRemoved",
+                                   G_CALLBACK(__bluetooth_internal_device_removed),
+                                       NULL, NULL);
+
+       _bluetooth_network_server_add_signal();
+
+       _bluetooth_network_client_add_filter();
+
+       dbus_g_proxy_call(bt_info.adapter_proxy, "ListDevices", &error,
+                         G_TYPE_INVALID,
+                         dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+                         &gp_array, G_TYPE_INVALID);
+
+       if (error == NULL) {
+               if (gp_array != NULL) {
+                       int i;
+                       for (i = 0; i < gp_array->len; i++) {
+                               gchar *gp_path = g_ptr_array_index(gp_array, i);
+
+                               if (gp_path != NULL) {
+                                       if (_bluetooth_internal_add_device(gp_path))
+                                               DBG("Newly added device [%s]", gp_path);
+                               }
+                               g_free(gp_path);
+                       }
+                       g_ptr_array_free(gp_array, TRUE);
+               }
+       } else {
+               DBG("ListDevices error: [%s]", error->message);
+               g_error_free(error);
+               return -2;
+       }
+
+       return 0;
+}
+
+static int __bluetooth_internal_remove_signal(void)
+{
+       if (bt_info.adapter_proxy == NULL) {
+               DBG("Removed Signal Failed!!!");
+               return -1;
+       }
+
+       dbus_g_proxy_disconnect_signal(bt_info.adapter_proxy, "PropertyChanged",
+                                      G_CALLBACK(__bluetooth_internal_adapter_property_changed),
+                                       NULL);
+
+       dbus_g_proxy_disconnect_signal(bt_info.adapter_proxy, "DeviceFound",
+                                      G_CALLBACK(__bluetooth_internal_remote_device_found), NULL);
+
+       dbus_g_proxy_disconnect_signal(bt_info.adapter_proxy, "DeviceCreated",
+                                      G_CALLBACK(__bluetooth_internal_device_created), NULL);
+
+       dbus_g_proxy_disconnect_signal(bt_info.adapter_proxy, "DeviceRemoved",
+                                      G_CALLBACK(__bluetooth_internal_device_removed), NULL);
+
+       _bluetooth_network_server_remove_signal();
+
+       _bluetooth_network_client_remove_filter();
+
+       if (bt_info.device_proxy_list != NULL) {
+               int i, list_length = 0;
+               DBusGProxy *device_proxy = NULL;
+
+               list_length = g_list_length(bt_info.device_proxy_list);
+
+               for (i = 0; i < list_length; i++) {
+                       device_proxy = g_list_nth_data(bt_info.device_proxy_list, i);
+                       __bluetooth_internal_remove_device_signal(device_proxy);
+                       g_object_unref(device_proxy);
+                       device_proxy = NULL;
+               }
+               g_list_free(bt_info.device_proxy_list);
+               bt_info.device_proxy_list = NULL;
+       }
+
+       g_object_unref(bt_info.adapter_proxy);
+       bt_info.adapter_proxy = NULL;
+
+       return 0;
+}
+
+int bluetooth_internal_set_adapter_path(const char *adapter_path)
+{
+       DBG("+\n");
+
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       char *name = NULL;
+       gboolean discovering = FALSE;
+
+       if (adapter_path == NULL) {
+               DBG("Invalid param");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("Get default adapter : [%s]", adapter_path);
+
+       g_strlcpy(bt_info.adapter_path, adapter_path, BT_ADAPTER_OBJECT_PATH_MAX);
+
+       bt_info.adapter_proxy =
+           dbus_g_proxy_new_for_name(bt_info.conn, "org.bluez", bt_info.adapter_path,
+                                       "org.bluez.Adapter");
+       if (!bt_info.adapter_proxy) {
+               AST("Could not create a dbus proxy");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /*Implementing the Adpater.GetProperties Synchronous.   This change is
+          required because, before giving the BLUETOOTH_EVENT_ENABLED event cb we
+          have to make sure that device add is filled. Otherwise if application calls
+          bluetooth_get_local_address(), from the event cb, we will return 00:00:00:00:00.
+        */
+
+       DBG("GetProperties Synchronous Implementation\n");
+
+       dbus_g_proxy_call(bt_info.adapter_proxy, "GetProperties", NULL,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Name");
+               name = (char *)(value ? g_value_get_string(value) : NULL);
+
+               value = g_hash_table_lookup(hash, "Discovering");
+               discovering = value ? g_value_get_boolean(value) : 0;
+       }
+
+       bt_info.is_discovering = discovering;
+
+       if (name && strlen(bt_info.bt_local_name.name) > 0 &&
+                       strcmp(name, bt_info.bt_local_name.name) != 0) {
+               DBG("store name : [%s] , bluez name [%s]", bt_info.bt_local_name.name, name);
+       }
+       /*Signal register*/
+       if (__bluetooth_internal_add_signal() < 0) {
+               AST("Can not add DM signal");
+       }
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bluetooth_internal_adapter_added_cb(DBusGProxy *manager_proxy,
+                                                 const char *adapter_path, gpointer user_data)
+{
+       DBG("<<<<<<< SIGNAL AdapterAdded >>>>>>>>>");
+       DBG("Adapter added [%s]", adapter_path);
+
+       if (strstr(adapter_path, "hci0")) {
+               if (bluetooth_internal_set_adapter_path(adapter_path) == BLUETOOTH_ERROR_NONE) {
+                       bt_info.bt_adapter_state = BLUETOOTH_ADAPTER_ENABLED;
+                       DBG("Send event to application");
+                       _bluetooth_internal_enabled_cb();
+               }
+       } else {
+               DBG("path is not include hci0");
+       }
+}
+
+static void __bluetooth_internal_adapter_removed_cb(DBusGProxy *manager_proxy,
+                                               const char *adapter_path,
+                                                gpointer user_data)
+{
+       DBG("<<<<<<< SIGNAL AdapterRemoved >>>>>>>>>");
+       DBG("Adapter removed [%s]", adapter_path);
+
+       if (strstr(adapter_path, "hci0")) {
+               __bluetooth_internal_remove_signal();
+       } else {
+               DBG("path is not include hci0");
+       }
+}
+
+static void __bluetooth_internal_name_owner_changed(DBusGProxy *dbus_proxy, const char *name,
+                                                 const char *prev, const char *new,
+                                                       gpointer user_data)
+{
+       DBG("<<<<<<< SIGNAL NameOwnerChanged >>>>>>>>>\n");
+
+       DBG("Name str = %s", name);
+
+       if (g_strcmp0(name, "org.bluez") == 0 && *new == '\0') {
+               DBG("BlueZ is terminated");
+               bt_info.bt_adapter_state = BLUETOOTH_ADAPTER_DISABLED;
+
+               DBG("Send event to application");
+               _bluetooth_internal_disabled_cb();
+       } else if (g_strcmp0(name, "org.bluez.frwk_agent") == 0) {
+               bt_info.agent_proxy = NULL;
+               bt_info.agent_proxy = dbus_g_proxy_new_for_name(bt_info.conn,
+                                                               "org.bluez.frwk_agent",
+                                                               "/org/bluez/agent/frwk_agent",
+                                                               "org.bluez.Agent");
+               if (!bt_info.agent_proxy) {
+                       AST("Could not create a agent dbus proxy");
+               }
+       }
+}
+
+static void __bluetooth_internal_mode_changed_cb(DBusGProxy *object, const char *changed_mode,
+                                               gpointer user_data)
+{
+
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       DBG("+\n");
+
+       DBG("Mode changed [%s]\n", changed_mode);
+
+       if (!bt_internal_info || !bt_internal_info->bt_cb_ptr)
+               return;
+
+       if (strlen(changed_mode) == 0) {
+               DBG("ModeChanged get mode failed\n");
+               bt_event.event = BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED;
+               bt_event.result = BLUETOOTH_ERROR_INTERNAL;
+               bt_event.param_data = NULL;
+       } else {
+               int scanEnable = 0;
+               bt_event.event = BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED;
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+               if (strcmp(changed_mode, "connectable") == 0)
+                       scanEnable = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+               else if (strcmp(changed_mode, "discoverable") == 0)
+                       scanEnable = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
+               else if (strcmp(changed_mode, "limited_discoverable") == 0)
+                       scanEnable = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
+               else
+                       scanEnable = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+
+               bt_event.param_data = &scanEnable;
+       }
+
+       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                               bt_internal_info->user_data);
+
+       DBG("-\n");
+}
+
+static void __bluetooth_internal_connection_changed_cb(gboolean connected,
+                                               const bluetooth_device_address_t *device_addr)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+");
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       bt_event.event = connected ? BLUETOOTH_EVENT_DEVICE_CONNECTED :
+                                                       BLUETOOTH_EVENT_DEVICE_DISCONNECTED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = (void *)device_addr;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       DBG("-");
+}
+
+static void __bluetooth_internal_authorized_cb(gboolean authorized,
+                                               const bluetooth_device_address_t *device_addr)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+");
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       bt_event.event = authorized ? BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
+                                                               BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = (void *)device_addr;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       DBG("-");
+}
+
+
+static int __bluetooth_get_default_name(char *default_dev_name, int size)
+{
+       /* Getting Phone name starts */
+       FILE *fp = NULL;
+       char buff[BT_FILE_BUFFER_MAX+1];
+       char *name = NULL;
+       char *token = NULL;
+       char *ptr = NULL;
+       size_t sz = 0;
+       int ret = 0;
+
+       if (default_dev_name == NULL) {
+               DBG("Invalid parameter");
+               return -1;
+       }
+       ret = __bluetooth_internal_store_get_value(BT_SETTING_DEVICE_NAME,
+                                BT_STORE_STRING, size,
+                                (void *)default_dev_name);
+
+       if (ret < 0) {
+               DBG("get value fail: %d", ret);
+               return -1;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size) {
+       int ret = 0;
+       char phone_no[BT_PHONE_NUM_LEN] = { 0 };
+
+       DBG("+");
+
+       if (dev_name == NULL)
+               return -1;
+
+       ret = __bluetooth_get_default_name(dev_name->name, size);
+
+       if (ret < 0) {
+               DBG("Fail to get default name: %d", ret);
+               return -1;
+       }
+
+       DBG("-");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+void _bluetooth_internal_session_init(void)
+{
+       GError *err = NULL;
+       const char *adapter_path = NULL;
+       int ret = 0;
+
+       DBG("+\n");
+       if (bt_info.application_pid == 0) {
+               DBG("Not yet session initialized, so init session");
+               g_type_init();
+               bt_info.application_pid = getpid();
+
+               bt_info.conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+               if (!bt_info.conn) {
+                       AST("ERROR: Can't get on system bus [%s]", err->message);
+                       g_error_free(err);
+                       return;
+               }
+
+               bt_info.dbus_proxy = dbus_g_proxy_new_for_name(bt_info.conn,
+                                                              DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+                                                               DBUS_INTERFACE_DBUS);
+               if (!bt_info.dbus_proxy) {
+                       AST("Could not create a dbus proxy");
+               } else {
+                       dbus_g_proxy_add_signal(bt_info.dbus_proxy, "NameOwnerChanged",
+                                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+                                               G_TYPE_INVALID);
+
+                       dbus_g_proxy_connect_signal(bt_info.dbus_proxy, "NameOwnerChanged",
+                                                 G_CALLBACK(__bluetooth_internal_name_owner_changed),
+                                                       NULL, NULL);
+               }
+
+               bt_info.manager_proxy = dbus_g_proxy_new_for_name(bt_info.conn, "org.bluez", "/",
+                                                                       "org.bluez.Manager");
+               if (!bt_info.manager_proxy) {
+                       AST("Could not create a dbus proxy");
+                       return;
+               }
+
+               bt_info.agent_proxy = dbus_g_proxy_new_for_name(bt_info.conn,
+                                                               "org.bluez.frwk_agent",
+                                                               "/org/bluez/agent/frwk_agent",
+                                                               "org.bluez.Agent");
+               if (!bt_info.agent_proxy) {
+                       AST("Could not create a agent dbus proxy");
+               }
+
+               ret = _bluetooth_internal_get_value(BT_STORE_NAME);
+               ret = _bluetooth_internal_get_value(BT_STORE_DISCOVERABLE_MODE);
+
+               dbus_g_proxy_add_signal(bt_info.manager_proxy, "AdapterAdded",
+                                       DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+               dbus_g_proxy_connect_signal(bt_info.manager_proxy, "AdapterAdded",
+                                           G_CALLBACK(__bluetooth_internal_adapter_added_cb), NULL,
+                                               NULL);
+
+               dbus_g_proxy_add_signal(bt_info.manager_proxy, "AdapterRemoved",
+                                       DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+               dbus_g_proxy_connect_signal(bt_info.manager_proxy, "AdapterRemoved",
+                                           G_CALLBACK(__bluetooth_internal_adapter_removed_cb),
+                                               NULL, NULL);
+
+               if (!dbus_g_proxy_call(bt_info.manager_proxy, "DefaultAdapter", &err,
+                                      G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &adapter_path,
+                                       G_TYPE_INVALID)) {
+                       if (err != NULL) {
+                               DBG("DefaultAdapter err:[%s]", err->message);
+                               g_error_free(err);
+                       }
+                       bt_info.bt_adapter_state = BLUETOOTH_ADAPTER_DISABLED;
+               } else {
+                       if (adapter_path && strlen(adapter_path) < 50) {
+                               bt_info.bt_adapter_state = BLUETOOTH_ADAPTER_ENABLED;
+                               bluetooth_internal_set_adapter_path(adapter_path);
+                       } else {
+                               AST("Get default adapter, but there is error");
+                               return;
+                       }
+
+               }
+
+               DBG("Session inited : pid (%d)", bt_info.application_pid);
+       }
+
+       DBG("-\n");
+
+}
+
+void bluetooth_internal_session_deinit(void)
+{
+       DBG("+\n");
+
+       if (bt_info.dbus_proxy != NULL) {
+               dbus_g_proxy_disconnect_signal(bt_info.dbus_proxy, "NameOwnerChanged",
+                                              G_CALLBACK(__bluetooth_internal_name_owner_changed),
+                                               NULL);
+
+               g_object_unref(bt_info.dbus_proxy);
+       } else {
+               DBG("bt_info.dbus_proxy is NULL\n");
+       }
+
+       if (bt_info.manager_proxy != NULL) {
+               dbus_g_proxy_disconnect_signal(bt_info.manager_proxy, "AdapterAdded",
+                                              G_CALLBACK(__bluetooth_internal_adapter_added_cb),
+                                               NULL);
+
+               dbus_g_proxy_disconnect_signal(bt_info.manager_proxy, "AdapterRemoved",
+                                              G_CALLBACK(__bluetooth_internal_adapter_removed_cb),
+                                               NULL);
+
+               g_object_unref(bt_info.manager_proxy);
+       } else {
+               DBG("bt_info.manager_proxy is NULL\n");
+       }
+
+       if (bt_info.agent_proxy) {
+               g_object_unref(bt_info.agent_proxy);
+       }
+
+       if (bt_info.bt_change_state_timer) {
+               g_source_remove(bt_info.bt_change_state_timer);
+               bt_info.bt_change_state_timer = 0;
+       }
+
+       if (bt_info.bt_discovery_req_timer) {
+               g_source_remove(bt_info.bt_discovery_req_timer);
+               bt_info.bt_discovery_req_timer = 0;
+       }
+
+       if (bt_info.bt_bonding_req_timer) {
+               g_source_remove(bt_info.bt_bonding_req_timer);
+               bt_info.bt_bonding_req_timer = 0;
+       }
+
+       __bluetooth_internal_remove_signal();
+
+       if (bt_info.conn) {
+               dbus_g_connection_unref(bt_info.conn);
+               bt_info.conn = NULL;
+       }
+
+       bt_info.application_pid = 0;
+
+       DBG("-\n");
+}
+
+BT_EXPORT_API int bluetooth_is_supported(void)
+{
+       int is_supported = 0;
+       int len = 0;
+       int fd = -1;
+       rfkill_event event;
+
+       DBG("+\n");
+
+        fd = open(RFKILL_NODE, O_RDONLY);
+        if (fd < 0) {
+               DBG("Fail to open RFKILL node");
+               return BLUETOOTH_ERROR_INTERNAL;
+        }
+
+        if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
+               DBG("Fail to set RFKILL node to non-blocking");
+               close(fd);
+               return BLUETOOTH_ERROR_INTERNAL;
+        }
+
+        while (1) {
+                len = read(fd, &event, sizeof(event));
+                if (len < 0) {
+                        DBG("Fail to read events");
+                        break;
+                }
+
+                if (len != RFKILL_EVENT_SIZE) {
+                        DBG("The size is wrong\n");
+                        continue;
+                }
+
+               if (event.type == RFKILL_TYPE_BLUETOOTH) {
+                       is_supported = 1;
+                       break;
+               }
+        }
+
+        close(fd);
+
+       DBG("supported: %d\n", is_supported);
+
+       DBG("-\n");
+
+       return is_supported;
+}
+
+BT_EXPORT_API int bluetooth_allow_service(gboolean allow)
+{
+       DBG("+\n");
+
+       /* Vconf value 1: Restrict to use BT service
+           Vconf value 0: Allow to use BT service */
+       if (vconf_set_bool(BT_MEMORY_KEY_RESTRICTION, !allow))
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+
+       if (allow == FALSE)
+               bluetooth_disable_adapter();
+
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+
+BT_EXPORT_API int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)
+{
+       _bluetooth_internal_session_init();
+
+       bt_info.bt_cb_ptr = callback_ptr;
+       bt_info.user_data = user_data;
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_unregister_callback(void)
+{
+       bluetooth_internal_session_deinit();
+
+       bt_info.bt_cb_ptr = NULL;
+
+       return BLUETOOTH_ERROR_NONE;
+}
diff --git a/lib/bluetooth-api-common.h b/lib/bluetooth-api-common.h
new file mode 100644 (file)
index 0000000..5fd752e
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 _BLUETOOTH_API_COMMON_H_
+#define _BLUETOOTH_API_COMMON_H_
+
+#include <stdbool.h>
+#include <string.h>
+#include <malloc.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+#include <glib.h>
+
+#include <dlog.h>
+#include <vconf-keys.h>
+
+#include "bluetooth-api.h"
+
+#define BT_FRWK        "BT_FRWK"
+
+#ifndef BT_EXPORT_API
+#define BT_EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#define PRT(level, fmt, function, args...) \
+       SLOG(LOG_DEBUG, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define DBG(fmt, args...) \
+       SLOG(LOG_DEBUG, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define ERR(fmt, args...) \
+       SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
+#define AST(fmt, args...) \
+       SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+#define BT_STORE_PREFIX "db/bluetooth/"
+#define BT_STORE_LOCAL_NAME_PATH BT_STORE_PREFIX"localname"
+#define BT_STORE_VISIBILITY_PATH BT_STORE_PREFIX"visibility"
+#define BT_STORE_VISIBILITY_TIME_PATH BT_STORE_PREFIX"visibility_time"
+#define BT_MEMORY_KEY_RESTRICTION "memory/bluetooth/restriction"
+#define BT_SETTING_DEVICE_NAME "db/setting/device_name"
+
+#define HCI_SCAN_ENABLE_NO_SCAN                                         0x00
+#define HCI_SCAN_ENABLE_INQUIRY_ONLY                                    0x01
+#define HCI_SCAN_ENABLE_PAGE_ONLY                                       0x02
+#define HCI_SCAN_ENABLE_PAGE_AND_INQUIRY                                0x03
+
+#define BT_ADDRESS_STRING_SIZE 18
+#define BT_ADAPTER_OBJECT_PATH_MAX 50
+
+#define RFKILL_NODE "/dev/rfkill"
+
+#define BLUETOOTH_UUID_POSTFIX "0000-1000-8000-00805f9b34fb"
+
+#define RFKILL_EVENT_SIZE 8
+
+#define BT_PHONE_NUM_LEN 50
+#define BT_FILE_BUFFER_MAX 256
+
+typedef enum {
+       BT_STORE_BOOLEAN,
+       BT_STORE_INT,
+       BT_STORE_STRING,
+} bt_store_type_t;
+
+typedef enum {
+       BT_STORE_NAME,
+       BT_STORE_DISCOVERABLE_MODE,
+} bt_store_key_t;
+
+
+typedef enum {
+        RFKILL_TYPE_ALL = 0,
+        RFKILL_TYPE_WLAN,
+        RFKILL_TYPE_BLUETOOTH,
+        RFKILL_TYPE_UWB,
+        RFKILL_TYPE_WIMAX,
+        RFKILL_TYPE_WWAN,
+        RFKILL_TYPE_GPS,
+        RFKILL_TYPE_FM,
+        NUM_RFKILL_TYPES,
+} rfkill_type;
+
+typedef struct {
+       unsigned int idx;
+       unsigned char type;
+       unsigned char op;
+       unsigned char soft;
+       unsigned char hard;
+} rfkill_event;
+
+typedef struct {
+       const char *match;
+       unsigned short match_uuid16;
+       const char *match_name;
+       unsigned int match_handle;
+} match_entries_t;
+
+typedef struct {
+       match_entries_t *search_match_ptr;
+       bluetooth_device_address_t remote_device_addr;
+       int success_search_index;
+} bt_info_for_searching_support_service_t;
+
+/**
+ *   @internal
+ *   This structure has information about BT
+ */
+
+typedef struct {
+       pid_t application_pid;                  /**< Application process id */
+       bluetooth_cb_func_ptr bt_cb_ptr;        /**< Function pointer for
+                                               responsing event to application */
+
+       DBusGConnection *conn;                  /**< DBUS bus connection for bluez ipc */
+       DBusConnection *sys_conn;
+       DBusGProxy *dbus_proxy;                 /**< DBUS proxy */
+       DBusGProxy *manager_proxy;              /**< bluez manager ipc proxy */
+       DBusGProxy *adapter_proxy;              /**< bluez adapter ipc proxy */
+       DBusGProxy *agent_proxy;                /**< Agent ipc proxy */
+       DBusGProxy *network_server_proxy;
+       char adapter_path[BT_ADAPTER_OBJECT_PATH_MAX];  /*bluez adapter path*/
+       GList *device_proxy_list;                       /**< bluez device ipc proxy list */
+
+       bluetooth_adapter_state_t bt_adapter_state;     /*Current bluetooth state*/
+       guint bt_change_state_timer;                    /**< g_timeout for checking timeout
+                                                       of BT status change */
+       bluetooth_device_name_t bt_local_name;          /*Local bluetooth device name*/
+
+       guint bt_discovery_req_timer;                   /**< g_timeout for checking timeout of
+                                                       BT discovery request */
+       gboolean is_discovery_req;                      /**< application request discovery or not*/
+       gboolean is_discovering;                        /**< Currently discovery state */
+       gboolean is_discovery_cancel;                   /**< discovery cancel is requested */
+
+       guint bt_bonding_req_timer;                     /**< g_timeout for checking timeout of
+                                                                BT discovery request */
+       gboolean is_bonding_req;                        /*application request bonding or not*/
+       gboolean is_headset_bonding;
+       char bt_bonding_req_addrstr[BT_ADDRESS_STRING_SIZE]; /**< bluetooth device address which
+                                                       currently bonding is requested to */
+       gboolean is_headset_pin_req;                    /*application request bonding or not*/
+       bt_info_for_searching_support_service_t info_for_searching_support_service;  /**< Service
+                                                               Seaching Session Infomation */
+       void *user_data;
+
+} bt_info_t;
+
+bt_info_t *_bluetooth_internal_get_information(void);
+void _bluetooth_internal_session_init(void);
+
+bool _bluetooth_internal_is_adapter_enabled(void);
+
+DBusGProxy *_bluetooth_internal_find_device_by_path(const char *dev_path);
+DBusGProxy *_bluetooth_internal_add_device(const char *path);
+
+void _bluetooth_internal_print_bluetooth_device_address_t(const  bluetooth_device_address_t  *addr);
+void _bluetooth_internal_convert_addr_string_to_addr_type(bluetooth_device_address_t *addr,
+                                                       const char *address);
+void _bluetooth_internal_addr_type_to_addr_string(char *address,
+                                               const bluetooth_device_address_t *addr);
+void _bluetooth_internal_divide_device_class(bluetooth_device_class_t *device_class,
+                                                                       unsigned int cod);
+void _bluetooth_internal_device_path_to_address(const char *device_path,
+                                              char *device_address);
+
+int _bluetooth_internal_get_value(bt_store_key_t key);
+int _bluetooth_internal_set_value(bt_store_key_t key);
+
+int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size);
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /*_BLUETOOTH_API_COMMON_H_*/
+
diff --git a/lib/bluetooth-api.h b/lib/bluetooth-api.h
new file mode 100644 (file)
index 0000000..d67a95e
--- /dev/null
@@ -0,0 +1,2515 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 _BLUETOOTH_API_H_
+#define _BLUETOOTH_API_H_
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @defgroup BLUETOOTHFW BluetoothFW
+ *
+ * A base library for bluetooth framework
+ *
+ * @addtogroup BLUETOOTHFW
+ * @{
+ */
+
+#define BLUETOOTH_ADDRESS_LENGTH            6 /**< This specifies bluetooth device address length */
+#define BLUETOOTH_INTERFACE_NAME_LENGTH        16
+#define BLUETOOTH_DEVICE_NAME_LENGTH_MAX       248 /**< This specifies maximum device name length */
+
+#define BLUETOOTH_MAX_SERVICES_FOR_DEVICE       40  /**< This specifies maximum number of services
+                                                       a device can support */
+
+#define BLUETOOTH_UUID_STRING_MAX 50
+
+/**
+ * This is Bluetooth Connected event role
+ */
+#define RFCOMM_ROLE_SERVER 1
+#define RFCOMM_ROLE_CLIENT 2
+
+/**
+ * This is Bluetooth error code
+ */
+#define BLUETOOTH_ERROR_BASE                   ((int)0)                /**< Error code base */
+
+#define BLUETOOTH_ERROR_NONE                   ((int)0)                /**< No error #0 */
+#define BLUETOOTH_ERROR_CANCEL                 ((int)BLUETOOTH_ERROR_BASE - 0x01)
+                                                               /**< cancelled */
+#define BLUETOOTH_ERROR_INVALID_CALLBACK       ((int)BLUETOOTH_ERROR_BASE - 0x02)
+                                                               /**< Callback error */
+#define BLUETOOTH_ERROR_INVALID_PARAM          ((int)BLUETOOTH_ERROR_BASE - 0x03)
+                                                               /**< invalid paramerror */
+#define BLUETOOTH_ERROR_INVALID_DATA           ((int)BLUETOOTH_ERROR_BASE - 0x04)
+                                                               /**< invalid data error */
+#define BLUETOOTH_ERROR_MEMORY_ALLOCATION      ((int)BLUETOOTH_ERROR_BASE - 0x05)
+                                                               /**< Memory allocation error */
+#define BLUETOOTH_ERROR_OUT_OF_MEMORY          ((int)BLUETOOTH_ERROR_BASE - 0x06)
+                                                               /**< out of memory error */
+#define BLUETOOTH_ERROR_TIMEOUT                ((int)BLUETOOTH_ERROR_BASE - 0x07)
+                                                               /**< timeout error */
+#define BLUETOOTH_ERROR_NO_RESOURCES           ((int)BLUETOOTH_ERROR_BASE - 0x08)
+                                                               /**< No resource error */
+#define BLUETOOTH_ERROR_INTERNAL               ((int)BLUETOOTH_ERROR_BASE - 0x09)
+                                                               /**< internal error */
+#define BLUETOOTH_ERROR_NOT_SUPPORT            ((int)BLUETOOTH_ERROR_BASE - 0x0a)
+                                                               /**< Not supported error */
+#define BLUETOOTH_ERROR_DEVICE_NOT_ENABLED     ((int)BLUETOOTH_ERROR_BASE - 0x0b)
+                                                               /**< Operation is failed because
+                                                               of not enabled BT Adapter */
+#define BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED ((int)BLUETOOTH_ERROR_BASE - 0x0c)
+                                                               /**< Enabling is failed because of
+                                                               already enabled BT Adapter */
+#define BLUETOOTH_ERROR_DEVICE_BUSY            ((int)BLUETOOTH_ERROR_BASE - 0x0d)
+                                                               /**< Operation is failed because of
+                                                               other on going operation */
+#define BLUETOOTH_ERROR_ACCESS_DENIED          ((int)BLUETOOTH_ERROR_BASE - 0x0e)
+                                                               /**< access denied error */
+#define BLUETOOTH_ERROR_MAX_CLIENT             ((int)BLUETOOTH_ERROR_BASE - 0x0f)
+                                                               /**< max client error */
+#define BLUETOOTH_ERROR_NOT_FOUND              ((int)BLUETOOTH_ERROR_BASE - 0x10)
+                                                               /**< not found error */
+#define BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR   ((int)BLUETOOTH_ERROR_BASE - 0x11)
+                                                               /**< service search fail */
+#define BLUETOOTH_ERROR_PARING_FAILED          ((int)BLUETOOTH_ERROR_BASE - 0x12)
+                                                               /**< pairing failed error */
+#define BLUETOOTH_ERROR_NOT_PAIRED             ((int)BLUETOOTH_ERROR_BASE - 0x13)
+                                                               /**< Not paired error */
+#define BLUETOOTH_ERROR_SERVICE_NOT_FOUND      ((int)BLUETOOTH_ERROR_BASE - 0x14)
+                                                               /**< no service error */
+#define BLUETOOTH_ERROR_NOT_CONNECTED          ((int)BLUETOOTH_ERROR_BASE - 0x15)
+                                                               /**< no connection error */
+#define BLUETOOTH_ERROR_ALREADY_CONNECT        ((int)BLUETOOTH_ERROR_BASE - 0x16)
+                                                               /**< alread connected error */
+#define BLUETOOTH_ERROR_CONNECTION_BUSY        ((int)BLUETOOTH_ERROR_BASE - 0x17)
+                                                               /**< connection busy error */
+#define BLUETOOTH_ERROR_CONNECTION_ERROR       ((int)BLUETOOTH_ERROR_BASE - 0x18)
+                                                               /**< connection error */
+#define BLUETOOTH_ERROR_MAX_CONNECTION         ((int)BLUETOOTH_ERROR_BASE - 0x19)
+                                                               /**< max connection error*/
+#define BLUETOOTH_ERROR_NOT_IN_OPERATION       ((int)BLUETOOTH_ERROR_BASE - 0x1a)
+                                                               /**< Not in operation */
+#define BLUETOOTH_ERROR_CANCEL_BY_USER         ((int)BLUETOOTH_ERROR_BASE - 0x1b)
+                                                               /**< Cancelled by user */
+#define BLUETOOTH_ERROR_REGISTRATION_FAILED    ((int)BLUETOOTH_ERROR_BASE - 0x1c)
+                                                               /**< Service record registration failed */
+#define BLUETOOTH_ERROR_IN_PROGRESS            ((int)BLUETOOTH_ERROR_BASE - 0x1d)
+                                                               /**< Operation in progress */
+#define BLUETOOTH_ERROR_AUTHENTICATION_FAILED  ((int)BLUETOOTH_ERROR_BASE - 0x1e)
+                                                               /**< authentication failed error when paring*/
+#define BLUETOOTH_ERROR_HOST_DOWN              ((int)BLUETOOTH_ERROR_BASE - 0x1f)
+                                                               /**< Remote host is down */
+#define BLUETOOTH_ERROR_END_OF_DEVICE_LIST     ((int)BLUETOOTH_ERROR_BASE - 0x20)
+                                                               /**< End of device list */
+
+#define BLUETOOTH_ERROR_AGENT_ALREADY_EXIST      ((int)BLUETOOTH_ERROR_BASE - 0x21)
+                                                               /**< Obex agent already exists */
+#define BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST    ((int)BLUETOOTH_ERROR_BASE - 0x22)
+                                                               /**< Obex agent does not exist */
+/**
+ * This is Bluetooth device address type, fixed to 6 bytes ##:##:##:##:##:##
+ */
+typedef struct {
+       unsigned char addr[BLUETOOTH_ADDRESS_LENGTH];
+} bluetooth_device_address_t;
+
+/**
+ * This is Bluetooth device name type, maximum size of Bluetooth device name is 248 bytes
+ */
+typedef struct {
+       char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1];
+} bluetooth_device_name_t;
+
+/**
+ * Adapter state
+ */
+typedef enum {
+       BLUETOOTH_ADAPTER_DISABLED,         /**< Bluetooth adapter is disabled */
+       BLUETOOTH_ADAPTER_ENABLED,          /**< Bluetooth adapter is enabled */
+       BLUETOOTH_ADAPTER_CHANGING_ENABLE,  /**< Bluetooth adapter is currently enabling */
+       BLUETOOTH_ADAPTER_CHANGING_DISABLE, /**< Bluetooth adapter is currently disabling */
+} bluetooth_adapter_state_t;
+
+/**
+ * Discoverable mode
+ */
+typedef enum {
+       BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE,         /**< Non discoverable mode */
+       /*Changed the order to make it compatable with old method */
+       BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,/**< Discoverable mode */
+       BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE,
+                                                        /**< Discoverable mode with time limit
+                                                       After specific timeout, it is changed
+                                                               to non discoverable mode */
+} bluetooth_discoverable_mode_t;
+
+/**
+ * Network connect mode
+ */
+typedef enum {
+       BLUETOOTH_NETWORK_PANU_ROLE,
+                                /**< PAN user */
+       BLUETOOTH_NETWORK_NAP_ROLE,/**< Network Access Point */
+       BLUETOOTH_NETWORK_GN_ROLE,  /**< Group ad-hoc Network */
+       BLUETOOTH_NETWORK_CUSTOM_UUID, /**< Custom role */
+} bluetooth_network_role_t;
+
+#define BLUETOOTH_EVENT_BASE            ((int)(0x0000))                /**< No event */
+#define BLUETOOTH_EVENT_GAP_BASE        ((int)(BLUETOOTH_EVENT_BASE + 0x0010))
+                                                               /**< Base ID for GAP Event */
+#define BLUETOOTH_EVENT_SDP_BASE        ((int)(BLUETOOTH_EVENT_GAP_BASE + 0x0020))
+                                                               /**< Base ID for SDP events */
+#define BLUETOOTH_EVENT_RFCOMM_BASE     ((int)(BLUETOOTH_EVENT_SDP_BASE + 0x0020))
+                                                               /**< Base ID for RFCOMM events */
+#define BLUETOOTH_EVENT_NETWORK_BASE     ((int)(BLUETOOTH_EVENT_RFCOMM_BASE + 0x0020))
+                                                               /**< Base ID for NETWORK events */
+#define BLUETOOTH_EVENT_HDP_BASE     ((int)(BLUETOOTH_EVENT_NETWORK_BASE + 0x0020))
+                                                               /**< Base ID for HDP events */
+#define BLUETOOTH_EVENT_OPC_BASE  ((int)(BLUETOOTH_EVENT_HDP_BASE + 0x0020))
+                                                               /**< Base ID for OPC events */
+#define BLUETOOTH_EVENT_OBEX_SERVER_BASE ((int)(BLUETOOTH_EVENT_OPC_BASE + 0x0020))
+                                                               /**< Base ID for Obex Server events */
+/**
+ * Bluetooth event type
+ */
+typedef enum {
+       BLUETOOTH_EVENT_NONE = BLUETOOTH_EVENT_BASE,/**< No event */
+
+       BLUETOOTH_EVENT_ENABLED,                    /**< Bluetooth event adpater enabled */
+       BLUETOOTH_EVENT_DISABLED,                   /**< Bluetooth event adpater disabled */
+       BLUETOOTH_EVENT_LOCAL_NAME_CHANGED,         /**< Bluetooth event local name changed*/
+       BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_REQUESTED,
+                                       /**< Bluetooth event Discoverable timeout requested*/
+       BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,  /**< Bluetooth event mode changed */
+       BLUETOOTH_EVENT_DISCOVERY_OPTION_REQUESTED, /**< Bluetooth event discovery option */
+       BLUETOOTH_EVENT_DISCOVERY_STARTED,          /**< Bluetooth event discovery started */
+       BLUETOOTH_EVENT_DISCOVERY_FINISHED,         /**< Bluetooth event discovery finished */
+
+       BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND,        /**< Bluetooth event remote deice found */
+       BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED,/**< Bluetooth event remote device name updated*/
+       BLUETOOTH_EVENT_BONDING_FINISHED,           /**< Bluetooth event bonding completed */
+       BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED,      /**< Bluetooth event bonding removed */
+       BLUETOOTH_EVENT_BONDED_DEVICE_FOUND,        /**< Bluetooth event paired device found */
+       BLUETOOTH_EVENT_REMOTE_DEVICE_READ,         /**< Bluetooth event read remote device */
+       BLUETOOTH_EVENT_DEVICE_AUTHORIZED,          /**< Bluetooth event authorize device */
+       BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED,        /**< Bluetooth event unauthorize device */
+
+       BLUETOOTH_EVENT_SERVICE_SEARCHED = BLUETOOTH_EVENT_SDP_BASE,
+                                                   /**< Bluetooth event serice search base id */
+       BLUETOOTH_EVENT_SERVICE_SEARCH_CANCELLED,   /**< Bluetooth event service search cancelled */
+       BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED = BLUETOOTH_EVENT_RFCOMM_BASE,
+                                                       /**< RFCOMM data receive event */
+       BLUETOOTH_EVENT_RFCOMM_CONNECTED,               /**< Rfcomm server incomming connection */
+       BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,            /**< Rfcomm server/client disconnect */
+
+       BLUETOOTH_EVENT_DEVICE_CONNECTED,           /**< Bluetooth event device connected */
+       BLUETOOTH_EVENT_DEVICE_DISCONNECTED,        /**< Bluetooth event device disconnected */
+
+       BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED = BLUETOOTH_EVENT_NETWORK_BASE,
+                                                               /**< Bluetooth Network event */
+       BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED, /**< Network server deactivated */
+       BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED,     /**< Network connected event in server */
+       BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED,
+                                                  /**< Network disconnected evnet in server */
+
+       BLUETOOTH_EVENT_NETWORK_CONNECTED,              /**< Network connected event in client*/
+       BLUETOOTH_EVENT_NETWORK_DISCONNECTED,           /**< Network disconnected evnet in client*/
+
+       BLUETOOTH_EVENT_HDP_ACTIVATED
+                       = BLUETOOTH_EVENT_HDP_BASE, /**<HDP Activation for Source and Sync>*/
+       BLUETOOTH_EVENT_HDP_DEACTIVATED,           /**<HDP DeActivation for Source and Sync>*/
+       BLUETOOTH_EVENT_HDP_CONNECTED,             /**<HDP Connect>*/
+       BLUETOOTH_EVENT_HDP_DISCONNECTED,          /**<HDP Disconnect>*/
+       BLUETOOTH_EVENT_HDP_DATA_RECEIVED,         /**<HDP Data Indication>*/
+
+       BLUETOOTH_EVENT_OPC_CONNECTED = BLUETOOTH_EVENT_OPC_BASE,
+                                                               /* OPC Connected event */
+       BLUETOOTH_EVENT_OPC_DISCONNECTED,               /* OPC Disonnected event */
+       BLUETOOTH_EVENT_OPC_TRANSFER_STARTED,   /* OPC Transfer started event */
+       BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS,  /* OPC Transfer progress event */
+       BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,  /* OPC Transfer Complete event */
+
+       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE = BLUETOOTH_EVENT_OBEX_SERVER_BASE,
+                                                               /* Obex server authorize event*/
+       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED,   /* Obex Server transfer started event*/
+       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,/* Obex Server transfer progress event*/
+       BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,/* Obex Server transfer complete event*/
+
+       BLUETOOTH_EVENT_MAX,                            /**< Bluetooth event Max value */
+} bluetooth_event_type_t;
+
+ /**
+ * This bt_service_uuid_list_t  enum  indicates service uuid list .
+ * This values is stored the service_list_array in bt_sdp_info_t and bluetooth_device_info_t.
+ */
+
+typedef enum {
+       BLUETOOTH_SPP_PROFILE_UUID = ((unsigned short)0x1101),                  /**<SPP*/
+       BLUETOOTH_LAP_PROFILE_UUID = ((unsigned short)0x1102),                  /**<LAP*/
+       BLUETOOTH_DUN_PROFILE_UUID = ((unsigned short)0x1103),                  /**<DUN*/
+       BLUETOOTH_OBEX_IR_MC_SYNC_SERVICE_UUID = ((unsigned short)0x1104),     /**<OBEX IR MC SYNC*/
+       BLUETOOTH_OBEX_OBJECT_PUSH_SERVICE_UUID = ((unsigned short)0x1105),    /**<OPP*/
+       BLUETOOTH_OBEX_FILE_TRANSFER_UUID = ((unsigned short)0x1106),           /**<FTP*/
+       BLUETOOTH_HS_PROFILE_UUID = ((unsigned short)0x1108),                   /**<HS*/
+       BLUETOOTH_CTP_PROFILE_UUID = ((unsigned short)0x1109),                  /**<CTP*/
+       BLUETOOTH_AUDIO_SOURCE_UUID = ((unsigned short)0x110A),                 /**<AUDIO SOURCE*/
+       BLUETOOTH_AUDIO_SINK_UUID = ((unsigned short)0x110B),                   /**<AUDIO SINK*/
+       BLUETOOTH_VIDEO_SOURCE_UUID = ((unsigned short)0x1303),                 /**<VEDIO SOURCE*/
+       BLUETOOTH_VIDEO_SINK_UUID = ((unsigned short)0x1304),                   /**<VEDIO SINK*/
+       BLUETOOTH_AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C),  /**<AV REMOTE CONTROL
+                                                                               TARGET*/
+       BLUETOOTH_ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D),    /**<A2DP*/
+       BLUETOOTH_AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E),    /**<AV REMOTE CONTROL UUID*/
+       BLUETOOTH_ICP_PROFILE_UUID = ((unsigned short)0x1110),                  /**<ICP*/
+       BLUETOOTH_FAX_PROFILE_UUID = ((unsigned short)0x1111),                  /**<FAX*/
+       BLUETOOTH_HEADSET_AG_SERVICE_UUID = ((unsigned short)0x1112),           /**<HS AG */
+       BLUETOOTH_PAN_PANU_PROFILE_UUID = ((unsigned short)0x1115),             /**<PAN*/
+       BLUETOOTH_PAN_NAP_PROFILE_UUID = ((unsigned short)0x1116),              /**<PAN*/
+       BLUETOOTH_PAN_GN_PROFILE_UUID = ((unsigned short)0x1117),               /**<PAN*/
+       BLUETOOTH_DIRECT_PRINTING = ((unsigned short)0x1118),
+       BLUETOOTH_REFERENCE_PRINTING = ((unsigned short)0x1119),
+       BLUETOOTH_OBEX_IMAGING_UUID = ((unsigned short)0x111A),                 /**<OBEX_IMAGING*/
+       BLUETOOTH_OBEX_IMAGING_RESPONDER_UUID = ((unsigned short)0x111B),       /**<OBEX_IMAGING
+                                                                               RESPONDER*/
+       BLUETOOTH_HF_PROFILE_UUID = ((unsigned short)0x111E),                   /**<HF*/
+       BLUETOOTH_HFG_PROFILE_UUID = ((unsigned short)0x111F),                  /**<HFG*/
+       BLUETOOTH_DIRECT_PRINTING_REFERENCE_OBJ_UUID = ((unsigned short)0x1120),
+                                                                       /**<DIRECT PRINTING*/
+       BLUETOOTH_BASIC_PRINTING = ((unsigned short)0x1122),            /**<BASIC PRINTING*/
+       BLUETOOTH_PRINTING_STATUS = ((unsigned short)0x1123),           /**<PRINTING  STATUS*/
+       BLUETOOTH_HID_PROFILE_UUID = ((unsigned short)0x1124),          /**<HID*/
+       BLUETOOTH_SIM_ACCESS_PROFILE_UUID = ((unsigned short)0x112D),   /**<SIM ACCESS PROFILE*/
+       BLUETOOTH_OBEX_PBA_PROFILE_UUID = ((unsigned short)0x112F),     /**<OBEX PBA*/
+       BLUETOOTH_OBEX_PBAP_UUID = ((unsigned short)0x1130),            /**<OBEX PBA*/
+       BLUETOOTH_OBEX_BPPS_PROFILE_UUID = ((unsigned short)0x1118),    /**<OBEX BPPS*/
+       BLUETOOTH_PNP_INFORMATION_UUID = ((unsigned short)0x1200),      /**<PNP*/
+       BLUETOOTH_OBEX_PRINTING_STATUS_UUID = ((unsigned short)0x1123), /**<OBEX PRINTING STATUS*/
+       BLUETOOTH_HCR_PROFILE_UUID = ((unsigned short)0x1125),          /**<HCRP*/
+       BLUETOOTH_OBEX_SYNCML_TRANSFER_UUID = ((unsigned short)0x0000)  /**<OBEX_SYNC*/
+} bluetooth_service_uuid_list_t;
+
+/**
+* Service class part of class of device returned from device discovery
+*/
+typedef enum {
+       BLUETOOTH_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000,
+       BLUETOOTH_DEVICE_SERVICE_CLASS_POSITIONING = 0x010000,                  /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_NETWORKING = 0x020000,                   /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_RENDERING = 0x040000,                    /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_CAPTURING = 0x080000,                    /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000,              /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_AUDIO = 0x200000,                        /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_TELEPHONY = 0x400000,                    /**<  */
+       BLUETOOTH_DEVICE_SERVICE_CLASS_INFORMATION = 0x800000,                  /**<  */
+} bluetooth_device_service_class_t;
+
+
+/**
+ * Major device mask (For device discovery)
+ */
+typedef enum {
+       BLUETOOTH_DEVICE_MAJOR_MASK_MISC = 0x00,
+       BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER = 0x0001,
+       BLUETOOTH_DEVICE_MAJOR_MASK_PHONE = 0x0002,
+       BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004,
+       BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO = 0x0008,
+       BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010,
+       BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING = 0x0020,
+       BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE = 0x0040,
+       BLUETOOTH_DEVICE_MAJOR_MASK_TOY = 0x0080,
+       BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH = 0x0100,
+} bluetooth_device_major_mask_t;
+
+
+/**
+ * Major device class (part of Class of Device)
+ */
+typedef enum {
+       BLUETOOTH_DEVICE_MAJOR_CLASS_MISC = 0x00,       /**< Miscellaneous major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER = 0x01,           /**< Computer major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE = 0x02,              /**< Phone major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT = 0x03,   /**< LAN major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO = 0x04,              /**< AUDIO major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL = 0x05,         /**< Peripheral major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING = 0x06,            /**< Imaging major device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE = 0x07,           /**< Wearable device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_TOY = 0x08,                /**< Toy device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH = 0x09,             /**< Health device class*/
+       BLUETOOTH_DEVICE_MAJOR_CLASS_UNCLASSIFIED = 0x1F        /**< Unknown major device class*/
+} bluetooth_device_major_class_t;
+
+typedef enum {
+       BLUETOOTH_DEVICE_MINOR_CLASS_UNCLASSIFIED = 0x00,       /**< unclassified minor class */
+
+       /* About Computer Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION = 0x04,        /**< desktop workstation
+                                                                       minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER = 0x08,      /**< server minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_LAPTOP = 0x0C,                     /**< laptop minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA = 0x10,         /**< PDA minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA = 0x14,       /**< PALM minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER = 0x18,  /**< Wearable PC minor class */
+
+       /* About Phone Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CELLULAR = 0x04,                   /**< Cellular minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CORDLESS = 0x08,                   /**< cordless minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_SMART_PHONE = 0x0C,        /**< smart phone minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
+                                                               /**< voice gateway minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS = 0x14,         /**< ISDN minor class */
+
+       /* About LAN/Network Access Point Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_FULLY_AVAILABLE = 0x04,            /**< Fully available minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED = 0x20,   /**< 1-17% utilized minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED = 0x40,  /**< 17-33% utilized minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED = 0x60,  /**< 33-50% utilized minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED = 0x80,  /**< 50-67% utilized minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED = 0xA0,  /**< 67-83% utilized minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED = 0xC0,  /**< 83-99% utilized minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE = 0xE0,               /**< No service available minor class */
+
+       /* About Audio/Video Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HEADSET_PROFILE = 0x04,            /**< Headset minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HANDSFREE = 0x08,                  /**< Handsfree minor class*/
+
+       BLUETOOTH_DEVICE_MINOR_CLASS_MICROPHONE = 0x10,         /**< Microphone minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_LOUD_SPEAKER = 0x14,       /**< Loud Speaker minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HEADPHONES = 0x18,         /**< Headphones minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_PORTABLE_AUDIO = 0x1C,     /**< Portable Audio minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CAR_AUDIO = 0x20,           /**< Car Audio minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_SET_TOP_BOX = 0x24,        /**< Set top box minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE = 0x28,  /**< Hifi minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_VCR = 0x2C,                /**< VCR minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CAMERA = 0x30,       /**< Video Camera minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CAM_CORDER = 0x34,         /**< CAM Corder minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_MONITOR = 0x38,      /**<Video Monitor minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_DISPLAY_AND_LOUD_SPEAKER = 0x3C,
+                                                                       /**< Video Display and Loud
+                                                                       Speaker minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_VIDEO_CONFERENCING = 0x40, /**< Video Conferencing minor
+                                                               class */
+
+       BLUETOOTH_DEVICE_MINOR_CLASS_GAMING_OR_TOY = 0x48,      /**< Gaming or toy minor class */
+
+       /* About Peripheral Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD = 0x40,          /**< Key board minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE = 0x80,    /**< Pointing Device minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_COMBO_KEYBOARD_OR_POINTING_DEVICE = 0xC0,
+                                                               /**< Combo Keyboard or pointing
+                                                               device minorclass */
+
+       BLUETOOTH_DEVICE_MINOR_CLASS_JOYSTICK = 0x04,           /**< JoyStick minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_GAME_PAD = 0x08,           /**< Game Pad minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_REMOTE_CONTROL = 0x0C,     /**< Remote Control minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_SENSING_DEVICE = 0x10,     /**< Sensing Device minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_DIGITIZER_TABLET = 0x14,   /**< Digitizer minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CARD_READER = 0x18,        /**< Card Reader minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_DIGITAL_PEN = 0x1C,        /**< Digital pen minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_SCANNER = 0x20,   /**< Handheld scanner for bar-codes, RFID minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24,     /**< Handheld gestural input device minor class */
+
+       /* About Imaging Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_DISPLAY = 0x10,            /**< Display minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CAMERA = 0x20,             /**< Camera minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_SCANNER = 0x40,            /**< Scanner minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_PRINTER = 0x80,            /**< Printer minor class */
+
+       /* About Wearable Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_WRIST_WATCH = 0x04,        /**< Wrist watch minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_PAGER = 0x08,              /**< Pager minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_JACKET = 0x0C,             /**< Jacket minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HELMET = 0x10,             /**< Helmet minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_GLASSES = 0x14,            /**< Glasses minor class */
+
+       /* About Toy Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_ROBOT = 0x04,              /**< Robot minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_VEHICLE = 0x08,            /**< Vehicle minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_DOLL_OR_ACTION = 0x0C,     /**< Doll or Action minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_CONTROLLER = 0x10,         /**< Controller minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_GAME = 0x14,               /**< Game minor class */
+
+       /* About Health Major class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_BLOOD_PRESSURE_MONITOR = 0x04,     /**< Blood Pressure minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_THERMOMETER = 0x08,                /**< Thermometer minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_WEIGHING_SCALE = 0x0C,             /**< Weighing Scale minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_GLUCOSE_METER = 0x10,              /**< Glucose minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_PULSE_OXIMETER = 0x14,             /**< Pulse Oximeter minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_HEART_OR_PULSE_RATE_MONITOR = 0x18,/**< Heart or pulse rate monitor minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_MEDICAL_DATA_DISPLAY = 0x1C,       /**< Medical minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_STEP_COUNTER = 0x20,               /**< Step Counter minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_BODY_COMPOSITION_ANALYZER = 0x24,  /**< Body composition analyzer minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_PEAK_FLOW_MONITOR = 0x28,  /**< Peak flow monitor minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_KNEE_PROSTHESIS = 0x30,    /**< Knee prosthesis minor class */
+       BLUETOOTH_DEVICE_MINOR_CLASS_ANKLE_PROSTHESIS = 0x34,   /**< Ankle prosthesis minor class */
+} bluetooth_device_minor_class_t;
+
+/**
+ * structure to hold the device information
+ */
+typedef struct {
+       bluetooth_device_major_class_t major_class; /**< major device class */
+       bluetooth_device_minor_class_t minor_class; /**< minor device class */
+       bluetooth_device_service_class_t service_class;
+                                                   /**< service device class */
+} bluetooth_device_class_t;
+
+/**
+* structure to hold the device information
+*/
+typedef struct {
+       bluetooth_device_address_t device_address;      /**< device address */
+       bluetooth_device_name_t device_name;    /**< device name */
+       bluetooth_device_class_t device_class;  /**< device class */
+       char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
+       unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
+       int service_index;
+       int rssi;                       /**< received strength signal*/
+       gboolean paired;                /**< paired flag */
+       gboolean connected;     /**< connected flag */
+       gboolean trust;         /**< connected flag */
+} bluetooth_device_info_t;
+
+/**
+ * structure to hold the paired device information
+ */
+typedef struct {
+       bluetooth_device_address_t device_address;  /**< paired device address */
+       bluetooth_device_name_t device_name;        /**< device name */
+       bluetooth_device_class_t device_class;      /**< device class */
+} bluetooth_paired_device_info_t;
+
+/**
+* structure to hold the paired device information
+*/
+typedef struct {
+       bluetooth_device_address_t device_address;
+                                              /**< device address */
+       char interface_name[BLUETOOTH_INTERFACE_NAME_LENGTH + 1];
+                                                         /**< network interface name */
+} bluetooth_network_device_info_t;
+
+/**
+* Stucture to hold discovery option
+*/
+typedef struct {
+       unsigned short max_response;    /**< the number of maximum response */
+       unsigned short discovery_duration;
+                                       /**< duration of discovery (seconds) */
+       unsigned int classOfDeviceMask; /**<  mask for values of class of device. to be used with
+                                       classOfDevice variable */
+} bluetooth_discovery_option_t;
+
+/**
+ * Stucture to hold event information
+ */
+typedef struct {
+       int event;      /**< event type */
+       int result;     /**< Success or error value */
+       void *param_data;
+                       /**<parameter data pointer */
+       void *user_data;
+} bluetooth_event_param_t;
+
+typedef struct {
+       bluetooth_device_address_t device_addr;
+       char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
+       unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
+       unsigned int service_name_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
+       int service_index;
+} bt_sdp_info_t;
+
+/**
+ * Stucture to rfcomm receive data
+ */
+
+typedef struct {
+       int socket_fd;
+               /**< the socket fd */
+       int buffer_size;/**< the length of the receive buffer */
+       char *buffer;
+               /**< the receive data buffer */
+} bluetooth_rfcomm_received_data_t;
+
+/**
+* Stucture to rfcomm connection
+*/
+
+typedef struct {
+       int socket_fd;
+               /**< the socket fd */
+       int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
+       bluetooth_device_address_t device_addr;
+                                             /**< device address */
+} bluetooth_rfcomm_connection_t;
+
+/**
+ * Stucture to rfcomm disconnection
+ */
+typedef struct {
+       int socket_fd;
+               /**< the socket fd */
+       bluetooth_device_address_t device_addr;
+                                             /**< device address */
+} bluetooth_rfcomm_disconnection_t;
+
+/**
+ * HDP QOS types
+ */
+typedef enum {
+       HDP_QOS_RELIABLE,
+       HDP_QOS_STREAMING,
+       HDP_QOS_ANY
+}bt_hdp_qos_type_t;
+
+/**
+ * HDP Role types
+ */
+typedef enum {
+       HDP_ROLE_SOURCE = 0x0,
+       HDP_ROLE_SINK
+}bt_hdp_role_type_t;
+
+/**
+ * Stucture to HDP activated
+ */
+typedef struct {
+       const char *app_handle; /**< the application handle */
+} bt_hdp_activate_t;
+
+/**
+ * Stucture to HDP deactivate
+ */
+typedef struct {
+       const char *app_handle; /**< the application handle */
+} bt_hdp_deactivate_t;
+
+/**
+ * Stucture to HDP connected
+ */
+typedef struct {
+       const char *app_handle; /**< the application handle */
+       unsigned int channel_id;        /**< the channel id */
+       bt_hdp_qos_type_t type; /**< the QOS type */
+       bluetooth_device_address_t device_address; /**< the remote address */
+} bt_hdp_connected_t;
+
+/**
+ * Stucture to HDP disconnected
+ */
+typedef struct {
+       unsigned int channel_id; /**< the channel id */
+       bluetooth_device_address_t device_address; /**< the remote address */
+} bt_hdp_disconnected_t;
+
+/**
+ * Stucture to HDP data indication
+ */
+typedef struct {
+       unsigned int channel_id;         /**< the channel id */
+       const char *buffer;      /**< the RX data buffer */
+       unsigned int size;       /**< the RX data size */
+} bt_hdp_data_ind_t;
+
+/**
+ * Stucture to OPP client transfer information
+ */
+typedef struct {
+       char *filename;
+       int size;
+}bt_opc_transfer_info_t;
+
+/**
+ * Stucture to OPP/FTP Server authorize information
+ */
+typedef struct {
+       char *filename;
+       char *device_name;
+       char *type;
+       int length;
+} bt_obex_server_authorize_into_t;
+
+/**
+ * Stucture to OPP/FTP server transfer information
+ */
+typedef struct {
+       char *filename;
+       char *device_name;
+       char *type;
+       int transfer_id;
+       int file_size;
+       int percentage;
+} bt_obex_server_transfer_info_t;
+
+/* This is for distingushing the FTP server operation type */
+#define FTS_TYPE_PUT   "x-obex/ftp-put"
+#define FTS_TYPE_GET   "x-obex/ftp-get"
+#define FTS_TYPE_DEL   "x-obex/ftp-delete"
+
+
+/**
+ * Callback pointer type
+ */
+typedef void (*bluetooth_cb_func_ptr) (int, bluetooth_event_param_t *, void *);
+
+/**
+ * @fn int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)
+ * @brief Set the callback function pointer for bluetooth event
+ *
+ *
+ * This API will register the callback function, when any response and event are received from
+ * bluetooth framework. @n
+ * this registered callback function will be get called with appropriate event and data structures.
+ * This function is a synchronous call. An application developer can call
+ * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
+ * type. This registered function will receive events of bluetooth_event_type_t type along with
+ * data any.
+ *
+ *
+ * @param[in]   callback_ptr    A pointer to the callback function
+ * @param[in]   user_data    A pointer to user data
+ * @return      BLUETOOTH_ERROR_NONE - Success
+ * @remark      None
+ * @see         None
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
+{
+       GMainLoop *main_loop = (GMainLoop*) user_data;
+
+       switch(event)
+       {
+               // Code for each event
+               default:
+                       g_main_loop_quit(main_loop);
+                       break;
+       }
+}
+
+int main()
+{
+       GMainLoop *main_loop = NULL;
+       int ret = 0;
+       g_type_init();
+       main_loop = g_main_loop_new(NULL, FALSE);
+       ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
+       if (ret >= BLUETOOTH_ERROR_NONE)
+       {
+               // bluetooth_register_callback returned Success
+       }
+       else
+       {
+               // bluetooth_register_callback returned failiure
+       }
+       g_main_loop_run(main_loop);
+}
+@endcode
+ */
+int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data);
+
+/**
+ * @fn int bluetooth_deregister_callback(bluetooth_cb_func_ptr callback_ptr)
+ * @brief Set the callback function pointer for bluetooth event
+ *
+ *
+ * This API will register the callback function, when any response and event are received from
+ * bluetooth framework. @n
+ * this registered callback function will be get called with appropriate event and data structures.
+ * This function is a synchronous call. An application developer can call
+ * bluetooth_register_callback() function to register a callback function of bluetooth_cb_func_ptr
+ * type. This registered function will receive events of bluetooth_event_type_t type along with
+ * data any.
+ *
+ *
+ * @param[in]   none
+ * @return      BLUETOOTH_ERROR_NONE - Success
+ * @remark      None
+ * @see         None
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param, void *user_data)
+{
+       GMainLoop *main_loop = (GMainLoop*) user_data;
+
+       switch(event)
+       {
+               // Code for each event
+               default:
+                       g_main_loop_quit(main_loop);
+                       break;
+       }
+}
+
+int main()
+{
+       GMainLoop *main_loop = NULL;
+       int ret = 0;
+       g_type_init();
+       main_loop = g_main_loop_new(NULL, FALSE);
+       ret = bluetooth_register_callback(bt_event_callback, (void*)main_loop);
+       if (ret >= BLUETOOTH_ERROR_NONE)
+       {
+               // bluetooth_register_callback returned Success
+       }
+       else
+       {
+               // bluetooth_register_callback returned failiure
+       }
+       ret = bluetooth_deregister_callback(void);
+       g_main_loop_run(main_loop);
+}
+@endcode
+ */
+int bluetooth_unregister_callback(void);
+
+/**
+ * @fn int bluetooth_enable_adapter(void)
+ * @brief Enable the Bluetooth H/W
+ *
+ *
+ * This API can be used to activate Bluetooth. It initializes Bluetooth protocol stack for use and
+ * send request to bluetooth chip for activation.
+ * This function is typically called at startup or when Bluetooth services are required.  This
+ * function must be called before calling any other API of Bluetooth operations.
+ *
+ * Before performing any operations like Device discover, service search etc.., the adapter must be
+ * enabled.
+ *
+ * This function is a asynchronous call.
+ * If the call is success then the application will receive BLUETOOTH_EVENT_ENABLED event
+ * through registered callback function with appropriate result code
+ *                     BLUETOOTH_CHANGE_STATUS_TIMEOUT - Timeout has happen \n
+ *                     BLUETOOTH_ERROR_NONE - Success \n
+ *
+ * If the adpter is not enabled with in 30 seconds then BLUETOOTH_EVENT_ENABLED with result code
+ * BLUETOOTH_CHANGE_STATUS_TIMEOUT will come
+ *
+ * @return      BLUETOOTH_ERROR_NONE - Success\n
+ *             BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED - Adapter already enabled\n
+ *             BLUETOOTH_ERROR_ACCESS_DENIED - Enabling adapter is not allowed by MDM policy\n
+ *             BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
+ * @exception   BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
+ * @remark      None
+ * @see         bluetooth_check_adapter, bluetooth_disable_adapter
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               // Successfully Enabled
+                       }
+                       else
+                       {
+                               // Failed
+                       }
+                       break;
+       }
+}
+
+...
+
+int ret = 0;
+ret = bluetooth_enable_adapter();
+
+@endcode
+ */
+int bluetooth_enable_adapter(void);
+
+/**
+ * @fn int bluetooth_disable_adapter(void)
+ * @brief Disable the Bluetooth H/W
+ *
+ *
+ * This function disables Bluetooth protocol stack and hardware. This function is called when
+ * Bluetooth is no longer used. It will internally free all resources and power off the RF radio.
+ *
+ * Bluetooth adapter should be disabled to switch off Bluetooth chip (and thereby saving power).
+ * bluetooth_disable_adapter() API will do that job for you. After switching off Bluetooth,
+ * BLUETOOTH_EVENT_DISABLED will be sent by SDK to application for confirmation with appropriate
+ * error code.
+ * The various error codes are BLUETOOTH_ERROR_NONE for success and BLUETOOTH_ERROR_INTERNAL for
+ * internal error.
+ *
+ * This function is a asynchronous call.
+ * If this call is success then the applications will receive BLUETOOTH_EVENT_DISABLED event
+ * through registered callback function.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success\n
+ *             BLUETOOTH_ERROR_IN_PROGRESS - Adapter is activating or deactivating\n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled\n
+ * @exception   BLUETOOTH_ERROR_INTERNAL - Dbus proxy call is fail
+ * @remark      None
+ * @see         bluetooth_check_adapter, bluetooth_enable_adapter
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_DISABLED:
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               // Successfully disabled
+                       }
+                       else
+                       {
+                               // Failed
+                       }
+                       break;
+       }
+}
+
+...
+
+int ret = 0;
+ret = bluetooth_disable_adapter();
+@endcode
+ */
+int bluetooth_disable_adapter(void);
+
+
+/**
+ * @fn int bluetooth_is_supported(void)
+ * @brief Check if the bluetooth is supported or not by the current target
+ *
+ * This API checks whether the bluetooth is supported or not.
+ * This API only run by root permission.
+ * This API was made for the MDM service.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     0 - if bluetooth is not supported\n
+ *             1 - if bluetooth is supported\n
+ *             BLUETOOTH_ERROR_INTERNAL - Error in API internal
+ * @remark      None
+@code
+
+int ret = 0;
+ret = bluetooth_is_supported();
+@endcode
+ */
+int bluetooth_is_supported(void);
+
+/**
+ * @fn int bluetooth_allow_service(gboolean allow)
+ * @brief Allow to start the bluetooth service
+ *
+ * This API is to allow the bluetooth service.
+ * If allow value is FALSE, disable the adapter. and user can't enable the adapter
+ * before allow value is to be TRUE or reboot.
+ * If user reboot the phone, this allow value will be TRUE. (If no one set the allow value again)
+ * This API only run by root permission.
+ * This API was made for the MDM service.
+ *
+ * This function is a synchronous call.
+ *
+ * @param[in]  allow the mode to allow BT service
+ * @return     BLUETOOTH_ERROR_NONE - success to change the value\n
+ *             BLUETOOTH_ERROR_ACCESS_DENIED - access denied because of the permission \n
+ * @remark      None
+@code
+
+int ret = 0;
+ret = bluetooth_is_supported();
+@endcode
+ */
+int bluetooth_allow_service(gboolean allow);
+
+
+/**
+ * @fn int bluetooth_check_adapter(void)
+ * @brief Check the current status of the Bluetooth adapter
+ *
+ *
+ * This API checks whether the Bluetooth adapter is enabled or not. Before performing any operations
+ * the bluetooth adapter should be enabled. This API helps to find out the current state of the
+ * bluetooth adapter.
+ * This API get the adapter internal data structure and check current adapter status.
+ *
+ * This function is a synchronous call.
+ *
+ *
+ * @return     BLUETOOTH_ADAPTER_DISABLED - if bluetooth adapter is disabled\n
+ *             BLUETOOTH_ADAPTER_ENABLED - if bluetooth adapter is enabled\n
+ * @remark      None
+ * @see         bluetooth_enable_adapter, bluetooth_disable_adapter
+@code
+
+int ret = 0;
+ret = bluetooth_check_adapter();
+@endcode
+ */
+int bluetooth_check_adapter(void);
+
+/**
+ * @fn int bluetooth_get_local_address(bluetooth_device_address_t *local_address)
+ * @brief Get the local adapter bluetooth address
+ *
+ *
+ * This API is used, get the device address of the local bluetooth adapter. Before calling this API,
+ * the adapter should be enabled.
+ * In its output parameter, you can receive bluetooth_device_address_t type of pointer which will
+ * contain Bluetooth address.
+ * Since its inconvenient for user to remember the address, Bluetooth provides a method to have a
+ * friendly name for each device.
+ * There is no event callback for this API.
+ *
+ * This function is a synchronous call.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Succeess \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM -  Invalid parameter (NULL buffer) \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED -  Adapter is disabled \n
+ * @param[out]  local_address   a device address of local bluetooth adapter
+ * @remark      None
+ * @see         None
+@code
+
+bluetooth_device_address_t local_address={0,};
+int ret = 0;
+
+ret = bluetooth_get_local_address(&local_address);
+@endcode
+ */
+int bluetooth_get_local_address(bluetooth_device_address_t *local_address);
+
+/**
+ * @fn int bluetooth_get_local_name(bluetooth_device_name_t* local_name)
+ * @brief Get the local device name
+ *
+ *
+ * This function is used, get the local device name. Since its difficult to remember the Adapter
+ * address, the friendly name can be assigned to the adapter and we can get it using this API. This
+ * friendly name is retrived by the remote device and displaying.
+ * Before calling this API, the adapter should be enabled. There is no event callback for this API.
+ *
+ * This function is a synchronous call.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer)\n
+ * @param[out]  local_name      a local device name
+ * @remark      None
+ * @see         None
+@code
+bluetooth_device_name_t local_name={0,}
+int ret = 0;
+ret = bluetooth_get_local_name (&local_name);
+@endcode
+ */
+int bluetooth_get_local_name(bluetooth_device_name_t *local_name);
+
+/**
+ * @fn int bluetooth_set_local_name(const bluetooth_device_name_t *local_name)
+ * @brief Set the local device name
+ *
+ *
+ * This function is used to set the local device name. This is a human friendly name whose
+ * length can be BLUETOOTH_DEVICE_NAME_LENGTH_MAX maximum
+ *
+ * This function is a synchronous call.
+ *
+ * @param[in]   local_name   bluetooth device name to set local device
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
+ *             BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
+ *             BLUETOOTH_ERROR_NO_RESOURCES - Pre-allocated memory error \n
+ *             BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
+ *
+ * @remark      None
+
+bluetooth_device_name_t local_name={0,}
+int ret = 0;
+ret = bluetooth_set_local_name (&local_name);
+@endcode
+ */
+int bluetooth_set_local_name(const bluetooth_device_name_t *local_name);
+
+/**
+ * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
+ * @brief Get the visibility mode
+ *
+ *
+ * This function is used to get the discoverable mode (Visibility option). Depending upon the
+ * visibity mode, the property of the device is determined whether it can be discoverable, non
+ * discoverable, connectable etc. Before calling this API make sure that the adapter is enabled.
+ *
+ * This function is a synchronous call.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INVALID_DATA - Invalid data \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
+ * @param[out]  discoverable_mode   current bluetooth discoverable mode
+ * @remark      None
+ * @see                bluetooth_set_discoverable_mode
+ @code
+ bluetooth_discoverable_mode_t discoverable_mode_ptr;
+ int ret = 0;
+ ret = bluetooth_get_discoverable_mode (&discoverable_mode_ptr);
+ @endcode
+ */
+int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr);
+
+/**
+ * @fn int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
+ *                                             int timeout)
+ * @brief Set the visibility mode
+ *
+ *
+ * This function is used to set the discoverable mode (Visibility option).
+ *
+ * Many times user may want to keep his device discoverable so that when peer device is performing
+ * device search, he/she can find user's device. Application programmer can keep the mode as
+ * BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE or
+ * BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE for the same purpose. However, all these
+ * modes cause bluetooth adapter to consume more battery. Hence developer should generally
+ * keep discoverable mode as BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_NOT_SUPPORT - Requested mode is not supported \n
+ *
+ * @param[in]  discoverable_mode   the bluetooth discoverable mode to set
+ * @param[in]  timeout   discoverable time in only limited discoverable mode (second), default: 0
+ * @remark      None
+ * @see         bluetooth_get_discoverable_mode
+
+@code
+
+bluetooth_discoverable_mode_t mode;
+int ret = 0;
+mode= BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
+ret = bluetooth_set_discoverable_mode (mode, 180);
+
+@endcode
+ */
+int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
+                                           int timeout);
+
+/**
+ * @fn int bluetooth_start_discovery(unsigned short max_response, unsigned short discovery_duration,
+ *                                     unsigned int  classOfDeviceMask)
+ * @brief Start the device discovery
+ *
+ * To connect connect to peer bluetooth device, you will need to know its bluetooth address and its
+ * name. You can search for Bluetooth devices in vicinity by bluetooth_start_discovery() API. It
+ * first performs an inquiry. For each device found from the inquiry it gets the remote name of the
+ * device. Bluetooth device address and name are given to Application via
+ * BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. In param_data of bluetooth_event_param_t, you will
+ * receive a pointer to a structure of bluetooth_device_info_t type. you will receive device
+ * address, device name, device class, rssi (received signal strength indicator). please see
+ * bluetooth_device_info_t for more details.
+ *
+ *
+ * This API provides searching options like max responses, discovery duration in seconds and class
+ * of device mask to filter device search. some times there may be too many bluetooth devices in
+ * vicinity of your device.in such scenario, application can request to reduce number of responces
+ * (BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event) with help of max_response parameter. However if you
+ * pass zero, bluetooth adapter will not restrict number of responses. you can also specify duration
+ * of the seach in discovery_duration. bluetooth adapter will automatically stop device search after
+ * application defined time. please note that discovery_duration should be mentioned in seconds.
+ * Also note that search will end after 180 seconds automatically if you pass 0 in discovery
+ * duration.
+ *
+ * sometimes user may want to search for a perticular kind of device. for ex, mobile or pc. in such
+ * case, you can use classOfDeviceMask parameter. please see bluetooth_device_service_class_t,
+ * bluetooth_device_major_class_t and bluetooth_device_minor_class_t enums
+ *
+ * This function is a asynchronous call.
+ * If the call is success then the application will receive BLUETOOTH_EVENT_DISCOVERY_STARTED event
+ * through registered callback function.
+ *
+ * The discovery is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event for each device it
+ * finds and an BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED event for each fount device its name
+ * finds.
+ *
+ * The completion or cancellation of the discovery is indicated by an
+ * BLUETOOTH_EVENT_DISCOVERY_FINISHED event.
+ *
+ * The device discovery can be cancelled by calling bluetooth_stop_discovery().
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
+ *             BLUETOOTH_ERROR_DEVICE_BUSY - Bluetooth adapter is busy doing some operation \n
+ *             BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
+                                               agent is not running \n
+ *
+ * @param[in] max_response             define the maximum response of the number of founded devices
+                                       (0 means unlimited)
+ * @param[in] discovery_duration       define bluetooth discovery duration (0 means 180s )
+ * @param[in] classOfDeviceMask                define classes of the device mask which user wants
+                                       (refer to class of device)
+ * @remark      None
+ * @see         bluetooth_cancel_discovery, bluetooth_device_info_t
+
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       printf("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]",
+                                       param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address,
+                                               sizeof(bluetooth_device_address_t));
+                       printf("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
+                               device_info->device_address.addr[0],
+                               device_info->device_address.addr[1],
+                               device_info->device_address.addr[2],
+                               device_info->device_address.addr[3],
+                               device_info->device_address.addr[4],
+                               device_info->device_address.addr[5]);
+                       break;
+               }
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       printf("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]",
+                                                                               param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address,
+                                                               sizeof(bluetooth_device_address_t));
+                       printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
+                                                       device_info->device_name.name,
+                                                       device_info->device_address.addr[0],
+                                                       device_info->device_address.addr[1],
+                                                       device_info->device_address.addr[2],
+                                                       device_info->device_address.addr[3],
+                                                       device_info->device_address.addr[4],
+                                                       device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       printf("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
+                       break;
+       }
+}
+
+unsigned short max_response;
+unsigned short discovery_duration;
+unsigned classOfDeviceMask;
+int ret = 0;
+
+max_response =0;
+discovery_duration =0;
+classOfDeviceMask =0;
+
+ret = bluetooth_start_discovery(max_response,discovery_duration,classOfDeviceMask);
+
+@endcode
+ *
+ */
+
+int bluetooth_start_discovery(unsigned short max_response,
+                                     unsigned short discovery_duration,
+                                     unsigned int classOfDeviceMask);
+
+/**
+ * @fn int bluetooth_cancel_discovery (void)
+ * @brief Cancel the on-going device discovery operation
+ *
+ *
+ * This function stops the on-going device discovery operation. This API has to be called after the
+ * bluetooth_start_discovery API and before the BLUETOOTH_EVENT_DISCOVERY_FINISHED event comes of
+ * the bluetooth_start_discovery API
+ *
+ * Normally the device discovery takes a more time (~10.24 seconds) to get all the devices in its
+ * vicinity and it recevies as BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND event. This API helps us to
+ * cancel the discover request once the user received the device to which he wish to connect.
+ *
+ * This function is a asynchronous call.
+ * If the call is success to cancel discovey then the application will receive
+ * BLUETOOTH_EVENT_DISCOVERY_FINISHED event through registered callback function
+ * with an error code BLUETOOTH_ERROR_CANCEL. In the case of failure the error code will be
+ * BLUETOOTH_ERROR_NONE
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_NOT_IN_OPERATION - No Discovery operation in progess to cancel \n
+ *             BLUETOOTH_ERROR_ACCESS_DENIED - Currently in discovery but it is requested from
+                                               other application \n
+ *             BLUETOOTH_ERROR_INTERNAL - Internel IPC error \n
+ * @remark      None
+ * @see                bluetooth_start_discovery
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result[0x%04x]", param->result);
+                       break;
+       }
+}
+
+..
+
+int ret = 0;
+
+ret = bluetooth_cancel_discovery();
+@endcode
+ */
+int bluetooth_cancel_discovery(void);
+
+/**
+ * @fn int bluetooth_is_discovering(void)
+ * @brief Check for the device discovery is in-progress or not.
+ *
+ * This API is used to check the current status of the Discovery operation.If discovery is in\
+ * progress normally other operations are not allowed.
+ * If a device discovery is in progress, we have to either cancel the discovery operation or wait
+ * for the BLUETOOTH_EVENT_DISCOVERY_FINISHED
+ * event before performing other operations. This API is used to get for the current discovery
+ * operation status and using bluetooth_cancel_discovery()
+ * we can cancell the ongoing discovery process.
+ * Before calling this API, make sure that the adapter is enabled. There is no callback event for
+ * this API.
+ *
+ * This function checks whether the device discovery is started or not.
+ *
+ * This function is a synchronous call.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Discovery is not in progress \n
+ *             BLUETOOTH_ERROR_NONE+1 - Discovery in progress \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *
+ * @remark      None
+ * @see         bluetooth_start_discovery, bluetooth_cancel_discovery
+
+@code
+int ret = 0;
+ret = bluetooth_is_discovering ();
+@endcode
+ */
+int bluetooth_is_discovering(void);
+
+/**
+ * @fn int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
+ * @brief Initiate a bonding process
+ *
+ *
+ * This function initiates a bonding procedure with a peer device.  The bonding procedure
+ * enables authentication and optionally encryption on the Bluetooth link.
+ *
+ * Bonding is applied to the discovered device to which we need a secure connection. We cannot
+ * inititate the bonding request to the devices already in the paired list.
+ *
+ * Usually we call this API after the device discovery.
+ * This function is a asynchronous call.
+ *
+ * Response will be received through BLUETOOTH_EVENT_BONDING_FINISHED event. It can any of the below
+ * mentioed result code
+ * BLUETOOTH_ERROR_PARING_FAILED - Pairing faied \n
+ * BLUETOOTH_ERROR_ACCESS_DENIED - Authetication rejected \n
+ * BLUETOOTH_ERROR_CANCEL_BY_USER - Cancelled by the user \n
+ * BLUETOOTH_ERROR_PARING_FAILED - Pairing failed \n
+ * BLUETOOTH_ERROR_TIMEOUT - Timeout has haapened \n
+ *
+ * If the remote user is not responding with in a specific time(60 seconds), then a timeout happens
+ * and BLUETOOTH_EVENT_BONDING_FINISHED callback event is called with and BLUETOOTH_ERROR_TIMEOUT
+ * result code
+ *
+ * The bonding operation can be cancelled by calling bluetooth_cancel_bonding().
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_DEVICE_BUSY - Adapter is busy or Discovery is in Progress \n
+ *             BLUETOOTH_ERROR_INVALID_DATA - Invalid BD address \n
+ * @exception   None
+ * @param[in]   device_address   This indicates an address of the device with which the pairing
+ *                                     should be initiated
+ * @remark      None
+ * @see                bluetooth_cancel_bonding
+ @code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               printf("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]
+                                                       mjr[%#x] min[%#x] srv[%#x]",
+                                                       device_info->device_name.name,
+                                                       device_info->device_address.addr[0],
+                                                       device_info->device_address.addr[1],
+                                                       device_info->device_address.addr[2],
+                                                       device_info->device_address.addr[3],
+                                                       device_info->device_address.addr[4],
+                                                       device_info->device_address.addr[5],
+                                                       device_info->device_class.major_class,
+                                                       device_info->device_class.minor_class,
+                                                       device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               //bonding failed
+                       }
+                       break;
+               }
+       }
+}
+
+...
+
+int ret = 0;
+bluetooth_device_address_t device_address={{0}};
+
+ret = bluetooth_bond_device(&device_address);
+
+@endcode
+ */
+int bluetooth_bond_device(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_cancel_bonding(void)
+ * @brief Cancel the on-going bonding process
+ *
+ * This API is called to cancel the on-going bonding procedure. It should be called before the
+ * BLUETOOTH_EVENT_BONDING_FINISHED event comes.
+ * This API is useful when the remote device is not responding to the bond request or we wish to
+ * cancel the bonding request. In this case we need not wait for the timeout to happen.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_NOT_IN_OPERATION - No bonding request in progress \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ * @exception   None
+ * @remark      None
+ * @see                bluetooth_bond_device
+@code
+...
+
+int ret = 0;
+
+ret = bluetooth_cancel_bonding();
+@endcode
+ */
+int bluetooth_cancel_bonding(void);
+
+/**
+ * @fn int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)
+ * @brief Remove bonding
+ *
+ *
+ * To communicate with remote device over bluetooth link, user should bond with peer device.
+ * After bonding is over, peer device is added to list of bonded devices. bluetooth_unbond_device()
+ * API is used to remove peer device from the list. Please note that after removing the device
+ * from bonded device list, you cannot communication with peer device until bonding happens again.
+ *
+ * User can call this function by passing bluetooth device address of any bonded device. Please note
+ * that after successful return of this function, any bluetooth application running on your device
+ * will not be able to communicate with unbonded device until bond operation happens again using
+ * bluetooth_bond_device()
+ *
+ *
+ * This function is a asynchronous call. The request to remove the specified device from the bonded
+ * list is responded by an BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED event. if the operation is success,
+ * you will receive BLUETOOTH_ERROR_NONE. BLUETOOTH_ERROR_NOT_PAIRED may be received in result code
+ * in case if there is a problem in locating given bluetooth device address in bonded devices list
+ *
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Device address is not valid \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Bluetooth adapter is not enabled \n
+ *             BLUETOOTH_ERROR_DEVICE_BUSY     - Bluetooth adapter is busy doing some operation \n
+ *             BLUETOOTH_ERROR_INVALID_DATA - Device address provided is incorrect \n
+ *             BLUETOOTH_ERROR_INTERNAL - System error like heap full has occured or bluetooth
+ *                                             agent is not running \n
+ *             BLUETOOTH_ERROR_NOT_PAIRED - Device address mentioned in the argument is not a
+ *                                             bonded device \n
+ *
+ * @param[in]   device_address   This indicates an address of the device to remove bonding
+ *
+ * @remark      None
+ *
+ * @see                bluetooth_bond_device, bluetooth_cancel_bonding
+ *
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event) {
+               case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED: {
+                       bluetooth_device_address_t *dev_addr = NULL;
+
+                       if (param->result == BLUETOOTH_ERROR_NONE) {
+                               dev_addr = (bluetooth_device_address_t *)param->param_data;
+                               //Unbound scuccess
+                               printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                       dev_addr->addr[0], dev_addr->addr[1]
+                                       dev_addr->addr[2], dev_addr->addr[3]
+                                       dev_addr->addr[4], dev_addr->addr[5]
+                       } else {
+                               //unbound failure
+                       }
+               }
+       }
+}
+
+...
+
+int ret = 0;
+bluetooth_device_address_t *device_address;
+
+// copy valid device address in device_address
+
+ret = bluetooth_unbond_device(device_address);
+@endcode
+ */
+int bluetooth_unbond_device(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_get_bonded_device_list(GPtrArray **dev_list)
+ * @brief Get bonded(paired) device list
+ *
+ *
+ * This API gets all bonded device list.
+ * The devices in the bonded device list further can be used to perform the authorization by calling
+ * bluetooth_authorize_device API.
+ *
+ * This function is a synchronous call.
+ * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
+ * there is no valid information in the dev_list.
+ * The len field in the dev_list represents the number of bonded devices. The data structure for
+ * bonded device information is bluetooth_device_info_t.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
+ * @remark      None
+ * @see                bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
+ @code
+void bt_get_bonded_devices(void)
+{
+...
+       int i;
+       GPtrArray *devinfo = NULL;
+       bluetooth_device_info_t *ptr;
+
+       // allocate the g_pointer_array
+       devinfo = g_ptr_array_new();
+
+       ret = bluetooth_get_bonded_device_list(&devinfo);
+       if (ret != BLUETOOTH_ERROR_NONE)
+       {
+               printf("bluetooth_get_bonded_device_list failed with [%d]",ret);
+       }
+       else
+       {
+               printf("g pointer arrary count : [%d]", devinfo->len);
+               for(i=0; i<devinfo->len;i++)
+               {
+                       ptr = g_ptr_array_index(devinfo, i);
+                       if(ptr != NULL)
+                       {
+                               printf("Name [%s]\n", ptr->device_name.name);
+                               printf("Major Class [%d]\n", ptr->device_class.major_class);
+                               printf("Minor Class [%d]\n", ptr->device_class.minor_class);
+                               printf("Service Class [%d]\n", ptr->device_class.service_class);
+                               printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                                               ptr->device_address.addr[0],
+                               ptr->device_address.addr[1], ptr->device_address.addr[2],
+                                                               ptr->device_address.addr[3],
+                               ptr->device_address.addr[4], ptr->device_address.addr[5]);
+
+                               // handle
+                               ...
+                       }
+               }
+       }
+       // free g_pointer_array
+       g_ptr_array_free(devinfo, TRUE);
+}
+
+@endcode
+ */
+int bluetooth_get_bonded_device_list(GPtrArray **dev_list);
+
+/**
+ * @fn int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
+ *                                     bluetooth_device_info_t *dev_info)
+ * @brief Get a bonded(paired) device
+ *
+ *
+ * This API gets a bonded device.
+ *
+ * This function is a synchronous call.
+ * Information for bonded devices can be obtained when result code is BLUETOOTH_ERROR_NONE. If not,
+ * there is no valid information in the dev_info.
+ * The data structure for bonded device information is bluetooth_device_info_t.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_NOT_SUPPORT - Opreation not supported \n
+ * @remark      None
+ * @see                bluetooth_bond_device, bluetooth_unbond_device, bluetooth_authorize_device
+ @code
+void bt_get_bonded_device(void)
+{
+...
+       int i;
+       bluetooth_device_info_t devinfo = {0};
+       bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}};
+
+       ret = bluetooth_get_bonded_device(&device_address, &devinfo);
+       if (ret != BLUETOOTH_ERROR_NONE)
+       {
+               printf("bluetooth_get_bonded_device failed with [%d]",ret);
+       }
+       else
+       {
+               printf("Name [%s]\n", devinfo.device_name.name);
+               printf("Major Class [%d]\n", devinfo.device_class.major_class);
+               printf("Minor Class [%d]\n", devinfo.device_class.minor_class);
+               printf("Service Class [%d]\n", devinfo.device_class.service_class);
+               printf("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", devinfo.device_address.addr[0],
+               devinfo.device_address.addr[1], devinfo.device_address.addr[2],
+               devinfo.device_address.addr[3], devinfo.device_address.addr[4],
+               devinfo.device_address.addr[5]);
+
+               // handle
+               ...
+       }
+}
+
+@endcode
+ */
+int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
+                                       bluetooth_device_info_t *dev_info);
+
+/**
+ * @fn int bluetooth_set_alias(const bluetooth_device_address_t *device_address, const char *alias)
+ * @brief set alias for bonded device
+ *
+ *
+ * This function set alias for bonded device.
+ *
+ * This function is a synchronous call.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ * @param[in]   device_address   This indicates an address of the remote device
+ * @param[in]   alias                  This indicates an alias to set
+ * @remark      None
+ * @see                None
+@code
+int ret = 0;
+ret = bluetooth_set_alias(&remote_address);
+@endcode
+ */
+int bluetooth_set_alias(const bluetooth_device_address_t *device_address,
+                               const char *alias);
+
+/**
+ * @fn int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
+ * @brief Get remote deivice
+ *
+ *
+ * This function gets specific remote device.
+ *
+ * This function is a asynchronous call.
+ * This API is responded by an BLUETOOTH_EVENT_REMOTE_DEVICE_READ event.
+ *
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_NOT_SUPPORT - Operation not supported \n
+ * @param[in]   device_address   This indicates an address of the remote device
+ * @remark      None
+ * @see                None
+@code
+int ret = 0;
+ret = bluetooth_get_remote_device(&remote_address);
+@endcode
+ */
+int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
+ *                                     gboolean authorized)
+ * @brief Authorize/Unauthorize a bonded device
+ *
+ *
+ * This function authorizes/unauthorize a bonded device. It decides the device to connect
+ * with/without user confirmation.
+ *
+ * If we select a paired device and make it authorized by calling this API with the authorized
+ * parameter to TRUE, then it will not ask for the user conformation before connecting. Similarly
+ * if we unauthorize the paired device by calling this API with the authorized parameter to FALSE,
+ * then it will ask for the user conformation before the connection.
+ *
+ * This API supposed to be called on the paired devices. Which means we have to use this API only
+ * after successful pairing.
+ *
+ * This function is a asynchronous call.
+ * Response will be received through BLUETOOTH_EVENT_DEVICE_AUTHORIZED event.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ * @exception   BLUETOOTH_ERROR_INTERNAL - Cannot get the interal DBUS proxy \n
+ * @param[in]   device_address   This indicates an address of the device to authorize \n
+ * @param[in]  authorized      TRUE : authorize FALSE: unauthorize
+ * @remark      None
+ * @see                bluetooth_get_bonded_device_list
+@code
+void bt_event_callback(int event, bluetooth_event_param_t *param)
+{
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
+               {
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               //Device authorized
+                       }
+                       //device authorization failed failure
+               }
+       }
+}
+
+...
+
+int ret = 0;
+bluetooth_device_address_t device_address={{0}};
+gboolean authorized;
+
+authorized =TRUE;
+
+ret = bluetooth_authorize_device(&device_address,authorized);
+@endcode
+ */
+int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
+                                      gboolean authorized);
+
+/**
+ * @fn int bluetooth_search_service(const bluetooth_device_address_t *device_address)
+ * @brief Get all services supported by remote device
+ *
+ *
+ * This API call initiates the search for the services supported by the specified device. Normally
+ * the service search will take a couple of seconds to get it completed. Before calling this API
+ * make sure that the Adapter is enabled. We have to give the device address of the remote device to
+ * perform the service search. We can get the device address by doing a device discovery operation.
+ *
+ *
+ * This function is a asynchronous call.
+ * The service search request is responded by BLUETOOTH_EVENT_SERVICE_SEARCHED event.
+ *
+ * There is a timeout associated with the service search. The default time out is 40 seconds. If the
+ * remove device did not respond with in the time out period the BLUETOOTH_EVENT_SERVICE_SEARCHED
+ * event is generated with appropriate result code.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR - Service search error (NULL device address) \n
+ *             BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
+ * @param[in]   device_address   This indicates an address of the device
+ *                               whose services need to be found
+ * @remark      None
+ * @see                bluetooth_cancel_service_search
+ */
+int bluetooth_search_service(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_cancel_service_search(void)
+ * @brief Cancel the ongoing service search operation
+ *
+ *
+ * This function cancel the ongoing service search operation. This API is usually calling after the
+ * bluetooth_search_service API.
+ * Normally service search will take a more time (> 5 seconds) to complete. This API will be called
+ * if the user wish to cancel the Ongoing service search operation.
+ *
+ * This API should be called just after the bluetooth_search_service API and before the
+ * BLUETOOTH_EVENT_SERVICE_SEARCHED event
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_CANCEL - Error in service search cancel operation \n
+ *             BLUETOOTH_ERROR_NOT_PAIRED - Not paired device \n
+ *             BLUETOOTH_ERROR_NOT_IN_OPERATION - Searching service is not in operation \n
+ *
+ * @remark      None
+ * @see                bluetooth_search_service
+@code
+...
+
+int ret = 0;
+ret = bluetooth_cancel_service_search();
+@endcode
+*/
+int bluetooth_cancel_service_search(void);
+
+/**
+ * @fn int bluetooth_rfcomm_create_socket(const char *uuid)
+ * @brief Register rfcomm socket with a specific uuid
+ *
+ *
+ * This API register rfcomm socket with the given UUID. The return value of this API is the socket
+ * descriptor of the server.
+ * This is the first API which is called to create the server. Once we created the server socket,
+ * we will listen on that return socket.
+ * So a bluetooth_rfcomm_listen_and_accept should follow this API call. This is a synchronous call.
+ *
+ *
+ * @return  socket FD on Success \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal error\n
+ *              BLUETOOTH_ERROR_MAX_CONNECTION - Maximum connection reached\n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ * @param[in]   UUID (128 bits)
+ *
+ * @remark      None
+ * @see       bluetooth_rfcomm_listen_and_accept, bluetooth_rfcomm_remove_socket
+ *
+ @code
+
+  const char *rfcomm_test_uuid="00001101-0000-1000-8000-00805F9B34FB";
+  fd  = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
+
+ @endcode
+ */
+int bluetooth_rfcomm_create_socket(const char *uuid);
+
+/**
+ * @fn int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
+ * @brief De-register the rfcomm socket
+ *
+ *
+ * This API deregister rfcomm socket with the given socket fd and  UUID. If the remote device is
+ * already connected then we will receive the BLUETOOTH_EVENT_RFCOMM_DISCONNECTED with socket
+ * descriptor else no event will come. We will call this API only after the
+ * bluetooth_rfcomm_listen_and_accept.
+ * This is a synchronous call.
+ *
+ * @return   BLUETOOTH_ERROR_NONE - Success \n
+ *               BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
+ *               BLUETOOTH_ERROR_NOT_FOUND - Cannot find the proxy\n
+ *               BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ * @param[in]  int socket_fd
+ * @param[in]   UUID (128 bits)
+ *
+ * @remark      None
+ * @see       bluetooth_rfcomm_create_socket, bluetooth_rfcomm_listen_and_accept
+ *
+ @code
+ void bt_event_callback(int event, bluetooth_event_param_t *param)
+ {
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *discon_ind =
+                                       (bluetooth_rfcomm_connection_t *)param->param_data;
+
+                       printf("\nDisconnected from FD %d",  discon_ind->socket_fd);
+               }
+       }
+ }
+
+ ...
+
+ int ret = 0;
+ fd  = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
+ ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
+ ....
+ ret = bluetooth_rfcomm_remove_socket(fd, rfcomm_test_uuid);
+ @endcode
+ */
+int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid);
+
+/**
+ * @fn int bluetooth_rfcomm_listen_and_accept(int socket_fd,int max_pending_connection)
+ * @brief Rfcomm socket listen
+ *
+ *
+ * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
+ * after the bluetooth_rfcomm_create_socket API.
+ * This API listen for the incomming connection and once it receives a connection, it will give
+ * BLUETOOTH_EVENT_RFCOMM_CONNECTED
+ * event to the application. This is an Asynchronous API call.
+ *
+ *
+ * @return  BLUETOOTH_ERROR_NONE - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
+
+ * @param[in]  int socket_fd
+ * @param[in]  max pending connection.
+ *
+ * @remark      None
+ * @see       bluetooth_rfcomm_create_socket
+ *
+  @code
+  void bt_event_callback(int event, bluetooth_event_param_t* param)
+ {
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *conn_ind =
+                                               (bluetooth_rfcomm_connection_t *)param->param_data;
+
+                       printf("\nConnected from FD %d",  conn_ind->socket_fd);
+               }
+       }
+ }
+
+ ...
+
+ int ret = 0;
+ fd  = bluetooth_rfcomm_create_socket(rfcomm_test_uuid);
+ ret = bluetooth_rfcomm_listen_and_accept(fd, 1);
+
+ @endcode
+ */
+int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection);
+
+/**
+ * @fn int bluetooth_rfcomm_connect(const bluetooth_device_address_t  *remote_bt_address,
+ *                                                                     const char *remote_uuid)
+ * @brief Connect to the remote device rfcomm *
+ *
+ * Connect to a specific RFCOMM based service on a remote device UUID. This is a Async call. Once
+ * the connection is successful callback BLUETOOTH_EVENT_RFCOMM_CONNECTED events is generated,
+ * which contains the socket_fd, device role (RFCOMM_ROLE_SERVER/RFCOMM_ROLE_CLIENT), device addess
+ * etc. The socket_fd can be further used to send the data. It better to do a sevice search before
+ * initiating a connection.
+ *
+ * @return  BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_CONNECTION_BUSY - Connection in progress \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error\n
+ * @param[in]  bluetooth_device_address_t remote bt_address
+ * @param[in]  char remote uuid
+ * @remark      None
+ * @see         bluetooth_rfcomm_disconnect, bluetooth_rfcomm_write, bluetooth_search_service
+ *
+ @code
+
+ void bt_event_callback(int event, bluetooth_event_param_t *param)
+ {
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_SERVICE_SEARCHED:
+               {
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bt_sdp_info_t *bt_sdp_info=param->param_data;
+
+                               printf("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                       bt_sdp_info->device_addr.addr[0],
+                                       bt_sdp_info->device_addr.addr[1],
+                                       bt_sdp_info->device_addr.addr[2],
+                                       bt_sdp_info->device_addr.addr[3],
+                                       bt_sdp_info->device_addr.addr[4],
+                                       bt_sdp_info->device_addr.addr[5]);
+
+                                       printf("Supported service list:\n");
+                                       for(i=0; i<bt_sdp_info->service_index; i++)
+                                               printf("[%#x]\n",
+                                                       bt_sdp_info->service_list_array[i]);
+
+                               //Alternate method
+                               //ret = bluetooth_rfcomm_connect(bt_sdp_info->device_addr,
+                                                                               //rfcomm_test_uuid);
+                       }
+                       break;
+               }
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *conn_ind =
+                                               (bluetooth_rfcomm_connection_t *)param->param_data;
+
+                       printf("\nConnected from FD %d, Role = %s",  conn_ind->socket_fd,
+                                               (conn_ind->device_role == RFCOMM_ROLE_SERVER) ?
+                                                                       "SERVER" : "CLIENT");
+               }
+       }
+ }
+
+  bluetooth_device_address_t remote_address = {{0},};
+  remote_address.addr[0] = 0x0; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A;
+  remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19;  remote_address.addr[5]= 0x36;
+  ret = bluetooth_search_service(&remote_address);
+ if (ret < 0)
+       printf("Seach failed, Reason = %d", ret);
+  else
+        printf("Search Success, Ret = %d", ret);
+
+  ret = bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid);
+  if (ret < 0)
+       printf("Connection failed, Reason = %d", ret);
+  else
+        printf("Connection Success, Ret = %d", ret);
+
+  @endcode
+  */
+int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
+                                    const char *remote_uuid);
+
+/**
+ * @fn int bluetooth_rfcomm_disconnect(int socket_fd)
+ * @brief Disconnect rfcomm connection
+ *
+ *
+ * Disconnect a specific(device node fd)  RFCOMM connection. This is a Synchronous call and there
+ * is no cabbback events for this API. We have to provice the valid client fd to disconnect from the
+ * remote server.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_NOT_CONNECTED - Not connected \n
+ * @param[in]  char remote bt_address
+ *
+ * @remark      None
+ * @see         bluetooth_rfcomm_connect
+ *
+ @code
+
+  ret = bluetooth_rfcomm_disconnect(g_ret_fd);
+  if (ret < 0)
+       printf("Disconnection failed");
+  else
+  printf("Disconnection Success");
+
+ @endcode
+ */
+
+int bluetooth_rfcomm_disconnect(int socket_fd);
+
+/**
+ * @fn int bluetooth_rfcomm_write (int fd, const char *buff, int length)
+ * @brief Write to rfcomm connection
+ *
+ *
+ * This API is used to send the data over the rfcomm connection. This is a synchronous API. The same
+ * API is used to send the data for server and the client.
+ *
+ * @return  BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_NOT_IN_OPERATION - The Fd is currently not in operation\n
+ * @param[in]  int fd
+ * @param[in]  const char *buff  Data buffer to send
+ * @param[in]  int length Length of the data
+ *
+ * @remark      None
+ * @see         bluetooth_rfcomm_connect
+ *
+  @code
+  char *buff = "Test data 123456789"
+  ret =  bluetooth_rfcomm_write(g_ret_fd, buff, 15);
+  if (ret < 0)
+       printf("Send failed");
+  else
+   printf("Send success");
+
+ @endcode
+ */
+int bluetooth_rfcomm_write(int fd, const char *buf, int length);
+
+/**
+ * @fn int bluetooth_network_activate_server(void)
+ * @brief Activate the NAP (Network Access Point) service
+ *
+ * This function is a asynchronous call.
+ * The activate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
+ *
+ * @remark      None
+  * @see       bluetooth_network_deactivate_server
+ *
+ */
+int bluetooth_network_activate_server(void);
+
+/**
+ * @fn int bluetooth_network_deactivate_server(void)
+ * @brief Deactivate the NAP (Network Access Point) service
+ *
+ * This function is a asynchronous call.
+ * The deactivate server request is responded by BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
+ *
+ * @remark      None
+ * @see                bluetooth_network_activate_server
+ *
+ */
+int bluetooth_network_deactivate_server(void);
+
+/**
+ * @fn int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
+ *                                     bluetooth_network_role_t role,
+ *                                     char  custom_uuid)
+ * @brief Connect the network server in the peer
+ *
+ * This function is a asynchronous call.
+ * The network connect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
+ *
+ * @exception   None
+ * @param[in]  device_address   This indicates an address of the device with which the pairing
+ *                             should be initiated
+ * @param[in]  role   The role to connect. PANU / GN / NAP / CUSTOM. If use the CUSTOM value,
+ *                     need to use the third parameter.
+ * @param[in]  custom_uuid   If use the CUSTOM value in second parameter, use this parameter to
+ *                             connect. UUID string
+ * @remark      None
+ * @see                bluetooth_network_disconnect
+ */
+int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
+                                     bluetooth_network_role_t role, char *custom_uuid);
+
+/**
+ * @fn int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address,
+ *                                                     bluetooth_network_role_t role,
+ *                                                       char *custom_uuid)
+ * @brief Connect the network server in the peer
+ *
+ * This function is a asynchronous call.
+ * The network disconnect request is responded by BLUETOOTH_EVENT_NETWORK_CONNECTED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Not enabled \n
+ *
+ * @exception   None
+ * @param[in]   device_address   This indicates an address of the device with which the pairing
+ *                                     should be initiated
+ * @remark       None
+ * @see                bluetooth_network_connect
+ */
+int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address);
+
+/*HDP - API's*/
+
+/**
+ * @fn int bluetooth_hdp_activate(unsigned short  data_type,
+ *                                     bt_hdp_role_type_t role,
+ *                                     bt_hdp_qos_type_t channel_type)
+ * @brief Activate the HDP service for a particular data type
+ *
+ * This function is a asynchronous call.
+ * The HDP activate is responded by BLUETOOTH_EVENT_HDP_ACTIVATED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *
+ * @exception   None
+ * @param[in]  data_type   The data type against corresponding service
+ * @param[in]  role   The role of HDP. HDP_ROLE_SOURCE/HDP_ROLE_SINK.
+ * @param[in]  channel_type   The QOS type for the channel.
+ *                             HDP_QOS_RELIABLE/HDP_QOS_STREAMING/HDP_QOS_ANY.
+ *                             For role = HDP_ROLE_SINK, the channel_type
+ *                             should be HDP_QOS_ANY.
+ * @remark       None
+ * @see           bluetooth_hdp_deactivate
+ */
+int bluetooth_hdp_activate(unsigned short  data_type,
+                               bt_hdp_role_type_t role,
+                               bt_hdp_qos_type_t channel_type);
+/**
+ * @fn int bluetooth_hdp_deactivate(const char *app_handle)
+ * @brief Deactivate the HDP service for a particular service using the handler
+ *
+ * This function is a asynchronous call.
+ * The HDP activate is responded by BLUETOOTH_EVENT_HDP_DEACTIVATED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *
+ * @exception   None
+ * @param[in]  app_handle   The application handler against corresponding service
+ * @remark       None
+ * @see           bluetooth_hdp_deactivate
+ */
+int bluetooth_hdp_deactivate(const char *app_handle);
+
+/**
+ * @fn int bluetooth_hdp_send_data(unsigned int channel_id,
+ *                                     const char *buffer, unsigned int size)
+ * @brief Send data to the remote HDP device
+ *
+ * This function is a synchronous call.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *             BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *             BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *             BLUETOOTH_ERROR_NOT_IN_OPERATION - FD is invalid  \n
+ *
+ * @exception   None
+ * @param[in]  channel_id   The channel id for the connection.
+ * @param[in]  buffer   The pdu buffer.
+ * @param[in]  size   Size of the buffer.
+ * @remark       None
+ * @see           bluetooth_hdp_connect
+ */
+int bluetooth_hdp_send_data(unsigned int channel_id,
+                               const char *buffer, unsigned int size);
+/**
+ * @fn int bluetooth_hdp_connect(const char *app_handle,
+ *                             bt_hdp_qos_type_t channel_type,
+ *                             const bluetooth_device_address_t *device_address)
+ * @brief Connect to the remote device(Mainly used by source)
+ *
+ * This function is a asynchronous call.
+ * The HDP activate is responded by BLUETOOTH_EVENT_HDP_CONNECTED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *              BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
+ *
+ * @exception   None
+ * @param[in]  app_handle   The application handler against corresponding service
+ * @param[in]  channel_type   The QOS type for the channel.
+ *                             HDP_QOS_RELIABLE/HDP_QOS_STREAMING.
+ * @param[in]  device_address   The remote device Bd address.
+ *
+ * @remark       None
+ * @see           bluetooth_hdp_disconnect
+ */
+int bluetooth_hdp_connect(const char *app_handle,
+                       bt_hdp_qos_type_t channel_type,
+                       const bluetooth_device_address_t *device_address);
+/**
+ * @fn int bluetooth_hdp_disconnect(unsigned int channel_id,
+ *                     const bluetooth_device_address_t *device_address)
+ * @brief Disconnect from the remote device(Mainly used by source)
+ *
+ * This function is a asynchronous call.
+ * The HDP activate is responded by BLUETOOTH_EVENT_HDP_DISCONNECTED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+  *              BLUETOOTH_ERROR_MEMORY_ALLOCATION -Memory allocation failed \n
+ *
+ * @exception   None
+ * @param[in]  channel_id    The channel id for the connection.
+ * @param[in]  device_address   The remote device Bd address.
+ *
+ * @remark       None
+ * @see           bluetooth_hdp_connect
+ */
+int bluetooth_hdp_disconnect(unsigned int channel_id,
+                       const bluetooth_device_address_t  *device_address);
+
+
+/**
+ * @fn int bluetooth_opc_init(void)
+ * @brief Initialize OPP client.
+ *
+ * This function is a synchronous call.
+ * No event corresponding to this api
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+  *             BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
+ *
+ * @exception   None
+ *
+ * @remark       None
+ * @see          bluetooth_opc_deinit
+ */
+int bluetooth_opc_init(void);
+
+/**
+ * @fn int bluetooth_opc_deinit(void)
+ * @brief Deinitialize OPP client.
+ *
+ * This function is a synchronous call.
+ * No event corresponding to this api
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+  *             BLUETOOTH_ERROR_ACCESS_DENIED -Memory allocation failed \n
+ *
+ * @exception   None
+ *
+ * @remark       None
+ * @see          bluetooth_opc_init
+ */
+
+ int bluetooth_opc_deinit(void);
+
+/**
+ * @fn int bluetooth_opc_push_files(bluetooth_device_address_t *device_address,
+                                       unsigned char **file_name_array)
+ * @brief Send multiple files to a remote device.
+ *
+ * This function is a asynchronous call.
+ * This api  is responded by BLUETOOTH_EVENT_OPC_CONNECTED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+  *             BLUETOOTH_ERROR_IN_PROGRESS -Already one push in progress \n
+ *
+ * @exception   None
+ * @param[in]  device_address   The remote device Bd address.
+ * @param[in]  file_name_array  Array of filepaths to be sent.
+ *
+ * @remark       None
+ * @see         bluetooth_opc_cancel_push
+ */
+
+int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
+                               char **file_name_array);
+
+/**
+ * @fn int bluetooth_opc_cancel_push(void)
+ * @brief Cancels the ongoing file push.
+ *
+ * This function is a asynchronous call.
+ * This api is responded with either BLUETOOTH_EVENT_OPC_CONNECTED or
+ * BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETED event.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+  *             BLUETOOTH_ERROR_ACCESS_DENIED - No push in progress \n
+ *
+ * @exception   None
+ *
+ * @remark       None
+ * @see          bluetooth_opc_push_files
+ */
+
+int bluetooth_opc_cancel_push(void);
+
+/**
+ * @fn gboolean bluetooth_opc_sessioin_is_exist(void)
+ * @brief Informs whether opc session exists or not.
+ *
+ * This function is a synchronous call.
+ *
+ * @return   TRUE  - OPC session exists \n
+ *              FALSE - OPC session does not exist \n
+ *
+ * @exception   None
+ *
+ * @remark       None
+ * @see         None
+ */
+
+gboolean bluetooth_opc_sessioin_is_exist(void);
+
+
+/**
+ * @fn int bluetooth_obex_server_init(char *dst_path)
+ * @brief Initialize OPP and FTP server.
+ *
+ * This function is a synchronous call.
+ * No event corresponding to this api
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+  *             BLUETOOTH_ERROR_AGENT_ALREADY_EXIST - Obex agent already registered \n
+ *
+ * @exception   None
+ *
+ * @remark       None
+ * @see          bluetooth_obex_server_deinit
+ */
+int bluetooth_obex_server_init(char *dst_path);
+
+/**
+ * @fn int bluetooth_obex_server_deinit(void)
+ * @brief Deinitialize OPP and FTP server.
+ *
+ * This function is a synchronous call.
+ * No event corresponding to this api
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *              BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
+ *
+ * @exception   None
+ * @param[in]  dst_path   OPS destination file path.
+
+ * @remark       None
+ * @see          bluetooth_obex_server_init
+ */
+
+int bluetooth_obex_server_deinit(void);
+
+
+/**
+ * @fn gboolean bluetooth_obex_server_is_activated(void)
+ * @brief Informs whether obex server is activated or not.
+ *
+ * This function is a synchronous call.
+ *
+ * @return   TRUE  - OBEX server is activated \n
+ *              FALSE - OBEX server is not activated \n
+ *
+ * @exception   None
+ *
+ * @remark       None
+ */
+
+gboolean bluetooth_obex_server_is_activated(void);
+
+
+/**
+ * @fn int bluetooth_obex_server_accept_authorize(char *filename)
+ * @brief Accepts the authorization request indicated by the event
+  * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
+ *
+ * This function is a asynchronous call.
+ * This api will be responded with the event BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *              BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
+ *
+ * @exception   None
+ * @param[in]  filename   Authorized filename.
+
+ * @remark       None
+ * @see          bluetooth_obex_server_reject_authorize
+ */
+
+int bluetooth_obex_server_accept_authorize(char *filename);
+
+/**
+ * @fn int bluetooth_obex_server_reject_authorize(void)
+ * @brief Reject the authorization request indicated by the event
+  * BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE.
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *              BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
+ *
+ * @exception   None
+
+ * @remark       None
+ * @see          bluetooth_obex_server_accept_authorize
+ */
+
+int bluetooth_obex_server_reject_authorize(void);
+
+/**
+ * @fn int bluetooth_obex_server_set_destination_path(char *dst_path)
+ * @brief Set the OPS destination file path..
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *              BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n
+ *
+ * @exception   None
+ * @param[in]  dst_path   OPS destination file path.
+
+ * @remark       None
+ * @see         None
+ */
+
+int bluetooth_obex_server_set_destination_path(char *dst_path);
+
+/**
+ * @fn int bluetooth_obex_server_set_root(char *root)
+ * @brief Set the FTS root folder..
+ *
+ * This function is a asynchronous call.
+ * No event for this api..
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *              BLUETOOTH_ERROR_NO_RESOURCES - Not resource available \n
+ *              BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST -Obex agent not registered \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid Param \n
+ *
+ * @exception  None
+ * @param[in]   root   FTS root folder.
+
+ * @remark       None
+ * @see         None
+ */
+
+int bluetooth_obex_server_set_root(char *root);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* _BLUETOOTH_API_H_*/
diff --git a/lib/bluetooth-api.pc.in b/lib/bluetooth-api.pc.in
new file mode 100644 (file)
index 0000000..4a1eda5
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: bluetooth-api
+Description: SAMSUNG Linux platform Bluetooth framework API
+Version: @VERSION@
+Requires: dlog dbus-glib-1 vconf
+Libs: -L${libdir} -lbluetooth-api
+Cflags: -I${includedir} -I${includedir}/bluetooth-api
diff --git a/lib/bluetooth-gap-api.c b/lib/bluetooth-gap-api.c
new file mode 100644 (file)
index 0000000..f1f56fd
--- /dev/null
@@ -0,0 +1,1912 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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-gap-api.h"
+
+static bluetooth_discovery_option_t discovery_option = { 0 };
+
+static int __bluetooth_internal_bonding_req(void);
+static void __bluetooth_internal_get_service_list(GValue *value, bluetooth_device_info_t *dev);
+
+BT_EXPORT_API int bluetooth_check_adapter(void)
+{
+       int adapter_state = BLUETOOTH_ADAPTER_DISABLED;
+
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == TRUE) {
+               adapter_state = BLUETOOTH_ADAPTER_ENABLED;
+       }
+
+       DBG("-\n");
+
+       return adapter_state;
+}
+
+void _bluetooth_internal_enabled_cb(void)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       if (bt_internal_info->bt_change_state_timer != 0) {
+               g_source_remove(bt_internal_info->bt_change_state_timer);
+               bt_internal_info->bt_change_state_timer = 0;
+       }
+
+       DBG("%s", bt_internal_info->bt_local_name.name);
+
+       /* Vconf value is not exist */
+       if (strlen(bt_internal_info->bt_local_name.name) == 0)
+               _bluetooth_get_default_adapter_name(&bt_internal_info->bt_local_name,
+                                               BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+
+       DBG("%s", bt_internal_info->bt_local_name.name);
+
+       /* default name setting*/
+       if (bluetooth_set_local_name(&bt_internal_info->bt_local_name) < 0)
+               ERR("init name setting failed");
+
+       bt_event.event = BLUETOOTH_EVENT_ENABLED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = NULL;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return;
+}
+
+void _bluetooth_internal_disabled_cb(void)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       if (bt_internal_info->bt_change_state_timer != 0) {
+               g_source_remove(bt_internal_info->bt_change_state_timer);
+               bt_internal_info->bt_change_state_timer = 0;
+       }
+
+       bt_event.event = BLUETOOTH_EVENT_DISABLED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = NULL;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return;
+}
+
+static int __bluetooth_internal_change_status_timeout_cb(void *data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       bt_internal_info->bt_change_state_timer = 0;
+
+       if (bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_ENABLE) {
+               bt_event.event = BLUETOOTH_EVENT_ENABLED;
+               bt_internal_info->bt_adapter_state = BLUETOOTH_ADAPTER_DISABLED;
+       } else if (bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_DISABLE) {
+               bt_event.event = BLUETOOTH_EVENT_DISABLED;
+               bt_internal_info->bt_adapter_state = BLUETOOTH_ADAPTER_ENABLED;
+       } else {
+               ERR("Wrong adapter state [%d]", bt_internal_info->bt_adapter_state);
+               return 0;
+       }
+
+       bt_event.result = BLUETOOTH_ERROR_TIMEOUT;
+       bt_event.param_data = NULL;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return 0;
+}
+
+static void __bluetooth_internal_change_state_req_finish_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                         gpointer user_data)
+{
+       GError *err = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+");
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
+
+       if (err != NULL) {
+               DBG("Error occured in change state [%s]", err->message);
+               g_error_free(err);
+
+               if (bt_internal_info->bt_change_state_timer != 0) {
+                       g_source_remove(bt_internal_info->bt_change_state_timer);
+                       bt_internal_info->bt_change_state_timer = 0;
+               }
+
+               if (bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_ENABLE) {
+                       bt_event.event = BLUETOOTH_EVENT_ENABLED;
+                       bt_internal_info->bt_adapter_state = BLUETOOTH_ADAPTER_DISABLED;
+               } else if (bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_DISABLE) {
+                       bt_event.event = BLUETOOTH_EVENT_DISABLED;
+                       bt_internal_info->bt_adapter_state = BLUETOOTH_ADAPTER_ENABLED;
+               } else {
+                       ERR("Wrong adapter state [%d]", bt_internal_info->bt_adapter_state);
+                       return;
+               }
+
+               bt_event.result = BLUETOOTH_ERROR_CANCEL_BY_USER;
+               bt_event.param_data = NULL;
+               if (bt_internal_info->bt_cb_ptr) {
+                       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                                   bt_internal_info->user_data);
+               }
+
+               return;
+       }
+
+       DBG("-");
+}
+
+static int __bluetooth_internal_enable_adapter(void *data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       /*BT intiate call to agent*/
+       if (dbus_g_proxy_begin_call(bt_internal_info->agent_proxy, "ConfirmMode",
+               (DBusGProxyCallNotify) __bluetooth_internal_change_state_req_finish_cb, NULL, NULL,
+               G_TYPE_STRING, "enable", G_TYPE_INVALID) == NULL) {
+               DBG("Agent call failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               bt_internal_info->bt_change_state_timer =
+                   g_timeout_add_seconds(BLUETOOTH_CHANGE_STATUS_TIMEOUT,
+                                         __bluetooth_internal_change_status_timeout_cb, NULL);
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_enable_adapter(void)
+{
+       bt_info_t *bt_internal_info = NULL;
+       int value;
+
+       DBG("+\n");
+
+       /* If the MDM set the allow value to FALSE, can't enable the adapter */
+       if (!vconf_get_bool(BT_MEMORY_KEY_RESTRICTION, &value)) {
+               if (value == 1) {
+                       DBG("Not allow to enable adapter!!");
+                       return BLUETOOTH_ERROR_ACCESS_DENIED;
+               }
+       }
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (_bluetooth_internal_is_adapter_enabled() == TRUE) {
+               DBG("Currently Enabled");
+               return BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
+       }
+
+       /* This information is the local state, other process can't know this information */
+       /* Nevertheless we add this code to avoid the unexpected result in one process */
+       if (bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_ENABLE ||
+           bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_DISABLE) {
+               DBG("Currently changing adapter state [%d]", bt_internal_info->bt_adapter_state);
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       }
+
+       bt_internal_info->bt_adapter_state = BLUETOOTH_ADAPTER_CHANGING_ENABLE;
+
+       DBG("-\n");
+       return __bluetooth_internal_enable_adapter(NULL);
+}
+
+static int __bluetooth_internal_disable_adapter(void *data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       /* BT terminate call to agent*/
+       if (dbus_g_proxy_begin_call(bt_internal_info->agent_proxy, "ConfirmMode",
+               (DBusGProxyCallNotify) __bluetooth_internal_change_state_req_finish_cb, NULL, NULL,
+               G_TYPE_STRING, "disable", G_TYPE_INVALID) == NULL) {
+               DBG("Agent call failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               bt_internal_info->bt_change_state_timer =
+                   g_timeout_add_seconds(BLUETOOTH_CHANGE_STATUS_TIMEOUT,
+                                         __bluetooth_internal_change_status_timeout_cb, NULL);
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_disable_adapter(void)
+{
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently Disabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       /* This information is the local state, other process can't know this information */
+       /* Nevertheless we add this code to avoid the unexpected result in one process */
+       if (bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_ENABLE ||
+           bt_internal_info->bt_adapter_state == BLUETOOTH_ADAPTER_CHANGING_DISABLE) {
+               DBG("Currently changing adapter state [%d]", bt_internal_info->bt_adapter_state);
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       }
+
+       bt_internal_info->bt_adapter_state = BLUETOOTH_ADAPTER_CHANGING_DISABLE;
+
+       return __bluetooth_internal_disable_adapter(NULL);
+}
+
+BT_EXPORT_API int bluetooth_get_local_address(bluetooth_device_address_t *local_address)
+{
+       DBG("+\n");
+       bt_info_t *bt_internal_info = NULL;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       char *address = NULL;
+
+       if (local_address == NULL) {
+               ERR("wrong parameter");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently Disabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "GetProperties", NULL,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Address");
+               address = (char *)(value ? g_value_get_string(value) : NULL);
+       }
+
+       if (address)
+               _bluetooth_internal_convert_addr_string_to_addr_type(local_address, address);
+       else
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_get_local_name(bluetooth_device_name_t *local_name)
+{
+       bt_info_t *bt_internal_info = NULL;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       char *name = NULL;
+       char *ptr = NULL;
+
+       if (local_name == NULL) {
+               ERR("wrong parameter");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "GetProperties", NULL,
+                         G_TYPE_INVALID,
+                         dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                         &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Name");
+               name = (char *)(value ? g_value_get_string(value) : NULL);
+       }
+
+       if (name && (strlen(name) > 0)) {
+               /* Check the utf8 valitation & Fill the NULL in the invalid location*/
+                if (!g_utf8_validate(name, -1, (const char **)&ptr))
+                        *ptr = '\0';
+
+               memcpy(local_name->name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+       } else {
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       local_name->name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX] = '\0';
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+void _bluetooth_internal_adapter_name_changed_cb(void)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_name_t changed_name = { {0} };
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       memcpy(&changed_name, &bt_internal_info->bt_local_name, sizeof(bluetooth_device_name_t));
+       changed_name.name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX] = '\0';
+
+       bt_event.event = BLUETOOTH_EVENT_LOCAL_NAME_CHANGED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = &changed_name;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return;
+}
+
+BT_EXPORT_API int bluetooth_set_local_name(const bluetooth_device_name_t *local_name)
+{
+       bt_info_t *bt_internal_info = NULL;
+       int ret = BLUETOOTH_ERROR_NONE;
+       GError *error = NULL;
+       char *ptr = NULL;
+
+       if (local_name == NULL) {
+               ERR("wrong parameter");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (strlen(local_name->name) > BLUETOOTH_DEVICE_NAME_LENGTH_MAX) {
+               ERR("size overflow");
+               return BLUETOOTH_ERROR_INVALID_DATA;
+       }
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (!g_utf8_validate(local_name->name, -1, (const char **)&ptr))
+               *ptr = '\0';
+
+       /* Set the bluez name (BT enabled case) */
+       GValue name = { 0 };
+       g_value_init(&name, G_TYPE_STRING);
+       g_value_set_string(&name, local_name->name);
+
+       if (bt_internal_info->adapter_proxy != NULL) {
+               dbus_g_proxy_call(bt_internal_info->adapter_proxy, "SetProperty",
+                               &error, G_TYPE_STRING, "Name",
+                               G_TYPE_VALUE, &name, G_TYPE_INVALID, G_TYPE_INVALID);
+
+               if (error) {
+                       DBG("SetProperty Fail: %s", error->message);
+                       g_error_free(error);
+                       ret = BLUETOOTH_ERROR_INTERNAL;
+               } else {
+                       ret = BLUETOOTH_ERROR_NONE;
+               }
+       }
+       g_value_unset(&name);
+
+       return ret;
+}
+
+BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *
+                                                 discoverable_mode_ptr)
+{
+       DBG("+");
+       bt_info_t *bt_internal_info = NULL;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       GValue *timeout_value = NULL;
+
+       if (NULL == discoverable_mode_ptr) {
+               DBG("discoverable pointer is NULL\n", discoverable_mode_ptr);
+               return BLUETOOTH_ERROR_INVALID_DATA;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (bt_internal_info->adapter_proxy != NULL) {
+               dbus_g_proxy_call(bt_internal_info->adapter_proxy, "GetProperties", NULL,
+                                 G_TYPE_INVALID,
+                                 dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                                 &hash, G_TYPE_INVALID);
+
+               if (hash != NULL) {
+                       value = g_hash_table_lookup(hash, "Discoverable");
+                       timeout_value = g_hash_table_lookup(hash, "DiscoverableTimeout");
+
+                       if (g_value_get_boolean(value)) {
+                               if (g_value_get_uint(timeout_value) == 0)
+                                       *discoverable_mode_ptr =
+                                           BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
+                               else
+                                       *discoverable_mode_ptr =
+                                           BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
+                       } else {
+                               *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+                       }
+
+                       DBG("-");
+                       return BLUETOOTH_ERROR_NONE;
+               }
+       }
+       DBG("Error: Proxy is NULL-");
+       return BLUETOOTH_ERROR_INTERNAL;
+}
+
+BT_EXPORT_API int bluetooth_set_discoverable_mode(bluetooth_discoverable_mode_t discoverable_mode,
+                                                 int timeout)
+{
+       DBG("+");
+       int ret = BLUETOOTH_ERROR_NONE;
+       bt_info_t *bt_internal_info = NULL;
+       gboolean inq_scan = 0;
+       gboolean pg_scan = 0;
+       GError *error = NULL;
+       GValue connectable = { 0 };
+       GValue discoverable = { 0 };
+       GValue val_timeout = { 0 };
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       g_value_init(&connectable, G_TYPE_BOOLEAN);
+       g_value_init(&discoverable, G_TYPE_BOOLEAN);
+       g_value_init(&val_timeout, G_TYPE_UINT);
+
+       DBG("Discoverable_mode = %d", discoverable_mode);
+       switch (discoverable_mode) {
+       case BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE:
+               pg_scan = TRUE;
+               inq_scan = FALSE;
+               timeout = 0;
+               break;
+       case BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE:
+               pg_scan = TRUE;
+               inq_scan = TRUE;
+               timeout = 0;
+               break;
+       case BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE:
+               inq_scan = TRUE;
+               pg_scan = TRUE;
+               break;
+       default:
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+               break;
+
+       }
+
+       g_value_set_boolean(&connectable, pg_scan);
+       g_value_set_boolean(&discoverable, inq_scan);
+       g_value_set_uint(&val_timeout, timeout);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "SetProperty", &error,
+                                  G_TYPE_STRING, "Powered", G_TYPE_VALUE, &connectable,
+                                  G_TYPE_INVALID, G_TYPE_INVALID);
+
+       if (error != NULL) {
+               DBG("Powered set err:[%s]", error->message);
+               g_error_free(error);
+               ret = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "SetProperty", &error,
+                                  G_TYPE_STRING, "Discoverable", G_TYPE_VALUE, &discoverable,
+                                  G_TYPE_INVALID, G_TYPE_INVALID);
+
+       if (error != NULL) {
+               DBG("Discoverable set err:[%s]", error->message);
+               g_error_free(error);
+               ret = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "SetProperty", &error,
+                                  G_TYPE_STRING, "DiscoverableTimeout", G_TYPE_VALUE, &val_timeout,
+                                  G_TYPE_INVALID, G_TYPE_INVALID);
+
+       if (error != NULL) {
+               DBG("Timeout set err:[%s]", error->message);
+               g_error_free(error);
+               ret = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_value_unset(&val_timeout);
+       g_value_unset(&connectable);
+       g_value_unset(&discoverable);
+
+       DBG("-");
+       return ret;
+}
+
+void _bluetooth_internal_discovery_started_cb(void)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info->bt_discovery_req_timer != 0) {
+               g_source_remove(bt_internal_info->bt_discovery_req_timer);
+               bt_internal_info->bt_discovery_req_timer = 0;
+               bt_internal_info->is_discovery_req = 1;
+       }
+
+       bt_event.event = BLUETOOTH_EVENT_DISCOVERY_STARTED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = NULL;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return;
+}
+
+void _bluetooth_internal_remote_device_found_cb(const char *address,
+                                              int rssi, unsigned int remote_class, gboolean paired)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_info_t dev_info = { { { 0 } } };
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&dev_info.device_address, address);
+       _bluetooth_internal_divide_device_class(&dev_info.device_class, remote_class);
+       dev_info.rssi = rssi;
+       dev_info.paired = paired;
+
+       bt_event.event = BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = &dev_info;
+       if (bt_internal_info->bt_cb_ptr && bt_internal_info->is_discovery_req) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return;
+}
+
+
+static bool __bluetooth_match_discovery_option(bluetooth_device_class_t device_class, unsigned int mask)
+{
+       DBG("+");
+
+       bluetooth_device_major_mask_t major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_MISC;
+
+       if (mask == 0x000000)
+               return TRUE;
+
+       DBG("mask: %x", mask);
+
+       DBG("service_class: %x", device_class.service_class);
+
+       /* Check the service_class */
+       if (device_class.service_class & mask)
+               return TRUE;
+
+       /* Check the major class */
+       switch (device_class.major_class) {
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_COMPUTER;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_PHONE;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_AUDIO;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_PERIPHERAL:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_PERIPHERAL;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_IMAGING:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_IMAGING;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_WEARABLE:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_WEARABLE;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_TOY:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_TOY;
+                       break;
+               case BLUETOOTH_DEVICE_MAJOR_CLASS_HEALTH:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_HEALTH;
+                       break;
+               default:
+                       major_mask = BLUETOOTH_DEVICE_MAJOR_MASK_MISC;
+                       break;
+       }
+
+       DBG("major_mask: %x", major_mask);
+
+       if (mask & major_mask)
+               return TRUE;
+
+       return FALSE;
+       DBG("-");
+}
+
+void _bluetooth_internal_remote_device_name_updated_cb(const char *address,
+                                                     const char *name, int rssi,
+                                                     unsigned int remote_class, gboolean paired)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_info_t dev_info = { { { 0 } } };
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       _bluetooth_internal_divide_device_class(&dev_info.device_class, remote_class);
+
+       if (__bluetooth_match_discovery_option(dev_info.device_class,
+                               discovery_option.classOfDeviceMask) == FALSE)
+               return;
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&dev_info.device_address, address);
+       if (strlen(name) <= BLUETOOTH_DEVICE_NAME_LENGTH_MAX) {
+               memcpy(&dev_info.device_name, name, strlen(name));
+       }
+
+       dev_info.rssi = rssi;
+       dev_info.paired = paired;
+
+       bt_event.event = BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = &dev_info;
+       if (bt_internal_info->bt_cb_ptr && bt_internal_info->is_discovery_req) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return;
+}
+
+void _bluetooth_internal_discovery_completed_cb(void)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       bt_event.event = BLUETOOTH_EVENT_DISCOVERY_FINISHED;
+       if (bt_internal_info->is_discovery_cancel) {
+               bt_event.result = BLUETOOTH_ERROR_CANCEL_BY_USER;
+               bt_internal_info->is_discovery_cancel = FALSE;
+       } else {
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+       }
+       bt_event.param_data = NULL;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       bt_internal_info->is_discovery_req = 0;
+
+       return;
+}
+
+static int __bluetooth_internal_discovery_req_timeout_cb(void *data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       bt_internal_info->bt_discovery_req_timer = 0;
+
+       DBG("");
+
+       dbus_g_proxy_call_no_reply(bt_internal_info->adapter_proxy, "StopDiscovery",
+                                  G_TYPE_INVALID, G_TYPE_INVALID);
+
+       bt_event.event = BLUETOOTH_EVENT_DISCOVERY_STARTED;
+       bt_event.result = BLUETOOTH_ERROR_TIMEOUT;
+       bt_event.param_data = NULL;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       return 0;
+}
+
+BT_EXPORT_API int bluetooth_start_discovery(unsigned short max_response,
+                                           unsigned short discovery_duration,
+                                           unsigned int classOfDeviceMask)
+{
+       DBG("+");
+
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (bluetooth_is_discovering() == TRUE) {
+               DBG("BT is already in discovering");
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       }
+
+       if (classOfDeviceMask > 0x800000) {
+               DBG("Not supported class");
+               return BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       if (discovery_option.max_response == 0)
+               discovery_option.max_response = 0;      /*unlimited*/
+
+       if (discovery_option.discovery_duration == 0)
+               discovery_option.discovery_duration = 180;      /* 3 minutes*/
+
+       discovery_option.classOfDeviceMask = classOfDeviceMask; /*searching Type*/
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       if (!dbus_g_proxy_call(bt_internal_info->adapter_proxy, "StartDiscovery", NULL,
+                              G_TYPE_INVALID, G_TYPE_INVALID)) {
+               DBG("Discover start failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (bt_internal_info->bt_discovery_req_timer != 0) {
+               g_source_remove(bt_internal_info->bt_discovery_req_timer);
+               bt_internal_info->bt_discovery_req_timer = 0;
+       }
+
+       bt_internal_info->bt_discovery_req_timer =
+           g_timeout_add_seconds(2, __bluetooth_internal_discovery_req_timeout_cb, NULL);
+
+       DBG("-");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_cancel_discovery(void)
+{
+       bt_info_t *bt_internal_info = NULL;
+       GError *error = NULL;
+       int ret = BLUETOOTH_ERROR_NONE;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "StopDiscovery", &error,
+                         G_TYPE_INVALID, G_TYPE_INVALID);
+
+       if (error) {
+               DBG("error in StopDiscovery [%s]\n", error->message);
+
+               if (!strcmp(error->message, "Invalid discovery session"))
+                       ret = BLUETOOTH_ERROR_NOT_IN_OPERATION;
+               else
+                       ret = BLUETOOTH_ERROR_INTERNAL;
+
+               g_error_free(error);
+               DBG("Discover stop failed");
+               return ret;
+       }
+
+       bt_internal_info->is_discovery_cancel = TRUE;
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_is_discovering(void)
+{
+       bt_info_t *bt_internal_info = NULL;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       int is_discovering = 0;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy != NULL) {
+               dbus_g_proxy_call(bt_internal_info->adapter_proxy, "GetProperties", NULL,
+                                 G_TYPE_INVALID,
+                                 dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                                 &hash, G_TYPE_INVALID);
+
+               if (hash != NULL) {
+                       value = g_hash_table_lookup(hash, "Discovering");
+
+                       if (value)
+                               is_discovering = g_value_get_boolean(value);
+               }
+       }
+
+       return is_discovering;
+}
+
+static int __bluetooth_is_headset_class(int dev_class)
+{
+       DBG("bluetooth_is_headset, %d +", dev_class);
+
+       int is_headset = 0;
+
+       switch ((dev_class & 0x1f00) >> 8) {
+       case 0x04:
+               switch ((dev_class & 0xfc) >> 2) {
+               case 0x01:
+               case 0x02:
+                       /* Headset */
+                       is_headset = 1;
+                       break;
+               case 0x06:
+                       /* Headphone */
+                       is_headset = 1;
+                       break;
+               case 0x0b:      /* VCR */
+               case 0x0c:      /* Video Camera */
+               case 0x0d:      /* Camcorder */
+                       break;
+               default:
+                       /* Other audio device */
+                       is_headset = 1;
+                       break;
+               }
+               break;
+       }
+
+       return is_headset;
+}
+
+
+int _bluetooth_is_headset_device(DBusGProxy *proxy)
+{
+       int is_headset = 0;
+       int remote_class = 0;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+
+       if (proxy == NULL)
+               return 0;
+
+       dbus_g_proxy_call(proxy, "GetProperties", NULL,
+                         G_TYPE_INVALID,
+                         dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
+                                             G_TYPE_VALUE), &hash,
+                         G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Class");
+               remote_class = value ? g_value_get_uint(value) : 0;
+       }
+
+       DBG("remote_class: %d", remote_class);
+
+       is_headset = __bluetooth_is_headset_class(remote_class);
+
+       return is_headset;
+}
+
+
+static void __bluetooth_internal_bonding_req_reply_cb(int error_type,
+                                                   const bluetooth_device_info_t *device_info,
+                                                   int is_headset)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_address_t device_address = { {0} };
+
+       DBG("+");
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       /* We need to cancel the timer */
+       if (bt_internal_info->bt_bonding_req_timer)
+               g_source_remove(bt_internal_info->bt_bonding_req_timer);
+
+       bt_internal_info->bt_bonding_req_timer = 0;
+
+       if (error_type != BLUETOOTH_ERROR_NONE) {
+               dbus_g_proxy_call_no_reply(bt_internal_info->adapter_proxy, "CancelDeviceCreation",
+                                          G_TYPE_STRING, bt_internal_info->bt_bonding_req_addrstr,
+                                          G_TYPE_INVALID, G_TYPE_INVALID);
+
+               DBG("error_type: %d", error_type);
+
+               /* Add the codes about auto-headset pairing */
+               if (error_type == BLUETOOTH_ERROR_AUTHENTICATION_FAILED
+                   && bt_internal_info->is_headset_pin_req == FALSE) {
+                       if (is_headset) {
+                               dbus_g_proxy_call_no_reply(bt_internal_info->agent_proxy,
+                                                          "IgnoreAutoPairing", G_TYPE_STRING,
+                                                          bt_internal_info->bt_bonding_req_addrstr,
+                                                          G_TYPE_INVALID, G_TYPE_INVALID);
+
+                               /* Auto-pairing fail case */
+                               _bluetooth_internal_convert_addr_string_to_addr_type(&device_address,
+                                                       bt_internal_info->bt_bonding_req_addrstr);
+
+                               bt_internal_info->is_headset_pin_req = TRUE;
+                               bt_internal_info->is_bonding_req = FALSE;
+                               bt_internal_info->is_headset_bonding = FALSE;
+                               memset(bt_internal_info->bt_bonding_req_addrstr, 0x00, 18);
+
+                               bluetooth_bond_device(&device_address);
+                               return;
+                       }
+               }
+       }
+
+       bt_internal_info->is_headset_pin_req = FALSE;
+       bt_internal_info->is_bonding_req = FALSE;
+       bt_internal_info->is_headset_bonding = FALSE;
+       memset(bt_internal_info->bt_bonding_req_addrstr, 0x00, 18);
+
+       bt_event.event = BLUETOOTH_EVENT_BONDING_FINISHED;
+       bt_event.result = error_type;
+       bt_event.param_data = (void *)device_info;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       DBG("-");
+}
+
+void _bluetooth_internal_bonding_created_cb(const char *bond_address, gpointer user_data)
+{
+       int remote_class = 0;
+       gboolean trust = FALSE;
+
+       DBusGProxy *device_proxy = (DBusGProxy *) user_data;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       GValue *uuid_value = NULL;
+       const gchar *name = NULL;       /*Sparrow fix */
+       gchar **array_ptr = NULL;
+       int passkey_len = 0;
+       gint rssi;
+
+       DBG("+\n");
+
+       dbus_g_proxy_call(device_proxy, "GetProperties", NULL,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Class");
+               remote_class = value ? g_value_get_uint(value) : 0;
+
+               value = g_hash_table_lookup(hash, "PinLength");
+               passkey_len = value ? g_value_get_uint(value) : 0;
+
+               value = g_hash_table_lookup(hash, "Trusted");
+               trust = value ? g_value_get_boolean(value) : FALSE;
+
+               value = g_hash_table_lookup(hash, "RSSI");
+               rssi = value ? g_value_get_int(value) : 0;
+
+               value = g_hash_table_lookup(hash, "UUIDs");
+               uuid_value = value;
+       }
+
+       DBG("Bonding Created with [%s][%s] Remote Class:[%#x]\n", name, bond_address, remote_class);
+
+       {
+               int is_headset = 0;
+               bluetooth_device_info_t device_info = { { { 0 } } };
+               bt_info_t *bt_internal_info = _bluetooth_internal_get_information();
+
+               _bluetooth_internal_convert_addr_string_to_addr_type(&device_info.device_address,
+                                                                   bond_address);
+
+               if (name && strlen(name) > 0)
+                       g_strlcpy(device_info.device_name.name, name,
+                                 sizeof(device_info.device_name.name));
+               else
+                       g_strlcpy(device_info.device_name.name, bond_address,
+                                 sizeof(device_info.device_name.name));
+
+               device_info.rssi = rssi;
+               device_info.trust = trust;
+               device_info.paired = TRUE;
+
+               __bluetooth_internal_get_service_list(uuid_value, &device_info);
+               _bluetooth_internal_divide_device_class(&device_info.device_class, remote_class);
+
+               is_headset = __bluetooth_is_headset_class(remote_class);
+
+               bt_internal_info->is_headset_pin_req = FALSE;
+               __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_NONE, &device_info,
+                                                       is_headset);
+       }
+
+       DBG("-\n");
+
+       return;
+}
+
+static void __bluetooth_internal_bonding_req_finish_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                    gpointer user_data)
+{
+       int remote_class = 0;
+       int is_headset = 0;
+       char *device_path = NULL;
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_info_t device_info = { { { 0 } } };
+       GError *err = NULL;
+       GHashTable *hash = NULL;
+       GValue *value = NULL;
+       DBusGProxy *device_proxy = NULL;
+
+       DBG("+");
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       dbus_g_proxy_end_call(proxy, call, &err,
+                             DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
+
+       if (err != NULL) {
+               DBG("Error occured in CreateBonding [%s]", err->message);
+               if (!strcmp(err->message, "Already Exists")) {
+                       DBG("Existing Bond, remove and retry");
+                       g_error_free(err);
+                       err = NULL;
+                       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", NULL,
+                                         G_TYPE_STRING, bt_internal_info->bt_bonding_req_addrstr,
+                                         G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &device_path,
+                                         G_TYPE_INVALID);
+
+                       if (device_path != NULL) {
+
+                               dbus_g_proxy_call(bt_internal_info->adapter_proxy, "RemoveDevice",
+                                                 &err, DBUS_TYPE_G_OBJECT_PATH, device_path,
+                                                 G_TYPE_INVALID, G_TYPE_INVALID);
+
+                               if (err != NULL) {
+                                       DBG("RemoveDevice Fail", err->message);
+                                       g_error_free(err);
+                                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_PARING_FAILED,
+                                                                                       NULL, 0);
+                               } else {
+                                       __bluetooth_internal_bonding_req();
+                               }
+                       } else {
+                               ERR("No device in adapter");
+                               __bluetooth_internal_bonding_req_reply_cb
+                                   (BLUETOOTH_ERROR_PARING_FAILED, NULL, 0);
+                       }
+                       return;
+               } else if (!strcmp(err->message, "Authentication Rejected")) {
+                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_ACCESS_DENIED,
+                                                                       NULL, 0);
+               } else if (!strcmp(err->message, "CanceledbyUser") ||
+                                       !strcmp(err->message, "Authentication Canceled")) {
+                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_CANCEL_BY_USER,
+                                                               NULL, 0);
+               } else if (!strcmp(err->message, "In Progress")) {
+                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_IN_PROGRESS,
+                                                               NULL, 0);
+               } else if (!strcmp(err->message, "Authentication Failed")) {
+                       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", NULL,
+                                         G_TYPE_STRING, bt_internal_info->bt_bonding_req_addrstr,
+                                         G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &device_path,
+                                         G_TYPE_INVALID);
+                       if (!device_path) {
+                               DBG("device_path is NULL");
+                       }
+
+                       /* Pairing fail case by wrong pin code */
+                       device_proxy = _bluetooth_internal_find_device_by_path(device_path);
+
+                       if (device_proxy) {
+                               dbus_g_proxy_call(device_proxy, "GetProperties", NULL,
+                                                 G_TYPE_INVALID,
+                                                 dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
+                                                                     G_TYPE_VALUE), &hash,
+                                                 G_TYPE_INVALID);
+                       } else {
+                               DBG("device proxy is NULL");
+                       }
+
+                       if (hash != NULL) {
+                               value = g_hash_table_lookup(hash, "Class");
+                               remote_class = value ? g_value_get_uint(value) : 0;
+                       }
+
+                       DBG("remote_class: %d", remote_class);
+
+                       is_headset = __bluetooth_is_headset_class(remote_class);
+
+                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_AUTHENTICATION_FAILED,
+                                                                       NULL, is_headset);
+               } else if (!strcmp(err->message, "Page Timeout")) {
+                       /* This is the special case
+                            As soon as call bluetooth_bond_device, try to cancel bonding.
+                            In this case, before completing to call 'CreatePairedDevice' method
+                            the procedure is stopped. So 'Cancle' error is not return.
+                       */
+
+                       if (bt_internal_info->is_bonding_req == FALSE) {
+                               __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_CANCEL_BY_USER,
+                                                                               NULL, 0);
+                       } else {
+                               if (bt_internal_info->is_headset_bonding)
+                                       /* Headset auto-pairing fail case */
+                                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_AUTHENTICATION_FAILED,
+                                                                               NULL, 1);
+                               else
+                                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_HOST_DOWN,
+                                                                                       NULL, 0);
+                       }
+               } else {
+                       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_PARING_FAILED,
+                                                                       NULL, 0);
+               }
+
+               if (err != NULL)
+                       g_error_free(err);
+       }
+
+       DBG("-");
+}
+
+static int __bluetooth_internal_bonding_req_timeout_cb(void *data)
+{
+       DBG("+");
+       __bluetooth_internal_bonding_req_reply_cb(BLUETOOTH_ERROR_TIMEOUT, NULL, 0);
+       DBG("-");
+
+       return 0;
+}
+
+static int __bluetooth_internal_bonding_req(void)
+{
+       DBG("+");
+       bt_info_t *bt_internal_info = NULL;
+       char default_path[128] = { 0 };
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       snprintf(default_path, 128, "/org/bluez/agent_slp");
+
+       if (!dbus_g_proxy_begin_call_with_timeout(bt_internal_info->adapter_proxy,
+               "CreatePairedDevice",
+               (DBusGProxyCallNotify) __bluetooth_internal_bonding_req_finish_cb, NULL, NULL, 50000,
+               G_TYPE_STRING, bt_internal_info->bt_bonding_req_addrstr, DBUS_TYPE_G_OBJECT_PATH,
+               default_path, G_TYPE_STRING, "DisplayYesNo", G_TYPE_INVALID)) {
+               DBG("CreatePairedDevice call fail");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("-");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
+{
+       DBG("+");
+       bt_info_t *bt_internal_info = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (device_address == NULL) {
+               ERR("wrong parameter");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (bluetooth_is_discovering() == TRUE) {
+               DBG("Currently in discovery");
+               return BLUETOOTH_ERROR_DEVICE_BUSY;
+       }
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+
+       g_strlcpy(bt_internal_info->bt_bonding_req_addrstr, address,
+                       sizeof(bt_internal_info->bt_bonding_req_addrstr));
+
+       if (__bluetooth_internal_bonding_req() != BLUETOOTH_ERROR_NONE) {
+               DBG("bonding request fail");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       bt_internal_info->is_bonding_req = TRUE;
+
+       bt_internal_info->bt_bonding_req_timer =
+           g_timeout_add_seconds(BLUETOOTH_BONDING_TIMEOUT,
+                                 __bluetooth_internal_bonding_req_timeout_cb, NULL);
+
+       DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_cancel_bonding(void)
+{
+       DBG("+");
+
+       bt_info_t *bt_internal_info = NULL;
+       GError *error = NULL;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (bt_internal_info->bt_bonding_req_timer)
+               g_source_remove(bt_internal_info->bt_bonding_req_timer);
+
+       bt_internal_info->bt_bonding_req_timer = 0;
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "CancelDeviceCreation", &error,
+                                  G_TYPE_STRING, bt_internal_info->bt_bonding_req_addrstr,
+                                  G_TYPE_INVALID, G_TYPE_INVALID);
+
+       bt_internal_info->is_bonding_req = 0;
+       memset(bt_internal_info->bt_bonding_req_addrstr, 0x00, 18);
+
+       if (error) {
+               DBG("CancelDeviceCreation error: [%s]", error->message);
+               g_error_free(error);
+               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+       }
+
+       DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+void _bluetooth_internal_bonding_removed_cb(const char *bond_address, gpointer user_data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_address_t device_address = { {0} };
+
+       DBG("+ Bonding Removed from [%s]\n", bond_address);
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&device_address, bond_address);
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       bt_event.event = BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = (void *)&device_address;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       DBG("-\n");
+
+       return;
+}
+
+static void __bluetooth_internal_unbond_request_complete_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                         gpointer user_data)
+{
+       GError *err = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_device_address_t *device_address;
+
+       DBG("+\n");
+
+       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
+
+       device_address = (bluetooth_device_address_t *) user_data;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (err != NULL) {
+               DBG("Error occured in RemoveBonding [%s]\n", err->message);
+               g_error_free(err);
+
+               if (bt_internal_info->bt_cb_ptr) {
+                       /* If control reaches here, it is always a debond request failure*/
+                       bt_event.event = BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED;
+                       bt_event.result = BLUETOOTH_ERROR_NOT_PAIRED;
+                       bt_event.param_data = (void *)device_address;
+                       if (bt_internal_info->bt_cb_ptr) {
+                               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                                           bt_internal_info->user_data);
+                       }
+               }
+       }
+       /*release user_data which was allocated in caller*/
+       if (device_address != NULL) {
+               free(device_address);
+               device_address = NULL;
+       }
+
+       DBG("-\n");
+}
+
+BT_EXPORT_API int bluetooth_unbond_device(const bluetooth_device_address_t *device_address)
+{
+       bt_info_t *bt_internal_info = NULL;
+       char address[18] = { 0 };
+       char *device_path = NULL;
+       bluetooth_device_address_t *bluetooth_address;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (device_address == NULL) {
+               ERR("wrong parameter");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (bluetooth_is_discovering() == TRUE) {
+               DBG("Currently in discovery");
+               return BLUETOOTH_ERROR_DEVICE_BUSY;
+       }
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+
+       /*allocate user data so that it can be retrieved in callback */
+       bluetooth_address =
+           (bluetooth_device_address_t *) malloc(sizeof(bluetooth_device_address_t));
+       if (bluetooth_address == NULL) {
+               DBG("Out of memory");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       memcpy(bluetooth_address, device_address, BLUETOOTH_ADDRESS_LENGTH);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", NULL,
+                         G_TYPE_STRING, address, G_TYPE_INVALID,
+                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
+
+       if (device_path != NULL) {
+               if (!dbus_g_proxy_begin_call(bt_internal_info->adapter_proxy, "RemoveDevice",
+                       (DBusGProxyCallNotify) __bluetooth_internal_unbond_request_complete_cb,
+                       (gpointer) bluetooth_address, NULL, DBUS_TYPE_G_OBJECT_PATH, device_path,
+                       G_TYPE_INVALID)) {
+                       DBG("RemoveBonding begin failed\n");
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+       } else {
+               DBG("No paired device");
+               free(bluetooth_address);
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bluetooth_internal_get_service_list(GValue *value, bluetooth_device_info_t *dev)
+{
+       DBG("+\n");
+
+       int i = 0;
+       char **uuids = NULL;
+       char **parts = NULL;
+
+       if (value == NULL || dev == NULL) {
+               ERR("wrong parameter");
+               return;
+       }
+
+       uuids = g_value_get_boxed(value);
+
+       if (uuids == NULL)
+               return;
+
+       dev->service_index = 0;
+
+       for (i = 0; uuids[i] != NULL && i < BLUETOOTH_MAX_SERVICES_FOR_DEVICE; i++) {
+               g_strlcpy(dev->uuids[i], uuids[i], BLUETOOTH_UUID_STRING_MAX);
+
+               parts = g_strsplit(uuids[i], "-", -1);
+
+               if (parts == NULL || parts[0] == NULL) {
+                       g_strfreev(parts);
+                       break;
+               }
+
+               dev->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
+               g_strfreev(parts);
+
+               DBG("dev->service_index is %d\n", dev->service_index);
+
+               dev->service_index++;
+       }
+
+       DBG("-\n");
+}
+
+static int __bluetooth_internal_get_bonded_device_list_details(gchar *device_path,
+                                                            bluetooth_device_info_t *dev)
+{
+       DBG("+\n");
+       GValue *value = { 0 };
+       GError *err = NULL;
+
+       const gchar *address, *name;
+       unsigned int cod;
+       gint rssi;
+       gboolean trust;
+       gboolean paired;
+       gboolean connected;
+       GHashTable *hash;
+       int ret_val = BLUETOOTH_ERROR_INTERNAL;
+
+       if ((dev == NULL) || (device_path == NULL))
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       DBusGProxy *device_proxy = _bluetooth_internal_find_device_by_path(device_path);
+       if (device_proxy == NULL) {
+               DBG("Not Found device with path %s\n", device_path);
+
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_g_proxy_call(device_proxy, "GetProperties", &err,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (err != NULL) {
+               DBG("Error occured in Proxy call [%s]\n", err->message);
+               g_error_free(err);
+
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Paired");
+               paired = g_value_get_boolean(value);
+
+               if (paired == FALSE)
+                       return BLUETOOTH_ERROR_NOT_PAIRED;
+
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Alias");
+               name = value ? g_value_get_string(value) : NULL;
+               if (name != NULL)
+                       DBG("Alias Name [%s]", name);
+               else {
+                       value = g_hash_table_lookup(hash, "Name");
+                       name = value ? g_value_get_string(value) : NULL;
+               }
+
+               value = g_hash_table_lookup(hash, "Class");
+               cod = value ? g_value_get_uint(value) : 0;
+               DBG("Address [%s], Name [%s], COD [0x%X]\n", address, name, cod);
+
+               value = g_hash_table_lookup(hash, "Connected");
+               connected = value ? g_value_get_boolean(value) : FALSE;
+
+               value = g_hash_table_lookup(hash, "Trusted");
+               trust = value ? g_value_get_boolean(value) : FALSE;
+
+               value = g_hash_table_lookup(hash, "RSSI");
+               rssi = value ? g_value_get_int(value) : 0;
+
+               value = g_hash_table_lookup(hash, "UUIDs");
+               __bluetooth_internal_get_service_list(value, dev);
+
+               _bluetooth_internal_convert_addr_string_to_addr_type(&dev->device_address,
+                                                                   address);
+               strncpy(dev->device_name.name, name, strlen(name));
+               dev->device_name.name[strlen(name)] = '\0';
+               dev->rssi = rssi;
+               dev->trust = trust;
+               dev->paired = paired;
+               dev->connected = connected;
+               _bluetooth_internal_divide_device_class(&dev->device_class, cod);
+
+               ret_val = BLUETOOTH_ERROR_NONE;
+       } else {
+               DBG("Hash is NULL\n");
+               ret_val = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("-\n");
+       return ret_val;
+
+}
+
+static int bluetooth_internal_get_bonded_device_list(GPtrArray **dev_list)
+{
+       DBG("+\n");
+       int ret_val = BLUETOOTH_ERROR_NONE;
+       bt_info_t *bt_internal_info = NULL;
+       GPtrArray *gp_array = NULL;
+       GPtrArray *result = NULL;
+       GError *error = NULL;
+       bluetooth_device_info_t *devinfo;
+
+       if (dev_list == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       result = *dev_list;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "ListDevices", &error,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+                               &gp_array, G_TYPE_INVALID);
+
+       if (error == NULL) {
+               if (gp_array != NULL) {
+                       int i;
+                       if (gp_array->len == 0) {
+                               result->len = 0;
+                       } else {
+                               DBG("Num of ListDevices = [%d]", gp_array->len);
+                               for (i = 0; i < gp_array->len; i++) {
+                                       gchar *gp_path = g_ptr_array_index(gp_array, i);
+                                       if (gp_path != NULL) {
+                                               DBG("Newly list device [%s]\n", gp_path);
+                                               devinfo =
+                                                   (bluetooth_device_info_t *)
+                                                   malloc(sizeof(bluetooth_device_info_t));
+                                               memset(devinfo, 0, sizeof(bluetooth_device_info_t));
+                                               if (__bluetooth_internal_get_bonded_device_list_details(gp_path,
+                                                                       devinfo) == BLUETOOTH_ERROR_NONE) {                                                                             g_ptr_array_add(result, (gpointer) devinfo);
+                                               } else {
+                                                       DBG("Can't get the paired device path \n");
+                                                       free(devinfo);
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       g_ptr_array_free(gp_array, TRUE);
+               } else {
+                       DBG("DBus error: \n");
+                       ret_val = BLUETOOTH_ERROR_INTERNAL;
+               }
+       } else {
+               DBG("ListDevices error: [%s]\n", error->message);
+               g_error_free(error);
+               ret_val = BLUETOOTH_ERROR_INTERNAL;
+       }
+       DBG("-\n");
+       return ret_val;
+}
+
+BT_EXPORT_API int bluetooth_get_bonded_device_list(GPtrArray **dev_list)
+{
+       int ret_val = BLUETOOTH_ERROR_NONE;
+
+       if (dev_list == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       ret_val = bluetooth_internal_get_bonded_device_list(dev_list);
+       return ret_val;
+}
+
+BT_EXPORT_API int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
+                                             bluetooth_device_info_t *dev_info)
+{
+       bt_info_t *bt_internal_info = NULL;
+       GPtrArray *gp_array = NULL;
+       GError *error = NULL;
+
+       if (device_address == NULL || dev_info == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "ListDevices", &error,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+                               &gp_array, G_TYPE_INVALID);
+
+       if (error == NULL) {
+               if (gp_array != NULL) {
+                       if (gp_array->len != 0) {
+                               int i;
+                               bluetooth_device_info_t devinfo;
+
+                               DBG("Num of ListDevices = [%d]", gp_array->len);
+                               for (i = 0; i < gp_array->len; i++) {
+                                       gchar *gp_path = g_ptr_array_index(gp_array, i);
+                                       if (gp_path != NULL) {
+                                               memset(&devinfo, 0x00,
+                                                               sizeof(bluetooth_device_info_t));
+
+                                               if (__bluetooth_internal_get_bonded_device_list_details(gp_path,
+                                                                                               &devinfo) ==                                                                                                    BLUETOOTH_ERROR_NONE) {
+                                                       if (memcmp(devinfo.device_address.addr,
+                                                                               device_address->addr,
+                                                                       BLUETOOTH_ADDRESS_LENGTH) == 0) {
+                                                               memcpy(dev_info, &devinfo,
+                                                                      sizeof(bluetooth_device_info_t));
+                                                               g_ptr_array_free(gp_array, TRUE);
+                                                               return BLUETOOTH_ERROR_NONE;
+                                                       }
+                                               } else {
+                                                       DBG("Can't get the paired device path \n");
+                                                       break;
+                                               }
+                                       }
+                               }
+                       } else {
+                               DBG("Num of ListDevices is 0");
+                       }
+                       g_ptr_array_free(gp_array, TRUE);
+               } else {
+                       DBG("DBus error: \n");
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+       } else {
+               DBG("ListDevices error: [%s]\n", error->message);
+               g_error_free(error);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NOT_FOUND;
+}
+
+BT_EXPORT_API int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
+{
+       if (device_address == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_set_alias(const bluetooth_device_address_t *device_address,
+                                     const char *alias)
+{
+       bt_info_t *bt_internal_info = NULL;
+       char addr[18] = { 0 };
+       int result = BLUETOOTH_ERROR_NONE;
+
+       const char *path = NULL;
+       DBusGProxy *device_proxy = NULL;
+       GValue name = { 0 };
+
+       if (!device_address)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       _bluetooth_internal_addr_type_to_addr_string(addr, device_address);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", NULL,
+                         G_TYPE_STRING, addr, G_TYPE_INVALID,
+                         DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID);
+
+       device_proxy = _bluetooth_internal_find_device_by_path(path);
+
+       if (device_proxy == NULL) {
+               DBG("No device [%s]\n", addr);
+               result = BLUETOOTH_ERROR_NOT_PAIRED;
+               goto done;
+       }
+
+       g_value_init(&name, G_TYPE_STRING);
+       g_value_set_string(&name, alias);
+
+       dbus_g_proxy_call_no_reply(device_proxy, "SetProperty",
+                                  G_TYPE_STRING, "Alias", G_TYPE_VALUE, &name, G_TYPE_INVALID);
+
+       g_value_unset(&name);
+
+ done:
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
+                                            gboolean authorized)
+{
+       bt_info_t *bt_internal_info = NULL;
+       char addr[18] = { 0 };
+       int result = BLUETOOTH_ERROR_NONE;
+
+       const char *path = NULL;
+       DBusGProxy *device_proxy = NULL;
+       GValue trusted = { 0 };
+
+       if (!device_address)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       _bluetooth_internal_addr_type_to_addr_string(addr, device_address);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", NULL,
+                         G_TYPE_STRING, addr, G_TYPE_INVALID,
+                         DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID);
+
+       device_proxy = _bluetooth_internal_find_device_by_path(path);
+
+       if (device_proxy == NULL) {
+               DBG("No device [%s]\n", addr);
+               result = BLUETOOTH_ERROR_NOT_PAIRED;
+               goto done;
+       }
+
+       g_value_init(&trusted, G_TYPE_BOOLEAN);
+       g_value_set_boolean(&trusted, authorized);
+
+       dbus_g_proxy_call_no_reply(device_proxy, "SetProperty",
+                                  G_TYPE_STRING, "Trusted", G_TYPE_VALUE, &trusted,
+                                  G_TYPE_INVALID);
+
+       g_value_unset(&trusted);
+
+ done:
+       return result;
+}
diff --git a/lib/bluetooth-gap-api.h b/lib/bluetooth-gap-api.h
new file mode 100644 (file)
index 0000000..d19b7a0
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 _BLUETOOTH_GAP_API_H_
+#define _BLUETOOTH_GAP_API_H_
+
+
+#include "bluetooth-api-common.h"
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#define BLUETOOTH_CHANGE_STATUS_TIMEOUT        30
+#define BLUETOOTH_BONDING_TIMEOUT              60
+
+typedef struct device_list {
+       char str_address[20];
+       char str_name[50];
+       int class;
+       struct device_list *next;
+} device_list_t;
+
+typedef struct paired_info {
+       int total_count;
+} paired_info_t;
+
+
+void _bluetooth_internal_enabled_cb(void);
+void _bluetooth_internal_disabled_cb(void);
+
+void _bluetooth_internal_adapter_name_changed_cb(void);
+
+void _bluetooth_internal_discovery_started_cb(void);
+void _bluetooth_internal_discovery_completed_cb(void);
+void _bluetooth_internal_bonding_created_cb(const char *bond_address,
+                                               gpointer user_data);
+void _bluetooth_internal_bonding_removed_cb(const char *bond_address,
+                                               gpointer user_data);
+void _bluetooth_internal_remote_device_found_cb(const char *address,
+                               int rssi, unsigned int remote_class,
+                               gboolean paired);
+void _bluetooth_internal_remote_device_name_updated_cb(const char *address,
+                                                       const char *name,
+                                                       int rssi, unsigned int remote_class,
+                                                       gboolean paired);
+
+int _bluetooth_is_headset_device(DBusGProxy *proxy);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*_BLUETOOTH_GAP_API_H_*/
diff --git a/lib/bluetooth-hdp-api.c b/lib/bluetooth-hdp-api.c
new file mode 100644 (file)
index 0000000..695b7ae
--- /dev/null
@@ -0,0 +1,1220 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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-api-common.h"
+#include "bluetooth-hdp-api.h"
+
+/**********************************************************************
+*              Static Functions declaration                            *
+***********************************************************************/
+static void __bt_hdp_internal_event_cb(int event, int result, void *param_data);
+
+static int __bt_hdp_internal_create_application(unsigned int data_type,
+                                               bool role,
+                                               bt_hdp_qos_type_t channel_type);
+
+static DBusHandlerResult __bt_hdp_internal_event_filter(DBusConnection *sys_conn,
+                                                       DBusMessage *msg,
+                                                       void *data);
+
+static void __bt_hdp_internal_handle_connect(DBusMessage *msg);
+
+static void __bt_hdp_internal_handle_disconnect(DBusMessage *msg);
+
+static void __bt_hdp_internal_handle_property_changed(DBusMessage *msg);
+
+static int __bt_hdp_internal_add_filter(void);
+
+static int __bt_hdp_internal_acquire_fd(const char *path);
+
+static void __bt_hdp_internal_watch_fd(int file_desc, const char *path);
+
+static gboolean __bt_hdp_internal_data_received(GIOChannel *gio,
+                                               GIOCondition cond,
+                                               gpointer data);
+
+static void __bt_hdp_internal_handle_disconnect_cb(int sk, const char *path);
+
+static int __bt_hdp_internal_destroy_application(const char *app_handle);
+
+static void __bt_hdp_internal_remove_filter(void);
+
+static hdp_app_list_t *__bt_hdp_internal_gslist_find_app_handler(void *app_handle);
+
+static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_fd(int fd);
+
+static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_obj_channel(
+                                               const char *obj_channel_path);
+
+/*Global Variables*/
+static DBusConnection *g_hdp_dus_conn;
+
+static GSList *g_app_list = NULL;
+
+/**********************************************************************
+*                      Health device APIs (HDP)                        *
+***********************************************************************/
+
+static void __bt_hdp_internal_event_cb(int event, int result, void *param_data)
+{
+       DBG("+");
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bt_event.event = event;
+       bt_event.result = result;
+       bt_event.param_data = param_data;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                       bt_internal_info->user_data);
+
+       DBG("-");
+}
+
+BT_EXPORT_API int bluetooth_hdp_activate(unsigned short data_type,
+                                       bt_hdp_role_type_t role,
+                                       bt_hdp_qos_type_t channel_type)
+{
+       DBG("+\n");
+       int result = BLUETOOTH_ERROR_NONE;
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (bt_internal_info->bt_adapter_state != BLUETOOTH_ADAPTER_ENABLED) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       /*For source role is mandatory */
+       if (role == HDP_ROLE_SOURCE && channel_type == HDP_QOS_ANY) {
+               DBG("For source, type is mandatory - Reliable/Streaming\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       result = __bt_hdp_internal_create_application(data_type, role,
+                                               channel_type);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+
+static gboolean  __bt_hdp_internal_create_application_cb(gpointer data)
+{
+       DBG(" +\n");
+       hdp_app_list_t *list = (hdp_app_list_t *)data;
+       bt_hdp_activate_t act_cfm;
+       act_cfm.app_handle = list->app_handle;
+
+       __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_ACTIVATED,
+                                 BLUETOOTH_ERROR_NONE, &act_cfm);
+       DBG(" -\n");
+       return FALSE;
+}
+static int __bt_hdp_internal_create_application(unsigned int data_type,
+                                       bool role,
+                                       bt_hdp_qos_type_t channel_type)
+{
+       DBG(" +\n");
+       DBusMessage *msg, *reply;
+       const char *svalue;
+       const char *key_type;
+       char *app_path;
+       DBusError err;
+       DBusMessageIter iter, array_iter, entry, variant;
+       guint16 value;
+       bt_info_t *bt_internal_info = NULL;
+       int ret = BLUETOOTH_ERROR_NONE;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("Internal info == NULL");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
+                                         BLUEZ_HDP_MANAGER_INTERFACE,
+                                         "CreateApplication");
+
+       if (!msg) {
+               DBG(" HDP:dbus allocate new method call failed");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+               DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING
+               DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+               &array_iter);
+
+       key_type = "DataType";
+       value = (guint16) data_type;
+       dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY,
+                                       NULL, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key_type);
+       dbus_message_iter_open_container(&entry,
+               DBUS_TYPE_VARIANT, DBUS_TYPE_UINT16_AS_STRING, &variant);
+       dbus_message_iter_append_basic(&variant, DBUS_TYPE_UINT16, &value);
+       dbus_message_iter_close_container(&entry, &variant);
+       dbus_message_iter_close_container(&array_iter, &entry);
+
+       key_type = "Role";
+       svalue = (role == HDP_ROLE_SINK) ? "Sink" : "Source";/*0-Source,1-Sink*/
+       dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY,
+                                       NULL, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key_type);
+       dbus_message_iter_open_container(&entry,
+               DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &variant);
+       dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &svalue);
+       dbus_message_iter_close_container(&entry, &variant);
+       dbus_message_iter_close_container(&array_iter, &entry);
+
+       key_type = "Description";
+       svalue = "Health Device";
+       dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY,
+                                       NULL, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key_type);
+       dbus_message_iter_open_container(&entry,
+               DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &variant);
+       dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &svalue);
+       dbus_message_iter_close_container(&entry, &variant);
+       dbus_message_iter_close_container(&array_iter, &entry);
+
+       if (role == HDP_ROLE_SOURCE) {
+               key_type = "ChannelType";
+               if (channel_type == HDP_QOS_RELIABLE)
+                       svalue = "Reliable";
+               else if (channel_type == HDP_QOS_STREAMING)
+                       svalue = "Streaming";
+
+               dbus_message_iter_open_container(&array_iter,
+                       DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
+                                               &key_type);
+               dbus_message_iter_open_container(&entry,
+                       DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING,
+                       &variant);
+               dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING,
+                                               &svalue);
+               dbus_message_iter_close_container(&entry, &variant);
+               dbus_message_iter_close_container(&array_iter, &entry);
+       }
+
+       dbus_message_iter_close_container(&iter, &array_iter);
+
+       dbus_error_init(&err);
+
+       reply = dbus_connection_send_with_reply_and_block(
+               dbus_g_connection_get_connection(bt_internal_info->conn),
+               msg, -1, &err);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG(" HDP:dbus Can't create application");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (!dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH,
+                               &app_path, DBUS_TYPE_INVALID)) {
+
+               DBG(" HDP: Can't get reply arguments from Dbus");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("Error: %s", err.message);
+                       dbus_error_free(&err);
+               }
+
+               dbus_message_unref(reply);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_message_unref(reply);
+
+       DBG("Created health application: %s", (char *)app_path);
+
+       ret = __bt_hdp_internal_add_filter();
+
+       if (ret != BLUETOOTH_ERROR_NONE) {
+               DBG("Funtion failed");
+               return ret;
+       }
+
+       hdp_app_list_t *list = malloc(sizeof(hdp_app_list_t));
+       if (NULL == list) {
+               DBG("Malloc list failed");
+               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+       }
+
+       list->app_handle = (void *)g_strdup(app_path);
+
+       list->obj_channel_path = NULL;
+
+       list->fd = -1;
+
+       g_app_list = g_slist_append(g_app_list, list);
+
+
+       g_idle_add(__bt_hdp_internal_create_application_cb, (gpointer)list);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static int __bt_hdp_internal_add_filter(void)
+{
+       DBG("+\n");
+       bt_info_t *bt_internal_info = NULL;
+       DBusError dbus_error;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL || bt_internal_info->conn == NULL) {
+               DBG("Internel info == NULL or Conn == NULL\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /*Single process only one signal registration is required */
+       if (g_hdp_dus_conn) {
+               DBG("g_hdp_dus_conn already exist");
+               goto done;
+       }
+
+       /* Add the filter for HDP client functions */
+       dbus_error_init(&dbus_error);
+
+       g_hdp_dus_conn = dbus_g_connection_get_connection(bt_internal_info->conn);
+
+       dbus_connection_add_filter(g_hdp_dus_conn,
+                               __bt_hdp_internal_event_filter, NULL, NULL);
+
+       dbus_bus_add_match(g_hdp_dus_conn,
+                       "type='signal',interface=" BLUEZ_HDP_DEVICE_INTERFACE,
+                       &dbus_error);
+
+       if (dbus_error_is_set(&dbus_error)) {
+               DBG("Fail to add dbus filter signal\n");
+               dbus_error_free(&dbus_error);
+               g_hdp_dus_conn = NULL;
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+done:
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+static DBusHandlerResult __bt_hdp_internal_event_filter(DBusConnection *sys_conn,
+                                       DBusMessage *msg, void *data)
+{
+       const char *path = dbus_message_get_path(msg);
+
+       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       DBG("Path = %s\n", path);
+       if (path == NULL || strcmp(path, "/") == 0)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       if (dbus_message_is_signal(msg, BLUEZ_HDP_DEVICE_INTERFACE,
+                                       "ChannelConnected"))
+               __bt_hdp_internal_handle_connect(msg);
+
+       else if (dbus_message_is_signal(msg, BLUEZ_HDP_DEVICE_INTERFACE,
+                                       "ChannelDeleted"))
+               __bt_hdp_internal_handle_disconnect(msg);
+
+       else if (dbus_message_is_signal(msg, BLUEZ_HDP_DEVICE_INTERFACE,
+                                       "PropertyChanged"))
+               __bt_hdp_internal_handle_property_changed(msg);
+
+       return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static void __bt_hdp_internal_handle_connect(DBusMessage *msg)
+{
+       DBG("+********Signal - ChannelConnected******\n\n");
+       const char *path = dbus_message_get_path(msg);
+       const char *obj_channel_path;
+       DBG("Path = %s\n", path);
+
+       if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH,
+                               &obj_channel_path, DBUS_TYPE_INVALID)) {
+               DBG("Unexpected parameters in ChannelConnected signal");
+               return;
+       }
+
+       DBG("Channel connected, Path = %s\n", obj_channel_path);
+
+       __bt_hdp_internal_acquire_fd(obj_channel_path);
+
+       DBG("-*************\n\n");
+}
+
+static void __bt_hdp_internal_handle_disconnect(DBusMessage *msg)
+{
+       DBG("+********Signal - ChannelDeleted ******\n\n");
+       const char *path = dbus_message_get_path(msg);
+       const char *obj_channel_path;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0, };
+       bluetooth_device_address_t device_addr = { {0} };
+       bt_hdp_disconnected_t dis_ind;
+
+       DBG("Path = %s\n", path);
+
+       if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH,
+                               &obj_channel_path, DBUS_TYPE_INVALID)) {
+               DBG("Unexpected parameters in ChannelDeleted signal");
+               return;
+       }
+
+       DBG("Channel Deleted, Path = %s\n", obj_channel_path);
+
+       /*Since bluetoothd is not sending the ChannelDeleted signal */
+       _bluetooth_internal_device_path_to_address(path, address);
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr,
+                                                       address);
+
+       hdp_app_list_t *list = __bt_hdp_internal_gslist_find_using_obj_channel(
+                                       obj_channel_path);
+       if (NULL == list) {
+               DBG("** Could not locate the list for ob_channel_path %s****\n",
+                       obj_channel_path);
+       } else {
+
+               if (list->fd == -1) {
+                       DBG("******* Warning! FD already deleted******\n");
+               }
+
+               dis_ind.channel_id = list->fd;
+               dis_ind.device_address = device_addr;
+
+               __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
+                                         BLUETOOTH_ERROR_NONE, &dis_ind);
+
+               close(list->fd);
+               list->fd = -1;
+               g_free(list->obj_channel_path);
+               list->obj_channel_path = NULL;
+
+               DBG(" Removed  fd and obj_channel_path from the list\n");
+       }
+
+       DBG("-*************\n\n");
+
+}
+
+static void __bt_hdp_internal_handle_property_changed(DBusMessage *msg)
+{
+       DBG("+*******Signal - PropertyChanged*******\n\n");
+       const char *path = dbus_message_get_path(msg);
+       DBusMessageIter item_iter, value_iter;
+       const char *property;
+       const char *obj_main_channel_path;
+
+       DBG("Path = %s\n", path);
+
+       dbus_message_iter_init(msg, &item_iter);
+
+       if (dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_STRING) {
+               DBG("This is bad format dbus\n");
+               return;
+       }
+
+       dbus_message_iter_get_basic(&item_iter, &property);
+
+       if (property == NULL) {
+               DBG("Property is NULL\n");
+               return;
+       }
+
+       DBG("Property (%s)\n", property);
+
+       if (0 == g_strcmp0(property, "MainChannel")) {
+               DBG("Property MainChannel received\n");
+
+               dbus_message_iter_next(&item_iter);
+
+               dbus_message_iter_recurse(&item_iter, &value_iter);
+
+               dbus_message_iter_get_basic(&value_iter,
+                                               &obj_main_channel_path);
+               DBG("Path = %s\n", path);
+
+               DBG("Main Channel  Path = %s\n", obj_main_channel_path);
+       }
+       DBG("-*************\n\n");
+}
+
+static int __bt_hdp_internal_acquire_fd(const char *path)
+{
+       DBG("+\n");
+       char address[BT_ADDRESS_STRING_SIZE] = { 0, };
+       bluetooth_device_address_t device_addr = { {0} };
+       DBusMessageIter reply_iter, reply_iter_entry;
+       const char *property;
+       char *type_qos = NULL;
+       char *device = NULL;;
+       char *app_handle = NULL;;
+       hdp_app_list_t *list = NULL;;
+       DBusMessage *msg, *reply;
+       bt_info_t *bt_internal_info = NULL;
+       bt_hdp_connected_t conn_ind;
+       DBusError err;
+       int fdd = -1;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       if (bt_internal_info == NULL) {
+               DBG(" HDP:bt_internal_info NULL");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       msg = dbus_message_new_method_call("org.bluez", path,
+                                         BLUEZ_HDP_CHANNEL_INTERFACE,
+                                         "Acquire");
+       if (!msg) {
+               DBG(" HDP:Acquire dbus failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_error_init(&err);
+
+       reply = dbus_connection_send_with_reply_and_block(
+                       dbus_g_connection_get_connection(bt_internal_info->conn),
+                       msg, -1, &err);
+
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG(" HDP:****** dbus Can't create application ****");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+               }
+
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (!dbus_message_get_args(reply, &err, DBUS_TYPE_UNIX_FD, &fdd,
+                               DBUS_TYPE_INVALID)) {
+               DBG(" HDP:dbus Can't get reply arguments");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+               }
+               goto error;
+       }
+
+       dbus_message_unref(reply);
+
+       DBG("File Descriptor = %d, Dev_path = %s \n", fdd, path);
+
+       msg = dbus_message_new_method_call("org.bluez", path,
+                       BLUEZ_HDP_CHANNEL_INTERFACE, "GetProperties");
+       if (!msg) {
+               DBG(" HDP:dbus Can't allocate new method call");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       dbus_error_init(&err);
+
+       reply = dbus_connection_send_with_reply_and_block(
+                       dbus_g_connection_get_connection(bt_internal_info->conn),
+                       msg, -1, &err);
+
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG(" HDP:dbus Can't get the reply");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+               }
+
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       dbus_message_iter_init(reply, &reply_iter);
+
+       if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
+               DBG("Can't get reply arguments - DBUS_TYPE_ARRAY\n");
+               goto error;
+       }
+
+       dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);
+
+       /*Parse the dict */
+       while (dbus_message_iter_get_arg_type(&reply_iter_entry) ==
+                                               DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter dict_entry, dict_entry_val;
+               dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
+               dbus_message_iter_get_basic(&dict_entry, &property);
+               DBG("String received = %s\n", property);
+
+               if (g_strcmp0("Type", property) == 0) {
+                       dbus_message_iter_next(&dict_entry);
+                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
+                       if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
+                                               DBUS_TYPE_STRING)
+                               continue;
+
+                       dbus_message_iter_get_basic(&dict_entry_val, &type_qos);
+
+               } else if (g_strcmp0("Device", property) == 0) {
+                       dbus_message_iter_next(&dict_entry);
+                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
+                       if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
+                                               DBUS_TYPE_OBJECT_PATH)
+                               continue;
+
+                       dbus_message_iter_get_basic(&dict_entry_val, &device);
+
+               } else if (g_strcmp0("Application", property) == 0) {
+                       dbus_message_iter_next(&dict_entry);
+                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
+                       if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
+                                               DBUS_TYPE_OBJECT_PATH)
+                               continue;
+
+                       dbus_message_iter_get_basic(&dict_entry_val,
+                                                       &app_handle);
+               }
+               dbus_message_iter_next(&reply_iter_entry);
+       }
+
+       DBG("QOS = %s, Device = %s, Apphandler = %s",
+                       type_qos, device, app_handle);
+
+       if (NULL == type_qos || NULL == app_handle) {
+               DBG("Pasing failed\n");
+               goto error;
+       }
+
+       list = __bt_hdp_internal_gslist_find_app_handler((void *)app_handle);
+
+       /*Only process register with app handle receive the Connected event */
+       if (NULL == list) {
+               DBG("**** Could not locate the list for %s*****\n", app_handle);
+               goto error;
+       }
+
+       list->obj_channel_path = g_strdup(path);
+
+       __bt_hdp_internal_watch_fd(fdd, list->obj_channel_path);
+
+       _bluetooth_internal_device_path_to_address(path, address);
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr,
+                                                               address);
+
+       conn_ind.app_handle = app_handle;
+
+       conn_ind.channel_id = fdd;
+
+       conn_ind.device_address = device_addr;
+
+       conn_ind.type = (g_strcmp0(type_qos, "Reliable") == 0) ?
+                       HDP_QOS_RELIABLE : HDP_QOS_STREAMING;
+
+       DBG("Going to give callback\n");
+
+       __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
+                                 BLUETOOTH_ERROR_NONE, &conn_ind);
+
+       dbus_message_unref(reply);
+
+       if (list->fd != -1) {
+               DBG("Warning! FD already updated(%d).Duplication!\n", list->fd);
+       }
+
+       list->fd = fdd;
+
+       DBG("Updated fd in the list*\n");
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+ error:
+       dbus_message_unref(reply);
+       return BLUETOOTH_ERROR_INTERNAL;
+}
+
+static void __bt_hdp_internal_watch_fd(int file_desc, const char *path)
+{
+       DBG("+\n");
+       GIOChannel *gio;
+
+       gio = g_io_channel_unix_new(file_desc);
+
+       g_io_channel_set_close_on_unref(gio, TRUE);
+
+       g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+                       __bt_hdp_internal_data_received, (void *)path);
+       DBG("-\n");
+}
+
+static gboolean __bt_hdp_internal_data_received(GIOChannel *gio,
+                                       GIOCondition cond, gpointer data)
+{
+       DBG("+\n");
+       char buff[5000] = { 0, };
+       int sk;
+       int act_read;
+       int to_read = sizeof(buff);
+       bt_hdp_data_ind_t data_ind = { 0, };
+
+       const char *path = (const char *)data;
+
+       sk = g_io_channel_unix_get_fd(gio);
+
+       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
+               DBG("GIOCondition %d.............path = %s\n", cond, path);
+               goto failed;
+       }
+
+       act_read = recv(sk, (void *)buff, to_read, 0);
+
+       if (act_read > 0) {
+               DBG("Received data of %d\n", act_read);
+       } else {
+               DBG("Read failed.....\n");
+               goto failed;
+       }
+
+       data_ind.channel_id = sk;
+
+       data_ind.buffer = buff;
+
+       data_ind.size = act_read;
+
+       __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_DATA_RECEIVED,
+                                         BLUETOOTH_ERROR_NONE, &data_ind);
+
+       return TRUE;
+failed:
+       __bt_hdp_internal_handle_disconnect_cb(sk, path);
+
+       DBG("-\n");
+
+       return FALSE;
+}
+
+static void __bt_hdp_internal_handle_disconnect_cb(int sk, const char *path)
+{
+       DBG("+\n");
+       char address[BT_ADDRESS_STRING_SIZE] = { 0, };
+       bluetooth_device_address_t device_addr = { {0} };
+       bt_hdp_disconnected_t dis_ind = { 0, };
+
+       hdp_app_list_t *list = __bt_hdp_internal_gslist_find_using_fd(sk);
+       if (NULL == list) {
+               ERR("** Could not locate the list for fd %d****\n", sk);
+               return;
+       }
+
+       _bluetooth_internal_device_path_to_address(path, address);
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(
+                                       &device_addr, address);
+
+       dis_ind.channel_id = sk;
+
+       dis_ind.device_address = device_addr;
+
+       __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, &dis_ind);
+
+       if (list->fd == -1) {
+               DBG("*** Warning! FD already deleted**\n");
+       }
+
+       list->fd = -1;
+
+       g_free(list->obj_channel_path);
+
+       list->obj_channel_path = NULL;
+
+       DBG("Successfully removed  fd value in the list\n");
+
+       close(sk);
+
+       DBG("-\n");
+}
+
+BT_EXPORT_API int bluetooth_hdp_deactivate(const char *app_handle)
+{
+       DBG("+\n");
+       int ret = BLUETOOTH_ERROR_NONE;
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (bt_internal_info->bt_adapter_state != BLUETOOTH_ADAPTER_ENABLED) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       if (NULL == app_handle) {
+               DBG("APP handler is nULL\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       ret = __bt_hdp_internal_destroy_application(app_handle);
+
+       app_handle = NULL;
+
+       return ret;
+}
+
+static hdp_app_list_t *__bt_hdp_internal_gslist_find_app_handler(void *app_handle)
+{
+       DBG("List length = %d\n", g_slist_length(g_app_list));
+
+       GSList *l;
+       for (l = g_app_list; l != NULL; l = l->next) {
+               hdp_app_list_t *list = l->data;
+
+               if (list) {
+                       if (0 == g_strcmp0((char *)list->app_handle,
+                                               (char *)app_handle))
+                               return list;
+               }
+       }
+       return NULL;
+}
+
+static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_fd(int fd)
+{
+       GSList *l;
+
+       DBG("List length = %d\n", g_slist_length(g_app_list));
+
+       for (l = g_app_list; l != NULL; l = l->next) {
+               hdp_app_list_t *list = l->data;
+
+               if (list) {
+                       if (fd == list->fd)
+                               return list;
+               }
+       }
+       return NULL;
+}
+
+static hdp_app_list_t *__bt_hdp_internal_gslist_find_using_obj_channel(
+                               const char *obj_channel_path)
+{
+       GSList *l;
+       DBG("List length = %d\n", g_slist_length(g_app_list));
+       for (l = g_app_list; l != NULL; l = l->next) {
+               hdp_app_list_t *list = l->data;
+               if (list) {
+                       if (0 == g_strcmp0((char *)list->obj_channel_path,
+                                               obj_channel_path))
+                               return list;
+               }
+       }
+       return NULL;
+}
+
+static gboolean  __bt_hdp_internal_destroy_application_cb(gpointer data)
+{
+       DBG(" +\n");
+       bt_hdp_deactivate_t deact_cfm;
+       hdp_app_list_t *list = NULL;
+       deact_cfm.app_handle = (const char *)data;
+       __bt_hdp_internal_event_cb(BLUETOOTH_EVENT_HDP_DEACTIVATED,
+                                       BLUETOOTH_ERROR_NONE, &deact_cfm);
+
+       list = __bt_hdp_internal_gslist_find_app_handler((void *)deact_cfm.app_handle);
+       if (NULL == list) {
+               DBG("***** Could not locate the list for %s*****\n",
+                                       deact_cfm.app_handle);
+               return FALSE;
+       }
+
+       g_app_list = g_slist_remove(g_app_list, list);
+
+       if (list != NULL) {
+               g_free(list->app_handle);
+               g_free(list->obj_channel_path);
+               g_free(list);
+       }
+
+       DBG("List length = %d\n", g_slist_length(g_app_list));
+
+       if (0 == g_slist_length(g_app_list))
+               __bt_hdp_internal_remove_filter();
+       DBG(" -\n");
+       return FALSE;
+}
+
+static int __bt_hdp_internal_destroy_application(const char *app_handle)
+{
+
+       DBusMessage *msg, *reply;
+       DBusError err;
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
+                       BLUEZ_HDP_MANAGER_INTERFACE, "DestroyApplication");
+
+       if (!msg) {
+               DBG(" HDP:dbus Can't allocate new method call");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &app_handle,
+                                       DBUS_TYPE_INVALID);
+
+       dbus_error_init(&err);
+
+       reply = dbus_connection_send_with_reply_and_block(
+                       dbus_g_connection_get_connection(bt_internal_info->conn),
+                       msg, -1, &err);
+
+       dbus_message_unref(msg);
+       if (!reply) {
+               DBG(" HDP:dbus Can't Destroy application");
+
+               if (dbus_error_is_set(&err)) {
+                       DBG("%s", err.message);
+                       dbus_error_free(&err);
+               }
+               DBG(" 5\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       dbus_message_unref(reply);
+
+       DBG("Destroyed health application: %s", (char *)app_handle);
+
+       g_idle_add(__bt_hdp_internal_destroy_application_cb,
+                       (gpointer)app_handle);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bt_hdp_internal_remove_filter(void)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL || bt_internal_info->conn == NULL)
+               return;
+
+       if (g_hdp_dus_conn == NULL) {
+               DBG("hdp_conn is NULL");
+               return;
+       }
+
+       dbus_connection_remove_filter(g_hdp_dus_conn,
+                                       __bt_hdp_internal_event_filter, NULL);
+
+       g_hdp_dus_conn = NULL;  /*should not unref here, bcz no ++reff */
+
+       DBG("-\n");
+}
+
+BT_EXPORT_API int bluetooth_hdp_send_data(unsigned int channel_id,
+                                           const char *buffer,
+                                           unsigned int size)
+{
+       DBG("+\n");
+
+       int wbytes = 0, written = 0;
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (bt_internal_info->bt_adapter_state != BLUETOOTH_ADAPTER_ENABLED) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       if ((channel_id <= 0) || (NULL == buffer) || (size <= 0)) {
+               DBG("Invalid arguments..\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       } else {
+               while (wbytes < size) {
+                       written = write(channel_id, buffer + wbytes, size - wbytes);
+                       if (written <= 0) {
+                               DBG("write failed..\n");
+                               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+                       }
+                       wbytes += written;
+               }
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_hdp_connect(const char *app_handle,
+                       bt_hdp_qos_type_t channel_type,
+                       const bluetooth_device_address_t *device_address)
+{
+       DBG("+\n");
+       GError *err = NULL;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *hdp_proxy = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
+       char *dev_path = NULL;
+       char *role;
+       char *obj_connect_path = NULL;
+
+       bt_info_t *bt_internal_info = NULL;
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (bt_internal_info->bt_adapter_state != BLUETOOTH_ADAPTER_ENABLED) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       if (NULL == app_handle || NULL == device_address) {
+               DBG("Invalid param\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (channel_type == HDP_QOS_RELIABLE)
+               role = "Reliable";
+
+       else if (channel_type == HDP_QOS_STREAMING)
+               role = "Streaming";
+
+       else if (channel_type == HDP_QOS_ANY)
+               role = "Any";
+       else {
+               DBG("Invalid channel_type %d", channel_type);
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (err != NULL) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /* If the adapter path is wrong, we can think the BT is not enabled. */
+       if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) {
+               DBG("Could not get adapter path\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+
+       DBG("create conection to  %s\n", address);
+
+       dev_path = g_strdup_printf("%s/dev_%s", default_adapter_path, address);
+
+       if (dev_path == NULL) {
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+       }
+
+       g_strdelimit(dev_path, ":", '_');
+
+       DBG("path  %s\n", dev_path);
+
+       hdp_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dev_path,
+                                              BLUEZ_HDP_DEVICE_INTERFACE);
+
+       if (hdp_proxy == NULL) {
+               DBG("Failed to get the HDP server proxy\n");
+               g_free(dev_path);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
+
+       DBG("app path %s\n", app_handle);
+
+       if (!dbus_g_proxy_call(hdp_proxy, "CreateChannel", NULL,
+               DBUS_TYPE_G_OBJECT_PATH, app_handle, G_TYPE_STRING,
+               role, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
+               &obj_connect_path, G_TYPE_INVALID)) {
+
+               DBG("HDP client connection Dbus Call Error");
+
+               g_free(dev_path);
+
+               g_object_unref(hdp_proxy);
+
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("Obj Path returned = %s\n", obj_connect_path);
+
+       g_free(dev_path);
+
+       g_object_unref(hdp_proxy);
+
+       dbus_g_connection_unref(conn);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_hdp_disconnect(unsigned int channel_id,
+                       const bluetooth_device_address_t *device_address)
+{
+       DBG("+\n");
+       GError *err = NULL;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *hdp_proxy = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
+       char *dev_path = NULL;
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (bt_internal_info->bt_adapter_state != BLUETOOTH_ADAPTER_ENABLED) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       if (NULL == device_address) {
+               DBG("Invalid param\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       hdp_app_list_t *list = __bt_hdp_internal_gslist_find_using_fd(channel_id);
+       if (NULL == list) {
+               DBG("*** Could not locate the list for %d*****\n", channel_id);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (err != NULL) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /* If the adapter path is wrong, we can think the BT is not enabled. */
+       if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) {
+               DBG("Could not get adapter path\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+
+       DBG("create conection to  %s\n", address);
+
+       dev_path = g_strdup_printf("%s/dev_%s", default_adapter_path, address);
+
+       if (dev_path == NULL) {
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+       }
+
+       g_strdelimit(dev_path, ":", '_');
+
+       DBG("path  %s\n", dev_path);
+
+       hdp_proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", dev_path,
+                                              BLUEZ_HDP_DEVICE_INTERFACE);
+
+       if (hdp_proxy == NULL) {
+               DBG("Failed to get the HDP proxy\n");
+               g_free(dev_path);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
+
+       if (!dbus_g_proxy_call(hdp_proxy, "DestroyChannel", NULL,
+                       DBUS_TYPE_G_OBJECT_PATH, list->obj_channel_path,
+                       G_TYPE_INVALID, G_TYPE_INVALID)) {
+               DBG("HDP client connection Dbus Call Error");
+               g_free(dev_path);
+               g_object_unref(hdp_proxy);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("Destroyed Obj Path  = %s\n", list->obj_channel_path);
+
+       g_free(dev_path);
+
+       g_object_unref(hdp_proxy);
+
+       dbus_g_connection_unref(conn);
+
+       return BLUETOOTH_ERROR_NONE;
+}
diff --git a/lib/bluetooth-hdp-api.h b/lib/bluetooth-hdp-api.h
new file mode 100644 (file)
index 0000000..a3252da
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __BLUETOOTH_HDP_API_H
+#define __BLUETOOTH_HDP_API_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#define BLUEZ_HDP_MANAGER_INTERFACE  "org.bluez.HealthManager"
+#define BLUEZ_HDP_DEVICE_INTERFACE  "org.bluez.HealthDevice"
+#define BLUEZ_HDP_CHANNEL_INTERFACE  "org.bluez.HealthChannel"
+
+typedef struct {
+       void *app_handle;
+       void *obj_channel_path;
+       int fd;
+} hdp_app_list_t;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BLUETOOTH_HDP_API_H */
diff --git a/lib/bluetooth-network-api.c b/lib/bluetooth-network-api.c
new file mode 100644 (file)
index 0000000..816c338
--- /dev/null
@@ -0,0 +1,736 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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-api-common.h"
+#include "bluetooth-network-api.h"
+
+/**********************************************************************
+*                                      Static Functions declaration    *
+***********************************************************************/
+
+static void __bluetooth_network_activate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                 gpointer user_data);
+static void __bluetooth_network_deactivate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                   gpointer user_data);
+static void __bluetooth_network_connect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                gpointer user_data);
+static void __bluetooth_network_disconnect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                   gpointer user_data);
+static void __bluetooth_network_server_connected(DBusGProxy *proxy, const char *device,
+                                              const char *address, gpointer user_data);
+static void __bluetooth_network_server_disconnected(DBusGProxy *proxy, const char *device,
+                                                 const char *address, gpointer user_data);
+static void __bluetooth_network_connection_changed_cb(gboolean connected,
+                                                   const bluetooth_device_address_t *device_addr);
+static DBusHandlerResult __bluetooth_network_event_filter(DBusConnection *sys_conn,
+                                                       DBusMessage *msg, void *data);
+
+/**********************************************************************
+*                                      Network server APIs (NAP)      *
+***********************************************************************/
+
+BT_EXPORT_API int bluetooth_network_activate_server(void)
+{
+       DBG("+\n");
+
+       GError *err = NULL;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *proxy_net_server = NULL;
+       char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (err != NULL) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /* If the adapter path is wrong, we can think the BT is not enabled. */
+       if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) {
+               DBG("Could not get adapter path\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       proxy_net_server = dbus_g_proxy_new_for_name(conn, "org.bluez",
+                                                    default_adapter_path, BLUEZ_NET_SERVER_PATH);
+
+       if (proxy_net_server == NULL) {
+               DBG("Failed to get the network server proxy\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (!dbus_g_proxy_begin_call(proxy_net_server, "Register",
+                       (DBusGProxyCallNotify) __bluetooth_network_activate_request_cb,
+                       conn,/*user data*/
+                       NULL, /*destroy*/
+                       G_TYPE_STRING,
+                       NAP_UUID_NAME,/*first_arg_type*/
+                       G_TYPE_STRING,
+                       NET_BRIDGE_INTERFACE,/*second_arg_type*/
+                       G_TYPE_INVALID)) {
+               DBG("Network server register Dbus Call Error");
+               g_object_unref(proxy_net_server);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_network_deactivate_server(void)
+{
+       DBG("+\n");
+
+       GError *err = NULL;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *proxy_net_server = NULL;
+       char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (err != NULL) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /* If the adapter path is wrong, we can think the BT is not enabled. */
+       if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) {
+               DBG("Could not get adapter path\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       proxy_net_server = dbus_g_proxy_new_for_name(conn, "org.bluez",
+                                                    default_adapter_path, BLUEZ_NET_SERVER_PATH);
+
+       if (proxy_net_server == NULL) {
+               DBG("Failed to get the network server proxy\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (!dbus_g_proxy_begin_call(proxy_net_server, "Unregister",
+                               (DBusGProxyCallNotify) __bluetooth_network_deactivate_request_cb,
+                               conn,   /*user_data*/
+                               NULL,   /*destroy*/
+                               G_TYPE_STRING, NAP_UUID_NAME,   /*first_arg_type*/
+                               G_TYPE_INVALID)) {
+               DBG("Network server deregister Dbus Call Error");
+               g_object_unref(proxy_net_server);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bluetooth_network_activate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                 gpointer user_data)
+{
+       GError *g_error = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       DBusGConnection *conn = NULL;
+
+       conn = (DBusGConnection *) user_data;
+
+       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
+
+       g_object_unref(proxy);
+       dbus_g_connection_unref(conn);
+
+       if (g_error != NULL) {
+               DBG("Network server register Dbus Call Error: %s\n", g_error->message);
+               g_error_free(g_error);
+               bt_event.result = BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               DBG("Network server register Dbus Call is done\n");
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+       }
+
+       bt_event.event = BLUETOOTH_EVENT_NETWORK_SERVER_ACTIVATED;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+}
+
+static void __bluetooth_network_deactivate_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                   gpointer user_data)
+{
+       GError *g_error = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       DBusGConnection *conn = NULL;
+
+       conn = (DBusGConnection *) user_data;
+
+       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
+
+       g_object_unref(proxy);
+       dbus_g_connection_unref(conn);
+
+       if (g_error != NULL) {
+               DBG("Network server unregister Dbus Call Error: %s\n", g_error->message);
+               g_error_free(g_error);
+               bt_event.result = BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               DBG("Network server unregister Dbus Call is done\n");
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+       }
+
+       bt_event.event = BLUETOOTH_EVENT_NETWORK_SERVER_DEACTIVATED;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+}
+
+void _bluetooth_network_server_add_signal(void)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+       DBusError dbus_error;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL || bt_internal_info->conn == NULL)
+               return;
+
+       if (strlen(bt_internal_info->adapter_path) <= 0)
+               return;
+
+       if (bt_internal_info->network_server_proxy != NULL) {
+               DBG("The network proxy already exist");
+               return;
+       }
+
+       /* Add the network server signal */
+       bt_internal_info->network_server_proxy =
+           dbus_g_proxy_new_for_name(bt_internal_info->conn, "org.bluez",
+                                     bt_internal_info->adapter_path, BLUEZ_NET_SERVER_PATH);
+
+       dbus_g_proxy_add_signal(bt_internal_info->network_server_proxy, "PeerConnected",
+                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(bt_internal_info->network_server_proxy, "PeerConnected",
+                                   G_CALLBACK(__bluetooth_network_server_connected), NULL, NULL);
+
+       dbus_g_proxy_add_signal(bt_internal_info->network_server_proxy, "PeerDisconnected",
+                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+       dbus_g_proxy_connect_signal(bt_internal_info->network_server_proxy, "PeerDisconnected",
+                                   G_CALLBACK(__bluetooth_network_server_disconnected), NULL, NULL);
+
+       DBG("-\n");
+}
+
+void _bluetooth_network_server_remove_signal(void)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return;
+
+       if (bt_internal_info->network_server_proxy == NULL) {
+               DBG("No network proxy exist");
+               return;
+       }
+
+       /* Remove the network server signal */
+       dbus_g_proxy_disconnect_signal(bt_internal_info->network_server_proxy, "PeerConnected",
+                                      G_CALLBACK(__bluetooth_network_server_connected), NULL);
+
+       dbus_g_proxy_disconnect_signal(bt_internal_info->network_server_proxy, "PeerDisconnected",
+                                      G_CALLBACK(__bluetooth_network_server_disconnected), NULL);
+
+       g_object_unref(bt_internal_info->network_server_proxy);
+
+       bt_internal_info->network_server_proxy = NULL;
+
+       DBG("-\n");
+}
+
+static void __bluetooth_network_server_connected(DBusGProxy *proxy,
+                                              const char *device, const char *address,
+                                              gpointer user_data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bluetooth_network_device_info_t device_info = { 0 };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+");
+
+       if (device == NULL || address == NULL)
+               return;
+
+       DBG("device[%s]", device);
+       DBG("address[%s]", address);
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&device_info.device_address, address);
+
+       memcpy(device_info.interface_name, device, BLUETOOTH_INTERFACE_NAME_LENGTH);
+
+       bt_event.event = BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED;
+       bt_event.param_data = (void *)&device_info;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+
+       DBG("-");
+}
+
+static void __bluetooth_network_server_disconnected(DBusGProxy *proxy,
+                                                 const char *device, const char *address,
+                                                 gpointer user_data)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bluetooth_network_device_info_t device_info = { 0 };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+");
+
+       if (device == NULL || address == NULL)
+               return;
+
+       DBG("device[%s]", device);
+       DBG("address[%s]", address);
+
+       _bluetooth_internal_convert_addr_string_to_addr_type(&device_info.device_address, address);
+
+       memcpy(device_info.interface_name, device, BLUETOOTH_INTERFACE_NAME_LENGTH);
+
+       bt_event.event = BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED;
+       bt_event.param_data = (void *)&device_info;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+
+       DBG("-");
+}
+
+/**********************************************************************
+*                                                 Network client APIs *
+***********************************************************************/
+
+BT_EXPORT_API int bluetooth_network_connect(const bluetooth_device_address_t *device_address,
+                                           bluetooth_network_role_t role, char *custom_uuid)
+{
+       DBG("+\n");
+
+       GError *err = NULL;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *proxy_net_client = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char theRemoteRole[BLUETOOTH_UUID_STRING_MAX] = { 0 };
+       char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
+       char *path = NULL;
+
+       if (role == BLUETOOTH_NETWORK_CUSTOM_UUID && custom_uuid == NULL) {
+               DBG("custom_uuid is NULL\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (err != NULL) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /* If the adapter path is wrong, we can think the BT is not enabled. */
+       if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) {
+               DBG("Could not get adapter path\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+
+       DBG("create conection to  %s\n", address);
+
+       path = g_strdup_printf("%s/dev_%s", default_adapter_path, address);
+
+       if (path == NULL) {
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+       }
+
+       g_strdelimit(path, ":", '_');
+       DBG("path  %s\n", path);
+
+       proxy_net_client = dbus_g_proxy_new_for_name(conn, "org.bluez",
+                                                    path, BLUEZ_NET_CLIENT_PATH);
+
+       if (proxy_net_client == NULL) {
+               DBG("Failed to get the network client proxy\n");
+               g_free(path);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
+
+       switch (role) {
+       case BLUETOOTH_NETWORK_PANU_ROLE:
+               g_strlcpy(theRemoteRole, PANU_UUID_NAME, BLUETOOTH_UUID_STRING_MAX);
+               break;
+
+       case BLUETOOTH_NETWORK_NAP_ROLE:
+               g_strlcpy(theRemoteRole, NAP_UUID_NAME, BLUETOOTH_UUID_STRING_MAX);
+               break;
+
+       case BLUETOOTH_NETWORK_GN_ROLE:
+               g_strlcpy(theRemoteRole, GN_UUID_NAME, BLUETOOTH_UUID_STRING_MAX);
+               break;
+
+       case BLUETOOTH_NETWORK_CUSTOM_UUID:
+               g_strlcpy(theRemoteRole, custom_uuid, BLUETOOTH_UUID_STRING_MAX);
+               break;
+
+       default:
+               g_strlcpy(theRemoteRole, PANU_UUID_NAME, BLUETOOTH_UUID_STRING_MAX);
+               break;
+       }
+
+       if (!dbus_g_proxy_begin_call(proxy_net_client, "Connect",
+                                       (DBusGProxyCallNotify) __bluetooth_network_connect_request_cb,
+                                       conn,/*user_data*/
+                                       NULL,   /*destroy*/
+                                       G_TYPE_STRING, theRemoteRole,   /* first_arg_type*/
+                                       G_TYPE_INVALID)) {
+               DBG("Network client connection Dbus Call Error");
+               g_free(path);
+               g_object_unref(proxy_net_client);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_free(path);
+
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+BT_EXPORT_API int bluetooth_network_disconnect(const bluetooth_device_address_t *device_address)
+{
+       DBG("+\n");
+
+       GError *err = NULL;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *proxy_net_client = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char *path = NULL;
+       char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+
+       if (err != NULL) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       /* If the adapter path is wrong, we can think the BT is not enabled. */
+       if (bluetooth_internal_get_adapter_path(conn, default_adapter_path) < 0) {
+               DBG("Could not get adapter path\n");
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+
+       path = g_strdup_printf("%s/dev_%s", default_adapter_path, address);
+
+       if (path == NULL) {
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+       }
+
+       g_strdelimit(path, ":", '_');
+       DBG("path  %s\n", path);
+
+       proxy_net_client = dbus_g_proxy_new_for_name(conn, "org.bluez",
+                                                    path, BLUEZ_NET_CLIENT_PATH);
+
+       if (proxy_net_client == NULL) {
+               DBG("Failed to get the network client proxy\n");
+               g_free(path);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
+
+       if (!dbus_g_proxy_begin_call(proxy_net_client, "Disconnect",
+                               (DBusGProxyCallNotify) __bluetooth_network_disconnect_request_cb,
+                               conn,   /*user_data*/
+                               NULL,   /*destroy*/
+                               G_TYPE_INVALID)) {
+               DBG("Network client connection Dbus Call Error");
+               g_free(path);
+               g_object_unref(proxy_net_client);
+               dbus_g_connection_unref(conn);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_free(path);
+
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+static void __bluetooth_network_connect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                gpointer user_data)
+{
+       GError *g_error = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       char *device = NULL;
+       DBusGConnection *conn = NULL;
+
+       conn = (DBusGConnection *) user_data;
+
+       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_STRING, &device, G_TYPE_INVALID);
+
+       g_object_unref(proxy);
+       dbus_g_connection_unref(conn);
+
+       if (g_error != NULL) {
+               DBG("Network Client connection  Dbus Call Error: %s\n", g_error->message);
+               g_error_free(g_error);
+               bt_event.result = BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               DBG("Network Client connection Dbus Call is done %s\n", device);
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+       }
+
+       bt_event.event = BLUETOOTH_EVENT_NETWORK_CONNECTED;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+}
+
+static void __bluetooth_network_disconnect_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                   gpointer user_data)
+{
+       GError *g_error = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       DBusGConnection *conn = NULL;
+
+       conn = (DBusGConnection *) user_data;
+
+       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
+
+       g_object_unref(proxy);
+       dbus_g_connection_unref(conn);
+
+       if (g_error != NULL) {
+               DBG("Network Client disconnection Dbus Call Error: %s\n", g_error->message);
+               g_error_free(g_error);
+               bt_event.result = BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               DBG("Network Client disconnection Dbus Call is done\n");
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+       }
+
+       bt_event.event = BLUETOOTH_EVENT_NETWORK_DISCONNECTED;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+}
+
+void _bluetooth_network_client_add_filter(void)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+       DBusError dbus_error;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL || bt_internal_info->conn == NULL)
+               return;
+
+       if (bt_internal_info->sys_conn) {
+               DBG("sys_conn already exist");
+               return;
+       }
+
+       /* Add the filter for network client functions */
+       dbus_error_init(&dbus_error);
+
+       bt_internal_info->sys_conn = dbus_g_connection_get_connection(bt_internal_info->conn);
+
+       dbus_connection_add_filter(bt_internal_info->sys_conn, __bluetooth_network_event_filter,
+                                       NULL, NULL);
+
+       dbus_bus_add_match(bt_internal_info->sys_conn,
+                          "type='signal',interface='" BLUEZ_NET_CLIENT_PATH
+                          "',member='PropertyChanged'", &dbus_error);
+
+       if (dbus_error_is_set(&dbus_error)) {
+               DBG("Fail to add dbus filter signal\n");
+               dbus_error_free(&dbus_error);
+       }
+
+       DBG("-\n");
+}
+
+void _bluetooth_network_client_remove_filter(void)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+       DBusError dbus_error;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info->sys_conn == NULL) {
+               DBG("sys_conn is NULL");
+               return;
+       }
+
+       /* Add the filter for network client functions */
+       dbus_error_init(&dbus_error);
+
+       dbus_connection_remove_filter(bt_internal_info->sys_conn, __bluetooth_network_event_filter,
+                                     NULL);
+
+       bt_internal_info->sys_conn = NULL;
+
+       DBG("-\n");
+}
+
+static void __bluetooth_network_connection_changed_cb(gboolean connected,
+                                                   const bluetooth_device_address_t *device_addr)
+{
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+");
+
+       bt_event.event =
+           connected ? BLUETOOTH_EVENT_NETWORK_CONNECTED : BLUETOOTH_EVENT_NETWORK_DISCONNECTED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = (void *)device_addr;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+
+       DBG("-");
+}
+
+static DBusHandlerResult __bluetooth_network_event_filter(DBusConnection *sys_conn,
+                                                       DBusMessage *msg, void *data)
+{
+       const char *path = dbus_message_get_path(msg);
+       DBusMessageIter item_iter, value_iter;
+       const char *property;
+       char *state;
+
+       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       if (!dbus_message_is_signal(msg, BLUEZ_NET_CLIENT_PATH, "PropertyChanged"))
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       if (path == NULL || strcmp(path, "/") == 0)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       dbus_message_iter_init(msg, &item_iter);
+
+       if (dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_STRING) {
+               DBG("This is bad format dbus\n");
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       }
+
+       dbus_message_iter_get_basic(&item_iter, &property);
+
+       if (property == NULL)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+       DBG("Property (%s)\n", property);
+
+       if (!strcmp(property, "Connected")) {
+               gboolean connected = FALSE;
+               char address[BT_ADDRESS_STRING_SIZE] = { 0, };
+               bluetooth_device_address_t device_addr = { {0} };
+
+               dbus_message_iter_next(&item_iter);
+               dbus_message_iter_recurse(&item_iter, &value_iter);
+               dbus_message_iter_get_basic(&value_iter, &connected);
+
+               DBG("connected: %d", connected);
+
+               _bluetooth_internal_device_path_to_address(path, address);
+               _bluetooth_internal_convert_addr_string_to_addr_type(&device_addr, address);
+
+               __bluetooth_network_connection_changed_cb(connected, &device_addr);
+       } else if (!strcmp(property, "Interface")) {
+               const gchar *device = NULL;
+
+               dbus_message_iter_next(&item_iter);
+               dbus_message_iter_recurse(&item_iter, &value_iter);
+               dbus_message_iter_get_basic(&value_iter, &device);
+
+               if (device)
+                       DBG("device is %s", device);
+       } else if (!strcmp(property, "UUID")) {
+               const gchar *uuid = NULL;
+
+               dbus_message_iter_next(&item_iter);
+               dbus_message_iter_recurse(&item_iter, &value_iter);
+               dbus_message_iter_get_basic(&value_iter, &uuid);
+
+               if (uuid)
+                       DBG("uuid is %s", uuid);
+       }
+
+       return DBUS_HANDLER_RESULT_HANDLED;
+}
diff --git a/lib/bluetooth-network-api.h b/lib/bluetooth-network-api.h
new file mode 100644 (file)
index 0000000..dfc159f
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __BLUETOOTH_NETWORK_API_H
+#define __BLUETOOTH_NETWORK_API_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BLUEZ_NET_SERVER_PATH "org.bluez.NetworkServer"
+#define BLUEZ_NET_CLIENT_PATH "org.bluez.Network"
+#define NAP_UUID_NAME "nap"
+#define GN_UUID_NAME "gn"
+#define PANU_UUID_NAME "panu"
+#define NET_BRIDGE_INTERFACE "pan0"
+
+void _bluetooth_network_server_add_signal(void);
+void _bluetooth_network_server_remove_signal(void);
+
+void _bluetooth_network_client_add_filter(void);
+void _bluetooth_network_client_remove_filter(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __BLUETOOTH_NETWORK_API_H */
diff --git a/lib/bluetooth-obex-server-api.c b/lib/bluetooth-obex-server-api.c
new file mode 100644 (file)
index 0000000..2bcb390
--- /dev/null
@@ -0,0 +1,798 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+#include <sys/time.h>
+#include <dbus/dbus-glib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <vconf.h>
+
+#include "bluetooth-api-common.h"
+#include "bluetooth-obex-server-api.h"
+#include "obex-agent.h"
+
+static GSList *transfers = NULL;
+char *g_dst_path = NULL;
+obex_server_info_t g_obex_server_info;
+
+static gboolean __bt_authorize_callback(DBusGMethodInvocation *context,
+                                       const char *path,
+                                       const char *bdaddress,
+                                       const char *name,
+                                       const char *type,
+                                       gint length,
+                                       gint time,
+                                       gpointer user_data);
+
+static int __bt_obex_agent_register(obex_server_info_t *obex_server_info,
+                                                       DBusGConnection *conn);
+
+static void __bt_obex_agent_unregister(obex_server_info_t *obex_server_info);
+
+static void __bt_transfer_progress_cb(DBusGProxy *object,
+                                       gint total,
+                                       gint transferred,
+                                       gpointer user_data);
+
+static void __bt_ops_internal_event_cb(int event, int result, void *param_data)
+{
+       DBG("+");
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bt_event.event = event;
+       bt_event.result = result;
+       bt_event.param_data = param_data;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                       bt_internal_info->user_data);
+
+       DBG("-");
+}
+
+static GQuark __bt_obex_agent_error_quark(void)
+{
+       static GQuark quark = 0;
+       if (!quark)
+               quark = g_quark_from_static_string("agent");
+
+       return quark;
+}
+
+static GError *__bt_obex_agent_error(bt_obex_agent_error_t error,
+                                    const char *err_msg)
+{
+       return g_error_new(BT_OBEX_AGENT_ERROR, error, err_msg);
+}
+
+BT_EXPORT_API int bluetooth_obex_server_init(char *dst_path)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (g_obex_server_info.obex_server_agent) {
+               DBG("Agent already registered");
+               return BLUETOOTH_ERROR_AGENT_ALREADY_EXIST;
+       }
+
+       if (NULL == dst_path) {
+               DBG("Invalid Param");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       g_dst_path = g_strdup(dst_path);
+
+       DBG("- \n");
+       return __bt_obex_agent_register(&g_obex_server_info,
+                                       bt_internal_info->conn);
+}
+
+BT_EXPORT_API int bluetooth_obex_server_deinit(void)
+{
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == g_obex_server_info.obex_server_agent) {
+               DBG("Agent not registered");
+               return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
+       }
+
+       __bt_obex_agent_unregister(&g_obex_server_info);
+
+       g_free(g_dst_path);
+       g_dst_path = NULL;
+
+       DBG("- \n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API gboolean bluetooth_obex_server_is_activated(void)
+{
+       gboolean exist = FALSE;
+       DBusGConnection *conn = NULL;
+       DBusGProxy *obex_proxy = NULL;
+       GError *error = NULL;
+
+       DBG("+");
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL)
+               return FALSE;
+
+       obex_proxy = dbus_g_proxy_new_for_name(conn,
+                                       OBEX_SERVER_SERVICE,
+                                       "/", OBEX_SERVER_MANAGER);
+
+       if (obex_proxy == NULL) {
+               DBG("obex_proxy is NULL \n");
+               dbus_g_connection_unref(conn);
+               return FALSE;
+       }
+
+       dbus_g_proxy_call(obex_proxy, "RegisterAgent", &error,
+                         DBUS_TYPE_G_OBJECT_PATH, BT_INVALID_PATH,
+                         G_TYPE_INVALID, G_TYPE_INVALID);
+       if (error != NULL) {
+               DBG("Error: %s\n", error->message);
+
+               if (!strcmp(error->message, "Agent already exists"))
+                       exist = TRUE;
+
+               g_error_free(error);
+       }
+
+       g_object_unref(obex_proxy);
+       dbus_g_connection_unref(conn);
+
+       DBG("-");
+
+       return exist;
+}
+
+static transfer_info_t *_bt_find_transfer(const char *transfer_path)
+{
+       GSList *l;
+
+       for (l = transfers; l != NULL; l = l->next) {
+               transfer_info_t *transfer = l->data;
+
+               if (transfer) {
+                       if (0 == g_strcmp0(transfer->path, transfer_path))
+                               return transfer;
+               }
+       }
+
+       return NULL;
+}
+
+static void __bt_obex_server_transfer_free(transfer_info_t *transfer_info)
+{
+       DBG("+");
+
+       if (transfer_info == NULL)
+               return;
+
+       if (transfer_info->transfer_proxy) {
+               dbus_g_proxy_disconnect_signal(transfer_info->transfer_proxy,
+                                      "Progress",
+                                      G_CALLBACK(__bt_transfer_progress_cb),
+                                      transfer_info);
+
+                       g_object_unref(transfer_info->transfer_proxy);
+                       transfer_info->transfer_proxy = NULL;
+       }
+
+       g_free(transfer_info->path);
+       g_free(transfer_info->filename);
+       g_free(transfer_info->device_name);
+       g_free(transfer_info->type);
+       g_free(transfer_info);
+
+       DBG("-");
+}
+
+static int __bt_obex_server_reply_authorize(const guint accept,
+                                       const char *filepath,
+                                       obex_server_info_t *obex_server_info)
+{
+       DBG("+\n");
+
+       if (obex_server_info) {
+               if (accept == BT_OBEX_AGENT_ACCEPT) {
+                       dbus_g_method_return(obex_server_info->reply_context, filepath);
+               } else {
+                       GError *error = NULL;
+                       error = __bt_obex_agent_error(BT_OBEX_AGENT_ERROR_CANCEL,
+                                                 "CanceledbyUser");
+                       dbus_g_method_return_error(obex_server_info->reply_context, error);
+                       g_error_free(error);
+                       g_free(obex_server_info->filename);
+                       obex_server_info->filename = NULL;
+                       g_free(obex_server_info->device_name);
+                       obex_server_info->device_name = NULL;
+                       g_free(obex_server_info->type);
+                       obex_server_info->type = NULL;
+               }
+       }
+
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+
+BT_EXPORT_API int bluetooth_obex_server_accept_authorize(char *filename)
+{
+       DBG("+\n");
+
+       char file_path[FILE_PATH_LEN] = { 0, };
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == g_obex_server_info.obex_server_agent) {
+               DBG("Agent not registered");
+               return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
+       }
+
+       if (NULL == filename) {
+               DBG("Invalid param");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (g_dst_path)
+               snprintf(file_path, sizeof(file_path), "%s/%s",
+                       g_dst_path, filename);
+
+       DBG("- \n");
+       return __bt_obex_server_reply_authorize(BT_OBEX_AGENT_ACCEPT,
+                                       file_path,
+                                       &g_obex_server_info);
+}
+
+BT_EXPORT_API int bluetooth_obex_server_reject_authorize(void)
+{
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == g_obex_server_info.obex_server_agent) {
+               DBG("Agent not registered");
+               return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
+       }
+
+       DBG("- \n");
+       return __bt_obex_server_reply_authorize(BT_OBEX_AGENT_REJECT,
+                                       NULL,
+                                       &g_obex_server_info);
+}
+
+BT_EXPORT_API int bluetooth_obex_server_set_destination_path(char *dst_path)
+{
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == g_obex_server_info.obex_server_agent) {
+               DBG("Agent not registered");
+               return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
+       }
+
+       if (NULL == dst_path) {
+               DBG("Invalid Param");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       g_free(g_dst_path);
+       g_dst_path = g_strdup(dst_path);
+
+       DBG("- \n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_obex_server_set_root(char *root)
+{
+       GError *error = NULL;
+       GValue folder = { 0 };
+       obex_server_info_t *obex_server_info = &g_obex_server_info;
+
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == obex_server_info->obex_server_agent) {
+               DBG("Agent not registered");
+               return BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST;
+       }
+
+
+       if (obex_server_info->obex_proxy == NULL) {
+               DBG("obex_proxy is NULL \n");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       if (root == NULL) {
+               DBG("Invalid parameter \n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       DBG("Set Root Foler: %s", root);
+
+       g_value_init(&folder, G_TYPE_STRING);
+       g_value_set_string(&folder, root);
+
+       dbus_g_proxy_call(obex_server_info->obex_proxy, "SetProperty",
+                       &error, G_TYPE_STRING, "Root",
+                       G_TYPE_VALUE, &folder, G_TYPE_INVALID, G_TYPE_INVALID);
+
+       g_value_unset(&folder);
+
+       if (error) {
+               DBG("SetProperty Fail: %s", error->message);
+               g_error_free(error);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static char *__bt_get_remote_device_name(DBusGConnection *bus,
+                                        const char *bdaddress)
+{
+       DBusGProxy *manager_proxy = NULL;
+       DBusGProxy *adapter_proxy = NULL;
+       GError *error = NULL;
+       const char *adapter_path = NULL;
+       char *device_path = NULL;
+       DBusGProxy *device = NULL;
+       GHashTable *hash = NULL;
+       GValue *value;
+       gchar *name = NULL;
+       DBG("+\n");
+
+       if ((NULL == bus) || (NULL == bdaddress)) {
+               return NULL;
+       }
+
+       manager_proxy = dbus_g_proxy_new_for_name(bus,
+                                       "org.bluez", "/",
+                                     "org.bluez.Manager");
+
+       if (NULL == manager_proxy) {
+               ERR("ERROR: Can't make dbus proxy");
+               goto done;
+       }
+
+       if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &error,
+                              G_TYPE_INVALID,
+                              DBUS_TYPE_G_OBJECT_PATH, &adapter_path,
+                              G_TYPE_INVALID)) {
+               DBG("Getting DefaultAdapter failed: [%s]", error->message);
+               g_error_free(error);
+               error = NULL;
+               goto done;
+       }
+
+       adapter_proxy = dbus_g_proxy_new_for_name(bus, "org.bluez",
+                                       adapter_path,
+                                     "org.bluez.Adapter");
+
+       if (NULL == adapter_proxy)
+               goto done;
+
+       if (!dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
+                              G_TYPE_STRING, bdaddress, G_TYPE_INVALID,
+                              DBUS_TYPE_G_OBJECT_PATH, &device_path,
+                              G_TYPE_INVALID)) {
+               goto done;
+       }
+
+       device = dbus_g_proxy_new_from_proxy(adapter_proxy,
+                                       "org.bluez.Device",
+                                       device_path);
+       if (NULL == device)
+               goto done;
+
+       if (!dbus_g_proxy_call(device, "GetProperties", &error,
+                              G_TYPE_INVALID,
+                              dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
+                                                  G_TYPE_VALUE), &hash,
+                              G_TYPE_INVALID)) {
+               DBG("error in GetBasicProperties [%s]\n", error->message);
+               g_error_free(error);
+               error = NULL;
+               goto done;
+       }
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "Name");
+               name = value ? g_value_dup_string(value) : NULL;
+       }
+
+ done:
+       if (device)
+               g_object_unref(device);
+
+       if (adapter_proxy)
+               g_object_unref(adapter_proxy);
+
+       if (manager_proxy)
+               g_object_unref(manager_proxy);
+
+       DBG("-");
+       return name;
+}
+
+static gboolean __bt_authorize_callback(DBusGMethodInvocation *context,
+                                       const char *path,
+                                       const char *bdaddress,
+                                       const char *name,
+                                       const char *type,
+                                       gint length,
+                                       gint time,
+                                       gpointer user_data)
+{
+       char *device_path = NULL;
+       DBusGProxy *device = NULL;
+       bt_obex_server_authorize_into_t auth_info;
+       const gchar *device_name = NULL;
+       obex_server_info_t *obex_server_info = user_data;
+       DBG("+\n");
+       DBG(" File name [%s] Address [%s] Type [%s] length [%d] path [%s] \n",
+           name, bdaddress, type, length, path);
+       obex_server_info->reply_context = context;
+
+       /* We have to free filename to handle the case -
+        * authorize reply is sent but transfer started did not come. */
+       g_free(obex_server_info->filename);
+       g_free(obex_server_info->device_name);
+       g_free(obex_server_info->type);
+       obex_server_info->filename = g_strdup(name);
+       auth_info.type = g_strdup(type);
+       obex_server_info->type = auth_info.type;
+       auth_info.filename = obex_server_info->filename;
+       auth_info.length = length;
+       obex_server_info->file_size = length;
+       obex_server_info->device_name = __bt_get_remote_device_name(obex_server_info->bus,
+                                                                                       bdaddress);
+       if (NULL == obex_server_info->device_name)
+               obex_server_info->device_name = g_strdup(bdaddress);
+
+       auth_info.device_name = obex_server_info->device_name;
+
+       __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE,
+                                               BLUETOOTH_ERROR_NONE, &auth_info);
+
+       DBG("-\n");
+       return TRUE;
+}
+
+static int __bt_get_transfer_id(const char *path)
+{
+       char *tmp = NULL;
+       if (path == NULL)
+               return -1;
+       tmp = strrchr(path, 'r') + 1;
+       return atoi(tmp);
+}
+
+static void __bt_transfer_progress_cb(DBusGProxy *object,
+                                       gint total,
+                                       gint transferred,
+                                       gpointer user_data)
+{
+       bt_obex_server_transfer_info_t info;
+       transfer_info_t *transfer_info = user_data;
+       gdouble percentage_progress = 0;
+
+       if (transfer_info) {
+               DBG("File [%s] path [%s]\n", transfer_info->filename,
+                   transfer_info->path);
+               info.filename = transfer_info->filename;
+
+               percentage_progress = (gdouble) transferred / (gdouble) total * 100;
+               info.percentage = percentage_progress;
+               info.transfer_id = __bt_get_transfer_id(transfer_info->path);
+               info.type = transfer_info->type;
+               info.device_name = transfer_info->device_name;
+               info.file_size = transfer_info->file_size;
+
+               DBG("Transfer ID : %d    Percentage : %d \n",
+                       info.transfer_id, (int)percentage_progress);
+
+               __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,
+                                               BLUETOOTH_ERROR_NONE, &info);
+       }
+}
+
+static void __bt_session_created_cb(DBusGProxy *object,
+                                   const char *session_path,
+                                   gpointer user_data)
+{
+       DBG("%s\n", session_path);
+}
+
+static void __bt_session_removed_cb(DBusGProxy *object,
+                                   const char *session_path,
+                                   gpointer user_data)
+{
+       DBG("%s\n", session_path);
+}
+
+static void __bt_transfer_started_cb(DBusGProxy *object,
+                                    const char *transfer_path,
+                                    gpointer user_data)
+{
+       obex_server_info_t *obex_server_info = user_data;
+       bt_obex_server_transfer_info_t app_transfer_info;
+       DBG("%s\n", transfer_path);
+       transfer_info_t *transfer_info = g_new0(transfer_info_t, 1);
+       if (transfer_info) {
+               transfer_info->transfer_proxy = dbus_g_proxy_new_for_name(obex_server_info->bus,
+                                             "org.openobex", transfer_path,
+                                             "org.openobex.Transfer");
+               if (transfer_info->transfer_proxy) {
+                       dbus_g_proxy_add_signal(transfer_info->transfer_proxy,
+                                               "Progress", G_TYPE_INT,
+                                               G_TYPE_INT, G_TYPE_INVALID);
+
+                       dbus_g_proxy_connect_signal(transfer_info->transfer_proxy,
+                                                       "Progress",
+                                                   G_CALLBACK(__bt_transfer_progress_cb),
+                                                   transfer_info, NULL);
+               }
+
+               transfer_info->path = g_strdup(transfer_path);
+               transfer_info->filename = obex_server_info->filename;
+               obex_server_info->filename = NULL;
+               transfer_info->device_name = obex_server_info->device_name;
+               transfer_info->transfer_id = __bt_get_transfer_id(transfer_info->path);
+               DBG("Transfer ID : %d \n", transfer_info->transfer_id);
+               obex_server_info->device_name = NULL;
+               transfer_info->type = obex_server_info->type;
+               transfer_info->file_size = obex_server_info->file_size;
+               obex_server_info->type = NULL;
+
+               transfers = g_slist_append(transfers, transfer_info);
+
+               app_transfer_info.filename = transfer_info->filename;
+               app_transfer_info.device_name = transfer_info->device_name;
+               app_transfer_info.transfer_id = transfer_info->transfer_id;
+               app_transfer_info.type = transfer_info->type;
+               app_transfer_info.file_size = transfer_info->file_size;
+
+               DBG("Transfer id %d\n", app_transfer_info.transfer_id);
+
+               __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED,
+                                               BLUETOOTH_ERROR_NONE, &app_transfer_info);
+       }
+}
+
+static void __bt_transfer_completed_cb(DBusGProxy *object,
+                                       const char *transfer_path,
+                                       gboolean success,
+                                       gpointer user_data)
+{
+       obex_server_info_t *obex_server_info = user_data;
+       transfer_info_t *transfer_info;
+       int result;
+       DBG("Transfer [%s] Success [%d] \n", transfer_path, success);
+       if (success)
+               result = BLUETOOTH_ERROR_NONE;
+       else
+               result = BLUETOOTH_ERROR_CANCEL;
+
+       transfer_info = _bt_find_transfer(transfer_path);
+       if (transfer_info) {
+               bt_obex_server_transfer_info_t transfer_complete_info;
+               transfers = g_slist_remove(transfers, transfer_info);
+               transfer_complete_info.filename = transfer_info->filename;
+               transfer_complete_info.device_name = transfer_info->device_name;
+               transfer_complete_info.transfer_id = __bt_get_transfer_id(transfer_path);
+               transfer_complete_info.type = transfer_info->type;
+               transfer_complete_info.file_size - transfer_info->file_size;
+
+               __bt_ops_internal_event_cb(BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,
+                                               result, &transfer_complete_info);
+
+               __bt_obex_server_transfer_free(transfer_info);
+       }
+}
+
+static int __bt_obex_agent_register(obex_server_info_t *obex_server_info,
+                                                       DBusGConnection *conn)
+{
+       GError *error = NULL;
+       DBG("\n");
+
+       obex_server_info->obex_server_agent = obex_agent_new();
+       if (NULL == obex_server_info->obex_server_agent) {
+               DBG("obex_server_agent is NULL \n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       obex_agent_set_authorize_func(obex_server_info->obex_server_agent,
+                                     __bt_authorize_callback,
+                                     obex_server_info);
+       obex_agent_setup(obex_server_info->obex_server_agent,
+                        OBEX_SERVER_AGENT_PATH);
+
+       obex_server_info->obex_proxy = dbus_g_proxy_new_for_name(conn,
+                                                       "org.openobex",
+                                                       "/", "org.openobex.Manager");
+
+       if (obex_server_info->obex_proxy == NULL) {
+               DBG("obex_proxy is NULL \n");
+               g_object_unref(obex_server_info->obex_server_agent);
+               obex_server_info->obex_server_agent = NULL;
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("Register Agent");
+       dbus_g_proxy_call(obex_server_info->obex_proxy, "RegisterAgent", &error,
+                         DBUS_TYPE_G_OBJECT_PATH, OBEX_SERVER_AGENT_PATH,
+                         G_TYPE_INVALID, G_TYPE_INVALID);
+       if (error != NULL) {
+               DBG("Agent registration failed: %s\n", error->message);
+               int result;
+               g_object_unref(obex_server_info->obex_proxy);
+               obex_server_info->obex_proxy = NULL;
+               g_object_unref(obex_server_info->obex_server_agent);
+               obex_server_info->obex_server_agent = NULL;
+               if(!g_strcmp0(error->message, "Agent already exists"))
+                       result = BLUETOOTH_ERROR_AGENT_ALREADY_EXIST;
+               else
+                       result = BLUETOOTH_ERROR_INTERNAL;
+               g_error_free(error);
+               return result;
+       }
+
+       obex_server_info->bus = conn;
+
+       dbus_g_proxy_add_signal(obex_server_info->obex_proxy, "TransferStarted",
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+
+       dbus_g_proxy_connect_signal(obex_server_info->obex_proxy,
+                                   "TransferStarted",
+                                   G_CALLBACK(__bt_transfer_started_cb),
+                                   obex_server_info, NULL);
+
+       dbus_g_proxy_add_signal(obex_server_info->obex_proxy,
+                               "TransferCompleted", DBUS_TYPE_G_OBJECT_PATH,
+                               G_TYPE_BOOLEAN, G_TYPE_INVALID);
+
+       dbus_g_proxy_connect_signal(obex_server_info->obex_proxy,
+                                   "TransferCompleted",
+                                   G_CALLBACK(__bt_transfer_completed_cb),
+                                   obex_server_info, NULL);
+
+       dbus_g_proxy_add_signal(obex_server_info->obex_proxy, "SessionCreated",
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+
+       dbus_g_proxy_connect_signal(obex_server_info->obex_proxy,
+                                   "SessionCreated",
+                                   G_CALLBACK(__bt_session_created_cb),
+                                   obex_server_info, NULL);
+
+       dbus_g_proxy_add_signal(obex_server_info->obex_proxy, "SessionRemoved",
+                               DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+
+       dbus_g_proxy_connect_signal(obex_server_info->obex_proxy,
+                                   "SessionRemoved",
+                                   G_CALLBACK(__bt_session_removed_cb),
+                                   obex_server_info, NULL);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static void __bt_obex_agent_unregister(obex_server_info_t *obex_server_info)
+{
+       GError *error = NULL;
+       DBG("\n");
+
+       dbus_g_proxy_call(obex_server_info->obex_proxy, "UnregisterAgent", &error,
+                         DBUS_TYPE_G_OBJECT_PATH, OBEX_SERVER_AGENT_PATH,
+                         G_TYPE_INVALID, G_TYPE_INVALID);
+       if (error != NULL) {
+               DBG("Agent unregistration failed: %s\n", error->message);
+               g_error_free(error);
+       }
+
+       dbus_g_proxy_disconnect_signal(obex_server_info->obex_proxy,
+                                   "TransferStarted",
+                                   G_CALLBACK(__bt_transfer_started_cb),
+                                   obex_server_info);
+
+       dbus_g_proxy_disconnect_signal(obex_server_info->obex_proxy,
+                                   "TransferCompleted",
+                                   G_CALLBACK(__bt_transfer_completed_cb),
+                                   obex_server_info);
+
+       dbus_g_proxy_disconnect_signal(obex_server_info->obex_proxy,
+                                   "SessionCreated",
+                                   G_CALLBACK(__bt_session_created_cb),
+                                   obex_server_info);
+
+       dbus_g_proxy_disconnect_signal(obex_server_info->obex_proxy,
+                                   "SessionRemoved",
+                                   G_CALLBACK(__bt_session_removed_cb),
+                                   obex_server_info);
+
+       obex_server_info->bus = NULL;
+
+       g_object_unref(obex_server_info->obex_proxy);
+       obex_server_info->obex_proxy = NULL;
+
+       g_object_unref(obex_server_info->obex_server_agent);
+       obex_server_info->obex_server_agent = NULL;
+}
+
+
diff --git a/lib/bluetooth-obex-server-api.h b/lib/bluetooth-obex-server-api.h
new file mode 100644 (file)
index 0000000..30bf834
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 BLUETOOTH_OBEX_SERVER_API_H
+#define BLUETOOTH_OBEX_SERVER_API_H
+
+#include "bluetooth-api-common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define FILE_PATH_LEN (4096 + 10)
+
+#define OBEX_SERVER_SERVICE "org.openobex"
+#define OBEX_SERVER_MANAGER "org.openobex.Manager"
+#define BT_OBEX_SERVICE_INTERFACE "org.openobex.Agent"
+#define OBEX_SERVER_AGENT_PATH "/org/bluez/obex_server_agent"
+#define BT_INVALID_PATH "/Invalid/Path"
+#define BT_OBEX_AGENT_ERROR (__bt_obex_agent_error_quark())
+
+typedef enum {
+       BT_OBEX_AGENT_ERROR_REJECT,
+       BT_OBEX_AGENT_ERROR_CANCEL,
+       BT_OBEX_AGENT_ERROR_TIMEOUT,
+} bt_obex_agent_error_t;
+
+typedef struct {
+       DBusGConnection *bus;
+       void *obex_server_agent;
+       DBusGProxy *obex_proxy;
+       DBusGMethodInvocation *reply_context;
+       char *filename;
+       char *device_name;
+       char *type;
+       int file_size;
+} obex_server_info_t;
+
+typedef enum {
+       BT_OBEX_AGENT_ACCEPT,
+       BT_OBEX_AGENT_REJECT,
+       BT_OBEX_AGENT_CANCEL,
+       BT_OBEX_AGENT_TIMEOUT,
+} bt_obex_server_accept_type_t;
+
+typedef struct {
+       DBusGProxy *transfer_proxy;
+       char *path;
+       char *filename;
+       char *device_name;
+       char *type;
+       int transfer_id;
+       int file_size;
+} transfer_info_t;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* BLUETOOTH_OBEX_SERVER_API_H */
+
diff --git a/lib/bluetooth-opc-api.c b/lib/bluetooth-opc-api.c
new file mode 100644 (file)
index 0000000..f820a26
--- /dev/null
@@ -0,0 +1,574 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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-api-common.h"
+#include "bluetooth-opc-api.h"
+
+#include "obex-agent.h"
+#include <sys/time.h>
+#include <dbus/dbus-glib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+static ObexAgent *opc_obex_agent = NULL;
+static DBusGProxy *client_proxy = NULL;
+static DBusGProxy *current_transfer = NULL;
+
+static gboolean cancel_sending_files = FALSE;
+struct obexd_transfer_hierarchy opc_current_transfer = { 0, };
+
+unsigned int g_counter = 0;
+
+static int __bt_obex_client_agent_init(char *agent_path);
+
+static void __bt_free_obexd_transfer_hierarchy(struct obexd_transfer_hierarchy
+                                              *current_transfer);
+
+static void __bt_send_files_cb(DBusGProxy *proxy,
+                              DBusGProxyCall *call, void *user_data);
+
+static void __bt_value_free(GValue *value)
+{
+       g_value_unset(value);
+       g_free(value);
+}
+static GQuark __bt_opc_error_quark(void)
+{
+       static GQuark quark = 0;
+       if (!quark)
+               quark = g_quark_from_static_string("agent");
+
+       return quark;
+}
+
+static GError *__bt_opc_agent_error(bt_opc_agent_error_t error,
+                                    const char *err_msg)
+{
+       return g_error_new(BT_OPC_AGENT_ERROR, error, err_msg);
+}
+static void __bt_opc_internal_event_cb(int event, int result, void *param_data)
+{
+       DBG("+");
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bt_event.event = event;
+       bt_event.result = result;
+       bt_event.param_data = param_data;
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info && bt_internal_info->bt_cb_ptr)
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                       bt_internal_info->user_data);
+
+       DBG("-");
+}
+
+
+BT_EXPORT_API int bluetooth_opc_init(void)
+{
+       DBG("+\n");
+
+       bt_info_t *bt_internal_info = NULL;
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL) {
+               DBG("bt_internal_info is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (client_proxy) {
+               DBG("Already initialized");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       client_proxy =  dbus_g_proxy_new_for_name(bt_internal_info->conn,
+                                                       "org.openobex.client", "/",
+                                                        "org.openobex.Client");
+
+       if (NULL == client_proxy) {
+               DBG("client_proxy is null");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("- \n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_opc_deinit(void)
+{
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == client_proxy) {
+               DBG("Not  initialized");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       g_object_unref(client_proxy);
+       client_proxy = NULL;
+
+       DBG("- \n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+
+BT_EXPORT_API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address,
+                                char **file_name_array)
+{
+       DBG("+ \n");
+       GHashTable *hash;
+       GValue *value;
+       char address[BT_BD_ADDR_MAX_LEN] = { 0 };
+       GError *error = NULL;
+       char agent_path[100] = {0};
+
+       if (remote_address == NULL || file_name_array == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == client_proxy) {
+               DBG("client_proxy is NULL\n");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
+       if (current_transfer || opc_obex_agent) {
+               DBG("Transfer in progress\n");
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       }
+
+       if ((NULL == remote_address) || (NULL == file_name_array)) {
+               DBG("Invalid Param\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       snprintf(agent_path, sizeof(agent_path), OBEX_CLIENT_AGENT_PATH,
+                               getpid(), g_counter++);
+
+       if (__bt_obex_client_agent_init(agent_path)) {
+               DBG("agent init failedL\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                    g_free, (GDestroyNotify) __bt_value_free);
+
+       _bluetooth_internal_print_bluetooth_device_address_t(remote_address);
+
+       _bluetooth_internal_addr_type_to_addr_string(address, remote_address);
+
+       value = g_new0(GValue, 1);
+       g_value_init(value, G_TYPE_STRING);
+       g_value_set_string(value, address);
+       g_hash_table_insert(hash, "Destination", value);
+
+       cancel_sending_files = FALSE;
+
+       if (!dbus_g_proxy_begin_call(client_proxy, "SendFiles",
+                               __bt_send_files_cb, NULL, NULL,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
+                                                   G_TYPE_VALUE), hash,
+                               G_TYPE_STRV, file_name_array,
+                               DBUS_TYPE_G_OBJECT_PATH, agent_path,
+                               G_TYPE_INVALID)) {
+                               DBG("SendFiles failed \n");
+                               g_object_unref(opc_obex_agent);
+                               opc_obex_agent = NULL;
+                               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("- \n");
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+BT_EXPORT_API int bluetooth_opc_cancel_push(void)
+{
+       DBG("+");
+
+       _bluetooth_internal_session_init();
+
+       if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
+               DBG("Adapter not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       if (NULL == opc_obex_agent) {
+               DBG("No Transfer");
+               return BLUETOOTH_ERROR_ACCESS_DENIED;
+       }
+
+       cancel_sending_files = TRUE;
+
+       if (current_transfer)
+               dbus_g_proxy_call_no_reply(current_transfer, "Cancel", G_TYPE_INVALID,
+                                  G_TYPE_INVALID);
+
+       DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API gboolean bluetooth_opc_sessioin_is_exist(void)
+{
+       DBG("+");
+
+       gboolean exist = FALSE;
+       DBusGProxy *opc_proxy = NULL;
+       DBusGConnection *conn = NULL;
+       GError *error = NULL;
+       GPtrArray *gp_array = NULL;
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL)
+               return FALSE;
+
+       opc_proxy = dbus_g_proxy_new_for_name(conn,
+                                       OBEX_CLIENT_SERVICE, "/",
+                                        OBEX_CLIENT_INTERFACE);
+
+       if (opc_proxy == NULL) {
+               dbus_g_connection_unref(conn);
+               return FALSE;
+       }
+
+       dbus_g_proxy_call(opc_proxy, "GetTransfers", &error,
+                       G_TYPE_INVALID,
+                       dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+                       &gp_array, G_TYPE_INVALID);
+
+       if (error == NULL) {
+               if (gp_array != NULL) {
+                       int i;
+                       for (i = 0; i < gp_array->len; i++) {
+                               gchar *gp_path = g_ptr_array_index(gp_array, i);
+
+                               if (gp_path != NULL) {
+                                       DBG("Session [%s]", gp_path);
+                                       exist = TRUE;
+                                       g_free(gp_path);
+                               }
+                       }
+                       g_ptr_array_free(gp_array, TRUE);
+               }
+       } else {
+               DBG("GetSessions error: [%s]", error->message);
+               g_error_free(error);
+       }
+
+       g_object_unref(opc_proxy);
+       dbus_g_connection_unref(conn);
+
+       DBG("exist: %d", exist);
+
+       DBG("-");
+
+       return exist;
+}
+
+static void __bt_send_files_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                               void *user_data)
+{
+       GError *error = NULL;
+       int result = BLUETOOTH_ERROR_NONE;
+
+       DBG("+");
+
+       if (dbus_g_proxy_end_call(proxy, call, &error,
+                               G_TYPE_INVALID) == FALSE) {
+
+               DBG("%s", error->message);
+
+               g_error_free(error);
+
+               result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
+       }
+
+       if (TRUE == cancel_sending_files)
+               result = BLUETOOTH_ERROR_CANCEL_BY_USER;
+
+       if (result != BLUETOOTH_ERROR_NONE) {
+               g_object_unref(opc_obex_agent);
+               opc_obex_agent = NULL;
+       }
+
+       __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_CONNECTED,
+                                               result, NULL);
+       DBG("-");
+}
+
+static gboolean __bt_progress_callback(DBusGMethodInvocation *context,
+                                       DBusGProxy *transfer,
+                                       guint64 transferred,
+                                       gpointer user_data)
+{
+       gdouble percentage_progress = 0;
+       int percentage_int = 0;
+
+       DBG("+");
+       DBG("transferred:[%ld] \n", transferred);
+
+       dbus_g_method_return(context);
+
+       if (opc_current_transfer.size != 0)
+               percentage_progress = (gdouble) transferred / (gdouble) opc_current_transfer.size * 100;
+       else
+               percentage_progress = 0;
+
+       percentage_int = percentage_progress;
+
+       __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS,
+                                               BLUETOOTH_ERROR_NONE, &percentage_int);
+
+       DBG("-");
+
+       return TRUE;
+}
+
+static gboolean __bt_complete_callback(DBusGMethodInvocation *context,
+                                       DBusGProxy *transfer,
+                                       gpointer user_data)
+{
+       bt_opc_transfer_info_t info;
+       DBG("+");
+
+       dbus_g_method_return(context);
+
+       g_object_unref(current_transfer);
+       current_transfer = NULL;
+
+       info.filename = opc_current_transfer.name;
+       info.size = opc_current_transfer.size;
+
+       __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
+                                               BLUETOOTH_ERROR_NONE, &info);
+
+       __bt_free_obexd_transfer_hierarchy(&opc_current_transfer);
+
+       DBG("-");
+       return TRUE;
+}
+
+static void __bt_free_obexd_transfer_hierarchy(struct obexd_transfer_hierarchy
+                                              *current_transfer)
+{
+       if (!current_transfer)
+               return;
+
+       if (current_transfer->name) {
+               free(current_transfer->name);
+               current_transfer->name = NULL;
+       }
+
+       if (current_transfer->file_name) {
+               free(current_transfer->file_name);
+               current_transfer->file_name = NULL;
+       }
+
+       current_transfer->size = 0;
+}
+
+static gboolean __bt_request_callback(DBusGMethodInvocation *context,
+                                       DBusGProxy *transfer,
+                                       gpointer user_data)
+{
+       g_assert(current_transfer == NULL);
+       bt_opc_transfer_info_t info;
+       GHashTable *hash = NULL;
+       GError *error;
+
+       DBG("+");
+       current_transfer = g_object_ref(transfer);
+
+       __bt_free_obexd_transfer_hierarchy(&opc_current_transfer);
+
+       if (TRUE == cancel_sending_files) {
+               DBG("Cancelling");
+               error = __bt_opc_agent_error(BT_OBEX_AGENT_ERROR_CANCEL, "CancelledByUser");
+               dbus_g_method_return_error(context, error);
+               g_error_free(error);
+               g_object_unref(opc_obex_agent);
+               opc_obex_agent = NULL;
+               __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_DISCONNECTED,
+                                               BLUETOOTH_ERROR_CANCEL_BY_USER, NULL);
+               return TRUE;
+       } else {
+               dbus_g_method_return(context, "");
+       }
+
+       dbus_g_proxy_call(transfer, "GetProperties", NULL,
+                               G_TYPE_INVALID,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       if (hash) {
+               GValue *value;
+               value = g_hash_table_lookup(hash, "Name");
+               opc_current_transfer.name = value ? g_strdup( g_value_get_string(value)) : NULL;
+
+               value = g_hash_table_lookup(hash, "Filename");
+               opc_current_transfer.file_name = value ? g_strdup( g_value_get_string(value)) : NULL;
+
+               value = g_hash_table_lookup(hash, "Size");
+               opc_current_transfer.size = value ? g_value_get_uint64(value) : 0;
+
+               g_hash_table_destroy(hash);
+
+               DBG("Name %s :",opc_current_transfer.name);
+               DBG("FileName %s :",opc_current_transfer.file_name);
+               DBG("Size %d :",opc_current_transfer.size);
+
+               info.filename = opc_current_transfer.name;
+               info.size = opc_current_transfer.size;
+
+               __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_TRANSFER_STARTED,
+                                               BLUETOOTH_ERROR_NONE, &info);
+       }
+
+       DBG("-");
+       return TRUE;
+}
+
+static gboolean __bt_release_callback(DBusGMethodInvocation *context,
+                                       gpointer user_data)
+{
+       DBG("+");
+
+       dbus_g_method_return(context);
+
+       if (current_transfer) {
+               g_object_unref(current_transfer);
+               current_transfer = NULL;
+       }
+
+       g_object_unref(opc_obex_agent);
+       opc_obex_agent = NULL;
+
+       /*release */
+       __bt_free_obexd_transfer_hierarchy(&opc_current_transfer);
+
+       __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_DISCONNECTED,
+                                               BLUETOOTH_ERROR_NONE, NULL);
+       DBG("-");
+
+       return TRUE;
+}
+
+static gboolean __bt_error_callback(DBusGMethodInvocation *context,
+                                       DBusGProxy *transfer,
+                                       const char *message,
+                                       gpointer user_data)
+{
+       int result = BLUETOOTH_ERROR_NONE;
+       bt_opc_transfer_info_t info;
+       DBG("+ \n");
+
+       DBG("message:[%s] \n", message);
+
+       dbus_g_method_return(context);
+
+       g_object_unref(current_transfer);
+       current_transfer = NULL;
+
+       if (TRUE == cancel_sending_files)  {
+               result = BLUETOOTH_ERROR_CANCEL_BY_USER;
+       } else if (0 == g_strcmp0(message, "Forbidden")) {
+               result = BLUETOOTH_ERROR_ACCESS_DENIED;
+       } else if (TRUE == g_str_has_prefix(message,
+                               "Transport endpoint is not connected")) {
+               result = BLUETOOTH_ERROR_NOT_CONNECTED;
+               cancel_sending_files = TRUE;
+       } else if (0 == g_strcmp0(message, "Database full")) {
+               result = BLUETOOTH_ERROR_OUT_OF_MEMORY;
+               cancel_sending_files = TRUE;
+       } else {
+               result = BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       info.filename = opc_current_transfer.name;
+       info.size = opc_current_transfer.size;
+
+       __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
+                                               result, &info);
+
+       __bt_free_obexd_transfer_hierarchy(&opc_current_transfer);
+
+       if (TRUE == cancel_sending_files)  {
+               /* User cancelled or Remote device is switched off / memory full*/
+               g_object_unref(opc_obex_agent);
+               opc_obex_agent = NULL;
+
+               __bt_opc_internal_event_cb(BLUETOOTH_EVENT_OPC_DISCONNECTED,
+                                               result, NULL);
+       }
+
+       DBG("- \n");
+       return TRUE;
+}
+
+static int __bt_obex_client_agent_init(char *agent_path)
+{
+       int random_num = 0;
+
+       opc_obex_agent = obex_agent_new();
+       if(NULL == opc_obex_agent)
+               return -1;
+
+       obex_agent_set_release_func(opc_obex_agent,
+                                   __bt_release_callback, NULL);
+       obex_agent_set_request_func(opc_obex_agent,
+                                   __bt_request_callback, NULL);
+       obex_agent_set_progress_func(opc_obex_agent,
+                                    __bt_progress_callback, NULL);
+       obex_agent_set_complete_func(opc_obex_agent,
+                                    __bt_complete_callback, NULL);
+       obex_agent_set_error_func(opc_obex_agent,
+                               __bt_error_callback, NULL);
+
+       obex_agent_setup(opc_obex_agent, agent_path);
+
+       return 0;
+
+}
+
+
diff --git a/lib/bluetooth-opc-api.h b/lib/bluetooth-opc-api.h
new file mode 100644 (file)
index 0000000..c99b13c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 _BLUETOOTH_OPC_API_H_
+#define _BLUETOOTH_OPC_API_H_
+
+
+#include "bluetooth-api.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define OBEX_CLIENT_SERVICE "org.openobex.client"
+#define OBEX_CLIENT_INTERFACE "org.openobex.Client"
+#define OBEX_CLIENT_AGENT_PATH "/org/bluez/obex_client_agent/%d/%d"
+#define BT_BD_ADDR_MAX_LEN 18
+#define BT_OPC_AGENT_ERROR (__bt_opc_error_quark())
+
+typedef enum {
+       BT_OBEX_AGENT_ERROR_REJECT,
+       BT_OBEX_AGENT_ERROR_CANCEL,
+       BT_OBEX_AGENT_ERROR_TIMEOUT,
+} bt_opc_agent_error_t;
+
+struct obexd_transfer_hierarchy {
+       char *name;
+       char *file_name;
+       gint64 size;
+};
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _BLUETOOTH_OPC_API_H_ */
+
diff --git a/lib/bluetooth-rfcomm-api.c b/lib/bluetooth-rfcomm-api.c
new file mode 100644 (file)
index 0000000..52ecfa9
--- /dev/null
@@ -0,0 +1,1374 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+/**
+* This file implements bluetooth gap api based on bluez
+* @file        bluetooth-rfcomm-api.c
+*/
+/*:Associate with "Bluetooth" */
+
+#include <dbus/dbus.h>
+#include <glib.h>
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/un.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "bluetooth-rfcomm-api.h"
+
+#define BLUEZ_SERVICE_NAME "org.bluez"
+#define BLUEZ_SERIAL_CLINET_INTERFACE "org.bluez.Serial"
+
+#define BLUEZ_MANAGER_OBJ_PATH "/"
+#define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager"
+
+#define BLUEZ_SERIAL_MANAGER_INTERFACE "org.bluez.SerialProxyManager"
+#define BLUEZ_SERIAL_PROXY_INTERFACE   "org.bluez.SerialProxy"
+
+#define RFCOMM_CLIENT_BUFFER_SIZE 1024
+#define RFCOMM_UDS_PATH "/bluez/rfcomm"
+#define RFCOMM_DEV_PATH "/dev/rfcomm"
+#define RFCOMM_SER_DEV_PATH "x00/bluez/rfcomm"
+
+static DBusConnection *connection = NULL;
+
+static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond, gpointer data);
+static gboolean __rfcomm_server_data_received_cb(GIOChannel *chan, GIOCondition cond, gpointer data);
+
+static gboolean __rfcomm_client_data_received_cb(GIOChannel *chan, GIOCondition cond, gpointer data);
+
+static int __get_default_adapter_path(char **adapter_path);
+
+static int __get_rfcomm_proxy_list(char ***proxy_list, int *len);
+
+static int __bluetooth_rfcomm_internal_disconnect(int index);
+
+static int __rfcomm_internal_terminate_server(rfcomm_server_t *server_info);
+
+static int __rfcomm_internal_terminate_client(int index);
+
+static int __bluetooth_rfcomm_internal_server_get_free_index(void);
+
+static int __bluetooth_rfcomm_internal_server_get_index_from_socket(int fd);
+
+static int __bluetooth_rfcomm_internal_client_get_index_from_socket(int fd);
+
+static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                      gpointer user_data);
+
+static int __bluetooth_internal_set_nonblocking(int sk);
+
+/*Get the free index channel for server */
+static int __bluetooth_rfcomm_internal_server_get_free_index(void)
+{
+
+       DBG("+ + + + + + + + \n");
+       int ind = -1;
+       int i = 0;
+       for (; i < RFCOMM_MAX_CONN; i++) {
+               if (rfcomm_server[i].id == 0) {
+                       ind = i;
+                       break;
+               }
+       }
+       DBG("Free index: %d\n", ind);
+       DBG("- - - - - - - - -\n");
+       return ind;
+}
+
+/*Get the index channel from server socket */
+static int __bluetooth_rfcomm_internal_server_get_index_from_socket(int fd)
+{
+       DBG("+ + + + + + + + \n");
+       int ind = -1;
+       int i = 0;
+       for (; i < RFCOMM_MAX_CONN; i++) {
+               if (rfcomm_server[i].server_sock_fd == fd) {
+                       ind = i;
+                       break;
+               }
+       }
+       DBG("Index from fd %d is index(%d)\n", fd, ind);
+       DBG("- - - - - - - - -\n");
+       return ind;
+}
+
+/*Get the  index channel from client socket */
+static int __bluetooth_rfcomm_internal_client_get_index_from_socket(int fd)
+{
+       DBG("+ + + + + + + + \n");
+       int ind = -1;
+       int i = 0;
+       for (; i < RFCOMM_MAX_CONN; i++) {
+               if (rfcomm_client[i].sock_fd == fd) {
+                       ind = rfcomm_client[i].id;
+                       break;
+               }
+       }
+
+       DBG("Index from fd %d is index(%d)\n", fd, ind);
+       DBG("- - - - - - - - -\n");
+       return ind;
+}
+
+/*Internal server disconnection */
+static int __rfcomm_internal_terminate_server(rfcomm_server_t *server_info)
+{
+       DBG("+\n");
+       DBusMessage *msg, *reply;
+       DBusError error;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       static char *default_adapter_obj_path = NULL;
+       int index;
+
+       index = __bluetooth_rfcomm_internal_server_get_index_from_socket(server_info->server_sock_fd);
+       if (index < 0) {
+               DBG("Invalid index %d", index);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (rfcomm_server[index].client_sock_fd != -1) {
+               DBG("Trying for Proxy disable\n");
+               DBG("Proxy disable for %s\n", rfcomm_server[index].uds_name);
+               /* Proxy Disable  Part */
+               msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                                  rfcomm_server[index].uds_name,
+                                                  BLUEZ_SERIAL_PROXY_INTERFACE, "Disable");
+               dbus_error_init(&error);
+               reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+
+               dbus_message_unref(msg);
+
+               if (!reply) {
+                       DBG("Can't Call DisableProxy\n");
+                       if (dbus_error_is_set(&error)) {
+                               DBG("%s\n", error.message);
+                               dbus_error_free(&error);
+                       }
+                       return -1;
+               }
+               dbus_message_unref(reply);
+
+               if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+                       DBG("Fail to get default hci adapter path\n");
+                       return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+               }
+
+               /* Remove Proxy Part */
+               DBG("RemoveProxy\n");
+               msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                                  default_adapter_obj_path,
+                                                  BLUEZ_SERIAL_MANAGER_INTERFACE, "RemoveProxy");
+
+               dbus_message_append_args(msg, DBUS_TYPE_STRING, &rfcomm_server[index].uds_name,
+                                        DBUS_TYPE_INVALID);
+
+               dbus_error_init(&error);
+               g_free(default_adapter_obj_path);
+               reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+               dbus_message_unref(msg);
+
+               if (!reply) {
+                       DBG("Can't Call RemoveProxy\n");
+                       if (dbus_error_is_set(&error)) {
+                               DBG("%s\n", error.message);
+                               dbus_error_free(&error);
+                       }
+                       return -1;
+               }
+               bt_internal_info = _bluetooth_internal_get_information();
+               if (bt_internal_info->bt_cb_ptr) {
+                       bluetooth_rfcomm_disconnection_t disconnection_ind;
+                       bt_event.event = BLUETOOTH_EVENT_RFCOMM_DISCONNECTED;
+                       bt_event.result = BLUETOOTH_ERROR_NONE;
+                       disconnection_ind.socket_fd = rfcomm_server[index].client_sock_fd;
+                       disconnection_ind.device_addr = rfcomm_server[index].device_addr;
+                       bt_event.param_data = (void *)(&disconnection_ind);
+                       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                                   bt_internal_info->user_data);
+               }
+
+               if (rfcomm_server[index].client_sock_fd != -1) {
+                       g_source_remove(rfcomm_server[index].client_event_src_id);
+                       rfcomm_server[index].client_sock_fd = -1;
+               }
+
+       }
+
+       DBG(" g_source_remove \n");
+       if (rfcomm_server[index].is_listen)
+               g_source_remove(rfcomm_server[index].server_event_src_id);
+       close(rfcomm_server[index].server_sock_fd);
+       rfcomm_server[index].server_sock_fd = -1;
+       rfcomm_server[index].is_listen = FALSE;
+
+       /*Resetting the connection */
+       rfcomm_server[index].id = 0;
+
+       /*Check free rfcomm_server[index].uds_name */
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+/*Internal client disconnection*/
+static int __rfcomm_internal_terminate_client(int index)
+{
+       DBG("+\n");
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       __bluetooth_rfcomm_internal_disconnect(index);
+
+       if (bt_internal_info->bt_cb_ptr) {
+               bluetooth_rfcomm_disconnection_t disconnection_ind;
+
+               bt_event.event = BLUETOOTH_EVENT_RFCOMM_DISCONNECTED;
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+               disconnection_ind.socket_fd = rfcomm_client[index].sock_fd;
+               disconnection_ind.device_addr = rfcomm_client[index].device_addr;
+               bt_event.param_data = (void *)(&disconnection_ind);
+
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+
+       }
+
+       g_source_remove(rfcomm_client[index].event_src_id);
+       rfcomm_client[index].event_src_id = -1;
+
+       close(rfcomm_client[index].sock_fd);
+       rfcomm_client[index].sock_fd = -1;
+       if (rfcomm_client[index].dev_node_name != NULL)
+               g_free(rfcomm_client[index].dev_node_name);
+       rfcomm_client[index].dev_node_name = NULL;
+
+       rfcomm_client[index].id = -1;
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+/*Internal connection */
+static gboolean __rfcomm_server_connected_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
+{
+       DBG("+\n");
+       DBG("rfcomm_server.server_io_channel has %d \n", cond);
+
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       DBusMessage *msg, *reply;
+       DBusError error;
+       DBusMessageIter reply_iter, reply_iter_entry;
+       const char *property;
+
+       rfcomm_server_t *server_data = data;
+       int fd = g_io_channel_unix_get_fd(chan);
+       int index = __bluetooth_rfcomm_internal_server_get_index_from_socket(fd);
+       if (index < 0) {
+               DBG("Invalid index %d", index);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+       int server_sock, client_sock;
+       int client_addr_len;
+       struct sockaddr_un client_sock_addr;
+
+       if (cond & G_IO_NVAL)
+               return FALSE;
+
+       if (cond & (G_IO_HUP | G_IO_ERR)) {
+               __rfcomm_internal_terminate_server(server_data);
+               return FALSE;
+       }
+
+       server_sock = g_io_channel_unix_get_fd(chan);
+
+       memset(&client_sock_addr, 0, sizeof(struct sockaddr_un));
+       client_addr_len = sizeof(struct sockaddr_un);
+
+       client_sock = accept(server_sock,
+                            (struct sockaddr *)&client_sock_addr, (socklen_t *)&client_addr_len);
+
+       if (client_sock < 0) {
+               perror("Server Accept Error");
+               return TRUE;
+
+       } else {
+               DBG("Accept Client Sock.(%d)\n", client_sock);
+
+       }
+
+       long arg;
+
+       arg = fcntl(client_sock, F_GETFL);
+
+       if (arg < 0)
+               return -errno;
+
+       if (arg & O_NONBLOCK) {
+               DBG("Already blocking \n");
+               arg ^= O_NONBLOCK;
+       }
+
+       if (fcntl(client_sock, F_SETFL, arg) < 0)
+               return -errno;
+
+       rfcomm_server[index].client_sock_fd = client_sock;
+
+       rfcomm_server[index].client_io_channel = g_io_channel_unix_new(client_sock);
+
+       g_io_channel_set_close_on_unref(rfcomm_server[index].client_io_channel, TRUE);
+
+       rfcomm_server[index].client_event_src_id =
+           g_io_add_watch(rfcomm_server[index].client_io_channel,
+                          G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                          __rfcomm_server_data_received_cb, &rfcomm_server[index]);
+
+       g_io_channel_unref(rfcomm_server[index].client_io_channel);
+       bt_internal_info = _bluetooth_internal_get_information();
+
+
+
+       /* GetInfo Proxy Part */
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          rfcomm_server[index].uds_name,
+                                          BLUEZ_SERIAL_PROXY_INTERFACE, "GetInfo");
+
+       dbus_error_init(&error);
+
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("\nCan't Call GetInfo Proxy\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return -1;
+       }
+
+       dbus_message_iter_init(reply, &reply_iter);
+
+       if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
+               DBG("Can't get reply arguments - DBUS_TYPE_ARRAY\n");
+               dbus_message_unref(reply);
+               return -1;
+       }
+
+       dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);
+
+       /*Parse the dict */
+       while (dbus_message_iter_get_arg_type(&reply_iter_entry) == DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter dict_entry, dict_entry_val;
+
+               dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
+
+               DBG("Looping....\n");
+
+               dbus_message_iter_get_basic(&dict_entry, &property);    /*get key value*/
+               DBG("String received = %s\n", property);
+
+               if (g_strcmp0("connected", property) == 0) {
+                       dbus_bool_t value;
+
+                       if (!dbus_message_iter_next(&dict_entry)) {
+                               DBG("Fail 1..\n");
+                       } else {
+                               DBG("OK 1..\n");
+                       }
+
+                       if (dbus_message_iter_get_arg_type(&dict_entry) != DBUS_TYPE_VARIANT) {
+                               DBG("Fail 2..\n");
+                       } else {
+                               DBG("OK 2..\n");
+                       }
+
+                       /*Getting the value of the varient*/
+                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
+
+                       if (dbus_message_iter_get_arg_type(&dict_entry_val) != DBUS_TYPE_BOOLEAN) {
+                               DBG("Fail 3..\n");
+                       } else {
+                               DBG("OK 3..\n");
+                       }
+
+                       dbus_message_iter_get_basic(&dict_entry_val, &value);   /*get value boolean
+                                                                               value*/
+
+                       DBG("Value bool = %d", value);
+
+                       /*Parsing the address */
+                       if (value == TRUE) {
+                               dbus_message_iter_next(&reply_iter_entry);
+                               dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
+                               dbus_message_iter_get_basic(&dict_entry, &property);    /*get key
+                                                                                       value*/
+                               DBG("String received...... = %s\n", property);
+
+                               if (g_strcmp0("address", property) == 0) {
+                                       if (!dbus_message_iter_next(&dict_entry)) {
+                                               DBG("Failed getting next dict entry\n");
+                                               return -1;
+                                       }
+
+                                       if (dbus_message_iter_get_arg_type(&dict_entry) !=
+                                           DBUS_TYPE_VARIANT) {
+                                               DBG("Failed get arg type varient\n");
+                                               return -1;
+                                       }
+                                       /*Getting the value of the varient*/
+                                       dbus_message_iter_recurse(&dict_entry,
+                                                                 &dict_entry_val);
+
+                                       if (dbus_message_iter_get_arg_type(&dict_entry_val)
+                                           != DBUS_TYPE_STRING) {
+                                               DBG("Failed get arg type string\n");
+                                               return -1;
+                                       }
+                                       /*get  value string address*/
+                                       dbus_message_iter_get_basic(&dict_entry_val, &property);
+
+                                       DBG("String received >>> = %s\n", property);
+                                       _bluetooth_internal_convert_addr_string_to_addr_type(
+                                                       &rfcomm_server[index].device_addr, property);
+
+                               }
+
+                       } else
+                               return -1;
+
+               }
+
+               dbus_message_iter_next(&reply_iter_entry);
+       }
+
+       bluetooth_rfcomm_connection_t con_ind;
+       con_ind.device_role = RFCOMM_ROLE_SERVER;
+       con_ind.device_addr = rfcomm_server[index].device_addr;
+       con_ind.socket_fd = rfcomm_server[index].client_sock_fd;
+       bt_event.event = BLUETOOTH_EVENT_RFCOMM_CONNECTED;
+       bt_event.result = BLUETOOTH_ERROR_NONE;
+       bt_event.param_data = (void *)&con_ind;
+
+       if (bt_internal_info->bt_cb_ptr) {
+               DBG("\ngoing to call callback BLUETOOTH_EVENT_RFCOMM_CONNECTED \n");
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       DBG("-\n");
+       return TRUE;
+}
+
+/*Internal: data indication*/
+static gboolean __rfcomm_server_data_received_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
+{
+       DBG("rfcomm_server.client_io_channel has %d \n", cond);
+
+       char buf[RFCOMM_CLIENT_BUFFER_SIZE] = { 0 };
+       unsigned int len;
+       rfcomm_server_t *rfcomm_server_info = data;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
+               DBG("Unix server  disconnected (fd=%d)\n", rfcomm_server_info->client_sock_fd);
+               __rfcomm_internal_terminate_server(rfcomm_server_info);
+               return FALSE;
+       }
+
+       memset(buf, 0, sizeof(buf));
+
+       if (g_io_channel_read(chan, buf, sizeof(buf), &len) != G_IO_ERROR_NONE) {
+
+               DBG("IO Channel read error server");
+               __rfcomm_internal_terminate_server(rfcomm_server_info);
+               return FALSE;
+       }
+
+       if (len <= 0) {
+               DBG("Read failed len=%d, fd=%d\n",
+                       len,  rfcomm_server_info->client_sock_fd);
+               __rfcomm_internal_terminate_server(rfcomm_server_info);
+               return FALSE;
+       }
+
+       DBG("%s\n", buf);
+       bt_internal_info = _bluetooth_internal_get_information();
+       if (bt_internal_info->bt_cb_ptr) {
+               bluetooth_rfcomm_received_data_t rx_data;
+               rx_data.socket_fd = rfcomm_server_info->client_sock_fd;
+               rx_data.buffer_size = len;
+               rx_data.buffer = buf;
+               bt_event.event = BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED;
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+               bt_event.param_data = (void *)&rx_data;
+
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+
+       }
+
+       return TRUE;
+}
+
+static gboolean __rfcomm_client_data_received_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
+{
+       DBG("rfcomm_server.client_io_channel has %d \n", cond);
+
+       char buf[RFCOMM_CLIENT_BUFFER_SIZE] = { 0 };
+       unsigned int len;
+       rfcomm_client_t *rfcomm_client_info = data;
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       int index = rfcomm_client_info->id;
+       if ((index < 0) || (index >= RFCOMM_MAX_CONN)) {
+               DBG("Invalid index %d ", index);
+               return FALSE;
+       }
+
+       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
+               DBG("Unix client disconnected (fd=%d)\n", rfcomm_client_info->sock_fd);
+               __rfcomm_internal_terminate_client(index);
+               return FALSE;
+       }
+
+       if (g_io_channel_read(chan, buf, sizeof(buf), &len) != G_IO_ERROR_NONE) {
+
+               DBG("IO Channel read error client");
+               __rfcomm_internal_terminate_client(index);
+               return FALSE;
+       }
+
+       if (len <= 0) {
+               DBG("Read failed len=%d, Clientfd=%d\n",
+                       len, rfcomm_client_info->sock_fd);
+               __rfcomm_internal_terminate_client(index);
+               return FALSE;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+       if (bt_internal_info->bt_cb_ptr) {
+               DBG("%s  -  clientfd = %d\n", buf, rfcomm_client_info->sock_fd);
+               bluetooth_rfcomm_received_data_t rx_data;
+               rx_data.socket_fd = rfcomm_client_info->sock_fd;
+               rx_data.buffer_size = len;
+               rx_data.buffer = buf;
+               bt_event.event = BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED;
+               bt_event.result = BLUETOOTH_ERROR_NONE;
+               bt_event.param_data = (void *)&rx_data;
+
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+
+       }
+       return TRUE;
+}
+
+static int __get_default_adapter_path(char **adapter_path)
+{
+       DBusError error;
+       DBusMessage *msg, *reply;
+       const char *reply_path;
+
+       dbus_error_init(&error);
+       if (NULL == connection) {
+               DBG("Connection is NULL, so getting the System bus");
+               connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+       }
+
+       if (dbus_error_is_set(&error)) {
+               DBG("Unable to connect to DBus :%s \n", error.message);
+               dbus_error_free(&error);
+               return -1;
+       }
+
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          BLUEZ_MANAGER_OBJ_PATH, BLUEZ_MANAGER_INTERFACE,
+                                          "DefaultAdapter");
+
+       dbus_error_init(&error);
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("Can't Call DefaultAdapater");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return -1;
+       }
+
+       if (!dbus_message_get_args(reply, &error,
+                                  DBUS_TYPE_OBJECT_PATH, &reply_path, DBUS_TYPE_INVALID)) {
+               DBG("Can't get reply arguments\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return -1;
+       }
+
+       *adapter_path = g_strdup(reply_path);
+       dbus_message_unref(reply);
+
+       return 0;
+}
+
+/* List Proxy */
+static int __get_rfcomm_proxy_list(char ***proxy_list, int *len)
+{
+       DBusError error;
+       DBusMessage *msg, *reply;
+       int i;
+       *len = 0;
+       static char *default_adapter_obj_path = NULL;
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          default_adapter_obj_path, BLUEZ_SERIAL_MANAGER_INTERFACE,
+                                          "ListProxies");
+
+       dbus_error_init(&error);
+       g_free(default_adapter_obj_path);
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("Can't Call CreateProxy\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return -1;
+       }
+
+       if (!dbus_message_get_args(reply, &error,
+                                  DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
+                                  proxy_list, len, DBUS_TYPE_INVALID)) {
+               DBG("Can't get reply arguments\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return -1;
+       }
+
+       if (*len == 0)
+               DBG("There are no previous Proxy: \n");
+
+       for (i = 0; i < *len; i++) {
+               DBG("proxy_list[%d]: %s \n", i, *((*proxy_list) + i));
+       }
+
+       dbus_message_unref(reply);
+
+       return 0;
+}
+
+/*Server Part */
+/*
+ * SLP 2.0 Bluetooth RFCOMM API
+ * input:  UUID
+ * Return: Success or negative error value
+ * Register RFCOMM Sock with the given UUID on the SDP.
+ *
+ */
+BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid)
+{
+       DBG("+\n");
+       DBusMessage *msg, *reply;
+       const char *reply_path;
+       DBusError error;
+       char **proxy_list;
+       int len;
+       char address_string[RFCOMM_ADDRESS_STRING_LEN], tmp[8];
+       char *address_string_ptr, *sock_addr_un_ptr;
+       int index;
+       int ret = 0;
+       char *uds_proxy = NULL;
+       static char *default_adapter_obj_path = NULL;
+       if (NULL == uuid) {
+               DBG("uuid is NULL\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       /*Get all the earlier proxies */
+       if (__get_rfcomm_proxy_list(&proxy_list, &len) < 0) {
+               DBG("Fail to RFCOMM List Proxy\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("Proxy count = %d\n", len);
+       index = __bluetooth_rfcomm_internal_server_get_free_index();
+       if (index < 0) {
+               DBG("MAX connection %d only supported", RFCOMM_MAX_CONN);
+               return BLUETOOTH_ERROR_MAX_CONNECTION;
+       }
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       DBG("Default Adapter Object Path:%s\n", default_adapter_obj_path);
+
+       /* Create Proxy Part */
+
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          default_adapter_obj_path, BLUEZ_SERIAL_MANAGER_INTERFACE,
+                                          "CreateProxy");
+
+       g_free(default_adapter_obj_path);
+
+       /*Assign index */
+       len = index;
+
+       g_strlcpy(address_string, RFCOMM_SER_DEV_PATH, sizeof(address_string));
+       DBG("address_string1 = %s\n", address_string);
+       snprintf(tmp, 7, "%d", len);
+       g_strlcat(address_string, tmp, sizeof(address_string));
+       DBG("address_string final = %s\n", address_string);
+       address_string_ptr = address_string;
+
+       DBG("**** Dbus args : address = %s, uuid = %s ******\n", address_string_ptr, uuid);
+       dbus_message_append_args(msg, DBUS_TYPE_STRING, &uuid,
+                                DBUS_TYPE_STRING, &address_string_ptr, DBUS_TYPE_INVALID);
+
+       dbus_error_init(&error);
+
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("\nCan't Call CreateProxy\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (!dbus_message_get_args(reply, &error, DBUS_TYPE_STRING, &reply_path, DBUS_TYPE_INVALID)) {
+               DBG("\nCan't get reply arguments\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       uds_proxy = g_strdup(reply_path);
+       rfcomm_server[index].uds_name = uds_proxy;
+       rfcomm_server[index].id = index + 1;    /*Incrementing the index by 1 */
+
+       DBG(">>>>>>>>>>rfcomm_server[%d].id = %d\n", index, rfcomm_server[index].id);
+
+       DBG("**** Unix Domain Socket Path %s *****\n", uds_proxy);
+
+       dbus_message_unref(reply);
+
+/* Proxy Enable Part */
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          uds_proxy, BLUEZ_SERIAL_PROXY_INTERFACE, "Enable");
+
+       dbus_error_init(&error);
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("\nCan't Call CreateProxy\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       dbus_message_unref(reply);
+
+/* Make Unix Socket */
+       int sk;
+       struct sockaddr_un server_addr;
+
+       sk = socket(AF_UNIX, SOCK_STREAM, 0);
+
+       if (sk < 0) {
+               perror("\nCan't Create Socket");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       rfcomm_server[index].server_sock_fd = sk;
+       memset(&server_addr, 0, sizeof(server_addr));
+       server_addr.sun_family = PF_UNIX;
+
+       strcpy(address_string, RFCOMM_UDS_PATH);
+       snprintf(tmp, 7, "%d", len);
+       strcat(address_string, tmp);
+       DBG("address_string final = %s\n", address_string);
+       sock_addr_un_ptr = address_string;
+
+       DBG("Unix bind path = %s\n", sock_addr_un_ptr);
+       strcpy(server_addr.sun_path + 1, sock_addr_un_ptr);
+
+       if (bind(sk, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
+               perror("\nCan't Bind Sock\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       DBG("Return fd = %d\n", sk);
+       DBG("-\n");
+
+       ret = __bluetooth_internal_set_nonblocking(sk);
+       if (ret != 0)
+               return ret;
+       else
+               return sk;
+}
+
+/*
+ * SLP 2.0 Bluetooth RFCOMM API
+ * bluetooth_rfcomm_listen_and_accept(int sockfd, int max_pending_connection)"
+ *
+ */
+
+BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection)
+{
+       DBG("+\n");
+       int is_success;
+       int index;
+       static char *default_adapter_obj_path = NULL;
+
+       if (socket_fd <= 0) {
+               DBG("\nInvalid fd..");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       index = __bluetooth_rfcomm_internal_server_get_index_from_socket(socket_fd);
+       if (index < 0) {
+               DBG("Invalid index %d", index);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+       is_success = listen(socket_fd, max_pending_connection);
+
+       if (is_success == 0)
+               rfcomm_server[index].is_listen = TRUE;
+       else {
+               rfcomm_server[index].is_listen = FALSE;
+               DBG("\nListen failed..");
+               return BLUETOOTH_ERROR_CONNECTION_ERROR;
+       }
+
+       rfcomm_server[index].server_io_channel = g_io_channel_unix_new(socket_fd);
+       g_io_channel_set_close_on_unref(rfcomm_server[index].server_io_channel, TRUE);
+
+       rfcomm_server[index].server_event_src_id =
+           g_io_add_watch(rfcomm_server[index].server_io_channel,
+                          G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, __rfcomm_server_connected_cb,
+                          &rfcomm_server[index]);
+       g_io_channel_unref(rfcomm_server[index].server_io_channel);
+
+       DBG(" -\n is success = %d\n", is_success);
+       return is_success;
+
+}
+
+/*
+ * SLP 2.0 Bluetooth RFCOMM API
+ * bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
+ *
+ */
+
+BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
+{
+       DBG("+\n");
+       DBusMessage *msg, *reply;
+       DBusError error;
+       int index;
+       static char *default_adapter_obj_path = NULL;
+       index = __bluetooth_rfcomm_internal_server_get_index_from_socket(socket_fd);
+       if (index < 0) {
+               DBG("Invalid index %d", index);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+       if ((socket_fd != rfcomm_server[index].server_sock_fd)
+           || (NULL == rfcomm_server[index].uds_name)) {
+               DBG("\nInvalid server socket \n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+/* Proxy Disable  Part */
+       DBG("Proxy disable \n");
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          rfcomm_server[index].uds_name,
+                                          BLUEZ_SERIAL_PROXY_INTERFACE, "Disable");
+       dbus_error_init(&error);
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("Can't Call DisableProxy\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       dbus_message_unref(reply);
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+/* Remove Proxy Part */
+       DBG("- RemoveProxy \n");
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          default_adapter_obj_path, BLUEZ_SERIAL_MANAGER_INTERFACE,
+                                          "RemoveProxy");
+
+       dbus_message_append_args(msg, DBUS_TYPE_STRING, &rfcomm_server[index].uds_name,
+                                DBUS_TYPE_INVALID);
+
+       dbus_error_init(&error);
+       g_free(default_adapter_obj_path);
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               DBG("Can't Call RemoveProxy\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+                       dbus_error_free(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (rfcomm_server[index].client_sock_fd) {
+               bluetooth_event_param_t bt_event = { 0, };
+               bt_info_t *bt_internal_info = NULL;
+               bt_internal_info = _bluetooth_internal_get_information();
+               if (bt_internal_info->bt_cb_ptr) {
+                       bluetooth_rfcomm_disconnection_t disconnection_ind;
+                       bt_event.event = BLUETOOTH_EVENT_RFCOMM_DISCONNECTED;
+                       bt_event.result = BLUETOOTH_ERROR_NONE;
+                       disconnection_ind.socket_fd = rfcomm_server[index].client_sock_fd;
+                       disconnection_ind.device_addr = rfcomm_server[index].device_addr;
+                       bt_event.param_data = (void *)(&disconnection_ind);
+                       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                                   bt_internal_info->user_data);
+               }
+
+               g_source_remove(rfcomm_server[index].client_event_src_id);
+               close(rfcomm_server[index].client_sock_fd);
+               rfcomm_server[index].client_sock_fd = -1;
+       }
+
+       if (rfcomm_server[index].is_listen)
+               g_source_remove(rfcomm_server[index].server_event_src_id);
+
+       close(rfcomm_server[index].server_sock_fd);
+       rfcomm_server[index].server_sock_fd = -1;
+
+       rfcomm_server[index].is_listen = FALSE;
+       g_free(rfcomm_server[index].uds_name);
+       rfcomm_server[index].uds_name = NULL;
+
+       /*Resetting the connection */
+       rfcomm_server[index].id = 0;
+
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+/* Asynchrous implementation */
+static void __rfcomm_client_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                      gpointer user_data)
+{
+       DBG("+\n");
+       GError *err = NULL;
+       bt_info_t *bt_internal_info = NULL;
+       gchar *rfcomm_device_node;
+
+       int dev_node_fd = -1;
+       char *dev_node = NULL;
+       char *dev_id_str = NULL;
+       int result = BLUETOOTH_ERROR_NONE;
+       int index = -1;
+
+       bluetooth_event_param_t bt_event = { 0, };
+       bluetooth_rfcomm_connection_t con_ind;
+
+       bluetooth_device_address_t *remote_address = user_data;
+       DBG("Received BD address = 0x%X:%X:%X:%X:%X:%X", remote_address->addr[0],
+           remote_address->addr[1], remote_address->addr[2], remote_address->addr[3],
+           remote_address->addr[4], remote_address->addr[5]);
+
+       DBG("+");
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       dbus_g_proxy_end_call(proxy, call, &err,
+                             G_TYPE_STRING, &rfcomm_device_node, G_TYPE_INVALID);
+
+       if (err != NULL) {
+               DBG("Error occured in connecting port [%s]", err->message);
+
+               if (!strcmp("Host is down", err->message))
+                       result = BLUETOOTH_ERROR_HOST_DOWN;
+               else
+                       result = BLUETOOTH_ERROR_CONNECTION_ERROR;
+
+               g_error_free(err);
+
+               goto done;
+       }
+
+       g_object_unref(proxy);
+
+       dev_node = g_strdup(rfcomm_device_node);
+
+       DBG("Succss Connect REMOTE Device RFCOMM Node[%s]", dev_node);
+       dev_id_str = dev_node + strlen(RFCOMM_DEV_PATH);
+
+       DBG("ID str = [%s]", dev_id_str);
+       if (NULL == dev_id_str) {
+               DBG("Invalid index creation");
+               result = BLUETOOTH_ERROR_CONNECTION_ERROR;
+               goto done;
+       }
+       index = (int)strtol(dev_id_str, NULL, 10);
+       DBG("Index ID = [%d]", index);
+
+       if ((index < 0) || (index >= RFCOMM_MAX_CONN)) {
+               DBG("Invalid index %d", index);
+               result = BLUETOOTH_ERROR_INVALID_PARAM;
+               goto done;
+       }
+
+       dev_node_fd = open(dev_node, O_RDWR | O_NOCTTY);
+
+       if (dev_node_fd < 0) {
+               DBG("\nCan't open TTY : %s(%d)");
+               result = BLUETOOTH_ERROR_CONNECTION_ERROR;
+               goto done;
+       }
+
+       DBG("\n/dev/rfcomm fd = %d\n", dev_node_fd);
+
+       rfcomm_client[index].id = index;
+       rfcomm_client[index].sock_fd = dev_node_fd;
+       rfcomm_client[index].dev_node_name = dev_node;
+       memcpy(&rfcomm_client[index].device_addr, remote_address, BLUETOOTH_ADDRESS_LENGTH);
+
+       rfcomm_client[index].io_channel = g_io_channel_unix_new(dev_node_fd);
+
+       g_io_channel_set_close_on_unref(rfcomm_client[index].io_channel, TRUE);
+
+       rfcomm_client[index].event_src_id =
+           g_io_add_watch(rfcomm_client[index].io_channel,
+                          G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                          __rfcomm_client_data_received_cb, &rfcomm_client[index]);
+
+ done:
+
+       if (result == BLUETOOTH_ERROR_NONE) {
+               con_ind.socket_fd = rfcomm_client[index].sock_fd;
+               con_ind.device_addr = rfcomm_client[index].device_addr;
+       } else {
+               con_ind.socket_fd = -1;
+               memcpy(&con_ind.device_addr, remote_address, BLUETOOTH_ADDRESS_LENGTH);
+
+               /* We are freeing dev_node in error case only. Success case
+                * will be handled during disconnection */
+               g_free(dev_node);
+       }
+
+       con_ind.device_role = RFCOMM_ROLE_CLIENT;
+       bt_event.event = BLUETOOTH_EVENT_RFCOMM_CONNECTED;
+       bt_event.result = result;
+       bt_event.param_data = (void *)&con_ind;
+
+       if (bt_internal_info->bt_cb_ptr) {
+               DBG("Going to call the callback");
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       free(remote_address);
+       DBG("-\n");
+
+}
+
+DBusGProxy *proxy_rfcomm_client = NULL;
+
+BT_EXPORT_API int bluetooth_rfcomm_connect(const bluetooth_device_address_t *remote_bt_address,
+                                               const char *remote_uuid)
+{
+       DBG("+\n");
+       gchar *address_up;
+       gchar *remote_device_path;
+       char str_addr[20];
+       bluetooth_device_address_t *remote_address;
+       GError *err = NULL;
+       DBusGConnection *conn;
+       static char *default_adapter_obj_path = NULL;
+       memset(str_addr, 0, 20);
+
+       if ((NULL == remote_bt_address) || (NULL == remote_uuid)) {
+               DBG("Error: Invalid param\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       DBG("Default Adapter Object Path:%s\n", default_adapter_obj_path);
+       _bluetooth_internal_addr_type_to_addr_string(str_addr, remote_bt_address);
+
+       address_up = g_ascii_strup(str_addr, -1);
+       DBG("BD addr str = %s, address_up = %s\n", str_addr, address_up);
+       remote_device_path = g_strdup_printf("%s/dev_%s", default_adapter_obj_path, address_up);
+       g_free(default_adapter_obj_path);
+       g_strdelimit(remote_device_path, ":", '_');
+       DBG("Remote device path = %s\n", remote_device_path);
+
+       g_free(address_up);
+
+       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+       if (!conn) {
+               DBG("ERROR: Can't get on system bus [%s]", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_CONNECTION_ERROR;
+       }
+
+       proxy_rfcomm_client = dbus_g_proxy_new_for_name(conn, BLUEZ_SERVICE_NAME,
+                                                       remote_device_path,
+                                                       BLUEZ_SERIAL_CLINET_INTERFACE);
+       g_free(remote_device_path);
+
+       if (proxy_rfcomm_client == NULL) {
+               DBG("Failed to get the network server proxy\n");
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
+
+       remote_address = malloc(sizeof(bluetooth_device_address_t));
+       memcpy(remote_address, remote_bt_address, sizeof(bluetooth_device_address_t));
+
+       DBG("Send BD address = 0x%X:%X:%X:%X:%X:%X", remote_address->addr[0],
+           remote_address->addr[1], remote_address->addr[2], remote_address->addr[3],
+           remote_address->addr[4], remote_address->addr[5]);
+
+       if (!dbus_g_proxy_begin_call(proxy_rfcomm_client, "Connect",
+                                       (DBusGProxyCallNotify)__rfcomm_client_connected_cb,
+                                       (gpointer)remote_address,       /*user_data*/
+                                       NULL,   /*destroy*/
+                                       G_TYPE_STRING, remote_uuid,     /*first_arg_type*/
+                                       G_TYPE_INVALID)) {
+               DBG("Network server register Dbus Call Error");
+               free(remote_address);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static int __bluetooth_rfcomm_internal_disconnect(int index)
+{
+       DBusMessage *msg, *reply;
+       DBusError error;
+
+       gchar *address_up;
+       gchar *remote_device_path;
+
+       bluetooth_device_address_t remote_bt_address;
+       char *dev_node;
+       static char *default_adapter_obj_path = NULL;
+       char str_addr[20];
+       memset(str_addr, 0, 20);
+
+       remote_bt_address = rfcomm_client[index].device_addr;
+       dev_node = rfcomm_client[index].dev_node_name;
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       DBG("Des add =  0x%x:%x:%x:%x:%x:%x\n", remote_bt_address.addr[0],
+           remote_bt_address.addr[1], remote_bt_address.addr[2], remote_bt_address.addr[3],
+           remote_bt_address.addr[4], remote_bt_address.addr[5]);
+       DBG("Default Adapter Object Path:%s\n", default_adapter_obj_path);
+
+       _bluetooth_internal_addr_type_to_addr_string(str_addr, &remote_bt_address);
+       address_up = g_ascii_strup(str_addr, -1);
+
+       DBG("BD addr str = %s, address_up = %s\n", str_addr, address_up);
+       remote_device_path = g_strdup_printf("%s/dev_%s", default_adapter_obj_path, address_up);
+       g_free(default_adapter_obj_path);
+       g_strdelimit(remote_device_path, ":", '_');
+       DBG("Remote device path == %s\n", remote_device_path);
+       g_free(address_up);
+       /* Disconnect */
+       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME,
+                                          remote_device_path, BLUEZ_SERIAL_CLINET_INTERFACE,
+                                          "Disconnect");
+       DBG("Device node name = %s\n", dev_node);
+       dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_node, DBUS_TYPE_INVALID);
+
+       dbus_error_init(&error);
+
+       reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, &error);
+       dbus_message_unref(msg);
+
+       if (!reply) {
+               int bt_rfcomm_client_return = BLUETOOTH_ERROR_ACCESS_DENIED;
+               DBG("Error While Call Serial.Conncet\n");
+               if (dbus_error_is_set(&error)) {
+                       DBG("%s\n", error.message);
+
+                       if (g_strcmp0("org.bluez.Error.InvalidArguments", error.message) == 0)
+                               bt_rfcomm_client_return = BLUETOOTH_ERROR_INVALID_PARAM;
+                       else if (g_strcmp0("org.bluez.Error.DoesNotExist", error.message) == 0)
+                               bt_rfcomm_client_return = BLUETOOTH_ERROR_NOT_SUPPORT;
+
+                       dbus_error_free(&error);
+               }
+               return bt_rfcomm_client_return;
+       }
+       DBG("Succss Disconnect REMOTE Device RFCOMM Node[%s]\n", dev_node);
+
+       g_free(remote_device_path);
+       dbus_message_unref(reply);
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd)
+{
+
+       DBG("+\n");
+
+       static char *default_adapter_obj_path = NULL;
+       int index = 0;
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       index = __bluetooth_rfcomm_internal_client_get_index_from_socket(socket_fd);
+       if (index < 0) {
+               DBG("Invalid index %d  for socket %d\n", index, socket_fd);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (!(socket_fd && (socket_fd == rfcomm_client[index].sock_fd)) ||
+              (NULL == rfcomm_client[index].dev_node_name)) {
+               DBG("Invalid FD %d  - %d\n", socket_fd, rfcomm_client[index].sock_fd);
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       __bluetooth_rfcomm_internal_disconnect(index);
+
+       g_source_remove(rfcomm_client[index].event_src_id);
+       close(rfcomm_client[index].sock_fd);
+       rfcomm_client[index].sock_fd = -1;
+
+       if (rfcomm_client[index].dev_node_name != NULL)
+               g_free(rfcomm_client[index].dev_node_name);
+       rfcomm_client[index].dev_node_name = NULL;
+
+       rfcomm_client[index].id = -1;
+       DBG("-\n");
+
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+BT_EXPORT_API int bluetooth_rfcomm_write(int fd, const char *buf, int length)
+{
+       DBG("\bluetooth_rfcomm_write() +\n");
+       int wbytes = 0, written = 0;
+       static char *default_adapter_obj_path = NULL;
+
+       if ((fd <= 0) || (NULL == buf) || (length <= 0)) {
+               DBG("Invalid arguments..\n");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       if (__get_default_adapter_path(&default_adapter_obj_path) < 0) {
+               DBG("Fail to get default hci adapter path\n");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       /*some times user may send huge data */
+       while (wbytes < length) {
+               written = write(fd, buf + wbytes, length - wbytes);
+               if (written <= 0) {
+                       DBG("write failed..\n");
+                       return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+               }
+               wbytes += written;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+       DBG("-\n");
+}
+
+static int __bluetooth_internal_set_nonblocking(int sk)
+{
+/* Set Nonblocking */
+       long arg;
+
+       arg = fcntl(sk, F_GETFL);
+
+       if (arg < 0)
+               return -errno;
+
+       if (arg & O_NONBLOCK) {
+               DBG("Already Non-blocking \n");
+       }
+
+       arg |= O_NONBLOCK;
+
+       if (fcntl(sk, F_SETFL, arg) < 0)
+               return -errno;
+       return 0;
+}
diff --git a/lib/bluetooth-rfcomm-api.h b/lib/bluetooth-rfcomm-api.h
new file mode 100644 (file)
index 0000000..7347e02
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 _BLUETOOTH_RFCOMM_API_H_
+#define _BLUETOOTH_RFCOMM_API_H_
+
+#include "bluetooth-api-common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#define RFCOMM_MAX_CONN 5
+#define RFCOMM_ADDRESS_STRING_LEN 24
+typedef struct {
+       int id;
+       int server_sock_fd;
+       GIOChannel *server_io_channel;
+       guint server_event_src_id;
+       gboolean is_listen;     /*server listen*/
+       char *uds_name; /*proxy name*/
+       char *file_name;        /*device name*/
+
+       int client_sock_fd;
+       bluetooth_device_address_t device_addr;
+       GIOChannel *client_io_channel;
+       guint client_event_src_id;
+} rfcomm_server_t;
+static rfcomm_server_t rfcomm_server[RFCOMM_MAX_CONN];
+
+typedef struct {
+       int id;
+       int sock_fd;
+       GIOChannel *io_channel;
+       guint event_src_id;
+       char *dev_node_name;
+       bluetooth_device_address_t device_addr;
+} rfcomm_client_t;
+
+static rfcomm_client_t rfcomm_client[RFCOMM_MAX_CONN] = { { 0, }, };
+
+struct connect_param_t {
+       char *remote_device_path;
+       char *connect_uuid;
+       bluetooth_device_address_t remote_bt_address;
+};
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+
+#endif                         /*_BLUETOOTH_RFCOMM_API_H_*/
diff --git a/lib/bluetooth-sdp-api.c b/lib/bluetooth-sdp-api.c
new file mode 100644 (file)
index 0000000..85d498a
--- /dev/null
@@ -0,0 +1,761 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+/**
+*This file implements bluetooth sdp api based on bluez
+*@file bluetooth-sdp-api.c
+*/
+/*:Associate with "Bluetooth" */
+
+#include "bluetooth-sdp-api.h"
+
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+
+/* This array should be optimized with the real bluetooth stack */
+static match_entries_t supported_service_info[] = {
+       {"00001101-0000-1000-8000-00805f9b34fb", 0x1101, "SPP", 0},
+       {"00001103-0000-1000-8000-00805f9b34fb", 0x1103, "DUN", 0},
+       {"00001105-0000-1000-8000-00805f9b34fb", 0x1105, "OPP", 0},
+       {"00001106-0000-1000-8000-00805f9b34fb", 0x1106, "FTP", 0},
+       {"00001112-0000-1000-8000-00805f9b34fb", 0x1112, "HS_AG", 0},
+       {"00001108-0000-1000-8000-00805f9b34fb", 0x1108, "HS", 0},
+       {"0000110b-0000-1000-8000-00805f9b34fb", 0x110b, "AUDIO_SINK", 0},
+       {"0000110c-0000-1000-8000-00805f9b34fb", 0x110c, "AV_REMOTE_CONTROL_TARGET", 0},
+       {"0000110e-0000-1000-8000-00805f9b34fb", 0x110e, "AV_REMOTE_CONTROL_UUID", 0},
+
+       {"00001118-0000-1000-8000-00805f9b34fb", 0x1118, "DIRECT_PRINTING_SVCLASS_ID", 0},
+       {"0000111a-0000-1000-8000-00805f9b34fb", 0x111a, "OBEX_IMAGING", 0},
+       {"0000111b-0000-1000-8000-00805f9b34fb", 0x111b, "IMAGING_RESPONDER_SVCLASS_ID", 0},
+       {"0000111f-0000-1000-8000-00805f9b34fb", 0x111f, " HF_AG", 0},
+       {"0000111e-0000-1000-8000-00805f9b34fb", 0x111e, "HF", 0},
+       {"00001122-0000-1000-8000-00805f9b34fb", 0x1122, "BASIC_PRINTING", 0},
+       {"0000112D-0000-1000-8000-00805f9b34fb", 0x112D, "SAP", 0},
+       {"00001130-0000-1000-8000-00805f9b34fb", 0x1130, "PBAP", 0},
+       {0}
+};
+
+static gboolean __bluetooth_internal_get_remote_service_handle(DBusGProxy *device_proxy,
+               bt_info_for_searching_support_service_t *bt_info_for_searching_support_service);
+
+static void __bluetooth_internal_request_search_supported_services(const bluetooth_device_address_t *device_address);
+
+static void __bluetooth_internal_get_remote_device_uuids_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                         gpointer user_data)
+{
+       GError *err = NULL;
+       char **array_ptr = NULL;
+       char **array_list;
+       int ret = 0;
+
+       const gchar *address;
+       bt_sdp_info_t device_uuids;
+
+       GHashTable *hash;
+       GValue *value = { 0 };
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+
+       DBG("+\n");
+
+       dbus_g_proxy_end_call(proxy, call, &err,
+                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+                               &hash, G_TYPE_INVALID);
+
+       device_uuids.service_index = 0;
+
+       if (err != NULL) {
+               DBG("Error occured in Proxy call [%s]\n", err->message);
+               g_error_free(err);
+               ret = -2;
+               goto done;
+       }
+
+       if (hash != NULL) {
+               value = g_hash_table_lookup(hash, "UUIDs");
+               array_ptr = value ? g_value_get_boxed(value) : NULL;
+
+               value = g_hash_table_lookup(hash, "Address");
+               address = value ? g_value_get_string(value) : NULL;
+
+               if (address) {
+                       DBG("%s", address);
+               }
+               _bluetooth_internal_convert_addr_string_to_addr_type(&device_uuids.device_addr,
+                                                                   address);
+       }
+
+       if (NULL == array_ptr) {
+               DBG("Error occured in parsing services\n");
+               ret = -2;
+               goto done;
+       }
+
+       array_list = array_ptr;
+
+       while (device_uuids.service_index < BLUETOOTH_MAX_SERVICES_FOR_DEVICE) {
+               if (*array_ptr) {
+                       g_strlcpy(device_uuids.uuids[device_uuids.service_index], *array_ptr, BLUETOOTH_UUID_STRING_MAX);
+
+                       device_uuids.service_list_array[device_uuids.service_index] =
+                           strtoll(*array_ptr, NULL, 16);
+                       DBG("Find UUID [%#x]\n",
+                           device_uuids.service_list_array[device_uuids.service_index]);
+               } else
+                       break;
+
+               array_ptr++;
+               device_uuids.service_index++;
+       }
+
+       g_strfreev(array_list);
+
+ done:
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED;
+               if (0 > ret) {
+                       bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR;
+                       device_uuids.service_index = 0x00;
+               } else {
+                       bt_event.result = BLUETOOTH_ERROR_NONE;
+               }
+
+               bt_event.param_data = &device_uuids;
+
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+
+       DBG("-\n");
+
+       return;
+}
+
+static void __bluetooth_internal_device_created_for_sdp_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                        gpointer user_data)
+{
+       GError *err = NULL;
+       const char *path = NULL;
+
+       DBG("+\n");
+
+       dbus_g_proxy_end_call(proxy, call, &err, DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID);
+       if (err != NULL) {
+               DBG("Error occured in Proxy call [%s]\n", err->message);
+               g_error_free(err);
+       } else {
+               DBusGProxy *device_proxy = NULL;
+               device_proxy = _bluetooth_internal_find_device_by_path(path);
+
+               if (device_proxy == NULL) {
+                       _bluetooth_internal_add_device(path);
+               }
+
+               if (!dbus_g_proxy_begin_call(device_proxy, "GetProperties",
+                       (DBusGProxyCallNotify) __bluetooth_internal_get_remote_device_uuids_cb,
+                       NULL, NULL, G_TYPE_INVALID)) {
+               }
+       }
+
+       DBG("-\n");
+
+       return;
+}
+
+static void __bluetooth_internal_sdp_fail_cb(const bt_sdp_info_t *sdp_data, int error_code)
+{
+
+       bluetooth_event_param_t bt_event = { 0, };
+       bt_info_t *bt_internal_info = NULL;
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED;
+       bt_event.result = error_code;
+       bt_event.param_data = (void *)sdp_data;
+       if (bt_internal_info->bt_cb_ptr) {
+               bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+       }
+}
+
+static int __bluetooth_internal_parse_sdp_xml(const char *buf_name, int size,
+                                               bt_sdp_info_t *xml_parsed_sdp);
+
+static gboolean __bluetooth_internal_get_service_rec_handle_from_node(xmlNodePtr xml_node,
+                                                               unsigned int *record_handle);
+static gboolean __bluetooth_internal_get_service_class_id_list_from_node(xmlNodePtr xml_node,
+                                                                      bt_sdp_info_t *sdp_info);
+
+static gboolean __bluetooth_internal_get_service_class_id_list_from_node(xmlNodePtr xml_node,
+                                                                       bt_sdp_info_t *sdp_info)
+{
+       xmlNodePtr local_node;
+       xmlAttr *uuid_attr;
+       xmlNodePtr uuid_node;
+
+       if (xml_node == NULL || sdp_info == NULL)
+               return FALSE;
+
+       local_node = xml_node->next;
+
+       while (local_node) {
+               if (!strcmp((char *)local_node->name, "sequence")) {
+                       DBG("\t\t %s\n", local_node->name);
+                       uuid_node = local_node->xmlChildrenNode;
+                       uuid_node = uuid_node->next;
+
+                       if (uuid_node) {
+                               uuid_attr = uuid_node->properties;
+                               DBG("\t\t\t%s, %s\n", uuid_node->name,
+                                   uuid_attr->children->content);
+
+                               if (sdp_info->service_index < BLUETOOTH_MAX_SERVICES_FOR_DEVICE) {
+                                       DBG("sdp_info->service_index %d", sdp_info->service_index);
+                                       g_strlcpy(sdp_info->uuids[sdp_info->service_index], uuid_attr->children->content, BLUETOOTH_UUID_STRING_MAX);
+
+                                       sdp_info->service_list_array[sdp_info->service_index] =
+                                                       strtol((char *)uuid_attr->children->content,
+                                                                                        NULL, 0);
+                                       sdp_info->service_index++;
+                               } else {
+                                       DBG("service index(%d) is more than"
+                                                       "BLUETOOTH_MAX_SERVICES_FOR_DEVICE",
+                                                                       sdp_info->service_index);
+                               }
+
+                       }
+               }
+               local_node = local_node->next;
+       }
+       return TRUE;
+}
+
+static gboolean __bluetooth_internal_get_service_rec_handle_from_node(xmlNodePtr xml_node,
+                                                               unsigned int *record_handle) {
+       xmlNodePtr local_node;
+       xmlAttr *local_attr;
+
+       if (xml_node == NULL || record_handle == NULL)
+               return FALSE;
+
+       local_node = xml_node->next;
+
+       if (local_node) {
+               if (!strcmp((char *)local_node->name, "uint32")) {
+                       local_attr = local_node->properties;
+                       DBG("\t\t%s, %s\n", local_node->name, local_attr->children->content);
+                       *record_handle = strtol((char *)local_attr->children->content, NULL, 0);
+               }
+       }
+       return TRUE;
+}
+
+static int __bluetooth_internal_parse_xml_parse_record(xmlNodePtr cur,
+                                                    bt_sdp_info_t *xml_parsed_sdp_data)
+{
+       xmlNodePtr icur;
+
+       icur = cur;
+       icur = icur->xmlChildrenNode;
+       xmlAttr *attr = NULL;
+
+       unsigned int attribute_value = 0;
+       unsigned int record_handle = 0;
+
+       while (icur) {
+               attr = icur->properties;
+
+               if (strcmp((char *)icur->name, "attribute")) {
+                       icur = icur->next;
+                       continue;
+               }
+
+               DBG("%s\n", icur->name);
+               while (attr) {
+                       if (strcmp((char *)attr->name, "id")) {
+                               attr = attr->next;
+                               continue;
+                       }
+                       DBG("\t%s, %s\n", attr->name, attr->children->content);
+                       attribute_value = strtol((char *)attr->children->content, NULL, 0);
+
+                       switch (attribute_value) {
+                       case SERVICE_RECORD_HANDLE:
+                               DBG("\tSERVICE_RECORD_HANDLE:\n");
+                               __bluetooth_internal_get_service_rec_handle_from_node
+                                   (icur->xmlChildrenNode, &record_handle);
+                               DBG("\tRecord Handle 0x%04x \n", record_handle);
+                               break;
+
+                       case SERVICE_CLASS_ID_LIST:
+                               DBG("\tSERVICE_CLASS_ID_LIST:\n");
+                               __bluetooth_internal_get_service_class_id_list_from_node
+                                   (icur->xmlChildrenNode, xml_parsed_sdp_data);
+                               break;
+
+                       case PROTOCOL_DESCRIPOTR_LIST:
+                               break;
+
+                       case BLUETOOTH_PROFILE_DESCRIPTOR_LIST:
+                               break;
+
+                       default:
+                               break;
+
+                       }
+                       attr = attr->next;
+               }
+               icur = icur->next;
+       }
+       return TRUE;
+}
+
+static int __bluetooth_internal_parse_sdp_xml(const char *buf_name, int size,
+                                           bt_sdp_info_t *xml_parsed_sdp)
+{
+       xmlDocPtr doc;
+       xmlNodePtr first;
+       xmlNodePtr base;
+       xmlInitParser();
+
+       char *check = NULL;
+
+       DBG("+\n");
+
+       /*Below check is done for proper parsing of BPP service UUID, in case of BPP '&' gets
+       appended to text value parameter of service list, when '&' containing data  is passed
+       to function "xmlParseMemory()" parse error occurs. so '&' is replaced with blank space ' '*/
+       if (buf_name != NULL) {
+               check = strchr(buf_name, '&');
+               if (check != NULL) {
+                       *check = ' ';
+               }
+       }
+
+       if (size != 0) {
+               doc = xmlParseMemory(buf_name, size);
+       } else
+               return -1;
+
+       if (doc == NULL) {
+               DBG("Document not parsed successfully.\n");
+               return -1;
+       }
+
+       DBG("Document parsed successfully.\n");
+
+       first = xmlDocGetRootElement(doc);
+
+       if (first == NULL) {
+               DBG("Root element = NULL \n");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       base = first;
+       if (base == NULL) {
+               DBG("empty document\n");
+               xmlFreeDoc(doc);
+
+               xmlCleanupParser();
+               return -1;
+       } else {
+               DBG("Root - %s\n", first->name);
+       }
+       while (base != NULL) {
+               DBG(" Main While %s\n", base->name);
+
+               __bluetooth_internal_parse_xml_parse_record(base, xml_parsed_sdp);
+               base = base->next;
+
+       }
+
+       xmlFreeDoc(doc);
+
+       xmlCleanupParser();
+       DBG("-\n");
+
+       return 0;
+}
+
+static void __bluetooth_internal_discover_services_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+                                                   gpointer user_data)
+{
+       GError *err = NULL;
+       GHashTable *hash;
+       static bt_sdp_info_t xml_parsed_sdp_data;
+       bt_info_t *bt_internal_info = NULL;
+       bluetooth_event_param_t bt_event = { 0, };
+
+       bt_info_for_searching_support_service_t *bt_info_for_searching_support_service =
+           (bt_info_for_searching_support_service_t *) user_data;
+
+       /* if service_info is NULL, it means search discover Browse group
+          Otherwise, it means search known UUIDs.
+        */
+
+       match_entries_t *service_info = bt_info_for_searching_support_service->search_match_ptr;
+       char *xml_record = NULL;
+
+       DBG("+\n");
+
+       dbus_g_proxy_end_call(proxy, call, &err,
+                             dbus_g_type_get_map("GHashTable", G_TYPE_UINT, G_TYPE_STRING), &hash,
+                             G_TYPE_INVALID);
+
+       _bluetooth_internal_print_bluetooth_device_address_t(&bt_info_for_searching_support_service->remote_device_addr);
+       memcpy(&xml_parsed_sdp_data.device_addr,
+              &bt_info_for_searching_support_service->remote_device_addr,
+              sizeof(bluetooth_device_address_t));
+
+       if (err != NULL) {
+               DBG("Error occured in Proxy call [%s]\n", err->message);
+               xml_parsed_sdp_data.service_index = 0;
+
+               if (!strcmp("Operation canceled", err->message)) {
+                       __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data,
+                                                      BLUETOOTH_ERROR_CANCEL_BY_USER);
+               } else if (!strcmp("In Progress", err->message)) {
+                       __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data,
+                                                      BLUETOOTH_ERROR_IN_PROGRESS);
+               } else if (!strcmp("Host is down", err->message)) {
+                       __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data,
+                                                      BLUETOOTH_ERROR_HOST_DOWN);
+               } else {
+                       __bluetooth_internal_sdp_fail_cb(&xml_parsed_sdp_data,
+                                                      BLUETOOTH_ERROR_CONNECTION_ERROR);
+               }
+
+               g_error_free(err);
+               return;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (service_info == NULL) {
+               xml_parsed_sdp_data.service_index = 0;
+               bt_info_for_searching_support_service->success_search_index = 0;
+               memcpy(&xml_parsed_sdp_data.device_addr,
+                      &bt_info_for_searching_support_service->remote_device_addr,
+                      sizeof(bluetooth_device_address_t));
+/* Read SDP XML record direclty and Call back to the upper layer. */
+
+               if (hash != NULL) {
+                       GList *list = g_hash_table_get_values(hash);
+                       GList *ptr = NULL;
+                       for (ptr = list; ptr; ptr = ptr->next) {
+                               xml_record = ptr->data;
+                               __bluetooth_internal_parse_sdp_xml(xml_record,
+                                                                g_utf8_strlen(xml_record, -1),
+                                                                &xml_parsed_sdp_data);
+                       }
+               }
+
+               if (bt_internal_info->bt_cb_ptr) {
+                       bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED;
+                       DBG("service_index %d\n", xml_parsed_sdp_data.service_index);
+                       if (xml_parsed_sdp_data.service_index < 0) {
+                               bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR;
+                               xml_parsed_sdp_data.service_index = 0;
+                       } else if (xml_parsed_sdp_data.service_index == 0) {
+                                       /*This is for some carkit, printer.*/
+                               __bluetooth_internal_request_search_supported_services(
+                                       &bt_info_for_searching_support_service->remote_device_addr);
+                               return;
+                       } else {
+                               bt_event.result = BLUETOOTH_ERROR_NONE;
+                               bt_event.param_data = &xml_parsed_sdp_data;
+                       }
+
+                       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event, bt_internal_info->user_data);
+               }
+               return;
+       }
+
+       xml_parsed_sdp_data.service_index = service_info - supported_service_info;
+       DBG("service_index %d\n", xml_parsed_sdp_data.service_index);
+
+       DBG("Search Service[%s]\n", service_info->match_name);
+       if (hash != NULL) {
+               GList *list = g_hash_table_get_values(hash);
+               if (list != NULL && g_list_length(list) > 0) {
+                       xml_record = (char *)g_list_nth_data(list, 0);
+                       __bluetooth_internal_parse_sdp_xml(xml_record, g_utf8_strlen(xml_record, -1),
+                                                        &xml_parsed_sdp_data);
+               }
+       }
+
+       if (xml_record == NULL) {
+               DBG("No Record [%s]\n", service_info->match_name);
+
+       }
+
+       bt_info_for_searching_support_service->search_match_ptr++;
+       service_info = bt_info_for_searching_support_service->search_match_ptr;
+
+       DBG("Search Service[%s]\n", service_info->match_name);
+
+       if (service_info->match) {
+               __bluetooth_internal_get_remote_service_handle(proxy,
+                                                            bt_info_for_searching_support_service);
+       } else {
+               DBG("Search Ending\n");
+               /* Report UUID list as xml_parsed_sdp_data to the upper layer. */
+               if (bt_internal_info->bt_cb_ptr) {
+                       bt_event.event = BLUETOOTH_EVENT_SERVICE_SEARCHED;
+                       if (xml_parsed_sdp_data.service_index <= 0
+                           || xml_parsed_sdp_data.service_index >=
+                           BLUETOOTH_MAX_SERVICES_FOR_DEVICE) {
+                               bt_event.result = BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR;
+                               xml_parsed_sdp_data.service_index = 0;
+                       } else {
+                               bt_event.result = BLUETOOTH_ERROR_NONE;
+                               bt_event.param_data = &xml_parsed_sdp_data;
+                       }
+
+                       bt_internal_info->bt_cb_ptr(bt_event.event, &bt_event,
+                                                   bt_internal_info->user_data);
+
+               }
+       }
+
+       DBG("-\n");
+
+       return;
+}
+
+BT_EXPORT_API int bluetooth_search_service(const bluetooth_device_address_t *device_address)
+{
+       bt_info_t *bt_internal_info = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+       GError *error = NULL;
+       const char *path = NULL;
+       DBusGProxy *device_proxy = NULL;
+       bt_info_for_searching_support_service_t *bt_info_for_searching_support_service = NULL;
+
+       DBG("+");
+       if (NULL == device_address) {
+               DBG("Device address is NULL\n");
+               return BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR;
+       }
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       bt_info_for_searching_support_service =
+           &bt_internal_info->info_for_searching_support_service;
+
+       _bluetooth_internal_addr_type_to_addr_string(address, device_address);
+       DBG("bluetooth address [%s]\n", address);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", &error,
+                         G_TYPE_STRING, address, G_TYPE_INVALID,
+                         DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID);
+
+       if (error != NULL && !strcmp(error->message, "Device does not exist")) {
+               DBG("FindDevice Call Error %s[%s]", error->message, address);
+               g_error_free(error);
+
+               if (!dbus_g_proxy_begin_call_with_timeout(bt_internal_info->adapter_proxy,
+                       "CreateDevice",
+                       (DBusGProxyCallNotify) __bluetooth_internal_device_created_for_sdp_cb, NULL,
+                        NULL, 5000, G_TYPE_STRING, address, G_TYPE_INVALID)) {
+                       DBG("Could not call CreateDevice dbus proxy\n");
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+
+       } else {
+               if (path == NULL) {
+                       DBG("No device created\n");
+
+                       return BLUETOOTH_ERROR_NOT_PAIRED;
+               }
+
+               device_proxy = _bluetooth_internal_find_device_by_path(path);
+
+               if (device_proxy == NULL) {
+                       DBG("We don't have device proxy in our internal device proxy list\n");
+                       _bluetooth_internal_add_device(path);
+               }
+
+               bt_info_for_searching_support_service =
+                   &bt_internal_info->info_for_searching_support_service;
+
+               bt_info_for_searching_support_service->search_match_ptr = NULL;
+               memcpy(&bt_info_for_searching_support_service->remote_device_addr, device_address,
+                      sizeof(bluetooth_device_address_t));
+
+               _bluetooth_internal_print_bluetooth_device_address_t
+                   (&bt_info_for_searching_support_service->remote_device_addr);
+
+               if (!dbus_g_proxy_begin_call_with_timeout(device_proxy, "DiscoverServices",
+                               (DBusGProxyCallNotify) __bluetooth_internal_discover_services_cb,
+                               (void *)bt_info_for_searching_support_service,
+                               NULL, 40000, G_TYPE_STRING, "", G_TYPE_INVALID)) {
+                       DBG("Could not call dbus proxy\n");
+                       return BLUETOOTH_ERROR_NONE;
+               }
+
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static gboolean __bluetooth_internal_get_remote_service_handle(DBusGProxy *device_proxy,
+               bt_info_for_searching_support_service_t *bt_info_for_searching_support_service)
+{
+
+       const char *wanted_uuid = NULL;
+       DBG("+\n");
+
+       if (device_proxy == NULL || bt_info_for_searching_support_service == NULL) {
+               DBG("Bad Input parameter \n");
+               return FALSE;
+       }
+
+       wanted_uuid = bt_info_for_searching_support_service->search_match_ptr->match;
+       DBG("__bluetooth_internal_get_remote_service_handle address[%s]\n",
+           dbus_g_proxy_get_path(device_proxy));
+
+       if (!dbus_g_proxy_begin_call_with_timeout(device_proxy, "DiscoverServices",
+                               (DBusGProxyCallNotify) __bluetooth_internal_discover_services_cb,
+                               bt_info_for_searching_support_service, NULL,
+                               25000, G_TYPE_STRING, wanted_uuid, G_TYPE_INVALID)) {
+       }
+
+       return TRUE;
+}
+
+static void __bluetooth_internal_request_search_supported_services(const bluetooth_device_address_t *device_address)
+{
+       bt_info_t *bt_internal_info = NULL;
+       DBusGProxy *device_proxy;
+       const char *path;
+       char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
+       GError *err = NULL;
+       bt_info_for_searching_support_service_t *bt_info_for_searching_support_service;
+
+       DBG("+\n");
+       if (device_address == NULL) {
+               DBG("device_address is NULL -\n");
+               return;
+       }
+
+       _bluetooth_internal_session_init();
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       bt_info_for_searching_support_service =
+           &bt_internal_info->info_for_searching_support_service;
+       _bluetooth_internal_addr_type_to_addr_string(addr, device_address);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", &err,
+                         G_TYPE_STRING, addr, G_TYPE_INVALID,
+                         DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID);
+
+       if (err != NULL) {
+               DBG("Error occured in FindDevice Proxy call [%s]\n", err->message);
+               g_error_free(err);
+               return;
+       }
+
+       device_proxy = _bluetooth_internal_find_device_by_path(path);
+
+       bt_info_for_searching_support_service->search_match_ptr = supported_service_info;
+       memcpy(&bt_info_for_searching_support_service->remote_device_addr, device_address,
+              sizeof(bluetooth_device_address_t));
+       _bluetooth_internal_print_bluetooth_device_address_t(&bt_info_for_searching_support_service->remote_device_addr);
+
+       __bluetooth_internal_get_remote_service_handle(device_proxy,
+                                                    bt_info_for_searching_support_service);
+
+       DBG("-\n");
+}
+
+BT_EXPORT_API int bluetooth_cancel_service_search(void)
+{
+       bt_info_t *bt_internal_info = NULL;
+       DBusGProxy *device_proxy;
+       const char *path;
+       char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
+       GError *err = NULL;
+       bt_info_for_searching_support_service_t *bt_info_for_searching_support_service;
+
+       DBG("+\n");
+
+       _bluetooth_internal_session_init();
+
+       if (_bluetooth_internal_is_adapter_enabled() == FALSE) {
+               DBG("Currently not enabled");
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       }
+
+       bt_internal_info = _bluetooth_internal_get_information();
+
+       if (bt_internal_info == NULL)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       if (bt_internal_info->adapter_proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       bt_info_for_searching_support_service =
+           &bt_internal_info->info_for_searching_support_service;
+       _bluetooth_internal_addr_type_to_addr_string(addr,
+                               &bt_info_for_searching_support_service->remote_device_addr);
+
+       dbus_g_proxy_call(bt_internal_info->adapter_proxy, "FindDevice", &err,
+                         G_TYPE_STRING, addr, G_TYPE_INVALID,
+                         DBUS_TYPE_G_OBJECT_PATH, &path, G_TYPE_INVALID);
+
+       if (err != NULL) {
+               DBG("Error occured in FindDevice Proxy call [%s]\n", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       device_proxy = _bluetooth_internal_find_device_by_path(path);
+
+       if (!device_proxy)
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+
+       dbus_g_proxy_call(device_proxy, "CancelDiscovery", &err, G_TYPE_INVALID, G_TYPE_INVALID);
+       if (err != NULL) {
+               DBG("Error occured in CancelDiscovery Proxy call [%s]\n", err->message);
+               g_error_free(err);
+               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+       }
+
+       DBG("-\n");
+       return BLUETOOTH_ERROR_NONE;
+}
diff --git a/lib/bluetooth-sdp-api.h b/lib/bluetooth-sdp-api.h
new file mode 100644 (file)
index 0000000..ed336c5
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 _BLUETOOTH_SDP_API_H_
+#define _BLUETOOTH_SDP_API_H_
+
+#include "bluetooth-api-common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#define SERVICE_RECORD_HANDLE   0x0000
+#define SERVICE_CLASS_ID_LIST   0x0001
+#define PROTOCOL_DESCRIPOTR_LIST 0x0004
+#define BLUETOOTH_PROFILE_DESCRIPTOR_LIST   0x0009
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /*_BLUETOOTH_SDP_API_H_*/
diff --git a/lib/marshal.list b/lib/marshal.list
new file mode 100644 (file)
index 0000000..ff4fa82
--- /dev/null
@@ -0,0 +1,25 @@
+# DBUS Signal argument converting list for bluetooth frwk  lib
+VOID:STRING
+VOID:STRING,UINT,INT
+VOID:STRING,STRING
+VOID:STRING,STRING,INT
+VOID:UINT
+VOID:STRING,STRING,INT,UINT
+
+# for BlueZ4
+VOID:STRING,BOXED
+# for obex
+VOID:STRING,STRING,UINT64
+VOID:UINT64
+VOID:STRING,STRING,STRING
+# for obexd
+VOID:OBJECT,BOOLEAN
+VOID:INT,INT
+#VOID:UINT64
+#VOID:STRING,UINT
+#VOID:STRING,BOOLEAN
+#VOID:STRING,STRING,BOOLEAN 
+#VOID:STRING,STRING,STRING
+#VOID:STRING,STRING,UINT64
+#VOID:STRING,STRING,STRING,STRING
+
diff --git a/lib/obex-agent.c b/lib/obex-agent.c
new file mode 100644 (file)
index 0000000..65d7aeb
--- /dev/null
@@ -0,0 +1,408 @@
+/*
+ *  Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "bluetooth-api-common.h"
+#include <stdio.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "obex-agent.h"
+#include <dlog.h>
+#include "marshal.h"
+
+#define BT_OBEX "BT_OBEX"
+#define DBG(fmt, args...) SLOG(LOG_DEBUG, BT_OBEX, "%s():%d "fmt, __func__, __LINE__, ##args)
+
+#define OBEX_SERVICE   "org.openobex.client"
+
+#define OBEX_CLIENT_PATH       "/"
+#define OBEX_CLIENT_INTERFACE  "org.openobex.Client"
+#define OBEX_TRANSFER_INTERFACE        "org.openobex.Transfer"
+
+static DBusGConnection *connection = NULL;
+
+#define OBEX_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+                                       OBEX_TYPE_AGENT, ObexAgentPrivate))
+
+typedef struct _ObexAgentPrivate ObexAgentPrivate;
+
+struct _ObexAgentPrivate {
+       gchar *busname;
+       gchar *path;
+
+       ObexAgentAuthorizeFunc authorize_func;
+       gpointer authorize_data;
+
+       ObexAgentReleaseFunc release_func;
+       gpointer release_data;
+
+       ObexAgentRequestFunc request_func;
+       gpointer request_data;
+
+       ObexAgentProgressFunc progress_func;
+       gpointer progress_data;
+
+       ObexAgentCompleteFunc complete_func;
+       gpointer complete_data;
+
+       ObexAgentErrorFunc error_func;
+       gpointer error_data;
+};
+
+G_DEFINE_TYPE(ObexAgent, obex_agent, G_TYPE_OBJECT)
+
+static gboolean obex_agent_request(ObexAgent *agent, const char *path,
+                                  DBusGMethodInvocation *context)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       DBG("agent %p sender %s", agent, sender);
+
+       if (priv->busname == NULL) {
+               /* When we get called the first time, if OBEX_SERVICE
+                * was not available, we get its name here */
+               priv->busname = sender;
+       } else {
+               if (g_strcmp0(sender, priv->busname) != 0) {
+                       g_free(sender);
+                       return FALSE;
+               }
+
+               g_free(sender);
+       }
+
+       if (priv->request_func) {
+               DBusGProxy *proxy;
+
+               proxy = dbus_g_proxy_new_for_name(connection, OBEX_SERVICE,
+                                                 path, OBEX_TRANSFER_INTERFACE);
+
+               /*FIXME check result*/
+               result = priv->request_func(context, proxy, priv->request_data);
+
+               g_object_unref(proxy);
+       } else
+               dbus_g_method_return(context, "");
+
+       return TRUE;
+}
+
+static gboolean obex_agent_authorize(ObexAgent *agent, const char *path, const char *bdaddress,
+                                    const char *name, const char *type, gint length, gint time,
+                                    DBusGMethodInvocation *context)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       gboolean result = FALSE;
+
+       DBG("agent %p sender %s", agent);
+
+       if (priv->authorize_func) {
+               result = priv->authorize_func(context, path, bdaddress, name, type, length, time,
+                                               priv->authorize_data);
+       } else
+               dbus_g_method_return(context);
+
+       return result;
+}
+
+static gboolean obex_agent_progress(ObexAgent *agent, const char *path,
+                                   guint64 transferred, DBusGMethodInvocation *context)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       DBG("agent %p sender %s", agent, sender);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       g_free(sender);
+
+       if (priv->progress_func) {
+               DBusGProxy *proxy;
+
+               proxy = dbus_g_proxy_new_for_name(connection, OBEX_SERVICE,
+                                                 path, OBEX_TRANSFER_INTERFACE);
+
+               result = priv->progress_func(context, proxy, transferred, priv->progress_data);
+
+               g_object_unref(proxy);
+       } else
+               dbus_g_method_return(context);
+
+       return result;
+}
+
+static gboolean obex_agent_complete(ObexAgent *agent, const char *path,
+                                   DBusGMethodInvocation *context)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       DBG("agent %p sender %s", agent, sender);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       g_free(sender);
+
+       if (priv->complete_func) {
+               DBusGProxy *proxy;
+
+               proxy = dbus_g_proxy_new_for_name(connection, OBEX_SERVICE,
+                                                 path, OBEX_TRANSFER_INTERFACE);
+
+               result = priv->complete_func(context, proxy, priv->complete_data);
+
+               g_object_unref(proxy);
+       } else
+               dbus_g_method_return(context);
+
+       return result;
+}
+
+static gboolean obex_agent_release(ObexAgent *agent, DBusGMethodInvocation *context)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       DBG("agent %p sender %s bbus %s", agent, sender, priv->busname);
+       if (priv->busname) {
+               /*In H2 if user denies auth,release will come without request and hence
+               priv->busname will be NULL */
+               if (g_strcmp0(sender, priv->busname) != 0) {
+                       g_free(sender);
+                       return FALSE;
+               }
+       }
+       g_free(sender);
+
+       if (priv->release_func)
+               result = priv->release_func(context, priv->release_data);
+       else
+               dbus_g_method_return(context);
+
+       g_object_unref(agent);
+
+       return result;
+}
+
+static gboolean obex_agent_error(ObexAgent *agent,
+                                const char *path,
+                                const char *message, DBusGMethodInvocation *context)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       char *sender = dbus_g_method_get_sender(context);
+       gboolean result = FALSE;
+
+       DBG("agent %p sender %s", agent, sender);
+
+       if (g_strcmp0(sender, priv->busname) != 0) {
+               g_free(sender);
+               return FALSE;
+       }
+
+       g_free(sender);
+
+       if (priv->error_func) {
+               DBusGProxy *proxy;
+
+               proxy = dbus_g_proxy_new_for_name(connection, OBEX_SERVICE,
+                                                 path, OBEX_TRANSFER_INTERFACE);
+
+               result = priv->error_func(context, proxy, message, priv->progress_data);
+
+               g_object_unref(proxy);
+       } else
+               dbus_g_method_return(context);
+
+       return result;
+}
+
+#include "obex-agent-glue.h"
+
+static void obex_agent_init(ObexAgent *agent)
+{
+       DBG("agent %p", agent);
+}
+
+static void obex_agent_finalize(GObject *agent)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       g_free(priv->path);
+       g_free(priv->busname);
+
+       G_OBJECT_CLASS(obex_agent_parent_class)->finalize(agent);
+}
+
+static void obex_agent_class_init(ObexAgentClass *klass)
+{
+       GObjectClass *object_class = (GObjectClass *) klass;
+       GError *error = NULL;
+
+       DBG("class %p", klass);
+
+       g_type_class_add_private(klass, sizeof(ObexAgentPrivate));
+
+       object_class->finalize = obex_agent_finalize;
+
+       connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+
+       if (error != NULL) {
+               DBG("error:%s", error->message);
+               g_printerr("Connecting to session bus failed: %s\n", error->message);
+               g_error_free(error);
+       }
+
+       dbus_g_object_type_install_info(OBEX_TYPE_AGENT, &dbus_glib_obex_agent_object_info);
+}
+
+BT_EXPORT_API ObexAgent *obex_agent_new(void)
+{
+       ObexAgent *agent;
+
+       agent = OBEX_AGENT(g_object_new(OBEX_TYPE_AGENT, NULL));
+       DBG("agent %p", agent);
+
+       return agent;
+}
+
+BT_EXPORT_API gboolean obex_agent_setup(ObexAgent *agent, const char *path)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+       DBusGProxy *proxy;
+       GObject *object;
+
+       DBG("agent %p path %s", agent, path);
+
+       if (priv->path != NULL)
+               return FALSE;
+
+       priv->path = g_strdup(path);
+
+       proxy = dbus_g_proxy_new_for_name_owner(connection, OBEX_SERVICE,
+                                               OBEX_CLIENT_PATH, OBEX_CLIENT_INTERFACE, NULL);
+
+       g_free(priv->busname);
+
+       if (proxy != NULL) {
+               priv->busname = g_strdup(dbus_g_proxy_get_bus_name(proxy));
+               g_object_unref(proxy);
+       } else
+               priv->busname = NULL;
+
+       object = dbus_g_connection_lookup_g_object(connection, priv->path);
+       if (object != NULL)
+               g_object_unref(object);
+
+       dbus_g_connection_register_g_object(connection, priv->path, G_OBJECT(agent));
+
+       dbus_g_object_register_marshaller(marshal_VOID__OBJECT_BOOLEAN,
+                                         G_TYPE_NONE, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_BOOLEAN,
+                                         G_TYPE_INVALID);
+
+       dbus_g_object_register_marshaller(marshal_VOID__INT_INT,
+                                         G_TYPE_NONE, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID);
+       return TRUE;
+}
+
+BT_EXPORT_API void obex_agent_set_authorize_func(ObexAgent *agent,
+                                                ObexAgentAuthorizeFunc func, gpointer data)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       priv->authorize_func = func;
+       priv->authorize_data = data;
+}
+
+BT_EXPORT_API void obex_agent_set_release_func(ObexAgent *agent,
+                                              ObexAgentReleaseFunc func, gpointer data)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       priv->release_func = func;
+       priv->release_data = data;
+}
+
+BT_EXPORT_API void obex_agent_set_request_func(ObexAgent *agent,
+                                              ObexAgentRequestFunc func, gpointer data)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       priv->request_func = func;
+       priv->request_data = data;
+}
+
+BT_EXPORT_API void obex_agent_set_progress_func(ObexAgent *agent,
+                                               ObexAgentProgressFunc func, gpointer data)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       priv->progress_func = func;
+       priv->progress_data = data;
+}
+
+BT_EXPORT_API void obex_agent_set_complete_func(ObexAgent *agent,
+                                               ObexAgentCompleteFunc func, gpointer data)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       priv->complete_func = func;
+       priv->complete_data = data;
+}
+
+BT_EXPORT_API void obex_agent_set_error_func(ObexAgent *agent,
+                                            ObexAgentErrorFunc func, gpointer data)
+{
+       ObexAgentPrivate *priv = OBEX_AGENT_GET_PRIVATE(agent);
+
+       DBG("agent %p", agent);
+
+       priv->error_func = func;
+       priv->error_data = data;
+}
diff --git a/lib/obex-agent.h b/lib/obex-agent.h
new file mode 100644 (file)
index 0000000..7609d23
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __OBEX_AGENT_H
+#define __OBEX_AGENT_H
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+#define OBEX_TYPE_AGENT (obex_agent_get_type())
+#define OBEX_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+                                               OBEX_TYPE_AGENT, ObexAgent))
+#define OBEX_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
+                                       OBEX_TYPE_AGENT, ObexAgentClass))
+#define OBEX_IS_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+                                                       OBEX_TYPE_AGENT))
+#define OBEX_IS_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
+                                                       OBEX_TYPE_AGENT))
+#define OBEX_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \
+                                       OBEX_TYPE_AGENT, ObexAgentClass))
+typedef struct _ObexAgent ObexAgent;
+typedef struct _ObexAgentClass ObexAgentClass;
+
+struct _ObexAgent {
+       GObject parent;
+};
+
+struct _ObexAgentClass {
+       GObjectClass parent_class;
+};
+
+GType obex_agent_get_type(void);
+
+ObexAgent *obex_agent_new(void);
+
+gboolean obex_agent_setup(ObexAgent *agent, const char *path);
+
+typedef gboolean(*ObexAgentAuthorizeFunc) (DBusGMethodInvocation *context,
+                                          const char *path,
+                                          const char *bdaddress,
+                                          const char *name,
+                                          const char *type, gint length, gint time, gpointer data);
+typedef gboolean(*ObexAgentReleaseFunc) (DBusGMethodInvocation *context, gpointer data);
+typedef gboolean(*ObexAgentRequestFunc) (DBusGMethodInvocation *context,
+                                        DBusGProxy *transfer, gpointer data);
+typedef gboolean(*ObexAgentProgressFunc) (DBusGMethodInvocation *context,
+                                         DBusGProxy *transfer,
+                                         guint64 transferred, gpointer data);
+typedef gboolean(*ObexAgentCompleteFunc) (DBusGMethodInvocation *context,
+                                         DBusGProxy *transfer, gpointer data);
+typedef gboolean(*ObexAgentErrorFunc) (DBusGMethodInvocation *context,
+                                      DBusGProxy *transfer, const char *message, gpointer data);
+
+void obex_agent_set_authorize_func(ObexAgent *agent, ObexAgentAuthorizeFunc func, gpointer data);
+void obex_agent_set_release_func(ObexAgent *agent, ObexAgentReleaseFunc func, gpointer data);
+void obex_agent_set_request_func(ObexAgent *agent, ObexAgentRequestFunc func, gpointer data);
+void obex_agent_set_progress_func(ObexAgent *agent, ObexAgentProgressFunc func, gpointer data);
+void obex_agent_set_complete_func(ObexAgent *agent, ObexAgentCompleteFunc func, gpointer data);
+void obex_agent_set_error_func(ObexAgent *agent, ObexAgentErrorFunc func, gpointer data);
+G_END_DECLS
+#endif                         /* __OBEX_AGENT_H */
diff --git a/lib/obex-agent.xml b/lib/obex-agent.xml
new file mode 100644 (file)
index 0000000..5915005
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/">
+  <interface name="org.openobex.Agent">
+    <method name="Request">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="transfer"/>
+      <arg type="s" name="name" direction="out"/>
+    </method>
+
+    <method name="Progress">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="transfer"/>
+      <arg type="t" name="transferred"/>
+    </method>
+
+    <method name="Complete">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="transfer"/>
+    </method>
+
+    <method name="Release">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+    </method>
+
+    <method name="Error">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="o" name="transfer"/>
+      <arg type="s" name="message"/>
+    </method>
+    <method name="Authorize">
+       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+               <arg type="o" name="objpath"/>
+               <arg type="s" name="bdaddress"/>
+               <arg type="s" name="name"/>
+               <arg type="s" name="type"/>
+               <arg type="i" name="length"/>
+               <arg type="i" name="time"/>
+               <arg type="s" name="filepath" direction="out"/>
+       </method>
+  </interface>
+</node>
diff --git a/lib/test/CMakeLists.txt b/lib/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..03bdba8
--- /dev/null
@@ -0,0 +1,34 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-frwk-test C)
+
+SET(SRCS bluetooth-frwk-test.c)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(package REQUIRED dlog dbus-glib-1 glib-2.0 gthread-2.0)
+
+FOREACH(flag ${package_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${package_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lbluetooth-api)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
diff --git a/lib/test/bluetooth-frwk-test.c b/lib/test/bluetooth-frwk-test.c
new file mode 100644 (file)
index 0000000..7f2f2f8
--- /dev/null
@@ -0,0 +1,1356 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+/**
+ * @file       bluetooth-frwk-test.c
+ * @brief      This is the source file for bluetooth framework test suite.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <pthread.h>
+
+#include "bluetooth-api.h"
+
+
+bluetooth_device_address_t searched_device = {{0}};
+
+#define TC_TIMEOUT     30000
+
+#define BT_DEFAULT_DEV_NAME "SLP-BT-TEST-TARGET"
+#define DISCOVER_TIMEOUT 20
+#define DISCOVER_CANCEL_INTERVAL 3
+
+#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
+#define TC_PRT(format, args...) PRT(format"\n", ##args)
+
+#define TC_PASS 1
+#define TC_FAIL 0
+int g_tmp = 0;
+int g_ret_client_fd1 = -1, g_ret_client_fd2 = -1;
+const char *g_hdp_app_handle1 =  NULL;
+const char *g_hdp_app_handle2 =  NULL;
+int selection;
+int hdp_manual_mode =  1;
+const char * rfcomm_test_uuid_spp ="00001101-0000-1000-8000-00805F9B34FB";
+const char * rfcomm_test_uuid_dun = "00001103-0000-1000-8000-00805F9B34FB";
+
+GMainLoop *main_loop = NULL;
+static int timeout_status = 0;
+
+typedef struct
+{
+       const char *tc_name;
+       int tc_code;
+} tc_table_t;
+
+tc_table_t tc_table[] =
+{
+       {"bluetooth_register_callback"          , 0x0001},
+       {"bluetooth_enable_adapter"                     , 0x0002},
+       {"bluetooth_disable_adapter"            , 0x0003},
+       {"bluetooth_check_adapter"                      , 0x0004},
+       {"bluetooth_get_local_address"          , 0x0005},
+       {"bluetooth_get_local_name"                     , 0x0006},
+       {"bluetooth_set_local_name"                     , 0x0007},
+       {"bluetooth_get_discoverable_mode"      , 0x0008},
+       {"bluetooth_set_discoverable_mode"      , 0x0009},
+       {"bluetooth_start_discovery"            , 0x000a},
+       {"bluetooth_cancel_discovery"           , 0x000b},
+       {"bluetooth_is_discovering"                     , 0x000c},
+       {"bluetooth_bond_device"                        , 0x000d},
+       {"bluetooth_cancel_bonding"                     , 0x000e},
+       {"bluetooth_unbond_device"                      , 0x000f},
+       {"bluetooth_get_bonded_device_list"     , 0x0010},
+       {"bluetooth_get_remote_device"          , 0x0011},
+       {"bluetooth_authorize_device"           , 0x0012},
+       {"bluetooth_search_service"                     , 0x0013},
+       {"bluetooth_set_alias"                          , 0x0014},
+       /*Rfcomm related*/
+       {"bluetooth_rfcomm_create_socket"       , 0x0020},
+       {"bluetooth_rfcomm_listen_and_accept"   , 0x0021},
+       {"bluetooth_rfcomm_remove_socket"       , 0x0022},
+
+       {"bluetooth_rfcomm_connect"     , 0x0023},
+       {"bluetooth_rfcomm_disconnect"  , 0x0024},
+       {"bluetooth_rfcomm_write"       , 0x0025},
+       {"bluetooth_network_activate_server"    , 0x0026},
+       {"bluetooth_network_deactivate_server"  , 0x0027},
+       {"bluetooth_network_connect"    , 0x0028},
+       {"bluetooth_network_disconnect" , 0x0029},
+
+       {"bluetooth_hdp_activate"       , 0x0030},
+       {"bluetooth_hdp_deactivate"     , 0x0031},
+       {"bluetooth_hdp_connect"        , 0x0032},
+       {"bluetooth_hdp_disconnect"     , 0x0033},
+       {"bluetooth_hdp_send_data"      , 0x0034},
+
+       {"bluetooth_opc_init"           , 0x0035},
+       {"bluetooth_opc_push_file"      , 0x0036},
+       {"bluetooth_opc_cancel_push"    , 0x0037},
+       {"bluetooth_opc_deinit"         , 0x0038},
+       /* -----------------------------------------*/
+       {"Finish"                                                       , 0x00ff},
+       {NULL                                                           , 0x0000},
+
+};
+
+#define tc_result(success, tc_index) \
+       TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS)?"Success":"Failed"));
+
+bluetooth_device_info_t bond_dev;
+int is_bond_device = FALSE;
+
+void tc_usage_print(void)
+{
+       int i = 0;
+
+       while (tc_table[i].tc_name && tc_table[i].tc_code)
+       {
+               if (tc_table[i].tc_code != 0x00ff)
+               {
+                       TC_PRT("Key %d : usage %s", i, tc_table[i].tc_name);
+               }
+               else
+               {
+                       TC_PRT("Key %d : usage %s\n\n", 0x00ff, tc_table[i].tc_name);
+               }
+
+               i++;
+       }
+
+}
+
+int test_input_callback(void *data)
+{
+       int ret = 0;
+       int test_id = (int)data;
+
+       switch (test_id)
+       {
+               case 0x00ff:
+                       TC_PRT("Finished");
+                       g_main_loop_quit(main_loop);
+                       break;
+
+               case 1:
+                       TC_PRT("TC : %s", tc_table[1].tc_name);
+                       ret = bluetooth_enable_adapter();
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[1].tc_name, ret);
+                               tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case 2:
+                       TC_PRT("TC : %s", tc_table[2].tc_name);
+                       ret = bluetooth_disable_adapter();
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[2].tc_name, ret);
+                               tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case 3:
+                       TC_PRT("TC : %s", tc_table[3].tc_name);
+                       ret = bluetooth_check_adapter();
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[3].tc_name, ret);
+                               tc_result(TC_FAIL, 3);
+                       }
+                       else
+                       {
+                               TC_PRT("BT state [0x%04x]", ret);
+                               tc_result(TC_PASS, 3);
+                       }
+                       break;
+
+               case 4:
+               {
+                       bluetooth_device_address_t local_address = {{0}};
+
+                       TC_PRT("TC : %s", tc_table[4].tc_name);
+                       ret = bluetooth_get_local_address(&local_address);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[4].tc_name, ret);
+                               tc_result(TC_FAIL, 4);
+                       }
+                       else
+                       {
+                               TC_PRT("BT local address[%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                                       local_address.addr[0], local_address.addr[1], local_address.addr[2], \
+                                       local_address.addr[3], local_address.addr[4], local_address.addr[5]);
+                               tc_result(TC_PASS, 4);
+                       }
+                       break;
+               }
+
+               case 5:
+               {
+                       bluetooth_device_name_t local_name = {{0}};
+
+                       TC_PRT("TC : %s", tc_table[5].tc_name);
+                       ret = bluetooth_get_local_name(&local_name);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[5].tc_name, ret);
+                               tc_result(TC_FAIL, 5);
+                       }
+                       else
+                       {
+                               TC_PRT("BT local name [%s]", \
+                                       local_name.name);
+                               tc_result(TC_PASS, 5);
+                       }
+                       break;
+               }
+
+               case 6:
+               {
+                       bluetooth_device_name_t local_name = {{0}};
+                       snprintf(local_name.name, sizeof(local_name.name),
+                                       "bt-frwk-pid-%d", getpid());
+
+                       TC_PRT("TC : %s", tc_table[6].tc_name);
+                       ret = bluetooth_set_local_name(&local_name);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[6].tc_name, ret);
+                               tc_result(TC_FAIL, 6);
+                       }
+                       break;
+               }
+
+               case 7:
+               {
+                       bluetooth_discoverable_mode_t mode;
+                       TC_PRT("TC : %s", tc_table[7].tc_name);
+                       ret = bluetooth_get_discoverable_mode(&mode);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[7].tc_name, ret);
+                               tc_result(TC_FAIL, 7);
+                       }
+                       else
+                       {
+                               TC_PRT("BT Get Discoverable mode [%d]", \
+                                       mode);
+                               tc_result(TC_PASS, 7);
+                       }
+                       break;
+               }
+
+               case 8:
+               {
+                       bluetooth_discoverable_mode_t mode = 3;
+                       TC_PRT("TC : %s", tc_table[8].tc_name);
+                       ret = bluetooth_set_discoverable_mode(mode, 180);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[8].tc_name, ret);
+                               tc_result(TC_FAIL, 8);
+                       }
+                       else
+                       {
+                               TC_PRT("BT Set Discoverable mode [%d]", \
+                                       mode);
+                               tc_result(TC_PASS, 8);
+                       }
+                       break;
+               }
+
+               case 9:
+                       TC_PRT("TC : %s", tc_table[9].tc_name);
+                       ret = bluetooth_start_discovery(0,0,0);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[9].tc_name, ret);
+                               tc_result(TC_FAIL, 9);
+                       }
+                       break;
+
+               case 10:
+                       TC_PRT("TC : %s", tc_table[10].tc_name);
+                       ret = bluetooth_cancel_discovery();
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[10].tc_name, ret);
+                               tc_result(TC_FAIL, 10);
+                       }
+                       break;
+
+               case 11:
+               {
+                       TC_PRT("TC : %s", tc_table[11].tc_name);
+                       ret = bluetooth_is_discovering();
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[11].tc_name, ret);
+                               tc_result(TC_FAIL, 11);
+                       }
+                       else
+                       {
+                               TC_PRT("Discovering [%d]", ret);
+                               tc_result(TC_PASS, 11);
+                       }
+                       break;
+               }
+
+               case 12:
+               {
+                       if (searched_device.addr[0] || searched_device.addr[1] || searched_device.addr[2] \
+                               || searched_device.addr[3] || searched_device.addr[4] || searched_device.addr[5])
+                       {
+                               TC_PRT("TC : %s", tc_table[12].tc_name);
+
+                               TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                                       searched_device.addr[0], searched_device.addr[1], searched_device.addr[2], \
+                                       searched_device.addr[3], searched_device.addr[4], searched_device.addr[5]);
+
+                               ret = bluetooth_bond_device(&searched_device);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[12].tc_name, ret);
+                                       tc_result(TC_FAIL, 12);
+                               }
+                       }
+                       else
+                       {
+                               TC_PRT("Do search first");
+                       }
+                       break;
+               }
+
+               case 13: /*Cancel bonding */
+               {
+
+                               TC_PRT("TC : %s", tc_table[13].tc_name);
+                               ret = bluetooth_cancel_bonding();
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[13].tc_name, ret);
+                                       tc_result(TC_FAIL, 13);
+                               }
+
+                       break;
+               }
+
+               case 14: /*Get paired device */
+               {
+                               bluetooth_device_info_t devinfo = {0};
+                               bluetooth_device_address_t device_address={{0x00,0x1C,0x43,0x2B,0x1A,0xE5}};
+
+                               ret = bluetooth_get_bonded_device(&device_address, &devinfo);
+                               if (ret != BLUETOOTH_ERROR_NONE)
+                               {
+                                       TC_PRT("bluetooth_get_bonded_device failed with [%d]",ret);
+                               }
+                               else
+                               {
+                                       TC_PRT("Name [%s]", devinfo.device_name.name);
+                                       TC_PRT("Major Class [%d]", devinfo.device_class.major_class);
+                                       TC_PRT("Minor Class [%d]", devinfo.device_class.minor_class);
+                                       TC_PRT("Service Class [%d]", devinfo.device_class.service_class);
+                                       TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", devinfo.device_address.addr[0], devinfo.device_address.addr[1], devinfo.device_address.addr[2], devinfo.device_address.addr[3], devinfo.device_address.addr[4], devinfo.device_address.addr[5]);
+                               }
+
+                       break;
+               }
+
+               case 15: /*Get paired device list */
+               {
+
+                               TC_PRT("TC : %s", tc_table[15].tc_name);
+//                             bluetooth_device_address_t remote_address = {{0}};
+
+                               GPtrArray *devinfo = NULL;
+                               devinfo = g_ptr_array_new();
+                               TC_PRT("g pointer arrary count : [%d]", devinfo->len);
+
+                               ret = bluetooth_get_bonded_device_list(&devinfo);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[19].tc_name, ret);
+                                       tc_result(TC_FAIL, 15);
+                               }
+                               else
+                               {
+                                       int i;
+                                       bluetooth_device_info_t *ptr;
+                                       TC_PRT("g pointer arrary count : [%d]", devinfo->len);
+
+                                       if(devinfo->len >=1)
+                                       {
+                                               ptr = g_ptr_array_index(devinfo, 0);
+                                               memcpy(&bond_dev, ptr, sizeof(bluetooth_device_info_t));
+                                               is_bond_device = TRUE;
+                                       }
+                                       else
+                                               is_bond_device = FALSE;
+
+                                       for(i=0; i<devinfo->len;i++)
+                                       {
+                                               ptr = g_ptr_array_index(devinfo, i);
+                                               if(ptr != NULL)
+                                               {
+                                                       TC_PRT("Name [%s]", ptr->device_name.name);
+                                                       TC_PRT("Major Class [%d]", ptr->device_class.major_class);
+                                                       TC_PRT("Minor Class [%d]", ptr->device_class.minor_class);
+                                                       TC_PRT("Service Class [%d]", ptr->device_class.service_class);
+                                                       TC_PRT("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", ptr->device_address.addr[0], ptr->device_address.addr[1], ptr->device_address.addr[2], ptr->device_address.addr[3], ptr->device_address.addr[4], ptr->device_address.addr[5]);
+                                                       TC_PRT("\n");
+                                               }
+                                       }
+                                       tc_result(TC_PASS, 15);
+                               }
+                               g_ptr_array_free(devinfo, TRUE);
+
+                       break;
+               }
+               case 18: /*service search */
+               {
+
+                               TC_PRT("TC : %s", tc_table[18].tc_name);
+                               bluetooth_device_address_t remote_address = {{0}};
+
+                               TC_PRT("Selected Choi Dongle\n");
+                               /*Syam PC Dongle choi*/
+                               remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x03; remote_address.addr[2] = 0x7A;
+                               remote_address.addr[3]= 0x2D; remote_address.addr[4] = 0xC9;  remote_address.addr[5]= 0x9D;
+
+                               ret = bluetooth_search_service(&remote_address);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[18].tc_name, ret);
+                                       tc_result(TC_FAIL, 18);
+                               }
+
+
+                       break;
+               }
+               case 19: /*set alias for bonded device */
+               {
+                               char buff[100] = {0,};
+                               TC_PRT("TC : %s", tc_table[19].tc_name);
+
+                               TC_PRT("TC : Input the alias = ");
+                               scanf("%s", buff);
+
+                               if(!strcmp(buff, "NULL"))
+                               {
+                                       memset(buff, 0, 100);
+                                       TC_PRT("There is no alias");
+                               }
+                               else
+                                       TC_PRT("ALIAS is %s", buff);
+
+                               if(is_bond_device)
+                               {
+                                       ret = bluetooth_set_alias(&bond_dev.device_address, buff);
+                                       if (ret < 0)
+                                       {
+                                               TC_PRT("%s failed with [0x%04x]", tc_table[19].tc_name, ret);
+                                               tc_result(TC_FAIL, 19);
+                                       }
+                                       else
+                                       {
+                                               tc_result(TC_PASS, 19);
+                                       }
+                               }
+                               else
+                               {
+                                       TC_PRT("Please get bonded device list calling  bluetooth_get_bonded_device_list");
+                               }
+                       break;
+               }
+
+               /*Rfcomm */
+               case 20: /*Create server socket */
+               {
+                               TC_PRT("TC : %s", tc_table[20].tc_name);
+                               ret = bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[20].tc_name, ret);
+                                       tc_result(TC_FAIL, 20);
+                               }
+                               TC_PRT("\nReturned FD = %d\n", ret);
+                               g_tmp = ret;
+                       break;
+               }
+               case 21: /*Listen and accept */
+               {
+
+                               TC_PRT("TC : %s", tc_table[21].tc_name);
+                               ret = bluetooth_rfcomm_listen_and_accept(g_tmp,1);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[21].tc_name, ret);
+                                       tc_result(TC_FAIL, 21);
+                               }
+                               TC_PRT("\nListining status(True/False) = %d\n", ret);
+                       break;
+               }
+               case 22: /*Server remove */
+               {
+
+                               TC_PRT("TC : %s", tc_table[22].tc_name);
+                               ret = bluetooth_rfcomm_remove_socket(g_tmp, rfcomm_test_uuid_spp);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[22].tc_name, ret);
+                                       tc_result(TC_FAIL, 22);
+                               }
+
+                       break;
+               }
+               case 23: /*connect */
+               {
+                               bluetooth_device_address_t remote_address = {{0}};
+                               TC_PRT("Enter connect device 1 or 2:");
+                               scanf("%d", &selection);
+                               if(selection == 1)
+                               {
+#if 1
+                                       TC_PRT("Selected Choi Dongle\n");
+                                       /*Syam PC Dongle choi*/
+                                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x0A; remote_address.addr[2] = 0x3A;
+                                       remote_address.addr[3]= 0x54; remote_address.addr[4] = 0x19;  remote_address.addr[5]= 0x36;
+#else
+                                       TC_PRT("Selected Grey Dongle\n");
+                                       /*Syam PC Dongle Grey BT*/
+                                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x0D; remote_address.addr[2] = 0x18;
+                                       remote_address.addr[3]= 0x01; remote_address.addr[4] = 0x24;  remote_address.addr[5]= 0x47;
+#endif
+                               }
+                               else
+                               {
+                                       /*Syam Mob 00:21:D1:0B:45:22*/
+                                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x21; remote_address.addr[2] = 0xD1;
+                                       remote_address.addr[3]= 0x0B; remote_address.addr[4] = 0x45;  remote_address.addr[5]= 0x22;
+
+                               }
+
+                               TC_PRT("TC : %s", tc_table[23].tc_name);
+
+                               ret = bluetooth_rfcomm_connect(&remote_address, rfcomm_test_uuid_spp);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[23].tc_name, ret);
+                                       tc_result(TC_FAIL, 23);
+                               }
+                               else
+                               {
+                                       TC_PRT("\n Returned value = %d\n", ret);
+                               }
+                       break;
+               }
+
+               case 24: /*disconnect */
+               {
+//                             bluetooth_device_address_t remote_address = {{0}};
+                               int no, fd_dis;
+                               TC_PRT("Enter Disconnect device 1 or 2:");
+                               scanf("%d", &no);
+
+                               if(no == 1)
+                               {
+                                       fd_dis = g_ret_client_fd1;
+                               }
+                               else
+                               {
+                                       fd_dis = g_ret_client_fd2;
+                               }
+
+                               TC_PRT("TC : %s", tc_table[24].tc_name);
+
+                               ret = bluetooth_rfcomm_disconnect(fd_dis);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
+                                       tc_result(TC_FAIL, 24);
+                               }
+                               TC_PRT("\n Disconnect result for fd %d is = %d\n", fd_dis, ret);
+                       break;
+               }
+
+               case 25: /*write */
+               {
+//                             bluetooth_device_address_t remote_address = {{0}};
+                               char *buff = "abcdefghijklmnopqrstuvwxyz";
+                               int fd_channel;
+                               TC_PRT("TC : %s", tc_table[25].tc_name);
+                               TC_PRT("\n Enter the channel: ");
+                               scanf("%d", &fd_channel);
+                               ret = bluetooth_rfcomm_write(fd_channel, buff, 26);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[25].tc_name, ret);
+                                       tc_result(TC_FAIL, 25);
+                               }
+                       break;
+               }
+
+               case 26: /*bluetooth_network_activate_server */
+               {
+                       bluetooth_network_activate_server();
+                       break;
+               }
+
+               case 27: /*bluetooth_network_deactivate_server */
+               {
+                       bluetooth_network_deactivate_server();
+                       break;
+               }
+
+               case 28: /*bluetooth_network_connect */
+               {
+                       bluetooth_device_address_t device_address={{0x00,0x02,0x10,0x54,0x90,0x27}};
+                       bluetooth_network_connect(&device_address, BLUETOOTH_NETWORK_NAP_ROLE, NULL);
+                       break;
+               }
+
+               case 29: /*bluetooth_network_disconnect */
+               {
+                       bluetooth_device_address_t device_address={{0x00,0x02,0x10,0x54,0x90,0x27}};
+                       bluetooth_network_disconnect(&device_address);
+                       break;
+               }
+
+
+               case 30: /*HDP Activate*/
+               {
+                       if(hdp_manual_mode == 1)
+                       {
+                               int d_type;
+                               TC_PRT("Enter the device type value\n");
+                               TC_PRT("eg: 4100(pulse), 4103(Blood pressure), 4104(thermometer), 4111(weight), 4113(Glucose)\n");
+                               scanf("%d", &d_type);
+                               ret = bluetooth_hdp_activate(d_type, HDP_ROLE_SINK, HDP_QOS_ANY);
+                               TC_PRT("Act Done\n");
+                               break;
+                       }
+
+                               ret = bluetooth_hdp_activate(4100, HDP_ROLE_SINK, HDP_QOS_ANY);
+
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[30].tc_name, ret);
+                                       tc_result(TC_FAIL, 30);
+                               }
+                       TC_PRT("Done, Res = %d\n", ret);
+                       break;
+               }
+               case 31: /*HDP DeActivate*/
+               {
+
+                       if(hdp_manual_mode == 1)
+                       {
+                               if(NULL == g_hdp_app_handle2)
+                               {
+                                       ret = bluetooth_hdp_deactivate(g_hdp_app_handle1);
+                                       g_hdp_app_handle1 = NULL;
+                               }
+                               else
+                               {
+                                       ret = bluetooth_hdp_deactivate(g_hdp_app_handle2);
+                                       g_hdp_app_handle2 = NULL;
+                               }
+                               TC_PRT("Done, Res = %d\n", ret);
+                               break;
+                       }
+                       ret = bluetooth_hdp_deactivate(g_hdp_app_handle1);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[31].tc_name, ret);
+                               tc_result(TC_FAIL, 31);
+                       }
+                       TC_PRT("Done, Res = %d\n", ret);
+                       break;
+               }
+               case 32: /*HDP Connect*/
+               {
+                       bluetooth_device_address_t remote_address = {{0}};
+                       TC_PRT("Warning!!! Make sure that you have changed the BD address \n");
+                       /*PTS Dongle 1*/
+                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+                       remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x07;
+                       if(hdp_manual_mode)
+                       {
+                               if(g_hdp_app_handle2 != NULL) /**/
+                               {
+                                       ret = bluetooth_hdp_connect(g_hdp_app_handle2, HDP_QOS_ANY, &remote_address);
+                                       g_hdp_app_handle2 = NULL;
+                               }
+                               else
+                               {
+                                       ret = bluetooth_hdp_connect(g_hdp_app_handle1, HDP_QOS_ANY, &remote_address);
+                                       g_hdp_app_handle1 = NULL;
+                               }
+                               TC_PRT("Done, Res = %d\n", ret);
+                               break;
+                       }
+
+
+                       ret = bluetooth_hdp_connect(g_hdp_app_handle1, HDP_QOS_ANY, &remote_address);
+                       if (ret < 0)
+                       {
+                               TC_PRT("%s failed with [0x%04x]", tc_table[32].tc_name, ret);
+                               tc_result(TC_FAIL, 32);
+                       }
+                       TC_PRT("Done, Res = %d\n", ret);
+                       break;
+               }
+
+               case 33: /*HDP Disconnect*/
+               {
+                               bluetooth_device_address_t remote_address = {{0}};
+                               TC_PRT("Warning!!! Make sure that you have changed the BD address \n");
+                               /*PTS Dongle 1*/
+                               remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+                               remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x07;
+                               if(hdp_manual_mode)
+                               {
+                                       int d_type;
+                                       TC_PRT("Enter the channel id (fd):\n");
+                                       scanf("%d", &d_type);
+                                       ret = bluetooth_hdp_disconnect(d_type, &remote_address);
+                                       TC_PRT("Done, Res = %d\n", ret);
+                                       break;
+                               }
+                               ret = bluetooth_hdp_disconnect(g_ret_client_fd1, &remote_address);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[33].tc_name, ret);
+                                       tc_result(TC_FAIL, 33);
+                               }
+                               close(g_ret_client_fd1);
+                               TC_PRT("Done..\n");
+                       break;
+               }
+
+
+               case 34: /*HDP Send Data*/
+               {
+                               char *buff = "abcdefghijklmnopqrstuvwxyz";
+
+                               ret = bluetooth_hdp_send_data(g_ret_client_fd1, buff, 26);
+                               if (ret < 0)
+                               {
+                                       TC_PRT("%s failed with [0x%04x]", tc_table[34].tc_name, ret);
+                                       tc_result(TC_FAIL, 34);
+                               }
+                               TC_PRT("Done, Res = %d\n", ret);
+                       break;
+               }
+
+               case 35:
+               {
+                       bluetooth_opc_init();
+                       break;
+               }
+
+               case 36:
+               {
+                       bluetooth_device_address_t remote_address = {{0}};
+                       TC_PRT("Warning!!! Make sure that you have changed the BD address \n");
+#if 0
+                       /*PTS Dongle 1*/
+                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x80; remote_address.addr[2] = 0x98;
+                       remote_address.addr[3]= 0xE7; remote_address.addr[4] = 0x34;  remote_address.addr[5]= 0x07;
+#endif
+                       /* Grey dongle */
+                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x19; remote_address.addr[2] = 0x0E;
+                       remote_address.addr[3]= 0x01; remote_address.addr[4] = 0x61;  remote_address.addr[5]= 0x17;
+                       char *files[5] = {NULL};
+                       files[0] = "/opt/media/photo1.jpg";
+                       files[1] = "/opt/media/photo2.jpg";
+                       files[2] = "/opt/media/photo3.jpg";
+//                     files[3] = "/opt/media/Downloads/4_photo_41.jpg";
+                       bluetooth_opc_push_files(&remote_address,files);
+                       break;
+               }
+
+               case 37:
+               {
+                       bluetooth_device_address_t remote_address = {{0}};
+                       /* Grey dongle */
+                       remote_address.addr[0] = 0x00; remote_address.addr[1] = 0x03; remote_address.addr[2] = 0x7A;
+                       remote_address.addr[3]= 0x2D; remote_address.addr[4] = 0xC9;  remote_address.addr[5]= 0x9D;
+
+                       char *files[5] = {NULL};
+                       files[0] = "/opt/media/photo1.jpg";
+                       files[1] = "/opt/media/photo2.jpg";
+                       files[2] = "/opt/media/photo3.jpg";
+                       bluetooth_opc_push_files(&remote_address,files);
+                       break;
+               }
+
+               case 38:
+               {
+                       bluetooth_opc_deinit();
+                       break;
+               }
+
+               case 39:
+               {
+                       bluetooth_obex_server_init("/opt/media/Downloads");
+                       break;
+               }
+
+               case 40:
+               {
+                       bluetooth_obex_server_deinit();
+                       break;
+               }
+
+               case 41:
+               {
+                       bluetooth_obex_server_accept_authorize("abc");
+                       break;
+               }
+
+               case 42:
+               {
+                       bluetooth_obex_server_reject_authorize();
+                       break;
+               }
+
+               case 43:
+               {
+                       bluetooth_is_supported();
+                       break;
+               }
+
+               case 44:
+               {
+                       bluetooth_allow_service(TRUE);
+                       break;
+               }
+
+               case 45:
+               {
+                       bluetooth_allow_service(FALSE);
+                       break;
+               }
+
+               case 46:
+               {
+                       bluetooth_opc_sessioin_is_exist();
+                       break;
+               }
+
+               case 47:
+               {
+                       bluetooth_obex_server_is_activated();
+                       break;
+               }
+
+               default:
+                       break;
+       }
+
+       return 0;
+}
+
+void startup()
+{
+       TC_PRT("bluetooth framework TC startup");
+
+       if(!g_thread_supported())
+       {
+               g_thread_init(NULL);
+       }
+
+       dbus_g_thread_init();
+
+       g_type_init();
+       main_loop = g_main_loop_new(NULL, FALSE);
+}
+
+void cleanup()
+{
+       TC_PRT("bluetooth framework TC cleanup");
+       if( main_loop!= NULL)
+       {
+               g_main_loop_unref(main_loop);
+       }
+}
+
+int timeout_callback(void *data)
+{
+       TC_PRT("timeout callback");
+       timeout_status = -1;
+
+       g_main_loop_quit(main_loop);
+
+       return FALSE;
+}
+
+void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_data)
+{
+       TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+       TC_PRT("bt event callback 0x%04x", event);
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_ENABLED:
+                       TC_PRT("BLUETOOTH_EVENT_ENABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               tc_result(TC_PASS, 1);
+                       }
+                       else
+                       {
+                               tc_result(TC_FAIL, 1);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_DISABLED:
+                       TC_PRT("BLUETOOTH_EVENT_DISABLED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               tc_result(TC_PASS, 2);
+                       }
+                       else
+                       {
+                               tc_result(TC_FAIL, 2);
+                       }
+                       break;
+
+               case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
+                       TC_PRT("BLUETOOTH_EVENT_LOCAL_NAME_CHANGED, result [0x%04x]", param->result);
+                       if (param->result == BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
+                               tc_result(TC_PASS, 6);
+                               TC_PRT("Changed Name : [%s]", local_name->name);
+                       }
+                       else
+                       {
+                               tc_result(TC_FAIL, 6);
+                       }
+                       break;
+
+
+               case BLUETOOTH_EVENT_DISCOVERY_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_STARTED, result [0x%04x]", param->result);
+                       break;
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+               {
+                       bluetooth_device_info_t *device_info = NULL;
+                       TC_PRT("BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED, result [0x%04x]", param->result);
+                       device_info  = (bluetooth_device_info_t *)param->param_data;
+                       memcpy(&searched_device, &device_info->device_address, sizeof(bluetooth_device_address_t));
+                       TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", device_info->device_name.name, \
+                               device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                               device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
+                       TC_PRT("BLUETOOTH_EVENT_DISCOVERY_FINISHED, result [0x%04x]", param->result);
+                       tc_result(TC_PASS, 9);
+                       break;
+
+
+               case BLUETOOTH_EVENT_BONDING_FINISHED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_BONDING_FINISHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               bluetooth_device_info_t *device_info = NULL;
+                               tc_result(TC_PASS, 12);
+                               device_info  = (bluetooth_device_info_t *)param->param_data;
+                               TC_PRT("dev [%s] [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X] mjr[%#x] min[%#x] srv[%#x]", device_info->device_name.name, \
+                                       device_info->device_address.addr[0], device_info->device_address.addr[1], device_info->device_address.addr[2], \
+                                       device_info->device_address.addr[3], device_info->device_address.addr[4], device_info->device_address.addr[5], \
+                                       device_info->device_class.major_class, device_info->device_class.minor_class, device_info->device_class.service_class);
+                       }
+                       else
+                       {
+                               tc_result(TC_FAIL, 12);
+                       }
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_BONDED_DEVICE_FOUND:
+               {
+                       // bluetooth_get_bonded_device_list is changed as synchronous API. This event is not used any more.
+                       // 2011.01.06
+#if 0
+//                     int i = 0;
+                       TC_PRT("BLUETOOTH_EVENT_BONDED_DEVICE_FOUND, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               ///tc_result(TC_PASS, 15);
+                               bluetooth_device_info_t * bt_dev_info= (bluetooth_device_info_t*)param->param_data;
+
+                               TC_PRT("Dev Name = %s, Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X, COD (major,minor,service)= 0x%x:%x:%x\n", bt_dev_info->device_name.name,
+                                       bt_dev_info->device_address.addr[0], bt_dev_info->device_address.addr[1], bt_dev_info->device_address.addr[2], \
+                                       bt_dev_info->device_address.addr[3], bt_dev_info->device_address.addr[4], bt_dev_info->device_address.addr[5], \
+                                       bt_dev_info->device_class.major_class, bt_dev_info->device_class.minor_class, bt_dev_info->device_class.service_class);
+
+                       }
+                       else
+                       if(param->result == BLUETOOTH_ERROR_END_OF_DEVICE_LIST) /*End of the Device found indication*/
+                       {
+                               tc_result(TC_PASS, 15);
+                               TC_PRT("*****<<No more BLUETOOTH_EVENT_BONDED_DEVICE_FOUND indication>>***** ");
+                       }
+                       else
+                       {
+                               tc_result(TC_FAIL, 15);
+                               TC_PRT("*****API failed ***** ");
+                       }
+                       break;
+#endif
+               }
+               case BLUETOOTH_EVENT_SERVICE_SEARCHED:
+               {
+                       int i = 0;
+                       TC_PRT("BLUETOOTH_EVENT_SERVICE_SEARCHED, result [0x%04x]", param->result);
+                       if (param->result >= BLUETOOTH_ERROR_NONE)
+                       {
+                               tc_result(TC_PASS, 18);
+                               bt_sdp_info_t * bt_sdp_info=param->param_data;
+
+                               TC_PRT("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                       bt_sdp_info->device_addr.addr[0], bt_sdp_info->device_addr.addr[1], bt_sdp_info->device_addr.addr[2], \
+                                       bt_sdp_info->device_addr.addr[3], bt_sdp_info->device_addr.addr[4], bt_sdp_info->device_addr.addr[5]);
+
+                                       TC_PRT("Supported service list:\n");
+                                       for(i=0; i<bt_sdp_info->service_index; i++)
+                                               TC_PRT("[%#x]\n", bt_sdp_info->service_list_array[i]);
+
+                       }
+                       else
+                       {
+                               tc_result(TC_FAIL, 18);
+                       }
+                       break;
+               }
+               case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED, result [0x%04x]", param->result);
+                       bluetooth_rfcomm_received_data_t *rx_data = param->param_data;
+                       printf("\n FD = %d \nBuffer len = %d ", rx_data->socket_fd, rx_data->buffer_size);
+                       //tc_result(TC_PASS, 21);
+                       break;
+               }
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *con_ind = (bluetooth_rfcomm_connection_t *)param->param_data;
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_CONNECTED, result [0x%04x], fd = %d, device add = 0x%X:%X:%X:%X:%X:%X, Role = %s", param->result,
+                                                               con_ind->socket_fd,
+                                                               con_ind->device_addr.addr[0], con_ind->device_addr.addr[1], con_ind->device_addr.addr[2],
+                                                               con_ind->device_addr.addr[3], con_ind->device_addr.addr[4], con_ind->device_addr.addr[5],
+                                                               (con_ind->device_role == RFCOMM_ROLE_SERVER)? "SERVER":"CLIENT");
+                       //tc_result(TC_PASS, 22);
+                       if((con_ind->device_role == RFCOMM_ROLE_CLIENT) && (con_ind->socket_fd > 0))
+                       {
+                               if(selection == 1)
+                                       g_ret_client_fd1 = con_ind->socket_fd;
+                               else
+                                       g_ret_client_fd2 = con_ind->socket_fd;
+                       }
+
+                       break;
+               }
+               case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
+               {
+                       bluetooth_rfcomm_disconnection_t *disconnection_ind = (bluetooth_rfcomm_disconnection_t *)param->param_data;;
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x] Fd = %d, device add = 0x%X:%X:%X:%X:%X:%X\n", param->result, disconnection_ind->socket_fd,
+                                                                                                               disconnection_ind->device_addr.addr[0], disconnection_ind->device_addr.addr[1], disconnection_ind->device_addr.addr[2],
+                                                                                                               disconnection_ind->device_addr.addr[3], disconnection_ind->device_addr.addr[4], disconnection_ind->device_addr.addr[5] );
+                       //tc_result(TC_PASS, 22);
+                       break;
+               }
+               case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED:
+               {
+                       bluetooth_network_device_info_t *dev_info = (bluetooth_network_device_info_t *)param->param_data;
+
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x]", param->result);
+                       TC_PRT("interface name: %s", dev_info->interface_name);
+
+                       TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                                               dev_info->device_address.addr[0], dev_info->device_address.addr[1], dev_info->device_address.addr[2],
+                                                               dev_info->device_address.addr[3], dev_info->device_address.addr[4], dev_info->device_address.addr[5] );
+                       break;
+               }
+               case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED:
+               {
+                       bluetooth_network_device_info_t *dev_info = (bluetooth_network_device_info_t *)param->param_data;
+
+                       TC_PRT("BLUETOOTH_EVENT_RFCOMM_DISCONNECTED, result [0x%04x]", param->result);
+                       TC_PRT("interface name: %s", dev_info->interface_name);
+
+                       TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                                               dev_info->device_address.addr[0], dev_info->device_address.addr[1], dev_info->device_address.addr[2],
+                                                               dev_info->device_address.addr[3], dev_info->device_address.addr[4], dev_info->device_address.addr[5] );
+                       break;
+               }
+
+
+               case BLUETOOTH_EVENT_HDP_ACTIVATED:
+               {
+
+                       TC_PRT("BLUETOOTH_EVENT_HDP_ACTIVATED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX");
+                       bt_hdp_activate_t *act_cfm =  (bt_hdp_activate_t *)param->param_data;
+                       TC_PRT("App handler = %s\n", act_cfm->app_handle);
+                       if(hdp_manual_mode == 1)
+                       {
+                               if(NULL == g_hdp_app_handle1)
+                                       g_hdp_app_handle1 =  act_cfm->app_handle; /*1st time */
+                               else
+                                       g_hdp_app_handle2 =  act_cfm->app_handle; /*2nd time */
+
+                               break;
+                       }
+                       g_hdp_app_handle1 =  act_cfm->app_handle;
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_HDP_DEACTIVATED:
+               {
+
+                       TC_PRT("BLUETOOTH_EVENT_HDP_DEACTIVATED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX");
+                       bt_hdp_deactivate_t *deact_cfm =  (bt_hdp_deactivate_t *)param->param_data;
+                       TC_PRT("App handler = %s\n", deact_cfm->app_handle);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_HDP_CONNECTED:
+               {
+                       bt_hdp_connected_t *conn_ind = (bt_hdp_connected_t *)param->param_data;
+
+                       TC_PRT("BLUETOOTH_EVENT_HDP_CONNECTED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX");
+                       TC_PRT("App handler = %s, channel id = %d, type = %s", conn_ind->app_handle, conn_ind->channel_id, (conn_ind->type == HDP_QOS_RELIABLE)? "Reliable":"Streaming");
+                       TC_PRT("device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                                                               conn_ind->device_address.addr[0], conn_ind->device_address.addr[1], conn_ind->device_address.addr[2],
+                                                               conn_ind->device_address.addr[3], conn_ind->device_address.addr[4], conn_ind->device_address.addr[5] );
+
+                       g_ret_client_fd1 = conn_ind->channel_id;
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_HDP_DISCONNECTED:
+               {
+                       bt_hdp_disconnected_t *dis_ind = (bt_hdp_disconnected_t *)param->param_data;
+
+                       TC_PRT("BLUETOOTH_EVENT_HDP_DISCONNECTED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX");
+                       TC_PRT("Channel = %d, Add = device add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", dis_ind->channel_id,
+                                                               dis_ind->device_address.addr[0], dis_ind->device_address.addr[1], dis_ind->device_address.addr[2],
+                                                               dis_ind->device_address.addr[3], dis_ind->device_address.addr[4], dis_ind->device_address.addr[5]);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_HDP_DATA_RECEIVED:
+               {
+                       bt_hdp_data_ind_t *data_ind = (bt_hdp_data_ind_t *)param->param_data;
+
+                       TC_PRT("BLUETOOTH_EVENT_HDP_DATA_RECEIVED, Result = %s\n", (param->result == 0)? "BLUETOOTH_ERROR_NONE": "BLUETOOTH_ERROR_XXXX");
+                       TC_PRT("Data received from channel id = %d and  size =%d, buff =[%s]\n",  data_ind->channel_id, data_ind->size, data_ind->buffer);
+
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_OPC_CONNECTED:
+                       TC_PRT("BLUETOOTH_EVENT_OPC_CONNECTED");
+                       break;
+
+               case BLUETOOTH_EVENT_OPC_DISCONNECTED:
+                       TC_PRT("BLUETOOTH_EVENT_OPC_DISCONNECTED");
+                       break;
+               case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
+                       if (param->param_data) {
+                               bt_opc_transfer_info_t *info = param->param_data;
+                               TC_PRT("file %s", info->filename);
+                               TC_PRT("size %d", info->size);
+                       }
+                       break;
+               }
+               case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS");
+                       break;
+               }
+               case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE:
+               {
+                       TC_PRT("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
+                       bt_opc_transfer_info_t *info = param->param_data;
+                       TC_PRT("file %s", info->filename);
+                       TC_PRT("size %d", info->size);
+                       break;
+               }
+
+               case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE:
+                       TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE");
+                       break;
+
+               case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED:
+                       TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
+                       break;
+
+               case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS:
+                       TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS");
+                       break;
+
+               case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED:
+                       TC_PRT("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED");
+                       break;
+
+               default:
+                       TC_PRT("received event [0x%04x]", event);
+                       break;
+       }
+       TC_PRT("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+}
+
+#ifdef __THREAD__
+static void* input_thread( void* arg )
+{
+       char test_code[8000];
+       int test_id;
+
+       while (1==1)
+       {
+
+               tc_usage_print();
+               printf("Input test ID : ");
+               gets(test_code);
+               test_id = atoi(test_code);
+               if (test_id)
+                       g_idle_add(test_input_callback, (void*)test_id);
+       }
+
+       return NULL;
+}
+#endif
+
+static gboolean key_event_cb(GIOChannel * chan, GIOCondition cond , gpointer data)
+{
+       char buf[10] = {0};
+
+       unsigned int len=0;
+       int test_id;
+       memset(buf, 0, sizeof(buf));
+
+       if(g_io_channel_read(chan, buf, sizeof(buf), &len) !=G_IO_ERROR_NONE) {
+
+               printf("IO Channel read error");
+               return FALSE;
+
+       }
+       printf("%s\n",buf);
+       tc_usage_print();
+
+       test_id=atoi(buf);
+
+       if(test_id)
+               g_idle_add(test_input_callback, (void*)test_id);
+
+       return TRUE;
+}
+
+int main()
+{
+       int ret_val;
+
+       startup();
+
+       // Register callback function
+       TC_PRT("TC : %s", tc_table[0].tc_name);
+       ret_val = bluetooth_register_callback(bt_event_callback, NULL);
+       if (ret_val >= BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_register_callback returned Success");
+               tc_result(TC_PASS, 0);
+       }
+       else
+       {
+               TC_PRT("bluetooth_register_callback returned failiure [0x%04x]", ret_val);
+               tc_result(TC_FAIL, 0);
+               return 0;
+       }
+
+       ret_val = bluetooth_check_adapter();
+       if (ret_val < BLUETOOTH_ERROR_NONE)
+       {
+               TC_PRT("bluetooth_check_adapter returned failiure [0x%04x]", ret_val);
+               tc_result(TC_FAIL, 3);
+       }
+       else
+       {
+               TC_PRT("BT state [0x%04x]", ret_val);
+               tc_result(TC_PASS, 3);
+       }
+
+#ifdef __THREAD__
+       {
+               pthread_t thread;
+               pthread_attr_t tattr = {{0}};
+
+               ret_val = pthread_attr_init(&tattr);
+               ret_val = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
+               pthread_attr_setstacksize(&tattr, 128*1024);
+               ret_val = pthread_create(&thread, &tattr, input_thread, NULL);
+               pthread_attr_destroy(&tattr);
+       }
+#else
+       {
+               GIOChannel *key_io;
+               key_io=g_io_channel_unix_new(fileno(stdin));
+
+               g_io_add_watch(key_io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                               key_event_cb, NULL);
+               g_io_channel_unref(key_io);
+       }
+#endif
+
+       g_main_loop_run(main_loop);
+
+       cleanup();
+       return 0;
+}
+
diff --git a/packaging/bluetooth-frwk.spec b/packaging/bluetooth-frwk.spec
new file mode 100644 (file)
index 0000000..b12a1c8
--- /dev/null
@@ -0,0 +1,96 @@
+Name:       bluetooth-frwk
+Summary:    Bluetooth framework for BlueZ This package is Bluetooth framework based on Blue
+Version:    0.1.21
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    TO BE FILLED IN
+Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(contacts-service)
+BuildRequires:  pkgconfig(dbus-glib-1)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(syspopup-caller)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(bluez)
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(utilX)
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(openobex)
+BuildRequires:  cmake
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+Bluetooth framework for BlueZ This package is Bluetooth framework based on BlueZ stack.
+ This package contains API set for BT GAP, BT SDP, and BT RFCOMM.
+
+
+%package devel
+Summary:    Bluetooth framework for BlueZ
+Group:      TO_BE/FILLED
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+This package is development files for Bluetooth framework based on BlueZ stack.
+This package contains API set for BT GAP, BT SDP, and BT RFCOMM.
+
+
+%package test
+Summary:    Bluetooth framework test application
+Group:      TO_BE/FILLED
+Requires:   %{name} = %{version}-%{release}
+
+%description test
+This package is a test application for bluetooth framework.
+
+
+%package agent
+Summary:    Bluetooth Agent for pairing and authorization
+Group:      TO_BE/FILLED
+Requires:   %{name} = %{version}-%{release}
+
+%description agent
+This package is Bluetooth useraction Agent to response pairing, authorization, and mode change with BlueZ.
+
+%prep
+%setup -q
+
+
+%build
+export CFLAGS+=" -fpie"
+export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
+
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+make
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+/usr/lib/*.so.*
+
+%files devel
+/usr/lib/*.so
+/usr/include/*
+/usr/lib/pkgconfig/*
+
+%files test
+/usr/bin/bluetooth-frwk-test
+
+%files agent
+/usr/bin/bluetooth-agent
+/usr/bin/bluetooth-pb-agent
+/etc/*
+/usr/share/process-info/bluetooth-agent.ini
+/usr/share/dbus-1/services/org.bluez.frwk_agent.service
+/usr/share/dbus-1/services/org.bluez.pb_agent.service