2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FCntPlayList.cpp
19 * @brief This is the implementation file for the %PlayList class.
21 * This is the implementation file for %PlayList class.
24 #include <FBaseSysLog.h>
25 #include <FCntPlayList.h>
26 #include <FBaseColIList.h>
28 #include <FSysEnvironment.h>
29 #include <FCnt_PlayListImpl.h>
31 using namespace Tizen::Io;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::System;
36 namespace Tizen { namespace Content
46 PlayList::~PlayList(void)
52 PlayList::Construct(const Tizen::Base::String& playListName)
56 SysAssertf(__pImpl == null,
57 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
59 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
61 _PlayListImpl* pPlayListImpl = new (std::nothrow) _PlayListImpl();
62 SysTryReturn(NID_CNT, pPlayListImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
64 r = pPlayListImpl->Construct(playListName);
65 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
67 __pImpl = pPlayListImpl;
69 __playListName = playListName;
79 PlayList::ConstructPlayList(const Tizen::Base::String& playListName)
83 SysAssertf(__pImpl == null,
84 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
86 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
88 _PlayListImpl* pPlayListImpl = new (std::nothrow) _PlayListImpl();
89 SysTryReturn(NID_CNT, pPlayListImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
91 r = pPlayListImpl->Construct(playListName, false);
92 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
94 __pImpl = pPlayListImpl;
96 __playListName = playListName;
101 delete pPlayListImpl;
106 PlayList::GetPlayListItemCount(void) const
109 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
111 return (__pImpl->GetPlayListItemCount(__playListName));
115 Tizen::Base::Collection::IList*
116 PlayList::GetContentInfoListN(void) const
119 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
121 return (__pImpl->GetContentInfoListN(__playListName));
125 PlayList::AddItem(const ContentId& contentId)
127 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
129 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
131 return (__pImpl->AddItem(__playListName, contentId));
135 PlayList::AddItems(const Tizen::Base::Collection::IList& contentIdList)
137 int listCount = contentIdList.GetCount();
138 ContentId *pContentId = NULL;
140 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
142 SysTryReturn(NID_CNT, listCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentIdList count is zero");
144 for (int index = 0; index < listCount; index++)
146 pContentId = (ContentId*)contentIdList.GetAt(index);
147 SysTryReturn(NID_CNT, *pContentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
150 return (__pImpl->AddItems(__playListName, contentIdList));
154 PlayList::RemoveItem(const ContentId& contentId)
156 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
158 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
160 return (__pImpl->RemoveItem(contentId));
164 PlayList::RemoveItems(const Tizen::Base::Collection::IList& contentIdList)
166 int listCount = contentIdList.GetCount();
167 ContentId *pContentId = NULL;
169 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
171 SysTryReturn(NID_CNT, listCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentIdList count is zero");
173 for (int index = 0; index < listCount; index++)
175 pContentId = (ContentId*)contentIdList.GetAt(index);
176 SysTryReturn(NID_CNT, *pContentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
179 return (__pImpl->RemoveItems(contentIdList));
183 PlayList::GetPlayListName(void) const
185 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
186 return __playListName;
190 PlayList::SetPlayListName(const Tizen::Base::String& playListName)
192 result r = E_SUCCESS;
194 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
196 SysTryReturn(NID_CNT, !playListName.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
198 r = __pImpl->SetPlayListName(__playListName, playListName); // impl need old and new name
199 SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] SetPlayListName failed. ", GetErrorMessage(r));
201 __playListName = playListName;
207 PlayList::GetPlayOrder(const ContentId& contentId) const
209 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
211 SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
213 return (__pImpl->GetPlayOrder(contentId));