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.
20 #include <AppCommon.h>
22 #include "DirectoryInfo.h"
25 struct SDirectoryInfo {
29 media_folder_h folder;
33 bool CDirectoryInfo::Create(CNameInfo::EClassType type)
38 m = new SDirectoryInfo;
42 if (!CExtNameInfo::Create(CLASS_TYPE_DIRECTORY)) {
52 void CDirectoryInfo::Destroy(void)
57 CExtNameInfo::Destroy();
64 bool CDirectoryInfo::SetCount(int nCount)
75 int CDirectoryInfo::Count(void)
84 bool CDirectoryInfo::Duplicate(CNameInfo *obj)
89 CDirectoryInfo *dst = (CDirectoryInfo*)obj;
91 if (!CExtNameInfo::Duplicate(obj))
94 if (!SetCount(dst->Count()))
101 static bool gFolderSize(media_info_h media_h, void *dt)
103 long long unsigned int size;
104 long long unsigned int *total_size;
109 total_size = (long long unsigned int *)dt;
111 if (media_info_get_size(media_h, &size) == MEDIA_CONTENT_ERROR_NONE)
112 *total_size = *total_size + size;
118 bool CDirectoryInfo::SetLoadInfo(filter_h filter, media_folder_h folder)
130 bool CDirectoryInfo::Load(void)
139 r = media_folder_get_name(m->folder, &str);
140 if (r != MEDIA_CONTENT_ERROR_NONE) {
141 _ERR("Media folder get name failed");
147 r = media_folder_get_path(m->folder, &str);
148 if (r != MEDIA_CONTENT_ERROR_NONE) {
149 _ERR("Media folder get path failed");
155 r = media_folder_get_folder_id(m->folder, &str);
156 if (r != MEDIA_CONTENT_ERROR_NONE) {
157 _ERR("Media folder get id failed");
164 r = media_folder_get_media_count_from_db(Id(), m->filter, &count);
165 if (r != MEDIA_CONTENT_ERROR_NONE) {
166 _ERR("Media folder get id failed");
171 SetType(E_GRP_FOLDER);
174 r = media_folder_get_modified_time(m->folder, &time);
175 if (r != MEDIA_CONTENT_ERROR_NONE) {
176 _ERR("Media folder get mod time failed");
179 SetModifiedTime(time);
182 r = media_folder_foreach_media_from_db(Id(), m->filter, gFolderSize, &size);
183 if (r != MEDIA_CONTENT_ERROR_NONE) {
184 _ERR("Media folder get size failed");