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}")
#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);
#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"
#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"
#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"
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}")
#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;
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) {
return db;
}
-
static int __bt_db_close(sqlite3 *db)
{
retv_if(db == NULL, BT_SHARE_ERR_INVALID_PARAM);
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)
-%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
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(libprivilege-control)
BuildRequires: pkgconfig(capi-content-media-content)
+BuildRequires: pkgconfig(libtzplatform-config)
%description
Bluetooth File Share Agent
%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
%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
%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
--- /dev/null
+#!/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