Fixed Issue TSAM-3492 and TSAM-4007 69/74269/2
authorbhutani.92 <bhutani.92@samsung.com>
Mon, 13 Jun 2016 11:30:35 +0000 (17:00 +0530)
committerbhutani.92 <bhutani.92@samsung.com>
Mon, 13 Jun 2016 11:44:20 +0000 (17:14 +0530)
Change-Id: Ia25f0b1e619eab6d3faec20ffb494bc74247e424
Signed-off-by: bhutani.92 <bhutani.92@samsung.com>
inc/mp-common-defs.h
src/common/mp-app.c
src/common/mp-common.c
src/common/mp-edit-callback.c
src/core/mp-playlist-mgr.c
src/core/mp-setting-ctrl.c
src/include/mp-define.h
src/mp-main.c
src/widget/mp-lockscreenmini.c

index 178f05b5b0a17bafb1ed41d9bc0f7193261bb481..c3168102d8ceb468a4b815c63c37a52f07bb2286 100755 (executable)
@@ -102,12 +102,12 @@ typedef enum {
 #define MP_REQ_TYPE_SHORTCUT_DESC "shortcut_desc"
 
 //for supprot nowplaying list in PD
-#define MP_NOWPLAYING_LIST_DATA                MP_INI_DIR"/MpPlayingList.dat"
+#define MP_NOWPLAYING_LIST_DATA                "MpPlayingList.dat"
 
 //for supprot group list in PD
-#define MP_GROUP_LIST_DATA             MP_INI_DIR"/MpGroupList.dat"
+#define MP_GROUP_LIST_DATA             "MpGroupList.dat"
 
-#define MP_NOWPLAYING_INI_FILE_NAME    MP_INI_DIR"/now_playing.ini"
+#define MP_NOWPLAYING_INI_FILE_NAME    "now_playing.ini"
 
 #define MP_AUTO_PLAYLIST_ITEM_MAX      50
 
index 673485ad0950f83182a27001b49573b2f6dfb8b2..e12aaa2fd0cf69fee0272aed383f61a21ee42f0b 100755 (executable)
@@ -434,12 +434,20 @@ void _mp_app_db_update_cb(void *data)
 #endif
 
                        /*as all the items are removed, remove now-playing.ini to avoid copy the same track but in DB, they are different*/
-                       mp_file_remove(MP_NOWPLAYING_INI_FILE_NAME);
+                       char *data_path = app_get_data_path();
+                       char nowplaying_ini[1024] = {0};
+                       snprintf(nowplaying_ini, 1024, "%s%s", data_path, MP_NOWPLAYING_INI_FILE_NAME);
+                       mp_file_remove(nowplaying_ini);
                        /* remove playing_track.ini to avoid lockscreen still using the file content*/
+                       char playing_ini[1024] = {0};
 #ifndef MP_SOUND_PLAYER
-                       mp_file_remove(MP_PLAYING_INI_FILE_NAME_MUSIC);
+                       snprintf(playing_ini, 1024, "%s%s", data_path, MP_PLAYING_INI_FILE_NAME_MUSIC);
+                       free(data_path);
+                       mp_file_remove(playing_ini);
 #else
-                       mp_file_remove(MP_PLAYING_INI_FILE_NAME_SOUND);
+                       snprintf(playing_ini, 1024, "%s%s", data_path, MP_PLAYING_INI_FILE_NAME_SOUND);
+                       free(data_path);
+                       mp_file_remove(playing_ini);
 #endif
                } else if (next_play) {
                        mp_play_new_file(ad, true);
@@ -552,7 +560,12 @@ mp_app_noti_init(void *data)
                ERROR_TRACE("Fail to register KEY_MUSIC_MENU_CHANGE key callback [%d]", retcode);
                res = FALSE;
        }
