[cleanup] revise file location 32/240132/1
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 4 Aug 2020 00:56:30 +0000 (09:56 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Tue, 4 Aug 2020 00:56:30 +0000 (09:56 +0900)
Change-Id: I738bbcef8a0ec01aa082c06b710057f239ee00cb

66 files changed:
AUTHORS [deleted file]
CMakeLists.txt
LICENSE [deleted file]
LICENSE.APLv2
app/CMakeLists.txt [new file with mode: 0644]
app/applog.h [new file with mode: 0644]
app/bt-share-common.c [new file with mode: 0644]
app/bt-share-common.h [new file with mode: 0644]
app/bt-share-cynara.c [new file with mode: 0644]
app/bt-share-cynara.h [new file with mode: 0644]
app/bt-share-ipc.c [new file with mode: 0644]
app/bt-share-ipc.h [new file with mode: 0644]
app/bt-share-main.c [new file with mode: 0644]
app/bt-share-main.h [new file with mode: 0644]
app/bt-share-noti-handler.c [new file with mode: 0644]
app/bt-share-noti-handler.h [new file with mode: 0644]
app/bt-share-notification.c [new file with mode: 0644]
app/bt-share-notification.h [new file with mode: 0644]
app/bt-share-resource.h [new file with mode: 0644]
app/bt-share-syspopup.c [new file with mode: 0644]
app/bt-share-syspopup.h [new file with mode: 0644]
app/obex-event-handler.c [new file with mode: 0644]
app/obex-event-handler.h [new file with mode: 0644]
app/org.bluetooth.share.service [new file with mode: 0644]
bt-share/CMakeLists.txt [deleted file]
bt-share/include/applog.h [deleted file]
bt-share/include/bt-share-common.h [deleted file]
bt-share/include/bt-share-cynara.h [deleted file]
bt-share/include/bt-share-ipc.h [deleted file]
bt-share/include/bt-share-main.h [deleted file]
bt-share/include/bt-share-noti-handler.h [deleted file]
bt-share/include/bt-share-notification.h [deleted file]
bt-share/include/bt-share-resource.h [deleted file]
bt-share/include/bt-share-syspopup.h [deleted file]
bt-share/include/obex-event-handler.h [deleted file]
bt-share/src/bt-share-common.c [deleted file]
bt-share/src/bt-share-cynara.c [deleted file]
bt-share/src/bt-share-ipc.c [deleted file]
bt-share/src/bt-share-main.c [deleted file]
bt-share/src/bt-share-noti-handler.c [deleted file]
bt-share/src/bt-share-notification.c [deleted file]
bt-share/src/bt-share-syspopup.c [deleted file]
bt-share/src/obex-event-handler.c [deleted file]
bt-share/src/org.bluetooth.share.service [deleted file]
debian/bluetooth-share-headers.install.in [deleted file]
debian/bluetooth-share.install.in [deleted file]
debian/bluetooth-share.postinst [deleted file]
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/libbluetooth-share-dev.install.in [deleted file]
debian/libbluetooth-share.install.in [deleted file]
debian/rules [deleted file]
packaging/bluetooth-share.changes [deleted file]
packaging/bluetooth-share.manifest
packaging/bluetooth-share.spec
packaging/libbluetooth-share-devel.manifest [deleted file]
packaging/libbluetooth-share.manifest [deleted file]
tests/CMakeLists.txt [new file with mode: 0644]
tests/bluetooth-share_test.cpp [new file with mode: 0644]
tests/mock/bluetooth-share-mock.c [new file with mode: 0644]
tests/run_coverage.sh [new file with mode: 0755]
unittest/CMakeLists.txt [deleted file]
unittest/bluetooth-share_test.cpp [deleted file]
unittest/mock/bluetooth-share-mock.c [deleted file]
unittest/run_coverage.sh [deleted file]

diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644 (file)
index 46d1687..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-Jinmin Jung <jinmin@samsung.com>
-DoHyun Pyun <dh79.pyun@samsung.com>
index 379c7f3a6ea4cc7b76c914e08b341c4488d6cfc7..5a57c6b4e7b31fda1f484830532c10a3f3ee248f 100644 (file)
@@ -2,8 +2,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 ADD_SUBDIRECTORY(lib)
 
-ADD_SUBDIRECTORY(bt-share)
+ADD_SUBDIRECTORY(app)
 
 IF (BUILD_GCOV)
-ADD_SUBDIRECTORY(unittest)
+ADD_SUBDIRECTORY(tests)
 ENDIF (BUILD_GCOV)
diff --git a/LICENSE b/LICENSE
deleted file mode 100644 (file)
index a06208b..0000000
--- a/LICENSE
+++ /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.
-
index 6b0b1270ff0ca8f03867efcd09ba6ddb6392b1e1..f7d6243c4078384573d05fb4f33badaec74bd52d 100644 (file)
@@ -1,3 +1,4 @@
+Copyright (c) 2000 - 2020 Samsung Electronics Co., Ltd. All rights reserved.
 
                                  Apache License
                            Version 2.0, January 2004
    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/app/CMakeLists.txt b/app/CMakeLists.txt
new file mode 100644 (file)
index 0000000..aa2f48c
--- /dev/null
@@ -0,0 +1,73 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-share C CXX)
+
+SET(SRCS bt-share-main.c
+bt-share-notification.c
+bt-share-common.c
+obex-event-handler.c
+bt-share-syspopup.c
+bt-share-ipc.c
+bt-share-noti-handler.c
+bt-share-cynara.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api
+                               aul appcore-common
+                               dlog vconf syspopup-caller deviced
+                               notification sqlite3 ecore-file
+                               appsvc appcore-efl storage
+                               capi-content-media-content
+                               libtzplatform-config eventsystem
+                               cynara-creds-dbus cynara-client cynara-session
+                               storage db-util libsystemd-login)
+pkg_check_modules(CALENDAR_SERVICE2 calendar-service2)
+pkg_check_modules(CONTACTS_SERVICE2 contacts-service2 zlib)
+
+#FOREACH(flag ${pkgs_CFLAGS})
+FOREACH(flag ${pkgs_CFLAGS} ${CALENDAR_SERVICE2_CFLAGS} ${CONTACTS_SERVICE2_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Werror -Wno-deprecated-declarations")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(INCLUDEDIR "/usr/include")
+SET(VERSION 1.0)
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DTARGET")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+#if(CALENDAR_SERVICE2_FOUND)
+#  ADD_DEFINITIONS("-DENABLE_CALENDAR_SERVICE2")
+#endif(CALENDAR_SERVICE2_FOUND)
+#if(CONTACTS_SERVICE2_FOUND)
+#  ADD_DEFINITIONS("-DENABLE_CONTACTS_SERVICE2")
+#endif(CONTACTS_SERVICE2_FOUND)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAGS} ${CONTACTS_SERVICE2_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
+#TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
+
+IF (BUILD_GCOV)
+# -fvisibility option should be "default" to call internal functions
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage")
+
+ADD_LIBRARY(bt-share SHARED ${SRCS})
+SET_TARGET_PROPERTIES(bt-share
+       PROPERTIES
+       SOVERSION 0.1.0
+       CLEAN_DIRECT_OUTPUT 1)
+
+TARGET_LINK_LIBRARIES(bt-share ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAGS} ${CONTACTS_SERVICE2_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api -lgcov)
+INSTALL(TARGETS bt-share DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+ENDIF (BUILD_GCOV)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.bluetooth.share.service DESTINATION share/dbus-1/system-services)
diff --git a/app/applog.h b/app/applog.h
new file mode 100644 (file)
index 0000000..5753b7a
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __APPLOG_H__
+#define __APPLOG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * SYSLOG_INFO(), SYSLOG_ERR(), SYSLOG_DBG() are syslog() wrappers.
+ * PRT_INFO(), PRT_ERR(), PRT_DBG() are fprintf() wrappers.
+ *
+ * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored.
+ *
+ * IF SLP_SYSLOG_OUT or SLP_DAEMON is defined,
+ *   INFO(), ERR(), DBG() are SYSLOG_XXX()
+ * Otherwise,
+ *   They are PRT_XXX()
+ *
+ *
+ * warn_if(exrp, fmt, ...)
+ *   If expr is true, The fmt string is printed using ERR().
+ *
+ * ret_if(), retv_if(), retm_if(), retvm_if()
+ *   If expr is true, current function return.
+ *   Postfix 'v' means that it has a return value and
+ *   'm' means that it has output message.
+ *
+ */
+
+#include <stdio.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "BLUETOOTH_SHARE"
+
+#define INFO(fmt, arg...) \
+       SLOGI(fmt, ##arg)
+
+#define ERR(fmt, arg...) \
+       SLOGE(fmt, ##arg)
+
+#define DBG(fmt, arg...) \
+       SLOGD(fmt, ##arg)
+
+#define        FN_START DBG("[ENTER FUNC]");
+#define        FN_END DBG("[EXIT FUNC]");
+
+#define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
+#define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
+#define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args)
+
+#define warn_if(expr, fmt, arg...) do { \
+               if (expr) { \
+                       ERR(fmt, ##arg); \
+               } \
+       } while (0)
+
+#define ret_if(expr) do { \
+               if (expr) { \
+                       return; \
+               } \
+       } while (0)
+
+#define retv_if(expr, val) do { \
+               if (expr) { \
+                       return (val); \
+               } \
+       } while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+               if (expr) { \
+                       ERR(fmt, ##arg); \
+                       return; \
+               } \
+       } while (0)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+               if (expr) { \
+                       ERR(fmt, ##arg); \
+                       return (val); \
+               } \
+       } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __APPLOG_H__ */
diff --git a/app/bt-share-common.c b/app/bt-share-common.c
new file mode 100644 (file)
index 0000000..e68b6ee
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <dd-display.h>
+#include <glib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <vconf.h>
+#include <Ecore_File.h>
+#include <bundle.h>
+#include <eventsystem.h>
+#include <sys/types.h>
+#include <sys/xattr.h>
+#include <linux/xattr.h>
+#include <storage.h>
+#include <systemd/sd-login.h>
+
+#include "vconf-keys.h"
+#include "applog.h"
+#include "bt-share-common.h"
+#include "bt-share-ipc.h"
+
+#if 0
+static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value)
+{
+       int ret;
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       bundle_add_str(b, key, value);
+
+       ret = eventsystem_send_system_event(event, b);
+
+       DBG("eventsystem_send_system_event result: %d", ret);
+
+       bundle_free(b);
+
+       return ret;
+}
+#endif
+
+int _bt_share_block_sleep(gboolean is_block)
+{
+       static int block_sleep_count = 0;
+       int result = BT_SHARE_FAIL;
+
+       DBG("is_block [%d], block_sleep_count[%d]\n", is_block,
+                    block_sleep_count);
+
+       if (is_block) {
+               if (block_sleep_count < 0) {
+                       /* This condition is for preventing the exception case, Never be called in the current logic */
+                       /* LCOV_EXCL_START */
+                       INFO("block_sleep_count[%d] is invalid. It is set to 0.\n",
+                                    block_sleep_count);
+                       block_sleep_count = 0;
+                       /* LCOV_EXCL_STOP */
+               } else if (block_sleep_count == 0) {
+                       result = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+                       if (result != 0)
+                               INFO("LCD Lock is failed with result code [%d]\n", result);
+               } else {
+                       result = BT_SHARE_ERROR_NONE;
+               }
+
+               if (result == BT_SHARE_ERROR_NONE)
+                       block_sleep_count++;
+       } else {
+               if (block_sleep_count <= 0) {
+                       INFO("block_sleep_count[%d] is invalid. It is set to 0.\n",
+                                    block_sleep_count);
+                       block_sleep_count = 0;
+               } else if (block_sleep_count == 1) {
+                       result = display_unlock_state(LCD_OFF, PM_RESET_TIMER);
+                       if (result != 0) {
+                               INFO("LCD Unlock is failed with result code [%d]\n",
+                                            result);
+                       }
+               } else {
+                       result = BT_SHARE_ERROR_NONE;
+               }
+
+               if (result == BT_SHARE_ERROR_NONE)
+                       block_sleep_count--;
+       }
+
+       DBG("result [%d]\n", result);
+       return result;
+}
+
+
+
+int _bt_set_transfer_indicator(gboolean state)
+{
+       static int block_cnt = 0;
+       int bt_device_state = 0;
+       int ret = VCONF_OK;
+       const char *event_val = NULL;
+
+       ret = vconf_get_int(VCONFKEY_BT_STATUS, (void *)&bt_device_state);
+       retvm_if(ret != VCONF_OK, VCONF_ERROR, "Get vconf failed\n");
+
+       if (state == TRUE) {
+               block_cnt++;
+               retv_if(bt_device_state & BT_STATUS_OFF, 0);
+               retv_if(bt_device_state & BT_STATUS_TRANSFER, 0);
+               bt_device_state |= BT_STATUS_TRANSFER;
+               event_val = EVT_VAL_BT_TRANSFERING;
+       } else {
+               if (block_cnt > 0)
+                       block_cnt--;
+               if (block_cnt != 0)
+                       return BT_SHARE_ERROR_NONE;
+               bt_device_state ^= BT_STATUS_TRANSFER;
+               event_val = EVT_VAL_BT_NON_TRANSFERING;
+       }
+
+       DBG("event_value: %s", event_val);
+
+       if (_bt_set_eventsystem_transfer_value(state) != BT_SHARE_ERROR_NONE)
+               ERR("Fail to set value"); /* LCOV_EXCL_LINE */
+
+#if 0
+       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_TRANSFERING_STATE,
+                                               event_val) != ES_R_OK)
+               ERR("Fail to set value");
+#endif
+
+       ret = vconf_set_int(VCONFKEY_BT_STATUS, bt_device_state);
+       retvm_if(ret != VCONF_OK, VCONF_ERROR, "Set vconf failed\n");
+       return BT_SHARE_ERROR_NONE;
+}
+
+static char *__bt_share_get_transfer_file_name(int file_type)
+{
+       int count = 0;
+       char *appendix = NULL;
+       char *file = NULL;
+       char *file_format = NULL;
+       char *file_name = NULL;
+
+       if (file_type == BT_HTTP_FILE) {
+               file_name = HTML_FILE_NAME;
+               file_format = HTML_FILE_FORMAT;
+       } else {
+               file_name = TXT_FILE_NAME;
+               file_format = TXT_FILE_FORMAT;
+       }
+
+       file = g_strdup(file_name);
+
+       /* While the file exists, increase the file name */
+       while (access(file, F_OK) == 0) {
+               g_free(file);
+
+               appendix = g_strdup_printf("_%d", count);
+               file = g_strdup_printf(file_format, appendix);
+               g_free(appendix);
+
+               count++;
+       }
+
+       return file;
+}
+
+void _bt_remove_tmp_file(char *file_path)
+{
+       if (g_str_has_prefix(file_path, BT_TMP_DIR) == TRUE) {
+               DBG_SECURE("Remove the file: %s", file_path);
+               ecore_file_remove(file_path);
+       }
+}
+
+void _bt_remove_vcf_file(char *file_path)
+{
+       if (g_str_has_prefix(file_path, BT_CONTACT_SHARE_TMP_DIR) == TRUE) {
+               DBG_SECURE("Remove the file: %s", file_path);
+               ecore_file_remove(file_path);
+       }
+}
+
+char *_bt_share_create_transfer_file(char *text)
+{
+       retv_if(text == NULL, NULL);
+
+       int fd = -1;
+       int file_type = -1;
+       char *file = NULL;
+       char *content = NULL;
+       char *url_sheme = NULL;
+       ssize_t write_size = -1;
+
+       url_sheme = g_uri_parse_scheme(text);
+
+       if (url_sheme) {
+               /* HTTP file generate */
+               g_free(url_sheme);
+               file_type = BT_HTTP_FILE;
+       } else {
+               /* TXT file generate */
+               file_type = BT_TXT_FILE;
+       }
+
+       file = __bt_share_get_transfer_file_name(file_type);
+       retv_if(file == NULL, NULL);
+
+       fd = open(file, O_RDWR | O_CREAT, 0755);
+
+       if (fd < 0) {
+               /* LCOV_EXCL_START */
+               ERR("Fail to open the file : %s", file);
+               goto fail;
+               /* LCOV_EXCL_STOP */
+       }
+
+       if (file_type == BT_HTTP_FILE)
+               content = g_strdup_printf(HTML_FORMAT, text, text);
+       else
+               content = g_strdup(text);
+
+       DBG_SECURE("content: \n%s", content);
+
+       write_size = write(fd, content, strlen(content));
+       g_free(content);
+       close(fd);
+
+       if (write_size < 0) {
+               /* LCOV_EXCL_START */
+               ERR("Fail to write in file");
+               goto fail;
+               /* LCOV_EXCL_STOP */
+       }
+
+       return file;
+fail:
+       g_free(file);
+       return NULL;
+}
+
+char *_bt_get_time_of_the_day(void)
+{
+       char *p = NULL;
+       char buffer[20] = {0, };
+       time_t cur_time = 0;
+       struct tm new_time;
+       struct timeval tv = {0, };
+
+       p = (char *)g_malloc(30);
+       gettimeofday(&tv, NULL);
+       cur_time = tv.tv_sec;
+       localtime_r(&cur_time, &new_time);
+       strftime(buffer, 20, "%m%d%Y%T", &new_time);
+       snprintf(p, 30, "%s%ld", buffer, tv.tv_usec);
+       return p;
+}
+
+/* LCOV_EXCL_START */
+static bool __bt_get_storage_id(int sid, storage_type_e type, storage_state_e state,
+               const char *path, void *user_data)
+{
+       int *storage_id = (int *)user_data;
+
+       if (type == STORAGE_TYPE_EXTERNAL && state == STORAGE_STATE_MOUNTED) {
+               *storage_id = sid;
+               return false;
+       }
+       return true;
+}
+/* LCOV_EXCL_STOP */
+
+void _bt_get_default_storage(char *storage)
+{
+       int val = BT_DEFAULT_MEM_PHONE;
+       char *path = NULL;
+
+       if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+                                               (void *)&val)) {
+               ERR("vconf error");
+               val = BT_DEFAULT_MEM_PHONE;
+       }
+
+       path = _bt_share_get_storage_path(val);
+
+       if (path == NULL)
+               path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+
+       g_strlcpy(storage, path, STORAGE_PATH_LEN_MAX);
+       g_free(path);
+
+       DBG("Default storage : %s\n", storage);
+
+       if (access(storage, W_OK) != 0)
+               DBG("Can't access the storage");
+}
+
+char *_bt_share_get_storage_path(int storage_type)
+{
+       int ret = 0;
+       int storage_id = 0;
+       char *path = NULL;
+
+       DBG("storage type: %d", storage_type);
+
+       if (storage_type == BT_DEFAULT_MEM_MMC) {
+               if (storage_foreach_device_supported(__bt_get_storage_id,
+                                               &storage_id) == STORAGE_ERROR_NONE) {
+                       DBG("storage_id = %d", storage_id);
+
+                       ret = storage_get_root_directory(storage_id, &path);
+
+                       if (ret != STORAGE_ERROR_NONE)
+                               DBG("Fail to get the download path: %d", ret);
+               }
+
+               if (path == NULL) {
+                       DBG("Fail to get the download path. So use media folder");
+                       path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+               }
+       } else {
+               path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+       }
+
+       return path;
+}
+
+int _bt_share_get_active_uid(uid_t *uid)
+{
+       DBG("+");
+
+       int ret = 0;
+       uid_t *active_user_list = NULL;
+       char *slice = NULL;
+       *uid = getuid();
+
+       ret = sd_pid_get_slice(getpid(), &slice);
+       if (0 <= ret && slice) {
+               if (!g_strcmp0(slice, "system.slice")) {
+                       ret = sd_get_uids(&active_user_list);
+                       /* the number of active users is 1 in tizen3.0 */
+                       if (1 == ret && active_user_list) {
+                               *uid = active_user_list[0];
+                               DBG("uid = %d", *uid);
+                       } else {
+                               ERR("sd_get_uids() Fail(%d)", ret);
+                               free(active_user_list);
+                               free(slice);
+                               return BT_SHARE_ERROR_NONE;
+                       }
+                       free(active_user_list);
+               }
+               free(slice);
+       } else {
+               ERR("sd_pid_get_slice() Fail(%d)", ret);
+       }
+
+       DBG("getuid() = %d, uid =  %d", getuid(), *uid);
+
+       return BT_SHARE_ERROR_NONE;
+}
+
+void _bt_convert_addr_type_to_string(char *address,
+                               char *addr)
+{
+       ret_if(address == NULL || addr == NULL);
+
+       g_snprintf(address, BT_ADDRESS_STRING_SIZE,
+                       "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
+                       addr[0], addr[1], addr[2],
+                       addr[3], addr[4], addr[5]);
+}
+
+int _bt_get_available_int_memory(double *dAvail)
+{
+       struct statvfs s = { 0, };
+       int r = 0;
+
+       r = storage_get_internal_memory_size(&s);
+       if (r < 0)
+               ERR("ret : %d", r);
+       else {
+               INFO("total : %lf, avail : %lf",
+               (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail);
+               *dAvail = (double)s.f_bsize*s.f_bavail;
+       }
+
+       return r;
+}
+
+gboolean _bt_get_available_ext_memory(unsigned long long *available_mem_size)
+{
+       struct statvfs s = {0, };
+       int r;
+
+       r = storage_get_internal_memory_size(&s);
+       if (r < 0) {
+               ERR("ret : %d", r);
+               *available_mem_size = 0;
+               return FALSE;
+       } else {
+               INFO("total : %lf, avail : %lf",
+               (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail);
+               *available_mem_size = (unsigned long long)s.f_bsize*s.f_bavail;
+       }
+
+       return TRUE;
+}
+
diff --git a/app/bt-share-common.h b/app/bt-share-common.h
new file mode 100644 (file)
index 0000000..e3f2aae
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_COMMON_H_
+#define __DEF_BLUETOOTH_SHARE_COMMON_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <tzplatform_config.h>
+
+/* Define Error type */
+#define BT_SHARE_FAIL -1
+#define BT_SHARE_ERROR_NONE 0
+
+#define BT_DEFAULT_MEM_PHONE 0
+#define BT_DEFAULT_MEM_MMC 1
+
+#define STORAGE_PATH_LEN_MAX 255
+
+#define BT_ADDRESS_STRING_SIZE 18 /**< This specifies bluetooth device address string length */
+#define BT_ADDRESS_LENGTH 6 /**< This specifies bluetooth device address length */
+
+#define BT_OBEX_PATH_PREFIX "/opt/usr/media"
+#define BT_OBEX_DEFAULT_PATH "/opt/usr/home/owner/media"
+
+#define BT_DOWNLOAD_DEFAULT_PHONE_FOLDER "/opt/usr/home/owner/media/Downloads"
+#define BT_DOWNLOAD_DEFAULT_MMC_FOLDER "/opt/media/SDCardA1"
+#define BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER "/opt/usr/home/owner/media/Downloads"
+#define BT_DOWNLOAD_PHONE_ROOT "/opt/usr/home/owner/media/"
+#define BT_DOWNLOAD_MMC_ROOT "/opt/media/SDCardA1"
+#define BT_FTP_FOLDER "/opt/share/bt-ftp"
+#define BT_FTP_FOLDER_PHONE "/opt/share/bt-ftp/Media/"
+#define BT_FTP_FOLDER_MMC "/opt/share/bt-ftp/SD_External/"
+
+#define BT_TMP_DIR "/opt/usr/home/owner/media/Downloads/"
+#define BT_TMP_FILE BT_TMP_DIR"bluetooth_content_share"
+#define TXT_FILE_NAME BT_TMP_DIR"bluetooth_content_share.txt"
+#define HTML_FILE_NAME BT_TMP_DIR"bluetooth_content_share.html"
+#define TXT_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.txt"
+#define HTML_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.html"
+#define HTML_FORMAT "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/></head><body><a href=\"%s\">%s</a></body></html>"
+#define BT_CONTACT_SHARE_TMP_DIR "/opt/usr/home/owner/media/Downloads/"
+
+#define BT_SHARE_DATA_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "bluetooth-share")
+
+typedef enum {
+       BT_HTTP_FILE,
+       BT_TXT_FILE,
+} bt_file_e;
+
+typedef enum {
+       BT_STATUS_OFF         = 0x0000,
+       BT_STATUS_ON          = 0x0001,
+       BT_STATUS_BT_VISIBLE  = 0x0002,
+       BT_STATUS_TRANSFER    = 0x0004,
+} bt_status_e;
+
+int _bt_share_block_sleep(gboolean is_block);
+int _bt_set_transfer_indicator(gboolean state);
+char *_bt_share_create_transfer_file(char *text);
+void _bt_remove_tmp_file(char *file_path);
+void _bt_remove_vcf_file(char *file_path);
+char *_bt_get_time_of_the_day(void);
+void _bt_get_default_storage(char *storage);
+char *_bt_share_get_storage_path(int storage_type);
+int _bt_share_get_active_uid(uid_t *uid);
+void _bt_convert_addr_type_to_string(char *address, char *addr);
+int _bt_get_available_int_memory(double *dAvail);
+gboolean _bt_get_available_ext_memory(unsigned long long *available_mem_size);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_COMMON_H_ */
diff --git a/app/bt-share-cynara.c b/app/bt-share-cynara.c
new file mode 100644 (file)
index 0000000..8f52232
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * bluetooth-share
+ *
+ * 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 "bt-share-cynara.h"
+
+#include "applog.h"
+#include "bt-share-common.h"
+
+#include <cynara-client.h>
+#include <cynara-session.h>
+#include <cynara-creds-dbus.h>
+#include <cynara-error.h>
+#include <malloc.h>
+
+static cynara *_cynara = NULL;
+const unsigned int error_msg_size = 256;
+
+/* LCOV_EXCL_START */
+// initialize cynara
+int _bt_share_cynara_init(void)
+{
+       char error_msg[error_msg_size];
+       int ret;
+
+       ret = cynara_initialize(&_cynara, NULL);
+       if (ret != CYNARA_API_SUCCESS) {
+               cynara_strerror(ret, error_msg, error_msg_size);
+               ERR("cynara_initialize failed: %s\n", error_msg);
+               return BT_SHARE_FAIL;
+       }
+
+       return BT_SHARE_ERROR_NONE;
+}
+
+// fill creds structure with data needed to perform checks using cynara-creds lib
+int _bt_share_cynara_get_creds(DBusConnection *conn, const char *sender,
+                                  bt_share_cynara_creds *creds)
+{
+       char error_msg[error_msg_size];
+       int ret;
+
+       ret = cynara_creds_dbus_get_pid(conn, sender, &(creds->pid));
+       if (ret < 0) {
+               cynara_strerror(ret, error_msg, error_msg_size);
+               ERR("cynara_creds_dbus_get_pid fail\n");
+               return BT_SHARE_FAIL;
+       }
+
+       ret = cynara_creds_dbus_get_user(conn, sender, USER_METHOD_UID, &(creds->uid));
+       if (ret < 0) {
+               cynara_strerror(ret, error_msg, error_msg_size);
+               ERR("cynara_creds_dbus_get_user failed\n");
+               return BT_SHARE_FAIL;
+       }
+
+       ret = cynara_creds_dbus_get_client(conn, sender, CLIENT_METHOD_SMACK, &(creds->smack));
+       if (ret < 0) {
+               cynara_strerror(ret, error_msg, error_msg_size);
+               ERR("cynara_creds_dbus_get_client failed\n");
+               return BT_SHARE_FAIL;
+       }
+
+       return BT_SHARE_ERROR_NONE;
+}
+
+// check if client has required privilege
+int _bt_share_cynara_check(const bt_share_cynara_creds *creds, const char *privilege)
+{
+       int ret;
+       char *client_session;
+       char error_msg[error_msg_size];
+
+       if (!creds || !privilege)
+               return BT_SHARE_FAIL;
+
+       client_session = cynara_session_from_pid(creds->pid);
+       if (!client_session) {
+               ERR("cynara_session_from_pid failed\n");
+               return BT_SHARE_FAIL;
+       }
+
+       ret = cynara_check(_cynara, creds->smack, client_session, creds->uid, privilege);
+       if (ret != CYNARA_API_ACCESS_ALLOWED) {
+               cynara_strerror(ret, error_msg, error_msg_size);
+               ERR("cynara_check error: %s\n", error_msg);
+       }
+
+       free(client_session);
+       return ret == CYNARA_API_ACCESS_ALLOWED ? BT_SHARE_ERROR_NONE : BT_SHARE_FAIL;
+}
+
+// finish working with cynara
+void _bt_share_cynara_finish(void)
+{
+       cynara_finish(_cynara);
+       _cynara = NULL;
+}
+/* LCOV_EXCL_STOP */
diff --git a/app/bt-share-cynara.h b/app/bt-share-cynara.h
new file mode 100644 (file)
index 0000000..ca028c7
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_CYNARA_H_
+#define __DEF_BLUETOOTH_SHARE_CYNARA_H_
+
+#include <unistd.h>
+#include <dbus/dbus.h>
+
+#define BT_SHARE_PRIVILEGE "http://tizen.org/privilege/bluetooth"
+
+/* #define CYNARA_ENABLE 1 */
+
+typedef struct {
+       pid_t pid;
+       char *uid;
+       char *smack;
+} bt_share_cynara_creds;
+
+int _bt_share_cynara_init(void);
+int _bt_share_cynara_get_creds(DBusConnection *conn, const char *sender,
+                                  bt_share_cynara_creds *creds);
+int _bt_share_cynara_check(const bt_share_cynara_creds *creds, const char *privilege);
+void _bt_share_cynara_finish(void);
+
+#endif                         /* __DEF_BLUETOOTH_SHARE_CYNARA_H_ */
diff --git a/app/bt-share-ipc.c b/app/bt-share-ipc.c
new file mode 100644 (file)
index 0000000..c47bda0
--- /dev/null
@@ -0,0 +1,1011 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <glib.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <notification.h>
+#include <aul.h>
+#include <vconf.h>
+#include <bundle_internal.h>
+
+#include "applog.h"
+#include "bt-share-main.h"
+#include "bt-share-ipc.h"
+#include "bt-share-syspopup.h"
+#include "bt-share-notification.h"
+#include "bt-share-resource.h"
+#include "obex-event-handler.h"
+#include "bluetooth-share-api.h"
+#include "bt-share-common.h"
+#include "bt-share-cynara.h"
+
+#define FILEPATH_LEN_MAX 4096
+
+#define SIGNAL_COUNT_TO_SUBSCRIBE 7
+
+GSList *bt_transfer_list = NULL;
+static GDBusConnection *gdbus_connection = NULL;
+static GDBusProxy *core_proxy = NULL;
+
+extern bt_appdata_t *app_state;
+
+static void __bt_create_send_data(opc_transfer_info_t *node);
+static void __bt_create_send_failed_data(char *filepath, char *dev_name,
+                                               char *addr, char *type, unsigned int size);
+static void __bt_share_update_tr_info(int tr_uid, int tr_type);
+static void __free_transfer_info(opc_transfer_info_t *node);
+static int __request_file_send(opc_transfer_info_t *node);
+static GDBusConnection *__bt_get_system_gconn(void);
+
+static void __bt_tr_data_free(bt_tr_data_t *data)
+{
+       retm_if(data == NULL, "Invalid param");
+
+       g_free(data->file_path);
+       g_free(data->dev_name);
+       g_free(data->addr);
+       g_free(data->type);
+       g_free(data->content);
+       g_free(data->db_sid);
+       g_free(data);
+}
+
+/* LCOV_EXCL_START */
+static void __popup_res_cb(int res)
+{
+       FN_START;
+       bt_appdata_t *ad = app_state;
+
+       retm_if(ad->popups.syspopup_request == FALSE, "This event is not mine\n");
+
+       DBG(" res : %d", res);
+       /* Inorder to support calling popup from callback, we have to make
+        * syspopup_request false here and also should not assign
+        * ad->popups.popup_cb = NULL */
+
+       ad->popups.syspopup_request = FALSE;
+
+       if (NULL != ad->popups.popup_cb) {
+               if (res == 0)
+                       ad->popups.popup_cb(ad->popups.popup_cb_data,
+                                           NULL, (void *)POPUP_RESPONSE_OK);
+               else if (res == 1)
+                       ad->popups.popup_cb(ad->popups.popup_cb_data,
+                                           NULL, (void *)POPUP_RESPONSE_CANCEL);
+               else if (res == 2)
+                       ad->popups.popup_cb(ad->popups.popup_cb_data,
+                                           NULL, (void *)POPUP_RESPONSE_TIMEOUT);
+       }
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static char *__bt_transfer_folder_path(char *dest_path)
+{
+       char *dst_path = (char *)g_malloc0(STORAGE_PATH_LEN_MAX);
+       if (dst_path == NULL) {
+               ERR("Not enough memory!");
+               return NULL;
+       }
+
+       if (g_str_has_prefix(dest_path, BT_OBEX_PATH_PREFIX))
+               snprintf(dst_path, STORAGE_PATH_LEN_MAX, BT_OBEX_DEFAULT_PATH"%s", dest_path + strlen(BT_OBEX_PATH_PREFIX));
+       else
+               snprintf(dst_path, STORAGE_PATH_LEN_MAX, "%s", dest_path);
+
+       DBG("obex transfed path : %s", dst_path);
+       return dst_path;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static opc_transfer_info_t *__add_transfer_info(GVariant *msg)
+{
+       FN_START;
+       retv_if(msg == NULL, NULL);
+
+       int i = 0;
+       int cnt = 0;
+       unsigned int file_size = 0;
+       char *name = NULL;
+       char *type = NULL;
+       char byte = 0;
+       char *file_path = NULL;
+       opc_transfer_info_t *data = NULL;
+       bt_appdata_t *ad = app_state;
+       GSList *list = NULL;
+       char addr[BLUETOOTH_ADDRESS_LENGTH] = {0, };
+       char mime_type[BT_MIME_TYPE_MAX_LEN] = {0, };
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
+       char file[FILEPATH_LEN_MAX] = {0, };
+       struct stat file_attr = {0, };
+
+       GVariantIter *iter_addr;
+       GVariantIter *iter_filepath;
+       GVariantIter *iter_file;
+
+       g_variant_get(msg, "(ayssaay)", &iter_addr, &name, &type, &iter_filepath);
+
+       while (g_variant_iter_loop(iter_addr, "y", &byte))
+               addr[i++] = byte;
+       g_variant_iter_free(iter_addr);
+
+       while (g_variant_iter_loop(iter_filepath, "ay", &iter_file)) {
+               char *dst_path = NULL;
+               i = 0;
+               memset(file, 0, FILEPATH_LEN_MAX);
+
+               while (g_variant_iter_loop(iter_file, "y", &byte))
+                       file[i++] = byte;
+
+               file_path = g_strdup(file);
+
+               dst_path = __bt_transfer_folder_path(file_path);
+               if (dst_path != NULL) {
+                       g_free(file_path);
+                       file_path = dst_path;
+               }
+
+               if (aul_get_mime_from_file(file_path, mime_type,
+                               BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
+                       INFO("mime type = %s", mime_type);
+
+               if (g_utf8_validate(file_path, -1, NULL)) {
+                       if (stat(file_path, &file_attr) == 0)
+                               file_size = file_attr.st_size;
+                       else
+                               file_size = 0;
+
+                       INFO("%d", file_size);
+                       list = g_slist_append(list, file_path);
+               } else {
+                       DBG("Invalid filepath");
+                       ad->send_data.tr_fail++;
+                       __bt_create_send_failed_data(file_path, name, addr,
+                                                               mime_type, file_size);
+
+                       _bt_convert_addr_type_to_string(bd_addr, addr);
+                       DBG_SECURE("bd_addr = [%s]", bd_addr);
+                       if (ad->send_noti == NULL) {
+                               ad->send_noti = _bt_insert_notification(ad,
+                                                       BT_SENT_NOTI, name,
+                                                       bd_addr, NULL);
+                       } else {
+                               _bt_update_notification(ad, ad->send_noti,
+                                               NULL, NULL, NULL, NULL, NULL);
+                       }
+
+                       g_free(file_path);
+                       file_path = NULL;
+               }
+       }
+
+       g_variant_iter_free(iter_filepath);
+
+       cnt = g_slist_length(list);
+       INFO("cnt = %d", cnt);
+
+       if (cnt == 0) {
+               /* Show unable to send popup */
+               _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL,
+                       BT_STR_UNABLE_TO_SEND);
+
+               g_slist_free_full(list, g_free);
+               g_free(name);
+               g_free(type);
+               return NULL;
+       }
+
+       INFO("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr[0],
+           addr[1], addr[2], addr[3], addr[4], addr[5]);
+       INFO(" cnt( %d )", cnt);
+       DBG_SECURE(" name ( %s )", name);
+
+       data = g_new0(opc_transfer_info_t, 1);
+       data->content = g_new0(char *, cnt + 1);
+       data->file_path = g_new0(char *, cnt + 1);
+       data->file_cnt = cnt;
+       data->type = g_new0(char *, cnt + 1);
+       data->size = (unsigned int *)g_new0(unsigned int *, cnt + 1);
+       memcpy(data->addr, addr, BLUETOOTH_ADDRESS_LENGTH);
+       memcpy(data->name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+
+       for (i = 0; i < cnt; i++) {
+               char *ptr = g_slist_nth_data(list, i);
+               DBG_SECURE("%s", ptr);
+               if (g_strcmp0(type, "text") == 0)
+                       data->file_path[i] = _bt_share_create_transfer_file(ptr);
+               else
+                       data->file_path[i] = g_strdup(ptr);
+
+               if (aul_get_mime_from_file(data->file_path[i], mime_type,
+                       BT_MIME_TYPE_MAX_LEN) == AUL_R_OK) {
+                       g_free(data->type[i]);
+                       data->type[i] = g_strdup(mime_type);
+               }
+
+               if (stat(data->file_path[i], &file_attr) == 0)
+                       file_size = file_attr.st_size;
+               else
+                       file_size = 0;
+
+               data->size[i] = file_size;
+               data->content[i] = g_strdup(ptr);
+               INFO(" type ( %s ), size (%d)", data->type[i], data->size[i]);
+       }
+
+       bt_transfer_list = g_slist_append(bt_transfer_list, data);
+
+       g_slist_free_full(list, g_free);
+       g_free(name);
+       g_free(type);
+
+       return data;
+}
+/* LCOV_EXCL_STOP */
+
+static void __free_transfer_info(opc_transfer_info_t *node)
+{
+       FN_START;
+       ret_if(node == NULL);
+
+       int i = 0;
+
+       for (i = 0; i < node->file_cnt; i++) {
+               g_free(node->file_path[i]);
+               g_free(node->content[i]);
+               g_free(node->type[i]);
+       }
+
+       g_free(node->file_path);
+       g_free(node->content);
+       g_free(node->type);
+       g_free(node->size);
+       g_free(node);
+
+       FN_END;
+}
+
+void _remove_transfer_info(opc_transfer_info_t *node)
+{
+       FN_START;
+       ret_if(node == NULL);
+
+       bt_transfer_list = g_slist_remove(bt_transfer_list, node);
+       __free_transfer_info(node);
+
+       FN_END;
+}
+
+/* LCOV_EXCL_START */
+static int __request_file_send(opc_transfer_info_t *node)
+{
+       FN_START;
+       int ret = 0;
+
+       retv_if(app_state == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+       retv_if(node == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+
+       ret = bluetooth_opc_push_files((bluetooth_device_address_t *)node->addr,
+                                    node->file_path);
+       retvm_if(ret != BLUETOOTH_ERROR_NONE, ret,
+                       "bluetooth_opc_push_files failed : %d", ret);
+
+       __bt_create_send_data(node);
+
+       FN_END;
+       return BLUETOOTH_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __event_filter(GDBusConnection *connection,
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       int ret = 0;
+       bt_appdata_t *ad = app_state;
+#ifdef CYNARA_ENABLE
+       const char *sender;
+       bt_share_cynara_creds sender_creds;
+#endif
+
+/*
+       DBG("Path = %s", object_path);
+*/
+       ret_if(object_path == NULL || strcmp(object_path, "/") == 0);
+       ret_if(interface_name == NULL || signal_name == NULL);
+
+       if (!g_strcmp0(interface_name, BT_SYSPOPUP_INTERFACE)) {
+               DBG("syspopup signal_name = %s", signal_name);
+               if (!g_strcmp0(signal_name, BT_SYSPOPUP_METHOD_RESPONSE)) {
+                       int res = 0;
+                       g_variant_get(parameters, "(i)", &res);
+                       __popup_res_cb(res);
+               }
+       } else if (!g_strcmp0(interface_name, BT_UG_IPC_INTERFACE)) {
+               DBG("ug signal_name = %s", signal_name);
+               if (!g_strcmp0(signal_name, BT_UG_IPC_METHOD_SEND)) {
+                       opc_transfer_info_t *node = NULL;
+
+#ifdef CYNARA_ENABLE
+               sender = dbus_message_get_sender(msg);
+               ret = _bt_share_cynara_get_creds(sys_conn, sender, &sender_creds);
+               if (ret != 0) {
+                       ERR("acquiring cynara creds failed\n");
+                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               }
+               if (_bt_share_cynara_check(&sender_creds, BT_SHARE_PRIVILEGE) != BT_SHARE_FAIL) {
+                       ERR("Cynara denied file send\n");
+                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               }
+#endif
+                       node = __add_transfer_info(parameters);
+                       retm_if(node == NULL, "node is NULL");
+
+                       ret = __request_file_send(node);
+                       if (ret == BLUETOOTH_ERROR_IN_PROGRESS) {
+                               INFO("Aleady OPC progressing. Once completed previous job, will be started");
+                       } else if (ret != BLUETOOTH_ERROR_NONE) {
+                               _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
+                               g_slist_free_full(bt_transfer_list, (GDestroyNotify)__free_transfer_info);
+                               bt_transfer_list = NULL;
+                       }
+               }
+       } else if (!g_strcmp0(interface_name, BT_SHARE_UI_INTERFACE)) {
+               DBG("share ui signal_name = %s", signal_name);
+
+               if (!g_strcmp0(signal_name, BT_SHARE_UI_SIGNAL_OPPABORT)) {
+                       const gchar *transfer_type = NULL;
+                       int noti_id = 0;
+
+                       g_variant_get(parameters, "(&si)", &transfer_type, &noti_id);
+
+                       ad->opp_transfer_abort = TRUE; /* Transfer aborted by user*/
+                       INFO("transfer_type = %s", transfer_type);
+                       if (!g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT)) {
+                               bluetooth_opc_cancel_push();
+                               if (ad->opc_noti) {
+                                       ret = _bt_delete_notification(ad->opc_noti);
+                                       if (ret == NOTIFICATION_ERROR_NONE) {
+                                               ad->opc_noti = NULL;
+                                               ad->opc_noti_id = 0;
+                                       }
+                               }
+                       } else {
+                               bluetooth_obex_server_cancel_transfer(noti_id);
+                       }
+               } else if (!g_strcmp0(signal_name, BT_SHARE_UI_SIGNAL_SEND_FILE)) {
+                       opc_transfer_info_t *node = NULL;
+
+#ifdef CYNARA_ENABLE
+                       sender = dbus_message_get_sender(msg);
+                       ret = _bt_share_cynara_get_creds(sys_conn, sender, &sender_creds);
+                       if (ret != 0) {
+                               ERR("acquiring cynara creds failed\n");
+                               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                       }
+
+                       if (_bt_share_cynara_check(&sender_creds, BT_SHARE_PRIVILEGE) != BT_SHARE_FAIL) {
+                               ERR("Cynara denied file send\n");
+                               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                       }
+#endif
+                       node = __add_transfer_info(parameters);
+                       retm_if(node == NULL, "node is NULL");
+
+                       ret = __request_file_send(node);
+                       if (ret == BLUETOOTH_ERROR_IN_PROGRESS) {
+                               INFO("Aleady OPC progressing. Once completed previous job, will be started");
+                       } else if (ret != BLUETOOTH_ERROR_NONE) {
+                               _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
+                               g_slist_free_full(bt_transfer_list, (GDestroyNotify)__free_transfer_info);
+                               bt_transfer_list = NULL;
+                       }
+               } else if (!g_strcmp0(signal_name, BT_SHARE_UI_SIGNAL_INFO_UPDATE)) {
+                       int tr_uid = 0;
+                       int tr_type = 0;
+
+                       g_variant_get(parameters, "(ii)", &tr_uid, &tr_type);
+
+                       __bt_share_update_tr_info(tr_uid, tr_type);
+               }
+       } else if (!g_strcmp0(interface_name, BT_SHARE_FRWK_INTERFACE)) {
+               DBG("frwk signal_name = %s", signal_name);
+
+               if (!g_strcmp0(signal_name, BT_SHARE_FRWK_SIGNAL_DEINIT)) {
+                       /* Deinitialize the obex server */
+                       if (bluetooth_obex_server_deinit() == BLUETOOTH_ERROR_NONE)
+                               DBG("Obex Server deinit");
+               }
+       } else if (!g_strcmp0(interface_name, BT_BLUEZ_INTERFACE)) {
+               if (!g_strcmp0(signal_name, BT_BLUEZ_SIGNAL_NAME_OWNER_CHANGED)) {
+                       char *name = NULL;
+                       char *previous = NULL;
+                       char *current = NULL;
+
+                       g_variant_get(parameters, "(&s&s&s)", &name, &previous, &current);
+
+                       if (*current != '\0')
+                               return;
+
+                       if (strcasecmp(name, "org.projectx.bt") == 0) {
+                               INFO("bt-service is terminated");
+                               _bt_terminate_bluetooth_share();
+                       }
+               }
+       } else {
+               DBG("Unhandled signal");
+       }
+}
+/* LCOV_EXCL_STOP */
+
+static int __bt_share_add_filter_subscribe_signal(GDBusConnection *conn,
+               gboolean subscribe)
+{
+       struct {
+               char *interface;
+               char *member;
+       } match_string[SIGNAL_COUNT_TO_SUBSCRIBE] = {
+                       { BT_SYSPOPUP_INTERFACE, BT_SYSPOPUP_METHOD_RESPONSE },
+                       { BT_UG_IPC_INTERFACE, BT_UG_IPC_METHOD_SEND},
+                       { BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_OPPABORT},
+                       { BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_SEND_FILE},
+                       { BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_INFO_UPDATE},
+                       { BT_SHARE_FRWK_INTERFACE, BT_SHARE_FRWK_SIGNAL_DEINIT},
+                       { BT_BLUEZ_INTERFACE, BT_BLUEZ_SIGNAL_NAME_OWNER_CHANGED}
+       };
+
+       static guint subs_add_filter_id[SIGNAL_COUNT_TO_SUBSCRIBE] = {0, };
+       int i;
+
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+
+       if (subscribe == FALSE) {
+               for (i = 0; i < SIGNAL_COUNT_TO_SUBSCRIBE; ++i) {
+                       if (subs_add_filter_id[i] != 0) {
+                               g_dbus_connection_signal_unsubscribe(conn, subs_add_filter_id[i]);
+                               subs_add_filter_id[i] = 0;
+                       }
+               }
+               return BLUETOOTH_ERROR_NONE;
+       }
+
+       for (i = 0; i < SIGNAL_COUNT_TO_SUBSCRIBE; ++i) {
+               if (subs_add_filter_id[i] == 0) {
+                       subs_add_filter_id[i] = g_dbus_connection_signal_subscribe(
+                                       conn, NULL, match_string[i].interface,
+                                       match_string[i].member, NULL, NULL,
+                                       G_DBUS_SIGNAL_FLAGS_NONE, __event_filter, NULL, NULL);
+               }
+       }
+       return BLUETOOTH_ERROR_NONE;
+}
+
+gboolean _bt_init_dbus_signal(void)
+{
+       FN_START;
+       GError *error = NULL;
+       GDBusConnection *conn = NULL;
+
+       conn = __bt_get_system_gconn();
+       if (!conn) {
+               /* LCOV_EXCL_START */
+               ERR("GDBUS get failed");
+               g_error_free(error);
+               return FALSE;
+               /* LCOV_EXCL_STOP */
+       }
+
+       gdbus_connection = conn;
+
+       /* Add the filter for network client functions */
+       __bt_share_add_filter_subscribe_signal(conn, TRUE);
+
+       FN_END;
+       return TRUE;
+}
+
+void _bt_deinit_dbus_signal(void)
+{
+       FN_START;
+       __bt_share_add_filter_subscribe_signal(gdbus_connection, FALSE);
+       FN_END;
+}
+
+void _bt_send_disconnected_signal(char *signal, int result,
+               char *address, int transfer_id)
+{
+       FN_START;
+       retm_if(gdbus_connection == NULL, "gdbus_connection == NULL");
+
+       GDBusMessage *msg = NULL;
+       GVariant *param = NULL;
+
+       msg = g_dbus_message_new_signal(BT_SHARE_ENG_OBJECT,
+                               BT_SHARE_ENG_INTERFACE,
+                               signal);
+       retm_if(msg == NULL, "Unable to allocate memory");
+
+       param = g_variant_new("(isi)", result, address, transfer_id);
+       g_dbus_message_set_body(msg, param);
+
+       g_dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
+       g_dbus_connection_send_message(gdbus_connection, msg,
+                       G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+
+       g_object_unref(msg);
+       FN_END;
+}
+
+void _bt_update_transfer_list_view(char *db)
+{
+       ret_if(gdbus_connection == NULL);
+
+       GDBusMessage *msg = NULL;
+       GVariant *param = NULL;
+
+       msg = g_dbus_message_new_signal(BT_SHARE_ENG_OBJECT,
+                               BT_SHARE_ENG_INTERFACE,
+                               BT_SHARE_ENG_SIGNAL_UPDATE_VIEW);
+       retm_if(!msg, "Unable to allocate memory");
+
+       param = g_variant_new("(s)", db);
+       g_dbus_message_set_body(msg, param);
+
+       g_dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
+       g_dbus_connection_send_message(gdbus_connection, msg,
+                       G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+
+       g_object_unref(msg);
+}
+
+void _bt_create_warning_popup(int error_type, char *msg)
+{
+       /* If bluetooth-share-ui process is  not running */
+       /* Then create the process and terminate it after popup shown */
+       if (aul_app_is_running(UI_PACKAGE) == 0) {
+               DBG("Creating new process for Warning Popup");
+               char str[BT_TEXT_LEN_MAX] = { 0, };
+               bundle *b = NULL;
+
+               DBG("error_type: %d", error_type);
+               switch (error_type) {
+               case BLUETOOTH_ERROR_SERVICE_NOT_FOUND:
+               case BLUETOOTH_ERROR_NOT_CONNECTED:
+               case BLUETOOTH_ERROR_ACCESS_DENIED:
+               case BLUETOOTH_ERROR_OUT_OF_MEMORY:
+               case BLUETOOTH_ERROR_INTERNAL:
+               case BLUETOOTH_ERROR_CANCEL:
+                       snprintf(str, BT_TEXT_LEN_MAX, "%s",
+                                msg);
+                       break;
+               default:
+                       return;
+               }
+
+               b = bundle_create();
+               ret_if(b == NULL);
+
+               bundle_add(b, "launch-type", "warning_popup");
+               bundle_add(b, "message", str);
+
+               aul_launch_app(UI_PACKAGE, b);
+
+               bundle_free(b);
+       }
+       return;
+}
+
+static time_t __bt_get_current_timedata(void)
+{
+       time_t t = 0;
+       time(&t);
+       return ((int)t);
+}
+
+/* LCOV_EXCL_START */
+static char *__bt_conv_addr_type_to_addr_string(char *addr)
+{
+       retv_if(addr == NULL, NULL);
+       char address[BT_ADDR_STR_LEN_MAX] = {0, };
+
+       snprintf(address, BT_ADDR_STR_LEN_MAX,
+                "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
+                addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+
+       return g_strdup(address);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_create_send_failed_data(char *filepath, char *dev_name,
+                                        char *addr, char *type, unsigned int size)
+{
+       int session_id = -1;
+       sqlite3 *db = NULL;
+
+       db = bt_share_open_db();
+       ret_if(!db);
+
+       session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
+       INFO("Last session id = %d", session_id);
+
+       bt_tr_data_t *tmp = NULL;
+       tmp = g_malloc0(sizeof(bt_tr_data_t));
+       ret_if(tmp == NULL);
+
+       tmp->tr_status = BT_TR_FAIL;
+       tmp->sid = session_id + 1;
+       tmp->file_path = g_strdup(filepath);
+       tmp->content = g_strdup(filepath);
+       tmp->dev_name = g_strdup(dev_name);
+       tmp->type = g_strdup(type);
+       tmp->timestamp = __bt_get_current_timedata();
+       tmp->addr = __bt_conv_addr_type_to_addr_string(addr);
+       tmp->size = size;
+       bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
+       __bt_tr_data_free(tmp);
+
+       bt_share_close_db(db);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_create_send_data(opc_transfer_info_t *node)
+{
+       FN_START;
+       ret_if(node == NULL);
+
+       int count = 0;
+       int session_id = -1;
+       char *snd_db_sid = NULL;
+       sqlite3 *db = NULL;
+
+       DBG_SECURE("Name [%s]", node->name);
+
+       db = bt_share_open_db();
+       ret_if(!db);
+
+       session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
+       snd_db_sid = _bt_get_time_of_the_day();
+       INFO("Last session id = %d", session_id);
+
+       for (count = 0; count < node->file_cnt; count++) {
+               bt_tr_data_t *tmp;
+               tmp = g_malloc0(sizeof(bt_tr_data_t));
+               if (tmp == NULL) {
+                       g_free(snd_db_sid);
+                       return;
+               }
+
+               tmp->tr_status = BT_TR_PENDING;
+               tmp->sid = session_id + 1;
+               tmp->file_path = g_strdup(node->file_path[count]);
+               DBG("tmp->file_path : %s", tmp->file_path);
+
+               tmp->content = g_strdup(node->content[count]);
+               tmp->dev_name = g_strdup(node->name);
+               tmp->type = g_strdup(node->type[count]);
+               tmp->timestamp = __bt_get_current_timedata();
+               tmp->addr = __bt_conv_addr_type_to_addr_string(node->addr);
+               tmp->size = node->size[count];
+               tmp->db_sid = g_strdup(snd_db_sid);
+               bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
+               __bt_tr_data_free(tmp);
+       }
+
+       bt_share_close_db(db);
+       g_free(snd_db_sid);
+
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+gboolean _bt_update_sent_data_status(int uid,
+                               bt_app_tr_status_e status, char *db_sid)
+{
+       INFO("uid = %d", uid);
+       sqlite3 *db = NULL;
+       bt_tr_data_t *tmp = NULL;
+
+       db = bt_share_open_db();
+       retv_if(!db, FALSE);
+
+       tmp = g_malloc0(sizeof(bt_tr_data_t));
+       retv_if(!tmp, FALSE);
+
+       tmp->tr_status = status;
+       tmp->timestamp = __bt_get_current_timedata();
+       tmp->db_sid = g_strdup(db_sid);
+       bt_share_update_tr_data(db, BT_DB_OUTBOUND, uid, tmp);
+       bt_share_close_db(db);
+
+       __bt_tr_data_free(tmp);
+       return TRUE;
+}
+
+gboolean _bt_update_recv_data_status(int uid,
+               bt_app_tr_status_e status, char *db_sid,
+               unsigned int filesize, const char *mime_type)
+{
+       INFO("uid = %d", uid);
+       sqlite3 *db = NULL;
+       bt_tr_data_t *tmp = NULL;
+
+       db = bt_share_open_db();
+       retv_if(!db, FALSE);
+
+       tmp = g_malloc0(sizeof(bt_tr_data_t));
+       retv_if(!tmp, FALSE);
+
+       tmp->tr_status = status;
+       tmp->timestamp = __bt_get_current_timedata();
+       tmp->db_sid = g_strdup(db_sid);
+       tmp->type = g_strdup(mime_type);
+       tmp->size = filesize;
+       bt_share_update_tr_data(db, BT_DB_INBOUND, uid, tmp);
+       bt_share_close_db(db);
+
+       __bt_tr_data_free(tmp);
+       return TRUE;
+}
+
+gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
+                               bt_app_tr_status_e status, char *db_sid)
+{
+       sqlite3 *db = NULL;
+       bt_tr_data_t *tmp = NULL;
+
+       db = bt_share_open_db();
+       retv_if(!db, FALSE);
+
+       tmp = g_malloc0(sizeof(bt_tr_data_t));
+       tmp->tr_status = status;
+       tmp->timestamp = __bt_get_current_timedata();
+       tmp->db_sid = g_strdup(db_sid);
+       bt_share_update_multiple_tr_data(db, BT_DB_OUTBOUND, uids, uid_cnt, tmp);
+       bt_share_close_db(db);
+
+       __bt_tr_data_free(tmp);
+       return TRUE;
+}
+
+gboolean _bt_add_recv_transfer_status_data(char *device_name,
+                       char *address, char *filepath, char *type,
+                       unsigned int size, int status, char *db_sid)
+{
+       retv_if(device_name == NULL || filepath == NULL, FALSE);
+
+       sqlite3 *db = NULL;
+       bt_tr_data_t *tmp = NULL;
+
+       DBG_SECURE("Name [%s]", device_name);
+
+       db = bt_share_open_db();
+       retv_if(!db, FALSE);
+
+       tmp = g_malloc0(sizeof(bt_tr_data_t));
+
+       tmp->tr_status = status;
+       tmp->file_path = g_strdup(filepath);
+       tmp->dev_name = g_strdup(device_name);
+       tmp->addr = g_strdup(address);
+       tmp->db_sid = g_strdup(db_sid);
+       tmp->timestamp = __bt_get_current_timedata();
+       tmp->type = g_strdup(type);
+       tmp->size = size;
+       bt_share_add_tr_data(db, BT_DB_INBOUND, tmp);
+       bt_share_close_db(db);
+
+       __bt_tr_data_free(tmp);
+       return TRUE;
+}
+
+int _bt_share_get_unique_id(int db_table, const char *db_sid)
+{
+       sqlite3 *db = NULL;
+       int index_id = -1;
+
+       DBG("db_table = %d", db_table);
+       db = bt_share_open_db();
+       retv_if(!db, 0);
+
+       index_id = bt_share_get_unique_id(db, db_table, db_sid);
+       bt_share_close_db(db);
+       DBG("index_id = %d", index_id);
+       return index_id;
+}
+
+/* LCOV_EXCL_START */
+static void __bt_share_update_tr_info(int tr_uid, int tr_type)
+{
+       DBG("tr_uid = %d", tr_uid);
+
+       int status = -1;
+       bt_appdata_t *ad = app_state;
+       bt_tr_data_t *info = NULL;
+       sqlite3 *db = NULL;
+
+       db = bt_share_open_db();
+       ret_if(!db);
+
+       if (tr_type == BT_TR_OUTBOUND) {
+               if (tr_uid == -1) {
+                       /* Click the "clear list" button in bluetooth-share-ui */
+                       /* Delete all outbound db / notification info */
+                       _bt_delete_notification(ad->send_noti);
+                       ad->send_noti = NULL;
+
+                       ad->send_data.tr_success = 0;
+                       ad->send_data.tr_fail = 0;
+                       DBG("clear all");
+                       bt_share_remove_tr_data_non_pending(db, BT_DB_OUTBOUND);
+                       bt_share_close_db(db);
+               } else {
+                       /* Delete selected outbound db / notification info */
+
+                       info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tr_uid);
+                       if (info != NULL) {
+                               status = info->tr_status;
+                               __bt_tr_data_free(info);
+                       }
+
+                       bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND,
+                                                     tr_uid);
+                       bt_share_close_db(db);
+
+                       if (status == BT_TR_SUCCESS && ad->send_data.tr_success > 0)
+                               ad->send_data.tr_success--;
+                       else if (status == BT_TR_FAIL && ad->send_data.tr_fail > 0)
+                               ad->send_data.tr_fail--;
+                       else
+                               return;
+
+                       if ((ad->send_data.tr_success + ad->send_data.tr_fail) != 0) {
+                               _bt_update_notification(ad, ad->send_noti,
+                                               NULL, NULL, NULL, NULL, NULL);
+                       } else {
+                               _bt_delete_notification(ad->send_noti);
+                       }
+               }
+       } else if (tr_type == BT_TR_INBOUND) {
+               if (tr_uid == -1) {
+                       /* Click the "clear list" button in bluetooth-share-ui */
+                       /* Delete all inbound db / notification info */
+
+                       _bt_delete_notification(ad->receive_noti);
+                       ad->receive_noti = NULL;
+                       ad->recv_data.tr_success = 0;
+                       ad->recv_data.tr_fail = 0;
+                       bt_share_remove_all_tr_data(db, BT_DB_INBOUND);
+                       bt_share_close_db(db);
+               } else {
+                       /* Delete selected outbound db / notification info */
+
+                       info = bt_share_get_tr_data(db, BT_DB_INBOUND, tr_uid);
+                       if (info != NULL) {
+                               status = info->tr_status;
+                               __bt_tr_data_free(info);
+                       }
+
+                       bt_share_remove_tr_data_by_id(db, BT_DB_INBOUND, tr_uid);
+                       bt_share_close_db(db);
+
+                       if (status == BT_TR_SUCCESS && ad->recv_data.tr_success > 0)
+                               ad->recv_data.tr_success--;
+                       else if (status == BT_TR_FAIL && ad->recv_data.tr_fail > 0)
+                               ad->recv_data.tr_fail--;
+                       else
+                               return;
+
+                       if ((ad->recv_data.tr_success + ad->recv_data.tr_fail) != 0) {
+                               _bt_update_notification(ad, ad->receive_noti,
+                                               NULL, NULL, NULL, NULL, NULL);
+                       } else {
+                               _bt_delete_notification(ad->receive_noti);
+                       }
+               }
+       } else {
+               ERR("Invalid transfer type");
+               bt_share_close_db(db);
+       }
+}
+/* LCOV_EXCL_STOP */
+
+static GDBusConnection *__bt_init_system_gconn(void)
+{
+       if (gdbus_connection == NULL)
+               gdbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+
+       return gdbus_connection;
+}
+
+static GDBusConnection *__bt_get_system_gconn(void)
+{
+       return (gdbus_connection) ? gdbus_connection : __bt_init_system_gconn();
+}
+
+GDBusProxy *__bt_init_core_proxy(void)
+{
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
+
+       conn = __bt_get_system_gconn();
+       if (!conn)
+               return NULL;
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL,
+                                       BT_CORE_NAME,
+                                       BT_CORE_PATH,
+                                       BT_CORE_INTERFACE,
+                                       NULL, NULL);
+
+       if (!proxy)
+               return NULL;
+
+       core_proxy = proxy;
+
+       return proxy;
+}
+
+static GDBusProxy *__bt_get_core_proxy(void)
+{
+       return (core_proxy) ? core_proxy : __bt_init_core_proxy();
+}
+
+int _bt_set_eventsystem_transfer_value(gboolean value)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *reply;
+       int ret = BT_SHARE_ERROR_NONE;
+
+       DBG("+");
+
+       proxy = __bt_get_core_proxy();
+       if (!proxy)
+               return BT_SHARE_FAIL;
+
+       reply = g_dbus_proxy_call_sync(proxy, "SetTransferValue",
+                       g_variant_new("(b)", value),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+
+       if (reply == NULL) {
+               ERR("Failed to Set tranfer value by bt core");
+               ret = BT_SHARE_FAIL;
+               if (error) {
+                       ERR("Error %s", error->message);
+                       g_error_free(error);
+               }
+       }
+       g_variant_unref(reply);
+
+       return ret;
+}
diff --git a/app/bt-share-ipc.h b/app/bt-share-ipc.h
new file mode 100644 (file)
index 0000000..853833a
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_IPC_H_
+#define __DEF_BLUETOOTH_SHARE_IPC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include "bluetooth-api.h"
+#include "bt-share-main.h"
+
+#define BT_BLUEZ_INTERFACE "org.freedesktop.DBus"
+#define BT_BLUEZ_SIGNAL_NAME_OWNER_CHANGED "NameOwnerChanged"
+
+#define BT_SYSPOPUP_INTERFACE "User.Bluetooth.syspopup"
+#define BT_SYSPOPUP_METHOD_RESPONSE "Response"
+
+#define BT_UG_IPC_INTERFACE "User.Bluetooth.UG"
+#define BT_UG_IPC_METHOD_SEND "Send"
+
+#define BT_SHARE_UI_INTERFACE "User.BluetoothShare.UI"
+#define BT_SHARE_UI_SIGNAL_OPPABORT "opp_abort"
+#define BT_SHARE_UI_SIGNAL_SEND_FILE "send_file"
+#define BT_SHARE_UI_SIGNAL_INFO_UPDATE "info_update"
+
+#define BT_SHARE_ENG_INTERFACE "User.BluetoothShare.Engine"
+#define BT_SHARE_ENG_OBJECT "/org/projectx/transfer_info"
+#define BT_SHARE_ENG_SIGNAL_UPDATE_VIEW "update_view"
+#define BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED "ShareOppClientDisconnected"
+#define BT_SHARE_ENG_SIGNAL_OPP_SERVER_DISCONNECTED "ShareOppServerDisconnected"
+#define BT_SHARE_FRWK_INTERFACE "User.Bluetooth.FRWK"
+#define BT_SHARE_FRWK_SIGNAL_DEINIT "deinit"
+
+#define BT_CORE_NAME "org.projectx.bt_core"
+#define BT_CORE_PATH "/org/projectx/bt_core"
+#define BT_CORE_INTERFACE "org.projectx.btcore"
+
+#define BT_IPC_STRING_SIZE 256
+#define BT_ADDR_STR_LEN_MAX    18
+#define BT_MIME_TYPE_MAX_LEN   20
+
+#define BT_INBOUND_TABLE       "inbound"
+#define BT_OUTBOUND_TABLE      "outbound"
+
+typedef enum {
+       BT_TR_PENDING = -2,
+       BT_TR_ONGOING = -1,
+       BT_TR_SUCCESS,
+       BT_TR_FAIL
+} bt_app_tr_status_e;
+
+typedef enum {
+       BT_TR_OUTBOUND,
+       BT_TR_INBOUND
+} bt_share_tr_type_e;
+
+typedef struct {
+       int file_cnt;
+       char addr[BLUETOOTH_ADDRESS_LENGTH];
+       char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX];
+       char *mode;
+       char **file_path;
+       char **content;
+       char **type;
+       unsigned int *size;
+} opc_transfer_info_t;
+
+gboolean _bt_init_dbus_signal(void);
+void _bt_deinit_dbus_signal(void);
+
+void _remove_transfer_info(opc_transfer_info_t *node);
+
+void _bt_create_warning_popup(int error_type, char *msg);
+gboolean _bt_update_sent_data_status(int uid,
+                               bt_app_tr_status_e status, char *db_sid);
+
+gboolean _bt_update_recv_data_status(int uid,
+               bt_app_tr_status_e status, char *db_sid,
+               unsigned int filesize, const char *mime_type);
+
+gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
+                               bt_app_tr_status_e status, char *db_sid);
+
+void _bt_update_transfer_list_view(char *db);
+void _bt_send_disconnected_signal(char *signal, int result, char *address,
+               int transfer_id);
+gboolean _bt_add_recv_transfer_status_data(char *device_name,
+                       char *address, char *filepath, char *type,
+                       unsigned int size, int status, char *db_sid);
+int _bt_share_get_unique_id(int db_table, const char *db_sid);
+int _bt_set_eventsystem_transfer_value(gboolean value);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_IPC_H_ */
diff --git a/app/bt-share-main.c b/app/bt-share-main.c
new file mode 100644 (file)
index 0000000..65bb335
--- /dev/null
@@ -0,0 +1,443 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <glib.h>
+#include <glib-object.h>
+#include <string.h>
+#include <appcore-efl.h>
+#include <vconf.h>
+#include <Ecore_File.h>
+#include <notification_internal.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
+#include "applog.h"
+#include "bt-share-main.h"
+#include "bluetooth-api.h"
+#include "obex-event-handler.h"
+#include "bt-share-ipc.h"
+#include "bt-share-noti-handler.h"
+#include "bt-share-resource.h"
+#include "bt-share-notification.h"
+#include "bt-share-common.h"
+#include "bt-share-cynara.h"
+
+#include "bluetooth-share-api.h"
+
+#define BLUETOOTH_SHARE_BUS            "org.projectx.bluetooth.share"
+
+static gboolean terminated;
+static GMainLoop *main_loop = NULL;
+bt_appdata_t *app_state = NULL;
+static guint owner_id;
+
+/* LCOV_EXCL_START */
+static void __lang_changed_cb(keynode_t *node, void *user_data)
+{
+       FN_START;
+       /* init internationalization */
+       retm_if(appcore_set_i18n(BT_COMMON_PKG, BT_COMMON_RES) < 0,
+                       "appcore_set_i18n failed!");
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+void _bt_terminate_bluetooth_share(void)
+{
+       FN_START;
+
+       if (main_loop)
+               g_main_loop_quit(main_loop); /* LCOV_EXCL_LINE */
+       else
+               terminated = TRUE;
+
+       FN_END;
+}
+
+/* LCOV_EXCL_START */
+static void __bt_release_service(bt_appdata_t *ad)
+{
+       ret_if(ad == NULL);
+
+       _bt_deinit_vconf_notification();
+       _bt_delete_notification(ad->opc_noti);
+       _bt_clear_receive_noti_list();
+       ad->send_noti = NULL;
+       ad->receive_noti = NULL;
+       ad->opc_noti = NULL;
+
+       bluetooth_opc_deinit();
+       bluetooth_obex_server_deinit();
+       _bt_unregister_notification_cb(ad);
+
+       vconf_ignore_key_changed(VCONFKEY_LANGSET, __lang_changed_cb);
+
+       g_free(server_auth_info.filename);
+       g_free(server_auth_info.name);
+       server_auth_info.filename = NULL;
+       server_auth_info.name = NULL;
+
+       if (ad->idler > 0) {
+               DBG("Removing idler!!!");
+               g_source_remove(ad->idler);
+       }
+       if (owner_id != 0)
+               g_bus_unown_name(owner_id);
+
+       DBG("Terminating bluetooth-share daemon");
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_sigterm_handler(int signo)
+{
+       FN_START;
+
+       if (main_loop)
+               g_main_loop_quit(main_loop);
+       else
+               terminated = TRUE;
+
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_update_transfer_status_values(void)
+{
+       bt_appdata_t *ad = app_state;
+       GSList *tr_data_list = NULL;
+       GSList *list_iter = NULL;
+       bt_tr_data_t *info = NULL;;
+       sqlite3 *db = NULL;
+
+#if 0
+       /* Update notification status durning BT off */
+       retm_if(_bt_update_notification_status(ad) == FALSE,
+                       "Notification item is not existed.");
+#endif
+
+       DBG("Initialize transfer information");
+
+       db = bt_share_open_db();
+       ret_if(!db);
+
+       tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_OUTBOUND);
+       if (tr_data_list != NULL) {
+               list_iter = tr_data_list;
+
+               while (list_iter != NULL) {
+                       info = list_iter->data;
+                       if (info == NULL)
+                               break;
+
+                       if (info->tr_status == BT_TRANSFER_SUCCESS) {
+                               ad->send_data.tr_success++;
+                       } else if (info->tr_status == BT_TRANSFER_FAIL) {
+                               ad->send_data.tr_fail++;
+                       } else if (info->tr_status == BT_TRANSFER_ONGOING) {
+                               /* In case of ongoing file transfer if bluetooth is switched off
+                               we need to update the status to fail for these transaction */
+                               ad->send_data.tr_fail++;
+                               info->tr_status = BT_TR_FAIL;
+                               bt_share_update_tr_data(db, BT_DB_OUTBOUND, info->id, info);
+                       } else {
+                               ERR("Invalid status");
+                       }
+
+                       list_iter = g_slist_next(list_iter);
+               }
+
+               bt_share_release_tr_data_list(tr_data_list);
+               tr_data_list = NULL;
+               list_iter = NULL;
+       }
+
+       tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_INBOUND);
+       if (tr_data_list != NULL) {
+               list_iter = tr_data_list;
+
+               while (list_iter != NULL) {
+                       info = list_iter->data;
+                       if (info == NULL)
+                               break;
+
+                       if (info->tr_status == BT_TRANSFER_SUCCESS)
+                               ad->recv_data.tr_success++;
+                       else
+                               ad->recv_data.tr_fail++;
+
+                       list_iter = g_slist_next(list_iter);
+               }
+               bt_share_release_tr_data_list(tr_data_list);
+               tr_data_list = NULL;
+               list_iter = NULL;
+       }
+
+       bt_share_close_db(db);
+
+       DBG("[Send] success %d, fail %d", ad->send_data.tr_success,
+                       ad->send_data.tr_fail);
+       DBG("[Receive] success %d, fail %d", ad->recv_data.tr_success,
+                       ad->recv_data.tr_fail);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static GSList *__merge_sorted(GSList *inbound, GSList *outbound)
+{
+       GSList *slist = NULL;
+       int *inbound_noti_id = NULL;
+       int *outbound_noti_id = NULL;
+
+       warn_if(inbound == NULL, "No inbound data!!!");
+       warn_if(outbound == NULL, "No outbound data!!!");
+
+/* **********************Note from glib documentation**************************
+ * g_slist_append() has to traverse the entire list to find the end, which
+ * is inefficient when adding multiple elements. A common idiom to avoid the
+ * inefficiency is to use g_slist_prepend() and reverse the list with
+ * g_slist_reverse() when all elements have been added.
+ * ***************************************************************************/
+
+       while (inbound && outbound) {
+               inbound_noti_id = (int *)inbound->data;
+               outbound_noti_id = (int *)outbound->data;
+
+               if (*inbound_noti_id > *outbound_noti_id) {
+                       slist = g_slist_prepend(slist, outbound_noti_id);
+                       outbound = g_slist_next(outbound);
+               } else {
+                       slist = g_slist_prepend(slist, inbound_noti_id);
+                       inbound = g_slist_next(inbound);
+               }
+       }
+
+       while (inbound) {
+               inbound_noti_id = (int *)inbound->data;
+               slist = g_slist_prepend(slist, inbound_noti_id);
+               inbound = g_slist_next(inbound);
+       }
+
+       while (outbound) {
+               outbound_noti_id = (int *)outbound->data;
+               slist = g_slist_prepend(slist, outbound_noti_id);
+               outbound = g_slist_next(outbound);
+       }
+
+       return slist;
+}
+/* LCOV_EXCL_STOP */
+
+void _bt_remove_temporary_files_by_noti_id(sqlite3 *db, int noti_id)
+{
+       FN_START;
+       GSList *file_list = bt_share_get_all_temporary_files_by_noti_id(db, noti_id, BT_TMP_DIR);
+
+       GSList *current_file = file_list;
+       while (current_file) {
+               /* LCOV_EXCL_START */
+               DBG("Removing [%s]", (char *)(current_file->data));
+               ecore_file_remove((char *)(current_file->data));
+               current_file = g_slist_next(current_file);
+               /* LCOV_EXCL_STOP */
+       }
+
+       bt_share_release_temporary_file_list(file_list);
+       FN_END;
+}
+
+/* LCOV_EXCL_START */
+gboolean __bt_clean_database(gpointer user_data)
+{
+       bt_appdata_t *ad = app_state;
+       notification_h noti = NULL;
+       notification_list_h noti_list = NULL;
+       notification_list_h current_noti = NULL;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+       sqlite3 *db = NULL;
+       GSList *inbound = NULL;
+       GSList *outbound = NULL;
+       GSList *slist = NULL;
+       GSList *current = NULL;
+       int group_id = 0;
+       int priv_id = 0;
+       int noti_id = 0;
+
+       FN_START;
+
+       if (ad->idler) {
+               DBG("Removing g_idler!!!");
+               g_source_remove(ad->idler);
+               ad->idler = 0;
+       }
+
+       noti_err = notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               ERR("Error in getting notification list. error(%d)", noti_err);
+               return G_SOURCE_REMOVE;
+       }
+
+       db = bt_share_open_db();
+       inbound = bt_share_get_noti_list(db, BT_DB_INBOUND);
+       outbound = bt_share_get_noti_list(db, BT_DB_OUTBOUND);
+
+       slist = __merge_sorted(inbound, outbound);
+       current = slist;
+       noti_list = notification_list_get_head(noti_list);
+       current_noti = noti_list;
+
+       while (current_noti && current) {
+               noti = notification_list_get_data(current_noti);
+               noti_err  = notification_get_id(noti, &group_id, &priv_id);
+               noti_id = *(int *)(current->data);
+               DBG("priv_id: %d | noti_id: %d", priv_id, noti_id);
+               if (noti_err == NOTIFICATION_ERROR_NONE) {
+                       if (priv_id == noti_id) {
+                               current = g_slist_next(current);
+                               current_noti = notification_list_get_next(current_noti);
+                       } else if (noti_id > priv_id) {
+                               DBG("Removing data by notification id: %d", noti_id);
+
+                               /* Remove all temporary files related to this noti_id */
+                               _bt_remove_temporary_files_by_noti_id(db, noti_id);
+
+                               bt_share_remove_tr_data_by_notification(db, BT_DB_INBOUND, noti_id);
+                               bt_share_remove_tr_data_by_notification(db, BT_DB_OUTBOUND, noti_id);
+                               current = g_slist_next(current);
+                       } else {
+                               current_noti = notification_list_get_next(current_noti);
+                       }
+               } else {
+                       current_noti = notification_list_get_next(current_noti);
+               }
+       }
+
+       /* Remove remaining records with remaining noti_id in slist */
+       while (current) {
+               noti_id = *(int *)(current->data);
+               DBG("Removing data by notification id: %d", noti_id);
+
+               /* Remove all temporary files related to this noti_id */
+               _bt_remove_temporary_files_by_noti_id(db, noti_id);
+
+               bt_share_remove_tr_data_by_notification(db, BT_DB_INBOUND, noti_id);
+               bt_share_remove_tr_data_by_notification(db, BT_DB_OUTBOUND, noti_id);
+               current = g_slist_next(current);
+       }
+
+       bt_share_close_db(db);
+       notification_free_list(noti_list);
+       bt_share_release_noti_list(inbound);
+       bt_share_release_noti_list(outbound);
+       g_slist_free(slist);
+
+
+       FN_END
+       return G_SOURCE_REMOVE;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static gboolean __bt_dbus_request_name(void)
+{
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, BLUETOOTH_SHARE_BUS,
+                       G_DBUS_CALL_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL);
+
+       return (owner_id != 0) ? TRUE : FALSE;
+}
+/* LCOV_EXCL_STOP */
+
+int _bt_init_obex_server(void)
+{
+       retvm_if(bluetooth_obex_server_init(BT_SHARE_DATA_DIR) != BLUETOOTH_ERROR_NONE,
+                       BT_SHARE_FAIL, "Fail to init obex server");
+
+       /* LCOV_EXCL_START */
+       bluetooth_obex_server_set_root(BT_SHARE_DATA_DIR);
+
+       return BT_SHARE_ERROR_NONE;
+       /* LCOV_EXCL_STOP */
+}
+
+/* LCOV_EXCL_START */
+int main(void)
+{
+       int ret = 0;
+       INFO("Starting bluetooth-share daemon");
+
+       signal(SIGTERM, __bt_sigterm_handler);
+
+       app_state = calloc(1, sizeof(bt_appdata_t));
+       if (!app_state)
+               return -1;
+
+       if (__bt_dbus_request_name() == FALSE) {
+               INFO("Aleady dbus instance existed");
+               exit(0);
+       }
+
+       /* init internationalization */
+       retvm_if(appcore_set_i18n(BT_COMMON_PKG, BT_COMMON_RES) < 0,
+                       BT_SHARE_FAIL, "appcore_set_i18n failed!");
+
+       if (_bt_share_cynara_init()) {
+               ERR("Failed to initialize Cynara.\n");
+               return -1;
+       }
+
+       ret = vconf_notify_key_changed(VCONFKEY_LANGSET, __lang_changed_cb, NULL);
+       warn_if(ret != VCONF_OK, "vconf_notify_key_changed failed");
+
+       ret = bluetooth_register_callback(_bt_share_event_handler, NULL);
+       warn_if(ret != BLUETOOTH_ERROR_NONE && ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED,
+                       "bluetooth_register callback failed");
+
+       ret = bluetooth_opc_init();
+       retvm_if(ret != BLUETOOTH_ERROR_NONE, BT_SHARE_FAIL, "bluetooth_opc_init failed");
+
+       _bt_init_dbus_signal();
+       _bt_init_vconf_notification((void *)app_state);
+       __bt_update_transfer_status_values();
+       _bt_register_notification_cb(app_state);
+
+       if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
+               app_state->obex_server_init = TRUE;
+
+       if (terminated == TRUE) {
+               __bt_release_service(app_state);
+               _bt_deinit_dbus_signal();
+               bluetooth_unregister_callback();
+               return BT_SHARE_FAIL;
+       }
+
+       app_state->idler = g_idle_add(__bt_clean_database, NULL);
+       warn_if(!app_state->idler, "Failed to create idler!!!");
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(main_loop);
+
+       __bt_release_service(app_state);
+       _bt_deinit_dbus_signal();
+       bluetooth_unregister_callback();
+
+       return BT_SHARE_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
diff --git a/app/bt-share-main.h b/app/bt-share-main.h
new file mode 100644 (file)
index 0000000..d8e6048
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_H_
+#define __DEF_BLUETOOTH_SHARE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <notification.h>
+#include <tzplatform_config.h>
+#include <db-util.h>
+
+#ifndef PACKAGE_NAME
+#define PACKAGE_NAME "bluetooth-share"
+#endif
+
+#define UI_PACKAGE "org.tizen.bluetooth-share-ui"
+
+typedef void (*bt_app_cb) (void *, void *, void *);
+
+typedef struct {
+       bt_app_cb popup_cb;
+       void *popup_cb_data;
+       gboolean syspopup_request;
+} bt_app_popups_t;
+
+typedef struct {
+       int tr_success;
+       int tr_fail;
+} bt_transfer_status_info_t;
+
+typedef struct {
+       bt_app_popups_t popups;
+       bt_transfer_status_info_t send_data;
+       bt_transfer_status_info_t recv_data;
+       GSList *tr_send_list;
+       GSList *tr_next_data;
+       int current_tr_uid;
+       notification_h send_noti;
+       notification_h receive_noti;
+       notification_h opc_noti;
+       int send_noti_id;
+       int receive_noti_id;
+       int opc_noti_id;
+       GDBusConnection *conn;
+       GObject *object;
+       gboolean obex_server_init;
+       bool opp_transfer_abort;
+       guint idler;
+} bt_appdata_t;
+
+int _bt_init_obex_server(void);
+
+void _bt_terminate_bluetooth_share(void);
+
+void _bt_remove_temporary_files_by_noti_id(sqlite3 *db, int noti_id);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_H_ */
diff --git a/app/bt-share-noti-handler.c b/app/bt-share-noti-handler.c
new file mode 100644 (file)
index 0000000..98c6b9b
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <glib.h>
+#include <vconf.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <storage.h>
+/* For multi-user support */
+#include <tzplatform_config.h>
+
+#include "applog.h"
+#include "bt-share-common.h"
+#include "bluetooth-api.h"
+#include "bt-share-noti-handler.h"
+#include "bt-share-main.h"
+#include "bt-share-notification.h"
+#include "obex-event-handler.h"
+
+/* LCOV_EXCL_START */
+static void __bt_default_memory_changed_cb(keynode_t *node, void *data)
+{
+       FN_START;
+       ret_if(node == NULL);
+
+       int default_memory = 0;
+       char *root_path = NULL;
+       char *download_path = NULL;
+
+       DBG_SECURE("key=%s\n", vconf_keynode_get_name(node));
+
+       if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) {
+               /* Phone memory is 0, MMC is 1 */
+               default_memory = vconf_keynode_get_int(node);
+
+               if (default_memory == BT_DEFAULT_MEM_MMC) /* MMC */ {
+                       download_path = _bt_share_get_storage_path(default_memory);
+                       root_path = _bt_share_get_storage_path(default_memory);
+
+                       if (download_path == NULL)
+                               download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+
+                       if (root_path == NULL)
+                               root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+
+               } else {
+                       download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+                       root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+               }
+
+               if (access(download_path, W_OK) != 0) {
+                       warn_if(mkdir(download_path, 0755) < 0,
+                                       "mkdir fail![%s]", download_path);
+               }
+
+               bluetooth_obex_server_set_root(root_path);
+               bluetooth_obex_server_set_destination_path(download_path);
+
+               g_free(download_path);
+               g_free(root_path);
+       }
+
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_mmc_status_changed_cb(keynode_t *node, void *data)
+{
+       FN_START;
+       retm_if(!node || !data, "invalid param!");
+
+       int mmc_status = 0;
+       int default_memory = 0;
+       int ret = NOTIFICATION_ERROR_NONE;
+       char *root_path = NULL;
+       char *download_path = NULL;
+
+       DBG_SECURE("key=%s", vconf_keynode_get_name(node));
+       bt_appdata_t *ad = (bt_appdata_t *)data;
+
+       if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) {
+               /* Phone memory is 0, MMC is 1 */
+               mmc_status = vconf_keynode_get_int(node);
+
+               if (mmc_status == VCONFKEY_SYSMAN_MMC_REMOVED ||
+                       mmc_status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
+                       retm_if(vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+                                                       &default_memory) != 0,
+                                                       "vconf_get_int failed");
+
+                       if (ad->opc_noti) {     /* sending case */
+                               DBG("cancel outbound transfer");
+                               bluetooth_opc_cancel_push();
+                               ret = _bt_delete_notification(ad->opc_noti);
+                               if (ret == NOTIFICATION_ERROR_NONE) {
+                                       ad->opc_noti = NULL;
+                                       ad->opc_noti_id = 0;
+                               }
+                       } else {                /* receiving case */
+                               DBG("cancel inbound transfer");
+                               if (default_memory == BT_DEFAULT_MEM_MMC) {
+                                       _bt_obex_cancel_transfer(data);
+                                       retm_if(vconf_set_int(
+                                               VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+                                               BT_DEFAULT_MEM_PHONE) != 0, "vconf_set_int failed");
+                                       DBG_SECURE("Default Memory set to Phone");
+                               }
+                       }
+               } else if (mmc_status == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+                       vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, &default_memory);
+                       if (default_memory == BT_DEFAULT_MEM_MMC) /* MMC */ {
+                               download_path = _bt_share_get_storage_path(default_memory);
+                               root_path = _bt_share_get_storage_path(default_memory);
+
+                               if (download_path == NULL)
+                                       download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+
+                               if (root_path == NULL)
+                                       root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+
+                       } else {
+                               download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+                               root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
+                       }
+
+                       if (access(download_path, W_OK) != 0) {
+                               warn_if(mkdir(download_path, 0755) < 0,
+                                               "mkdir fail![%s]", download_path);
+                       }
+
+                       bluetooth_obex_server_set_root(root_path);
+                       bluetooth_obex_server_set_destination_path(download_path);
+
+                       g_free(download_path);
+                       g_free(root_path);
+               }
+       }
+
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+void _bt_init_vconf_notification(void *data)
+{
+       retm_if(!data, "invalid param!");
+
+       int ret = VCONF_OK;
+
+       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+                       __bt_default_memory_changed_cb, NULL);
+       warn_if(ret != VCONF_OK, "vconf_notify_key_changed init failed");
+
+       ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+                       __bt_mmc_status_changed_cb, data);
+       warn_if(ret != VCONF_OK, "vconf_notify_key_changed init failed");
+}
+
+void _bt_deinit_vconf_notification(void)
+{
+       int ret = VCONF_OK;
+       ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+                       (vconf_callback_fn) __bt_default_memory_changed_cb);
+       warn_if(ret != VCONF_OK, "vconf_notify_key_changed deinit failed");
+
+       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+                       (vconf_callback_fn) __bt_mmc_status_changed_cb);
+       warn_if(ret != VCONF_OK, "vconf_notify_key_changed deinit failed");
+}
+
diff --git a/app/bt-share-noti-handler.h b/app/bt-share-noti-handler.h
new file mode 100644 (file)
index 0000000..c346618
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_NOTI_HANDLER_H_
+#define __DEF_BLUETOOTH_SHARE_NOTI_HANDLER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void _bt_init_vconf_notification(void *data);
+void _bt_deinit_vconf_notification(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_NOTI_HANDLER_H_ */
diff --git a/app/bt-share-notification.c b/app/bt-share-notification.c
new file mode 100644 (file)
index 0000000..b59eae3
--- /dev/null
@@ -0,0 +1,673 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <applog.h>
+#include <notification.h>
+#include <notification_list.h>
+#include <notification_text_domain.h>
+#include <notification_internal.h>
+#include <appsvc.h>
+#include <vconf.h>
+
+#include "bt-share-common.h"
+#include "bt-share-notification.h"
+#include "bt-share-main.h"
+#include "bt-share-ipc.h"
+#include "obex-event-handler.h"
+#include "bluetooth-share-api.h"
+#include "bt-share-resource.h"
+
+#define BT_PRIV_ID_STR_LEN 12
+
+extern GSList *bt_rcv_noti_info_list;
+extern GSList *bt_snd_noti_info_list;
+
+void _bt_insert_instant_notification(bt_notification_type_e type)
+{
+       FN_START;
+       notification_h noti = NULL;
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+       char *title = NULL;
+       char *icon_path = NULL;
+
+       DBG("Create notification type : %d", type);
+
+       switch (type) {
+       case BT_SENDING_NOTI: {
+               title = BT_STR_SENDING_FILES;
+               icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
+               break;
+       }
+
+       case BT_RECEIVING_NOTI: {
+               title = BT_STR_RECEIVING_FILES;
+               icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
+               break;
+       }
+
+       case BT_SENT_NOTI: {
+               title = BT_STR_FILES_SENT;
+               icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
+               break;
+       }
+
+       case BT_SENT_FAILED_NOTI: {
+               title = BT_STR_SENDING_FILES_FAILED;
+               icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
+               break;
+       }
+
+       case BT_RECEIVED_NOTI: {
+               title = BT_STR_FILES_RECEIVED;
+               icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
+               break;
+       }
+
+       case BT_RECEIVED_FAILED_NOTI: {
+               title = BT_STR_RECEIVING_FILES_FAILED;
+               icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
+               break;
+       }
+
+       default:
+               return;
+       }
+
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       retm_if(!noti, "Fail to notification_create");
+
+       if (title) {
+               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                                       NULL, title,
+                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                               "Fail to notification_set_text [%d]", ret);
+       }
+
+       if (icon_path) {
+               ret = notification_set_image(noti,
+                               NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, icon_path);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_image [%d]", ret);
+       }
+
+       ret  = notification_set_display_applist(noti,
+                       NOTIFICATION_DISPLAY_APP_TICKER);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_set_display_applist [%d]", ret);
+
+       ret = notification_post(noti);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_insert [%d]", ret);
+
+       if (noti)
+               notification_free(noti);
+       FN_END;
+}
+
+notification_h _bt_insert_notification(bt_appdata_t *ad,
+                       bt_notification_type_e type, char *dev_name,
+                       char *address, char *db_sid)
+{
+       notification_h noti = NULL;
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+       notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
+       char *title = NULL;
+       char *content = NULL;
+       char *icon_path = NULL;
+       char *indicator_icon_path = NULL;
+       char *app_id = NULL;
+       int noti_id = 0;
+       int flag = -1;
+       int success = 0;
+       int fail = 0;
+       bool include_name_param = false;
+
+       DBG("Create notification type : %d", type);
+
+       if (type == BT_SENT_NOTI) {
+               success = ad->send_data.tr_success;
+               fail = ad->send_data.tr_fail;
+
+               if (success == 0) {
+                       title = "IDS_BT_MBODY_SENDING_FAILED";
+               } else {
+                       title = "IDS_WIFI_BODY_FILES_SENT_TO_PS_M_STATUS";
+                       include_name_param = true;
+               }
+
+               if (success == 0 && fail > 0)
+                       content = "IDS_BT_SBODY_PD_FAILED_ABB";
+               else if (fail == 0 && success > 0)
+                       content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
+               else
+                       content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
+
+               icon_path = BT_ICON_NOTIFICATION_SENT;
+               indicator_icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
+               flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE;
+               app_id = NOTI_OPC_APP_ID;
+               noti_type = NOTIFICATION_TYPE_NOTI;
+       } else if (type == BT_RECEIVED_NOTI) {
+               success = ad->recv_data.tr_success;
+               fail = ad->recv_data.tr_fail;
+
+               if (success == 0 && fail > 0) {
+                       content = "IDS_BT_SBODY_PD_FAILED_ABB";
+                       title = "IDS_BT_MBODY_RECEIVING_FAILED";
+               } else if (fail == 0 && success > 0) {
+                       title = "IDS_WIFI_MBODY_FILES_RECEIVED_FROM_PS";
+                       content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
+                       include_name_param = true;
+               } else {
+                       title = "IDS_WIFI_MBODY_FILES_RECEIVED_FROM_PS";
+                       content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
+                       include_name_param = true;
+               }
+               icon_path = BT_ICON_NOTIFICATION_RECEIVED;
+               indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
+               flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE;
+               app_id = NOTI_OPS_APP_ID;
+               noti_type = NOTIFICATION_TYPE_NOTI;
+       } else if (type == BT_SENDING_NOTI) {
+               title = "IDS_BT_SBODY_PREPARING_TO_SEND_FILES_ING_ABB";
+               icon_path = BT_ICON_NOTIFICATION_SENDING;
+               indicator_icon_path = BT_ICON_NOTIFICATION_SENDING_INDICATOR;
+               flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI;
+               noti_type = NOTIFICATION_TYPE_ONGOING;
+       } else if (type == BT_RECEIVING_NOTI) {
+               title = "IDS_BT_SBODY_PREPARING_TO_RECEIVE_FILES_ING_ABB";
+               icon_path = BT_ICON_NOTIFICATION_RECEIVING;
+               indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVING_INDICATOR;
+               flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI;
+               noti_type = NOTIFICATION_TYPE_ONGOING;
+       }
+
+       noti = notification_create(noti_type);
+       if (!noti) {
+               ERR("Fail to notification_create");
+               return NULL;
+       }
+
+       notification_set_text_domain(noti, BT_COMMON_PKG, BT_COMMON_RES);
+
+       if (title) {
+               if (include_name_param == true) {
+                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                               NULL, title,
+                               NOTIFICATION_VARIABLE_TYPE_STRING, dev_name,
+                               NOTIFICATION_VARIABLE_TYPE_NONE);
+               } else {
+                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                               NULL, title,
+                               NOTIFICATION_VARIABLE_TYPE_NONE);
+               }
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_text [%d]", ret);
+       }
+
+       if (content) {
+               DBG("success : %d, fail : %d", success, fail);
+               if (success > 0 && fail > 0) {
+                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                               NULL, content,
+                                               NOTIFICATION_VARIABLE_TYPE_INT, success,
+                                               NOTIFICATION_VARIABLE_TYPE_INT, fail,
+                                               NOTIFICATION_VARIABLE_TYPE_NONE);
+               } else {
+                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                               NULL, content,
+                                               NOTIFICATION_VARIABLE_TYPE_INT, (success > 0) ? success : fail,
+                                               NOTIFICATION_VARIABLE_TYPE_NONE);
+               }
+
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_text [%d]", ret);
+       }
+
+       if (icon_path) {
+               ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_image [%d]", ret);
+       }
+
+       if (indicator_icon_path) {
+               ret = notification_set_image(noti,
+                               NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, indicator_icon_path);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_image [%d]", ret);
+       }
+
+       if (flag != -1) {
+               ret = notification_set_property(noti, flag);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_property [%d]", ret);
+
+               if (type == BT_SENDING_NOTI || type == BT_RECEIVING_NOTI) {
+                       ret = notification_set_property(noti,
+                                       NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
+                       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                               "Fail to set property for DISABLE_APP_LAUNCH [%d]", ret);
+               }
+       }
+
+       if (app_id) {
+               ret = notification_set_pkgname(noti, app_id);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_pkgname [%d]", ret);
+       }
+
+       ret = notification_set_display_applist(noti,
+                       NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_set_display_applist [%d]", ret);
+
+       if (type == BT_SENT_NOTI) {
+               _bt_set_notification_app_launch(noti, dev_name, address, db_sid,
+                               CREATE_TR_LIST, NOTI_TR_TYPE_OUT, NULL, 0, NULL, 0);
+       } else if (type == BT_RECEIVED_NOTI) {
+               _bt_set_notification_app_launch(noti, dev_name, address, db_sid,
+                               CREATE_TR_LIST, NOTI_TR_TYPE_IN, NULL, 0, NULL, 0);
+       }
+
+       ret = notification_insert(noti, &noti_id);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_insert [%d]", ret);
+
+       if (type == BT_SENT_NOTI)
+               ad->send_noti_id = noti_id;
+       else if (type == BT_RECEIVED_NOTI)
+               ad->receive_noti_id = noti_id;
+
+       INFO("Insert %s type: %d ", (type == BT_SENT_NOTI ||
+                       type == BT_RECEIVED_NOTI) ? "Notification" : "Ongoing", type);
+
+       return noti;
+}
+
+int _bt_update_notification(bt_appdata_t *ad,
+               notification_h noti, char *title, char *content, char *dev_name,
+               char *icon_path, char *opc_count)
+{
+       retvm_if(!noti, BT_SHARE_FAIL, "noti is NULL");
+
+       INFO("Update noti : %p", noti);
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+       int success = 0;
+       int fail = 0;
+       int flags = -1;
+
+       if (ad->send_noti == noti) {
+               success = ad->send_data.tr_success;
+               fail = ad->send_data.tr_fail;
+       } else if (ad->receive_noti == noti) {
+               success = ad->recv_data.tr_success;
+               fail = ad->recv_data.tr_fail;
+       }
+
+       if (ad->send_noti == noti || ad->receive_noti == noti) {
+               if (success == 0 && fail > 0)
+                       content = "IDS_BT_SBODY_PD_FAILED_ABB";
+               else if (fail == 0 && success > 0)
+                       content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
+               else
+                       content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
+       }
+
+       if (title) {
+               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                                       NULL, title,
+                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_text [%d]", ret);
+       }
+
+       if (content) {
+               if (noti == ad->send_noti || noti == ad->receive_noti) {
+                       if (success > 0 && fail > 0) {
+                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                               NULL, content,
+                                               NOTIFICATION_VARIABLE_TYPE_INT, success,
+                                               NOTIFICATION_VARIABLE_TYPE_INT, fail,
+                                               NOTIFICATION_VARIABLE_TYPE_NONE);
+                       } else {
+                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                                               NULL, content,
+                                                               NOTIFICATION_VARIABLE_TYPE_INT, (success > 0) ? success : fail,
+                                                               NOTIFICATION_VARIABLE_TYPE_NONE);
+                       }
+               } else {
+                       if (dev_name) {
+                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                                       NULL, content,
+                                                       NOTIFICATION_VARIABLE_TYPE_STRING, dev_name,
+                                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+                       } else {
+                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                                                       NULL, content, NOTIFICATION_VARIABLE_TYPE_NONE);
+                       }
+               }
+
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_text [%d]", ret);
+       }
+
+       if (opc_count) {
+               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT,
+                                       NULL, opc_count, NOTIFICATION_VARIABLE_TYPE_NONE);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_text [%d]", ret);
+       }
+
+       if (icon_path) {
+               ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
+                               icon_path);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_set_image [%d]", ret);
+       }
+
+       ret  = notification_get_property(noti, &flags);
+       if (ret == NOTIFICATION_ERROR_NONE) {
+               if (flags & NOTIFICATION_PROP_DISABLE_APP_LAUNCH) {
+                       ret = notification_set_property(noti,
+                                       flags ^ NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
+                       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                                       "Failed to set app launch property");
+               }
+       } else {
+               ERR("failed to get the property: [%d]", ret);
+       }
+
+       ret = notification_update(noti);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                       "Fail to notification_update [%d]", ret);
+
+       return ret;
+}
+
+int _bt_update_notification_progress(notification_h not,
+                               int id, int val)
+{
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+
+       ret = notification_update_progress(not, id, (double)val / 100);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_update_progress [%d]\n", ret);
+
+       return ret;
+}
+
+int _bt_get_notification_priv_id(notification_h noti)
+{
+       int group_id = 0;
+       int priv_id = 0;
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+
+       ret = notification_get_id(noti, &group_id, &priv_id);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_get_id [%d]", ret);
+
+       return priv_id;
+}
+
+int _bt_delete_notification(notification_h noti)
+{
+       retv_if(!noti, BT_SHARE_FAIL);
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+
+       INFO("Delete noti : %p", noti);
+
+       /* In case daemon, give full path */
+       ret = notification_delete(noti);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_delete [%d]", ret);
+
+       return ret;
+}
+
+int _bt_set_notification_app_launch(notification_h noti,
+               char *device_name,
+               char *device_addr,
+               char *db_sid,
+               bt_notification_launch_type_e launch_type,
+               const char *transfer_type,
+               const char *filename,
+               unsigned long size,
+               const char *progress_cnt,
+               int transfer_id)
+{
+       FN_START;
+       retv_if(!noti, BT_SHARE_FAIL);
+       retv_if(!transfer_type, BT_SHARE_FAIL);
+       retv_if(launch_type != CREATE_PROGRESS && launch_type != CREATE_TR_LIST,
+                       BT_SHARE_FAIL);
+
+       notification_error_e ret = NOTIFICATION_ERROR_NONE;
+       bundle *b = NULL;
+       b = bundle_create();
+       retv_if(!b, BT_SHARE_FAIL);
+
+       appsvc_set_pkgname(b, UI_PACKAGE);
+       appsvc_add_data(b, "device_name", device_name);
+       appsvc_add_data(b, "device_addr", device_addr);
+       appsvc_add_data(b, "transfer_type", transfer_type);
+       appsvc_add_data(b, "db_sid", db_sid);
+
+       if (launch_type == CREATE_PROGRESS) {
+               if (!filename) {
+                       bundle_free(b);
+                       return BT_SHARE_FAIL;
+               }
+
+               char priv_id_str[BT_PRIV_ID_STR_LEN] = {0, };
+               char size_str[BT_PRIV_ID_STR_LEN] = {0, };
+               snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", transfer_id);
+               snprintf(size_str, BT_PRIV_ID_STR_LEN, "%lu", size);
+
+               appsvc_add_data(b, "launch-type", "ongoing");
+               appsvc_add_data(b, "filename", filename);
+               appsvc_add_data(b, "size", size_str);
+               appsvc_add_data(b, "transfer_id", priv_id_str);
+               if (g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT) == 0) {
+                       if (!progress_cnt) {
+                               bundle_free(b);
+                               return BT_SHARE_FAIL;
+                       }
+                       appsvc_add_data(b, "progress_cnt", progress_cnt);
+               }
+       } else {
+               char priv_id_str[BT_PRIV_ID_STR_LEN] = {0, };
+               snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", transfer_id);
+
+               appsvc_add_data(b, "launch-type", "transfer_list");
+               appsvc_add_data(b, "transfer_id", priv_id_str);
+               appsvc_add_data(b, "filename", filename);
+       }
+
+       ret = notification_set_execute_option(noti,
+                                       NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
+                                       NULL, NULL, b);
+       warn_if(ret != NOTIFICATION_ERROR_NONE,
+               "Fail to notification_set_execute_option [%d]\n", ret);
+
+       bundle_free(b);
+       FN_END;
+       return ret;
+}
+
+#if 0
+gboolean _bt_update_notification_status(bt_appdata_t *ad)
+{
+       retv_if(ad == NULL, FALSE);
+
+       notification_h noti = NULL;
+       notification_list_h list_head = NULL;
+       notification_list_h list_traverse = NULL;
+       gboolean is_noti_existed = FALSE;
+       gboolean send_noti = FALSE;
+       gboolean receive_noti = FALSE;
+       sqlite3 *db = NULL;
+       char *app_id = NULL;
+       int group_id = 0;
+       int priv_id = 0;
+       int ret = 0;
+
+       /* When bt-share is launched, need to update notification status  */
+       notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &list_head);
+       list_traverse = list_head;
+
+       while (list_traverse != NULL) {
+               noti = notification_list_get_data(list_traverse);
+               notification_get_pkgname(noti, &app_id);
+
+               if (g_strcmp0(app_id, NOTI_OPS_APP_ID) == 0) {
+                       ret = notification_clone(noti, &ad->receive_noti);
+                       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                                       "Fail to clone notificatoin");
+
+                       ret = notification_get_id(noti, &group_id, &priv_id);
+                       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                                       "Fail to get notification id");
+
+                       ad->receive_noti_id = priv_id;
+                       receive_noti = TRUE;
+               } else if (g_strcmp0(app_id, NOTI_OPC_APP_ID) == 0) {
+                       ret = notification_clone(noti, &ad->send_noti);
+                       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                                       "Unable to clone notificatoin");
+
+                       ret = notification_get_id(noti, &group_id, &priv_id);
+                       warn_if(ret != NOTIFICATION_ERROR_NONE,
+                               "Fail to get notification id");
+
+                       ad->send_noti_id = priv_id;
+                       send_noti = TRUE;
+               }
+
+               if (receive_noti || send_noti) {
+                       time_t ret_time;
+                       /* Set notication insert_time */
+                       notification_get_insert_time(noti, &ret_time);
+                       notification_set_time(noti, ret_time);
+                       notification_update(noti);
+                       is_noti_existed = TRUE;
+                       send_noti = FALSE;
+                       receive_noti = FALSE;
+               }
+
+               list_traverse = notification_list_get_next(list_traverse);
+       }
+
+       if (list_head != NULL) {
+               notification_free_list(list_head);
+               list_head = NULL;
+       }
+
+       /* If notification item is removed durning BT off, need to remove DB */
+       db = bt_share_open_db();
+       retv_if(!db, is_noti_existed);
+
+       if (!receive_noti)
+               bt_share_remove_all_tr_data(db, BT_DB_INBOUND);
+       if (!send_noti)
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+       bt_share_close_db(db);
+
+       return is_noti_existed;
+}
+#endif
+
+/* LCOV_EXCL_START */
+static void __bt_notification_changed_cb(void *data, notification_type_e type,
+               notification_op *op_list, int num_op)
+{
+       FN_START;
+       retm_if(data == NULL, "Invalid data");
+       retm_if(op_list == NULL, "Invalid op_list");
+
+       bt_appdata_t *ad = (bt_appdata_t *)data;
+       sqlite3 *db = NULL;
+       int i;
+
+       ret_if(type != NOTIFICATION_TYPE_NOTI ||
+               (op_list->type != NOTIFICATION_OP_DELETE &&
+               op_list->type != NOTIFICATION_OP_DELETE_ALL));
+
+       DBG("Notifications Changed: %d", num_op);
+       DBG("Currently Received NotiID: %d", ad->receive_noti_id);
+       db = bt_share_open_db();
+       for (i = 0; i < num_op; i++, op_list++) {
+               DBG("TYPE:%d PRIV_ID:%d", op_list->type, op_list->priv_id);
+
+               if (op_list->priv_id == ad->receive_noti_id) {
+                       ad->receive_noti = NULL;
+                       ad->receive_noti_id = 0;
+               }
+
+               if (bt_share_check_noti_id(db, BT_DB_OUTBOUND, op_list->priv_id)
+                                               == BT_SHARE_ERR_NONE) {
+                       DBG("Delete Entries from OUTBOUND for NotiID %d", op_list->priv_id);
+                       ad->send_noti = NULL;
+                       ad->send_noti_id = 0;
+                       ad->send_data.tr_fail = 0;
+                       ad->send_data.tr_success = 0;
+                       _bt_remove_temporary_files_by_noti_id(db, op_list->priv_id);
+                       bt_share_remove_tr_data_by_notification(db,
+                                       BT_DB_OUTBOUND, op_list->priv_id);
+               }
+               if (bt_share_check_noti_id(db, BT_DB_INBOUND, op_list->priv_id)
+                                               == BT_SHARE_ERR_NONE) {
+                       DBG("Delete Entries from INBOUND for NotiID %d", op_list->priv_id);
+                       ad->receive_noti = NULL;
+                       ad->receive_noti_id = 0;
+                       ad->recv_data.tr_fail = 0;
+                       ad->recv_data.tr_success = 0;
+                       bt_share_remove_tr_data_by_notification(db,
+                                       BT_DB_INBOUND, op_list->priv_id);
+               }
+       }
+       bt_share_close_db(db);
+
+       DBG("SEND: Success[%d] Fail[%d] ||||| RECEIVE: Success[%d] Fail[%d]",
+                       ad->send_data.tr_success, ad->send_data.tr_fail,
+                       ad->recv_data.tr_success, ad->recv_data.tr_fail);
+       FN_END;
+
+}
+/* LCOV_EXCL_STOP */
+
+void _bt_register_notification_cb(bt_appdata_t *ad)
+{
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti_err = notification_register_detailed_changed_cb(
+                       __bt_notification_changed_cb, ad);
+       warn_if(noti_err != NOTIFICATION_ERROR_NONE,
+                       "notification_resister_changed_cb failed [%d]\n", noti_err);
+}
+
+void _bt_unregister_notification_cb(bt_appdata_t *ad)
+{
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti_err = notification_unregister_detailed_changed_cb(
+                       __bt_notification_changed_cb, NULL);
+       warn_if(noti_err != NOTIFICATION_ERROR_NONE,
+                       "notification_unresister_changed_cb failed [%d]\n", noti_err);
+}
diff --git a/app/bt-share-notification.h b/app/bt-share-notification.h
new file mode 100644 (file)
index 0000000..3879c2a
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_NOTI_H_
+#define __DEF_BLUETOOTH_SHARE_NOTI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <notification.h>
+#include <tzplatform_config.h>
+
+#include "bt-share-main.h"
+
+#define NOTIFICATION_TEXT_LEN_MAX 100
+#define NOTI_TR_TYPE_IN "inbound"
+#define NOTI_TR_TYPE_OUT "outbound"
+#define NOTI_OPS_APP_ID        "bluetooth-share-opp-server"
+#define NOTI_OPC_APP_ID        "bluetooth-share-opp-client"
+
+typedef enum {
+       BT_SENT_NOTI,
+       BT_SENT_FAILED_NOTI,
+       BT_SENDING_NOTI,
+       BT_RECEIVED_NOTI,
+       BT_RECEIVED_FAILED_NOTI,
+       BT_RECEIVING_NOTI,
+} bt_notification_type_e;
+
+typedef enum {
+       CREATE_PROGRESS,
+       CREATE_TR_LIST
+} bt_notification_launch_type_e;
+
+void _bt_insert_instant_notification(bt_notification_type_e type);
+
+notification_h _bt_insert_notification(bt_appdata_t *ad,
+               bt_notification_type_e type, char *dev_name,
+               char *address, char *db_sid);
+
+int _bt_update_notification(bt_appdata_t *ad, notification_h noti,
+               char *title, char *content, char *dev_name, char *icon_path, char *opc_count);
+
+int _bt_update_notification_progress(notification_h noti,
+               int id,
+               int val);
+
+int _bt_get_notification_priv_id(notification_h noti);
+
+int _bt_delete_notification(notification_h noti);
+
+int _bt_set_notification_app_launch(notification_h noti, char *device_name,
+               char *device_addr, char *db_sid,
+               bt_notification_launch_type_e launch_type,
+               const char *transfer_type,
+               const char *filename,
+               unsigned long size,
+               const char *progress_cnt,
+               int transfer_id);
+
+#if 0
+gboolean _bt_update_notification_status(bt_appdata_t *ad);
+#endif
+
+void _bt_register_notification_cb(bt_appdata_t *ad);
+
+void _bt_unregister_notification_cb(bt_appdata_t *ad);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_NOTI_H_ */
diff --git a/app/bt-share-resource.h b/app/bt-share-resource.h
new file mode 100644 (file)
index 0000000..e6d17d8
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_RES_H_
+#define __DEF_BLUETOOTH_SHARE_RES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libintl.h>
+#include <tzplatform_config.h>
+
+/*==============  String ================= */
+#define BT_COMMON_PKG          "ug-setting-bluetooth-efl"
+#define BT_COMMON_RES          "/usr/ug/res/locale/"
+
+#define BT_STR_MEMORY_FULL     \
+       dgettext(BT_COMMON_PKG, "IDS_BT_POP_MEMORYFULL")
+#define BT_STR_UNABLE_TO_SEND  \
+       dgettext(BT_COMMON_PKG, "IDS_BT_POP_SENDINGFAIL")
+#define BT_STR_UNABLE_TO_RECEIVE       \
+       dgettext(BT_COMMON_PKG, "IDS_BT_BODY_UNABLE_TO_RECEIVE")
+#define BT_STR_FILES_SENT\
+       dgettext(BT_COMMON_PKG, "IDS_ST_BODY_FILES_SENT_ABB")
+#define BT_STR_FILES_RECEIVED\
+       dgettext(BT_COMMON_PKG, "IDS_ST_BODY_FILES_RECEIVED_ABB")
+#define BT_STR_FILES_SENT_TO \
+       dgettext(BT_COMMON_PKG, "IDS_WIFI_BODY_FILES_SENT_TO_PS_M_STATUS")
+#define BT_STR_FILES_RECEIVED_FROM \
+       dgettext(BT_COMMON_PKG, "IDS_WIFI_MBODY_FILES_RECEIVED_FROM_PS")
+
+#define BT_STR_SENDING_FILES_TO \
+       dgettext(BT_COMMON_PKG, "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING")
+#define BT_STR_SENDING_FILES \
+       dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SENDING_FILES_ING_ABB")
+#define BT_STR_RECEIVING_FILES_FROM \
+       dgettext(BT_COMMON_PKG, "IDS_WIFI_BODY_RECEIVING_FILES_FROM_PS_ING")
+#define BT_STR_RECEIVING_FILES \
+       dgettext(BT_COMMON_PKG, "IDS_NFC_BODY_RECEIVING_FILES_ING")
+#define BT_STR_SENDING_FILES_FAILED \
+       dgettext(BT_COMMON_PKG, "IDS_WIFI_POP_SENDING_FILES_FAILED")
+#define BT_STR_RECEIVING_FILES_FAILED \
+       dgettext(BT_COMMON_PKG, "IDS_WIFI_POP_RECEIVING_FILES_FAILED")
+
+/*==============  Image ================= */
+#define ICONDIR                "/usr/ug/res/images/ug-setting-bluetooth-efl"
+#define QP_PRELOAD_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/Common"
+#define BT_ICON_PATH_MAX       256
+
+#define BT_ICON_QP_SEND                tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \
+                                                       "/Q02_icon_BT_transmit.png")
+#define BT_ICON_QP_RECEIVE     tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \
+                                                       "/Q02_icon_BT_receive.png")
+#define BT_ICON_QP_BT_ON       tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \
+                                                       "/Q02_Notification_bluetooth.png")
+
+#define BT_ICON_NOTIFICATION_SENDING           "reserved://quickpanel/ani/uploading"
+#define BT_ICON_NOTIFICATION_SENDING_INDICATOR         "reserved://indicator/ani/uploading"
+#define BT_ICON_NOTIFICATION_SENT              QP_PRELOAD_NOTI_ICON_PATH"/noti_upload_complete.png"
+#define BT_ICON_NOTIFICATION_SENT_INDICATOR            ICONDIR"/B03_upload_complete.png"
+#define BT_ICON_NOTIFICATION_RECEIVING         "reserved://quickpanel/ani/downloading"
+#define BT_ICON_NOTIFICATION_RECEIVING_INDICATOR               "reserved://indicator/ani/downloading"
+#define BT_ICON_NOTIFICATION_RECEIVED          QP_PRELOAD_NOTI_ICON_PATH"/noti_download_complete.png"
+#define BT_ICON_NOTIFICATION_RECEIVED_INDICATOR                ICONDIR"/B03_download_complete.png"
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_RES_H_ */
diff --git a/app/bt-share-syspopup.c b/app/bt-share-syspopup.c
new file mode 100644 (file)
index 0000000..f808bd2
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syspopup_caller.h>
+#include <bundle_internal.h>
+
+#include "applog.h"
+#include "bt-share-common.h"
+#include "bluetooth-api.h"
+#include "bt-share-syspopup.h"
+#include "bt-share-main.h"
+#include "bt-share-resource.h"
+#include "obex-event-handler.h"
+
+extern bt_appdata_t *app_state;
+#define BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
+#define BT_SYSPOPUP_EVENT_LEN_MAX 50
+
+/* LCOV_EXCL_START */
+static gboolean __bt_system_popup_timer_cb(gpointer user_data)
+{
+       int ret = 0;
+       bundle *b = (bundle *) user_data;
+
+       retvm_if(!b, FALSE,
+               "There is some problem with the user data..popup can not be created\n");
+
+       ret = syspopup_launch("bt-syspopup", b);
+       warn_if(0 > ret, "launching sys-popup failed\n");
+
+       bundle_free(b);
+       return FALSE;
+}
+/* LCOV_EXCL_STOP */
+
+int _bt_launch_system_popup(bt_app_event_type_e event_type,
+                           bt_app_sys_popup_params_t *popup_params,
+                           void *cb,
+                           void *data)
+{
+       FN_START;
+       int ret = BT_SHARE_ERROR_NONE;
+       bundle *b = NULL;
+       bt_appdata_t *ad = NULL;
+       char event_str[BT_SYSPOPUP_EVENT_LEN_MAX] = {0, };
+
+       if (data)
+               ad = (bt_appdata_t *)data;
+       else
+               ad = app_state;
+
+       retv_if(!ad, BT_SHARE_FAIL);
+
+       b = bundle_create();
+       retvm_if(!b, BT_SHARE_FAIL, "bundle_create failed");
+
+       bundle_add(b, "title", popup_params->title);
+       bundle_add(b, "type", popup_params->type);
+       bundle_add(b, "file", popup_params->file);
+       bundle_add(b, "device_name", popup_params->device_name);
+
+       switch (event_type) {
+       case BT_APP_EVENT_CONFIRM_MODE_REQUEST: {
+               strncpy(event_str, "app-confirm-request", sizeof(event_str));
+               break;
+       }
+
+       case BT_APP_EVENT_FILE_RECEIVED: {
+               strncpy(event_str, "file-received", sizeof(event_str));
+               break;
+       }
+
+       case BT_APP_EVENT_INFORMATION: {
+               strncpy(event_str, "bt-information", sizeof(event_str));
+               break;
+       }
+
+       case BT_APP_EVENT_OVERWRITE_REQUEST: {
+               strncpy(event_str, "confirm-overwrite-request", sizeof(event_str));
+               break;
+       }
+
+       default:
+               break;
+       }
+
+       bundle_add(b, "event-type", event_str);
+
+       /*The system popup launch function is not able to launch second popup
+         * if first popup is being processed still, this due to the check
+         * in AUL module to restrict multiple launching of syspopup,
+         * to solve this problem after discussion it is decided that  if
+         * the popup launch fails then it will be retried
+         * after small timeout. */
+       ret = syspopup_launch("bt-syspopup", b);
+       if (0 > ret) {
+               ERR("Popup launch failed...retry = %d\n", ret);
+               g_timeout_add(BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS,
+                             (GSourceFunc) __bt_system_popup_timer_cb, b);
+       } else {
+               bundle_free(b);
+       }
+
+       if (cb != NULL)
+               ad->popups.popup_cb = (bt_app_cb) cb;
+
+       ad->popups.popup_cb_data = data;
+       ad->popups.syspopup_request = TRUE;
+
+       FN_END;
+       return BT_SHARE_ERROR_NONE;
+}
+
+
+gboolean _bt_app_popup_memoryfull(gpointer user_data)
+{
+       bt_app_sys_popup_params_t popup_params = { NULL };
+
+       popup_params.title = BT_STR_MEMORY_FULL;
+       popup_params.type = "none";
+       _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
+                       &popup_params, NULL, NULL);
+       return FALSE;
+}
+
+
diff --git a/app/bt-share-syspopup.h b/app/bt-share-syspopup.h
new file mode 100644 (file)
index 0000000..ca73b3b
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * bluetooth-share
+ *
+ * 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 __DEF_BLUETOOTH_SHARE_SYSPOPUP_H_
+#define __DEF_BLUETOOTH_SHARE_SYSPOPUP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BT_GLOBALIZATION_STR_LENGTH    256
+#define BT_FILE_NAME_LEN_MAX 255
+#define BT_POPUP_TEXT_LEN \
+               (BT_GLOBALIZATION_STR_LENGTH + BT_FILE_NAME_LEN_MAX)
+
+/* This value are used in the N-prj */
+#define BT_APP_POPUP_LAUNCH_TIMEOUT 100
+
+typedef enum {
+       BT_APP_EVENT_CONFIRM_MODE_REQUEST = 0x0001,
+       BT_APP_EVENT_FILE_RECEIVED = 0x0002,
+       BT_APP_EVENT_INFORMATION = 0x0004,
+       BT_APP_EVENT_OVERWRITE_REQUEST = 0x0008
+} bt_app_event_type_e;
+
+typedef enum {
+       POPUP_RESPONSE_OK,
+       POPUP_RESPONSE_CANCEL,
+       POPUP_RESPONSE_TIMEOUT
+} bt_popup_response_e;
+
+typedef struct {
+       char *title;
+       char *type;
+       char *file;
+       char *device_name;
+} bt_app_sys_popup_params_t;
+
+int _bt_launch_system_popup(bt_app_event_type_e event_type,
+                           bt_app_sys_popup_params_t *popup_params,
+                           void *cb,
+                           void *data);
+
+gboolean _bt_app_popup_memoryfull(gpointer user_data);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __DEF_BLUETOOTH_SHARE_SYSPOPUP_H_ */
diff --git a/app/obex-event-handler.c b/app/obex-event-handler.c
new file mode 100644 (file)
index 0000000..5669fcc
--- /dev/null
@@ -0,0 +1,1683 @@
+/*
+ * bluetooth-share
+ *
+ * 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 <sys/vfs.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <ctype.h>
+#include <arpa/inet.h>
+#include <app_control.h>
+#include <vconf-keys.h>
+#ifdef ENABLE_CALENDAR_SERVICE2
+#include <calendar.h>
+#endif
+#ifdef ENABLE_CONTACTS_SERVICE2
+#include <contacts.h>
+#include <contacts_filter.h>
+#endif
+#include <vconf.h>
+#include <Ecore_File.h>
+#include <bluetooth-share-api.h>
+#include <notification.h>
+#include <media_content.h>
+#include <media_content_internal.h>
+#include <sys/stat.h>
+#include <aul.h>
+#include <storage.h>
+#include <zlib.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
+#include "applog.h"
+#include "bluetooth-api.h"
+#include "obex-event-handler.h"
+#include "bt-share-main.h"
+#include "bt-share-syspopup.h"
+#include "bt-share-resource.h"
+#include "bt-share-ipc.h"
+#include "bt-share-notification.h"
+#include "bt-share-common.h"
+#include "bt-share-noti-handler.h"
+
+typedef struct {
+       void *noti_handle;
+       int transfer_id;
+       int noti_id;
+} bt_noti_data_t;
+
+typedef struct {
+       char *file_path;
+       bt_file_type_e file_type;
+} bt_file_info_t;
+
+extern bt_appdata_t *app_state;
+extern GSList *bt_transfer_list;
+GSList *bt_receive_noti_list;
+GSList *bt_rcv_noti_info_list = NULL;
+GSList *bt_snd_noti_info_list = NULL;
+bt_obex_server_authorize_into_t server_auth_info;
+
+static gboolean isTransferConnectedReceived = FALSE;
+
+static void *__bt_obex_writeclose(bt_file_info_t *info);
+
+static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t *server_auth_info);
+
+/* LCOV_EXCL_START */
+static void __bt_free_rcv_notification(gpointer data)
+{
+       bt_device_rcv_noti_info_t *noti_data = data;
+       ret_if(!noti_data);
+
+       bt_rcv_noti_info_list = g_slist_remove(bt_rcv_noti_info_list, noti_data);
+       g_free(noti_data->address);
+       g_free(noti_data->device_name);
+       g_free(noti_data->db_sid);
+       g_free(noti_data);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_free_snd_notification(gpointer data)
+{
+       bt_device_snd_noti_info_t *noti_data = data;
+       ret_if(!noti_data);
+
+       bt_snd_noti_info_list = g_slist_remove(bt_snd_noti_info_list, noti_data);
+       g_free(noti_data->db_sid);
+       g_free(noti_data);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void _bt_get_pending_list(bt_appdata_t *ad)
+{
+       sqlite3 *db = NULL;
+       retm_if(ad == NULL, "Application data ad is NULL");
+
+       db = bt_share_open_db();
+       if (ad->tr_send_list) {
+               bt_share_release_tr_data_list(ad->tr_send_list);
+               ad->tr_send_list = NULL;
+               ad->tr_next_data = NULL;
+       }
+
+       ad->tr_send_list = bt_share_get_tr_data_list_by_status(db,
+                               BT_DB_OUTBOUND, BT_TR_PENDING);
+
+       bt_share_close_db(db);
+
+       if (ad->tr_send_list)
+               ad->tr_next_data = ad->tr_send_list;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static bt_device_snd_noti_info_t *__bt_get_snd_noti_data_by_device_address(char *address)
+{
+       GSList *l = NULL;
+       bt_device_snd_noti_info_t *data = NULL;
+
+       for (l = bt_snd_noti_info_list; l != NULL; l = l->next) {
+               data = l->data;
+               if (data == NULL)
+                       continue;
+
+               retv_if(!strcmp(data->address, address), data);
+       }
+
+       return NULL;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static bt_device_rcv_noti_info_t *__bt_get_rcv_noti_data_by_device_address(char *address)
+{
+       GSList *l = NULL;
+       bt_device_rcv_noti_info_t *data = NULL;
+
+       for (l = bt_rcv_noti_info_list; l != NULL; l = l->next) {
+               data = l->data;
+               if (data == NULL)
+                       continue;
+
+               retv_if(!strcmp(data->address, address), data);
+       }
+
+       return NULL;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static bt_noti_data_t *__bt_get_noti_data_by_transfer_id(int transfer_id)
+{
+       GSList *l = NULL;
+       bt_noti_data_t *data = NULL;
+
+       for (l = bt_receive_noti_list; l != NULL; l = l->next) {
+               data = l->data;
+               if (data == NULL)
+                       continue;
+
+               retv_if(data->transfer_id == transfer_id, data);
+       }
+
+       return NULL;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static char *__get_file_name(int cnt, char **path)
+{
+       retvm_if(path == NULL || path[cnt] == NULL, NULL, "Path is invalid");
+       char *pfilename = NULL;
+
+       pfilename = strrchr(path[cnt], '/') + 1;
+       DBG_SECURE("File name[%d] : %s", cnt, pfilename);
+       return pfilename;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __delete_notification(gpointer data, gpointer user_data)
+{
+       bt_noti_data_t *noti_data = data;
+       ret_if(!noti_data);
+
+       _bt_delete_notification(noti_data->noti_handle);
+       g_free(noti_data);
+}
+/* LCOV_EXCL_STOP */
+
+void _bt_obex_cancel_transfer(void *data)
+{
+       FN_START;
+       retm_if(!data, "invalid param!");
+
+       GSList *l = NULL;
+       bt_noti_data_t *noti_data = NULL;
+       int ret = 0;
+
+       for (l = bt_receive_noti_list; l != NULL; l = l->next) {
+               /* LCOV_EXCL_START */
+               noti_data = l->data;
+               if (noti_data == NULL)
+                       continue;
+
+               DBG("noti_id : %d", noti_data->noti_id);
+               ret = bluetooth_obex_server_cancel_transfer(noti_data->transfer_id);
+               warn_if(ret != BLUETOOTH_ERROR_NONE,
+                       "bluetooth_obex_server_cancel_transfer[ret:%d]", ret);
+               /* LCOV_EXCL_STOP */
+       }
+       FN_END;
+}
+
+void _bt_clear_receive_noti_list(void)
+{
+       if (bt_receive_noti_list) {
+               /* LCOV_EXCL_START */
+               g_slist_foreach(bt_receive_noti_list,
+                               (GFunc)__delete_notification,
+                               NULL);
+               g_slist_free(bt_receive_noti_list);
+               bt_receive_noti_list = NULL;
+               /* LCOV_EXCL_STOP */
+       }
+}
+
+/* LCOV_EXCL_START */
+char *__get_dest_file_path(const char *path)
+{
+       char file_path[BT_TEMP_FILE_PATH_LEN_MAX] = {0, };
+
+       /* Media updation is failing if we give FTP folder path.
+            So we have to map the FTP folder path like below
+            /opt/share/bt-ftp/Media/XX -> /opt/usr/media/XX
+            /opt/share/bt-ftp/SD_External/XX -> /opt/storage/sdcard/XX
+        */
+       if (g_str_has_prefix(path, BT_FTP_FOLDER_PHONE)) {
+               snprintf(file_path, sizeof(file_path), "%s/%s",
+                       BT_DOWNLOAD_PHONE_ROOT,
+                       path + strlen(BT_FTP_FOLDER_PHONE));
+       } else if (g_str_has_prefix(path, BT_FTP_FOLDER_MMC)) {
+               snprintf(file_path, sizeof(file_path), "%s/%s",
+                       BT_DOWNLOAD_MMC_ROOT,
+                       path + strlen(BT_FTP_FOLDER_MMC));
+       } else {
+               snprintf(file_path, sizeof(file_path), "%s", path);
+       }
+
+       DBG_SECURE("File path %s", file_path);
+       return g_strdup(file_path);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __free_file_info(bt_file_info_t *info)
+{
+       g_free(info->file_path);
+       g_free(info);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static bt_file_type_e __get_file_type(char *extn)
+{
+       if (extn != NULL) {
+
+               DBG("extn : %s", extn);
+
+               if (!strcmp(extn, "vcf"))
+                       return BT_FILE_VCARD;
+               else if (!strcmp(extn, "vcs"))
+                       return BT_FILE_VCAL;
+               else if (!strcmp(extn, "vbm"))
+                       return BT_FILE_VBOOKMARK;
+       }
+       return BT_FILE_OTHER;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static gboolean __bt_scan_media_file(char *file_path)
+{
+       int ret = 0;
+       uid_t uid = 0;
+
+       /* Set active UID for system session's bt-share process */
+       ret = _bt_share_get_active_uid(&uid);
+       retvm_if(ret != BT_SHARE_ERROR_NONE, FALSE,
+               "Fail to get the active uid: %d", ret);
+
+       ret = media_content_connect_with_uid(uid);
+       retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, FALSE,
+               "Fail to connect the media content: %d", ret);
+
+       ret = media_content_scan_file(file_path);
+       warn_if(ret != MEDIA_CONTENT_ERROR_NONE, "Fail to scan file: %d", ret);
+
+       ret = media_content_disconnect();
+       warn_if(ret != MEDIA_CONTENT_ERROR_NONE,
+                       "Fail to disconnect the media content: %d", ret);
+
+       return TRUE;
+}
+
+static void __bt_move_media_file(char *file_path)
+{
+       char storage[STORAGE_PATH_LEN_MAX] = {0, };
+       char media_file_path[BT_FILE_PATH_LEN_MAX] = {0, };
+
+       retm_if(!file_path, "invalid param!");
+
+       INFO("File path: %s", file_path);
+
+       _bt_get_default_storage(storage);
+
+       retm_if(!BT_SHARE_DATA_DIR, "DATA dir is NULL");
+
+       snprintf(media_file_path, BT_FILE_PATH_LEN_MAX, "%s/%s",
+               storage, file_path + strlen(BT_SHARE_DATA_DIR));
+
+       INFO("Media file path: %s", media_file_path);
+
+       ecore_file_mv(file_path, media_file_path);
+
+       __bt_scan_media_file(media_file_path);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+void __bt_update_db_with_noti_id(bt_tr_db_table_e table, notification_h noti,
+               const char *db_sid)
+{
+       sqlite3 *db = bt_share_open_db();
+       int noti_id = 0;
+
+       noti_id = _bt_get_notification_priv_id(noti);
+       INFO("Update into database noti_id: %d", noti_id);
+       bt_share_update_noti_id(db, table, noti_id, db_sid);
+
+       bt_share_close_db(db);
+}
+/* LCOV_EXCL_STOP */
+
+#ifdef ENABLE_CONTACTS_SERVICE2
+#if 0
+/* LCOV_EXCL_START */
+void _bt_util_get_number(char *source, char *dest)
+{
+       int len = 7;
+       int slen = 0;
+       char buf[9];
+
+       slen = strlen(source);
+       slen--;
+       buf[8] = '\0';
+       while (len > -1) {
+               if (slen > -1) {
+                       if (isdigit(source[slen])) {
+                               buf[len] = source[slen];
+                               --len;
+                       }
+                       --slen;
+               } else {
+                       break;
+               }
+       }
+       if (len < 0)
+               len = 0;
+       strcpy(dest, &buf[len]);
+}
+
+void _bt_util_get_contact_name(int lcontact_id, char **contact_name)
+{
+       int ret = 0;
+       int count = 0;
+       contacts_filter_h filter = NULL;
+       contacts_query_h query = NULL;
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+       char *name = NULL;
+
+       DBG("+");
+       ret = contacts_filter_create(_contacts_contact._uri, &filter);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to create filter for contacts");
+               goto fail;
+       }
+
+       ret = contacts_filter_add_int(filter, _contacts_contact.id,
+                       CONTACTS_MATCH_EXACTLY, lcontact_id);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to add str to filter for contacts");
+               goto fail;
+       }
+
+       ret = contacts_query_create(_contacts_contact._uri, &query);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to create qurey for contacts");
+               goto fail;
+       }
+
+       ret = contacts_query_set_filter(query, filter);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to set filter for contacts");
+               goto fail;
+       }
+
+       ret = contacts_db_get_count_with_query(query, &count);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to get count from db");
+               goto fail;
+       }
+
+       if (count < 1) {
+               DBG("No match");
+               goto fail;
+       }
+       DBG("count = %d", count);
+       ret = contacts_db_get_records_with_query(query, 0, 0, &list);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to get records from db");
+               goto fail;
+       }
+       contacts_list_first(list);
+
+       while (ret == CONTACTS_ERROR_NONE) {
+               contacts_list_get_current_record_p(list, &record);
+               contacts_record_get_str_p(record,
+                               _contacts_contact.display_name,
+                               &name);
+               if (name != NULL) {
+                       *contact_name = g_strdup(name);
+                       break;
+               }
+
+               ret = contacts_list_next(list);
+       }
+
+fail:
+       if (filter)
+               contacts_filter_destroy(filter);
+
+       if (query)
+               contacts_query_destroy(query);
+
+       if (list)
+               contacts_list_destroy(list, true);
+       DBG("-");
+       return;
+}
+
+unsigned int bt_crc32(const void *src, unsigned long src_sz)
+{
+       return (crc32(0, src, src_sz) & 0xFFFF);
+}
+
+void _bt_util_get_contact_info(unsigned char *auth_info, int *contact_id, char **contact_name)
+{
+       unsigned int shash = 0;
+       unsigned int chash = 0;
+       char pnumber[20] = {0,};
+       char str_hash[7] = {0,};
+       int ret = CONTACTS_ERROR_NONE;
+       char *number = NULL;
+       int lcontact_id = 0;
+       int count = 0;
+
+       contacts_filter_h filter = NULL;
+       contacts_query_h query = NULL;
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+
+       retm_if(!auth_info, "auth_info is NULL");
+       retm_if(!contact_id, "contact_id is NULL");
+       retm_if(!contact_name, "contact_name is NULL");
+       DBG("+");
+       if (contacts_connect() != CONTACTS_ERROR_NONE) {
+               ERR("contacts_connect failed");
+               return;
+       }
+
+       memcpy(&shash, auth_info, 3);
+       shash = ntohl(shash);
+       shash >>= 8;
+
+       memcpy(&chash, &auth_info[3], 2);
+       chash = ntohl(chash);
+       chash >>= 16;
+
+       g_snprintf(str_hash, 7, "%X", shash);
+
+#if 0
+       ret = contacts_filter_create(_contacts_quick_connect_info._uri, &filter);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to create filter for contacts");
+               goto fail;
+       }
+
+       ret = contacts_filter_add_str(filter, _contacts_quick_connect_info.hash,
+                       CONTACTS_MATCH_EXACTLY, str_hash);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to add str to filter for contacts");
+               goto fail;
+       }
+
+       ret = contacts_query_create(_contacts_quick_connect_info._uri, &query);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to create qurey for contacts");
+               goto fail;
+       }
+#endif
+
+       ret = contacts_query_set_filter(query, filter);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to set filter for contacts");
+               goto fail;
+       }
+
+       ret = contacts_db_get_count_with_query(query, &count);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to get count from db");
+               goto fail;
+       }
+
+       if (count < 1) {
+               DBG("No match");
+               goto fail;
+       }
+
+       ret = contacts_db_get_records_with_query(query, 0, 0, &list);
+       if (ret != CONTACTS_ERROR_NONE) {
+               ERR("Fail to get records from db");
+               goto fail;
+       }
+
+       contacts_list_first(list);
+
+       while (ret == CONTACTS_ERROR_NONE) {
+               contacts_list_get_current_record_p(list, &record);
+#if 0
+               contacts_record_get_str_p(record,
+                               _contacts_quick_connect_info.number,
+                               &number);
+#endif
+               DBG_SECURE("number: [%s]", number);
+               if (number != NULL) {
+                       _bt_util_get_number(number, pnumber);
+                       DBG_SECURE("pnumber: [%s]", pnumber);
+
+                       DBG_SECURE("CRC [%X], [%X]", chash, bt_crc32(pnumber, strlen(pnumber)));
+
+                       if (bt_crc32(pnumber , strlen(pnumber)) == chash) {
+#if 0
+                               contacts_record_get_int(record,
+                                               _contacts_quick_connect_info.contact_id,
+                                               &lcontact_id);
+#endif
+                               *contact_id = lcontact_id;
+                               _bt_util_get_contact_name(lcontact_id, contact_name);
+                               DBG_SECURE("contact id : %d", lcontact_id);
+                               break;
+                       }
+               }
+               ret = contacts_list_next(list);
+       }
+
+fail:
+       if (filter)
+               contacts_filter_destroy(filter);
+
+       if (query)
+               contacts_query_destroy(query);
+
+       if (list)
+               contacts_list_destroy(list, true);
+
+       contacts_disconnect();
+
+       DBG("-");
+}
+/* LCOV_EXCL_STOP */
+#endif
+#endif
+
+/* LCOV_EXCL_START */
+void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
+                              void *user_data)
+{
+       static int send_index = 0;
+       static gboolean is_started = FALSE;
+       static char *snd_db_sid = NULL;
+       static char *rcv_db_sid = NULL;
+       static bool is_tr_wait = true;
+       int percentage = 0;
+       int s_id = 0;
+       char *name = NULL;
+       char *opc_cnt = NULL;
+       notification_h noti = NULL;
+       bt_obex_server_authorize_into_t *auth_info = NULL;
+       bt_obex_server_transfer_info_t *transfer_info = NULL;
+       opc_transfer_info_t *node = NULL;
+       bt_appdata_t *ad = app_state;
+       bt_tr_data_t *info = NULL;
+       bt_opc_transfer_info_t *client_info = NULL;
+       bt_noti_data_t *data = NULL;
+       bt_device_snd_noti_info_t *snd_noti_info = NULL;
+
+       pthread_t thread_id = 0;
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
+
+       if (bt_transfer_list)
+               node = bt_transfer_list->data;
+
+       switch (event) {
+       case BLUETOOTH_EVENT_ENABLED: {
+               if (ad->obex_server_init == FALSE) {
+                       if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
+                               ad->obex_server_init = TRUE;
+               }
+               break;
+       }
+       case BLUETOOTH_EVENT_DISABLED: {
+               INFO("BT is disabled");
+               _bt_terminate_bluetooth_share();
+               break;
+       }
+       case BLUETOOTH_EVENT_OPC_CONNECTED: {
+               INFO("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d]", param->result);
+               ret_if(node == NULL);
+
+               send_index = 0;
+               is_started = FALSE;
+               is_tr_wait = true;
+
+               _bt_get_pending_list(ad);
+
+               retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
+
+               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+               retm_if(info == NULL, "info is NULL");
+
+               snd_db_sid = info->db_sid;
+               DBG_SECURE("snd_db_sid = [%s]", snd_db_sid);
+
+               _bt_convert_addr_type_to_string(bd_addr, info->addr);
+               DBG_SECURE("bd_addr = [%s]", bd_addr);
+
+               INFO("New device %s", node->name);
+
+               snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
+               memcpy(snd_noti_info->device_name, node->name,
+                                       BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+               memcpy(snd_noti_info->address,
+                               info->addr, BT_ADDRESS_STRING_SIZE);
+               snd_noti_info->db_sid = g_strdup(snd_db_sid);
+               snd_noti_info->send_noti = NULL;
+               snd_noti_info->send_data.tr_success = 0;
+               snd_noti_info->send_data.tr_fail = 0;
+               bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
+
+               if (param->result != BLUETOOTH_ERROR_NONE) {
+                       _bt_create_warning_popup(param->result,
+                               BT_STR_UNABLE_TO_SEND);
+                       if (node->file_cnt > send_index) {
+                               int *uids;
+                               int uid_cnt = 0;
+
+                               s_id = info->sid;
+                               INFO("info->sid = %d info->id = %d", info->sid, info->id);
+                               uids = g_malloc0(node->file_cnt * sizeof(int));
+
+                               while (ad->tr_next_data != NULL) {
+                                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+                                       if (info == NULL)
+                                               break;
+                                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
+                                       if (info->sid != s_id) {
+                                               DBG("SID did not match so break done.");
+                                               break;
+                                       }
+
+                                       uids[uid_cnt++] = info->id;
+                                       snd_noti_info->send_data.tr_fail++;
+                                       ad->tr_next_data = g_slist_next(ad->tr_next_data);
+                               }
+                               _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
+                                                               snd_noti_info->db_sid);
+                               _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+
+                               if (snd_noti_info->send_noti == NULL) {
+                                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+                                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+                                       snd_noti_info->send_noti = _bt_insert_notification(
+                                               ad, BT_SENT_NOTI, snd_noti_info->device_name,
+                                               snd_noti_info->address, snd_noti_info->db_sid);
+                               } else {
+                                       ad->send_noti = snd_noti_info->send_noti;
+                                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+                                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+                                       _bt_update_notification(ad, ad->send_noti, NULL, NULL,
+                                                                       NULL, NULL, NULL);
+                               }
+                               /* Update Database with Notification ID*/
+                               __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
+                                               snd_noti_info->db_sid);
+                               g_free(uids);
+                       }
+
+                       __bt_free_snd_notification(snd_noti_info);
+                       _remove_transfer_info(node);
+
+                       if (!ad->tr_next_data) {
+                               bt_share_release_tr_data_list(ad->tr_send_list);
+                               ad->tr_send_list = NULL;
+                       }
+
+               } else {
+                       _bt_insert_instant_notification(BT_SENDING_NOTI);
+
+                       if (ad->opc_noti) {
+                               _bt_delete_notification(ad->opc_noti);
+                               ad->opc_noti = NULL;
+                               ad->opc_noti_id = 0;
+                       }
+
+                       noti = _bt_insert_notification(ad,
+                                               BT_SENDING_NOTI, node->name,
+                                               node->addr, info->db_sid);
+                       ad->opc_noti = noti;
+                       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
+
+                       _bt_share_block_sleep(TRUE);
+                       _bt_set_transfer_indicator(TRUE);
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: {
+               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
+               ret_if(node == NULL);
+               retm_if(!ad, "ad is NULL");
+               retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
+
+               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+               ret_if(info == NULL);
+
+               is_started = TRUE;
+
+               if (send_index > 0 && is_tr_wait == true)
+                       is_tr_wait = false;
+
+               name = __get_file_name(send_index++, node->file_path);
+
+               if (node->file_cnt > 1)
+                       opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
+
+               INFO("file count %d", node->file_cnt);
+               _bt_convert_addr_type_to_string(bd_addr, node->addr);
+               DBG_SECURE("bd_addr = [%s]", bd_addr);
+
+               if (node->file_cnt > 1)
+                       _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
+                                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
+                                       name, *(node->size), opc_cnt, 0);
+               else
+                       _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
+                                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
+                                       name, *(node->size), "[1/1]", 0);
+
+               _bt_update_sent_data_status(info->id, BT_TR_ONGOING, info->db_sid);
+               _bt_update_transfer_list_view("outbound");
+
+               if (ad->opc_noti && is_tr_wait == false) {
+                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
+                       _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
+                       _bt_update_notification_progress(NULL, ad->opc_noti_id, 0);
+               }
+
+               g_free(opc_cnt);
+               retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
+
+               ad->current_tr_uid = info->id;
+               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: {
+               client_info = (bt_opc_transfer_info_t *)param->param_data;
+               ret_if(client_info == NULL);
+               ret_if(node == NULL);
+
+               percentage = client_info->percentage;
+               name =  strrchr(client_info->filename, '/');
+               if (name)
+                       name++;
+               else
+                       name = client_info->filename;
+
+               if (ad->opc_noti) {
+                       if (is_tr_wait == true) {
+                               char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
+
+                               if (node->file_cnt > 1)
+                                       opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
+
+                               _bt_update_notification(ad, ad->opc_noti, name, sending_files,
+                                               node->name, NULL, opc_cnt);
+
+                               g_free(opc_cnt);
+                               is_tr_wait = false;
+                       }
+                       _bt_update_notification_progress(NULL, ad->opc_noti_id, percentage);
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: {
+               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
+               ret_if(node == NULL);
+
+               if (!is_started) {
+                       INFO("TRANSFER operation abnormal. It is completed without TRANSFER START");
+                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+                       ret_if(info == NULL);
+                       ad->current_tr_uid = info->id;
+                       INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
+                       send_index++;
+               }
+
+               is_started = FALSE;
+
+               client_info = (bt_opc_transfer_info_t *)param->param_data;
+               ret_if(client_info == NULL);
+
+               DBG_SECURE("client_info->filename = [%s]", client_info->filename);
+               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
+
+               name =  strrchr(client_info->filename, '/');
+               if (name)
+                       name++;
+               else
+                       name = client_info->filename;
+
+               if (ad->opc_noti && is_tr_wait == true) {
+                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
+
+                       if (node->file_cnt > 1)
+                               opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
+
+                       _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
+                       g_free(opc_cnt);
+                       is_tr_wait = false;
+               }
+
+               DBG("name address = [%s]", name);
+
+               _bt_convert_addr_type_to_string(bd_addr, node->addr);
+               DBG_SECURE("bd_addr = [%s]", bd_addr);
+
+               snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
+               if (snd_noti_info == NULL) {
+                       INFO("New device %s", node->name);
+
+                       snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
+                       memcpy(snd_noti_info->device_name, node->name,
+                                               BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+                       memcpy(snd_noti_info->address, bd_addr,
+                                               BT_ADDRESS_STRING_SIZE);
+                       snd_noti_info->db_sid = g_strdup(snd_db_sid);
+                       snd_noti_info->send_noti = NULL;
+                       snd_noti_info->send_data.tr_success = 0;
+                       snd_noti_info->send_data.tr_fail = 0;
+                       bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
+               }
+               INFO("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d",
+                       ad->send_data.tr_fail, ad->send_data.tr_success);
+
+               if (param->result != BLUETOOTH_ERROR_NONE)
+                       snd_noti_info->send_data.tr_fail++;
+               else {
+                       snd_noti_info->send_data.tr_success++;
+                       _bt_remove_tmp_file(client_info->filename);
+                       _bt_remove_vcf_file(client_info->filename);
+                       _bt_update_notification_progress(NULL, ad->opc_noti_id, 100);
+               }
+
+               if (param->result == BLUETOOTH_ERROR_NOT_FOUND) {
+                       ERR("File Doesn't exist. ");
+                       _bt_update_sent_data_status(ad->current_tr_uid,
+                                                       BT_TR_FAIL, snd_noti_info->db_sid);
+               } else if (param->result != BLUETOOTH_ERROR_NONE) {
+                       _bt_update_sent_data_status(ad->current_tr_uid,
+                                                       BT_TR_FAIL, snd_noti_info->db_sid);
+                       ERR("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
+
+                       if (!ad->opp_transfer_abort)
+                               _bt_create_warning_popup(param->result,
+                                       BT_STR_UNABLE_TO_SEND);
+
+                       ad->opp_transfer_abort = FALSE;
+               } else {
+                       _bt_update_sent_data_status(ad->current_tr_uid,
+                                                       BT_TR_SUCCESS, snd_noti_info->db_sid);
+               }
+
+               _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+
+               ad->tr_next_data = g_slist_next(ad->tr_next_data);
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OPC_DISCONNECTED: {
+               INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED");
+               ret_if(node == NULL);
+
+               if (ad->opc_noti) {
+                       _bt_delete_notification(ad->opc_noti);
+                       ad->opc_noti = NULL;
+                       ad->opc_noti_id = 0;
+               }
+
+               _bt_convert_addr_type_to_string(bd_addr, node->addr);
+               DBG_SECURE("bd_addr = [%s]", bd_addr);
+
+               snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
+
+               if (snd_noti_info == NULL) {
+                       ERR("snd_noti_info == NULL, this shouldn't happen");
+                       goto done;
+               }
+
+               if (node->file_cnt > send_index) {
+                       int *uids;
+                       int uid_cnt = 0;
+                       send_index = 0;
+                       is_started = FALSE;
+                       retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
+
+                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+                       if (info == NULL) {
+                               /* Send Disconnect to Share-UI */
+                               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
+                                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
+                               break;
+                       }
+
+                       s_id = info->sid;
+                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
+                       uids = g_malloc0(node->file_cnt * sizeof(int));
+
+                       while (NULL != ad->tr_next_data) {
+                               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+                               if (info == NULL)
+                                       break;
+                               INFO("info->sid = %d info->id = %d", info->sid, info->id);
+
+                               if (s_id != info->sid) {
+                                       DBG("SID did not match so break done.");
+                                       break;
+                               }
+
+                               uids[uid_cnt++] = info->id;
+                               snd_noti_info->send_data.tr_fail++;
+                               ad->tr_next_data = g_slist_next(ad->tr_next_data);
+                       }
+                       _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
+                                                               snd_noti_info->db_sid);
+                       ad->send_noti = snd_noti_info->send_noti;
+                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+                       g_free(uids);
+               }
+
+               if (snd_noti_info->send_noti == NULL) {
+                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
+                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
+                       snd_noti_info->send_noti = _bt_insert_notification(ad,
+                               BT_SENT_NOTI, snd_noti_info->device_name,
+                               snd_noti_info->address, snd_noti_info->db_sid);
+               }
+
+               if (snd_noti_info->send_data.tr_success)
+                       _bt_insert_instant_notification(BT_SENT_NOTI);
+               else
+                       _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
+
+               /* Update Database with Notification ID*/
+               __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
+                               snd_noti_info->db_sid);
+done:
+               /* Send Disconnect to Share-UI */
+               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
+
+               send_index = 0;
+               is_started = FALSE;
+               __bt_free_snd_notification(snd_noti_info);
+               _bt_share_block_sleep(FALSE);
+               _bt_set_transfer_indicator(FALSE);
+               _remove_transfer_info(node);
+               if (!ad->tr_next_data) {
+                       bt_share_release_tr_data_list(ad->tr_send_list);
+                       ad->tr_send_list = NULL;
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE");
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: {
+               INFO("BT_EVENT_OBEX_TRANSFER_AUTHORIZE");
+               if (param->result == BLUETOOTH_ERROR_NONE) {
+                       g_free(server_auth_info.filename);
+                       g_free(server_auth_info.name);
+                       server_auth_info.filename = NULL;
+                       server_auth_info.name = NULL;
+
+                       auth_info = param->param_data;
+                       server_auth_info.filename = g_strdup(auth_info->filename);
+                       server_auth_info.length = auth_info->length;
+                       server_auth_info.name = g_strdup(auth_info->name);
+
+                       if (server_auth_info.filename)
+                               __bt_obex_file_push_auth(&server_auth_info);
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED");
+               bt_device_rcv_noti_info_t *rcv_noti_info = NULL;
+
+               rcv_db_sid = _bt_get_time_of_the_day();
+
+               DBG_SECURE("rcv_db_sid = [%s]", rcv_db_sid);
+               if (param->result == BLUETOOTH_ERROR_NONE) {
+                       bt_obex_server_connection_info_t *conn_info = param->param_data;
+                       DBG_SECURE("Address[%s] DeviceName[%s] TransferID[%d]",
+                                       conn_info->address, conn_info->device_name,
+                                       conn_info->transfer_id);
+
+                       rcv_noti_info =
+                               __bt_get_rcv_noti_data_by_device_address(conn_info->address);
+                       if (rcv_noti_info == NULL) {
+                               INFO("New device %s", conn_info->device_name);
+
+                               rcv_noti_info = g_new0(bt_device_rcv_noti_info_t, 1);
+                               rcv_noti_info->id = -1;
+                               rcv_noti_info->address = g_strdup(conn_info->address);
+                               rcv_noti_info->device_name = g_strdup(conn_info->device_name);
+                               rcv_noti_info->db_sid = g_strdup(rcv_db_sid);
+                               rcv_noti_info->recv_data.tr_success = -1;
+                               rcv_noti_info->recv_data.tr_fail = -1;
+                               bt_rcv_noti_info_list = g_slist_append(bt_rcv_noti_info_list, rcv_noti_info);
+                       }
+
+                       /* Insert Notification */
+                       /* TODO: Need to distinguish between GET or PUT request and show Receiving or Sending */
+                       noti = _bt_insert_notification(ad,
+                                       BT_RECEIVING_NOTI,
+                                       rcv_noti_info->device_name,
+                                       rcv_noti_info->address,
+                                       rcv_noti_info->db_sid);
+
+                       /* Save notification handle & ID and Transfer ID*/
+                       data = g_new0(bt_noti_data_t, 1);
+                       data->noti_handle = noti;
+                       data->noti_id = _bt_get_notification_priv_id(noti);
+                       data->transfer_id = conn_info->transfer_id;
+                       bt_receive_noti_list = g_slist_append(bt_receive_noti_list, data);
+
+
+                       isTransferConnectedReceived = TRUE;
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
+               transfer_info = param->param_data;
+               unsigned int file_size = 0;
+               char *contact_name = NULL;
+               bt_device_rcv_noti_info_t *rcv_noti_info =
+                       __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
+               data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
+               int current_file;
+
+               retm_if(data == NULL || rcv_noti_info == NULL, "Notification data NULL");
+
+               if (rcv_noti_info->recv_data.tr_success == -1 &&
+                               rcv_noti_info->recv_data.tr_fail == -1) {
+                       current_file = 1;
+               } else {
+                       current_file = rcv_noti_info->recv_data.tr_success +
+                                       rcv_noti_info->recv_data.tr_fail + 1;
+               }
+
+               opc_cnt = g_strdup_printf("[%d/All]", current_file);
+
+               if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
+                       /*GET request */
+                       _bt_set_notification_app_launch(noti,
+                                       transfer_info->device_name,
+                                       transfer_info->address,
+                                       rcv_db_sid,
+                                       CREATE_PROGRESS,
+                                       NOTI_TR_TYPE_OUT,
+                                       transfer_info->filename,
+                                       transfer_info->file_size, NULL,
+                                       transfer_info->transfer_id);
+               } else {
+                       /*PUT Request */
+                       _bt_add_recv_transfer_status_data(transfer_info->device_name,
+                                       transfer_info->address, transfer_info->filename, NULL,
+                                       file_size, BT_TR_ONGOING, rcv_noti_info->db_sid);
+                       rcv_noti_info->id = _bt_share_get_unique_id(BT_DB_INBOUND,
+                                       rcv_noti_info->db_sid);
+                       _bt_update_transfer_list_view(BT_INBOUND_TABLE);
+
+                       _bt_set_notification_app_launch(data->noti_handle,
+                                       transfer_info->device_name, transfer_info->address,
+                                       rcv_noti_info->db_sid, CREATE_PROGRESS,
+                                       NOTI_TR_TYPE_IN, transfer_info->filename,
+                                       transfer_info->file_size, NULL,
+                                       transfer_info->transfer_id);
+               }
+
+#ifdef ENABLE_CONTACTS_SERVICE2
+#if 0
+               int contact_id = -1;
+
+               if (transfer_info->contact_auth_info) {
+                       unsigned char auth_info_null[5];
+                       memset(auth_info_null, 0X0, 5);
+                       if (memcmp(transfer_info->contact_auth_info, auth_info_null, 5)) {
+                               _bt_util_get_contact_info(transfer_info->contact_auth_info, &contact_id, &contact_name);
+                               DBG_SECURE("contact_id: %d | contact_name: [%s]", contact_id, contact_name);
+                       }
+               }
+#endif
+#endif
+               char *receiving_files = "IDS_WIFI_BODY_RECEIVING_FILES_FROM_PS_ING";
+
+               INFO("Notification data: %p", data);
+               if (data) {
+                       _bt_update_notification(ad, data->noti_handle,
+                               transfer_info->filename, receiving_files,
+                               transfer_info->device_name, NULL, opc_cnt);
+                       _bt_update_notification_progress(data->noti_handle,
+                                       data->noti_id, 0);
+               }
+
+               _bt_set_transfer_indicator(TRUE);
+               _bt_share_block_sleep(TRUE);
+               g_free(opc_cnt);
+               g_free(contact_name);
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: {
+               if (param->result == BLUETOOTH_ERROR_NONE) {
+                       transfer_info = param->param_data;
+                       data = __bt_get_noti_data_by_transfer_id(
+                                               transfer_info->transfer_id);
+                       retm_if(data == NULL, "Data is NULL, returning");
+
+                       if (data && data->noti_id)
+                               _bt_update_notification_progress(
+                                               data->noti_handle,
+                                               data->noti_id,
+                                               transfer_info->percentage);
+                       else
+                               DBG("noti_id is not exist!");
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED");
+               char mime_type[BT_MIME_TYPE_MAX_LEN] = {0, };
+               unsigned int file_size = 0;
+               struct stat file_attr;
+               char *file_path = NULL;
+               transfer_info = param->param_data;
+               _bt_set_transfer_indicator(FALSE);
+               _bt_share_block_sleep(FALSE);
+
+               data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
+
+               if (g_strcmp0(transfer_info->type, TRANSFER_PUT) == 0) {
+                       INFO("TRANSFER_PUT");
+
+                       bt_device_rcv_noti_info_t *rcv_noti_info =
+                               __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
+
+                       if (rcv_noti_info == NULL)
+                               break;
+
+                       file_path = __get_dest_file_path(transfer_info->file_path);
+                       DBG_SECURE("Filename[%s] FilePath[%s] Address[%s]",
+                                       transfer_info->filename, file_path,
+                                       transfer_info->address);
+
+                       if (aul_get_mime_from_file(file_path, mime_type,
+                                       BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
+                               DBG_SECURE("mime type : %s", mime_type);
+
+                       if (g_utf8_validate(file_path, -1, NULL)) {
+                               if (stat(file_path, &file_attr) == 0)
+                                       file_size = file_attr.st_size;
+                               else
+                                       file_size = 0;
+                       }
+
+                       g_free(file_path);
+
+                       if (rcv_noti_info->recv_data.tr_success == -1 &&
+                                       rcv_noti_info->recv_data.tr_fail == -1) {
+                               rcv_noti_info->recv_data.tr_success = 0;
+                               rcv_noti_info->recv_data.tr_fail = 0;
+                       }
+
+                       if (param->result != BLUETOOTH_ERROR_NONE) {
+                               rcv_noti_info->recv_data.tr_fail++;
+                               _bt_update_recv_data_status(rcv_noti_info->id,
+                                                       BT_TR_FAIL, rcv_noti_info->db_sid,
+                                                       file_size, mime_type);
+                       } else {
+                               rcv_noti_info->recv_data.tr_success++;
+                               _bt_update_recv_data_status(rcv_noti_info->id,
+                                                       BT_TR_SUCCESS, rcv_noti_info->db_sid,
+                                                       file_size, mime_type);
+                               if (data)
+                                       _bt_update_notification_progress(data->noti_handle,
+                                                       data->noti_id, 100);
+                       }
+
+                       _bt_update_transfer_list_view(BT_INBOUND_TABLE);
+
+               } else if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
+                       INFO("TRANSFER_GET");
+               }
+
+               if (param->result == BLUETOOTH_ERROR_NONE) {
+                       bt_file_type_e file_type;
+                       char *extn = NULL;
+                       bt_file_info_t *info = NULL;
+
+                       transfer_info = param->param_data;
+                       if (transfer_info->file_path == NULL) {
+                               ERR("File path is NULL");
+                               break;
+                       }
+
+                       if (!g_strcmp0(transfer_info->type, TRANSFER_GET)) {
+                               DBG("Transfer is GET, so no need to handle");
+                               break;
+                       }
+
+                       name = __get_dest_file_path(transfer_info->file_path);
+
+                       extn = strrchr(name, '.');
+                       if (extn != NULL)
+                               extn++;
+                       file_type = __get_file_type(extn);
+
+                       INFO("file type %d", file_type);
+
+                       if (transfer_info->server_type == FTP_SERVER ||
+                                       file_type != BT_FILE_VCARD) {
+                               if (file_type != BT_FILE_VCAL)
+                                       __bt_scan_media_file(name);
+
+                               if (file_type != BT_FILE_VCARD)
+                                       __bt_move_media_file(name);
+                               else
+                                       ecore_file_remove(name);
+
+                               g_free(name);
+                               break;
+                       }
+
+                       info = g_new0(bt_file_info_t, 1);
+                       info->file_path = name;
+                       info->file_type = file_type;
+
+                       if (pthread_create(&thread_id, NULL, (void *)&__bt_obex_writeclose,
+                                                       info) < 0) {
+                               ERR("pthread_create() is failed");
+                               __free_file_info(info);
+                               break;
+                       }
+                       warn_if(pthread_detach(thread_id) < 0, "pthread_detach() is failed");
+
+               } else {
+                       DBG("param->result = %d", param->result);
+                       DBG("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
+
+                       if (!ad->opp_transfer_abort)
+                               _bt_create_warning_popup(param->result,
+                                       BT_STR_UNABLE_TO_RECEIVE);
+
+                       ad->opp_transfer_abort = FALSE;
+               }
+               break;
+       }
+
+       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED: {
+               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED");
+               transfer_info = param->param_data;
+
+               char *address = transfer_info->address;
+               int transfer_id = transfer_info->transfer_id;
+               int ret;
+
+               DBG_SECURE("OBEX Disconnected from: %s, transfer_id: %d", address, transfer_id);
+
+               if (param->result == BLUETOOTH_ERROR_NONE)
+                       isTransferConnectedReceived = FALSE;
+
+               /* P150828-03206 : OPP connection is disconnected without completed event
+               in this case, noti should be removed in the disconnected event */
+               data = __bt_get_noti_data_by_transfer_id(transfer_id);
+
+               if (data) {
+                       DBG("delete noti in the disconnected event!");
+                       _bt_delete_notification(data->noti_handle);
+                       bt_receive_noti_list = g_slist_remove(bt_receive_noti_list, data);
+                       g_free(data);
+               }
+
+               DBG("Sending signal to bt-share-ui");
+
+               /* Send Disconnect to Share-UI */
+               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_SERVER_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, address, transfer_id);
+
+               bt_device_rcv_noti_info_t *rcv_noti_info =
+                               __bt_get_rcv_noti_data_by_device_address(address);
+               if (rcv_noti_info == NULL) {
+                       INFO("rcv_noti_info does not exist!");
+                       break;
+               }
+
+               ad->recv_data.tr_success = rcv_noti_info->recv_data.tr_success;
+               ad->recv_data.tr_fail = rcv_noti_info->recv_data.tr_fail;
+               DBG("SUCCESS[%d] Failed[%d]", rcv_noti_info->recv_data.tr_success, rcv_noti_info->recv_data.tr_fail);
+
+               if (rcv_noti_info->recv_data.tr_success == -1 &&
+                               rcv_noti_info->recv_data.tr_fail == -1) {
+                       __bt_free_rcv_notification(rcv_noti_info);
+                       break;
+               }
+               notification_h rcv_noti_info_receive_noti = _bt_insert_notification(ad,
+                               BT_RECEIVED_NOTI, rcv_noti_info->device_name,
+                               rcv_noti_info->address, rcv_noti_info->db_sid);
+               ad->receive_noti = rcv_noti_info_receive_noti;
+               DBG("LAUNCH DATA: Filename [%s] TransferID[%d]",
+                               transfer_info->filename, transfer_info->transfer_id);
+
+               _bt_set_notification_app_launch(rcv_noti_info_receive_noti,
+                               rcv_noti_info->device_name, rcv_noti_info->address,
+                               rcv_noti_info->db_sid, CREATE_TR_LIST,
+                               NOTI_TR_TYPE_IN, transfer_info->filename,
+                               0, NULL, transfer_info->transfer_id);
+               ret = notification_update(rcv_noti_info_receive_noti);
+               warn_if(ret != NOTIFICATION_ERROR_NONE,
+                               "Fail to notification_update [%d]", ret);
+
+               if (rcv_noti_info->recv_data.tr_success != -1) {
+                       if (rcv_noti_info->recv_data.tr_success)
+                               _bt_insert_instant_notification(BT_RECEIVED_NOTI);
+                       else
+                               _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
+
+                       /* Update Database with Notification ID*/
+                       __bt_update_db_with_noti_id(BT_DB_INBOUND, rcv_noti_info_receive_noti,
+                                       rcv_noti_info->db_sid);
+               }
+
+               __bt_free_rcv_notification(rcv_noti_info);
+               break;
+       }
+
+       default:
+               break;
+       }
+
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static gchar *__bt_get_unique_file_name(char *storage_path, char *filename)
+{
+       char temp_filepath[BT_FILE_PATH_LEN_MAX] = { 0, };
+       char temp_filename[BT_TEMP_FILE_PATH_LEN_MAX] = { 0, };
+       char *ext = NULL;
+       char *temp = NULL;
+       unsigned int seq = 1;
+
+       temp = strrchr(filename, '.');
+       if (temp != NULL) {
+               ext = temp + 1;
+               *temp = '\0';
+       }
+
+       do {
+               if (ext != NULL)
+                       snprintf(temp_filename, sizeof(temp_filename), "%s_%d.%s",
+                                       filename, seq, ext);
+               else
+                       snprintf(temp_filename, sizeof(temp_filename), "%s_%d",
+                                       filename, seq);
+
+               snprintf(temp_filepath, sizeof(temp_filepath), "%s/%s",
+                                       storage_path, temp_filename);
+
+               /* In below code check is done for unique file name or
+                  Max value of integer reached, in this case overwrite
+                  the last file */
+               if ((access(temp_filepath, F_OK) == 0) && (seq < 65536))
+                       seq++;
+               else
+                       break;
+       } while (1);
+
+       return g_strdup(temp_filename);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_app_obex_openwrite_requested(bt_obex_server_authorize_into_t
+                                                       *server_auth_info)
+{
+       ret_if(server_auth_info == NULL);
+       ret_if(server_auth_info->filename == NULL);
+
+       char temp_filename[BT_FILE_PATH_LEN_MAX] = { 0, };
+       char storage[STORAGE_PATH_LEN_MAX] = { 0, };
+       char *name = NULL;
+       GRegex *regex = NULL;
+
+       /* Check if  file is already present */
+       _bt_get_default_storage(storage);
+
+       /* For vcf file type, some device send weird filename like "telecom/pb.vcf"
+           This filename should be renamed.
+       */
+
+       regex = g_regex_new("[*\"<>;?|\\^:/]", 0, 0, NULL);
+       name = g_regex_replace(regex, server_auth_info->filename, -1, 0, "_", 0, NULL);
+
+       g_regex_unref(regex);
+       if (g_strcmp0(name, server_auth_info->filename) != 0) {
+               g_free(server_auth_info->filename);
+               server_auth_info->filename = name;
+       } else {
+               g_free(name);
+       }
+
+       snprintf(temp_filename, BT_FILE_PATH_LEN_MAX, "%s/%s",
+                   storage, server_auth_info->filename);
+       INFO("temp_filename : %s", temp_filename);
+       if (access(temp_filename, F_OK) == 0) {
+               name = server_auth_info->filename;
+
+               server_auth_info->filename = __bt_get_unique_file_name(storage,
+                                                                       name);
+
+               g_free(name);
+       }
+
+       bluetooth_obex_server_accept_authorize(server_auth_info->filename);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t
+                                                       *server_auth_info)
+{
+       FN_START;
+
+       int val = -1;
+       gboolean ret = FALSE;
+       unsigned long long available_ext_mem_size = 0;
+       double available_int_mem_size = 0;
+
+       if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+                       (void *)&val)) {
+               ERR("vconf error");
+               goto reject;
+       }
+
+       INFO("File Length =%ld", (long int)server_auth_info->length);
+
+       if (val == BT_DEFAULT_MEM_MMC) {
+               ret = _bt_get_available_ext_memory(&available_ext_mem_size);
+               if (ret == FALSE) {
+                       ERR("Unable to get available memory size");
+                       goto reject;
+               }
+
+               INFO("available_ext_mem_size =%llu", available_ext_mem_size);
+               if (available_ext_mem_size < server_auth_info->length) {
+                       g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT,
+                               (GSourceFunc)_bt_app_popup_memoryfull,
+                               NULL);
+                       goto reject;
+               }
+       } else {
+               if (_bt_get_available_int_memory(&available_int_mem_size) < 0) {
+                       ERR("Unable to get available memory size");
+                       goto reject;
+               }
+
+               INFO("available_int_mem_size =%llu", available_ext_mem_size);
+               if (available_int_mem_size < server_auth_info->length) {
+                       g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT,
+                               (GSourceFunc)_bt_app_popup_memoryfull,
+                               NULL);
+                       goto reject;
+               }
+       }
+
+       DBG("isTransferConnectedReceived is : %d", isTransferConnectedReceived);
+
+       if (isTransferConnectedReceived) {
+               _bt_insert_instant_notification(BT_RECEIVING_NOTI);
+               isTransferConnectedReceived = FALSE;
+       }
+
+       __bt_app_obex_openwrite_requested(server_auth_info);
+
+       FN_END;
+       return;
+
+reject:
+       bluetooth_obex_server_reject_authorize();
+
+       FN_END;
+}
+/* LCOV_EXCL_STOP */
+
+#ifdef ENABLE_CONTACTS_SERVICE2
+/* LCOV_EXCL_START */
+static bool __bt_vcard_handler(contacts_record_h record, void *user_data)
+{
+       int ret = 0;
+
+       ret = contacts_db_insert_record(record, NULL);
+       warn_if(ret != CONTACTS_ERROR_NONE,
+               "contacts_svc_insert_vcard error : %d", ret);
+
+       return true;
+}
+/* LCOV_EXCL_STOP */
+#endif /* ENABLE_CONTACTS_SERVICE2 */
+
+#ifdef ENABLE_CALENDAR_SERVICE2
+/* LCOV_EXCL_START */
+static bool __bt_vcalendar_handler(calendar_record_h record, void *user_data)
+{
+       int ret = 0;
+
+       ret = calendar_db_insert_record(record, NULL);
+       warn_if(ret != CALENDAR_ERROR_NONE,
+               "calendar_db_insert_record error : %d", ret);
+
+       return true;
+       /* LCOV_EXCL_STOP */
+}
+#endif /* ENABLE_CALENDAR_SERVICE2 */
+
+/* LCOV_EXCL_START */
+static gboolean __bt_save_v_object(char *file_path,
+                                           bt_file_type_e file_type)
+{
+       retv_if(NULL == file_path, FALSE);
+
+       DBG_SECURE("file_path = %s, file_type = %d", file_path, file_type);
+
+       switch (file_type) {
+#ifdef ENABLE_CONTACTS_SERVICE2
+       case BT_FILE_VCARD: {
+               int ret = 0;
+               ret = contacts_connect();
+               if (ret != CONTACTS_ERROR_NONE) {
+                       ERR("contacts_connect2 error = %d \n", ret);
+                       return FALSE;
+               }
+
+               ret = contacts_vcard_parse_to_contact_foreach(file_path,
+                                       __bt_vcard_handler, NULL);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       ERR("[error] = %d \n", ret);
+                       ret = contacts_disconnect();
+                       if (ret != CONTACTS_ERROR_NONE)
+                               ERR("contacts_disconnect2 error = %d \n", ret);
+                       return FALSE;
+               }
+
+               ret = contacts_disconnect();
+               if (ret != CONTACTS_ERROR_NONE) {
+                       ERR("contacts_disconnect2 error = %d \n", ret);
+                       return FALSE;
+               }
+               break;
+       }
+#endif /* ENABLE_CONTACTS_SERVICE2 */
+
+#ifdef ENABLE_CALENDAR_SERVICE2
+       case BT_FILE_VCAL: {
+               int ret = 0;
+
+               ret = calendar_connect();
+               retvm_if(ret != CALENDAR_ERROR_NONE, FALSE,
+                               "calendar_connect error = %d", ret);
+
+               ret = calendar_vcalendar_parse_to_calendar_foreach(file_path,
+                                       __bt_vcalendar_handler, NULL);
+               if (ret != CALENDAR_ERROR_NONE) {
+                       ERR("[error] = %d", ret);
+                       ret = calendar_disconnect();
+                       warn_if(ret != CALENDAR_ERROR_NONE,
+                               "calendar_disconnect error = %d", ret);
+                       return FALSE;
+               }
+               ret = calendar_disconnect();
+               retvm_if(ret != CALENDAR_ERROR_NONE, FALSE,
+                               "calendar_disconnect error = %d", ret);
+               break;
+       }
+#endif /* ENABLE_CALENDAR_SERVICE2 */
+
+       default:
+               return FALSE;
+       }
+
+       return TRUE;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void *__bt_obex_writeclose(bt_file_info_t *info)
+{
+       if (info->file_type == BT_FILE_VCAL || info->file_type == BT_FILE_VCARD) {
+               if (__bt_save_v_object(info->file_path, info->file_type) == FALSE)
+                       ERR("Unable to save vObject");
+
+               ecore_file_remove(info->file_path);
+       } else {
+               __bt_move_media_file(info->file_path);
+       }
+
+       __free_file_info(info);
+
+       return NULL;
+}
+/* LCOV_EXCL_STOP */
diff --git a/app/obex-event-handler.h b/app/obex-event-handler.h
new file mode 100644 (file)
index 0000000..2ef1cc7
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * bluetooth-share
+ *
+ * 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_EVENT_HANDLER_H__
+#define __BT_EVENT_HANDLER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "bluetooth-api.h"
+#include "bt-share-main.h"
+#include "bt-share-common.h"
+
+#define BT_FILE_PATH_LEN_MAX   (4096 + 10)
+#define BT_TEMP_FILE_PATH_LEN_MAX 262
+#define BT_TEXT_LEN_MAX 255
+#define BLUETOOTH_DEVICE_NAME_LENGTH_MAX 248 /**< This specifies maximum device name length */
+
+typedef enum {
+       BT_FILE_IMAGE,  /**<IMAGE */
+       BT_FILE_VCARD,  /**<VCARD */
+       BT_FILE_VCAL,   /**<VCAL */
+       BT_FILE_VBOOKMARK,      /**<VBOOKMARK */
+       BT_FILE_VMEMO,
+       BT_FILE_DOC,    /**<DOC, */
+       BT_FILE_OTHER   /**<OTHER*/
+} bt_file_type_e;
+
+typedef struct {
+       int id;
+       char *address;
+       char *device_name;
+       char *db_sid;
+       bt_transfer_status_info_t recv_data;
+} bt_device_rcv_noti_info_t;
+
+typedef struct {
+       char address[BT_ADDRESS_STRING_SIZE];
+       char device_name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX];
+       char *db_sid;
+       notification_h send_noti;
+       bt_transfer_status_info_t send_data;
+} bt_device_snd_noti_info_t;
+
+extern bt_obex_server_authorize_into_t server_auth_info;
+
+void _bt_clear_receive_noti_list(void);
+
+void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
+                              void *user_data);
+
+void _bt_obex_cancel_transfer(void *data);
+
+void _bt_obex_server_event_handler(int event,
+                                      bluetooth_event_param_t *param,
+                                      void *user_data);
+
+void _bt_app_obex_download_dup_file_cb(void *data, void *obj,
+                                      void *event_info);
+
+void _bt_free_auth_info();
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __BT_EVENT_HANDLER_H__ */
diff --git a/app/org.bluetooth.share.service b/app/org.bluetooth.share.service
new file mode 100644 (file)
index 0000000..600471b
--- /dev/null
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.bluetooth.share
+Exec=/bin/false
+SystemdService=bluetooth-share.service
diff --git a/bt-share/CMakeLists.txt b/bt-share/CMakeLists.txt
deleted file mode 100644 (file)
index e443b13..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bluetooth-share C CXX)
-
-SET(SRCS src/bt-share-main.c
-src/bt-share-notification.c
-src/bt-share-common.c
-src/obex-event-handler.c
-src/bt-share-syspopup.c
-src/bt-share-ipc.c
-src/bt-share-noti-handler.c
-src/bt-share-cynara.c
-)
-
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api
-                               aul appcore-common
-                               dlog vconf syspopup-caller deviced
-                               notification sqlite3 ecore-file
-                               appsvc appcore-efl storage
-                               capi-content-media-content
-                               libtzplatform-config eventsystem
-                               cynara-creds-dbus cynara-client cynara-session
-                               storage db-util libsystemd-login)
-pkg_check_modules(CALENDAR_SERVICE2 calendar-service2)
-pkg_check_modules(CONTACTS_SERVICE2 contacts-service2 zlib)
-
-#FOREACH(flag ${pkgs_CFLAGS})
-FOREACH(flag ${pkgs_CFLAGS} ${CALENDAR_SERVICE2_CFLAGS} ${CONTACTS_SERVICE2_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Werror -Wno-deprecated-declarations")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(INCLUDEDIR "/usr/include")
-SET(VERSION 1.0)
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
-ADD_DEFINITIONS("-DTARGET")
-ADD_DEFINITIONS("-DSLP_DEBUG")
-#if(CALENDAR_SERVICE2_FOUND)
-#  ADD_DEFINITIONS("-DENABLE_CALENDAR_SERVICE2")
-#endif(CALENDAR_SERVICE2_FOUND)
-#if(CONTACTS_SERVICE2_FOUND)
-#  ADD_DEFINITIONS("-DENABLE_CONTACTS_SERVICE2")
-#endif(CONTACTS_SERVICE2_FOUND)
-
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAGS} ${CONTACTS_SERVICE2_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
-#TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api)
-
-IF (BUILD_GCOV)
-# -fvisibility option should be "default" to call internal functions
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=default -fPIC -Werror -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage")
-
-ADD_LIBRARY(bt-share SHARED ${SRCS})
-SET_TARGET_PROPERTIES(bt-share
-       PROPERTIES
-       SOVERSION 0.1.0
-       CLEAN_DIRECT_OUTPUT 1)
-
-TARGET_LINK_LIBRARIES(bt-share ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAGS} ${CONTACTS_SERVICE2_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api -lgcov)
-INSTALL(TARGETS bt-share DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-ENDIF (BUILD_GCOV)
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/org.bluetooth.share.service DESTINATION share/dbus-1/system-services)
diff --git a/bt-share/include/applog.h b/bt-share/include/applog.h
deleted file mode 100644 (file)
index 5753b7a..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __APPLOG_H__
-#define __APPLOG_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * SYSLOG_INFO(), SYSLOG_ERR(), SYSLOG_DBG() are syslog() wrappers.
- * PRT_INFO(), PRT_ERR(), PRT_DBG() are fprintf() wrappers.
- *
- * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored.
- *
- * IF SLP_SYSLOG_OUT or SLP_DAEMON is defined,
- *   INFO(), ERR(), DBG() are SYSLOG_XXX()
- * Otherwise,
- *   They are PRT_XXX()
- *
- *
- * warn_if(exrp, fmt, ...)
- *   If expr is true, The fmt string is printed using ERR().
- *
- * ret_if(), retv_if(), retm_if(), retvm_if()
- *   If expr is true, current function return.
- *   Postfix 'v' means that it has a return value and
- *   'm' means that it has output message.
- *
- */
-
-#include <stdio.h>
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "BLUETOOTH_SHARE"
-
-#define INFO(fmt, arg...) \
-       SLOGI(fmt, ##arg)
-
-#define ERR(fmt, arg...) \
-       SLOGE(fmt, ##arg)
-
-#define DBG(fmt, arg...) \
-       SLOGD(fmt, ##arg)
-
-#define        FN_START DBG("[ENTER FUNC]");
-#define        FN_END DBG("[EXIT FUNC]");
-
-#define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
-#define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
-#define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args)
-
-#define warn_if(expr, fmt, arg...) do { \
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-               } \
-       } while (0)
-
-#define ret_if(expr) do { \
-               if (expr) { \
-                       return; \
-               } \
-       } while (0)
-
-#define retv_if(expr, val) do { \
-               if (expr) { \
-                       return (val); \
-               } \
-       } while (0)
-
-#define retm_if(expr, fmt, arg...) do { \
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-                       return; \
-               } \
-       } while (0)
-
-#define retvm_if(expr, val, fmt, arg...) do { \
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-                       return (val); \
-               } \
-       } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __APPLOG_H__ */
diff --git a/bt-share/include/bt-share-common.h b/bt-share/include/bt-share-common.h
deleted file mode 100644 (file)
index e3f2aae..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_COMMON_H_
-#define __DEF_BLUETOOTH_SHARE_COMMON_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-#include <tzplatform_config.h>
-
-/* Define Error type */
-#define BT_SHARE_FAIL -1
-#define BT_SHARE_ERROR_NONE 0
-
-#define BT_DEFAULT_MEM_PHONE 0
-#define BT_DEFAULT_MEM_MMC 1
-
-#define STORAGE_PATH_LEN_MAX 255
-
-#define BT_ADDRESS_STRING_SIZE 18 /**< This specifies bluetooth device address string length */
-#define BT_ADDRESS_LENGTH 6 /**< This specifies bluetooth device address length */
-
-#define BT_OBEX_PATH_PREFIX "/opt/usr/media"
-#define BT_OBEX_DEFAULT_PATH "/opt/usr/home/owner/media"
-
-#define BT_DOWNLOAD_DEFAULT_PHONE_FOLDER "/opt/usr/home/owner/media/Downloads"
-#define BT_DOWNLOAD_DEFAULT_MMC_FOLDER "/opt/media/SDCardA1"
-#define BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER "/opt/usr/home/owner/media/Downloads"
-#define BT_DOWNLOAD_PHONE_ROOT "/opt/usr/home/owner/media/"
-#define BT_DOWNLOAD_MMC_ROOT "/opt/media/SDCardA1"
-#define BT_FTP_FOLDER "/opt/share/bt-ftp"
-#define BT_FTP_FOLDER_PHONE "/opt/share/bt-ftp/Media/"
-#define BT_FTP_FOLDER_MMC "/opt/share/bt-ftp/SD_External/"
-
-#define BT_TMP_DIR "/opt/usr/home/owner/media/Downloads/"
-#define BT_TMP_FILE BT_TMP_DIR"bluetooth_content_share"
-#define TXT_FILE_NAME BT_TMP_DIR"bluetooth_content_share.txt"
-#define HTML_FILE_NAME BT_TMP_DIR"bluetooth_content_share.html"
-#define TXT_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.txt"
-#define HTML_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.html"
-#define HTML_FORMAT "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/></head><body><a href=\"%s\">%s</a></body></html>"
-#define BT_CONTACT_SHARE_TMP_DIR "/opt/usr/home/owner/media/Downloads/"
-
-#define BT_SHARE_DATA_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "bluetooth-share")
-
-typedef enum {
-       BT_HTTP_FILE,
-       BT_TXT_FILE,
-} bt_file_e;
-
-typedef enum {
-       BT_STATUS_OFF         = 0x0000,
-       BT_STATUS_ON          = 0x0001,
-       BT_STATUS_BT_VISIBLE  = 0x0002,
-       BT_STATUS_TRANSFER    = 0x0004,
-} bt_status_e;
-
-int _bt_share_block_sleep(gboolean is_block);
-int _bt_set_transfer_indicator(gboolean state);
-char *_bt_share_create_transfer_file(char *text);
-void _bt_remove_tmp_file(char *file_path);
-void _bt_remove_vcf_file(char *file_path);
-char *_bt_get_time_of_the_day(void);
-void _bt_get_default_storage(char *storage);
-char *_bt_share_get_storage_path(int storage_type);
-int _bt_share_get_active_uid(uid_t *uid);
-void _bt_convert_addr_type_to_string(char *address, char *addr);
-int _bt_get_available_int_memory(double *dAvail);
-gboolean _bt_get_available_ext_memory(unsigned long long *available_mem_size);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_COMMON_H_ */
diff --git a/bt-share/include/bt-share-cynara.h b/bt-share/include/bt-share-cynara.h
deleted file mode 100644 (file)
index ca028c7..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_CYNARA_H_
-#define __DEF_BLUETOOTH_SHARE_CYNARA_H_
-
-#include <unistd.h>
-#include <dbus/dbus.h>
-
-#define BT_SHARE_PRIVILEGE "http://tizen.org/privilege/bluetooth"
-
-/* #define CYNARA_ENABLE 1 */
-
-typedef struct {
-       pid_t pid;
-       char *uid;
-       char *smack;
-} bt_share_cynara_creds;
-
-int _bt_share_cynara_init(void);
-int _bt_share_cynara_get_creds(DBusConnection *conn, const char *sender,
-                                  bt_share_cynara_creds *creds);
-int _bt_share_cynara_check(const bt_share_cynara_creds *creds, const char *privilege);
-void _bt_share_cynara_finish(void);
-
-#endif                         /* __DEF_BLUETOOTH_SHARE_CYNARA_H_ */
diff --git a/bt-share/include/bt-share-ipc.h b/bt-share/include/bt-share-ipc.h
deleted file mode 100644 (file)
index 853833a..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_IPC_H_
-#define __DEF_BLUETOOTH_SHARE_IPC_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-#include "bluetooth-api.h"
-#include "bt-share-main.h"
-
-#define BT_BLUEZ_INTERFACE "org.freedesktop.DBus"
-#define BT_BLUEZ_SIGNAL_NAME_OWNER_CHANGED "NameOwnerChanged"
-
-#define BT_SYSPOPUP_INTERFACE "User.Bluetooth.syspopup"
-#define BT_SYSPOPUP_METHOD_RESPONSE "Response"
-
-#define BT_UG_IPC_INTERFACE "User.Bluetooth.UG"
-#define BT_UG_IPC_METHOD_SEND "Send"
-
-#define BT_SHARE_UI_INTERFACE "User.BluetoothShare.UI"
-#define BT_SHARE_UI_SIGNAL_OPPABORT "opp_abort"
-#define BT_SHARE_UI_SIGNAL_SEND_FILE "send_file"
-#define BT_SHARE_UI_SIGNAL_INFO_UPDATE "info_update"
-
-#define BT_SHARE_ENG_INTERFACE "User.BluetoothShare.Engine"
-#define BT_SHARE_ENG_OBJECT "/org/projectx/transfer_info"
-#define BT_SHARE_ENG_SIGNAL_UPDATE_VIEW "update_view"
-#define BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED "ShareOppClientDisconnected"
-#define BT_SHARE_ENG_SIGNAL_OPP_SERVER_DISCONNECTED "ShareOppServerDisconnected"
-#define BT_SHARE_FRWK_INTERFACE "User.Bluetooth.FRWK"
-#define BT_SHARE_FRWK_SIGNAL_DEINIT "deinit"
-
-#define BT_CORE_NAME "org.projectx.bt_core"
-#define BT_CORE_PATH "/org/projectx/bt_core"
-#define BT_CORE_INTERFACE "org.projectx.btcore"
-
-#define BT_IPC_STRING_SIZE 256
-#define BT_ADDR_STR_LEN_MAX    18
-#define BT_MIME_TYPE_MAX_LEN   20
-
-#define BT_INBOUND_TABLE       "inbound"
-#define BT_OUTBOUND_TABLE      "outbound"
-
-typedef enum {
-       BT_TR_PENDING = -2,
-       BT_TR_ONGOING = -1,
-       BT_TR_SUCCESS,
-       BT_TR_FAIL
-} bt_app_tr_status_e;
-
-typedef enum {
-       BT_TR_OUTBOUND,
-       BT_TR_INBOUND
-} bt_share_tr_type_e;
-
-typedef struct {
-       int file_cnt;
-       char addr[BLUETOOTH_ADDRESS_LENGTH];
-       char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX];
-       char *mode;
-       char **file_path;
-       char **content;
-       char **type;
-       unsigned int *size;
-} opc_transfer_info_t;
-
-gboolean _bt_init_dbus_signal(void);
-void _bt_deinit_dbus_signal(void);
-
-void _remove_transfer_info(opc_transfer_info_t *node);
-
-void _bt_create_warning_popup(int error_type, char *msg);
-gboolean _bt_update_sent_data_status(int uid,
-                               bt_app_tr_status_e status, char *db_sid);
-
-gboolean _bt_update_recv_data_status(int uid,
-               bt_app_tr_status_e status, char *db_sid,
-               unsigned int filesize, const char *mime_type);
-
-gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
-                               bt_app_tr_status_e status, char *db_sid);
-
-void _bt_update_transfer_list_view(char *db);
-void _bt_send_disconnected_signal(char *signal, int result, char *address,
-               int transfer_id);
-gboolean _bt_add_recv_transfer_status_data(char *device_name,
-                       char *address, char *filepath, char *type,
-                       unsigned int size, int status, char *db_sid);
-int _bt_share_get_unique_id(int db_table, const char *db_sid);
-int _bt_set_eventsystem_transfer_value(gboolean value);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_IPC_H_ */
diff --git a/bt-share/include/bt-share-main.h b/bt-share/include/bt-share-main.h
deleted file mode 100644 (file)
index d8e6048..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_H_
-#define __DEF_BLUETOOTH_SHARE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <notification.h>
-#include <tzplatform_config.h>
-#include <db-util.h>
-
-#ifndef PACKAGE_NAME
-#define PACKAGE_NAME "bluetooth-share"
-#endif
-
-#define UI_PACKAGE "org.tizen.bluetooth-share-ui"
-
-typedef void (*bt_app_cb) (void *, void *, void *);
-
-typedef struct {
-       bt_app_cb popup_cb;
-       void *popup_cb_data;
-       gboolean syspopup_request;
-} bt_app_popups_t;
-
-typedef struct {
-       int tr_success;
-       int tr_fail;
-} bt_transfer_status_info_t;
-
-typedef struct {
-       bt_app_popups_t popups;
-       bt_transfer_status_info_t send_data;
-       bt_transfer_status_info_t recv_data;
-       GSList *tr_send_list;
-       GSList *tr_next_data;
-       int current_tr_uid;
-       notification_h send_noti;
-       notification_h receive_noti;
-       notification_h opc_noti;
-       int send_noti_id;
-       int receive_noti_id;
-       int opc_noti_id;
-       GDBusConnection *conn;
-       GObject *object;
-       gboolean obex_server_init;
-       bool opp_transfer_abort;
-       guint idler;
-} bt_appdata_t;
-
-int _bt_init_obex_server(void);
-
-void _bt_terminate_bluetooth_share(void);
-
-void _bt_remove_temporary_files_by_noti_id(sqlite3 *db, int noti_id);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_H_ */
diff --git a/bt-share/include/bt-share-noti-handler.h b/bt-share/include/bt-share-noti-handler.h
deleted file mode 100644 (file)
index c346618..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_NOTI_HANDLER_H_
-#define __DEF_BLUETOOTH_SHARE_NOTI_HANDLER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void _bt_init_vconf_notification(void *data);
-void _bt_deinit_vconf_notification(void);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_NOTI_HANDLER_H_ */
diff --git a/bt-share/include/bt-share-notification.h b/bt-share/include/bt-share-notification.h
deleted file mode 100644 (file)
index 3879c2a..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_NOTI_H_
-#define __DEF_BLUETOOTH_SHARE_NOTI_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <glib.h>
-#include <notification.h>
-#include <tzplatform_config.h>
-
-#include "bt-share-main.h"
-
-#define NOTIFICATION_TEXT_LEN_MAX 100
-#define NOTI_TR_TYPE_IN "inbound"
-#define NOTI_TR_TYPE_OUT "outbound"
-#define NOTI_OPS_APP_ID        "bluetooth-share-opp-server"
-#define NOTI_OPC_APP_ID        "bluetooth-share-opp-client"
-
-typedef enum {
-       BT_SENT_NOTI,
-       BT_SENT_FAILED_NOTI,
-       BT_SENDING_NOTI,
-       BT_RECEIVED_NOTI,
-       BT_RECEIVED_FAILED_NOTI,
-       BT_RECEIVING_NOTI,
-} bt_notification_type_e;
-
-typedef enum {
-       CREATE_PROGRESS,
-       CREATE_TR_LIST
-} bt_notification_launch_type_e;
-
-void _bt_insert_instant_notification(bt_notification_type_e type);
-
-notification_h _bt_insert_notification(bt_appdata_t *ad,
-               bt_notification_type_e type, char *dev_name,
-               char *address, char *db_sid);
-
-int _bt_update_notification(bt_appdata_t *ad, notification_h noti,
-               char *title, char *content, char *dev_name, char *icon_path, char *opc_count);
-
-int _bt_update_notification_progress(notification_h noti,
-               int id,
-               int val);
-
-int _bt_get_notification_priv_id(notification_h noti);
-
-int _bt_delete_notification(notification_h noti);
-
-int _bt_set_notification_app_launch(notification_h noti, char *device_name,
-               char *device_addr, char *db_sid,
-               bt_notification_launch_type_e launch_type,
-               const char *transfer_type,
-               const char *filename,
-               unsigned long size,
-               const char *progress_cnt,
-               int transfer_id);
-
-#if 0
-gboolean _bt_update_notification_status(bt_appdata_t *ad);
-#endif
-
-void _bt_register_notification_cb(bt_appdata_t *ad);
-
-void _bt_unregister_notification_cb(bt_appdata_t *ad);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_NOTI_H_ */
diff --git a/bt-share/include/bt-share-resource.h b/bt-share/include/bt-share-resource.h
deleted file mode 100644 (file)
index e6d17d8..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_RES_H_
-#define __DEF_BLUETOOTH_SHARE_RES_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <libintl.h>
-#include <tzplatform_config.h>
-
-/*==============  String ================= */
-#define BT_COMMON_PKG          "ug-setting-bluetooth-efl"
-#define BT_COMMON_RES          "/usr/ug/res/locale/"
-
-#define BT_STR_MEMORY_FULL     \
-       dgettext(BT_COMMON_PKG, "IDS_BT_POP_MEMORYFULL")
-#define BT_STR_UNABLE_TO_SEND  \
-       dgettext(BT_COMMON_PKG, "IDS_BT_POP_SENDINGFAIL")
-#define BT_STR_UNABLE_TO_RECEIVE       \
-       dgettext(BT_COMMON_PKG, "IDS_BT_BODY_UNABLE_TO_RECEIVE")
-#define BT_STR_FILES_SENT\
-       dgettext(BT_COMMON_PKG, "IDS_ST_BODY_FILES_SENT_ABB")
-#define BT_STR_FILES_RECEIVED\
-       dgettext(BT_COMMON_PKG, "IDS_ST_BODY_FILES_RECEIVED_ABB")
-#define BT_STR_FILES_SENT_TO \
-       dgettext(BT_COMMON_PKG, "IDS_WIFI_BODY_FILES_SENT_TO_PS_M_STATUS")
-#define BT_STR_FILES_RECEIVED_FROM \
-       dgettext(BT_COMMON_PKG, "IDS_WIFI_MBODY_FILES_RECEIVED_FROM_PS")
-
-#define BT_STR_SENDING_FILES_TO \
-       dgettext(BT_COMMON_PKG, "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING")
-#define BT_STR_SENDING_FILES \
-       dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SENDING_FILES_ING_ABB")
-#define BT_STR_RECEIVING_FILES_FROM \
-       dgettext(BT_COMMON_PKG, "IDS_WIFI_BODY_RECEIVING_FILES_FROM_PS_ING")
-#define BT_STR_RECEIVING_FILES \
-       dgettext(BT_COMMON_PKG, "IDS_NFC_BODY_RECEIVING_FILES_ING")
-#define BT_STR_SENDING_FILES_FAILED \
-       dgettext(BT_COMMON_PKG, "IDS_WIFI_POP_SENDING_FILES_FAILED")
-#define BT_STR_RECEIVING_FILES_FAILED \
-       dgettext(BT_COMMON_PKG, "IDS_WIFI_POP_RECEIVING_FILES_FAILED")
-
-/*==============  Image ================= */
-#define ICONDIR                "/usr/ug/res/images/ug-setting-bluetooth-efl"
-#define QP_PRELOAD_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/Common"
-#define BT_ICON_PATH_MAX       256
-
-#define BT_ICON_QP_SEND                tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \
-                                                       "/Q02_icon_BT_transmit.png")
-#define BT_ICON_QP_RECEIVE     tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \
-                                                       "/Q02_icon_BT_receive.png")
-#define BT_ICON_QP_BT_ON       tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \
-                                                       "/Q02_Notification_bluetooth.png")
-
-#define BT_ICON_NOTIFICATION_SENDING           "reserved://quickpanel/ani/uploading"
-#define BT_ICON_NOTIFICATION_SENDING_INDICATOR         "reserved://indicator/ani/uploading"
-#define BT_ICON_NOTIFICATION_SENT              QP_PRELOAD_NOTI_ICON_PATH"/noti_upload_complete.png"
-#define BT_ICON_NOTIFICATION_SENT_INDICATOR            ICONDIR"/B03_upload_complete.png"
-#define BT_ICON_NOTIFICATION_RECEIVING         "reserved://quickpanel/ani/downloading"
-#define BT_ICON_NOTIFICATION_RECEIVING_INDICATOR               "reserved://indicator/ani/downloading"
-#define BT_ICON_NOTIFICATION_RECEIVED          QP_PRELOAD_NOTI_ICON_PATH"/noti_download_complete.png"
-#define BT_ICON_NOTIFICATION_RECEIVED_INDICATOR                ICONDIR"/B03_download_complete.png"
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_RES_H_ */
diff --git a/bt-share/include/bt-share-syspopup.h b/bt-share/include/bt-share-syspopup.h
deleted file mode 100644 (file)
index ca73b3b..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 __DEF_BLUETOOTH_SHARE_SYSPOPUP_H_
-#define __DEF_BLUETOOTH_SHARE_SYSPOPUP_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BT_GLOBALIZATION_STR_LENGTH    256
-#define BT_FILE_NAME_LEN_MAX 255
-#define BT_POPUP_TEXT_LEN \
-               (BT_GLOBALIZATION_STR_LENGTH + BT_FILE_NAME_LEN_MAX)
-
-/* This value are used in the N-prj */
-#define BT_APP_POPUP_LAUNCH_TIMEOUT 100
-
-typedef enum {
-       BT_APP_EVENT_CONFIRM_MODE_REQUEST = 0x0001,
-       BT_APP_EVENT_FILE_RECEIVED = 0x0002,
-       BT_APP_EVENT_INFORMATION = 0x0004,
-       BT_APP_EVENT_OVERWRITE_REQUEST = 0x0008
-} bt_app_event_type_e;
-
-typedef enum {
-       POPUP_RESPONSE_OK,
-       POPUP_RESPONSE_CANCEL,
-       POPUP_RESPONSE_TIMEOUT
-} bt_popup_response_e;
-
-typedef struct {
-       char *title;
-       char *type;
-       char *file;
-       char *device_name;
-} bt_app_sys_popup_params_t;
-
-int _bt_launch_system_popup(bt_app_event_type_e event_type,
-                           bt_app_sys_popup_params_t *popup_params,
-                           void *cb,
-                           void *data);
-
-gboolean _bt_app_popup_memoryfull(gpointer user_data);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __DEF_BLUETOOTH_SHARE_SYSPOPUP_H_ */
diff --git a/bt-share/include/obex-event-handler.h b/bt-share/include/obex-event-handler.h
deleted file mode 100644 (file)
index 2ef1cc7..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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_EVENT_HANDLER_H__
-#define __BT_EVENT_HANDLER_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "bluetooth-api.h"
-#include "bt-share-main.h"
-#include "bt-share-common.h"
-
-#define BT_FILE_PATH_LEN_MAX   (4096 + 10)
-#define BT_TEMP_FILE_PATH_LEN_MAX 262
-#define BT_TEXT_LEN_MAX 255
-#define BLUETOOTH_DEVICE_NAME_LENGTH_MAX 248 /**< This specifies maximum device name length */
-
-typedef enum {
-       BT_FILE_IMAGE,  /**<IMAGE */
-       BT_FILE_VCARD,  /**<VCARD */
-       BT_FILE_VCAL,   /**<VCAL */
-       BT_FILE_VBOOKMARK,      /**<VBOOKMARK */
-       BT_FILE_VMEMO,
-       BT_FILE_DOC,    /**<DOC, */
-       BT_FILE_OTHER   /**<OTHER*/
-} bt_file_type_e;
-
-typedef struct {
-       int id;
-       char *address;
-       char *device_name;
-       char *db_sid;
-       bt_transfer_status_info_t recv_data;
-} bt_device_rcv_noti_info_t;
-
-typedef struct {
-       char address[BT_ADDRESS_STRING_SIZE];
-       char device_name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX];
-       char *db_sid;
-       notification_h send_noti;
-       bt_transfer_status_info_t send_data;
-} bt_device_snd_noti_info_t;
-
-extern bt_obex_server_authorize_into_t server_auth_info;
-
-void _bt_clear_receive_noti_list(void);
-
-void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
-                              void *user_data);
-
-void _bt_obex_cancel_transfer(void *data);
-
-void _bt_obex_server_event_handler(int event,
-                                      bluetooth_event_param_t *param,
-                                      void *user_data);
-
-void _bt_app_obex_download_dup_file_cb(void *data, void *obj,
-                                      void *event_info);
-
-void _bt_free_auth_info();
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* __BT_EVENT_HANDLER_H__ */
diff --git a/bt-share/src/bt-share-common.c b/bt-share/src/bt-share-common.c
deleted file mode 100644 (file)
index e68b6ee..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <dd-display.h>
-#include <glib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <vconf.h>
-#include <Ecore_File.h>
-#include <bundle.h>
-#include <eventsystem.h>
-#include <sys/types.h>
-#include <sys/xattr.h>
-#include <linux/xattr.h>
-#include <storage.h>
-#include <systemd/sd-login.h>
-
-#include "vconf-keys.h"
-#include "applog.h"
-#include "bt-share-common.h"
-#include "bt-share-ipc.h"
-
-#if 0
-static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value)
-{
-       int ret;
-       bundle *b = NULL;
-
-       b = bundle_create();
-
-       bundle_add_str(b, key, value);
-
-       ret = eventsystem_send_system_event(event, b);
-
-       DBG("eventsystem_send_system_event result: %d", ret);
-
-       bundle_free(b);
-
-       return ret;
-}
-#endif
-
-int _bt_share_block_sleep(gboolean is_block)
-{
-       static int block_sleep_count = 0;
-       int result = BT_SHARE_FAIL;
-
-       DBG("is_block [%d], block_sleep_count[%d]\n", is_block,
-                    block_sleep_count);
-
-       if (is_block) {
-               if (block_sleep_count < 0) {
-                       /* This condition is for preventing the exception case, Never be called in the current logic */
-                       /* LCOV_EXCL_START */
-                       INFO("block_sleep_count[%d] is invalid. It is set to 0.\n",
-                                    block_sleep_count);
-                       block_sleep_count = 0;
-                       /* LCOV_EXCL_STOP */
-               } else if (block_sleep_count == 0) {
-                       result = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
-                       if (result != 0)
-                               INFO("LCD Lock is failed with result code [%d]\n", result);
-               } else {
-                       result = BT_SHARE_ERROR_NONE;
-               }
-
-               if (result == BT_SHARE_ERROR_NONE)
-                       block_sleep_count++;
-       } else {
-               if (block_sleep_count <= 0) {
-                       INFO("block_sleep_count[%d] is invalid. It is set to 0.\n",
-                                    block_sleep_count);
-                       block_sleep_count = 0;
-               } else if (block_sleep_count == 1) {
-                       result = display_unlock_state(LCD_OFF, PM_RESET_TIMER);
-                       if (result != 0) {
-                               INFO("LCD Unlock is failed with result code [%d]\n",
-                                            result);
-                       }
-               } else {
-                       result = BT_SHARE_ERROR_NONE;
-               }
-
-               if (result == BT_SHARE_ERROR_NONE)
-                       block_sleep_count--;
-       }
-
-       DBG("result [%d]\n", result);
-       return result;
-}
-
-
-
-int _bt_set_transfer_indicator(gboolean state)
-{
-       static int block_cnt = 0;
-       int bt_device_state = 0;
-       int ret = VCONF_OK;
-       const char *event_val = NULL;
-
-       ret = vconf_get_int(VCONFKEY_BT_STATUS, (void *)&bt_device_state);
-       retvm_if(ret != VCONF_OK, VCONF_ERROR, "Get vconf failed\n");
-
-       if (state == TRUE) {
-               block_cnt++;
-               retv_if(bt_device_state & BT_STATUS_OFF, 0);
-               retv_if(bt_device_state & BT_STATUS_TRANSFER, 0);
-               bt_device_state |= BT_STATUS_TRANSFER;
-               event_val = EVT_VAL_BT_TRANSFERING;
-       } else {
-               if (block_cnt > 0)
-                       block_cnt--;
-               if (block_cnt != 0)
-                       return BT_SHARE_ERROR_NONE;
-               bt_device_state ^= BT_STATUS_TRANSFER;
-               event_val = EVT_VAL_BT_NON_TRANSFERING;
-       }
-
-       DBG("event_value: %s", event_val);
-
-       if (_bt_set_eventsystem_transfer_value(state) != BT_SHARE_ERROR_NONE)
-               ERR("Fail to set value"); /* LCOV_EXCL_LINE */
-
-#if 0
-       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_TRANSFERING_STATE,
-                                               event_val) != ES_R_OK)
-               ERR("Fail to set value");
-#endif
-
-       ret = vconf_set_int(VCONFKEY_BT_STATUS, bt_device_state);
-       retvm_if(ret != VCONF_OK, VCONF_ERROR, "Set vconf failed\n");
-       return BT_SHARE_ERROR_NONE;
-}
-
-static char *__bt_share_get_transfer_file_name(int file_type)
-{
-       int count = 0;
-       char *appendix = NULL;
-       char *file = NULL;
-       char *file_format = NULL;
-       char *file_name = NULL;
-
-       if (file_type == BT_HTTP_FILE) {
-               file_name = HTML_FILE_NAME;
-               file_format = HTML_FILE_FORMAT;
-       } else {
-               file_name = TXT_FILE_NAME;
-               file_format = TXT_FILE_FORMAT;
-       }
-
-       file = g_strdup(file_name);
-
-       /* While the file exists, increase the file name */
-       while (access(file, F_OK) == 0) {
-               g_free(file);
-
-               appendix = g_strdup_printf("_%d", count);
-               file = g_strdup_printf(file_format, appendix);
-               g_free(appendix);
-
-               count++;
-       }
-
-       return file;
-}
-
-void _bt_remove_tmp_file(char *file_path)
-{
-       if (g_str_has_prefix(file_path, BT_TMP_DIR) == TRUE) {
-               DBG_SECURE("Remove the file: %s", file_path);
-               ecore_file_remove(file_path);
-       }
-}
-
-void _bt_remove_vcf_file(char *file_path)
-{
-       if (g_str_has_prefix(file_path, BT_CONTACT_SHARE_TMP_DIR) == TRUE) {
-               DBG_SECURE("Remove the file: %s", file_path);
-               ecore_file_remove(file_path);
-       }
-}
-
-char *_bt_share_create_transfer_file(char *text)
-{
-       retv_if(text == NULL, NULL);
-
-       int fd = -1;
-       int file_type = -1;
-       char *file = NULL;
-       char *content = NULL;
-       char *url_sheme = NULL;
-       ssize_t write_size = -1;
-
-       url_sheme = g_uri_parse_scheme(text);
-
-       if (url_sheme) {
-               /* HTTP file generate */
-               g_free(url_sheme);
-               file_type = BT_HTTP_FILE;
-       } else {
-               /* TXT file generate */
-               file_type = BT_TXT_FILE;
-       }
-
-       file = __bt_share_get_transfer_file_name(file_type);
-       retv_if(file == NULL, NULL);
-
-       fd = open(file, O_RDWR | O_CREAT, 0755);
-
-       if (fd < 0) {
-               /* LCOV_EXCL_START */
-               ERR("Fail to open the file : %s", file);
-               goto fail;
-               /* LCOV_EXCL_STOP */
-       }
-
-       if (file_type == BT_HTTP_FILE)
-               content = g_strdup_printf(HTML_FORMAT, text, text);
-       else
-               content = g_strdup(text);
-
-       DBG_SECURE("content: \n%s", content);
-
-       write_size = write(fd, content, strlen(content));
-       g_free(content);
-       close(fd);
-
-       if (write_size < 0) {
-               /* LCOV_EXCL_START */
-               ERR("Fail to write in file");
-               goto fail;
-               /* LCOV_EXCL_STOP */
-       }
-
-       return file;
-fail:
-       g_free(file);
-       return NULL;
-}
-
-char *_bt_get_time_of_the_day(void)
-{
-       char *p = NULL;
-       char buffer[20] = {0, };
-       time_t cur_time = 0;
-       struct tm new_time;
-       struct timeval tv = {0, };
-
-       p = (char *)g_malloc(30);
-       gettimeofday(&tv, NULL);
-       cur_time = tv.tv_sec;
-       localtime_r(&cur_time, &new_time);
-       strftime(buffer, 20, "%m%d%Y%T", &new_time);
-       snprintf(p, 30, "%s%ld", buffer, tv.tv_usec);
-       return p;
-}
-
-/* LCOV_EXCL_START */
-static bool __bt_get_storage_id(int sid, storage_type_e type, storage_state_e state,
-               const char *path, void *user_data)
-{
-       int *storage_id = (int *)user_data;
-
-       if (type == STORAGE_TYPE_EXTERNAL && state == STORAGE_STATE_MOUNTED) {
-               *storage_id = sid;
-               return false;
-       }
-       return true;
-}
-/* LCOV_EXCL_STOP */
-
-void _bt_get_default_storage(char *storage)
-{
-       int val = BT_DEFAULT_MEM_PHONE;
-       char *path = NULL;
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
-                                               (void *)&val)) {
-               ERR("vconf error");
-               val = BT_DEFAULT_MEM_PHONE;
-       }
-
-       path = _bt_share_get_storage_path(val);
-
-       if (path == NULL)
-               path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-
-       g_strlcpy(storage, path, STORAGE_PATH_LEN_MAX);
-       g_free(path);
-
-       DBG("Default storage : %s\n", storage);
-
-       if (access(storage, W_OK) != 0)
-               DBG("Can't access the storage");
-}
-
-char *_bt_share_get_storage_path(int storage_type)
-{
-       int ret = 0;
-       int storage_id = 0;
-       char *path = NULL;
-
-       DBG("storage type: %d", storage_type);
-
-       if (storage_type == BT_DEFAULT_MEM_MMC) {
-               if (storage_foreach_device_supported(__bt_get_storage_id,
-                                               &storage_id) == STORAGE_ERROR_NONE) {
-                       DBG("storage_id = %d", storage_id);
-
-                       ret = storage_get_root_directory(storage_id, &path);
-
-                       if (ret != STORAGE_ERROR_NONE)
-                               DBG("Fail to get the download path: %d", ret);
-               }
-
-               if (path == NULL) {
-                       DBG("Fail to get the download path. So use media folder");
-                       path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-               }
-       } else {
-               path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-       }
-
-       return path;
-}
-
-int _bt_share_get_active_uid(uid_t *uid)
-{
-       DBG("+");
-
-       int ret = 0;
-       uid_t *active_user_list = NULL;
-       char *slice = NULL;
-       *uid = getuid();
-
-       ret = sd_pid_get_slice(getpid(), &slice);
-       if (0 <= ret && slice) {
-               if (!g_strcmp0(slice, "system.slice")) {
-                       ret = sd_get_uids(&active_user_list);
-                       /* the number of active users is 1 in tizen3.0 */
-                       if (1 == ret && active_user_list) {
-                               *uid = active_user_list[0];
-                               DBG("uid = %d", *uid);
-                       } else {
-                               ERR("sd_get_uids() Fail(%d)", ret);
-                               free(active_user_list);
-                               free(slice);
-                               return BT_SHARE_ERROR_NONE;
-                       }
-                       free(active_user_list);
-               }
-               free(slice);
-       } else {
-               ERR("sd_pid_get_slice() Fail(%d)", ret);
-       }
-
-       DBG("getuid() = %d, uid =  %d", getuid(), *uid);
-
-       return BT_SHARE_ERROR_NONE;
-}
-
-void _bt_convert_addr_type_to_string(char *address,
-                               char *addr)
-{
-       ret_if(address == NULL || addr == NULL);
-
-       g_snprintf(address, BT_ADDRESS_STRING_SIZE,
-                       "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
-                       addr[0], addr[1], addr[2],
-                       addr[3], addr[4], addr[5]);
-}
-
-int _bt_get_available_int_memory(double *dAvail)
-{
-       struct statvfs s = { 0, };
-       int r = 0;
-
-       r = storage_get_internal_memory_size(&s);
-       if (r < 0)
-               ERR("ret : %d", r);
-       else {
-               INFO("total : %lf, avail : %lf",
-               (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail);
-               *dAvail = (double)s.f_bsize*s.f_bavail;
-       }
-
-       return r;
-}
-
-gboolean _bt_get_available_ext_memory(unsigned long long *available_mem_size)
-{
-       struct statvfs s = {0, };
-       int r;
-
-       r = storage_get_internal_memory_size(&s);
-       if (r < 0) {
-               ERR("ret : %d", r);
-               *available_mem_size = 0;
-               return FALSE;
-       } else {
-               INFO("total : %lf, avail : %lf",
-               (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail);
-               *available_mem_size = (unsigned long long)s.f_bsize*s.f_bavail;
-       }
-
-       return TRUE;
-}
-
diff --git a/bt-share/src/bt-share-cynara.c b/bt-share/src/bt-share-cynara.c
deleted file mode 100644 (file)
index 8f52232..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 "bt-share-cynara.h"
-
-#include "applog.h"
-#include "bt-share-common.h"
-
-#include <cynara-client.h>
-#include <cynara-session.h>
-#include <cynara-creds-dbus.h>
-#include <cynara-error.h>
-#include <malloc.h>
-
-static cynara *_cynara = NULL;
-const unsigned int error_msg_size = 256;
-
-/* LCOV_EXCL_START */
-// initialize cynara
-int _bt_share_cynara_init(void)
-{
-       char error_msg[error_msg_size];
-       int ret;
-
-       ret = cynara_initialize(&_cynara, NULL);
-       if (ret != CYNARA_API_SUCCESS) {
-               cynara_strerror(ret, error_msg, error_msg_size);
-               ERR("cynara_initialize failed: %s\n", error_msg);
-               return BT_SHARE_FAIL;
-       }
-
-       return BT_SHARE_ERROR_NONE;
-}
-
-// fill creds structure with data needed to perform checks using cynara-creds lib
-int _bt_share_cynara_get_creds(DBusConnection *conn, const char *sender,
-                                  bt_share_cynara_creds *creds)
-{
-       char error_msg[error_msg_size];
-       int ret;
-
-       ret = cynara_creds_dbus_get_pid(conn, sender, &(creds->pid));
-       if (ret < 0) {
-               cynara_strerror(ret, error_msg, error_msg_size);
-               ERR("cynara_creds_dbus_get_pid fail\n");
-               return BT_SHARE_FAIL;
-       }
-
-       ret = cynara_creds_dbus_get_user(conn, sender, USER_METHOD_UID, &(creds->uid));
-       if (ret < 0) {
-               cynara_strerror(ret, error_msg, error_msg_size);
-               ERR("cynara_creds_dbus_get_user failed\n");
-               return BT_SHARE_FAIL;
-       }
-
-       ret = cynara_creds_dbus_get_client(conn, sender, CLIENT_METHOD_SMACK, &(creds->smack));
-       if (ret < 0) {
-               cynara_strerror(ret, error_msg, error_msg_size);
-               ERR("cynara_creds_dbus_get_client failed\n");
-               return BT_SHARE_FAIL;
-       }
-
-       return BT_SHARE_ERROR_NONE;
-}
-
-// check if client has required privilege
-int _bt_share_cynara_check(const bt_share_cynara_creds *creds, const char *privilege)
-{
-       int ret;
-       char *client_session;
-       char error_msg[error_msg_size];
-
-       if (!creds || !privilege)
-               return BT_SHARE_FAIL;
-
-       client_session = cynara_session_from_pid(creds->pid);
-       if (!client_session) {
-               ERR("cynara_session_from_pid failed\n");
-               return BT_SHARE_FAIL;
-       }
-
-       ret = cynara_check(_cynara, creds->smack, client_session, creds->uid, privilege);
-       if (ret != CYNARA_API_ACCESS_ALLOWED) {
-               cynara_strerror(ret, error_msg, error_msg_size);
-               ERR("cynara_check error: %s\n", error_msg);
-       }
-
-       free(client_session);
-       return ret == CYNARA_API_ACCESS_ALLOWED ? BT_SHARE_ERROR_NONE : BT_SHARE_FAIL;
-}
-
-// finish working with cynara
-void _bt_share_cynara_finish(void)
-{
-       cynara_finish(_cynara);
-       _cynara = NULL;
-}
-/* LCOV_EXCL_STOP */
diff --git a/bt-share/src/bt-share-ipc.c b/bt-share/src/bt-share-ipc.c
deleted file mode 100644 (file)
index c47bda0..0000000
+++ /dev/null
@@ -1,1011 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <glib.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <string.h>
-#include <notification.h>
-#include <aul.h>
-#include <vconf.h>
-#include <bundle_internal.h>
-
-#include "applog.h"
-#include "bt-share-main.h"
-#include "bt-share-ipc.h"
-#include "bt-share-syspopup.h"
-#include "bt-share-notification.h"
-#include "bt-share-resource.h"
-#include "obex-event-handler.h"
-#include "bluetooth-share-api.h"
-#include "bt-share-common.h"
-#include "bt-share-cynara.h"
-
-#define FILEPATH_LEN_MAX 4096
-
-#define SIGNAL_COUNT_TO_SUBSCRIBE 7
-
-GSList *bt_transfer_list = NULL;
-static GDBusConnection *gdbus_connection = NULL;
-static GDBusProxy *core_proxy = NULL;
-
-extern bt_appdata_t *app_state;
-
-static void __bt_create_send_data(opc_transfer_info_t *node);
-static void __bt_create_send_failed_data(char *filepath, char *dev_name,
-                                               char *addr, char *type, unsigned int size);
-static void __bt_share_update_tr_info(int tr_uid, int tr_type);
-static void __free_transfer_info(opc_transfer_info_t *node);
-static int __request_file_send(opc_transfer_info_t *node);
-static GDBusConnection *__bt_get_system_gconn(void);
-
-static void __bt_tr_data_free(bt_tr_data_t *data)
-{
-       retm_if(data == NULL, "Invalid param");
-
-       g_free(data->file_path);
-       g_free(data->dev_name);
-       g_free(data->addr);
-       g_free(data->type);
-       g_free(data->content);
-       g_free(data->db_sid);
-       g_free(data);
-}
-
-/* LCOV_EXCL_START */
-static void __popup_res_cb(int res)
-{
-       FN_START;
-       bt_appdata_t *ad = app_state;
-
-       retm_if(ad->popups.syspopup_request == FALSE, "This event is not mine\n");
-
-       DBG(" res : %d", res);
-       /* Inorder to support calling popup from callback, we have to make
-        * syspopup_request false here and also should not assign
-        * ad->popups.popup_cb = NULL */
-
-       ad->popups.syspopup_request = FALSE;
-
-       if (NULL != ad->popups.popup_cb) {
-               if (res == 0)
-                       ad->popups.popup_cb(ad->popups.popup_cb_data,
-                                           NULL, (void *)POPUP_RESPONSE_OK);
-               else if (res == 1)
-                       ad->popups.popup_cb(ad->popups.popup_cb_data,
-                                           NULL, (void *)POPUP_RESPONSE_CANCEL);
-               else if (res == 2)
-                       ad->popups.popup_cb(ad->popups.popup_cb_data,
-                                           NULL, (void *)POPUP_RESPONSE_TIMEOUT);
-       }
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static char *__bt_transfer_folder_path(char *dest_path)
-{
-       char *dst_path = (char *)g_malloc0(STORAGE_PATH_LEN_MAX);
-       if (dst_path == NULL) {
-               ERR("Not enough memory!");
-               return NULL;
-       }
-
-       if (g_str_has_prefix(dest_path, BT_OBEX_PATH_PREFIX))
-               snprintf(dst_path, STORAGE_PATH_LEN_MAX, BT_OBEX_DEFAULT_PATH"%s", dest_path + strlen(BT_OBEX_PATH_PREFIX));
-       else
-               snprintf(dst_path, STORAGE_PATH_LEN_MAX, "%s", dest_path);
-
-       DBG("obex transfed path : %s", dst_path);
-       return dst_path;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static opc_transfer_info_t *__add_transfer_info(GVariant *msg)
-{
-       FN_START;
-       retv_if(msg == NULL, NULL);
-
-       int i = 0;
-       int cnt = 0;
-       unsigned int file_size = 0;
-       char *name = NULL;
-       char *type = NULL;
-       char byte = 0;
-       char *file_path = NULL;
-       opc_transfer_info_t *data = NULL;
-       bt_appdata_t *ad = app_state;
-       GSList *list = NULL;
-       char addr[BLUETOOTH_ADDRESS_LENGTH] = {0, };
-       char mime_type[BT_MIME_TYPE_MAX_LEN] = {0, };
-       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
-       char file[FILEPATH_LEN_MAX] = {0, };
-       struct stat file_attr = {0, };
-
-       GVariantIter *iter_addr;
-       GVariantIter *iter_filepath;
-       GVariantIter *iter_file;
-
-       g_variant_get(msg, "(ayssaay)", &iter_addr, &name, &type, &iter_filepath);
-
-       while (g_variant_iter_loop(iter_addr, "y", &byte))
-               addr[i++] = byte;
-       g_variant_iter_free(iter_addr);
-
-       while (g_variant_iter_loop(iter_filepath, "ay", &iter_file)) {
-               char *dst_path = NULL;
-               i = 0;
-               memset(file, 0, FILEPATH_LEN_MAX);
-
-               while (g_variant_iter_loop(iter_file, "y", &byte))
-                       file[i++] = byte;
-
-               file_path = g_strdup(file);
-
-               dst_path = __bt_transfer_folder_path(file_path);
-               if (dst_path != NULL) {
-                       g_free(file_path);
-                       file_path = dst_path;
-               }
-
-               if (aul_get_mime_from_file(file_path, mime_type,
-                               BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
-                       INFO("mime type = %s", mime_type);
-
-               if (g_utf8_validate(file_path, -1, NULL)) {
-                       if (stat(file_path, &file_attr) == 0)
-                               file_size = file_attr.st_size;
-                       else
-                               file_size = 0;
-
-                       INFO("%d", file_size);
-                       list = g_slist_append(list, file_path);
-               } else {
-                       DBG("Invalid filepath");
-                       ad->send_data.tr_fail++;
-                       __bt_create_send_failed_data(file_path, name, addr,
-                                                               mime_type, file_size);
-
-                       _bt_convert_addr_type_to_string(bd_addr, addr);
-                       DBG_SECURE("bd_addr = [%s]", bd_addr);
-                       if (ad->send_noti == NULL) {
-                               ad->send_noti = _bt_insert_notification(ad,
-                                                       BT_SENT_NOTI, name,
-                                                       bd_addr, NULL);
-                       } else {
-                               _bt_update_notification(ad, ad->send_noti,
-                                               NULL, NULL, NULL, NULL, NULL);
-                       }
-
-                       g_free(file_path);
-                       file_path = NULL;
-               }
-       }
-
-       g_variant_iter_free(iter_filepath);
-
-       cnt = g_slist_length(list);
-       INFO("cnt = %d", cnt);
-
-       if (cnt == 0) {
-               /* Show unable to send popup */
-               _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL,
-                       BT_STR_UNABLE_TO_SEND);
-
-               g_slist_free_full(list, g_free);
-               g_free(name);
-               g_free(type);
-               return NULL;
-       }
-
-       INFO("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr[0],
-           addr[1], addr[2], addr[3], addr[4], addr[5]);
-       INFO(" cnt( %d )", cnt);
-       DBG_SECURE(" name ( %s )", name);
-
-       data = g_new0(opc_transfer_info_t, 1);
-       data->content = g_new0(char *, cnt + 1);
-       data->file_path = g_new0(char *, cnt + 1);
-       data->file_cnt = cnt;
-       data->type = g_new0(char *, cnt + 1);
-       data->size = (unsigned int *)g_new0(unsigned int *, cnt + 1);
-       memcpy(data->addr, addr, BLUETOOTH_ADDRESS_LENGTH);
-       memcpy(data->name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
-
-       for (i = 0; i < cnt; i++) {
-               char *ptr = g_slist_nth_data(list, i);
-               DBG_SECURE("%s", ptr);
-               if (g_strcmp0(type, "text") == 0)
-                       data->file_path[i] = _bt_share_create_transfer_file(ptr);
-               else
-                       data->file_path[i] = g_strdup(ptr);
-
-               if (aul_get_mime_from_file(data->file_path[i], mime_type,
-                       BT_MIME_TYPE_MAX_LEN) == AUL_R_OK) {
-                       g_free(data->type[i]);
-                       data->type[i] = g_strdup(mime_type);
-               }
-
-               if (stat(data->file_path[i], &file_attr) == 0)
-                       file_size = file_attr.st_size;
-               else
-                       file_size = 0;
-
-               data->size[i] = file_size;
-               data->content[i] = g_strdup(ptr);
-               INFO(" type ( %s ), size (%d)", data->type[i], data->size[i]);
-       }
-
-       bt_transfer_list = g_slist_append(bt_transfer_list, data);
-
-       g_slist_free_full(list, g_free);
-       g_free(name);
-       g_free(type);
-
-       return data;
-}
-/* LCOV_EXCL_STOP */
-
-static void __free_transfer_info(opc_transfer_info_t *node)
-{
-       FN_START;
-       ret_if(node == NULL);
-
-       int i = 0;
-
-       for (i = 0; i < node->file_cnt; i++) {
-               g_free(node->file_path[i]);
-               g_free(node->content[i]);
-               g_free(node->type[i]);
-       }
-
-       g_free(node->file_path);
-       g_free(node->content);
-       g_free(node->type);
-       g_free(node->size);
-       g_free(node);
-
-       FN_END;
-}
-
-void _remove_transfer_info(opc_transfer_info_t *node)
-{
-       FN_START;
-       ret_if(node == NULL);
-
-       bt_transfer_list = g_slist_remove(bt_transfer_list, node);
-       __free_transfer_info(node);
-
-       FN_END;
-}
-
-/* LCOV_EXCL_START */
-static int __request_file_send(opc_transfer_info_t *node)
-{
-       FN_START;
-       int ret = 0;
-
-       retv_if(app_state == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-       retv_if(node == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       ret = bluetooth_opc_push_files((bluetooth_device_address_t *)node->addr,
-                                    node->file_path);
-       retvm_if(ret != BLUETOOTH_ERROR_NONE, ret,
-                       "bluetooth_opc_push_files failed : %d", ret);
-
-       __bt_create_send_data(node);
-
-       FN_END;
-       return BLUETOOTH_ERROR_NONE;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __event_filter(GDBusConnection *connection,
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       int ret = 0;
-       bt_appdata_t *ad = app_state;
-#ifdef CYNARA_ENABLE
-       const char *sender;
-       bt_share_cynara_creds sender_creds;
-#endif
-
-/*
-       DBG("Path = %s", object_path);
-*/
-       ret_if(object_path == NULL || strcmp(object_path, "/") == 0);
-       ret_if(interface_name == NULL || signal_name == NULL);
-
-       if (!g_strcmp0(interface_name, BT_SYSPOPUP_INTERFACE)) {
-               DBG("syspopup signal_name = %s", signal_name);
-               if (!g_strcmp0(signal_name, BT_SYSPOPUP_METHOD_RESPONSE)) {
-                       int res = 0;
-                       g_variant_get(parameters, "(i)", &res);
-                       __popup_res_cb(res);
-               }
-       } else if (!g_strcmp0(interface_name, BT_UG_IPC_INTERFACE)) {
-               DBG("ug signal_name = %s", signal_name);
-               if (!g_strcmp0(signal_name, BT_UG_IPC_METHOD_SEND)) {
-                       opc_transfer_info_t *node = NULL;
-
-#ifdef CYNARA_ENABLE
-               sender = dbus_message_get_sender(msg);
-               ret = _bt_share_cynara_get_creds(sys_conn, sender, &sender_creds);
-               if (ret != 0) {
-                       ERR("acquiring cynara creds failed\n");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-               if (_bt_share_cynara_check(&sender_creds, BT_SHARE_PRIVILEGE) != BT_SHARE_FAIL) {
-                       ERR("Cynara denied file send\n");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-#endif
-                       node = __add_transfer_info(parameters);
-                       retm_if(node == NULL, "node is NULL");
-
-                       ret = __request_file_send(node);
-                       if (ret == BLUETOOTH_ERROR_IN_PROGRESS) {
-                               INFO("Aleady OPC progressing. Once completed previous job, will be started");
-                       } else if (ret != BLUETOOTH_ERROR_NONE) {
-                               _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
-                               g_slist_free_full(bt_transfer_list, (GDestroyNotify)__free_transfer_info);
-                               bt_transfer_list = NULL;
-                       }
-               }
-       } else if (!g_strcmp0(interface_name, BT_SHARE_UI_INTERFACE)) {
-               DBG("share ui signal_name = %s", signal_name);
-
-               if (!g_strcmp0(signal_name, BT_SHARE_UI_SIGNAL_OPPABORT)) {
-                       const gchar *transfer_type = NULL;
-                       int noti_id = 0;
-
-                       g_variant_get(parameters, "(&si)", &transfer_type, &noti_id);
-
-                       ad->opp_transfer_abort = TRUE; /* Transfer aborted by user*/
-                       INFO("transfer_type = %s", transfer_type);
-                       if (!g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT)) {
-                               bluetooth_opc_cancel_push();
-                               if (ad->opc_noti) {
-                                       ret = _bt_delete_notification(ad->opc_noti);
-                                       if (ret == NOTIFICATION_ERROR_NONE) {
-                                               ad->opc_noti = NULL;
-                                               ad->opc_noti_id = 0;
-                                       }
-                               }
-                       } else {
-                               bluetooth_obex_server_cancel_transfer(noti_id);
-                       }
-               } else if (!g_strcmp0(signal_name, BT_SHARE_UI_SIGNAL_SEND_FILE)) {
-                       opc_transfer_info_t *node = NULL;
-
-#ifdef CYNARA_ENABLE
-                       sender = dbus_message_get_sender(msg);
-                       ret = _bt_share_cynara_get_creds(sys_conn, sender, &sender_creds);
-                       if (ret != 0) {
-                               ERR("acquiring cynara creds failed\n");
-                               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-                       }
-
-                       if (_bt_share_cynara_check(&sender_creds, BT_SHARE_PRIVILEGE) != BT_SHARE_FAIL) {
-                               ERR("Cynara denied file send\n");
-                               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-                       }
-#endif
-                       node = __add_transfer_info(parameters);
-                       retm_if(node == NULL, "node is NULL");
-
-                       ret = __request_file_send(node);
-                       if (ret == BLUETOOTH_ERROR_IN_PROGRESS) {
-                               INFO("Aleady OPC progressing. Once completed previous job, will be started");
-                       } else if (ret != BLUETOOTH_ERROR_NONE) {
-                               _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
-                               g_slist_free_full(bt_transfer_list, (GDestroyNotify)__free_transfer_info);
-                               bt_transfer_list = NULL;
-                       }
-               } else if (!g_strcmp0(signal_name, BT_SHARE_UI_SIGNAL_INFO_UPDATE)) {
-                       int tr_uid = 0;
-                       int tr_type = 0;
-
-                       g_variant_get(parameters, "(ii)", &tr_uid, &tr_type);
-
-                       __bt_share_update_tr_info(tr_uid, tr_type);
-               }
-       } else if (!g_strcmp0(interface_name, BT_SHARE_FRWK_INTERFACE)) {
-               DBG("frwk signal_name = %s", signal_name);
-
-               if (!g_strcmp0(signal_name, BT_SHARE_FRWK_SIGNAL_DEINIT)) {
-                       /* Deinitialize the obex server */
-                       if (bluetooth_obex_server_deinit() == BLUETOOTH_ERROR_NONE)
-                               DBG("Obex Server deinit");
-               }
-       } else if (!g_strcmp0(interface_name, BT_BLUEZ_INTERFACE)) {
-               if (!g_strcmp0(signal_name, BT_BLUEZ_SIGNAL_NAME_OWNER_CHANGED)) {
-                       char *name = NULL;
-                       char *previous = NULL;
-                       char *current = NULL;
-
-                       g_variant_get(parameters, "(&s&s&s)", &name, &previous, &current);
-
-                       if (*current != '\0')
-                               return;
-
-                       if (strcasecmp(name, "org.projectx.bt") == 0) {
-                               INFO("bt-service is terminated");
-                               _bt_terminate_bluetooth_share();
-                       }
-               }
-       } else {
-               DBG("Unhandled signal");
-       }
-}
-/* LCOV_EXCL_STOP */
-
-static int __bt_share_add_filter_subscribe_signal(GDBusConnection *conn,
-               gboolean subscribe)
-{
-       struct {
-               char *interface;
-               char *member;
-       } match_string[SIGNAL_COUNT_TO_SUBSCRIBE] = {
-                       { BT_SYSPOPUP_INTERFACE, BT_SYSPOPUP_METHOD_RESPONSE },
-                       { BT_UG_IPC_INTERFACE, BT_UG_IPC_METHOD_SEND},
-                       { BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_OPPABORT},
-                       { BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_SEND_FILE},
-                       { BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_INFO_UPDATE},
-                       { BT_SHARE_FRWK_INTERFACE, BT_SHARE_FRWK_SIGNAL_DEINIT},
-                       { BT_BLUEZ_INTERFACE, BT_BLUEZ_SIGNAL_NAME_OWNER_CHANGED}
-       };
-
-       static guint subs_add_filter_id[SIGNAL_COUNT_TO_SUBSCRIBE] = {0, };
-       int i;
-
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       if (subscribe == FALSE) {
-               for (i = 0; i < SIGNAL_COUNT_TO_SUBSCRIBE; ++i) {
-                       if (subs_add_filter_id[i] != 0) {
-                               g_dbus_connection_signal_unsubscribe(conn, subs_add_filter_id[i]);
-                               subs_add_filter_id[i] = 0;
-                       }
-               }
-               return BLUETOOTH_ERROR_NONE;
-       }
-
-       for (i = 0; i < SIGNAL_COUNT_TO_SUBSCRIBE; ++i) {
-               if (subs_add_filter_id[i] == 0) {
-                       subs_add_filter_id[i] = g_dbus_connection_signal_subscribe(
-                                       conn, NULL, match_string[i].interface,
-                                       match_string[i].member, NULL, NULL,
-                                       G_DBUS_SIGNAL_FLAGS_NONE, __event_filter, NULL, NULL);
-               }
-       }
-       return BLUETOOTH_ERROR_NONE;
-}
-
-gboolean _bt_init_dbus_signal(void)
-{
-       FN_START;
-       GError *error = NULL;
-       GDBusConnection *conn = NULL;
-
-       conn = __bt_get_system_gconn();
-       if (!conn) {
-               /* LCOV_EXCL_START */
-               ERR("GDBUS get failed");
-               g_error_free(error);
-               return FALSE;
-               /* LCOV_EXCL_STOP */
-       }
-
-       gdbus_connection = conn;
-
-       /* Add the filter for network client functions */
-       __bt_share_add_filter_subscribe_signal(conn, TRUE);
-
-       FN_END;
-       return TRUE;
-}
-
-void _bt_deinit_dbus_signal(void)
-{
-       FN_START;
-       __bt_share_add_filter_subscribe_signal(gdbus_connection, FALSE);
-       FN_END;
-}
-
-void _bt_send_disconnected_signal(char *signal, int result,
-               char *address, int transfer_id)
-{
-       FN_START;
-       retm_if(gdbus_connection == NULL, "gdbus_connection == NULL");
-
-       GDBusMessage *msg = NULL;
-       GVariant *param = NULL;
-
-       msg = g_dbus_message_new_signal(BT_SHARE_ENG_OBJECT,
-                               BT_SHARE_ENG_INTERFACE,
-                               signal);
-       retm_if(msg == NULL, "Unable to allocate memory");
-
-       param = g_variant_new("(isi)", result, address, transfer_id);
-       g_dbus_message_set_body(msg, param);
-
-       g_dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
-       g_dbus_connection_send_message(gdbus_connection, msg,
-                       G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
-
-       g_object_unref(msg);
-       FN_END;
-}
-
-void _bt_update_transfer_list_view(char *db)
-{
-       ret_if(gdbus_connection == NULL);
-
-       GDBusMessage *msg = NULL;
-       GVariant *param = NULL;
-
-       msg = g_dbus_message_new_signal(BT_SHARE_ENG_OBJECT,
-                               BT_SHARE_ENG_INTERFACE,
-                               BT_SHARE_ENG_SIGNAL_UPDATE_VIEW);
-       retm_if(!msg, "Unable to allocate memory");
-
-       param = g_variant_new("(s)", db);
-       g_dbus_message_set_body(msg, param);
-
-       g_dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
-       g_dbus_connection_send_message(gdbus_connection, msg,
-                       G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
-
-       g_object_unref(msg);
-}
-
-void _bt_create_warning_popup(int error_type, char *msg)
-{
-       /* If bluetooth-share-ui process is  not running */
-       /* Then create the process and terminate it after popup shown */
-       if (aul_app_is_running(UI_PACKAGE) == 0) {
-               DBG("Creating new process for Warning Popup");
-               char str[BT_TEXT_LEN_MAX] = { 0, };
-               bundle *b = NULL;
-
-               DBG("error_type: %d", error_type);
-               switch (error_type) {
-               case BLUETOOTH_ERROR_SERVICE_NOT_FOUND:
-               case BLUETOOTH_ERROR_NOT_CONNECTED:
-               case BLUETOOTH_ERROR_ACCESS_DENIED:
-               case BLUETOOTH_ERROR_OUT_OF_MEMORY:
-               case BLUETOOTH_ERROR_INTERNAL:
-               case BLUETOOTH_ERROR_CANCEL:
-                       snprintf(str, BT_TEXT_LEN_MAX, "%s",
-                                msg);
-                       break;
-               default:
-                       return;
-               }
-
-               b = bundle_create();
-               ret_if(b == NULL);
-
-               bundle_add(b, "launch-type", "warning_popup");
-               bundle_add(b, "message", str);
-
-               aul_launch_app(UI_PACKAGE, b);
-
-               bundle_free(b);
-       }
-       return;
-}
-
-static time_t __bt_get_current_timedata(void)
-{
-       time_t t = 0;
-       time(&t);
-       return ((int)t);
-}
-
-/* LCOV_EXCL_START */
-static char *__bt_conv_addr_type_to_addr_string(char *addr)
-{
-       retv_if(addr == NULL, NULL);
-       char address[BT_ADDR_STR_LEN_MAX] = {0, };
-
-       snprintf(address, BT_ADDR_STR_LEN_MAX,
-                "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
-                addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
-
-       return g_strdup(address);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_create_send_failed_data(char *filepath, char *dev_name,
-                                        char *addr, char *type, unsigned int size)
-{
-       int session_id = -1;
-       sqlite3 *db = NULL;
-
-       db = bt_share_open_db();
-       ret_if(!db);
-
-       session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
-       INFO("Last session id = %d", session_id);
-
-       bt_tr_data_t *tmp = NULL;
-       tmp = g_malloc0(sizeof(bt_tr_data_t));
-       ret_if(tmp == NULL);
-
-       tmp->tr_status = BT_TR_FAIL;
-       tmp->sid = session_id + 1;
-       tmp->file_path = g_strdup(filepath);
-       tmp->content = g_strdup(filepath);
-       tmp->dev_name = g_strdup(dev_name);
-       tmp->type = g_strdup(type);
-       tmp->timestamp = __bt_get_current_timedata();
-       tmp->addr = __bt_conv_addr_type_to_addr_string(addr);
-       tmp->size = size;
-       bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
-       __bt_tr_data_free(tmp);
-
-       bt_share_close_db(db);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_create_send_data(opc_transfer_info_t *node)
-{
-       FN_START;
-       ret_if(node == NULL);
-
-       int count = 0;
-       int session_id = -1;
-       char *snd_db_sid = NULL;
-       sqlite3 *db = NULL;
-
-       DBG_SECURE("Name [%s]", node->name);
-
-       db = bt_share_open_db();
-       ret_if(!db);
-
-       session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
-       snd_db_sid = _bt_get_time_of_the_day();
-       INFO("Last session id = %d", session_id);
-
-       for (count = 0; count < node->file_cnt; count++) {
-               bt_tr_data_t *tmp;
-               tmp = g_malloc0(sizeof(bt_tr_data_t));
-               if (tmp == NULL) {
-                       g_free(snd_db_sid);
-                       return;
-               }
-
-               tmp->tr_status = BT_TR_PENDING;
-               tmp->sid = session_id + 1;
-               tmp->file_path = g_strdup(node->file_path[count]);
-               DBG("tmp->file_path : %s", tmp->file_path);
-
-               tmp->content = g_strdup(node->content[count]);
-               tmp->dev_name = g_strdup(node->name);
-               tmp->type = g_strdup(node->type[count]);
-               tmp->timestamp = __bt_get_current_timedata();
-               tmp->addr = __bt_conv_addr_type_to_addr_string(node->addr);
-               tmp->size = node->size[count];
-               tmp->db_sid = g_strdup(snd_db_sid);
-               bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
-               __bt_tr_data_free(tmp);
-       }
-
-       bt_share_close_db(db);
-       g_free(snd_db_sid);
-
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-gboolean _bt_update_sent_data_status(int uid,
-                               bt_app_tr_status_e status, char *db_sid)
-{
-       INFO("uid = %d", uid);
-       sqlite3 *db = NULL;
-       bt_tr_data_t *tmp = NULL;
-
-       db = bt_share_open_db();
-       retv_if(!db, FALSE);
-
-       tmp = g_malloc0(sizeof(bt_tr_data_t));
-       retv_if(!tmp, FALSE);
-
-       tmp->tr_status = status;
-       tmp->timestamp = __bt_get_current_timedata();
-       tmp->db_sid = g_strdup(db_sid);
-       bt_share_update_tr_data(db, BT_DB_OUTBOUND, uid, tmp);
-       bt_share_close_db(db);
-
-       __bt_tr_data_free(tmp);
-       return TRUE;
-}
-
-gboolean _bt_update_recv_data_status(int uid,
-               bt_app_tr_status_e status, char *db_sid,
-               unsigned int filesize, const char *mime_type)
-{
-       INFO("uid = %d", uid);
-       sqlite3 *db = NULL;
-       bt_tr_data_t *tmp = NULL;
-
-       db = bt_share_open_db();
-       retv_if(!db, FALSE);
-
-       tmp = g_malloc0(sizeof(bt_tr_data_t));
-       retv_if(!tmp, FALSE);
-
-       tmp->tr_status = status;
-       tmp->timestamp = __bt_get_current_timedata();
-       tmp->db_sid = g_strdup(db_sid);
-       tmp->type = g_strdup(mime_type);
-       tmp->size = filesize;
-       bt_share_update_tr_data(db, BT_DB_INBOUND, uid, tmp);
-       bt_share_close_db(db);
-
-       __bt_tr_data_free(tmp);
-       return TRUE;
-}
-
-gboolean _bt_update_multiple_sent_data_status(int *uids, int uid_cnt,
-                               bt_app_tr_status_e status, char *db_sid)
-{
-       sqlite3 *db = NULL;
-       bt_tr_data_t *tmp = NULL;
-
-       db = bt_share_open_db();
-       retv_if(!db, FALSE);
-
-       tmp = g_malloc0(sizeof(bt_tr_data_t));
-       tmp->tr_status = status;
-       tmp->timestamp = __bt_get_current_timedata();
-       tmp->db_sid = g_strdup(db_sid);
-       bt_share_update_multiple_tr_data(db, BT_DB_OUTBOUND, uids, uid_cnt, tmp);
-       bt_share_close_db(db);
-
-       __bt_tr_data_free(tmp);
-       return TRUE;
-}
-
-gboolean _bt_add_recv_transfer_status_data(char *device_name,
-                       char *address, char *filepath, char *type,
-                       unsigned int size, int status, char *db_sid)
-{
-       retv_if(device_name == NULL || filepath == NULL, FALSE);
-
-       sqlite3 *db = NULL;
-       bt_tr_data_t *tmp = NULL;
-
-       DBG_SECURE("Name [%s]", device_name);
-
-       db = bt_share_open_db();
-       retv_if(!db, FALSE);
-
-       tmp = g_malloc0(sizeof(bt_tr_data_t));
-
-       tmp->tr_status = status;
-       tmp->file_path = g_strdup(filepath);
-       tmp->dev_name = g_strdup(device_name);
-       tmp->addr = g_strdup(address);
-       tmp->db_sid = g_strdup(db_sid);
-       tmp->timestamp = __bt_get_current_timedata();
-       tmp->type = g_strdup(type);
-       tmp->size = size;
-       bt_share_add_tr_data(db, BT_DB_INBOUND, tmp);
-       bt_share_close_db(db);
-
-       __bt_tr_data_free(tmp);
-       return TRUE;
-}
-
-int _bt_share_get_unique_id(int db_table, const char *db_sid)
-{
-       sqlite3 *db = NULL;
-       int index_id = -1;
-
-       DBG("db_table = %d", db_table);
-       db = bt_share_open_db();
-       retv_if(!db, 0);
-
-       index_id = bt_share_get_unique_id(db, db_table, db_sid);
-       bt_share_close_db(db);
-       DBG("index_id = %d", index_id);
-       return index_id;
-}
-
-/* LCOV_EXCL_START */
-static void __bt_share_update_tr_info(int tr_uid, int tr_type)
-{
-       DBG("tr_uid = %d", tr_uid);
-
-       int status = -1;
-       bt_appdata_t *ad = app_state;
-       bt_tr_data_t *info = NULL;
-       sqlite3 *db = NULL;
-
-       db = bt_share_open_db();
-       ret_if(!db);
-
-       if (tr_type == BT_TR_OUTBOUND) {
-               if (tr_uid == -1) {
-                       /* Click the "clear list" button in bluetooth-share-ui */
-                       /* Delete all outbound db / notification info */
-                       _bt_delete_notification(ad->send_noti);
-                       ad->send_noti = NULL;
-
-                       ad->send_data.tr_success = 0;
-                       ad->send_data.tr_fail = 0;
-                       DBG("clear all");
-                       bt_share_remove_tr_data_non_pending(db, BT_DB_OUTBOUND);
-                       bt_share_close_db(db);
-               } else {
-                       /* Delete selected outbound db / notification info */
-
-                       info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tr_uid);
-                       if (info != NULL) {
-                               status = info->tr_status;
-                               __bt_tr_data_free(info);
-                       }
-
-                       bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND,
-                                                     tr_uid);
-                       bt_share_close_db(db);
-
-                       if (status == BT_TR_SUCCESS && ad->send_data.tr_success > 0)
-                               ad->send_data.tr_success--;
-                       else if (status == BT_TR_FAIL && ad->send_data.tr_fail > 0)
-                               ad->send_data.tr_fail--;
-                       else
-                               return;
-
-                       if ((ad->send_data.tr_success + ad->send_data.tr_fail) != 0) {
-                               _bt_update_notification(ad, ad->send_noti,
-                                               NULL, NULL, NULL, NULL, NULL);
-                       } else {
-                               _bt_delete_notification(ad->send_noti);
-                       }
-               }
-       } else if (tr_type == BT_TR_INBOUND) {
-               if (tr_uid == -1) {
-                       /* Click the "clear list" button in bluetooth-share-ui */
-                       /* Delete all inbound db / notification info */
-
-                       _bt_delete_notification(ad->receive_noti);
-                       ad->receive_noti = NULL;
-                       ad->recv_data.tr_success = 0;
-                       ad->recv_data.tr_fail = 0;
-                       bt_share_remove_all_tr_data(db, BT_DB_INBOUND);
-                       bt_share_close_db(db);
-               } else {
-                       /* Delete selected outbound db / notification info */
-
-                       info = bt_share_get_tr_data(db, BT_DB_INBOUND, tr_uid);
-                       if (info != NULL) {
-                               status = info->tr_status;
-                               __bt_tr_data_free(info);
-                       }
-
-                       bt_share_remove_tr_data_by_id(db, BT_DB_INBOUND, tr_uid);
-                       bt_share_close_db(db);
-
-                       if (status == BT_TR_SUCCESS && ad->recv_data.tr_success > 0)
-                               ad->recv_data.tr_success--;
-                       else if (status == BT_TR_FAIL && ad->recv_data.tr_fail > 0)
-                               ad->recv_data.tr_fail--;
-                       else
-                               return;
-
-                       if ((ad->recv_data.tr_success + ad->recv_data.tr_fail) != 0) {
-                               _bt_update_notification(ad, ad->receive_noti,
-                                               NULL, NULL, NULL, NULL, NULL);
-                       } else {
-                               _bt_delete_notification(ad->receive_noti);
-                       }
-               }
-       } else {
-               ERR("Invalid transfer type");
-               bt_share_close_db(db);
-       }
-}
-/* LCOV_EXCL_STOP */
-
-static GDBusConnection *__bt_init_system_gconn(void)
-{
-       if (gdbus_connection == NULL)
-               gdbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
-
-       return gdbus_connection;
-}
-
-static GDBusConnection *__bt_get_system_gconn(void)
-{
-       return (gdbus_connection) ? gdbus_connection : __bt_init_system_gconn();
-}
-
-GDBusProxy *__bt_init_core_proxy(void)
-{
-       GDBusProxy *proxy;
-       GDBusConnection *conn;
-
-       conn = __bt_get_system_gconn();
-       if (!conn)
-               return NULL;
-
-       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
-                                       NULL,
-                                       BT_CORE_NAME,
-                                       BT_CORE_PATH,
-                                       BT_CORE_INTERFACE,
-                                       NULL, NULL);
-
-       if (!proxy)
-               return NULL;
-
-       core_proxy = proxy;
-
-       return proxy;
-}
-
-static GDBusProxy *__bt_get_core_proxy(void)
-{
-       return (core_proxy) ? core_proxy : __bt_init_core_proxy();
-}
-
-int _bt_set_eventsystem_transfer_value(gboolean value)
-{
-       GDBusProxy *proxy;
-       GError *error = NULL;
-       GVariant *reply;
-       int ret = BT_SHARE_ERROR_NONE;
-
-       DBG("+");
-
-       proxy = __bt_get_core_proxy();
-       if (!proxy)
-               return BT_SHARE_FAIL;
-
-       reply = g_dbus_proxy_call_sync(proxy, "SetTransferValue",
-                       g_variant_new("(b)", value),
-                       G_DBUS_CALL_FLAGS_NONE, -1,
-                       NULL, &error);
-
-       if (reply == NULL) {
-               ERR("Failed to Set tranfer value by bt core");
-               ret = BT_SHARE_FAIL;
-               if (error) {
-                       ERR("Error %s", error->message);
-                       g_error_free(error);
-               }
-       }
-       g_variant_unref(reply);
-
-       return ret;
-}
diff --git a/bt-share/src/bt-share-main.c b/bt-share/src/bt-share-main.c
deleted file mode 100644 (file)
index 65bb335..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <glib.h>
-#include <glib-object.h>
-#include <string.h>
-#include <appcore-efl.h>
-#include <vconf.h>
-#include <Ecore_File.h>
-#include <notification_internal.h>
-
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#include "applog.h"
-#include "bt-share-main.h"
-#include "bluetooth-api.h"
-#include "obex-event-handler.h"
-#include "bt-share-ipc.h"
-#include "bt-share-noti-handler.h"
-#include "bt-share-resource.h"
-#include "bt-share-notification.h"
-#include "bt-share-common.h"
-#include "bt-share-cynara.h"
-
-#include "bluetooth-share-api.h"
-
-#define BLUETOOTH_SHARE_BUS            "org.projectx.bluetooth.share"
-
-static gboolean terminated;
-static GMainLoop *main_loop = NULL;
-bt_appdata_t *app_state = NULL;
-static guint owner_id;
-
-/* LCOV_EXCL_START */
-static void __lang_changed_cb(keynode_t *node, void *user_data)
-{
-       FN_START;
-       /* init internationalization */
-       retm_if(appcore_set_i18n(BT_COMMON_PKG, BT_COMMON_RES) < 0,
-                       "appcore_set_i18n failed!");
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-void _bt_terminate_bluetooth_share(void)
-{
-       FN_START;
-
-       if (main_loop)
-               g_main_loop_quit(main_loop); /* LCOV_EXCL_LINE */
-       else
-               terminated = TRUE;
-
-       FN_END;
-}
-
-/* LCOV_EXCL_START */
-static void __bt_release_service(bt_appdata_t *ad)
-{
-       ret_if(ad == NULL);
-
-       _bt_deinit_vconf_notification();
-       _bt_delete_notification(ad->opc_noti);
-       _bt_clear_receive_noti_list();
-       ad->send_noti = NULL;
-       ad->receive_noti = NULL;
-       ad->opc_noti = NULL;
-
-       bluetooth_opc_deinit();
-       bluetooth_obex_server_deinit();
-       _bt_unregister_notification_cb(ad);
-
-       vconf_ignore_key_changed(VCONFKEY_LANGSET, __lang_changed_cb);
-
-       g_free(server_auth_info.filename);
-       g_free(server_auth_info.name);
-       server_auth_info.filename = NULL;
-       server_auth_info.name = NULL;
-
-       if (ad->idler > 0) {
-               DBG("Removing idler!!!");
-               g_source_remove(ad->idler);
-       }
-       if (owner_id != 0)
-               g_bus_unown_name(owner_id);
-
-       DBG("Terminating bluetooth-share daemon");
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_sigterm_handler(int signo)
-{
-       FN_START;
-
-       if (main_loop)
-               g_main_loop_quit(main_loop);
-       else
-               terminated = TRUE;
-
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_update_transfer_status_values(void)
-{
-       bt_appdata_t *ad = app_state;
-       GSList *tr_data_list = NULL;
-       GSList *list_iter = NULL;
-       bt_tr_data_t *info = NULL;;
-       sqlite3 *db = NULL;
-
-#if 0
-       /* Update notification status durning BT off */
-       retm_if(_bt_update_notification_status(ad) == FALSE,
-                       "Notification item is not existed.");
-#endif
-
-       DBG("Initialize transfer information");
-
-       db = bt_share_open_db();
-       ret_if(!db);
-
-       tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_OUTBOUND);
-       if (tr_data_list != NULL) {
-               list_iter = tr_data_list;
-
-               while (list_iter != NULL) {
-                       info = list_iter->data;
-                       if (info == NULL)
-                               break;
-
-                       if (info->tr_status == BT_TRANSFER_SUCCESS) {
-                               ad->send_data.tr_success++;
-                       } else if (info->tr_status == BT_TRANSFER_FAIL) {
-                               ad->send_data.tr_fail++;
-                       } else if (info->tr_status == BT_TRANSFER_ONGOING) {
-                               /* In case of ongoing file transfer if bluetooth is switched off
-                               we need to update the status to fail for these transaction */
-                               ad->send_data.tr_fail++;
-                               info->tr_status = BT_TR_FAIL;
-                               bt_share_update_tr_data(db, BT_DB_OUTBOUND, info->id, info);
-                       } else {
-                               ERR("Invalid status");
-                       }
-
-                       list_iter = g_slist_next(list_iter);
-               }
-
-               bt_share_release_tr_data_list(tr_data_list);
-               tr_data_list = NULL;
-               list_iter = NULL;
-       }
-
-       tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_INBOUND);
-       if (tr_data_list != NULL) {
-               list_iter = tr_data_list;
-
-               while (list_iter != NULL) {
-                       info = list_iter->data;
-                       if (info == NULL)
-                               break;
-
-                       if (info->tr_status == BT_TRANSFER_SUCCESS)
-                               ad->recv_data.tr_success++;
-                       else
-                               ad->recv_data.tr_fail++;
-
-                       list_iter = g_slist_next(list_iter);
-               }
-               bt_share_release_tr_data_list(tr_data_list);
-               tr_data_list = NULL;
-               list_iter = NULL;
-       }
-
-       bt_share_close_db(db);
-
-       DBG("[Send] success %d, fail %d", ad->send_data.tr_success,
-                       ad->send_data.tr_fail);
-       DBG("[Receive] success %d, fail %d", ad->recv_data.tr_success,
-                       ad->recv_data.tr_fail);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static GSList *__merge_sorted(GSList *inbound, GSList *outbound)
-{
-       GSList *slist = NULL;
-       int *inbound_noti_id = NULL;
-       int *outbound_noti_id = NULL;
-
-       warn_if(inbound == NULL, "No inbound data!!!");
-       warn_if(outbound == NULL, "No outbound data!!!");
-
-/* **********************Note from glib documentation**************************
- * g_slist_append() has to traverse the entire list to find the end, which
- * is inefficient when adding multiple elements. A common idiom to avoid the
- * inefficiency is to use g_slist_prepend() and reverse the list with
- * g_slist_reverse() when all elements have been added.
- * ***************************************************************************/
-
-       while (inbound && outbound) {
-               inbound_noti_id = (int *)inbound->data;
-               outbound_noti_id = (int *)outbound->data;
-
-               if (*inbound_noti_id > *outbound_noti_id) {
-                       slist = g_slist_prepend(slist, outbound_noti_id);
-                       outbound = g_slist_next(outbound);
-               } else {
-                       slist = g_slist_prepend(slist, inbound_noti_id);
-                       inbound = g_slist_next(inbound);
-               }
-       }
-
-       while (inbound) {
-               inbound_noti_id = (int *)inbound->data;
-               slist = g_slist_prepend(slist, inbound_noti_id);
-               inbound = g_slist_next(inbound);
-       }
-
-       while (outbound) {
-               outbound_noti_id = (int *)outbound->data;
-               slist = g_slist_prepend(slist, outbound_noti_id);
-               outbound = g_slist_next(outbound);
-       }
-
-       return slist;
-}
-/* LCOV_EXCL_STOP */
-
-void _bt_remove_temporary_files_by_noti_id(sqlite3 *db, int noti_id)
-{
-       FN_START;
-       GSList *file_list = bt_share_get_all_temporary_files_by_noti_id(db, noti_id, BT_TMP_DIR);
-
-       GSList *current_file = file_list;
-       while (current_file) {
-               /* LCOV_EXCL_START */
-               DBG("Removing [%s]", (char *)(current_file->data));
-               ecore_file_remove((char *)(current_file->data));
-               current_file = g_slist_next(current_file);
-               /* LCOV_EXCL_STOP */
-       }
-
-       bt_share_release_temporary_file_list(file_list);
-       FN_END;
-}
-
-/* LCOV_EXCL_START */
-gboolean __bt_clean_database(gpointer user_data)
-{
-       bt_appdata_t *ad = app_state;
-       notification_h noti = NULL;
-       notification_list_h noti_list = NULL;
-       notification_list_h current_noti = NULL;
-       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-       sqlite3 *db = NULL;
-       GSList *inbound = NULL;
-       GSList *outbound = NULL;
-       GSList *slist = NULL;
-       GSList *current = NULL;
-       int group_id = 0;
-       int priv_id = 0;
-       int noti_id = 0;
-
-       FN_START;
-
-       if (ad->idler) {
-               DBG("Removing g_idler!!!");
-               g_source_remove(ad->idler);
-               ad->idler = 0;
-       }
-
-       noti_err = notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &noti_list);
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               ERR("Error in getting notification list. error(%d)", noti_err);
-               return G_SOURCE_REMOVE;
-       }
-
-       db = bt_share_open_db();
-       inbound = bt_share_get_noti_list(db, BT_DB_INBOUND);
-       outbound = bt_share_get_noti_list(db, BT_DB_OUTBOUND);
-
-       slist = __merge_sorted(inbound, outbound);
-       current = slist;
-       noti_list = notification_list_get_head(noti_list);
-       current_noti = noti_list;
-
-       while (current_noti && current) {
-               noti = notification_list_get_data(current_noti);
-               noti_err  = notification_get_id(noti, &group_id, &priv_id);
-               noti_id = *(int *)(current->data);
-               DBG("priv_id: %d | noti_id: %d", priv_id, noti_id);
-               if (noti_err == NOTIFICATION_ERROR_NONE) {
-                       if (priv_id == noti_id) {
-                               current = g_slist_next(current);
-                               current_noti = notification_list_get_next(current_noti);
-                       } else if (noti_id > priv_id) {
-                               DBG("Removing data by notification id: %d", noti_id);
-
-                               /* Remove all temporary files related to this noti_id */
-                               _bt_remove_temporary_files_by_noti_id(db, noti_id);
-
-                               bt_share_remove_tr_data_by_notification(db, BT_DB_INBOUND, noti_id);
-                               bt_share_remove_tr_data_by_notification(db, BT_DB_OUTBOUND, noti_id);
-                               current = g_slist_next(current);
-                       } else {
-                               current_noti = notification_list_get_next(current_noti);
-                       }
-               } else {
-                       current_noti = notification_list_get_next(current_noti);
-               }
-       }
-
-       /* Remove remaining records with remaining noti_id in slist */
-       while (current) {
-               noti_id = *(int *)(current->data);
-               DBG("Removing data by notification id: %d", noti_id);
-
-               /* Remove all temporary files related to this noti_id */
-               _bt_remove_temporary_files_by_noti_id(db, noti_id);
-
-               bt_share_remove_tr_data_by_notification(db, BT_DB_INBOUND, noti_id);
-               bt_share_remove_tr_data_by_notification(db, BT_DB_OUTBOUND, noti_id);
-               current = g_slist_next(current);
-       }
-
-       bt_share_close_db(db);
-       notification_free_list(noti_list);
-       bt_share_release_noti_list(inbound);
-       bt_share_release_noti_list(outbound);
-       g_slist_free(slist);
-
-
-       FN_END
-       return G_SOURCE_REMOVE;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static gboolean __bt_dbus_request_name(void)
-{
-       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, BLUETOOTH_SHARE_BUS,
-                       G_DBUS_CALL_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL);
-
-       return (owner_id != 0) ? TRUE : FALSE;
-}
-/* LCOV_EXCL_STOP */
-
-int _bt_init_obex_server(void)
-{
-       retvm_if(bluetooth_obex_server_init(BT_SHARE_DATA_DIR) != BLUETOOTH_ERROR_NONE,
-                       BT_SHARE_FAIL, "Fail to init obex server");
-
-       /* LCOV_EXCL_START */
-       bluetooth_obex_server_set_root(BT_SHARE_DATA_DIR);
-
-       return BT_SHARE_ERROR_NONE;
-       /* LCOV_EXCL_STOP */
-}
-
-/* LCOV_EXCL_START */
-int main(void)
-{
-       int ret = 0;
-       INFO("Starting bluetooth-share daemon");
-
-       signal(SIGTERM, __bt_sigterm_handler);
-
-       app_state = calloc(1, sizeof(bt_appdata_t));
-       if (!app_state)
-               return -1;
-
-       if (__bt_dbus_request_name() == FALSE) {
-               INFO("Aleady dbus instance existed");
-               exit(0);
-       }
-
-       /* init internationalization */
-       retvm_if(appcore_set_i18n(BT_COMMON_PKG, BT_COMMON_RES) < 0,
-                       BT_SHARE_FAIL, "appcore_set_i18n failed!");
-
-       if (_bt_share_cynara_init()) {
-               ERR("Failed to initialize Cynara.\n");
-               return -1;
-       }
-
-       ret = vconf_notify_key_changed(VCONFKEY_LANGSET, __lang_changed_cb, NULL);
-       warn_if(ret != VCONF_OK, "vconf_notify_key_changed failed");
-
-       ret = bluetooth_register_callback(_bt_share_event_handler, NULL);
-       warn_if(ret != BLUETOOTH_ERROR_NONE && ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED,
-                       "bluetooth_register callback failed");
-
-       ret = bluetooth_opc_init();
-       retvm_if(ret != BLUETOOTH_ERROR_NONE, BT_SHARE_FAIL, "bluetooth_opc_init failed");
-
-       _bt_init_dbus_signal();
-       _bt_init_vconf_notification((void *)app_state);
-       __bt_update_transfer_status_values();
-       _bt_register_notification_cb(app_state);
-
-       if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
-               app_state->obex_server_init = TRUE;
-
-       if (terminated == TRUE) {
-               __bt_release_service(app_state);
-               _bt_deinit_dbus_signal();
-               bluetooth_unregister_callback();
-               return BT_SHARE_FAIL;
-       }
-
-       app_state->idler = g_idle_add(__bt_clean_database, NULL);
-       warn_if(!app_state->idler, "Failed to create idler!!!");
-
-       main_loop = g_main_loop_new(NULL, FALSE);
-       g_main_loop_run(main_loop);
-
-       __bt_release_service(app_state);
-       _bt_deinit_dbus_signal();
-       bluetooth_unregister_callback();
-
-       return BT_SHARE_ERROR_NONE;
-}
-/* LCOV_EXCL_STOP */
diff --git a/bt-share/src/bt-share-noti-handler.c b/bt-share/src/bt-share-noti-handler.c
deleted file mode 100644 (file)
index 98c6b9b..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <glib.h>
-#include <vconf.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <storage.h>
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#include "applog.h"
-#include "bt-share-common.h"
-#include "bluetooth-api.h"
-#include "bt-share-noti-handler.h"
-#include "bt-share-main.h"
-#include "bt-share-notification.h"
-#include "obex-event-handler.h"
-
-/* LCOV_EXCL_START */
-static void __bt_default_memory_changed_cb(keynode_t *node, void *data)
-{
-       FN_START;
-       ret_if(node == NULL);
-
-       int default_memory = 0;
-       char *root_path = NULL;
-       char *download_path = NULL;
-
-       DBG_SECURE("key=%s\n", vconf_keynode_get_name(node));
-
-       if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) {
-               /* Phone memory is 0, MMC is 1 */
-               default_memory = vconf_keynode_get_int(node);
-
-               if (default_memory == BT_DEFAULT_MEM_MMC) /* MMC */ {
-                       download_path = _bt_share_get_storage_path(default_memory);
-                       root_path = _bt_share_get_storage_path(default_memory);
-
-                       if (download_path == NULL)
-                               download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-
-                       if (root_path == NULL)
-                               root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-
-               } else {
-                       download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-                       root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-               }
-
-               if (access(download_path, W_OK) != 0) {
-                       warn_if(mkdir(download_path, 0755) < 0,
-                                       "mkdir fail![%s]", download_path);
-               }
-
-               bluetooth_obex_server_set_root(root_path);
-               bluetooth_obex_server_set_destination_path(download_path);
-
-               g_free(download_path);
-               g_free(root_path);
-       }
-
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_mmc_status_changed_cb(keynode_t *node, void *data)
-{
-       FN_START;
-       retm_if(!node || !data, "invalid param!");
-
-       int mmc_status = 0;
-       int default_memory = 0;
-       int ret = NOTIFICATION_ERROR_NONE;
-       char *root_path = NULL;
-       char *download_path = NULL;
-
-       DBG_SECURE("key=%s", vconf_keynode_get_name(node));
-       bt_appdata_t *ad = (bt_appdata_t *)data;
-
-       if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) {
-               /* Phone memory is 0, MMC is 1 */
-               mmc_status = vconf_keynode_get_int(node);
-
-               if (mmc_status == VCONFKEY_SYSMAN_MMC_REMOVED ||
-                       mmc_status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
-                       retm_if(vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
-                                                       &default_memory) != 0,
-                                                       "vconf_get_int failed");
-
-                       if (ad->opc_noti) {     /* sending case */
-                               DBG("cancel outbound transfer");
-                               bluetooth_opc_cancel_push();
-                               ret = _bt_delete_notification(ad->opc_noti);
-                               if (ret == NOTIFICATION_ERROR_NONE) {
-                                       ad->opc_noti = NULL;
-                                       ad->opc_noti_id = 0;
-                               }
-                       } else {                /* receiving case */
-                               DBG("cancel inbound transfer");
-                               if (default_memory == BT_DEFAULT_MEM_MMC) {
-                                       _bt_obex_cancel_transfer(data);
-                                       retm_if(vconf_set_int(
-                                               VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
-                                               BT_DEFAULT_MEM_PHONE) != 0, "vconf_set_int failed");
-                                       DBG_SECURE("Default Memory set to Phone");
-                               }
-                       }
-               } else if (mmc_status == VCONFKEY_SYSMAN_MMC_MOUNTED) {
-                       vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, &default_memory);
-                       if (default_memory == BT_DEFAULT_MEM_MMC) /* MMC */ {
-                               download_path = _bt_share_get_storage_path(default_memory);
-                               root_path = _bt_share_get_storage_path(default_memory);
-
-                               if (download_path == NULL)
-                                       download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-
-                               if (root_path == NULL)
-                                       root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-
-                       } else {
-                               download_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-                               root_path = g_strdup(BT_DOWNLOAD_DEFAULT_MEDIA_FOLDER);
-                       }
-
-                       if (access(download_path, W_OK) != 0) {
-                               warn_if(mkdir(download_path, 0755) < 0,
-                                               "mkdir fail![%s]", download_path);
-                       }
-
-                       bluetooth_obex_server_set_root(root_path);
-                       bluetooth_obex_server_set_destination_path(download_path);
-
-                       g_free(download_path);
-                       g_free(root_path);
-               }
-       }
-
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-void _bt_init_vconf_notification(void *data)
-{
-       retm_if(!data, "invalid param!");
-
-       int ret = VCONF_OK;
-
-       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
-                       __bt_default_memory_changed_cb, NULL);
-       warn_if(ret != VCONF_OK, "vconf_notify_key_changed init failed");
-
-       ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
-                       __bt_mmc_status_changed_cb, data);
-       warn_if(ret != VCONF_OK, "vconf_notify_key_changed init failed");
-}
-
-void _bt_deinit_vconf_notification(void)
-{
-       int ret = VCONF_OK;
-       ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
-                       (vconf_callback_fn) __bt_default_memory_changed_cb);
-       warn_if(ret != VCONF_OK, "vconf_notify_key_changed deinit failed");
-
-       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
-                       (vconf_callback_fn) __bt_mmc_status_changed_cb);
-       warn_if(ret != VCONF_OK, "vconf_notify_key_changed deinit failed");
-}
-
diff --git a/bt-share/src/bt-share-notification.c b/bt-share/src/bt-share-notification.c
deleted file mode 100644 (file)
index b59eae3..0000000
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <applog.h>
-#include <notification.h>
-#include <notification_list.h>
-#include <notification_text_domain.h>
-#include <notification_internal.h>
-#include <appsvc.h>
-#include <vconf.h>
-
-#include "bt-share-common.h"
-#include "bt-share-notification.h"
-#include "bt-share-main.h"
-#include "bt-share-ipc.h"
-#include "obex-event-handler.h"
-#include "bluetooth-share-api.h"
-#include "bt-share-resource.h"
-
-#define BT_PRIV_ID_STR_LEN 12
-
-extern GSList *bt_rcv_noti_info_list;
-extern GSList *bt_snd_noti_info_list;
-
-void _bt_insert_instant_notification(bt_notification_type_e type)
-{
-       FN_START;
-       notification_h noti = NULL;
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-       char *title = NULL;
-       char *icon_path = NULL;
-
-       DBG("Create notification type : %d", type);
-
-       switch (type) {
-       case BT_SENDING_NOTI: {
-               title = BT_STR_SENDING_FILES;
-               icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
-               break;
-       }
-
-       case BT_RECEIVING_NOTI: {
-               title = BT_STR_RECEIVING_FILES;
-               icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
-               break;
-       }
-
-       case BT_SENT_NOTI: {
-               title = BT_STR_FILES_SENT;
-               icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
-               break;
-       }
-
-       case BT_SENT_FAILED_NOTI: {
-               title = BT_STR_SENDING_FILES_FAILED;
-               icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
-               break;
-       }
-
-       case BT_RECEIVED_NOTI: {
-               title = BT_STR_FILES_RECEIVED;
-               icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
-               break;
-       }
-
-       case BT_RECEIVED_FAILED_NOTI: {
-               title = BT_STR_RECEIVING_FILES_FAILED;
-               icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
-               break;
-       }
-
-       default:
-               return;
-       }
-
-       noti = notification_create(NOTIFICATION_TYPE_NOTI);
-       retm_if(!noti, "Fail to notification_create");
-
-       if (title) {
-               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                                       NULL, title,
-                                       NOTIFICATION_VARIABLE_TYPE_NONE);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                               "Fail to notification_set_text [%d]", ret);
-       }
-
-       if (icon_path) {
-               ret = notification_set_image(noti,
-                               NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, icon_path);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_image [%d]", ret);
-       }
-
-       ret  = notification_set_display_applist(noti,
-                       NOTIFICATION_DISPLAY_APP_TICKER);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_set_display_applist [%d]", ret);
-
-       ret = notification_post(noti);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_insert [%d]", ret);
-
-       if (noti)
-               notification_free(noti);
-       FN_END;
-}
-
-notification_h _bt_insert_notification(bt_appdata_t *ad,
-                       bt_notification_type_e type, char *dev_name,
-                       char *address, char *db_sid)
-{
-       notification_h noti = NULL;
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-       notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
-       char *title = NULL;
-       char *content = NULL;
-       char *icon_path = NULL;
-       char *indicator_icon_path = NULL;
-       char *app_id = NULL;
-       int noti_id = 0;
-       int flag = -1;
-       int success = 0;
-       int fail = 0;
-       bool include_name_param = false;
-
-       DBG("Create notification type : %d", type);
-
-       if (type == BT_SENT_NOTI) {
-               success = ad->send_data.tr_success;
-               fail = ad->send_data.tr_fail;
-
-               if (success == 0) {
-                       title = "IDS_BT_MBODY_SENDING_FAILED";
-               } else {
-                       title = "IDS_WIFI_BODY_FILES_SENT_TO_PS_M_STATUS";
-                       include_name_param = true;
-               }
-
-               if (success == 0 && fail > 0)
-                       content = "IDS_BT_SBODY_PD_FAILED_ABB";
-               else if (fail == 0 && success > 0)
-                       content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
-               else
-                       content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
-
-               icon_path = BT_ICON_NOTIFICATION_SENT;
-               indicator_icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR;
-               flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE;
-               app_id = NOTI_OPC_APP_ID;
-               noti_type = NOTIFICATION_TYPE_NOTI;
-       } else if (type == BT_RECEIVED_NOTI) {
-               success = ad->recv_data.tr_success;
-               fail = ad->recv_data.tr_fail;
-
-               if (success == 0 && fail > 0) {
-                       content = "IDS_BT_SBODY_PD_FAILED_ABB";
-                       title = "IDS_BT_MBODY_RECEIVING_FAILED";
-               } else if (fail == 0 && success > 0) {
-                       title = "IDS_WIFI_MBODY_FILES_RECEIVED_FROM_PS";
-                       content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
-                       include_name_param = true;
-               } else {
-                       title = "IDS_WIFI_MBODY_FILES_RECEIVED_FROM_PS";
-                       content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
-                       include_name_param = true;
-               }
-               icon_path = BT_ICON_NOTIFICATION_RECEIVED;
-               indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR;
-               flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE;
-               app_id = NOTI_OPS_APP_ID;
-               noti_type = NOTIFICATION_TYPE_NOTI;
-       } else if (type == BT_SENDING_NOTI) {
-               title = "IDS_BT_SBODY_PREPARING_TO_SEND_FILES_ING_ABB";
-               icon_path = BT_ICON_NOTIFICATION_SENDING;
-               indicator_icon_path = BT_ICON_NOTIFICATION_SENDING_INDICATOR;
-               flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI;
-               noti_type = NOTIFICATION_TYPE_ONGOING;
-       } else if (type == BT_RECEIVING_NOTI) {
-               title = "IDS_BT_SBODY_PREPARING_TO_RECEIVE_FILES_ING_ABB";
-               icon_path = BT_ICON_NOTIFICATION_RECEIVING;
-               indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVING_INDICATOR;
-               flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI;
-               noti_type = NOTIFICATION_TYPE_ONGOING;
-       }
-
-       noti = notification_create(noti_type);
-       if (!noti) {
-               ERR("Fail to notification_create");
-               return NULL;
-       }
-
-       notification_set_text_domain(noti, BT_COMMON_PKG, BT_COMMON_RES);
-
-       if (title) {
-               if (include_name_param == true) {
-                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                               NULL, title,
-                               NOTIFICATION_VARIABLE_TYPE_STRING, dev_name,
-                               NOTIFICATION_VARIABLE_TYPE_NONE);
-               } else {
-                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                               NULL, title,
-                               NOTIFICATION_VARIABLE_TYPE_NONE);
-               }
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_text [%d]", ret);
-       }
-
-       if (content) {
-               DBG("success : %d, fail : %d", success, fail);
-               if (success > 0 && fail > 0) {
-                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                               NULL, content,
-                                               NOTIFICATION_VARIABLE_TYPE_INT, success,
-                                               NOTIFICATION_VARIABLE_TYPE_INT, fail,
-                                               NOTIFICATION_VARIABLE_TYPE_NONE);
-               } else {
-                       ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                               NULL, content,
-                                               NOTIFICATION_VARIABLE_TYPE_INT, (success > 0) ? success : fail,
-                                               NOTIFICATION_VARIABLE_TYPE_NONE);
-               }
-
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_text [%d]", ret);
-       }
-
-       if (icon_path) {
-               ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_image [%d]", ret);
-       }
-
-       if (indicator_icon_path) {
-               ret = notification_set_image(noti,
-                               NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, indicator_icon_path);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_image [%d]", ret);
-       }
-
-       if (flag != -1) {
-               ret = notification_set_property(noti, flag);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_property [%d]", ret);
-
-               if (type == BT_SENDING_NOTI || type == BT_RECEIVING_NOTI) {
-                       ret = notification_set_property(noti,
-                                       NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
-                       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                               "Fail to set property for DISABLE_APP_LAUNCH [%d]", ret);
-               }
-       }
-
-       if (app_id) {
-               ret = notification_set_pkgname(noti, app_id);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_pkgname [%d]", ret);
-       }
-
-       ret = notification_set_display_applist(noti,
-                       NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_set_display_applist [%d]", ret);
-
-       if (type == BT_SENT_NOTI) {
-               _bt_set_notification_app_launch(noti, dev_name, address, db_sid,
-                               CREATE_TR_LIST, NOTI_TR_TYPE_OUT, NULL, 0, NULL, 0);
-       } else if (type == BT_RECEIVED_NOTI) {
-               _bt_set_notification_app_launch(noti, dev_name, address, db_sid,
-                               CREATE_TR_LIST, NOTI_TR_TYPE_IN, NULL, 0, NULL, 0);
-       }
-
-       ret = notification_insert(noti, &noti_id);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_insert [%d]", ret);
-
-       if (type == BT_SENT_NOTI)
-               ad->send_noti_id = noti_id;
-       else if (type == BT_RECEIVED_NOTI)
-               ad->receive_noti_id = noti_id;
-
-       INFO("Insert %s type: %d ", (type == BT_SENT_NOTI ||
-                       type == BT_RECEIVED_NOTI) ? "Notification" : "Ongoing", type);
-
-       return noti;
-}
-
-int _bt_update_notification(bt_appdata_t *ad,
-               notification_h noti, char *title, char *content, char *dev_name,
-               char *icon_path, char *opc_count)
-{
-       retvm_if(!noti, BT_SHARE_FAIL, "noti is NULL");
-
-       INFO("Update noti : %p", noti);
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-       int success = 0;
-       int fail = 0;
-       int flags = -1;
-
-       if (ad->send_noti == noti) {
-               success = ad->send_data.tr_success;
-               fail = ad->send_data.tr_fail;
-       } else if (ad->receive_noti == noti) {
-               success = ad->recv_data.tr_success;
-               fail = ad->recv_data.tr_fail;
-       }
-
-       if (ad->send_noti == noti || ad->receive_noti == noti) {
-               if (success == 0 && fail > 0)
-                       content = "IDS_BT_SBODY_PD_FAILED_ABB";
-               else if (fail == 0 && success > 0)
-                       content = "IDS_BT_SBODY_PD_SUCCEEDED_ABB";
-               else
-                       content = "IDS_BT_SBODY_P1SD_SUCCEEDED_P2SD_FAILED_ABB2";
-       }
-
-       if (title) {
-               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                                       NULL, title,
-                                       NOTIFICATION_VARIABLE_TYPE_NONE);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_text [%d]", ret);
-       }
-
-       if (content) {
-               if (noti == ad->send_noti || noti == ad->receive_noti) {
-                       if (success > 0 && fail > 0) {
-                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                               NULL, content,
-                                               NOTIFICATION_VARIABLE_TYPE_INT, success,
-                                               NOTIFICATION_VARIABLE_TYPE_INT, fail,
-                                               NOTIFICATION_VARIABLE_TYPE_NONE);
-                       } else {
-                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                                               NULL, content,
-                                                               NOTIFICATION_VARIABLE_TYPE_INT, (success > 0) ? success : fail,
-                                                               NOTIFICATION_VARIABLE_TYPE_NONE);
-                       }
-               } else {
-                       if (dev_name) {
-                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                                       NULL, content,
-                                                       NOTIFICATION_VARIABLE_TYPE_STRING, dev_name,
-                                                       NOTIFICATION_VARIABLE_TYPE_NONE);
-                       } else {
-                               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                                       NULL, content, NOTIFICATION_VARIABLE_TYPE_NONE);
-                       }
-               }
-
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_text [%d]", ret);
-       }
-
-       if (opc_count) {
-               ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT,
-                                       NULL, opc_count, NOTIFICATION_VARIABLE_TYPE_NONE);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_text [%d]", ret);
-       }
-
-       if (icon_path) {
-               ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
-                               icon_path);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_set_image [%d]", ret);
-       }
-
-       ret  = notification_get_property(noti, &flags);
-       if (ret == NOTIFICATION_ERROR_NONE) {
-               if (flags & NOTIFICATION_PROP_DISABLE_APP_LAUNCH) {
-                       ret = notification_set_property(noti,
-                                       flags ^ NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
-                       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                                       "Failed to set app launch property");
-               }
-       } else {
-               ERR("failed to get the property: [%d]", ret);
-       }
-
-       ret = notification_update(noti);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                       "Fail to notification_update [%d]", ret);
-
-       return ret;
-}
-
-int _bt_update_notification_progress(notification_h not,
-                               int id, int val)
-{
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-
-       ret = notification_update_progress(not, id, (double)val / 100);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_update_progress [%d]\n", ret);
-
-       return ret;
-}
-
-int _bt_get_notification_priv_id(notification_h noti)
-{
-       int group_id = 0;
-       int priv_id = 0;
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-
-       ret = notification_get_id(noti, &group_id, &priv_id);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_get_id [%d]", ret);
-
-       return priv_id;
-}
-
-int _bt_delete_notification(notification_h noti)
-{
-       retv_if(!noti, BT_SHARE_FAIL);
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-
-       INFO("Delete noti : %p", noti);
-
-       /* In case daemon, give full path */
-       ret = notification_delete(noti);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_delete [%d]", ret);
-
-       return ret;
-}
-
-int _bt_set_notification_app_launch(notification_h noti,
-               char *device_name,
-               char *device_addr,
-               char *db_sid,
-               bt_notification_launch_type_e launch_type,
-               const char *transfer_type,
-               const char *filename,
-               unsigned long size,
-               const char *progress_cnt,
-               int transfer_id)
-{
-       FN_START;
-       retv_if(!noti, BT_SHARE_FAIL);
-       retv_if(!transfer_type, BT_SHARE_FAIL);
-       retv_if(launch_type != CREATE_PROGRESS && launch_type != CREATE_TR_LIST,
-                       BT_SHARE_FAIL);
-
-       notification_error_e ret = NOTIFICATION_ERROR_NONE;
-       bundle *b = NULL;
-       b = bundle_create();
-       retv_if(!b, BT_SHARE_FAIL);
-
-       appsvc_set_pkgname(b, UI_PACKAGE);
-       appsvc_add_data(b, "device_name", device_name);
-       appsvc_add_data(b, "device_addr", device_addr);
-       appsvc_add_data(b, "transfer_type", transfer_type);
-       appsvc_add_data(b, "db_sid", db_sid);
-
-       if (launch_type == CREATE_PROGRESS) {
-               if (!filename) {
-                       bundle_free(b);
-                       return BT_SHARE_FAIL;
-               }
-
-               char priv_id_str[BT_PRIV_ID_STR_LEN] = {0, };
-               char size_str[BT_PRIV_ID_STR_LEN] = {0, };
-               snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", transfer_id);
-               snprintf(size_str, BT_PRIV_ID_STR_LEN, "%lu", size);
-
-               appsvc_add_data(b, "launch-type", "ongoing");
-               appsvc_add_data(b, "filename", filename);
-               appsvc_add_data(b, "size", size_str);
-               appsvc_add_data(b, "transfer_id", priv_id_str);
-               if (g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT) == 0) {
-                       if (!progress_cnt) {
-                               bundle_free(b);
-                               return BT_SHARE_FAIL;
-                       }
-                       appsvc_add_data(b, "progress_cnt", progress_cnt);
-               }
-       } else {
-               char priv_id_str[BT_PRIV_ID_STR_LEN] = {0, };
-               snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", transfer_id);
-
-               appsvc_add_data(b, "launch-type", "transfer_list");
-               appsvc_add_data(b, "transfer_id", priv_id_str);
-               appsvc_add_data(b, "filename", filename);
-       }
-
-       ret = notification_set_execute_option(noti,
-                                       NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
-                                       NULL, NULL, b);
-       warn_if(ret != NOTIFICATION_ERROR_NONE,
-               "Fail to notification_set_execute_option [%d]\n", ret);
-
-       bundle_free(b);
-       FN_END;
-       return ret;
-}
-
-#if 0
-gboolean _bt_update_notification_status(bt_appdata_t *ad)
-{
-       retv_if(ad == NULL, FALSE);
-
-       notification_h noti = NULL;
-       notification_list_h list_head = NULL;
-       notification_list_h list_traverse = NULL;
-       gboolean is_noti_existed = FALSE;
-       gboolean send_noti = FALSE;
-       gboolean receive_noti = FALSE;
-       sqlite3 *db = NULL;
-       char *app_id = NULL;
-       int group_id = 0;
-       int priv_id = 0;
-       int ret = 0;
-
-       /* When bt-share is launched, need to update notification status  */
-       notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &list_head);
-       list_traverse = list_head;
-
-       while (list_traverse != NULL) {
-               noti = notification_list_get_data(list_traverse);
-               notification_get_pkgname(noti, &app_id);
-
-               if (g_strcmp0(app_id, NOTI_OPS_APP_ID) == 0) {
-                       ret = notification_clone(noti, &ad->receive_noti);
-                       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                                       "Fail to clone notificatoin");
-
-                       ret = notification_get_id(noti, &group_id, &priv_id);
-                       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                                       "Fail to get notification id");
-
-                       ad->receive_noti_id = priv_id;
-                       receive_noti = TRUE;
-               } else if (g_strcmp0(app_id, NOTI_OPC_APP_ID) == 0) {
-                       ret = notification_clone(noti, &ad->send_noti);
-                       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                                       "Unable to clone notificatoin");
-
-                       ret = notification_get_id(noti, &group_id, &priv_id);
-                       warn_if(ret != NOTIFICATION_ERROR_NONE,
-                               "Fail to get notification id");
-
-                       ad->send_noti_id = priv_id;
-                       send_noti = TRUE;
-               }
-
-               if (receive_noti || send_noti) {
-                       time_t ret_time;
-                       /* Set notication insert_time */
-                       notification_get_insert_time(noti, &ret_time);
-                       notification_set_time(noti, ret_time);
-                       notification_update(noti);
-                       is_noti_existed = TRUE;
-                       send_noti = FALSE;
-                       receive_noti = FALSE;
-               }
-
-               list_traverse = notification_list_get_next(list_traverse);
-       }
-
-       if (list_head != NULL) {
-               notification_free_list(list_head);
-               list_head = NULL;
-       }
-
-       /* If notification item is removed durning BT off, need to remove DB */
-       db = bt_share_open_db();
-       retv_if(!db, is_noti_existed);
-
-       if (!receive_noti)
-               bt_share_remove_all_tr_data(db, BT_DB_INBOUND);
-       if (!send_noti)
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-       bt_share_close_db(db);
-
-       return is_noti_existed;
-}
-#endif
-
-/* LCOV_EXCL_START */
-static void __bt_notification_changed_cb(void *data, notification_type_e type,
-               notification_op *op_list, int num_op)
-{
-       FN_START;
-       retm_if(data == NULL, "Invalid data");
-       retm_if(op_list == NULL, "Invalid op_list");
-
-       bt_appdata_t *ad = (bt_appdata_t *)data;
-       sqlite3 *db = NULL;
-       int i;
-
-       ret_if(type != NOTIFICATION_TYPE_NOTI ||
-               (op_list->type != NOTIFICATION_OP_DELETE &&
-               op_list->type != NOTIFICATION_OP_DELETE_ALL));
-
-       DBG("Notifications Changed: %d", num_op);
-       DBG("Currently Received NotiID: %d", ad->receive_noti_id);
-       db = bt_share_open_db();
-       for (i = 0; i < num_op; i++, op_list++) {
-               DBG("TYPE:%d PRIV_ID:%d", op_list->type, op_list->priv_id);
-
-               if (op_list->priv_id == ad->receive_noti_id) {
-                       ad->receive_noti = NULL;
-                       ad->receive_noti_id = 0;
-               }
-
-               if (bt_share_check_noti_id(db, BT_DB_OUTBOUND, op_list->priv_id)
-                                               == BT_SHARE_ERR_NONE) {
-                       DBG("Delete Entries from OUTBOUND for NotiID %d", op_list->priv_id);
-                       ad->send_noti = NULL;
-                       ad->send_noti_id = 0;
-                       ad->send_data.tr_fail = 0;
-                       ad->send_data.tr_success = 0;
-                       _bt_remove_temporary_files_by_noti_id(db, op_list->priv_id);
-                       bt_share_remove_tr_data_by_notification(db,
-                                       BT_DB_OUTBOUND, op_list->priv_id);
-               }
-               if (bt_share_check_noti_id(db, BT_DB_INBOUND, op_list->priv_id)
-                                               == BT_SHARE_ERR_NONE) {
-                       DBG("Delete Entries from INBOUND for NotiID %d", op_list->priv_id);
-                       ad->receive_noti = NULL;
-                       ad->receive_noti_id = 0;
-                       ad->recv_data.tr_fail = 0;
-                       ad->recv_data.tr_success = 0;
-                       bt_share_remove_tr_data_by_notification(db,
-                                       BT_DB_INBOUND, op_list->priv_id);
-               }
-       }
-       bt_share_close_db(db);
-
-       DBG("SEND: Success[%d] Fail[%d] ||||| RECEIVE: Success[%d] Fail[%d]",
-                       ad->send_data.tr_success, ad->send_data.tr_fail,
-                       ad->recv_data.tr_success, ad->recv_data.tr_fail);
-       FN_END;
-
-}
-/* LCOV_EXCL_STOP */
-
-void _bt_register_notification_cb(bt_appdata_t *ad)
-{
-       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-
-       noti_err = notification_register_detailed_changed_cb(
-                       __bt_notification_changed_cb, ad);
-       warn_if(noti_err != NOTIFICATION_ERROR_NONE,
-                       "notification_resister_changed_cb failed [%d]\n", noti_err);
-}
-
-void _bt_unregister_notification_cb(bt_appdata_t *ad)
-{
-       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-
-       noti_err = notification_unregister_detailed_changed_cb(
-                       __bt_notification_changed_cb, NULL);
-       warn_if(noti_err != NOTIFICATION_ERROR_NONE,
-                       "notification_unresister_changed_cb failed [%d]\n", noti_err);
-}
diff --git a/bt-share/src/bt-share-syspopup.c b/bt-share/src/bt-share-syspopup.c
deleted file mode 100644 (file)
index f808bd2..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <glib.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syspopup_caller.h>
-#include <bundle_internal.h>
-
-#include "applog.h"
-#include "bt-share-common.h"
-#include "bluetooth-api.h"
-#include "bt-share-syspopup.h"
-#include "bt-share-main.h"
-#include "bt-share-resource.h"
-#include "obex-event-handler.h"
-
-extern bt_appdata_t *app_state;
-#define BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
-#define BT_SYSPOPUP_EVENT_LEN_MAX 50
-
-/* LCOV_EXCL_START */
-static gboolean __bt_system_popup_timer_cb(gpointer user_data)
-{
-       int ret = 0;
-       bundle *b = (bundle *) user_data;
-
-       retvm_if(!b, FALSE,
-               "There is some problem with the user data..popup can not be created\n");
-
-       ret = syspopup_launch("bt-syspopup", b);
-       warn_if(0 > ret, "launching sys-popup failed\n");
-
-       bundle_free(b);
-       return FALSE;
-}
-/* LCOV_EXCL_STOP */
-
-int _bt_launch_system_popup(bt_app_event_type_e event_type,
-                           bt_app_sys_popup_params_t *popup_params,
-                           void *cb,
-                           void *data)
-{
-       FN_START;
-       int ret = BT_SHARE_ERROR_NONE;
-       bundle *b = NULL;
-       bt_appdata_t *ad = NULL;
-       char event_str[BT_SYSPOPUP_EVENT_LEN_MAX] = {0, };
-
-       if (data)
-               ad = (bt_appdata_t *)data;
-       else
-               ad = app_state;
-
-       retv_if(!ad, BT_SHARE_FAIL);
-
-       b = bundle_create();
-       retvm_if(!b, BT_SHARE_FAIL, "bundle_create failed");
-
-       bundle_add(b, "title", popup_params->title);
-       bundle_add(b, "type", popup_params->type);
-       bundle_add(b, "file", popup_params->file);
-       bundle_add(b, "device_name", popup_params->device_name);
-
-       switch (event_type) {
-       case BT_APP_EVENT_CONFIRM_MODE_REQUEST: {
-               strncpy(event_str, "app-confirm-request", sizeof(event_str));
-               break;
-       }
-
-       case BT_APP_EVENT_FILE_RECEIVED: {
-               strncpy(event_str, "file-received", sizeof(event_str));
-               break;
-       }
-
-       case BT_APP_EVENT_INFORMATION: {
-               strncpy(event_str, "bt-information", sizeof(event_str));
-               break;
-       }
-
-       case BT_APP_EVENT_OVERWRITE_REQUEST: {
-               strncpy(event_str, "confirm-overwrite-request", sizeof(event_str));
-               break;
-       }
-
-       default:
-               break;
-       }
-
-       bundle_add(b, "event-type", event_str);
-
-       /*The system popup launch function is not able to launch second popup
-         * if first popup is being processed still, this due to the check
-         * in AUL module to restrict multiple launching of syspopup,
-         * to solve this problem after discussion it is decided that  if
-         * the popup launch fails then it will be retried
-         * after small timeout. */
-       ret = syspopup_launch("bt-syspopup", b);
-       if (0 > ret) {
-               ERR("Popup launch failed...retry = %d\n", ret);
-               g_timeout_add(BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS,
-                             (GSourceFunc) __bt_system_popup_timer_cb, b);
-       } else {
-               bundle_free(b);
-       }
-
-       if (cb != NULL)
-               ad->popups.popup_cb = (bt_app_cb) cb;
-
-       ad->popups.popup_cb_data = data;
-       ad->popups.syspopup_request = TRUE;
-
-       FN_END;
-       return BT_SHARE_ERROR_NONE;
-}
-
-
-gboolean _bt_app_popup_memoryfull(gpointer user_data)
-{
-       bt_app_sys_popup_params_t popup_params = { NULL };
-
-       popup_params.title = BT_STR_MEMORY_FULL;
-       popup_params.type = "none";
-       _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
-                       &popup_params, NULL, NULL);
-       return FALSE;
-}
-
-
diff --git a/bt-share/src/obex-event-handler.c b/bt-share/src/obex-event-handler.c
deleted file mode 100644 (file)
index 5669fcc..0000000
+++ /dev/null
@@ -1,1683 +0,0 @@
-/*
- * bluetooth-share
- *
- * 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 <sys/vfs.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <ctype.h>
-#include <arpa/inet.h>
-#include <app_control.h>
-#include <vconf-keys.h>
-#ifdef ENABLE_CALENDAR_SERVICE2
-#include <calendar.h>
-#endif
-#ifdef ENABLE_CONTACTS_SERVICE2
-#include <contacts.h>
-#include <contacts_filter.h>
-#endif
-#include <vconf.h>
-#include <Ecore_File.h>
-#include <bluetooth-share-api.h>
-#include <notification.h>
-#include <media_content.h>
-#include <media_content_internal.h>
-#include <sys/stat.h>
-#include <aul.h>
-#include <storage.h>
-#include <zlib.h>
-
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#include "applog.h"
-#include "bluetooth-api.h"
-#include "obex-event-handler.h"
-#include "bt-share-main.h"
-#include "bt-share-syspopup.h"
-#include "bt-share-resource.h"
-#include "bt-share-ipc.h"
-#include "bt-share-notification.h"
-#include "bt-share-common.h"
-#include "bt-share-noti-handler.h"
-
-typedef struct {
-       void *noti_handle;
-       int transfer_id;
-       int noti_id;
-} bt_noti_data_t;
-
-typedef struct {
-       char *file_path;
-       bt_file_type_e file_type;
-} bt_file_info_t;
-
-extern bt_appdata_t *app_state;
-extern GSList *bt_transfer_list;
-GSList *bt_receive_noti_list;
-GSList *bt_rcv_noti_info_list = NULL;
-GSList *bt_snd_noti_info_list = NULL;
-bt_obex_server_authorize_into_t server_auth_info;
-
-static gboolean isTransferConnectedReceived = FALSE;
-
-static void *__bt_obex_writeclose(bt_file_info_t *info);
-
-static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t *server_auth_info);
-
-/* LCOV_EXCL_START */
-static void __bt_free_rcv_notification(gpointer data)
-{
-       bt_device_rcv_noti_info_t *noti_data = data;
-       ret_if(!noti_data);
-
-       bt_rcv_noti_info_list = g_slist_remove(bt_rcv_noti_info_list, noti_data);
-       g_free(noti_data->address);
-       g_free(noti_data->device_name);
-       g_free(noti_data->db_sid);
-       g_free(noti_data);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_free_snd_notification(gpointer data)
-{
-       bt_device_snd_noti_info_t *noti_data = data;
-       ret_if(!noti_data);
-
-       bt_snd_noti_info_list = g_slist_remove(bt_snd_noti_info_list, noti_data);
-       g_free(noti_data->db_sid);
-       g_free(noti_data);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void _bt_get_pending_list(bt_appdata_t *ad)
-{
-       sqlite3 *db = NULL;
-       retm_if(ad == NULL, "Application data ad is NULL");
-
-       db = bt_share_open_db();
-       if (ad->tr_send_list) {
-               bt_share_release_tr_data_list(ad->tr_send_list);
-               ad->tr_send_list = NULL;
-               ad->tr_next_data = NULL;
-       }
-
-       ad->tr_send_list = bt_share_get_tr_data_list_by_status(db,
-                               BT_DB_OUTBOUND, BT_TR_PENDING);
-
-       bt_share_close_db(db);
-
-       if (ad->tr_send_list)
-               ad->tr_next_data = ad->tr_send_list;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static bt_device_snd_noti_info_t *__bt_get_snd_noti_data_by_device_address(char *address)
-{
-       GSList *l = NULL;
-       bt_device_snd_noti_info_t *data = NULL;
-
-       for (l = bt_snd_noti_info_list; l != NULL; l = l->next) {
-               data = l->data;
-               if (data == NULL)
-                       continue;
-
-               retv_if(!strcmp(data->address, address), data);
-       }
-
-       return NULL;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static bt_device_rcv_noti_info_t *__bt_get_rcv_noti_data_by_device_address(char *address)
-{
-       GSList *l = NULL;
-       bt_device_rcv_noti_info_t *data = NULL;
-
-       for (l = bt_rcv_noti_info_list; l != NULL; l = l->next) {
-               data = l->data;
-               if (data == NULL)
-                       continue;
-
-               retv_if(!strcmp(data->address, address), data);
-       }
-
-       return NULL;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static bt_noti_data_t *__bt_get_noti_data_by_transfer_id(int transfer_id)
-{
-       GSList *l = NULL;
-       bt_noti_data_t *data = NULL;
-
-       for (l = bt_receive_noti_list; l != NULL; l = l->next) {
-               data = l->data;
-               if (data == NULL)
-                       continue;
-
-               retv_if(data->transfer_id == transfer_id, data);
-       }
-
-       return NULL;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static char *__get_file_name(int cnt, char **path)
-{
-       retvm_if(path == NULL || path[cnt] == NULL, NULL, "Path is invalid");
-       char *pfilename = NULL;
-
-       pfilename = strrchr(path[cnt], '/') + 1;
-       DBG_SECURE("File name[%d] : %s", cnt, pfilename);
-       return pfilename;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __delete_notification(gpointer data, gpointer user_data)
-{
-       bt_noti_data_t *noti_data = data;
-       ret_if(!noti_data);
-
-       _bt_delete_notification(noti_data->noti_handle);
-       g_free(noti_data);
-}
-/* LCOV_EXCL_STOP */
-
-void _bt_obex_cancel_transfer(void *data)
-{
-       FN_START;
-       retm_if(!data, "invalid param!");
-
-       GSList *l = NULL;
-       bt_noti_data_t *noti_data = NULL;
-       int ret = 0;
-
-       for (l = bt_receive_noti_list; l != NULL; l = l->next) {
-               /* LCOV_EXCL_START */
-               noti_data = l->data;
-               if (noti_data == NULL)
-                       continue;
-
-               DBG("noti_id : %d", noti_data->noti_id);
-               ret = bluetooth_obex_server_cancel_transfer(noti_data->transfer_id);
-               warn_if(ret != BLUETOOTH_ERROR_NONE,
-                       "bluetooth_obex_server_cancel_transfer[ret:%d]", ret);
-               /* LCOV_EXCL_STOP */
-       }
-       FN_END;
-}
-
-void _bt_clear_receive_noti_list(void)
-{
-       if (bt_receive_noti_list) {
-               /* LCOV_EXCL_START */
-               g_slist_foreach(bt_receive_noti_list,
-                               (GFunc)__delete_notification,
-                               NULL);
-               g_slist_free(bt_receive_noti_list);
-               bt_receive_noti_list = NULL;
-               /* LCOV_EXCL_STOP */
-       }
-}
-
-/* LCOV_EXCL_START */
-char *__get_dest_file_path(const char *path)
-{
-       char file_path[BT_TEMP_FILE_PATH_LEN_MAX] = {0, };
-
-       /* Media updation is failing if we give FTP folder path.
-            So we have to map the FTP folder path like below
-            /opt/share/bt-ftp/Media/XX -> /opt/usr/media/XX
-            /opt/share/bt-ftp/SD_External/XX -> /opt/storage/sdcard/XX
-        */
-       if (g_str_has_prefix(path, BT_FTP_FOLDER_PHONE)) {
-               snprintf(file_path, sizeof(file_path), "%s/%s",
-                       BT_DOWNLOAD_PHONE_ROOT,
-                       path + strlen(BT_FTP_FOLDER_PHONE));
-       } else if (g_str_has_prefix(path, BT_FTP_FOLDER_MMC)) {
-               snprintf(file_path, sizeof(file_path), "%s/%s",
-                       BT_DOWNLOAD_MMC_ROOT,
-                       path + strlen(BT_FTP_FOLDER_MMC));
-       } else {
-               snprintf(file_path, sizeof(file_path), "%s", path);
-       }
-
-       DBG_SECURE("File path %s", file_path);
-       return g_strdup(file_path);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __free_file_info(bt_file_info_t *info)
-{
-       g_free(info->file_path);
-       g_free(info);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static bt_file_type_e __get_file_type(char *extn)
-{
-       if (extn != NULL) {
-
-               DBG("extn : %s", extn);
-
-               if (!strcmp(extn, "vcf"))
-                       return BT_FILE_VCARD;
-               else if (!strcmp(extn, "vcs"))
-                       return BT_FILE_VCAL;
-               else if (!strcmp(extn, "vbm"))
-                       return BT_FILE_VBOOKMARK;
-       }
-       return BT_FILE_OTHER;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static gboolean __bt_scan_media_file(char *file_path)
-{
-       int ret = 0;
-       uid_t uid = 0;
-
-       /* Set active UID for system session's bt-share process */
-       ret = _bt_share_get_active_uid(&uid);
-       retvm_if(ret != BT_SHARE_ERROR_NONE, FALSE,
-               "Fail to get the active uid: %d", ret);
-
-       ret = media_content_connect_with_uid(uid);
-       retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, FALSE,
-               "Fail to connect the media content: %d", ret);
-
-       ret = media_content_scan_file(file_path);
-       warn_if(ret != MEDIA_CONTENT_ERROR_NONE, "Fail to scan file: %d", ret);
-
-       ret = media_content_disconnect();
-       warn_if(ret != MEDIA_CONTENT_ERROR_NONE,
-                       "Fail to disconnect the media content: %d", ret);
-
-       return TRUE;
-}
-
-static void __bt_move_media_file(char *file_path)
-{
-       char storage[STORAGE_PATH_LEN_MAX] = {0, };
-       char media_file_path[BT_FILE_PATH_LEN_MAX] = {0, };
-
-       retm_if(!file_path, "invalid param!");
-
-       INFO("File path: %s", file_path);
-
-       _bt_get_default_storage(storage);
-
-       retm_if(!BT_SHARE_DATA_DIR, "DATA dir is NULL");
-
-       snprintf(media_file_path, BT_FILE_PATH_LEN_MAX, "%s/%s",
-               storage, file_path + strlen(BT_SHARE_DATA_DIR));
-
-       INFO("Media file path: %s", media_file_path);
-
-       ecore_file_mv(file_path, media_file_path);
-
-       __bt_scan_media_file(media_file_path);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-void __bt_update_db_with_noti_id(bt_tr_db_table_e table, notification_h noti,
-               const char *db_sid)
-{
-       sqlite3 *db = bt_share_open_db();
-       int noti_id = 0;
-
-       noti_id = _bt_get_notification_priv_id(noti);
-       INFO("Update into database noti_id: %d", noti_id);
-       bt_share_update_noti_id(db, table, noti_id, db_sid);
-
-       bt_share_close_db(db);
-}
-/* LCOV_EXCL_STOP */
-
-#ifdef ENABLE_CONTACTS_SERVICE2
-#if 0
-/* LCOV_EXCL_START */
-void _bt_util_get_number(char *source, char *dest)
-{
-       int len = 7;
-       int slen = 0;
-       char buf[9];
-
-       slen = strlen(source);
-       slen--;
-       buf[8] = '\0';
-       while (len > -1) {
-               if (slen > -1) {
-                       if (isdigit(source[slen])) {
-                               buf[len] = source[slen];
-                               --len;
-                       }
-                       --slen;
-               } else {
-                       break;
-               }
-       }
-       if (len < 0)
-               len = 0;
-       strcpy(dest, &buf[len]);
-}
-
-void _bt_util_get_contact_name(int lcontact_id, char **contact_name)
-{
-       int ret = 0;
-       int count = 0;
-       contacts_filter_h filter = NULL;
-       contacts_query_h query = NULL;
-       contacts_list_h list = NULL;
-       contacts_record_h record = NULL;
-       char *name = NULL;
-
-       DBG("+");
-       ret = contacts_filter_create(_contacts_contact._uri, &filter);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to create filter for contacts");
-               goto fail;
-       }
-
-       ret = contacts_filter_add_int(filter, _contacts_contact.id,
-                       CONTACTS_MATCH_EXACTLY, lcontact_id);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to add str to filter for contacts");
-               goto fail;
-       }
-
-       ret = contacts_query_create(_contacts_contact._uri, &query);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to create qurey for contacts");
-               goto fail;
-       }
-
-       ret = contacts_query_set_filter(query, filter);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to set filter for contacts");
-               goto fail;
-       }
-
-       ret = contacts_db_get_count_with_query(query, &count);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to get count from db");
-               goto fail;
-       }
-
-       if (count < 1) {
-               DBG("No match");
-               goto fail;
-       }
-       DBG("count = %d", count);
-       ret = contacts_db_get_records_with_query(query, 0, 0, &list);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to get records from db");
-               goto fail;
-       }
-       contacts_list_first(list);
-
-       while (ret == CONTACTS_ERROR_NONE) {
-               contacts_list_get_current_record_p(list, &record);
-               contacts_record_get_str_p(record,
-                               _contacts_contact.display_name,
-                               &name);
-               if (name != NULL) {
-                       *contact_name = g_strdup(name);
-                       break;
-               }
-
-               ret = contacts_list_next(list);
-       }
-
-fail:
-       if (filter)
-               contacts_filter_destroy(filter);
-
-       if (query)
-               contacts_query_destroy(query);
-
-       if (list)
-               contacts_list_destroy(list, true);
-       DBG("-");
-       return;
-}
-
-unsigned int bt_crc32(const void *src, unsigned long src_sz)
-{
-       return (crc32(0, src, src_sz) & 0xFFFF);
-}
-
-void _bt_util_get_contact_info(unsigned char *auth_info, int *contact_id, char **contact_name)
-{
-       unsigned int shash = 0;
-       unsigned int chash = 0;
-       char pnumber[20] = {0,};
-       char str_hash[7] = {0,};
-       int ret = CONTACTS_ERROR_NONE;
-       char *number = NULL;
-       int lcontact_id = 0;
-       int count = 0;
-
-       contacts_filter_h filter = NULL;
-       contacts_query_h query = NULL;
-       contacts_list_h list = NULL;
-       contacts_record_h record = NULL;
-
-       retm_if(!auth_info, "auth_info is NULL");
-       retm_if(!contact_id, "contact_id is NULL");
-       retm_if(!contact_name, "contact_name is NULL");
-       DBG("+");
-       if (contacts_connect() != CONTACTS_ERROR_NONE) {
-               ERR("contacts_connect failed");
-               return;
-       }
-
-       memcpy(&shash, auth_info, 3);
-       shash = ntohl(shash);
-       shash >>= 8;
-
-       memcpy(&chash, &auth_info[3], 2);
-       chash = ntohl(chash);
-       chash >>= 16;
-
-       g_snprintf(str_hash, 7, "%X", shash);
-
-#if 0
-       ret = contacts_filter_create(_contacts_quick_connect_info._uri, &filter);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to create filter for contacts");
-               goto fail;
-       }
-
-       ret = contacts_filter_add_str(filter, _contacts_quick_connect_info.hash,
-                       CONTACTS_MATCH_EXACTLY, str_hash);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to add str to filter for contacts");
-               goto fail;
-       }
-
-       ret = contacts_query_create(_contacts_quick_connect_info._uri, &query);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to create qurey for contacts");
-               goto fail;
-       }
-#endif
-
-       ret = contacts_query_set_filter(query, filter);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to set filter for contacts");
-               goto fail;
-       }
-
-       ret = contacts_db_get_count_with_query(query, &count);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to get count from db");
-               goto fail;
-       }
-
-       if (count < 1) {
-               DBG("No match");
-               goto fail;
-       }
-
-       ret = contacts_db_get_records_with_query(query, 0, 0, &list);
-       if (ret != CONTACTS_ERROR_NONE) {
-               ERR("Fail to get records from db");
-               goto fail;
-       }
-
-       contacts_list_first(list);
-
-       while (ret == CONTACTS_ERROR_NONE) {
-               contacts_list_get_current_record_p(list, &record);
-#if 0
-               contacts_record_get_str_p(record,
-                               _contacts_quick_connect_info.number,
-                               &number);
-#endif
-               DBG_SECURE("number: [%s]", number);
-               if (number != NULL) {
-                       _bt_util_get_number(number, pnumber);
-                       DBG_SECURE("pnumber: [%s]", pnumber);
-
-                       DBG_SECURE("CRC [%X], [%X]", chash, bt_crc32(pnumber, strlen(pnumber)));
-
-                       if (bt_crc32(pnumber , strlen(pnumber)) == chash) {
-#if 0
-                               contacts_record_get_int(record,
-                                               _contacts_quick_connect_info.contact_id,
-                                               &lcontact_id);
-#endif
-                               *contact_id = lcontact_id;
-                               _bt_util_get_contact_name(lcontact_id, contact_name);
-                               DBG_SECURE("contact id : %d", lcontact_id);
-                               break;
-                       }
-               }
-               ret = contacts_list_next(list);
-       }
-
-fail:
-       if (filter)
-               contacts_filter_destroy(filter);
-
-       if (query)
-               contacts_query_destroy(query);
-
-       if (list)
-               contacts_list_destroy(list, true);
-
-       contacts_disconnect();
-
-       DBG("-");
-}
-/* LCOV_EXCL_STOP */
-#endif
-#endif
-
-/* LCOV_EXCL_START */
-void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
-                              void *user_data)
-{
-       static int send_index = 0;
-       static gboolean is_started = FALSE;
-       static char *snd_db_sid = NULL;
-       static char *rcv_db_sid = NULL;
-       static bool is_tr_wait = true;
-       int percentage = 0;
-       int s_id = 0;
-       char *name = NULL;
-       char *opc_cnt = NULL;
-       notification_h noti = NULL;
-       bt_obex_server_authorize_into_t *auth_info = NULL;
-       bt_obex_server_transfer_info_t *transfer_info = NULL;
-       opc_transfer_info_t *node = NULL;
-       bt_appdata_t *ad = app_state;
-       bt_tr_data_t *info = NULL;
-       bt_opc_transfer_info_t *client_info = NULL;
-       bt_noti_data_t *data = NULL;
-       bt_device_snd_noti_info_t *snd_noti_info = NULL;
-
-       pthread_t thread_id = 0;
-       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
-
-       if (bt_transfer_list)
-               node = bt_transfer_list->data;
-
-       switch (event) {
-       case BLUETOOTH_EVENT_ENABLED: {
-               if (ad->obex_server_init == FALSE) {
-                       if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
-                               ad->obex_server_init = TRUE;
-               }
-               break;
-       }
-       case BLUETOOTH_EVENT_DISABLED: {
-               INFO("BT is disabled");
-               _bt_terminate_bluetooth_share();
-               break;
-       }
-       case BLUETOOTH_EVENT_OPC_CONNECTED: {
-               INFO("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d]", param->result);
-               ret_if(node == NULL);
-
-               send_index = 0;
-               is_started = FALSE;
-               is_tr_wait = true;
-
-               _bt_get_pending_list(ad);
-
-               retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
-
-               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-               retm_if(info == NULL, "info is NULL");
-
-               snd_db_sid = info->db_sid;
-               DBG_SECURE("snd_db_sid = [%s]", snd_db_sid);
-
-               _bt_convert_addr_type_to_string(bd_addr, info->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
-
-               INFO("New device %s", node->name);
-
-               snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
-               memcpy(snd_noti_info->device_name, node->name,
-                                       BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
-               memcpy(snd_noti_info->address,
-                               info->addr, BT_ADDRESS_STRING_SIZE);
-               snd_noti_info->db_sid = g_strdup(snd_db_sid);
-               snd_noti_info->send_noti = NULL;
-               snd_noti_info->send_data.tr_success = 0;
-               snd_noti_info->send_data.tr_fail = 0;
-               bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
-
-               if (param->result != BLUETOOTH_ERROR_NONE) {
-                       _bt_create_warning_popup(param->result,
-                               BT_STR_UNABLE_TO_SEND);
-                       if (node->file_cnt > send_index) {
-                               int *uids;
-                               int uid_cnt = 0;
-
-                               s_id = info->sid;
-                               INFO("info->sid = %d info->id = %d", info->sid, info->id);
-                               uids = g_malloc0(node->file_cnt * sizeof(int));
-
-                               while (ad->tr_next_data != NULL) {
-                                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                                       if (info == NULL)
-                                               break;
-                                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
-                                       if (info->sid != s_id) {
-                                               DBG("SID did not match so break done.");
-                                               break;
-                                       }
-
-                                       uids[uid_cnt++] = info->id;
-                                       snd_noti_info->send_data.tr_fail++;
-                                       ad->tr_next_data = g_slist_next(ad->tr_next_data);
-                               }
-                               _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
-                                                               snd_noti_info->db_sid);
-                               _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
-
-                               if (snd_noti_info->send_noti == NULL) {
-                                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                                       snd_noti_info->send_noti = _bt_insert_notification(
-                                               ad, BT_SENT_NOTI, snd_noti_info->device_name,
-                                               snd_noti_info->address, snd_noti_info->db_sid);
-                               } else {
-                                       ad->send_noti = snd_noti_info->send_noti;
-                                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                                       _bt_update_notification(ad, ad->send_noti, NULL, NULL,
-                                                                       NULL, NULL, NULL);
-                               }
-                               /* Update Database with Notification ID*/
-                               __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
-                                               snd_noti_info->db_sid);
-                               g_free(uids);
-                       }
-
-                       __bt_free_snd_notification(snd_noti_info);
-                       _remove_transfer_info(node);
-
-                       if (!ad->tr_next_data) {
-                               bt_share_release_tr_data_list(ad->tr_send_list);
-                               ad->tr_send_list = NULL;
-                       }
-
-               } else {
-                       _bt_insert_instant_notification(BT_SENDING_NOTI);
-
-                       if (ad->opc_noti) {
-                               _bt_delete_notification(ad->opc_noti);
-                               ad->opc_noti = NULL;
-                               ad->opc_noti_id = 0;
-                       }
-
-                       noti = _bt_insert_notification(ad,
-                                               BT_SENDING_NOTI, node->name,
-                                               node->addr, info->db_sid);
-                       ad->opc_noti = noti;
-                       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
-
-                       _bt_share_block_sleep(TRUE);
-                       _bt_set_transfer_indicator(TRUE);
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: {
-               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
-               ret_if(node == NULL);
-               retm_if(!ad, "ad is NULL");
-               retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
-
-               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-               ret_if(info == NULL);
-
-               is_started = TRUE;
-
-               if (send_index > 0 && is_tr_wait == true)
-                       is_tr_wait = false;
-
-               name = __get_file_name(send_index++, node->file_path);
-
-               if (node->file_cnt > 1)
-                       opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
-
-               INFO("file count %d", node->file_cnt);
-               _bt_convert_addr_type_to_string(bd_addr, node->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
-
-               if (node->file_cnt > 1)
-                       _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
-                                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
-                                       name, *(node->size), opc_cnt, 0);
-               else
-                       _bt_set_notification_app_launch(ad->opc_noti, node->name, bd_addr,
-                                       info->db_sid, CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
-                                       name, *(node->size), "[1/1]", 0);
-
-               _bt_update_sent_data_status(info->id, BT_TR_ONGOING, info->db_sid);
-               _bt_update_transfer_list_view("outbound");
-
-               if (ad->opc_noti && is_tr_wait == false) {
-                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
-                       _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
-                       _bt_update_notification_progress(NULL, ad->opc_noti_id, 0);
-               }
-
-               g_free(opc_cnt);
-               retm_if(ad->tr_next_data == NULL, "ad->tr_next_data is NULL");
-
-               ad->current_tr_uid = info->id;
-               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: {
-               client_info = (bt_opc_transfer_info_t *)param->param_data;
-               ret_if(client_info == NULL);
-               ret_if(node == NULL);
-
-               percentage = client_info->percentage;
-               name =  strrchr(client_info->filename, '/');
-               if (name)
-                       name++;
-               else
-                       name = client_info->filename;
-
-               if (ad->opc_noti) {
-                       if (is_tr_wait == true) {
-                               char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
-
-                               if (node->file_cnt > 1)
-                                       opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
-
-                               _bt_update_notification(ad, ad->opc_noti, name, sending_files,
-                                               node->name, NULL, opc_cnt);
-
-                               g_free(opc_cnt);
-                               is_tr_wait = false;
-                       }
-                       _bt_update_notification_progress(NULL, ad->opc_noti_id, percentage);
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: {
-               INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
-               ret_if(node == NULL);
-
-               if (!is_started) {
-                       INFO("TRANSFER operation abnormal. It is completed without TRANSFER START");
-                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                       ret_if(info == NULL);
-                       ad->current_tr_uid = info->id;
-                       INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
-                       send_index++;
-               }
-
-               is_started = FALSE;
-
-               client_info = (bt_opc_transfer_info_t *)param->param_data;
-               ret_if(client_info == NULL);
-
-               DBG_SECURE("client_info->filename = [%s]", client_info->filename);
-               INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
-
-               name =  strrchr(client_info->filename, '/');
-               if (name)
-                       name++;
-               else
-                       name = client_info->filename;
-
-               if (ad->opc_noti && is_tr_wait == true) {
-                       char *sending_files = "IDS_WIFI_BODY_SENDING_FILES_TO_PS_ING";
-
-                       if (node->file_cnt > 1)
-                               opc_cnt = g_strdup_printf("[%d/%d]", send_index, node->file_cnt);
-
-                       _bt_update_notification(ad, ad->opc_noti, name, sending_files, node->name, NULL, opc_cnt);
-                       g_free(opc_cnt);
-                       is_tr_wait = false;
-               }
-
-               DBG("name address = [%s]", name);
-
-               _bt_convert_addr_type_to_string(bd_addr, node->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
-
-               snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
-               if (snd_noti_info == NULL) {
-                       INFO("New device %s", node->name);
-
-                       snd_noti_info = g_new0(bt_device_snd_noti_info_t, 1);
-                       memcpy(snd_noti_info->device_name, node->name,
-                                               BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
-                       memcpy(snd_noti_info->address, bd_addr,
-                                               BT_ADDRESS_STRING_SIZE);
-                       snd_noti_info->db_sid = g_strdup(snd_db_sid);
-                       snd_noti_info->send_noti = NULL;
-                       snd_noti_info->send_data.tr_success = 0;
-                       snd_noti_info->send_data.tr_fail = 0;
-                       bt_snd_noti_info_list = g_slist_append(bt_snd_noti_info_list, snd_noti_info);
-               }
-               INFO("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d",
-                       ad->send_data.tr_fail, ad->send_data.tr_success);
-
-               if (param->result != BLUETOOTH_ERROR_NONE)
-                       snd_noti_info->send_data.tr_fail++;
-               else {
-                       snd_noti_info->send_data.tr_success++;
-                       _bt_remove_tmp_file(client_info->filename);
-                       _bt_remove_vcf_file(client_info->filename);
-                       _bt_update_notification_progress(NULL, ad->opc_noti_id, 100);
-               }
-
-               if (param->result == BLUETOOTH_ERROR_NOT_FOUND) {
-                       ERR("File Doesn't exist. ");
-                       _bt_update_sent_data_status(ad->current_tr_uid,
-                                                       BT_TR_FAIL, snd_noti_info->db_sid);
-               } else if (param->result != BLUETOOTH_ERROR_NONE) {
-                       _bt_update_sent_data_status(ad->current_tr_uid,
-                                                       BT_TR_FAIL, snd_noti_info->db_sid);
-                       ERR("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
-
-                       if (!ad->opp_transfer_abort)
-                               _bt_create_warning_popup(param->result,
-                                       BT_STR_UNABLE_TO_SEND);
-
-                       ad->opp_transfer_abort = FALSE;
-               } else {
-                       _bt_update_sent_data_status(ad->current_tr_uid,
-                                                       BT_TR_SUCCESS, snd_noti_info->db_sid);
-               }
-
-               _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
-
-               ad->tr_next_data = g_slist_next(ad->tr_next_data);
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OPC_DISCONNECTED: {
-               INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED");
-               ret_if(node == NULL);
-
-               if (ad->opc_noti) {
-                       _bt_delete_notification(ad->opc_noti);
-                       ad->opc_noti = NULL;
-                       ad->opc_noti_id = 0;
-               }
-
-               _bt_convert_addr_type_to_string(bd_addr, node->addr);
-               DBG_SECURE("bd_addr = [%s]", bd_addr);
-
-               snd_noti_info = __bt_get_snd_noti_data_by_device_address(bd_addr);
-
-               if (snd_noti_info == NULL) {
-                       ERR("snd_noti_info == NULL, this shouldn't happen");
-                       goto done;
-               }
-
-               if (node->file_cnt > send_index) {
-                       int *uids;
-                       int uid_cnt = 0;
-                       send_index = 0;
-                       is_started = FALSE;
-                       retm_if(!ad->tr_next_data, "ad>tr_next_data is NULL");
-
-                       info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                       if (info == NULL) {
-                               /* Send Disconnect to Share-UI */
-                               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
-                                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
-                               break;
-                       }
-
-                       s_id = info->sid;
-                       INFO("info->sid = %d info->id = %d", info->sid, info->id);
-                       uids = g_malloc0(node->file_cnt * sizeof(int));
-
-                       while (NULL != ad->tr_next_data) {
-                               info = (bt_tr_data_t *)(ad->tr_next_data)->data;
-                               if (info == NULL)
-                                       break;
-                               INFO("info->sid = %d info->id = %d", info->sid, info->id);
-
-                               if (s_id != info->sid) {
-                                       DBG("SID did not match so break done.");
-                                       break;
-                               }
-
-                               uids[uid_cnt++] = info->id;
-                               snd_noti_info->send_data.tr_fail++;
-                               ad->tr_next_data = g_slist_next(ad->tr_next_data);
-                       }
-                       _bt_update_multiple_sent_data_status(uids, uid_cnt, BT_TR_FAIL,
-                                                               snd_noti_info->db_sid);
-                       ad->send_noti = snd_noti_info->send_noti;
-                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                       g_free(uids);
-               }
-
-               if (snd_noti_info->send_noti == NULL) {
-                       ad->send_data.tr_success = snd_noti_info->send_data.tr_success;
-                       ad->send_data.tr_fail = snd_noti_info->send_data.tr_fail;
-                       snd_noti_info->send_noti = _bt_insert_notification(ad,
-                               BT_SENT_NOTI, snd_noti_info->device_name,
-                               snd_noti_info->address, snd_noti_info->db_sid);
-               }
-
-               if (snd_noti_info->send_data.tr_success)
-                       _bt_insert_instant_notification(BT_SENT_NOTI);
-               else
-                       _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
-
-               /* Update Database with Notification ID*/
-               __bt_update_db_with_noti_id(BT_DB_OUTBOUND, snd_noti_info->send_noti,
-                               snd_noti_info->db_sid);
-done:
-               /* Send Disconnect to Share-UI */
-               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
-                               BLUETOOTH_ERROR_NONE, bd_addr, 0);
-
-               send_index = 0;
-               is_started = FALSE;
-               __bt_free_snd_notification(snd_noti_info);
-               _bt_share_block_sleep(FALSE);
-               _bt_set_transfer_indicator(FALSE);
-               _remove_transfer_info(node);
-               if (!ad->tr_next_data) {
-                       bt_share_release_tr_data_list(ad->tr_send_list);
-                       ad->tr_send_list = NULL;
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE");
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: {
-               INFO("BT_EVENT_OBEX_TRANSFER_AUTHORIZE");
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       g_free(server_auth_info.filename);
-                       g_free(server_auth_info.name);
-                       server_auth_info.filename = NULL;
-                       server_auth_info.name = NULL;
-
-                       auth_info = param->param_data;
-                       server_auth_info.filename = g_strdup(auth_info->filename);
-                       server_auth_info.length = auth_info->length;
-                       server_auth_info.name = g_strdup(auth_info->name);
-
-                       if (server_auth_info.filename)
-                               __bt_obex_file_push_auth(&server_auth_info);
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED");
-               bt_device_rcv_noti_info_t *rcv_noti_info = NULL;
-
-               rcv_db_sid = _bt_get_time_of_the_day();
-
-               DBG_SECURE("rcv_db_sid = [%s]", rcv_db_sid);
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       bt_obex_server_connection_info_t *conn_info = param->param_data;
-                       DBG_SECURE("Address[%s] DeviceName[%s] TransferID[%d]",
-                                       conn_info->address, conn_info->device_name,
-                                       conn_info->transfer_id);
-
-                       rcv_noti_info =
-                               __bt_get_rcv_noti_data_by_device_address(conn_info->address);
-                       if (rcv_noti_info == NULL) {
-                               INFO("New device %s", conn_info->device_name);
-
-                               rcv_noti_info = g_new0(bt_device_rcv_noti_info_t, 1);
-                               rcv_noti_info->id = -1;
-                               rcv_noti_info->address = g_strdup(conn_info->address);
-                               rcv_noti_info->device_name = g_strdup(conn_info->device_name);
-                               rcv_noti_info->db_sid = g_strdup(rcv_db_sid);
-                               rcv_noti_info->recv_data.tr_success = -1;
-                               rcv_noti_info->recv_data.tr_fail = -1;
-                               bt_rcv_noti_info_list = g_slist_append(bt_rcv_noti_info_list, rcv_noti_info);
-                       }
-
-                       /* Insert Notification */
-                       /* TODO: Need to distinguish between GET or PUT request and show Receiving or Sending */
-                       noti = _bt_insert_notification(ad,
-                                       BT_RECEIVING_NOTI,
-                                       rcv_noti_info->device_name,
-                                       rcv_noti_info->address,
-                                       rcv_noti_info->db_sid);
-
-                       /* Save notification handle & ID and Transfer ID*/
-                       data = g_new0(bt_noti_data_t, 1);
-                       data->noti_handle = noti;
-                       data->noti_id = _bt_get_notification_priv_id(noti);
-                       data->transfer_id = conn_info->transfer_id;
-                       bt_receive_noti_list = g_slist_append(bt_receive_noti_list, data);
-
-
-                       isTransferConnectedReceived = TRUE;
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
-               transfer_info = param->param_data;
-               unsigned int file_size = 0;
-               char *contact_name = NULL;
-               bt_device_rcv_noti_info_t *rcv_noti_info =
-                       __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
-               data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
-               int current_file;
-
-               retm_if(data == NULL || rcv_noti_info == NULL, "Notification data NULL");
-
-               if (rcv_noti_info->recv_data.tr_success == -1 &&
-                               rcv_noti_info->recv_data.tr_fail == -1) {
-                       current_file = 1;
-               } else {
-                       current_file = rcv_noti_info->recv_data.tr_success +
-                                       rcv_noti_info->recv_data.tr_fail + 1;
-               }
-
-               opc_cnt = g_strdup_printf("[%d/All]", current_file);
-
-               if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
-                       /*GET request */
-                       _bt_set_notification_app_launch(noti,
-                                       transfer_info->device_name,
-                                       transfer_info->address,
-                                       rcv_db_sid,
-                                       CREATE_PROGRESS,
-                                       NOTI_TR_TYPE_OUT,
-                                       transfer_info->filename,
-                                       transfer_info->file_size, NULL,
-                                       transfer_info->transfer_id);
-               } else {
-                       /*PUT Request */
-                       _bt_add_recv_transfer_status_data(transfer_info->device_name,
-                                       transfer_info->address, transfer_info->filename, NULL,
-                                       file_size, BT_TR_ONGOING, rcv_noti_info->db_sid);
-                       rcv_noti_info->id = _bt_share_get_unique_id(BT_DB_INBOUND,
-                                       rcv_noti_info->db_sid);
-                       _bt_update_transfer_list_view(BT_INBOUND_TABLE);
-
-                       _bt_set_notification_app_launch(data->noti_handle,
-                                       transfer_info->device_name, transfer_info->address,
-                                       rcv_noti_info->db_sid, CREATE_PROGRESS,
-                                       NOTI_TR_TYPE_IN, transfer_info->filename,
-                                       transfer_info->file_size, NULL,
-                                       transfer_info->transfer_id);
-               }
-
-#ifdef ENABLE_CONTACTS_SERVICE2
-#if 0
-               int contact_id = -1;
-
-               if (transfer_info->contact_auth_info) {
-                       unsigned char auth_info_null[5];
-                       memset(auth_info_null, 0X0, 5);
-                       if (memcmp(transfer_info->contact_auth_info, auth_info_null, 5)) {
-                               _bt_util_get_contact_info(transfer_info->contact_auth_info, &contact_id, &contact_name);
-                               DBG_SECURE("contact_id: %d | contact_name: [%s]", contact_id, contact_name);
-                       }
-               }
-#endif
-#endif
-               char *receiving_files = "IDS_WIFI_BODY_RECEIVING_FILES_FROM_PS_ING";
-
-               INFO("Notification data: %p", data);
-               if (data) {
-                       _bt_update_notification(ad, data->noti_handle,
-                               transfer_info->filename, receiving_files,
-                               transfer_info->device_name, NULL, opc_cnt);
-                       _bt_update_notification_progress(data->noti_handle,
-                                       data->noti_id, 0);
-               }
-
-               _bt_set_transfer_indicator(TRUE);
-               _bt_share_block_sleep(TRUE);
-               g_free(opc_cnt);
-               g_free(contact_name);
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: {
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       transfer_info = param->param_data;
-                       data = __bt_get_noti_data_by_transfer_id(
-                                               transfer_info->transfer_id);
-                       retm_if(data == NULL, "Data is NULL, returning");
-
-                       if (data && data->noti_id)
-                               _bt_update_notification_progress(
-                                               data->noti_handle,
-                                               data->noti_id,
-                                               transfer_info->percentage);
-                       else
-                               DBG("noti_id is not exist!");
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED");
-               char mime_type[BT_MIME_TYPE_MAX_LEN] = {0, };
-               unsigned int file_size = 0;
-               struct stat file_attr;
-               char *file_path = NULL;
-               transfer_info = param->param_data;
-               _bt_set_transfer_indicator(FALSE);
-               _bt_share_block_sleep(FALSE);
-
-               data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id);
-
-               if (g_strcmp0(transfer_info->type, TRANSFER_PUT) == 0) {
-                       INFO("TRANSFER_PUT");
-
-                       bt_device_rcv_noti_info_t *rcv_noti_info =
-                               __bt_get_rcv_noti_data_by_device_address(transfer_info->address);
-
-                       if (rcv_noti_info == NULL)
-                               break;
-
-                       file_path = __get_dest_file_path(transfer_info->file_path);
-                       DBG_SECURE("Filename[%s] FilePath[%s] Address[%s]",
-                                       transfer_info->filename, file_path,
-                                       transfer_info->address);
-
-                       if (aul_get_mime_from_file(file_path, mime_type,
-                                       BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
-                               DBG_SECURE("mime type : %s", mime_type);
-
-                       if (g_utf8_validate(file_path, -1, NULL)) {
-                               if (stat(file_path, &file_attr) == 0)
-                                       file_size = file_attr.st_size;
-                               else
-                                       file_size = 0;
-                       }
-
-                       g_free(file_path);
-
-                       if (rcv_noti_info->recv_data.tr_success == -1 &&
-                                       rcv_noti_info->recv_data.tr_fail == -1) {
-                               rcv_noti_info->recv_data.tr_success = 0;
-                               rcv_noti_info->recv_data.tr_fail = 0;
-                       }
-
-                       if (param->result != BLUETOOTH_ERROR_NONE) {
-                               rcv_noti_info->recv_data.tr_fail++;
-                               _bt_update_recv_data_status(rcv_noti_info->id,
-                                                       BT_TR_FAIL, rcv_noti_info->db_sid,
-                                                       file_size, mime_type);
-                       } else {
-                               rcv_noti_info->recv_data.tr_success++;
-                               _bt_update_recv_data_status(rcv_noti_info->id,
-                                                       BT_TR_SUCCESS, rcv_noti_info->db_sid,
-                                                       file_size, mime_type);
-                               if (data)
-                                       _bt_update_notification_progress(data->noti_handle,
-                                                       data->noti_id, 100);
-                       }
-
-                       _bt_update_transfer_list_view(BT_INBOUND_TABLE);
-
-               } else if (g_strcmp0(transfer_info->type, TRANSFER_GET) == 0) {
-                       INFO("TRANSFER_GET");
-               }
-
-               if (param->result == BLUETOOTH_ERROR_NONE) {
-                       bt_file_type_e file_type;
-                       char *extn = NULL;
-                       bt_file_info_t *info = NULL;
-
-                       transfer_info = param->param_data;
-                       if (transfer_info->file_path == NULL) {
-                               ERR("File path is NULL");
-                               break;
-                       }
-
-                       if (!g_strcmp0(transfer_info->type, TRANSFER_GET)) {
-                               DBG("Transfer is GET, so no need to handle");
-                               break;
-                       }
-
-                       name = __get_dest_file_path(transfer_info->file_path);
-
-                       extn = strrchr(name, '.');
-                       if (extn != NULL)
-                               extn++;
-                       file_type = __get_file_type(extn);
-
-                       INFO("file type %d", file_type);
-
-                       if (transfer_info->server_type == FTP_SERVER ||
-                                       file_type != BT_FILE_VCARD) {
-                               if (file_type != BT_FILE_VCAL)
-                                       __bt_scan_media_file(name);
-
-                               if (file_type != BT_FILE_VCARD)
-                                       __bt_move_media_file(name);
-                               else
-                                       ecore_file_remove(name);
-
-                               g_free(name);
-                               break;
-                       }
-
-                       info = g_new0(bt_file_info_t, 1);
-                       info->file_path = name;
-                       info->file_type = file_type;
-
-                       if (pthread_create(&thread_id, NULL, (void *)&__bt_obex_writeclose,
-                                                       info) < 0) {
-                               ERR("pthread_create() is failed");
-                               __free_file_info(info);
-                               break;
-                       }
-                       warn_if(pthread_detach(thread_id) < 0, "pthread_detach() is failed");
-
-               } else {
-                       DBG("param->result = %d", param->result);
-                       DBG("opp_transfer_abort by user %d ", ad->opp_transfer_abort);
-
-                       if (!ad->opp_transfer_abort)
-                               _bt_create_warning_popup(param->result,
-                                       BT_STR_UNABLE_TO_RECEIVE);
-
-                       ad->opp_transfer_abort = FALSE;
-               }
-               break;
-       }
-
-       case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED: {
-               INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED");
-               transfer_info = param->param_data;
-
-               char *address = transfer_info->address;
-               int transfer_id = transfer_info->transfer_id;
-               int ret;
-
-               DBG_SECURE("OBEX Disconnected from: %s, transfer_id: %d", address, transfer_id);
-
-               if (param->result == BLUETOOTH_ERROR_NONE)
-                       isTransferConnectedReceived = FALSE;
-
-               /* P150828-03206 : OPP connection is disconnected without completed event
-               in this case, noti should be removed in the disconnected event */
-               data = __bt_get_noti_data_by_transfer_id(transfer_id);
-
-               if (data) {
-                       DBG("delete noti in the disconnected event!");
-                       _bt_delete_notification(data->noti_handle);
-                       bt_receive_noti_list = g_slist_remove(bt_receive_noti_list, data);
-                       g_free(data);
-               }
-
-               DBG("Sending signal to bt-share-ui");
-
-               /* Send Disconnect to Share-UI */
-               _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_SERVER_DISCONNECTED,
-                               BLUETOOTH_ERROR_NONE, address, transfer_id);
-
-               bt_device_rcv_noti_info_t *rcv_noti_info =
-                               __bt_get_rcv_noti_data_by_device_address(address);
-               if (rcv_noti_info == NULL) {
-                       INFO("rcv_noti_info does not exist!");
-                       break;
-               }
-
-               ad->recv_data.tr_success = rcv_noti_info->recv_data.tr_success;
-               ad->recv_data.tr_fail = rcv_noti_info->recv_data.tr_fail;
-               DBG("SUCCESS[%d] Failed[%d]", rcv_noti_info->recv_data.tr_success, rcv_noti_info->recv_data.tr_fail);
-
-               if (rcv_noti_info->recv_data.tr_success == -1 &&
-                               rcv_noti_info->recv_data.tr_fail == -1) {
-                       __bt_free_rcv_notification(rcv_noti_info);
-                       break;
-               }
-               notification_h rcv_noti_info_receive_noti = _bt_insert_notification(ad,
-                               BT_RECEIVED_NOTI, rcv_noti_info->device_name,
-                               rcv_noti_info->address, rcv_noti_info->db_sid);
-               ad->receive_noti = rcv_noti_info_receive_noti;
-               DBG("LAUNCH DATA: Filename [%s] TransferID[%d]",
-                               transfer_info->filename, transfer_info->transfer_id);
-
-               _bt_set_notification_app_launch(rcv_noti_info_receive_noti,
-                               rcv_noti_info->device_name, rcv_noti_info->address,
-                               rcv_noti_info->db_sid, CREATE_TR_LIST,
-                               NOTI_TR_TYPE_IN, transfer_info->filename,
-                               0, NULL, transfer_info->transfer_id);
-               ret = notification_update(rcv_noti_info_receive_noti);
-               warn_if(ret != NOTIFICATION_ERROR_NONE,
-                               "Fail to notification_update [%d]", ret);
-
-               if (rcv_noti_info->recv_data.tr_success != -1) {
-                       if (rcv_noti_info->recv_data.tr_success)
-                               _bt_insert_instant_notification(BT_RECEIVED_NOTI);
-                       else
-                               _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
-
-                       /* Update Database with Notification ID*/
-                       __bt_update_db_with_noti_id(BT_DB_INBOUND, rcv_noti_info_receive_noti,
-                                       rcv_noti_info->db_sid);
-               }
-
-               __bt_free_rcv_notification(rcv_noti_info);
-               break;
-       }
-
-       default:
-               break;
-       }
-
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static gchar *__bt_get_unique_file_name(char *storage_path, char *filename)
-{
-       char temp_filepath[BT_FILE_PATH_LEN_MAX] = { 0, };
-       char temp_filename[BT_TEMP_FILE_PATH_LEN_MAX] = { 0, };
-       char *ext = NULL;
-       char *temp = NULL;
-       unsigned int seq = 1;
-
-       temp = strrchr(filename, '.');
-       if (temp != NULL) {
-               ext = temp + 1;
-               *temp = '\0';
-       }
-
-       do {
-               if (ext != NULL)
-                       snprintf(temp_filename, sizeof(temp_filename), "%s_%d.%s",
-                                       filename, seq, ext);
-               else
-                       snprintf(temp_filename, sizeof(temp_filename), "%s_%d",
-                                       filename, seq);
-
-               snprintf(temp_filepath, sizeof(temp_filepath), "%s/%s",
-                                       storage_path, temp_filename);
-
-               /* In below code check is done for unique file name or
-                  Max value of integer reached, in this case overwrite
-                  the last file */
-               if ((access(temp_filepath, F_OK) == 0) && (seq < 65536))
-                       seq++;
-               else
-                       break;
-       } while (1);
-
-       return g_strdup(temp_filename);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_app_obex_openwrite_requested(bt_obex_server_authorize_into_t
-                                                       *server_auth_info)
-{
-       ret_if(server_auth_info == NULL);
-       ret_if(server_auth_info->filename == NULL);
-
-       char temp_filename[BT_FILE_PATH_LEN_MAX] = { 0, };
-       char storage[STORAGE_PATH_LEN_MAX] = { 0, };
-       char *name = NULL;
-       GRegex *regex = NULL;
-
-       /* Check if  file is already present */
-       _bt_get_default_storage(storage);
-
-       /* For vcf file type, some device send weird filename like "telecom/pb.vcf"
-           This filename should be renamed.
-       */
-
-       regex = g_regex_new("[*\"<>;?|\\^:/]", 0, 0, NULL);
-       name = g_regex_replace(regex, server_auth_info->filename, -1, 0, "_", 0, NULL);
-
-       g_regex_unref(regex);
-       if (g_strcmp0(name, server_auth_info->filename) != 0) {
-               g_free(server_auth_info->filename);
-               server_auth_info->filename = name;
-       } else {
-               g_free(name);
-       }
-
-       snprintf(temp_filename, BT_FILE_PATH_LEN_MAX, "%s/%s",
-                   storage, server_auth_info->filename);
-       INFO("temp_filename : %s", temp_filename);
-       if (access(temp_filename, F_OK) == 0) {
-               name = server_auth_info->filename;
-
-               server_auth_info->filename = __bt_get_unique_file_name(storage,
-                                                                       name);
-
-               g_free(name);
-       }
-
-       bluetooth_obex_server_accept_authorize(server_auth_info->filename);
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t
-                                                       *server_auth_info)
-{
-       FN_START;
-
-       int val = -1;
-       gboolean ret = FALSE;
-       unsigned long long available_ext_mem_size = 0;
-       double available_int_mem_size = 0;
-
-       if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
-                       (void *)&val)) {
-               ERR("vconf error");
-               goto reject;
-       }
-
-       INFO("File Length =%ld", (long int)server_auth_info->length);
-
-       if (val == BT_DEFAULT_MEM_MMC) {
-               ret = _bt_get_available_ext_memory(&available_ext_mem_size);
-               if (ret == FALSE) {
-                       ERR("Unable to get available memory size");
-                       goto reject;
-               }
-
-               INFO("available_ext_mem_size =%llu", available_ext_mem_size);
-               if (available_ext_mem_size < server_auth_info->length) {
-                       g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT,
-                               (GSourceFunc)_bt_app_popup_memoryfull,
-                               NULL);
-                       goto reject;
-               }
-       } else {
-               if (_bt_get_available_int_memory(&available_int_mem_size) < 0) {
-                       ERR("Unable to get available memory size");
-                       goto reject;
-               }
-
-               INFO("available_int_mem_size =%llu", available_ext_mem_size);
-               if (available_int_mem_size < server_auth_info->length) {
-                       g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT,
-                               (GSourceFunc)_bt_app_popup_memoryfull,
-                               NULL);
-                       goto reject;
-               }
-       }
-
-       DBG("isTransferConnectedReceived is : %d", isTransferConnectedReceived);
-
-       if (isTransferConnectedReceived) {
-               _bt_insert_instant_notification(BT_RECEIVING_NOTI);
-               isTransferConnectedReceived = FALSE;
-       }
-
-       __bt_app_obex_openwrite_requested(server_auth_info);
-
-       FN_END;
-       return;
-
-reject:
-       bluetooth_obex_server_reject_authorize();
-
-       FN_END;
-}
-/* LCOV_EXCL_STOP */
-
-#ifdef ENABLE_CONTACTS_SERVICE2
-/* LCOV_EXCL_START */
-static bool __bt_vcard_handler(contacts_record_h record, void *user_data)
-{
-       int ret = 0;
-
-       ret = contacts_db_insert_record(record, NULL);
-       warn_if(ret != CONTACTS_ERROR_NONE,
-               "contacts_svc_insert_vcard error : %d", ret);
-
-       return true;
-}
-/* LCOV_EXCL_STOP */
-#endif /* ENABLE_CONTACTS_SERVICE2 */
-
-#ifdef ENABLE_CALENDAR_SERVICE2
-/* LCOV_EXCL_START */
-static bool __bt_vcalendar_handler(calendar_record_h record, void *user_data)
-{
-       int ret = 0;
-
-       ret = calendar_db_insert_record(record, NULL);
-       warn_if(ret != CALENDAR_ERROR_NONE,
-               "calendar_db_insert_record error : %d", ret);
-
-       return true;
-       /* LCOV_EXCL_STOP */
-}
-#endif /* ENABLE_CALENDAR_SERVICE2 */
-
-/* LCOV_EXCL_START */
-static gboolean __bt_save_v_object(char *file_path,
-                                           bt_file_type_e file_type)
-{
-       retv_if(NULL == file_path, FALSE);
-
-       DBG_SECURE("file_path = %s, file_type = %d", file_path, file_type);
-
-       switch (file_type) {
-#ifdef ENABLE_CONTACTS_SERVICE2
-       case BT_FILE_VCARD: {
-               int ret = 0;
-               ret = contacts_connect();
-               if (ret != CONTACTS_ERROR_NONE) {
-                       ERR("contacts_connect2 error = %d \n", ret);
-                       return FALSE;
-               }
-
-               ret = contacts_vcard_parse_to_contact_foreach(file_path,
-                                       __bt_vcard_handler, NULL);
-               if (ret != CONTACTS_ERROR_NONE) {
-                       ERR("[error] = %d \n", ret);
-                       ret = contacts_disconnect();
-                       if (ret != CONTACTS_ERROR_NONE)
-                               ERR("contacts_disconnect2 error = %d \n", ret);
-                       return FALSE;
-               }
-
-               ret = contacts_disconnect();
-               if (ret != CONTACTS_ERROR_NONE) {
-                       ERR("contacts_disconnect2 error = %d \n", ret);
-                       return FALSE;
-               }
-               break;
-       }
-#endif /* ENABLE_CONTACTS_SERVICE2 */
-
-#ifdef ENABLE_CALENDAR_SERVICE2
-       case BT_FILE_VCAL: {
-               int ret = 0;
-
-               ret = calendar_connect();
-               retvm_if(ret != CALENDAR_ERROR_NONE, FALSE,
-                               "calendar_connect error = %d", ret);
-
-               ret = calendar_vcalendar_parse_to_calendar_foreach(file_path,
-                                       __bt_vcalendar_handler, NULL);
-               if (ret != CALENDAR_ERROR_NONE) {
-                       ERR("[error] = %d", ret);
-                       ret = calendar_disconnect();
-                       warn_if(ret != CALENDAR_ERROR_NONE,
-                               "calendar_disconnect error = %d", ret);
-                       return FALSE;
-               }
-               ret = calendar_disconnect();
-               retvm_if(ret != CALENDAR_ERROR_NONE, FALSE,
-                               "calendar_disconnect error = %d", ret);
-               break;
-       }
-#endif /* ENABLE_CALENDAR_SERVICE2 */
-
-       default:
-               return FALSE;
-       }
-
-       return TRUE;
-}
-/* LCOV_EXCL_STOP */
-
-/* LCOV_EXCL_START */
-static void *__bt_obex_writeclose(bt_file_info_t *info)
-{
-       if (info->file_type == BT_FILE_VCAL || info->file_type == BT_FILE_VCARD) {
-               if (__bt_save_v_object(info->file_path, info->file_type) == FALSE)
-                       ERR("Unable to save vObject");
-
-               ecore_file_remove(info->file_path);
-       } else {
-               __bt_move_media_file(info->file_path);
-       }
-
-       __free_file_info(info);
-
-       return NULL;
-}
-/* LCOV_EXCL_STOP */
diff --git a/bt-share/src/org.bluetooth.share.service b/bt-share/src/org.bluetooth.share.service
deleted file mode 100644 (file)
index 600471b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.bluetooth.share
-Exec=/bin/false
-SystemdService=bluetooth-share.service
diff --git a/debian/bluetooth-share-headers.install.in b/debian/bluetooth-share-headers.install.in
deleted file mode 100644 (file)
index 8881471..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/usr/include/bluetooth-share/*
-/usr/lib/pkgconfig/*
diff --git a/debian/bluetooth-share.install.in b/debian/bluetooth-share.install.in
deleted file mode 100644 (file)
index 66423bd..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@PREFIX@/bin/*
-/opt/share/bt-ftp
-/usr/share/dbus-1/services/*.service
\ No newline at end of file
diff --git a/debian/bluetooth-share.postinst b/debian/bluetooth-share.postinst
deleted file mode 100644 (file)
index d7e918c..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-if [ ! -f /opt/dbspace/.bluetooth_trasnfer.db ]
-then
-       sqlite3 /opt/dbspace/.bluetooth_trasnfer.db 'PRAGMA journal_mode = PERSIST;
-       create table if not exists inbound (
-               id INTEGER PRIMARY KEY autoincrement,
-               tr_status INTEGER,
-               file_path TEXT,
-               dev_name TEXT,
-               timestamp INTEGER default 0,
-               addr TEXT
-       );
-       create table if not exists outbound (
-               id INTEGER PRIMARY KEY autoincrement,
-               tr_status INTEGER,
-               file_path TEXT,
-               dev_name TEXT,
-               timestamp INTEGER default 0,
-               addr TEXT
-       );
-       '
-fi
-
-# root case
-if [ ${USER} == "root" ]
-then
-       # Set vconf values with -g/-u options
-
-       # 5000 is inhouse user id
-       # do not use relative path
-
-       # For the FTP server folder
-
-       if  [ ! -e /opt/share/bt-ftp/Media ]
-       then
-               ln -s /opt/media /opt/share/bt-ftp/Media
-       fi
-
-       if  [ ! -e /opt/share/bt-ftp/SD_External ]
-       then
-               ln -s /opt/storage/sdcard /opt/share/bt-ftp/SD_External
-       fi
-
-       chown :5000 /opt/dbspace/.bluetooth_trasnfer.db
-       chown :5000 /opt/dbspace/.bluetooth_trasnfer.db-journal
-fi
-
-chmod 660 /opt/dbspace/.bluetooth_trasnfer.db
-chmod 660 /opt/dbspace/.bluetooth_trasnfer.db-journal
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644 (file)
index 2a4f3f8..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-bluetooth-share (0.0.46) unstable; urgency=low
-
-  * Tagging and Uploading package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.46
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Wed, 12 Dec 2012 10:06:29 +0900
-
-bluetooth-share (0.0.45) unstable; urgency=low
-
-  * Tagging and Uploading package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.45
-
- -- Sunil Kumar Behera <sunil.behera@samsung.com>  Wed, 28 Nov 2012 19:11:47 +0530
-
-bluetooth-share (0.0.44) unstable; urgency=low
-
-  * Change the media update method
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.44
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Mon, 26 Nov 2012 13:02:41 +0900
-
-bluetooth-share (0.0.43) unstable; urgency=low
-
-  * Modify the manifast
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.43
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Thu, 22 Nov 2012 11:28:29 +0900
-
-bluetooth-share (0.0.42) unstable; urgency=low
-
-  * Modify the manifast
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.42
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Wed, 21 Nov 2012 13:02:00 +0900
-
-bluetooth-share (0.0.41) unstable; urgency=low
-
-  * Fix the bug about notification
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.41
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Fri, 16 Nov 2012 10:51:28 +0900
-
-bluetooth-share (0.0.40) unstable; urgency=low
-
-  * Modify the notification API
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.40
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Thu, 15 Nov 2012 18:09:24 +0900
-
-bluetooth-share (0.0.39) unstable; urgency=low
-
-  * Change the contact API
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.39
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 13 Nov 2012 10:46:00 +0900
-
-bluetooth-share (0.0.38) unstable; urgency=low
-
-  * Fix the build break
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.38
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Thu, 08 Nov 2012 14:44:16 +0900
-
-bluetooth-share (0.0.37) unstable; urgency=low
-
-  * Fix the JIRA issue
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.37
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 06 Nov 2012 15:55:39 +0900
-
-bluetooth-share (0.0.36) unstable; urgency=low
-
-  * Add -pie compile option
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.36
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Wed, 31 Oct 2012 15:27:26 +0900
-
-bluetooth-share (0.0.35) unstable; urgency=low
-
-  * Fix for retry file send crash issue
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.35
-
- -- Chethan T N <chethan.tn@samsung.com>  Fri, 26 Oct 2012 17:26:55 +0530
-
-bluetooth-share (0.0.34) unstable; urgency=low
-
-  * Change directory path
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.34
-
- -- InJun Yang <injun.yang@samsung.com>  Thu, 25 Oct 2012 13:56:00 +0900
-
-bluetooth-share (0.0.33) unstable; urgency=low
-
-  * Fix the bug abt abnormal termination
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.33
-
- -- InJun Yang <injun.yang@samsung.com>  Fri, 19 Oct 2012 17:38:30 +0900
-
-bluetooth-share (0.0.32) unstable; urgency=low
-
-  * Fix the bug about OPP server
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.32
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Thu, 18 Oct 2012 09:40:09 +0900
-
-bluetooth-share (0.0.31) unstable; urgency=low
-
-  * Fix the bug about OPP server
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.31
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Fri, 12 Oct 2012 15:06:22 +0900
-
-bluetooth-share (0.0.30) unstable; urgency=low
-
-  * Change SMACK domain name
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.30
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Mon, 26 Nov 2012 14:42:28 +0900
-
-bluetooth-share (0.0.28) unstable; urgency=low
-
-  * Change SMACK domain name
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.28
-
- -- Sangki Park <sangki79.park@samsung.com>  Tue, 25 Sep 2012 10:27:55 +0900
-
-bluetooth-share (0.0.27) unstable; urgency=low
-
-  * Apply smack manifest file
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.27
-
- -- Sangki Park <sangki79.park@samsung.com>  Fri, 21 Sep 2012 10:03:02 +0900
-
-bluetooth-share (0.0.26) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.26
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 11 Sep 2012 11:05:27 +0900
-
-bluetooth-share (0.0.25) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.25
-
- -- InJun Yang <injun.yang@samsung.com>  Tue, 07 Aug 2012 12:38:33 +0900
-
-bluetooth-share (0.0.24) unstable; urgency=low
-
-  * Fix the PLM issue abt clear button of notification bar
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.24
-
- -- InJun Yang <injun.yang@samsung.com>  Fri, 20 Jul 2012 18:44:33 +0900
-
-bluetooth-share (0.0.23) unstable; urgency=low
-
-  * Tagging and upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.23
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Fri, 20 Jul 2012 13:36:44 +0900
-
-bluetooth-share (0.0.22) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.22
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 17 Jul 2012 10:27:35 +0900
-
-bluetooth-share (0.0.21) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.21
-
- -- InJun Yang <injun.yang@samsung.com>  Tue, 10 Jul 2012 19:26:52 +0900
-
-bluetooth-share (0.0.20) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.20
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 10 Jul 2012 17:55:02 +0900
-
-bluetooth-share (0.0.19) unstable; urgency=low
-
-  * Ordered by timestamp
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.19
-
- -- InJun Yang <injun.yang@samsung.com>  Tue, 10 Jul 2012 08:57:19 +0900
-
-bluetooth-share (0.0.18) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.18
-
- -- InJun Yang <injun.yang@samsung.com>  Fri, 06 Jul 2012 20:09:04 +0900
-
-bluetooth-share (0.0.17) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.17
-
- -- InJun Yang <injun.yang@samsung.com>  Wed, 20 Jun 2012 20:45:27 +0900
-
-bluetooth-share (0.0.16) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.16
-
- -- InJun Yang <injun.yang@samsung.com>  Fri, 15 Jun 2012 18:45:52 +0900
-
-bluetooth-share (0.0.15) unstable; urgency=low
-
-  * Modify the sending flow as UX guideline
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.15
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Mon, 04 Jun 2012 08:59:20 +0900
-
-bluetooth-share (0.0.14) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.14
-
- -- InJun Yang <injun.yang@samsung.com>  Tue, 29 May 2012 17:47:33 +0900
-
-bluetooth-share (0.0.13) unstable; urgency=low
-
-  * Add db script to postinst file
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.13
-
- -- InJun Yang <injun.yang@samsung.com>  Thu, 24 May 2012 13:05:43 +0900
-
-bluetooth-share (0.0.12) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.12
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Wed, 23 May 2012 12:16:47 +0900
-
-bluetooth-share (0.0.11) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.11
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 22 May 2012 09:45:06 +0900
-
-bluetooth-share (0.0.10) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.10
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Mon, 21 May 2012 11:06:30 +0900
-
-bluetooth-share (0.0.9) unstable; urgency=low
-
-  * Fix the auto activating issue
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.9
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Wed, 16 May 2012 11:36:34 +0900
-
-bluetooth-share (0.0.8) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.8
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Tue, 08 May 2012 08:56:03 +0900
-
-bluetooth-share (0.0.7) unstable; urgency=low
-
-  * Upload the package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.7
-
- -- InJun Yang <injun.yang@samsung.com>  Thu, 22 Mar 2012 16:48:32 +0900
-
-bluetooth-share (0.0.6) unstable; urgency=low
-
-  * Increase the version number to upload.
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.6
-
- -- Sunil Kumar Behera <sunil.behera@samsung.com>  Tue, 21 Feb 2012 14:09:43 +0530
-
-bluetooth-share (0.0.5) unstable; urgency=low
-
-  * FIx the spelling of API name (sessioin -> session)
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.5
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Thu, 05 Jan 2012 17:55:10 +0900
-
-bluetooth-share (0.0.4) unstable; urgency=low
-
-  * Upload package
-  * Git: slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.4
-
- -- DoHyun Pyun <dh79.pyun@samsung.com>  Fri, 30 Dec 2011 08:01:56 +0900
-
-bluetooth-share (0.0.3) unstable; urgency=low
-
-  * Upload package
-  * Git: 165.213.180.234:slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.3
-
- -- InJun Yang <injun.yang@samsung.com>  Wed, 30 Nov 2011 10:24:29 +0900
-
-bluetooth-share (0.0.2) unstable; urgency=low
-
-  * Upload package
-  * Git: 165.213.180.234:slp/pkgs/b/bluetooth-share
-  * Tag: bluetooth-share_0.0.2
-
- -- InJun Yang <injun.yang@samsung.com>  Wed, 09 Nov 2011 08:50:32 +0900
-
-bluetooth-share (0.0.1) unstable; urgency=low
-
-   * initial release
-   * Git: 165.213.180.234:slp/pkgs/b/bluetooth-share
-   * Tag: bluetooth-share_0.0.1
-
- -- Injun Yang <injun.yang@samsung.com>  Fri, 23 Sep 2011 16:17:49 +0900
diff --git a/debian/compat b/debian/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644 (file)
index a44a820..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-Source: bluetooth-share
-Section: net
-Priority: extra
-Maintainer:  Hocheol Seo <hocheol.seo@samsung.com>, DoHyun Pyun <dh79.pyun@samsung.com>, ChanYeol Park <chanyeol.park@samsung.com>, InJun Yang <injun.yang@samsung.com>, Seungyoun Ju <sy39.ju@samsung.com>
-Uploaders: Sunil Behera <sunil.behera@samsung.com>, Syam Sidhardhan <s.syam@samsung.com>
-Build-Depends: debhelper (>= 5), libbluetooth-frwk-dev, libglib2.0-dev, libdbus-1-dev, libdbus-glib-1-dev, libappcore-common-dev, dlog-dev, libappsvc-dev, libbundle-dev, libnotification-dev, libslp-calendar-dev, libcontacts-service-dev, libslp-pm-dev, libslp-sysman-dev, libx11-dev, libappcore-efl-dev, libslp-db-util-dev, libprivilege-control-dev
-Standards-Version: 3.7.2
-
-Package: bluetooth-share
-Section: application
-Provides:bluetooth-app-headers
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},libbluetooth-frwk-0, libdlog-0
-Description: Bluetooth File Share Agent
-
-Package: bluetooth-share-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-share (= ${Source-Version})
-Description: Bluetooth file share Agent (unstripped)
-
-Package: libbluetooth-share
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Bluetooth Share library
-
-Package: libbluetooth-share-dev
-Section: devel
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},dlog-dev, libdbus-glib-1-dev, libglib2.0-dev, libbluetooth-share (= ${Source-Version})
-XB-Generate-Docs: yes
-Description: Bluetooth Share
diff --git a/debian/libbluetooth-share-dev.install.in b/debian/libbluetooth-share-dev.install.in
deleted file mode 100644 (file)
index ceab20e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/usr/include/*
-/usr/lib/pkgconfig/*
diff --git a/debian/libbluetooth-share.install.in b/debian/libbluetooth-share.install.in
deleted file mode 100644 (file)
index fef5120..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/lib*
diff --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index e32bf05..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/make -f
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-PREFIX ?= /usr
-#RESDIR ?= /usr/bin/bluetooth-share/res
-#DATADIR ?= /usr/bin/bluetooth-share/data
-CFLAGS ?= -Wall -g
-LDFLAGS ?=
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-else
-       CFLAGS += -O2
-endif
-
-CFLAGS += -fpie
-LDFLAGS += -pie -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs
-
-configure: configure-stamp
-configure-stamp:
-       dh_testdir
-       # Add here commands to configure the package.
-       CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
-       cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
-       touch configure-stamp
-
-
-build: build-stamp
-
-build-stamp: configure-stamp
-       dh_testdir
-
-       # Add here commands to compile the package.
-       $(MAKE)
-       #docbook-to-man debian/bluetooth.sgml > bluetooth.1
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               cat $$f > $${f%.in}; \
-               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
-       done
-
-       touch $@
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp configure-stamp
-
-       # Add here commands to clean up after the build process.
-       -$(MAKE) clean
-
-       for f in `find $(CURDIR)/ -name "CMakeCache.txt"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "CMakeFiles"`; do \
-               rm -rf $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "cmake_install.cmake"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "Makefile"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "install_manifest.txt"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "*.edj"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
-               rm -f $${f%.in}; \
-       done
-
-       dh_clean
-
-install: build
-       dh_testdir
-       dh_testroot
-       dh_clean -k
-       dh_installdirs
-
-       # Add here commands to install the package into debian/tmp.
-       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-       mkdir -p $(CURDIR)/debian/tmp/opt/share/bt-ftp
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-#      dh_installchangelogs
-#      dh_installdocs
-#      dh_installexamples
-       dh_install --sourcedir=debian/tmp
-#      dh_installman
-       dh_link
-       dh_strip --dbg-package=bluetooth-share-dbg
-       dh_compress
-       dh_fixperms
-#      dh_perl
-       dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/packaging/bluetooth-share.changes b/packaging/bluetooth-share.changes
deleted file mode 100644 (file)
index 29ab349..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-* Wed Jun 26 2013 Victor Hakoun <victor.hakoun@eurogiciel.fr> submit/tizen/20130620.153559@1189c02
-- Fix rmplint issues
-- Replace manifest with default floor
-
index c00c25b815125046729bb1c45b1fe0dd17429162..a76fdbae7d915118498d7699ad37ccc98f8884f1 100644 (file)
@@ -1,5 +1,5 @@
 <manifest>
-        <request>
-                <domain name="_" />
-        </request>
+       <request>
+               <domain name="_" />
+       </request>
 </manifest>
index 4b54535ccecc89f18522cc36724fce5d64f8ab4b..018312b7603be3d960c45c4a0a9bd8040b8ce431 100644 (file)
@@ -10,8 +10,6 @@ Group:      Network & Connectivity/Bluetooth
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
-Source1002: libbluetooth-share.manifest
-Source1003: libbluetooth-share-devel.manifest
 Source1004: init_db.sh
 Requires(post): coreutils
 Requires(post): smack
@@ -77,7 +75,7 @@ This package is C-API test application.
 
 %prep
 %setup -q
-cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} .
+cp %{SOURCE1001} .
 
 %build
 %if 0%{?gcov:1}
@@ -127,7 +125,7 @@ cp -f packaging/init_db.sh %{buildroot}%{upgrade_data_path}
 
 %check
 %if 0%{?gcov:1}
-pushd unittest
+pushd tests
 ./run_coverage.sh
 popd
 %endif
@@ -137,39 +135,31 @@ popd
 %{TZ_COMM_DATA}/%{name}/init_db.sh
 mkdir -p %{_unitdir}/multi-user.target.wants/
 
-%post -n libbluetooth-share-devel -p /sbin/ldconfig
-
 %post -n libbluetooth-share -p /sbin/ldconfig
 
-%postun -n libbluetooth-share-devel -p /sbin/ldconfig
-
 %postun -n libbluetooth-share -p /sbin/ldconfig
 
 %files
 %manifest %{name}.manifest
-%license LICENSE
 %attr(755, network_fw, network_fw)%{TZ_COMM_DATA}/%{name}
-%defattr(-,root,root,-)
-%{_bindir}/bluetooth-share
+%{_bindir}/%{name}
 #%{_datadir}/dbus-1/system-services/org.bluetooth.share.service
 %{TZ_COMM_DATA}/%{name}/init_db.sh
-%{_unitdir}/bluetooth-share.service
-%{_unitdir}/bluetooth-share-start.service
-%{upgrade_script_path}/500.bluetooth-share_upgrade.sh
+%{_unitdir}/%{name}.service
+%{_unitdir}/%{name}-start.service
+%{upgrade_script_path}/500.%{name}_upgrade.sh
 %{upgrade_data_path}/init_db.sh
+%license LICENSE.APLv2
 
 %files -n libbluetooth-share
-%manifest libbluetooth-share.manifest
-%license LICENSE
-%defattr(-, root, root)
-%{_libdir}/libbluetooth-share-api.so.0.*
+%manifest %{name}.manifest
+%{_libdir}/*.so.*
+%license LICENSE.APLv2
 
 %files -n libbluetooth-share-devel
-%manifest libbluetooth-share-devel.manifest
-%defattr(-, root, root)
-%{_includedir}/bluetooth-share-api/bluetooth-share-api.h
-%{_libdir}/libbluetooth-share-api.so
-%{_libdir}/pkgconfig/bluetooth-share-api.pc
+%{_includedir}/%{name}-api/%{name}-api.h
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/%{name}-api.pc
 
 %if 0%{?gcov:1}
 %files gcov
diff --git a/packaging/libbluetooth-share-devel.manifest b/packaging/libbluetooth-share-devel.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
diff --git a/packaging/libbluetooth-share.manifest b/packaging/libbluetooth-share.manifest
deleted file mode 100644 (file)
index c00c25b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-        <request>
-                <domain name="_" />
-        </request>
-</manifest>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..33b4b3e
--- /dev/null
@@ -0,0 +1,70 @@
+# Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+# @author
+# @brief       Cmake for tests
+#
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+SET(TARGET_GTEST_TESTS "gtest-bluetooth-share")
+
+INCLUDE_DIRECTORIES(/usr/include)
+INCLUDE_DIRECTORIES(/usr/include/db-util)
+INCLUDE_DIRECTORIES(/usr/include/glib-2.0)
+INCLUDE_DIRECTORIES(/usr/include/bt-service)
+INCLUDE_DIRECTORIES(/usr/include/notification)
+INCLUDE_DIRECTORIES(/usr/include/storage)
+INCLUDE_DIRECTORIES(/usr/include/appfw)
+INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/app)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(INCLUDEDIR "/usr/include")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(testpkgs REQUIRED glib-2.0)
+
+SET(GTEST_TESTS_SOURCES
+bluetooth-share_test.cpp
+)
+
+SET(BLUETOOTH_SHARE_MOCK "bluetooth-share-mock")
+SET(BLUETOOTH_SHARE_MOCK_SRCS
+       mock/bluetooth-share-mock.c)
+SET(BLUETOOTH_SHARE_MOCK_CFLAGS "${CMAKE_C_FLAGS}" )
+ADD_LIBRARY(${BLUETOOTH_SHARE_MOCK} SHARED ${BLUETOOTH_SHARE_MOCK_SRCS})
+TARGET_LINK_LIBRARIES(${BLUETOOTH_SHARE_MOCK} -ldl)
+SET_TARGET_PROPERTIES(${BLUETOOTH_SHARE_MOCK} PROPERTIES
+       COMPILE_FLAGS ${BLUETOOTH_SHARE_MOCK_CFLAGS}
+)
+
+ADD_EXECUTABLE(${TARGET_GTEST_TESTS}
+       ${GTEST_TESTS_SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_GTEST_TESTS}
+       ${pkgs_LDFLAGS}
+       ${pkgs_LIBRARIES}
+       gtest
+       -L${CMAKE_SOURCE_DIR}/lib
+       -lbluetooth-share-api
+       -L${CMAKE_SOURCE_DIR}/app
+       -lbt-share
+)
+
+INSTALL(TARGETS ${TARGET_GTEST_TESTS} DESTINATION /usr/bin)
diff --git a/tests/bluetooth-share_test.cpp b/tests/bluetooth-share_test.cpp
new file mode 100644 (file)
index 0000000..7191ac4
--- /dev/null
@@ -0,0 +1,630 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file        bluetooth-share_test.cpp
+ * @author      abc
+ * @version     1.0
+ * @brief       Unit-tests setup
+ */
+
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.h>
+#include <syspopup_caller.h>
+#include "bluetooth-share-api.h"
+#include "bt-share-common.h"
+#include "bt-share-ipc.h"
+#include "bt-share-resource.h"
+#include "bt-share-main.h"
+#include "bt-share-noti-handler.h"
+#include "bt-share-notification.h"
+#include "bt-share-syspopup.h"
+#include "obex-event-handler.h"
+
+TEST(BluetoothShare_test, _bt_share_block_sleep_p) {
+       int ret = BT_SHARE_ERROR_NONE;
+
+       ret = _bt_share_block_sleep(TRUE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_share_block_sleep(TRUE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_share_block_sleep(FALSE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_share_block_sleep(FALSE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+TEST(BluetoothShare_test, _bt_share_block_sleep_n) {
+       int ret = BT_SHARE_ERROR_NONE;
+
+       ret = _bt_share_block_sleep(FALSE);
+       ASSERT_TRUE(ret == BT_SHARE_FAIL);
+}
+
+TEST(BluetoothShare_test, _bt_set_transfer_indicator_p) {
+       int ret = BT_SHARE_ERROR_NONE;
+
+       ret = _bt_set_transfer_indicator(TRUE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_set_transfer_indicator(TRUE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_set_transfer_indicator(FALSE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_set_transfer_indicator(FALSE);
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+TEST(BluetoothShare_test, _bt_remove_tmp_file_p) {
+       _bt_remove_tmp_file(BT_TMP_FILE);
+}
+
+TEST(BluetoothShare_test, _bt_remove_vcf_file_p) {
+       _bt_remove_vcf_file(BT_CONTACT_SHARE_TMP_DIR"test");
+}
+
+TEST(BluetoothShare_test, _bt_share_create_transfer_file_p) {
+       char *file = NULL;
+
+       file = _bt_share_create_transfer_file("http://www.tizen.org");
+       ASSERT_FALSE(file == NULL);
+
+       _bt_remove_tmp_file(HTML_FILE_NAME);
+       g_free(file);
+
+       file = _bt_share_create_transfer_file("Text test");
+       ASSERT_FALSE(file == NULL);
+
+       _bt_remove_tmp_file(TXT_FILE_FORMAT);
+       g_free(file);
+}
+
+TEST(BluetoothShare_test, _bt_share_create_transfer_file_n) {
+       char *file = NULL;
+
+       file = _bt_share_create_transfer_file(NULL);
+       ASSERT_TRUE(file == NULL);
+}
+
+TEST(BluetoothShare_test, _bt_get_time_of_the_day_p) {
+       char *time = NULL;
+
+       time = _bt_get_time_of_the_day();
+       ASSERT_FALSE(time == NULL);
+
+       g_free(time);
+}
+
+TEST(BluetoothShare_test, _bt_share_get_storage_path_p) {
+       char *path = NULL;
+
+       path = _bt_share_get_storage_path(BT_DEFAULT_MEM_PHONE);
+       ASSERT_FALSE(path == NULL);
+
+       g_free(path);
+
+       path = _bt_share_get_storage_path(BT_DEFAULT_MEM_MMC);
+       ASSERT_FALSE(path == NULL);
+
+       g_free(path);
+}
+
+
+TEST(BluetoothShare_test, _bt_share_get_active_uid_p) {
+       int ret = BT_SHARE_ERROR_NONE;
+       uid_t uid = 0;
+
+       ret = _bt_share_get_active_uid(&uid);
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+TEST(BluetoothShare_test, _remove_transfer_info_p) {
+       opc_transfer_info_t *data = NULL;
+
+       data = g_new0(opc_transfer_info_t, 1);
+       data->content = g_new0(char *, 1);
+       data->file_path = g_new0(char *, 1);
+       data->file_cnt = 1;
+       data->type = g_new0(char *, 1);
+       data->size = (unsigned int *)g_new0(unsigned int *, 1);
+
+       _remove_transfer_info(data);
+}
+
+TEST(BluetoothShare_test, _bt_init_dbus_signal_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_init_dbus_signal();
+
+       ASSERT_TRUE(ret == TRUE);
+
+       _bt_deinit_dbus_signal();
+}
+
+
+TEST(BluetoothShare_test, _bt_send_disconnected_signal_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_init_dbus_signal();
+
+       ASSERT_TRUE(ret == TRUE);
+
+       _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
+                                                       BLUETOOTH_ERROR_NONE, "BT address", 0);
+
+       _bt_deinit_dbus_signal();
+}
+
+TEST(BluetoothShare_test, _bt_update_transfer_list_view_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_init_dbus_signal();
+
+       ASSERT_TRUE(ret == TRUE);
+
+       _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+
+       _bt_deinit_dbus_signal();
+}
+
+
+TEST(BluetoothShare_test, _bt_create_warning_popup_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_init_dbus_signal();
+
+       ASSERT_TRUE(ret == TRUE);
+
+       _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
+
+       _bt_deinit_dbus_signal();
+}
+
+TEST(BluetoothShare_test, _bt_update_sent_data_status_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_update_sent_data_status(1, BT_TR_ONGOING, "1");
+
+       ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothShare_test, _bt_update_recv_data_status_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_update_recv_data_status(1, BT_TR_FAIL, "1", 100, "text/vcard");
+
+       ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothShare_test, _bt_update_multiple_sent_data_status_p) {
+       gboolean ret = FALSE;
+
+       int uids[2] = { 1, 2};
+
+       ret = _bt_update_multiple_sent_data_status(uids, 1, BT_TR_FAIL, "1");
+
+       ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothShare_test, _bt_add_recv_transfer_status_data_p) {
+       gboolean ret = FALSE;
+
+       ret = _bt_add_recv_transfer_status_data("NAME",
+                                       "ADDRESS", "FILE NAME", "TYPE",
+                                       100, BT_TR_ONGOING, "1");
+
+       ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothShare_test, _bt_share_get_unique_id_p) {
+       int id;
+
+       id = _bt_share_get_unique_id(BT_DB_INBOUND,     "1");
+
+       ASSERT_FALSE(id < 0);
+}
+
+TEST(BluetoothShare_test, _bt_set_eventsystem_transfer_value_p) {
+       int ret = BT_SHARE_ERROR_NONE;
+
+       ret = _bt_set_eventsystem_transfer_value(TRUE);
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+}
+
+TEST(BluetoothShare_test, _bt_terminate_bluetooth_share_p) {
+       _bt_terminate_bluetooth_share();
+}
+
+
+TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p) {
+       sqlite3 *db = NULL;
+
+       db = bt_share_open_db();
+
+       _bt_remove_temporary_files_by_noti_id(db, 1);
+
+       bt_share_close_db(db);
+}
+
+TEST(BluetoothShare_test, _bt_init_obex_server_p) {
+       int ret = BT_SHARE_ERROR_NONE;
+
+       ret = _bt_init_obex_server();
+
+       /* bluetooth-share process already allocate the obex serivce, so will return the error */
+       /* ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE); */
+}
+
+TEST(BluetoothShare_test, _bt_init_vconf_notification_p) {
+       _bt_init_vconf_notification(NULL);
+
+       _bt_deinit_vconf_notification();
+}
+
+TEST(BluetoothShare_test, _bt_insert_instant_notification_p) {
+       _bt_insert_instant_notification(BT_SENT_NOTI);
+
+       _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
+
+       _bt_insert_instant_notification(BT_SENDING_NOTI);
+
+       _bt_insert_instant_notification(BT_RECEIVED_NOTI);
+
+       _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
+
+       _bt_insert_instant_notification(BT_RECEIVING_NOTI);
+}
+
+TEST(BluetoothShare_test, _bt_notification_test_p) {
+       bt_appdata_t *ad = NULL;
+
+       notification_h noti = NULL;
+
+       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
+
+
+       noti = _bt_insert_notification(ad,
+                                                       BT_SENDING_NOTI, "TEST",
+                                                       "test address", "1");
+
+       if (noti == NULL)
+               g_free(ad);
+
+       ASSERT_FALSE(noti == NULL);
+
+       ad->send_noti = noti;
+       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
+
+       _bt_set_notification_app_launch(noti, "TEST", "test address", "1",
+                                       CREATE_TR_LIST, NOTI_TR_TYPE_OUT, NULL, 0, NULL, 0);
+
+       _bt_update_notification(ad, ad->send_noti,
+                                                       NULL, NULL, NULL, NULL, NULL);
+
+       _bt_delete_notification(noti);
+       ad->send_noti = NULL;
+
+       noti = _bt_insert_notification(ad,
+                                                       BT_RECEIVED_NOTI, "TEST",
+                                                       "test address", "1");
+
+       if (noti == NULL)
+               g_free(ad);
+
+       ASSERT_FALSE(noti == NULL);
+
+       ad->receive_noti = noti;
+
+       _bt_update_notification(ad, ad->receive_noti,
+                                                       NULL, NULL, NULL, NULL, NULL);
+
+       _bt_delete_notification(noti);
+       ad->receive_noti = NULL;
+
+       noti = _bt_insert_notification(ad,
+                                                       BT_SENDING_NOTI, "TEST",
+                                                       "test address", "1");
+
+       if (noti == NULL)
+               g_free(ad);
+
+       ASSERT_FALSE(noti == NULL);
+
+       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
+
+       _bt_set_notification_app_launch(noti, "TEST", "test address",
+                                               "1", CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
+                                               "TEST", 0, NULL, 1);
+
+       _bt_update_notification_progress(noti, ad->opc_noti_id, 100);
+
+       _bt_delete_notification(noti);
+
+       noti = _bt_insert_notification(ad,
+                                                       BT_RECEIVING_NOTI, "TEST",
+                                                       "test address", "1");
+
+       if (noti == NULL)
+               g_free(ad);
+
+       ASSERT_FALSE(noti == NULL);
+
+       _bt_delete_notification(noti);
+}
+
+
+TEST(BluetoothShare_test, _bt_register_notification_cb_p) {
+       _bt_register_notification_cb(NULL);
+
+       _bt_unregister_notification_cb(NULL);
+}
+
+TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
+       bt_app_sys_popup_params_t popup_params = { NULL };
+       int ret = BT_SHARE_ERROR_NONE;
+       bt_appdata_t *ad = NULL;
+
+       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
+
+       popup_params.title = BT_STR_MEMORY_FULL;
+       popup_params.type = "none";
+
+       ret = _bt_launch_system_popup(BT_APP_EVENT_CONFIRM_MODE_REQUEST,
+                               &popup_params, NULL, ad);
+
+       if (ret != BT_SHARE_ERROR_NONE)
+               g_free(ad);
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       syspopup_destroy_all();
+       usleep(1000 * 200);
+
+       ret = _bt_launch_system_popup(BT_APP_EVENT_FILE_RECEIVED,
+                               &popup_params, NULL, ad);
+
+       syspopup_destroy_all();
+       usleep(1000 * 200);
+
+       if (ret != BT_SHARE_ERROR_NONE)
+               g_free(ad);
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
+                       &popup_params, NULL, ad);
+
+       if (ret != BT_SHARE_ERROR_NONE)
+               g_free(ad);
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       syspopup_destroy_all();
+       usleep(1000 * 200);
+
+       ret = _bt_launch_system_popup(BT_APP_EVENT_OVERWRITE_REQUEST,
+                               &popup_params, NULL, ad);
+
+       if (ret != BT_SHARE_ERROR_NONE)
+               g_free(ad);
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       syspopup_destroy_all();
+       usleep(1000 * 200);
+}
+
+TEST(BluetoothShare_test, _bt_app_popup_memoryfull_p) {
+       _bt_app_popup_memoryfull(NULL);
+}
+
+TEST(BluetoothShare_test, _bt_convert_addr_type_to_string_p) {
+       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
+       char addr[BT_ADDRESS_LENGTH] = {0, };
+
+       addr[0] = '1';
+       addr[1] = '1';
+       addr[2] = '1';
+       addr[3] = '1';
+       addr[4] = '1';
+       addr[5] = '1';
+
+       _bt_convert_addr_type_to_string(bd_addr, addr);
+}
+
+TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p) {
+       bt_appdata_t *ad = NULL;
+
+       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
+
+       _bt_obex_cancel_transfer((void *)ad);
+
+       g_free(ad);
+}
+
+TEST(BluetoothShare_test, _bt_clear_receive_noti_list_p) {
+       _bt_clear_receive_noti_list();
+}
+
+TEST(BluetoothShare_test, _bt_get_default_storage_p) {
+       char storage[STORAGE_PATH_LEN_MAX] = {0, };
+
+       _bt_get_default_storage(storage);
+}
+
+TEST(BluetoothShare_test, _bt_get_available_int_memory_p) {
+       int ret = 0;
+       double available_int_mem_size = 0;
+
+       ret = _bt_get_available_int_memory(&available_int_mem_size);
+
+       ASSERT_TRUE(ret >= 0);
+}
+
+TEST(BluetoothShare_test, _bt_get_available_ext_memory_p) {
+       int ret = 0;
+       unsigned long long available_ext_mem_size = 0;
+
+       ret = _bt_get_available_ext_memory(&available_ext_mem_size);
+
+       ASSERT_TRUE(ret >= 0);
+}
+
+TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
+       int ret = BT_SHARE_ERR_NONE;
+       int session_id = -1;
+       int cnt = -1;
+       sqlite3 *db = NULL;
+       bt_tr_data_t *tmp = NULL;
+       bt_tr_data_t *info = NULL;
+       GSList *tr_data_list = NULL;
+
+       db = bt_share_open_db();
+
+       ASSERT_FALSE(db == NULL);
+
+       tmp = (bt_tr_data_t *)g_malloc0(sizeof(bt_tr_data_t));
+
+       tmp->tr_status = BT_TRANSFER_FAIL;
+       tmp->sid = 1;
+       tmp->file_path = "TEST";
+       tmp->content = "TEST";
+       tmp->dev_name = "TEST";
+       tmp->type = "TEST";
+       tmp->timestamp = 2;
+       tmp->addr = "TEST";
+       tmp->size = 0;
+       tmp->db_sid = "1";
+
+       ret = bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
+
+       if (ret != BT_SHARE_ERR_NONE) {
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_TRUE(ret == BT_SHARE_ERR_NONE);
+
+       info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tmp->sid);
+
+       if (info != NULL) {
+               g_free(info->file_path);
+               g_free(info->dev_name);
+               g_free(info->addr);
+               g_free(info->type);
+               g_free(info->content);
+               g_free(info);
+       }
+
+       tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_OUTBOUND);
+
+       if (tr_data_list == NULL) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_FALSE(tr_data_list == NULL);
+
+       bt_share_release_tr_data_list(tr_data_list);
+       tr_data_list = NULL;
+
+       tr_data_list = bt_share_get_all_tr_data_by_sid(db,
+                                       BT_DB_OUTBOUND, "TEST", "1");
+
+       if (tr_data_list == NULL) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_FALSE(tr_data_list == NULL);
+
+       bt_share_release_tr_data_list(tr_data_list);
+       tr_data_list = NULL;
+
+       tr_data_list = bt_share_get_failed_tr_data_by_sid(db,
+                                       BT_DB_OUTBOUND, "TEST", "1");
+
+       if (tr_data_list == NULL) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_FALSE(tr_data_list == NULL);
+
+       bt_share_release_tr_data_list(tr_data_list);
+       tr_data_list = NULL;
+
+       session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
+
+       if (session_id == -1) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_FALSE(session_id == -1);
+
+       cnt = bt_share_get_tr_data_count(db, BT_DB_OUTBOUND);
+
+       if (cnt == -1) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_FALSE(cnt == -1);
+
+       ret = bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND, 1);
+
+       if (ret != BT_SHARE_ERROR_NONE) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       ret = bt_share_remove_tr_data_non_pending(db, BT_DB_OUTBOUND);
+
+       if (ret != BT_SHARE_ERROR_NONE) {
+               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+               bt_share_close_db(db);
+               g_free(tmp);
+       }
+
+       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
+
+       bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
+       bt_share_close_db(db);
+       g_free(tmp);
+}
+
+
+int main(int argc, char **argv) {
+  testing::InitGoogleTest(&argc, argv);
+
+  return RUN_ALL_TESTS();
+}
diff --git a/tests/mock/bluetooth-share-mock.c b/tests/mock/bluetooth-share-mock.c
new file mode 100644 (file)
index 0000000..fb3ec1c
--- /dev/null
@@ -0,0 +1,446 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    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.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <sqlite3.h>
+#include <db-util.h>
+#include <notification.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <storage.h>
+#include <bluetooth-api.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+static int access_count = 0;
+static bool row_return_required = false;
+
+API int display_lock_state(unsigned int state, unsigned int flag, unsigned int timeout)
+{
+       return 0;
+}
+
+API int display_unlock_state(unsigned int state, unsigned int flag)
+{
+       return 0;
+}
+
+API int vconf_get_int(const char *in_key, int *intval)
+{
+       if (strcmp(in_key, "db/bluetooth/status") == 0) // VCONFKEY_BT_STATUS
+               *intval = TRUE;
+       return 0;
+}
+
+API int vconf_set_int(const char *in_key, const int intval)
+{
+       return 0;
+}
+
+API GDBusConnection *g_bus_get_sync(GBusType bus_type,
+               GCancellable *cancellable,
+               GError **error)
+{
+       return (void *)1234;
+}
+
+API GVariant *g_dbus_proxy_call_sync(GDBusProxy *proxy,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusCallFlags flags,
+               gint timeout_msec,
+               GCancellable *cancellable,
+               GError **error)
+{
+       return (void *)1234;
+}
+
+API GDBusProxy *g_dbus_proxy_new_sync(GDBusConnection *connection,
+               GDBusProxyFlags flags,
+               GDBusInterfaceInfo *info,
+               const gchar *name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               GCancellable *cancellable,
+               GError **error)
+{
+       return (void *)1234;
+}
+
+API char *g_uri_parse_scheme(const char *uri)
+{
+       if (strcmp(uri, "http://www.tizen.org") == 0)
+               return strdup("http");
+       else if (strcmp(uri, "Text test") == 0)
+               return NULL;
+       else
+               return NULL;
+}
+
+API int access(const char *pathname, int mode)
+{
+       if (access_count == 0) {
+               access_count = 1;
+               return 0;
+       } else {
+               access_count = 0;
+               return -1;
+       }
+}
+
+API int open(const char *__path, int __oflag, ...)
+{
+       if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share.html") == 0) {
+               return 0;
+       } else if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share_0.txt") == 0) {
+               return 0;
+       } else if (strcmp(__path, "/opt/system/model-config/system_info_db") == 0) {
+               return 0;
+       } else if (strcmp(__path, "/etc/dlog.conf.d") == 0) {
+               return 0;
+       }
+
+       int (*org_fn)(const char *, int, ...) = NULL;
+       org_fn = dlsym(RTLD_NEXT, "open");
+
+       int ret;
+       va_list ap;
+       va_start(ap, __oflag);
+       int mode = va_arg(ap, int);
+       if (mode <= 0x777)
+               ret = org_fn(__path, __oflag, mode);
+       else
+               ret = org_fn(__path, __oflag);
+       va_end(ap);
+       return ret;
+}
+
+API ssize_t write(int fd, const void *buf, size_t count)
+{
+       return 0;
+}
+
+API int close(int fd)
+{
+       return 0;
+}
+
+API void g_dbus_connection_signal_unsubscribe(GDBusConnection *connection,
+               guint subscription_id)
+{
+}
+
+API guint g_dbus_connection_signal_subscribe(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *interface_name,
+               const gchar *member,
+               const gchar *object_path,
+               const gchar *arg0,
+               GDBusSignalFlags flags,
+               GDBusSignalCallback callback,
+               gpointer user_data,
+               GDestroyNotify user_data_free_func)
+{
+       return 0;
+}
+
+API GDBusMessage *g_dbus_message_new_signal(const gchar *path,
+       const gchar *interface_,
+       const gchar *signal)
+{
+       return (void *)1234;
+}
+
+API void g_dbus_message_set_body(GDBusMessage *message,
+               GVariant *body)
+{
+}
+
+API void g_dbus_message_set_destination(GDBusMessage *message,
+               const gchar *value)
+{
+}
+
+API gboolean g_dbus_connection_send_message(GDBusConnection *connection,
+               GDBusMessage *message,
+               GDBusSendMessageFlags flags,
+               volatile guint32 *out_serial,
+               GError **error)
+{
+       return TRUE;
+}
+
+API void g_object_unref(gpointer object)
+{
+}
+
+API void g_variant_unref(GVariant *value)
+{
+}
+
+API int db_util_open(const char *pszFilePath, sqlite3 **ppDB,
+               int nOption)
+{
+       *ppDB = (void *)1234;
+       return 0;
+}
+
+API int sqlite3_prepare(
+               sqlite3 *db,
+               const char *zSql,
+               int nByte,
+               sqlite3_stmt **ppStmt,
+               const char **pzTail)
+{
+       *ppStmt = (sqlite3_stmt *)1234;
+       if (strncasecmp(zSql, "select", strlen("select")) == 0) {
+               row_return_required = true;
+       }
+       return 0;
+}
+
+API int sqlite3_prepare_v2(
+               sqlite3 *db,
+               const char *zSql,
+               int nByte,
+               sqlite3_stmt **ppStmt,
+               const char **pzTail)
+{
+       return sqlite3_prepare(db, zSql, nByte, ppStmt, pzTail);
+}
+
+API int sqlite3_step(sqlite3_stmt *pStmt)
+{
+       if (row_return_required) {
+               row_return_required = false;
+               return SQLITE_ROW;
+       }
+       return SQLITE_DONE;
+}
+
+API int sqlite3_finalize(sqlite3_stmt *pStmt)
+{
+       return 0;
+}
+
+API int db_util_close(sqlite3 *ppDB)
+{
+       return 0;
+}
+
+API char *sqlite3_mprintf(const char *param1, ...)
+{
+       return "success";
+}
+
+API void sqlite3_free(void *param1)
+{
+}
+
+API int sqlite3_bind_int(sqlite3_stmt *param1, int param2, int param3)
+{
+       return 0;
+}
+
+API int sqlite3_reset(sqlite3_stmt *pStmt)
+{
+}
+
+API const char *sqlite3_errmsg(sqlite3 *param1)
+{
+       return "success";
+}
+
+API int sqlite3_column_int(sqlite3_stmt *param1, int iCol)
+{
+       return 0;
+}
+
+API const unsigned char *sqlite3_column_text(sqlite3_stmt *param1, int iCol)
+{
+       return "1234";
+}
+
+API notification_h notification_create(notification_type_e type)
+{
+       return (void *)1234;
+}
+
+API int notification_set_text(notification_h noti, notification_text_type_e type,
+               const char *text, const char *key, int args_type, ...)
+{
+       return 0;
+}
+
+API int notification_set_image(notification_h noti, notification_image_type_e type, const char *image_path)
+{
+       return 0;
+}
+
+API int notification_set_display_applist(notification_h noti, int applist)
+{
+       return 0;
+}
+
+API int notification_post(notification_h noti)
+{
+       return 0;
+}
+
+API int notification_free(notification_h noti)
+{
+       return 0;
+}
+
+API int notification_set_text_domain(notification_h noti,
+               const char *domain,
+               const char *dir)
+{
+       return 0;
+}
+
+API int notification_set_property(notification_h noti, int flags)
+{
+       return 0;
+}
+
+API int notification_get_property(notification_h noti, int *flags)
+{
+       return 0;
+}
+
+API int notification_set_pkgname(notification_h noti, const char *pkgname)
+{
+       return 0;
+}
+
+API int notification_set_execute_option(notification_h noti,
+               notification_execute_type_e type,
+               const char *text,
+               const char *key,
+               bundle *service_handle)
+{
+       return 0;
+}
+
+API int notification_insert(notification_h noti, int *priv_id)
+{
+       return 0;
+}
+
+API int notification_get_id(notification_h noti, int *group_id, int *priv_id)
+{
+       return 0;
+}
+
+API int notification_delete(notification_h noti)
+{
+       return 0;
+}
+
+API int notification_update(notification_h noti)
+{
+       return 0;
+}
+
+API int notification_update_progress(notification_h noti, int priv_id, double progress)
+{
+       return 0;
+}
+
+API int notification_register_detailed_changed_cb(
+               void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+               void *user_data)
+{
+       return 0;
+}
+
+API int notification_unregister_detailed_changed_cb(
+               void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+               void *user_data)
+{
+       return 0;
+}
+
+API int appsvc_set_pkgname(bundle *b, const char *pkg_name)
+{
+       return 0;
+}
+
+API int appsvc_add_data(bundle *b, const char *key, const char *val)
+{
+       return 0;
+}
+
+API bundle *bundle_create(void)
+{
+       return (void *)1234;
+}
+
+API int bundle_add(bundle *b, const char *key, const char *val)
+{
+       return 0;
+}
+
+API int bundle_free(bundle *b)
+{
+       return 0;
+}
+
+API int aul_app_is_running(const char *appid)
+{
+       return 0;
+}
+
+API int aul_launch_app(const char *appid, bundle *kb)
+{
+       return 0;
+}
+
+API int syspopup_launch(char *popup_name, bundle *b)
+{
+       return 0;
+}
+
+API int syspopup_destroy_all(void)
+{
+       return 0;
+}
+
+API int storage_get_internal_memory_size(struct statvfs *buf)
+{
+       return 0;
+}
+
+API int bluetooth_obex_server_init(const char *dst_path)
+{
+       return 0;
+}
+
+API int bluetooth_obex_server_set_root(const char *root)
+{
+       return 0;
+}
diff --git a/tests/run_coverage.sh b/tests/run_coverage.sh
new file mode 100755 (executable)
index 0000000..24fb7ab
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=..:.:../lib:../app:$LD_LIBRARY_PATH
+pushd ../
+RootDir=$PWD
+popd
+
+unitTestFile=gtest-bluetooth-share
+if [ ! -x  "./$unitTestFile" ]
+then
+    echo "$unitTestFile file does not exist!"
+    exit -1
+fi
+#./$unitTestFile
+
+LD_PRELOAD=./libbluetooth-share-mock.so ./$unitTestFile
+
+CMakeDir=${RootDir}/app/CMakeFiles/bt-share.dir/
+CoverageDir=${RootDir}/coverage
+
+pushd $CMakeDir
+
+    for obj in `ls *.o`
+    do
+        gcov -b -c $obj
+    done
+
+    if [ -f /usr/bin/lcov ]
+    then
+        lcov -c -d . --exclude "/usr/lib/gcc/armv7l-tizen-linux-gnueabi/9.2.0/include/c++/*" -o cov.info
+        genhtml cov.info -o ${CoverageDir}
+        echo "Coverage test result created! [${CoverageDir}]"
+    else
+        echo "lcov does not exist!"
+    fi
+popd
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
deleted file mode 100644 (file)
index 7f6c281..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-#
-# @file        CMakeLists.txt
-# @author
-# @brief       Cmake for tests
-#
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-SET(TARGET_GTEST_TESTS "gtest-bluetooth-share")
-
-INCLUDE_DIRECTORIES(/usr/include)
-INCLUDE_DIRECTORIES(/usr/include/db-util)
-INCLUDE_DIRECTORIES(/usr/include/glib-2.0)
-INCLUDE_DIRECTORIES(/usr/include/bt-service)
-INCLUDE_DIRECTORIES(/usr/include/notification)
-INCLUDE_DIRECTORIES(/usr/include/storage)
-INCLUDE_DIRECTORIES(/usr/include/appfw)
-INCLUDE_DIRECTORIES(/usr/lib/glib-2.0/include/)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/bt-share/include)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(INCLUDEDIR "/usr/include")
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(testpkgs REQUIRED glib-2.0)
-
-SET(GTEST_TESTS_SOURCES
-bluetooth-share_test.cpp
-)
-
-SET(BLUETOOTH_SHARE_MOCK "bluetooth-share-mock")
-SET(BLUETOOTH_SHARE_MOCK_SRCS
-       mock/bluetooth-share-mock.c)
-SET(BLUETOOTH_SHARE_MOCK_CFLAGS "${CMAKE_C_FLAGS}" )
-ADD_LIBRARY(${BLUETOOTH_SHARE_MOCK} SHARED ${BLUETOOTH_SHARE_MOCK_SRCS})
-TARGET_LINK_LIBRARIES(${BLUETOOTH_SHARE_MOCK} -ldl)
-SET_TARGET_PROPERTIES(${BLUETOOTH_SHARE_MOCK} PROPERTIES
-       COMPILE_FLAGS ${BLUETOOTH_SHARE_MOCK_CFLAGS}
-)
-
-ADD_EXECUTABLE(${TARGET_GTEST_TESTS}
-       ${GTEST_TESTS_SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_GTEST_TESTS}
-       ${pkgs_LDFLAGS}
-       ${pkgs_LIBRARIES}
-       gtest
-       -L${CMAKE_SOURCE_DIR}/lib
-       -lbluetooth-share-api
-       -L${CMAKE_SOURCE_DIR}/bt-share
-       -lbt-share
-)
-
-INSTALL(TARGETS ${TARGET_GTEST_TESTS} DESTINATION /usr/bin)
diff --git a/unittest/bluetooth-share_test.cpp b/unittest/bluetooth-share_test.cpp
deleted file mode 100644 (file)
index 7191ac4..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file        bluetooth-share_test.cpp
- * @author      abc
- * @version     1.0
- * @brief       Unit-tests setup
- */
-
-#include <gtest/gtest.h>
-#include <unistd.h>
-#include <glib.h>
-#include <syspopup_caller.h>
-#include "bluetooth-share-api.h"
-#include "bt-share-common.h"
-#include "bt-share-ipc.h"
-#include "bt-share-resource.h"
-#include "bt-share-main.h"
-#include "bt-share-noti-handler.h"
-#include "bt-share-notification.h"
-#include "bt-share-syspopup.h"
-#include "obex-event-handler.h"
-
-TEST(BluetoothShare_test, _bt_share_block_sleep_p) {
-       int ret = BT_SHARE_ERROR_NONE;
-
-       ret = _bt_share_block_sleep(TRUE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_share_block_sleep(TRUE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_share_block_sleep(FALSE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_share_block_sleep(FALSE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-TEST(BluetoothShare_test, _bt_share_block_sleep_n) {
-       int ret = BT_SHARE_ERROR_NONE;
-
-       ret = _bt_share_block_sleep(FALSE);
-       ASSERT_TRUE(ret == BT_SHARE_FAIL);
-}
-
-TEST(BluetoothShare_test, _bt_set_transfer_indicator_p) {
-       int ret = BT_SHARE_ERROR_NONE;
-
-       ret = _bt_set_transfer_indicator(TRUE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_set_transfer_indicator(TRUE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_set_transfer_indicator(FALSE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_set_transfer_indicator(FALSE);
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-TEST(BluetoothShare_test, _bt_remove_tmp_file_p) {
-       _bt_remove_tmp_file(BT_TMP_FILE);
-}
-
-TEST(BluetoothShare_test, _bt_remove_vcf_file_p) {
-       _bt_remove_vcf_file(BT_CONTACT_SHARE_TMP_DIR"test");
-}
-
-TEST(BluetoothShare_test, _bt_share_create_transfer_file_p) {
-       char *file = NULL;
-
-       file = _bt_share_create_transfer_file("http://www.tizen.org");
-       ASSERT_FALSE(file == NULL);
-
-       _bt_remove_tmp_file(HTML_FILE_NAME);
-       g_free(file);
-
-       file = _bt_share_create_transfer_file("Text test");
-       ASSERT_FALSE(file == NULL);
-
-       _bt_remove_tmp_file(TXT_FILE_FORMAT);
-       g_free(file);
-}
-
-TEST(BluetoothShare_test, _bt_share_create_transfer_file_n) {
-       char *file = NULL;
-
-       file = _bt_share_create_transfer_file(NULL);
-       ASSERT_TRUE(file == NULL);
-}
-
-TEST(BluetoothShare_test, _bt_get_time_of_the_day_p) {
-       char *time = NULL;
-
-       time = _bt_get_time_of_the_day();
-       ASSERT_FALSE(time == NULL);
-
-       g_free(time);
-}
-
-TEST(BluetoothShare_test, _bt_share_get_storage_path_p) {
-       char *path = NULL;
-
-       path = _bt_share_get_storage_path(BT_DEFAULT_MEM_PHONE);
-       ASSERT_FALSE(path == NULL);
-
-       g_free(path);
-
-       path = _bt_share_get_storage_path(BT_DEFAULT_MEM_MMC);
-       ASSERT_FALSE(path == NULL);
-
-       g_free(path);
-}
-
-
-TEST(BluetoothShare_test, _bt_share_get_active_uid_p) {
-       int ret = BT_SHARE_ERROR_NONE;
-       uid_t uid = 0;
-
-       ret = _bt_share_get_active_uid(&uid);
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-TEST(BluetoothShare_test, _remove_transfer_info_p) {
-       opc_transfer_info_t *data = NULL;
-
-       data = g_new0(opc_transfer_info_t, 1);
-       data->content = g_new0(char *, 1);
-       data->file_path = g_new0(char *, 1);
-       data->file_cnt = 1;
-       data->type = g_new0(char *, 1);
-       data->size = (unsigned int *)g_new0(unsigned int *, 1);
-
-       _remove_transfer_info(data);
-}
-
-TEST(BluetoothShare_test, _bt_init_dbus_signal_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_init_dbus_signal();
-
-       ASSERT_TRUE(ret == TRUE);
-
-       _bt_deinit_dbus_signal();
-}
-
-
-TEST(BluetoothShare_test, _bt_send_disconnected_signal_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_init_dbus_signal();
-
-       ASSERT_TRUE(ret == TRUE);
-
-       _bt_send_disconnected_signal(BT_SHARE_ENG_SIGNAL_OPP_CLIENT_DISCONNECTED,
-                                                       BLUETOOTH_ERROR_NONE, "BT address", 0);
-
-       _bt_deinit_dbus_signal();
-}
-
-TEST(BluetoothShare_test, _bt_update_transfer_list_view_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_init_dbus_signal();
-
-       ASSERT_TRUE(ret == TRUE);
-
-       _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
-
-       _bt_deinit_dbus_signal();
-}
-
-
-TEST(BluetoothShare_test, _bt_create_warning_popup_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_init_dbus_signal();
-
-       ASSERT_TRUE(ret == TRUE);
-
-       _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND);
-
-       _bt_deinit_dbus_signal();
-}
-
-TEST(BluetoothShare_test, _bt_update_sent_data_status_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_update_sent_data_status(1, BT_TR_ONGOING, "1");
-
-       ASSERT_TRUE(ret == TRUE);
-}
-
-TEST(BluetoothShare_test, _bt_update_recv_data_status_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_update_recv_data_status(1, BT_TR_FAIL, "1", 100, "text/vcard");
-
-       ASSERT_TRUE(ret == TRUE);
-}
-
-TEST(BluetoothShare_test, _bt_update_multiple_sent_data_status_p) {
-       gboolean ret = FALSE;
-
-       int uids[2] = { 1, 2};
-
-       ret = _bt_update_multiple_sent_data_status(uids, 1, BT_TR_FAIL, "1");
-
-       ASSERT_TRUE(ret == TRUE);
-}
-
-TEST(BluetoothShare_test, _bt_add_recv_transfer_status_data_p) {
-       gboolean ret = FALSE;
-
-       ret = _bt_add_recv_transfer_status_data("NAME",
-                                       "ADDRESS", "FILE NAME", "TYPE",
-                                       100, BT_TR_ONGOING, "1");
-
-       ASSERT_TRUE(ret == TRUE);
-}
-
-TEST(BluetoothShare_test, _bt_share_get_unique_id_p) {
-       int id;
-
-       id = _bt_share_get_unique_id(BT_DB_INBOUND,     "1");
-
-       ASSERT_FALSE(id < 0);
-}
-
-TEST(BluetoothShare_test, _bt_set_eventsystem_transfer_value_p) {
-       int ret = BT_SHARE_ERROR_NONE;
-
-       ret = _bt_set_eventsystem_transfer_value(TRUE);
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-}
-
-TEST(BluetoothShare_test, _bt_terminate_bluetooth_share_p) {
-       _bt_terminate_bluetooth_share();
-}
-
-
-TEST(BluetoothShare_test, _bt_remove_temporary_files_by_noti_id_p) {
-       sqlite3 *db = NULL;
-
-       db = bt_share_open_db();
-
-       _bt_remove_temporary_files_by_noti_id(db, 1);
-
-       bt_share_close_db(db);
-}
-
-TEST(BluetoothShare_test, _bt_init_obex_server_p) {
-       int ret = BT_SHARE_ERROR_NONE;
-
-       ret = _bt_init_obex_server();
-
-       /* bluetooth-share process already allocate the obex serivce, so will return the error */
-       /* ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE); */
-}
-
-TEST(BluetoothShare_test, _bt_init_vconf_notification_p) {
-       _bt_init_vconf_notification(NULL);
-
-       _bt_deinit_vconf_notification();
-}
-
-TEST(BluetoothShare_test, _bt_insert_instant_notification_p) {
-       _bt_insert_instant_notification(BT_SENT_NOTI);
-
-       _bt_insert_instant_notification(BT_SENT_FAILED_NOTI);
-
-       _bt_insert_instant_notification(BT_SENDING_NOTI);
-
-       _bt_insert_instant_notification(BT_RECEIVED_NOTI);
-
-       _bt_insert_instant_notification(BT_RECEIVED_FAILED_NOTI);
-
-       _bt_insert_instant_notification(BT_RECEIVING_NOTI);
-}
-
-TEST(BluetoothShare_test, _bt_notification_test_p) {
-       bt_appdata_t *ad = NULL;
-
-       notification_h noti = NULL;
-
-       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
-
-
-       noti = _bt_insert_notification(ad,
-                                                       BT_SENDING_NOTI, "TEST",
-                                                       "test address", "1");
-
-       if (noti == NULL)
-               g_free(ad);
-
-       ASSERT_FALSE(noti == NULL);
-
-       ad->send_noti = noti;
-       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
-
-       _bt_set_notification_app_launch(noti, "TEST", "test address", "1",
-                                       CREATE_TR_LIST, NOTI_TR_TYPE_OUT, NULL, 0, NULL, 0);
-
-       _bt_update_notification(ad, ad->send_noti,
-                                                       NULL, NULL, NULL, NULL, NULL);
-
-       _bt_delete_notification(noti);
-       ad->send_noti = NULL;
-
-       noti = _bt_insert_notification(ad,
-                                                       BT_RECEIVED_NOTI, "TEST",
-                                                       "test address", "1");
-
-       if (noti == NULL)
-               g_free(ad);
-
-       ASSERT_FALSE(noti == NULL);
-
-       ad->receive_noti = noti;
-
-       _bt_update_notification(ad, ad->receive_noti,
-                                                       NULL, NULL, NULL, NULL, NULL);
-
-       _bt_delete_notification(noti);
-       ad->receive_noti = NULL;
-
-       noti = _bt_insert_notification(ad,
-                                                       BT_SENDING_NOTI, "TEST",
-                                                       "test address", "1");
-
-       if (noti == NULL)
-               g_free(ad);
-
-       ASSERT_FALSE(noti == NULL);
-
-       ad->opc_noti_id = _bt_get_notification_priv_id(noti);
-
-       _bt_set_notification_app_launch(noti, "TEST", "test address",
-                                               "1", CREATE_PROGRESS, NOTI_TR_TYPE_OUT,
-                                               "TEST", 0, NULL, 1);
-
-       _bt_update_notification_progress(noti, ad->opc_noti_id, 100);
-
-       _bt_delete_notification(noti);
-
-       noti = _bt_insert_notification(ad,
-                                                       BT_RECEIVING_NOTI, "TEST",
-                                                       "test address", "1");
-
-       if (noti == NULL)
-               g_free(ad);
-
-       ASSERT_FALSE(noti == NULL);
-
-       _bt_delete_notification(noti);
-}
-
-
-TEST(BluetoothShare_test, _bt_register_notification_cb_p) {
-       _bt_register_notification_cb(NULL);
-
-       _bt_unregister_notification_cb(NULL);
-}
-
-TEST(BluetoothShare_test, _bt_launch_system_popup_p) {
-       bt_app_sys_popup_params_t popup_params = { NULL };
-       int ret = BT_SHARE_ERROR_NONE;
-       bt_appdata_t *ad = NULL;
-
-       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
-
-       popup_params.title = BT_STR_MEMORY_FULL;
-       popup_params.type = "none";
-
-       ret = _bt_launch_system_popup(BT_APP_EVENT_CONFIRM_MODE_REQUEST,
-                               &popup_params, NULL, ad);
-
-       if (ret != BT_SHARE_ERROR_NONE)
-               g_free(ad);
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       syspopup_destroy_all();
-       usleep(1000 * 200);
-
-       ret = _bt_launch_system_popup(BT_APP_EVENT_FILE_RECEIVED,
-                               &popup_params, NULL, ad);
-
-       syspopup_destroy_all();
-       usleep(1000 * 200);
-
-       if (ret != BT_SHARE_ERROR_NONE)
-               g_free(ad);
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = _bt_launch_system_popup(BT_APP_EVENT_INFORMATION,
-                       &popup_params, NULL, ad);
-
-       if (ret != BT_SHARE_ERROR_NONE)
-               g_free(ad);
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       syspopup_destroy_all();
-       usleep(1000 * 200);
-
-       ret = _bt_launch_system_popup(BT_APP_EVENT_OVERWRITE_REQUEST,
-                               &popup_params, NULL, ad);
-
-       if (ret != BT_SHARE_ERROR_NONE)
-               g_free(ad);
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       syspopup_destroy_all();
-       usleep(1000 * 200);
-}
-
-TEST(BluetoothShare_test, _bt_app_popup_memoryfull_p) {
-       _bt_app_popup_memoryfull(NULL);
-}
-
-TEST(BluetoothShare_test, _bt_convert_addr_type_to_string_p) {
-       char bd_addr[BT_ADDRESS_STRING_SIZE] = {0, };
-       char addr[BT_ADDRESS_LENGTH] = {0, };
-
-       addr[0] = '1';
-       addr[1] = '1';
-       addr[2] = '1';
-       addr[3] = '1';
-       addr[4] = '1';
-       addr[5] = '1';
-
-       _bt_convert_addr_type_to_string(bd_addr, addr);
-}
-
-TEST(BluetoothShare_test, _bt_obex_cancel_transfer_p) {
-       bt_appdata_t *ad = NULL;
-
-       ad = (bt_appdata_t *)calloc(1, sizeof(bt_appdata_t));
-
-       _bt_obex_cancel_transfer((void *)ad);
-
-       g_free(ad);
-}
-
-TEST(BluetoothShare_test, _bt_clear_receive_noti_list_p) {
-       _bt_clear_receive_noti_list();
-}
-
-TEST(BluetoothShare_test, _bt_get_default_storage_p) {
-       char storage[STORAGE_PATH_LEN_MAX] = {0, };
-
-       _bt_get_default_storage(storage);
-}
-
-TEST(BluetoothShare_test, _bt_get_available_int_memory_p) {
-       int ret = 0;
-       double available_int_mem_size = 0;
-
-       ret = _bt_get_available_int_memory(&available_int_mem_size);
-
-       ASSERT_TRUE(ret >= 0);
-}
-
-TEST(BluetoothShare_test, _bt_get_available_ext_memory_p) {
-       int ret = 0;
-       unsigned long long available_ext_mem_size = 0;
-
-       ret = _bt_get_available_ext_memory(&available_ext_mem_size);
-
-       ASSERT_TRUE(ret >= 0);
-}
-
-TEST(BluetoothShareApi_test, bt_share_db_api_test_p) {
-       int ret = BT_SHARE_ERR_NONE;
-       int session_id = -1;
-       int cnt = -1;
-       sqlite3 *db = NULL;
-       bt_tr_data_t *tmp = NULL;
-       bt_tr_data_t *info = NULL;
-       GSList *tr_data_list = NULL;
-
-       db = bt_share_open_db();
-
-       ASSERT_FALSE(db == NULL);
-
-       tmp = (bt_tr_data_t *)g_malloc0(sizeof(bt_tr_data_t));
-
-       tmp->tr_status = BT_TRANSFER_FAIL;
-       tmp->sid = 1;
-       tmp->file_path = "TEST";
-       tmp->content = "TEST";
-       tmp->dev_name = "TEST";
-       tmp->type = "TEST";
-       tmp->timestamp = 2;
-       tmp->addr = "TEST";
-       tmp->size = 0;
-       tmp->db_sid = "1";
-
-       ret = bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp);
-
-       if (ret != BT_SHARE_ERR_NONE) {
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_TRUE(ret == BT_SHARE_ERR_NONE);
-
-       info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tmp->sid);
-
-       if (info != NULL) {
-               g_free(info->file_path);
-               g_free(info->dev_name);
-               g_free(info->addr);
-               g_free(info->type);
-               g_free(info->content);
-               g_free(info);
-       }
-
-       tr_data_list = bt_share_get_all_tr_data_list(db, BT_DB_OUTBOUND);
-
-       if (tr_data_list == NULL) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_FALSE(tr_data_list == NULL);
-
-       bt_share_release_tr_data_list(tr_data_list);
-       tr_data_list = NULL;
-
-       tr_data_list = bt_share_get_all_tr_data_by_sid(db,
-                                       BT_DB_OUTBOUND, "TEST", "1");
-
-       if (tr_data_list == NULL) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_FALSE(tr_data_list == NULL);
-
-       bt_share_release_tr_data_list(tr_data_list);
-       tr_data_list = NULL;
-
-       tr_data_list = bt_share_get_failed_tr_data_by_sid(db,
-                                       BT_DB_OUTBOUND, "TEST", "1");
-
-       if (tr_data_list == NULL) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_FALSE(tr_data_list == NULL);
-
-       bt_share_release_tr_data_list(tr_data_list);
-       tr_data_list = NULL;
-
-       session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND);
-
-       if (session_id == -1) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_FALSE(session_id == -1);
-
-       cnt = bt_share_get_tr_data_count(db, BT_DB_OUTBOUND);
-
-       if (cnt == -1) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_FALSE(cnt == -1);
-
-       ret = bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND, 1);
-
-       if (ret != BT_SHARE_ERROR_NONE) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       ret = bt_share_remove_tr_data_non_pending(db, BT_DB_OUTBOUND);
-
-       if (ret != BT_SHARE_ERROR_NONE) {
-               bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-               bt_share_close_db(db);
-               g_free(tmp);
-       }
-
-       ASSERT_TRUE(ret == BT_SHARE_ERROR_NONE);
-
-       bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND);
-       bt_share_close_db(db);
-       g_free(tmp);
-}
-
-
-int main(int argc, char **argv) {
-  testing::InitGoogleTest(&argc, argv);
-
-  return RUN_ALL_TESTS();
-}
diff --git a/unittest/mock/bluetooth-share-mock.c b/unittest/mock/bluetooth-share-mock.c
deleted file mode 100644 (file)
index fb3ec1c..0000000
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    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.
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <sqlite3.h>
-#include <db-util.h>
-#include <notification.h>
-#include <dlfcn.h>
-#include <fcntl.h>
-#include <storage.h>
-#include <bluetooth-api.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-static int access_count = 0;
-static bool row_return_required = false;
-
-API int display_lock_state(unsigned int state, unsigned int flag, unsigned int timeout)
-{
-       return 0;
-}
-
-API int display_unlock_state(unsigned int state, unsigned int flag)
-{
-       return 0;
-}
-
-API int vconf_get_int(const char *in_key, int *intval)
-{
-       if (strcmp(in_key, "db/bluetooth/status") == 0) // VCONFKEY_BT_STATUS
-               *intval = TRUE;
-       return 0;
-}
-
-API int vconf_set_int(const char *in_key, const int intval)
-{
-       return 0;
-}
-
-API GDBusConnection *g_bus_get_sync(GBusType bus_type,
-               GCancellable *cancellable,
-               GError **error)
-{
-       return (void *)1234;
-}
-
-API GVariant *g_dbus_proxy_call_sync(GDBusProxy *proxy,
-               const gchar *method_name,
-               GVariant *parameters,
-               GDBusCallFlags flags,
-               gint timeout_msec,
-               GCancellable *cancellable,
-               GError **error)
-{
-       return (void *)1234;
-}
-
-API GDBusProxy *g_dbus_proxy_new_sync(GDBusConnection *connection,
-               GDBusProxyFlags flags,
-               GDBusInterfaceInfo *info,
-               const gchar *name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               GCancellable *cancellable,
-               GError **error)
-{
-       return (void *)1234;
-}
-
-API char *g_uri_parse_scheme(const char *uri)
-{
-       if (strcmp(uri, "http://www.tizen.org") == 0)
-               return strdup("http");
-       else if (strcmp(uri, "Text test") == 0)
-               return NULL;
-       else
-               return NULL;
-}
-
-API int access(const char *pathname, int mode)
-{
-       if (access_count == 0) {
-               access_count = 1;
-               return 0;
-       } else {
-               access_count = 0;
-               return -1;
-       }
-}
-
-API int open(const char *__path, int __oflag, ...)
-{
-       if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share.html") == 0) {
-               return 0;
-       } else if (strcmp(__path, "/opt/usr/home/owner/media/Downloads/bluetooth_content_share_0.txt") == 0) {
-               return 0;
-       } else if (strcmp(__path, "/opt/system/model-config/system_info_db") == 0) {
-               return 0;
-       } else if (strcmp(__path, "/etc/dlog.conf.d") == 0) {
-               return 0;
-       }
-
-       int (*org_fn)(const char *, int, ...) = NULL;
-       org_fn = dlsym(RTLD_NEXT, "open");
-
-       int ret;
-       va_list ap;
-       va_start(ap, __oflag);
-       int mode = va_arg(ap, int);
-       if (mode <= 0x777)
-               ret = org_fn(__path, __oflag, mode);
-       else
-               ret = org_fn(__path, __oflag);
-       va_end(ap);
-       return ret;
-}
-
-API ssize_t write(int fd, const void *buf, size_t count)
-{
-       return 0;
-}
-
-API int close(int fd)
-{
-       return 0;
-}
-
-API void g_dbus_connection_signal_unsubscribe(GDBusConnection *connection,
-               guint subscription_id)
-{
-}
-
-API guint g_dbus_connection_signal_subscribe(GDBusConnection *connection,
-               const gchar *sender,
-               const gchar *interface_name,
-               const gchar *member,
-               const gchar *object_path,
-               const gchar *arg0,
-               GDBusSignalFlags flags,
-               GDBusSignalCallback callback,
-               gpointer user_data,
-               GDestroyNotify user_data_free_func)
-{
-       return 0;
-}
-
-API GDBusMessage *g_dbus_message_new_signal(const gchar *path,
-       const gchar *interface_,
-       const gchar *signal)
-{
-       return (void *)1234;
-}
-
-API void g_dbus_message_set_body(GDBusMessage *message,
-               GVariant *body)
-{
-}
-
-API void g_dbus_message_set_destination(GDBusMessage *message,
-               const gchar *value)
-{
-}
-
-API gboolean g_dbus_connection_send_message(GDBusConnection *connection,
-               GDBusMessage *message,
-               GDBusSendMessageFlags flags,
-               volatile guint32 *out_serial,
-               GError **error)
-{
-       return TRUE;
-}
-
-API void g_object_unref(gpointer object)
-{
-}
-
-API void g_variant_unref(GVariant *value)
-{
-}
-
-API int db_util_open(const char *pszFilePath, sqlite3 **ppDB,
-               int nOption)
-{
-       *ppDB = (void *)1234;
-       return 0;
-}
-
-API int sqlite3_prepare(
-               sqlite3 *db,
-               const char *zSql,
-               int nByte,
-               sqlite3_stmt **ppStmt,
-               const char **pzTail)
-{
-       *ppStmt = (sqlite3_stmt *)1234;
-       if (strncasecmp(zSql, "select", strlen("select")) == 0) {
-               row_return_required = true;
-       }
-       return 0;
-}
-
-API int sqlite3_prepare_v2(
-               sqlite3 *db,
-               const char *zSql,
-               int nByte,
-               sqlite3_stmt **ppStmt,
-               const char **pzTail)
-{
-       return sqlite3_prepare(db, zSql, nByte, ppStmt, pzTail);
-}
-
-API int sqlite3_step(sqlite3_stmt *pStmt)
-{
-       if (row_return_required) {
-               row_return_required = false;
-               return SQLITE_ROW;
-       }
-       return SQLITE_DONE;
-}
-
-API int sqlite3_finalize(sqlite3_stmt *pStmt)
-{
-       return 0;
-}
-
-API int db_util_close(sqlite3 *ppDB)
-{
-       return 0;
-}
-
-API char *sqlite3_mprintf(const char *param1, ...)
-{
-       return "success";
-}
-
-API void sqlite3_free(void *param1)
-{
-}
-
-API int sqlite3_bind_int(sqlite3_stmt *param1, int param2, int param3)
-{
-       return 0;
-}
-
-API int sqlite3_reset(sqlite3_stmt *pStmt)
-{
-}
-
-API const char *sqlite3_errmsg(sqlite3 *param1)
-{
-       return "success";
-}
-
-API int sqlite3_column_int(sqlite3_stmt *param1, int iCol)
-{
-       return 0;
-}
-
-API const unsigned char *sqlite3_column_text(sqlite3_stmt *param1, int iCol)
-{
-       return "1234";
-}
-
-API notification_h notification_create(notification_type_e type)
-{
-       return (void *)1234;
-}
-
-API int notification_set_text(notification_h noti, notification_text_type_e type,
-               const char *text, const char *key, int args_type, ...)
-{
-       return 0;
-}
-
-API int notification_set_image(notification_h noti, notification_image_type_e type, const char *image_path)
-{
-       return 0;
-}
-
-API int notification_set_display_applist(notification_h noti, int applist)
-{
-       return 0;
-}
-
-API int notification_post(notification_h noti)
-{
-       return 0;
-}
-
-API int notification_free(notification_h noti)
-{
-       return 0;
-}
-
-API int notification_set_text_domain(notification_h noti,
-               const char *domain,
-               const char *dir)
-{
-       return 0;
-}
-
-API int notification_set_property(notification_h noti, int flags)
-{
-       return 0;
-}
-
-API int notification_get_property(notification_h noti, int *flags)
-{
-       return 0;
-}
-
-API int notification_set_pkgname(notification_h noti, const char *pkgname)
-{
-       return 0;
-}
-
-API int notification_set_execute_option(notification_h noti,
-               notification_execute_type_e type,
-               const char *text,
-               const char *key,
-               bundle *service_handle)
-{
-       return 0;
-}
-
-API int notification_insert(notification_h noti, int *priv_id)
-{
-       return 0;
-}
-
-API int notification_get_id(notification_h noti, int *group_id, int *priv_id)
-{
-       return 0;
-}
-
-API int notification_delete(notification_h noti)
-{
-       return 0;
-}
-
-API int notification_update(notification_h noti)
-{
-       return 0;
-}
-
-API int notification_update_progress(notification_h noti, int priv_id, double progress)
-{
-       return 0;
-}
-
-API int notification_register_detailed_changed_cb(
-               void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
-               void *user_data)
-{
-       return 0;
-}
-
-API int notification_unregister_detailed_changed_cb(
-               void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
-               void *user_data)
-{
-       return 0;
-}
-
-API int appsvc_set_pkgname(bundle *b, const char *pkg_name)
-{
-       return 0;
-}
-
-API int appsvc_add_data(bundle *b, const char *key, const char *val)
-{
-       return 0;
-}
-
-API bundle *bundle_create(void)
-{
-       return (void *)1234;
-}
-
-API int bundle_add(bundle *b, const char *key, const char *val)
-{
-       return 0;
-}
-
-API int bundle_free(bundle *b)
-{
-       return 0;
-}
-
-API int aul_app_is_running(const char *appid)
-{
-       return 0;
-}
-
-API int aul_launch_app(const char *appid, bundle *kb)
-{
-       return 0;
-}
-
-API int syspopup_launch(char *popup_name, bundle *b)
-{
-       return 0;
-}
-
-API int syspopup_destroy_all(void)
-{
-       return 0;
-}
-
-API int storage_get_internal_memory_size(struct statvfs *buf)
-{
-       return 0;
-}
-
-API int bluetooth_obex_server_init(const char *dst_path)
-{
-       return 0;
-}
-
-API int bluetooth_obex_server_set_root(const char *root)
-{
-       return 0;
-}
diff --git a/unittest/run_coverage.sh b/unittest/run_coverage.sh
deleted file mode 100755 (executable)
index bbdf0c8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-export LD_LIBRARY_PATH=..:.:../lib:../bt-share:$LD_LIBRARY_PATH
-pushd ../
-RootDir=$PWD
-popd
-
-unitTestFile=gtest-bluetooth-share
-if [ ! -x  "./$unitTestFile" ]
-then
-    echo "$unitTestFile file does not exist!"
-    exit -1
-fi
-#./$unitTestFile
-
-LD_PRELOAD=./libbluetooth-share-mock.so ./$unitTestFile
-
-CMakeDir=${RootDir}/bt-share/CMakeFiles/bt-share.dir/src/
-CoverageDir=${RootDir}/coverage
-
-pushd $CMakeDir
-
-    for obj in `ls *.o`
-    do
-        gcov -b -c $obj
-    done
-
-    if [ -f /usr/bin/lcov ]
-    then
-        lcov -c -d . --exclude "/usr/lib/gcc/armv7l-tizen-linux-gnueabi/9.2.0/include/c++/*" -o cov.info
-        genhtml cov.info -o ${CoverageDir}
-        echo "Coverage test result created! [${CoverageDir}]"
-    else
-        echo "lcov does not exist!"
-    fi
-popd