2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_
17 #define WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_
19 #include <dpl/shared_ptr.h>
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>
28 namespace WrtPlugins {
30 class Gallery : public Api::Gallery::IGallery
37 * Stores state of the gallery
41 * Last ID field is used to give for an MediaItem unique ID
43 unsigned long m_lastId;
45 * Set of all media items found on device
47 Api::Gallery::IMediaItemsSet m_mediaItems;
49 * Set of media items selected by changeView method
51 Api::Gallery::IMediaItemsSetPtr m_view;
53 * Properties to manage view of media items
55 Api::Gallery::IViewProperties m_viewProperties;
58 * Map to convert from file extension to media type
60 static std::map<std::string,
61 Api::Gallery::IMediaItem::MediaType> &m_extensionToType;
63 * Map to convert from file extension to MIME type
65 static std::map<std::string,
66 std::string> &m_extensionToMime;
69 * Recurrent search files trough whole tree exposed by file manager
70 * \param node - node to start from
71 * \exception - Filesystem related
73 void searchFiles(const DPL::SharedPtr<Api::Filesystem::INode> &node);
77 unsigned long getFreeId();
81 * Constructor of the gallery
82 * \param name - the gallery name
84 Gallery(const std::string &name) :
91 * Destructor of the gallery
97 * Gets number of media items selected by current view
98 * \exception Commons::PlatformWrongStateException when gallery not open
99 * \return number of media items
101 virtual unsigned int getNumberOfItems() const;
103 * Gets name of the gallery
104 * \return name of the gallery
106 virtual std::string getName() const;
109 * \exception Commons::PlatformWrongStateException when gallery is already
113 /* Gets the current state of the gallery
114 * \return true if the gallery is open
116 virtual bool isOpen() const;
119 * \exception Commons::PlatformWrongStateException when gallery is not open
121 virtual void close();
123 * Refreshes files in the gallery
124 * \exception Commons::PlatformWrongStateException when gallery is not open
126 virtual void refresh();
128 * Changes current view with given properties
129 * \param props - view properties
130 * \exception Commons::PlatformWrongStateException when gallery is not open
132 virtual void changeView(const Api::Gallery::IViewProperties &props);
134 * Gets media items selected by current view
135 * \return set of media items
136 * \exception Commons::PlatformWrongStateException when gallery is not open
138 virtual const Api::Gallery::IMediaItemsSetPtr getMediaItems() const;
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
145 virtual const Api::Gallery::IMediaItemPtr getMediaItemById(unsigned long id)
151 #endif // WRTDEVICEAPIS_PLATFORM_GALLERY_GALLERY_H_