INSTALL(TARGETS ${LIBNAME} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/ail.h DESTINATION include)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/desktop.conf.in ${CMAKE_SOURCE_DIR}/desktop.conf)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/desktop.conf DESTINATION share/install-info)
# AIL init database
+++ /dev/null
-/opt/share/applications
--- /dev/null
+@TZ_SYS_RW_DESKTOP_APP@
#include <sys/types.h>
#include <pwd.h>
#include <tzplatform_config.h>
+
#define OWNER_ROOT 0
#define GROUP_MENU 6010
+#define GLOBAL_USER 0 //tzplatform
#define BUFSZE 1024
#define OPT_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP)
#define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
#define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
#define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
-#define APP_INFO_DB_LABEL "ail::db"
+#define APP_INFO_DB_LABEL "_"
#ifdef __cplusplus
extern "C" {
/**
* @fn ail_error_e ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data)
- *
+ * @fn ail_error_e ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data, uid_t uid)
* @brief Calls the callback function for each app filtered by given filter. If the filter is not given (i.e filter handle is NULL), it is invoked for all apps.
*
* @par Sync (or) Async : Synchronous API
* @param[in] filter a filter handle
* @param[in] func the function to call with each app's appinfo
* @param[in] user_data user_data to pass to the function
+ * @param[in] uid ID of the owner of the application
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter,
ail_list_appinfo_cb appinfo_func,
void *user_data);
-
-
-
+ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
+ ail_list_appinfo_cb appinfo_func,
+ void *user_data, uid_t uid);
/**
- * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count)
- *
+ * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count, uid_t uid)
+ * @fn ail_error_e ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count)
* @brief Gets the number of app which is filtered by the given filter. If the filter is not given (i.e filter handle is NULL), all app are counted.
*
* @par Sync (or) Async : Synchronous API
*
* @param[in] filter a filter handle
* @param[in] count the number of appinfo which is filtered
+ * @param[in] uid ID of the owner of the application
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* @endcode
*/
ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
-
-
+ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count, uid_t uid);
/**
* @fn ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle)
- *
+ * @fn ail_error_e ail_package_get_appinfo(const char *package, uid_t uid, ail_appinfo_h *handle)
* @brief get an application information related to a package.
This API just retrieves all the information of the package from Application Information Database.
All data related to the package are loaded in the memory after calling this function.
* @par Sync (or) Async : Synchronous API.
*
* @param[in] package package name what you want to know about.
+ * @param[in] uid ID of the owner of the application
* @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
*
* @return 0 if success, negative value(<0) if fail\n
* @endcode
*/
ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle) __attribute__((deprecated));
-
-
+ail_error_e ail_package_get_usr_appinfo(const char *package, uid_t uid, ail_appinfo_h *handle) __attribute__((deprecated));
/**
* @fn ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle)
- *
+ * @fn ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *handle)
* @brief get an application information related to a appid.
This API just retrieves all the information of the application from Application Information Database.
All data related to the appid are loaded in the memory after calling this function.
* @endcode
*/
ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle);
-
+ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *handle);
/**
* @fn ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value)
*/
ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value);
-
-
/**
- * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str)
- *
+ * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, uid_t uid, char **str)
+ * @fn ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *property, char **str)
* @brief get a string related to the property.
Before using this API, the handle is defined by calling ail_get_appinfo.
This function needs a out-parameter for the value.
*
* @param[in] handle the handle is defined by calling ail_get_appinfo.
* @param[in] property a property type of string.
+ * @param[in] uid the addressee user id of the instruction
* @param[out] str a out-parameter string that is mapped with the property. The icon property contains the absolute file path. If there is no data, the value of str is NULL.
*
* @return 0 if success, negative value(<0) if fail\n
* @endcode
*/
ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str);
-
+ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *property, uid_t uid, char **str);
/**
/**
- * @fn ail_error_e ail_desktop_add(const char *appid)
- *
+ * @fn ail_error_e ail_desktop_add(const char *appid, )
+ * @fn ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
* @brief add a app information into Application Information Database.
A desktop file for this app has to be installed in the desktop directory before using this API.
If there is no database for Application Information Database, this API will create the DB.
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid
+ * @param[in] uid the addressee user id of the instruction
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* @endcode
*/
ail_error_e ail_desktop_add(const char *appid);
-
+ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid);
/**
* @fn ail_error_e ail_desktop_update(const char *appid)
- *
+ * @fn ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid)
* @brief update a app information in the Application Information Database.
A desktop file for this app has to be installed in the desktop directory before using this API.
And a notification is published to the applications who want to know about changing DB.
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid
+ * @param[in] uid ID of the owner of the application
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* @endcode
*/
ail_error_e ail_desktop_update(const char *appid);
-
+ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid);
/**
* @fn ail_error_e ail_desktop_remove(const char *appid)
- *
+ * @fn ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
* @brief remove a app information in the Application Information Database.
And a notification is published to the applications who want to know about changing DB.
*
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid
+ * @param[in] uid the addressee user id of the instruction
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* @endcode
*/
ail_error_e ail_desktop_remove(const char *appid);
+ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid);
/**
* @fn ail_error_e ail_desktop_clean(const char *pkgid)
- *
+ * @fn ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid))
* @brief clean a pkg information in the Application Information Database.
*
* @par Sync (or) Async : Synchronous API.
*
* @param[in] pkgid
+ * @param[in] uid ID of the owner of the application
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* @endcode
*/
ail_error_e ail_desktop_clean(const char *pkgid);
-
+ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid);
/**
* @fn ail_error_e ail_desktop_fota(const char *appid)
- *
+ * @fn ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
* @brief add a app information into Application Information Database.
A desktop file for this app has to be installed in the desktop directory before using this API.
If there is no database for Application Information Database, this API will create the DB.
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid
+ * @param[in] uid the addressee user id of the instruction
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* @endcode
*/
ail_error_e ail_desktop_fota(const char *appid);
-
+ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid);
/**
- * @fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
- *
+ *@fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
+ * @fn ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast)
* @brief update a app information db.
And a notification is published to the applications who want to know about changing DB.
*
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid
+ * @param[in] uid ID of the owner of the application
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* External Apps.
*
* @code
-static ail_error_e _appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
+static ail_error_e _appinfo_modify_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast)
{
ail_error_e ret;
*/
ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast);
-
+ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast);
/** @} */
return -1;
}
- ret = ail_filter_count_appinfo(filter, &total);
+ ret = ail_filter_count_appinfo(filter, &total, getuid());
if (ret != AIL_ERROR_OK) {
ail_filter_destroy(filter);
return -1;
continue;
}
- if (ail_desktop_add(package) != AIL_ERROR_OK) {
+ if (ail_desktop_add(package, getuid()) != AIL_ERROR_OK) {
_E("Failed to add a package[%s]", package);
} else {
ok_cnt++;
if (!__is_authorized()) {
fprintf(stderr, "You are not an authorized user!\n");
_D("You are not root user!\n");
-
+ exit(-1);
}
else {
const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
%endif
-%cmake . -DBUILD_PKGTYPE=rpm \
- -DSMACK=Off
+%cmake . -DTZ_SYS_RW_DESKTOP_APP=%TZ_SYS_RW_DESKTOP_APP \
+ -DBUILD_PKGTYPE=rpm \
+ -DSMACK=Off
%__make %{?_smp_mflags}
#include <stdlib.h>
#include <string.h>
#include <db-util.h>
+#include <errno.h>
#include <glib.h>
+#include <grp.h>
+#include <pwd.h>
+#include <sys/stat.h>
#include "ail_private.h"
#include "ail_db.h"
+#define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO
+#define BUFSIZE 4096
+#define QUERY_ATTACH "attach database '%s' as Global"
+#define QUERY_CREATE_VIEW_APP "CREATE temp VIEW app_info as select distinct * from (select * from main.app_info m union select * from Global.app_info g)"
+
+#define QUERY_CREATE_VIEW_LOCAL "CREATE temp VIEW localname as select distinct * from (select * from main.localname m union select * from Global.localname g)"
+
#define retv_with_dbmsg_if(expr, val) do { \
if (expr) { \
- _E("db_info.dbro: %s", sqlite3_errmsg(db_info.dbro)); \
- _E("db_info.dbrw: %s", sqlite3_errmsg(db_info.dbrw)); \
- _E("db_info.dbro errcode: %d", sqlite3_extended_errcode(db_info.dbro)); \
- _E("db_info.dbrw errcode: %d", sqlite3_extended_errcode(db_info.dbrw)); \
+ _E("db_info.dbUserro: %s", sqlite3_errmsg(db_info.dbUserro)); \
+ _E("db_info.dbGlobalro: %s", sqlite3_errmsg(db_info.dbGlobalro)); \
+ _E("db_info.dbUserrw: %s", sqlite3_errmsg(db_info.dbUserrw)); \
+ _E("db_info.dbGlobalrw: %s", sqlite3_errmsg(db_info.dbGlobalrw)); \
+ _E("db_info.dbUserro errcode: %d", sqlite3_extended_errcode(db_info.dbUserro)); \
+ _E("db_info.dbGlobalro errcode: %d", sqlite3_extended_errcode(db_info.dbGlobalro)); \
+ _E("db_info.dbUserrw errcode: %d", sqlite3_extended_errcode(db_info.dbUserrw)); \
+ _E("db_info.dbGlobalrw errcode: %d", sqlite3_extended_errcode(db_info.dbGlobalrw)); \
return (val); \
} \
} while (0)
-
static __thread struct {
- sqlite3 *dbro;
- sqlite3 *dbrw;
+ sqlite3 *dbUserro;
+ sqlite3 *dbGlobalro;
+ sqlite3 *dbUserrw;
+ sqlite3 *dbGlobalrw;
} db_info = {
- .dbro = NULL,
- .dbrw = NULL
+ .dbUserro = NULL,
+ .dbGlobalro = NULL,
+ .dbUserrw = NULL,
+ .dbGlobalrw = NULL
};
+ static __thread sqlite3 *dbInit = NULL;
+
+static int ail_db_change_perm(const char *db_file)
+{
+ char buf[BUFSIZE];
+ char journal_file[BUFSIZE];
+ char *files[3];
+ int ret, i;
+ struct group *grpinfo = NULL;
+ const char *name = "users";
+
+ files[0] = (char *)db_file;
+ files[1] = journal_file;
+ files[2] = NULL;
+
+ retv_if(!db_file, AIL_ERROR_FAIL);
+ if(getuid()) //At this time we should be root to apply this
+ return AIL_ERROR_OK;
+
+ snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
+
+ for (i = 0; files[i]; i++) {
+ grpinfo = getgrnam(name);
+ if(grpinfo == NULL)
+ _E("getgrnam(users) returns NULL !");
+
+ // Compare git_t type and not group name
+ ret = chown(files[i], OWNER_ROOT, grpinfo->gr_gid);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, grpinfo->gr_gid, buf);
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+ return AIL_ERROR_FAIL;
+ }
+ }
+
+ return AIL_ERROR_OK;
+}
+
+char* ail_get_icon_path(uid_t uid)
+{
+ char *result_psswd = NULL;
+ if(uid == GLOBAL_USER)
+ {
+ result_psswd = tzplatform_getenv(TZ_SYS_RW_ICONS);
+ }
+ else
+ {
+ const char *name = "users";
+ struct passwd *userinfo = NULL;
+ struct group *grpinfo = NULL;
+
+ userinfo = getpwuid(uid);
+ if(userinfo == NULL) {
+ _E("getpwuid(%d) returns NULL !", uid);
+ return NULL;
+ }
+
+ grpinfo = getgrnam(name);
+ if(grpinfo == NULL) {
+ _E("getgrnam(users) returns NULL !");
+ return NULL;
+ }
+ // Compare git_t type and not group name
+ if (grpinfo->gr_gid != userinfo->pw_gid) {
+ _E("UID [%d] does not belong to 'users' group!", uid);
+ return NULL;
+ }
+ result_psswd = tzplatform_getenv(TZ_USER_ICONS);
+ }
+ return result_psswd;
+}
-static char* getUserAppDB(void)
+static char* ail_get_app_DB(uid_t uid)
{
- if(getuid())
- return tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.app_info.db");
- else
- return APP_INFO_DB_FILE;
+ char *result_psswd = NULL;
+ struct group *grpinfo = NULL;
+ char * dir = NULL;
+ if(uid == GLOBAL_USER)
+ {
+ result_psswd = strdup(APP_INFO_DB_FILE);
+ grpinfo = getgrnam("root");
+ if(grpinfo == NULL) {
+ _E("getgrnam(users) returns NULL !");
+ return NULL;
+ }
+ }
+ else
+ {
+ struct passwd *userinfo = getpwuid(uid);
+ if(userinfo == NULL) {
+ _E("getpwuid(%d) returns NULL !", uid);
+ return NULL;
+ }
+ grpinfo = getgrnam("users");
+ if(grpinfo == NULL) {
+ _E("getgrnam(users) returns NULL !");
+ return NULL;
+ }
+ // Compare git_t type and not group name
+ if (grpinfo->gr_gid != userinfo->pw_gid) {
+ _E("UID [%d] does not belong to 'users' group!", uid);
+ return NULL;
+ }
+ asprintf(&result_psswd, "%s/.applications/dbspace/.app_info.db", userinfo->pw_dir);
+ }
+
+ dir = strrchr(result_psswd, '/');
+ if(!dir)
+ return result_psswd;
+
+ //Control if db exist create otherwise
+ if(access(dir + 1, F_OK)) {
+ int ret;
+ mkdir(dir + 1, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
+ ret = chown(dir + 1, uid, grpinfo->gr_gid);
+ if (ret == -1) {
+ char buf[BUFSIZE];
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chown %s %d.%d, because %s", dir + 1, uid, grpinfo->gr_gid, buf);
+ }
+ }
+ return result_psswd;
}
static ail_error_e db_do_prepare(sqlite3 *db, const char *query, sqlite3_stmt **stmt)
return AIL_ERROR_OK;
}
-ail_error_e db_open(db_open_mode mode)
+ail_error_e db_open(db_open_mode mode, uid_t uid)
{
int ret;
int changed = 0;
-
+ int i;
+ const char *tbls[3] = {
+ "CREATE TABLE app_info "
+ "(package TEXT PRIMARY KEY, "
+ "exec TEXT DEFAULT 'No Exec', "
+ "name TEXT DEFAULT 'No Name', "
+ "type TEXT DEFAULT 'Application', "
+ "icon TEXT DEFAULT 'No Icon', "
+ "categories TEXT, "
+ "version TEXT, "
+ "mimetype TEXT, "
+ "x_slp_service TEXT, "
+ "x_slp_packagetype TEXT, "
+ "x_slp_packagecategories TEXT, "
+ "x_slp_packageid TEXT, "
+ "x_slp_uri TEXT, "
+ "x_slp_svc TEXT, "
+ "x_slp_exe_path TEXT, "
+ "x_slp_appid TEXT, "
+ "x_slp_pkgid TEXT, "
+ "x_slp_domain TEXT, "
+ "x_slp_submodemainid TEXT, "
+ "x_slp_installedstorage TEXT, "
+ "x_slp_baselayoutwidth INTEGER DEFAULT 0, "
+ "x_slp_installedtime INTEGER DEFAULT 0, "
+ "nodisplay INTEGER DEFAULT 0, "
+ "x_slp_taskmanage INTEGER DEFAULT 1, "
+ "x_slp_multiple INTEGER DEFAULT 0, "
+ "x_slp_removable INTEGER DEFAULT 1, "
+ "x_slp_ishorizontalscale INTEGER DEFAULT 0, "
+ "x_slp_enabled INTEGER DEFAULT 1, "
+ "x_slp_submode INTEGER DEFAULT 0, "
+ "desktop TEXT UNIQUE NOT NULL);",
+ "CREATE TABLE localname (package TEXT NOT NULL, "
+ "locale TEXT NOT NULL, "
+ "name TEXT NOT NULL, "
+ "x_slp_pkgid TEXT NOT NULL, PRIMARY KEY (package, locale));",
+
+ NULL
+ };
+
+ if (access(ail_get_app_DB(uid), F_OK)) {
+ if (AIL_ERROR_OK == db_util_open_with_options(ail_get_app_DB(uid), &dbInit, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL))
+ {
+ for (i = 0; tbls[i] != NULL; i++) {
+ ret = do_db_exec(tbls[i], dbInit);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ }
+ } else {
+ dbInit = NULL;
+ _E("Failed to create table %s\n",ail_get_app_DB(uid));
+ }
+ }
+ if(dbInit) {
+ if(AIL_ERROR_OK != ail_db_change_perm(ail_get_app_DB(uid))) {
+ _E("Failed to change permission\n");
+ }
+ ret = sqlite3_close(dbInit);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+ dbInit = NULL;
+ }
if(mode & DB_OPEN_RO) {
- if (!db_info.dbro) {
- //ret = db_util_open_with_options(APP_INFO_DB, &db_info.dbro, SQLITE_OPEN_READONLY, NULL);
- ret = db_util_open(getUserAppDB(), &db_info.dbro, 0);
- retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+ if (!db_info.dbUserro) {
+ db_util_open_with_options(ail_get_app_DB(uid), &db_info.dbUserro, SQLITE_OPEN_READONLY, NULL);
+ char query_attach[AIL_SQL_QUERY_MAX_LEN];
+ char query_view_app[AIL_SQL_QUERY_MAX_LEN];
+ char query_view_local[AIL_SQL_QUERY_MAX_LEN];
+ snprintf(query_attach, AIL_SQL_QUERY_MAX_LEN, QUERY_ATTACH, ail_get_app_DB(GLOBAL_USER));
+ _E("info : execute query_attach : %s", query_attach );
+ if (db_exec_usr_ro(query_attach) < 0) {
+ return AIL_ERROR_DB_FAILED;
+ }
+ snprintf(query_view_app, AIL_SQL_QUERY_MAX_LEN, QUERY_CREATE_VIEW_APP);
+ _E("info : execute query_attach : %s", query_view_app );
+ if (db_exec_usr_ro(query_view_app) < 0) {
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ snprintf(query_view_local, AIL_SQL_QUERY_MAX_LEN, QUERY_CREATE_VIEW_LOCAL);
+ _E("info : execute query_attach : %s", query_view_local );
+ if (db_exec_usr_ro(query_view_local) < 0) {
+ return AIL_ERROR_DB_FAILED;
+ }
}
+ if (!db_info.dbGlobalro) {
+ ret = db_util_open_with_options(ail_get_app_DB(GLOBAL_USER), &db_info.dbGlobalro, SQLITE_OPEN_READONLY, NULL);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+ }
}
if(mode & DB_OPEN_RW) {
- if (!db_info.dbrw) {
- ret = db_util_open(getUserAppDB(), &db_info.dbrw, 0);
- retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+ //if (__is_admin) {
+ if(uid != GLOBAL_USER) {//TOCHANGETO is_admin
+ if(!db_info.dbUserrw){
+ ret = db_util_open(ail_get_app_DB(uid), &db_info.dbUserrw, 0);
+ }
+ } else {
+ if(!db_info.dbGlobalrw){
+ ret = db_util_open(ail_get_app_DB(GLOBAL_USER), &db_info.dbGlobalrw, 0);
+ }
}
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ //}
}
return AIL_ERROR_OK;
}
+
ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt)
{
- return db_do_prepare(db_info.dbro, query, stmt);
+ return db_do_prepare(db_info.dbUserro, query, stmt);
+}
+
+ail_error_e db_prepare_globalro(const char *query, sqlite3_stmt **stmt)
+{
+ return db_do_prepare(db_info.dbGlobalro, query, stmt);
}
ail_error_e db_prepare_rw(const char *query, sqlite3_stmt **stmt)
{
- return db_do_prepare(db_info.dbrw, query, stmt);
+ return db_do_prepare(db_info.dbUserrw, query, stmt);
+}
+
+
+ail_error_e db_prepare_globalrw(const char *query, sqlite3_stmt **stmt)
+{
+ return db_do_prepare(db_info.dbGlobalrw, query, stmt);
}
-ail_error_e db_exec(const char *query)
+ail_error_e do_db_exec(const char *query, sqlite3 * fileSQL)
{
int ret;
char *errmsg;
retv_if(!query, AIL_ERROR_INVALID_PARAMETER);
- retv_if(!db_info.dbrw, AIL_ERROR_DB_FAILED);
+ retv_if(!fileSQL, AIL_ERROR_DB_FAILED);
- ret = sqlite3_exec(db_info.dbrw, query, NULL, NULL, &errmsg);
+ ret = sqlite3_exec(fileSQL, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
_E("Cannot execute this query - %s. because %s",
query, errmsg? errmsg:"uncatched error");
+ail_error_e db_exec_usr_rw(const char *query)
+{
+ return do_db_exec(query, db_info.dbUserrw);
+}
+
+
+ail_error_e db_exec_usr_ro(const char *query)
+{
+ return do_db_exec(query, db_info.dbUserro);
+}
+
+ail_error_e db_exec_glo_ro(const char *query)
+{
+ return do_db_exec(query, db_info.dbGlobalro);
+}
+
+ail_error_e db_exec_glo_rw(const char *query)
+{
+ return do_db_exec(query, db_info.dbGlobalrw);
+}
+
+
ail_error_e db_close(void)
{
int ret;
- if(db_info.dbro) {
- ret = sqlite3_close(db_info.dbro);
+ if(db_info.dbUserro) {
+ ret = sqlite3_close(db_info.dbUserro);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ db_info.dbUserro = NULL;
+ }
+ if(db_info.dbGlobalrw) {
+ ret = sqlite3_close(db_info.dbGlobalrw);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
- db_info.dbro = NULL;
+ db_info.dbGlobalrw = NULL;
}
- if(db_info.dbrw) {
- ret = sqlite3_close(db_info.dbrw);
+ if(db_info.dbUserrw) {
+ ret = sqlite3_close(db_info.dbUserrw);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
- db_info.dbrw = NULL;
+ db_info.dbUserrw = NULL;
}
return AIL_ERROR_OK;
int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data)
{
char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(db_info.dbro, query, callback, data, &error_message)) {
- _E("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return -1;
+ if(db_info.dbUserro) {
+ if (SQLITE_OK !=
+ sqlite3_exec(db_info.dbUserro, query, callback, data, &error_message)) {
+ _E("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ return -1;
+ }
+ }
+ if(db_info.dbUserro) {
+ if (SQLITE_OK !=
+ sqlite3_exec(db_info.dbUserro, query, callback, data, &error_message)) {
+ _E("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ return -1;
+ }
}
sqlite3_free(error_message);
return 0;
} db_open_mode;
typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
-ail_error_e db_open(db_open_mode mode);
+static int ail_db_change_perm(const char *db_file);
+char* ail_get_icon_path(uid_t uid);
+ail_error_e db_open(db_open_mode mode, uid_t uid);
ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt);
+ail_error_e db_prepare_globalro(const char *query, sqlite3_stmt **stmt);
ail_error_e db_prepare_rw(const char *query, sqlite3_stmt **stmt);
+ail_error_e db_prepare_globalrw(const char *query, sqlite3_stmt **stmt);
ail_error_e db_bind_bool(sqlite3_stmt *stmt, int idx, bool value);
ail_error_e db_bind_int(sqlite3_stmt *stmt, int idx, int value);
ail_error_e db_reset(sqlite3_stmt *stmt);
ail_error_e db_finalize(sqlite3_stmt *stmt);
-
-ail_error_e db_exec(const char *query);
+ail_error_e do_db_exec(const char *query,sqlite3 * fileSQL);
+ail_error_e db_exec_usr_rw(const char *query);
+ail_error_e db_exec_usr_ro(const char *query);
ail_error_e db_close(void);
int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data);
#endif
#define _GNU_SOURCE
+#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <vconf.h>
#include <glib.h>
+#include <grp.h>
+#include <pwd.h>
#include "ail_private.h"
#include "ail_db.h"
#include "ail_sql.h"
#include "ail.h"
-#define BUFSZE 4096
+#define BUFSIZE 4096
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#define argsdelimiter " \t"
static char*
-_get_icon_with_path(char* icon)
+_get_icon_with_path(char* icon, uid_t uid)
{
retv_if(!icon, NULL);
memset(icon_with_path, 0, len);
- sqlite3_snprintf( len, icon_with_path,"/opt/share/icons/%q/small/%q", theme, icon);
+ sqlite3_snprintf( len, icon_with_path,"%s/%q/small/%q", ail_get_icon_path(uid), theme, icon);
do {
if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path,"/usr/share/icons/%q/small/%q", theme, icon);
+ sqlite3_snprintf( len, icon_with_path,"%s/%q/small/%q", tzplatform_getenv(TZ_SYS_RO_ICONS), theme, icon);
if (access(icon_with_path, R_OK) == 0) break;
_D("cannot find icon %s", icon_with_path);
- sqlite3_snprintf( len, icon_with_path, "/opt/share/icons/default/small/%q", icon);
+ sqlite3_snprintf( len, icon_with_path, "%s/default/small/%q", ail_get_icon_path(uid), icon);
if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path, "/usr/share/icons/default/small/%q", icon);
+ sqlite3_snprintf( len, icon_with_path, "%s/default/small/%q", tzplatform_getenv(TZ_SYS_RO_ICONS), icon);
if (access(icon_with_path, R_OK) == 0) break;
#if 1 /* this will be remove when finish the work for moving icon path */
_E("icon file must be moved to %s", icon_with_path);
- sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/%q/small/%q", package, theme, icon);
+ sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", tzplatform_getenv(TZ_SYS_RW_APP), package, theme, icon);
if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/%q/small/%q", package, theme, icon);
+ sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q", tzplatform_getenv(TZ_SYS_RO_APP), package, theme, icon);
if (access(icon_with_path, R_OK) == 0) break;
_D("cannot find icon %s", icon_with_path);
- sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/default/small/%q", package, icon);
+ sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/default/small/%q", tzplatform_getenv(TZ_SYS_RW_APP), package, icon);
if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/default/small/%q", package, icon);
+ sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/default/small/%q", tzplatform_getenv(TZ_SYS_RO_APP), package, icon);
if (access(icon_with_path, R_OK) == 0) break;
#endif
} while (0);
}
-static ail_error_e _read_icon(void *data, char *tag, char *value)
+static ail_error_e _read_icon(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
- info->icon = _get_icon_with_path(value);
+ info->icon = _get_icon_with_path(value, uid);
retv_if (!info->icon, AIL_ERROR_OUT_OF_MEMORY);
/* Utility functions */
-static int _count_all(void)
+static int _count_all(uid_t uid)
{
ail_error_e ret;
int count;
- ret = ail_filter_count_appinfo(NULL, &count);
+ if (uid != GLOBAL_USER)
+ ret = ail_filter_count_usr_appinfo(NULL, &count, uid);
+ else
+ ret = ail_filter_count_appinfo(NULL, &count);
if(ret != AIL_ERROR_OK) {
_E("cannot count appinfo");
count = -1;
return count;
}
-char *_pkgname_to_desktop(const char *package)
+char *_pkgname_to_desktop(const char *package, uid_t uid)
{
char *desktop;
- char *desktop_path;
+ char *desktop_path;
int size;
retv_if(!package, NULL);
- if(getuid() > 0)
- {
+ if(uid != GLOBAL_USER)
+ {
desktop_path = tzplatform_mkpath(TZ_USER_HOME, ".applications/desktop");
+ if(access(desktop_path, F_OK)) {
+ struct group *grpinfo = NULL;
+ const char *name = "users"; //to change
+ int ret;
+ char buf[BUFSIZE];
+ mkdir(desktop_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
+ grpinfo = getgrnam(name);
+ if(grpinfo == NULL)
+ _E("getgrnam(users) returns NULL !");
+
+ ret = chown(desktop_path, uid, grpinfo->gr_gid);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chown %s %d.%d, because %s", desktop_path, uid, grpinfo->gr_gid, buf);
+ }
+ }
}
else
{
desktop_path = tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP);
+ if(access(desktop_path, F_OK)) {
+ struct group *grpinfo = NULL;
+ const char *name = "root"; //to change
+ int ret;
+ char buf[BUFSIZE];
+ mkdir(desktop_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
+ grpinfo = getgrnam(name);
+ if(grpinfo == NULL)
+ _E("getgrnam(users) returns NULL !");
+
+ ret = chown(desktop_path, uid, grpinfo->gr_gid);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chown %s %d.%d, because %s", desktop_path, uid, grpinfo->gr_gid, buf);
+ }
+ }
}
size = strlen(desktop_path) + strlen(package) + 10;
snprintf(desktop, size, "%s/%s.desktop", desktop_path, package);
- _D("uid: %d / desktop: [%s]\n", getuid(), desktop);
+ _D("uid: %d / desktop: [%s]\n", uid, desktop);
return desktop;
}
}
-static inline int _insert_local_info(desktop_info_s* info)
+static inline int _insert_local_info(desktop_info_s* info, uid_t uid)
{
int len_query = SQL_INSERT_LOCALNAME_STR_LEN;
int nb_locale_args;
strcat(query, SQL_LOCALNAME_TRIPLET_STR);
do {
- ret = db_prepare_rw(query, &stmt);
+ if(uid != GLOBAL_USER)
+ ret = db_prepare_rw(query, &stmt);
+ else
+ ret = db_prepare_globalrw(query, &stmt);
if (ret < 0) break;
ret = _bind_local_info(info, stmt);
}
/* Manipulating desktop_info functions */
-static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package)
+static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package, uid_t uid)
{
static int is_initdb = -1;
info->x_slp_enabled = 1;
- info->desktop = _pkgname_to_desktop(package);
+ info->desktop = _pkgname_to_desktop(package, uid);
retv_if(!info->desktop, AIL_ERROR_FAIL);
_D("desktop - [%s].", info->desktop);
}
-static ail_error_e _load_desktop_info(desktop_info_s* info)
+static ail_error_e _load_desktop_info(desktop_info_s* info, uid_t uid)
{
ail_error_e ret;
char query[AIL_SQL_QUERY_MAX_LEN];
snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
do {
- ret = db_open(DB_OPEN_RO);
+ ret = db_open(DB_OPEN_RO, uid);
if (ret < 0) break;
-
+//is_admin
ret = db_prepare(query, &stmt);
+ //ret = db_prepare_globalro(query, &stmt);
if (ret < 0) break;
ret = db_step(stmt);
}
-
-
-static ail_error_e _create_table(void)
-{
- int i;
- ail_error_e ret;
- const char *tbls[3] = {
- "CREATE TABLE app_info "
- "(package TEXT PRIMARY KEY, "
- "exec TEXT DEFAULT 'No Exec', "
- "name TEXT DEFAULT 'No Name', "
- "type TEXT DEFAULT 'Application', "
- "icon TEXT DEFAULT 'No Icon', "
- "categories TEXT, "
- "version TEXT, "
- "mimetype TEXT, "
- "x_slp_service TEXT, "
- "x_slp_packagetype TEXT, "
- "x_slp_packagecategories TEXT, "
- "x_slp_packageid TEXT, "
- "x_slp_uri TEXT, "
- "x_slp_svc TEXT, "
- "x_slp_exe_path TEXT, "
- "x_slp_appid TEXT, "
- "x_slp_pkgid TEXT, "
- "x_slp_domain TEXT, "
- "x_slp_submodemainid TEXT, "
- "x_slp_installedstorage TEXT, "
- "x_slp_baselayoutwidth INTEGER DEFAULT 0, "
- "x_slp_installedtime INTEGER DEFAULT 0, "
- "nodisplay INTEGER DEFAULT 0, "
- "x_slp_taskmanage INTEGER DEFAULT 1, "
- "x_slp_multiple INTEGER DEFAULT 0, "
- "x_slp_removable INTEGER DEFAULT 1, "
- "x_slp_ishorizontalscale INTEGER DEFAULT 0, "
- "x_slp_enabled INTEGER DEFAULT 1, "
- "x_slp_submode INTEGER DEFAULT 0, "
- "desktop TEXT UNIQUE NOT NULL);",
- "CREATE TABLE localname (package TEXT NOT NULL, "
- "locale TEXT NOT NULL, "
- "name TEXT NOT NULL, "
- "x_slp_pkgid TEXT NOT NULL, PRIMARY KEY (package, locale));",
-
- NULL
- };
-
- ret = db_open(DB_OPEN_RW);
- retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
-
- for (i = 0; tbls[i] != NULL; i++) {
- ret = db_exec(tbls[i]);
- retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
- }
-
- return AIL_ERROR_OK;
-}
-
-
-static inline void _insert_localname(gpointer data, gpointer user_data)
+static inline void _insert_localname(gpointer data, gpointer user_data, uid_t uid)
{
char query[512];
sqlite3_snprintf(sizeof(query), query, "insert into localname (package, locale, name, x_slp_pkgid) "
"values ('%q', '%q', '%q', '%q');",
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);
+ if(uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0)
+ _E("Failed to insert local name of package[%s]",info->package);
+ } else {
+ if (db_exec_glo_rw(query) < 0)
+ _E("Failed to insert local name of package[%s]",info->package);
+ }
}
-static ail_error_e _insert_desktop_info(desktop_info_s *info)
+static ail_error_e _insert_desktop_info(desktop_info_s *info, uid_t uid)
{
char *query;
int len;
info->desktop
);
- ret = db_open(DB_OPEN_RW);
+ ret = db_open(DB_OPEN_RW, uid);
if(ret != AIL_ERROR_OK) {
_E("(tmp == NULL) return\n");
free(query);
return AIL_ERROR_DB_FAILED;
}
-
- ret = db_exec(query);
+ if (uid != GLOBAL_USER)
+ ret = db_exec_usr_rw(query);
+ else
+ ret = db_exec_glo_rw(query);
+
free(query);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
if (info->localname)
- _insert_local_info(info);
+ _insert_local_info(info, uid);
_D("Add (%s).", query);
-static ail_error_e _update_desktop_info(desktop_info_s *info)
+static ail_error_e _update_desktop_info(desktop_info_s *info, uid_t uid)
{
char *query;
int len;
retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RW) < 0) {
+ if (db_open(DB_OPEN_RW, uid) < 0) {
return AIL_ERROR_DB_FAILED;
}
info->desktop,
info->package);
- if (db_exec(query) < 0) {
- free (query);
- return AIL_ERROR_DB_FAILED;
+ if(uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0) {
+ free (query);
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ if (db_exec_glo_rw(query) < 0) {
+ free (query);
+ return AIL_ERROR_DB_FAILED;
+ }
}
-
snprintf(query, len, "delete from localname where package = '%s'", info->package);
-
- if (db_exec(query) < 0) {
- free (query);
- return AIL_ERROR_DB_FAILED;
+ if (uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0) {
+ free (query);
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ if (db_exec_glo_rw(query) < 0) {
+ free (query);
+ return AIL_ERROR_DB_FAILED;
+ }
}
-
if (info->localname)
- _insert_local_info(info);
+ _insert_local_info(info, uid);
_D("Update (%s).", info->package);
-static ail_error_e _remove_package(const char* package)
+static ail_error_e _remove_package(const char* package, uid_t uid)
{
char *query;
int size;
retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RW) < 0) {
+ if (db_open(DB_OPEN_RW, uid) < 0) {
return AIL_ERROR_DB_FAILED;
}
snprintf(query, size, "delete from app_info where package = '%s'", package);
- if (db_exec(query) < 0) {
- free(query);
- return AIL_ERROR_DB_FAILED;
+ if(uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ if (db_exec_glo_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
}
-
snprintf(query, size, "delete from localname where package = '%s'", package);
_D("query=%s",query);
-
- if (db_exec(query) < 0) {
- free(query);
- return AIL_ERROR_DB_FAILED;
+
+ if(uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ if (db_exec_glo_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
}
-
_D("Remove (%s).", package);
free(query);
return AIL_ERROR_OK;
}
-static ail_error_e _clean_pkgid_data(const char* pkgid)
+static ail_error_e _clean_pkgid_data(const char* pkgid, uid_t uid)
{
char *query;
int size;
retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RW) < 0) {
+ if (db_open(DB_OPEN_RW, uid) ){
return AIL_ERROR_DB_FAILED;
}
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;
+ if(uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ if (db_exec_glo_rw(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;
+ if(uid != GLOBAL_USER) {
+ if (db_exec_usr_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ if (db_exec_glo_rw(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
}
-
_D("Clean pkgid data (%s).", pkgid);
free(query);
/* Public functions */
-EXPORT_API ail_error_e ail_desktop_add(const char *appid)
+EXPORT_API ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
{
desktop_info_s info = {0,};
ail_error_e ret;
- int count;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- count = _count_all();
- if (count <= 0) {
- ret = _create_table();
- if (ret != AIL_ERROR_OK) {
- _D("Cannot create a table. Maybe there is already a table.");
- }
- }
- ret = _init_desktop_info(&info, appid);
+ ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _read_desktop_info(&info);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _insert_desktop_info(&info);
+ ret = _insert_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _send_db_done_noti(NOTI_ADD, appid);
return AIL_ERROR_OK;
}
+EXPORT_API ail_error_e ail_desktop_add(const char *appid)
+{
+ return ail_usr_desktop_add(appid,GLOBAL_USER);
+}
-
-EXPORT_API ail_error_e ail_desktop_update(const char *appid)
+EXPORT_API ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid)
{
desktop_info_s info = {0,};
ail_error_e ret;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- ret = _init_desktop_info(&info, appid);
+ ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _read_desktop_info(&info);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _update_desktop_info(&info);
+ ret = _update_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _send_db_done_noti(NOTI_UPDATE, appid);
return AIL_ERROR_OK;
}
+EXPORT_API ail_error_e ail_desktop_update(const char *appid)
+{
+ return ail_usr_desktop_update(appid,GLOBAL_USER);
+}
-EXPORT_API ail_error_e ail_desktop_remove(const char *appid)
+EXPORT_API ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
{
ail_error_e ret;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- ret = _remove_package(appid);
+ ret = _remove_package(appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _send_db_done_noti(NOTI_REMOVE, appid);
return AIL_ERROR_OK;
}
-EXPORT_API ail_error_e ail_desktop_clean(const char *pkgid)
+EXPORT_API ail_error_e ail_desktop_remove(const char *appid)
+{
+ return ail_usr_desktop_remove(appid, GLOBAL_USER);
+}
+
+
+EXPORT_API ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid)
{
ail_error_e ret;
_D("ail_desktop_clean=%s",pkgid);
- ret = _clean_pkgid_data(pkgid);
+ ret = _clean_pkgid_data(pkgid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
return AIL_ERROR_OK;
}
+EXPORT_API ail_error_e ail_desktop_clean(const char *pkgid)
+{
+ return ail_usr_desktop_clean(pkgid, GLOBAL_USER);
+}
-EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
+EXPORT_API ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
{
desktop_info_s info = {0,};
ail_error_e ret;
- int count;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- count = _count_all();
- if (count <= 0) {
- ret = _create_table();
- if (ret != AIL_ERROR_OK) {
- _D("Cannot create a table. Maybe there is already a table.");
- }
- }
-
- ret = _init_desktop_info(&info, appid);
+ ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _read_desktop_info(&info);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _insert_desktop_info(&info);
+ ret = _insert_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
_fini_desktop_info(&info);
return AIL_ERROR_OK;
}
-EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
+EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
+{
+ return ail_usr_desktop_fota(appid, GLOBAL_USER);
+}
+
+
+EXPORT_API ail_error_e ail_desktop_appinfo_modify_usr_bool(const char *appid,
const char *property,
bool value,
- bool broadcast)
+ bool broadcast, uid_t uid)
{
desktop_info_s info = {0,};
ail_error_e ret;
retv_if(strcmp(property, AIL_PROP_X_SLP_ENABLED_BOOL),
AIL_ERROR_INVALID_PARAMETER);
- ret = _init_desktop_info(&info, appid);
+ ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _load_desktop_info(&info);
+ ret = _load_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _modify_desktop_info_bool(&info, property, value);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _update_desktop_info(&info);
+ ret = _update_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
if (broadcast) {
return AIL_ERROR_OK;
}
+EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
+ const char *property,
+ bool value,
+ bool broadcast)
+{
+ return ail_desktop_appinfo_modify_usr_bool(appid, property, value, broadcast,
+ GLOBAL_USER);
+}
+
-EXPORT_API ail_error_e ail_desktop_appinfo_modify_str(const char *appid,
+EXPORT_API ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid,
const char *property,
const char *value,
bool broadcast)
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- ret = _init_desktop_info(&info, appid);
+ ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _load_desktop_info(&info);
+ ret = _load_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
_D("info.name [%s], value [%s]", info.name, value);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
_D("info.name [%s], value [%s]", info.name, value);
- ret = _update_desktop_info(&info);
+ ret = _update_desktop_info(&info, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
if (broadcast) {
return AIL_ERROR_OK;
}
+EXPORT_API ail_error_e ail_desktop_appinfo_modify_str(const char *appid,
+ const char *property,
+ const char *value,
+ bool broadcast)
+{
+ return ail_desktop_appinfo_modify_usr_str(appid, GLOBAL_USER, property, value,
+ broadcast);
+}
+
// End of File
retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
+ if (db_open(DB_OPEN_RO, GLOBAL_USER) != AIL_ERROR_OK)
return AIL_ERROR_DB_FAILED;
snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
}
else
_D("No filter exists. All records are retreived");
-
+//is_admin
if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
_E("db_prepare fail for query = %s",q);
return AIL_ERROR_DB_FAILED;
}
+/* if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+ _E("db_prepare fail for query = %s",q);
+ return AIL_ERROR_DB_FAILED;
+ }*/
+ ai = appinfo_create();
+
+ appinfo_set_stmt(ai, stmt);
+ while (db_step(stmt) == AIL_ERROR_OK) {
+
+ if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+ continue;
+
+ filter_count++;
+ }
+
+ db_finalize(stmt);
+
+ appinfo_destroy(ai);
+ *cnt = filter_count;
+
+ return AIL_ERROR_OK;
+}
+
+EXPORT_API ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *cnt, uid_t uid)
+{
+ char q[AIL_SQL_QUERY_MAX_LEN];
+ char *w;
+ char *tmp_q;
+ char *l;
+ ail_cb_ret_e r;
+ sqlite3_stmt *stmt;
+ ail_appinfo_h ai;
+ int filter_count = 0;
+
+ retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
+ if (db_open(DB_OPEN_RO, uid) != AIL_ERROR_OK)
+ return AIL_ERROR_DB_FAILED;
+
+ snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
+
+ tmp_q = strdup(q);
+ retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ l = sql_get_locale();
+ if (NULL == l) {
+ _E("Failed to get locale string");
+ free(tmp_q);
+ return AIL_ERROR_FAIL;
+ }
+ snprintf(q, sizeof(q), tmp_q, l);
+ free(l);
+ free(tmp_q);
+
+ if (filter && filter->list) {
+ w = _get_where_clause(filter);
+ retv_if (NULL == w, AIL_ERROR_FAIL);
+ strncat(q, w, sizeof(q)-strlen(q)-1);
+ q[sizeof(q)-1] = '\0';
+ free(w);
+ }
+ else
+ _D("No filter exists. All records are retreived");
+
+ if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+ _E("db_prepare fail for query = %s",q);
+ return AIL_ERROR_DB_FAILED;
+ }
ai = appinfo_create();
appinfo_set_stmt(ai, stmt);
return AIL_ERROR_OK;
}
+
EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb cb, void *user_data)
{
char q[AIL_SQL_QUERY_MAX_LEN];
retv_if (NULL == cb, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
+ if (db_open(DB_OPEN_RO, GLOBAL_USER) != AIL_ERROR_OK)
return AIL_ERROR_DB_FAILED;
snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
_D("No filter exists. All records are retreived");
// _D("Query = %s",q);
-
- if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+//is_admin
+ if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
_E("db_prepare fail for query = %s",q);
return AIL_ERROR_DB_FAILED;
}
-
+ /*if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
+ _E("db_prepare fail for query = %s",q);
+ return AIL_ERROR_DB_FAILED;
+ }*/
ai = appinfo_create();
appinfo_set_stmt(ai, stmt);
- while (db_step(stmt) == AIL_ERROR_OK) {
-
+ uint i = 0;
+ while (i = db_step(stmt) == AIL_ERROR_OK) {
+ _E("------------------------dbstep : %u\n", i);
if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
continue;
appinfo_destroy(ai);
db_finalize(stmt);
-
return AIL_ERROR_OK;
}
+EXPORT_API ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb cb, void *user_data, uid_t uid)
+{
+ char q[AIL_SQL_QUERY_MAX_LEN];
+ char *tmp_q;
+ char *w;
+ char *l;
+ ail_cb_ret_e r;
+ sqlite3_stmt *stmt;
+ ail_appinfo_h ai;
+
+ retv_if (NULL == cb, AIL_ERROR_INVALID_PARAMETER);
+
+ if (db_open(DB_OPEN_RO, uid) != AIL_ERROR_OK)
+ return AIL_ERROR_DB_FAILED;
+
+ snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
+
+ tmp_q = strdup(q);
+ retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ l = sql_get_locale();
+ if (NULL == l) {
+ _E("Failed to get locale string");
+ free(tmp_q);
+ return AIL_ERROR_FAIL;
+ }
+ snprintf(q, sizeof(q), tmp_q, l);
+ free(l);
+ free(tmp_q);
+
+ if (filter && filter->list) {
+ w = _get_where_clause(filter);
+ retv_if (NULL == w, AIL_ERROR_FAIL);
+ strncat(q, w, sizeof(q)-strlen(q)-1);
+ q[sizeof(q)-1] = '\0';
+ strncat(q, " order by app_info.package", sizeof(q)-strlen(q)-1);
+ q[sizeof(q)-1] = '\0';
+ free(w);
+ }
+ else
+ _D("No filter exists. All records are retreived");
+
+//is_admin
+ if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+ _E("db_prepare fail for query = %s",q);
+ return AIL_ERROR_DB_FAILED;
+ }
+ ai = appinfo_create();
+ appinfo_set_stmt(ai, stmt);
+ uint i = 0;
+ while (i = db_step(stmt) == AIL_ERROR_OK) {
+ if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+ continue;
+
+ r = cb(ai, user_data);
+ if (AIL_CB_RET_CANCEL == r)
+ break;
+ }
+ appinfo_destroy(ai);
+
+ db_finalize(stmt);
+ return AIL_ERROR_OK;
+}
#include <string.h>
#include <stdlib.h>
#include <db-util.h>
+#include <tzplatform_config.h>
#include <vconf.h>
#include "ail.h"
#include "ail_private.h"
#define LANGUAGE_LENGTH 2
#define DEFAULT_LOCALE "No Locale"
#define MAX_QUERY_LEN 4096
-#define PKG_SD_PATH "/opt/storage/sdcard/app2sd/"
+#define PKG_SD_PATH tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard/app2sd/")
#define QUERY_GET_LOCALNAME "select name from localname where package='%s' and locale='%s'"
struct ail_appinfo {
return ail_get_appinfo(package, ai);
}
+EXPORT_API ail_error_e ail_package_get_usr_appinfo(const char *package, uid_t uid, ail_appinfo_h *ai)
+{
+ return ail_get_usr_appinfo(package, uid, ai);
+}
+
+
+
EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
{
ail_error_e ret;
snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
do {
- ret = db_open(DB_OPEN_RO);
+ ret = db_open(DB_OPEN_RO, GLOBAL_USER);
if (ret < 0) break;
-
+//is_admin
ret = db_prepare(query, &stmt);
if (ret < 0) break;
+// ret = db_prepare(query, &stmt);
+// if (ret < 0) break;
+
ret = db_step(stmt);
if (ret < 0) {
return ret;
}
+EXPORT_API ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *ai)
+{
+ ail_error_e ret;
+ char query[AIL_SQL_QUERY_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
+ char w[AIL_SQL_QUERY_MAX_LEN];
+
+ retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+
+ *ai = appinfo_create();
+ retv_if(!*ai, AIL_ERROR_OUT_OF_MEMORY);
+
+ snprintf(w, sizeof(w), sql_get_filter(E_AIL_PROP_X_SLP_APPID_STR), appid);
+
+ snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
+
+ do {
+ ret = db_open(DB_OPEN_RO, uid);
+ if (ret < 0) break;
+//is_admin
+ ret = db_prepare(query, &stmt);
+ if (ret < 0) break;
+// ret = db_prepare(query, &stmt);
+// if (ret < 0) break;
+
+ ret = db_step(stmt);
+ if (ret < 0) {
+ db_finalize(stmt);
+ break;
+ }
+
+ (*ai)->stmt = stmt;
+
+ ret = _appinfo_check_installed_storage(*ai);
+ if (ret < 0) {
+ db_finalize((*ai)->stmt);
+ break;
+ }
+
+ ret = __retrieve_all_column(*ai);
+ if (ret < 0) {
+ db_finalize((*ai)->stmt);
+ break;
+ }
+
+ ret = db_finalize((*ai)->stmt);
+ if (ret < 0) break;
+ (*ai)->stmt = NULL;
+
+ return AIL_ERROR_OK;
+ } while(0);
+
+ appinfo_destroy(*ai);
+
+ return ret;
+}
EXPORT_API ail_error_e ail_appinfo_get_bool(const ail_appinfo_h ai, const char *property, bool *value)
{
ail_prop_bool_e prop;
return AIL_ERROR_OK;
}
-
-
EXPORT_API ail_error_e ail_appinfo_get_int(const ail_appinfo_h ai, const char *property, int *value)
{
ail_prop_int_e prop;
return AIL_ERROR_OK;
}
-char *appinfo_get_localname(const char *package, char *locale)
+char *appinfo_get_localname(const char *package, char *locale, uid_t uid)
{
- db_open(DB_OPEN_RO);
+ db_open(DB_OPEN_RO, uid);
sqlite3_stmt *stmt;
char *str = NULL;
char *localname;
snprintf(query, sizeof(query), QUERY_GET_LOCALNAME, package, locale);
// _D("Query = %s",query);
+//is_admin
retv_if (db_prepare(query, &stmt) < 0, NULL);
+ //retv_if (db_prepare(query, &stmt) < 0, NULL);
do {
if (db_step(stmt) < 0)
return NULL;
}
-
EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *property, char **str)
{
int index;
}
locale_new = __get_app_locale_by_fallback(pkg, locale);
- localname = (char *)appinfo_get_localname(pkg,locale_new);
+ localname = (char *)appinfo_get_localname(pkg, locale_new, GLOBAL_USER);
+ free(locale);
+ free(locale_new);
+ } else {
+ if (db_column_str(ai->stmt, SQL_LOCALNAME_IDX, &localname) < 0)
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ pkg_type = ai->values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR];
+ pkg = ai->values[E_AIL_PROP_PACKAGE_STR];
+ retv_if (NULL == pkg, AIL_ERROR_FAIL);
+
+ locale = sql_get_locale();
+ retv_if (NULL == locale, AIL_ERROR_FAIL);
+
+ if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
+ {
+ locale_new = __get_app_locale_by_fallback(pkg, locale);
+ localname = (char *)appinfo_get_localname(pkg, locale_new, GLOBAL_USER);
+ free(locale);
+ free(locale_new);
+ } else {
+ localname = (char *)appinfo_get_localname(pkg, locale, GLOBAL_USER);
+ free(locale);
+ }
+ }
+
+ if (localname) {
+ if (!ai->stmt) {
+ if (ai->values) {
+ if (ai->values[prop])
+ free(ai->values[prop]);
+ ai->values[prop] = localname;
+ }
+ }
+ *str = localname;
+ return AIL_ERROR_OK;
+ }
+ }
+
+ if (ai->stmt) {
+ index = sql_get_app_info_idx(prop);
+ if (db_column_str(ai->stmt, index, &value) < 0){
+ return AIL_ERROR_DB_FAILED;
+ }
+ *str = value;
+ } else
+ *str = ai->values[prop];
+
+ return AIL_ERROR_OK;
+}
+EXPORT_API ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h ai, const char *property, uid_t uid, char **str)
+{
+ int index;
+ char *value;
+ char *pkg;
+ char *pkg_type;
+ char *locale, *localname;
+ ail_prop_str_e prop;
+ char *locale_new;
+
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!str, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_str(property);
+
+ if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ localname = NULL;
+
+ if (E_AIL_PROP_NAME_STR == prop) {
+ if (ai->stmt) {
+ if (db_column_str(ai->stmt, E_AIL_PROP_X_SLP_PACKAGETYPE_STR, &pkg_type) < 0)
+ return AIL_ERROR_DB_FAILED;
+ if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
+ {
+ locale = sql_get_locale();
+ retv_if (NULL == locale, AIL_ERROR_FAIL);
+
+ if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+ free(locale);
+ return AIL_ERROR_DB_FAILED;
+ }
+ if (pkg == NULL){
+ free(locale);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ locale_new = __get_app_locale_by_fallback(pkg, locale);
+ localname = (char *)appinfo_get_localname(pkg, locale_new, uid);
free(locale);
free(locale_new);
} else {
if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
{
locale_new = __get_app_locale_by_fallback(pkg, locale);
- localname = (char *)appinfo_get_localname(pkg,locale_new);
+ localname = (char *)appinfo_get_localname(pkg, locale_new, uid);
free(locale);
free(locale_new);
} else {
- localname = (char *)appinfo_get_localname(pkg,locale);
+ localname = (char *)appinfo_get_localname(pkg, locale, uid);
free(locale);
}
}
return AIL_ERROR_OK;
}
+
EXPORT_API ail_error_e ail_close_appinfo_db(void)
{
return db_close();
#define SQL_TBL_APP_INFO "app_info"
#define SQL_TBL_APP_INFO_WITH_LOCALNAME "app_info LEFT OUTER JOIN localname " \
"ON app_info.package=localname.package " \
- "and locale='%s'"
+ "and localname.locale='%s'"
#define SQL_FLD_APP_INFO "app_info.PACKAGE," \
"app_info.EXEC," \
return r;
}
-ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
+ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
{
char *rs = NULL;
int t=-1;
#endif
#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
-static int initdb_count_app(void)
+static int initdb_count_app(uid_t uid)
{
ail_filter_h filter;
ail_error_e ret;
ail_filter_destroy(filter);
return -1;
}
-
- ret = ail_filter_count_appinfo(filter, &total);
+//__isadmin
+ ret = ail_filter_count_usr_appinfo(filter, &total, uid);
+ //ret = ail_filter_count_appinfo(filter, &total);
if (ret != AIL_ERROR_OK) {
ail_filter_destroy(filter);
return -1;
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
- ret = initdb_count_app();
+ ret = initdb_count_app(getuid());
if (ret > 0) {
_D("Some Apps in the App Info DB.");
}
-static ail_error_e _get_appinfo(const char *package, const char *property)
+static ail_error_e _get_appinfo(const char *package, const char *property, uid_t uid)
{
ail_appinfo_h handle;
ail_error_e ret;
struct element e;
struct element *p;
int t;
-
+ //__isadmin)
ret = ail_package_get_appinfo(package, &handle);
if (ret != AIL_ERROR_OK) {
return AIL_ERROR_FAIL;
if (4 == argc) {
if (!strncmp(argv[1], "get", 3)) {
- ret = _get_appinfo(argv[2], argv[3]);
+ ret = _get_appinfo(argv[2], argv[3], getuid());
}
}
else {
ail_filter_destroy(filter);
return -1;
}
-
ret = ail_filter_count_appinfo(filter, &total);
if (ret != AIL_ERROR_OK) {
ail_filter_destroy(filter);