2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 * @file GlAlbumInfo.cpp
19 * @brief This is the implementation file for AlbumInfo class.
22 #include "GlAlbumInfo.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Content;
28 using namespace Tizen::Graphics;
30 AlbumInfo::AlbumInfo(void)
31 : __pDirectoryFullPathList(null)
32 , __pContentIdList(null)
33 , __pFolderThumnailBitmap(null)
37 AlbumInfo::~AlbumInfo(void)
39 if (__pDirectoryFullPathList != null)
41 delete __pDirectoryFullPathList;
44 if (__pContentIdList != null)
46 delete __pContentIdList;
49 if (__pFolderThumnailBitmap != null)
51 delete __pFolderThumnailBitmap;
56 AlbumInfo::GetAlbumName(void) const
59 if ((__albumName != null) && (__albumName.GetLength() > 0))
61 returnValue = __albumName;
68 AlbumInfo::SetAlbumName(const String& albumName)
70 if (&albumName == null)
72 __albumName = EMPTY_SPACE;
76 __albumName = String(albumName);
81 AlbumInfo::GetDirectory(int index) const
83 String fullDirPath = *(static_cast<String*>(__pDirectoryFullPathList->GetAt(index)));
88 AlbumInfo::GetDirectoryListN(void) const
90 if (__pDirectoryFullPathList == null)
95 IList* pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
97 IEnumerator* pEnum = __pDirectoryFullPathList->GetEnumeratorN();
99 while (pEnum->MoveNext() == E_SUCCESS)
101 pItem = new (std::nothrow) String((static_cast<String*>(pEnum->GetCurrent()))->GetPointer());
102 pDirectoryFullPathList->Add(pItem);
106 return pDirectoryFullPathList;
110 AlbumInfo::ClearDirectoryList(void)
112 if (__pDirectoryFullPathList != null)
114 delete __pDirectoryFullPathList;
117 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
121 AlbumInfo::AppendDirectory(const String& directoryPath)
123 if (&directoryPath == null || directoryPath == EMPTY_SPACE)
128 if (__pDirectoryFullPathList == null)
130 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
133 __pDirectoryFullPathList->Add(new (std::nothrow) String(directoryPath));
137 AlbumInfo::AppendDirectoryList(const ICollection& directoryList)
139 if (&directoryList == null || directoryList.GetCount() == 0)
143 if (__pDirectoryFullPathList == null)
145 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
147 IEnumerator* pEnum = directoryList.GetEnumeratorN();
148 String* pItem = null;
150 while (pEnum->MoveNext() == E_SUCCESS)
152 pItem = new (std::nothrow) String((static_cast<String*>(pEnum->GetCurrent()))->GetPointer());
153 __pDirectoryFullPathList->Add(pItem);
159 AlbumInfo::GetDirectoryCount(void) const
161 if (__pDirectoryFullPathList == null)
167 return __pDirectoryFullPathList->GetCount();
172 AlbumInfo::GetContentIdListN(void) const
174 if (__pContentIdList == null)
179 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
181 IEnumerator* pEnum = __pContentIdList->GetEnumeratorN();
183 while (pEnum->MoveNext() == E_SUCCESS)
185 pItem = new (std::nothrow) ContentId(*static_cast<ContentId*>(pEnum->GetCurrent()));
186 pContentIdList->Add(pItem);
190 return pContentIdList;
194 AlbumInfo::GetContentId(int index) const
196 ContentId contentId = *(static_cast<ContentId*>(__pContentIdList->GetAt(index)));
201 AlbumInfo::Construct(void)
203 __albumName = EMPTY_SPACE;
204 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
205 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
206 result r = E_SUCCESS;
207 if (GetLastResult() != E_SUCCESS || __pDirectoryFullPathList == null || __pContentIdList == null)
209 delete __pDirectoryFullPathList;
210 __pDirectoryFullPathList = null;
211 delete __pContentIdList;
212 __pContentIdList = null;
220 AlbumInfo::Construct(const String& albumName, ContentType contentType ,
221 const IList& directoryList, const IList& contentIdList)
223 if (&albumName == null)
225 __albumName = EMPTY_SPACE;
229 __albumName = albumName;
232 if (&directoryList == null)
234 ClearDirectoryList();
238 ClearDirectoryList();
239 AppendDirectoryList(directoryList);
242 if (&contentIdList == null)
244 ClearContentIdList();
248 AppendContentIdList(contentIdList);
255 AlbumInfo::Construct(const AlbumInfo& albumInfo)
257 if (&albumInfo == null)
259 __albumName = EMPTY_SPACE;
260 ClearDirectoryList();
261 ClearContentIdList();
264 __albumName = albumInfo.GetAlbumName();
266 ClearDirectoryList();
267 IList* pDirList = albumInfo.GetDirectoryListN();
268 AppendDirectoryList(*pDirList);
271 ClearContentIdList();
272 IList* pContentIdList = albumInfo.GetContentIdListN();
273 AppendContentIdList(*pContentIdList);
274 delete pContentIdList;
280 AlbumInfo::ClearContentIdList(void)
282 if (__pContentIdList != null)
284 delete __pContentIdList;
287 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
291 AlbumInfo::AppendContentId(const ContentId& contentId)
293 if (&contentId == null)
298 if (__pContentIdList == null)
300 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
302 ContentId* pItem = new (std::nothrow) ContentId(contentId);
303 __pContentIdList->Add(pItem);
307 AlbumInfo::AppendContentIdList(const ICollection& contentIdList)
309 if (&contentIdList == null || contentIdList.GetCount() == 0)
314 if (__pContentIdList == null)
316 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
319 IEnumerator* pEnum = contentIdList.GetEnumeratorN();
320 ContentId* pItem = null;
322 while (pEnum->MoveNext() == E_SUCCESS)
324 pItem = new (std::nothrow) ContentId(*(static_cast<ContentId*>(pEnum->GetCurrent())));
325 __pContentIdList->Add(pItem);
331 AlbumInfo::ClearAll(void)
333 if (__pDirectoryFullPathList != null)
335 delete __pDirectoryFullPathList;
336 __pDirectoryFullPathList = null;
339 if (__pContentIdList != null)
341 delete __pContentIdList;
342 __pContentIdList = null;
347 AlbumInfo::GetContentIdCount(void) const
349 if (__pContentIdList == null)
355 return __pContentIdList->GetCount();
360 AlbumInfo::RemoveContentIdAt(const int index)
362 result r = E_SUCCESS;
364 if (__pContentIdList != null)
366 r = __pContentIdList->RemoveAt(index, true);
373 AlbumInfo::SetFolderThumnailBitmap(Bitmap* pFolderThumnailBitmap)
375 __pFolderThumnailBitmap = pFolderThumnailBitmap;
379 AlbumInfo::GetFolderThumnailBitmap(void) const
381 return __pFolderThumnailBitmap;
385 AlbumInfo::GetAlbumInfoType(void) const
387 return ALBUM_INFO_TYPE_FOLDER;