Add multi-user support 99/16599/1 accepted/tizen/generic accepted/tizen_ivi_panda accepted/tizen_ivi_release tizen_ivi_release accepted/tizen/generic/20140225.074608 accepted/tizen/generic/20140312.094936 accepted/tizen/ivi/20140225.174029 accepted/tizen/ivi/panda/20140312.111838 accepted/tizen/ivi/release/20140312.123126 accepted/tizen/mobile/20140227.071837 submit/tizen/20140225.053622 submit/tizen/20140312.070653 submit/tizen_ivi_release/20140312.071127
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Mon, 20 Jan 2014 14:44:56 +0000 (15:44 +0100)
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Mon, 17 Feb 2014 12:53:41 +0000 (13:53 +0100)
Also:
+ remove the creation of links "/opt/share/bt-ftp/Media" and
  "/opt/share/bt-ftp/SD_External" in the spec file since they don't seem
  to be used.
+ set a valid license tag in spec file
+ set a valid group tag in spec file

Bug-Tizen: PTREL-368
Change-Id: Ic272a472ca6c707e7ce4ab64f1eefe0eec8a7df7
Signed-off-by: Kévin THIERRY <kevin.thierry@open.eurogiciel.org>
bt-share/CMakeLists.txt
bt-share/include/bt-share-noti-handler.h
bt-share/src/bt-share-main.c
bt-share/src/bt-share-noti-handler.c
bt-share/src/obex-event-handler.c
lib/CMakeLists.txt
lib/bt-share-db.c
lib/bt-share-db.h
packaging/bluetooth-share.spec
packaging/init_db.sh [new file with mode: 0644]

index 76f355c..259b46e 100644 (file)
@@ -21,7 +21,8 @@ pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api
                                dlog vconf syspopup-caller pmapi sysman
                                notification calendar-service2 contacts-service2
                                appsvc appcore-efl libprivilege-control
