aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2021-01-07 21:32:07 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2021-01-07 21:32:07 +0100
commit78a3137920d9680072dc3796dd90f849e8467fd4 (patch)
treefeec4de641d5663c57f31a5ae2c71bf86a42c8c1 /lib
parentaa790406aa0b076938f877e38545baf481a986ec (diff)
downloadlibquotient-78a3137920d9680072dc3796dd90f849e8467fd4.tar.gz
libquotient-78a3137920d9680072dc3796dd90f849e8467fd4.zip
isJobRunning() -> isJobPending()
To be very clear what this function checks. See also #437.
Diffstat (limited to 'lib')
-rw-r--r--lib/avatar.cpp14
-rw-r--r--lib/connection.cpp8
-rw-r--r--lib/jobs/basejob.h2
-rw-r--r--lib/room.cpp14
4 files changed, 19 insertions, 19 deletions
diff --git a/lib/avatar.cpp b/lib/avatar.cpp
index c65aa25c..df43f8b0 100644
--- a/lib/avatar.cpp
+++ b/lib/avatar.cpp
@@ -37,9 +37,9 @@ public:
explicit Private(QUrl url = {}) : _url(move(url)) {}
~Private()
{
- if (isJobRunning(_thumbnailRequest))
+ if (isJobPending(_thumbnailRequest))
_thumbnailRequest->abandon();
- if (isJobRunning(_uploadRequest))
+ if (isJobPending(_uploadRequest))
_uploadRequest->abandon();
}
@@ -87,7 +87,7 @@ QImage Avatar::get(Connection* connection, int width, int height,
bool Avatar::upload(Connection* connection, const QString& fileName,
upload_callback_t callback) const
{
- if (isJobRunning(d->_uploadRequest))
+ if (isJobPending(d->_uploadRequest))
return false;
return d->upload(connection->uploadFile(fileName), move(callback));
}
@@ -95,7 +95,7 @@ bool Avatar::upload(Connection* connection, const QString& fileName,
bool Avatar::upload(Connection* connection, QIODevice* source,
upload_callback_t callback) const
{
- if (isJobRunning(d->_uploadRequest) || !source->isReadable())
+ if (isJobPending(d->_uploadRequest) || !source->isReadable())
return false;
return d->upload(connection->uploadContent(source), move(callback));
}
@@ -125,7 +125,7 @@ QImage Avatar::Private::get(Connection* connection, QSize size,
&& checkUrl(_url)) {
qCDebug(MAIN) << "Getting avatar from" << _url.toString();
_requestedSize = size;
- if (isJobRunning(_thumbnailRequest))
+ if (isJobPending(_thumbnailRequest))
_thumbnailRequest->abandon();
if (callback)
callbacks.emplace_back(move(callback));
@@ -157,7 +157,7 @@ QImage Avatar::Private::get(Connection* connection, QSize size,
bool Avatar::Private::upload(UploadContentJob* job, upload_callback_t &&callback)
{
_uploadRequest = job;
- if (!isJobRunning(_uploadRequest))
+ if (!isJobPending(_uploadRequest))
return false;
_uploadRequest->connect(_uploadRequest, &BaseJob::success, _uploadRequest,
[job, callback] { callback(job->contentUri()); });
@@ -194,7 +194,7 @@ bool Avatar::updateUrl(const QUrl& newUrl)
d->_url = newUrl;
d->_imageSource = Private::Unknown;
- if (isJobRunning(d->_thumbnailRequest))
+ if (isJobPending(d->_thumbnailRequest))
d->_thumbnailRequest->abandon();
return true;
}
diff --git a/lib/connection.cpp b/lib/connection.cpp
index b8b131bf..b8294393 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -271,7 +271,7 @@ Connection::~Connection()
void Connection::resolveServer(const QString& mxid)
{
- if (isJobRunning(d->resolverJob))
+ if (isJobPending(d->resolverJob))
d->resolverJob->abandon();
auto maybeBaseUrl = QUrl::fromUserInput(serverPart(mxid));
@@ -1229,7 +1229,7 @@ QByteArray Connection::accessToken() const
{
// The logout job needs access token to do its job; so the token is
// kept inside d->data but no more exposed to the outside world.
- return isJobRunning(d->logoutJob) ? QByteArray() : d->data->accessToken();
+ return isJobPending(d->logoutJob) ? QByteArray() : d->data->accessToken();
}
bool Connection::isLoggedIn() const { return !accessToken().isEmpty(); }
@@ -1544,10 +1544,10 @@ QByteArray Connection::generateTxnId() const
void Connection::setHomeserver(const QUrl& url)
{
- if (isJobRunning(d->resolverJob))
+ if (isJobPending(d->resolverJob))
d->resolverJob->abandon();
d->resolverJob = nullptr;
- if (isJobRunning(d->loginFlowsJob))
+ if (isJobPending(d->loginFlowsJob))
d->loginFlowsJob->abandon();
d->loginFlowsJob = nullptr;
d->loginFlows.clear();
diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h
index a72f6120..317d5701 100644
--- a/lib/jobs/basejob.h
+++ b/lib/jobs/basejob.h
@@ -478,7 +478,7 @@ private:
QScopedPointer<Private> d;
};
-inline bool isJobRunning(BaseJob* job)
+inline bool isJobPending(BaseJob* job)
{
return job && job->error() == BaseJob::Pending;
}
diff --git a/lib/room.cpp b/lib/room.cpp
index a9b2ba30..5e71881a 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -858,7 +858,7 @@ const Room::RelatedEvents Room::relatedEvents(const RoomEvent& evt,
void Room::Private::getAllMembers()
{
// If already loaded or already loading, there's nothing to do here.
- if (q->joinedCount() <= membersMap.size() || isJobRunning(allMembersJob))
+ if (q->joinedCount() <= membersMap.size() || isJobPending(allMembersJob))
return;
allMembersJob = connection->callApi<GetMembersByRoomJob>(
@@ -1685,7 +1685,7 @@ QString Room::retryMessage(const QString& txnId)
<< "File for transaction" << txnId
<< "has already been uploaded, bypassing re-upload";
} else {
- if (isJobRunning(transferIt->job)) {
+ if (isJobPending(transferIt->job)) {
qCDebug(MESSAGES) << "Abandoning the upload job for transaction"
<< txnId << "and starting again";
transferIt->job->abandon();
@@ -1718,7 +1718,7 @@ void Room::discardMessage(const QString& txnId)
const auto& transferIt = d->fileTransfers.find(txnId);
if (transferIt != d->fileTransfers.end()) {
Q_ASSERT(transferIt->isUpload);
- if (isJobRunning(transferIt->job)) {
+ if (isJobPending(transferIt->job)) {
transferIt->status = FileTransferInfo::Cancelled;
transferIt->job->abandon();
emit fileTransferFailed(txnId, tr("File upload cancelled"));
@@ -1924,7 +1924,7 @@ void Room::getPreviousContent(int limit, const QString &filter) { d->getPrevious
void Room::Private::getPreviousContent(int limit, const QString &filter)
{
- if (isJobRunning(eventsHistoryJob))
+ if (isJobPending(eventsHistoryJob))
return;
eventsHistoryJob =
@@ -1977,7 +1977,7 @@ void Room::uploadFile(const QString& id, const QUrl& localFilename,
"localFilename should point at a local file");
auto fileName = localFilename.toLocalFile();
auto job = connection()->uploadFile(fileName, overrideContentType);
- if (isJobRunning(job)) {
+ if (isJobPending(job)) {
d->fileTransfers[id] = { job, fileName, true };
connect(job, &BaseJob::uploadProgress, this,
[this, id](qint64 sent, qint64 total) {
@@ -2033,7 +2033,7 @@ void Room::downloadFile(const QString& eventId, const QUrl& localFilename)
qDebug(MAIN) << "File path:" << filePath;
}
auto job = connection()->downloadFile(fileUrl, filePath);
- if (isJobRunning(job)) {
+ if (isJobPending(job)) {
// If there was a previous transfer (completed or failed), overwrite it.
d->fileTransfers[eventId] = { job, job->targetFileName() };
connect(job, &BaseJob::downloadProgress, this,
@@ -2061,7 +2061,7 @@ void Room::cancelFileTransfer(const QString& id)
<< d->id;
return;
}
- if (isJobRunning(it->job))
+ if (isJobPending(it->job))
it->job->abandon();
d->fileTransfers.remove(id);
emit fileTransferCancelled(id);