Update wrt-plugins-common_0.3.53
[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     /*
92      * Destructor of the gallery
93      */
94     virtual ~Gallery()
95     {
96     }
97
98     /*
99      * Gets number of media items selected by current view
100      * \exception Commons::PlatformWrongStateException when gallery not open
101      * \return number of media items
102      */
103     virtual unsigned int getNumberOfItems() const;
104     /*
105      * Gets name of the gallery
106      * \return name of the gallery
107      */
108     virtual std::string getName() const;
109     /*
110      * Opens the gallery
111      * \exception Commons::PlatformWrongStateException when gallery is already open
112      */
113     virtual void open();
114     /* Gets the current state of the gallery
115      * \return true if the gallery is open
116      */
117     virtual bool isOpen() const;
118     /*
119      * Closes the gallery
120      * \exception Commons::PlatformWrongStateException when gallery is not open
121      */
122     virtual void close();
123     /*
124      * Refreshes files in the gallery
125      * \exception Commons::PlatformWrongStateException when gallery is not open
126      */
127     virtual void refresh();
128     /*
129      * Changes current view with given properties
130      * \param props - view properties
131      * \exception Commons::PlatformWrongStateException when gallery is not open
132      */
133     virtual void changeView(const Api::Gallery::IViewProperties &props);
134     /*
135      * Gets media items selected by current view
136      * \return set of media items
137      * \exception Commons::PlatformWrongStateException when gallery is not open
138      */
139     virtual const Api::Gallery::IMediaItemsSetPtr getMediaItems() const;
140     /*
141      * Gets specified media item
142      * \param id of wanted item
143      * \return an media item
144      * \exception Commons::PlatformWrongStateException when gallery is not open
145      */
146     virtual const Api::Gallery::IMediaItemPtr getMediaItemById(unsigned long id)
147     const;
148 };
149 } // Platform
150 } // WrtPlugins
151
152 #endif // WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_