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 "category_info.h"
25 struct SCategoryInfo {
30 Eina_List *memberList;
33 memset(this, 0, sizeof(SCategoryInfo));
38 CCategoryInfo::CListMember *CCategoryInfo::m_MemberDuplicate(CListMember *member)
45 item = new CListMember;
49 item->memberId = member->memberId;
50 item->mediaId = t_Clone(member->mediaId);
56 bool CCategoryInfo::Create(void)
61 m = new SCategoryInfo();
63 _ERR("Mem allocation failed");
67 if (!CExtNameInfo::Create()) {
77 void CCategoryInfo::Destroy(void)
85 CExtNameInfo::Destroy();
87 eina_list_free(m->albumList);
89 EINA_LIST_FREE(m->memberList, obj) {
90 item = (CListMember*)obj;
101 int CCategoryInfo::CategoryId(void)
106 return m->categoryId;
110 int CCategoryInfo::AlbumCount(void)
115 return m->albumCount;
119 int CCategoryInfo::SongCount(void)
128 Eina_List *CCategoryInfo::AlbumList(void)
137 Eina_List *CCategoryInfo::MemberList(void)
142 return m->memberList;
146 bool CCategoryInfo::SetCategoryId(int categoryId)
151 m->categoryId = categoryId;
157 bool CCategoryInfo::SetAlbumCount(int albumCount)
162 m->albumCount = albumCount;
168 bool CCategoryInfo::SetSongCount(int songCount)
173 m->songCount = songCount;
179 bool CCategoryInfo::SetAlbumInfo(CAlbumInfo *albumInfo)
184 m->albumList = eina_list_append(m->albumList, albumInfo);
190 bool CCategoryInfo::SetMember(CListMember *member)
195 m->memberList = eina_list_append(m->memberList, member);
201 bool CCategoryInfo::Duplicate(CNameInfo *obj)
206 CCategoryInfo* dst = (CCategoryInfo*)obj;
208 if (!CExtNameInfo::Duplicate(obj))
211 if (!SetCategoryId(dst->CategoryId()))
213 if (!SetAlbumCount(dst->AlbumCount()))
215 if (!SetSongCount(dst->SongCount()))
218 m->albumList = eina_list_clone(dst->AlbumList());
220 CListMember *item, *dupItem;
223 EINA_LIST_FOREACH(dst->MemberList(), l, listObj) {
224 item = (CListMember *)listObj;
225 dupItem = m_MemberDuplicate(item);
228 if (!SetMember(dupItem))
236 CCategoryInfo *CCategoryInfo::FindCategory(Eina_List *list, const char *categoryName)
239 CCategoryInfo *catinfo;
242 if (!list || !categoryName)
245 EINA_LIST_FOREACH(list, l, obj) {
246 catinfo = (CCategoryInfo*)obj;
247 if (!strcmp(catinfo->Name(), categoryName))