-       ecore_file_monitor_add(MP_NOW_PLAYING_ID_INI, mp_app_now_playing_id_changed_cb, ad);
+       char *path = app_get_data_path();
+       char now_playing_id[1024] = {0};
+
+       snprintf(now_playing_id, 1024, "%s%s", path, MP_NOW_PLAYING_ID_INI);
+       free(path);
+       ecore_file_monitor_add(now_playing_id, mp_app_now_playing_id_changed_cb, ad);
 
        if (storage_set_state_changed_cb(ad->externalStorageId, _mp_app_storage_state_changed_cb, ad) < 0) {
                ERROR_TRACE("Fail to register storage state changed callback");
index 0ba8caa6fca84007d8d11a02a01adb58e92686dc..c9b4b5ff9c11a9ce5fcf5f96beccefda6ae5ebef 100755 (executable)
@@ -1547,7 +1547,11 @@ void mp_common_create_default_playlist()
        mp_common_create_playlist_mgr();
        mp_playlist_mgr_clear(ad->playlist_mgr);
 
-       mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, MP_NOWPLAYING_LIST_DATA, last_played_path, -1);
+       char *data_path = app_get_data_path();
+       char nowplaying_list_data[1024] = {0};
+       snprintf(nowplaying_list_data, 1024, "%s%s", data_path, MP_NOWPLAYING_LIST_DATA);
+       free(data_path);
+       mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, nowplaying_list_data, last_played_path, -1);
 
        if (mp_playlist_mgr_count(ad->playlist_mgr) == 0) {
                mp_media_info_list_count(MP_TRACK_ALL, NULL, NULL, NULL, 0, &count);
index 76c4321f4138a7b32e483e4bdc08209ba0bb68f9..0c87e8f21d761a6b90a4c16f506925f9e646c29a 100755 (executable)
@@ -688,13 +688,22 @@ static void _mp_edit_cb_check_playlist()
                        }
 #endif
 
+                       char *data_path = app_get_data_path();
                        /*as all the items are removed, remove now-playing.ini to avoid copy the same track but in DB, they are different*/
-                       mp_file_remove(MP_NOWPLAYING_INI_FILE_NAME);
+                       char nowplaying_ini[1024] = {0};
+                       snprintf(nowplaying_ini, 1024, "%s%s", data_path, MP_NOWPLAYING_INI_FILE_NAME);
+                       mp_file_remove(nowplaying_ini);
                        /* remove playing_track.ini to avoid lockscreen still using the file content*/
+
+                       char playing_ini[1024] = {0};
 #ifndef MP_SOUND_PLAYER
-                       mp_file_remove(MP_PLAYING_INI_FILE_NAME_MUSIC);
+                       snprintf(playing_ini, 1024, "%s%s", data_path, MP_PLAYING_INI_FILE_NAME_MUSIC);
+                       free(data_path);
+                       mp_file_remove(playing_ini);
 #else
-                       mp_file_remove(MP_PLAYING_INI_FILE_NAME_SOUND);
+                       snprintf(playing_ini, 1024, "%s%s", data_path, MP_PLAYING_INI_FILE_NAME_SOUND);
+                       free(data_path);
+                       mp_file_remove(playing_ini);
 #endif
                } else if (next_play) {
                        mp_play_new_file(ad, true);
index f892ff8868fc4d78682ca6f65983b3ca026817d4..33b93d891e4f815ede0fe2090953a66b22c16785 100755 (executable)
@@ -112,10 +112,14 @@ __save_playing_list(mp_plst_mgr *playlist_mgr)
 
        int i;
 
-       fp = fopen(MP_NOWPLAYING_LIST_DATA, "w");
+       char *data_path = app_get_data_path();
+       char nowplaying_list_data[1024] = {0};
+       snprintf(nowplaying_list_data, 1024, "%s%s", data_path, MP_NOWPLAYING_LIST_DATA);
+       free(data_path);
+       fp = fopen(nowplaying_list_data, "w");
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_NOWPLAYING_LIST_DATA);
+               SECURE_ERROR("Failed to open ini files. : %s", nowplaying_list_data);
                return;
        }
 
