[Release] wrt-plugins-common_0.3.74
[platform/framework/web/wrt-plugins-common.git] / src / modules / tizen / DEPRACATED / Gallery / Gallery.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_
17 #define WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_
18
19 #include <dpl/shared_ptr.h>
20 #include <string>
21 #include <map>
22 #include <platform/commons/EventReceiver.h>
23 #include <API/Gallery/IGallery.h>
24 #include <API/Gallery/IMediaItem.h>
25 #include <Filesystem/Path.h>
26 #include <Filesystem/Node.h>
27
28 namespace WrtPlugins {
29 namespace Platform {
30 class Gallery : public Api::Gallery::IGallery
31 {
32     /*
33      * Gallery name
34      */
35     std::string m_name;
36     /*
37      * Stores state of the gallery
38      */
39     bool m_opened;
40     /*
41      * Last ID field is used to give for an MediaItem unique ID
42      */
43     unsigned long m_lastId;
44     /*
45      * Set of all media items found on device
46      */
47     Api::Gallery::IMediaItemsSet m_mediaItems;
48     /*
49      * Set of media items selected by changeView method
50      */
51     Api::Gallery::IMediaItemsSetPtr m_view;
52     /*
53      * Properties to manage view of media items
54      */
55     Api::Gallery::IViewProperties m_viewProperties;
56
57     /*
58      * Map to convert from file extension to media type
59      */
60     static std::map<std::string,
61                     Api::Gallery::IMediaItem::MediaType>  &m_extensionToType;
62     /*
63      * Map to convert from file extension to MIME type
64      */
65     static std::map<std::string,
66                     std::string>  &m_extensionToMime;
67
68     /*
69      * Recurrent search files trough whole tree exposed by file manager
70      * \param node - node to start from
71      * \exception - Filesystem related
72      */
73     void searchFiles(const DPL::SharedPtr<Api::Filesystem::INode> &node);
74     /*
75      * Gets free ID
76      */
77     unsigned long getFreeId();
78
79   public:
80     /*
81      * Constructor of the gallery
82      * \param name - the gallery name
83      */
84     Gallery(const std::string &name) :
85         IGallery(),
86         m_name(name),
87         m_opened(false),
88         m_lastId(0)
89     {}
90     /*
91      * Destructor of the gallery
92      */
93     virtual ~Gallery()
94     {}
95
96     /*
97      * Gets number of media items selected by current view
98      * \exception Commons::PlatformWrongStateException when gallery not open
99      * \return number of media items
100      */
101     virtual unsigned int getNumberOfItems() const;
102     /*
103      * Gets name of the gallery
104      * \return name of the gallery
105      */
106     virtual std::string getName() const;
107     /*
108      * Opens the gallery
109      * \exception Commons::PlatformWrongStateException when gallery is already
110      * open
111      */
112     virtual void open();
113     /* Gets the current state of the gallery
114      * \return true if the gallery is open
115      */
116     virtual bool isOpen() const;
117     /*
118      * Closes the gallery
119      * \exception Commons::PlatformWrongStateException when gallery is not open
120      */
121     virtual void close();
122     /*
123      * Refreshes files in the gallery
124      * \exception Commons::PlatformWrongStateException when gallery is not open
125      */
126     virtual void refresh();
127     /*
128      * Changes current view with given properties
129      * \param props - view properties
130      * \exception Commons::PlatformWrongStateException when gallery is not open
131      */
132     virtual void changeView(const Api::Gallery::IViewProperties &props);
133     /*
134      * Gets media items selected by current view
135      * \return set of media items
136      * \exception Commons::PlatformWrongStateException when gallery is not open
137      */
138     virtual const Api::Gallery::IMediaItemsSetPtr getMediaItems() const;
139     /*
140      * Gets specified media item
141      * \param id of wanted item
142      * \return an media item
143      * \exception Commons::PlatformWrongStateException when gallery is not open
144      */
145     virtual const Api::Gallery::IMediaItemPtr getMediaItemById(unsigned long id)
146     const;
147 };
148 } // Platform
149 } // WrtPlugins
150
151 #endif // WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_