2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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 StWallpaperAlbumInfo.cpp
19 * @brief This is the implementation file for WallpaperAlbumInfo class.
22 #include "StWallpaperAlbumInfo.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Content;
29 static const int FORMAT_BUFFER_SIZE = 256;
30 static const wchar_t* EMPTY_SPACE = L"";
32 AlbumInfo::AlbumInfo(void)
33 : __albumName(EMPTY_SPACE)
34 , __pDirectoryFullPathList(null)
35 , __pContentIdList(null)
39 AlbumInfo::~AlbumInfo(void)
41 if (__pDirectoryFullPathList != null)
43 delete __pDirectoryFullPathList;
46 if (__pContentIdList != null)
48 delete __pContentIdList;
53 AlbumInfo::GetAlbumName(void) const
56 if ((__albumName != null) && (__albumName.GetLength() > 0))
58 returnValue = __albumName;
65 AlbumInfo::SetAlbumName(const String& albumName)
67 if (&albumName == null)
69 __albumName = EMPTY_SPACE;
73 __albumName = String(albumName);
78 AlbumInfo::GetDirectory(int index) const
80 String fullDirPath = *(static_cast<String*>(__pDirectoryFullPathList->GetAt(index)));
85 AlbumInfo::GetDirectoryListN(void) const
87 if (__pDirectoryFullPathList == null)
92 IList* pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
94 IEnumerator* pEnum = __pDirectoryFullPathList->GetEnumeratorN();
96 while (pEnum->MoveNext() == E_SUCCESS)
98 pItem = new (std::nothrow) String((static_cast<String*>(pEnum->GetCurrent()))->GetPointer());
99 pDirectoryFullPathList->Add(pItem);
104 return pDirectoryFullPathList;
108 AlbumInfo::ClearDirectoryList(void)
110 if (__pDirectoryFullPathList != null)
112 delete __pDirectoryFullPathList;
114 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
118 AlbumInfo::AppendDirectory(const String& directoryPath)
120 if (&directoryPath == null || directoryPath == EMPTY_SPACE)
125 if (__pDirectoryFullPathList == null)
127 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
130 __pDirectoryFullPathList->Add(new (std::nothrow) String(directoryPath));
134 AlbumInfo::AppendDirectoryList(const ICollection& directoryList)
136 if (&directoryList == null || directoryList.GetCount() == 0)
140 if (__pDirectoryFullPathList == null)
142 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
144 IEnumerator* pEnum = directoryList.GetEnumeratorN();
145 String* pItem = null;
147 while (pEnum->MoveNext() == E_SUCCESS)
149 pItem = new (std::nothrow) String((static_cast<String*>(pEnum->GetCurrent()))->GetPointer());
150 __pDirectoryFullPathList->Add(pItem);
157 AlbumInfo::GetDirectoryCount(void) const
159 if (__pDirectoryFullPathList == null)
165 return __pDirectoryFullPathList->GetCount();
170 AlbumInfo::GetContentIdListN(void) const
172 if (__pContentIdList == null)
177 IList* pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
179 IEnumerator* pEnum = __pContentIdList->GetEnumeratorN();
181 while (pEnum->MoveNext() == E_SUCCESS)
183 pItem = new (std::nothrow) ContentId(*static_cast<ContentId*>(pEnum->GetCurrent()));
184 pContentIdList->Add(pItem);
189 return pContentIdList;
193 AlbumInfo::GetContentId(int index) const
195 ContentId contentId = *(static_cast<ContentId*>(__pContentIdList->GetAt(index)));
200 AlbumInfo::Construct(void)
202 __albumName = EMPTY_SPACE;
203 __pDirectoryFullPathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
204 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
205 result r = E_SUCCESS;
206 if (__pDirectoryFullPathList != null && __pContentIdList != null)
212 delete __pDirectoryFullPathList;
213 delete __pContentIdList;
221 AlbumInfo::Construct(const String& albumName, ContentType contentType ,
222 const IList& directoryList, const IList& contentIdList)
224 if (&albumName == null)
226 __albumName = EMPTY_SPACE;
230 __albumName = albumName;
233 if (&directoryList == null)
235 ClearDirectoryList();
239 ClearDirectoryList();
240 AppendDirectoryList(directoryList);
243 if (&contentIdList == null)
245 ClearContentIdList();
249 AppendContentIdList(contentIdList);
256 AlbumInfo::Construct(const AlbumInfo& albumInfo)
258 if (&albumInfo == null)
260 __albumName = EMPTY_SPACE;
261 ClearDirectoryList();
262 ClearContentIdList();
265 __albumName = albumInfo.GetAlbumName();
267 ClearDirectoryList();
268 IList* pDirList = albumInfo.GetDirectoryListN();
269 AppendDirectoryList(*pDirList);
272 ClearContentIdList();
273 IList* pContentIdList = albumInfo.GetContentIdListN();
274 AppendContentIdList(*pContentIdList);
275 delete pContentIdList;
281 AlbumInfo::ClearContentIdList(void)
283 if (__pContentIdList != null)
285 delete __pContentIdList;
288 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
292 AlbumInfo::AppendContentIdList(const ICollection& contentIdList)
294 if (&contentIdList == null || contentIdList.GetCount() == 0)
299 if (__pContentIdList == null)
301 __pContentIdList = new (std::nothrow) ArrayList(SingleObjectDeleter);
304 IEnumerator* pEnum = contentIdList.GetEnumeratorN();
305 ContentId* pItem = null;
307 while (pEnum->MoveNext() == E_SUCCESS)
309 pItem = new (std::nothrow) ContentId(*(static_cast<ContentId*>(pEnum->GetCurrent())));
310 __pContentIdList->Add(pItem);
317 AlbumInfo::GetContentIdCount(void) const
319 if (__pContentIdList == null)
325 return __pContentIdList->GetCount();
330 AlbumInfo::GetCreateDateString(void) const
332 return __createFileDateString;
336 AlbumInfo::SetCreateDateString(String& strMinimumDate, String& strMaximumDate)
340 if (strMinimumDate == strMaximumDate)
342 resultTime.Format(FORMAT_BUFFER_SIZE, L"%ls", strMaximumDate.GetPointer());
346 resultTime.Format(FORMAT_BUFFER_SIZE, L"%ls - %ls", strMinimumDate.GetPointer(),
347 strMaximumDate.GetPointer());
350 __createFileDateString = resultTime;