Integrate privilege DBs 10/167810/3
authorYunjin Lee <yunjin-.lee@samsung.com>
Mon, 22 Jan 2018 07:19:24 +0000 (16:19 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Mon, 22 Jan 2018 07:44:38 +0000 (16:44 +0900)
- Integrate privilege DBs into one: (old) core_privilege_info.db,
    core_privilege_mapping.db, wrt_privilege_info.db, and
    wrt_privilege_mapping.db into (new) privilege.db

- Use sqlite csv import function instead of parsing csv file.
It cuts down required time for rpm build.

- privilege_info table contains core/wrt privilege definition.

- privilege_mapping table contains core/wrt privilege mapping
information.

- privacy_privilege_info.csv file contains privacy privilege of each
profile. We can handle privacy privileges according to the profile.
(For example, privilege A can be a privacy privilege in profile 'mobile' and
 non-privacy privilege in profile 'tv')

- Modified DB queries accordingly.

- Update release version.

- TODO: remove profile and version from privilege information except
default privilege mapping.

Change-Id: Ie14e92092aadc81734d7082e4bb67be26a9cdf84
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
20 files changed:
capi/CMakeLists.txt
capi/res/dbspace/CMakeLists.txt
capi/res/dbspace/core_db_generator.sh [deleted file]
capi/res/dbspace/core_mapping_db_generator.sh [deleted file]
capi/res/dbspace/core_privilege_mapping.csv
capi/res/dbspace/privacy_privilege_info.csv [new file with mode: 0644]
capi/res/dbspace/privilege_db_generator.sh [new file with mode: 0755]
capi/res/dbspace/schema.sql [new file with mode: 0644]
capi/res/dbspace/tv_core_db_generator.sh [deleted file]
capi/res/dbspace/tv_core_mapping_db_generator.sh [deleted file]
capi/res/dbspace/tv_core_privilege_mapping.csv
capi/res/dbspace/tv_wrt_db_generator.sh [deleted file]
capi/res/dbspace/tv_wrt_mapping_db_generator.sh [deleted file]
capi/res/dbspace/tv_wrt_privilege_mapping.csv
capi/res/dbspace/wrt_db_generator.sh [deleted file]
capi/res/dbspace/wrt_mapping_db_generator.sh [deleted file]
capi/res/dbspace/wrt_privilege_mapping.csv
capi/src/privilege_db_manager.c
packaging/privilege-checker.spec
tool/CMakeLists.txt

index 61f973c..bf16a6c 100644 (file)
@@ -93,10 +93,7 @@ ADD_CUSTOM_COMMAND(
 ENDIF(UNIX)
 
 SET(PRIVILEGE_DB_DIR "${DATADIR}/privilege-manager")
-ADD_DEFINITIONS(-DPRIVILEGE_INFO_CORE_DB_PATH="${PRIVILEGE_DB_DIR}/.core_privilege_info.db")
-ADD_DEFINITIONS(-DPRIVILEGE_INFO_WRT_DB_PATH="${PRIVILEGE_DB_DIR}/.wrt_privilege_info.db")
-ADD_DEFINITIONS(-DPRIVILEGE_MAPPING_CORE_DB_PATH="${PRIVILEGE_DB_DIR}/.core_privilege_mapping.db")
-ADD_DEFINITIONS(-DPRIVILEGE_MAPPING_WRT_DB_PATH="${PRIVILEGE_DB_DIR}/.wrt_privilege_mapping.db")
+ADD_DEFINITIONS(-DPRIVILEGE_DB_PATH="${PRIVILEGE_DB_DIR}/.privilege.db")
 ADD_DEFINITIONS(-DPRIVILEGE_POLICY_DB_PATH="${TZ_SYS_DB}/.policy.db")
 ADD_DEFINITIONS(-DPRIVILEGE_PRIVACY_DB_PATH="${TZ_SYS_DB}/.privacy.db")
 ADD_DEFINITIONS(-DASKUSER_RUNTIME_DISABLE_PATH="${TZ_SYS_SHARE}/askuser_disable")
index bb1a333..dd03a85 100644 (file)
@@ -1,53 +1,26 @@
-SET(CORE_PRIVILEGE_DB ".core_privilege_info.db")
-SET(WRT_PRIVILEGE_DB ".wrt_privilege_info.db")
-SET(CORE_PRIVILEGE_MAPPING_DB ".core_privilege_mapping.db")
-SET(WRT_PRIVILEGE_MAPPING_DB ".wrt_privilege_mapping.db")
+SET(PRIVILEGE_DB ".privilege.db")
 SET(POLICY_DB ".policy.db")
 SET(PRIVACY_DB ".privacy.db")
 
-SET(CORE_PRIVILEGE_DB_MOBILE ".core_privilege_info.mobile.db")
-SET(WRT_PRIVILEGE_DB_MOBILE ".wrt_privilege_info.mobile.db")
-SET(CORE_PRIVILEGE_MAPPING_DB_MOBILE ".core_privilege_mapping.mobile.db")
-SET(WRT_PRIVILEGE_MAPPING_DB_MOBILE ".wrt_privilege_mapping.mobile.db")
+SET(PRIVILEGE_DB_TV ".privilege.tv.db")
+SET(PRIVILEGE_DB_MOBILE ".privilege.mobile.db")
+SET(PRIVILEGE_DB_WEARABLE ".privilege.wearable.db")
 
-SET(CORE_PRIVILEGE_DB_TV ".core_privilege_info.tv.db")
-SET(WRT_PRIVILEGE_DB_TV ".wrt_privilege_info.tv.db")
-SET(CORE_PRIVILEGE_MAPPING_DB_TV ".core_privilege_mapping.tv.db")
-SET(WRT_PRIVILEGE_MAPPING_DB_TV ".wrt_privilege_mapping.tv.db")
-
-SET(CORE_PRIVILEGE_DB_WEARABLE ".core_privilege_info.wearable.db")
-SET(WRT_PRIVILEGE_DB_WEARABLE ".wrt_privilege_info.wearable.db")
-SET(CORE_PRIVILEGE_MAPPING_DB_WEARABLE ".core_privilege_mapping.wearable.db")
-SET(WRT_PRIVILEGE_MAPPING_DB_WEARABLE ".wrt_privilege_mapping.wearable.db")
-
-# Create TV DB / WEARABLE DB / MOBILE DB
 ADD_CUSTOM_COMMAND(
-       OUTPUT ${POLICY_DB} ${PRIVACY_DB}
-               ${CORE_PRIVILEGE_DB_TV} ${WRT_PRIVILEGE_DB_TV} ${CORE_PRIVILEGE_MAPPING_DB_TV} ${WRT_PRIVILEGE_MAPPING_DB_TV}
-               ${CORE_PRIVILEGE_DB_WEARABLE} ${WRT_PRIVILEGE_DB_WEARABLE} ${CORE_PRIVILEGE_MAPPING_DB_WEARABLE} ${WRT_PRIVILEGE_MAPPING_DB_WEARABLE}
-               ${CORE_PRIVILEGE_DB_MOBILE} ${WRT_PRIVILEGE_DB_MOBILE} ${CORE_PRIVILEGE_MAPPING_DB_MOBILE} ${WRT_PRIVILEGE_MAPPING_DB_MOBILE}
-               COMMAND ./policy_db_generator.sh && ./privacy_db_generator.sh &&
-               ./tv_core_db_generator.sh && ./tv_wrt_db_generator.sh && ./tv_core_mapping_db_generator.sh && ./tv_wrt_mapping_db_generator.sh &&
-                       mv ${CORE_PRIVILEGE_DB} ${CORE_PRIVILEGE_DB_TV} && mv ${WRT_PRIVILEGE_DB} ${WRT_PRIVILEGE_DB_TV} &&
-                       mv ${CORE_PRIVILEGE_MAPPING_DB} ${CORE_PRIVILEGE_MAPPING_DB_TV} && mv ${WRT_PRIVILEGE_MAPPING_DB} ${WRT_PRIVILEGE_MAPPING_DB_TV} &&
-               ./core_db_generator.sh wearable && ./wrt_db_generator.sh wearable && ./core_mapping_db_generator.sh wearable && ./wrt_mapping_db_generator.sh wearable &&
-                       mv ${CORE_PRIVILEGE_DB} ${CORE_PRIVILEGE_DB_WEARABLE} && mv ${WRT_PRIVILEGE_DB} ${WRT_PRIVILEGE_DB_WEARABLE} &&
-                       mv ${CORE_PRIVILEGE_MAPPING_DB} ${CORE_PRIVILEGE_MAPPING_DB_WEARABLE} && mv ${WRT_PRIVILEGE_MAPPING_DB} ${WRT_PRIVILEGE_MAPPING_DB_WEARABLE} &&
-               ./core_db_generator.sh mobile && ./wrt_db_generator.sh mobile && ./core_mapping_db_generator.sh mobile && ./wrt_mapping_db_generator.sh mobile &&
-                       mv ${CORE_PRIVILEGE_DB} ${CORE_PRIVILEGE_DB_MOBILE} && mv ${WRT_PRIVILEGE_DB} ${WRT_PRIVILEGE_DB_MOBILE} &&
-                       mv ${CORE_PRIVILEGE_MAPPING_DB} ${CORE_PRIVILEGE_MAPPING_DB_MOBILE} && mv ${WRT_PRIVILEGE_MAPPING_DB} ${WRT_PRIVILEGE_MAPPING_DB_MOBILE}
+    OUTPUT ${POLICY_DB} ${PRIVACY_DB}
+               ${PRIVILEGE_DB_TV} ${PRIVILEGE_DB_MOBILE} ${PRIVILEGE_DB_WEARABLE}
+        COMMAND ./policy_db_generator.sh && ./privacy_db_generator.sh &&
+                               ./privilege_db_generator.sh tv && mv ${PRIVILEGE_DB} ${PRIVILEGE_DB_TV} &&
+                               ./privilege_db_generator.sh mobile && mv ${PRIVILEGE_DB} ${PRIVILEGE_DB_MOBILE} &&
+                               ./privilege_db_generator.sh wearable && mv ${PRIVILEGE_DB} ${PRIVILEGE_DB_WEARABLE}
 )
 
 ADD_CUSTOM_TARGET(privilege-db ALL DEPENDS ${POLICY_DB} ${PRIVACY_DB}
-                                       ${CORE_PRIVILEGE_DB_TV} ${WRT_PRIVILEGE_DB_TV} ${CORE_PRIVILEGE_MAPPING_DB_TV} ${WRT_PRIVILEGE_MAPPING_DB_TV}
-                                       ${CORE_PRIVILEGE_DB_WEARABLE} ${WRT_PRIVILEGE_DB_WEARABLE} ${CORE_PRIVILEGE_MAPPING_DB_WEARABLE} ${WRT_PRIVILEGE_MAPPING_DB_WEARABLE}
-                                       ${CORE_PRIVILEGE_DB_MOBILE} ${WRT_PRIVILEGE_DB_MOBILE} ${CORE_PRIVILEGE_MAPPING_DB_MOBILE} ${WRT_PRIVILEGE_MAPPING_DB_MOBILE}
+                                                                                       ${PRIVILEGE_DB_TV} ${PRIVILEGE_DB_MOBILE} ${PRIVILEGE_DB_WEARABLE}
 )
 
-INSTALL(FILES ${CORE_PRIVILEGE_DB_TV} ${WRT_PRIVILEGE_DB_TV} ${CORE_PRIVILEGE_MAPPING_DB_TV} ${WRT_PRIVILEGE_MAPPING_DB_TV}
-               ${CORE_PRIVILEGE_DB_WEARABLE} ${WRT_PRIVILEGE_DB_WEARABLE} ${CORE_PRIVILEGE_MAPPING_DB_WEARABLE} ${WRT_PRIVILEGE_MAPPING_DB_WEARABLE}
-               ${CORE_PRIVILEGE_DB_MOBILE} ${WRT_PRIVILEGE_DB_MOBILE} ${CORE_PRIVILEGE_MAPPING_DB_MOBILE} ${WRT_PRIVILEGE_MAPPING_DB_MOBILE}
-               DESTINATION ${DATADIR}/privilege-manager/
+INSTALL(FILES ${PRIVILEGE_DB_TV} ${PRIVILEGE_DB_WEARABLE} ${PRIVILEGE_DB_MOBILE}
+                       DESTINATION ${DATADIR}/privilege-manager/
 )
 
 INSTALL(FILES ${POLICY_DB} ${POLICY_DB}-journal ${PRIVACY_DB} ${PRIVACY_DB}-journal DESTINATION ${TZ_SYS_DB}/)
diff --git a/capi/res/dbspace/core_db_generator.sh b/capi/res/dbspace/core_db_generator.sh
deleted file mode 100755 (executable)
index 66add2d..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".core_privilege_info.db"
-
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-target_profile=$1
-PRIVACYLIST_CSV="privacylist.csv"
-PRIVACY_WHITELIST_CSV="$target_profile""_privacy_whitelist.csv"
-
-echo "Creating PRIVILEGE_INFO table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_INFO (PROFILE_ID NUMERIC, PROFILE TEXT, PACKAGE_TYPE_ID NUMERIC, PACKAGE_TYPE TEXT, PRIVILEGE_LEVEL_ID NUMERIC, PRIVILEGE_LEVEL TEXT, API_VERSION_ISSUED TEXT, API_VERSION_EXPIRED TEXT, DOCUMENTED INTEGER, PRIVILEGE_NAME TEXT, IS_PRIVACY NUMERIC, PRIVACY_NAME TEXT, PRIVILEGE_DISPLAY TEXT, PRIVILEGE_DESCRIPTION TEXT, PRIVILEGE_GROUP_ID NUMERIC, PRIVLEGE_GROUP TEXT, CHANGED_TO_2_3_1 TEXT, CHANGED_TO_2_4_0 TEXT);"
-
-echo "Create VALID_PRIVILEGE_INFO Table..."
-sqlite3 $DB_NAME "CREATE TABLE VALID_PRIVILEGE_INFO (PRIVILEGE_NAME TEXT UNIQUE, IS_PRIVACY NUMERIC, PRIVACY_NAME TEXT, IS_INTERNAL NUMERIC);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-
-for i in `cat core_privilege_info.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-       elif [ ! "$PROFILE" = "$target_profile" ]
-       then
-               continue
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PACKAGE_TYPE=`echo $i | cut -d "," -f 2`
-       PRIVILEGE_GROUP=`echo $i | cut -d "," -f 13`
-
-       if [ "$PACKAGE_TYPE" = "wrt" ]
-       then
-               PACKAGE_TYPE_ID=0
-
-       elif [ "$PACKAGE_TYPE" = "core" ]
-       then
-               PACKAGE_TYPE_ID=1
-       elif [ "$PACKAGE_TYPE" = "metadata" ]
-       then
-               PACKAGE_TYPE_ID=2
-               PRIVILEGE_GROUP="IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB"
-
-       else
-               echo "Fail to create table : PACKAGE_TYPE must be metadata, wrt or core"
-               exit
-       fi
-
-       PRIVILEGE_LEVEL=`echo $i | cut -d "," -f 3`
-
-       if [ "$PRIVILEGE_LEVEL" = "public" ]
-       then
-               PRIVILEGE_LEVEL_ID=0
-
-       elif [ "$PRIVILEGE_LEVEL" = "partner" ]
-       then
-               PRIVILEGE_LEVEL_ID=1
-
-       elif [ "$PRIVILEGE_LEVEL" = "platform" ]
-       then
-               PRIVILEGE_LEVEL_ID=2
-
-       else
-               echo "Fail to create table : PRIVILEGE_LEVEL must be public, partner or platform"
-               exit
-       fi
-
-       API_VERSION_ISSUED=`echo $i | cut -d "," -f 4`
-       API_VERSION_EXPIRED=`echo $i | cut -d "," -f 5`
-       DOCUMENTED=`echo $i | cut -d "," -f 6`
-
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 7`
-
-       IS_PRIVACY_TEXT=`echo $i | cut -d "," -f 8`
-       if [ "$IS_PRIVACY_TEXT" = "yes" ]
-       then
-               IS_PRIVACY=1
-       elif [ "$IS_PRIVACY_TEXT" = "no" ]
-       then
-               IS_PRIVACY=0
-       else
-               echo "Fail to create table : IS_PRIVACY must be yes or no"
-               exit
-       fi
-
-       PRIVACY_NAME=`echo $i | cut -d "," -f 9`
-
-       PRIVILEGE_DISPLAY=`echo $i | cut -d "," -f 11`
-
-       PRIVILEGE_DESCRIPTION=`echo $i | cut -d "," -f 12`
-
-       #PRIVILEGE_GROUP=`echo $i | cut -d "," -f 13`
-
-       if [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=0
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_OPT_LOCATION_T_LBS" ]
-       then
-               PRIVILEGE_GROUP_ID=1
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=2
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=3
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=4
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=5
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=6
-
-       else
-               echo "PRIVILEGE_GROUP = $PRIVILEGE_GROUP"
-               echo "Fail to create table : PRIVILEGE_GROUP must be one of them below"
-               echo "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB"
-               echo "IDS_TPLATFORM_OPT_LOCATION_T_LBS"
-               echo "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB"
-               echo "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB"
-               echo "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB"
-               echo "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB"
-               echo "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB"
-               exit
-       fi
-
-       CHANGED_TO_2_3_1=`echo $i | cut -d "," -f 14`
-       CHANGED_TO_2_4_0=`echo $i | cut -d "," -f 15`
-
-       echo "Inserting $PRIVILEGE_NAME ..."
-
-       sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$IS_PRIVACY', '$PRIVACY_NAME', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP', '$CHANGED_TO_2_3_1', '$CHANGED_TO_2_4_0')"
-       sqlite3 $DB_NAME "insert into valid_privilege_info (privilege_name, is_privacy, privacy_name, is_internal) values ('$PRIVILEGE_NAME', '$IS_PRIVACY', '$PRIVACY_NAME', 0)"
-done
-
-for internal_privilege in `cat internal_only.list`
-do
-       echo "Inserting $internal_privilege ..."
-       sqlite3 $DB_NAME "insert into valid_privilege_info (privilege_name, is_privacy, privacy_name, is_internal) values ('$internal_privilege', 0, 'N/A', 1)"
-done
-
-echo "Create PRIVACY_INFO table..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVACY_INFO (PRIVACY_NAME TEXT UNIQUE, PRIVACY_ID NUMERIC, PRIVACY_DISPLAY TEXT);"
-echo "Insert into privacy_info ...."
-PRIVACY_ID=0
-for i in `cat $PRIVACYLIST_CSV`
-do
-    temp=`echo $i | awk '/^#/'`
-    if [ ! "$temp" = "" ]
-    then
-        continue
-    fi
-       PRIVACY_NAME=`echo $i | cut -d "," -f1`
-       PRIVACY_NAME_ONLY=`echo $PRIVACY_NAME | cut -d "/" -f5`
-       declare ${PRIVACY_NAME_ONLY}=$((PRIVACY_ID))
-       PRIVACY_DISPLAY=`echo $i | cut -d "," -f2`
-       echo "Insert $PRIVACY_NAME, PRIVACY_ID = $PRIVACY_ID "
-       sqlite3 $DB_NAME "insert into privacy_info (privacy_name, privacy_id, privacy_display) values ('$PRIVACY_NAME', $((PRIVACY_ID++)), '$PRIVACY_DISPLAY')"
-done
-
-echo "Create PRIVACY_WHITELIST table..."
-CREATE_WHITELIST_TABLE_QUERY="CREATE TABLE PRIVACY_WHITELIST (PKG_ID TEXT, PRIVACY_OPTION TEXT, SETTABLE TEXT);"
-sqlite3 $DB_NAME "$CREATE_WHITELIST_TABLE_QUERY"
-echo "insert into privacy_whiteliste ...."
-for i in `cat $PRIVACY_WHITELIST_CSV`
-do
-    temp=`echo $i | awk '/^#/'`
-    if [ ! "$temp" = "" ]
-    then
-        continue
-    fi
-       PKG_ID=`echo $i | cut -d "," -f1`
-       PRIVACY_OPTION=`echo $i | cut -d "," -f2`
-       #echo "first char ${PRIVACY_OPTION:0:1}"
-       IFS='-+ ' read -r -a array <<< $PRIVACY_OPTION
-       # init
-       TEMP=0
-       while [ $((TEMP)) -lt $((PRIVACY_ID)) ]
-       do
-               option_array[$((TEMP++))]=0
-       done
-       # privacy list set
-       for element in "${array[@]}"
-       do
-               if [ "$element" = "*" ]; then
-                       TEMP=0
-                       while [ $((TEMP)) -lt $PRIVACY_ID ]
-                       do
-                               option_array[$((TEMP++))]=1
-                       done
-               else
-                       if [ "${option_array[${element}]}" = "1" ]; then
-                               option_array[${element}]=0
-                       else
-                               option_array[${element}]=1
-                       fi
-               fi
-       done
-       SETTABLE=`echo $i | cut -d "," -f3`
-       # privacy option string
-       TEMP=0
-       PRIVACY_OPTION_STRING=""
-       while [ $((TEMP)) -lt $((PRIVACY_ID)) ]
-       do
-               PRIVACY_OPTION_STRING="$PRIVACY_OPTION_STRING""${option_array[$((TEMP++))]}"
-       done
-       echo "PKG_ID=$PKG_ID, PRIVACY_OPTION=$PRIVACY_OPTION_STRING, SETTABLE=$SETTABLE"
-       sqlite3 $DB_NAME "insert into privacy_whitelist values ('$PKG_ID', '$PRIVACY_OPTION_STRING', '$SETTABLE')"
-done
-
diff --git a/capi/res/dbspace/core_mapping_db_generator.sh b/capi/res/dbspace/core_mapping_db_generator.sh
deleted file mode 100755 (executable)
index 525aa71..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".core_privilege_mapping.db"
-
-target_profile=$1
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-echo "Creating PRIVILEGE_MAPPING table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_MAPPING (PROFILE_ID NUMERIC, PROFILE TEXT, PRIVILEGE_NAME TEXT, FROM_API_VERSION TEXT, TO_API_VERSION TEXT, MAPPED_PRIVILEGE_NAME TEXT);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat core_privilege_mapping.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-       elif [ ! "$PROFILE" = "$target_profile" ]
-       then
-               continue
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 2`
-       FROM_API_VERSION=`echo $i | cut -d "," -f 3`
-       TO_API_VERSION=`echo $i | cut -d "," -f 4`
-       MAPPED_PRIVILEGE_NAME=`echo $i | cut -d "," -f 5`
-
-       echo "Inserting $PRIVILEGE_NAME $MAPPED_PRIVILEGE_NAME..."
-
-       sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
-       if [[ $MAPPED_PRIVILEGE_NAME == *"/internal/"* ]]; then
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 1)"
-       else
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 0)"
-       fi
-done
-
index a194f52..366ae91 100644 (file)
@@ -1,4 +1,4 @@
-#PROFILE,#PRIVILEGE_NAME,#FROM,#TO,#MAPPED_PRIVILEGE_NAME
+#PROFILE,#PRIVILEGE_NAME,#FROM_API_VERSION,#TO_API_VERSION,#MAPPED_PRIVILEGE_NAME
 mobile,http://tizen.org/privilege/account.read,2.3,9.9,http://tizen.org/privilege/account.read
 mobile,http://tizen.org/privilege/account.read,2.3,9.9,http://tizen.org/privilege/internal/buxton/account.read
 wearable,http://tizen.org/privilege/account.read,3,9.9,http://tizen.org/privilege/account.read
diff --git a/capi/res/dbspace/privacy_privilege_info.csv b/capi/res/dbspace/privacy_privilege_info.csv
new file mode 100644 (file)
index 0000000..c7b068f
--- /dev/null
@@ -0,0 +1,44 @@
+#PROFILE,#PRIVILEGE_NAME,#PRIVACY_NAME
+mobile,http://tizen.org/privilege/account.read,http://tizen.org/privacy/account
+mobile,http://tizen.org/privilege/account.write,http://tizen.org/privacy/account
+mobile,http://tizen.org/privilege/bookmark.admin,http://tizen.org/privacy/bookmark
+mobile,http://tizen.org/privilege/calendar.read,http://tizen.org/privacy/calendar
+mobile,http://tizen.org/privilege/calendar.write,http://tizen.org/privacy/calendar
+mobile,http://tizen.org/privilege/call,http://tizen.org/privacy/call
+mobile,http://tizen.org/privilege/camera,http://tizen.org/privacy/camera
+mobile,http://tizen.org/privilege/contact.read,http://tizen.org/privacy/contacts
+mobile,http://tizen.org/privilege/contact.write,http://tizen.org/privacy/contacts
+mobile,http://tizen.org/privilege/location.coarse,http://tizen.org/privacy/location
+mobile,http://tizen.org/privilege/location,http://tizen.org/privacy/location
+mobile,http://tizen.org/privilege/location.enable,http://tizen.org/privacy/location
+mobile,http://tizen.org/privilege/message.read,http://tizen.org/privacy/message
+mobile,http://tizen.org/privilege/message.write,http://tizen.org/privacy/message
+mobile,http://tizen.org/privilege/recorder,http://tizen.org/privacy/microphone
+mobile,http://tizen.org/privilege/healthinfo,http://tizen.org/privacy/sensor
+mobile,http://tizen.org/privilege/externalstorage,http://tizen.org/privacy/storage
+mobile,http://tizen.org/privilege/mediastorage,http://tizen.org/privacy/storage
+mobile,http://tizen.org/privilege/apphistory.read,http://tizen.org/privacy/userhistory
+mobile,http://tizen.org/privilege/callhistory.read,http://tizen.org/privacy/userhistory
+mobile,http://tizen.org/privilege/callhistory.write,http://tizen.org/privacy/userhistory
+mobile,http://tizen.org/privilege/mediahistory.read,http://tizen.org/privacy/userhistory
+mobile,http://tizen.org/privilege/web-history.admin,http://tizen.org/privacy/userhistory
+wearable,http://tizen.org/privilege/account.read,http://tizen.org/privacy/account
+wearable,http://tizen.org/privilege/account.write,http://tizen.org/privacy/account
+wearable,http://tizen.org/privilege/calendar.read,http://tizen.org/privacy/calendar
+wearable,http://tizen.org/privilege/calendar.write,http://tizen.org/privacy/calendar
+wearable,http://tizen.org/privilege/call,http://tizen.org/privacy/call
+wearable,http://tizen.org/privilege/camera,http://tizen.org/privacy/camera
+wearable,http://tizen.org/privilege/contact.read,http://tizen.org/privacy/contacts
+wearable,http://tizen.org/privilege/contact.write,http://tizen.org/privacy/contacts
+wearable,http://tizen.org/privilege/location.coarse,http://tizen.org/privacy/location
+wearable,http://tizen.org/privilege/location,http://tizen.org/privacy/location
+wearable,http://tizen.org/privilege/location.enable,http://tizen.org/privacy/location
+wearable,http://tizen.org/privilege/message.read,http://tizen.org/privacy/message
+wearable,http://tizen.org/privilege/message.write,http://tizen.org/privacy/message
+wearable,http://tizen.org/privilege/recorder,http://tizen.org/privacy/microphone
+wearable,http://tizen.org/privilege/healthinfo,http://tizen.org/privacy/sensor
+wearable,http://tizen.org/privilege/externalstorage,http://tizen.org/privacy/storage
+wearable,http://tizen.org/privilege/mediastorage,http://tizen.org/privacy/storage
+wearable,http://tizen.org/privilege/apphistory.read,http://tizen.org/privacy/userhistory
+wearable,http://tizen.org/privilege/callhistory.read,http://tizen.org/privacy/userhistory
+wearable,http://tizen.org/privilege/callhistory.write,http://tizen.org/privacy/userhistory
diff --git a/capi/res/dbspace/privilege_db_generator.sh b/capi/res/dbspace/privilege_db_generator.sh
new file mode 100755 (executable)
index 0000000..64b7e3d
--- /dev/null
@@ -0,0 +1,210 @@
+#!/bin/bash
+
+#PRIVILEGE_DB_DIR="/usr/share/privilege-manager/"
+PRIVILEGE_DB=$PRIVILEGE_DB_DIR".privilege.db"
+PRIVILEGE_DB_SCHEMA=$PRIVILEGE_DB_DIR"schema.sql"
+
+target_profile=$1
+
+CORE_PRIVILEGE_INFO_CSV=$PRIVILEGE_DB_DIR"core_privilege_info.csv"
+CORE_PRIVILEGE_MAPPING_CSV=$PRIVILEGE_DB_DIR"core_privilege_mapping.csv"
+WRT_PRIVILEGE_INFO_CSV=$PRIVILEGE_DB_DIR"wrt_privilege_info.csv"
+WRT_PRIVILEGE_MAPPING_CSV=$PRIVILEGE_DB_DIR"wrt_privilege_mapping.csv"
+if [ "$target_profile" == "tv" ]; then
+       CORE_PRIVILEGE_INFO_CSV="tv_""$CORE_PRIVILEGE_INFO_CSV"
+       CORE_PRIVILEGE_MAPPING_CSV="tv_""$CORE_PRIVILEGE_MAPPING_CSV"
+       WRT_PRIVILEGE_INFO_CSV="tv_""$WRT_PRIVILEGE_INFO_CSV"
+       WRT_PRIVILEGE_MAPPING_CSV="tv_""$WRT_PRIVILEGE_MAPPING_CSV"
+fi
+PRIVACYLIST_CSV=$PRIVILEGE_DB_DIR"privacylist.csv"
+PRIVACY_WHITELIST_CSV=$PRIVILEGE_DB_DIR"$target_profile""_privacy_whitelist.csv"
+PRIVACY_PRIVILEGE_INFO_CSV=$PRIVILEGE_DB_DIR"privacy_privilege_info.csv"
+
+function privilege_info_migration {
+       if [ -a $1 ]; then
+               echo "privilege info: $1"
+               sed -e "s/#//g" $1 > tmp.csv
+               sqlite3 -csv -separator "," $PRIVILEGE_DB ".import tmp.csv tmp"
+               sed -e "s/#//g" $PRIVACY_PRIVILEGE_INFO_CSV > tmp_privacy.csv
+               sqlite3 -csv -separator "," $PRIVILEGE_DB ".import tmp_privacy.csv tmp_privacy"
+
+               sqlite3 $PRIVILEGE_DB "
+               insert into privilege_info (
+                       profile_id,
+                       profile,
+                       package_type_id,
+                       package_type,
+                       privilege_level_id,
+                       privilege_level,
+                       api_version_issued,
+                       api_version_expired,
+                       documented,
+                       privilege_name,
+                       is_privacy,
+                       privacy_name,
+                       privilege_display,
+                       privilege_description,
+                       privilege_group_id,
+                       privilege_group)
+               select
+                       (case t.profile
+                               when 'common' then 0
+                               when 'mobile' then 1
+                               when 'wearable' then 2
+                               when 'tv' then 3 end),
+                       t.profile,
+                       (case t.package_type
+                               when 'wrt' then 0
+                               when 'core' then 1
+                               when 'metadata' then 2 end),
+                       t.package_type,
+                       (case t.privilege_level
+                               when 'public' then 0
+                               when 'partner' then 1
+                               when 'platform' then 2 end),
+                       t.privilege_level,
+                       t.api_version_issued,
+                       t.api_version_expired,
+                       t.documented,
+                       t.privilege_name,
+                       case when t.package_type='core' and tp.profile='$target_profile' and tp.privacy_name is not null then 1 else 0 end,
+                       case when t.package_type='core' and tp.profile='$target_profile' and tp.privacy_name is not null then tp.privacy_name else 'N/A' end,
+                       t.privilege_display,
+                       t.privilege_description,
+                       (case t.privilege_group
+                               when 'IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB' then 0
+                               when 'IDS_TPLATFORM_OPT_LOCATION_T_LBS' then 1
+                               when 'IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB' then 2
+                               when 'IDS_TPLATFORM_BODY_PAID_SERVICES_ABB' then 3
+                               when 'IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB' then 4
+                               when 'IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB' then 5
+                               when 'IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB' then 6 end),
+                       t.privilege_group
+                       from tmp t left join tmp_privacy tp on t.privilege_name=tp.privilege_name and tp.profile='$target_profile' where t.profile='$target_profile' or t.profile='common'"
+
+               sqlite3 $PRIVILEGE_DB "drop table tmp" "drop table tmp_privacy"
+               rm tmp.csv tmp_privacy.csv
+       fi
+}
+
+function privilege_mapping_migration {
+       if [ -a $1 ]; then
+               echo "privilege mapping: $1"
+               sed -e "s/#//g" $1 > tmp.csv
+
+               sqlite3 -csv -separator "," $PRIVILEGE_DB ".import tmp.csv tmp"
+
+               sqlite3 $PRIVILEGE_DB "
+               insert into privilege_mapping (
+                       profile_id,
+                       profile,
+                       package_type_id,
+                       package_type,
+                       privilege_name,
+                       from_api_version,
+                       to_api_version,
+                       mapped_privilege_name)
+               select
+                       (case profile
+                               when 'common' then 0
+                               when 'mobile' then 1
+                               when 'wearable' then 2
+                               when 'tv' then 3 end),
+                       profile,
+                       $2,
+                       '$3',
+                       privilege_name,
+                       from_api_version,
+                       to_api_version,
+                       mapped_privilege_name
+               from tmp where profile='common' or profile='$target_profile'"
+               sqlite3 $PRIVILEGE_DB "drop table tmp"
+               rm tmp.csv
+       fi
+}
+
+if [ -a $PRIVILEGE_DB ]; then
+       rm $PRIVILEGE_DB
+fi
+
+echo "Creating $PRIVILEGE_DB ..."
+touch $PRIVILEGE_DB
+sqlite3 "$PRIVILEGE_DB" < "$PRIVILEGE_DB_SCHEMA"
+
+privilege_info_migration $CORE_PRIVILEGE_INFO_CSV
+
+privilege_info_migration $WRT_PRIVILEGE_INFO_CSV
+
+privilege_mapping_migration $CORE_PRIVILEGE_MAPPING_CSV 1 'core'
+
+privilege_mapping_migration $WRT_PRIVILEGE_MAPPING_CSV 0 'wrt'
+
+if [ -a $PRIVACYLIST_CSV ];then
+       echo "privacy info"
+       sed -e "s/#//g" $PRIVACYLIST_CSV > tmp.csv
+       sqlite3 -csv -separator "," $PRIVILEGE_DB ".import tmp.csv tmp"
+
+       sqlite3 $PRIVILEGE_DB "insert into privacy_info (privacy_name, privacy_display, privacy_id) select privacy_id, privacy_display, (oid-1) from tmp"
+
+       sqlite3 $PRIVILEGE_DB "drop table tmp"
+       rm tmp.csv
+fi
+
+if [ -a $PRIVACY_WHITELIST_CSV ]; then
+       privacy_info_list=`sqlite3 $PRIVILEGE_DB "select distinct privacy_id, privacy_name from privacy_info"`
+       for i in $privacy_info_list
+       do
+               PRIVACY_ID=`echo $i | cut -d "|" -f1`
+               PRIVACY_NAME=`echo $i | cut -d "|" -f2`
+               PRIVACY_NAME_ONLY=`echo $PRIVACY_NAME | cut -d "/" -f5`
+               declare ${PRIVACY_NAME_ONLY}=$((PRIVACY_ID))
+       done
+
+       PRIVACY_NUM=$((PRIVACY_ID++))
+
+       #echo "Insert data into privacy_whitelist ...."
+       for i in `cat $PRIVACY_WHITELIST_CSV`
+       do
+               temp=`echo $i | awk '/^#/'`
+               if [ ! "$temp" = "" ]
+               then
+                       continue
+               fi
+               PKG_ID=`echo $i | cut -d "," -f1`
+               PRIVACY_OPTION=`echo $i | cut -d "," -f2`
+               IFS='-+ ' read -r -a array <<< $PRIVACY_OPTION
+               # init
+               TEMP=0
+               while [ $((TEMP)) -lt $((PRIVACY_ID)) ]
+               do
+                       option_array[$((TEMP++))]=0
+               done
+               # privacy list set
+               for element in "${array[@]}"
+               do
+                       if [ "$element" = "*" ]; then
+                               TEMP=0
+                               while [ $((TEMP)) -lt $PRIVACY_ID ]
+                               do
+                                       option_array[$((TEMP++))]=1
+                               done
+                       else
+                               if [ "${option_array[${element}]}" = "1" ]; then
+                                       option_array[${element}]=0
+                               else
+                                       option_array[${element}]=1
+                               fi
+                       fi
+               done
+               SETTABLE=`echo $i | cut -d "," -f3`
+               # privacy option string
+               TEMP=0
+               PRIVACY_OPTION_STRING=""
+               while [ $((TEMP)) -lt $((PRIVACY_ID)) ]
+               do
+                       PRIVACY_OPTION_STRING="$PRIVACY_OPTION_STRING""${option_array[$((TEMP++))]}"
+               done
+               #echo "PKG_ID=$PKG_ID, PRIVACY_OPTION=$PRIVACY_OPTION_STRING, SETTABLE=$SETTABLE"
+               sqlite3 $PRIVILEGE_DB "insert into privacy_whitelist(pkg_id, privacy_option, settable) values ('$PKG_ID', '$PRIVACY_OPTION_STRING', '$SETTABLE')"
+       done
+fi
diff --git a/capi/res/dbspace/schema.sql b/capi/res/dbspace/schema.sql
new file mode 100644 (file)
index 0000000..31bfbe8
--- /dev/null
@@ -0,0 +1,69 @@
+BEGIN EXCLUSIVE TRANSACTION;
+
+CREATE TABLE IF NOT EXISTS PRIVILEGE_INFO (
+       PROFILE_ID INTEGER,
+       PROFILE TEXT NOT NULL CHECK(PROFILE='mobile' or
+                                                               PROFILE='wearable' or
+                                                               PROFILE='tv' or
+                                                               PROFILE='common'),
+       PACKAGE_TYPE_ID INTEGER,
+       PACKAGE_TYPE TEXT NOT NULL CHECK(PACKAGE_TYPE='core' or
+                                                                       PACKAGE_TYPE='wrt' or
+                                                                       PACKAGE_TYPE='metadata'),
+       PRIVILEGE_LEVEL_ID INTEGER,
+       PRIVILEGE_LEVEL TEXT NOT NULL CHECK(PRIVILEGE_LEVEL='public' or
+                                                                               PRIVILEGE_LEVEL='partner' or
+                                                                               PRIVILEGE_LEVEL='platform'),
+       API_VERSION_ISSUED TEXT NOT NULL,
+       API_VERSION_EXPIRED TEXT NOT NULL,
+       DOCUMENTED TEXT NOT NULL CHECK(DOCUMENTED='yes' or
+                                                                       DOCUMENTED='no'),
+       PRIVILEGE_NAME TEXT NOT NULL,
+       IS_PRIVACY TEXT NOT NULL CHECK(IS_PRIVACY='0' or
+                                                                       IS_PRIVACY='1') DEFAULT '0',
+       PRIVACY_NAME TEXT DEFAULT 'N/A',
+       PRIVILEGE_DISPLAY TEXT,
+       PRIVILEGE_DESCRIPTION TEXT,
+       PRIVILEGE_GROUP_ID INTEGER,
+       PRIVILEGE_GROUP TEXT NOT NULL CHECK(PRIVILEGE_GROUP='IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB' or
+                                                                               PRIVILEGE_GROUP='IDS_TPLATFORM_OPT_LOCATION_T_LBS' or
+                                                                               PRIVILEGE_GROUP='IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB' or
+                                                                               PRIVILEGE_GROUP='IDS_TPLATFORM_BODY_PAID_SERVICES_ABB' or
+                                                                               PRIVILEGE_GROUP='IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB' or
+                                                                               PRIVILEGE_GROUP='IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB' or
+                                                                               PRIVILEGE_GROUP='IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB'),
+       CHANGED_TO_2_3_1 TEXT DEFAULT '',
+       CHANGED_TO_2_4_0 TEXT DEFAULT ''
+);
+
+CREATE TABLE IF NOT EXISTS PRIVILEGE_MAPPING (
+       PROFILE_ID INTEGER,
+       PROFILE TEXT NOT NULL CHECK(PROFILE='mobile' or
+                                                               PROFILE='wearable' or
+                                                               PROFILE='tv' or
+                                                               PROFILE='common'),
+       PACKAGE_TYPE_ID INTEGER,
+       PACKAGE_TYPE TEXT NOT NULL CHECK(PACKAGE_TYPE='core' or
+                                                                       PACKAGE_TYPE='wrt'),
+       PRIVILEGE_NAME TEXT NOT NULL,
+       FROM_API_VERSION TEXT NOT NULL,
+       TO_API_VERSION TEXT NOT NULL,
+       MAPPED_PRIVILEGE_NAME TEXT NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS PRIVACY_INFO (
+       PRIVACY_NAME TEXT NOT NULL,
+       PRIVACY_ID INTEGER PRIMARY KEY,
+       PRIVACY_DISPLAY TEXT NOT NULL,
+       UNIQUE(PRIVACY_NAME, PRIVACY_ID)
+);
+
+CREATE TABLE IF NOT EXISTS PRIVACY_WHITELIST (
+       PKG_ID TEXT NOT NULL,
+       PRIVACY_OPTION TEXT NOT NULL,
+       SETTABLE TEXT NOT NULL CHECK(SETTABLE='0' or SETTABLE='1')
+);
+
+COMMIT TRANSACTION;
+
+
diff --git a/capi/res/dbspace/tv_core_db_generator.sh b/capi/res/dbspace/tv_core_db_generator.sh
deleted file mode 100755 (executable)
index 5bbf956..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".core_privilege_info.db"
-
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-PRIVACYLIST_CSV="privacylist.csv"
-
-echo "Creating PRIVILEGE_INFO table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_INFO (PROFILE_ID NUMERIC, PROFILE TEXT, PACKAGE_TYPE_ID NUMERIC, PACKAGE_TYPE TEXT, PRIVILEGE_LEVEL_ID NUMERIC, PRIVILEGE_LEVEL TEXT, API_VERSION_ISSUED TEXT, API_VERSION_EXPIRED TEXT, DOCUMENTED INTEGER, PRIVILEGE_NAME TEXT, IS_PRIVACY NUMERIC, PRIVACY_NAME TEXT, PRIVILEGE_DISPLAY TEXT, PRIVILEGE_DESCRIPTION TEXT, PRIVILEGE_GROUP_ID NUMERIC, PRIVLEGE_GROUP TEXT, CHANGED_TO_2_3_1 TEXT, CHANGED_TO_2_4_0 TEXT);"
-
-echo "Create VALID_PRIVILEGE_INFO Table..."
-sqlite3 $DB_NAME "CREATE TABLE VALID_PRIVILEGE_INFO (PRIVILEGE_NAME TEXT UNIQUE, IS_PRIVACY NUMERIC, PRIVACY_NAME TEXT, IS_INTERNAL NUMERIC);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat tv_core_privilege_info.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PACKAGE_TYPE=`echo $i | cut -d "," -f 2`
-       PRIVILEGE_GROUP=`echo $i | cut -d "," -f 13`
-
-       if [ "$PACKAGE_TYPE" = "wrt" ]
-       then
-               PACKAGE_TYPE_ID=0
-
-       elif [ "$PACKAGE_TYPE" = "core" ]
-       then
-               PACKAGE_TYPE_ID=1
-       elif [ "$PACKAGE_TYPE" = "metadata" ]
-       then
-               PACKAGE_TYPE_ID=2
-               PRIVILEGE_GROUP="IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB"
-
-       else
-               echo "Fail to create table : PACKAGE_TYPE must be metadata, wrt or core"
-               exit
-       fi
-
-       PRIVILEGE_LEVEL=`echo $i | cut -d "," -f 3`
-
-       if [ "$PRIVILEGE_LEVEL" = "public" ]
-       then
-               PRIVILEGE_LEVEL_ID=0
-
-       elif [ "$PRIVILEGE_LEVEL" = "partner" ]
-       then
-               PRIVILEGE_LEVEL_ID=1
-
-       elif [ "$PRIVILEGE_LEVEL" = "platform" ]
-       then
-               PRIVILEGE_LEVEL_ID=2
-
-       else
-               echo "Fail to create table : PRIVILEGE_LEVEL must be public, partner or platform"
-               exit
-       fi
-
-       API_VERSION_ISSUED=`echo $i | cut -d "," -f 4`
-       API_VERSION_EXPIRED=`echo $i | cut -d "," -f 5`
-       DOCUMENTED=`echo $i | cut -d "," -f 6`
-
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 7`
-
-       IS_PRIVACY_TEXT=`echo $i | cut -d "," -f 8`
-       if [ "$IS_PRIVACY_TEXT" = "yes" ]
-       then
-               IS_PRIVACY=1
-       elif [ "$IS_PRIVACY_TEXT" = "no" ]
-       then
-               IS_PRIVACY=0
-       else
-               echo "Fail to create table : IS_PRIVACY must be yes or no"
-               exit
-       fi
-
-       PRIVACY_NAME=`echo $i | cut -d "," -f 9`
-
-       PRIVILEGE_DISPLAY=`echo $i | cut -d "," -f 11`
-
-       PRIVILEGE_DESCRIPTION=`echo $i | cut -d "," -f 12`
-
-       #PRIVILEGE_GROUP=`echo $i | cut -d "," -f 13`
-
-       if [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=0
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_OPT_LOCATION_T_LBS" ]
-       then
-               PRIVILEGE_GROUP_ID=1
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=2
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=3
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=4
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=5
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=6
-
-       else
-               echo "PRIVILEGE_GROUP = $PRIVILEGE_GROUP"
-               echo "Fail to create table : PRIVILEGE_GROUP must be one of them below"
-               echo "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB"
-               echo "IDS_TPLATFORM_OPT_LOCATION_T_LBS"
-               echo "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB"
-               echo "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB"
-               echo "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB"
-               echo "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB"
-               echo "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB"
-               exit
-       fi
-
-       CHANGED_TO_2_4_0=`echo $i | cut -d "," -f 14`
-
-       echo "Inserting $PRIVILEGE_NAME ..."
-
-       sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$IS_PRIVACY', '$PRIVACY_NAME', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP', '$CHANGED_TO_2_3_1', '$CHANGED_TO_2_4_0')"
-       sqlite3 $DB_NAME "insert into valid_privilege_info (privilege_name, is_privacy, privacy_name, is_internal) values ('$PRIVILEGE_NAME', '$IS_PRIVACY', '$PRIVACY_NAME', 0)"
-done
-
-for internal_privilege in `cat internal_only.list`
-do
-       echo "Inserting $internal_privilege ..."
-       sqlite3 $DB_NAME "insert into valid_privilege_info (privilege_name, is_privacy, privacy_name, is_internal) values ('$internal_privilege', 0, 'N/A', 1)"
-done
-
-echo "Create PRIVACY_INFO table..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVACY_INFO (PRIVACY_NAME TEXT UNIQUE, PRIVACY_ID NUMERIC, PRIVACY_DISPLAY TEXT);"
-echo "Insert into privacy_info ...."
-PRIVACY_ID=0
-for i in `cat $PRIVACYLIST_CSV`
-do
-    temp=`echo $i | awk '/^#/'`
-    if [ ! "$temp" = "" ]
-    then
-        continue
-    fi
-       PRIVACY_NAME=`echo $i | cut -d "," -f1`
-       PRIVACY_NAME_ONLY=`echo $PRIVACY_NAME | cut -d "/" -f5`
-       declare ${PRIVACY_NAME_ONLY}=$((PRIVACY_ID))
-       PRIVACY_DISPLAY=`echo $i | cut -d "," -f2`
-       echo "Insert $PRIVACY_NAME, PRIVACY_ID = $PRIVACY_ID "
-       sqlite3 $DB_NAME "insert into privacy_info (privacy_name, privacy_id, privacy_display) values ('$PRIVACY_NAME', $((PRIVACY_ID++)), '$PRIVACY_DISPLAY')"
-done
diff --git a/capi/res/dbspace/tv_core_mapping_db_generator.sh b/capi/res/dbspace/tv_core_mapping_db_generator.sh
deleted file mode 100755 (executable)
index 13e91c9..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".core_privilege_mapping.db"
-
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-echo "Creating PRIVILEGE_MAPPING table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_MAPPING (PROFILE_ID NUMERIC, PROFILE TEXT, PRIVILEGE_NAME TEXT, FROM_API_VERSION TEXT, TO_API_VERSION TEXT, MAPPED_PRIVILEGE_NAME TEXT);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat tv_core_privilege_mapping.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 2`
-       FROM_API_VERSION=`echo $i | cut -d "," -f 3`
-       TO_API_VERSION=`echo $i | cut -d "," -f 4`
-       MAPPED_PRIVILEGE_NAME=`echo $i | cut -d "," -f 5`
-
-       echo "Inserting $PRIVILEGE_NAME $MAPPED_PRIVILEGE_NAME..."
-
-       sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
-       if [[ $MAPPED_PRIVILEGE_NAME == *"/internal/"* ]]; then
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 1)"
-       else
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 0)"
-       fi
-done
-
index 74ed5cf..214878b 100644 (file)
@@ -1,4 +1,4 @@
-#PROFILE,#PRIVILEGE_NAME,#FROM,#TO,#MAPPED_PRIVILEGE_NAME
+#PROFILE,#PRIVILEGE_NAME,#FROM_API_VERSION,#TO_API_VERSION,#MAPPED_PRIVILEGE_NAME
 tv,http://tizen.org/privilege/account.read,2.4,9.9,http://tizen.org/privilege/account.read
 tv,http://tizen.org/privilege/account.read,2.4,9.9,http://tizen.org/privilege/internal/buxton/account.read
 tv,http://tizen.org/privilege/account.write,2.4,9.9,http://tizen.org/privilege/account.write
diff --git a/capi/res/dbspace/tv_wrt_db_generator.sh b/capi/res/dbspace/tv_wrt_db_generator.sh
deleted file mode 100755 (executable)
index a09831f..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".wrt_privilege_info.db"
-
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-echo "Creating PRIVILEGE_INFO table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_INFO (PROFILE_ID NUMERIC, PROFILE TEXT, PACKAGE_TYPE_ID NUMERIC, PACKAGE_TYPE TEXT, PRIVILEGE_LEVEL_ID NUMERIC, PRIVILEGE_LEVEL TEXT, API_VERSION_ISSUED TEXT, API_VERSION_EXPIRED TEXT, DOCUMENTED INTEGER, PRIVILEGE_NAME TEXT, PRIVILEGE_DISPLAY TEXT, PRIVILEGE_DESCRIPTION TEXT, PRIVILEGE_GROUP_ID NUMERIC, PRIVLEGE_GROUP TEXT, CHANGED_TO_2_4_0 TEXT);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat tv_wrt_privilege_info.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-    elif [ "$PROFILE" = "tv" ]
-    then
-        PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile or wearable"
-               exit
-       fi
-
-       PACKAGE_TYPE=`echo $i | cut -d "," -f 2`
-
-       if [ "$PACKAGE_TYPE" = "wrt" ]
-       then
-               PACKAGE_TYPE_ID=0
-
-       elif [ "$PACKAGE_TYPE" = "core" ]
-       then
-               PACKAGE_TYPE_ID=1
-
-       else
-               echo "Fail to create table : PACKAGE_TYPE must be wrt or core"
-               exit
-       fi
-
-       PRIVILEGE_LEVEL=`echo $i | cut -d "," -f 3`
-
-       if [ "$PRIVILEGE_LEVEL" = "public" ]
-       then
-               PRIVILEGE_LEVEL_ID=0
-
-       elif [ "$PRIVILEGE_LEVEL" = "partner" ]
-       then
-               PRIVILEGE_LEVEL_ID=1
-
-       elif [ "$PRIVILEGE_LEVEL" = "platform" ]
-       then
-               PRIVILEGE_LEVEL_ID=2
-
-       else
-               echo "Fail to create table : PRIVILEGE_LEVEL must be public, partner or platform"
-               exit
-       fi
-
-       API_VERSION_ISSUED=`echo $i | cut -d "," -f 4`
-       API_VERSION_EXPIRED=`echo $i | cut -d "," -f 5`
-       DOCUMENTED=`echo $i | cut -d "," -f 6`
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 7`
-
-       PRIVILEGE_DISPLAY=`echo $i | cut -d "," -f 9`
-
-       PRIVILEGE_DESCRIPTION=`echo $i | cut -d "," -f 10`
-
-       PRIVILEGE_GROUP=`echo $i | cut -d "," -f 11`
-
-       if [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=0
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_OPT_LOCATION_T_LBS" ]
-       then
-               PRIVILEGE_GROUP_ID=1
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=2
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=3
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=4
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=5
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=6
-
-       else
-               echo "Fail to create table : PRIVILEGE_GROUP must be one of them below"
-               echo "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB"
-               echo "IDS_TPLATFORM_OPT_LOCATION_T_LBS"
-               echo "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB"
-               echo "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB"
-               echo "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB"
-               echo "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB"
-               echo "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB" 
-               exit
-       fi
-
-    CHANGED_TO_2_4_0=`echo $i | cut -d "," -f 12`
-
-       echo "Inserting $PRIVILEGE_NAME ..."
-
-       sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP', '$CHANGED_TO_2_4_0')"
-done
-
diff --git a/capi/res/dbspace/tv_wrt_mapping_db_generator.sh b/capi/res/dbspace/tv_wrt_mapping_db_generator.sh
deleted file mode 100755 (executable)
index a814f81..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".wrt_privilege_mapping.db"
-
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-echo "Creating PRIVILEGE_MAPPING table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_MAPPING (PROFILE_ID NUMERIC, PROFILE TEXT, PRIVILEGE_NAME TEXT, FROM_API_VERSION TEXT, TO_API_VERSION TEXT, MAPPED_PRIVILEGE_NAME TEXT);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat tv_wrt_privilege_mapping.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 2`
-       FROM_API_VERSION=`echo $i | cut -d "," -f 3`
-       TO_API_VERSION=`echo $i | cut -d "," -f 4`
-       MAPPED_PRIVILEGE_NAME=`echo $i | cut -d "," -f 5`
-
-       echo "Inserting $PRIVILEGE_NAME $MAPPED_PRIVILEGE_NAME..."
-
-       sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
-       if [[ $MAPPED_PRIVILEGE_NAME == *"/internal/"* ]]; then
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 1)"
-       else
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 0)"
-       fi
-done
-
index a312c08..cf58650 100644 (file)
@@ -1,4 +1,4 @@
-#PROFILE,#PRIVILEGE_NAME,#FROM,#TO,#MAPPED_PRIVILEGE_NAME
+#PROFILE,#PRIVILEGE_NAME,#FROM_API_VERSION,#TO_API_VERSION,#MAPPED_PRIVILEGE_NAME
 tv,http://tizen.org/privilege/alarm,2.3,9.9,http://tizen.org/privilege/alarm.get
 tv,http://tizen.org/privilege/alarm,2.3,9.9,http://tizen.org/privilege/alarm.set
 tv,http://tizen.org/privilege/apphistory.read,4,9.9,http://tizen.org/privilege/apphistory.read
