int all_local_cnt = 0;
Eina_List *list = NULL;
ge_album_s *album = NULL;
+ ge_cluster *default_album = NULL;
ge_album_s *camera_album = NULL;
ge_album_s *downloads_album = NULL;
ge_cluster *camera_cluster = NULL;
}
GE_CHECK_VAL(ugd->cluster_list, -1);
-GE_DATA_AGAIN:
+ GE_DATA_AGAIN:
/* Get local albums for first time and local albums is more than 9 */
if (type == GE_ALBUM_DATA_NONE || type == GE_ALBUM_DATA_LOCAL) {
/* Get real albums */
memset(&filter, 0x00, sizeof(ge_filter_s));
g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO,
- CONDITION_LENGTH);
+ CONDITION_LENGTH);
filter.collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
filter.sort_type = MEDIA_CONTENT_ORDER_ASC;
g_strlcpy(filter.sort_keyword, FOLDER_NAME, KEYWORD_LENGTH);
- _ge_local_data_get_album_by_path(GE_CAMERA_PATH_PHONE,
- &camera_album);
- if (camera_album) {
- list = eina_list_append(list, camera_album);
- }
- camera_album = NULL;
- _ge_local_data_get_album_by_path(GE_CAMERA_PATH_MMC,
- &camera_album);
- if (camera_album) {
- list = eina_list_append(list, camera_album);
- }
- _ge_local_data_get_album_by_path(GE_DOWNLOADS_PATH,
- &downloads_album);
- if (downloads_album) {
- list = eina_list_append(list, downloads_album);
- }
if (type == GE_ALBUM_DATA_NONE) {
filter.count = GE_ALBUMS_FIRST_COUNT;
memset(&filter, 0x00, sizeof(ge_filter_s));
if (ugd->file_type_mode == GE_FILE_T_IMAGE)
g_strlcpy(filter.cond, GE_CONDITION_IMAGE,
- CONDITION_LENGTH);
+ CONDITION_LENGTH);
else if (ugd->file_type_mode == GE_FILE_T_VIDEO)
g_strlcpy(filter.cond, GE_CONDITION_VIDEO,
- CONDITION_LENGTH);
+ CONDITION_LENGTH);
else
g_strlcpy(filter.cond, GE_CONDITION_IMAGE_VIDEO,
- CONDITION_LENGTH);
+ CONDITION_LENGTH);
filter.sort_type = MEDIA_CONTENT_ORDER_DESC;
g_strlcpy(filter.sort_keyword, MEDIA_DISPLAY_NAME,
- KEYWORD_LENGTH);
+ KEYWORD_LENGTH);
filter.offset = GE_GET_ALL_RECORDS;
filter.count = GE_GET_ALL_RECORDS;
filter.with_meta = false;
ge_dbgE("Invalid ge_album_s!");
continue;
}
- ge_sdbg("Cluster ID: %s.", album->uuid);
+ ge_sdbg("Cluster name : %s.", album->display_name);
err = _ge_local_data_get_media_count(album->uuid,
- &filter,
- &medias_cnt);
+ &filter,
+ &medias_cnt);
if (err == 0 && medias_cnt > 0) {
album->count = medias_cnt;
all_local_cnt += medias_cnt;
gcluster->cluster = album;
gcluster->ugd = ugd;
length += album->count;
-
- clist = eina_list_append(clist, gcluster);
- if (type == GE_ALBUM_DATA_NONE) {
- if (_ge_data_is_camera_album(album)) {
- camera_cluster = gcluster;
+ if (_ge_data_is_camera_album(album)) {
+ camera_cluster = gcluster;
+ /**
+ * Default album: Camera
+ * Now Camera Shot is located in Phone/MMC.
+ * If user can determine the location of default album,
+ * here we should get the path and check it's in Phone or MMC.
+ */
+ if (default_album) {
+ /* album 'Camera' is in phone, set it before MMC album 'Camera' */
+ char *phone_root_path = _ge_get_root_folder_path_internal();
+ if (phone_root_path && _ge_data_check_root_type(album->path, phone_root_path)) {
+ clist = eina_list_prepend(clist,
+ gcluster);
+ } else {
+ clist = eina_list_append_relative(clist,
+ gcluster,
+ default_album);
+ default_album = gcluster;
+ }
+ GE_FREEIF(phone_root_path);
+ } else {
+ default_album = gcluster;
+ clist = eina_list_prepend(clist,
+ gcluster);
}
+ } else if (_ge_data_is_default_album(GE_ALBUM_DOWNLOADS_NAME, album)) {
+ if (default_album)
+ clist = eina_list_append_relative(clist,
+ gcluster,
+ default_album);
+ else
+ clist = eina_list_prepend(clist,
+ gcluster);
+ } else {
+ clist = eina_list_append(clist,
+ gcluster);
}
ugd->cluster_list->clist = clist;
}
if (camera_cluster) {
clist = eina_list_append_relative(clist, gcluster,
- camera_cluster);
+ camera_cluster);
} else {
clist = eina_list_prepend(clist, gcluster);
}
ge_dbg("Parent path: %s", parent_path);
/* Parent directory is same as Phone root path, it's default folder */
- ret = g_strcmp0(parent_path, GE_ROOT_PATH_PHONE);
+ char *path = _ge_get_root_folder_path_internal();
+ if (!path) {
+ return false;
+ }
+ ret = g_strcmp0(parent_path, path);
GE_FREE(parent_path);
+ GE_FREE(path);
if (ret == 0) {
ge_dbgW("Default folder!");
if (!g_strcmp0(mcluster->display_name, GE_ALBUM_CAMERA_NAME)) {
const char *root = NULL;
if (mcluster->type == GE_PHONE) {
- root = GE_ROOT_PATH_PHONE;
+ char * path = _ge_get_camera_folder_path_internal();
} else {
- root = GE_ROOT_PATH_MMC;
+ char * path = _ge_get_camera_folder_path_external();
}
-
ge_dbg("Full path: %s", mcluster->path);
char *parent_path = ge_file_dir_get(mcluster->path);
GE_CHECK_FALSE(parent_path);
ge_dbg("Parent path: %s.", parent_path);
-
- char *dcim_path = g_strdup_printf("%s/%s", root, GE_DCIM);
- if (dcim_path == NULL) {
- GE_GFREE(parent_path);
- return false;
- }
/* And parent folder is Phone root path, it's default folder */
bool ret = false;
- ret = !g_strcmp0(dcim_path, parent_path);
-
- GE_GFREE(dcim_path);
- GE_GFREE(parent_path);
- return ret;
+ if (!g_strcmp0(root, mcluster->path)) {
+ GE_GFREE(parent_path);
+ GE_FREEIF(root);
+ return true;
+ }
}
-
return false;
}
bool _ge_data_is_root_path(const char *path)
{
GE_CHECK_FALSE(path);
-
- if (!g_strcmp0(GE_ROOT_PATH_PHONE, path) ||
- !g_strcmp0(GE_ROOT_PATH_MMC, path)) {
+ char *path_internal= NULL;
+ char *path_external= NULL;
+ if(get_internal_storage_id() != -1) {
+ storage_get_root_directory(get_internal_storage_id(), &path_internal);
+ }
+ if (get_external_storage_id() != -1) {
+ storage_get_root_directory(get_external_storage_id(), &path_external);
+ }
+ if ((path_internal && !g_strcmp0(path_internal, path)) ||
+ (path_external && !g_strcmp0(path_external, path))) {
ge_dbg("Root path: %s", path);
return true;
}
ge_dbg("Error code: %d", err);
return err;
}
+
+bool _ge_data_check_root_type(const char *path, const char *root)
+{
+ if (path == NULL || root == NULL) {
+ return false;
+ }
+
+ if (!strncmp(root, path, strlen(root))) {
+ ge_sdbg("Root path: %s", path);
+ return true;
+ }
+
+ return false;
+}
#define GE_PERIOD_LIVEBOX 30.0
-static int __externalStorageId = 0;
+static int __externalStorageId = -1;
+static int __internalStorageId = 0;
bool getSupportedStorages_cb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
{
if (type == STORAGE_TYPE_EXTERNAL) {
__externalStorageId = storageId;
return false;
+ } else if (type == STORAGE_TYPE_INTERNAL) {
+ __internalStorageId = storageId;
+ return false;
}
return true;
return path;
}
+int get_external_storage_id(void)
+{
+ return __externalStorageId;
+}
+
+int get_internal_storage_id(void)
+{
+ return __internalStorageId;
+}
+
+static char *__ge_get_folder_path(int storage_id, int directory)
+{
+ char *path = NULL;
+ if (storage_id != -1) {
+ char *path_camera = NULL;
+ storage_get_directory(storage_id, directory, &path_camera);
+ if (path_camera) {
+ path = strdup(path_camera);
+ GE_FREEIF(path_camera);
+ } else {
+ path = strdup("");
+ }
+ } else {
+ path = strdup("");
+ }
+ return path;
+}
+
+char * _ge_get_camera_folder_path_internal(void)
+{
+ return __ge_get_folder_path(__internalStorageId, STORAGE_DIRECTORY_CAMERA);
+}
+
+char * _ge_get_camera_folder_path_external(void)
+{
+ return __ge_get_folder_path(__externalStorageId, STORAGE_DIRECTORY_CAMERA);
+}
+
+char *_ge_get_downloads_folder_path(void)
+{
+ return __ge_get_folder_path(__internalStorageId, STORAGE_DIRECTORY_DOWNLOADS);
+}
+
+char * _ge_get_root_folder_path_internal(void)
+{
+ char *path = NULL;
+ if (get_internal_storage_id() != -1) {
+ char *path_root = NULL;
+ storage_get_root_directory(get_external_storage_id(), &path_root);
+ if (path_root) {
+ path = strdup(path_root);
+ GE_FREEIF(path_root);
+ } else {
+ path = strdup(GE_ROOT_PATH_PHONE);
+ }
+ } else {
+ path = strdup(GE_ROOT_PATH_PHONE);
+ }
+ return path;
+}
+
+char * _ge_get_root_folder_path_external(void)
+{
+ char *path = NULL;
+ if (get_external_storage_id() != -1) {
+ char *path_root = NULL;
+ storage_get_root_directory(get_external_storage_id(), &path_root);
+ if (path_root) {
+ path = strdup(path_root);
+ GE_FREEIF(path_root);
+ } else {
+ path = strdup(GE_ROOT_PATH_MMC);
+ }
+ } else {
+ path = strdup(GE_ROOT_PATH_MMC);
+ }
+ return path;
+}