remove hardcoded path for multiuser support 43/16443/2 accepted/tizen_ivi_panda tizen_ivi_panda accepted/tizen/ivi/panda/20140403.014831 submit/tizen_ivi_panda/20140403.011921
authorJean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org>
Thu, 23 Jan 2014 16:30:28 +0000 (17:30 +0100)
committerJean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org>
Mon, 3 Mar 2014 13:53:27 +0000 (14:53 +0100)
Bug-Tizen: PTREL-338

Change-Id: Iac0b1f033b8ad12324eacd68a58c693051d7c986
Signed-off-by: Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org>
agent/CMakeLists.txt
agent/download-agent-file.c
agent/include/download-agent-file.h
packaging/download-provider.spec
provider/CMakeLists.txt
provider/download-provider-db.c

index 26f2b34..92c1677 100755 (executable)
@@ -21,6 +21,7 @@ pkg_check_modules(subpkgs REQUIRED
        capi-network-connection
        glib-2.0
        dlog
+       libtzplatform-config
 )
 
 FOREACH(flag ${subpkgs_CFLAGS})
index 0da5445..59b093a 100755 (executable)
@@ -19,6 +19,8 @@
 #include <unistd.h>
 #include <math.h>
 #include <errno.h>
+#include <tzplatform_config.h>
+
 #include "download-agent-client-mgr.h"
 #include "download-agent-debug.h"
 #include "download-agent-utils.h"
@@ -1152,7 +1154,7 @@ da_result_t create_dir(const char *install_dir)
                ret = DA_ERR_FAIL_TO_ACCESS_STORAGE;
        } else {
                DA_SECURE_LOGD("[%s] is created!", install_dir);
-               if (chown(install_dir, 5000, 5000) < 0) {
+               if (chown(install_dir, tzplatform_getuid(TZ_USER_NAME),tzplatform_getuid(TZ_SYS_USER_GROUP)) < 0) {
                        DA_LOG_ERR(FileManager, "Fail to chown");
                        ret = DA_ERR_FAIL_TO_ACCESS_STORAGE;
                }
index b4d3995..a537bb7 100755 (executable)
@@ -24,7 +24,7 @@
 #include "download-agent-type.h"
 #include "download-agent-dl-mgr.h"
 
-#define DA_DEFAULT_INSTALL_PATH_FOR_PHONE "/opt/usr/media/Downloads"
+#define DA_DEFAULT_INSTALL_PATH_FOR_PHONE tzplatform_getenv(TZ_USER_DOWNLOADS)
 
 da_bool_t is_file_exist(const char *file_path);
 da_bool_t is_dir_exist(const char *dir_path);
index 81ed6f7..d05584a 100755 (executable)
@@ -32,6 +32,8 @@ BuildRequires:  pkgconfig(wifi-direct)
 BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  gettext-devel
 BuildRequires:  pkgconfig(libsystemd-daemon)
+BuildRequires: pkgconfig(libtzplatform-config)
+Requires:      libtzplatform-config
 
 %description
 Description: download the contents in background
@@ -47,15 +49,13 @@ Description: download the contents in background (development files)
 %prep
 %setup -q
 
-%define _data_install_path /usr/share/%{name}
+%define _data_install_path %{_datadir}/%{name}
 %define _imagedir %{_data_install_path}/images
 %define _localedir %{_data_install_path}/locales
 %define _sqlschemadir %{_data_install_path}/sql
-%define _databasedir /opt/usr/dbspace
-%define _databasefile %{_databasedir}/.download-provider.db
 %define _sqlschemafile %{_sqlschemadir}/download-provider-schema.sql
 %define _licensedir /usr/share/license
-%define _smackruledir /opt/etc/smack/accesses.d
+%define _smackruledir %{TZ_SYS_SMACK}/accesses.d
 
 %define cmake \
        CFLAGS="${CFLAGS:-%optflags} -fPIC -D_REENTRANT -fvisibility=hidden"; export CFLAGS \
@@ -72,7 +72,6 @@ Description: download the contents in background (development files)
                -DIMAGE_DIR:PATH=%{_imagedir} \\\
                -DLOCALE_DIR:PATH=%{_localedir} \\\
                -DDATABASE_SCHEMA_DIR=%{_sqlschemadir} \\\
-               -DDATABASE_FILE:PATH=%{_databasefile} \\\
                -DDATABASE_SCHEMA_FILE=%{_sqlschemafile} \\\
                -DLICENSE_DIR:PATH=%{_licensedir} \\\
                -DSMACK_RULE_DIR:PATH=%{_smackruledir} \\\
@@ -114,16 +113,8 @@ ln -s ../download-provider.socket %{buildroot}%{_libdir}/systemd/system/sockets.
 /sbin/ldconfig
 
 %post
-mkdir -p %{_databasedir}
 /sbin/ldconfig
 
-if [ ! -f %{_databasefile} ];
-then
-sqlite3 %{_databasefile} '.read %{_sqlschemafile}'
-chmod 660 %{_databasefile}
-chmod 660 %{_databasefile}-journal
-fi
-
 %files
 %defattr(-,root,root,-)
 %manifest download-provider.manifest
index be89a9d..fef1222 100755 (executable)
@@ -19,8 +19,9 @@ pkg_check_modules(dp2_pkgs REQUIRED glib-2.0
                appsvc
                bundle
                libsmack
-               dlog
-               libsystemd-daemon)
+               libsystemd-daemon
+               libtzplatform-config
+               dlog)
 
 FOREACH(flag ${dp2_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -38,10 +39,6 @@ set(DP2_LINK_LIBRARIES ${GLIB-2_LIBRARIES}
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall")
 
-IF(DEFINED DATABASE_FILE)
-       ADD_DEFINITIONS(-DDATABASE_FILE=\"${DATABASE_FILE}\")
-ENDIF(DEFINED DATABASE_FILE)
-
 IF(DEFINED DATABASE_SCHEMA_FILE)
        ADD_DEFINITIONS(-DDATABASE_SCHEMA_FILE=\"${DATABASE_SCHEMA_FILE}\")
 ENDIF(DEFINED DATABASE_SCHEMA_FILE)
index 4bc1353..8a86d30 100755 (executable)
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <tzplatform_config.h>
 
 #include <stdlib.h>
 #include <sqlite3.h>
@@ -27,6 +28,8 @@
 #include "download-provider-log.h"
 #include "download-provider-pthread.h"
 
+#define DATABASE_FILE tzplatform_mkpath(TZ_USER_DB,".download-provider.db")
+
 //BASIC
 #define DP_DB_BASIC_GET_QUERY_FORMAT "SELECT %s FROM %s WHERE id = ?"
 #define DP_DB_BASIC_SET_QUERY_FORMAT "UPDATE %s SET %s = ? WHERE id = ?"