Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsFsDaemonClient.h
Go to the documentation of this file.
1 
13 //#ifdef HAS_DAEMON
14 #ifndef WS_FS_DAEMON_CLIENT_H__
15 #define WS_FS_DAEMON_CLIENT_H__
16 #include "WsAbstractFsClient.h"
17 #include <zmq.hpp>
18 #include <json/json.h>
19 #include <json/reader.h>
20 #include <json/writer.h>
21 #include <json/value.h>
24 
25 #include <boost/thread.hpp>
26 
27 
34 public:
39  WsFsDaemonClient(const std::string& id, const std::string& pass, const std::string& ip);
40 
45 
50  int clearServerCache();
51 
55  int load();
56 
60  int getPermissions(const std::string& p);
61 
65  const WsNodeProperties* getProperties(const std::string& p);
66 
70  std::string getProperty(const std::string& section, const std::string& p, const std::string& prop);
71 
75  const std::string& getSurname() const;
76 
80  const std::string& getFirstName() const;
81 
85  const std::string& getEmail() const;
86 
90  int getLock(const std::string& path);
91 
95  int putLock(const std::string& path);
96 
100  int isLocked(const std::string& path, std::string& uid);
101 
105  NodePtr getAccessRoot(const bool& forceUpdate = false);
106 
110  vector<WsResultItem> getSearchResults(const std::string& terms);
111 
115  std::set<string> getAllGroups();
116 
120  const std::string getRootPath();
121 
125  int saveProperties(WsNodeProperties* props, const std::string& path);
126 
130  int createNode(const string& path, int type);
131 
135  int deleteNode(const string& path);
136 
140  int renameNode(const string& path, const string& newPath);
141 
145  int saveProperty(const std::string& path, const std::string& section, const std::string& attr, const std::string& val);
146 
150  bool isEditor();
151 
155  bool isAdministrator();
156 
160  std::vector<std::string> getTemplatesList(const std::string& path);
161 
162 
163 private:
168  int authentify();
169 
175  int send(const std::string& message);
176 
182  int receive(std::string& receivedData);
183 
188  int receiveAuthAnswer();
189 
194  int receiveSuccessCode();
195 
201  int receivePermissions();
202 
207  bool receiveBoolean();
208 
213  int receiveInt();
214 
219  const std::string receiveString();
220 
227 
233  const std::string receiveProperty();
234 
240 
246  vector<WsResultItem> receiveSearchResults();
247 
248  int receiveIsLockedStatus(std::string uid);
249 
255  std::set<string> receiveAllGroups();
256 
262  std::string rawDataToString(zmq::message_t& msg);
263 
269  int parse(const std::string& s);
270 
275  int threadUpdate();
276 
277  std::string m_uid;
278  std::string m_pass;
279  std::string m_ip;
280  std::string m_email;
281  std::string m_name;
282  std::string m_surname;
283 
284  std::string m_host;
285  std::string m_port;
286  std::string m_proto;
288  Json::Reader m_reader;
290 
294  std::string m_accessTreeStamp;
295  std::string m_menuTreeStamp;
296  std::string m_rootPath;
299 
300  bool m_listen;
301  zmq::socket_t* m_sock;
304  static zmq::context_t* m_context;
305  boost::mutex* m_sendMutex;
306  boost::thread* m_updateThread;
307 
308 };
309 
310 #endif
311 //#endif
int authentify()
authenticate user. Sends an auth request to the daemon
const std::string receiveProperty()
receive a property after a getProperty request
int send(const std::string &message)
sends a string to the daemon
WsFsDaemonClient(const std::string &id, const std::string &pass, const std::string &ip)
constructor
std::set< string > getAllGroups()
boost::shared_ptr< WsAbstractNode > NodePtr
WsDecompressor * m_decompressor
std::string getProperty(const std::string &section, const std::string &p, const std::string &prop)
returns the properties of a node
NodePtr receiveAccessItems()
receive the access tree items after a getAccessRoot request
Global properties class.
boost::mutex * m_sendMutex
int receiveAuthAnswer()
receive the answer after performing an Auth request to the daemon
int receiveInt()
receive an int after a request that returns an int
int threadUpdate()
Launch the routine that will retrieve new AccessTree from fsdaemon This method should be called in a ...
static zmq::context_t * m_context
~WsFsDaemonClient()
destructor
int receiveSuccessCode()
receive the success code after a request that returns a SUCCESS or FAILURE answer only ...
WsCompressor * m_compressor
const WsNodeProperties * receiveProperties()
receive the properties after a getProperties request
int clearServerCache()
clears the server cache (removes the ldap results cached
int deleteNode(const string &path)
delete a node. The user must be an Admin on editor to remove the node In case of a WsDirNode...
Properties of a WsNode.
Used to compress data.
Definition: WsCompressor.h:24
const std::string receiveString()
receive a string after a request that returns a string
int receiveIsLockedStatus(std::string uid)
const std::string & getEmail() const
return the email of the person
std::string m_surname
std::set< string > receiveAllGroups()
receive all the groups after a getAllGroups() request
int createNode(const string &path, int type)
create a directory or File. If the node is a WsDirNode than it will be only accessible to the Admin a...
Used to decompress data.
int parse(const std::string &s)
parse the received Json from the fsdaemon
std::string m_rootPath
int putLock(const std::string &path)
int getLock(const std::string &path)
std::string rawDataToString(zmq::message_t &msg)
Converts raw data received to string. This method should be used each time data is received from netw...
const std::string & getFirstName() const
return the name of the person
int saveProperty(const std::string &path, const std::string &section, const std::string &attr, const std::string &val)
sets one property of the node and save it on disk.
int load()
loads the user info
int saveProperties(WsNodeProperties *props, const std::string &path)
save the properties of the node on disk. The user must have access and edit rights for the node...
boost::thread * m_updateThread
const std::string & getSurname() const
return the surname of the person
int receive(std::string &receivedData)
receive a string from the daemon.
WsGlobalProperties * m_conf
std::vector< std::string > getTemplatesList(const std::string &path)
std::string m_accessTreeStamp
vector< WsResultItem > getSearchResults(const std::string &terms)
search for all matching results of terms using WsSearch class
NodePtr getAccessRoot(const bool &forceUpdate=false)
return the root node of the access tree starting from the root
const std::string Value
Definition: WsRequestType.h:39
Interface between the User class and the fsdaemon.
const WsNodeProperties * getProperties(const std::string &p)
Abstract Interface between the WsUser class and the operation on the tree.
int receivePermissions()
receive the answer of a permission request
std::string m_menuTreeStamp
zmq::socket_t * m_sock
bool receiveBoolean()
receive a Boolean after a request that returns a boolean
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
int isLocked(const std::string &path, std::string &uid)
Json::Reader m_reader
int renameNode(const string &path, const string &newPath)
renames a node In case of a WsDirNode, all the contents of the directory and the directory will be mo...
vector< WsResultItem > receiveSearchResults()
receive the search results after a getSearchResults() request
int getPermissions(const std::string &p)
Load infos of the user.