From 588f31ec26940fdcfdb4a7ad6f5985b3e08589cc Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Tue, 18 Jun 2013 18:46:29 +0900 Subject: [PATCH] merge master branch Change-Id: I7cb9eb1afa2b1e41c819db85b7a152b0baf3a0a0 Signed-off-by: junsuk77.oh --- include/ail.h | 41 ++++++++++++++++++++++++++++++++++ initdb/src/initdb.c | 13 +++++++++-- packaging/ail.spec | 6 ++--- src/ail_desktop.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 114 insertions(+), 9 deletions(-) diff --git a/include/ail.h b/include/ail.h index 161033c..1a1e78d 100755 --- a/include/ail.h +++ b/include/ail.h @@ -1150,6 +1150,47 @@ static ail_error_e _remove_desktop(const char *appid) */ ail_error_e ail_desktop_remove(const char *appid); +/** + * @fn ail_error_e ail_desktop_clean(const char *pkgid) + * + * @brief clean a pkg information in the Application Information Database. + * + * @par Sync (or) Async : Synchronous API. + * + * @param[in] pkgid + * + * @return 0 if success, negative value(<0) if fail\n + * @retval AIL_ERROR_OK success + * @retval AIL_ERROR_FAIL internal error + * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter + * + * @pre no pre-condition. + * @post app information is removed in the Application Information Database. + * + * @see ail_desktop_add(), ail_desktop_update() + * + * @par Prospective Clients: + * External Apps. + * + * @code +static ail_error_e _clean_desktop(const char *pkgid) +{ + ail_error_e ret; + + if (!appid) { + return AIL_ERROR_FAIL; + } + + ret = ail_desktop_clean(pkgid); + if (ret != AIL_ERROR_OK) { + return AIL_ERROR_FAIL; + } + + return AIL_ERROR_OK; +} + * @endcode + */ +ail_error_e ail_desktop_clean(const char *pkgid); /** * @fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast) diff --git a/initdb/src/initdb.c b/initdb/src/initdb.c index 7e644d5..469a5ef 100755 --- a/initdb/src/initdb.c +++ b/initdb/src/initdb.c @@ -38,6 +38,8 @@ #define OPT_DESKTOP_DIRECTORY "/opt/share/applications" #define USR_DESKTOP_DIRECTORY "/usr/share/applications" #define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db" +#define APP_INFO_DB_FILE_JOURNAL "/opt/dbspace/.app_info.db-journal" +#define APP_INFO_DB_LABEL "ail::db" #ifdef _E #undef _E @@ -242,8 +244,10 @@ int main(int argc, char *argv[]) return AIL_ERROR_FAIL; } - const char *argv_bin[] = { "/bin/rm", APP_INFO_DB_FILE, NULL }; - xsystem(argv_bin); + const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL }; + xsystem(argv_rm); + const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL }; + xsystem(argv_rmjn); ret = setenv("AIL_INITDB", "1", 1); _D("AIL_INITDB : %d", ret); @@ -272,6 +276,11 @@ int main(int argc, char *argv[]) return AIL_ERROR_FAIL; } + const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL }; + xsystem(argv_smack); + const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL }; + xsystem(argv_smackjn); + return AIL_ERROR_OK; } diff --git a/packaging/ail.spec b/packaging/ail.spec index b28d29e..385cb5b 100755 --- a/packaging/ail.spec +++ b/packaging/ail.spec @@ -1,7 +1,7 @@ #sbs-git:slp/pkgs/a/ail ail 0.2.22 29ac1f2c98453cad647cca6a92abc7da3dbb047b Name: ail Summary: Application Information Library -Version: 0.2.68 +Version: 0.2.72 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 @@ -40,8 +40,8 @@ make %{?jobs:-j%jobs} %make_install %post -vconftool set -t string db/ail/ail_info "0" -f -vconftool set -t string db/menuscreen/desktop "0" -f +vconftool set -t string db/ail/ail_info "0" -f -s system::vconf_inhouse +vconftool set -t string db/menuscreen/desktop "0" -f -s system::vconf_inhouse CHDBGID="6010" diff --git a/src/ail_desktop.c b/src/ail_desktop.c index a1d19c5..330bf94 100755 --- a/src/ail_desktop.c +++ b/src/ail_desktop.c @@ -1101,7 +1101,9 @@ static ail_error_e _create_table(void) "desktop TEXT UNIQUE NOT NULL);", "CREATE TABLE localname (package TEXT NOT NULL, " "locale TEXT NOT NULL, " - "name TEXT NOT NULL, PRIMARY KEY (package, locale));", + "name TEXT NOT NULL, " + "x_slp_pkgid TEXT NOT NULL, PRIMARY KEY (package, locale));", + NULL }; @@ -1124,9 +1126,9 @@ static inline void _insert_localname(gpointer data, gpointer user_data) struct name_item *item = (struct name_item *)data; desktop_info_s *info = (desktop_info_s *)user_data; - snprintf(query, sizeof(query), "insert into localname (package, locale, name) " - "values ('%s', '%s', '%s');", - info->package, item->locale, item->name); + snprintf(query, sizeof(query), "insert into localname (package, locale, name, x_slp_pkgid) " + "values ('%s', '%s', '%s', '%s');", + info->package, item->locale, item->name, info->x_slp_pkgid); if (db_exec(query) < 0) _E("Failed to insert local name of package[%s]",info->package); } @@ -1356,6 +1358,41 @@ static ail_error_e _remove_package(const char* package) return AIL_ERROR_OK; } +static ail_error_e _clean_pkgid_data(const char* pkgid) +{ + char *query; + int size; + + retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER); + + if (db_open(DB_OPEN_RW) < 0) { + return AIL_ERROR_DB_FAILED; + } + + size = strlen(pkgid) + (0x01 << 10); + query = calloc(1, size); + retv_if(!query, AIL_ERROR_OUT_OF_MEMORY); + + snprintf(query, size, "delete from app_info where x_slp_pkgid = '%s'", pkgid); + + if (db_exec(query) < 0) { + free(query); + return AIL_ERROR_DB_FAILED; + } + + snprintf(query, size, "delete from localname where x_slp_pkgid = '%s'", pkgid); + _D("query=%s",query); + + if (db_exec(query) < 0) { + free(query); + return AIL_ERROR_DB_FAILED; + } + + _D("Clean pkgid data (%s).", pkgid); + free(query); + + return AIL_ERROR_OK; +} static ail_error_e _send_db_done_noti(noti_type type, const char *package) @@ -1533,6 +1570,24 @@ EXPORT_API ail_error_e ail_desktop_remove(const char *appid) return AIL_ERROR_OK; } +EXPORT_API ail_error_e ail_desktop_clean(const char *pkgid) +{ + ail_error_e ret; + + retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER); + if (!__is_authorized()) { + _E("You are not an authorized user on removing!\n"); + return -1; + } + + _D("ail_desktop_clean=%s",pkgid); + + ret = _clean_pkgid_data(pkgid); + retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL); + + return AIL_ERROR_OK; +} + EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid, const char *property, -- 2.7.4