index cd6b8d5e39c9ed25a69f7d41815eea2db5d7f796..6e472a2330fb2723fc04e09697276eaf1e05508e 100755 (executable)
@@ -466,10 +466,15 @@ mp_setting_set_nowplaying_id(int val)
 {
        startfunc;
 
-       FILE *fp = fopen(MP_NOW_PLAYING_ID_INI, "w");   /* make new file. */
+       char *path = app_get_data_path();
+       char now_playing_id[1024] = {0};
+
+       snprintf(now_playing_id, 1024, "%s%s", path, MP_NOW_PLAYING_ID_INI);
+       free(path);
+       FILE *fp = fopen(now_playing_id, "w");  /* make new file. */
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_NOW_PLAYING_ID_INI);
+               SECURE_ERROR("Failed to open ini files. : %s", now_playing_id);
                return;
        }
 
@@ -490,8 +495,13 @@ mp_setting_get_nowplaying_id(void)
        FILE *fp = NULL;
        char line[MAX_NAM_LEN + 1];
        int pid = -1;
-       if ((fp = fopen(MP_NOW_PLAYING_ID_INI, "r")) == NULL) {
-               DEBUG_TRACE("unable to open %s/shared/data/NowPlayingId.ini", DATA_PREFIX);
+       char *path = app_get_data_path();
+       char now_playing_id[1024] = {0};
+
+       snprintf(now_playing_id, 1024, "%s%s", path, MP_NOW_PLAYING_ID_INI);
+       free(path);
+       if ((fp = fopen(now_playing_id, "r")) == NULL) {
+               DEBUG_TRACE("unable to open %s", now_playing_id);
                return -1;
        }
        if (fgets(line, MAX_NAM_LEN, fp)) { /* #Nowplaying */
@@ -524,10 +534,14 @@ mp_setting_set_player_state(int val)
                return;
        }
 
-       FILE *fp = fopen(MP_PLAY_STATE, "w");   /* make new file. */
+       char *path = app_get_data_path();
+       char play_state[1024] = {0};
+       snprintf(play_state, 1024, "%s%s", path, MP_PLAY_STATE);
+       free(path);
+       FILE *fp = fopen(play_state, "w");      /* make new file. */
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_PLAY_STATE);
+               SECURE_ERROR("Failed to open ini files. : %s", play_state);
                return;
        }
 
@@ -623,17 +637,23 @@ mp_setting_save_playing_info(void *data)
        MP_CHECK(item);
        MP_CHECK(ad->current_track_info);
 
+       char *data_path = app_get_data_path();
+       char playing_ini[1024] = {0};
 #ifndef MP_SOUND_PLAYER
-       fp = fopen(MP_PLAYING_INI_FILE_NAME_MUSIC, "w");        /* make new file. */
+       snprintf(playing_ini, 1024, "%s%s", data_path, MP_PLAYING_INI_FILE_NAME_MUSIC);
+       free(data_path);
+       fp = fopen(playing_ini, "w");        /* make new file. */
 #else
-       fp = fopen(MP_PLAYING_INI_FILE_NAME_SOUND, "w");        /* make new file. */
+       snprintf(playing_ini, 1024, "%s%s", data_path, MP_PLAYING_INI_FILE_NAME_SOUND);
+       free(data_path);
+       fp = fopen(playing_ini, "w");        /* make new file. */
 #endif
 
        if (fp == NULL) {
 #ifndef MP_SOUND_PLAYER
-               ERROR_TRACE("Failed to open ini files. : %s", MP_PLAYING_INI_FILE_NAME_MUSIC);
+               ERROR_TRACE("Failed to open ini files. : %s", playing_ini);
 #else
-               ERROR_TRACE("Failed to open ini files. : %s", MP_PLAYING_INI_FILE_NAME_SOUND);
+               ERROR_TRACE("Failed to open ini files. : %s", playing_ini);
 #endif
                return;
        }
