aboutsummaryrefslogtreecommitdiff
path: root/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'jobs')
-rw-r--r--jobs/basejob.cpp12
-rw-r--r--jobs/basejob.h9
-rw-r--r--jobs/checkauthmethods.cpp6
-rw-r--r--jobs/checkauthmethods.h6
-rw-r--r--jobs/joinroomjob.cpp4
-rw-r--r--jobs/joinroomjob.h6
-rw-r--r--jobs/leaveroomjob.cpp4
-rw-r--r--jobs/leaveroomjob.h4
-rw-r--r--jobs/mediathumbnailjob.cpp6
-rw-r--r--jobs/mediathumbnailjob.h6
-rw-r--r--jobs/passwordlogin.cpp8
-rw-r--r--jobs/passwordlogin.h8
-rw-r--r--jobs/postmessagejob.cpp8
-rw-r--r--jobs/postmessagejob.h8
-rw-r--r--jobs/postreceiptjob.cpp4
-rw-r--r--jobs/postreceiptjob.h2
-rw-r--r--jobs/roommembersjob.cpp6
-rw-r--r--jobs/roommembersjob.h6
-rw-r--r--jobs/roommessagesjob.cpp6
-rw-r--r--jobs/roommessagesjob.h8
-rw-r--r--jobs/syncjob.cpp6
-rw-r--r--jobs/syncjob.h6
22 files changed, 69 insertions, 70 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp
index cfdf8a28..50c85048 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;
@@ -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()
@@ -67,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();
}
@@ -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..98b7358b 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;
@@ -63,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 18b5f9a5..55d8632a 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)
{
}
@@ -52,7 +52,7 @@ QString CheckAuthMethods::session()
return d->session;
}
-QString CheckAuthMethods::apiPath()
+QString CheckAuthMethods::apiPath() const
{
return "_matrix/client/r0/login";
}
@@ -60,4 +60,4 @@ QString CheckAuthMethods::apiPath()
void CheckAuthMethods::parseJson(const QJsonDocument& data)
{
// TODO
-} \ No newline at end of file
+}
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 85a331fa..799d4926 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;
@@ -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 1adab31f..b29c80ed 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))
{
}
@@ -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 02d9bbd9..48ed0ffb 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;
@@ -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 d989815f..9f0cb2e1 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;
@@ -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");
@@ -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();
}
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 67c79669..cf9b94fd 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;
@@ -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);
@@ -71,4 +71,4 @@ void PostMessageJob::parseJson(const QJsonDocument& data)
return;
}
emitResult();
-} \ No newline at end of file
+}
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 c26186e8..f99b6869 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;
@@ -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 e12bc6c4..c16ba481 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;
@@ -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());
}
@@ -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/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<State*> 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 5a97cc23..f1943d2c 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;
@@ -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 6b8ec510..37f79298 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;
@@ -87,12 +87,12 @@ QList<SyncRoomData> 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;