Verified Commit d67cfb3c authored by Linus Jahn's avatar Linus Jahn

Fix some clazy warnings

parent a17f832b
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
*/ */
#include "AvatarFileStorage.h" #include "AvatarFileStorage.h"
// Qt
#include <QDir>
#include <QUrl>
#include <QStandardPaths>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QDebug> #include <QDebug>
#include <QDir>
#include <QStandardPaths>
#include <QUrl>
AvatarFileStorage::AvatarFileStorage(QObject *parent) : QObject(parent) AvatarFileStorage::AvatarFileStorage(QObject *parent) : QObject(parent)
{ {
...@@ -64,11 +64,9 @@ AvatarFileStorage::AvatarFileStorage(QObject *parent) : QObject(parent) ...@@ -64,11 +64,9 @@ AvatarFileStorage::AvatarFileStorage(QObject *parent) : QObject(parent)
while (!line.isNull()) { while (!line.isNull()) {
// get hash and jid from line (seperated by a blank) // get hash and jid from line (seperated by a blank)
QStringList list = line.split(' ', QString::SkipEmptyParts); QStringList list = line.split(' ', QString::SkipEmptyParts);
QString hash = list.at(0);
QString jid = list.at(1);
// set the hash for the jid // set the hash for the jid
jidAvatarMap[jid] = hash; jidAvatarMap[list.at(1)] = list.at(0);
// read the next line // read the next line
line = stream.readLine(); line = stream.readLine();
...@@ -108,7 +106,7 @@ AvatarFileStorage::AddAvatarResult AvatarFileStorage::addAvatar(const QString &j ...@@ -108,7 +106,7 @@ AvatarFileStorage::AddAvatarResult AvatarFileStorage::addAvatar(const QString &j
// write the avatar to disk: // write the avatar to disk:
// get the writable cache location for writing // get the writable cache location for writing
QFile file(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QFile file(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
QDir::separator() + QString("avatars") + QDir::separator() + result.hash); QDir::separator() + QString("avatars") + QDir::separator() + result.hash);
if (!file.open(QIODevice::WriteOnly)) if (!file.open(QIODevice::WriteOnly))
return result; return result;
...@@ -131,14 +129,13 @@ void AvatarFileStorage::clearAvatar(QString &jid) ...@@ -131,14 +129,13 @@ void AvatarFileStorage::clearAvatar(QString &jid)
oldHash = jidAvatarMap[jid]; oldHash = jidAvatarMap[jid];
// if user had no avatar before, just return // if user had no avatar before, just return
if (oldHash.isEmpty()) { if (oldHash.isEmpty())
return; return;
} else {
jidAvatarMap.remove(jid); jidAvatarMap.remove(jid);
saveAvatarsFile(); saveAvatarsFile();
cleanUp(oldHash); cleanUp(oldHash);
emit avatarIdsChanged(); emit avatarIdsChanged();
}
} }
void AvatarFileStorage::cleanUp(QString &oldHash) void AvatarFileStorage::cleanUp(QString &oldHash)
...@@ -147,12 +144,12 @@ void AvatarFileStorage::cleanUp(QString &oldHash) ...@@ -147,12 +144,12 @@ void AvatarFileStorage::cleanUp(QString &oldHash)
return; return;
// check if the same avatar is still used by another account // check if the same avatar is still used by another account
if (jidAvatarMap.values().contains(oldHash)) if (std::find(jidAvatarMap.cbegin(), jidAvatarMap.cend(), oldHash) != jidAvatarMap.cend())
return; return;
// delete the old avatar locally // delete the old avatar locally
QString path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QString path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
QDir::separator() + QString("avatars"); QDir::separator() + QString("avatars");
QDir dir(path); QDir dir(path);
if (dir.exists(oldHash)) if (dir.exists(oldHash))
dir.remove(oldHash); dir.remove(oldHash);
...@@ -194,7 +191,8 @@ void AvatarFileStorage::saveAvatarsFile() ...@@ -194,7 +191,8 @@ void AvatarFileStorage::saveAvatarsFile()
return; return;
QTextStream out(&file); QTextStream out(&file);
for (const auto jid : jidAvatarMap.keys()) const QStringList jidAvatarKeys = jidAvatarMap.keys();
for (const auto &jid : jidAvatarKeys)
/* < HASH > < JID > */ /* < HASH > < JID > */
out << jidAvatarMap[jid] << " " << jid << "\n"; out << jidAvatarMap[jid] << " " << jid << "\n";
} }
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include "ClientWorker.h" #include "ClientWorker.h"
// Qt // Qt
#include <QDebug> #include <QDebug>
#include <QSettings>
#include <QGuiApplication> #include <QGuiApplication>
#include <QSettings>
#include <QSysInfo> #include <QSysInfo>
// QXmpp // QXmpp
#include <QXmppClient.h> #include <QXmppClient.h>
...@@ -40,15 +40,15 @@ ...@@ -40,15 +40,15 @@
#include <QXmppPresence.h> #include <QXmppPresence.h>
#include <QXmppVersionManager.h> #include <QXmppVersionManager.h>
// Kaidan // Kaidan
#include "DiscoveryManager.h"
#include "DownloadManager.h"
#include "Kaidan.h" #include "Kaidan.h"
#include "LogHandler.h" #include "LogHandler.h"
#include "MessageHandler.h"
#include "RegistrationManager.h" #include "RegistrationManager.h"
#include "RosterManager.h" #include "RosterManager.h"
#include "MessageHandler.h"
#include "DiscoveryManager.h"
#include "VCardManager.h"
#include "UploadManager.h" #include "UploadManager.h"
#include "DownloadManager.h" #include "VCardManager.h"
ClientWorker::ClientWorker(Caches *caches, Kaidan *kaidan, bool enableLogging, QGuiApplication *app, ClientWorker::ClientWorker(Caches *caches, Kaidan *kaidan, bool enableLogging, QGuiApplication *app,
QObject* parent) QObject* parent)
...@@ -182,10 +182,11 @@ void ClientWorker::onConnectionError(QXmppClient::Error error) ...@@ -182,10 +182,11 @@ void ClientWorker::onConnectionError(QXmppClient::Error error)
QString ClientWorker::generateRandomString(unsigned int length) const QString ClientWorker::generateRandomString(unsigned int length) const
{ {
const QString resourceChars(KAIDAN_RESOURCE_RANDOM_CHARS);
QString randomString; QString randomString;
for (unsigned int i = 0; i < length; ++i) for (unsigned int i = 0; i < length; ++i)
randomString.append(KAIDAN_RESOURCE_RANDOM_CHARS.at( randomString.append(resourceChars.at(qrand() % resourceChars.length()));
qrand() % KAIDAN_RESOURCE_RANDOM_CHARS.length()));
return randomString; return randomString;
} }
......
...@@ -33,19 +33,19 @@ ...@@ -33,19 +33,19 @@
// Qt // Qt
#include <QObject> #include <QObject>
#include <QTimer>
#include <QSettings> #include <QSettings>
#include <QTimer>
class QGuiApplication; class QGuiApplication;
// QXmpp // QXmpp
#include <QXmppClient.h> #include <QXmppClient.h>
// Kaidan // Kaidan
#include "Globals.h" #include "AvatarFileStorage.h"
#include "Enums.h"
#include "Database.h" #include "Database.h"
#include "Enums.h"
#include "Globals.h"
#include "MessageModel.h" #include "MessageModel.h"
#include "RosterModel.h"
#include "AvatarFileStorage.h"
#include "PresenceCache.h" #include "PresenceCache.h"
#include "RosterModel.h"
#include "TransferCache.h" #include "TransferCache.h"
class LogHandler; class LogHandler;
class Kaidan; class Kaidan;
...@@ -128,7 +128,7 @@ public slots: ...@@ -128,7 +128,7 @@ public slots:
* *
* @param creds The new credentials for the next connect * @param creds The new credentials for the next connect
*/ */
void setCredentials(Credentials creds) void setCredentials(ClientWorker::Credentials creds)
{ {
this->creds = creds; this->creds = creds;
} }
...@@ -142,11 +142,11 @@ signals: ...@@ -142,11 +142,11 @@ signals:
// emitted by 'Kaidan' to us: // emitted by 'Kaidan' to us:
void connectRequested(); void connectRequested();
void disconnectRequested(); void disconnectRequested();
void credentialsUpdated(Credentials creds); void credentialsUpdated(ClientWorker::Credentials creds);
// emitted by us: // emitted by us:
// connection state is directly connected (client -> kaidan) without this step // connection state is directly connected (client -> kaidan) without this step
void disconnReasonChanged(DisconnectionReason reason); void disconnReasonChanged(Enums::DisconnectionReason reason);
private slots: private slots:
/** /**
......
...@@ -318,8 +318,10 @@ void Database::convertDatabaseToV5() ...@@ -318,8 +318,10 @@ void Database::convertDatabaseToV5()
void Database::convertDatabaseToV6() void Database::convertDatabaseToV6()
{ {
QSqlQuery query(m_database); QSqlQuery query(m_database);
for (QString column : {"'mediaSize' INTEGER", "'mediaContentType' TEXT", for (const QString &column : {"'mediaSize' INTEGER",
"'mediaLastModified' INTEGER", "'mediaLocation' TEXT"}) { "'mediaContentType' TEXT",
"'mediaLastModified' INTEGER",
"'mediaLocation' TEXT"}) {
Utils::execQuery(query, QString("ALTER TABLE 'Messages' ADD ").append(column)); Utils::execQuery(query, QString("ALTER TABLE 'Messages' ADD ").append(column));
} }
} }
......
...@@ -47,7 +47,7 @@ DiscoveryManager::DiscoveryManager(QXmppClient *client, QObject *parent) ...@@ -47,7 +47,7 @@ DiscoveryManager::DiscoveryManager(QXmppClient *client, QObject *parent)
#else #else
// Plasma Mobile packages won't differ from desktop builds, so we need to check the mobile // Plasma Mobile packages won't differ from desktop builds, so we need to check the mobile
// variable on runtime. // variable on runtime.
if (!qgetenv("QT_QUICK_CONTROLS_MOBILE").isEmpty()) if (!qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_MOBILE"))
manager->setClientType("phone"); manager->setClientType("phone");
else else
manager->setClientType("pc"); manager->setClientType("pc");
...@@ -79,7 +79,8 @@ void DiscoveryManager::handleInfo(const QXmppDiscoveryIq&) ...@@ -79,7 +79,8 @@ void DiscoveryManager::handleInfo(const QXmppDiscoveryIq&)
void DiscoveryManager::handleItems(const QXmppDiscoveryIq &iq) void DiscoveryManager::handleItems(const QXmppDiscoveryIq &iq)
{ {
// request info from all items // request info from all items
for (const QXmppDiscoveryIq::Item &item : iq.items()) { const QList<QXmppDiscoveryIq::Item> items = iq.items();
for (const QXmppDiscoveryIq::Item &item : items) {
if (item.jid() == client->configuration().domain()) if (item.jid() == client->configuration().domain())
continue; continue;
manager->requestInfo(item.jid()); manager->requestInfo(item.jid());
......
...@@ -30,18 +30,18 @@ ...@@ -30,18 +30,18 @@
// Kaidan // Kaidan
#include "DownloadManager.h" #include "DownloadManager.h"
#include "Globals.h"
#include "Kaidan.h" #include "Kaidan.h"
#include "TransferCache.h"
#include "MessageModel.h" #include "MessageModel.h"
#include "Globals.h" #include "TransferCache.h"
// C++ // C++
#include <utility> #include <utility>
// Qt // Qt
#include "QDir" #include <QDir>
#include "QStandardPaths" #include <QNetworkAccessManager>
#include "QNetworkRequest" #include <QNetworkReply>
#include "QNetworkReply" #include <QNetworkRequest>
#include "QNetworkAccessManager" #include <QStandardPaths>
DownloadManager::DownloadManager(Kaidan *kaidan, TransferCache *transferCache, DownloadManager::DownloadManager(Kaidan *kaidan, TransferCache *transferCache,
MessageModel *model, QObject *parent) MessageModel *model, QObject *parent)
...@@ -69,7 +69,7 @@ DownloadManager::~DownloadManager() ...@@ -69,7 +69,7 @@ DownloadManager::~DownloadManager()
void DownloadManager::startDownload(const QString &msgId, const QString &url) void DownloadManager::startDownload(const QString &msgId, const QString &url)
{ {
// don't download the same file twice and in parallel // don't download the same file twice and in parallel
if (downloads.keys().contains(msgId)) { if (downloads.contains(msgId)) {
qWarning() << "Tried to download a file that is currently being " qWarning() << "Tried to download a file that is currently being "
"downloaded."; "downloaded.";
return; return;
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#ifndef GLOBALS_H #ifndef GLOBALS_H
#define GLOBALS_H #define GLOBALS_H
#include <QString>
// Application information // Application information
#define APPLICATION_DESCRIPTION "A simple, user-friendly Jabber/XMPP client" #define APPLICATION_DESCRIPTION "A simple, user-friendly Jabber/XMPP client"
...@@ -41,8 +39,8 @@ ...@@ -41,8 +39,8 @@
#define KAIDAN_SETTINGS_AUTH_RESOURCE "auth/resource" #define KAIDAN_SETTINGS_AUTH_RESOURCE "auth/resource"
#define KAIDAN_SETTINGS_AUTH_PASSWD "auth/password" #define KAIDAN_SETTINGS_AUTH_PASSWD "auth/password"
const QString KAIDAN_RESOURCE_RANDOM_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop" #define KAIDAN_RESOURCE_RANDOM_CHARS \
"qrstuvwxyz0123456789"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
// XML namespaces // XML namespaces
#define NS_SPOILERS "urn:xmpp:spoiler:0" #define NS_SPOILERS "urn:xmpp:spoiler:0"
......
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
#define KAIDAN_H #define KAIDAN_H
// Qt // Qt
#include <QColor>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QColor>
// Kaidan // Kaidan
#include "ClientWorker.h" #include "ClientWorker.h"
#include "Globals.h"
#include "Enums.h" #include "Enums.h"
#include "Globals.h"
class QGuiApplication; class QGuiApplication;
class Database; class Database;
...@@ -284,7 +284,7 @@ signals: ...@@ -284,7 +284,7 @@ signals:
/** /**
* The upload progress of a file upload has changed * The upload progress of a file upload has changed
*/ */
void uploadProgressMade(QString msgId, unsigned long sent, unsigned long total); void uploadProgressMade(QString msgId, quint64 sent, quint64 total);
/** /**
* An HTTP File Upload service was discovered * An HTTP File Upload service was discovered
...@@ -362,12 +362,12 @@ public slots: ...@@ -362,12 +362,12 @@ public slots:
/** /**
* Sets the disconnection error/reason * Sets the disconnection error/reason
*/ */
void setDisconnReason(DisconnectionReason reason); void setDisconnReason(Enums::DisconnectionReason reason);
/** /**
* Receives messages from another instance of the application * Receives messages from another instance of the application
*/ */
void receiveMessage(quint32, QByteArray msg) void receiveMessage(quint32, const QByteArray &msg)
{ {
// currently we only send XMPP URIs // currently we only send XMPP URIs
addOpenUri(msg); addOpenUri(msg);
......
...@@ -229,7 +229,7 @@ void MessageModel::addMessage(const Message &msg) ...@@ -229,7 +229,7 @@ void MessageModel::addMessage(const Message &msg)
|| QXmppUtils::jidToBareJid(msg.to()) == m_chatPartner) { || QXmppUtils::jidToBareJid(msg.to()) == m_chatPartner) {
// index where to add the new message // index where to add the new message
int i = 0; int i = 0;
for (const auto &message : m_messages) { for (const auto &message : qAsConst(m_messages)) {
if (msg.stamp() > message.stamp()) { if (msg.stamp() > message.stamp()) {
insertMessage(i, msg); insertMessage(i, msg);
return; return;
......
...@@ -135,7 +135,7 @@ void RegistrationManager::setClient(QXmppClient *client) ...@@ -135,7 +135,7 @@ void RegistrationManager::setClient(QXmppClient *client)
connect(disco, &QXmppDiscoveryManager::infoReceived, connect(disco, &QXmppDiscoveryManager::infoReceived,
this, &RegistrationManager::handleDiscoInfo); this, &RegistrationManager::handleDiscoInfo);
connect(client, &QXmppClient::disconnected, [this] () { connect(client, &QXmppClient::disconnected, this, [=] () {
setRegistrationSupported(false); setRegistrationSupported(false);
}); });
} }
......
...@@ -57,7 +57,7 @@ RosterManager::RosterManager(Kaidan *kaidan, ...@@ -57,7 +57,7 @@ RosterManager::RosterManager(Kaidan *kaidan,
this, &RosterManager::populateRoster); this, &RosterManager::populateRoster);
connect(&manager, &QXmppRosterManager::itemAdded, connect(&manager, &QXmppRosterManager::itemAdded,
[this, vCardManager, model] (const QString &jid) { this, [this, vCardManager, model] (const QString &jid) {
emit model->addItemRequested(RosterItem(manager.getRosterEntry(jid))); emit model->addItemRequested(RosterItem(manager.getRosterEntry(jid)));
vCardManager->fetchVCard(jid); vCardManager->fetchVCard(jid);
...@@ -111,7 +111,8 @@ void RosterManager::populateRoster() ...@@ -111,7 +111,8 @@ void RosterManager::populateRoster()
qDebug() << "[client] [RosterManager] Populating roster"; qDebug() << "[client] [RosterManager] Populating roster";
// create a new list of contacts // create a new list of contacts
QHash<QString, RosterItem> items; QHash<QString, RosterItem> items;
for (const auto &jid : manager.getRosterBareJids()) { const QStringList bareJids = manager.getRosterBareJids();
for (const auto &jid : bareJids) {
items[jid] = RosterItem(manager.getRosterEntry(jid)); items[jid] = RosterItem(manager.getRosterEntry(jid));
if (avatarStorage->getHashOfJid(jid).isEmpty()) if (avatarStorage->getHashOfJid(jid).isEmpty())
......
...@@ -140,7 +140,7 @@ void RosterModel::addItem(const RosterItem &item) ...@@ -140,7 +140,7 @@ void RosterModel::addItem(const RosterItem &item)
// index where to add the new contact // index where to add the new contact
int i = 0; int i = 0;
for (const auto &itrItem : m_items) { for (const auto &itrItem : qAsConst(m_items)) {
if (item.lastExchanged().toMSecsSinceEpoch() >= itrItem.lastExchanged().toMSecsSinceEpoch()) { if (item.lastExchanged().toMSecsSinceEpoch() >= itrItem.lastExchanged().toMSecsSinceEpoch()) {
insertContact(i, item); insertContact(i, item);
return; return;
...@@ -205,7 +205,7 @@ void RosterModel::updateItem(const QString &jid, ...@@ -205,7 +205,7 @@ void RosterModel::updateItem(const QString &jid,
void RosterModel::replaceItems(const QHash<QString, RosterItem> &items) void RosterModel::replaceItems(const QHash<QString, RosterItem> &items)
{ {
QVector<RosterItem> newItems; QVector<RosterItem> newItems;
for (auto item : items.values()) { for (auto item : items) {
// find old item // find old item
auto oldItem = std::find_if( auto oldItem = std::find_if(
m_items.begin(), m_items.begin(),
......
...@@ -80,7 +80,8 @@ void Utils::execQuery(QSqlQuery &query, ...@@ -80,7 +80,8 @@ void Utils::execQuery(QSqlQuery &query,
{ {
prepareQuery(query, sql); prepareQuery(query, sql);
for (const auto &key : bindValues.keys()) const QStringList bindKeys = bindValues.keys();
for (const auto &key : bindKeys)
query.bindValue(key, bindValues.value(key)); query.bindValue(key, bindValues.value(key));
execQuery(query); execQuery(query);
......
...@@ -226,7 +226,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) ...@@ -226,7 +226,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// send a possible link to the primary instance // send a possible link to the primary instance
if (!parser.positionalArguments().isEmpty()) if (!parser.positionalArguments().isEmpty())
app.sendMessage(parser.positionalArguments()[0].toUtf8()); app.sendMessage(parser.positionalArguments().first().toUtf8());
return 0; return 0;
} }
#endif #endif
...@@ -246,7 +246,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) ...@@ -246,7 +246,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// open the XMPP-URI/link (if given) // open the XMPP-URI/link (if given)
if (!parser.positionalArguments().isEmpty()) if (!parser.positionalArguments().isEmpty())
kaidan.addOpenUri(parser.positionalArguments()[0].toUtf8()); kaidan.addOpenUri(parser.positionalArguments().first().toUtf8());
// //
// QML-GUI // QML-GUI
...@@ -258,11 +258,11 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) ...@@ -258,11 +258,11 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
// QtQuickControls2 Style // QtQuickControls2 Style
if (qgetenv("QT_QUICK_CONTROLS_STYLE").isEmpty()) { if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QString defaultStyle = "Universal"; const QString defaultStyle = QStringLiteral("Universal");
#else #else
QString defaultStyle = "Material"; const QString defaultStyle = QStringLiteral("Material");
#endif #endif
qDebug() << "QT_QUICK_CONTROLS_STYLE not set, setting to" << defaultStyle; qDebug() << "QT_QUICK_CONTROLS_STYLE not set, setting to" << defaultStyle;
qputenv("QT_QUICK_CONTROLS_STYLE", defaultStyle.toLatin1()); qputenv("QT_QUICK_CONTROLS_STYLE", defaultStyle.toLatin1());
......
...@@ -186,7 +186,8 @@ void QXmppHttpUpload::startUpload() ...@@ -186,7 +186,8 @@ void QXmppHttpUpload::startUpload()
// other header fields // other header fields
const QMap<QString, QString> &headers = m_slot.headerFields(); const QMap<QString, QString> &headers = m_slot.headerFields();
for (const QString &name : headers.keys()) const QStringList headerKeys = headers.keys();
for (const QString &name : headerKeys)
request.setRawHeader(name.toUtf8(), headers.value(name).toUtf8()); request.setRawHeader(name.toUtf8(), headers.value(name).toUtf8());
// open file // open file
...@@ -204,12 +205,12 @@ void QXmppHttpUpload::startUpload() ...@@ -204,12 +205,12 @@ void QXmppHttpUpload::startUpload()
this, &QXmppHttpUpload::uploadFailed); this, &QXmppHttpUpload::uploadFailed);
// delete file object after upload // delete file object after upload
connect(m_putReply, &QNetworkReply::finished, [this, file] () { connect(m_putReply, &QNetworkReply::finished, this, [=] () {
file->deleteLater(); file->deleteLater();
m_started = false; m_started = false;
}); });
connect(m_putReply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), connect(m_putReply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),
[this, file] () { this, [=] () {
file->deleteLater(); file->deleteLater();
m_started = false; m_started = false;
}); });
...@@ -235,9 +236,8 @@ QXmppUploadManager::QXmppUploadManager() ...@@ -235,9 +236,8 @@ QXmppUploadManager::QXmppUploadManager()
QXmppUploadManager::~QXmppUploadManager() QXmppUploadManager::~QXmppUploadManager()
{ {
for (QXmppHttpUpload *upload : m_uploads) { for (QXmppHttpUpload *upload : qAsConst(m_uploads))
upload->abort(); upload->abort();
}
} }
/// Requests an upload slot and starts uploading the file /// Requests an upload slot and starts uploading the file
...@@ -299,7 +299,7 @@ void QXmppUploadManager::startNextUpload() ...@@ -299,7 +299,7 @@ void QXmppUploadManager::startNextUpload()
void QXmppUploadManager::handleSlot(const QXmppHttpUploadSlotIq &slot) void QXmppUploadManager::handleSlot(const QXmppHttpUploadSlotIq &slot)
{ {
for (QXmppHttpUpload *upload : m_uploads) { for (QXmppHttpUpload *upload : qAsConst(m_uploads)) {
if (upload->requestId() != slot.id()) if (upload->requestId() != slot.id())
continue; continue;
...@@ -321,7 +321,7 @@ void QXmppUploadManager::handleSlot(const QXmppHttpUploadSlotIq &slot) ...@@ -321,7 +321,7 @@ void QXmppUploadManager::handleSlot(const QXmppHttpUploadSlotIq &slot)
void QXmppUploadManager::handleRequestError(const QXmppHttpUploadRequestIq &request) void QXmppUploadManager::handleRequestError(const QXmppHttpUploadRequestIq &request)
{ {
for (QXmppHttpUpload *upload : m_uploads) { for (QXmppHttpUpload *upload : qAsConst(m_uploads)) {
if (upload->requestId() == request.id()) { if (upload->requestId() == request.id()) {
m_runningJobs--; m_runningJobs--;
m_uploads.removeAll(upload); m_uploads.removeAll(upload);
......
...@@ -115,7 +115,8 @@ void QXmppUploadRequestManager::handleDiscoInfo(const QXmppDiscoveryIq &iq) ...@@ -115,7 +115,8 @@ void QXmppUploadRequestManager::handleDiscoInfo(const QXmppDiscoveryIq &iq)
if (!iq.features().contains(ns_httpupload)) if (!iq.features().contains(ns_httpupload))
return; return;
for (const QXmppDiscoveryIq::Identity &identity : iq.identities()) { const QList<QXmppDiscoveryIq::Identity> identities = iq.identities();
for (const auto &identity : identities) {
if (identity.category() == "store" && identity.type() == "file") if (identity.category() == "store" && identity.type() == "file")
goto addService; goto addService;
} }
...@@ -127,7 +128,7 @@ addService: ...@@ -127,7 +128,7 @@ addService:
// get size limit // get size limit
bool isFormNsCorrect = false; bool isFormNsCorrect = false;
for (const QXmppDataForm::Field &field : iq.form().fields()) { for (const QXmppDataForm::Field &field : qAsConst(iq.form().fields())) {
if (field.key() == "FORM_TYPE") { if (</