dbd5396bc2d9b4e654b55e76926a2573a8d4515c
[framework/web/wrt-plugins-common.git] / src / modules / API / Filesystem / IManager.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_FILESYSTEM_IMANAGER_H_
17 #define WRTDEVICEAPIS_FILESYSTEM_IMANAGER_H_
18
19 #include <vector>
20 #include <string>
21 #include <cstddef>
22 #include <dpl/noncopyable.h>
23 #include <Commons/EventReceiver.h>
24 #include <Filesystem/EventResolve.h>
25 #include <Filesystem/EventCopy.h>
26 #include <Filesystem/EventMove.h>
27 #include <Filesystem/EventRemove.h>
28 #include <Filesystem/EventFind.h>
29 #include <Filesystem/Enums.h>
30 #include <Filesystem/INode.h>
31 #include <Filesystem/IPath.h>
32
33 namespace WrtDeviceApis {
34 namespace Filesystem {
35 namespace Api {
36
37 typedef std::vector<IPathPtr> LocationPaths;
38 typedef std::vector<LocationType> LocationTypes;
39
40 class IManager :
41     public Commons::EventRequestReceiver<EventResolve>,
42     public Commons::EventRequestReceiver<EventCopy>,
43     public Commons::EventRequestReceiver<EventMove>,
44     public Commons::EventRequestReceiver<EventRemove>,
45     public Commons::EventRequestReceiver<EventFind>
46 {
47   public:
48     static IManager& getInstance();
49
50     virtual ~IManager() = 0;
51
52     /**
53      * Gets base path.
54      * @return Valid path or empty shared pointer.
55      */
56     virtual IPathPtr getBasePath() const = 0;
57
58     /**
59      * Gets path for specified location type.
60      * @param type Location type @see WrtDeviceApis::Api::Filesystem::LocationType.
61      * @return Valid path or empty shared pointer.
62      */
63     virtual IPathPtr getLocationPath(LocationType type) const = 0;
64
65     /**
66      * Gets paths to default locations.
67      * @return Paths to predefined virtual locations.
68      */
69     virtual LocationPaths getLocationPaths() const = 0;
70
71     /**
72      * Gets locations supported by platform.
73      * @return Supported locations.
74      */
75     virtual LocationTypes getLocations() const = 0;
76
77     /**
78      * Gets filesystem node.
79      * @param event Get node event @see Api::Filesystem::EventGetNode.
80      * @remarks Asynchronous.
81      */
82     virtual void getNode(const EventResolvePtr& event) = 0;
83
84     /**
85      * Gets maximum length of filesystem path.
86      * @return Maximum path length.
87      */
88     virtual std::size_t getMaxPathLength() const = 0;
89
90     /**
91      * Copies node to specified destination.
92      * @param event Copy node event @see Api::Filesystem::EventCopy.
93      * @remarks Asynchronous.
94      */
95     virtual void copy(const EventCopyPtr& event) = 0;
96
97     /**
98      * Moves node to specified destination.
99      * @param event Move node event @see Api::Filesystem::EventMove.
100      * @remarks Asynchronous.
101      */
102     virtual void move(const EventMovePtr& event) = 0;
103
104     /**
105      * Removes node.
106      * @param event Remove node event @see Api::Filesystem::EventRemove.
107      * @remarks Asynchronous.
108      */
109     virtual void remove(const EventRemovePtr& event) = 0;
110
111     /**
112      * Finds nodes.
113      * @param event Find nodes event @see Api::Filesystem::EventFind.
114      * @remarks Asynchronous.
115      */
116     virtual void find(const EventFindPtr& event) = 0;
117
118     /**
119      * Checks if node at specified path has supplied access rights.
120      * @param path Path to the node.
121      * @param accessType Access right(s) to check @see AccessType. Multiple values
122      *                   can be passed using OR operator.
123      * @return True if specified node has supplied access rights, false otherwise.
124      */
125     virtual bool access(const IPathPtr& path,
126             int accessType) const = 0;
127
128     virtual void addOpenedNode(const INodePtr& node) = 0;
129     virtual void removeOpenedNode(const INodePtr& node) = 0;
130     virtual bool checkIfOpened(const IPathPtr& path) const = 0;
131
132   protected:
133     IManager();
134
135     virtual void OnRequestReceived(const EventResolvePtr& event) = 0;
136     virtual void OnRequestReceived(const EventCopyPtr& event) = 0;
137     virtual void OnRequestReceived(const EventMovePtr& event) = 0;
138     virtual void OnRequestReceived(const EventRemovePtr& event) = 0;
139     virtual void OnRequestReceived(const EventFindPtr& event) = 0;
140 }; // IManager
141
142 } // API
143 } // Filesystem
144 } // WrtDeviceApis
145
146 #endif // WRTDEVICEAPIS_FILESYSTEM_IMANAGER_H_