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