|
QtPdCom
1.5.2
|
PdCom::Process implementation for Qt. More...
#include <Process.h>


Classes | |
| struct | Impl |
Public Types | |
| enum class | SslCaMode { NoTLS , DefaultCAs , CustomCAs , IgnoreCertificate } |
| enum | ConnectionState { Disconnected , Connecting , Connected , ConnectError , ConnectedError } |
| State of the process connection. More... | |
Signals | |
| void | processConnected () |
| Connection established. | |
| void | disconnected () |
| Disconnected gracefully. | |
| void | error () |
| Connection error. | |
| void | broadcastReceived (const QString &message, const QString &attr, std::uint64_t time_ns, const QString &user) |
| void | connectionStatusChanged () |
| void | sslCaModeChanged () |
Public Member Functions | |
| Process (QObject *parent=nullptr) | |
| Constructor. | |
| virtual | ~Process () |
| Destructor. | |
| void | setApplicationName (const QString &) |
| Sets the application name. | |
| QString | getApplicationName () const |
| Q_INVOKABLE void | connectToHost (const QString &, quint16=2345) |
| Starts to connect to a process. | |
| Q_INVOKABLE void | disconnectFromHost () |
| Disconnects from a process. | |
| Q_ENUM (ConnectionState) | |
| ConnectionState | getConnectionState () const |
| bool | isConnected () const |
| const QString & | getErrorString () const |
| QString | getPeerName () const |
| QUrl | getUrl () const |
| int | getPort () const |
| QString | getHost () const |
| Q_INVOKABLE void | sendBroadcast (const QString &, const QString &attr="text") |
| Send a broadcast message. | |
| Q_INVOKABLE quint64 | getRxBytes () const |
| Q_INVOKABLE quint64 | getTxBytes () const |
| QVariant | nameQt () const |
| Remote process name string. | |
| QVariant | versionQt () const |
| Remote process version string. | |
| QFuture< PdCom::Variable > | find (const QString &) |
| Find a Variable. | |
| QFuture< VariableList > | list (const QString &="") |
| Wrapper function for Process::list. | |
| QFuture< void > | pingQt () |
| QFuture< std::vector< PdCom::ClientStatistics > > | getClientStatisticsQt () |
| template<class Class, class Function> | |
| QFutureWatcher< PdCom::Variable > & | find (const QString &path, Class *obj, Function &&callback) |
| Also find a Variable. | |
| template<class Class, class Function> | |
| QFutureWatcher< VariableList > & | list (const QString &path, Class *obj, Function &&callback) |
| template<class Class, class Function> | |
| QFutureWatcher< void > & | ping (Class *obj, Function &&callback) |
| template<class Class, class Function> | |
| QFutureWatcher< std::vector< PdCom::ClientStatistics > > & | getClientStatistics (Class *obj, Function &&callback) |
| void | setCaMode (SslCaMode mode) |
| Set Traffic Encryption mode. | |
| SslCaMode | getCaMode () const |
| Get Traffic Encryption mode. | |
| void | setClientCertificate (const QSslCertificate &cert, const QSslKey &key) |
| Provide a client certificate. | |
| void | setCustomCAs (QList< QSslCertificate > cas) |
| Set list of trusted Certificate Authorities. | |
| PdCom::MessageManagerBase * | getMessageManager () const |
| void | setLoginManager (LoginManager *lm) |
| Set the Login Manager. | |
| LoginManager * | getLoginManager () const |
Static Public Member Functions | |
| static QtPdCom::Process * | getDefaultProcess () |
| static void | setDefaultProcess (QtPdCom::Process *) |
| Set default process "manually". | |
Properties | |
| bool | connected |
| The process is connected and ready. | |
| ConnectionState | connectionState |
| SslCaMode | sslCaMode |
| int | port |
| QString | host |
| QUrl | url |
| QString | applicationName |
| QtPdCom::LoginManager * | loginManager |
| QVariant | name |
| QVariant | version |
Private Slots | |
| void | socketConnected () |
| Socket connection established. | |
| void | socketDisconnected () |
| Socket disconnected. | |
| void | socketError () |
| There was a socket error. | |
| void | socketRead () |
| The socket has new data to read. | |
Private Member Functions | |
| std::string | applicationName () const override |
| Virtual from PdCom::Process. | |
| std::string | hostname () const override |
| int | read (char *, int) override |
| Read data from the socket. | |
| void | write (const char *, size_t) override |
| Sends data via the socket. | |
| void | flush () override |
| Flushed the socket. | |
| void | connected () override |
| void | broadcastReply (const std::string &message, const std::string &attr, std::chrono::nanoseconds time_ns, const std::string &user) override |
| Broadcast Reply. | |
| void | pingReply () override |
| Ping Reply. | |
| void | findReply (PdCom::Variable const &var) override |
| void | listReply (std::vector< PdCom::Variable > vars, std::vector< std::string > dirs) override |
| void | clientStatisticsReply (std::vector< PdCom::ClientStatistics > statistics) override |
| void | reset () |
| Resets the PdCom process. | |
| bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *method=0) |
| Disconnect method inherited from QObject. | |
Private Attributes | |
| struct Q_DECL_HIDDEN | Impl |
| std::unique_ptr< Impl > | impl |
PdCom::Process implementation for Qt.
|
strong |
| Process::Process | ( | QObject * | parent = nullptr | ) |
Constructor.
References impl, and Process().
Referenced by QtPdCom::Process::Impl::Impl(), and Process().
|
virtual |
Destructor.
References disconnectFromHost(), impl, and reset().
|
overrideprivate |
Virtual from PdCom::Process.
References impl.
|
signal |
Referenced by broadcastReply(), and QtPdCom::BroadcastModel::connectProcess().
|
overrideprivate |
|
overrideprivate |
References impl.
Referenced by connected().
|
overrideprivate |
References broadcastReply(), clientStatisticsReply(), findReply(), listReply(), pingReply(), and reset().
|
signal |
| void Process::connectToHost | ( | const QString & | address, |
| quint16 | port = 2345 ) |
|
private |
Disconnect method inherited from QObject.
This is made private, to avoid confusion.
| signal | Signal. |
| receiver | Receiver. |
| method | Method. |
|
signal |
Disconnected gracefully.
This is only emitted, after the user called disconnectFromHost().
Referenced by disconnectFromHost(), socketDisconnected(), and QtPdCom::PdVariable::updateConnection().
| void Process::disconnectFromHost | ( | ) |
Disconnects from a process.
References Connected, Connecting, Disconnected, disconnected(), impl, and reset().
Referenced by ~Process().
|
signal |
Connection error.
This is emitted after a connection error or when the connection was closed due to a parser error.
Referenced by socketDisconnected(), socketError(), socketRead(), QtPdCom::PdVariable::updateConnection(), and write().
| QFuture< PdCom::Variable > Process::find | ( | const QString & | path | ) |
Find a Variable.
Wrapper function for Process::findVariable.
Finding a variable is asynchronous in general. If you need to write to a variable, a variable object is needed. To write a variable with a single call you can use futures and a lambda function. See the example in the overloaded method find(const QString&, Class *, Function&&).
|
inline |
Also find a Variable.
Here, a FutureWatcher is created on your behalf. Callback can be one of
The obj reference is needed to use it as a parent for the watcher and to make the connections disconnect automatically when the Process or the object itself goes away.
Below is an example of how to make use of a lambda function to find a variable and write to it once it is found:
| path | Variable to find. |
| obj | QObject-derived class. |
| callback | Callback which receives the result. |
References QtPdCom::createWatcher(), and find().
|
overrideprivate |
References impl.
Referenced by connected().
|
overrideprivate |
Flushed the socket.
| QString Process::getApplicationName | ( | ) | const |
References impl.
| Process::SslCaMode Process::getCaMode | ( | ) | const |
|
inline |
References QtPdCom::createWatcher(), and getClientStatisticsQt().
Referenced by getClientStatisticsQt(), and Q_ENUM().
| QFuture< std::vector< PdCom::ClientStatistics > > QtPdCom::Process::getClientStatisticsQt | ( | ) |
References getClientStatistics(), and impl.
Referenced by getClientStatistics(), and Q_ENUM().
| Process::ConnectionState Process::getConnectionState | ( | ) | const |
|
static |
References QtPdCom::Process::Impl::defaultProcess.
Referenced by Q_ENUM().
| const QString & Process::getErrorString | ( | ) | const |
| QtPdCom::LoginManager * Process::getLoginManager | ( | ) | const |
References QtPdCom::LoginManagerPrivate::q_ptr.
Referenced by Q_ENUM().
| PdCom::MessageManagerBase * Process::getMessageManager | ( | ) | const |
| QString Process::getPeerName | ( | ) | const |
|
overrideprivate |
References hostname().
Referenced by hostname().
| bool Process::isConnected | ( | ) | const |
| QFuture< QtPdCom::VariableList > Process::list | ( | const QString & | path = "" | ) |
|
inline |
References QtPdCom::createWatcher(), and list().
|
overrideprivate |
References impl.
Referenced by connected().
| QVariant Process::nameQt | ( | ) | const |
|
inline |
References QtPdCom::createWatcher(), and pingQt().
Referenced by QtPdCom::QmlProcess::ping(), pingQt(), and Q_ENUM().
| QFuture< void > Process::pingQt | ( | ) |
|
overrideprivate |
|
signal |
Connection established.
This is emitted after the connection is established.
Referenced by QtPdCom::MessageModel::connect().
| QtPdCom::Process::Q_ENUM | ( | ConnectionState | ) |
References find(), getCaMode(), getClientStatistics(), getClientStatisticsQt(), getConnectionState(), getDefaultProcess(), getErrorString(), getHost(), getLoginManager(), getMessageManager(), getPeerName(), getPort(), getRxBytes(), getTxBytes(), getUrl(), isConnected(), list(), nameQt(), ping(), pingQt(), sendBroadcast(), setCaMode(), setClientCertificate(), setCustomCAs(), setDefaultProcess(), setLoginManager(), and versionQt().
|
overrideprivate |
Read data from the socket.
References ConnectedError, Disconnected, and impl.
|
private |
Resets the PdCom process.
Referenced by connected(), disconnectFromHost(), reset(), socketDisconnected(), socketError(), socketRead(), write(), and ~Process().
| void Process::sendBroadcast | ( | const QString & | msg, |
| const QString & | attr = "text" ) |
Send a broadcast message.
Referenced by Q_ENUM().
| void Process::setApplicationName | ( | const QString & | name | ) |
| void QtPdCom::Process::setCaMode | ( | SslCaMode | mode | ) |
Set Traffic Encryption mode.
See the SslCaMode enum for details.
| mode | Mode. |
References impl, NoTLS, and sslCaModeChanged().
Referenced by Q_ENUM().
| void QtPdCom::Process::setClientCertificate | ( | const QSslCertificate & | cert, |
| const QSslKey & | key ) |
| void QtPdCom::Process::setCustomCAs | ( | QList< QSslCertificate > | cas | ) |
Set list of trusted Certificate Authorities.
For SslCaMode::CustomCAs mode.
| cas | List of trusted CAs. |
References impl.
Referenced by Q_ENUM().
|
static |
Set default process "manually".
References QtPdCom::Process::Impl::defaultProcess.
Referenced by QtPdCom::DefaultProcess::createDefaultInstance(), and Q_ENUM().
| void QtPdCom::Process::setLoginManager | ( | LoginManager * | lm | ) |
Set the Login Manager.
| lm | The Login manager. May be NULL. |
References QtPdCom::LoginManager::d_ptr.
Referenced by Q_ENUM().
|
privateslot |
Socket connection established.
This is called, when the pure socket connection was established and the Process object can start using it.
References impl.
Referenced by sslCaModeChanged().
|
privateslot |
Socket disconnected.
The socket was closed and the process has to be told, that it is disconnected.
References Connected, ConnectError, Connecting, Disconnected, disconnected(), error(), impl, and reset().
Referenced by sslCaModeChanged().
|
privateslot |
There was a socket error.
The error could come up either while connecting the socket, or when the socket was already connected.
References Connected, ConnectedError, ConnectError, Connecting, error(), impl, and reset().
Referenced by sslCaModeChanged().
|
privateslot |
The socket has new data to read.
References Connected, ConnectedError, ConnectError, error(), impl, and reset().
Referenced by sslCaModeChanged().
|
signal |
References socketConnected(), socketDisconnected(), socketError(), and socketRead().
Referenced by setCaMode().
| QVariant Process::versionQt | ( | ) | const |
|
overrideprivate |
|
private |
|
private |
Referenced by applicationName(), clientStatisticsReply(), connectToHost(), disconnectFromHost(), find(), findReply(), getApplicationName(), getCaMode(), getClientStatisticsQt(), getConnectionState(), getErrorString(), getHost(), getMessageManager(), getPeerName(), getPort(), getRxBytes(), getTxBytes(), getUrl(), isConnected(), list(), listReply(), pingQt(), pingReply(), Process(), read(), reset(), setApplicationName(), setCaMode(), setClientCertificate(), setCustomCAs(), socketConnected(), socketDisconnected(), socketError(), socketRead(), write(), and ~Process().
|
readwrite |
|
read |
The process is connected and ready.
This virtual function from PdCom::Process has to be overloaded to let subclasses know about this event.
|
read |
|
read |
|
readwrite |
|
read |
Referenced by nameQt(), and setApplicationName().
|
read |
Referenced by connectToHost(), and QtPdCom::Process::Impl::connectToHost().
|
readwrite |
|
read |
|
read |
Referenced by versionQt().