ArnLib  4.0.x
Active Registry Network
ArnMonitor.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2022 Michael Wiklund.
2 // All rights reserved.
3 // Contact: arnlib@wiklunden.se
4 //
5 // This file is part of the ArnLib - Active Registry Network.
6 // Parts of ArnLib depend on Qt and/or other libraries that have their own
7 // licenses. Usage of these other libraries is subject to their respective
8 // license agreements.
9 //
10 // GNU Lesser General Public License Usage
11 // This file may be used under the terms of the GNU Lesser General Public
12 // License version 2.1 as published by the Free Software Foundation and
13 // appearing in the file LICENSE_LGPL.txt included in the packaging of this
14 // file. In addition, as a special exception, you may use the rights described
15 // in the Nokia Qt LGPL Exception version 1.1, included in the file
16 // LGPL_EXCEPTION.txt in this package.
17 //
18 // GNU General Public License Usage
19 // Alternatively, this file may be used under the terms of the GNU General Public
20 // License version 3.0 as published by the Free Software Foundation and appearing
21 // in the file LICENSE_GPL.txt included in the packaging of this file.
22 //
23 // Other Usage
24 // Alternatively, this file may be used in accordance with the terms and conditions
25 // contained in a signed written agreement between you and Michael Wiklund.
26 //
27 // This program is distributed in the hope that it will be useful, but WITHOUT ANY
28 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
29 // PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
30 //
31 
32 #ifndef ARNMONITOR_HPP
33 #define ARNMONITOR_HPP
34 
35 
36 #include "ArnLib_global.hpp"
37 #include "ArnInc/ArnItemB.hpp"
38 #include <QStringList>
39 #include <QObject>
40 #include <QPointer>
41 
42 class ArnMonitorPrivate;
43 class ArnClient;
44 
45 
47 
66 {
67  Q_OBJECT
68  Q_DECLARE_PRIVATE(ArnMonitor)
69 
70 public:
71  explicit ArnMonitor( QObject* parent = arnNullptr);
72 
74 
78  ArnMonitor( const QString& path, QObject* parent = arnNullptr);
79 
80  ~ArnMonitor();
81 
83 
85  void setClient( ArnClient* client);
86 
88 
90  void setClient( const QString& id);
91 
93 
96  QString clientId() const;
97 
99 
102  ArnClient* client() const;
103 
105 
113  void setMonitorPath( const QString& path, ArnClient* client = arnNullptr);
114 
116 
122  bool start( const QString& path, ArnClient* client);
123 
125 
130  bool start( const QString& path);
131 
133 
136  QString monitorPath() const;
137 
139 
142  void reStart();
143 
145 
151  void setReference( void* reference);
152 
154 
157  void* reference() const;
158 
159 signals:
161 
165  void monitorClosed();
166 
168 
173  void arnItemCreated( const QString& path);
174 
176 
188  void arnChildFound( const QString& path);
189 
191 
201  void arnChildFoundFolder( const QString& path);
202 
204 
213  void arnChildFoundLeaf( const QString& path);
214 
216 
221  void arnItemDeleted( const QString& path);
222 
224 
235  void arnChildDeleted( const QString& path);
236 
238 
243  void arnItemModeChanged( const QString& path, int mode);
244 
246 
255  void arnChildModeChanged( const QString& path, int mode);
256 
257 public slots:
259 
266  void foundChildDeleted( const QString& path);
267 
269 protected:
270  virtual QString outPathConvert( const QString& path);
271  virtual QString inPathConvert( const QString& path);
272 
273  virtual void customEvent( QEvent* ev);
274 
275  QString toLocalPath( const QString& remotePath) const;
276 
277  ArnMonitor( ArnMonitorPrivate& dd, QObject* parent);
278  ArnMonitorPrivate* const d_ptr;
280 
281 private slots:
282  void dispatchArnMonEvent( int type, const QByteArray& data, bool isLocal);
283  void sendArnMonEvent( int type, const QByteArray& data = QByteArray());
284  void setupLocalMonitorItem();
285 
286 private:
287  void init();
288  void doEventItemFoundCreated( int type, const QByteArray& data, bool isLocal);
289  void doEventItemDeleted( const QByteArray& data, bool isLocal);
290  void doEventItemModeChg( const QByteArray& data, bool isLocal);
291 };
292 
293 
294 #endif // ARNMONITOR_HPP
void setReference(void *reference)
Set an associated external reference.
void * reference() const
Get the stored external reference.
Class for connecting to an Arn Server.
Definition: ArnClient.hpp:104
Base class handle for an Arn Data Object.
Definition: ArnItemB.hpp:59
#define ARNLIBSHARED_EXPORT
A client remote monitor to detect changes at server.
Definition: ArnMonitor.hpp:65