From 7bf926aeb3502712aa04b915e7b404b411b51599 Mon Sep 17 00:00:00 2001 From: David A Roberts Date: Thu, 7 Apr 2016 19:04:41 +1000 Subject: Allow Connections to be used in QML. --- connection.cpp | 5 +++++ connection.h | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/connection.cpp b/connection.cpp index 01392848..5127dea8 100644 --- a/connection.cpp +++ b/connection.cpp @@ -44,6 +44,11 @@ Connection::Connection(QUrl server, QObject* parent) d->data = new ConnectionData(server); } +Connection::Connection() + : Connection(QUrl("https://matrix.org")) +{ +} + Connection::~Connection() { delete d; diff --git a/connection.h b/connection.h index afe124f9..64d3d077 100644 --- a/connection.h +++ b/connection.h @@ -38,24 +38,25 @@ namespace QMatrixClient Q_OBJECT public: Connection(QUrl server, QObject* parent=0); + Connection(); virtual ~Connection(); QHash roomMap() const; - virtual bool isConnected(); + Q_INVOKABLE virtual bool isConnected(); - virtual void connectToServer( QString user, QString password ); - virtual void reconnect(); - virtual SyncJob* sync(int timeout=-1); - virtual void postMessage( Room* room, QString type, QString message ); - virtual PostReceiptJob* postReceipt( Room* room, Event* event ); - virtual void joinRoom( QString roomAlias ); - virtual void leaveRoom( Room* room ); - virtual void getMembers( Room* room ); - virtual RoomMessagesJob* getMessages( Room* room, QString from ); + Q_INVOKABLE virtual void connectToServer( QString user, QString password ); + Q_INVOKABLE virtual void reconnect(); + Q_INVOKABLE virtual SyncJob* sync(int timeout=-1); + Q_INVOKABLE virtual void postMessage( Room* room, QString type, QString message ); + Q_INVOKABLE virtual PostReceiptJob* postReceipt( Room* room, Event* event ); + Q_INVOKABLE virtual void joinRoom( QString roomAlias ); + Q_INVOKABLE virtual void leaveRoom( Room* room ); + Q_INVOKABLE virtual void getMembers( Room* room ); + Q_INVOKABLE virtual RoomMessagesJob* getMessages( Room* room, QString from ); virtual MediaThumbnailJob* getThumbnail( QUrl url, int requestedWidth, int requestedHeight ); - virtual User* user(QString userId); - virtual User* user(); + Q_INVOKABLE virtual User* user(QString userId); + Q_INVOKABLE virtual User* user(); signals: void connected(); @@ -90,4 +91,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_CONNECTION_H \ No newline at end of file +#endif // QMATRIXCLIENT_CONNECTION_H -- cgit v1.2.3