@@ -680,7 +700,7 @@ mp_setting_remove_now_playing_shared_status(void)
        if (path == NULL) {
                return;
        }
-       snprintf(playing_status, 1024, "%s%s", path, "NowPlayingStatus");
+       snprintf(playing_status, 1024, "%s%s", path, MP_SHARED_PLAYING_STATUS_INI);
        free(path);
 
        FILE *fp = fopen(playing_status, "w");  /* make new file. */
@@ -702,10 +722,14 @@ mp_setting_remove_now_playing(void)
        startfunc;
        FILE *fp = NULL;
 
-       fp = fopen(MP_NOWPLAYING_INI_FILE_NAME, "w");   /* make new file. */
+       char *data_path = app_get_data_path();
+       char nowplaying_ini[1024] = {0};
+       snprintf(nowplaying_ini, 1024, "%s%s", data_path, MP_NOWPLAYING_INI_FILE_NAME);
+       free(data_path);
+       fp = fopen(nowplaying_ini, "w");        /* make new file. */
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_NOWPLAYING_INI_FILE_NAME);
+               SECURE_ERROR("Failed to open ini files. : %s", nowplaying_ini);
                return;
        }
        fprintf(fp, " \n");
@@ -723,11 +747,15 @@ mp_setting_get_now_playing_path_from_file(char **path)
        char line[MAX_NAM_LEN + 1];
        FILE *fp = NULL;
 
