mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
Implement a working Distant Chat prototype in Qml
Deprecate id field in JSON API as it may cause problems in Qml Offer gxs_id field in JSON API as an id alternative LibresapiLocalClient support callbacks now an instance may be shared for different tasks Expose an instance of LibresapiLocalClient to Qml, type exposure is kept for retrocompatibility but deprecated Qml app now has a tab that permit to exchange some message with selected distant peer
This commit is contained in:
parent
242338d10c
commit
c3aca0cf26
11 changed files with 259 additions and 170 deletions
|
@ -21,9 +21,8 @@
|
|||
#define LIBRESAPILOCALCLIENT_H
|
||||
|
||||
#include <QLocalSocket>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QVector>
|
||||
#include <QQueue>
|
||||
#include <QJSValue>
|
||||
|
||||
class LibresapiLocalClient : public QObject
|
||||
{
|
||||
|
@ -32,25 +31,27 @@ class LibresapiLocalClient : public QObject
|
|||
public:
|
||||
LibresapiLocalClient() : mLocalSocket(this) {}
|
||||
|
||||
// potser abstreure el següent amb QUrl urlPath (path) i amb QJson jsonData.
|
||||
Q_INVOKABLE int request(const QString & path, const QString & jsonData);
|
||||
const QJsonDocument & getJson();
|
||||
Q_INVOKABLE int request( const QString& path, const QString& jsonData = "",
|
||||
QJSValue callback = QJSValue::NullValue);
|
||||
Q_INVOKABLE void openConnection(QString socketPath);
|
||||
|
||||
private:
|
||||
QLocalSocket mLocalSocket;
|
||||
QByteArray receivedBytes;
|
||||
QJsonDocument json;
|
||||
//QVector<QJsonDocument> responses;
|
||||
|
||||
bool parseResponse(); //std::string msg);
|
||||
QQueue<QJSValue> callbackQueue;
|
||||
|
||||
private slots:
|
||||
void socketError(QLocalSocket::LocalSocketError error);
|
||||
void read();
|
||||
|
||||
signals:
|
||||
void goodResponseReceived(const QString & msg);//, int requestId);
|
||||
/// @deprecated @see LibresapiLocalClient::responseReceived instead
|
||||
void goodResponseReceived(const QString & msg);
|
||||
|
||||
/**
|
||||
* @brief responseReceived emitted when a response is received
|
||||
* @param msg
|
||||
*/
|
||||
void responseReceived(const QString & msg);
|
||||
};
|
||||
|
||||
#endif // LIBRESAPILOCALCLIENT_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue