#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <tzplatform_config.h>
#include <xdgmime.h>
-#include <vconf.h>
#include <glib.h>
#include <grp.h>
#include <pwd.h>
#include "ail_db.h"
#include "ail_sql.h"
#include "ail.h"
+#include "ail_vconf.h"
#define BUFSIZE 4096
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#define argsdelimiter " \t"
struct entry_parser {
const char *field;
- ail_error_e (*value_cb)(void *data, char *tag, char *value);
+ ail_error_e (*value_cb)(void *data, char *tag, char *value, uid_t uid);
};
inline static char *_ltrim(char *str)
-static ail_error_e _read_exec(void *data, char *tag, char *value)
+static ail_error_e _read_exec(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
char *token_exe_path;
-static ail_error_e _read_name(void *data, char *tag, char *value)
+static ail_error_e _read_name(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_type(void *data, char *tag, char *value)
+static ail_error_e _read_type(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
char* theme = NULL;
char* icon_with_path = NULL;
int len;
+ char *app_path = NULL;
package = _get_package_from_icon(icon);
retv_if(!package, NULL);
/* "db/setting/theme" is not exist */
#if 0
- theme = vconf_get_str("db/setting/theme");
+ theme = ail_vconf_get_str("db/setting/theme");
if (!theme) {
theme = strdup("default");
if(!theme) {
len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
icon_with_path = malloc(len);
if(icon_with_path == NULL) {
- _E("(icon_with_path == NULL) return\n");
+ _E("icon_with_path == NULL\n");
free(package);
free(theme);
return NULL;
}
memset(icon_with_path, 0, len);
-
- 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,"%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, "%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, "%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, "%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, "%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, "%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, "%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);
-
+ if (uid != GLOBAL_USER)
+ sqlite3_snprintf( len, icon_with_path, "%s%q", ail_get_icon_path(uid), icon);
+ else
+ sqlite3_snprintf( len, icon_with_path, "%s/%q/small/%q", ail_get_icon_path(GLOBAL_USER), theme, icon);
+
+ if (access (icon_with_path, F_OK)) {
+ app_path = tzplatform_getenv(TZ_SYS_RW_APP);
+ if (app_path)
+ sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q",app_path, package, theme, icon);
+ if (access (icon_with_path, F_OK))
+ _E("Cannot find icon path");
+ }
free(theme);
free(package);
-
- _D("Icon path : %s ---> %s", icon, icon_with_path);
-
+ _D("Icon path : %s", icon_with_path);
return icon_with_path;
} else {
char* confirmed_icon = NULL;
-static ail_error_e _read_categories(void *data, char *tag, char *value)
+static ail_error_e _read_categories(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_version(void *data, char *tag, char *value)
+static ail_error_e _read_version(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_mimetype(void *data, char *tag, char *value)
+static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
int size, total_len = 0;
-static ail_error_e _read_nodisplay(void *data, char *tag, char *value)
+static ail_error_e _read_nodisplay(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s* info = data;
-static ail_error_e _read_x_slp_service(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_service(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_packagetype(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_packagetype(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_packagecategories(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_packagecategories(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_packageid(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_packageid(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
return AIL_ERROR_OK;
}
-static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
return AIL_ERROR_OK;
}
-static ail_error_e _read_x_slp_installedstorage(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_installedstorage(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
return AIL_ERROR_OK;
}
-static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_svc(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_svc(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_taskmanage(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_taskmanage(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_multiple(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_multiple(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
-static ail_error_e _read_x_slp_removable(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_removable(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
}
-static ail_error_e _read_x_slp_submode(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_submode(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
return AIL_ERROR_OK;
}
-static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
}
-static ail_error_e _read_x_slp_pkgid(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_pkgid(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
}
-static ail_error_e _read_x_slp_domain(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_domain(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
}
-static ail_error_e _read_x_slp_enabled(void *data, char *tag, char *value)
+static ail_error_e _read_x_slp_enabled(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
retv_if(!package, NULL);
- 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);
- }
- }
- }
+ desktop_path = ail_get_desktop_path(uid);
size = strlen(desktop_path) + strlen(package) + 10;
desktop = malloc(size);
-static ail_error_e _read_desktop_info(desktop_info_s* info)
+static ail_error_e _read_desktop_info(desktop_info_s* info,uid_t uid)
{
char *line = NULL;
FILE *fp;
for (idx = 0; entry_parsers[idx].field; idx ++) {
if (!g_ascii_strcasecmp(entry_parsers[idx].field, field_name) && entry_parsers[idx].value_cb) {
- if (entry_parsers[idx].value_cb(info, tag, tmp) != AIL_ERROR_OK) {
+ if (entry_parsers[idx].value_cb(info, tag, tmp,uid) != AIL_ERROR_OK) {
_E("field - [%s] is wrong.", field_name);
}
break;
do {
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 (uid != GLOBAL_USER) {
+ ret = db_prepare(query, &stmt);
+ } else {
+ ret = db_prepare_globalro(query, &stmt);
+ }
+
if (ret < 0) break;
ret = db_step(stmt);
retv_if(!noti_string, AIL_ERROR_OUT_OF_MEMORY);
snprintf(noti_string, size + 1, "%s:%s:%u", type_string, package, getuid());
- vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
- vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
+ ail_vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
+ ail_vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
_D("Noti : %s", noti_string);
free(noti_string);
static int __is_authorized()
{
uid_t uid = getuid();
- if ((uid_t) 0 == uid )
+ if ((uid_t) GLOBAL_USER == uid )
return 1;
else
return 0;
ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _read_desktop_info(&info);
+ ret = _read_desktop_info(&info,uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _insert_desktop_info(&info, uid);
ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _read_desktop_info(&info);
+ ret = _read_desktop_info(&info,uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _update_desktop_info(&info, uid);
ret = _init_desktop_info(&info, appid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
- ret = _read_desktop_info(&info);
+ ret = _read_desktop_info(&info,uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ret = _insert_desktop_info(&info, uid);