diff options
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/basejob.h | 5 | ||||
-rw-r--r-- | jobs/checkauthmethods.h | 13 | ||||
-rw-r--r-- | jobs/geteventsjob.cpp | 96 | ||||
-rw-r--r-- | jobs/geteventsjob.h | 49 | ||||
-rw-r--r-- | jobs/joinroomjob.cpp | 1 | ||||
-rw-r--r-- | jobs/joinroomjob.h | 5 | ||||
-rw-r--r-- | jobs/leaveroomjob.h | 5 | ||||
-rw-r--r-- | jobs/mediathumbnailjob.h | 5 | ||||
-rw-r--r-- | jobs/passwordlogin.cpp | 2 | ||||
-rw-r--r-- | jobs/passwordlogin.h | 5 | ||||
-rw-r--r-- | jobs/postmessagejob.h | 5 | ||||
-rw-r--r-- | jobs/postreceiptjob.cpp | 17 | ||||
-rw-r--r-- | jobs/postreceiptjob.h | 10 | ||||
-rw-r--r-- | jobs/roommembersjob.cpp | 70 | ||||
-rw-r--r-- | jobs/roommembersjob.h | 47 | ||||
-rw-r--r-- | jobs/roommessagesjob.cpp | 1 | ||||
-rw-r--r-- | jobs/roommessagesjob.h | 5 | ||||
-rw-r--r-- | jobs/syncjob.cpp | 4 | ||||
-rw-r--r-- | jobs/syncjob.h | 7 |
19 files changed, 17 insertions, 335 deletions
diff --git a/jobs/basejob.h b/jobs/basejob.h index b356eb7e..55267def 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_BASEJOB_H -#define QMATRIXCLIENT_BASEJOB_H +#pragma once #include <QtCore/QObject> #include <QtCore/QJsonDocument> @@ -229,5 +228,3 @@ namespace QMatrixClient QScopedPointer<Private> d; }; } - -#endif // QMATRIXCLIENT_BASEJOB_H diff --git a/jobs/checkauthmethods.h b/jobs/checkauthmethods.h index e6aeba69..f6eb978a 100644 --- a/jobs/checkauthmethods.h +++ b/jobs/checkauthmethods.h @@ -16,30 +16,27 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_CHECKAUTHMETHODS_H -#define QMATRIXCLIENT_CHECKAUTHMETHODS_H +#pragma once #include "basejob.h" namespace QMatrixClient { class ConnectionData; - + class CheckAuthMethods : public BaseJob { public: CheckAuthMethods(ConnectionData* connection); virtual ~CheckAuthMethods(); - + QString session(); - + protected: Status parseJson(const QJsonDocument& data) override; - + private: class Private; Private* d; }; } - -#endif // QMATRIXCLIENT_CHECKAUTHMETHODS_H diff --git a/jobs/geteventsjob.cpp b/jobs/geteventsjob.cpp deleted file mode 100644 index 748a0189..00000000 --- a/jobs/geteventsjob.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach <kde@fxrh.de> - * - * 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 - */ - -#include "geteventsjob.h" - -#include <QtCore/QJsonDocument> -#include <QtCore/QJsonObject> -#include <QtCore/QJsonValue> -#include <QtCore/QJsonArray> -#include <QtCore/QDebug> - -#include <QtNetwork/QNetworkReply> - -#include "../room.h" -#include "../connectiondata.h" -#include "../events/event.h" - -using namespace QMatrixClient; - -class GetEventsJob::Private -{ - public: - Private() {} - - QList<Event*> events; - QString from; -}; - -GetEventsJob::GetEventsJob(ConnectionData* connection, QString from) - : BaseJob(connection, JobHttpType::GetJob) - , d(new Private) -{ - if( from.isEmpty() ) - from = connection->lastEvent(); - d->from = from; -} - -GetEventsJob::~GetEventsJob() -{ - delete d; -} - -QList< Event* > GetEventsJob::events() -{ - return d->events; -} - -QString GetEventsJob::apiPath() -{ - return "_matrix/client/r0/events"; -} - -QUrlQuery GetEventsJob::query() -{ - QUrlQuery query; - query.addQueryItem("from", d->from); - return query; -} - -void GetEventsJob::parseJson(const QJsonDocument& data) -{ - QJsonObject json = data.object(); - if( !json.contains("chunk") || !json.value("chunk").isArray() ) - { - fail( BaseJob::UserDefinedError, "Couldn't find chunk" ); - return; - } - QJsonArray chunk = json.value("chunk").toArray(); -// qDebug() << chunk; - for( const QJsonValue& val: chunk ) - { - QJsonObject eventObj = val.toObject(); - Event* event = Event::fromJson(eventObj); - if( event ) - { - d->events.append(event); - } - } - connection()->setLastEvent( json.value("end").toString() ); - emitResult(); -}
\ No newline at end of file diff --git a/jobs/geteventsjob.h b/jobs/geteventsjob.h deleted file mode 100644 index d2eb75eb..00000000 --- a/jobs/geteventsjob.h +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach <kde@fxrh.de> - * - * 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 - */ - -#ifndef QMATRIXCLIENT_GETEVENTSJOB_H -#define QMATRIXCLIENT_GETEVENTSJOB_H - -#include "basejob.h" - -namespace QMatrixClient -{ - class ConnectionData; - class Room; - class Event; - class GetEventsJob: public BaseJob - { - Q_OBJECT - public: - GetEventsJob(ConnectionData* connection, QString from=QString()); - virtual ~GetEventsJob(); - - QList<Event*> events(); - - protected: - QString apiPath(); - QUrlQuery query(); - void parseJson(const QJsonDocument& data); - - private: - class Private; - Private* d; - }; -} - -#endif // QMATRIXCLIENT_GETEVENTSJOB_H
\ No newline at end of file diff --git a/jobs/joinroomjob.cpp b/jobs/joinroomjob.cpp index d443acd7..073084c4 100644 --- a/jobs/joinroomjob.cpp +++ b/jobs/joinroomjob.cpp @@ -18,7 +18,6 @@ #include "joinroomjob.h" -#include <QtCore/QJsonObject> #include <QtNetwork/QNetworkReply> #include "../connectiondata.h" diff --git a/jobs/joinroomjob.h b/jobs/joinroomjob.h index c1eebbef..a69843ed 100644 --- a/jobs/joinroomjob.h +++ b/jobs/joinroomjob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_JOINROOMJOB_H -#define QMATRIXCLIENT_JOINROOMJOB_H +#pragma once #include "basejob.h" @@ -41,5 +40,3 @@ namespace QMatrixClient Private* d; }; } - -#endif // QMATRIXCLIENT_JOINROOMJOB_H diff --git a/jobs/leaveroomjob.h b/jobs/leaveroomjob.h index 492233f6..4a62810f 100644 --- a/jobs/leaveroomjob.h +++ b/jobs/leaveroomjob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_LEAVEROOMJOB_H -#define QMATRIXCLIENT_LEAVEROOMJOB_H +#pragma once #include "basejob.h" @@ -33,5 +32,3 @@ namespace QMatrixClient virtual ~LeaveRoomJob(); }; } - -#endif // QMATRIXCLIENT_LEAVEROOMJOB_H diff --git a/jobs/mediathumbnailjob.h b/jobs/mediathumbnailjob.h index 15bec9a1..cf1e9afb 100644 --- a/jobs/mediathumbnailjob.h +++ b/jobs/mediathumbnailjob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_MEDIATHUMBNAILJOB_H -#define QMATRIXCLIENT_MEDIATHUMBNAILJOB_H +#pragma once #include "basejob.h" @@ -44,5 +43,3 @@ namespace QMatrixClient Private* d; }; } - -#endif // QMATRIXCLIENT_MEDIATHUMBNAILJOB_H diff --git a/jobs/passwordlogin.cpp b/jobs/passwordlogin.cpp index a7a405aa..c78c15b5 100644 --- a/jobs/passwordlogin.cpp +++ b/jobs/passwordlogin.cpp @@ -18,8 +18,6 @@ #include "passwordlogin.h" -#include <QtCore/QJsonDocument> -#include <QtCore/QJsonObject> #include <QtNetwork/QNetworkReply> #include "../connectiondata.h" diff --git a/jobs/passwordlogin.h b/jobs/passwordlogin.h index 156865a3..c1291389 100644 --- a/jobs/passwordlogin.h +++ b/jobs/passwordlogin.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_PASSWORDLOGIN_H -#define QMATRIXCLIENT_PASSWORDLOGIN_H +#pragma once #include "basejob.h" @@ -43,5 +42,3 @@ namespace QMatrixClient Private* d; }; } - -#endif // QMATRIXCLIENT_PASSWORDLOGIN_H diff --git a/jobs/postmessagejob.h b/jobs/postmessagejob.h index 9d52ae8d..2e1989fd 100644 --- a/jobs/postmessagejob.h +++ b/jobs/postmessagejob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_POSTMESSAGEJOB_H -#define QMATRIXCLIENT_POSTMESSAGEJOB_H +#pragma once #include "basejob.h" @@ -40,5 +39,3 @@ namespace QMatrixClient Private* d; }; } - -#endif // QMATRIXCLIENT_POSTMESSAGEJOB_H diff --git a/jobs/postreceiptjob.cpp b/jobs/postreceiptjob.cpp index d0c82b4f..1eaefc2a 100644 --- a/jobs/postreceiptjob.cpp +++ b/jobs/postreceiptjob.cpp @@ -24,23 +24,10 @@ using namespace QMatrixClient; -class PostReceiptJob::Private -{ - public: - Private() {} - - QString roomId; - QString eventId; -}; - PostReceiptJob::PostReceiptJob(ConnectionData* connection, QString roomId, QString eventId) : BaseJob(connection, JobHttpType::PostJob, "PostReceiptJob", QString("/_matrix/client/r0/rooms/%1/receipt/m.read/%2").arg(roomId, eventId)) - , d(new Private) -{ -} +{ } PostReceiptJob::~PostReceiptJob() -{ - delete d; -} +{ } diff --git a/jobs/postreceiptjob.h b/jobs/postreceiptjob.h index 4e047b3a..c0002dc0 100644 --- a/jobs/postreceiptjob.h +++ b/jobs/postreceiptjob.h @@ -16,24 +16,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_POSTRECEIPTJOB_H -#define QMATRIXCLIENT_POSTRECEIPTJOB_H +#pragma once #include "basejob.h" namespace QMatrixClient { - class Room; class PostReceiptJob: public BaseJob { public: PostReceiptJob(ConnectionData* connection, QString roomId, QString eventId); virtual ~PostReceiptJob(); - - private: - class Private; - Private* d; }; } - -#endif // QMATRIXCLIENT_POSTRECEIPTJOB_H diff --git a/jobs/roommembersjob.cpp b/jobs/roommembersjob.cpp deleted file mode 100644 index 7fc44c63..00000000 --- a/jobs/roommembersjob.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach <kde@fxrh.de> - * - * 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 - */ - -#include "roommembersjob.h" - -#include <QtCore/QJsonObject> -#include <QtCore/QJsonArray> -#include <QtCore/QDebug> - -#include "../room.h" -#include "../state.h" - -using namespace QMatrixClient; - -class RoomMembersJob::Private -{ - public: - Room* room; - QList<State*> states; -}; - -RoomMembersJob::RoomMembersJob(ConnectionData* data, Room* room) - : BaseJob(data, JobHttpType::GetJob, "RoomMembersJob") - , d(new Private) -{ - d->room = room; -} - -RoomMembersJob::~RoomMembersJob() -{ - delete d; -} - -QList< State* > RoomMembersJob::states() -{ - return d->states; -} - -QString RoomMembersJob::apiPath() const -{ - return QString("_matrix/client/r0/rooms/%1/members").arg(d->room->id()); -} - -BaseJob::Status RoomMembersJob::parseJson(const QJsonDocument& data) -{ - QJsonArray chunk = data.object().value("chunk").toArray(); - for( const QJsonValue& val : chunk ) - { - State* state = State::fromJson(val.toObject()); - if( state ) - d->states.append(state); - } - qDebug() << "States: " << d->states.count(); - return Success; -} diff --git a/jobs/roommembersjob.h b/jobs/roommembersjob.h deleted file mode 100644 index 04803d67..00000000 --- a/jobs/roommembersjob.h +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach <kde@fxrh.de> - * - * 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 - */ - -#ifndef QMATRIXCLIENT_ROOMMEMBERSJOB_H -#define QMATRIXCLIENT_ROOMMEMBERSJOB_H - -#include "basejob.h" - -namespace QMatrixClient -{ - class ConnectionData; - class Room; - class State; - class RoomMembersJob: public BaseJob - { - public: - RoomMembersJob(ConnectionData* data, Room* room); - virtual ~RoomMembersJob(); - - QList<State*> states(); - - protected: - QString apiPath() const override; - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - Private* d; - }; -} - -#endif // QMATRIXCLIENT_ROOMMEMBERSJOB_H diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index d67ffc2a..1e53f601 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -19,7 +19,6 @@ #include "roommessagesjob.h" #include "../room.h" -#include <QtCore/QJsonObject> #include <QtCore/QJsonArray> using namespace QMatrixClient; diff --git a/jobs/roommessagesjob.h b/jobs/roommessagesjob.h index 227ffac2..348217cc 100644 --- a/jobs/roommessagesjob.h +++ b/jobs/roommessagesjob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_ROOMMESSAGESJOB_H -#define QMATRIXCLIENT_ROOMMESSAGESJOB_H +#pragma once #include "basejob.h" @@ -47,5 +46,3 @@ namespace QMatrixClient Private* d; }; } - -#endif // QMATRIXCLIENT_ROOMMESSAGESJOB_H diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 521f829e..554ac0f7 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -18,13 +18,9 @@ #include "syncjob.h" -#include <QtCore/QJsonDocument> -#include <QtCore/QJsonObject> -#include <QtCore/QJsonValue> #include <QtCore/QJsonArray> #include <QtCore/QDebug> -#include "../room.h" #include "../connectiondata.h" using namespace QMatrixClient; diff --git a/jobs/syncjob.h b/jobs/syncjob.h index e7b23d16..be1d4776 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef QMATRIXCLIENT_SYNCJOB_H -#define QMATRIXCLIENT_SYNCJOB_H +#pragma once #include "basejob.h" @@ -102,7 +101,7 @@ namespace QMatrixClient SyncJob(ConnectionData* connection, QString since = {}, QString filter = {}, int timeout = -1, QString presence = {}); virtual ~SyncJob(); - + SyncData& roomData(); QString nextBatch() const; @@ -114,5 +113,3 @@ namespace QMatrixClient Private* d; }; } - -#endif // QMATRIXCLIENT_SYNCJOB_H |