Remove Profile Build Dependency 82/96882/6
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 10 Nov 2016 12:08:31 +0000 (21:08 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 16 Jan 2017 08:07:39 +0000 (17:07 +0900)
- This is for Tizen 4.0.
- The syspopup initdb tool is added.

Change-Id: Ia46f7d423eb138c72b9c8ffeecf71d050b104bce
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
CMakeLists.txt
data/syspopup_db.sql [deleted file]
data/wearable/syspopup_db.sql [deleted file]
packaging/syspopup.manifest
packaging/syspopup.spec
scripts/502.syspopup_upgrade.sh
test/CMakeLists.txt [deleted file]
test/test.c [deleted file]
tool/CMakeLists.txt [new file with mode: 0644]
tool/sp_initdb.c [new file with mode: 0755]
tool/test.c [new file with mode: 0755]

index ea0106b6a99b8044ac013c4942a633e69c9d0572..7d756df917bada91cc1de1fe68f8d897c529f170 100644 (file)
@@ -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 (executable)
index c96573a..0000000
+++ /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 (executable)
index 9db2601..0000000
+++ /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");
-
index 776b0ca273f0d7fbb449b47910428e7cad25f090..f5a44ec920efb421b522894ebcfc5f521481cf61 100644 (file)
@@ -2,7 +2,4 @@
         <request>
                 <domain name="_"/>
         </request>
-       <assign>
-               <filesystem path="TZ_SYS_DB/.syspopup.db" label="System::Shared"/>
-       </assign>
 </manifest>
index bb52152536406633d64a1aad83c3692ee7b149fb..e433de5f8ae9d3544f730bea4241a0e208be951f 100644 (file)
@@ -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
index eeb859f3f4c802b2beeea20c06959497141d5e08..32fdfe21ffc7c29569df0df679a5cd243d6b5693 100755 (executable)
@@ -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 (file)
index 86f105d..0000000
+++ /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/test/test.c b/test/test.c
deleted file mode 100755 (executable)
index 6a620c4..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * syspopup
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * 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.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <bundle.h>
-#include <bundle_internal.h>
-#include "syspopup_caller.h"
-
-static void usage(void)
-{
-       printf("[usage] sp_test launch/destroy popup_name..."
-                               "(key1,val1,key2,val2,...)\n");
-}
-
-int main(int argc, char **argv)
-{
-       bundle *b;
-       int i;
-       int ret = 0;
-
-       if (argc < 2) {
-               usage();
-               return -1;
-       }
-
-       if (strcmp(argv[1], "launch") == 0) {
-               if ((argc < 3) || (argc % 2 == 0)) {
-                       usage();
-                       return -1;
-               }
-
-               b = bundle_create();
-               for (i = 3; i < argc; i = i + 2)
-                       bundle_add(b, argv[i], argv[i + 1]);
-               ret = syspopup_launch(argv[2], b);
-               bundle_free(b);
-               if (ret < 0)
-                       return -1;
-
-       } else if (strcmp(argv[1], "destroy") == 0) {
-               ret = syspopup_destroy_all();
-               if (ret < 0)
-                       return -1;
-       } else {
-               usage();
-       }
-
-       return 0;
-}
-
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ccff37b
--- /dev/null
@@ -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 (executable)
index 0000000..216f326
--- /dev/null
@@ -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/tool/test.c b/tool/test.c
new file mode 100755 (executable)
index 0000000..6a620c4
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * syspopup
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <bundle.h>
+#include <bundle_internal.h>
+#include "syspopup_caller.h"
+
+static void usage(void)
+{
+       printf("[usage] sp_test launch/destroy popup_name..."
+                               "(key1,val1,key2,val2,...)\n");
+}
+
+int main(int argc, char **argv)
+{
+       bundle *b;
+       int i;
+       int ret = 0;
+
+       if (argc < 2) {
+               usage();
+               return -1;
+       }
+
+       if (strcmp(argv[1], "launch") == 0) {
+               if ((argc < 3) || (argc % 2 == 0)) {
+                       usage();
+                       return -1;
+               }
+
+               b = bundle_create();
+               for (i = 3; i < argc; i = i + 2)
+                       bundle_add(b, argv[i], argv[i + 1]);
+               ret = syspopup_launch(argv[2], b);
+               bundle_free(b);
+               if (ret < 0)
+                       return -1;
+
+       } else if (strcmp(argv[1], "destroy") == 0) {
+               ret = syspopup_destroy_all();
+               if (ret < 0)
+                       return -1;
+       } else {
+               usage();
+       }
+
+       return 0;
+}
+