[Bug] get size of download from DB .
authoryigang.jing <yigang.jing@samsung.com>
Fri, 9 Nov 2012 02:05:45 +0000 (10:05 +0800)
committeryigang.jing <yigang.jing@samsung.com>
Fri, 9 Nov 2012 02:05:45 +0000 (10:05 +0800)
Change-Id: I81f7d469667599b828917093f0777f828201a7e2

setting-storage/src/setting-storage-main.c

index 5bc1f7b..67ad910 100755 (executable)
@@ -335,7 +335,7 @@ static double __setting_storage_main_pictures_videos_status_get()
        filter_h filter = NULL;
 
        /*Set Filter*/
-       char *condition = "(MEDIA_TYPE=0 OR MEDIA_TYPE=1)";     /*0-image, 1-video, 2-sound, 3-music, 4-other*/
+       char *condition = "(MEDIA_TYPE=0 OR MEDIA_TYPE=1) and MEDIA_PATH LIKE \'/opt/media/%%\'";       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
 
        ret = media_filter_create(&filter);
        if(ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -371,10 +371,38 @@ static double __setting_storage_main_downloads_status_get()
        SETTING_TRACE_BEGIN;
 
        double total_size = 0.0;
-       int ret = SETTING_RETURN_SUCCESS;
 
-       total_size = __setting_storage_main_folder_size_get(SETTING_STORAGE_DOWNLOADS_PATH);
-       setting_retvm_if(ret == SETTING_RETURN_FAIL, total_size, "get downloads status failed");
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_h filter = NULL;
+
+       /*Set Filter*/
+       char *condition = "MEDIA_PATH LIKE \'/opt/media/Downloads/%%\'";
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               SETTING_TRACE("Fail to create filter");
+               return total_size;
+       }
+
+       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               SETTING_TRACE("Fail to set condition");
+               return total_size;
+       }
+
+       ret = media_info_foreach_media_from_db(filter, __setting_storage_main_media_item_cb, &total_size);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               SETTING_TRACE("Fail to get media");
+               return total_size;
+       }
+
+       ret = media_filter_destroy(filter);
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               SETTING_TRACE_ERROR("destroy filter failed\n\n");
+               return total_size;
+       }
 
        return total_size;
 }
@@ -389,7 +417,7 @@ static double __setting_storage_main_audio_status_get()
        filter_h filter = NULL;
 
        /*Set Filter*/
-       char *condition = "MEDIA_TYPE=3";       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
+       char *condition = "MEDIA_TYPE=3 and MEDIA_PATH LIKE \'/opt/media/%%\'"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
 
        ret = media_filter_create(&filter);
        if(ret != MEDIA_CONTENT_ERROR_NONE) {