Fix issues in the merged Tizen 3.0 code 28/36528/3
authorSudha Bheemanna <b.sudha@samsung.com>
Mon, 9 Mar 2015 14:01:20 +0000 (19:31 +0530)
committerseungku kim <seungku.kim@samsung.com>
Thu, 26 Mar 2015 03:21:14 +0000 (12:21 +0900)
1> Fix issues in the call back handling.
2> Did the required code changes to fix the merged 2.4 code in the Tizen 3.0 branch.
3> Only Basic test cases verified like BT enable/disable, discovery and pair device.

Change-Id: Ib730a786488ae50eaeae55fd02757b7bd99839e1
Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
39 files changed:
LICENSE.APLv2 [deleted file]
NOTICE [deleted file]
bluetooth-frwk-core.manifest [deleted file]
bluetooth-frwk-test.manifest [deleted file]
bluetooth-frwk.manifest [deleted file]
bluetooth_log_dump.sh [deleted file]
bt-api/bt-adapter.c [changed mode: 0644->0755]
bt-api/bt-common.c
bt-api/bt-gatt.c [changed mode: 0644->0755]
bt-core/CMakeLists.txt
bt-core/bluetooth-frwk-core.conf [changed mode: 0644->0755]
bt-core/bt-core-adapter.c [changed mode: 0644->0755]
bt-core/bt-core-dbus-handler.c
bt-core/bt-core-main.c
bt-core/bt_core.c [deleted file]
bt-core/bt_core.h [deleted file]
bt-core/bt_core.xml [deleted file]
bt-core/include/bt-core-adapter.h
bt-service/CMakeLists.txt [changed mode: 0644->0755]
bt-service/bluetooth-frwk-service.conf.in [changed mode: 0644->0755]
bt-service/bluetooth-frwk-service.service [changed mode: 0644->0755]
bt-service/bt-popup.c [deleted file]
bt-service/bt-request-handler.c
bt-service/bt-service-adapter.c [changed mode: 0644->0755]
bt-service/bt-service-agent-notification.c [deleted file]
bt-service/bt-service-common.c [changed mode: 0644->0755]
bt-service/bt-service-device.c
bt-service/bt-service-device.c.orig [deleted file]
bt-service/bt-service-event-receiver.c [changed mode: 0644->0755]
bt-service/bt-service-event-sender.c
bt-service/bt-service-gap-agent.c [changed mode: 0644->0755]
bt-service/bt-service-main.c [changed mode: 0644->0755]
bt-service/include/bt-popup.h [deleted file]
bt-service/include/bt-service-agent-notification.h [deleted file]
bt-service/org.projectx.bt.service.in [changed mode: 0644->0755]
packaging/bluetooth-frwk.changes [deleted file]
packaging/bluetooth-frwk.spec [changed mode: 0644->0755]
packaging/bt-icon.png [changed mode: 0644->0755]
test/CMakeLists.txt

diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
deleted file mode 100644 (file)
index a06208b..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-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/NOTICE b/NOTICE
deleted file mode 100644 (file)
index 0e0f016..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,3 +0,0 @@
-Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
-Except as noted, this software is licensed under Apache License, Version 2.
-Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/bluetooth-frwk-core.manifest b/bluetooth-frwk-core.manifest
deleted file mode 100755 (executable)
index e3bf17e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<manifest>
-       <define>
-               <domain name="bt-core"/>
-
-       <request>
-               <smack request="dbus" type="rwx"/>
-               <smack request="aul::launch" type="x"/>
-               <smack request="tizen::vconf::public::r::platform::rw" type="rw"/>
-               <smack request="tizen::vconf::setting::admin" type="rw"/>
-       </request>
-       <permit>
-               <smack permit="dbus" type="rwx"/>
-       </permit>
-       </define>
-       <assign>
-               <filesystem path="/etc/init.d/bluetooth-frwk-core" label="_" exec_label="none" />
-               <filesystem path="/usr/share/dbus-1/system-services/org.projectx.bt_core.service" label="_" exec_label="none" />
-               <filesystem path="/usr/bin/bt-core" label="_" exec_label="none"/>
-       </assign>
-
-       <request>
-               <domain name="bt-core"/>
-       </request>
-</manifest>
diff --git a/bluetooth-frwk-test.manifest b/bluetooth-frwk-test.manifest
deleted file mode 100755 (executable)
index 5f737de..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<manifest>
-    <define>
-        <domain name="bt-frwk-test"/>
-       <request>
-               <smack request="bt-service::manager" type="w"/>
-               <smack request="bt-service::admin" type="w"/>
-               <smack request="bt-service::gap" type="w"/>
-       </request>
-    </define>
-    <request>
-        <domain name="bt-frwk-test"/>
-    </request>
-</manifest>
diff --git a/bluetooth-frwk.manifest b/bluetooth-frwk.manifest
deleted file mode 100755 (executable)
index c82d314..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<manifest>
-       <define>
-               <domain name="bt-service"/>
-               <provide>
-                       <label name="bt-service::public"/>
-                       <label name="bt-service::platform"/>
-               </provide>
-               <request>
-                       <smack request="system::share" type="rwxat"/>
-                       <smack request="system::ext_storage" type="rwxat"/>
-                       <smack request="system::media" type="rwxat"/>
-                       <smack request="system::homedir" type="rwxat"/>
-                       <smack request="dbus" type="rwx"/>
-                       <smack request="xorg" type="rwx"/>
-                       <smack request="device::app_logging" type="w"/>
-                       <smack request="syspopup::db" type="rwx"/>
-                       <smack request="device::dialout" type="rw"/>
-                       <smack request="sys-assert::core" type="rwxat"/>
-                       <smack request="tethering::dbus-access" type="rw"/>
-                       <smack request="alarm-server::alarm" type="w"/>
-                       <smack request="aul::launch" type="x"/>
-                       <smack request="security-server::api-cookie-check" type="w"/>
-                       <smack request="connman::get" type="rwx"/>
-                       <smack request="connman::set" type="rwx"/>
-                       <smack request="connman::profile" type="rwx"/>
-                       <smack request="factory-reset" type="rwx"/>
-                       <smack request="bt-service::public" type="w"/>
-                       <smack request="bt-service::platform" type="w"/>
-                       <smack request="telephony_framework::api_ps_public" type="rw"/>
-                       <smack request="tizen::vconf::platform::r" type="rw"/>
-                       <smack request="tizen::vconf::platform::rw" type="rw"/>
-                       <smack request="tizen::vconf::public::r::platform::rw" type="rw"/>
-                       <smack request="tizen::vconf::setting::admin" type="rw"/>
-               </request>
-       </define>
-       <assign>
-               <filesystem path="/etc/init.d/bluetooth-frwk" label="_" exec_label="none" />
-               <filesystem path="/usr/share/dbus-1/system-services/org.projectx.bt.service" label="_" exec_label="none" />
-               <filesystem path="/opt/etc/dump.d/module.d/bluetooth_log_dump.sh" label="_" exec_label="none"/>
-               <filesystem path="/usr/etc/bluetooth" label="_" exec_label="none"/>
-               <filesystem path="/usr/etc/bluetooth/stack_info" label="_" exec_label="none"/>
-               <filesystem path="/opt/var/lib/bluetooth" label="_" exec_label="none"/>
-       </assign>
-       <request>
-               <domain name="bt-service"/>
-       </request>
-</manifest>
diff --git a/bluetooth_log_dump.sh b/bluetooth_log_dump.sh
deleted file mode 100755 (executable)
index 073e407..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-#--------------------------------------
-#    bluetooth
-#--------------------------------------
-
-BLUETOOTH_DEBUG=${1}/bluetooth
-PREV_PWD=${PWD}
-BT_DATA_DIR=/var/lib/bluetooth
-
-mkdir -p ${BLUETOOTH_DEBUG}
-
-if [ -e ${BT_DATA_DIR} ]
-then
-       cd ${BT_DATA_DIR}
-       /bin/tar -cvzf ${BLUETOOTH_DEBUG}/bt_log.tar.gz *
-fi
-
-cd ${PREV_PWD}
old mode 100644 (file)
new mode 100755 (executable)
index 9973c3e..422dde5
@@ -69,22 +69,26 @@ static int __bt_fill_device_list(GArray *out_param2, GPtrArray **dev_list)
 
 BT_EXPORT_API int bluetooth_check_adapter(void)
 {
-       int result;
-       bluetooth_adapter_state_t state;
+       int ret;
+       int value;
 
-       BT_INIT_PARAMS();
-       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+       ret = _bt_get_adapter_path(_bt_gdbus_get_system_gconn(), NULL);
 
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_CHECK_ADAPTER,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
+       if (ret != BLUETOOTH_ERROR_NONE) {
+               BT_ERR("error in get adapter ");
+               return BLUETOOTH_ADAPTER_DISABLED;
+       }
 
-       if (result == BLUETOOTH_ERROR_NONE) {
-               state = g_array_index(out_param, bluetooth_adapter_state_t, 0);
+       /* check VCONFKEY_BT_STATUS */
+       if (vconf_get_int(VCONFKEY_BT_STATUS, &value) != 0) {
+               BT_ERR("fail to get vconf key! return disabled");
+               return BLUETOOTH_ADAPTER_DISABLED;
        }
 
-       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+       BT_ERR("get status from vconf key \n");
 
-       return state ? BLUETOOTH_ADAPTER_ENABLED : BLUETOOTH_ADAPTER_DISABLED;
+       return value == VCONFKEY_BT_STATUS_OFF ? BLUETOOTH_ADAPTER_DISABLED :
+                                               BLUETOOTH_ADAPTER_ENABLED;
 }
 
 BT_EXPORT_API int bluetooth_enable_adapter(void)
@@ -111,6 +115,7 @@ BT_EXPORT_API int bluetooth_disable_adapter(void)
        int result;
 
        BT_INFO("");
+
        BT_CHECK_ENABLED(return);
 
        BT_INIT_PARAMS();
index 6b1e0f5..4fdfa85 100755 (executable)
@@ -48,6 +48,9 @@ static GDBusConnection *system_gdbus_conn = NULL;
 
 static guint bus_id;
 
+static char *cookie;
+static size_t cookie_size;
+
 static GDBusConnection *system_gconn = NULL;
 
 GDBusConnection *_bt_gdbus_init_system_gconn(void)
@@ -1225,6 +1228,39 @@ DBusConnection *_bt_get_system_conn(void)
        return dbus_g_connection_get_connection(g_conn);
 }
 
+void _bt_generate_cookie(void)
+{
+       int retval;
+
+       ret_if(cookie != NULL);
+
+       cookie_size = security_server_get_cookie_size();
+
+       cookie = g_malloc0((cookie_size*sizeof(char))+1);
+
+       retval = security_server_request_cookie(cookie, cookie_size);
+       if(retval < 0) {
+               BT_ERR("Fail to get cookie: %d", retval);
+       }
+}
+
+void _bt_destroy_cookie(void)
+{
+       g_free(cookie);
+       cookie = NULL;
+       cookie_size = 0;
+}
+
+char *_bt_get_cookie(void)
+{
+       return cookie;
+}
+
+int _bt_get_cookie_size(void)
+{
+       return cookie_size;
+}
+
 int _bt_register_osp_server_in_agent(int type, char *uuid, char *path, int fd)
 {
        int ret;
old mode 100644 (file)
new mode 100755 (executable)
index 25837a5..b1e9153 100755 (executable)
@@ -60,3 +60,4 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt_core.service DESTINATION share/dbus-1/system-services)
 
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-core.conf DESTINATION /etc/dbus-1/system.d)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 0837281..211d855
@@ -37,6 +37,8 @@ static gboolean is_recovery_mode = FALSE;
 static int bt_status_before[BT_MODE_MAX] = { VCONFKEY_BT_STATUS_OFF, };
 static int bt_le_status_before[BT_MODE_MAX] = { 0, };
 
+static DBusGConnection *conn = NULL;
+
 static void __bt_core_set_status(bt_status_t status)
 {
        adapter_status = status;
@@ -196,7 +198,6 @@ static int __execute_command(const char *cmd, char *const arg_list[])
        return 0;
 }
 
-#if 0
 static DBusGProxy *_bt_get_connman_proxy(void)
 {
        DBusGProxy *proxy;
@@ -235,36 +236,31 @@ static int _bt_power_adapter(gboolean powered)
                                G_TYPE_INVALID, G_TYPE_INVALID);
 
        if (error != NULL) {
-               BT_ERR("Powered set err:[%s]", error->message);
+               BT_ERR("Powered set err: \n [%s]", error->message);
                g_error_free(error);
                g_value_unset(&state);
                return BLUETOOTH_ERROR_INTERNAL;
        }
        return BLUETOOTH_ERROR_NONE;
 }
-#endif
 
 int _bt_enable_adapter(void)
 {
        int ret;
        bt_status_t status;
        bt_le_status_t le_status;
-
-       BT_INFO("");
 #ifdef __TIZEN_MOBILE__
-       int ret;
-
        __bt_core_set_status(BT_ACTIVATING);
 
-       ret = system("/usr/etc/bluetooth/bt-stack-up.sh &");
+       ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
        if (ret < 0) {
-               BT_DBG("running script failed");
-               ret = system("/usr/etc/bluetooth/bt-dev-end.sh &");
+               BT_ERR("running script failed");
+               ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh", NULL);
                __bt_core_set_status(BT_DEACTIVATED);
                return -1;
        }
 #else
-//     _bt_power_adapter(TRUE);
+       _bt_power_adapter(TRUE);
 #endif
 
        return 0;
@@ -273,16 +269,16 @@ int _bt_enable_adapter(void)
 int _bt_disable_adapter(void)
 {
        BT_INFO_C("Disable adapter");
-#ifdef __TIZEN_MOBILE__
+#if __TIZEN_MOBILE__
        __bt_core_set_status(BT_DEACTIVATING);
 
-       if (system("/usr/etc/bluetooth/bt-stack-down.sh &") < 0) {
-               BT_DBG("running script failed");
+       if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+               BT_ERR("running script failed");
                __bt_core_set_status(BT_ACTIVATED);
                return -1;
        }
 #else
-//     _bt_power_adapter(FALSE);
+       _bt_power_adapter(FALSE);
 #endif
        return 0;
 }
@@ -308,7 +304,7 @@ int _bt_enable_adapter_le(void)
                __bt_core_set_le_status(BT_LE_ACTIVATED);
        }
 #else
-//     _bt_power_adapter(TRUE);
+       _bt_power_adapter(TRUE);
 #endif
        return 0;
 }
@@ -324,7 +320,7 @@ int _bt_disable_adapter_le(void)
        if (status == BT_DEACTIVATED) {
                __bt_core_set_le_status(BT_LE_DEACTIVATING);
 
-                       if (system("/usr/etc/bluetooth/bt-stack-down.sh &") < 0) {
+               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
                        BT_ERR("running script failed");
                        __bt_core_set_le_status(BT_LE_ACTIVATED);
                        return -1;
@@ -332,7 +328,7 @@ int _bt_disable_adapter_le(void)
        }
        __bt_core_set_le_status(BT_LE_DEACTIVATED);
 #else
-//     _bt_power_adapter(FALSE);
+       _bt_power_adapter(FALSE);
 #endif
 
        BT_DBG("-");
index 4895a23..5208e71 100755 (executable)
@@ -304,7 +304,10 @@ static DBusHandlerResult __bt_core_event_filter(DBusConnection *conn,
                }
 
                if (strcasecmp(object_path, "/org/bluez/hci0") == 0) {
-                       _bt_core_adapter_removed_cb();
+#ifdef __TIZEN_MOBILE__
+               __bt_core_set_status(BT_DEACTIVATED);
+#endif
+                       _bt_core_terminate();
                }
        } else if (strcasecmp(member, "NameOwnerChanged") == 0) {
                char *name = NULL;
@@ -339,7 +342,6 @@ static DBusHandlerResult __bt_core_event_filter(DBusConnection *conn,
                        if (_bt_check_terminating_condition() == TRUE) {
                                _bt_disable_adapter();
                                _bt_disable_adapter_le();
-                               _bt_core_terminate();
                        }
                }
        }