-       if(access(MP_NOWPLAYING_INI_FILE_NAME, F_OK) != -1)
+       char *data_path = app_get_data_path();
+       char nowplaying_ini[1024] = {0};
+       snprintf(nowplaying_ini, 1024, "%s%s", data_path, MP_NOWPLAYING_INI_FILE_NAME);
+       free(data_path);
+       if(access(nowplaying_ini, F_OK) != -1)
        {
-               fp = fopen(MP_NOWPLAYING_INI_FILE_NAME, "r");
+               fp = fopen(nowplaying_ini, "r");
                if (!fp) {
-                       SECURE_ERROR("unable to open %s...", MP_NOWPLAYING_INI_FILE_NAME);
+                       SECURE_ERROR("unable to open %s...", nowplaying_ini);
                        return;
                }
                if (fgets(line, MAX_NAM_LEN, fp)) { /* audio id */
@@ -758,10 +786,14 @@ mp_setting_save_now_playing(void *data)
        MP_CHECK(item);
        MP_CHECK(ad->current_track_info);
 
-       fp = fopen(MP_NOWPLAYING_INI_FILE_NAME, "w");   /* make new file. */
+       char *data_path = app_get_data_path();
+       char nowplaying_ini[1024] = {0};
+       snprintf(nowplaying_ini, 1024, "%s%s", data_path, MP_NOWPLAYING_INI_FILE_NAME);
+       free(data_path);
+       fp = fopen(nowplaying_ini, "w");        /* make new file. */
 
        if (fp == NULL) {
-               SECURE_ERROR("Failed to open ini files. : %s", MP_NOWPLAYING_INI_FILE_NAME);
+               SECURE_ERROR("Failed to open ini files. : %s", nowplaying_ini);
                return;
        }
 
@@ -852,11 +884,15 @@ mp_setting_read_playing_status(char *uri, char *status)
        int valid_uri = 0;
        int valid_status = 0;
        char *path = app_get_data_path();
+       if (!path) {
+               return -1;
+       }
+       DEBUG_TRACE("Data Path is: %s", path);
        char playing_status[1024] = {0};
        if (path == NULL) {
                return -1;
        }
-       snprintf(playing_status, 1024, "%s%s", path, "NowPlayingStatus");
+       snprintf(playing_status, 1024, "%s%s", path, MP_SHARED_PLAYING_STATUS_INI);
        free(path);
 
        FILE *fp = fopen(playing_status, "r");  /* read MP_SHARED_PLAYING_STATUS_INI file.  */
@@ -921,12 +957,14 @@ mp_setting_write_playing_status(char *uri, char *status)
                mp_setting_remove_now_playing_shared_status();
        } else {
                char *path = app_get_data_path();
-               DEBUG_TRACE("Path is: %s", path);
+               char *shared_path = app_get_shared_resource_path();
+               DEBUG_TRACE("Data Path is: %s", path);
+               DEBUG_TRACE("Shared Resource Path is: %s", shared_path);
                char playing_status[1024] = {0};
                if (path == NULL) {
                        return;
                }
-               snprintf(playing_status, 1024, "%s%s", path, "NowPlayingStatus");
+               snprintf(playing_status, 1024, "%s%s", path, MP_SHARED_PLAYING_STATUS_INI);
                free(path);
 
                FILE *fp = fopen(playing_status, "w");  /* make new file. */
index db6a33fe63237c5c471e69a501c42ec0d4fa0279..47cf74f3599e8838f0e10f3d0c0b531a1e17cdb7 100755 (executable)
@@ -389,26 +389,26 @@ typedef enum
 
 #define MP_FILE_PREFIX "file://"
 
-#define MP_NOW_PLAYING_ID_INI          DATA_PREFIX"/shared/data/NowPlayingId.ini"      //playing thread id
+#define MP_NOW_PLAYING_ID_INI          "NowPlayingId.ini"      //playing thread id
 #ifdef MP_SOUND_PLAYER
-#define MP_SHARED_PLAYING_STATUS_INI   DATA_PREFIX"/shared/data/nowplaying.ini"        //share track info of sound-player
+#define MP_SHARED_PLAYING_STATUS_INI   "nowplaying.ini"        //share track info of sound-player
 #else
-#define MP_SHARED_PLAYING_STATUS_INI   DATA_PREFIX"/shared/data/NowPlayingStatus" //share track info of music-player
+#define MP_SHARED_PLAYING_STATUS_INI   "NowPlayingStatus" //share track info of music-player
 #endif
 //@@ MP_PLAYING_INI_FILE_NAME
 //this hard corded value is used for music player & sound player.
 //if this is need to be changed, you need to inform about it to lockscreen.
-#define MP_PLAYING_INI_FILE_NAME_MUSIC         DATA_PREFIX"/data/playing_track_music.ini"
-#define MP_PLAYING_INI_FILE_NAME_SOUND         DATA_PREFIX"/data/playing_track_sound.ini"
+#define MP_PLAYING_INI_FILE_NAME_MUSIC         "playing_track_music.ini"
+#define MP_PLAYING_INI_FILE_NAME_SOUND         "playing_track_sound.ini"
 
 /* music play state for livebox and music player and sound player */
-#define MP_PLAY_STATE                          DATA_PREFIX"/shared/data/MusicPlayStatus.ini"   //player state
+#define MP_PLAY_STATE                          "MusicPlayStatus.ini"   //player state
 
 
 #ifndef MP_SOUND_PLAYER
-#define MP_LSCR_CONTROL                                DATA_PREFIX"/data/lock_music_ctrl"
+#define MP_LSCR_CONTROL                                "lock_music_ctrl"
 #else
-#define MP_LSCR_CONTROL                                DATA_PREFIX"/data/lock_sound_ctrl"
+#define MP_LSCR_CONTROL                                        "lock_sound_ctrl"
 #endif
 
 
index e58420138311be2e3b3e97a3d184e4e4768ce858..cb6a7cab7b957e33bc33c8c12ddbbad3883de0bd 100755 (executable)
@@ -502,7 +502,11 @@ static bool _parse_widget_event(bundle *b, bool *activate_window)
                mp_common_create_playlist_mgr();
                mp_playlist_mgr_clear(ad->playlist_mgr);
 
-               mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, MP_GROUP_LIST_DATA, NULL, index);
+               char *data_path = app_get_data_path();
+               char group_list_data[1024] = {0};
+               snprintf(group_list_data, 1024, "%s%s", data_path, MP_GROUP_LIST_DATA);
+               free(data_path);
+               mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, group_list_data, NULL, index);
                return true;
        }
 
