#ifndef __MP_COMMON_DEFS_H__
#define __MP_COMMON_DEFS_H__
+#include <storage/storage.h>
+#include <glib.h>
+#include "mp-player-debug.h"
+
#define MP_B_PATH "path"
#define MP_MM_KEY "multimedia_key"
#define MP_PLAY_RECENT "play_recent"
#define MC_SHOW_VAL "show"
#define MC_HIDE_VAL "hide"
-
+typedef enum {
+ DEVICE,
+ MMC
+}storage_mode_e;
//1 Do not change default thumbnail path. it's shared by other apps
#define DEFAULT_THUMBNAIL "default_album_art_120.png"
#define FACTORY_MUSIC "/opt/usr/media/Sounds/Over the horizon.mp3"
-#define MP_PHONE_ROOT_PATH "/opt/usr/media"
-#define MP_MMC_ROOT_PATH "/opt/storage/sdcard"
-
-#define CONTROLLER_REW_SOURCE "control_previous"
-#define CONTROLLER_FF_SOURCE "control_next"
+static int device_id = -1;
+static int mmc_id = -1;
+
+static void mp_lower_string(char *str) {
+ int i = 0;
+ while(str[i] != '\0') {
+ if (str[i] >= 'A' && str[i] <= 'Z') {
+ str[i] = str[i] + 32;
+ }
+ i++;
+ }
+}
+
+static bool __mp_get_all_supported_storage_cb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
+{
+ char *temp_path = g_strdup(path);
+ mp_lower_string(temp_path);
+ if (type == STORAGE_TYPE_EXTERNAL && strstr(temp_path, "sdcard")) {
+ mmc_id = storageId;
+ }
+ if (type == STORAGE_TYPE_INTERNAL) {
+ device_id = storageId;
+ }
+ if (temp_path) {
+ g_free(temp_path);
+ }
+ return true;
+}
+
+static inline char *Get_Root_Path(int storage_type, storage_mode_e smode)
+{
+ char *path = NULL;
+ int error_code = storage_foreach_device_supported(__mp_get_all_supported_storage_cb, NULL);
+ if (error_code != STORAGE_ERROR_NONE) {
+ ERROR_TRACE("failed to get storage Id");
+ return NULL;
+ }
+ if (smode == DEVICE && device_id != -1) {
+ storage_get_root_directory(device_id, &path);
+ } else if (smode == MMC && mmc_id != -1) {
+ storage_get_root_directory(mmc_id, &path);
+ } else {
+ ERROR_TRACE("Invalid storage Id");
+ return NULL;
+ }
+ return path;
+}
+
+#define MP_PHONE_ROOT_PATH Get_Root_Path(STORAGE_TYPE_INTERNAL, DEVICE);
+#define MP_MMC_ROOT_PATH Get_Root_Path(STORAGE_TYPE_EXTERNAL, MMC)
+#define CONTROLLER_REW_SOURCE "control_previous"
+#define CONTROLLER_FF_SOURCE "control_next"
#define PLAY_TIME_ARGS(t) \
(((int)(t)) / 60) % 60, \
#define MC_FILE_PREFIX "file://"
-static int externalStorageId = -1;
bool detail_view = false;
+static external_mmc_id = -1;
static Eina_Bool
_back_cb(void *data, Elm_Object_Item *it)
bool mc_get_supported_storages_callback(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
{
if (type == STORAGE_TYPE_EXTERNAL) {
- externalStorageId = storageId;
+ external_mmc_id = storageId;
return false;
}
return true;
int error = storage_foreach_device_supported(mc_get_supported_storages_callback, NULL);
if (error == STORAGE_ERROR_NONE) {
storage_state_e state;
- storage_get_state(externalStorageId, &state);
+ storage_get_state(external_mmc_id, &state);
if (state == STORAGE_STATE_REMOVED) {
return true;
}
#define TITLE_H 90
#define START_Y_POSITION 94
-#define MP_PHONE_ROOT_PATH "/opt/usr/media"
-#define MP_MMC_ROOT_PATH "/opt/storage/sdcard"
-
#ifndef FALSE
#define FALSE 0
#endif
#define PREF_SOUND_PLAYER_LAUNCH "preference/org.tizen.sound-player/launch_state"
#define PREF_MUSIC_PLAYER_LAUNCH "preference/org.tizen.music-player/launch_state"
+void mp_to_lower(char *str);
int mp_setting_get_nowplaying_id(void);
bool mp_util_is_streaming(const char *uri);
bool mp_util_text_multiline_check(Evas_Object *obj,const char*text, const char*textstyle, int text_width, int text_height);
}
+static bool __mp_get_supported_storage_cb();
+
void
_mp_app_storage_state_changed_cb(int storage_id, storage_state_e state, void *user_data)
{
struct appdata *ad = (struct appdata *)user_data;
MP_CHECK(ad);
+ char *path = NULL;
ad->is_sdcard_removed = true;
if (state == STORAGE_STATE_REMOVED) {
mp_view_mgr_post_event(GET_VIEW_MGR, MP_MMC_REMOVED);
mp_common_force_close_delete();
#endif
} else if (state == STORAGE_STATE_UNMOUNTABLE) {
- if (strstr(ad->current_track_info->uri, MP_MMC_ROOT_PATH)
- == ad->current_track_info->uri) {
+ char *mmc_path = MP_MMC_ROOT_PATH;
+ if (mmc_path && ad->current_track_info && ad->current_track_info->uri && (strstr(ad->current_track_info->uri, mmc_path)
+ == ad->current_track_info->uri)) {
+ IF_FREE(mmc_path);
mp_play_next_and_updateview(ad);
} else {
+ IF_FREE(mmc_path);
mp_view_mgr_post_event(GET_VIEW_MGR, MP_MMC_REMOVED);
#ifndef MP_SOUND_PLAYER
mp_common_force_close_delete();
{
if (type == STORAGE_TYPE_EXTERNAL) {
struct appdata *ad = (struct appdata *)userData;
- ad->externalStorageId = storageId;
+ ad->mmc_id = storageId;
return false;
}
return true;
int error = storage_foreach_device_supported(mp_app_get_supported_storages_callback, ad);
if (error == STORAGE_ERROR_NONE) {
storage_state_e state;
- storage_get_state(ad->externalStorageId, &state);
+ storage_get_state(ad->mmc_id, &state);
}
ad->idle_unlocked = false;
bool res = TRUE;
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) {
+ if (storage_set_state_changed_cb(ad->mmc_id, _mp_app_storage_state_changed_cb, ad) < 0) {
ERROR_TRACE("Fail to register storage state changed callback");
res = FALSE;
}
return FALSE;
}
- if (storage_unset_state_changed_cb(ad->externalStorageId, _mp_app_storage_state_changed_cb) != STORAGE_ERROR_NONE) {
+ if (storage_unset_state_changed_cb(ad->mmc_id, _mp_app_storage_state_changed_cb) != STORAGE_ERROR_NONE) {
ERROR_TRACE("Error when ignore callback");
return FALSE;
}
ad->music_length = mp_player_mgr_get_duration() / 1000.0;
ad->player_state = PLAY_STATE_PLAYING;
-
if (!ad->noti) {
DEBUG_TRACE("notification create");
if (mp_view_mgr_count_view(GET_VIEW_MGR) == 0) {
mp_common_create_initial_view(ad, NULL, NULL);
evas_object_show(ad->win_main);
- elm_win_iconified_set(ad->win_main, EINA_TRUE);
- elm_win_lower(ad->win_main);
- ad->app_is_foreground = false;
- ad->is_focus_out = true;
}
if (ad->create_view_on_play) {
bool track_deleted = false;
#define SINGLE_BYTE_MAX 0x7F
#define PATH_MAX 4096
-static int externalStorageId = -1;
-static int internalStorageId = -1;
+static int external_mmc_id = -1;
+static int internal_device_id = -1;
struct index_s {
const char *index;
mp_util_file_is_in_phone_memory(const char *path)
{
MP_CHECK_VAL(path, 0);
- if (!strncmp(MP_PHONE_ROOT_PATH, path, strlen(MP_PHONE_ROOT_PATH))) {
+ int phone_len = 0;
+ char *phone_path = MP_PHONE_ROOT_PATH;
+ if (phone_path) {
+ phone_len = strlen(phone_path);
+ }
+ if (!strncmp(phone_path, path, strlen(phone_path))) {
+ IF_FREE(phone_path);
return 1;
} else {
+ IF_FREE(phone_path);
return 0;
}
}
}
}
+void mp_to_lower(char *str) {
+ int i = 0;
+ while(str[i] != '\0') {
+ if (str[i] >= 'A' && str[i] <= 'Z') {
+ str[i] = str[i] + 32;
+ }
+ i++;
+ }
+}
+
bool
mp_check_file_exist(const char *path)
{
bool mmc_removed = mp_util_is_mmc_removed();
- if (mmc_removed && strstr(path, MP_MMC_ROOT_PATH) == path) {
+ char *temp_path = g_strdup(path);
+ mp_to_lower(temp_path);
+ if (mmc_removed && strstr(temp_path, "sdcard") == path) {
+ IF_G_FREE(temp_path);
return false;
}
+ IF_G_FREE(temp_path);
if (strstr(path, MP_FILE_PREFIX)) {
if (!g_file_test(path + strlen(MP_FILE_PREFIX), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
ERROR_TRACE("file not exist: %s", path);
bool mp_util_get_supported_storages_callback(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
{
if (type == STORAGE_TYPE_EXTERNAL) {
- externalStorageId = storageId;
+ external_mmc_id = storageId;
return false;
}
return true;
int error = storage_foreach_device_supported(mp_util_get_supported_storages_callback, NULL);
if (error == STORAGE_ERROR_NONE) {
storage_state_e state;
- storage_get_state(externalStorageId, &state);
+ storage_get_state(external_mmc_id, &state);
if (state == STORAGE_STATE_REMOVED || state == STORAGE_STATE_UNMOUNTABLE) {
return true;
}
static bool __mp_get_all_supported_storageids_cb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
{
if (type == STORAGE_TYPE_EXTERNAL) {
- externalStorageId = storageId;
+ external_mmc_id = storageId;
}
if (type == STORAGE_TYPE_INTERNAL) {
- internalStorageId = storageId;
+ internal_device_id = storageId;
}
return true;
ERROR_TRACE("Failed to get Storage Id");
return NULL;
}
- if (storage_type == STORAGE_TYPE_INTERNAL && internalStorageId != -1) {
- storage_get_root_directory(internalStorageId, &path);
- } else if (storage_type == STORAGE_TYPE_EXTERNAL && externalStorageId != -1) {
- storage_get_root_directory(externalStorageId, &path);
+ if (storage_type == STORAGE_TYPE_INTERNAL && internal_device_id != -1) {
+ storage_get_root_directory(internal_device_id, &path);
+ } else if (storage_type == STORAGE_TYPE_EXTERNAL && external_mmc_id != -1) {
+ storage_get_root_directory(external_mmc_id, &path);
} else {
ERROR_TRACE("Invalid Storage Id");
return NULL;
if (item) {
if (item->uri && item->track_type == MP_TRACK_URI && !mp_util_is_streaming(item->uri)) {
SECURE_DEBUG("uri = %s", item->uri);
- if (!mp_file_exists(item->uri) || (mmc_removed && strstr(item->uri, MP_MMC_ROOT_PATH) == item->uri)) {
+ char *temp_uri = g_strdup(item->uri);
+ mp_to_lower(temp_uri);
+ if (!mp_file_exists(item->uri) || (mmc_removed && strstr(temp_uri, "sdcard") == item->uri)) {
SECURE_DEBUG("removed uri = %s", item->uri);
mp_playlist_mgr_item_remove_item(playlist_mgr, item);
if (current_removed && cur == item) {
*current_removed = true;
}
}
+ IF_G_FREE(temp_uri);
}
}
list = list->next;
Ecore_Timer *app_control_check_timer;
bool prepare_by_init; //to indicate if player created and prepared to ready state in init idler
- int externalStorageId;
+ int mmc_id;
app_event_low_battery_status_e low_battery_status;
};
mp_retvm_if(!file_path, NULL, "File path is null...");
int prefix_pos;
- if (!strncmp(file_path, MP_PHONE_ROOT_PATH, strlen(MP_PHONE_ROOT_PATH))) {
- prefix_pos = strlen(MP_PHONE_ROOT_PATH);
+ int phone_len = 0;
+ int mmc_len = 0;
+ char *phone_path = MP_PHONE_ROOT_PATH;
+ char *mmc_path = MP_MMC_ROOT_PATH;
+ if (!strncmp(file_path, phone_path, phone_len)) {
+ prefix_pos = phone_len;
+ IF_FREE(phone_path);
+ IF_FREE(mmc_path);
return g_strdup_printf("Device memory%s", file_path + prefix_pos);
- } else if (!strncmp(file_path, MP_MMC_ROOT_PATH, strlen(MP_MMC_ROOT_PATH))) {
- prefix_pos = strlen(MP_MMC_ROOT_PATH);
+ } else if (!strncmp(file_path, mmc_path, mmc_len)) {
+ prefix_pos = mmc_len;
+ IF_FREE(phone_path);
+ IF_FREE(mmc_path);
return g_strdup_printf("SD card%s", file_path + prefix_pos);
} else if (!strncmp(file_path, "/mnt/mmc", strlen("/mnt/mmc"))) {
prefix_pos = strlen("/mnt/mmc");
+ IF_FREE(phone_path);
+ IF_FREE(mmc_path);
return g_strdup_printf("Memory%s", file_path + prefix_pos);
} else {
WARN_TRACE("Unable to get proper location...");
+ IF_FREE(phone_path);
+ IF_FREE(mmc_path);
return strdup(file_path);
}
}
mp_retvm_if((ret != 0), NULL, "Fail to get value");
if (folder) {
const char *icon_path = NULL;
- if (g_strstr_len(folder, strlen(MP_PHONE_ROOT_PATH), MP_PHONE_ROOT_PATH)) {
+ int phone_len = 0;
+ int mmc_len = 0;
+ char *phone_path = MP_PHONE_ROOT_PATH;
+ char *mmc_path = MP_MMC_ROOT_PATH;
+ if (phone_path) {
+ phone_len = strlen(phone_path);
+ }
+ if (mmc_path) {
+ mmc_len = strlen(mmc_path);
+ }
+ if (g_strstr_len(folder, phone_len, phone_path)) {
icon_path = MP_ICON_STORAGE_PHONE;
- } else if (g_strstr_len(folder, strlen(MP_MMC_ROOT_PATH), MP_MMC_ROOT_PATH)) {
+ } else if (g_strstr_len(folder, mmc_len, mmc_path)) {
icon_path = MP_ICON_STORAGE_MEMORY;
} else {
icon_path = MP_ICON_STORAGE_EXTERNAL;
}
+ IF_FREE(phone_path);
+ IF_FREE(mmc_path);
storage_icon = elm_icon_add(obj);
MP_CHECK_NULL(storage_icon);
elm_image_file_set(storage_icon, IMAGE_EDJ_NAME, icon_path);
mp_retvm_if((ret != 0), NULL, "Fail to get value");
if (folder) {
const char *icon_path = NULL;
- if (g_strstr_len(folder, strlen(MP_PHONE_ROOT_PATH), MP_PHONE_ROOT_PATH)) {
+ int phone_len = 0;
+ int mmc_len = 0;
+ char *phone_path = MP_PHONE_ROOT_PATH;
+ char *mmc_path = MP_MMC_ROOT_PATH;
+ if (phone_path) {
+ phone_len = strlen(phone_path);
+ }
+ if (mmc_path) {
+ mmc_len = strlen(mmc_path);
+ }
+ if (g_strstr_len(folder, phone_len, phone_path)) {
icon_path = MP_ICON_STORAGE_PHONE;
- } else if (g_strstr_len(folder, strlen(MP_MMC_ROOT_PATH), MP_MMC_ROOT_PATH)) {
+ } else if (g_strstr_len(folder, mmc_len, mmc_path)) {
icon_path = MP_ICON_STORAGE_MEMORY;
} else {
icon_path = MP_ICON_STORAGE_EXTERNAL;
}
+ IF_FREE(phone_path);
+ IF_FREE(mmc_path);
icon = elm_icon_add(obj);
MP_CHECK_NULL(icon);
elm_image_file_set(icon, IMAGE_EDJ_NAME, icon_path);