Modify the logic and locaion for db_init.sh script 22/68422/1 accepted/tizen/common/20160504.130928 accepted/tizen/ivi/20160504.115308 accepted/tizen/mobile/20160504.115140 accepted/tizen/tv/20160504.114951 accepted/tizen/wearable/20160504.115215 submit/tizen/20160504.072325
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 4 May 2016 07:13:24 +0000 (16:13 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 4 May 2016 07:13:24 +0000 (16:13 +0900)
Change-Id: I2edbc10560d0f8aaa3228ca236c2547299231bfd
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-share/src/bt-share-main.c
lib/bt-share-db.c
lib/bt-share-db.h
packaging/bluetooth-share.spec

index 71e9920..33367f9 100644 (file)
@@ -22,6 +22,8 @@
 #include <string.h>
 #include <appcore-efl.h>
 #include <vconf.h>
+#include <errno.h>
+#include <sys/stat.h>
 
 /* For multi-user support */
 #include <tzplatform_config.h>
@@ -36,6 +38,8 @@
 #include "bt-share-notification.h"
 #include "bt-share-common.h"
 #include "bt-share-cynara.h"
+#include "bt-share-db.h"
+
 
 #include <sys/types.h>
 #include <unistd.h>
@@ -313,6 +317,23 @@ void _bt_terminate_app(void)
        }
 }
 
+void __bt_create_transfer_db(void)
+{
+       struct stat sts;
+       int ret;
+
+       /* Check if the DB exists; if not, create it and initialize it */
+       ret = stat(BT_TRANSFER_DB, &sts);
+       if (ret == -1 && errno == ENOENT)
+       {
+               DBG("DB %s doesn't exist, it needs to be created and initialized", BT_TRANSFER_DB);
+               DBG("script path: %s", SCRIPT_INIT_DB);
+               ret = system(SCRIPT_INIT_DB);
+               if (ret != EXIT_SUCCESS)
+                       ERR("Exit code of epp not clean: %i", ret);
+       }
+}
+
 int main(void)
 {
        int ret;
@@ -323,6 +344,8 @@ int main(void)
 
        signal(SIGTERM, __bt_sigterm_handler);
 
+       __bt_create_transfer_db();
+
        if (__bt_dbus_request_name() == FALSE) {
                DBG("Aleady dbus instance existed\n");
                exit(0);
index d1dfc95..da41d96 100644 (file)
@@ -58,18 +58,6 @@ sqlite3 *__bt_db_open(void)
 {
        int ret;
        sqlite3 *db = NULL;
-       struct stat sts;
-
-       /* Check if the DB exists; if not, create it and initialize it */
-       ret = stat(BT_TRANSFER_DB, &sts);
-       if (ret == -1 && errno == ENOENT)
-       {
-               DBG("DB %s doesn't exist, it needs to be created and initialized", BT_TRANSFER_DB);
-               DBG("script path: %s", SCRIPT_INIT_DB);
-               ret = system(SCRIPT_INIT_DB);
-               if (ret != EXIT_SUCCESS)
-                       ERR("Exit code of epp not clean: %i", ret);
-       }
 
        ret = db_util_open(BT_TRANSFER_DB, &db, DB_UTIL_REGISTER_HOOK_METHOD);
        if (ret) {
index d7190a4..7d983bd 100644 (file)
@@ -29,7 +29,9 @@ extern "C" {
 #define BT_OUTBOUND_TABLE      "outbound"
 #define BT_DB_QUERY_LEN                512
 
-#define SCRIPT_INIT_DB         tzplatform_mkpath(TZ_USER_DATA, "bluetooth-share/init_db.sh")
+//#define SCRIPT_INIT_DB               tzplatform_mkpath(TZ_USER_DATA, "bluetooth-share/init_db.sh")
+#define SCRIPT_INIT_DB         "/opt/data/bluetooth-share/init_db.sh"
+
 
 #define TABLE(type) ((type == BT_DB_INBOUND) ? BT_INBOUND_TABLE : BT_OUTBOUND_TABLE)
 #define TEXT(s, n) (char *)sqlite3_column_text(s, n)
index 36f9901..6a4c24f 100644 (file)
@@ -1,4 +1,4 @@
-%define TZ_SYS_SHARE /opt/home/owner/data/
+%define TZ_SYS_DATA /opt/data/
 
 Name:       bluetooth-share
 Summary:    Bluetooth file share Agent
@@ -80,12 +80,7 @@ make
 %install
 %make_install
 
-mkdir -p  %{buildroot}%{TZ_SYS_SHARE}/bt-ftp
-install -D -m 0755 %{SOURCE1004} %{buildroot}%{TZ_SYS_SHARE}/%{name}/init_db.sh
-
-%post
-/sbin/ldconfig
-%{TZ_SYS_SHARE}/%{name}/init_db.sh
+install -D -m 0755 %{SOURCE1004} %{buildroot}%{TZ_SYS_DATA}/%{name}/init_db.sh
 
 %post -n libbluetooth-share-devel -p /sbin/ldconfig
 
@@ -100,8 +95,7 @@ install -D -m 0755 %{SOURCE1004} %{buildroot}%{TZ_SYS_SHARE}/%{name}/init_db.sh
 %defattr(-,root,root,-)
 %{_bindir}/bluetooth-share
 %{_datadir}/dbus-1/system-services/org.bluetooth.share.service
-%{TZ_SYS_SHARE}/bt-ftp
-%{TZ_SYS_SHARE}/%{name}
+%{TZ_SYS_DATA}/%{name}/init_db.sh
 
 %files -n libbluetooth-share
 %manifest libbluetooth-share.manifest