summaryrefslogtreecommitdiff
path: root/wearable_src/Filesystem/IManager.h
blob: 48c55a7d812a3991db3d6ac786dc119f964f4b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//
// Tizen Web Device API
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

 
#ifndef TIZENAPIS_FILESYSTEM_IMANAGER_H_
#define TIZENAPIS_FILESYSTEM_IMANAGER_H_

#include <map>
#include <vector>
#include <string>
#include <cstddef>
#include <dpl/noncopyable.h>
#include <Commons/EventReceiver.h>
#include "EventResolve.h"
#include "EventGetStorage.h"
#include "EventListStorages.h"
#include "EventStorageStateChanged.h"
#include "EventCopy.h"
#include "EventMove.h"
#include "EventRemove.h"
#include "EventCreate.h"
#include "EventFind.h"
#include "Enums.h"
#include "INode.h"
#include "IPath.h"

namespace DeviceAPI {
namespace Filesystem {
typedef std::vector<IPathPtr> LocationPaths;

typedef std::vector<LocationType> LocationTypes;

typedef std::map<std::string, IPathPtr> StorageList;

class IManager : public WrtDeviceApis::Commons::EventRequestReceiver<EventResolve>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventGetStorage>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventListStorages>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventCopy>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventMove>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventCreate>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventRemove>,
    public WrtDeviceApis::Commons::EventRequestReceiver<EventFind>
{
  public:
    static IManager& getInstance();

    virtual ~IManager() = 0;

    /**
     * Gets base path.
     * @return Valid path or empty shared pointer.
     */
    virtual IPathPtr getBasePath() const = 0;

    virtual StorageList getStorageList() const = 0;

    /**
     * Gets path for specified location type.
     * @param type Location type @see WrtPlugins::Api::Filesystem::LocationType.
     * @return Valid path or empty shared pointer.
     */
    virtual IPathPtr getLocationPath(LocationType type) const = 0;

    /**
     * Gets paths to default locations.
     * @return Paths to predefined virtual locations.
     */
    virtual LocationPaths getLocationPaths() const = 0;

    /**
     * Gets locations supported by platform.
     * @return Supported locations.
     */
    virtual LocationTypes getLocations() const = 0;

    /**
     * Gets filesystem node.
     * @param event Get node event @see Api::Filesystem::EventGetNode.
     * @remarks Asynchronous.
     */
    virtual void getNode(const EventResolvePtr& event) = 0;

    /**
     * Gets maximum length of filesystem path.
     * @return Maximum path length.
     */
    virtual std::size_t getMaxPathLength() const = 0;

    /**
     * Copies node to specified destination.
     * @param event Copy node event @see Api::Filesystem::EventCopy.
     * @remarks Asynchronous.
     */
    virtual void copy(const EventCopyPtr& event) = 0;

    /**
     * Moves node to specified destination.
     * @param event Move node event @see Api::Filesystem::EventMove.
     * @remarks Asynchronous.
     */
    virtual void move(const EventMovePtr& event) = 0;

    /**
     * Creates a node.
     * @param event Create node event @see Api::Filesystem::EventCreate.
     * @remarks Asynchronous.
     */
    virtual void create(const EventCreatePtr& event) = 0;

    /**
     * Removes node.
     * @param event Remove node event @see Api::Filesystem::EventRemove.
     * @remarks Asynchronous.
     */
    virtual void remove(const EventRemovePtr& event) = 0;

    /**
     * Finds nodes.
     * @param event Find nodes event @see Api::Filesystem::EventFind.
     * @remarks Asynchronous.
     */
    virtual void find(const EventFindPtr& event) = 0;

    /**
     * Checks if node at specified path has supplied access rights.
     * @param path Path to the node.
     * @param accessType Access right(s) to check @see AccessType. Multiple values
     *                   can be passed using OR operator.
     * @return True if specified node has supplied access rights, false otherwise.
     */
//    virtual bool access(const IPathPtr& path,
//            int accessType) const = 0;

    virtual void addOpenedNode(const INodePtr& node) = 0;
    virtual void removeOpenedNode(const INodePtr& node) = 0;
    virtual bool checkIfOpened(const IPathPtr& path) const = 0;

    virtual void getStorage(const EventGetStoragePtr& event) = 0;
    virtual void listStorages(const EventListStoragesPtr& event) = 0;

    virtual long addStorageStateChangeListener(const EventStorageStateChangedEmitterPtr& emitter) = 0;
    virtual void removeStorageStateChangeListener(EventStorageStateChangedEmitter::IdType id) = 0;
	virtual void addWidgetStorage(const std::string &key, const std::string &value) = 0;

  protected:
    IManager();

    virtual void OnRequestReceived(const EventResolvePtr& event) = 0;
    virtual void OnRequestReceived(const EventGetStoragePtr& event) = 0;
    virtual void OnRequestReceived(const EventListStoragesPtr& event) = 0;
    virtual void OnRequestReceived(const EventCopyPtr& event) = 0;
    virtual void OnRequestReceived(const EventMovePtr& event) = 0;
    virtual void OnRequestReceived(const EventCreatePtr& event) = 0;
    virtual void OnRequestReceived(const EventRemovePtr& event) = 0;
    virtual void OnRequestReceived(const EventFindPtr& event) = 0;
}; // IManager
} // Filesystem
} // TizenApis

#endif // TIZENAPIS_FILESYSTEM_IMANAGER_H_