Changed data folder path for widget 93/68493/1
authorbhutani.92 <bhutani.92@samsung.com>
Thu, 5 May 2016 07:51:06 +0000 (13:21 +0530)
committerbhutani.92 <bhutani.92@samsung.com>
Thu, 5 May 2016 07:51:06 +0000 (13:21 +0530)
Change-Id: I124f08aa36336c5b7d89c3467d8b0dbafd6b28c2
Signed-off-by: bhutani.92 <bhutani.92@samsung.com>
src/core/mp-setting-ctrl.c
widget/src/mp-widget-create.c

index eee1287..3a81968 100755 (executable)
@@ -675,11 +675,18 @@ void
 mp_setting_remove_now_playing_shared_status(void)
 {
        startfunc;
+       char *path = app_get_data_path();
+       char playing_status[1024] = {0};
+       if (path == NULL) {
+               return;
+       }
+       snprintf(playing_status, 1024, "%s%s", path, "NowPlayingStatus");
+       free(path);
 
-       FILE *fp = fopen(MP_SHARED_PLAYING_STATUS_INI, "w");    /* make new file. */
+       FILE *fp = fopen(playing_status, "w");  /* make new file. */
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_NOWPLAYING_INI_FILE_NAME);
+               ERROR_TRACE("Failed to open ini files. : %s", playing_status);
                return;
        }
        fprintf(fp, " \n");
@@ -844,10 +851,18 @@ mp_setting_read_playing_status(char *uri, char *status)
        char str[1000] = {0,};
        int valid_uri = 0;
        int valid_status = 0;
-       FILE *fp = fopen(MP_SHARED_PLAYING_STATUS_INI, "r");    /* read MP_SHARED_PLAYING_STATUS_INI file.  */
+       char *path = app_get_data_path();
+       char playing_status[1024] = {0};
+       if (path == NULL) {
+               return -1;
+       }
+       snprintf(playing_status, 1024, "%s%s", path, "NowPlayingStatus");
+       free(path);
+
+       FILE *fp = fopen(playing_status, "r");  /* read MP_SHARED_PLAYING_STATUS_INI file.  */
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_SHARED_PLAYING_STATUS_INI);
+               ERROR_TRACE("Failed to open ini files. : %s", playing_status);
                return -1;
        }
        char *sptr = NULL;
@@ -905,10 +920,19 @@ mp_setting_write_playing_status(char *uri, char *status)
        if (count <= 0) {
                mp_setting_remove_now_playing_shared_status();
        } else {
-               FILE *fp = fopen(MP_SHARED_PLAYING_STATUS_INI, "w");    /* make new file. */
+               char *path = app_get_data_path();
+               DEBUG_TRACE("Path is: %s", path);
+               char playing_status[1024] = {0};
+               if (path == NULL) {
+                       return;
+               }
+               snprintf(playing_status, 1024, "%s%s", path, "NowPlayingStatus");
+               free(path);
+
+               FILE *fp = fopen(playing_status, "w");  /* make new file. */
 
                if (fp == NULL) {
-                       SECURE_ERROR("Failed to open ini files. : %s", MP_SHARED_PLAYING_STATUS_INI);
+                       ERROR_TRACE("Failed to open ini files. : %s", playing_status);
                        return;
                }
 
index 62dd6ab..5f290d6 100644 (file)
@@ -48,7 +48,7 @@
 
 #define BROKEN_ALBUMART_IMAGE_PATH             "/opt/usr/share/media/.thumb/thumb_default.png"
 #define DEFAULT_ALBUM_ART_ICON SHAREDDIR"/res/shared_images/default_albumart.png"
-#define NOW_PLAYING_INI_PATH DATA_PREFIX"/shared/data/NowPlayingStatus"
+#define NOW_PLAYING_INI_PATH "NowPlayingStatus"
 
 static Eina_Bool is_play = EINA_FALSE;
 Eina_List *widget_list = NULL;
@@ -211,10 +211,18 @@ static void mp_widget_read_ini_file_ecore(void *data, char *path)
 
 void __create_read_ini_file(void)
 {
-       FILE *fp = fopen(NOW_PLAYING_INI_PATH, "w");    /* make new file. */
+       char *path = app_get_data_path();
+       char playing_status[1024] = {0};
+       if (path == NULL) {
+               return;
+       }
+       snprintf(playing_status, 1024, "%s%s", path, NOW_PLAYING_INI_PATH);
+       free(path);
+
+       FILE *fp = fopen(playing_status, "w");  /* make new file. */
 
        if (fp == NULL) {
-               ERROR_TRACE("Failed to open ini files. : %s", NOW_PLAYING_INI_PATH);
+               ERROR_TRACE("Failed to open ini files. : %s", playing_status);
                return;
        }
        fprintf(fp, " \n");
@@ -787,7 +795,14 @@ static void __mp_change_multiple_widgets(void *data, Ecore_File_Monitor *em, Eco
        if (event == ECORE_FILE_EVENT_MODIFIED || event == ECORE_FILE_EVENT_CREATED_FILE) {
                DEBUG_TRACE("The monitored file path is: %s", ecore_file_monitor_path_get(em));
                EINA_LIST_FOREACH(widget_list, temp_list, wgtdata) {
-                       mp_widget_read_ini_file_ecore(wgtdata, NOW_PLAYING_INI_PATH);
+                       char *path = app_get_data_path();
+                       char playing_status[1024] = {0};
+                       if (path == NULL) {
+                               return;
+                       }
+                       snprintf(playing_status, 1024, "%s%s", path, NOW_PLAYING_INI_PATH);
+                       free(path);
+                       mp_widget_read_ini_file_ecore(wgtdata, playing_status);
                }
        }
        free(temp_list);
@@ -833,14 +848,18 @@ int mp_widget_create(WidgetData* data, int w, int h)
 
        elm_object_domain_translatable_part_text_set(layout, "noitems_title", "music-player", "IDS_MUSIC_BODY_MUSIC");
        elm_object_domain_translatable_part_text_set(layout, "noitems_subtitle", "music-player", "IDS_MUSIC_SK3_ADD_TRACKS");
+       char *path = app_get_data_path();
+       DEBUG_TRACE("Path is: %s", path);
+       char playing_status[1024] = {0};
+       if (path == NULL) {
+               return -1;
+       }
+       snprintf(playing_status, 1024, "%s%s", path, NOW_PLAYING_INI_PATH);
+       free(path);
+       mp_widget_read_ini_file(playing_status, data);
 
-       mp_widget_read_ini_file(NOW_PLAYING_INI_PATH, data);
-
-       char *path = NULL;
-       path = g_strdup_printf("%s/shared/data/NowPlayingStatus", DATA_PREFIX);
-       DEBUG_TRACE("path :%s", path);
        if (data->em == NULL) {
-               data->em = ecore_file_monitor_add(path, __mp_change_multiple_widgets, NULL);
+               data->em = ecore_file_monitor_add(playing_status, __mp_change_multiple_widgets, NULL);
        }
 
        elm_object_signal_callback_add(layout, "mouse,down,1",