In Tizen 3.0 application packages can be installed per user.
It means that application working directory must be discovered on runtime
instead of using fixed paths. Patch introduces new functions for getting
absoulte path to resource directories using Tizen app framework api.
Change-Id: I53661a413791eeacb24f57584dc2ca54a8f10ab2
Signed-off-by: Lukasz Stanislawski <l.stanislaws@samsung.com>
/*=================================DATABASE===================================*/
#define DATABASE_FILE \
- "/usr/apps/org.tizen.homescreen-efl/data/homescreen-efl.db"
+ "homescreen-efl.db"
/*=================================RESOURCES==================================*/
-#define DEFAULT_BG \
- "/usr/apps/com.samsung.home-lite/res/images/default_bg.png"
-#define EDJE_DIR "/usr/apps/org.tizen.homescreen-efl/res/edje"
-#define IMAGE_DIR "/usr/apps/org.tizen.homescreen-efl/res/images"
+#define EDJE_DIR "edje"
+#define IMAGE_DIR "images"
/*******************************************************************************
*
/*================================ APP_ICON.C=================================*/
#define DEFAULT_APP_ICON \
- "/usr/apps/org.tizen.homescreen-efl/res/images/default.png"
+ IMAGE_DIR "/default.png"
#define BADGE_REL_X 0.85
#define BADGE_REL_Y 0.00
*/
Elm_Object_Item *elm_gengrid_get_item_at_index(Evas_Object *gengrid, int idx);
+/*
+ * @brief Application sub-directories type.
+ */
+enum app_subdir {
+ APP_DIR_DATA,
+ APP_DIR_CACHE,
+ APP_DIR_RESOURCE,
+ APP_DIR_SHARED_DATA,
+ APP_DIR_SHARED_RESOURCE,
+ APP_DIR_SHARED_TRUSTED,
+ APP_DIR_EXTERNAL_DATA,
+ APP_DIR_EXTERNAL_CACHE,
+ APP_DIR_EXTERNAL_SHARED_DATA,
+};
+
+/**
+ * @brief Returns absolute path to resource file located in applications directory.
+ *
+ * @param subdir type of subdirectory
+ * @param relative path of resource from starting from "data" dir.
+ * eg. for DATA_DIR subdir and relative "database.db" => "/home/owner/apps/org.tizen.homescreen-efl/data/database.db"
+ * @return absolute path string.
+ */
+const char *util_get_file_path(enum app_subdir dir, const char *relative);
+
+/**
+ * @brief Convinience macros
+ */
+#define util_get_data_file_path(x) util_get_file_path(APP_DIR_DATA, (x))
+#define util_get_cache_file_path(x) util_get_file_path(APP_DIR_CACHE, (x))
+#define util_get_res_file_path(x) util_get_file_path(APP_DIR_RESOURCE, (x))
+#define util_get_shared_data_file_path(x) util_get_file_path(APP_DIR_SHARED_DATA, (x))
+#define util_get_shared_res_file_path(x) util_get_file_path(APP_DIR_SHARED_RESOURCE, (x))
+#define util_get_trusted_file_path(x) util_get_file_path(APP_DIR_SHARED_TRUSTED, (x))
+#define util_get_external_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_DATA, (x))
+#define util_get_external_cache_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_CACHE, (x))
+#define util_get_external_shared_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_SHARED_DATA, (x))
+
#endif /* __HOME_SCREEN_UTIL_H__ */
return NULL;
}
- if (!elm_layout_file_set(ly, EDJE_DIR"/app_grid.edj", GROUP_APP_GRID)) {
- LOGE("[FAILED][elm_layout_file_set][%s]", EDJE_DIR"/app_grid.edj");
+ if (!elm_layout_file_set(ly, util_get_res_file_path(EDJE_DIR"/app_grid.edj)"), GROUP_APP_GRID)) {
+ LOGE("[FAILED][elm_layout_file_set][%s]", util_get_res_file_path(EDJE_DIR"/app_grid.edj"));
evas_object_del(ly);
return NULL;
}
container = elm_layout_add(parent);
- if (!elm_layout_file_set(container, EDJE_DIR"/app_grid.edj", GROUP_APP_GRID_ITEM_CONTAINER)) {
- LOGE("[FAILED][elm_layout_file_set][%s]", EDJE_DIR"/app_grid.edj");
+ if (!elm_layout_file_set(container, util_get_res_file_path(EDJE_DIR"/app_grid.edj"), GROUP_APP_GRID_ITEM_CONTAINER)) {
+ LOGE("[FAILED][elm_layout_file_set][%s]", util_get_res_file_path(EDJE_DIR"/app_grid.edj"));
evas_object_del(container);
return NULL;
}
}
if (type == APP_ICON_TYPE_APP || type == APP_ICON_TYPE_FOLDER) {
- icon_layout = util_create_edje_layout(parent, EDJE_DIR"/icon.edj", GROUP_ICON_LY);
+ icon_layout = util_create_edje_layout(parent, util_get_res_file_path(EDJE_DIR"/icon.edj"), GROUP_ICON_LY);
if (!icon_layout) {
LOGE("Failed to create icon layout");
return NULL;
return NULL;
}
- if (!elm_layout_file_set(folder_icon_layout, EDJE_DIR"/folder.edj", GROUP_FOLDER_ICON_LAYOUT)) {
+ if (!elm_layout_file_set(folder_icon_layout, util_get_res_file_path(EDJE_DIR"/folder.edj"), GROUP_FOLDER_ICON_LAYOUT)) {
LOGE("Failed to load edje file for layout");
evas_object_del(folder_icon_layout);
evas_object_del(icon_layout);
return NULL;
}
- if ((strncmp("", icon_path, strlen(icon_path)) && elm_image_file_set(icon_image, icon_path, NULL)) || elm_image_file_set(icon_image, DEFAULT_APP_ICON, NULL))
+ if ((strncmp("", icon_path, strlen(icon_path)) && elm_image_file_set(icon_image, icon_path, NULL)) || elm_image_file_set(icon_image, util_get_res_file_path(DEFAULT_APP_ICON), NULL))
return icon_image;
evas_object_del(icon_image);
if (db_info.db)
return true;
- if (!_db_is_success(sqlite3_open(DATABASE_FILE, &db_info.db)))
+ if (!_db_is_success(sqlite3_open(util_get_data_file_path(DATABASE_FILE), &db_info.db)))
return false;
if (sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL,
return NULL;
}
- if (!elm_layout_file_set(layout, INDEX_EDJE, GROUP_INDEX_ELEMENT)) {
+ if (!elm_layout_file_set(layout, util_get_res_file_path(INDEX_EDJE), GROUP_INDEX_ELEMENT)) {
evas_object_del(layout);
return NULL;
}
}
elm_theme_ref_set(s_info.folder_entry_theme, NULL);
- elm_theme_extension_add(s_info.folder_entry_theme, EDJE_DIR"/folder_entry.edj");
+ elm_theme_extension_add(s_info.folder_entry_theme, util_get_res_file_path(EDJE_DIR"/folder_entry.edj"));
}
}
return false;
}
- if (!elm_layout_file_set(s_info.opened_folder_window, EDJE_DIR"/folder.edj", GROUP_FOLDER_WINDOW)) {
+ if (!elm_layout_file_set(s_info.opened_folder_window, util_get_res_file_path(EDJE_DIR"/folder.edj"), GROUP_FOLDER_WINDOW)) {
LOGE("Failed to load edje file for layout");
evas_object_del(s_info.opened_folder_window);
s_info.opened_folder_window = NULL;
Evas_Object *add_icon = NULL;
LOGI("");
- icon_layout = util_create_edje_layout(home_screen_get_win(), EDJE_DIR"/icon.edj", GROUP_ICON_LY);
+ icon_layout = util_create_edje_layout(home_screen_get_win(), util_get_res_file_path(EDJE_DIR"/icon.edj"), GROUP_ICON_LY);
if (!icon_layout) {
LOGE("Failed to create icon layout");
return NULL;
return NULL;
}
- if (!elm_layout_file_set(add_icon, EDJE_DIR"/folder.edj", GROUP_FOLDER_ADD_ICON)) {
+ if (!elm_layout_file_set(add_icon, util_get_res_file_path(EDJE_DIR"/folder.edj"), GROUP_FOLDER_ADD_ICON)) {
LOGE("Failed to load edje file for layout");
evas_object_del(add_icon);
evas_object_del(icon_layout);
return NULL;
}
- if (!elm_layout_file_set(folder_popup, EDJE_DIR"/folder.edj", GROUP_FOLDER_POPUP)) {
+ if (!elm_layout_file_set(folder_popup, util_get_res_file_path(EDJE_DIR"/folder.edj"), GROUP_FOLDER_POPUP)) {
LOGE("Failed to set folder popup");
evas_object_del(folder_popup);
return NULL;
static void __homescreen_efl_create_base_gui(void)
{
char edj_path[PATH_MAX] = {0, };
- const char *bg_path = IMAGE_DIR"/default_bg.png";
+ const char *bg_path = util_get_res_file_path(IMAGE_DIR"/default_bg.png");
char trbuf[PATH_MAX] = {0, };
char *buf = NULL;
int ret = -1;
// s_info.conformant = _create_conformant();
// /* Base Layout */
- snprintf(edj_path, sizeof(edj_path), EDJE_DIR"/home.edj");
+ snprintf(edj_path, sizeof(edj_path), "%s", util_get_res_file_path(EDJE_DIR"/home.edj"));
s_info.layout = elm_layout_add(s_info.win);
elm_layout_file_set(s_info.layout, edj_path, GROUP_HOME_LY);
evas_object_size_hint_weight_set(s_info.layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
{
Evas_Object *grid = NULL;
Evas_Object *rect = NULL;
+
Evas_Object *livebox_container = util_create_edje_layout(
- livebox_scroller, EDJE_LIVEBOX_CONTAINER_FILENAME,
+ livebox_scroller, util_get_res_file_path(EDJE_LIVEBOX_CONTAINER_FILENAME),
GROUP_LIVEBOX_CONTAINER);
if (!livebox_container) {
return NULL;
}
- all_pages_layout = util_create_edje_layout(win, EDJE_DIR"/page_edit.edj", GROUP_ALL_PAGES);
+ all_pages_layout = util_create_edje_layout(win, util_get_res_file_path(EDJE_DIR"/page_edit.edj"), GROUP_ALL_PAGES);
if (!all_pages_layout) {
LOGE("[FAILED][util_edje_layout_create]");
return NULL;
w = THUMB_W_REL * w;
h = THUMB_H_REL * h;
- ly_grid_item = util_create_edje_layout(win, EDJE_DIR"/page_edit.edj", GROUP_GRID_ITEM);
+ ly_grid_item = util_create_edje_layout(win, util_get_res_file_path(EDJE_DIR"/page_edit.edj"), GROUP_GRID_ITEM);
if (!ly_grid_item) {
LOGE("[FAILED][util_edje_layout_create]");
return NULL;
}
- ly_thumb = util_create_edje_layout(win, EDJE_DIR"/page_edit.edj", GROUP_THUMB);
+ ly_thumb = util_create_edje_layout(win, util_get_res_file_path(EDJE_DIR"/page_edit.edj"), GROUP_THUMB);
if (!ly_thumb) {
LOGE("[FAILED][util_edje_layout_create]");
evas_object_del(ly_grid_item);
}
evas_object_color_set(add_icon, 0, 0, 0, 0);
- ly_grid_item = util_create_edje_layout(win, EDJE_DIR"/page_edit.edj", GROUP_GRID_ITEM);
+ ly_grid_item = util_create_edje_layout(win, util_get_res_file_path(EDJE_DIR"/page_edit.edj"), GROUP_GRID_ITEM);
if (!ly_grid_item) {
LOGE("[FAILED][util_edje_layout_create]");
evas_object_del(add_icon);
return NULL;
}
- ly_thumb = util_create_edje_layout(win, EDJE_DIR"/page_edit.edj", GROUP_THUMB);
+ ly_thumb = util_create_edje_layout(win, util_get_res_file_path(EDJE_DIR"/page_edit.edj"), GROUP_THUMB);
if (!ly_thumb) {
LOGE("[FAILED][util_edje_layout_create]");
evas_object_del(add_icon);
return found;
}
+
+const char *util_get_file_path(enum app_subdir dir, const char *relative)
+{
+ static char buf[PATH_MAX];
+ char *prefix;
+
+ switch (dir) {
+ case APP_DIR_DATA:
+ prefix = app_get_data_path();
+ break;
+ case APP_DIR_CACHE:
+ prefix = app_get_cache_path();
+ break;
+ case APP_DIR_RESOURCE:
+ prefix = app_get_resource_path();
+ break;
+ case APP_DIR_SHARED_DATA:
+ prefix = app_get_shared_data_path();
+ break;
+ case APP_DIR_SHARED_RESOURCE:
+ prefix = app_get_shared_resource_path();
+ break;
+ case APP_DIR_SHARED_TRUSTED:
+ prefix = app_get_shared_trusted_path();
+ break;
+ case APP_DIR_EXTERNAL_DATA:
+ prefix = app_get_external_data_path();
+ break;
+ case APP_DIR_EXTERNAL_CACHE:
+ prefix = app_get_external_cache_path();
+ break;
+ case APP_DIR_EXTERNAL_SHARED_DATA:
+ prefix = app_get_external_shared_data_path();
+ break;
+ default:
+ LOGE("Not handled directory type.");
+ return NULL;
+ }
+ size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative);
+ free(prefix);
+ if (res > sizeof(buf)) {
+ LOGE("Path exceeded PATH_MAX");
+ return NULL;
+ }
+
+ return &buf[0];
+}