merge with master
[platform/framework/native/content.git] / src / inc / FCnt_PlayListImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18  * @file                FCnt_PlayListImpl.h
19  * @brief               This is the header file for the %_PlayListImpl class.
20  *
21  * This header file contains the declarations of the %_PlayListImpl class.
22  */
23
24 #ifndef _FCNT_INTERNAL_CONTENT_PLAYLIST_IMPL_H_
25 #define _FCNT_INTERNAL_CONTENT_PLAYLIST_IMPL_H_
26
27 #include <glib.h>
28 #include <unique_ptr.h>
29 #include <media_content.h>
30 #include <FBaseColAllElementsDeleter.h>
31
32 namespace Tizen { namespace Content
33 {
34
35 class PlayList;
36
37 struct PlayListHandleDeleter
38 {
39         void operator()(media_playlist_h playListHandle)
40         {
41                 media_playlist_destroy(playListHandle);
42                 playListHandle = NULL;
43         }
44 };
45
46 struct MediaHandleDeleter
47 {
48         void operator()(media_info_h mediaHandle)
49         {
50                 media_info_destroy(mediaHandle);
51                 mediaHandle = NULL;
52         }
53 };
54
55 struct GListDeleter
56 {
57         void operator()(GList* pGList)
58         {
59                 g_list_free(pGList);
60                 pGList = NULL;
61         }
62 };
63
64 struct FilterHandleDeleter
65 {
66         void operator()(filter_h* pFilterHandle)
67         {
68                 media_filter_destroy(*pFilterHandle);
69         }
70 };
71
72 class _PlayListImpl
73         : public Tizen::Base::Object
74 {
75 public:
76
77         /**
78          * This is the default constructor for this class.
79          *
80          * @since 2.1
81          */
82         _PlayListImpl(void);
83
84         /**
85          * This is the destructor for this class.
86          *
87          * @since 2.1
88          */
89         virtual ~_PlayListImpl(void);
90
91         result Construct(const Tizen::Base::String& playListName, bool isAdd = true);
92
93         int GetPlayListItemCount(const Tizen::Base::String& playlistName) const;
94
95         Tizen::Base::Collection::IList* GetContentInfoListN(const Tizen::Base::String& playlistName) const;
96
97         result AddItem(const Tizen::Base::String& playlistName, const ContentId& contentId);
98
99         result AddItems(const Tizen::Base::String& playlistName, const Tizen::Base::Collection::IList& contentIdList);
100
101         result RemoveItem(const ContentId& contentId);
102
103         result RemoveItems(const Tizen::Base::Collection::IList& contentIdList);
104
105         result SetPlayListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName);
106
107         result SetPlayOrder(const ContentId& contentId, const ContentId& nextContentId);
108
109         int GetPlayOrder(const ContentId& contentId) const;
110
111         static _PlayListImpl* GetInstance(PlayList& playList);
112
113         static const _PlayListImpl* GetInstance(const PlayList& playList);
114
115 private:
116         _PlayListImpl(const _PlayListImpl& rhs);
117         _PlayListImpl& operator =(const _PlayListImpl& rhs);
118
119         mutable std::unique_ptr<filter_h, FilterHandleDeleter> __pFilterHandle;
120
121         result CreateFilterUsingContentId(const ContentId& contentId) const;
122         result CreateFilter(const Tizen::Base::String& playListName) const;
123         result GetPlayListHandle(media_playlist_h* playListHandle) const;
124         result AddItemInternal(media_playlist_h playListHandle, const ContentId& contentId);
125         result SetorGetPlayOrder(const ContentId& contentId, int& playOrder, bool isSet) const;
126         result FillPlayListInfo(int playlistId, Tizen::Base::Collection::ArrayList* pPlayListItemList) const;
127         result MapCoreErrorToNativeResult(int reason) const;
128         result MapCoreDatabaseErrorToNativeResult(int reason) const;
129
130 };      // class _PlayListImpl
131
132 }}      // Tizen::Content
133
134 #endif  // _FCNT_INTERNAL_CONTENT_PLAYLIST_IMPL_H_