index 4afda78..3c68e78 100755 (executable)
@@ -174,16 +174,13 @@ int main(void)
                goto fail;
        }
 
-
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = __bt_core_sigterm_handler;
        sigaction(SIGINT, &sa, NULL);
        sigaction(SIGTERM, &sa, NULL);
 
        g_timeout_add(500, (GSourceFunc)__bt_check_bt_core, NULL);
-
        main_loop = g_main_loop_new(NULL, FALSE);
-
        g_main_loop_run(main_loop);
 
 fail:
diff --git a/bt-core/bt_core.c b/bt-core/bt_core.c
deleted file mode 100644 (file)
index 70f80f9..0000000
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
- *
- * 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 <vconf.h>
-#include <vconf-keys.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
-#include <glib.h>
-
-#include "bt_core.h"
-#include "bt-internal-types.h"
-
-static GMainLoop *main_loop = NULL;
-static DBusGConnection *conn = NULL;
-
-#ifdef __TIZEN_MOBILE__
-typedef enum {
-       BT_DEACTIVATED,
-       BT_ACTIVATED,
-       BT_ACTIVATING,
-       BT_DEACTIVATING,
-} bt_status_t;
-
-static bt_status_t adapter_status = BT_DEACTIVATED;
-
-static void __bt_core_set_status(bt_status_t status)
-{
-       adapter_status = status;
-}
-
-static bt_status_t __bt_core_get_status(void)
-{
-       return adapter_status;
-}
-#endif
-
-static void __bt_core_terminate(void)
-{
-       if (main_loop) {
-               g_main_loop_quit(main_loop);
-       } else {
-               BT_DBG("Terminating bt-core daemon");
-               exit(0);
-       }
-}
-
-static gboolean bt_core_enable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_disable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_reset_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-#include "bt_core_glue.h"
-
-GType bt_core_get_type (void);
-
-
-G_DEFINE_TYPE(BtCore, bt_core, G_TYPE_OBJECT);
-
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_core_class_init (BtCoreClass *bt_core_class)
-{
-       dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(bt_core_class),
-                                       &dbus_glib_bt_core_object_info);
-}
-
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_core_init (BtCore *core)
-{
-}
-
-typedef enum {
-       BT_CORE_ERROR_REJECT,
-       BT_CORE_ERROR_CANCEL,
-       BT_CORE_ERROR_TIMEOUT,
-} BtCoreError;
-
-#define BT_CORE_ERROR (bt_core_error_quark())
-
-static GQuark bt_core_error_quark(void)
-{
-       static GQuark quark = 0;
-       if (!quark)
-               quark = g_quark_from_static_string("BtCore");
-
-       return quark;
-}
-
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-static GError *bt_core_error(BtCoreError error, const char *err_msg)
-{
-       return g_error_new(BT_CORE_ERROR, error, err_msg, NULL);
-}
-
-static DBusGProxy *_bt_get_connman_proxy(void)
-{
-       DBusGProxy *proxy;
-
-       if (conn == NULL) {
-               conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
-               retv_if(conn == NULL, NULL);
-       }
-
-       proxy = dbus_g_proxy_new_for_name(conn,
-                       CONNMAN_DBUS_NAME,
-                       CONNMAN_BLUETOOTH_TECHNOLOGY_PATH,
-                       CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE);
-       retv_if(proxy == NULL, NULL);
-
-       return proxy;
-}
-
-static int _bt_power_adapter(gboolean powered)
-{
-       GValue state = { 0 };
-       GError *error = NULL;
-       DBusGProxy *proxy;
-
-       proxy = _bt_get_connman_proxy();
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       g_value_init(&state, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&state, powered);
-
-       BT_DBG("set power property state: %d to connman", powered);
-
-       dbus_g_proxy_call(proxy, "SetProperty", &error,
-                               G_TYPE_STRING, "Powered",
-                               G_TYPE_VALUE, &state,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_ERR("Powered set err:[%s]", error->message);
-               g_error_free(error);
-               g_value_unset(&state);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static int __bt_enable_adapter(void)
-{
-       BT_DBG("");
-#ifdef __TIZEN_MOBILE__
-       int ret;
-
-       __bt_core_set_status(BT_ACTIVATING);
-
-       ret = system("/usr/etc/bluetooth/bt-stack-up.sh &");
-       if (ret < 0) {
-               BT_DBG("running script failed");
-               ret = system("/usr/etc/bluetooth/bt-dev-end.sh &");
-               __bt_core_set_status(BT_DEACTIVATED);
-               return -1;
-       }
-#else
-       _bt_power_adapter(TRUE);
-#endif
-       return 0;
-}
-
-static int __bt_disable_adapter(void)
-{
-       BT_DBG("");
-
-#ifdef __TIZEN_MOBILE__
-       __bt_core_set_status(BT_DEACTIVATING);
-
-       if (system("/usr/etc/bluetooth/bt-stack-down.sh &") < 0) {
-               BT_DBG("running script failed");
-               __bt_core_set_status(BT_ACTIVATED);
-               return -1;
-       }
-#else
-       _bt_power_adapter(FALSE);
-#endif
-       __bt_core_terminate();
-       return 0;
-}
-
-static gboolean bt_core_enable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
-{
-       char *sender = dbus_g_method_get_sender(context);
-       int ret;
-
-       if (sender == NULL)
-               return FALSE;
-
-       ret = __bt_enable_adapter();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "Activation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       return TRUE;
-}
-
-static gboolean bt_core_disable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
-{
-       char *sender = dbus_g_method_get_sender(context);
-       int ret;
-
-       if (sender == NULL)
-               return FALSE;
-
-       ret = __bt_disable_adapter();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "Deactivation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       return TRUE;
-}
-
-static int __bt_reset_adapter(void)
-{
-       /* Forcely terminate */
-       if (system("/usr/etc/bluetooth/bt-reset-env.sh &") < 0) {
-               BT_DBG("running script failed");
-       }
-       __bt_core_terminate();
-       return 0;
-}
-
-static gboolean bt_core_reset_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
-{
-       char *sender = dbus_g_method_get_sender(context);
-       int ret;
-
-       if (sender == NULL)
-               return FALSE;
-
-       ret = __bt_reset_adapter();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "Deactivation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       return TRUE;
-}
-
-static int __bt_core_get_object_path(DBusMessage *msg, char **path)
-{
-       DBusMessageIter item_iter;
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_OBJECT_PATH) {
-               BT_ERR("This is bad format dbus\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, path);
-
-       if (*path == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static int __bt_core_get_owner_info(DBusMessage *msg, char **name,
-                               char **previous, char **current)
-{
-       DBusMessageIter item_iter;
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, name);
-
-       if (*name == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
-
-       dbus_message_iter_next(&item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, previous);
-
-       if (*previous == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
-
-       dbus_message_iter_next(&item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, current);
-
-       if (*current == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static DBusHandlerResult __bt_core_event_filter(DBusConnection *conn,
-                                          DBusMessage *msg, void *data)
-{
-       char *object_path = NULL;
-       const char *member = dbus_message_get_member(msg);
-
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       if (member == NULL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       if (strcasecmp(member, "InterfacesAdded") == 0) {
-               if (__bt_core_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-#ifdef __TIZEN_MOBILE__
-               if (strcasecmp(object_path, "/org/bluez/hci0") == 0) {
-                       __bt_core_set_status(BT_ACTIVATED);
-               }
-#endif
-       } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
-               if (__bt_core_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-
-               if (strcasecmp(object_path, "/org/bluez/hci0") == 0) {
-#ifdef __TIZEN_MOBILE__
-                       __bt_core_set_status(BT_DEACTIVATED);
-#endif
-                       __bt_core_terminate();
-               }
-       } else if (strcasecmp(member, "NameOwnerChanged") == 0) {
-               char *name = NULL;
-               char *previous = NULL;
-               char *current = NULL;
-
-               if (__bt_core_get_owner_info(msg, &name, &previous, &current)) {
-                       BT_ERR("Fail to get the owner info");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-
-               if (*current != '\0')
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-               if (strcasecmp(name, "org.bluez") == 0) {
-                       BT_DBG("Bluetoothd is terminated");
-                       __bt_disable_adapter();
-                       __bt_core_terminate();
-               } else if (strcasecmp(name, "org.projectx.bt") == 0) {
-                       BT_DBG("bt-service is terminated abnormally");
-                       __bt_disable_adapter();
-               }
-       }
-
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static DBusGProxy *__bt_core_register_event_filter(DBusGConnection *g_conn,
-                                               BtCore *bt_core)
-{
-       DBusError dbus_error;
-       DBusConnection *conn;
-       DBusGProxy *proxy;
-       GError *err = NULL;
-       guint result = 0;
-
-       if (g_conn == NULL)
-               return NULL;
-
-       conn = dbus_g_connection_get_connection(g_conn);
-       if (conn == NULL)
-               return NULL;
-
-       proxy = dbus_g_proxy_new_for_name(g_conn, DBUS_SERVICE_DBUS,
-                               DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-       if (proxy == NULL) {
-               BT_ERR("proxy is NULL");
-               return NULL;
-       }
-
-       if (!dbus_g_proxy_call(proxy, "RequestName", &err, G_TYPE_STRING,
-                       BT_CORE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
-                       G_TYPE_UINT, &result, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("RequestName RPC failed[%s]\n", err->message);
-                       g_error_free(err);
-               }
-               g_object_unref(proxy);
-               return NULL;
-       }
-
-       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-               BT_ERR("Failed to get the primary well-known name.\n");
-               g_object_unref(proxy);
-               return NULL;
-       }
-
-       if (!dbus_connection_add_filter(conn, __bt_core_event_filter,
-                                       NULL, NULL)) {
-               BT_ERR("Fail to add filter");
-               g_object_unref(proxy);
-               return NULL;
-       }
-
-       dbus_error_init(&dbus_error);
-
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus'"
-                       ",member='NameOwnerChanged'",
-                       &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               g_object_unref(proxy);
-               return NULL;
-       }
-
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus.ObjectManager'"
-                       ",member='InterfacesAdded'",
-                       &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               g_object_unref(proxy);
-               return NULL;
-       }
-
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus.ObjectManager'"
-                       ",member='InterfacesRemoved'",
-                       &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               g_object_unref(proxy);
-               return NULL;
-       }
-
-       dbus_g_connection_register_g_object(g_conn, BT_CORE_PATH,
-                                       G_OBJECT(bt_core));
-
-       return proxy;
-}
-
-static void __bt_unregister_event_filter(DBusGConnection *g_conn,
-                                       BtCore *bt_core,
-                                       DBusGProxy *dbus_proxy)
-{
-       DBusConnection *conn;
-
-       if (g_conn == NULL ||
-            bt_core == NULL ||
-             dbus_proxy == NULL) {
-               BT_ERR("Invalid parameter");
-               return;
-       }
-
-       conn = dbus_g_connection_get_connection(g_conn);
-
-       dbus_connection_remove_filter(conn, __bt_core_event_filter, NULL);
-
-       dbus_g_connection_unregister_g_object(g_conn, G_OBJECT(bt_core));
-
-       g_object_unref(bt_core);
-       g_object_unref(dbus_proxy);
-}
-
-static void __bt_core_sigterm_handler(int signo)
-{
-       BT_DBG("Got the signal: %d", signo);
-
-       __bt_core_terminate();
-}
-
-int main(void)
-{
-       GError *error = NULL;
-       BtCore *bt_core;
-       DBusGProxy *dbus_proxy = NULL;
-       struct sigaction sa;
-
-       BT_DBG("+");
-
-       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-       if (error != NULL) {
-               BT_ERR("ERROR: Can't get on system bus [%s]", error->message);
-               g_error_free(error);
-               return FALSE;
-       }
-
-       bt_core = g_object_new(BT_CORE_TYPE, NULL);
-       if (bt_core == NULL) {
-               BT_ERR("bt_service is NULL");
-               goto fail;
-       }
-
-       dbus_proxy = __bt_core_register_event_filter(conn, bt_core);
-       if (!dbus_proxy) {
-               BT_ERR("__bt_core_register_event_filter failed");
-               g_object_unref(bt_core);
-               bt_core = NULL;
-               goto fail;
-       }
-
-       main_loop = g_main_loop_new(NULL, FALSE);
-
-       memset(&sa, 0, sizeof(sa));
-       sa.sa_handler = __bt_core_sigterm_handler;
-       sigaction(SIGINT, &sa, NULL);
-       sigaction(SIGTERM, &sa, NULL);
-
-       g_main_loop_run(main_loop);
-
-fail:
-       __bt_unregister_event_filter(conn, bt_core, dbus_proxy);
-
-       if (main_loop)
-               g_main_loop_unref(main_loop);
-
-       dbus_g_connection_unref(conn);
-
-       BT_DBG("-");
-       return FALSE;
-}
-
diff --git a/bt-core/bt_core.h b/bt-core/bt_core.h
deleted file mode 100644 (file)
index 4194b17..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
- *
- * 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_CORE_H_
-#define _BT_CORE_H_
-
-#include <sys/types.h>
-#include <dlog.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <glib.h>
-#include <glib-object.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#undef LOG_TAG
-#define LOG_TAG "BLUETOOTH_FRWK_CORE"
-
-#define BT_DBG(fmt, args...) \
-        SLOGD(fmt, ##args)
-#define BT_ERR(fmt, args...) \
-        SLOGE(fmt, ##args)
-
-#define retv_if(expr, val) \
-       do { \
-               if (expr) { \
-                       BT_ERR("(%s) return", #expr); \
-                       return (val); \
-               } \
-       } while (0)
-
-#define CONNMAN_DBUS_NAME "net.connman"
-#define CONNMAN_BLUETOOTH_TECHNOLOGY_PATH "/net/connman/technology/bluetooth"
-#define CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE "net.connman.Technology"
-
-#define BT_CORE_NAME "org.projectx.bt_core"
-#define BT_CORE_PATH "/org/projectx/bt_core"
-
-#define BT_CORE_TYPE (bt_core_get_type())
-
-typedef struct _BtCore
-{
-    GObject object;
-} BtCore;
-
-typedef struct _BtCoreClass
-{
-    GObjectClass object_class;
-} BtCoreClass;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /*_BT_CORE_H_*/
diff --git a/bt-core/bt_core.xml b/bt-core/bt_core.xml
deleted file mode 100644 (file)
index 40a7f37..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
-  <interface name="org.projectx.btcore">
-    <method name="EnableAdapter">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-    </method>
-       <method name="DisableAdapter">
-         <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-       </method>
-       <method name="ResetAdapter">
-         <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-       </method>
-  </interface>
-</node>
index 2c8e6e8..d129661 100755 (executable)
 extern "C" {
 #endif
 
+#define CONNMAN_DBUS_NAME "net.connman"
+#define CONNMAN_BLUETOOTH_TECHNOLOGY_PATH "/net/connman/technology/bluetooth"
+#define CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE "net.connman.Technology"
+
+#define BT_CORE_NAME "org.projectx.bt_core"
+#define BT_CORE_PATH "/org/projectx/bt_core"
+
 #define BT_CORE_TYPE (bt_core_get_type())
 
 typedef enum {
old mode 100644 (file)
new mode 100755 (executable)
index 162e9de..86edea7
@@ -144,5 +144,7 @@ ELSE ()
        INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
 ENDIF (TIZEN_WEARABLE)
 
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/system.d)
+
 
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
old mode 100644 (file)
new mode 100755 (executable)
index 1c490a5..03f609b
@@ -4,6 +4,7 @@
     <policy group="@TZ_SYS_USER_GROUP@">
         <allow own="org.projectx.bt"/>
         <allow own="org.projectx.bt_event"/>
+       <allow send_type="method_call"/>
     </policy>
     <policy at_console="true">
         <allow send_destination="org.projectx.bt"/>
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/bt-service/bt-popup.c b/bt-service/bt-popup.c
deleted file mode 100644 (file)
index 66a6995..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2013 Intel Corporation.
- *
- * 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 "bt-popup.h"
-
-static void
-__free_user_data(struct bt_popup_appdata *ad)
-{
-       if (ad->agent_proxy) {
-               g_object_unref(ad->agent_proxy);
-               ad->agent_proxy = NULL;
-       }
-       if (ad->obex_proxy) {
-               g_object_unref(ad->obex_proxy);
-               ad->obex_proxy = NULL;
-       }
-       g_free(ad);
-}
-
-static DBusGProxy*
-__bluetooth_create_agent_proxy(DBusGConnection *sys_conn, const char *path)
-{
-       return dbus_g_proxy_new_for_name (      sys_conn,
-                                               "org.projectx.bt",
-                                               path,
-                                               "org.bluez.Agent1");
-}
-
-static DBusGProxy*
-__bluetooth_create_obex_proxy(DBusGConnection *sys_conn)
-{
-       return dbus_g_proxy_new_for_name(       sys_conn,
-                                               "org.bluez.frwk_agent",
-                                               "/org/obex/ops_agent",
-                                               "org.openobex.Agent");
-}
-
-static void
-__gtk_pin_ok_cb(GtkWidget *widget, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(ad->agent_proxy,
-                                  "ReplyPinCode",
-                                  G_TYPE_UINT, BT_AGENT_ACCEPT,
-                                  G_TYPE_STRING, gtk_entry_get_text(GTK_ENTRY(ad->entry)),
-                                  G_TYPE_INVALID, G_TYPE_INVALID);
-
-       gtk_widget_destroy(GTK_WIDGET(ad->window));
-       __free_user_data(ad);
-}
-
-static void
-__gtk_pin_cancel_cb(GtkWidget *widget, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(ad->agent_proxy,
-                                  "ReplyPinCode",
-                                  G_TYPE_UINT, BT_AGENT_CANCEL,
-                                  G_TYPE_STRING, "",
-                                  G_TYPE_INVALID, G_TYPE_INVALID);
-
-       gtk_widget_destroy(GTK_WIDGET(ad->window));
-       __free_user_data(ad);
-}
-
-static void
-__gtk_passkey_ok_cb(GtkWidget *widget, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(ad->agent_proxy,
-                                  "ReplyPasskey",
-                                  G_TYPE_UINT, BT_AGENT_ACCEPT,
-                                  G_TYPE_STRING, gtk_entry_get_text(GTK_ENTRY(ad->entry)),
-                                  G_TYPE_INVALID, G_TYPE_INVALID);
-
-       gtk_widget_destroy(GTK_WIDGET(ad->window));
-       __free_user_data(ad);
-}
-
-static void
-__gtk_passkey_cancel_cb(GtkWidget *widget, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(ad->agent_proxy,
-                                  "ReplyPasskey",
-                                  G_TYPE_UINT, BT_AGENT_CANCEL,
-                                  G_TYPE_STRING, "",
-                                  G_TYPE_INVALID, G_TYPE_INVALID);
-
-       gtk_widget_destroy(GTK_WIDGET(ad->window));
-       __free_user_data(ad);
-}
-
-static void
-__notify_passkey_confirm_request_accept_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(     ad->agent_proxy, "ReplyConfirmation",
-                                       G_TYPE_UINT, BT_AGENT_ACCEPT,
-                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       notify_notification_close(n, NULL);
-}
-
-
-
-static void
-__notify_passkey_confirm_request_cancel_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(     ad->agent_proxy, "ReplyConfirmation",
-                                       G_TYPE_UINT, BT_AGENT_CANCEL,
-                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       notify_notification_close(n, NULL);
-}
-
-static void
-__notify_passkey_display_request_ok_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       /* Close the popup */
-       notify_notification_close(n, NULL);
-}
-
-static void
-__notify_passkey_display_request_cancel_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       bluetooth_cancel_bonding();
-
-       notify_notification_close(n, NULL);
-}
-
-static void
-__notify_push_authorize_request_accept_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(     ad->obex_proxy, "ReplyAuthorize",
-                                       G_TYPE_UINT, BT_AGENT_ACCEPT,
-                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       notify_notification_close(n, NULL);
-}
-
-static void
-__notify_push_authorize_request_cancel_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(     ad->obex_proxy, "ReplyAuthorize",
-                                       G_TYPE_UINT, BT_AGENT_CANCEL,
-                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       notify_notification_close(n, NULL);
-}
-
-static void
-__notify_authorize_request_accept_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(     ad->agent_proxy, "ReplyAuthorize",
-                                       G_TYPE_UINT, BT_AGENT_ACCEPT,
-                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       notify_notification_close(n, NULL);
-}
-
-static void
-__notify_authorize_request_cancel_cb(NotifyNotification *n, const char *action, struct bt_popup_appdata *ad)
-{
-       g_assert(ad != NULL);
-
-       dbus_g_proxy_call_no_reply(     ad->agent_proxy, "ReplyAuthorize",
-                                       G_TYPE_UINT, BT_AGENT_CANCEL,
-                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       notify_notification_close(n, NULL);
-}
-
-static GdkPixbuf*
-__create_pixbuf(const gchar * filename)
-{
-       GdkPixbuf *pixbuf;
-       GError *error = NULL;
-       pixbuf = gdk_pixbuf_new_from_file(filename, &error);
-       if(!pixbuf) {
-               BT_ERR("%s\n", error->message);
-               g_error_free(error);
-       }
-
-       return pixbuf;
-}
-
-static void
-__close_window(GtkWidget *widget, struct bt_popup_appdata *ad)
-{
-       gtk_widget_destroy(GTK_WIDGET(ad->window));
-}
-
-static int
-__draw_input_view(     const char *event_type,
-                       struct bt_popup_appdata *ad,
-                       char *title,
-                       char* body,
-                       void *ok_cb,
-                       void *cancel_cb)
-{
-
-       if ((!event_type) && strcasecmp(event_type, "pin-request") && strcasecmp(event_type, "passkey-request"))
-               return BT_FAILED;
-       GtkWidget *layout;
-       GtkWidget *text_wdgt;
-       GtkWidget *image;
-       GtkWidget *ok_bt;
-       GtkWidget *cancel_bt;
-
-       gtk_init(NULL, NULL);
-       ad->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_default_size(GTK_WINDOW(ad->window), 300, 100);
-       gtk_window_set_position(GTK_WINDOW(ad->window), GTK_WIN_POS_CENTER);
-       gtk_window_set_icon(GTK_WINDOW(ad->window), __create_pixbuf(NOTIFY_ICON));
-       gtk_window_set_title(GTK_WINDOW (ad->window), title);
-
-       layout = gtk_layout_new(NULL, NULL);
-       gtk_container_add(GTK_CONTAINER (ad->window), layout);
-       gtk_widget_show(layout);
-
-       image = gtk_image_new_from_file(NOTIFY_ICON);
-       gtk_layout_put(GTK_LAYOUT(layout), image, 0, 25);
-
-       text_wdgt = gtk_label_new(body);
-       gtk_layout_put(GTK_LAYOUT(layout), text_wdgt, 90, 0);
-
-       ad->entry = gtk_entry_new();
-
-       if(!strcasecmp(event_type, "pin-request"))
-               gtk_entry_set_max_length(GTK_ENTRY(ad->entry), BT_PIN_MLEN);
-       else if (!strcasecmp(event_type, "passkey-request"))
-               gtk_entry_set_max_length(GTK_ENTRY(ad->entry), BT_PK_MLEN);
-
-       gtk_layout_put(GTK_LAYOUT(layout), ad->entry, 90, 20);
-
-       ok_bt = gtk_button_new_with_label("Ok");
-       gtk_layout_put(GTK_LAYOUT(layout), ok_bt, 100, 50);
-       gtk_widget_set_size_request(ok_bt, 60, 35);
-
-       cancel_bt = gtk_button_new_with_label("Cancel");
-       gtk_layout_put(GTK_LAYOUT(layout), cancel_bt, 160, 50);
-       gtk_widget_set_size_request(cancel_bt, 60, 35);
-
-       g_signal_connect (ad->window, "destroy",  G_CALLBACK(__close_window), ad);
-       g_signal_connect(ok_bt, "clicked", G_CALLBACK(ok_cb), ad);
-       g_signal_connect(cancel_bt, "clicked", G_CALLBACK(cancel_cb), ad);
-
-       gtk_widget_show_all(ad->window);
-
-       return BT_SUCCESS;
-}
-
-static int
-__notify_send_popup(   struct bt_popup_appdata *ad,
-                       char *body,
-                       char *action1_name,
-                       NotifyActionCallback action1_cb,
-                       char *action2_name,
-                       NotifyActionCallback action2_cb)
-{
-       NotifyNotification *n = NULL;
-       GError *error = NULL;
-
-       n = notify_notification_new(    "Tizen Bluetooth",
-                                       body,
-                                       NOTIFY_ICON);
-       if (!n){
-               __free_user_data(ad);
-               BT_ERR("failed to create new notification\n");
-               return BT_FAILED;
-       }
-
-       notify_notification_set_timeout(n, NOTIFY_EXPIRES_DEFAULT);
-
-       if (action1_name && action1_cb)
-               notify_notification_add_action( n, "action1", action1_name,
-                                               (NotifyActionCallback)action1_cb,
-                                               ad,
-                                               (GFreeFunc) __free_user_data);
-       if (action2_name && action2_cb)
-               notify_notification_add_action( n, "action2", action2_name,
-                                               (NotifyActionCallback)action2_cb,
-                                               ad,
-                                               (GFreeFunc) __free_user_data);
-       if (!notify_notification_show(n, &error)){
-               __free_user_data(ad);
-               BT_ERR("failed to send notification : %s\n", error->message);
-               return BT_FAILED;
-       }
-       return BT_SUCCESS;
-}
-
-int
-notify_launch(bundle * user_data)
-{
-       int ret = 0;
-       struct bt_popup_appdata *ad;
-       ad = (struct bt_popup_appdata*) malloc ( sizeof(struct bt_popup_appdata));
-       memset(ad, 0x0, sizeof(struct bt_popup_appdata));
-       DBusGConnection *sys_conn;
-       const char *device_name = NULL;
-       const char *passkey = NULL;
-       const char *file = NULL;
-       const char *agent_path;
-       const char *event_type = NULL;
-       char *title = NULL;
-       char *body = NULL;
-
-       if (!notify_is_initted())
-               if (!notify_init("Tizen Bluetooth-frwk")){
-                       BT_ERR("notification init failed\n");
-                       free(ad);
-                       return BT_FAILED;
-               }
-
-       event_type = bundle_get_val(user_data, "event-type");
-
-       if(!strcasecmp(event_type, "pin-request")) {
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               title = g_strdup_printf("Bluetooth pairing request");
-               body = g_strdup_printf("Enter PIN to pair with %s (Try 0000 or 1234)", device_name);
-
-               ret = __draw_input_view(event_type, ad, title, body, &__gtk_pin_ok_cb, &__gtk_pin_cancel_cb);
-               g_free(body);
-               g_free(title);
-       } else if (!strcasecmp(event_type, "passkey-confirm-request")){
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               passkey = (gchar*) bundle_get_val(user_data, "passkey");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               body = g_strdup_printf("Confirm passkey is %s to pair with %s", passkey, device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Accept",
-                                               (NotifyActionCallback) __notify_passkey_confirm_request_accept_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_passkey_confirm_request_cancel_cb);
-               g_free(body);
-       }  else if (!strcasecmp(event_type, "passkey-request")) {
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               title = g_strdup_printf("Bluetooth pairing request");
-               body = g_strdup_printf("Enter PIN to pair with %s (Try 0000 or 1234)", device_name);
-
-               ret = __draw_input_view(event_type, ad, title, body, &__gtk_passkey_ok_cb, &__gtk_passkey_cancel_cb);
-               g_free(body);
-               g_free(title);
-       } else if (!strcasecmp(event_type, "passkey-display-request")) {
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               passkey = (gchar*) bundle_get_val(user_data, "passkey");
-
-               body = g_strdup_printf("Enter %s on %s to pair", passkey, device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Ok",
-                                               (NotifyActionCallback) __notify_passkey_display_request_ok_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_passkey_display_request_cancel_cb);
-               g_free(body);
-       } else if (!strcasecmp(event_type, "authorize-request")) {
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               body = g_strdup_printf("Allow %s to connect?", device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Accept",
-                                               (NotifyActionCallback) __notify_authorize_request_accept_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_authorize_request_cancel_cb);
-               g_free(body);
-       } else if (!strcasecmp(event_type, "app-confirm-request")) {
-               /* FIXME Seems to be an osp mechanism so not implemented to be confirmed */
-               BT_DBG("app-confirm-request even_type seems to be an osp mechanism so not implemented in gnome environment; to be confirmed\n");
-               ret = BT_FAILED;
-       } else if (!strcasecmp(event_type, "push-authorize-request")) {
-               file = (gchar*) bundle_get_val(user_data, "file");
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->obex_proxy = __bluetooth_create_obex_proxy(sys_conn);
-               if (!ad->obex_proxy){
-                       BT_ERR("create new obex_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               body = g_strdup_printf("Receive %s from %s?", file, device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Accept",
-                                               (NotifyActionCallback) __notify_push_authorize_request_accept_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_push_authorize_request_cancel_cb);
-               g_free(body);
-       } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
-               /* FIXME Seems to be an osp mechanism so not implemented to be confirmed*/
-               BT_DBG("confirm-overwrite-request even_type seems to be an osp mechanism so not implemented in gnome environment; to be confirmed\n");
-               ret = BT_FAILED;
-       } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               passkey = (gchar*) bundle_get_val(user_data, "passkey");
-
-               body = g_strdup_printf("Enter %s on %s to pair", passkey, device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Ok",
-                                               (NotifyActionCallback) __notify_passkey_display_request_ok_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_passkey_display_request_cancel_cb);
-               g_free(body);
-       } else if (!strcasecmp(event_type, "bt-information")) {
-               /* FIXME Seems to be an osp mechanism so not implemented to be confirmed */
-               BT_DBG("bt-information even_type seems to be an osp mechanism so not implemented in gnome environment; to be confirmed\n");
-               ret = BT_FAILED;
-       } else if (!strcasecmp(event_type, "exchange-request")) {
-               device_name = (gchar*) bundle_get_val(user_data, "device-name");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               body = g_strdup_printf("exchange-request from %s", device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Accept",
-                                               (NotifyActionCallback) __notify_authorize_request_accept_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_authorize_request_cancel_cb);
-               g_free(body);
-       } else if (!strcasecmp(event_type, "phonebook-request")) {
-               device_name = bundle_get_val(user_data, "device-name");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               body = g_strdup_printf("Allow %s phonebook access", device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Accept",
-                                               (NotifyActionCallback) __notify_authorize_request_accept_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_authorize_request_cancel_cb);
-               g_free(body);
-       } else if (!strcasecmp(event_type, "message-request")) {
-               device_name = bundle_get_val(user_data, "device-name");
-               agent_path = bundle_get_val(user_data, "agent-path");
-
-               sys_conn = _bt_get_system_gconn();
-               if (sys_conn == NULL) {
-                       BT_ERR("ERROR: Can't get on system bus");
-                       return BT_FAILED;
-               }
-
-               ad->agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path);
-               if (!ad->agent_proxy){
-                       BT_ERR("create new agent_proxy failed\n");
-                       return BT_FAILED;
-               }
-
-               body = g_strdup_printf("Allow %s to access messages?", device_name);
-
-               ret = __notify_send_popup(      ad,
-                                               body,
-                                               "Accept",
-                                               (NotifyActionCallback) __notify_authorize_request_accept_cb,
-                                               "Cancel",
-                                               (NotifyActionCallback) __notify_authorize_request_cancel_cb);
-               g_free(body);
-       } else {
-               ret = BT_FAILED;
-       }
-
-       return ret;
-}
index 6ec617c..9209020 100755 (executable)
@@ -103,8 +103,8 @@ static int __bt_bluez_request(int function_name,
                break;
        case BT_CHECK_ADAPTER: {
                int enabled = BT_ADAPTER_DISABLED;
-
                result = _bt_check_adapter(&enabled);
+               BT_DBG("_bt_check_adapter result is %d", result);
 
                g_array_append_vals(*out_param1, &enabled,
                                sizeof(int));
@@ -186,6 +186,7 @@ static int __bt_bluez_request(int function_name,
                break;
        }
        case BT_START_DISCOVERY:
+               BT_DBG("_bt_start_discovery ");
                result = _bt_start_discovery();
 
                break;
old mode 100644 (file)
new mode 100755 (executable)
index 094df55..8a31963
@@ -32,7 +32,7 @@
 #if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
 #endif
-#ifdef __TIZEN_MOBILE__
+#if __TIZEN_MOBILE__
 #include <aul.h>
 #endif
 #include <notification.h>
@@ -674,7 +674,7 @@ static void __launch_bt_service(int status, int run_type)
        bundle_add(kb, "status", status_val);
        bundle_add(kb, "run-type", run_type_val);
 
-       aul_launch_app("com.samsung.bluetooth", kb);
+       aul_launch_app("org.tizen.bluetooth", kb);
 
        bundle_free(kb);
 }
@@ -800,12 +800,13 @@ static void __bt_set_local_name(void)
        free(phone_name);
 }
 
-static int __bt_set_enabled(void)
+int __bt_set_enabled(void)
 {
        int adapter_status = BT_ADAPTER_DISABLED;
        int result = BLUETOOTH_ERROR_NONE;
 
        _bt_check_adapter(&adapter_status);
+       adapter_status = BT_ADAPTER_ENABLED;
 
        if (adapter_status == BT_ADAPTER_DISABLED) {
                BT_ERR("Bluetoothd is not running");
@@ -864,13 +865,17 @@ void _bt_set_disabled(int result)
 
        _bt_adapter_set_status(BT_DEACTIVATED);
 
+               /* Send disabled event */
+       _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
+                       DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+
+#if 0
        if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
                /* Send disabled event */
                _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
                                DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
        }
-
-       BT_INFO("Adapter disabled");
+#endif
 }
 
 static int __bt_set_le_enabled(void)
@@ -1022,6 +1027,41 @@ void _bt_service_unregister_vconf_handler(void)
 #endif
 }
 
+static int _bt_set_powered(gboolean is_powered)
+{
+       DBusGProxy *proxy;
+       GValue powered = { 0 };
+       GError *error = NULL;
+
+       if (__bt_is_factory_test_mode()) {
+               BT_ERR("Unable to set power in factory binary !!");
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       }
+
+       proxy = _bt_get_adapter_properties_proxy();
+
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       g_value_init(&powered, G_TYPE_BOOLEAN);
+       g_value_set_boolean(&powered, is_powered);
+
+       dbus_g_proxy_call(proxy, "Set", &error,
+                                                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
+                                                       G_TYPE_STRING, "Powered",
+                                                       G_TYPE_VALUE, &powered,
+                                                       G_TYPE_INVALID, G_TYPE_INVALID);
+
+       g_value_unset(&powered);
+       if (error != NULL) {
+               BT_ERR("Powered set err:\n [%s]", error->message);
+               g_error_free(error);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_INFO("Set powered [%d]", is_powered);
+       return BLUETOOTH_ERROR_NONE;
+}
+
 void _bt_handle_adapter_added(void)
 {
        BT_DBG("+");
@@ -1043,15 +1083,16 @@ void _bt_handle_adapter_added(void)
        adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
        if (!adapter_agent) {
                BT_ERR("Fail to register agent");
-               return;
+               //return;
        }
 
 #ifdef __TIZEN_MOBILE__
-       if (!aul_app_is_running("com.samsung.bluetooth"))
+       if (!aul_app_is_running("org.tizen.bluetooth"))
                        __launch_bt_service(0, 0);
 
        if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
                BT_ERR("Fail to register media player");
+
 #endif
 
        if (_bt_register_obex_server() != BLUETOOTH_ERROR_NONE)
@@ -1074,6 +1115,9 @@ void _bt_handle_adapter_added(void)
                __bt_set_le_enabled();
                _bt_adapter_set_le_status(BT_LE_ACTIVATED);
        }
+
+       BT_ERR("Activating BT ......");
+
        if (status == BT_ACTIVATING) {
                __bt_set_enabled();
                _bt_adapter_set_status(BT_ACTIVATED);
@@ -1241,7 +1285,6 @@ int _bt_enable_adapter(void)
                        return BLUETOOTH_ERROR_INTERNAL;
                }
        }
-
         if (dbus_g_proxy_call_with_timeout(proxy, "EnableAdapter",
                                        BT_ENABLE_TIMEOUT, &err,
                                        G_TYPE_INVALID,
@@ -1389,7 +1432,6 @@ int __bt_disable_cb(void)
 
 int _bt_disable_adapter(void)
 {
-       BT_DBG("+");
        int ret;
 
        if (_bt_adapter_get_status() == BT_DEACTIVATING) {
@@ -1408,6 +1450,7 @@ int _bt_disable_adapter(void)
        }
 
        __bt_disconnect_all();
+
        ret = __bt_disable_cb();
 
        BT_DBG("-");
@@ -1472,12 +1515,19 @@ int _bt_reset_adapter(void)
 
 int _bt_check_adapter(int *status)
 {
+       char *adapter_path = NULL;
+
        BT_CHECK_PARAMETER(status, return);
 
-       *status = 0; /* 0: disabled */
+       *status = BT_ADAPTER_DISABLED;
+
+       adapter_path = _bt_get_adapter_path();
+
 
-       if (_bt_get_adapter_power())
-               *status = 1; /* 1: enabled */
+       if (adapter_path != NULL)
+               *status = BT_ADAPTER_ENABLED;
+
+       g_free(adapter_path);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1510,6 +1560,11 @@ int _bt_enable_adapter_le(void)
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
+#if 0 // vconf key not found so commenting to resolve build issues.
+       if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
+               BT_ERR("Set vconf failed");
+#endif
+
        if (dbus_g_proxy_call_with_timeout(proxy, "EnableAdapterLe",
                                BT_ENABLE_TIMEOUT, &err,
                                G_TYPE_INVALID,
@@ -1570,6 +1625,10 @@ int _bt_disable_adapter_le(void)
        proxy = __bt_get_core_proxy();
        if (!proxy)
                return BLUETOOTH_ERROR_INTERNAL;
+#if 0 // vconf key not found so commenting to resolve build issues.
+       if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
+               BT_ERR("Set vconf failed");
+#endif
 
        if (dbus_g_proxy_call(proxy, "DisableAdapterLe", NULL,
                                       G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
@@ -1976,6 +2035,7 @@ int _bt_start_discovery(void)
        is_discovering = TRUE;
        cancel_by_user = FALSE;
        /* discovery status will be change in event */
+               BT_ERR("_bt_start_discovery 3");
 
        return BLUETOOTH_ERROR_NONE;
 }
diff --git a/bt-service/bt-service-agent-notification.c b/bt-service/bt-service-agent-notification.c
deleted file mode 100644 (file)
index d240d7a..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2013 Intel Corporation.
- *
- * 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 "bt-service-agent-notification.h"
-
-const char*
-error_to_string(notification_error_e error)
-{
-    if (error == NOTIFICATION_ERROR_INVALID_DATA)
-        return "NOTIFICATION_ERROR_INVALID_DATA";
-    if (error == NOTIFICATION_ERROR_NO_MEMORY)
-        return "NOTIFICATION_ERROR_NO_MEMORY";
-    if (error == NOTIFICATION_ERROR_FROM_DB)
-        return "NOTIFICATION_ERROR_FROM_DB";
-    if (error == NOTIFICATION_ERROR_ALREADY_EXIST_ID)
-        return "NOTIFICATION_ERROR_ALREADY_EXIST_ID";
-    if (error == NOTIFICATION_ERROR_FROM_DBUS)
-        return "NOTIFICATION_ERROR_FROM_DBUS";
-    if (error == NOTIFICATION_ERROR_NOT_EXIST_ID)
-        return "NOTIFICATION_ERROR_NOT_EXIST_ID";
-    if (error == NOTIFICATION_ERROR_IO)
-        return "NOTIFICATION_ERROR_IO";
-    if (error == NOTIFICATION_ERROR_SERVICE_NOT_READY)
-        return "NOTIFICATION_ERROR_SERVICE_NOT_READY";
-    if (error == NOTIFICATION_ERROR_NONE)
-        return "NOTIFICATION_ERROR_NONE";
-
-    return "UNHANDLED ERROR";
-}
-
-static int
-__notification_set_text(notification_h noti, char *title, char *body)
-{
-    notification_error_e err = NOTIFICATION_ERROR_NONE;
-
-    err = notification_set_text(    noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                                    title,
-                                    NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-    if (err != NOTIFICATION_ERROR_NONE) {
-        BT_ERR("Unable to set notification title: %s", error_to_string(err));
-        return BT_FAILED;
-    }
-
-    err = notification_set_text(    noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                    body,
-                                    NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-    if (err != NOTIFICATION_ERROR_NONE) {
-        BT_ERR("Unable to set notification content: %s", error_to_string(err));
-        return BT_FAILED;
-    }
-    return BT_SUCCESS;
-}
-
-int
-notification_launch(bundle * user_data)
-{
-    int ret = BT_SUCCESS;
-    const char *device_name = NULL;
-    const char *passkey = NULL;
-    const char *file = NULL;
-    const char *event_type = NULL;
-    char *title = NULL;
-    char *body = NULL;
-    notification_h notif;
-    notification_error_e err = NOTIFICATION_ERROR_NONE;
-
-    event_type = bundle_get_val(user_data, "event-type");
-    BT_DBG("create notification for '%s' event", event_type);
-
-    notif = notification_new(NOTIFICATION_TYPE_NOTI,
-                             NOTIFICATION_GROUP_ID_NONE,
-                             NOTIFICATION_PRIV_ID_NONE);
-    if (notif == NULL) {
-        BT_ERR("Failed to create notification: %s", error_to_string(err));
-        return BT_FAILED;
-    }
-
-    err = notification_set_pkgname(notif, "bluetooth-frwk-bt-service");
-    if (err != NOTIFICATION_ERROR_NONE) {
-        BT_ERR("Unable to set pkgname: %s", error_to_string(err));
-        return BT_FAILED;
-    }
-
-    err = notification_set_image(notif, NOTIFICATION_IMAGE_TYPE_ICON, BT_ICON);
-    if (err != NOTIFICATION_ERROR_NONE) {
-        BT_ERR("Unable to set notification icon path: %s", error_to_string(err));
-        return BT_FAILED;
-    }
-
-    /* 
-     * Pass the full bundle to the notification
-     */
-    err  = notification_set_execute_option(notif, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, user_data);
-    if (err != NOTIFICATION_ERROR_NONE) {
-        BT_ERR("Unable to set notification icon path: %s", error_to_string(err));
-        return BT_FAILED;
-    }
-
-    if(!strcasecmp(event_type, "pin-request")) {
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth pairing request");
-        body = g_strdup_printf("Enter PIN to pair with %s (Try 0000 or 1234)", device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "passkey-confirm-request")){
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-        passkey = (gchar*) bundle_get_val(user_data, "passkey");
-
-        title = g_strdup_printf("Bluetooth passkey confirm request");
-        body = g_strdup_printf("Confirm passkey is %s to pair with %s", passkey, device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    }  else if (!strcasecmp(event_type, "passkey-request")) {
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth pairing request");
-        body = g_strdup_printf("Enter PIN to pair with %s (Try 0000 or 1234)", device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "passkey-display-request")) {
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-        passkey = (gchar*) bundle_get_val(user_data, "passkey");
-
-        title = g_strdup_printf("Bluetooth passkey display request");
-        body = g_strdup_printf("Enter %s on %s to pair", passkey, device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "authorize-request")) {
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth authorize request");
-        body = g_strdup_printf("Allow %s to connect?", device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "app-confirm-request")) {
-        /* FIXME Seems to be an osp mechanism so not implemented to be confirmed */
-        BT_DBG("app-confirm-request even_type seems to be an osp mechanism so not implemented in gnome environment; to be confirmed");
-        ret = BT_FAILED;
-    } else if (!strcasecmp(event_type, "push-authorize-request")) {
-        file = (gchar*) bundle_get_val(user_data, "file");
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth push authorize request");
-        body = g_strdup_printf("Receive %s from %s?", file, device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "confirm-overwrite-request")) {
-        /* FIXME Seems to be an osp mechanism so not implemented to be confirmed*/
-        BT_DBG("confirm-overwrite-request even_type seems to be an osp mechanism so not implemented in gnome environment; to be confirmed");
-        ret = BT_FAILED;
-    } else if (!strcasecmp(event_type, "keyboard-passkey-request")) {
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-        passkey = (gchar*) bundle_get_val(user_data, "passkey");
-
-        title = g_strdup_printf("Bluetooth keyboard passkey request");
-        body = g_strdup_printf("Enter %s on %s to pair", passkey, device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "bt-information")) {
-        /* FIXME Seems to be an osp mechanism so not implemented to be confirmed */
-        BT_DBG("bt-information even_type seems to be an osp mechanism so not implemented in gnome environment; to be confirmed");
-        ret = BT_FAILED;
-    } else if (!strcasecmp(event_type, "exchange-request")) {
-        device_name = (gchar*) bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth exchange request");
-        body = g_strdup_printf("exchange-request from %s", device_name);
-
-        ret = __notification_set_text(notif, title, body);
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "phonebook-request")) {
-        device_name = bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth phonebook request");
-        body = g_strdup_printf("Allow %s phonebook access", device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else if (!strcasecmp(event_type, "message-request")) {
-        device_name = bundle_get_val(user_data, "device-name");
-
-        title = g_strdup_printf("Bluetooth keyboard passkey request");
-        body = g_strdup_printf("Allow %s to access messages?", device_name);
-
-        ret = __notification_set_text(notif, title, body);
-
-        g_free(title);
-        g_free(body);
-    } else {
-        ret = BT_FAILED;
-    }
-
-    err = notification_insert(notif, NULL);
-    if (err != NOTIFICATION_ERROR_NONE) {
-        BT_ERR("Unable to insert notification: %s\n", error_to_string(err));
-        return BT_FAILED;
-    }
-
-    return ret;
-}
-
old mode 100644 (file)
new mode 100755 (executable)
index 8955dae..4005434
@@ -201,6 +201,7 @@ gboolean _bt_get_adapter_power(void)
        GValue powered_v = { 0 };
        GError *err = NULL;
 
+       BT_DBG("_bt_check_adapter 4");
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, FALSE);
 
@@ -211,7 +212,7 @@ gboolean _bt_get_adapter_power(void)
                        G_TYPE_VALUE, &powered_v,
                        G_TYPE_INVALID)) {
                if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
+                       BT_ERR("Getting property failed \n: [%s]\n", err->message);
                        g_error_free(err);
                }
                return FALSE;
index 831c655..94cd20a 100755 (executable)
@@ -349,7 +349,6 @@ bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, NULL);
 
-
        object_path = _bt_get_device_object_path(address);
 
        retv_if(object_path == NULL, NULL);
@@ -613,7 +612,7 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 
        /* Terminate ALL system popup */
 #if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
-       syspopup_destroy_all();
+       //syspopup_destroy_all();
 #endif
 
        dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
@@ -676,6 +675,7 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 
                        result = BLUETOOTH_ERROR_INTERNAL;
                } else if (!strcmp(err->message, "Connection Timeout")) {
+                       BT_INFO("pairing request timeout");
                        /* Pairing request timeout */
                        result = BLUETOOTH_ERROR_TIMEOUT;
                } else if (!strcmp(err->message, "Authentication Timeout")) {
@@ -686,12 +686,14 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                        result = BLUETOOTH_ERROR_PARING_FAILED;
                }
        }
-
+#if 0
        if (result == BLUETOOTH_ERROR_PARING_FAILED ||
                        result == BLUETOOTH_ERROR_AUTHENTICATION_FAILED ||
                        result == BLUETOOTH_ERROR_TIMEOUT ||
                        result == BLUETOOTH_ERROR_HOST_DOWN) {
-               bonding_info->result = result;
+
+                       BT_INFO("result error %d", result);
+                       bonding_info->result = result;
 #ifdef TIZEN_WEARABLE
                __bt_launch_unable_to_pairing_syspopup(result);
 #endif
@@ -699,7 +701,7 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 
        g_object_unref(proxy);
        bonding_info->device_proxy = NULL;
-
+#endif
        if (result != BLUETOOTH_ERROR_NONE)
                goto dbus_return;
 
@@ -728,6 +730,7 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
        }
 
 dbus_return:
+
        if (req_info->context == NULL)
                goto done;
 
@@ -738,8 +741,10 @@ dbus_return:
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        bonding_info->addr);
 
+#if 0
        if (_bt_adapter_get_status() != BT_ACTIVATED)
                result = BLUETOOTH_ERROR_NOT_IN_OPERATION;
+#endif
 
        g_array_append_vals(out_param1, &dev_info,
                                sizeof(bluetooth_device_info_t));
@@ -751,12 +756,14 @@ dbus_return:
        g_array_free(out_param2, TRUE);
 
        _bt_delete_request_list(req_info->req_id);
+
 done:
        if (err)
                g_error_free(err);
 
+#if 0
        _bt_agent_set_canceled(FALSE);
-
+#endif
 
        g_free(bonding_info->addr);
        g_free(bonding_info);
diff --git a/bt-service/bt-service-device.c.orig b/bt-service/bt-service-device.c.orig
deleted file mode 100644 (file)
index ba8b1fa..0000000
+++ /dev/null
@@ -1,1338 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
- *
- * 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 <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
-#include <glib.h>
-#include <dlog.h>
-#include <string.h>
-#include <syspopup_caller.h>
-
-#include "bluetooth-api.h"
-#include "bt-internal-types.h"
-
-#include "bt-service-common.h"
-#include "bt-service-event.h"
-#include "bt-service-device.h"
-#include "bt-service-rfcomm-client.h"
-#include "bt-service-util.h"
-#include "bt-service-agent.h"
-
-typedef struct {
-       int req_id;
-       char *addr;
-       gboolean is_autopair;
-       DBusGProxy *device_proxy;
-       DBusGProxy *adapter_proxy;
-} bt_funcion_data_t;
-
-gboolean is_deivce_creating;
-bt_funcion_data_t *bonding_info;
-bt_funcion_data_t *searching_info;
-
-/* This HID Mouse does not support pairing precedure. need to skip it. */
-#define SMB_MOUSE_LAP_ADDR "00:12:A1"
-
-static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                                    gpointer user_data);
-
-
-gboolean _bt_is_device_creating(void)
-{
-       return is_deivce_creating;
-}
-
-void _bt_set_autopair_status_in_bonding_info(gboolean is_autopair)
-{
-       ret_if(bonding_info == NULL);
-       bonding_info->is_autopair = is_autopair;
-}
-
-void _bt_device_path_to_address(const char *device_path,
-                                       char *device_address)
-{
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       char *dev_addr;
-       char *pos;
-
-       ret_if(device_path == NULL);
-       ret_if(device_address == NULL);
-
-       dev_addr = strstr(device_path, "dev_");
-       ret_if(dev_addr == 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);
-}
-
-void __bt_cancel_search_service_done(void)
-{
-       int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-       request_info_t *req_info;
-       bluetooth_device_info_t dev_info;
-       GArray *out_param1;
-       GArray *out_param2;
-
-       ret_if(searching_info == NULL);
-
-       req_info = _bt_get_request_info(searching_info->req_id);
-       if (req_info == NULL) {
-               BT_ERR("req_info == NULL");
-               goto done;
-       }
-
-       if (req_info->context == NULL)
-               goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       searching_info->addr);
-
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
-       _bt_delete_request_list(req_info->req_id);
-
-done:
-       if (searching_info->device_proxy)
-               g_object_unref(searching_info->device_proxy);
-
-       if (searching_info->adapter_proxy)
-               g_object_unref(searching_info->adapter_proxy);
-
-       g_free(searching_info->addr);
-       g_free(searching_info);
-       searching_info = NULL;
-}
-
-static void __bt_get_uuids(GValue *value, bt_remote_dev_info_t *info)
-{
-       int i = 0;
-       char **uuid_value;
-
-       ret_if(value == NULL);
-       ret_if(info == NULL);
-
-       info->uuid_count = 0;
-
-       uuid_value = g_value_get_boxed(value);
-       ret_if(uuid_value == NULL);
-
-       while (uuid_value[i]) {
-               i++;
-       }
-       ret_if(i == 0);
-
-       info->uuid_count = i;
-
-       info->uuids = g_new0(char *, info->uuid_count + 1);
-
-       for (i = 0; uuid_value[i] != NULL; i++) {
-               info->uuids[i] = g_strdup(uuid_value[i]);
-       }
-}
-
-bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
-{
-       bt_remote_dev_info_t *dev_info;
-       char *object_path = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy;
-       GHashTable *hash = NULL;
-       GValue *value;
-       const gchar *name;
-       DBusGConnection *conn;
-
-       retv_if(address == NULL, NULL);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, NULL);
-
-       object_path = _bt_get_device_object_path(address);
-
-       retv_if(object_path == NULL, NULL);
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               BT_ERR("conn == NULL");
-               g_free(object_path);
-               return NULL;
-       }
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_PROPERTIES_INTERFACE);
-       g_free(object_path);
-       retv_if(device_proxy == NULL, NULL);
-
-       dbus_g_proxy_call(device_proxy, "GetAll", NULL,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-
-       g_object_unref(device_proxy);
-
-       dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
-
-       if (hash != NULL) {
-               value = g_hash_table_lookup(hash, "Alias");
-               name = value ? g_value_get_string(value) : NULL;
-
-               if (name != NULL)
-                       BT_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");
-               dev_info->class = value ? g_value_get_uint(value) : 0;
-
-               value = g_hash_table_lookup(hash, "Connected");
-               dev_info->connected = value ? g_value_get_boolean(value) : FALSE;
-
-               value = g_hash_table_lookup(hash, "Trusted");
-               dev_info->trust = value ? g_value_get_boolean(value) : FALSE;
-
-               value = g_hash_table_lookup(hash, "RSSI");
-               dev_info->rssi = value ? g_value_get_int(value) : 0;
-
-               value = g_hash_table_lookup(hash, "UUIDs");
-               __bt_get_uuids(value, dev_info);
-
-               dev_info->address = g_strdup(address);
-               dev_info->name = g_strdup(name);
-
-               value = g_hash_table_lookup(hash, "Paired");
-               dev_info->paired = value ? g_value_get_boolean(value) : FALSE;
-
-               g_hash_table_destroy(hash);
-       } else {
-               BT_ERR("Hash is NULL\n");
-               g_free(dev_info);
-               dev_info = NULL;
-       }
-
-       return dev_info;
-}
-
-static gboolean __ignore_auto_pairing_request(const char *address)
-{
-       gchar *buffer;
-       char **lines;
-       int i;
-       char lap_address[BT_LOWER_ADDRESS_LENGTH + 1] = {0,};
-       char *temp_buffer;
-       FILE *fp;
-       long size;
-       size_t result;
-
-       BT_DBG("+\n");
-
-       if (address == NULL)
-               return FALSE;
-
-       /* Get the LAP(Lower Address part) */
-       /* User BT_LOWER_ADDRESS_LENGTH+1 for lap_address to accomodate
-            a "," */
-       snprintf(lap_address, sizeof(lap_address), ",%s", address);
-
-       fp = fopen(BT_AGENT_AUTO_PAIR_BLACKLIST_FILE, "r");
-
-       if (fp == NULL) {
-               BT_DBG("fopen failed \n");
-               return FALSE;
-       }
-
-       fseek(fp, 0, SEEK_END);
-       size = ftell(fp);
-       rewind(fp);
-
-       if (size < 0) {
-               BT_DBG("Get file size failed \n");
-               fclose(fp);
-               return FALSE;
-       }
-
-       buffer = g_malloc0(sizeof(char) * size);
-       result = fread((char *)buffer, 1, size, fp);
-       fclose(fp);
-       if (result != size) {
-               BT_DBG("Read Error\n");
-               g_free(buffer);
-               return FALSE;
-       }
-
-       BT_DBG("Buffer = %s\n", buffer);
-
-       lines = g_strsplit_set(buffer, BT_AGENT_NEW_LINE, 0);
-       g_free(buffer);
-
-       if (lines == NULL)
-               return FALSE;
-
-       /* Write the data and insert new device data */
-       for (i = 0; lines[i] != NULL; i++) {
-               if (g_str_has_prefix(lines[i], "AddressBlacklist")) {
-                       temp_buffer = g_strconcat(lines[i], lap_address, NULL);
-                       g_free(lines[i]);
-                       lines[i] = temp_buffer;
-               }
-       }
-       buffer = g_strjoinv(BT_AGENT_NEW_LINE, lines);
-       g_strfreev(lines);
-
-       fp = fopen(BT_AGENT_AUTO_PAIR_BLACKLIST_FILE, "w");
-
-       if (fp == NULL) {
-               BT_DBG("fopen failed \n");
-               g_free(buffer);
-               return FALSE;
-       }
-
-       BT_DBG("Buffer = %s\n", buffer);
-       fwrite(buffer, 1, strlen(buffer), fp);
-       fclose(fp);
-
-       g_free(buffer);
-
-       BT_DBG("-\n");
-
-       return FALSE;
-}
-
-static int __bt_retry_bond(void)
-{
-       DBusGProxy *device_proxy;
-       char *device_path;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(bonding_info, return);
-       BT_CHECK_PARAMETER(bonding_info->addr, return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       device_path = _bt_get_device_object_path(bonding_info->addr);
-
-       if (device_path == NULL) {
-               BT_ERR("No searched device");
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-       }
-
-       if (bonding_info->device_proxy) {
-               device_proxy = bonding_info->device_proxy;
-       } else  {
-               device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_DEVICE_INTERFACE);
-       }
-
-       g_free(device_path);
-       retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       is_deivce_creating = TRUE;
-       bonding_info->device_proxy = device_proxy;
-
-       if (!dbus_g_proxy_begin_call_with_timeout(device_proxy, "Pair",
-                               (DBusGProxyCallNotify) __bt_bond_device_cb,
-                               NULL, NULL, BT_MAX_DBUS_TIMEOUT,
-                               G_TYPE_INVALID,
-                               G_TYPE_INVALID)) {
-               BT_ERR("Pair call fail");
-               is_deivce_creating = FALSE;
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-
-static int __bt_remove_and_bond(void)
-{
-       DBusGProxy *adapter_proxy;
-       GError *err = NULL;
-       char *device_path = NULL;
-
-       BT_CHECK_PARAMETER(bonding_info, return);
-       BT_CHECK_PARAMETER(bonding_info->addr, return);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       device_path = _bt_get_device_object_path(bonding_info->addr);
-
-       retv_if (device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(adapter_proxy, "RemoveDevice",
-                         &err, DBUS_TYPE_G_OBJECT_PATH, device_path,
-                         G_TYPE_INVALID, G_TYPE_INVALID);
-       g_free(device_path);
-       if (err != NULL) {
-               BT_ERR("RemoveDevice Fail: %s", err->message);
-               g_error_free(err);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return __bt_retry_bond();
-}
-
-static int __bt_cancel_and_bond(void)
-{
-       BT_CHECK_PARAMETER(bonding_info, return);
-       BT_CHECK_PARAMETER(bonding_info->device_proxy, return);
-
-       dbus_g_proxy_call_no_reply(bonding_info->device_proxy,
-                               "CancelPairing",
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       return __bt_retry_bond();
-}
-
-
-static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                                    gpointer user_data)
-{
-       int result = BLUETOOTH_ERROR_NONE;
-       GError *err = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
-       request_info_t *req_info;
-       bluetooth_device_info_t dev_info;
-       bt_remote_dev_info_t *remote_dev_info;
-
-       /* Terminate ALL system popup */
-       syspopup_destroy_all();
-
-       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
-
-       g_object_unref(proxy);
-
-       is_deivce_creating = FALSE;
-
-       if (bonding_info == NULL) {
-               /* Send reply */
-               BT_ERR("bonding_info == NULL");
-               if (err)
-                       g_error_free(err);
-               return;
-       }
-
-       bonding_info->device_proxy = NULL;
-
-       req_info = _bt_get_request_info(bonding_info->req_id);
-       if (req_info == NULL) {
-               BT_ERR("req_info == NULL");
-               goto done;
-       }
-
-       if (err != NULL) {
-               BT_ERR("Error occured in Pair [%s]", err->message);
-
-               if (!strcmp(err->message, "Already Exists")) {
-                       BT_DBG("Existing Bond, remove and retry");
-                       ret_if(__bt_remove_and_bond() == BLUETOOTH_ERROR_NONE);
-
-                       result = BLUETOOTH_ERROR_PARING_FAILED;
-               } else if (!strcmp(err->message, "Authentication Rejected")) {
-                       result = BLUETOOTH_ERROR_ACCESS_DENIED;
-//             } else if (_bt_agent_is_canceled(bonding_info->agent) ||
-//                     !strcmp(err->message, "Authentication Canceled")) {
-//                     result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-               } else if (!strcmp(err->message, "In Progress")) {
-                       BT_DBG("Bond in progress, cancel and retry");
-                       ret_if(__bt_cancel_and_bond() == BLUETOOTH_ERROR_NONE);
-
-                       result = BLUETOOTH_ERROR_PARING_FAILED;
-               } else if (!strcmp(err->message, "Authentication Failed")) {
-                       if (bonding_info->is_autopair == TRUE) {
-                               _bt_set_autopair_status_in_bonding_info(FALSE);
-                               __ignore_auto_pairing_request(bonding_info->addr);
-                       }
-                       result = BLUETOOTH_ERROR_AUTHENTICATION_FAILED;
-               } 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.
-                       */
-                       result = BLUETOOTH_ERROR_HOST_DOWN;
-               } else if (!strcmp(err->message, BT_TIMEOUT_MESSAGE)) {
-                       dbus_g_proxy_call(proxy, "CancelDeviceCreation", NULL,
-                                          G_TYPE_STRING, bonding_info->addr,
-                                          G_TYPE_INVALID, G_TYPE_INVALID);
-
-                       result = BLUETOOTH_ERROR_TIMEOUT;
-               } else {
-                       result = BLUETOOTH_ERROR_PARING_FAILED;
-               }
-       }
-
-       if (result != BLUETOOTH_ERROR_NONE)
-               goto dbus_return;
-
-       remote_dev_info = _bt_get_remote_device_info(bonding_info->addr);
-
-       /* Send the event to application */
-       if (remote_dev_info != NULL) {
-               _bt_send_event(BT_ADAPTER_EVENT,
-                       BLUETOOTH_EVENT_BONDING_FINISHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &bonding_info->addr,
-                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                       DBUS_TYPE_INVALID);
-
-               _bt_free_device_info(remote_dev_info);
-       }
-
-dbus_return:
-       if (req_info->context == NULL)
-               goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       bonding_info->addr);
-
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
-       _bt_delete_request_list(req_info->req_id);
-done:
-       if (err)
-               g_error_free(err);
-
-       g_free(bonding_info->addr);
-       g_free(bonding_info);
-       bonding_info = NULL;
-
-}
-
-int _bt_bond_device(int request_id,
-               bluetooth_device_address_t *device_address,
-               GArray **out_param1)
-{
-       DBusGProxy *proxy;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       bluetooth_device_info_t dev_info;
-       DBusGConnection *conn;
-       char *device_path = NULL;
-
-       BT_CHECK_PARAMETER(device_address, return);
-
-       if (bonding_info) {
-               BT_ERR("Bonding in progress");
-               return BLUETOOTH_ERROR_DEVICE_BUSY;
-       }
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       device_path = _bt_get_device_object_path(address);
-
-       if (device_path == NULL) {
-               BT_ERR("No searched device");
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-       }
-
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_DEVICE_INTERFACE);
-
-       g_free(device_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       bonding_info = g_malloc0(sizeof(bt_funcion_data_t));
-       bonding_info->addr = g_strdup(address);
-       bonding_info->req_id = request_id;
-       bonding_info->device_proxy = proxy;
-
-       is_deivce_creating = TRUE;
-
-       if (!dbus_g_proxy_begin_call_with_timeout(proxy, "Pair",
-                               (DBusGProxyCallNotify) __bt_bond_device_cb,
-                               NULL, NULL, BT_MAX_DBUS_TIMEOUT,
-                               G_TYPE_INVALID,
-                               G_TYPE_INVALID)) {
-               BT_ERR("Pair call fail");
-               g_object_unref(proxy);
-               goto fail;
-       }
-
-
-/* To Do: We need to check if we can pair the specific device using 'pair' API of bluez 5.x */
-#if 0
-       if (!strncmp(address, SMB_MOUSE_LAP_ADDR, strlen(SMB_MOUSE_LAP_ADDR))) {
-               bluetooth_device_address_t device_addr = { {0} };
-               BT_ERR("This device don't support pairing. So skip pairing.");
-               if (!dbus_g_proxy_begin_call(proxy, "CreateDevice",
-                               (DBusGProxyCallNotify)__bt_bond_device_cb,
-                               NULL, NULL,
-                               G_TYPE_STRING, device_addr,
-                               G_TYPE_INVALID)) {
-                       BT_ERR("CreateDevice failed");
-                       goto fail;
-               }
-
-               _bt_convert_addr_string_to_type(device_addr.addr, address);
-               if (_bt_set_authorization(&device_addr, TRUE))
-                       BT_ERR("_bt_set_authorization failed [%s]", address);
-
-       } else {
-               if (!dbus_g_proxy_begin_call_with_timeout(proxy, "CreatePairedDevice",
-                                       (DBusGProxyCallNotify) __bt_bond_device_cb,
-                                       NULL, NULL, BT_MAX_DBUS_TIMEOUT,
-                                       G_TYPE_STRING, address,
-                                       DBUS_TYPE_G_OBJECT_PATH, BT_DEVICE_AGENT_PATH,
-                                       G_TYPE_STRING, "DisplayYesNo",
-                                       G_TYPE_INVALID)) {
-                       BT_ERR("CreatePairedDevice call fail");
-                       goto fail;
-               }
-       }
-#endif
-
-       return BLUETOOTH_ERROR_NONE;
-fail:
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       bonding_info->addr);
-
-       g_array_append_vals(*out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-
-       is_deivce_creating = FALSE;
-
-       g_free(bonding_info->addr);
-       g_free(bonding_info);
-       bonding_info = NULL;
-
-       return BLUETOOTH_ERROR_INTERNAL;
-}
-
-int _bt_cancel_bonding(void)
-{
-       retv_if(bonding_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);
-       retv_if(bonding_info->device_proxy == NULL,
-                               BLUETOOTH_ERROR_NOT_IN_OPERATION);
-
-       dbus_g_proxy_call_no_reply(bonding_info->device_proxy,
-                               "CancelPairing",
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static void __bt_unbond_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                               gpointer user_data)
-{
-       GError *err = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
-       int result = BLUETOOTH_ERROR_NONE;
-       bt_funcion_data_t *unbonding_info;
-       bluetooth_device_info_t dev_info;
-       request_info_t *req_info;
-
-       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
-
-       unbonding_info = user_data;
-
-       if (unbonding_info == NULL) {
-               /* Send reply */
-               BT_ERR("unbonding_info == NULL");
-               goto done;
-       }
-
-       req_info = _bt_get_request_info(unbonding_info->req_id);
-       if (req_info == NULL) {
-               BT_ERR("req_info == NULL");
-               goto done;
-       }
-
-       if (err != NULL) {
-               BT_ERR("Error occured in RemoveBonding [%s]\n", err->message);
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto dbus_return;
-       }
-
-dbus_return:
-       if (req_info->context == NULL)
-               goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       unbonding_info->addr);
-
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       _bt_delete_request_list(req_info->req_id);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
-done:
-       if (err)
-               g_error_free(err);
-
-       if (unbonding_info) {
-               g_free(unbonding_info->addr);
-               g_free(unbonding_info);
-       }
-}
-
-int _bt_unbond_device(int request_id,
-                       bluetooth_device_address_t *device_address,
-                       GArray **out_param1)
-{
-       char *device_path = NULL;
-       bt_funcion_data_t *unbonding_info;
-       DBusGProxy *adapter_proxy;
-       int result = BLUETOOTH_ERROR_INTERNAL;
-       bluetooth_device_info_t dev_info;
-
-       BT_CHECK_PARAMETER(device_address, return);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       /* allocate user data so that it can be retrieved in callback */
-       unbonding_info = g_malloc0(sizeof(bt_funcion_data_t));
-       unbonding_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
-       unbonding_info->req_id = request_id;
-
-       _bt_convert_addr_type_to_string(unbonding_info->addr,
-                                       device_address->addr);
-
-       device_path = _bt_get_device_object_path(unbonding_info->addr);
-
-       if (device_path == NULL) {
-               BT_ERR("No paired device");
-               result = BLUETOOTH_ERROR_NOT_PAIRED;
-               goto fail;
-       }
-
-       if (!dbus_g_proxy_begin_call(adapter_proxy, "RemoveDevice",
-                               (DBusGProxyCallNotify) __bt_unbond_cb,
-                               (gpointer)unbonding_info, NULL,
-                               DBUS_TYPE_G_OBJECT_PATH, device_path,
-                               G_TYPE_INVALID)) {
-               BT_ERR("RemoveBonding begin failed\n");
-               goto fail;
-       }
-       g_free(device_path);
-       return BLUETOOTH_ERROR_NONE;
-
-fail:
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       unbonding_info->addr);
-
-       g_array_append_vals(*out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_free(device_path);
-       g_free(unbonding_info->addr);
-       g_free(unbonding_info);
-       return result;
-}
-
-static void __bt_discover_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                               gpointer user_data)
-{
-       GError *err = NULL;
-       GHashTable *hash = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
-       GValue uuid_v = { 0 };
-       int result = BLUETOOTH_ERROR_NONE;
-       bluetooth_device_info_t dev_info;
-       bt_remote_dev_info_t *remote_dev_info;
-       request_info_t *req_info;
-
-       dbus_g_proxy_end_call(proxy, call, &err,
-                             G_TYPE_VALUE, &uuid_v,
-                             G_TYPE_INVALID);
-
-       g_object_unref(proxy);
-
-       if (searching_info == NULL) {
-               /* Send reply */
-               BT_ERR("searching_info == NULL");
-               goto done;
-       }
-
-       req_info = _bt_get_request_info(searching_info->req_id);
-       if (req_info == NULL) {
-               BT_ERR("req_info == NULL");
-               goto done;
-       }
-
-       if (err != NULL) {
-               BT_ERR("Error occured in Proxy call [%s]\n", err->message);
-
-               if (!strcmp("Operation canceled", err->message)) {
-                       result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-               } else if (!strcmp("In Progress", err->message)) {
-                       result = BLUETOOTH_ERROR_IN_PROGRESS;
-               } else if (!strcmp("Host is down", err->message)) {
-                       result = BLUETOOTH_ERROR_HOST_DOWN;
-               } else {
-                       result = BLUETOOTH_ERROR_CONNECTION_ERROR;
-               }
-
-               if (result == BLUETOOTH_ERROR_HOST_DOWN ||
-                    result == BLUETOOTH_ERROR_CONNECTION_ERROR) {
-                       remote_dev_info = _bt_get_remote_device_info(searching_info->addr);
-                       if (remote_dev_info && remote_dev_info->uuids != NULL &&
-                            remote_dev_info->uuid_count > 0) {
-                               result = BLUETOOTH_ERROR_NONE;
-                               goto event;
-                       }
-                       _bt_free_device_info(remote_dev_info);
-               }
-               goto dbus_return;
-       }
-
-       remote_dev_info = _bt_get_remote_device_info(searching_info->addr);
-
-event:
-       /* Send the event to application */
-       if (remote_dev_info != NULL) {
-               _bt_send_event(BT_ADAPTER_EVENT,
-                       BLUETOOTH_EVENT_SERVICE_SEARCHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &searching_info->addr,
-                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                       DBUS_TYPE_INVALID);
-
-               _bt_free_device_info(remote_dev_info);
-       }
-
-dbus_return:
-       if (req_info->context == NULL)
-               goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       searching_info->addr);
-
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
-       _bt_delete_request_list(req_info->req_id);
-done:
-       if (err)
-               g_error_free(err);
-
-       g_hash_table_destroy(hash);
-
-       if (searching_info) {
-               g_free(searching_info->addr);
-               g_free(searching_info);
-               searching_info = NULL;
-       }
-}
-
-static void __bt_create_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                               gpointer user_data)
-{
-       GError *err = NULL;
-       char *device_path = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
-       int result = BLUETOOTH_ERROR_NONE;
-       bluetooth_device_info_t dev_info;
-       bt_remote_dev_info_t *remote_dev_info;
-       request_info_t *req_info;
-
-       is_deivce_creating = FALSE;
-
-       dbus_g_proxy_end_call(proxy, call, &err,
-                       DBUS_TYPE_G_OBJECT_PATH, &device_path,
-                       G_TYPE_INVALID);
-       g_free(device_path);
-       if (searching_info == NULL) {
-               /* Send reply */
-               BT_ERR("searching_info == NULL");
-               goto done;
-       }
-
-       req_info = _bt_get_request_info(searching_info->req_id);
-       if (req_info == NULL) {
-               BT_ERR("req_info == NULL");
-               goto done;
-       }
-
-       if (err != NULL) {
-               BT_ERR("Error occured in Proxy call [%s]\n", err->message);
-               result = BLUETOOTH_ERROR_CONNECTION_ERROR;
-               goto dbus_return;
-       }
-
-       remote_dev_info = _bt_get_remote_device_info(searching_info->addr);
-
-       /* Send the event to application */
-       if (remote_dev_info != NULL) {
-               _bt_send_event(BT_ADAPTER_EVENT,
-                       BLUETOOTH_EVENT_SERVICE_SEARCHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &searching_info->addr,
-                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                       DBUS_TYPE_INVALID);
-
-               _bt_free_device_info(remote_dev_info);
-       }
-
-dbus_return:
-       if (req_info->context == NULL)
-               goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-       _bt_convert_addr_string_to_type(dev_info.device_address.addr,
-                                       searching_info->addr);
-
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
-       _bt_delete_request_list(req_info->req_id);
-done:
-       if (err)
-               g_error_free(err);
-
-       if (searching_info) {
-               g_free(searching_info->addr);
-               g_free(searching_info);
-               searching_info = NULL;
-       }
-}
-
-int _bt_search_device(int request_id,
-                       bluetooth_device_address_t *device_address)
-{
-       char *device_path = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy = NULL;
-       DBusGConnection *conn;
-       int result = BLUETOOTH_ERROR_INTERNAL;
-
-       BT_CHECK_PARAMETER(device_address, return);
-
-       if (searching_info) {
-               BT_ERR("Service searching in progress");
-               return BLUETOOTH_ERROR_DEVICE_BUSY;
-       }
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       /* allocate user data so that it can be retrieved in callback */
-       searching_info = g_malloc0(sizeof(bt_funcion_data_t));
-       searching_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
-       searching_info->req_id = request_id;
-
-       _bt_convert_addr_type_to_string(searching_info->addr,
-                                       device_address->addr);
-
-       device_path = _bt_get_device_object_path(searching_info->addr);
-
-       if (device_path == NULL) {
-               /* Not support this function in bluez 5.2 */
-               BT_ERR("No paired device");
-               goto fail;
-
-               is_deivce_creating = TRUE;
-
-               if (!dbus_g_proxy_begin_call(adapter_proxy,
-                               "CreateDevice",
-                               (DBusGProxyCallNotify)__bt_create_device_cb,
-                               (gpointer)searching_info, NULL,
-                               G_TYPE_STRING, searching_info->addr,
-                               G_TYPE_INVALID)) {
-                       BT_ERR("CreateDevice failed");
-                       result = BLUETOOTH_ERROR_INTERNAL;
-                       is_deivce_creating = FALSE;
-                       goto fail;
-               }
-
-               searching_info->adapter_proxy = device_proxy;
-
-               return BLUETOOTH_ERROR_NONE;
-       }
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_PROPERTIES_INTERFACE);
-       g_free(device_path);
-       if (device_proxy == NULL) {
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto fail;
-       }
-
-       if (!dbus_g_proxy_begin_call(device_proxy, "Get",
-                       (DBusGProxyCallNotify)__bt_discover_cb,
-                       (gpointer)searching_info, NULL,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "UUIDs",
-                       G_TYPE_INVALID)) {
-               BT_ERR("DiscoverServices failed");
-               goto fail;
-       }
-
-       searching_info->device_proxy = device_proxy;
-
-       return BLUETOOTH_ERROR_NONE;
-fail:
-       if (device_proxy)
-               g_object_unref(device_proxy);
-
-       g_free(searching_info->addr);
-       g_free(searching_info);
-       searching_info = NULL;
-       return result;
-}
-
-int _bt_cancel_search_device(void)
-{
-       GError *err = NULL;
-
-       retv_if(searching_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);
-
-       if (searching_info->device_proxy) {
-               dbus_g_proxy_call(searching_info->device_proxy,
-                               "CancelDiscovery",
-                               &err,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-       } else if (searching_info->adapter_proxy) {
-               dbus_g_proxy_call(searching_info->adapter_proxy,
-                               "CancelDeviceCreation",
-                               &err,
-                               G_TYPE_STRING, searching_info->addr,
-                               G_TYPE_INVALID);
-       } else {
-               BT_ERR("No proxy info");
-               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-       }
-
-       if (err != NULL) {
-               BT_ERR("Error occured [%s]\n", err->message);
-               g_error_free(err);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       __bt_cancel_search_service_done();
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-int _bt_set_alias(bluetooth_device_address_t *device_address,
-                                     const char *alias)
-{
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       gchar *device_path = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy;
-       GError *error = NULL;
-       GValue name = { 0 };
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(device_address, return);
-       BT_CHECK_PARAMETER(alias, return);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       device_path = _bt_get_device_object_path(address);
-
-       if (device_path == NULL) {
-               BT_ERR("No paired device");
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-       }
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_PROPERTIES_INTERFACE);
-
-       g_free(device_path);
-       retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-       g_value_init(&name, G_TYPE_STRING);
-       g_value_set_string(&name, alias);
-
-       dbus_g_proxy_call(device_proxy, "Set", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "Alias",
-                       G_TYPE_VALUE, &name,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_object_unref(device_proxy);
-
-       g_value_unset(&name);
-
-       if (error) {
-                BT_ERR("SetProperty error: [%s]", error->message);
-                g_error_free(error);
-                return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-int _bt_set_authorization(bluetooth_device_address_t *device_address,
-                                     gboolean authorize)
-{
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       gchar *device_path = NULL;
-       DBusGProxy *device_proxy;
-       gboolean previous_value;
-       GError *error = NULL;
-       GValue trusted = { 0 };
-       GValue trusted_v = { 0 };
-       DBusGConnection *conn;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       BT_CHECK_PARAMETER(device_address, return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       device_path = _bt_get_device_object_path(address);
-
-       if (device_path == NULL) {
-               BT_ERR("No paired device");
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-       }
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_PROPERTIES_INTERFACE);
-       g_free(device_path);
-       retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       if (!dbus_g_proxy_call(device_proxy, "Get", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "Trusted",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &trusted_v,
-                       G_TYPE_INVALID)) {
-               if (error != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", error->message);
-                       g_error_free(error);
-               }
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       previous_value = g_value_get_boolean(&trusted_v);
-
-       /* If the input is same with previous value, return error. */
-       if (previous_value == authorize) {
-               BT_ERR("Same value: %d", previous_value);
-               g_object_unref(device_proxy);
-               ret = BLUETOOTH_ERROR_INVALID_PARAM;
-               goto done;
-       }
-
-       g_value_init(&trusted, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&trusted, authorize);
-
-       dbus_g_proxy_call(device_proxy, "Set", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "Trusted",
-                       G_TYPE_VALUE, &trusted,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_object_unref(device_proxy);
-       g_value_unset(&trusted);
-
-       if (error) {
-                BT_ERR("SetProperty error: [%s]", error->message);
-                g_error_free(error);
-                ret = BLUETOOTH_ERROR_INTERNAL;
-       }
-done:
-       return ret;
-}
-
-int _bt_is_device_connected(bluetooth_device_address_t *device_address,
-                       int connection_type, gboolean *is_connected)
-{
-       char *object_path = NULL;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       DBusGProxy *device_proxy = NULL;
-       DBusGProxy *adapter_proxy = NULL;
-       DBusGConnection *conn;
-       GError *error = NULL;
-       GHashTable *hash = NULL;
-       GValue *value = NULL;
-       char *interface = NULL;
-
-       retv_if(device_address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-       retv_if(is_connected == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       if (connection_type == BLUETOOTH_RFCOMM_SERVICE)
-               return _bt_rfcomm_is_device_connected(device_address,
-                                               is_connected);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       dbus_g_proxy_call(adapter_proxy, "FindDevice",
-                         &error, G_TYPE_STRING, address,
-                         G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
-                         &object_path, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_ERR("Failed to Find device: %s", error->message);
-               g_error_free(error);
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-       }
-
-       retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       switch (connection_type) {
-       case BLUETOOTH_HSP_SERVICE:
-               interface = BT_HFP_AGENT_INTERFACE;
-               break;
-       case BLUETOOTH_A2DP_SERVICE:
-               interface = BT_SINK_INTERFACE;
-               break;
-       case BLUETOOTH_HID_SERVICE:
-               interface = BT_INPUT_INTERFACE;
-               break;
-       default:
-               BT_DBG("Unknown type!");
-               g_free(object_path);
-               return BLUETOOTH_ERROR_INVALID_PARAM;
-       }
-
-       BT_DBG("Interface name: %s", interface);
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME, object_path, interface);
-       g_free(object_path);
-       if (device_proxy == NULL) {
-               BT_DBG("Device don't have this service");
-               is_connected = FALSE;
-               return BLUETOOTH_ERROR_NONE;
-       }
-       dbus_g_proxy_call(device_proxy, "GetProperties", &error,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_DBG("Failed to get properties: %s\n", error->message);
-               g_error_free(error);
-               g_object_unref(device_proxy);
-               is_connected = FALSE;
-               return BLUETOOTH_ERROR_NONE;
-       }
-
-       if (hash != NULL) {
-               value = g_hash_table_lookup(hash, "Connected");
-               *is_connected = value ? g_value_get_boolean(value) : FALSE;
-               g_hash_table_destroy(hash);
-       } else {
-               *is_connected = FALSE;
-       }
-
-       g_object_unref(device_proxy);
-       return BLUETOOTH_ERROR_NONE;
-}
-
old mode 100644 (file)
new mode 100755 (executable)
index a13db80..82efdb6
@@ -29,7 +29,7 @@
 #include <dlog.h>
 #include <vconf.h>
 #include <vconf-internal-bt-keys.h>
-#ifdef ENABLE_TIZEN_2_4
+#if 0
 #include <journal/device.h>
 #endif
 
@@ -653,6 +653,12 @@ void _bt_handle_adapter_event(DBusMessage *msg)
 
                _bt_convert_device_path_to_address(object_path, address);
 
+               _bt_send_event(BT_ADAPTER_EVENT,
+                       BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED,
+                       DBUS_TYPE_INT32, &result,
+                       DBUS_TYPE_STRING, &address,
+                       DBUS_TYPE_INVALID);
+
                node = g_list_first(p_cache_list);
 
                while (node != NULL){
@@ -831,20 +837,10 @@ static void __bt_adapter_property_changed_event(DBusMessageIter *msg_iter, const
                                        DBUS_TYPE_INT32, &result,
                                        DBUS_TYPE_INVALID);
                        } else {
-                               ret_if(event_id > 0);
-
-                               adapter_proxy = _bt_get_adapter_proxy();
-                               ret_if(adapter_proxy == NULL);
-
-                               /* Need to stop searching */
-                               dbus_g_proxy_call(adapter_proxy,
-                                                       "StopDiscovery",
-                                                       NULL,
-                                                       G_TYPE_INVALID,
-                                                       G_TYPE_INVALID);
-
-                               event_id = g_timeout_add(BT_DISCOVERY_FINISHED_DELAY,
-                                                 (GSourceFunc)_bt_discovery_finished_cb, NULL);
+                               if (event_id > 0){
+                                       g_source_remove(event_id);
+                                       event_id = 0;
+                               }
                        }
                } else if (strcasecmp(property, "LEDiscovering") == 0) {
                        gboolean le_discovering = FALSE;
@@ -967,22 +963,23 @@ static void __bt_adapter_property_changed_event(DBusMessageIter *msg_iter, const
        /* TODO: Need to check this operation!! */
                        gboolean powered = FALSE;
                        int bt_state;
-
                        dbus_message_iter_recurse(&dict_iter, &value_iter);
                        dbus_message_iter_get_basic(&value_iter, &powered);
                        BT_DBG("Powered = %d", powered);
-                       if (powered == FALSE) {
-                               if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_state) == 0 &&
-                                       bt_state != VCONFKEY_BT_STATUS_OFF) {
-                                       _bt_disable_adapter();
-                               }
-#ifdef ENABLE_TIZEN_2_4
+
+                       if (powered == TRUE) {
+                               BT_ERR("calling _bt_handle_adapter_added ...........");
+                               _bt_handle_adapter_added();
+                       }
+                       else {
+                               _bt_set_disabled(BLUETOOTH_ERROR_NONE);
+                       }
+#if 0
                                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_state) == 0 &&
                                        bt_state != VCONFKEY_BT_LE_STATUS_OFF) {
                                        _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
                                }
 #endif
-                       }
                } else if (strcasecmp(property, "Connectable") == 0) {
                        gboolean connectable = FALSE;
 
@@ -1046,6 +1043,7 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
        char *address;
        bt_remote_dev_info_t *remote_dev_info;
 
+
        dbus_message_iter_recurse(msg_iter, &item_iter);
 
        if (dbus_message_iter_get_arg_type(&item_iter)
@@ -1062,6 +1060,8 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                ret_if(!dbus_message_iter_next(&dict_iter));
 
+               BT_ERR(" device property changed \n %s" , property);
+
                if (strcasecmp(property, "Connected") == 0) {
                        gboolean connected = FALSE;
 
@@ -1193,13 +1193,14 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
                                BT_INFO("Paired: %s", address);
                                __bt_update_remote_cache_devinfo(address, TRUE);
 
+#if 0
                                if (_bt_is_device_creating() == TRUE) {
                                        BT_DBG("Try to Pair by me");
                                        _bt_free_device_info(remote_dev_info);
                                        g_free(address);
                                        return;
                                }
-
+#endif
                                _bt_send_event(BT_ADAPTER_EVENT,
                                        BLUETOOTH_EVENT_BONDING_FINISHED,
                                        DBUS_TYPE_INT32, &result,
@@ -1263,6 +1264,8 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
                        BT_DBG("trusted: %d", trusted);
                        BT_DBG("address: %s", address);
 
+                       remote_dev_info = _bt_get_remote_device_info(address);
+
                        /* Send event to application */
                        _bt_send_event(BT_DEVICE_EVENT,
                                        event,
@@ -1427,6 +1430,7 @@ void _bt_handle_property_changed_event(DBusMessage *msg)
        } else if (strcasecmp(interface_name, BT_DEVICE_INTERFACE) == 0) {
                __bt_device_property_changed_event(&item_iter,
                                        dbus_message_get_path(msg));
+
        } else if (strcasecmp(interface_name, BT_OBEX_TRANSFER_INTERFACE) == 0) {
                BT_DBG("BT_OBEX_TRANSFER_INTERFACE");
                __bt_obex_property_changed_event(&item_iter,
@@ -1508,17 +1512,15 @@ void _bt_handle_input_event(DBusMessage *msg)
                        BT_DBG("HID device class [%x]", remote_dev_info->class);
                        if (remote_dev_info->class &
                                        BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD) {
-#ifdef ENABLE_TIZEN_2_4
+#if 0
                                __bt_set_device_values(property_flag,
                                                VCONFKEY_BT_DEVICE_HID_KEYBOARD_CONNECTED);
 #endif
-
                        }
-
                        if (remote_dev_info->class &
                                        BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE)
                        {
-#ifdef ENABLE_TIZEN_2_4
+#if 0
                                __bt_set_device_values(property_flag,
                                                VCONFKEY_BT_DEVICE_HID_MOUSE_CONNECTED);
 #endif
@@ -1790,7 +1792,7 @@ void _bt_handle_device_event(DBusMessage *msg)
                BT_ERR_C("Connected [%s]", !addr_type ? "BREDR" : "LE");
 
                _bt_logging_connection(TRUE, addr_type);
-#ifdef ENABLE_TIZEN_2_4
+#if 0
                journal_bt_connected();
 #endif
 
@@ -1819,7 +1821,7 @@ void _bt_handle_device_event(DBusMessage *msg)
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
                _bt_convert_device_path_to_address(path, address);
-#ifdef ENABLE_TIZEN_2_4
+#if 0
                journal_bt_disconnected();
 #endif
 
@@ -2513,9 +2515,11 @@ static int __bt_parse_event(DBusMessage *msg)
                } else if (g_strcmp0(interface_name,
                                BT_MEDIATRANSPORT_INTERFACE) == 0) {
                        return BT_MEDIA_TRANSFER_EVENT;
+       #if 0
                } else if (g_strcmp0(interface_name,
                                BT_PLAYER_CONTROL_INTERFACE) == 0) {
                        return BT_AVRCP_CONTROL_EVENT;
+#endif
                }
                dbus_message_iter_next(&value_iter);
        }
@@ -2594,6 +2598,7 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
        retv_if(member == NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
 
        if (strcasecmp(member, "InterfacesAdded") == 0) {
+
                char *object_path = NULL;
 
                BT_DBG("InterfacesAdded");
@@ -2657,23 +2662,14 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
                                        DBUS_TYPE_INVALID);
 
                                p_cache_list = g_list_append(p_cache_list, cache_info);
-                       } else if (bt_event == BT_AVRCP_CONTROL_EVENT) {
-                               BT_DBG("Device path : %s ", object_path);
-                               _bt_set_control_device_path(object_path);
                        }
                }
        } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
+
                bt_event = __bt_parse_remove_event(msg);
 
-               if ((bt_event != 0) && (bt_event != BT_MEDIA_TRANSFER_EVENT)) {
+               if ((bt_event != 0) && (bt_event != BT_MEDIA_TRANSFER_EVENT))
                        _bt_handle_adapter_event(msg);
-                       if (bt_event == BT_AVRCP_CONTROL_EVENT) {
-                               char *object_path = NULL;
-                               result = __bt_get_object_path(msg, &object_path);
-                               if (result == BLUETOOTH_ERROR_NONE)
-                                       _bt_remove_control_device_path(object_path);
-                       }
-               }
 
        } else if (strcasecmp(member, "NameOwnerChanged") == 0) {
                gboolean value;
@@ -2681,6 +2677,8 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
                char *previous = NULL;
                char *current = NULL;
 
+               BT_DBG("NameOwnerChanged");
+
                if (__bt_get_owner_info(msg, &name, &previous, &current)) {
                        BT_ERR("Fail to get the owner info");
                        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -2711,9 +2709,6 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
                        /* The obex server was terminated abnormally */
                        _bt_rfcomm_server_check_termination(name);
                }
-
-               /* Stop advertising started by terminated process */
-               _bt_stop_advertising_by_terminated_process(name);
        } else  if (dbus_message_has_interface(msg, BT_PROPERTIES_INTERFACE)) {
                const char *path = dbus_message_get_path(msg);
 
@@ -3045,6 +3040,7 @@ int _bt_register_service_event(DBusGConnection *g_conn, int event_type)
 
        switch (event_type) {
        case BT_MANAGER_EVENT:
+               BT_ERR("BT_MANAGER_EVENT_REC:  \n register service event");
                event_func = __bt_manager_event_filter;
                match1 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
                                        BT_MANAGER_INTERFACE,
@@ -3257,7 +3253,7 @@ fail:
                manager_conn = NULL;
        }
 
-       BT_DBG("-");
+       BT_DBG("REGISTER successfull");
 
        return BLUETOOTH_ERROR_INTERNAL;
 }
index 4efa378..f78ecbe 100755 (executable)
@@ -511,7 +511,7 @@ int _bt_init_service_event_sender(void)
 
        if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
                if (dbus_error_is_set(&err) == TRUE) {
-                       BT_ERR("Event init failed, %s", err.message);
+                       BT_ERR(" Sudha 112 Event init failed \n \n, %s", err.message);
                        dbus_error_free(&err);
                }
                return BLUETOOTH_ERROR_INTERNAL;
@@ -537,7 +537,7 @@ int _bt_init_hf_local_term_event_sender(void)
        int ret;
 
        if (hf_local_term_event_conn) {
-               BT_ERR("Event handler is already exist");
+               BT_ERR(" Sudha Event handler is already exist");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
@@ -551,7 +551,7 @@ int _bt_init_hf_local_term_event_sender(void)
 
        if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
                if (dbus_error_is_set(&err) == TRUE) {
-                       BT_ERR("Event init failed, %s", err.message);
+                       BT_ERR("Sudha Event init failed \n, %s ", err.message);
                        dbus_error_free(&err);
                }
                return BLUETOOTH_ERROR_INTERNAL;
old mode 100644 (file)
new mode 100755 (executable)
index 9d57a44..89d73c7
@@ -944,10 +944,17 @@ gboolean _gap_agent_register(GapAgent *agent)
                agent_manager = priv->agent_manager;
        }
 
+#ifdef __TIZEN_MOBILE_
        dbus_g_proxy_call(agent_manager, "RegisterAgent", &error,
                                DBUS_TYPE_G_OBJECT_PATH, priv->path,
                                G_TYPE_STRING, "DisplayYesNo", G_TYPE_INVALID,
                                G_TYPE_INVALID);
+else
+       dbus_g_proxy_call(agent_manager, "RegisterAgent", &error,
+                       DBUS_TYPE_G_OBJECT_PATH, priv->path,
+                       G_TYPE_STRING, "NoInputNoOutput", G_TYPE_INVALID,
+                       G_TYPE_INVALID);
+#endif
        if (error != NULL) {
                BT_DBG("Agent registration failed: %s\n", error->message);
                g_error_free(error);
old mode 100644 (file)
new mode 100755 (executable)
index 4685604..cbc66c9
@@ -25,7 +25,6 @@
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
-#include <privilege-control.h>
 #include <vconf.h>
 
 #include "bt-internal-types.h"
@@ -35,7 +34,6 @@
 #include "bt-service-util.h"
 #include "bt-request-handler.h"
 #include "bt-service-adapter.h"
-#include "bt-service-adapter-le.h"
 
 static GMainLoop *main_loop;
 static gboolean terminated = FALSE;
@@ -44,7 +42,6 @@ static void __bt_release_service(void)
 {
        _bt_service_unregister_vconf_handler();
 
-       _bt_service_adapter_le_deinit();
        _bt_deinit_service_event_sender();
        _bt_deinit_hf_local_term_event_sender();
        _bt_deinit_service_event_receiver();
@@ -113,7 +110,6 @@ gboolean _bt_reliable_terminate_service(gpointer user_data)
 
        _bt_set_disabled(BLUETOOTH_ERROR_NONE);
 
-       _bt_service_adapter_le_deinit();
        _bt_deinit_service_event_sender();
        _bt_deinit_hf_local_term_event_sender();
 
@@ -140,6 +136,9 @@ static gboolean __bt_check_bt_service(void *data)
        bt_le_status_t le_status = BT_LE_DEACTIVATED;
        int flight_mode_deactivation = 0;
        int bt_off_due_to_timeout = 0;
+       _bt_enable_adapter();
+       return FALSE;
+
 #if 0
        int ps_mode_deactivation = 0;
 #endif
@@ -191,7 +190,9 @@ static gboolean __bt_check_bt_service(void *data)
 
                if ((status != BT_ACTIVATING && status != BT_ACTIVATED) &&
                                (le_status != BT_LE_ACTIVATING && le_status != BT_LE_ACTIVATED)){
+#ifndef USB_BLUETOOTH
                        _bt_terminate_service(NULL);
+#endif
                }
        }
 
@@ -210,10 +211,6 @@ int main(void)
 
        g_type_init();
 
-       if (perm_app_set_privilege("bluetooth-frwk-service", NULL, NULL) !=
-                                                               PC_OPERATION_SUCCESS)
-               BT_ERR("Failed to set app privilege.\n");
-
        /* Event reciever Init */
        if (_bt_init_service_event_receiver() != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Fail to init event reciever");
@@ -222,7 +219,7 @@ int main(void)
 
        /* Event sender Init */
        if (_bt_init_service_event_sender() != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Fail to init event sender");
+               BT_ERR(" Sudha 13 Fail to init event sender");
                return 0;
        }
 
@@ -236,11 +233,6 @@ int main(void)
                return 0;
        }
 
-       if (_bt_service_adapter_le_init() != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Fail to init le");
-               return 0;
-       }
-
        _bt_init_request_id();
 
        _bt_init_request_list();
diff --git a/bt-service/include/bt-popup.h b/bt-service/include/bt-popup.h
deleted file mode 100644 (file)
index 9aff172..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2013 Intel Corporation.
- *
- * 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 <libnotify/notify.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <bundle.h>
-#include "bt-service-common.h"
-
-#define BT_PIN_MLEN    16      /* Pin key max length */
-#define BT_PK_MLEN     6       /* Passkey max length */
-#define NOTIFY_ICON    DATA_DIR_ICON"/icons/default/bt-icon.png"
-#define BT_SUCCESS     0
-#define BT_FAILED      1
-
-typedef enum {
-       BT_AGENT_ACCEPT,
-       BT_AGENT_REJECT,
-       BT_AGENT_CANCEL,
-       BT_CORE_AGENT_TIMEOUT,
-} bt_agent_accept_type_t;
-
-struct bt_popup_appdata {
-       DBusGProxy *agent_proxy;
-       DBusGProxy *obex_proxy;
-       GtkWidget *window;
-       GtkWidget *entry;
-};
-
-int notify_launch(bundle *user_data);
diff --git a/bt-service/include/bt-service-agent-notification.h b/bt-service/include/bt-service-agent-notification.h
deleted file mode 100644 (file)
index 19d1634..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2013 Intel Corporation.
- *
- * 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 <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <bundle.h>
-#include <notification.h>
-#include "bt-service-common.h"
-
-#define BT_ICON        DATA_DIR_ICON"/icons/default/bt-icon.png"
-#define BT_SUCCESS     0
-#define BT_FAILED      1
-
-int notification_launch(bundle *user_data);
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/packaging/bluetooth-frwk.changes b/packaging/bluetooth-frwk.changes
deleted file mode 100644 (file)
index ece8fcc..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-* Fri Aug 23 2013 Victor Hakoun <victor.hakoun@eurogiciel.fr> submit/tizen/20130822.094138@03300bb
-- Fix permission denied on open dev node /dev/rfcomm
-
-* Wed Aug 21 2013 Victor Hakoun <victor.hakoun@eurogiciel.fr> submit/tizen/20130809.082724@2a3c24d
-- Start bt-service with systemd user with multi-user option
-
-* Fri Aug 09 2013 Victor Hakoun <victor.hakoun@eurogiciel.fr> submit/tizen/20130809.031242@26a0212
-- Add a libnotify/gtk popup system to bluetooth-frwk. This is helping having Bluetooth popups with no OSP application dependencies (bt-syspopup and osp-launcher) and gtk/libnotify on the patform.
-
-* Thu Aug 08 2013 Jimmy Huang <jimmy.huang@intel.com> accepted/tizen/20130710.221452@4dcc5cd
-- Fixes Tizen bluetooth device api fails to work for web apps TIVI-1275
-
-* Fri Jun 28 2013 Patrick McCarty <patrick.mccarty@linux.intel.com> 083ac72
-- packaging: remove explicit requires on sys-assert
-
-* Fri Jun 28 2013 Alexandru Cornea <alexandru.cornea@intel.com> 2ab9e05
-- resetting manifest requested domain to floor
-
-* Tue Jun 25 2013 Victor Hakoun <victor.hakoun@eurogiciel.fr> submit/tizen/20130621.103930@afec205
-- Use macro %{_unitdir_user} unstead  of %{_libdir}/systemd/user in specfile
-
-* Fri Jun 21 2013 Baptiste DURAND <baptiste.durand@eurogiciel.fr> accepted/tizen/20130529.191100@62b0858
-- Replace manifest with default floor
-
-* Wed May 29 2013 Anas Nashif <anas.nashif@intel.com> accepted/tizen/20130522.164550@48f114b
-- Fixed build and remove hardcoding of libdir
-
-* Tue May 21 2013 Rusty Lynch <rusty.lynch@intel.com> submit/tizen/20130517.044858@4269c84
-- Fix rpmlint errors
-
old mode 100644 (file)
new mode 100755 (executable)
index 95fff5e..18a22f5
@@ -1,15 +1,12 @@
 %define _dumpdir /opt/etc/dump.d/module.d
 %define _varlibdir /opt/var/lib
-#%bcond_with bluetooth_frwk_libnotify
-#%bcond_with bluetooth_frwk_libnotification
-#%bcond_with x
 
 Name:       bluetooth-frwk
 Summary:    Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework based on BlueZ and Obexd stack.
 Version:    0.2.146
 Release:    0
 Group:      Network & Connectivity/Bluetooth
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: bluetooth-frwk.manifest
 Source1002: bt-icon.png
@@ -37,7 +34,7 @@ BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(dbus-1)
 #%if %{with x}
-BuildRequires:  pkgconfig(utilX)
+#BuildRequires:  pkgconfig(utilX)
 #%endif
 BuildRequires:  pkgconfig(capi-network-connection)
 
@@ -51,10 +48,6 @@ BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(pkgmgr)
 #BuildRequires:  pkgconfig(journal)
 
-%if "%{?tizen_profile_name}" == "mobile"
-BuildRequires:  pkgconfig(capi-network-tethering)
-%endif
-
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(libtzplatform-config)
 
@@ -112,23 +105,6 @@ export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
-%if "%{?tizen_profile_name}" == "mobile"
-export CFLAGS="$CFLAGS -DTIZEN_NETWORK_TETHERING_ENABLE"
-%endif
-
-%if "%{?tizen_profile_name}" == "wearable"
-export CFLAGS="$CFLAGS -DTIZEN_WEARABLE"
-%define _servicefile packaging/bluetooth-frwk-wearable.service
-%else
-%define _servicefile packaging/bluetooth-frwk-mobile.service
-%endif
-%define _servicedir multi-user.target.wants
-
-%if "%{?tizen_profile_name}" == "mobile"
-%else
-export CFLAGS="$CFLAGS -DTIZEN_TELEPHONY_ENABLED"
-%endif
-
 %ifarch x86_64
 export CFLAGS+=" -Wall -g -fvisibility=hidden -fPIC -DRFCOMM_DIRECT "
 export LDFLAGS+=" -Wl,--rpath=%{_libdir} -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs"
@@ -154,11 +130,13 @@ export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=
 %cmake \
 %if "%{?tizen_profile_name}" == "wearable"
        -DTIZEN_WEARABLE=YES \
-%else
+%endif
+%if "%{?tizen_profile_name}" == "mobile"
+       -DTIZEN_WEARABLE=NO \
+%endif
+%if "%{?tizen_profile_name}" == "common"
        -DTIZEN_WEARABLE=NO \
 %endif
-
-%__make
 
 %install
 rm -rf %{buildroot}
@@ -181,36 +159,32 @@ install -m 0644 %{SOURCE1002} %{buildroot}%{_datadir}/icons/default/bt-icon.png
 sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-services/org.projectx.bt.service
 %endif
 
-mkdir -p %{buildroot}%{_dumpdir}
-install -m 0755 bluetooth_log_dump.sh %{buildroot}%{_dumpdir}
-
 %post
 /sbin/ldconfig
 %if "%{?tizen_profile_name}" == "wearable"
 vconftool set -f -t int db/bluetooth/status "1" -g 6520
-%else
+%endif
+%if "%{?tizen_profile_name}" == "mobile"
 vconftool set -f -t int db/bluetooth/status "0" -g 6520
 %endif
+%if "%{?tizen_profile_name}" == "common"
+vconftool set -f -t int db/bluetooth/status "0" -g 6520
+%endif
+
 
-vconftool set -f -t int db/bluetooth/lestatus "0" -g 6520 -i
-vconftool set -f -t int file/private/bt-service/flight_mode_deactivated "0" -g 6520 -i
-vconftool set -f -t int file/private/bt-core/flight_mode_deactivated "0" -g 6520 -i
-vconftool set -f -t int file/private/bt-core/powersaving_mode_deactivated "0" -g 6520 -i
-vconftool set -f -t int file/private/bt-service/bt_off_due_to_timeout "0" -g 6520 -i
+vconftool set -f -t int db/bluetooth/status "0" -s User
+vconftool set -f -t int db/bluetooth/lestatus "0" -s User
+vconftool set -f -t int file/private/bt-core/flight_mode_deactivated "0" -s User
+vconftool set -f -t int file/private/bt-core/powersaving_mode_deactivated "0" -s User
+vconftool set -f -t int file/private/bt-service/bt_off_due_to_timeout "0" -s User
 vconftool set -f -t string memory/bluetooth/sco_headset_name "" -g 6520 -i
 vconftool set -f -t int memory/bluetooth/device "0" -g 6520 -i
-vconftool set -f -t int memory/bluetooth/btsco "0" -g 6520 -i
+vconftool set -f -t bool memory/bluetooth/btsco "0" -g 6520 -i
 vconftool set -f -t bool memory/bluetooth/dutmode "0" -g 6520 -i
-# set 'User' smack label to vconf keys in order to allow bt-service to access them.
-chsmack -a 'User' %TZ_SYS_CONFIG/db/bluetooth/status
-chsmack -a 'User' %TZ_SYS_CONFIG/file/private/bt-service/flight_mode_deactivated
-chsmack -a 'User' %TZ_SYS_CONFIG/memory_init/memory/bluetooth/sco_headset_name
-chsmack -a 'User' %TZ_SYS_CONFIG/memory_init/memory/bluetooth/device
-chsmack -a 'User' %TZ_SYS_CONFIG/memory_init/memory/bluetooth/btsco
 
-%post service
-mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
-ln -sf %{_libdir}/systemd/system/bluetooth-frwk.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+#%post service
+#mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+#ln -sf %{_libdir}/systemd/system/bluetooth-frwk.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
 
 %postun -p /sbin/ldconfig
 
@@ -236,17 +210,15 @@ ln -sf %{_libdir}/systemd/system/bluetooth-frwk.service %{_sysconfdir}/systemd/d
 %manifest %{name}.manifest
 %defattr(-, root, root)
 %{_datadir}/dbus-1/system-services/org.projectx.bt.service
+
 %{_bindir}/bt-service
 %{_unitdir_user}/bluetooth-frwk-service.service
+%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-service.conf
 %{_bindir}/bluetooth-frwk-test
-%{_bindir}/bluetooth-gatt-test
-%{_bindir}/bluetooth-advertising-test
+#%{_bindir}/bluetooth-gatt-test
+#%{_bindir}/bluetooth-advertising-test
 %{_varlibdir}/bluetooth
 %{_prefix}/etc/bluetooth
-#%attr(0666,-,-) %{_varlibdir}/bluetooth/auto-pair-blacklist
-#%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-service.conf
-#%attr(0666,-,-) %{_prefix}/etc/bluetooth/stack_info
-%{_dumpdir}/bluetooth_log_dump.sh
 %{_datadir}/license/bluetooth-frwk-service
 %if %{with bluetooth_frwk_libnotify} || %{with bluetooth_frwk_libnotification}
 %{_datadir}/icons/default/bt-icon.png
@@ -257,11 +229,11 @@ ln -sf %{_libdir}/systemd/system/bluetooth-frwk.service %{_sysconfdir}/systemd/d
 %defattr(-, root, root)
 %{_datadir}/dbus-1/system-services/org.projectx.bt_core.service
 %{_bindir}/bt-core
-#%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-core.conf
+%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-core.conf
 
 %files test
 %manifest %{name}.manifest
 %defattr(-, root, root)
 %{_bindir}/bluetooth-frwk-test
-%{_bindir}/bluetooth-gatt-test
-%{_bindir}/bluetooth-advertising-test
+#%{_bindir}/bluetooth-gatt-test
+#%{_bindir}/bluetooth-advertising-test
old mode 100644 (file)
new mode 100755 (executable)
index 4c628e3..7cf3104 100755 (executable)
@@ -36,6 +36,6 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 
 #ADD_SUBDIRECTORY(media-control)
 #ADD_SUBDIRECTORY(telephony)
-ADD_SUBDIRECTORY(gatt-test)
+#ADD_SUBDIRECTORY(gatt-test)
 #ADD_SUBDIRECTORY(handsfree)
-ADD_SUBDIRECTORY(le-adv)
+#ADD_SUBDIRECTORY(le-adv)