-                               capi-content-media-content)
+                               capi-content-media-content
+                               libtzplatform-config)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index d2ff61e..79ed7af 100644 (file)
@@ -28,10 +28,10 @@ extern "C" {
 #define BT_DEFAULT_MEM_PHONE 0
 #define BT_DEFAULT_MEM_MMC 1
 
-#define BT_DOWNLOAD_PHONE_FOLDER "/opt/usr/media/Downloads"
-#define BT_DOWNLOAD_MMC_FOLDER "/opt/storage/sdcard"
-#define BT_DOWNLOAD_MEDIA_FOLDER "/opt/usr/media"
-#define BT_FTP_FOLDER "/opt/share/bt-ftp"
+#define BT_DOWNLOAD_PHONE_FOLDER tzplatform_mkpath(TZ_USER_CONTENT, "Downloads")
+#define BT_DOWNLOAD_MMC_FOLDER tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard")
+#define BT_DOWNLOAD_MEDIA_FOLDER tzplatform_getenv(TZ_USER_CONTENT)
+#define BT_FTP_FOLDER tzplatform_mkpath(TZ_SYS_SHARE, "bt-ftp")
 
 void _bt_init_vconf_notification(void);
 void _bt_deinit_vconf_notification(void);
index 8af3cf1..4f1cc16 100644 (file)
 #include <appcore-efl.h>
 #include <privilege-control.h>
 #include <vconf.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "applog.h"
 #include "bt-share-main.h"
 #include "bluetooth-api.h"
index 80f2eb4..fa9919a 100644 (file)
 
 #include <glib.h>
 #include <vconf.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "applog.h"
 #include "bluetooth-api.h"
 #include "bt-share-noti-handler.h"
index 0a0026d..97cd205 100644 (file)
@@ -31,6 +31,9 @@
 #include <notification.h>
 #include <media_content.h>
 
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "applog.h"
 #include "bluetooth-api.h"
 #include "obex-event-handler.h"
index 84f0b1f..65e5fe7 100644 (file)
@@ -8,7 +8,7 @@ SET(HEADERS bluetooth-share-api.h)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(apipkgs REQUIRED glib-2.0 db-util dlog)
+pkg_check_modules(apipkgs REQUIRED glib-2.0 db-util dlog libtzplatform-config)
 
 FOREACH(flag ${apipkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 26a6175..5f059b0 100644 (file)
 #include <fcntl.h>
 #include <sqlite3.h>
 #include <db-util.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
 
 #include "applog.h"
 #include "bt-share-db.h"
 #include "bluetooth-share-api.h"
 
-
 static int __bt_exec_query(sqlite3 *db, char *query)
 {
        int ret;
@@ -49,11 +53,19 @@ static int __bt_exec_query(sqlite3 *db, char *query)
        return BT_SHARE_ERR_NONE;
 }
 
-
 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);
+               system(SCRIPT_INIT_DB);
+       }
 
        ret = db_util_open(BT_TRANSFER_DB, &db, DB_UTIL_REGISTER_HOOK_METHOD);
        if (ret) {
@@ -65,7 +77,6 @@ sqlite3 *__bt_db_open(void)
        return db;
 }
 
-
 static int __bt_db_close(sqlite3 *db)
 {
        retv_if(db == NULL, BT_SHARE_ERR_INVALID_PARAM);
index 5983ae9..604e67f 100644 (file)
 extern "C" {
 #endif
 
-#define BT_TRANSFER_DB         "/opt/usr/dbspace/.bluetooth_trasnfer.db"
+#define BT_TRANSFER_DB         tzplatform_mkpath(TZ_USER_DB, ".bluetooth_transfer.db")
 #define BT_INBOUND_TABLE       "inbound"
 #define BT_OUTBOUND_TABLE      "outbound"
 #define BT_DB_QUERY_LEN                512
 
+#define SCRIPT_INIT_DB         tzplatform_mkpath(TZ_SYS_SHARE, "bluetooth-share/resources/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)
 #define INT(s, n) sqlite3_column_int(s, n)
index ac72ea8..0ec14ac 100644 (file)
@@ -1,15 +1,14 @@
-%define _optdir /opt
-
 Name:       bluetooth-share
 Summary:    Bluetooth file share Agent
 Version:    0.0.47
-Release:    2
-Group:      Connectivity/Bluetooth
-License:    Apache License, Version 2.0
+Release:    0
+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
+Source1001: %{name}.manifest
+Source1002: libbluetooth-share.manifest
+Source1003: libbluetooth-share-devel.manifest
+Source1004: init_db.sh
 Requires(post): vconf
 Requires(post): coreutils
 Requires(post): sqlite
@@ -32,6 +31,7 @@ BuildRequires:  pkgconfig(appsvc)
 BuildRequires:  pkgconfig(db-util)
 BuildRequires:  pkgconfig(libprivilege-control)
 BuildRequires:  pkgconfig(capi-content-media-content)
+BuildRequires:  pkgconfig(libtzplatform-config)
 
 %description
 Bluetooth File Share Agent
@@ -65,63 +65,8 @@ make
 
 %install
 %make_install
-mkdir -p  %{buildroot}%{_optdir}/share/bt-ftp
-
-%post
-# For the FTP server folder
-if  [ ! -e /opt/share/bt-ftp ]
-then
-       mkdir -p  /opt/share/bt-ftp
-fi
-
-if  [ ! -e /opt/share/bt-ftp/Media ]
-then
-       ln -s /opt/usr/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
-
-if [ ! -f /opt/usr/dbspace/.bluetooth_trasnfer.db ]
-then
-       sqlite3 /opt/usr/dbspace/.bluetooth_trasnfer.db 'PRAGMA journal_mode = PERSIST;
-        create table if not exists inbound (
-               id INTEGER PRIMARY KEY autoincrement,
-               sid INTEGER,
-               tr_status INTEGER,
-               file_path TEXT,
-               dev_name TEXT,
-               timestamp INTEGER default 0,
-               addr TEXT,
-               type TEXT,
-               content TEXT
-       );
-       create table if not exists outbound (
-               id INTEGER PRIMARY KEY autoincrement,
-               sid INTEGER,
-               tr_status INTEGER,
-               file_path TEXT,
-               dev_name TEXT,
-               timestamp INTEGER default 0,
-               addr TEXT,
-               type TEXT,
-               content TEXT
-       );
-       '
-fi
-
-chown :5000 /opt/usr/dbspace/.bluetooth_trasnfer.db
-chown :5000 /opt/usr/dbspace/.bluetooth_trasnfer.db-journal
-chmod 660 /opt/usr/dbspace/.bluetooth_trasnfer.db
-chmod 660 /opt/usr/dbspace/.bluetooth_trasnfer.db-journal
-
-if [ -f /usr/lib/rpm-plugins/msm.so ]
-then
-chsmack -a 'bt_share::db' /opt/usr/dbspace/.bluetooth_trasnfer.db
-chsmack -a 'bt_share::db' /opt/usr/dbspace/.bluetooth_trasnfer.db-journal
-fi
+mkdir -p  %{buildroot}%{TZ_SYS_SHARE}/bt-ftp
+install -D -m 0755 %{SOURCE1004} %{buildroot}%{TZ_SYS_SHARE}/%{name}/ressources/init_db.sh
 
 %post -n libbluetooth-share-devel -p /sbin/ldconfig
 
@@ -133,11 +78,12 @@ fi
 
 %files
 %manifest %{name}.manifest
-/opt/etc/smack/accesses.d/bluetooth-share.rule
+%{TZ_SYS_ETC}/smack/accesses.d/bluetooth-share.rule
 %defattr(-,root,root,-)
 %{_bindir}/bluetooth-share
 %{_datadir}/dbus-1/system-services/org.bluetooth.share.service
-%{_optdir}/share/bt-ftp
+%{TZ_SYS_SHARE}/bt-ftp
+%{TZ_SYS_SHARE}/%{name}
 
 %files -n libbluetooth-share
 %manifest libbluetooth-share.manifest
@@ -147,6 +93,6 @@ fi
 %files -n libbluetooth-share-devel
 %manifest libbluetooth-share-devel.manifest
 %defattr(-, root, root)
-/usr/include/bluetooth-share-api/bluetooth-share-api.h
+%{_includedir}/bluetooth-share-api/bluetooth-share-api.h
 %{_libdir}/libbluetooth-share-api.so
 %{_libdir}/pkgconfig/bluetooth-share-api.pc
diff --git a/packaging/init_db.sh b/packaging/init_db.sh
new file mode 100644 (file)
index 0000000..9ffb03b
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+eval $(tzplatform-get TZ_USER_DB)
+
+if [ ! -f $TZ_USER_DB/.bluetooth_transfer.db ]
+then
+       sqlite3 $TZ_USER_DB/.bluetooth_transfer.db 'PRAGMA journal_mode = PERSIST;
+        create table if not exists inbound (
+               id INTEGER PRIMARY KEY autoincrement,
+               sid INTEGER,
+               tr_status INTEGER,
+               file_path TEXT,
+               dev_name TEXT,
+               timestamp INTEGER default 0,
+               addr TEXT,
+               type TEXT,
+               content TEXT
+       );
+       create table if not exists outbound (
+               id INTEGER PRIMARY KEY autoincrement,
+               sid INTEGER,
+               tr_status INTEGER,
+               file_path TEXT,
+               dev_name TEXT,
+               timestamp INTEGER default 0,
+               addr TEXT,
+               type TEXT,
+               content TEXT
+       );
+       '
+fi
+
+chown :$UID $TZ_USER_DB/.bluetooth_transfer.db
+chown :$UID $TZ_USER_DB/.bluetooth_transfer.db-journal
+chmod 660 $TZ_USER_DB/.bluetooth_transfer.db
+chmod 660 $TZ_USER_DB/.bluetooth_transfer.db-journal
+
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+       chsmack -a 'bt_share::db' $TZ_USER_DB/.bluetooth_transfer.db
+       chsmack -a 'bt_share::db' $TZ_USER_DB/.bluetooth_transfer.db-journal
+fi