@@ -614,7 +618,11 @@ _mp_main_app_init_idler_cb(void *data)
 
                if (ad->playlist_mgr && ad->current_track_info) {
                        if (ad->current_track_info->uri) {
-                               mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, MP_NOWPLAYING_LIST_DATA, ad->current_track_info->uri, -1);
+                               char *data_path = app_get_data_path();
+                               char nowplaying_list_data[1024] = {0};
+                               snprintf(nowplaying_list_data, 1024, "%s%s", data_path, MP_NOWPLAYING_LIST_DATA);
+                               free(data_path);
+                               mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, nowplaying_list_data, ad->current_track_info->uri, -1);
                        }
                }
        }
@@ -938,7 +946,11 @@ _mp_main_create_default_playing_list(struct appdata *ad, int index)
        mp_common_create_playlist_mgr();
        mp_playlist_mgr_clear(ad->playlist_mgr);
 
-       mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, MP_NOWPLAYING_LIST_DATA, last_played_path, -1);
+       char *data_path = app_get_data_path();
+       char nowplaying_list_data[1024] = {0};
+       snprintf(nowplaying_list_data, 1024, "%s%s", data_path, MP_NOWPLAYING_LIST_DATA);
+       free(data_path);
+       mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, nowplaying_list_data, last_played_path, -1);
 
        if (mp_playlist_mgr_count(ad->playlist_mgr) == 0) {
                mp_media_info_list_count(MP_TRACK_ALL, NULL, NULL, NULL, 0, &count);
@@ -1033,7 +1045,11 @@ _mp_main_parse_livebox_event(app_control_h app_control, bool *activate_window, b
                mp_common_create_playlist_mgr();
                mp_playlist_mgr_clear(ad->playlist_mgr);
 
-               mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, MP_GROUP_LIST_DATA, NULL, index);
+               char *data_path = app_get_data_path();
+               char group_list_data[1024] = {0};
+               snprintf(group_list_data, 1024, "%s%s", data_path, MP_GROUP_LIST_DATA);
+               free(data_path);
+               mp_playlist_mgr_lazy_append_with_file(ad->playlist_mgr, group_list_data, NULL, index);
                *start_playback = true;
                return true;
        }
index e22595388875d32628c8589b746ef594383f48cf..e9efc37c98d185093d965abdec0c5f510554cddf 100755 (executable)
@@ -545,7 +545,11 @@ mp_lockscreenmini_show(struct appdata *ad)
        ad->b_lockmini_show = TRUE;
        mp_lockscreenmini_update(ad);
 
-       FILE *fp = fopen(MP_LSCR_CONTROL, "w");
+       char *path = app_get_data_path();
+       char lscr_state[1024] = {0};
+       snprintf(lscr_state, 1024, "%s%s", path, MP_LSCR_CONTROL);
+       free(path);
+       FILE *fp = fopen(lscr_state, "w");
        if (fp) {
                fclose(fp);
        }
@@ -892,7 +896,11 @@ mp_lockscreenmini_destroy(struct appdata *ad)
        mp_ecore_timer_del(ad->lockmini_button_timer);
        ad->lockmini_visible = false;
 
-       ecore_file_remove(MP_LSCR_CONTROL);
+       char *path = app_get_data_path();
+       char lscr_state[1024] = {0};
+       snprintf(lscr_state, 1024, "%s%s", path, MP_LSCR_CONTROL);
+       free(path);
+       ecore_file_remove(lscr_state);
        return 0;
 }