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