diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2016-11-10 21:08:31 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2017-01-16 17:07:39 +0900 |
commit | 05c3266154856a5f0e0f8338b7e7626c3f485ec6 (patch) | |
tree | 4ab32c98bd402ad44bf5ccd53791b782d85a8d15 | |
parent | a461cdd034666f38f0ec45354a042c2f37a0476e (diff) | |
download | syspopup-05c3266154856a5f0e0f8338b7e7626c3f485ec6.tar.gz syspopup-05c3266154856a5f0e0f8338b7e7626c3f485ec6.tar.bz2 syspopup-05c3266154856a5f0e0f8338b7e7626c3f485ec6.zip |
Remove Profile Build Dependency
- This is for Tizen 4.0.
- The syspopup initdb tool is added.
Change-Id: Ia46f7d423eb138c72b9c8ffeecf71d050b104bce
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rwxr-xr-x | data/syspopup_db.sql | 40 | ||||
-rwxr-xr-x | data/wearable/syspopup_db.sql | 30 | ||||
-rw-r--r-- | packaging/syspopup.manifest | 3 | ||||
-rw-r--r-- | packaging/syspopup.spec | 27 | ||||
-rwxr-xr-x | scripts/502.syspopup_upgrade.sh | 20 | ||||
-rw-r--r-- | test/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tool/CMakeLists.txt | 21 | ||||
-rwxr-xr-x | tool/sp_initdb.c | 286 | ||||
-rwxr-xr-x | tool/test.c (renamed from test/test.c) | 0 |
10 files changed, 317 insertions, 127 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea0106b..7d756df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,14 +65,7 @@ add_library(syspopup_mods STATIC ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/SLP_SYSPOPUP_PG.h DESTINATION include) -IF(PROFILE_WEARABLE) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/wearable/syspopup_db.sql DESTINATION ${TZ_SYS_RO_SHARE}/syspopup) -ELSE(PROFILE_WEARABLE) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/syspopup_db.sql DESTINATION ${TZ_SYS_RO_SHARE}/syspopup) -ENDIF(PROFILE_WEARABLE) add_subdirectory(syspopup) add_subdirectory(syspopup-caller) - -# test -add_subdirectory(test) +add_subdirectory(tool) diff --git a/data/syspopup_db.sql b/data/syspopup_db.sql deleted file mode 100755 index c96573a..0000000 --- a/data/syspopup_db.sql +++ /dev/null @@ -1,40 +0,0 @@ -PRAGMA journal_mode = PERSIST; - -/* prio : 0~2 (0:low, 2:high) */ -/* focus : 0~1 (0:focus, 1:unfocus) */ -/* timeout : -1 ~ integer value (-1:infinite, 0:don't use) */ -/* term_act : 0~2(0:TERM, 1:HIDE, 2:IGNORE) */ -/* endkey_act : 0~2(0:TERM, 1:HIDE, 2:IGNORE) */ -CREATE TABLE IF NOT EXISTS syspopup_info ( - id INTEGER PRIMARY KEY, - name TEXT UNIQUE NOT NULL, - prio INTEGER, - focus INTEGER, - timeout INTEGER, - term_act INTEGER, - endkey_act INTEGER, - pkgname TEXT -); - -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"volume", 1,1,-1,1,1,"org.tizen.volume"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"bt-syspopup", 0,0,-1,0,0,"org.tizen.bt-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"wifi-qs", 0,0,-1,0,2,"net.wifi-qs"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"powerkey-syspopup", 2,0,-1,0,0,"org.tizen.powerkey-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"overheat-syspopup", 2,0,-1,0,0,"org.tizen.overheat-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"lowmem-syspopup", 0,0,5,0,0,"org.tizen.lowmem-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"battery-syspopup", 0,0,5,0,0,"org.tizen.battery-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"net-popup", 0,0,-1,0,0,"net.netpopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"usb-syspopup", 1,0,-1,2,2,"org.tizen.usb-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"usbotg-syspopup", 0,1,-1,0,0,"org.tizen.usbotg-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mmc-syspopup", 0,0,-1,0,0,"org.tizen.mmc-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mobileap-syspopup", 0,0,-1,0,0,"org.tizen.mobileap-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"telephony-syspopup", 1,1,5,0,0,"org.tizen.telephony-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"system-syspopup", 1,0,-1,0,0,"org.tizen.system-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"safetyvolume-syspopup", 1,0,-1,0,0,"org.tizen.safetyvolume-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"datausage-syspopup", 1,0,-1,0,0,"org.tizen.datausage-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"crash-syspopup", 1,0,-1,0,0,"org.tizen.crash-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"gps-syspopup", 0,0,-1,0,0,"org.tizen.gps-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mode-syspopup", 1,0,-1,0,0,"org.tizen.mode-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"d2d-conv-syspopup", 2,0,-1,0,0,"org.tizen.d2d-conv-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"fido-syspopup", 2,0,-1,0,0,"org.tizen.fido-syspopup"); - diff --git a/data/wearable/syspopup_db.sql b/data/wearable/syspopup_db.sql deleted file mode 100755 index 9db2601..0000000 --- a/data/wearable/syspopup_db.sql +++ /dev/null @@ -1,30 +0,0 @@ -PRAGMA journal_mode = PERSIST; - -/* prio : 0~2 (0:low, 2:high) */ -/* focus : 0~1 (0:focus, 1:unfocus) */ -/* timeout : -1 ~ integer value (-1:infinite, 0:don't use) */ -/* term_act : 0~2(0:TERM, 1:HIDE, 2:IGNORE) */ -/* endkey_act : 0~2(0:TERM, 1:HIDE, 2:IGNORE) */ -CREATE TABLE IF NOT EXISTS syspopup_info ( - id INTEGER PRIMARY KEY, - name TEXT UNIQUE NOT NULL, - prio INTEGER, - focus INTEGER, - timeout INTEGER, - term_act INTEGER, - endkey_act INTEGER, - pkgname TEXT -); - -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"volume", 1,1,-1,1,1,"org.tizen.windicator"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"powerkey-syspopup", 2,0,-1,0,0,"org.tizen.powerkey-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"lowmem-syspopup", 0,0,5,0,0,"org.tizen.lowmem-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"battery-syspopup", 0,0,5,0,0,"org.tizen.battery-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"system-syspopup", 1,0,-1,0,0,"org.tizen.system-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"safetyvolume-syspopup", 2,1,-1,0,0,"org.tizen.safetyvolume-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"crash-syspopup", 1,0,-1,0,0,"org.tizen.crash-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"wc-syspopup", 0,0,-1,0,0,"net.wc-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"bt-syspopup", 0,0,-1,0,0,"org.tizen.bt-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"d2d-conv-syspopup", 2,0,-1,0,0,"org.tizen.d2d-conv-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"fido-syspopup", 2,0,-1,0,0,"org.tizen.fido-syspopup"); - diff --git a/packaging/syspopup.manifest b/packaging/syspopup.manifest index 776b0ca..f5a44ec 100644 --- a/packaging/syspopup.manifest +++ b/packaging/syspopup.manifest @@ -2,7 +2,4 @@ <request> <domain name="_"/> </request> - <assign> - <filesystem path="TZ_SYS_DB/.syspopup.db" label="System::Shared"/> - </assign> </manifest> diff --git a/packaging/syspopup.spec b/packaging/syspopup.spec index bb52152..e433de5 100644 --- a/packaging/syspopup.spec +++ b/packaging/syspopup.spec @@ -33,15 +33,10 @@ BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(libsmack) %define upgrade_script_path /usr/share/upgrade/scripts -%define upgrade_data_path /usr/share/upgrade/data - -%if "%{?profile}" == "wearable" -%define profile_wearable 1 -%else -%define profile_wearable 0 -%endif %description syspopup package for popup @@ -74,13 +69,9 @@ syspopup-caller development package for popup %prep %setup -q -sed -i %{SOURCE1001} -e "s|TZ_SYS_DB|%TZ_SYS_DB|g" cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} . %build -%if %{?profile_wearable} -PROFILE_WEARABLE=ON -%endif %cmake \ %if %{with wayland} @@ -93,7 +84,6 @@ PROFILE_WEARABLE=ON -DTZ_SYS_RO_PACKAGES=%{TZ_SYS_RO_PACKAGES} \ -DTZ_SYS_RO_SHARE=%{TZ_SYS_RO_SHARE} \ -DEXTRA_CFLAGS=-fPIC \ - -DPROFILE_WEARABLE:BOOL=${PROFILE_WEARABLE} \ . make %{?jobs:-j%jobs} @@ -106,17 +96,10 @@ install LICENSE %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name}-devel install LICENSE %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name}-caller install LICENSE %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name}-caller-devel -mkdir -p %{buildroot}%{TZ_SYS_DB} -sqlite3 %{buildroot}%{TZ_SYS_DB}/.syspopup.db < %{buildroot}%{TZ_SYS_RO_SHARE}/syspopup/syspopup_db.sql -rm -rf %{buildroot}%{TZ_SYS_RO_SHARE}/syspopup/syspopup_db.sql -rm -rf %{buildroot}%{TZ_SYS_DB}/.syspopup.db-journal - touch %{buildroot}%{_datadir}/popup_noti_term mkdir -p %{buildroot}%{upgrade_script_path} -mkdir -p %{buildroot}%{upgrade_data_path} cp -f scripts/502.syspopup_upgrade.sh %{buildroot}%{upgrade_script_path} -cp -f %{buildroot}%{TZ_SYS_DB}/.syspopup.db %{buildroot}%{upgrade_data_path} %post -p /sbin/ldconfig @@ -126,16 +109,18 @@ cp -f %{buildroot}%{TZ_SYS_DB}/.syspopup.db %{buildroot}%{upgrade_data_path} %postun caller -p /sbin/ldconfig +%posttrans +/usr/bin/sp_initdb + %files %manifest %{name}.manifest %defattr(-,root,root,-) %{_bindir}/sp_test +%{_bindir}/sp_initdb %{_libdir}/libsyspopup.so.0.1.0 %{_datadir}/popup_noti_term -%attr(644,root,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_DB}/.syspopup.db %TZ_SYS_RO_SHARE/license/%{name} %{upgrade_script_path}/502.syspopup_upgrade.sh -%{upgrade_data_path}/.syspopup.db %files devel %manifest %{name}-devel.manifest diff --git a/scripts/502.syspopup_upgrade.sh b/scripts/502.syspopup_upgrade.sh index eeb859f..32fdfe2 100755 --- a/scripts/502.syspopup_upgrade.sh +++ b/scripts/502.syspopup_upgrade.sh @@ -1,25 +1,11 @@ #!/bin/sh #------------------------------------------# -# syspopup upgrade (2.4 -> 3.0) # +# syspopup upgrade (2.4 -> 3.0) # #------------------------------------------# # Macro PATH=/bin:/usr/bin:/sbin:/usr/sbin -UPGRADE_DB_DIR=/usr/share/upgrade/data -DB_DIR=/opt/dbspace - -UPGRADE_DB_SYSPOPUP=$UPGRADE_DB_DIR/.syspopup.db -DB_SYSPOPUP=$DB_DIR/.syspopup.db - -# Copy DB -cp -rf $UPGRADE_DB_SYSPOPUP $DB_SYSPOPUP - -chmod 644 $DB_SYSPOPUP -chown :users $DB_SYSPOPUP -chsmack -a System::Shared $DB_SYSPOPUP - -# Delete DB journal -rm -rf $DB_SYSPOPUP-journal - +# Initialize DB +sp_initdb diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 86f105d..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Test executables -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}") - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/syspopup-caller) -add_executable(sp_test test.c) -target_link_libraries(sp_test syspopup_caller ${pkgs_LDFLAGS}) -INSTALL(TARGETS sp_test DESTINATION bin) - diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt new file mode 100644 index 0000000..ccff37b --- /dev/null +++ b/tool/CMakeLists.txt @@ -0,0 +1,21 @@ +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") + +pkg_check_modules(PKGS REQUIRED + libtzplatform-config + capi-system-info + sqlite3 + libsmack + ) + +FOREACH(FLAGS ${PKGS_CFLAGS}) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}") +ENDFOREACH(FLAGS) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/syspopup-caller) +add_executable(sp_test test.c) +target_link_libraries(sp_test syspopup_caller ${pkgs_LDFLAGS}) +INSTALL(TARGETS sp_test DESTINATION bin) + +ADD_EXECUTABLE(sp_initdb sp_initdb.c) +TARGET_LINK_LIBRARIES(sp_initdb ${PKGS_LDFLAGS} "-pie") +INSTALL(TARGETS sp_initdb DESTINATION bin) diff --git a/tool/sp_initdb.c b/tool/sp_initdb.c new file mode 100755 index 0000000..216f326 --- /dev/null +++ b/tool/sp_initdb.c @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/smack.h> +#include <sqlite3.h> +#include <tzplatform_config.h> +#include <system_info.h> + +#define CREATE_SYSPOPUP_INFO_TABLE \ +"PRAGMA journal_mode = PERSIST; " \ +"CREATE TABLE IF NOT EXISTS syspopup_info ( " \ +" id INTEGER PRIMARY KEY, " \ +" name TEXT UNIQUE NOT NULL, " \ +" prio INTEGER, " \ +" focus INTEGER, " \ +" timeout INTEGER, " \ +" term_act INTEGER, " \ +" endkey_act INTEGER, " \ +" pkgname TEXT NOT NULL);" + +#define QUERY_INSERT_SYSPOPUP_INFO \ +"INSERT OR REPLACE INTO syspopup_info " \ +"(name, prio, focus, timeout, term_act, endkey_act, pkgname) " \ +"VALUES(?, ?, ?, ?, ?, ?, ?);" + +#define PATH_DB tzplatform_mkpath(TZ_SYS_DB, ".syspopup.db") +#define PATH_DB_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".syspopup.db-journal") +#define ARRAY_SIZE(x) ((sizeof(x)) / (sizeof(x[0]))) +#define DB_LABEL "User::Home" +#define ROOT_UID 0 + +struct syspopup_info { + const char *name; + int prio; + int focus; + int timeout; + int term_act; + int endkey_act; + const char *appid; +}; + +static sqlite3 *db; +static struct syspopup_info mobile_info[] = { + {"volume", 1, 1, -1, 1, 1, "org.tizen.volume"}, + {"bt-syspopup", 0, 0, -1, 0, 0, "org.tizen.bt-syspopup"}, + {"wifi-qs", 0, 0, -1, 0, 2, "net.wifi-qs"}, + {"powerkey-syspopup", 2, 0, -1, 0, 0, "org.tizen.powerkey-syspopup"}, + {"overheat-syspopup", 2, 0, -1, 0, 0, "org.tizen.overheat-syspopup"}, + {"lowmem-syspopup", 0, 0, 5, 0, 0, "org.tizen.lowmem-syspopup"}, + {"battery-syspopup", 0, 0, 5, 0, 0, "org.tizen.battery-syspopup"}, + {"net-popup", 0, 0, -1, 0, 0, "net.netpopup"}, + {"usb-syspopup", 1, 0, -1, 2, 2, "org.tizen.usb-syspopup"}, + {"usbotg-syspopup", 0, 1, -1, 0, 0, "org.tizen.usbotg-syspopup"}, + {"mmc-syspopup", 0, 0, -1, 0, 0, "org.tizen.mmc-syspopup"}, + {"mobileap-syspopup", 0, 0, -1, 0, 0, "org.tizen.mobileap-syspopup"}, + {"telephony-syspopup", 1, 1, 5, 0, 0, "org.tizen.telephony-syspopup"}, + {"system-syspopup", 1, 0, -1, 0, 0, "org.tizen.system-syspopup"}, + {"safetyvolume-syspopup", 1, 0, -1, 0, 0, "org.tizen.safetyvolume-syspopup"}, + {"datausage-syspopup", 1, 0, -1, 0, 0, "org.tizen.datausage-syspopup"}, + {"crash-syspopup", 1, 0, -1, 0, 0, "org.tizen.crash-syspopup"}, + {"gps-syspopup", 0, 0, -1, 0, 0, "org.tizen.gps-syspopup"}, + {"mode-syspopup", 1, 0, -1, 0, 0, "org.tizen.mode-syspopup"}, + {"d2d-conv-syspopup", 2, 0, -1, 0, 0, "org.tizen.d2d-conv-syspopup"}, + {"fido-syspopup", 2, 0, -1, 0, 0, "org.tizen.fido-syspopup"} +}; +static struct syspopup_info wearable_info[] = { + {"volume", 1, 1, -1, 1, 1, "org.tizen.windicator"}, + {"powerkey-syspopup", 2, 0, -1, 0, 0, "org.tizen.powerkey-syspopup"}, + {"lowmem-syspopup", 0, 0, 5, 0, 0, "org.tizen.lowmem-syspopup"}, + {"battery-syspopup", 0, 0, 5, 0, 0, "org.tizen.battery-syspopup"}, + {"system-syspopup", 1, 0, -1, 0, 0, "org.tizen.system-syspopup"}, + {"safetyvolume-syspopup", 2, 1, -1, 0, 0, "org.tizen.safetyvolume-syspopup"}, + {"crash-syspopup", 1, 0, -1, 0, 0, "org.tizen.crash-syspopup"}, + {"wc-syspopup", 0, 0, -1, 0, 0, "net.wc-syspopup"}, + {"bt-syspopup", 0, 0, -1, 0, 0, "org.tizen.bt-syspopup"}, + {"d2d-conv-syspopup", 2, 0, -1, 0, 0, "org.tizen.d2d-conv-syspopup"}, + {"fido-syspopup", 2, 0, -1, 0, 0, "org.tizen.fido-syspopup"} +}; + +static int __unlink_db(void) +{ + int ret; + + ret = access(PATH_DB, F_OK); + if (ret == 0) { + ret = unlink(PATH_DB); + if (ret != 0) { + printf("Failed to delete %s\n", PATH_DB); + return -1; + } + } + + return 0; +} + +static void __close_db(void) +{ + if (db == NULL) + return; + + sqlite3_close(db); + db = NULL; +} + +static int __open_db(void) +{ + int ret; + const char *query = CREATE_SYSPOPUP_INFO_TABLE; + char *err_msg = NULL; + + ret = sqlite3_open_v2(PATH_DB, &db, + SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL); + if (ret != SQLITE_OK) { + printf("Failed to create syspopup db - ret(%d), errmsg(%s)\n", + ret, sqlite3_errmsg(db)); + return -1; + } + + ret = sqlite3_exec(db, query, NULL, NULL, &err_msg); + if (ret != SQLITE_OK) { + printf("Failed to create syspopup info table(%s)\n", err_msg); + sqlite3_free(err_msg); + __close_db(); + return -1; + } + + ret = smack_setlabel(PATH_DB, DB_LABEL, SMACK_LABEL_ACCESS); + if (ret < 0) { + printf("Failed to set label\n"); + __close_db(); + return -1; + } + + if (access(PATH_DB_JOURNAL, F_OK) == 0) + smack_setlabel(PATH_DB_JOURNAL, DB_LABEL, SMACK_LABEL_ACCESS); + + return 0; +} + +static int __insert_syspopup_info(struct syspopup_info *info) +{ + int ret; + int result = 0; + sqlite3_stmt *stmt = NULL; + const char *query = QUERY_INSERT_SYSPOPUP_INFO; + + if (info == NULL) + return -1; + + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) + return -1; + + ret = sqlite3_bind_text(stmt, 1, info->name, -1, SQLITE_TRANSIENT); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_bind_int(stmt, 2, info->prio); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_bind_int(stmt, 3, info->focus); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_bind_int(stmt, 4, info->timeout); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_bind_int(stmt, 5, info->term_act); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_bind_int(stmt, 6, info->endkey_act); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_bind_text(stmt, 7, info->appid, -1, SQLITE_TRANSIENT); + if (ret != SQLITE_OK) { + result = -1; + goto end; + } + + ret = sqlite3_step(stmt); + if (ret != SQLITE_DONE) + result = -1; + +end: + sqlite3_finalize(stmt); + + return result; +} + +static int __init_db(void) +{ + int ret; + struct syspopup_info *info; + unsigned int info_size; + unsigned int i; + char *profile = NULL; + + system_info_get_platform_string("http://tizen.org/feature/profile", + &profile); + if (profile == NULL) { + printf("Failed to get profile info\n"); + return -1; + } + + switch (*profile) { + case 'm': + case 'M': + info = mobile_info; + info_size = ARRAY_SIZE(mobile_info); + break; + case 'w': + case 'W': + info = wearable_info; + info_size = ARRAY_SIZE(wearable_info); + break; + default: + printf("syspopup info doesn't exists\n"); + return -1; + } + free(profile); + + ret = __open_db(); + if (ret < 0) + return -1; + + for (i = 0; i < info_size; i++) { + ret = __insert_syspopup_info(&info[i]); + if (ret < 0) + break; + } + + __close_db(); + + return 0; +} + +int main(int argc, char **argv) +{ + int ret; + + if (getuid() != ROOT_UID) { + printf("This binary should be run as root user\n"); + return -1; + } + + ret = __unlink_db(); + if (ret < 0) + return -1; + + return __init_db(); +} diff --git a/test/test.c b/tool/test.c index 6a620c4..6a620c4 100755 --- a/test/test.c +++ b/tool/test.c |