From: Kévin THIERRY Date: Tue, 28 Jan 2014 15:52:34 +0000 (+0100) Subject: Add multi-user support X-Git-Tag: accepted/tizen/common/20140506.112840^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27bbf892e0f237c6ed297b78c55690994e0f60d5;p=platform%2Fcore%2Fappfw%2Fshortcut.git Add multi-user support Note that offending paths ("/opt/usr/apps") in the file sample.xml were not removed since this file is neither used nor part of the generated RPM. As the name of the file suggest it, it simply is a sample. Also correct some RPMLINT warnings/errors: + set a valid license tag in spec file + set a valid group tag in spec file + call ldconfig during post install (%post) and post uninstall (%postun) processes in spec file Bug-Tizen: PTREL-345 Change-Id: I1b4b00ddcf8d51c98f67e5ae268e0ca0503de176 Signed-off-by: Kévin THIERRY --- diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 924ab26..6204865 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -17,6 +17,7 @@ pkg_check_modules(svc_pkgs REQUIRED db-util com-core vconf + libtzplatform-config ) FOREACH(flag ${svc_pkgs_CFLAGS}) diff --git a/lib/src/main.c b/lib/src/main.c index 253c6c3..ff41c28 100644 --- a/lib/src/main.c +++ b/lib/src/main.c @@ -34,6 +34,9 @@ #include #include +/* For multi-user support */ +#include + #include "shortcut.h" #include "shortcut_internal.h" @@ -56,7 +59,7 @@ static struct info { .server_fd = -1, .client_fd = -1, .socket_file = "/tmp/.shortcut.service", - .dbfile = "/opt/dbspace/.shortcut_service.db", + .dbfile = "", .handle = NULL, .initialized = 0, .db_opened = 0, @@ -630,6 +633,7 @@ static inline int open_db(void) { int ret; + s_info.dbfile = tzplatform_mkpath(TZ_SYS_DB, ".shortcut_service.db"); ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD); if (ret != SQLITE_OK) { DbgPrint("Failed to open a %s\n", s_info.dbfile); diff --git a/packaging/libshortcut.spec b/packaging/libshortcut.spec index d31dd4d..fc107bb 100644 --- a/packaging/libshortcut.spec +++ b/packaging/libshortcut.spec @@ -1,14 +1,15 @@ -Name: libshortcut -Summary: Shortcut add feature supporting library -Version: 0.6.11 -Release: 0 -Group: HomeTF/Framework -License: Apache -Source0: %{name}-%{version}.tar.gz +Name: libshortcut +Summary: Shortcut add feature supporting library +Version: 0.6.11 +Release: 0 +Group: Graphics & UI Framework/Libraries +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest -Requires(post): /sbin/ldconfig +Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig +Requires: tizen-platform-config-tools BuildRequires: cmake, gettext-tools, coreutils BuildRequires: pkgconfig(glib-2.0) @@ -18,6 +19,7 @@ BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(com-core) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(libtzplatform-config) %description [Shortcut] AddToHome feature supporting library for menu/home screen developers. @@ -52,13 +54,13 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/opt/dbspace -touch %{buildroot}/opt/dbspace/.shortcut_service.db -touch %{buildroot}/opt/dbspace/.shortcut_service.db-journal +mkdir -p %{buildroot}%{TZ_SYS_DB} +touch %{buildroot}%{TZ_SYS_DB}/.shortcut_service.db +touch %{buildroot}%{TZ_SYS_DB}/.shortcut_service.db-journal -%post +%post -n libshortcut -p /sbin/ldconfig -%postun +%postun -n libshortcut -p /sbin/ldconfig %files -n libshortcut %manifest %{name}.manifest @@ -66,8 +68,8 @@ touch %{buildroot}/opt/dbspace/.shortcut_service.db-journal %{_libdir}/*.so* %{_prefix}/etc/package-manager/parserlib/* %{_datarootdir}/license/* -%attr(640,root,app) /opt/dbspace/.shortcut_service.db -%attr(640,root,app) /opt/dbspace/.shortcut_service.db-journal +%attr(640,root,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_DB}/.shortcut_service.db +%attr(640,root,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_DB}/.shortcut_service.db-journal %files devel %manifest %{name}.manifest diff --git a/pkgmgr_shortcut/CMakeLists.txt b/pkgmgr_shortcut/CMakeLists.txt index 0a4abc7..30b81ac 100644 --- a/pkgmgr_shortcut/CMakeLists.txt +++ b/pkgmgr_shortcut/CMakeLists.txt @@ -8,6 +8,7 @@ pkg_check_modules(bin_pkgs REQUIRED sqlite3 libxml-2.0 db-util + libtzplatform-config ) FOREACH(flag ${bin_pkgs_CFLAGS}) diff --git a/pkgmgr_shortcut/src/service_register.c b/pkgmgr_shortcut/src/service_register.c index 672e424..2e03c2c 100644 --- a/pkgmgr_shortcut/src/service_register.c +++ b/pkgmgr_shortcut/src/service_register.c @@ -29,6 +29,9 @@ #include #include +/* For multi-user support */ +#include + #include "dlist.h" #if !defined(SECURE_LOGD) @@ -81,7 +84,7 @@ static struct { const char *dbfile; sqlite3 *handle; } s_info = { - .dbfile = "/opt/dbspace/.shortcut_service.db", + .dbfile = "", .handle = NULL, }; @@ -759,6 +762,7 @@ static int db_init(void) int ret; struct stat stat; + s_info.dbfile = tzplatform_mkpath(TZ_SYS_DB, ".shortcut_service.db"); ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD); if (ret != SQLITE_OK) { ErrPrint("Failed to open a DB\n"); diff --git a/test/application.c b/test/application.c index 6c1e5f3..886cff3 100644 --- a/test/application.c +++ b/test/application.c @@ -18,6 +18,11 @@ #include #include +/* For multi-user support */ +#include + +#define FILE_PNG tzplatform_mkpath(TZ_SYS_SHARE, "image/what.png") + static int result_cb(int ret, int pid, void *data) { printf("Client: Return %d (%d)\n", ret, pid); @@ -29,10 +34,10 @@ static Eina_Bool shortcut_add_cb(void *data) { int ret; - ret = add_to_home_shortcut("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", result_cb, NULL); + ret = add_to_home_shortcut("pkgname", "MyName", 0, "/usr/bin/true", FILE_PNG, result_cb, NULL); printf("Client: shortcut_add_to_home returns: %d\n", ret); - ret = add_to_home_livebox("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", 1.0f, result_cb, NULL); + ret = add_to_home_livebox("pkgname", "MyName", 0, "/usr/bin/true", FILE_PNG, 1.0f, result_cb, NULL); printf("Client: shortcut_add_to_home_with_period returns: %d\n", ret); return ECORE_CALLBACK_RENEW; diff --git a/test/icon.c b/test/icon.c index 9267bad..71547c5 100644 --- a/test/icon.c +++ b/test/icon.c @@ -18,6 +18,11 @@ #include #include +/* For multi-user support */ +#include + +#define USR_SHARE tzplatform_getenv(TZ_USER_SHARE) + static int result_cb(struct shortcut_icon *handle, int ret, void *data) { printf("Client: Return %d (%p)\n", ret, handle); @@ -48,7 +53,7 @@ static Eina_Bool test_main(void *data) ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL); printf("TEXT set_info: %d\n", ret); - snprintf(filename, sizeof(filename), "/opt/usr/share/live_magazine/always/out%d.png", idx); + snprintf(filename, sizeof(filename), "%s/live_magazine/always/out%d.png", USR_SHARE, idx); switch (idx % 7) { case 0: type = LIVEBOX_TYPE_1x1; break; diff --git a/test_db_builder.sh b/test_db_builder.sh index 2221c7f..6e20008 100755 --- a/test_db_builder.sh +++ b/test_db_builder.sh @@ -16,7 +16,8 @@ # * #*/ -DBFILE="/opt/dbspace/.shortcut_service.db" +eval $(tzplatform-get TZ_SYS_DB) +DBFILE=$TZ_SYS_DB"/.shortcut_service.db" APPID=( "org.tizen.facebook"