summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@open.eurogiciel.org>2014-02-14 16:53:25 +0100
committerJosé Bollo <jose.bollo@open.eurogiciel.org>2014-02-19 15:08:38 +0100
commit4c76df1a86b356aefbc9faf5f5ba48fa3f0cde6d (patch)
treecbcf6c28114fdde1dcf534a38bc396814adedf73
parent5989bdf8a27392f56de66b3b093d853e92093aa9 (diff)
downloadprivacy-manager-4c76df1a86b356aefbc9faf5f5ba48fa3f0cde6d.tar.gz
privacy-manager-4c76df1a86b356aefbc9faf5f5ba48fa3f0cde6d.tar.bz2
privacy-manager-4c76df1a86b356aefbc9faf5f5ba48fa3f0cde6d.zip
Adding multi user capability
Bug-Tizen: PTREL-264 Change-Id: I6c5aeb64471d579b2a0d317fb8a01a3114aed7b4 Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
-rw-r--r--client/CMakeLists.txt2
-rw-r--r--client/src/PrivacyChecker.cpp4
-rw-r--r--common/inc/PrivacyManagerTypes.h5
-rw-r--r--common/src/PrivacyDb.cpp16
-rw-r--r--common/src/PrivacyIdInfo.cpp8
-rw-r--r--packaging/privacy-manager.spec11
-rwxr-xr-xres/usr/bin/privacy_manager_create_clean_db.sh19
-rw-r--r--server/CMakeLists.txt2
8 files changed, 35 insertions, 32 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 6930aeb..4a6f526 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -8,7 +8,7 @@ SET(LIBDIR ${LIB_INSTALL_DIR})
SET(INCLUDEDIR ${INCLUDE_INSTALL_DIR})
INCLUDE(FindPkgConfig)
-pkg_check_modules(privacy-manager-client REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info)
+pkg_check_modules(privacy-manager-client REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info libtzplatform-config)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/client/src/PrivacyChecker.cpp b/client/src/PrivacyChecker.cpp
index dac7b16..c856f85 100644
--- a/client/src/PrivacyChecker.cpp
+++ b/client/src/PrivacyChecker.cpp
@@ -319,7 +319,7 @@ PrivacyChecker::updateCache(const std::string pkgId, std::string privacyId, std:
{
static const std::string PrivacyQuery = "SELECT IS_ENABLED from PrivacyInfo where PKG_ID=? and PRIVACY_ID=?";
- openDb(PRIVACY_DB_PATH.c_str(), pDbH, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_DB_PATH, pDbH, SQLITE_OPEN_READONLY);
prepareDb(pDbH, PrivacyQuery.c_str(), pPrivacyStmt);
int res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
TryReturn( res == 0, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
@@ -346,7 +346,7 @@ PrivacyChecker::updateCache(std::string pkgId, std::map < std::string, bool >& p
pkgCacheMap.clear();
- openDb(PRIVACY_DB_PATH.c_str(), pDbH, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_DB_PATH, pDbH, SQLITE_OPEN_READONLY);
prepareDb(pDbH, PrivacyQuery.c_str(), pPrivacyStmt);
int res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
diff --git a/common/inc/PrivacyManagerTypes.h b/common/inc/PrivacyManagerTypes.h
index becb451..0e994d1 100644
--- a/common/inc/PrivacyManagerTypes.h
+++ b/common/inc/PrivacyManagerTypes.h
@@ -19,9 +19,10 @@
#include <string>
#include <privacy_manager_client_types.h>
+#include <tzplatform_config.h>
-static const std::string PRIVACY_DB_PATH("/opt/dbspace/.privacy.db");
-static const std::string PRIVACY_INFO_DB_PATH("/opt/dbspace/.privacylist.db");
+#define PRIVACY_DB_PATH tzplatform_mkpath(TZ_SYS_DB,".privacy.db")
+#define PRIVACY_INFO_DB_PATH tzplatform_mkpath(TZ_SYS_DB,".privacylist.db")
static const std::string SERVER_ADDRESS ("/tmp/privacy_manager_server");
static const std::string DBUS_PATH("/privacy_manager/dbus_notification");
static const std::string DBUS_SIGNAL_INTERFACE("org.tizen.privacy_manager.signal");
diff --git a/common/src/PrivacyDb.cpp b/common/src/PrivacyDb.cpp
index acd91a7..f577edd 100644
--- a/common/src/PrivacyDb.cpp
+++ b/common/src/PrivacyDb.cpp
@@ -71,7 +71,7 @@ PrivacyDb::setPrivacySetting(const std::string pkgId, const std::string privacyI
{
static const std::string query = std::string("UPDATE PrivacyInfo set IS_ENABLED =? where PKG_ID=? and PRIVACY_ID=?");
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READWRITE);
prepareDb(pDbHandler, query.c_str(), pStmt);
int res = sqlite3_bind_int(pStmt.get(), 1, enabled);
@@ -94,7 +94,7 @@ PrivacyDb::getPrivacyAppPackages(std::list <std::string>& list) const
{
std::string query = "SELECT PKG_ID from PackageInfo";
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, query.c_str(), pStmt);
while ( sqlite3_step(pStmt.get()) == SQLITE_ROW )
@@ -120,7 +120,7 @@ PrivacyDb::getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pa
{
static const std::string query = "SELECT PRIVACY_ID, IS_ENABLED from PrivacyInfo where PKG_ID=?";
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, query.c_str(), pStmt);
int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
@@ -146,7 +146,7 @@ PrivacyDb::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < s
static const std::string pkgInfoQuery("INSERT INTO PackageInfo(PKG_ID, IS_SET) VALUES(?, ?)");
static const std::string privacyQuery("INSERT INTO PrivacyInfo(PKG_ID, PRIVACY_ID, IS_ENABLED) VALUES(?, ?, ?)");
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READWRITE);
prepareDb(pDbHandler, pkgInfoQuery.c_str(), pPkgInfoStmt);
int res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
@@ -190,7 +190,7 @@ PrivacyDb::removeAppPackagePrivacyInfo(const std::string pkgId)
int res;
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READWRITE);
prepareDb(pDbHandler, pkgInfoQuery.c_str(), pPkgInfoStmt);
res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
@@ -223,7 +223,7 @@ PrivacyDb::isUserPrompted(const std::string pkgId, bool& isPrompted) const
return 0;
}
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, query.c_str(), pStmt);
int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
@@ -251,7 +251,7 @@ PrivacyDb::setUserPrompted(const std::string pkgId, bool prompted)
int res;
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READWRITE);
prepareDb(pDbHandler, query.c_str(), pStmt);
res = sqlite3_bind_int(pStmt.get(), 1, prompted? 1 : 0);
@@ -271,7 +271,7 @@ PrivacyDb::getAppPackagesbyPrivacyId(std::string privacyId, std::list < std::pai
{
std::string sql = std::string("SELECT PKG_ID, IS_ENABLED from PrivacyInfo where PRIVACY_ID=?");
- openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+ openDb(PRIVACY_DB_PATH, pDbHandler, SQLITE_OPEN_READWRITE);
prepareDb(pDbHandler, sql.c_str(), pStmt);
SECURE_LOGD("privacy id : %s", privacyId.c_str());
diff --git a/common/src/PrivacyIdInfo.cpp b/common/src/PrivacyIdInfo.cpp
index 5102c53..ba651d8 100644
--- a/common/src/PrivacyIdInfo.cpp
+++ b/common/src/PrivacyIdInfo.cpp
@@ -32,7 +32,7 @@ PrivacyIdInfo::initialize(void)
static const std::string sqlPrivilege("SELECT PRIVILEGE_ID, PRIVACY_ID from PrivilegeToPrivacyTable");
static const std::string sqlPrivacyInfo("SELECT FEATURE FROM PrivacyInfo where PRIVACY_ID=?");
- openDb(PRIVACY_INFO_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_INFO_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, sqlPrivilege.c_str(), pStmtPrivilege);
int res;
@@ -154,7 +154,7 @@ PrivacyIdInfo::getAllPrivacyId(std::list< std::string >& privacyIdList)
initialize();
}
- openDb(PRIVACY_INFO_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_INFO_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, sql.c_str(), pStmt);
int res;
@@ -192,7 +192,7 @@ PrivacyIdInfo::getPrivaycDisplayName(const std::string privacyId, std::string& d
std::string sql = std::string("SELECT STR_MODULE_ID, STR_NAME_ID from PrivacyInfo where PRIVACY_ID=?");
- openDb(PRIVACY_INFO_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_INFO_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, sql.c_str(), pStmt);
int res = sqlite3_bind_text(pStmt.get(), 1, privacyId.c_str(), -1, SQLITE_TRANSIENT);
@@ -231,7 +231,7 @@ PrivacyIdInfo::getPrivaycDescription(const std::string privacyId, std::string& d
std::string sql = std::string("SELECT STR_MODULE_ID, STR_NAME_ID from PrivacyInfo where PRIVACY_ID=?");
- openDb(PRIVACY_INFO_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+ openDb(PRIVACY_INFO_DB_PATH, pDbHandler, SQLITE_OPEN_READONLY);
prepareDb(pDbHandler, sql.c_str(), pStmt);
int res = sqlite3_bind_text(pStmt.get(), 1, privacyId.c_str(), -1, SQLITE_TRANSIENT);
diff --git a/packaging/privacy-manager.spec b/packaging/privacy-manager.spec
index cfbb461..f963fbd 100644
--- a/packaging/privacy-manager.spec
+++ b/packaging/privacy-manager.spec
@@ -24,6 +24,7 @@ BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(libtzplatform-config)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
@@ -92,8 +93,8 @@ make %{?_smp_mflags}
%install
mkdir -p %{buildroot}%{_prefix}/bin
cp res/usr/bin/* %{buildroot}%{_bindir}/
-mkdir -p %{buildroot}/opt/dbspace
-cp res/opt/dbspace/.privacylist.db /%{buildroot}/opt/dbspace/
+mkdir -p %{buildroot}%{TZ_SYS_DB}
+cp res/opt/dbspace/.privacylist.db /%{buildroot}%{TZ_SYS_DB}
mkdir -p %{buildroot}%{_datadir}/privacy-manager/
cp res/usr/share/privacy-manager/privacy-filter-list.ini %{buildroot}%{_datadir}/privacy-manager/
@@ -108,10 +109,10 @@ mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
/sbin/ldconfig
echo "Check privacy DB"
-if [ ! -f /opt/dbspace/.privacy.db ]
+if [ ! -f %{TZ_SYS_DB}/.privacy.db ]
then
echo "Create privacy DB"
- /usr/bin/privacy_manager_create_clean_db.sh
+ %{_bindir}/privacy_manager_create_clean_db.sh
fi
%postun -p /sbin/ldconfig
@@ -129,7 +130,7 @@ fi
%license LICENSE.APLv2
%manifest privacy-manager-server.manifest
%{_libdir}/libprivacy-manager-server.so*
-/opt/dbspace/.privacylist.db
+%{TZ_SYS_DB}/.privacylist.db
/usr/bin/*
%files -n privacy-manager-server-devel
diff --git a/res/usr/bin/privacy_manager_create_clean_db.sh b/res/usr/bin/privacy_manager_create_clean_db.sh
index 3a366c0..5f47112 100755
--- a/res/usr/bin/privacy_manager_create_clean_db.sh
+++ b/res/usr/bin/privacy_manager_create_clean_db.sh
@@ -13,19 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+source /etc/tizen-platform.conf
for name in privacy
do
- rm -f /opt/dbspace/.$name.db
- rm -f /opt/dbspace/.$name.db-journal
+ rm -f ${TZ_SYS_DB}/.$name.db
+ rm -f ${TZ_SYS_DB}/.$name.db-journal
SQL="PRAGMA journal_mode = PERSIST;"
- sqlite3 /opt/dbspace/.$name.db "$SQL"
+ sqlite3 ${TZ_SYS_DB}/.$name.db "$SQL"
SQL=".read /usr/bin/"$name"_db.sql"
- sqlite3 /opt/dbspace/.$name.db "$SQL"
- touch /opt/dbspace/.$name.db-journal
- chown 0:0 /opt/dbspace/.$name.db
- chown 0:0 /opt/dbspace/.$name.db-journal
- chmod 664 /opt/dbspace/.$name.db
- chmod 664 /opt/dbspace/.$name.db-journal
+ sqlite3 ${TZ_SYS_DB}/.$name.db "$SQL"
+ touch ${TZ_SYS_DB}/.$name.db-journal
+ chown root:root ${TZ_SYS_DB}/.$name.db
+ chown root:root ${TZ_SYS_DB}/.$name.db-journal
+ chmod 664 ${TZ_SYS_DB}/.$name.db
+ chmod 664 ${TZ_SYS_DB}/.$name.db-journal
done
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
index f62ae61..ec51d1a 100644
--- a/server/CMakeLists.txt
+++ b/server/CMakeLists.txt
@@ -7,7 +7,7 @@ SET(EXEC_PREFIX "\${prefix}")
SET(INCLUDEDIR "\${prefix}/include")
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info)
+pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info libtzplatform-config)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")