From: jin0.kim Date: Thu, 18 Feb 2016 02:47:12 +0000 (+0830) Subject: Change the way to get appdata path X-Git-Tag: accepted/tizen/common/20160222.162158^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F59728%2F2;p=apps%2Fcore%2Fpreloaded%2Fquickpanel.git Change the way to get appdata path Change-Id: I400ae028b8d09e74a2ce2a8cf2c5c06cdb71c2aa --- diff --git a/daemon/notifications/noti_win.c b/daemon/notifications/noti_win.c index a2e6d9a..ba9456a 100755 --- a/daemon/notifications/noti_win.c +++ b/daemon/notifications/noti_win.c @@ -187,7 +187,7 @@ HAPI Evas_Object *quickpanel_noti_win_add(Evas_Object *parent) ecore_evas_name_class_set(ee, "APP_POPUP", "APP_POPUP"); - elm_win_alpha_set(win, EINA_TRUE); + elm_win_alpha_set(win, EINA_FALSE); elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE); elm_win_title_set(win, "noti_win"); elm_win_borderless_set(win, EINA_TRUE); diff --git a/daemon/preference.c b/daemon/preference.c index 9c0d72c..5eed343 100755 --- a/daemon/preference.c +++ b/daemon/preference.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "preference.h" #include "common.h" @@ -33,7 +34,22 @@ #include "quickpanel-ui.h" -#define FILE_PREFERENCE DATADIR_RW"/preference.ini" +#define PREFERENCE_FILE_NAME "preference.ini" + +static char *_get_preference_file_path() +{ + char *data_path = NULL; + char file_path[MAX_FILE_PATH_LEN] = {0, }; + + + data_path = app_get_data_path(); + retif(data_path == NULL, NULL, "failed to app_get_data_path()"); + + snprintf(file_path, sizeof(file_path), "%s%s", data_path, PREFERENCE_FILE_NAME); + free(data_path); + + return strdup(file_path); +} static const char *_default_preference_get(const char *key) { @@ -73,20 +89,28 @@ static inline int _key_validation_check(const char *key) static inline int _is_file_exist(void) { + char *file_path = _get_preference_file_path(); + retif(file_path == NULL, 0, "failed to _get_preference_file_path()"); - if (access(FILE_PREFERENCE, O_RDWR) == 0) { + if (access(file_path, O_RDWR) == 0) { return 1; } + if (file_path != NULL) { + free(file_path); + } + return 0; } static void _default_file_create(void) { FILE *fp = NULL ; + char *file_path = _get_preference_file_path(); + retif(file_path == NULL, , "failed to _get_preference_file_path()"); - fp = fopen(FILE_PREFERENCE, "w"); - retif(fp == NULL, , "fatal:failed to create preference file"); + fp = fopen(file_path, "w"); + retif(fp == NULL, , "fatal:failed to create preference file %s", file_path); fprintf(fp, "\n\ [%s]\n\ @@ -105,6 +129,10 @@ static void _default_file_create(void) ); fclose(fp); + + if (file_path != NULL) { + free(file_path); + } } HAPI int quickpanel_preference_get(const char *key, char *value) @@ -112,10 +140,14 @@ HAPI int quickpanel_preference_get(const char *key, char *value) int ret = QP_OK; dictionary *ini = NULL; const char *value_r = NULL; + char *file_path = NULL; retif(key == NULL, QP_FAIL, "Invalid parameter!"); retif(value == NULL, QP_FAIL, "Invalid parameter!"); - ini = iniparser_load(FILE_PREFERENCE); + file_path = _get_preference_file_path(); + retif(file_path == NULL, QP_FAIL, "failed to _get_preference_file_path()"); + + ini = iniparser_load(file_path); if (ini == NULL) { DBG("failed to load ini file"); _default_file_create(); @@ -145,6 +177,10 @@ END: iniparser_freedict(ini); } + if (file_path != NULL) { + free(file_path); + } + return ret; } @@ -167,7 +203,10 @@ HAPI int quickpanel_preference_set(const char *key, char *value) _default_file_create(); } - ini = iniparser_load(FILE_PREFERENCE); + char *file_path = _get_preference_file_path(); + retif(file_path == NULL, QP_FAIL, "failed to _get_preference_file_path()"); + + ini = iniparser_load(file_path); retif(ini == NULL, QP_FAIL, "failed to load ini file"); if (iniparser_set(ini, (char *)key, value) == 0) { @@ -176,7 +215,7 @@ HAPI int quickpanel_preference_set(const char *key, char *value) ERR("failed to write %s=%s", key, value); } - fp = fopen(FILE_PREFERENCE, "w"); + fp = fopen(file_path, "w"); if (fp != NULL) { iniparser_dump_ini(ini, fp); fclose(fp); @@ -184,5 +223,12 @@ HAPI int quickpanel_preference_set(const char *key, char *value) iniparser_freedict(ini); + if (file_path != NULL) { + free(file_path); + } + return ret; } + + + diff --git a/daemon/quickpanel-ui.h b/daemon/quickpanel-ui.h index 260bd70..6c8606b 100755 --- a/daemon/quickpanel-ui.h +++ b/daemon/quickpanel-ui.h @@ -51,6 +51,7 @@ #define STR_ATOM_WINDOW_CONTENTS_REGION "_E_COMP_WINDOW_CONTENTS_REGION" #define MAX_NAM_LEN 4096 +#define MAX_FILE_PATH_LEN 1024 #define INDICATOR_COVER_W 64 #define INDICATOR_COVER_H 60