From a2c08f646bf2d6fe0ce385940b5c1bb7b430d5fb Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 27 May 2016 16:49:15 +0900 Subject: Don't assign the token twice In a case when authentication doesn't even happen, PasswordLogin job won't run. The better place to assign (and log) the token is in Connection::connectWithToken(), therefore. --- connection.cpp | 2 ++ jobs/passwordlogin.cpp | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/connection.cpp b/connection.cpp index a219f1da..69121930 100644 --- a/connection.cpp +++ b/connection.cpp @@ -79,6 +79,8 @@ void Connection::connectWithToken(QString userId, QString token) d->isConnected = true; d->userId = userId; d->data->setToken(token); + qDebug() << "Connected with token:"; + qDebug() << token; emit connected(); } diff --git a/jobs/passwordlogin.cpp b/jobs/passwordlogin.cpp index d989815f..6cf45b26 100644 --- a/jobs/passwordlogin.cpp +++ b/jobs/passwordlogin.cpp @@ -88,9 +88,7 @@ void PasswordLogin::parseJson(const QJsonDocument& data) fail( BaseJob::UserDefinedError, "Unexpected data" ); } d->returned_token = json.value("access_token").toString(); - qDebug() << d->returned_token; d->returned_server = json.value("home_server").toString(); d->returned_id = json.value("user_id").toString(); - connection()->setToken(d->returned_token); emitResult(); } -- cgit v1.2.3 From 5e6a0b961d1fc2162c5a7498f10bbd1a477f1ece Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 27 May 2016 16:51:13 +0900 Subject: Use nullptr --- connection.cpp | 2 +- connection.h | 2 +- connectionprivate.cpp | 2 +- events/roommessageevent.cpp | 2 +- jobs/basejob.cpp | 2 +- state.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/connection.cpp b/connection.cpp index 69121930..8d916280 100644 --- a/connection.cpp +++ b/connection.cpp @@ -177,7 +177,7 @@ User* Connection::user(QString userId) User *Connection::user() { if( d->userId.isEmpty() ) - return 0; + return nullptr; return user(d->userId); } diff --git a/connection.h b/connection.h index 9f3d23f3..452db198 100644 --- a/connection.h +++ b/connection.h @@ -37,7 +37,7 @@ namespace QMatrixClient class Connection: public QObject { Q_OBJECT public: - Connection(QUrl server, QObject* parent=0); + Connection(QUrl server, QObject* parent = nullptr); Connection(); virtual ~Connection(); diff --git a/connectionprivate.cpp b/connectionprivate.cpp index bcca8744..62840473 100644 --- a/connectionprivate.cpp +++ b/connectionprivate.cpp @@ -39,7 +39,7 @@ ConnectionPrivate::ConnectionPrivate(Connection* parent) : q(parent) { isConnected = false; - data = 0; + data = nullptr; } ConnectionPrivate::~ConnectionPrivate() diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp index 99d17e5c..b7459054 100644 --- a/events/roommessageevent.cpp +++ b/events/roommessageevent.cpp @@ -39,7 +39,7 @@ RoomMessageEvent::RoomMessageEvent() : Event(EventType::RoomMessage) , d(new Private) { - d->content = 0; + d->content = nullptr; } RoomMessageEvent::~RoomMessageEvent() diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index cfdf8a28..074a2629 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -31,7 +31,7 @@ class BaseJob::Private { public: Private(ConnectionData* c, JobHttpType t, bool nt) - : connection(c), reply(0), type(t), needsToken(nt) {} + : connection(c), reply(nullptr), type(t), needsToken(nt) {} ConnectionData* connection; QNetworkReply* reply; diff --git a/state.cpp b/state.cpp index ed57bea4..59a3b007 100644 --- a/state.cpp +++ b/state.cpp @@ -61,7 +61,7 @@ State* State::fromJson(const QJsonObject& obj) { Event* event = Event::fromJson(obj); if( !event ) - return 0; + return nullptr; State* state = new State(event); state->d->stateKey = obj.value("state_key").toString(); state->d->replacesState = obj.value("replaces_state").toString(); -- cgit v1.2.3 From 028ed5afc18209064002c9f6aa34e08a228d471f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 11 Apr 2016 11:17:48 +0900 Subject: Enhance logging 1. Introduce QDebug manipulators and formatJson manipulator in particular - this allows to accommodate some changes in Qt's debug printing behaviour between versions. 2. Show JSON for some questionable objects (UnknownEvents, events with no event_id etc.) 3. Log the list of typing users and the user id when getting an avatar. --- events/event.cpp | 37 ++++++++++++++------------ events/roomaliasesevent.cpp | 3 +-- events/typingevent.cpp | 2 ++ events/unknownevent.cpp | 7 ++++- logging_util.h | 63 +++++++++++++++++++++++++++++++++++++++++++++ user.cpp | 2 +- 6 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 logging_util.h diff --git a/events/event.cpp b/events/event.cpp index 9a48108c..d05d666f 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -23,6 +23,7 @@ #include #include +#include "../logging_util.h" #include "roommessageevent.h" #include "roomnameevent.h" #include "roomaliasesevent.h" @@ -110,36 +111,38 @@ Event* Event::fromJson(const QJsonObject& obj) } if( obj.value("type").toString() == "m.typing" ) { - qDebug() << "m.typing..."; return TypingEvent::fromJson(obj); } if( obj.value("type").toString() == "m.receipt" ) { return ReceiptEvent::fromJson(obj); } - //qDebug() << "Unknown event"; return UnknownEvent::fromJson(obj); } bool Event::parseJson(const QJsonObject& obj) { d->originalJson = QString::fromUtf8(QJsonDocument(obj).toJson()); - bool correct = true; - if( obj.contains("event_id") ) + bool correct = (d->type != EventType::Unknown); + if ( d->type != EventType::Unknown && d->type != EventType::Typing ) { - d->id = obj.value("event_id").toString(); - } else { - correct = false; - qDebug() << "Event: can't find event_id"; - } - if( obj.contains("origin_server_ts") ) - { - d->timestamp = QDateTime::fromMSecsSinceEpoch( - static_cast(obj.value("origin_server_ts").toDouble()), Qt::UTC ); - } else { - correct = false; - qDebug() << "Event: can't find ts"; - //qDebug() << obj; + if( obj.contains("event_id") ) + { + d->id = obj.value("event_id").toString(); + } else { + correct = false; + qDebug() << "Event: can't find event_id"; + qDebug() << formatJson << obj; + } + if( obj.contains("origin_server_ts") ) + { + d->timestamp = QDateTime::fromMSecsSinceEpoch( + static_cast(obj.value("origin_server_ts").toDouble()), Qt::UTC ); + } else { + correct = false; + qDebug() << "Event: can't find ts"; + qDebug() << formatJson << obj; + } } if( obj.contains("room_id") ) { diff --git a/events/roomaliasesevent.cpp b/events/roomaliasesevent.cpp index 54fb5682..15b4c54e 100644 --- a/events/roomaliasesevent.cpp +++ b/events/roomaliasesevent.cpp @@ -64,7 +64,6 @@ QStringList RoomAliasesEvent::aliases() const RoomAliasesEvent* RoomAliasesEvent::fromJson(const QJsonObject& obj) { - qDebug() << "RoomAliasesEvent::fromJson"; RoomAliasesEvent* e = new RoomAliasesEvent(); e->parseJson(obj); const QJsonObject contents = obj.value("content").toObject(); @@ -73,6 +72,6 @@ RoomAliasesEvent* RoomAliasesEvent::fromJson(const QJsonObject& obj) { e->d->aliases << alias.toString(); } - qDebug() << e->d->aliases; + qDebug() << "RoomAliasesEvent:" << e->d->aliases; return e; } diff --git a/events/typingevent.cpp b/events/typingevent.cpp index 242094e1..36a7e693 100644 --- a/events/typingevent.cpp +++ b/events/typingevent.cpp @@ -19,6 +19,7 @@ #include "typingevent.h" #include +#include using namespace QMatrixClient; @@ -53,5 +54,6 @@ TypingEvent* TypingEvent::fromJson(const QJsonObject& obj) { e->d->users << user.toString(); } + qDebug() << "Typing:" << e->d->users; return e; } diff --git a/events/unknownevent.cpp b/events/unknownevent.cpp index 758d0ec8..90551409 100644 --- a/events/unknownevent.cpp +++ b/events/unknownevent.cpp @@ -19,6 +19,9 @@ #include "unknownevent.h" #include +#include + +#include "../logging_util.h" using namespace QMatrixClient; @@ -56,5 +59,7 @@ UnknownEvent* UnknownEvent::fromJson(const QJsonObject& obj) e->parseJson(obj); e->d->type = obj.value("type").toString(); e->d->content = QString::fromUtf8(QJsonDocument(obj).toJson()); + qDebug() << "UnknownEvent, JSON follows:"; + qDebug() << formatJson << obj; return e; -} \ No newline at end of file +} diff --git a/logging_util.h b/logging_util.h new file mode 100644 index 00000000..47b2e062 --- /dev/null +++ b/logging_util.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * Copyright (C) 2016 Kitsune Ral + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file logging_util.h - a collection of utilities to facilitate debug logging. + */ + +#pragma once + +#include + +namespace QMatrixClient { + +// QDebug manipulators + +using QDebugManip = QDebug (*)(QDebug); + +/** + * @brief QDebug manipulator to setup the stream for JSON output. + * + * Originally made to encapsulate the change in QDebug behavior in Qt 5.4 + * and the respective addition of QDebug::noquote(). + * Together with the operator<<() helper, the proposed usage is + * (similar to std:: I/O manipulators): + * + * @example qDebug() << formatJson << json_object; // (QJsonObject, or QJsonValue, etc.) + */ +static QDebugManip formatJson = [](QDebug debug_object) { +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) + return debug_object; +#else + return debug_object.noquote(); +#endif + }; + +/** + * @brief A helper operator to facilitate using formatJson (and possibly other manipulators) + * + * @param debug_object to output the json to + * @param qdm a QDebug manipulator + * @return a copy of debug_object that has its mode altered by qdm + */ +inline QDebug operator<< (QDebug debug_object, QDebugManip qdm) { + return qdm(debug_object); +} + +} + diff --git a/user.cpp b/user.cpp index 5018fe83..6bef0de1 100644 --- a/user.cpp +++ b/user.cpp @@ -87,7 +87,7 @@ QPixmap User::avatar(int width, int height) { if( !d->avatarOngoingRequest && d->avatarUrl.isValid() ) { - qDebug() << "Get avatar..."; + qDebug() << "Getting avatar for" << id(); d->requestedWidth = width; d->requestedHeight = height; d->avatarOngoingRequest = true; -- cgit v1.2.3 From 40195a814673fb8557a8b9c67a0f4d61191eb34e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 11 May 2016 17:42:24 +0900 Subject: Set the object name for each job, to make it clear which job has failed And we don't need two log lines for timeouts. --- jobs/basejob.cpp | 6 +++--- jobs/basejob.h | 3 ++- jobs/checkauthmethods.cpp | 4 ++-- jobs/joinroomjob.cpp | 2 +- jobs/leaveroomjob.cpp | 2 +- jobs/mediathumbnailjob.cpp | 2 +- jobs/passwordlogin.cpp | 2 +- jobs/postmessagejob.cpp | 4 ++-- jobs/postreceiptjob.cpp | 2 +- jobs/roommembersjob.cpp | 4 ++-- jobs/roommessagesjob.cpp | 2 +- jobs/syncjob.cpp | 2 +- 12 files changed, 18 insertions(+), 17 deletions(-) diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 074a2629..e4350306 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -39,7 +39,7 @@ class BaseJob::Private bool needsToken; }; -BaseJob::BaseJob(ConnectionData* connection, JobHttpType type, bool needsToken) +BaseJob::BaseJob(ConnectionData* connection, JobHttpType type, QString name, bool needsToken) : d(new Private(connection, type, needsToken)) { // Work around KJob inability to separate success and failure signals @@ -49,6 +49,7 @@ BaseJob::BaseJob(ConnectionData* connection, JobHttpType type, bool needsToken) else emit failure(this); }); + setObjectName(name); } BaseJob::~BaseJob() @@ -121,7 +122,7 @@ void BaseJob::fail(int errorCode, QString errorString) setErrorText( errorString ); if( d->reply->isRunning() ) d->reply->abort(); - qWarning() << this << "failed:" << errorString; + qWarning() << "Job" << objectName() << "failed:" << errorString; emitResult(); } @@ -155,7 +156,6 @@ void BaseJob::gotReply() void BaseJob::timeout() { - qDebug() << "Timeout!"; fail( TimeoutError, "The job has timed out" ); } diff --git a/jobs/basejob.h b/jobs/basejob.h index f1ad66d1..bb3f42d4 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -40,7 +40,8 @@ namespace QMatrixClient { Q_OBJECT public: - BaseJob(ConnectionData* connection, JobHttpType type, bool needsToken=true); + BaseJob(ConnectionData* connection, JobHttpType type, + QString name, bool needsToken=true); virtual ~BaseJob(); void start() override; diff --git a/jobs/checkauthmethods.cpp b/jobs/checkauthmethods.cpp index 18b5f9a5..0554f749 100644 --- a/jobs/checkauthmethods.cpp +++ b/jobs/checkauthmethods.cpp @@ -37,7 +37,7 @@ class CheckAuthMethods::Private }; CheckAuthMethods::CheckAuthMethods(ConnectionData* connection) - : BaseJob(connection, JobHttpType::GetJob, false) + : BaseJob(connection, JobHttpType::GetJob, "CheckAuthMethods", false) , d(new Private) { } @@ -60,4 +60,4 @@ QString CheckAuthMethods::apiPath() void CheckAuthMethods::parseJson(const QJsonDocument& data) { // TODO -} \ No newline at end of file +} diff --git a/jobs/joinroomjob.cpp b/jobs/joinroomjob.cpp index 85a331fa..1001cd10 100644 --- a/jobs/joinroomjob.cpp +++ b/jobs/joinroomjob.cpp @@ -33,7 +33,7 @@ class JoinRoomJob::Private }; JoinRoomJob::JoinRoomJob(ConnectionData* data, QString roomAlias) - : BaseJob(data, JobHttpType::PostJob) + : BaseJob(data, JobHttpType::PostJob, "JoinRoomJob") , d(new Private) { d->roomAlias = roomAlias; diff --git a/jobs/leaveroomjob.cpp b/jobs/leaveroomjob.cpp index 1adab31f..4960a9df 100644 --- a/jobs/leaveroomjob.cpp +++ b/jobs/leaveroomjob.cpp @@ -34,7 +34,7 @@ class LeaveRoomJob::Private }; LeaveRoomJob::LeaveRoomJob(ConnectionData* data, Room* room) - : BaseJob(data, JobHttpType::PostJob) + : BaseJob(data, JobHttpType::PostJob, "LeaveRoomJob") , d(new Private(room)) { } diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp index 02d9bbd9..b7d34bf2 100644 --- a/jobs/mediathumbnailjob.cpp +++ b/jobs/mediathumbnailjob.cpp @@ -34,7 +34,7 @@ class MediaThumbnailJob::Private MediaThumbnailJob::MediaThumbnailJob(ConnectionData* data, QUrl url, int requestedWidth, int requestedHeight, ThumbnailType thumbnailType) - : BaseJob(data, JobHttpType::GetJob) + : BaseJob(data, JobHttpType::GetJob, "MediaThumbnailJob") , d(new Private) { d->url = url; diff --git a/jobs/passwordlogin.cpp b/jobs/passwordlogin.cpp index 6cf45b26..e8a6e5b4 100644 --- a/jobs/passwordlogin.cpp +++ b/jobs/passwordlogin.cpp @@ -39,7 +39,7 @@ class PasswordLogin::Private }; PasswordLogin::PasswordLogin(ConnectionData* connection, QString user, QString password) - : BaseJob(connection, JobHttpType::PostJob, false) + : BaseJob(connection, JobHttpType::PostJob, "PasswordLogin", false) , d(new Private) { d->user = user; diff --git a/jobs/postmessagejob.cpp b/jobs/postmessagejob.cpp index 67c79669..65042ed0 100644 --- a/jobs/postmessagejob.cpp +++ b/jobs/postmessagejob.cpp @@ -35,7 +35,7 @@ class PostMessageJob::Private }; PostMessageJob::PostMessageJob(ConnectionData* connection, Room* room, QString type, QString message) - : BaseJob(connection, JobHttpType::PostJob) + : BaseJob(connection, JobHttpType::PostJob, "PostMessageJob") , d(new Private) { d->type = type; @@ -71,4 +71,4 @@ void PostMessageJob::parseJson(const QJsonDocument& data) return; } emitResult(); -} \ No newline at end of file +} diff --git a/jobs/postreceiptjob.cpp b/jobs/postreceiptjob.cpp index c26186e8..54220626 100644 --- a/jobs/postreceiptjob.cpp +++ b/jobs/postreceiptjob.cpp @@ -34,7 +34,7 @@ class PostReceiptJob::Private }; PostReceiptJob::PostReceiptJob(ConnectionData* connection, QString roomId, QString eventId) - : BaseJob(connection, JobHttpType::PostJob) + : BaseJob(connection, JobHttpType::PostJob, "PostReceiptJob") , d(new Private) { d->roomId = roomId; diff --git a/jobs/roommembersjob.cpp b/jobs/roommembersjob.cpp index e12bc6c4..6f1dabb7 100644 --- a/jobs/roommembersjob.cpp +++ b/jobs/roommembersjob.cpp @@ -34,7 +34,7 @@ class RoomMembersJob::Private }; RoomMembersJob::RoomMembersJob(ConnectionData* data, Room* room) - : BaseJob(data, JobHttpType::GetJob) + : BaseJob(data, JobHttpType::GetJob, "RoomMembersJob") , d(new Private) { d->room = room; @@ -67,4 +67,4 @@ void RoomMembersJob::parseJson(const QJsonDocument& data) } qDebug() << "States: " << d->states.count(); emitResult(); -} \ No newline at end of file +} diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index 5a97cc23..7db98a87 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -40,7 +40,7 @@ class RoomMessagesJob::Private }; RoomMessagesJob::RoomMessagesJob(ConnectionData* data, Room* room, QString from, FetchDirectory dir, int limit) - : BaseJob(data, JobHttpType::GetJob) + : BaseJob(data, JobHttpType::GetJob, "RoomMessagesJob") { d = new Private(); d->room = room; diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 6b8ec510..04299b2c 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -44,7 +44,7 @@ class SyncJob::Private }; SyncJob::SyncJob(ConnectionData* connection, QString since) - : BaseJob(connection, JobHttpType::GetJob) + : BaseJob(connection, JobHttpType::GetJob, "SyncJob") , d(new Private) { d->since = since; -- cgit v1.2.3 From 46050cd59a7af8cc7d616fab1a80db95dc8b5b35 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 25 May 2016 20:37:36 +0900 Subject: Use 'override' keyword throughout job classes; constify apiPath(), query(), data() Thanks to CLang model. --- jobs/basejob.cpp | 4 ++-- jobs/basejob.h | 6 +++--- jobs/checkauthmethods.cpp | 2 +- jobs/checkauthmethods.h | 6 +++--- jobs/joinroomjob.cpp | 2 +- jobs/joinroomjob.h | 6 +++--- jobs/leaveroomjob.cpp | 2 +- jobs/leaveroomjob.h | 4 ++-- jobs/mediathumbnailjob.cpp | 4 ++-- jobs/mediathumbnailjob.h | 6 +++--- jobs/passwordlogin.cpp | 4 ++-- jobs/passwordlogin.h | 8 ++++---- jobs/postmessagejob.cpp | 4 ++-- jobs/postmessagejob.h | 8 ++++---- jobs/postreceiptjob.cpp | 2 +- jobs/postreceiptjob.h | 2 +- jobs/roommembersjob.cpp | 2 +- jobs/roommembersjob.h | 6 +++--- jobs/roommessagesjob.cpp | 4 ++-- jobs/roommessagesjob.h | 8 ++++---- jobs/syncjob.cpp | 4 ++-- jobs/syncjob.h | 6 +++--- 22 files changed, 50 insertions(+), 50 deletions(-) diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index e4350306..50c85048 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -68,12 +68,12 @@ ConnectionData* BaseJob::connection() const return d->connection; } -QJsonObject BaseJob::data() +QJsonObject BaseJob::data() const { return QJsonObject(); } -QUrlQuery BaseJob::query() +QUrlQuery BaseJob::query() const { return QUrlQuery(); } diff --git a/jobs/basejob.h b/jobs/basejob.h index bb3f42d4..98b7358b 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -64,9 +64,9 @@ namespace QMatrixClient ConnectionData* connection() const; // to implement - virtual QString apiPath()=0; - virtual QUrlQuery query(); - virtual QJsonObject data(); + virtual QString apiPath() const = 0; + virtual QUrlQuery query() const; + virtual QJsonObject data() const; virtual void parseJson(const QJsonDocument& data); void fail( int errorCode, QString errorString ); diff --git a/jobs/checkauthmethods.cpp b/jobs/checkauthmethods.cpp index 0554f749..55d8632a 100644 --- a/jobs/checkauthmethods.cpp +++ b/jobs/checkauthmethods.cpp @@ -52,7 +52,7 @@ QString CheckAuthMethods::session() return d->session; } -QString CheckAuthMethods::apiPath() +QString CheckAuthMethods::apiPath() const { return "_matrix/client/r0/login"; } diff --git a/jobs/checkauthmethods.h b/jobs/checkauthmethods.h index 2c9ab61a..197f7aa7 100644 --- a/jobs/checkauthmethods.h +++ b/jobs/checkauthmethods.h @@ -35,8 +35,8 @@ namespace QMatrixClient QString session(); protected: - QString apiPath(); - void parseJson(const QJsonDocument& data); + QString apiPath() const override; + void parseJson(const QJsonDocument& data) override; private: class Private; @@ -44,4 +44,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_CHECKAUTHMETHODS_H \ No newline at end of file +#endif // QMATRIXCLIENT_CHECKAUTHMETHODS_H diff --git a/jobs/joinroomjob.cpp b/jobs/joinroomjob.cpp index 1001cd10..799d4926 100644 --- a/jobs/joinroomjob.cpp +++ b/jobs/joinroomjob.cpp @@ -49,7 +49,7 @@ QString JoinRoomJob::roomId() return d->roomId; } -QString JoinRoomJob::apiPath() +QString JoinRoomJob::apiPath() const { return QString("_matrix/client/r0/join/%1").arg(d->roomAlias); } diff --git a/jobs/joinroomjob.h b/jobs/joinroomjob.h index 8f4059f2..1329ca56 100644 --- a/jobs/joinroomjob.h +++ b/jobs/joinroomjob.h @@ -34,8 +34,8 @@ namespace QMatrixClient QString roomId(); protected: - QString apiPath(); - void parseJson(const QJsonDocument& data); + QString apiPath() const override; + void parseJson(const QJsonDocument& data) override; private: class Private; @@ -43,4 +43,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_JOINROOMJOB_H \ No newline at end of file +#endif // QMATRIXCLIENT_JOINROOMJOB_H diff --git a/jobs/leaveroomjob.cpp b/jobs/leaveroomjob.cpp index 4960a9df..b29c80ed 100644 --- a/jobs/leaveroomjob.cpp +++ b/jobs/leaveroomjob.cpp @@ -44,7 +44,7 @@ LeaveRoomJob::~LeaveRoomJob() delete d; } -QString LeaveRoomJob::apiPath() +QString LeaveRoomJob::apiPath() const { return QString("_matrix/client/r0/rooms/%1/leave").arg(d->room->id()); } diff --git a/jobs/leaveroomjob.h b/jobs/leaveroomjob.h index 535c44b8..9ce9bf4a 100644 --- a/jobs/leaveroomjob.h +++ b/jobs/leaveroomjob.h @@ -33,7 +33,7 @@ namespace QMatrixClient virtual ~LeaveRoomJob(); protected: - QString apiPath(); + QString apiPath() const override; private: class Private; @@ -41,4 +41,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_LEAVEROOMJOB_H \ No newline at end of file +#endif // QMATRIXCLIENT_LEAVEROOMJOB_H diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp index b7d34bf2..48ed0ffb 100644 --- a/jobs/mediathumbnailjob.cpp +++ b/jobs/mediathumbnailjob.cpp @@ -53,12 +53,12 @@ QPixmap MediaThumbnailJob::thumbnail() return d->thumbnail; } -QString MediaThumbnailJob::apiPath() +QString MediaThumbnailJob::apiPath() const { return QString("/_matrix/media/v1/thumbnail/%1/%2").arg(d->url.host()).arg(d->url.path()); } -QUrlQuery MediaThumbnailJob::query() +QUrlQuery MediaThumbnailJob::query() const { QUrlQuery query; query.addQueryItem("width", QString::number(d->requestedWidth)); diff --git a/jobs/mediathumbnailjob.h b/jobs/mediathumbnailjob.h index 85dc8251..df7c1832 100644 --- a/jobs/mediathumbnailjob.h +++ b/jobs/mediathumbnailjob.h @@ -38,8 +38,8 @@ namespace QMatrixClient QPixmap thumbnail(); protected: - QString apiPath() override; - QUrlQuery query() override; + QString apiPath() const override; + QUrlQuery query() const override; protected slots: void gotReply() override; @@ -50,4 +50,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_MEDIATHUMBNAILJOB_H \ No newline at end of file +#endif // QMATRIXCLIENT_MEDIATHUMBNAILJOB_H diff --git a/jobs/passwordlogin.cpp b/jobs/passwordlogin.cpp index e8a6e5b4..9f0cb2e1 100644 --- a/jobs/passwordlogin.cpp +++ b/jobs/passwordlogin.cpp @@ -66,12 +66,12 @@ QString PasswordLogin::server() return d->returned_server; } -QString PasswordLogin::apiPath() +QString PasswordLogin::apiPath() const { return "_matrix/client/r0/login"; } -QJsonObject PasswordLogin::data() +QJsonObject PasswordLogin::data() const { QJsonObject json; json.insert("type", "m.login.password"); diff --git a/jobs/passwordlogin.h b/jobs/passwordlogin.h index 19df118e..5e93e74e 100644 --- a/jobs/passwordlogin.h +++ b/jobs/passwordlogin.h @@ -37,9 +37,9 @@ namespace QMatrixClient QString server(); protected: - QString apiPath(); - QJsonObject data(); - void parseJson(const QJsonDocument& data); + QString apiPath() const override; + QJsonObject data() const override; + void parseJson(const QJsonDocument& data) override; private: class Private; @@ -47,4 +47,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_PASSWORDLOGIN_H \ No newline at end of file +#endif // QMATRIXCLIENT_PASSWORDLOGIN_H diff --git a/jobs/postmessagejob.cpp b/jobs/postmessagejob.cpp index 65042ed0..cf9b94fd 100644 --- a/jobs/postmessagejob.cpp +++ b/jobs/postmessagejob.cpp @@ -48,12 +48,12 @@ PostMessageJob::~PostMessageJob() delete d; } -QString PostMessageJob::apiPath() +QString PostMessageJob::apiPath() const { return QString("_matrix/client/r0/rooms/%1/send/m.room.message").arg(d->room->id()); } -QJsonObject PostMessageJob::data() +QJsonObject PostMessageJob::data() const { QJsonObject json; json.insert("msgtype", d->type); diff --git a/jobs/postmessagejob.h b/jobs/postmessagejob.h index 7f40534e..1917ef25 100644 --- a/jobs/postmessagejob.h +++ b/jobs/postmessagejob.h @@ -34,9 +34,9 @@ namespace QMatrixClient //bool success(); protected: - QString apiPath(); - QJsonObject data(); - void parseJson(const QJsonDocument& data); + QString apiPath() const override; + QJsonObject data() const override; + void parseJson(const QJsonDocument& data) override; private: class Private; @@ -44,4 +44,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_POSTMESSAGEJOB_H \ No newline at end of file +#endif // QMATRIXCLIENT_POSTMESSAGEJOB_H diff --git a/jobs/postreceiptjob.cpp b/jobs/postreceiptjob.cpp index 54220626..f99b6869 100644 --- a/jobs/postreceiptjob.cpp +++ b/jobs/postreceiptjob.cpp @@ -46,7 +46,7 @@ PostReceiptJob::~PostReceiptJob() delete d; } -QString PostReceiptJob::apiPath() +QString PostReceiptJob::apiPath() const { return QString("/_matrix/client/r0/rooms/%1/receipt/m.read/%2").arg(d->roomId).arg(d->eventId); } diff --git a/jobs/postreceiptjob.h b/jobs/postreceiptjob.h index 2767fa9a..c5224af5 100644 --- a/jobs/postreceiptjob.h +++ b/jobs/postreceiptjob.h @@ -32,7 +32,7 @@ namespace QMatrixClient virtual ~PostReceiptJob(); protected: - QString apiPath(); + QString apiPath() const override; private: class Private; diff --git a/jobs/roommembersjob.cpp b/jobs/roommembersjob.cpp index 6f1dabb7..c16ba481 100644 --- a/jobs/roommembersjob.cpp +++ b/jobs/roommembersjob.cpp @@ -50,7 +50,7 @@ QList< State* > RoomMembersJob::states() return d->states; } -QString RoomMembersJob::apiPath() +QString RoomMembersJob::apiPath() const { return QString("_matrix/client/r0/rooms/%1/members").arg(d->room->id()); } diff --git a/jobs/roommembersjob.h b/jobs/roommembersjob.h index 0349aa02..ffae4309 100644 --- a/jobs/roommembersjob.h +++ b/jobs/roommembersjob.h @@ -35,8 +35,8 @@ namespace QMatrixClient QList states(); protected: - virtual QString apiPath(); - virtual void parseJson(const QJsonDocument& data); + virtual QString apiPath() const override; + virtual void parseJson(const QJsonDocument& data) override; private: class Private; @@ -44,4 +44,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_ROOMMEMBERSJOB_H \ No newline at end of file +#endif // QMATRIXCLIENT_ROOMMEMBERSJOB_H diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index 7db98a87..f1943d2c 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -64,12 +64,12 @@ QString RoomMessagesJob::end() return d->end; } -QString RoomMessagesJob::apiPath() +QString RoomMessagesJob::apiPath() const { return QString("/_matrix/client/r0/rooms/%1/messages").arg(d->room->id()); } -QUrlQuery RoomMessagesJob::query() +QUrlQuery RoomMessagesJob::query() const { QUrlQuery query; query.addQueryItem("from", d->from); diff --git a/jobs/roommessagesjob.h b/jobs/roommessagesjob.h index 2a12ac08..6160dc57 100644 --- a/jobs/roommessagesjob.h +++ b/jobs/roommessagesjob.h @@ -39,9 +39,9 @@ namespace QMatrixClient QString end(); protected: - QString apiPath(); - QUrlQuery query(); - void parseJson(const QJsonDocument& data); + QString apiPath() const override; + QUrlQuery query() const override; + void parseJson(const QJsonDocument& data) override; private: class Private; @@ -49,4 +49,4 @@ namespace QMatrixClient }; } -#endif // QMATRIXCLIENT_ROOMMESSAGESJOB_H \ No newline at end of file +#endif // QMATRIXCLIENT_ROOMMESSAGESJOB_H diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 04299b2c..37f79298 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -87,12 +87,12 @@ QList SyncJob::roomData() const return d->roomData; } -QString SyncJob::apiPath() +QString SyncJob::apiPath() const { return "_matrix/client/r0/sync"; } -QUrlQuery SyncJob::query() +QUrlQuery SyncJob::query() const { QUrlQuery query; if( !d->filter.isEmpty() ) diff --git a/jobs/syncjob.h b/jobs/syncjob.h index abbef23a..19dd4646 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -72,9 +72,9 @@ namespace QMatrixClient QString nextBatch() const; protected: - QString apiPath(); - QUrlQuery query(); - void parseJson(const QJsonDocument& data); + QString apiPath() const override; + QUrlQuery query() const override; + void parseJson(const QJsonDocument& data) override; private: class Private; -- cgit v1.2.3