5#include "qi-qmp/qmpi_export.h"
14#include <QJsonDocument>
24 enum State { Disconnected, Connecting, AwaitingWelcome, Negotiating, Idle, Closing, SendingCommand,
AwaitingMessage, ReadingMessage };
25 enum CommunicationError { WriteFailed, ReadFailed, TransactionTimeout, UnexpectedReceive, UnexpectedResponse };
39 std::variant<QHostAddress, QString> mHostId;
static_assert(std::variant_size_v<
decltype(mHostId)> == 2);
45 std::queue<ExecutionTask> mExecutionQueue;
63 void changeState(State newState);
64 bool startTransactionTimer();
65 bool stopTransactionTimer();
67 void raiseCommunicationError(CommunicationError error);
71 void negotiateCapabilities();
79 bool processGreetingMessage(
const QJsonObject& jGreeting);
80 bool processSuccessMessage(
const QJsonObject& jSuccess);
81 bool processErrorMessage(
const QJsonObject& jError);
82 bool processEventMessage(
const QJsonObject& jEvent);
92 int transactionTimeout()
const;
95 void setHostname(
const QString hostname);
96 void setPort(quint16 port);
97 void setTransactionTimeout(
int timeout = 30000);
100 void connectToHost();
101 void disconnectFromHost();
103 bool isConnectionActive()
const;
104 bool isConnected()
const;
112 void handleReceivedData();
113 void handleTransactionTimeout();
The Qmpi class is an interface through which to communicate with a QEMU instance via the QEMU Machine...
Definition: qmpi.h:20
void stateChanged(Qmpi::State state)
State
Definition: qmpi.h:24
@ AwaitingMessage
Definition: qmpi.h:24
CommunicationError
Definition: qmpi.h:25
void eventReceived(QString name, QJsonObject data, QDateTime timestamp)
void connected(QJsonObject version, QJsonArray capabilities)
void commandQueueExhausted()
void communicationErrorOccurred(Qmpi::CommunicationError error)
void errorResponseReceived(QString errorClass, QString description, std::any context)
void connectionErrorOccurred(QAbstractSocket::SocketError error)
void responseReceived(QJsonValue value, std::any context)
QTextStream & reset(QTextStream &stream)