2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <media_content.h>
24 #include "ExtNameInfo.h"
25 #include "DirectoryInfo.h"
28 struct SDirectoryInfo {
32 media_folder_h folder;
36 bool CDirectoryInfo::Create(CNameInfo::EClassType type)
40 m = new SDirectoryInfo;
43 if (!CExtNameInfo::Create(CLASS_TYPE_DIRECTORY)) {
53 void CDirectoryInfo::Destroy(void)
57 CExtNameInfo::Destroy();
64 bool CDirectoryInfo::SetCount(int nCount)
74 int CDirectoryInfo::Count(void)
82 bool CDirectoryInfo::Duplicate(CNameInfo *obj)
86 CDirectoryInfo *dst = (CDirectoryInfo*)obj;
88 if (!CExtNameInfo::Duplicate(obj))
91 if (!SetCount(dst->Count()))
98 static bool gFolderSize(media_info_h media_h, void *dt)
100 long long unsigned int size;
101 long long unsigned int *total_size;
106 total_size = (long long unsigned int *)dt;
108 if (media_info_get_size(media_h, &size) == MEDIA_CONTENT_ERROR_NONE)
109 *total_size = *total_size + size;
115 bool CDirectoryInfo::SetLoadInfo(filter_h filter, media_folder_h folder)
126 bool CDirectoryInfo::Load(void)
134 r = media_folder_get_name(m->folder, &str);
135 if (r != MEDIA_CONTENT_ERROR_NONE) {
136 _ERR("Media folder get name failed");
142 r = media_folder_get_path(m->folder, &str);
143 if (r != MEDIA_CONTENT_ERROR_NONE) {
144 _ERR("Media folder get path failed");
150 r = media_folder_get_folder_id(m->folder, &str);
151 if (r != MEDIA_CONTENT_ERROR_NONE) {
152 _ERR("Media folder get id failed");
159 r = media_folder_get_media_count_from_db(Id(), m->filter, &count);
160 if (r != MEDIA_CONTENT_ERROR_NONE) {
161 _ERR("Media folder get id failed");
166 SetType(E_GRP_FOLDER);
169 r = media_folder_get_modified_time(m->folder, &time);
170 if (r != MEDIA_CONTENT_ERROR_NONE) {
171 _ERR("Media folder get mod time failed");
174 SetModifiedTime(time);
177 r = media_folder_foreach_media_from_db(Id(), m->filter, gFolderSize, &size);
178 if (r != MEDIA_CONTENT_ERROR_NONE) {
179 _ERR("Media folder get size failed");