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)
41 m = new SDirectoryInfo;
45 if (!CExtNameInfo::Create(CLASS_TYPE_DIRECTORY)) {
55 void CDirectoryInfo::Destroy(void)
60 CExtNameInfo::Destroy();
67 bool CDirectoryInfo::SetCount(int nCount)
78 int CDirectoryInfo::Count(void)
87 bool CDirectoryInfo::Duplicate(CNameInfo *obj)
92 CDirectoryInfo *dst = (CDirectoryInfo*)obj;
94 if (!CExtNameInfo::Duplicate(obj))
97 if (!SetCount(dst->Count()))
104 static bool gFolderSize(media_info_h media_h, void *dt)
106 long long unsigned int size;
107 long long unsigned int *total_size;
112 total_size = (long long unsigned int *)dt;
114 if (media_info_get_size(media_h, &size) == MEDIA_CONTENT_ERROR_NONE)
115 *total_size = *total_size + size;
121 bool CDirectoryInfo::SetLoadInfo(filter_h filter, media_folder_h folder)
133 bool CDirectoryInfo::Load(void)
142 r = media_folder_get_name(m->folder, &str);
143 if (r != MEDIA_CONTENT_ERROR_NONE) {
144 _ERR("Media folder get name failed");
150 r = media_folder_get_path(m->folder, &str);
151 if (r != MEDIA_CONTENT_ERROR_NONE) {
152 _ERR("Media folder get path failed");
158 r = media_folder_get_folder_id(m->folder, &str);
159 if (r != MEDIA_CONTENT_ERROR_NONE) {
160 _ERR("Media folder get id failed");
167 r = media_folder_get_media_count_from_db(Id(), m->filter, &count);
168 if (r != MEDIA_CONTENT_ERROR_NONE) {
169 _ERR("Media folder get id failed");
174 SetType(E_GRP_FOLDER);
177 r = media_folder_get_modified_time(m->folder, &time);
178 if (r != MEDIA_CONTENT_ERROR_NONE) {
179 _ERR("Media folder get mod time failed");
182 SetModifieidTime(time);
185 r = media_folder_foreach_media_from_db(Id(), m->filter, gFolderSize, &size);
186 if (r != MEDIA_CONTENT_ERROR_NONE) {
187 _ERR("Media folder get size failed");