diff --git a/capi/res/dbspace/wrt_db_generator.sh b/capi/res/dbspace/wrt_db_generator.sh
deleted file mode 100755 (executable)
index 0c10674..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".wrt_privilege_info.db"
-target_profile=$1
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-echo "Creating PRIVILEGE_INFO table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_INFO (PROFILE_ID NUMERIC, PROFILE TEXT, PACKAGE_TYPE_ID NUMERIC, PACKAGE_TYPE TEXT, PRIVILEGE_LEVEL_ID NUMERIC, PRIVILEGE_LEVEL TEXT, API_VERSION_ISSUED TEXT, API_VERSION_EXPIRED TEXT, DOCUMENTED INTEGER, PRIVILEGE_NAME TEXT, PRIVILEGE_DISPLAY TEXT, PRIVILEGE_DESCRIPTION TEXT, PRIVILEGE_GROUP_ID NUMERIC, PRIVLEGE_GROUP TEXT, CHANGED_TO_2_3_1 TEXT,CHANGED_TO_2_4_0 TEXT);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat wrt_privilege_info.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-       elif [ ! "$PROFILE" = "$target_profile" ]
-       then
-               continue
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PACKAGE_TYPE=`echo $i | cut -d "," -f 2`
-
-       if [ "$PACKAGE_TYPE" = "wrt" ]
-       then
-               PACKAGE_TYPE_ID=0
-
-       elif [ "$PACKAGE_TYPE" = "core" ]
-       then
-               PACKAGE_TYPE_ID=1
-
-       else
-               echo "Fail to create table : PACKAGE_TYPE must be wrt or core"
-               exit
-       fi
-
-       PRIVILEGE_LEVEL=`echo $i | cut -d "," -f 3`
-
-       if [ "$PRIVILEGE_LEVEL" = "public" ]
-       then
-               PRIVILEGE_LEVEL_ID=0
-
-       elif [ "$PRIVILEGE_LEVEL" = "partner" ]
-       then
-               PRIVILEGE_LEVEL_ID=1
-
-       elif [ "$PRIVILEGE_LEVEL" = "platform" ]
-       then
-               PRIVILEGE_LEVEL_ID=2
-
-       else
-               echo "Fail to create table : PRIVILEGE_LEVEL must be public, partner or platform"
-               exit
-       fi
-
-       API_VERSION_ISSUED=`echo $i | cut -d "," -f 4`
-       API_VERSION_EXPIRED=`echo $i | cut -d "," -f 5`
-       DOCUMENTED=`echo $i | cut -d "," -f 6`
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 7`
-
-       PRIVILEGE_DISPLAY=`echo $i | cut -d "," -f 9`
-
-       PRIVILEGE_DESCRIPTION=`echo $i | cut -d "," -f 10`
-
-       PRIVILEGE_GROUP=`echo $i | cut -d "," -f 11`
-
-       if [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=0
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_OPT_LOCATION_T_LBS" ]
-       then
-               PRIVILEGE_GROUP_ID=1
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=2
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=3
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=4
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=5
-
-       elif [ "$PRIVILEGE_GROUP" = "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB" ]
-       then
-               PRIVILEGE_GROUP_ID=6
-
-       else
-               echo "Fail to create table : PRIVILEGE_GROUP must be one of them below"
-               echo "IDS_TPLATFORM_BODY_HARDWARE_CONTROLS_ABB"
-               echo "IDS_TPLATFORM_OPT_LOCATION_T_LBS"
-               echo "IDS_TPLATFORM_BODY_NETWORK_CONNECTIONS_ABB"
-               echo "IDS_TPLATFORM_BODY_PAID_SERVICES_ABB"
-               echo "IDS_TPLATFORM_BODY_PERSONAL_INFORMATION_ABB"
-               echo "IDS_TPLATFORM_BODY_SYSTEM_SETTINGS_ABB"
-               echo "IDS_TPLATFORM_BODY_OTHER_PRIVILEGES_ABB"
-               exit
-       fi
-
-       CHANGED_TO_2_3_1=`echo $i | cut -d "," -f 12`
-       CHANGED_TO_2_4_0=`echo $i | cut -d "," -f 13`
-
-       echo "Inserting $PRIVILEGE_NAME ..."
-
-       sqlite3 $DB_NAME "insert into privilege_info values ( $PROFILE_ID, '$PROFILE', $PACKAGE_TYPE_ID, '$PACKAGE_TYPE', $PRIVILEGE_LEVEL_ID, '$PRIVILEGE_LEVEL', '$API_VERSION_ISSUED', '$API_VERSION_EXPIRED', '$DOCUMENTED', '$PRIVILEGE_NAME', '$PRIVILEGE_DISPLAY', '$PRIVILEGE_DESCRIPTION', $PRIVILEGE_GROUP_ID, '$PRIVILEGE_GROUP','$CHANGED_TO_2_3_1', '$CHANGED_TO_2_4_0')"
-done
-
diff --git a/capi/res/dbspace/wrt_mapping_db_generator.sh b/capi/res/dbspace/wrt_mapping_db_generator.sh
deleted file mode 100755 (executable)
index 255022a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-
-DB_NAME=".wrt_privilege_mapping.db"
-target_profile=$1
-rm $DB_NAME 2> /dev/null
-echo "Creating $DB_NAME ..."
-touch $DB_NAME
-
-echo "Creating PRIVILEGE_MAPPING table ..."
-sqlite3 $DB_NAME "CREATE TABLE PRIVILEGE_MAPPING (PROFILE_ID NUMERIC, PROFILE TEXT, PRIVILEGE_NAME TEXT, FROM_API_VERSION TEXT, TO_API_VERSION TEXT, MAPPED_PRIVILEGE_NAME TEXT);"
-
-echo "Inserting data ..."
-IFS=$'\n'
-for i in `cat wrt_privilege_mapping.csv`
-do
-       temp=`echo $i | awk '/^#/'`
-       if [ ! "$temp" = "" ]
-       then
-               continue
-       fi
-
-       PROFILE=`echo $i | cut -d "," -f 1`
-       #echo PROFILE = $PROFILE
-
-       if [ "$PROFILE" = "common" ]
-       then
-               PROFILE_ID=0
-       elif [ ! "$PROFILE" = "$target_profile" ]
-       then
-               continue
-       elif [ "$PROFILE" = "mobile" ]
-       then
-               PROFILE_ID=1
-       elif [ "$PROFILE" = "wearable" ]
-       then
-               PROFILE_ID=2
-       elif [ "$PROFILE" = "tv" ]
-       then
-               PROFILE_ID=3
-       else
-               echo "Fail to create table : PROFILE must be common, mobile, wearable or tv"
-               exit
-       fi
-
-       PRIVILEGE_NAME=`echo $i | cut -d "," -f 2`
-       FROM_API_VERSION=`echo $i | cut -d "," -f 3`
-       TO_API_VERSION=`echo $i | cut -d "," -f 4`
-       MAPPED_PRIVILEGE_NAME=`echo $i | cut -d "," -f 5`
-
-       echo "Inserting $PRIVILEGE_NAME $MAPPED_PRIVILEGE_NAME..."
-
-       sqlite3 $DB_NAME "insert into privilege_mapping values ( $PROFILE_ID, '$PROFILE', '$PRIVILEGE_NAME','$FROM_API_VERSION', '$TO_API_VERSION', '$MAPPED_PRIVILEGE_NAME')"
-       if [[ $MAPPED_PRIVILEGE_NAME == *"/internal/"* ]]; then
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 1)"
-       else
-               sqlite3 .core_privilege_info.db "insert or ignore into valid_privilege_info values ('$MAPPED_PRIVILEGE_NAME', 0, 'N/A', 0)"
-       fi
-done
-
index 662c46e..3203427 100644 (file)
@@ -1,6 +1,4 @@
-#,,,,,There's no platform version 2.2.1 indeed but requirement of backward compatibility exist by product released with version 2.2.x hence change platform 2.3 issued privilege's from version to 2.2.1
-#,,,,,"The list of modified privileges are as follows: account.read, account.write, audiorecorder, call, camera, healthinfo, internet, nfc.cardemulation, volume.set"
-#PROFILE,#PRIVILEGE_NAME,#FROM,#TO,#MAPPED_PRIVILEGE_NAME,
+#PROFILE,#PRIVILEGE_NAME,#FROM_API_VERSION,#TO_API_VERSION,#MAPPED_PRIVILEGE_NAME,
 mobile,http://tizen.org/privilege/account.read,2.2.1,9.9,http://tizen.org/privilege/account.read,
 mobile,http://tizen.org/privilege/account.read,2.2.1,9.9,http://tizen.org/privilege/internal/buxton/account.read,
 wearable,http://tizen.org/privilege/account.read,4,9.9,http://tizen.org/privilege/account.read,
index 8c92e83..52c1794 100755 (executable)
@@ -105,23 +105,14 @@ char* __get_policy_table(privilege_manager_policy_type_e policy_type)
        }
 }
 
-int __initialize_db(privilege_db_type_e type, sqlite3 ** db, privilege_manager_package_type_e package_type)
+int __initialize_db(privilege_db_type_e type, sqlite3 ** db)
 {
        char *db_path = NULL;
        int db_mode = SQLITE_OPEN_READONLY;
 
        switch (type) {
        case PRIVILEGE_DB_TYPE_INFO:
-               if (package_type == PRVMGR_PACKAGE_TYPE_WRT)
-                       db_path = PRIVILEGE_INFO_WRT_DB_PATH;
-               else
-                       db_path = PRIVILEGE_INFO_CORE_DB_PATH;
-               break;
-       case PRIVILEGE_DB_TYPE_MAPPING:
-               if (package_type == PRVMGR_PACKAGE_TYPE_WRT)
-                       db_path = PRIVILEGE_MAPPING_WRT_DB_PATH;
-               else
-                       db_path = PRIVILEGE_MAPPING_CORE_DB_PATH;
+               db_path = PRIVILEGE_DB_PATH;
                break;
        case PRIVILEGE_DB_TYPE_POLICY_RW:
                db_mode = SQLITE_OPEN_READWRITE;
@@ -202,7 +193,7 @@ int privilege_db_manager_check_black_list(uid_t uid, privilege_manager_package_t
        int ret = 0;
        int count = 0;
 
-       ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RO, &db, package_type);
+       ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE) {
                _LOGE("db initialize failed. ret = %d", ret);
                return ret;
@@ -250,7 +241,7 @@ int privilege_db_manager_get_privilege_list(const char *api_version, privilege_m
        }
        TryReturn(changed_to_version != NULL, , PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] privilege_name's strdup is failed.");
 
-       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, package_type);
+       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE) {
                free(changed_to_version);
                return ret;
@@ -328,7 +319,7 @@ int privilege_db_manager_get_mapped_privilege_list(const char *api_version, priv
        sqlite3_stmt *stmt = NULL;
        int ret;
 
-       ret = __initialize_db(PRIVILEGE_DB_TYPE_MAPPING, &db, package_type);
+       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -338,7 +329,7 @@ int privilege_db_manager_get_mapped_privilege_list(const char *api_version, priv
        ret = __make_privilege_list_str(privilege_list, &privilege_list_str);
        TryReturn(ret == 0 && privilege_list_str != NULL, sqlite3_close(db), PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY, "[PRIVILEGE_DB_MANAGER_ERR_OUT_OF_MEMORY] making privilege_list_str for where in query is failed.");
 
-       char *sql = sqlite3_mprintf("select distinct mapped_privilege_name from privilege_mapping where privilege_name in(%s)and(profile_id=%d or profile_id=%d)and from_api_version<=%Q and to_api_version>%Q", privilege_list_str, PRIVILEGE_PROFILE_TYPE_COMMON, g_privilege_profile_type, api_version, api_version);
+       char *sql =  sqlite3_mprintf("select distinct mapped_privilege_name from privilege_mapping where package_type_id=%d and privilege_name in(%s)and(profile_id=%d or profile_id=%d)and from_api_version<=%Q and to_api_version>%Q", package_type, privilege_list_str, PRIVILEGE_PROFILE_TYPE_COMMON, g_privilege_profile_type, api_version, api_version, package_type);
        sqlite3_free(privilege_list_str);
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
 
@@ -364,7 +355,7 @@ int privilege_db_manager_get_privacy_display(const char *privacy_name, char **pr
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
        char *sql = sqlite3_mprintf("select privacy_display from privacy_info where privacy_name=%Q", privacy_name);
@@ -390,7 +381,7 @@ int privilege_db_manager_get_privilege_display(privilege_manager_package_type_e
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
        int ret;
-       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, package_type);
+       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -425,16 +416,17 @@ int privilege_db_manager_get_privilege_description(privilege_manager_package_typ
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
        int ret;
-       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, package_type);
+       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
        char *sql = NULL;
 
-       if (api_version == NULL)
+       if (api_version == NULL) {
                sql = sqlite3_mprintf("select privilege_description from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d and privilege_name=%Q", PRIVILEGE_PROFILE_TYPE_COMMON, g_privilege_profile_type, package_type, privilege_name);
-       else
+       } else {
                sql = sqlite3_mprintf("select privilege_description from privilege_info where(profile_id=%d or profile_id=%d)and package_type_id=%d and privilege_name=%Q and api_version_issued<=%Q and api_version_expired>%Q", PRIVILEGE_PROFILE_TYPE_COMMON, g_privilege_profile_type, package_type, privilege_name, api_version, api_version);
+       }
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
 
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
@@ -459,7 +451,7 @@ int privilege_db_manager_get_privilege_group_id(privilege_manager_package_type_e
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
        int ret;
-       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, package_type);
+       ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -488,10 +480,24 @@ int privilege_db_manager_is(char type, const char* privilege)
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
        int res = 0;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        TryReturn(ret == PRIVILEGE_DB_MANAGER_ERR_NONE, , ret, "[PRIVILEGE_DB_MANAGER] DB INITIALIZE FAIL");
 
-       char *sql = sqlite3_mprintf("select privilege_name, is_privacy, is_internal from valid_privilege_info where privilege_name=%Q", privilege);
+       char *sql = NULL;
+       switch (type) {
+       case 'v':
+               sql = sqlite3_mprintf("select privilege_name from privilege_mapping where mapped_privilege_name=%Q", privilege);
+               break;
+       case 'p':
+               sql = sqlite3_mprintf("select is_privacy from privilege_info where privilege_name=%Q and package_type='core'", privilege);
+               break;
+       case 'i':
+               sql = sqlite3_mprintf("select distinct (case when exists(select * from privilege_info where privilege_name=%Q) then 0 else 1 end) from privilege_mapping where mapped_privilege_name=%Q", privilege, privilege);
+               break;
+       default:
+               _LOGE("Undefined type for privilege_db_manager_is()");
+               return PRIVILEGE_DB_MANAGER_ERR_INVALID_TYPE;
+       }
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database : %s", sqlite3_errmsg(db));
@@ -503,10 +509,8 @@ int privilege_db_manager_is(char type, const char* privilege)
                        res = 1;
                        break;
                case 'p':
-                       res = sqlite3_column_int(stmt, 1);
-                       break;
                case 'i':
-                       res = sqlite3_column_int(stmt, 2);
+                       res = sqlite3_column_int(stmt, 0);
                        break;
                default:
                        _LOGE("Undefined type for privilege_db_manager_is()");
@@ -538,7 +542,7 @@ int privilege_db_manager_is_privacy_white_list(const char* pkgid, const char* pr
 
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        TryReturn(ret == PRIVILEGE_DB_MANAGER_ERR_NONE, , ret, "[PRIVILEGE_DB_MANAGER] DB INITIALIZE FAIL");
 
        int privacy_id = 0;
@@ -575,7 +579,7 @@ int privilege_db_manager_is_user_settable(const char* pkgid, const char* privacy
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
        int res = 1;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        TryReturn(ret == PRIVILEGE_DB_MANAGER_ERR_NONE, , ret, "[PRIVILEGE_DB_MANAGER] DB INITIALIZE FAIL");
 
        int privacy_id = 0;
@@ -618,7 +622,7 @@ int privilege_db_manager_is_disabled_privilege(uid_t uid, const char* privilege)
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RO, &db);
        TryReturn(ret == PRIVILEGE_DB_MANAGER_ERR_NONE, , ret, "[PRIVILEGE_DB_MANAGER] DB INITIALIZE FAIL. ret = %d", ret);
 
        char *sql = sqlite3_mprintf("select * from disable_list where privilege_name=%Q and (uid=%d or uid=%d)", privilege, uid, GLOBAL_USER);
@@ -642,11 +646,11 @@ int privilege_db_manager_get_privacy_list(GList **privacy_list)
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
-       char *sql = sqlite3_mprintf("select DISTINCT privacy_name from privilege_info where is_privacy=1 order by privacy_name");
+       char *sql = sqlite3_mprintf("select DISTINCT privacy_name from privilege_info where is_privacy=1 and package_type='core' order by privacy_name");
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
@@ -672,11 +676,11 @@ int privilege_db_manager_get_privilege_list_by_privacy(const char* privacy, GLis
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
-       char *sql = sqlite3_mprintf("select distinct privilege_name from valid_privilege_info where is_privacy=1 and privacy_name=%Q", privacy);
+       char *sql = sqlite3_mprintf("select distinct privilege_name from privilege_info where is_privacy=1 and privacy_name=%Q", privacy);
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
@@ -702,11 +706,11 @@ int privilege_db_manager_get_privacy_by_privilege(const char* privilege, char**
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
-       char *sql = sqlite3_mprintf("select privacy_name from valid_privilege_info where privilege_name=%Q", privilege);
+       char *sql = sqlite3_mprintf("select privacy_name from privilege_info where privilege_name=%Q and package_type='core'", privilege);
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
@@ -727,11 +731,11 @@ int privilege_db_manager_get_privacy_id_by_privilege(const char* privilege, int
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
-       char *sql = sqlite3_mprintf("select privacy_id from privacy_info where privacy_name=(select privacy_name from valid_privilege_info where privilege_name=%Q)", privilege);
+       char *sql = sqlite3_mprintf("select privacy_id from privacy_info where privacy_name=(select privacy_name from privilege_info where privilege_name=%Q and package_type='core')", privilege);
        TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
        ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
        TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
@@ -753,7 +757,7 @@ int privilege_db_manager_get_privacy_id(const char* privacy, int *privacy_id)
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db, PRVMGR_PACKAGE_TYPE_CORE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_INFO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -780,7 +784,7 @@ int privilege_db_manager_get_black_list(privilege_manager_policy_type_e policy_t
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RO, &db, package_type);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
        char* sql = NULL;
@@ -814,7 +818,7 @@ int privilege_db_manager_set_black_list(privilege_manager_policy_type_e policy_t
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RW, &db, package_type);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RW, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -849,7 +853,7 @@ int privilege_db_manager_unset_black_list(privilege_manager_policy_type_e policy
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RW, &db, package_type);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_POLICY_RW, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -884,7 +888,7 @@ int privilege_db_manager_set_package_critical_privilege_info(const uid_t uid, co
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RW, &db, package_type);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RW, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -931,7 +935,7 @@ int privilege_db_manager_set_package_privacy_privilege_info(const uid_t uid, con
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RW, &db, package_type);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RW, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
        GList* mapped_privilege_list = NULL;
@@ -977,7 +981,7 @@ int privilege_db_manager_unset_package_privilege_info(const uid_t uid, const cha
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RW, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RW, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -1001,7 +1005,7 @@ int privilege_db_manager_is_privacy_requestable(const uid_t uid, const char* pkg
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -1035,7 +1039,7 @@ int privilege_db_manager_is_critical_privilege(const uid_t uid, const char* pkgi
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -1069,7 +1073,7 @@ int privilege_db_manager_get_all_privacy_package_list(const uid_t uid, GList** p
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -1100,7 +1104,7 @@ int privilege_db_manager_get_privacy_list_by_pkgid(const uid_t uid, const char*
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -1130,7 +1134,7 @@ int privilege_db_manager_get_package_list_by_privacy(const uid_t uid, const char
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
@@ -1161,7 +1165,7 @@ int privilege_db_manager_get_privilege_list_by_pkgid_and_privacy(const uid_t uid
 {
        sqlite3 *db = NULL;
        sqlite3_stmt *stmt = NULL;
-       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db, PRVMGR_PACKAGE_TYPE_NONE);
+       int ret = __initialize_db(PRIVILEGE_DB_TYPE_PRIVACY_RO, &db);
        if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
                return ret;
 
index c5815f3..d8ee36f 100644 (file)
@@ -1,7 +1,7 @@
 Name:    privilege-checker
 Summary: Privilege Management
-Version: 0.0.5
-Release: 3
+Version: 1.0.0
+Release: 0
 Group:   System/Libraries
 License: Apache-2.0
 Source0: %{name}-%{version}.tar.gz
@@ -147,14 +147,9 @@ sed "s|@PROFILE@|wearable|" privilege-checker.ini > %{buildroot}%{_sysconfdir}/p
 sed "s|@PROFILE@|mobile|" privilege-checker.ini > %{buildroot}%{_sysconfdir}/privilege-checker.ini.mobile
 
 %if "%{?build_type}" != "NO_DB"
-mv %{buildroot}%{_datadir}/privilege-manager/.core_privilege_info.mobile.db %{buildroot}%{_datadir}/privilege-manager/.core_privilege_info.db
-mv %{buildroot}%{_datadir}/privilege-manager/.core_privilege_mapping.mobile.db %{buildroot}%{_datadir}/privilege-manager/.core_privilege_mapping.db
-mv %{buildroot}%{_datadir}/privilege-manager/.wrt_privilege_info.mobile.db %{buildroot}%{_datadir}/privilege-manager/.wrt_privilege_info.db
-mv %{buildroot}%{_datadir}/privilege-manager/.wrt_privilege_mapping.mobile.db %{buildroot}%{_datadir}/privilege-manager/.wrt_privilege_mapping.db
+mv %{buildroot}%{_datadir}/privilege-manager/.privilege.mobile.db %{buildroot}%{_datadir}/privilege-manager/.privilege.db
 %endif
 
-%find_lang privilege
-
 %post -n security-privilege-manager
 /sbin/ldconfig
 %if "%{?build_type}" != "NO_DB"
@@ -171,13 +166,11 @@ chsmack -a System::Shared %{TZ_SYS_DB}/.privacy.db-journal
 %manifest packaging/privilege-checker.manifest
 %license LICENSE.APLv2
 
-%files -n security-privilege-manager -f privilege.lang
+%files -n security-privilege-manager
 %{_libdir}/libsecurity-privilege-manager.so*
+%{_datadir}/locale/*
 %if "%{?build_type}" != "NO_DB"
-%{_datadir}/privilege-manager/.core_privilege_info.db
-%{_datadir}/privilege-manager/.core_privilege_mapping.db
-%{_datadir}/privilege-manager/.wrt_privilege_info.db
-%{_datadir}/privilege-manager/.wrt_privilege_mapping.db
+%{_datadir}/privilege-manager/.privilege.db
 %attr(700,root,root) %{_datadir}/privilege-manager/policy_db_updater.sh
 %config(noreplace) %attr(0660, root, security_fw) /%{TZ_SYS_DB}/.policy.db
 %config(noreplace) %attr(0660, root, security_fw) /%{TZ_SYS_DB}/.policy.db-journal
@@ -197,19 +190,13 @@ mv %{_sysconfdir}/privilege-checker.ini.mobile %{_sysconfdir}/privilege-checker.
 
 %post -n security-privilege-manager-extension-tv
 %if "%{?build_type}" != "NO_DB"
-mv %{_datadir}/privilege-manager/.core_privilege_info.tv.db %{_datadir}/privilege-manager/.core_privilege_info.db
-mv %{_datadir}/privilege-manager/.core_privilege_mapping.tv.db %{_datadir}/privilege-manager/.core_privilege_mapping.db
-mv %{_datadir}/privilege-manager/.wrt_privilege_info.tv.db %{_datadir}/privilege-manager/.wrt_privilege_info.db
-mv %{_datadir}/privilege-manager/.wrt_privilege_mapping.tv.db %{_datadir}/privilege-manager/.wrt_privilege_mapping.db
+mv %{_datadir}/privilege-manager/.privilege.tv.db %{_datadir}/privilege-manager/.privilege.db
 %endif
 mv %{_sysconfdir}/privilege-checker.ini.tv %{_sysconfdir}/privilege-checker.ini
 
 %files -n security-privilege-manager-extension-tv
 %if "%{?build_type}" != "NO_DB"
-%{_datadir}/privilege-manager/.core_privilege_info.tv.db
-%{_datadir}/privilege-manager/.core_privilege_mapping.tv.db
-%{_datadir}/privilege-manager/.wrt_privilege_info.tv.db
-%{_datadir}/privilege-manager/.wrt_privilege_mapping.tv.db
+%{_datadir}/privilege-manager/.privilege.tv.db
 %endif
 %manifest packaging/security-privilege-manager.manifest
 %license LICENSE.APLv2
@@ -217,19 +204,13 @@ mv %{_sysconfdir}/privilege-checker.ini.tv %{_sysconfdir}/privilege-checker.ini
 
 %post -n security-privilege-manager-extension-wearable
 %if "%{?build_type}" != "NO_DB"
-mv %{_datadir}/privilege-manager/.core_privilege_info.wearable.db %{_datadir}/privilege-manager/.core_privilege_info.db
-mv %{_datadir}/privilege-manager/.core_privilege_mapping.wearable.db %{_datadir}/privilege-manager/.core_privilege_mapping.db
-mv %{_datadir}/privilege-manager/.wrt_privilege_info.wearable.db %{_datadir}/privilege-manager/.wrt_privilege_info.db
-mv %{_datadir}/privilege-manager/.wrt_privilege_mapping.wearable.db %{_datadir}/privilege-manager/.wrt_privilege_mapping.db
+mv %{_datadir}/privilege-manager/.privilege.wearable.db %{_datadir}/privilege-manager/.privilege.db
 %endif
 mv %{_sysconfdir}/privilege-checker.ini.wearable %{_sysconfdir}/privilege-checker.ini
 
 %files -n security-privilege-manager-extension-wearable
 %if "%{?build_type}" != "NO_DB"
-%{_datadir}/privilege-manager/.core_privilege_info.wearable.db
-%{_datadir}/privilege-manager/.core_privilege_mapping.wearable.db
-%{_datadir}/privilege-manager/.wrt_privilege_info.wearable.db
-%{_datadir}/privilege-manager/.wrt_privilege_mapping.wearable.db
+%{_datadir}/privilege-manager/.privilege.wearable.db
 %endif
 %manifest packaging/security-privilege-manager.manifest
 %license LICENSE.APLv2
index 30f42e7..8cae7a3 100755 (executable)
@@ -17,10 +17,7 @@ ENDFOREACH(flag)
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE -fvisibility=hidden -static-libgcc -static-libstdc++")
 
-ADD_DEFINITIONS(-DPRIVILEGE_INFO_CORE_DB_PATH="core_privilege_info.db")
-ADD_DEFINITIONS(-DPRIVILEGE_INFO_WRT_DB_PATH="wrt_privilege_info.db")
-ADD_DEFINITIONS(-DPRIVILEGE_MAPPING_CORE_DB_PATH="core_privilege_mapping.db")
-ADD_DEFINITIONS(-DPRIVILEGE_MAPPING_WRT_DB_PATH="wrt_privilege_mapping.db")
+ADD_DEFINITIONS(-DPRIVILEGE_DB_PATH="privilege.db")
 ADD_DEFINITIONS(-DPRIVILEGE_POLICY_DB_PATH="policy.db")
 ADD_DEFINITIONS(-DPRIVILEGE_PRIVACY_DB_PATH="${TZ_SYS_DB}/.privacy.db")
 ADD_DEFINITIONS(-DASKUSER_RUNTIME_DISABLE_PATH="${TZ_SYS_SHARE}/askuser_disable")