2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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.
17 * @file FCntPlayList.cpp
18 * @brief This is the implementation file for the %PlayList class.
20 * This is the implementation file for %PlayList class.
23 #include <FBaseSysLog.h>
24 #include <FCntPlayList.h>
25 #include <FBaseColIList.h>
27 #include <FSysEnvironment.h>
28 #include <FCnt_PlayListImpl.h>
30 using namespace Tizen::Io;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::System;
35 namespace Tizen { namespace Content
45 PlayList::~PlayList(void)
51 PlayList::Construct(const Tizen::Base::String& playListName)
55 SysAssertf(__pImpl == null,
56 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
58 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
60 _PlayListImpl* pPlayListImpl = new (std::nothrow) _PlayListImpl();
61 SysTryReturn(NID_CNT, pPlayListImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
63 r = pPlayListImpl->Construct(playListName);
64 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
66 __pImpl = pPlayListImpl;
68 __playListName = playListName;
78 PlayList::ConstructPlayList(const Tizen::Base::String& playListName)
82 SysAssertf(__pImpl == null,
83 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
85 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
87 _PlayListImpl* pPlayListImpl = new (std::nothrow) _PlayListImpl();
88 SysTryReturn(NID_CNT, pPlayListImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
90 r = pPlayListImpl->Construct(playListName, false);
91 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
93 __pImpl = pPlayListImpl;
95 __playListName = playListName;
100 delete pPlayListImpl;
105 PlayList::GetPlayListItemCount(void) const
108 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
110 return (__pImpl->GetPlayListItemCount(__playListName));
114 Tizen::Base::Collection::IList*
115 PlayList::GetContentInfoListN(void) const
118 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
120 return (__pImpl->GetContentInfoListN(__playListName));
124 PlayList::AddItem(const ContentId& contentId)
126 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
128 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
130 return (__pImpl->AddItem(__playListName, contentId));
134 PlayList::AddItems(const Tizen::Base::Collection::IList& contentIdList)
136 int listCount = contentIdList.GetCount();
137 ContentId *pContentId = NULL;
139 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
141 SysTryReturn(NID_CNT, listCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentIdList count is zero");
143 for (int index = 0; index < listCount; index++)
145 pContentId = (ContentId*)contentIdList.GetAt(index);
146 SysTryReturn(NID_CNT, *pContentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
149 return (__pImpl->AddItems(__playListName, contentIdList));
153 PlayList::RemoveItem(const ContentId& contentId)
155 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
157 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
159 return (__pImpl->RemoveItem(contentId));
163 PlayList::RemoveItems(const Tizen::Base::Collection::IList& contentIdList)
165 int listCount = contentIdList.GetCount();
166 ContentId *pContentId = NULL;
168 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
170 SysTryReturn(NID_CNT, listCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentIdList count is zero");
172 for (int index = 0; index < listCount; index++)
174 pContentId = (ContentId*)contentIdList.GetAt(index);
175 SysTryReturn(NID_CNT, *pContentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
178 return (__pImpl->RemoveItems(contentIdList));
182 PlayList::GetPlayListName(void) const
184 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
185 return __playListName;
189 PlayList::SetPlayListName(const Tizen::Base::String& playListName)
191 result r = E_SUCCESS;
193 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
195 SysTryReturn(NID_CNT, !playListName.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
197 r = __pImpl->SetPlayListName(__playListName, playListName); // impl need old and new name
198 SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] SetPlayListName failed. ", GetErrorMessage(r));
200 __playListName = playListName;
206 PlayList::GetPlayOrder(const ContentId& contentId) const
208 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
210 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
212 return (__pImpl->GetPlayOrder(contentId));