22 #ifndef QTPDCOM_PROCESS_H 23 #define QTPDCOM_PROCESS_H 28 #include <QSslCertificate> 32 #include <pdcom5/ClientStatistics.h> 33 #include <pdcom5/Process.h> 36 #ifndef PDCOM_VERSION_CODE 37 # error "No PDCOM_VERSION_CODE found." 40 && (PDCOM_VERSION_CODE < PDCOM_VERSION(5, 0, 0) \ 41 || PDCOM_VERSION_CODE >= PDCOM_VERSION(6, 0, 0)) 42 # error "Invalid PdCom version." 54 #ifdef QTPDCOM_HAS_LOGIN_MANAGER 71 public QObject,
public PdCom::Process
74 Q_PROPERTY(
bool connected READ isConnected NOTIFY connectionStatusChanged)
75 Q_PROPERTY(
ConnectionState connectionState READ getConnectionState NOTIFY connectionStatusChanged)
76 Q_PROPERTY(
SslCaMode sslCaMode READ getCaMode WRITE setCaMode NOTIFY sslCaModeChanged)
77 Q_PROPERTY(
int port READ getPort NOTIFY connectionStatusChanged)
78 Q_PROPERTY(QString host READ getHost NOTIFY connectionStatusChanged)
79 Q_PROPERTY(QUrl url READ getUrl NOTIFY connectionStatusChanged)
80 Q_PROPERTY(QString applicationName READ getApplicationName WRITE setApplicationName)
92 Process(QObject *parent =
nullptr);
95 void setApplicationName(
const QString &);
96 QString getApplicationName()
const;
97 Q_INVOKABLE
void connectToHost(
const QString &, quint16 = 2345);
98 Q_INVOKABLE
void disconnectFromHost();
110 Q_ENUM(ConnectionState);
112 ConnectionState getConnectionState()
const;
113 bool isConnected()
const;
114 const QString &getErrorString()
const;
115 QString getPeerName()
const;
118 QString getHost()
const;
120 Q_INVOKABLE
void sendBroadcast(
const QString &,
const QString &attr =
"text");
121 quint64 getRxBytes()
const;
122 quint64 getTxBytes()
const;
134 QFuture<PdCom::Variable> find(
const QString&);
135 QFuture<VariableList> list(
const QString& =
"");
136 QFuture<void> pingQt();
137 QFuture<std::vector<PdCom::ClientStatistics>> getClientStatisticsQt();
175 template<
class Class,
class Function>
176 QFutureWatcher<PdCom::Variable>& find(
const QString& path, Class *obj, Function&& callback);
177 template<
class Class,
class Function>
178 QFutureWatcher<VariableList>& list(
const QString& path, Class *obj, Function&& callback);
179 template<
class Class,
class Function>
180 QFutureWatcher<void>& ping(Class *obj, Function&& callback);
181 template<
class Class,
class Function>
182 QFutureWatcher<std::vector<PdCom::ClientStatistics>>&
183 getClientStatistics(Class *obj, Function&& callback);
192 void setCaMode(SslCaMode mode);
198 SslCaMode getCaMode()
const;
206 void setClientCertificate(
const QSslCertificate& cert,
const QSslKey& key);
214 void setCustomCAs(QList<QSslCertificate> cas);
219 PdCom::MessageManagerBase *getMessageManager()
const;
232 std::string applicationName()
const override;
233 std::string hostname()
const override;
234 int read(
char *,
int)
override;
235 void write(
const char *,
size_t)
override;
236 void flush()
override;
237 void connected()
override;
239 const std::string &message,
240 const std::string &attr,
241 std::chrono::nanoseconds time_ns,
242 const std::string &user)
override;
243 void pingReply()
override;
244 void findReply(PdCom::Variable
const& var)
override;
245 void listReply(std::vector<PdCom::Variable> vars, std::vector<std::string> dirs)
override;
246 void clientStatisticsReply(std::vector<PdCom::ClientStatistics> statistics)
override;
254 const char *signal = 0,
255 const QObject *receiver = 0,
256 const char *method = 0
260 using PdCom::Process::setMessageManager;
267 void processConnected();
282 void broadcastReceived(
283 const QString &message,
285 std::uint64_t time_ns,
286 const QString &user);
288 void connectionStatusChanged();
290 void sslCaModeChanged();
294 void socketConnected();
295 void socketDisconnected();
302 template<
class Class,
class Function>
304 const QString& path, Class *obj, Function&& callback)
306 auto& ans = createWatcher<PdCom::Variable>(obj, callback);
307 ans.setFuture(
find(path));
313 template<
class Class,
class Function>
314 inline QFutureWatcher<VariableList>&
Process::list(
const QString& path, Class *obj, Function&& callback)
316 auto& ans = createWatcher<VariableList>(obj, callback);
317 ans.setFuture(
list(path));
323 template<
class Class,
class Function>
326 auto& ans = createWatcher<void>(obj, callback);
333 template<
class Class,
class Function>
334 inline QFutureWatcher<std::vector<PdCom::ClientStatistics>>&
337 auto& ans = createWatcher<std::vector<PdCom::ClientStatistics>>(
348 #endif // QTPDCOM_PROCESS_H Definition: Process.cpp:74
Process connection established.
Definition: Process.h:105
Currently connecting.
Definition: Process.h:104
PdCom::Process implementation for Qt.
Definition: Process.h:70
An error happened while connecting.
Definition: Process.h:106
QFutureWatcher< std::vector< PdCom::ClientStatistics > > & getClientStatistics(Class *obj, Function &&callback)
Definition: Process.h:335
Definition: BroadcastModel.h:32
ConnectionState
State of the process connection.
Definition: Process.h:102
Q_DECLARE_OPAQUE_POINTER(QtPdCom::LoginManager *)
QFuture< VariableList > list(const QString &="")
Wrapper function for Process::list.
Definition: Process.cpp:328
QFuture< std::vector< PdCom::ClientStatistics > > getClientStatisticsQt()
Definition: Process.cpp:343
#define QTPDCOM_PUBLIC
Definition: Export.h:30
QFuture< void > pingQt()
Definition: Process.cpp:584
Definition: LoginManager.h:36
Process disconnected.
Definition: Process.h:103
std::unique_ptr< Impl > impl
Definition: Process.h:229
QFutureWatcher< void > & ping(Class *obj, Function &&callback)
Definition: Process.h:324
QFuture< PdCom::Variable > find(const QString &)
Find a Variable.
Definition: Process.cpp:310
SslCaMode
Definition: Process.h:84