aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2020-02-02 18:14:27 +0100
committerLNJ <lnj@kaidan.im>2020-02-03 00:11:55 +0100
commit57f1b775197aed1d32e98b0299c0999339a7d5f6 (patch)
treece5702781e15f3a5c438ab153edf06f51a501b29 /src/client
parent99b850a3008bbb03d3449d683adb87839f7d5c4b (diff)
downloadqxmpp-57f1b775197aed1d32e98b0299c0999339a7d5f6.tar.gz
Run clang-format also on all cpp files
Diffstat (limited to 'src/client')
-rw-r--r--src/client/QXmppArchiveManager.cpp16
-rw-r--r--src/client/QXmppBookmarkManager.cpp23
-rw-r--r--src/client/QXmppCallManager.cpp84
-rw-r--r--src/client/QXmppCarbonManager.cpp18
-rw-r--r--src/client/QXmppClient.cpp71
-rw-r--r--src/client/QXmppClientExtension.cpp1
-rw-r--r--src/client/QXmppClient_p.h4
-rw-r--r--src/client/QXmppConfiguration.cpp28
-rw-r--r--src/client/QXmppDiscoveryManager.cpp39
-rw-r--r--src/client/QXmppEntityTimeManager.cpp10
-rw-r--r--src/client/QXmppInvokable.cpp68
-rw-r--r--src/client/QXmppMessageReceiptManager.cpp7
-rw-r--r--src/client/QXmppMucManager.cpp43
-rw-r--r--src/client/QXmppOutgoingClient.cpp168
-rw-r--r--src/client/QXmppRemoteMethod.cpp31
-rw-r--r--src/client/QXmppRemoteMethod.h6
-rw-r--r--src/client/QXmppRosterManager.cpp118
-rw-r--r--src/client/QXmppRpcManager.cpp102
-rw-r--r--src/client/QXmppTransferManager.cpp234
-rw-r--r--src/client/QXmppTransferManager.h4
-rw-r--r--src/client/QXmppUploadRequestManager.cpp4
-rw-r--r--src/client/QXmppVCardManager.cpp7
-rw-r--r--src/client/QXmppVersionManager.cpp7
23 files changed, 437 insertions, 656 deletions
diff --git a/src/client/QXmppArchiveManager.cpp b/src/client/QXmppArchiveManager.cpp
index e9bb5ef8..afade708 100644
--- a/src/client/QXmppArchiveManager.cpp
+++ b/src/client/QXmppArchiveManager.cpp
@@ -42,22 +42,17 @@ bool QXmppArchiveManager::handleStanza(const QDomElement &element)
return false;
// XEP-0136: Message Archiving
- if(QXmppArchiveChatIq::isArchiveChatIq(element))
- {
+ if (QXmppArchiveChatIq::isArchiveChatIq(element)) {
QXmppArchiveChatIq archiveIq;
archiveIq.parse(element);
emit archiveChatReceived(archiveIq.chat(), archiveIq.resultSetReply());
return true;
- }
- else if(QXmppArchiveListIq::isArchiveListIq(element))
- {
+ } else if (QXmppArchiveListIq::isArchiveListIq(element)) {
QXmppArchiveListIq archiveIq;
archiveIq.parse(element);
emit archiveListReceived(archiveIq.chats(), archiveIq.resultSetReply());
return true;
- }
- else if(QXmppArchivePrefIq::isArchivePrefIq(element))
- {
+ } else if (QXmppArchivePrefIq::isArchivePrefIq(element)) {
// TODO: handle preference iq
QXmppArchivePrefIq archiveIq;
archiveIq.parse(element);
@@ -76,8 +71,8 @@ bool QXmppArchiveManager::handleStanza(const QDomElement &element)
/// \param end Optional end time.
/// \param rsm Optional Result Set Management query
///
-void QXmppArchiveManager::listCollections(const QString& jid, const QDateTime& start,
- const QDateTime& end, const QXmppResultSetQuery &rsm)
+void QXmppArchiveManager::listCollections(const QString &jid, const QDateTime &start,
+ const QDateTime &end, const QXmppResultSetQuery &rsm)
{
QXmppArchiveListIq packet;
packet.setResultSetQuery(rsm);
@@ -103,7 +98,6 @@ void QXmppArchiveManager::listCollections(const QString &jid, const QDateTime &s
listCollections(jid, start, end, rsm);
}
-
/// Removes the specified collection(s).
///
/// \param jid The JID of the collection
diff --git a/src/client/QXmppBookmarkManager.cpp b/src/client/QXmppBookmarkManager.cpp
index 8afb0bd0..697ed47b 100644
--- a/src/client/QXmppBookmarkManager.cpp
+++ b/src/client/QXmppBookmarkManager.cpp
@@ -66,7 +66,7 @@ bool QXmppPrivateStorageIq::isPrivateStorageIq(const QDomElement &element)
{
const QDomElement queryElement = element.firstChildElement("query");
return queryElement.namespaceURI() == ns_private &&
- QXmppBookmarkSet::isBookmarkSet(queryElement.firstChildElement());
+ QXmppBookmarkSet::isBookmarkSet(queryElement.firstChildElement());
}
void QXmppPrivateStorageIq::parseElementFromChild(const QDomElement &element)
@@ -150,35 +150,29 @@ void QXmppBookmarkManager::setClient(QXmppClient *client)
QXmppClientExtension::setClient(client);
connect(client, &QXmppClient::connected,
- this, &QXmppBookmarkManager::slotConnected);
+ this, &QXmppBookmarkManager::slotConnected);
connect(client, &QXmppClient::disconnected,
- this, &QXmppBookmarkManager::slotDisconnected);
+ this, &QXmppBookmarkManager::slotDisconnected);
}
bool QXmppBookmarkManager::handleStanza(const QDomElement &stanza)
{
- if (stanza.tagName() == "iq")
- {
- if (QXmppPrivateStorageIq::isPrivateStorageIq(stanza))
- {
+ if (stanza.tagName() == "iq") {
+ if (QXmppPrivateStorageIq::isPrivateStorageIq(stanza)) {
QXmppPrivateStorageIq iq;
iq.parse(stanza);
- if (iq.type() == QXmppIq::Result)
- {
+ if (iq.type() == QXmppIq::Result) {
d->bookmarks = iq.bookmarks();
d->bookmarksReceived = true;
emit bookmarksReceived(d->bookmarks);
}
return true;
- }
- else if (!d->pendingId.isEmpty() && stanza.attribute("id") == d->pendingId)
- {
+ } else if (!d->pendingId.isEmpty() && stanza.attribute("id") == d->pendingId) {
QXmppIq iq;
iq.parse(stanza);
- if (iq.type() == QXmppIq::Result)
- {
+ if (iq.type() == QXmppIq::Result) {
d->bookmarks = d->pendingBookmarks;
emit bookmarksReceived(d->bookmarks);
}
@@ -202,4 +196,3 @@ void QXmppBookmarkManager::slotDisconnected()
d->bookmarks = QXmppBookmarkSet();
d->bookmarksReceived = false;
}
-
diff --git a/src/client/QXmppCallManager.cpp b/src/client/QXmppCallManager.cpp
index 067efb82..5d63b4a6 100644
--- a/src/client/QXmppCallManager.cpp
+++ b/src/client/QXmppCallManager.cpp
@@ -42,7 +42,8 @@ static const QLatin1String VIDEO_MEDIA("video");
class QXmppCallPrivate
{
public:
- class Stream {
+ class Stream
+ {
public:
QXmppRtpChannel *channel;
QXmppIceConnection *connection;
@@ -77,7 +78,7 @@ public:
// Media streams
bool sendVideo;
- QList<Stream*> streams;
+ QList<Stream *> streams;
QIODevice::OpenMode audioMode;
QIODevice::OpenMode videoMode;
@@ -92,7 +93,7 @@ public:
QXmppCall *findCall(const QString &sid) const;
QXmppCall *findCall(const QString &sid, QXmppCall::Direction direction) const;
- QList<QXmppCall*> calls;
+ QList<QXmppCall *> calls;
QHostAddress stunHost;
quint16 stunPort;
QHostAddress turnHost;
@@ -106,12 +107,12 @@ private:
QXmppCallPrivate::QXmppCallPrivate(QXmppCall *qq)
: direction(QXmppCall::IncomingDirection),
- manager(nullptr),
- state(QXmppCall::ConnectingState),
- sendVideo(false),
- audioMode(QIODevice::NotOpen),
- videoMode(QIODevice::NotOpen),
- q(qq)
+ manager(nullptr),
+ state(QXmppCall::ConnectingState),
+ sendVideo(false),
+ audioMode(QIODevice::NotOpen),
+ videoMode(QIODevice::NotOpen),
+ q(qq)
{
qRegisterMetaType<QXmppCall::State>();
}
@@ -164,7 +165,7 @@ bool QXmppCallPrivate::handleTransport(QXmppCallPrivate::Stream *stream, const Q
{
stream->connection->setRemoteUser(content.transportUser());
stream->connection->setRemotePassword(content.transportPassword());
- const auto & candidates = content.transportCandidates();
+ const auto &candidates = content.transportCandidates();
for (const auto &candidate : candidates)
stream->connection->addRemoteCandidate(candidate);
@@ -264,7 +265,7 @@ void QXmppCallPrivate::handleRequest(const QXmppJingleIq &iq)
}
streams << stream;
- // accept content
+ // accept content
QXmppJingleIq iq;
iq.setTo(q->jid());
iq.setType(QXmppIq::Set);
@@ -285,7 +286,6 @@ void QXmppCallPrivate::handleRequest(const QXmppJingleIq &iq)
// FIXME: what action?
return;
}
-
}
}
@@ -327,25 +327,25 @@ QXmppCallPrivate::Stream *QXmppCallPrivate::createStream(const QString &media)
// connect signals
QObject::connect(stream->connection, &QXmppIceConnection::localCandidatesChanged,
- q, &QXmppCall::localCandidatesChanged);
+ q, &QXmppCall::localCandidatesChanged);
QObject::connect(stream->connection, &QXmppIceConnection::connected,
- q, &QXmppCall::updateOpenMode);
+ q, &QXmppCall::updateOpenMode);
QObject::connect(q, &QXmppCall::stateChanged,
- q, &QXmppCall::updateOpenMode);
+ q, &QXmppCall::updateOpenMode);
QObject::connect(stream->connection, &QXmppIceConnection::disconnected,
- q, &QXmppCall::hangup);
+ q, &QXmppCall::hangup);
if (channelObject) {
QXmppIceComponent *rtpComponent = stream->connection->component(RTP_COMPONENT);
QObject::connect(rtpComponent, SIGNAL(datagramReceived(QByteArray)),
- channelObject, SLOT(datagramReceived(QByteArray)));
+ channelObject, SLOT(datagramReceived(QByteArray)));
QObject::connect(channelObject, SIGNAL(sendDatagram(QByteArray)),
- rtpComponent, SLOT(sendDatagram(QByteArray)));
+ rtpComponent, SLOT(sendDatagram(QByteArray)));
}
return stream;
}
@@ -409,8 +409,7 @@ bool QXmppCallPrivate::sendRequest(const QXmppJingleIq &iq)
void QXmppCallPrivate::setState(QXmppCall::State newState)
{
- if (state != newState)
- {
+ if (state != newState) {
state = newState;
emit q->stateChanged(state);
@@ -470,8 +469,7 @@ QXmppCall::~QXmppCall()
void QXmppCall::accept()
{
- if (d->direction == IncomingDirection && d->state == ConnectingState)
- {
+ if (d->direction == IncomingDirection && d->state == ConnectingState) {
Q_ASSERT(d->streams.size() == 1);
QXmppCallPrivate::Stream *stream = d->streams.first();
@@ -503,7 +501,7 @@ QXmppRtpAudioChannel *QXmppCall::audioChannel() const
{
QXmppCallPrivate::Stream *stream = d->findStreamByMedia(AUDIO_MEDIA);
if (stream)
- return static_cast<QXmppRtpAudioChannel*>(stream->channel);
+ return static_cast<QXmppRtpAudioChannel *>(stream->channel);
else
return nullptr;
}
@@ -522,7 +520,7 @@ QXmppRtpVideoChannel *QXmppCall::videoChannel() const
{
QXmppCallPrivate::Stream *stream = d->findStreamByMedia(VIDEO_MEDIA);
if (stream)
- return static_cast<QXmppRtpVideoChannel*>(stream->channel);
+ return static_cast<QXmppRtpVideoChannel *>(stream->channel);
else
return nullptr;
}
@@ -568,7 +566,7 @@ void QXmppCall::hangup()
void QXmppCall::localCandidatesChanged()
{
// find the stream
- auto *conn = qobject_cast<QXmppIceConnection*>(sender());
+ auto *conn = qobject_cast<QXmppIceConnection *>(sender());
QXmppCallPrivate::Stream *stream = nullptr;
for (auto *ptr : d->streams) {
if (ptr->connection == conn) {
@@ -689,8 +687,8 @@ void QXmppCall::stopVideo()
QXmppCallManagerPrivate::QXmppCallManagerPrivate(QXmppCallManager *qq)
: stunPort(0),
- turnPort(0),
- q(qq)
+ turnPort(0),
+ q(qq)
{
}
@@ -698,7 +696,7 @@ QXmppCall *QXmppCallManagerPrivate::findCall(const QString &sid) const
{
for (auto *call : calls)
if (call->sid() == sid)
- return call;
+ return call;
return nullptr;
}
@@ -706,7 +704,7 @@ QXmppCall *QXmppCallManagerPrivate::findCall(const QString &sid, QXmppCall::Dire
{
for (auto *call : calls)
if (call->sid() == sid && call->direction() == direction)
- return call;
+ return call;
return nullptr;
}
@@ -730,20 +728,18 @@ QXmppCallManager::~QXmppCallManager()
QStringList QXmppCallManager::discoveryFeatures() const
{
return QStringList()
- << ns_jingle // XEP-0166 : Jingle
- << ns_jingle_rtp // XEP-0167 : Jingle RTP Sessions
+ << ns_jingle // XEP-0166 : Jingle
+ << ns_jingle_rtp // XEP-0167 : Jingle RTP Sessions
<< ns_jingle_rtp_audio
<< ns_jingle_rtp_video
- << ns_jingle_ice_udp; // XEP-0176 : Jingle ICE-UDP Transport Method
+ << ns_jingle_ice_udp; // XEP-0176 : Jingle ICE-UDP Transport Method
}
bool QXmppCallManager::handleStanza(const QDomElement &element)
{
- if(element.tagName() == "iq")
- {
+ if (element.tagName() == "iq") {
// XEP-0166: Jingle
- if (QXmppJingleIq::isJingleIq(element))
- {
+ if (QXmppJingleIq::isJingleIq(element)) {
QXmppJingleIq jingleIq;
jingleIq.parse(element);
_q_jingleIqReceived(jingleIq);
@@ -760,13 +756,13 @@ void QXmppCallManager::setClient(QXmppClient *client)
QXmppClientExtension::setClient(client);
connect(client, &QXmppClient::disconnected,
- this, &QXmppCallManager::_q_disconnected);
+ this, &QXmppCallManager::_q_disconnected);
connect(client, &QXmppClient::iqReceived,
- this, &QXmppCallManager::_q_iqReceived);
+ this, &QXmppCallManager::_q_iqReceived);
connect(client, &QXmppClient::presenceReceived,
- this, &QXmppCallManager::_q_presenceReceived);
+ this, &QXmppCallManager::_q_presenceReceived);
}
/// \endcond
@@ -793,7 +789,7 @@ QXmppCall *QXmppCallManager::call(const QString &jid)
// register call
d->calls << call;
connect(call, &QObject::destroyed,
- this, &QXmppCallManager::_q_callDestroyed);
+ this, &QXmppCallManager::_q_callDestroyed);
emit callStarted(call);
call->d->sendInvite();
@@ -846,7 +842,7 @@ void QXmppCallManager::setTurnPassword(const QString &password)
void QXmppCallManager::_q_callDestroyed(QObject *object)
{
- d->calls.removeAll(static_cast<QXmppCall*>(object));
+ d->calls.removeAll(static_cast<QXmppCall *>(object));
}
/// Handles disconnection from server.
@@ -879,8 +875,7 @@ void QXmppCallManager::_q_jingleIqReceived(const QXmppJingleIq &iq)
if (iq.type() != QXmppIq::Set)
return;
- if (iq.action() == QXmppJingleIq::SessionInitiate)
- {
+ if (iq.action() == QXmppJingleIq::SessionInitiate) {
// build call
QXmppCall *call = new QXmppCall(iq.from(), QXmppCall::IncomingDirection, this);
call->d->sid = iq.sid();
@@ -909,7 +904,7 @@ void QXmppCallManager::_q_jingleIqReceived(const QXmppJingleIq &iq)
// register call
d->calls << call;
connect(call, &QObject::destroyed,
- this, &QXmppCallManager::_q_callDestroyed);
+ this, &QXmppCallManager::_q_callDestroyed);
// send ringing indication
QXmppJingleIq ringing;
@@ -950,4 +945,3 @@ void QXmppCallManager::_q_presenceReceived(const QXmppPresence &presence)
}
}
}
-
diff --git a/src/client/QXmppCarbonManager.cpp b/src/client/QXmppCarbonManager.cpp
index 68277f90..d403e6de 100644
--- a/src/client/QXmppCarbonManager.cpp
+++ b/src/client/QXmppCarbonManager.cpp
@@ -57,12 +57,12 @@ bool QXmppCarbonManager::carbonsEnabled() const
void QXmppCarbonManager::setCarbonsEnabled(bool enabled)
{
- if(m_carbonsEnabled == enabled)
+ if (m_carbonsEnabled == enabled)
return;
m_carbonsEnabled = enabled;
- if(client()) {
+ if (client()) {
QXmppIq iq(QXmppIq::Set);
QXmppElement carbonselement;
carbonselement.setTagName(m_carbonsEnabled ? "enable" : "disable");
@@ -80,31 +80,31 @@ QStringList QXmppCarbonManager::discoveryFeatures() const
bool QXmppCarbonManager::handleStanza(const QDomElement &element)
{
- if(element.tagName() != "message")
+ if (element.tagName() != "message")
return false;
bool sent = true;
QDomElement carbon = element.firstChildElement("sent");
- if(carbon.isNull()) {
+ if (carbon.isNull()) {
carbon = element.firstChildElement("received");
sent = false;
}
- if(carbon.isNull() || carbon.namespaceURI() != ns_carbons)
- return false; // Neither sent nor received -> no carbon message
+ if (carbon.isNull() || carbon.namespaceURI() != ns_carbons)
+ return false; // Neither sent nor received -> no carbon message
QDomElement forwarded = carbon.firstChildElement("forwarded");
- if(forwarded.isNull())
+ if (forwarded.isNull())
return false;
QDomElement messageelement = forwarded.firstChildElement("message");
- if(messageelement.isNull())
+ if (messageelement.isNull())
return false;
QXmppMessage message;
message.parse(messageelement);
- if(sent)
+ if (sent)
emit messageSent(message);
else
emit messageReceived(message);
diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp
index 6c958dd6..97785f25 100644
--- a/src/client/QXmppClient.cpp
+++ b/src/client/QXmppClient.cpp
@@ -42,22 +42,15 @@
#include <QTimer>
/// \cond
-QXmppClientPrivate::QXmppClientPrivate(QXmppClient *qq)
- : clientPresence(QXmppPresence::Available)
- , logger(nullptr)
- , stream(nullptr)
- , receivedConflict(false)
- , reconnectionTries(0)
- , reconnectionTimer(nullptr)
- , isActive(true)
- , q(qq)
+QXmppClientPrivate::QXmppClientPrivate(QXmppClient* qq)
+ : clientPresence(QXmppPresence::Available), logger(nullptr), stream(nullptr), receivedConflict(false), reconnectionTries(0), reconnectionTimer(nullptr), isActive(true), q(qq)
{
}
void QXmppClientPrivate::addProperCapability(QXmppPresence& presence)
{
auto* ext = q->findExtension<QXmppDiscoveryManager>();
- if(ext) {
+ if (ext) {
presence.setCapabilityHash("sha-1");
presence.setCapabilityNode(ext->clientCapabilitiesNode());
presence.setCapabilityVer(ext->capabilities().verificationString());
@@ -81,40 +74,40 @@ int QXmppClientPrivate::getNextReconnectTime() const
/// \param parent is passed to the QObject's constructor.
/// The default value is 0.
-QXmppClient::QXmppClient(QObject *parent)
+QXmppClient::QXmppClient(QObject* parent)
: QXmppLoggable(parent),
- d(new QXmppClientPrivate(this))
+ d(new QXmppClientPrivate(this))
{
d->stream = new QXmppOutgoingClient(this);
d->addProperCapability(d->clientPresence);
connect(d->stream, &QXmppOutgoingClient::elementReceived,
- this, &QXmppClient::_q_elementReceived);
+ this, &QXmppClient::_q_elementReceived);
connect(d->stream, &QXmppOutgoingClient::messageReceived,
- this, &QXmppClient::messageReceived);
+ this, &QXmppClient::messageReceived);
connect(d->stream, &QXmppOutgoingClient::presenceReceived,
- this, &QXmppClient::presenceReceived);
+ this, &QXmppClient::presenceReceived);
connect(d->stream, &QXmppOutgoingClient::iqReceived,
- this, &QXmppClient::iqReceived);
+ this, &QXmppClient::iqReceived);
connect(d->stream, &QXmppOutgoingClient::sslErrors,
- this, &QXmppClient::sslErrors);
+ this, &QXmppClient::sslErrors);
connect(d->stream->socket(), &QAbstractSocket::stateChanged,
- this, &QXmppClient::_q_socketStateChanged);
+ this, &QXmppClient::_q_socketStateChanged);
connect(d->stream, &QXmppStream::connected,
- this, &QXmppClient::_q_streamConnected);
+ this, &QXmppClient::_q_streamConnected);
connect(d->stream, &QXmppStream::disconnected,
- this, &QXmppClient::_q_streamDisconnected);
+ this, &QXmppClient::_q_streamDisconnected);
connect(d->stream, &QXmppOutgoingClient::error,
- this, &QXmppClient::_q_streamError);
+ this, &QXmppClient::_q_streamError);
// reconnection
d->reconnectionTimer = new QTimer(this);
@@ -155,10 +148,9 @@ bool QXmppClient::addExtension(QXmppClientExtension* extension)
/// \param index
/// \param extension
-bool QXmppClient::insertExtension(int index, QXmppClientExtension *extension)
+bool QXmppClient::insertExtension(int index, QXmppClientExtension* extension)
{
- if (d->extensions.contains(extension))
- {
+ if (d->extensions.contains(extension)) {
qWarning("Cannot add extension, it has already been added");
return false;
}
@@ -176,8 +168,7 @@ bool QXmppClient::insertExtension(int index, QXmppClientExtension *extension)
bool QXmppClient::removeExtension(QXmppClientExtension* extension)
{
- if (d->extensions.contains(extension))
- {
+ if (d->extensions.contains(extension)) {
d->extensions.removeAll(extension);
delete extension;
return true;
@@ -226,7 +217,7 @@ void QXmppClient::connectToServer(const QXmppConfiguration& config,
/// \param jid JID for the account.
/// \param password Password for the account.
-void QXmppClient::connectToServer(const QString &jid, const QString &password)
+void QXmppClient::connectToServer(const QString& jid, const QString& password)
{
QXmppConfiguration config;
config.setJid(jid);
@@ -344,17 +335,16 @@ QXmppRosterManager& QXmppClient::rosterManager()
void QXmppClient::sendMessage(const QString& bareJid, const QString& message)
{
- QXmppRosterManager *rosterManager = findExtension<QXmppRosterManager>();
+ QXmppRosterManager* rosterManager = findExtension<QXmppRosterManager>();
const QStringList resources = rosterManager
- ? rosterManager->getResources(bareJid)
- : QStringList();
+ ? rosterManager->getResources(bareJid)
+ : QStringList();
if (!resources.isEmpty()) {
- for (const auto &resource : resources) {
+ for (const auto& resource : resources) {
sendPacket(
- QXmppMessage({}, bareJid + QStringLiteral("/") + resource, message)
- );
+ QXmppMessage({}, bareJid + QStringLiteral("/") + resource, message));
}
} else {
sendPacket(QXmppMessage({}, bareJid, message));
@@ -400,8 +390,7 @@ void QXmppClient::setClientPresence(const QXmppPresence& presence)
d->clientPresence = presence;
d->addProperCapability(d->clientPresence);
- if (presence.type() == QXmppPresence::Unavailable)
- {
+ if (presence.type() == QXmppPresence::Unavailable) {
// cancel reconnection
d->reconnectionTimer->stop();
@@ -411,8 +400,7 @@ void QXmppClient::setClientPresence(const QXmppPresence& presence)
sendPacket(d->clientPresence);
d->stream->disconnectFromHost();
- }
- else if (d->stream->isConnected())
+ } else if (d->stream->isConnected())
sendPacket(d->clientPresence);
else
connectToServer(d->stream->configuration(), presence);
@@ -467,9 +455,9 @@ QXmppVersionManager& QXmppClient::versionManager()
/// \param element
/// \param handled
-void QXmppClient::_q_elementReceived(const QDomElement &element, bool &handled)
+void QXmppClient::_q_elementReceived(const QDomElement& element, bool& handled)
{
- for (auto *extension : d->extensions) {
+ for (auto* extension : d->extensions) {
if (extension->handleStanza(element)) {
handled = true;
return;
@@ -537,14 +525,14 @@ void QXmppClient::_q_streamError(QXmppClient::Error err)
/// Returns the QXmppLogger associated with the current QXmppClient.
-QXmppLogger *QXmppClient::logger() const
+QXmppLogger* QXmppClient::logger() const
{
return d->logger;
}
/// Sets the QXmppLogger associated with the current QXmppClient.
-void QXmppClient::setLogger(QXmppLogger *logger)
+void QXmppClient::setLogger(QXmppLogger* logger)
{
if (logger != d->logger) {
if (d->logger) {
@@ -569,4 +557,3 @@ void QXmppClient::setLogger(QXmppLogger *logger)
emit loggerChanged(d->logger);
}
}
-
diff --git a/src/client/QXmppClientExtension.cpp b/src/client/QXmppClientExtension.cpp
index 01f0ab8c..ff4c5fd7 100644
--- a/src/client/QXmppClientExtension.cpp
+++ b/src/client/QXmppClientExtension.cpp
@@ -80,4 +80,3 @@ void QXmppClientExtension::setClient(QXmppClient *client)
{
d->client = client;
}
-
diff --git a/src/client/QXmppClient_p.h b/src/client/QXmppClient_p.h
index 4ae1f637..6045ef3a 100644
--- a/src/client/QXmppClient_p.h
+++ b/src/client/QXmppClient_p.h
@@ -52,7 +52,7 @@ public:
/// Current presence of the client
QXmppPresence clientPresence;
- QList<QXmppClientExtension*> extensions;
+ QList<QXmppClientExtension *> extensions;
QXmppLogger *logger;
/// Pointer to the XMPP stream
QXmppOutgoingClient *stream;
@@ -72,4 +72,4 @@ private:
QXmppClient *q;
};
-#endif // QXMPPCLIENT_P_H
+#endif // QXMPPCLIENT_P_H
diff --git a/src/client/QXmppConfiguration.cpp b/src/client/QXmppConfiguration.cpp
index 200dc47c..888f0603 100644
--- a/src/client/QXmppConfiguration.cpp
+++ b/src/client/QXmppConfiguration.cpp
@@ -78,19 +78,7 @@ public:
};
QXmppConfigurationPrivate::QXmppConfigurationPrivate()
- : port(5222)
- , resource("QXmpp")
- , autoAcceptSubscriptions(false)
- , sendIntialPresence(true)
- , sendRosterRequest(true)
- , keepAliveInterval(60)
- , keepAliveTimeout(20)
- , autoReconnectionEnabled(true)
- , useSASLAuthentication(true)
- , useNonSASLAuthentication(true)
- , ignoreSslErrors(false)
- , streamSecurityMode(QXmppConfiguration::TLSEnabled)
- , nonSASLAuthMechanism(QXmppConfiguration::NonSASLDigest)
+ : port(5222), resource("QXmpp"), autoAcceptSubscriptions(false), sendIntialPresence(true), sendRosterRequest(true), keepAliveInterval(60), keepAliveTimeout(20), autoReconnectionEnabled(true), useSASLAuthentication(true), useNonSASLAuthentication(true), ignoreSslErrors(false), streamSecurityMode(QXmppConfiguration::TLSEnabled), nonSASLAuthMechanism(QXmppConfiguration::NonSASLDigest)
{
}
@@ -103,7 +91,7 @@ QXmppConfiguration::QXmppConfiguration()
/// Creates a copy of \a other.
-QXmppConfiguration::QXmppConfiguration(const QXmppConfiguration &other)
+QXmppConfiguration::QXmppConfiguration(const QXmppConfiguration& other)
: d(other.d)
{
}
@@ -117,7 +105,7 @@ QXmppConfiguration::~QXmppConfiguration()
/// Assigns \a other to this QXmppConfiguration.
-QXmppConfiguration& QXmppConfiguration::operator=(const QXmppConfiguration &other)
+QXmppConfiguration& QXmppConfiguration::operator=(const QXmppConfiguration& other)
{
d = other.d;
return *this;
@@ -296,7 +284,7 @@ QString QXmppConfiguration::jidBare() const
if (d->user.isEmpty())
return d->domain;
else
- return d->user+"@"+d->domain;
+ return d->user + "@" + d->domain;
}
/// Returns the access token used for X-FACEBOOK-PLATFORM authentication.
@@ -474,7 +462,7 @@ QXmppConfiguration::StreamSecurityMode QXmppConfiguration::streamSecurityMode()
/// \param mode StreamSecurityMode
void QXmppConfiguration::setStreamSecurityMode(
- QXmppConfiguration::StreamSecurityMode mode)
+ QXmppConfiguration::StreamSecurityMode mode)
{
d->streamSecurityMode = mode;
}
@@ -495,7 +483,7 @@ QXmppConfiguration::NonSASLAuthMechanism QXmppConfiguration::nonSASLAuthMechanis
///
void QXmppConfiguration::setNonSASLAuthMechanism(
- QXmppConfiguration::NonSASLAuthMechanism mech)
+ QXmppConfiguration::NonSASLAuthMechanism mech)
{
d->nonSASLAuthMechanism = mech;
}
@@ -512,7 +500,7 @@ QString QXmppConfiguration::saslAuthMechanism() const
/// Valid values: "SCRAM-SHA-256", "SCRAM-SHA-1", "DIGEST-MD5", "PLAIN", "ANONYMOUS",
// "X-FACEBOOK-PLATFORM", "X-MESSENGER-OAUTH2", "X-OAUTH2"
-void QXmppConfiguration::setSaslAuthMechanism(const QString &mechanism)
+void QXmppConfiguration::setSaslAuthMechanism(const QString& mechanism)
{
d->saslAuthMechanism = mechanism;
}
@@ -584,7 +572,7 @@ int QXmppConfiguration::keepAliveTimeout() const
/// Specifies a list of trusted CA certificates.
-void QXmppConfiguration::setCaCertificates(const QList<QSslCertificate> &caCertificates)
+void QXmppConfiguration::setCaCertificates(const QList<QSslCertificate>& caCertificates)
{
d->caCertificates = caCertificates;
}
diff --git a/src/client/QXmppDiscoveryManager.cpp b/src/client/QXmppDiscoveryManager.cpp
index 21c3c397..0088fb2b 100644
--- a/src/client/QXmppDiscoveryManager.cpp
+++ b/src/client/QXmppDiscoveryManager.cpp
@@ -75,9 +75,9 @@ QString QXmppDiscoveryManager::requestInfo(const QString& jid, const QString& no
request.setType(QXmppIq::Get);
request.setQueryType(QXmppDiscoveryIq::InfoQuery);
request.setTo(jid);
- if(!node.isEmpty())
+ if (!node.isEmpty())
request.setQueryNode(node);
- if(client()->sendPacket(request))
+ if (client()->sendPacket(request))
return request.id();
else
return QString();
@@ -94,9 +94,9 @@ QString QXmppDiscoveryManager::requestItems(const QString& jid, const QString& n
request.setType(QXmppIq::Get);
request.setQueryType(QXmppDiscoveryIq::ItemsQuery);
request.setTo(jid);
- if(!node.isEmpty())
+ if (!node.isEmpty())
request.setQueryNode(node);
- if(client()->sendPacket(request))
+ if (client()->sendPacket(request))
return request.id();
else
return QString();
@@ -113,16 +113,16 @@ QXmppDiscoveryIq QXmppDiscoveryManager::capabilities()
// features
QStringList features;
features
- << ns_data // XEP-0004: Data Forms
- << ns_rsm // XEP-0059: Result Set Management
- << ns_xhtml_im // XEP-0071: XHTML-IM
- << ns_chat_states // XEP-0085: Chat State Notifications
- << ns_capabilities // XEP-0115: Entity Capabilities
- << ns_ping // XEP-0199: XMPP Ping
- << ns_attention // XEP-0224: Attention
- << ns_chat_markers; // XEP-0333: Chat Markers
-
- for (auto *extension : client()->extensions()) {
+ << ns_data // XEP-0004: Data Forms
+ << ns_rsm // XEP-0059: Result Set Management
+ << ns_xhtml_im // XEP-0071: XHTML-IM
+ << ns_chat_states // XEP-0085: Chat State Notifications
+ << ns_capabilities // XEP-0115: Entity Capabilities
+ << ns_ping // XEP-0199: XMPP Ping
+ << ns_attention // XEP-0224: Attention
+ << ns_chat_markers; // XEP-0333: Chat Markers
+
+ for (auto* extension : client()->extensions()) {
if (extension)
features << extension->discoveryFeatures();
}
@@ -138,7 +138,7 @@ QXmppDiscoveryIq QXmppDiscoveryManager::capabilities()
identity.setName(clientName());
identities << identity;
- for (auto *extension : client()->extensions()) {
+ for (auto* extension : client()->extensions()) {
if (extension)
identities << extension->discoveryIdentities();
}
@@ -156,7 +156,7 @@ QXmppDiscoveryIq QXmppDiscoveryManager::capabilities()
///
/// \param node
-void QXmppDiscoveryManager::setClientCapabilitiesNode(const QString &node)
+void QXmppDiscoveryManager::setClientCapabilitiesNode(const QString& node)
{
d->clientCapabilitiesNode = node;
}
@@ -242,7 +242,7 @@ QXmppDataForm QXmppDiscoveryManager::clientInfoForm() const
/// Sets the client's extended information form, as defined
/// by XEP-0128 Service Discovery Extensions.
-void QXmppDiscoveryManager::setClientInfoForm(const QXmppDataForm &form)
+void QXmppDiscoveryManager::setClientInfoForm(const QXmppDataForm& form)
{
d->clientInfoForm = form;
}
@@ -253,10 +253,9 @@ QStringList QXmppDiscoveryManager::discoveryFeatures() const
return QStringList() << ns_disco_info;
}
-bool QXmppDiscoveryManager::handleStanza(const QDomElement &element)
+bool QXmppDiscoveryManager::handleStanza(const QDomElement& element)
{
- if (element.tagName() == "iq" && QXmppDiscoveryIq::isDiscoveryIq(element))
- {
+ if (element.tagName() == "iq" && QXmppDiscoveryIq::isDiscoveryIq(element)) {
QXmppDiscoveryIq receivedIq;
receivedIq.parse(element);
diff --git a/src/client/QXmppEntityTimeManager.cpp b/src/client/QXmppEntityTimeManager.cpp
index fdb9e24a..3837c32d 100644
--- a/src/client/QXmppEntityTimeManager.cpp
+++ b/src/client/QXmppEntityTimeManager.cpp
@@ -40,7 +40,7 @@ QString QXmppEntityTimeManager::requestTime(const QString& jid)
QXmppEntityTimeIq request;
request.setType(QXmppIq::Get);
request.setTo(jid);
- if(client()->sendPacket(request))
+ if (client()->sendPacket(request))
return request.id();
else
return QString();
@@ -52,15 +52,13 @@ QStringList QXmppEntityTimeManager::discoveryFeatures() const
return QStringList() << ns_entity_time;
}
-bool QXmppEntityTimeManager::handleStanza(const QDomElement &element)
+bool QXmppEntityTimeManager::handleStanza(const QDomElement& element)
{
- if(element.tagName() == "iq" && QXmppEntityTimeIq::isEntityTimeIq(element))
- {
+ if (element.tagName() == "iq" && QXmppEntityTimeIq::isEntityTimeIq(element)) {
QXmppEntityTimeIq entityTime;
entityTime.parse(element);
- if(entityTime.type() == QXmppIq::Get)
- {
+ if (entityTime.type() == QXmppIq::Get) {
// respond to query
QXmppEntityTimeIq responseIq;
responseIq.setType(QXmppIq::Result);
diff --git a/src/client/QXmppInvokable.cpp b/src/client/QXmppInvokable.cpp
index 6b511e30..c3aaa4b9 100644
--- a/src/client/QXmppInvokable.cpp
+++ b/src/client/QXmppInvokable.cpp
@@ -43,15 +43,15 @@ QXmppInvokable::~QXmppInvokable()
{
}
-QVariant QXmppInvokable::dispatch( const QByteArray & method, const QList< QVariant > & args )
+QVariant QXmppInvokable::dispatch(const QByteArray &method, const QList<QVariant> &args)
{
buildMethodHash();
- if( !m_methodHash.contains(method))
+ if (!m_methodHash.contains(method))
return QVariant();
int idx = m_methodHash[method];
- if( paramTypes( args) != metaObject()->method(idx).parameterTypes ())
+ if (paramTypes(args) != metaObject()->method(idx).parameterTypes())
return QVariant();
const char *typeName = metaObject()->method(idx).typeName();
@@ -59,41 +59,37 @@ QVariant QXmppInvokable::dispatch( const QByteArray & method, const QList< QVari
void *result = QMetaType::create(resultType, nullptr);
- QGenericReturnArgument ret( typeName, result );
+ QGenericReturnArgument ret(typeName, result);
QList<QGenericArgument> genericArgs;
QList<QVariant>::ConstIterator iter = args.begin();
- while( iter != args.end())
- {
+ while (iter != args.end()) {
const void *data = iter->data();
const char *name = iter->typeName();
- genericArgs << QGenericArgument(name,data);
+ genericArgs << QGenericArgument(name, data);
++iter;
}
- if( QMetaObject::invokeMethod ( this, method.constData(), ret,
- genericArgs.value(0, QGenericArgument() ),
- genericArgs.value(1, QGenericArgument() ),
- genericArgs.value(2, QGenericArgument() ),
- genericArgs.value(3, QGenericArgument() ),
- genericArgs.value(4, QGenericArgument() ),
- genericArgs.value(5, QGenericArgument() ),
- genericArgs.value(6, QGenericArgument() ),
- genericArgs.value(7, QGenericArgument() ),
- genericArgs.value(8, QGenericArgument() ),
- genericArgs.value(9, QGenericArgument() )) )
- {
- QVariant returnValue( resultType, result);
+ if (QMetaObject::invokeMethod(this, method.constData(), ret,
+ genericArgs.value(0, QGenericArgument()),
+ genericArgs.value(1, QGenericArgument()),
+ genericArgs.value(2, QGenericArgument()),
+ genericArgs.value(3, QGenericArgument()),
+ genericArgs.value(4, QGenericArgument()),
+ genericArgs.value(5, QGenericArgument()),
+ genericArgs.value(6, QGenericArgument()),
+ genericArgs.value(7, QGenericArgument()),
+ genericArgs.value(8, QGenericArgument()),
+ genericArgs.value(9, QGenericArgument()))) {
+ QVariant returnValue(resultType, result);
QMetaType::destroy(resultType, result);
return returnValue;
- }
- else
- {
- qDebug("No such method '%s'", method.constData() );
+ } else {
+ qDebug("No such method '%s'", method.constData());
return QVariant();
}
}
-QList< QByteArray > QXmppInvokable::paramTypes( const QList< QVariant > & params )
+QList<QByteArray> QXmppInvokable::paramTypes(const QList<QVariant> &params)
{
QList<QByteArray> types;
for (const auto &variant : qAsConst(params))
@@ -101,33 +97,29 @@ QList< QByteArray > QXmppInvokable::paramTypes( const QList< QVariant > & params
return types;
}
-void QXmppInvokable::buildMethodHash( )
+void QXmppInvokable::buildMethodHash()
{
QWriteLocker locker(&m_lock);
- if( m_methodHash.size() > 0 )
+ if (m_methodHash.size() > 0)
return;
- int methodCount = metaObject()->methodCount ();
- for( int idx = 0; idx < methodCount; ++idx)
- {
+ int methodCount = metaObject()->methodCount();
+ for (int idx = 0; idx < methodCount; ++idx) {
QByteArray signature = metaObject()->method(idx).methodSignature();
m_methodHash[signature.left(signature.indexOf('('))] = idx;
-// qDebug() << metaObject()->method(idx).parameterTypes();
+ // qDebug() << metaObject()->method(idx).parameterTypes();
}
}
-QStringList QXmppInvokable::interfaces( ) const
+QStringList QXmppInvokable::interfaces() const
{
QStringList results;
- int methodCount = metaObject()->methodCount ();
- for( int idx = 0; idx < methodCount; ++idx)
- {
- if( metaObject()->method(idx).methodType() == QMetaMethod::Slot )
- {
+ int methodCount = metaObject()->methodCount();
+ for (int idx = 0; idx < methodCount; ++idx) {
+ if (metaObject()->method(idx).methodType() == QMetaMethod::Slot) {
QByteArray signature = metaObject()->method(idx).methodSignature();
results << signature.left(signature.indexOf('('));
}
}
return results;
}
-
diff --git a/src/client/QXmppMessageReceiptManager.cpp b/src/client/QXmppMessageReceiptManager.cpp
index e3b8aae5..3b5c0159 100644
--- a/src/client/QXmppMessageReceiptManager.cpp
+++ b/src/client/QXmppMessageReceiptManager.cpp
@@ -57,17 +57,14 @@ bool QXmppMessageReceiptManager::handleStanza(const QDomElement &stanza)
if (!message.receiptId().isEmpty()) {
// Buggy clients also mark carbon messages as received; to avoid this
// we check whether sender and receiver have the same bare JID.
- if (QXmppUtils::jidToBareJid(message.from())
- != QXmppUtils::jidToBareJid(message.to())) {
+ if (QXmppUtils::jidToBareJid(message.from()) != QXmppUtils::jidToBareJid(message.to())) {
emit messageDelivered(message.from(), message.receiptId());
}
return true;
}
// If requested, send a receipt.
- if (message.isReceiptRequested()
- && !message.from().isEmpty()
- && !message.id().isEmpty()) {
+ if (message.isReceiptRequested() && !message.from().isEmpty() && !message.id().isEmpty()) {
QXmppMessage receipt;
receipt.setTo(message.from());
receipt.setReceiptId(message.id());
diff --git a/src/client/QXmppMucManager.cpp b/src/client/QXmppMucManager.cpp
index b65df6b0..d8645b59 100644
--- a/src/client/QXmppMucManager.cpp
+++ b/src/client/QXmppMucManager.cpp
@@ -36,7 +36,7 @@
class QXmppMucManagerPrivate
{
public:
- QMap<QString, QXmppMucRoom*> rooms;
+ QMap<QString, QXmppMucRoom *> rooms;
};
class QXmppMucRoomPrivate
@@ -81,7 +81,7 @@ QXmppMucRoom *QXmppMucManager::addRoom(const QString &roomJid)
room = new QXmppMucRoom(client(), roomJid, this);
d->rooms.insert(roomJid, room);
connect(room, &QObject::destroyed,
- this, &QXmppMucManager::_q_roomDestroyed);
+ this, &QXmppMucManager::_q_roomDestroyed);
// emit signal
emit roomAdded(room);
@@ -91,7 +91,7 @@ QXmppMucRoom *QXmppMucManager::addRoom(const QString &roomJid)
/// Returns the list of managed rooms.
-QList<QXmppMucRoom*> QXmppMucManager::rooms() const
+QList<QXmppMucRoom *> QXmppMucManager::rooms() const
{
return d->rooms.values();
}
@@ -110,10 +110,8 @@ QStringList QXmppMucManager::discoveryFeatures() const
bool QXmppMucManager::handleStanza(const QDomElement &element)
{
- if (element.tagName() == "iq")
- {
- if (QXmppMucAdminIq::isMucAdminIq(element))
- {
+ if (element.tagName() == "iq") {
+ if (QXmppMucAdminIq::isMucAdminIq(element)) {
QXmppMucAdminIq iq;
iq.parse(element);
@@ -129,9 +127,7 @@ bool QXmppMucManager::handleStanza(const QDomElement &element)
}
return true;
}
- }
- else if (QXmppMucOwnerIq::isMucOwnerIq(element))
- {
+ } else if (QXmppMucOwnerIq::isMucOwnerIq(element)) {
QXmppMucOwnerIq iq;
iq.parse(element);
@@ -145,13 +141,13 @@ bool QXmppMucManager::handleStanza(const QDomElement &element)
return false;
}
-void QXmppMucManager::setClient(QXmppClient* client)
+void QXmppMucManager::setClient(QXmppClient *client)
{
QXmppClientExtension::setClient(client);
connect(client, &QXmppClient::messageReceived,
- this, &QXmppMucManager::_q_messageReceived);
+ this, &QXmppMucManager::_q_messageReceived);
}
/// \endcond
@@ -169,7 +165,7 @@ void QXmppMucManager::_q_messageReceived(const QXmppMessage &msg)
void QXmppMucManager::_q_roomDestroyed(QObject *object)
{
- const QString key = d->rooms.key(static_cast<QXmppMucRoom*>(object));
+ const QString key = d->rooms.key(static_cast<QXmppMucRoom *>(object));
d->rooms.remove(key);
}
@@ -188,17 +184,17 @@ QXmppMucRoom::QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *par
d->jid = jid;
connect(d->client, &QXmppClient::disconnected,
- this, &QXmppMucRoom::_q_disconnected);
+ this, &QXmppMucRoom::_q_disconnected);
connect(d->client, &QXmppClient::messageReceived,
- this, &QXmppMucRoom::_q_messageReceived);
+ this, &QXmppMucRoom::_q_messageReceived);
connect(d->client, &QXmppClient::presenceReceived,
- this, &QXmppMucRoom::_q_presenceReceived);
+ this, &QXmppMucRoom::_q_presenceReceived);
if (d->discoManager) {
connect(d->discoManager, &QXmppDiscoveryManager::infoReceived,
- this, &QXmppMucRoom::_q_discoveryInfoReceived);
+ this, &QXmppMucRoom::_q_discoveryInfoReceived);
}
// convenience signals for properties
@@ -378,8 +374,7 @@ void QXmppMucRoom::setNickName(const QString &nickName)
packet.setTo(d->jid + "/" + nickName);
packet.setType(QXmppPresence::Available);
d->client->sendPacket(packet);
- }
- else {
+ } else {
d->nickName = nickName;
emit nickNameChanged(nickName);
}
@@ -597,7 +592,7 @@ void QXmppMucRoom::_q_discoveryInfoReceived(const QXmppDiscoveryIq &iq)
void QXmppMucRoom::_q_messageReceived(const QXmppMessage &message)
{
- if (QXmppUtils::jidToBareJid(message.from())!= d->jid)
+ if (QXmppUtils::jidToBareJid(message.from()) != d->jid)
return;
// handle message subject
@@ -663,8 +658,7 @@ void QXmppMucRoom::_q_presenceReceived(const QXmppPresence &presence)
} else {
emit participantChanged(jid);
}
- }
- else if (presence.type() == QXmppPresence::Unavailable) {
+ } else if (presence.type() == QXmppPresence::Unavailable) {
if (d->participants.contains(jid)) {
d->participants.insert(jid, presence);
@@ -705,8 +699,7 @@ void QXmppMucRoom::_q_presenceReceived(const QXmppPresence &presence)
emit left();
}
}
- }
- else if (presence.type() == QXmppPresence::Error) {
+ } else if (presence.type() == QXmppPresence::Error) {
if (presence.isMucSupported()) {
// emit error
emit error(presence.error());
@@ -714,5 +707,5 @@ void QXmppMucRoom::_q_presenceReceived(const QXmppPresence &presence)
// notify the user we left the room
emit left();
}
- }
+ }
}
diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp
index ba4f9349..46b5e02d 100644
--- a/src/client/QXmppOutgoingClient.cpp
+++ b/src/client/QXmppOutgoingClient.cpp
@@ -120,21 +120,7 @@ private:
};
QXmppOutgoingClientPrivate::QXmppOutgoingClientPrivate(QXmppOutgoingClient *qq)
- : nextSrvRecordIdx(0)
- , redirectPort(0)
- , bindModeAvailable(false)
- , sessionAvailable(false)
- , sessionStarted(false)
- , isAuthenticated(false)
- , saslClient(nullptr)
- , streamManagementAvailable(false)
- , canResume(false)
- , isResuming(false)
- , resumePort(0)
- , clientStateIndicationEnabled(false)
- , pingTimer(nullptr)
- , timeoutTimer(nullptr)
- , q(qq)
+ : nextSrvRecordIdx(0), redirectPort(0), bindModeAvailable(false), sessionAvailable(false), sessionStarted(false), isAuthenticated(false), saslClient(nullptr), streamManagementAvailable(false), canResume(false), isResuming(false), resumePort(0), clientStateIndicationEnabled(false), pingTimer(nullptr), timeoutTimer(nullptr), q(qq)
{
}
@@ -182,7 +168,7 @@ void QXmppOutgoingClientPrivate::connectToNextDNSHost()
QXmppOutgoingClient::QXmppOutgoingClient(QObject *parent)
: QXmppStream(parent),
- d(new QXmppOutgoingClientPrivate(this))
+ d(new QXmppOutgoingClientPrivate(this))
{
// initialise socket
auto *socket = new QSslSocket(this);
@@ -216,7 +202,7 @@ QXmppOutgoingClient::~QXmppOutgoingClient()
/// Returns a reference to the stream's configuration.
-QXmppConfiguration& QXmppOutgoingClient::configuration()
+QXmppConfiguration &QXmppOutgoingClient::configuration()
{
return d->config;
}
@@ -261,7 +247,7 @@ void QXmppOutgoingClient::_q_dnsLookupFinished()
} else {
// as a fallback, use domain as the host name
warning(QString("Lookup for domain %1 failed: %2")
- .arg(d->dns.name(), d->dns.errorString()));
+ .arg(d->dns.name(), d->dns.errorString()));
d->connectToHost(d->config.domain(), d->config.port());
}
}
@@ -304,7 +290,7 @@ void QXmppOutgoingClient::socketSslErrors(const QList<QSslError> &errors)
{
// log errors
warning("SSL errors");
- for(int i = 0; i< errors.count(); ++i)
+ for (int i = 0; i < errors.count(); ++i)
warning(errors.at(i).errorString());
// relay signal
@@ -318,13 +304,11 @@ void QXmppOutgoingClient::socketSslErrors(const QList<QSslError> &errors)
void QXmppOutgoingClient::socketError(QAbstractSocket::SocketError socketError)
{
Q_UNUSED(socketError);
- if ( !d->sessionStarted &&
- (d->dns.serviceRecords().count() > d->nextSrvRecordIdx) )
- {
+ if (!d->sessionStarted &&
+ (d->dns.serviceRecords().count() > d->nextSrvRecordIdx)) {
// some network error occurred during startup -> try next available SRV record server
d->connectToNextDNSHost();
- }
- else
+ } else
emit error(QXmppClient::SocketError);
}
@@ -359,17 +343,16 @@ void QXmppOutgoingClient::handleStart()
void QXmppOutgoingClient::handleStream(const QDomElement &streamElement)
{
- if(d->streamId.isEmpty())
+ if (d->streamId.isEmpty())
d->streamId = streamElement.attribute("id");
if (d->streamFrom.isEmpty())
d->streamFrom = streamElement.attribute("from");
- if(d->streamVersion.isEmpty())
- {
+ if (d->streamVersion.isEmpty()) {
d->streamVersion = streamElement.attribute("version");
// no version specified, signals XMPP Version < 1.0.
// switch to old auth mechanism if enabled
- if(d->streamVersion.isEmpty() && configuration().useNonSASLAuthentication()) {
+ if (d->streamVersion.isEmpty() && configuration().useNonSASLAuthentication()) {
d->sendNonSASLAuthQuery();
}
}
@@ -388,8 +371,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
if (handled)
return;
- if(QXmppStreamFeatures::isStreamFeatures(nodeRecv))
- {
+ if (QXmppStreamFeatures::isStreamFeatures(nodeRecv)) {
QXmppStreamFeatures features;
features.parse(nodeRecv);
@@ -399,8 +381,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
// handle authentication
const bool nonSaslAvailable = features.nonSaslAuthMode() != QXmppStreamFeatures::Disabled;
const bool saslAvailable = !features.authMechanisms().isEmpty();
- if (saslAvailable && configuration().useSASLAuthentication())
- {
+ if (saslAvailable && configuration().useSASLAuthentication()) {
// supported and preferred SASL auth mechanisms
const QString preferredMechanism = configuration().saslAuthMechanism();
QStringList supportedMechanisms = QXmppSaslClient::availableMechanisms();
@@ -461,7 +442,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
}
sendPacket(QXmppSaslAuth(d->saslClient->mechanism(), response));
return;
- } else if(nonSaslAvailable && configuration().useNonSASLAuthentication()) {
+ } else if (nonSaslAvailable && configuration().useNonSASLAuthentication()) {
d->sendNonSASLAuthQuery();
return;
}
@@ -497,9 +478,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
// otherwise we are done
d->sessionStarted = true;
emit connected();
- }
- else if(ns == ns_stream && nodeRecv.tagName() == "error")
- {
+ } else if (ns == ns_stream && nodeRecv.tagName() == "error") {
// handle redirects
QRegExp redirectRegex("([^:]+)(:[0-9]+)?");
if (redirectRegex.exactMatch(nodeRecv.firstChildElement("see-other-host").text())) {
@@ -517,21 +496,16 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
else
d->xmppStreamError = QXmppStanza::Error::UndefinedCondition;
emit error(QXmppClient::XmppStreamError);
- }
- else if(ns == ns_sasl)
- {
+ } else if (ns == ns_sasl) {
if (!d->saslClient) {
warning("SASL stanza received, but no mechanism selected");
return;
}
- if(nodeRecv.tagName() == "success")
- {
+ if (nodeRecv.tagName() == "success") {
debug("Authenticated");
d->isAuthenticated = true;
handleStart();
- }
- else if(nodeRecv.tagName() == "challenge")
- {
+ } else if (nodeRecv.tagName() == "challenge") {
QXmppSaslChallenge challenge;
challenge.parse(nodeRecv);
@@ -542,9 +516,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
warning("Could not respond to SASL challenge");
disconnectFromHost();
}
- }
- else if(nodeRecv.tagName() == "failure")
- {
+ } else if (nodeRecv.tagName() == "failure") {
QXmppSaslFailure failure;
failure.parse(nodeRecv);
@@ -560,47 +532,35 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
warning("Authentication failure");
disconnectFromHost();
}
- }
- else if(ns == ns_client)
- {
+ } else if (ns == ns_client) {
- if(nodeRecv.tagName() == "iq")
- {
+ if (nodeRecv.tagName() == "iq") {
QDomElement element = nodeRecv.firstChildElement();
QString id = nodeRecv.attribute("id");
QString type = nodeRecv.attribute("type");
- if(type.isEmpty())
+ if (type.isEmpty())
warning("QXmppStream: iq type can't be empty");
- if(id == d->sessionId)
- {
+ if (id == d->sessionId) {
QXmppSessionIq session;
session.parse(nodeRecv);
d->sessionStarted = true;
- if(d->streamManagementAvailable)
- {
+ if (d->streamManagementAvailable) {
d->sendStreamManagementEnable();
- }
- else
- {
+ } else {
// we are connected now
emit connected();
}
- }
- else if(QXmppBindIq::isBindIq(nodeRecv) && id == d->bindId)
- {
+ } else if (QXmppBindIq::isBindIq(nodeRecv) && id == d->bindId) {
QXmppBindIq bind;
bind.parse(nodeRecv);
// bind result
- if (bind.type() == QXmppIq::Result)
- {
- if (!bind.jid().isEmpty())
- {
+ if (bind.type() == QXmppIq::Result) {
+ if (!bind.jid().isEmpty()) {
QRegExp jidRegex("^([^@/]+)@([^@/]+)/(.+)$");
- if (jidRegex.exactMatch(bind.jid()))
- {
+ if (jidRegex.exactMatch(bind.jid())) {
configuration().setUser(jidRegex.cap(1));
configuration().setDomain(jidRegex.cap(2));
configuration().setResource(jidRegex.cap(3));
@@ -626,8 +586,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
// extensions
// XEP-0078: Non-SASL Authentication
- else if(id == d->nonSASLAuthId && type == "result")
- {
+ else if (id == d->nonSASLAuthId && type == "result") {
// successful Non-SASL Authentication
debug("Authenticated (Non-SASL)");
d->isAuthenticated = true;
@@ -635,31 +594,23 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
// xmpp connection made
d->sessionStarted = true;
emit connected();
- }
- else if(QXmppNonSASLAuthIq::isNonSASLAuthIq(nodeRecv))
- {
- if(type == "result")
- {
- bool digest = !nodeRecv.firstChildElement("query").
- firstChildElement("digest").isNull();
- bool plain = !nodeRecv.firstChildElement("query").
- firstChildElement("password").isNull();
+ } else if (QXmppNonSASLAuthIq::isNonSASLAuthIq(nodeRecv)) {
+ if (type == "result") {
+ bool digest = !nodeRecv.firstChildElement("query").firstChildElement("digest").isNull();
+ bool plain = !nodeRecv.firstChildElement("query").firstChildElement("password").isNull();
bool plainText = false;
- if(plain && digest)
- {
- if(configuration().nonSASLAuthMechanism() ==
- QXmppConfiguration::NonSASLDigest)
+ if (plain && digest) {
+ if (configuration().nonSASLAuthMechanism() ==
+ QXmppConfiguration::NonSASLDigest)
plainText = false;
else
plainText = true;
- }
- else if(plain)
+ } else if (plain)
plainText = true;
- else if(digest)
+ else if (digest)
plainText = false;
- else
- {
+ else {
warning("No supported Non-SASL Authentication mechanism available");
disconnectFromHost();
return;
@@ -668,8 +619,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
}
}
// XEP-0199: XMPP Ping
- else if(QXmppPingIq::isPingIq(nodeRecv))
- {
+ else if (QXmppPingIq::isPingIq(nodeRecv)) {
QXmppPingIq req;
req.parse(nodeRecv);
@@ -677,47 +627,38 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
iq.setId(req.id());
iq.setTo(req.from());
sendPacket(iq);
- }
- else
- {
+ } else {
QXmppIq iqPacket;
iqPacket.parse(nodeRecv);
// if we didn't understant the iq, reply with error
// except for "result" and "error" iqs
- if (type != "result" && type != "error")
- {
+ if (type != "result" && type != "error") {
QXmppIq iq(QXmppIq::Error);
iq.setId(iqPacket.id());
iq.setTo(iqPacket.from());
QXmppStanza::Error error(QXmppStanza::Error::Cancel,
- QXmppStanza::Error::FeatureNotImplemented);
+ QXmppStanza::Error::FeatureNotImplemented);
iq.setError(error);
sendPacket(iq);
} else {
emit iqReceived(iqPacket);
}
}
- }
- else if(nodeRecv.tagName() == "presence")
- {
+ } else if (nodeRecv.tagName() == "presence") {
QXmppPresence presence;
presence.parse(nodeRecv);
// emit presence
emit presenceReceived(presence);
- }
- else if(nodeRecv.tagName() == "message")
- {
+ } else if (nodeRecv.tagName() == "message") {
QXmppMessage message;
message.parse(nodeRecv);
// emit message
emit messageReceived(message);
}
- }
- else if(QXmppStreamManagementEnabled::isStreamManagementEnabled(nodeRecv))
- {
+ } else if (QXmppStreamManagementEnabled::isStreamManagementEnabled(nodeRecv)) {
QXmppStreamManagementEnabled streamManagementEnabled;
streamManagementEnabled.parse(nodeRecv);
d->smId = streamManagementEnabled.id();
@@ -739,9 +680,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
enableStreamManagement(true);
// we are connected now
emit connected();
- }
- else if(QXmppStreamManagementResumed::isStreamManagementResumed(nodeRecv))
- {
+ } else if (QXmppStreamManagementResumed::isStreamManagementResumed(nodeRecv)) {
QXmppStreamManagementResumed streamManagementResumed;
streamManagementResumed.parse(nodeRecv);
setAcknowledgedSequenceNumber(streamManagementResumed.h());
@@ -751,9 +690,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
// we are connected now
// TODO: The stream was resumed. Therefore, we should not send presence information or request the roster.
emit connected();
- }
- else if(QXmppStreamManagementFailed::isStreamManagementFailed(nodeRecv))
- {
+ } else if (QXmppStreamManagementFailed::isStreamManagementFailed(nodeRecv)) {
if (d->isResuming) {
// resuming failed. We can try to bind a resource now.
d->isResuming = false;
@@ -785,8 +722,7 @@ void QXmppOutgoingClient::pingStart()
{
const int interval = configuration().keepAliveInterval();
// start ping timer
- if (interval > 0)
- {
+ if (interval > 0) {
d->pingTimer->setInterval(interval * 1000);
d->pingTimer->start();
}
@@ -808,8 +744,7 @@ void QXmppOutgoingClient::pingSend()
// start timeout timer
const int timeout = configuration().keepAliveTimeout();
- if (timeout > 0)
- {
+ if (timeout > 0) {
d->timeoutTimer->setInterval(timeout * 1000);
d->timeoutTimer->start();
}
@@ -880,4 +815,3 @@ QXmppStanza::Error::Condition QXmppOutgoingClient::xmppStreamError()
{
return d->xmppStreamError;
}
-
diff --git a/src/client/QXmppRemoteMethod.cpp b/src/client/QXmppRemoteMethod.cpp
index 9493f54e..e2f719a1 100644
--- a/src/client/QXmppRemoteMethod.cpp
+++ b/src/client/QXmppRemoteMethod.cpp
@@ -30,33 +30,31 @@
#include <QEventLoop>
#include <QTimer>
-QXmppRemoteMethod::QXmppRemoteMethod(const QString &jid, const QString &method, const QVariantList &args, QXmppClient *client) :
- QObject(client), m_client(client)
+QXmppRemoteMethod::QXmppRemoteMethod(const QString &jid, const QString &method, const QVariantList &args, QXmppClient *client) : QObject(client), m_client(client)
{
- m_payload.setTo( jid );
- m_payload.setFrom( client->configuration().jid() );
- m_payload.setMethod( method );
- m_payload.setArguments( args );
+ m_payload.setTo(jid);
+ m_payload.setFrom(client->configuration().jid());
+ m_payload.setMethod(method);
+ m_payload.setArguments(args);
}
-QXmppRemoteMethodResult QXmppRemoteMethod::call( )
+QXmppRemoteMethodResult QXmppRemoteMethod::call()
{
// FIXME : spinning an event loop is a VERY bad idea, it can cause
// us to lose incoming packets
QEventLoop loop(this);
- connect( this, &QXmppRemoteMethod::callDone, &loop, &QEventLoop::quit);
- QTimer::singleShot(30000,&loop, &QEventLoop::quit); // Timeout in case the other end hangs...
+ connect(this, &QXmppRemoteMethod::callDone, &loop, &QEventLoop::quit);
+ QTimer::singleShot(30000, &loop, &QEventLoop::quit); // Timeout in case the other end hangs...
- m_client->sendPacket( m_payload );
+ m_client->sendPacket(m_payload);
- loop.exec( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents );
+ loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
return m_result;
}
-void QXmppRemoteMethod::gotError( const QXmppRpcErrorIq &iq )
+void QXmppRemoteMethod::gotError(const QXmppRpcErrorIq &iq)
{
- if ( iq.id() == m_payload.id() )
- {
+ if (iq.id() == m_payload.id()) {
m_result.hasError = true;
m_result.errorMessage = iq.error().text();
m_result.code = iq.error().type();
@@ -64,10 +62,9 @@ void QXmppRemoteMethod::gotError( const QXmppRpcErrorIq &iq )
}
}
-void QXmppRemoteMethod::gotResult( const QXmppRpcResponseIq &iq )
+void QXmppRemoteMethod::gotResult(const QXmppRpcResponseIq &iq)
{
- if ( iq.id() == m_payload.id() )
- {
+ if (iq.id() == m_payload.id()) {
m_result.hasError = false;
// FIXME: we don't handle multiple responses
m_result.result = iq.values().first();
diff --git a/src/client/QXmppRemoteMethod.h b/src/client/QXmppRemoteMethod.h
index fa255f97..2726ecdf 100644
--- a/src/client/QXmppRemoteMethod.h
+++ b/src/client/QXmppRemoteMethod.h
@@ -24,15 +24,15 @@
#ifndef QXMPPREMOTEMETHOD_H
#define QXMPPREMOTEMETHOD_H
+#include "QXmppRpcIq.h"
+
#include <QObject>
#include <QVariant>
-#include "QXmppRpcIq.h"
-
class QXmppClient;
struct QXmppRemoteMethodResult {
- QXmppRemoteMethodResult() : hasError(false), code(0) {}
+ QXmppRemoteMethodResult() : hasError(false), code(0) { }
bool hasError;
int code;
QString errorMessage;
diff --git a/src/client/QXmppRosterManager.cpp b/src/client/QXmppRosterManager.cpp
index 1b93870d..7bba45ec 100644
--- a/src/client/QXmppRosterManager.cpp
+++ b/src/client/QXmppRosterManager.cpp
@@ -40,7 +40,7 @@ public:
QMap<QString, QXmppRosterIq::Item> entries;
// map of resources of the jid and map of resources and presences
- QMap<QString, QMap<QString, QXmppPresence> > presences;
+ QMap<QString, QMap<QString, QXmppPresence>> presences;
// flag to store that the roster has been populated
bool isRosterReceived;
@@ -54,25 +54,25 @@ private:
QXmppRosterManagerPrivate::QXmppRosterManagerPrivate(QXmppRosterManager *qq)
: isRosterReceived(false),
- q(qq)
+ q(qq)
{
}
/// Constructs a roster manager.
-QXmppRosterManager::QXmppRosterManager(QXmppClient* client)
+QXmppRosterManager::QXmppRosterManager(QXmppClient *client)
{
d = new QXmppRosterManagerPrivate(this);
connect(client, &QXmppClient::connected,
- this, &QXmppRosterManager::_q_connected);
+ this, &QXmppRosterManager::_q_connected);
connect(client, &QXmppClient::disconnected,
- this, &QXmppRosterManager::_q_disconnected);
+ this, &QXmppRosterManager::_q_disconnected);
connect(client, &QXmppClient::presenceReceived,
- this, &QXmppRosterManager::_q_presenceReceived);
+ this, &QXmppRosterManager::_q_presenceReceived);
}
QXmppRosterManager::~QXmppRosterManager()
@@ -128,52 +128,47 @@ bool QXmppRosterManager::handleStanza(const QDomElement &element)
rosterIq.parse(element);
bool isInitial = (d->rosterReqId == rosterIq.id());
- switch(rosterIq.type())
- {
- case QXmppIq::Set:
- {
- // send result iq
- QXmppIq returnIq(QXmppIq::Result);
- returnIq.setId(rosterIq.id());
- client()->sendPacket(returnIq);
-
- // store updated entries and notify changes
- const QList<QXmppRosterIq::Item> items = rosterIq.items();
- for (const auto &item : items) {
- const QString bareJid = item.bareJid();
- if (item.subscriptionType() == QXmppRosterIq::Item::Remove) {
- if (d->entries.remove(bareJid)) {
- // notify the user that the item was removed
- emit itemRemoved(bareJid);
- }
+ switch (rosterIq.type()) {
+ case QXmppIq::Set: {
+ // send result iq
+ QXmppIq returnIq(QXmppIq::Result);
+ returnIq.setId(rosterIq.id());
+ client()->sendPacket(returnIq);
+
+ // store updated entries and notify changes
+ const QList<QXmppRosterIq::Item> items = rosterIq.items();
+ for (const auto &item : items) {
+ const QString bareJid = item.bareJid();
+ if (item.subscriptionType() == QXmppRosterIq::Item::Remove) {
+ if (d->entries.remove(bareJid)) {
+ // notify the user that the item was removed
+ emit itemRemoved(bareJid);
+ }
+ } else {
+ const bool added = !d->entries.contains(bareJid);
+ d->entries.insert(bareJid, item);
+ if (added) {
+ // notify the user that the item was added
+ emit itemAdded(bareJid);
} else {
- const bool added = !d->entries.contains(bareJid);
- d->entries.insert(bareJid, item);
- if (added) {
- // notify the user that the item was added
- emit itemAdded(bareJid);
- } else {
- // notify the user that the item changed
- emit itemChanged(bareJid);
- }
+ // notify the user that the item changed
+ emit itemChanged(bareJid);
}
}
}
- break;
- case QXmppIq::Result:
- {
- const QList<QXmppRosterIq::Item> items = rosterIq.items();
- for (const auto &item : items) {
- const QString bareJid = item.bareJid();
- d->entries.insert(bareJid, item);
- }
- if (isInitial)
- {
- d->isRosterReceived = true;
- emit rosterReceived();
- }
- break;
+ } break;
+ case QXmppIq::Result: {
+ const QList<QXmppRosterIq::Item> items = rosterIq.items();
+ for (const auto &item : items) {
+ const QString bareJid = item.bareJid();
+ d->entries.insert(bareJid, item);
+ }
+ if (isInitial) {
+ d->isRosterReceived = true;
+ emit rosterReceived();
}
+ break;
+ }
default:
break;
}
@@ -182,7 +177,7 @@ bool QXmppRosterManager::handleStanza(const QDomElement &element)
}
/// \endcond
-void QXmppRosterManager::_q_presenceReceived(const QXmppPresence& presence)
+void QXmppRosterManager::_q_presenceReceived(const QXmppPresence &presence)
{
const QString jid = presence.from();
const QString bareJid = QXmppUtils::jidToBareJid(jid);
@@ -191,8 +186,7 @@ void QXmppRosterManager::_q_presenceReceived(const QXmppPresence& presence)
if (bareJid.isEmpty())
return;
- switch(presence.type())
- {
+ switch (presence.type()) {
case QXmppPresence::Available:
d->presences[bareJid][resource] = presence;
emit presenceChanged(bareJid, resource);
@@ -202,8 +196,7 @@ void QXmppRosterManager::_q_presenceReceived(const QXmppPresence& presence)
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Subscribe:
- if (client()->configuration().autoAcceptSubscriptions())
- {
+ if (client()->configuration().autoAcceptSubscriptions()) {
// accept subscription request
acceptSubscription(bareJid);
@@ -340,10 +333,10 @@ QStringList QXmppRosterManager::getRosterBareJids() const
///
QXmppRosterIq::Item QXmppRosterManager::getRosterEntry(
- const QString& bareJid) const
+ const QString &bareJid) const
{
// will return blank entry if bareJid doesn't exist
- if(d->entries.contains(bareJid))
+ if (d->entries.contains(bareJid))
return d->entries.value(bareJid);
else
return QXmppRosterIq::Item();
@@ -355,9 +348,9 @@ QXmppRosterIq::Item QXmppRosterManager::getRosterEntry(
/// \return list of associated resources as a QStringList
///
-QStringList QXmppRosterManager::getResources(const QString& bareJid) const
+QStringList QXmppRosterManager::getResources(const QString &bareJid) const
{
- if(d->presences.contains(bareJid))
+ if (d->presences.contains(bareJid))
return d->presences[bareJid].keys();
else
return QStringList();
@@ -372,9 +365,9 @@ QStringList QXmppRosterManager::getResources(const QString& bareJid) const
///
QMap<QString, QXmppPresence> QXmppRosterManager::getAllPresencesForBareJid(
- const QString& bareJid) const
+ const QString &bareJid) const
{
- if(d->presences.contains(bareJid))
+ if (d->presences.contains(bareJid))
return d->presences[bareJid];
else
return QMap<QString, QXmppPresence>();
@@ -387,13 +380,12 @@ QMap<QString, QXmppPresence> QXmppRosterManager::getAllPresencesForBareJid(
/// \return QXmppPresence
///
-QXmppPresence QXmppRosterManager::getPresence(const QString& bareJid,
- const QString& resource) const
+QXmppPresence QXmppRosterManager::getPresence(const QString &bareJid,
+ const QString &resource) const
{
- if(d->presences.contains(bareJid) && d->presences[bareJid].contains(resource))
+ if (d->presences.contains(bareJid) && d->presences[bareJid].contains(resource))
return d->presences[bareJid][resource];
- else
- {
+ else {
QXmppPresence presence;
presence.setType(QXmppPresence::Unavailable);
return presence;
diff --git a/src/client/QXmppRpcManager.cpp b/src/client/QXmppRpcManager.cpp
index f76546e1..d425cf84 100644
--- a/src/client/QXmppRpcManager.cpp
+++ b/src/client/QXmppRpcManager.cpp
@@ -39,16 +39,16 @@ QXmppRpcManager::QXmppRpcManager()
///
/// \param interface
-void QXmppRpcManager::addInvokableInterface( QXmppInvokable *interface )
+void QXmppRpcManager::addInvokableInterface(QXmppInvokable *interface)
{
- m_interfaces[ interface->metaObject()->className() ] = interface;
+ m_interfaces[interface->metaObject()->className()] = interface;
}
/// Invokes a remote interface using RPC.
///
/// \param iq
-void QXmppRpcManager::invokeInterfaceMethod( const QXmppRpcInvokeIq &iq )
+void QXmppRpcManager::invokeInterfaceMethod(const QXmppRpcInvokeIq &iq)
{
QXmppStanza::Error error;
@@ -58,36 +58,27 @@ void QXmppRpcManager::invokeInterfaceMethod( const QXmppRpcInvokeIq &iq )
const QString interface = methodBits.first();
const QString method = methodBits.last();
QXmppInvokable *iface = m_interfaces.value(interface);
- if (iface)
- {
- if ( iface->isAuthorized( iq.from() ) )
- {
+ if (iface) {
+ if (iface->isAuthorized(iq.from())) {
- if ( iface->interfaces().contains(method) )
- {
+ if (iface->interfaces().contains(method)) {
QVariant result = iface->dispatch(method.toLatin1(),
- iq.arguments() );
+ iq.arguments());
QXmppRpcResponseIq resultIq;
resultIq.setId(iq.id());
resultIq.setTo(iq.from());
resultIq.setValues(QVariantList() << result);
- client()->sendPacket( resultIq );
+ client()->sendPacket(resultIq);
return;
- }
- else
- {
+ } else {
error.setType(QXmppStanza::Error::Cancel);
error.setCondition(QXmppStanza::Error::ItemNotFound);
}
- }
- else
- {
+ } else {
error.setType(QXmppStanza::Error::Auth);
error.setCondition(QXmppStanza::Error::Forbidden);
}
- }
- else
- {
+ } else {
error.setType(QXmppStanza::Error::Cancel);
error.setCondition(QXmppStanza::Error::ItemNotFound);
}
@@ -104,40 +95,50 @@ void QXmppRpcManager::invokeInterfaceMethod( const QXmppRpcInvokeIq &iq )
/// \note This method blocks until the response is received, and it may
/// cause XMPP stanzas to be lost!
-QXmppRemoteMethodResult QXmppRpcManager::callRemoteMethod( const QString &jid,
- const QString &interface,
- const QVariant &arg1,
- const QVariant &arg2,
- const QVariant &arg3,
- const QVariant &arg4,
- const QVariant &arg5,
- const QVariant &arg6,
- const QVariant &arg7,
- const QVariant &arg8,
- const QVariant &arg9,
- const QVariant &arg10 )
+QXmppRemoteMethodResult QXmppRpcManager::callRemoteMethod(const QString &jid,
+ const QString &interface,
+ const QVariant &arg1,
+ const QVariant &arg2,
+ const QVariant &arg3,
+ const QVariant &arg4,
+ const QVariant &arg5,
+ const QVariant &arg6,
+ const QVariant &arg7,
+ const QVariant &arg8,
+ const QVariant &arg9,
+ const QVariant &arg10)
{
QVariantList args;
- if( arg1.isValid() ) args << arg1;
- if( arg2.isValid() ) args << arg2;
- if( arg3.isValid() ) args << arg3;
- if( arg4.isValid() ) args << arg4;
- if( arg5.isValid() ) args << arg5;
- if( arg6.isValid() ) args << arg6;
- if( arg7.isValid() ) args << arg7;
- if( arg8.isValid() ) args << arg8;
- if( arg9.isValid() ) args << arg9;
- if( arg10.isValid() ) args << arg10;
+ if (arg1.isValid())
+ args << arg1;
+ if (arg2.isValid())
+ args << arg2;
+ if (arg3.isValid())
+ args << arg3;
+ if (arg4.isValid())
+ args << arg4;
+ if (arg5.isValid())
+ args << arg5;
+ if (arg6.isValid())
+ args << arg6;
+ if (arg7.isValid())
+ args << arg7;
+ if (arg8.isValid())
+ args << arg8;
+ if (arg9.isValid())
+ args << arg9;
+ if (arg10.isValid())
+ args << arg10;
bool check;
Q_UNUSED(check)
- QXmppRemoteMethod method( jid, interface, args, client() );
+ QXmppRemoteMethod method(jid, interface, args, client());
check = connect(this, SIGNAL(rpcCallResponse(QXmppRpcResponseIq)),
- &method, SLOT(gotResult(QXmppRpcResponseIq)));
+ &method, SLOT(gotResult(QXmppRpcResponseIq)));
Q_ASSERT(check);
check = connect(this, SIGNAL(rpcCallError(QXmppRpcErrorIq)),
- &method, SLOT(gotError(QXmppRpcErrorIq)));
+ &method, SLOT(gotError(QXmppRpcErrorIq)));
Q_ASSERT(check);
return method.call();
@@ -161,22 +162,17 @@ QList<QXmppDiscoveryIq::Identity> QXmppRpcManager::discoveryIdentities() const
bool QXmppRpcManager::handleStanza(const QDomElement &element)
{
// XEP-0009: Jabber-RPC
- if (QXmppRpcInvokeIq::isRpcInvokeIq(element))
- {
+ if (QXmppRpcInvokeIq::isRpcInvokeIq(element)) {
QXmppRpcInvokeIq rpcIqPacket;
rpcIqPacket.parse(element);
invokeInterfaceMethod(rpcIqPacket);
return true;
- }
- else if(QXmppRpcResponseIq::isRpcResponseIq(element))
- {
+ } else if (QXmppRpcResponseIq::isRpcResponseIq(element)) {
QXmppRpcResponseIq rpcResponseIq;
rpcResponseIq.parse(element);
emit rpcCallResponse(rpcResponseIq);
return true;
- }
- else if(QXmppRpcErrorIq::isRpcErrorIq(element))
- {
+ } else if (QXmppRpcErrorIq::isRpcErrorIq(element)) {
QXmppRpcErrorIq rpcErrorIq;
rpcErrorIq.parse(element);
emit rpcCallError(rpcErrorIq);
diff --git a/src/client/QXmppTransferManager.cpp b/src/client/QXmppTransferManager.cpp
index ecbdbd1e..76d69b10 100644
--- a/src/client/QXmppTransferManager.cpp
+++ b/src/client/QXmppTransferManager.cpp
@@ -140,14 +140,10 @@ void QXmppTransferFileInfo::setSize(qint64 size)
bool QXmppTransferFileInfo::isNull() const
{
- return d->date.isNull()
- && d->description.isEmpty()
- && d->hash.isEmpty()
- && d->name.isEmpty()
- && d->size == 0;
+ return d->date.isNull() && d->description.isEmpty() && d->hash.isEmpty() && d->name.isEmpty() && d->size == 0;
}
-QXmppTransferFileInfo& QXmppTransferFileInfo::operator=(const QXmppTransferFileInfo &other)
+QXmppTransferFileInfo &QXmppTransferFileInfo::operator=(const QXmppTransferFileInfo &other)
{
d = other.d;
return *this;
@@ -222,23 +218,23 @@ public:
QXmppTransferJobPrivate::QXmppTransferJobPrivate()
: blockSize(16384),
- client(nullptr),
- direction(QXmppTransferJob::IncomingDirection),
- done(0),
- error(QXmppTransferJob::NoError),
- hash(QCryptographicHash::Md5),
- iodevice(nullptr),
- method(QXmppTransferJob::NoMethod),
- state(QXmppTransferJob::OfferState),
- deviceIsOwn(false),
- ibbSequence(0),
- socksSocket(nullptr)
+ client(nullptr),
+ direction(QXmppTransferJob::IncomingDirection),
+ done(0),
+ error(QXmppTransferJob::NoError),
+ hash(QCryptographicHash::Md5),
+ iodevice(nullptr),
+ method(QXmppTransferJob::NoMethod),
+ state(QXmppTransferJob::OfferState),
+ deviceIsOwn(false),
+ ibbSequence(0),
+ socksSocket(nullptr)
{
}
QXmppTransferJob::QXmppTransferJob(const QString &jid, QXmppTransferJob::Direction direction, QXmppClient *client, QObject *parent)
: QXmppLoggable(parent),
- d(new QXmppTransferJobPrivate)
+ d(new QXmppTransferJobPrivate)
{
d->client = client;
d->direction = direction;
@@ -263,11 +259,9 @@ void QXmppTransferJob::abort()
void QXmppTransferJob::accept(const QString &filePath)
{
- if (d->direction == IncomingDirection && d->state == OfferState && !d->iodevice)
- {
+ if (d->direction == IncomingDirection && d->state == OfferState && !d->iodevice) {
auto *file = new QFile(filePath, this);
- if (!file->open(QIODevice::WriteOnly))
- {
+ if (!file->open(QIODevice::WriteOnly)) {
warning(QString("Could not write to %1").arg(filePath));
abort();
return;
@@ -284,8 +278,7 @@ void QXmppTransferJob::accept(const QString &filePath)
void QXmppTransferJob::accept(QIODevice *iodevice)
{
- if (d->direction == IncomingDirection && d->state == OfferState && !d->iodevice)
- {
+ if (d->direction == IncomingDirection && d->state == OfferState && !d->iodevice) {
d->iodevice = iodevice;
setState(QXmppTransferJob::StartState);
}
@@ -405,8 +398,7 @@ QXmppTransferJob::State QXmppTransferJob::state() const
void QXmppTransferJob::setState(QXmppTransferJob::State state)
{
- if (d->state != state)
- {
+ if (d->state != state) {
d->state = state;
if (d->state == QXmppTransferJob::TransferState)
d->transferStart.start();
@@ -436,8 +428,7 @@ void QXmppTransferJob::terminate(QXmppTransferJob::Error cause)
d->iodevice->close();
// close socket
- if (d->socksSocket)
- {
+ if (d->socksSocket) {
d->socksSocket->flush();
d->socksSocket->close();
}
@@ -447,10 +438,8 @@ void QXmppTransferJob::terminate(QXmppTransferJob::Error cause)
}
/// \cond
-QXmppTransferIncomingJob::QXmppTransferIncomingJob(const QString& jid, QXmppClient* client, QObject* parent)
- : QXmppTransferJob(jid, IncomingDirection, client, parent)
- , m_candidateClient(nullptr)
- , m_candidateTimer(nullptr)
+QXmppTransferIncomingJob::QXmppTransferIncomingJob(const QString &jid, QXmppClient *client, QObject *parent)
+ : QXmppTransferJob(jid, IncomingDirection, client, parent), m_candidateClient(nullptr), m_candidateTimer(nullptr)
{
}
@@ -482,10 +471,7 @@ void QXmppTransferIncomingJob::connectToNextHost()
// try next host
m_candidateHost = m_streamCandidates.takeFirst();
- info(QString("Connecting to streamhost: %1 (%2 %3)").arg(
- m_candidateHost.jid(),
- m_candidateHost.host(),
- QString::number(m_candidateHost.port())));
+ info(QString("Connecting to streamhost: %1 (%2 %3)").arg(m_candidateHost.jid(), m_candidateHost.host(), QString::number(m_candidateHost.port())));
const QString hostName = streamHash(d->sid,
d->jid,
@@ -534,10 +520,7 @@ void QXmppTransferIncomingJob::_q_candidateReady()
if (!m_candidateClient)
return;
- info(QString("Connected to streamhost: %1 (%2 %3)").arg(
- m_candidateHost.jid(),
- m_candidateHost.host(),
- QString::number(m_candidateHost.port())));
+ info(QString("Connected to streamhost: %1 (%2 %3)").arg(m_candidateHost.jid(), m_candidateHost.host(), QString::number(m_candidateHost.port())));
setState(QXmppTransferJob::TransferState);
d->socksSocket = m_candidateClient;
@@ -562,10 +545,7 @@ void QXmppTransferIncomingJob::_q_candidateDisconnected()
if (!m_candidateClient)
return;
- warning(QString("Failed to connect to streamhost: %1 (%2 %3)").arg(
- m_candidateHost.jid(),
- m_candidateHost.host(),
- QString::number(m_candidateHost.port())));
+ warning(QString("Failed to connect to streamhost: %1 (%2 %3)").arg(m_candidateHost.jid(), m_candidateHost.host(), QString::number(m_candidateHost.port())));
m_candidateClient->deleteLater();
m_candidateClient = nullptr;
@@ -590,8 +570,7 @@ void QXmppTransferIncomingJob::_q_receiveData()
return;
// receive data block
- if (d->direction == QXmppTransferJob::IncomingDirection)
- {
+ if (d->direction == QXmppTransferJob::IncomingDirection) {
writeData(d->socksSocket->readAll());
// if we have received all the data, stop here
@@ -600,17 +579,14 @@ void QXmppTransferIncomingJob::_q_receiveData()
}
}
-QXmppTransferOutgoingJob::QXmppTransferOutgoingJob(const QString& jid, QXmppClient* client, QObject* parent)
+QXmppTransferOutgoingJob::QXmppTransferOutgoingJob(const QString &jid, QXmppClient *client, QObject *parent)
: QXmppTransferJob(jid, OutgoingDirection, client, parent)
{
}
void QXmppTransferOutgoingJob::connectToProxy()
{
- info(QString("Connecting to proxy: %1 (%2 %3)").arg(
- d->socksProxy.jid(),
- d->socksProxy.host(),
- QString::number(d->socksProxy.port())));
+ info(QString("Connecting to proxy: %1 (%2 %3)").arg(d->socksProxy.jid(), d->socksProxy.host(), QString::number(d->socksProxy.port())));
const QString hostName = streamHash(d->sid,
d->client->configuration().jid(),
@@ -669,8 +645,7 @@ void QXmppTransferOutgoingJob::_q_sendData()
return;
// check whether we have written the whole file
- if (d->fileInfo.size() && d->done >= d->fileInfo.size())
- {
+ if (d->fileInfo.size() && d->done >= d->fileInfo.size()) {
if (!d->socksSocket->bytesToWrite())
terminate(QXmppTransferJob::NoError);
return;
@@ -678,16 +653,13 @@ void QXmppTransferOutgoingJob::_q_sendData()
char *buffer = new char[d->blockSize];
qint64 length = d->iodevice->read(buffer, d->blockSize);
- if (length < 0)
- {
- delete [] buffer;
+ if (length < 0) {
+ delete[] buffer;
terminate(QXmppTransferJob::FileAccessError);
return;
- }
- else
- {
+ } else {
d->socksSocket->write(buffer, length);
- delete [] buffer;
+ delete[] buffer;
d->done += length;
emit progress(d->done, fileSize());
}
@@ -704,7 +676,7 @@ public:
QXmppTransferOutgoingJob *getOutgoingJobByRequestId(const QString &jid, const QString &id);
int ibbBlockSize;
- QList<QXmppTransferJob*> jobs;
+ QList<QXmppTransferJob *> jobs;
QString proxy;
bool proxyOnly;
QXmppSocksServer *socksServer;
@@ -716,15 +688,11 @@ private:
};
QXmppTransferManagerPrivate::QXmppTransferManagerPrivate(QXmppTransferManager *qq)
- : ibbBlockSize(4096)
- , proxyOnly(false)
- , socksServer(nullptr)
- , supportedMethods(QXmppTransferJob::AnyMethod)
- , q(qq)
+ : ibbBlockSize(4096), proxyOnly(false), socksServer(nullptr), supportedMethods(QXmppTransferJob::AnyMethod), q(qq)
{
}
-QXmppTransferJob* QXmppTransferManagerPrivate::getJobByRequestId(QXmppTransferJob::Direction direction, const QString &jid, const QString &id)
+QXmppTransferJob *QXmppTransferManagerPrivate::getJobByRequestId(QXmppTransferJob::Direction direction, const QString &jid, const QString &id)
{
for (auto *job : jobs) {
if (job->d->direction == direction &&
@@ -737,23 +705,23 @@ QXmppTransferJob* QXmppTransferManagerPrivate::getJobByRequestId(QXmppTransferJo
QXmppTransferIncomingJob *QXmppTransferManagerPrivate::getIncomingJobByRequestId(const QString &jid, const QString &id)
{
- return static_cast<QXmppTransferIncomingJob*>(getJobByRequestId(QXmppTransferJob::IncomingDirection, jid, id));
+ return static_cast<QXmppTransferIncomingJob *>(getJobByRequestId(QXmppTransferJob::IncomingDirection, jid, id));
}
-QXmppTransferIncomingJob* QXmppTransferManagerPrivate::getIncomingJobBySid(const QString &jid, const QString &sid)
+QXmppTransferIncomingJob *QXmppTransferManagerPrivate::getIncomingJobBySid(const QString &jid, const QString &sid)
{
for (auto *job : jobs) {
if (job->d->direction == QXmppTransferJob::IncomingDirection &&
job->d->jid == jid &&
job->d->sid == sid)
- return static_cast<QXmppTransferIncomingJob*>(job);
+ return static_cast<QXmppTransferIncomingJob *>(job);
}
return nullptr;
}
QXmppTransferOutgoingJob *QXmppTransferManagerPrivate::getOutgoingJobByRequestId(const QString &jid, const QString &id)
{
- return static_cast<QXmppTransferOutgoingJob*>(getJobByRequestId(QXmppTransferJob::OutgoingDirection, jid, id));
+ return static_cast<QXmppTransferOutgoingJob *>(getJobByRequestId(QXmppTransferJob::OutgoingDirection, jid, id));
}
/// Constructs a QXmppTransferManager to handle incoming and outgoing
@@ -821,20 +789,18 @@ void QXmppTransferManager::byteStreamResultReceived(const QXmppByteStreamIq &iq)
return;
// check the stream host
- if (iq.streamHostUsed() == job->d->socksProxy.jid())
- {
+ if (iq.streamHostUsed() == job->d->socksProxy.jid()) {
job->connectToProxy();
return;
}
// direction connection, start sending data
- if (!job->d->socksSocket)
- {
+ if (!job->d->socksSocket) {
warning("Client says they connected to our SOCKS server, but they did not");
job->terminate(QXmppTransferJob::ProtocolError);
return;
}
-
+
connect(job->d->socksSocket, &QTcpSocket::disconnected, job, &QXmppTransferOutgoingJob::_q_disconnected);
job->startSending();
}
@@ -851,8 +817,7 @@ void QXmppTransferManager::byteStreamSetReceived(const QXmppByteStreamIq &iq)
QXmppTransferIncomingJob *job = d->getIncomingJobBySid(iq.from(), iq.sid());
if (!job ||
job->method() != QXmppTransferJob::SocksMethod ||
- job->state() != QXmppTransferJob::StartState)
- {
+ job->state() != QXmppTransferJob::StartState) {
// the stream is unknown
QXmppStanza::Error error(QXmppStanza::Error::Auth, QXmppStanza::Error::NotAcceptable);
error.setCode(406);
@@ -869,10 +834,10 @@ void QXmppTransferManager::byteStreamSetReceived(const QXmppByteStreamIq &iq)
QStringList QXmppTransferManager::discoveryFeatures() const
{
return QStringList()
- << ns_ibb // XEP-0047: In-Band Bytestreams
- << ns_bytestreams // XEP-0065: SOCKS5 Bytestreams
- << ns_stream_initiation // XEP-0095: Stream Initiation
- << ns_stream_initiation_file_transfer; // XEP-0096: SI File Transfer
+ << ns_ibb // XEP-0047: In-Band Bytestreams
+ << ns_bytestreams // XEP-0065: SOCKS5 Bytestreams
+ << ns_stream_initiation // XEP-0095: Stream Initiation
+ << ns_stream_initiation_file_transfer; // XEP-0096: SI File Transfer
}
bool QXmppTransferManager::handleStanza(const QDomElement &element)
@@ -881,38 +846,31 @@ bool QXmppTransferManager::handleStanza(const QDomElement &element)
return false;
// XEP-0047 In-Band Bytestreams
- if(QXmppIbbCloseIq::isIbbCloseIq(element))
- {
+ if (QXmppIbbCloseIq::isIbbCloseIq(element)) {
QXmppIbbCloseIq ibbCloseIq;
ibbCloseIq.parse(element);
ibbCloseIqReceived(ibbCloseIq);
return true;
- }
- else if(QXmppIbbDataIq::isIbbDataIq(element))
- {
+ } else if (QXmppIbbDataIq::isIbbDataIq(element)) {
QXmppIbbDataIq ibbDataIq;
ibbDataIq.parse(element);
ibbDataIqReceived(ibbDataIq);
return true;
- }
- else if(QXmppIbbOpenIq::isIbbOpenIq(element))
- {
+ } else if (QXmppIbbOpenIq::isIbbOpenIq(element)) {
QXmppIbbOpenIq ibbOpenIq;
ibbOpenIq.parse(element);
ibbOpenIqReceived(ibbOpenIq);
return true;
}
// XEP-0065: SOCKS5 Bytestreams
- else if(QXmppByteStreamIq::isByteStreamIq(element))
- {
+ else if (QXmppByteStreamIq::isByteStreamIq(element)) {
QXmppByteStreamIq byteStreamIq;
byteStreamIq.parse(element);
byteStreamIqReceived(byteStreamIq);
return true;
}
// XEP-0095: Stream Initiation
- else if(QXmppStreamInitiationIq::isStreamInitiationIq(element))
- {
+ else if (QXmppStreamInitiationIq::isStreamInitiationIq(element)) {
QXmppStreamInitiationIq siIq;
siIq.parse(element);
streamInitiationIqReceived(siIq);
@@ -939,8 +897,7 @@ void QXmppTransferManager::ibbCloseIqReceived(const QXmppIbbCloseIq &iq)
QXmppTransferIncomingJob *job = d->getIncomingJobBySid(iq.from(), iq.sid());
if (!job ||
- job->method() != QXmppTransferJob::InBandMethod)
- {
+ job->method() != QXmppTransferJob::InBandMethod) {
// the job is unknown, cancel it
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::ItemNotFound);
response.setType(QXmppIq::Error);
@@ -966,8 +923,7 @@ void QXmppTransferManager::ibbDataIqReceived(const QXmppIbbDataIq &iq)
QXmppTransferIncomingJob *job = d->getIncomingJobBySid(iq.from(), iq.sid());
if (!job ||
job->method() != QXmppTransferJob::InBandMethod ||
- job->state() != QXmppTransferJob::TransferState)
- {
+ job->state() != QXmppTransferJob::TransferState) {
// the job is unknown, cancel it
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::ItemNotFound);
response.setType(QXmppIq::Error);
@@ -976,8 +932,7 @@ void QXmppTransferManager::ibbDataIqReceived(const QXmppIbbDataIq &iq)
return;
}
- if (iq.sequence() != job->d->ibbSequence)
- {
+ if (iq.sequence() != job->d->ibbSequence) {
// the packet is out of sequence
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::UnexpectedRequest);
response.setType(QXmppIq::Error);
@@ -1003,8 +958,7 @@ void QXmppTransferManager::ibbOpenIqReceived(const QXmppIbbOpenIq &iq)
QXmppTransferJob *job = d->getIncomingJobBySid(iq.from(), iq.sid());
if (!job ||
- job->method() != QXmppTransferJob::InBandMethod)
- {
+ job->method() != QXmppTransferJob::InBandMethod) {
// the job is unknown, cancel it
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::ItemNotFound);
response.setType(QXmppIq::Error);
@@ -1013,8 +967,7 @@ void QXmppTransferManager::ibbOpenIqReceived(const QXmppIbbOpenIq &iq)
return;
}
- if (iq.blockSize() > d->ibbBlockSize)
- {
+ if (iq.blockSize() > d->ibbBlockSize) {
// we prefer a smaller block size
QXmppStanza::Error error(QXmppStanza::Error::Modify, QXmppStanza::Error::ResourceConstraint);
response.setType(QXmppIq::Error);
@@ -1043,12 +996,10 @@ void QXmppTransferManager::ibbResponseReceived(const QXmppIq &iq)
if (!job->d->iodevice->isOpen())
return;
- if (iq.type() == QXmppIq::Result)
- {
+ if (iq.type() == QXmppIq::Result) {
const QByteArray buffer = job->d->iodevice->read(job->d->blockSize);
job->setState(QXmppTransferJob::TransferState);
- if (buffer.size())
- {
+ if (buffer.size()) {
// send next data block
QXmppIbbDataIq dataIq;
dataIq.setTo(job->d->jid);
@@ -1070,9 +1021,7 @@ void QXmppTransferManager::ibbResponseReceived(const QXmppIq &iq)
job->terminate(QXmppTransferJob::NoError);
}
- }
- else if (iq.type() == QXmppIq::Error)
- {
+ } else if (iq.type() == QXmppIq::Error) {
// close the bytestream
QXmppIbbCloseIq closeIq;
closeIq.setTo(job->d->jid);
@@ -1090,11 +1039,10 @@ void QXmppTransferManager::_q_iqReceived(const QXmppIq &iq)
for (auto *ptr : d->jobs) {
// handle IQ from proxy
if (ptr->direction() == QXmppTransferJob::OutgoingDirection && ptr->d->socksProxy.jid() == iq.from() && ptr->d->requestId == iq.id()) {
- auto *job = static_cast<QXmppTransferOutgoingJob*>(ptr);
+ auto *job = static_cast<QXmppTransferOutgoingJob *>(ptr);
if (job->d->socksSocket) {
// proxy connection activation result
- if (iq.type() == QXmppIq::Result)
- {
+ if (iq.type() == QXmppIq::Result) {
// proxy stream activated, start sending data
job->startSending();
} else if (iq.type() == QXmppIq::Error) {
@@ -1111,24 +1059,18 @@ void QXmppTransferManager::_q_iqReceived(const QXmppIq &iq)
}
// handle IQ from peer
- else if (ptr->d->jid == iq.from() && ptr->d->requestId == iq.id())
- {
+ else if (ptr->d->jid == iq.from() && ptr->d->requestId == iq.id()) {
QXmppTransferJob *job = ptr;
if (job->direction() == QXmppTransferJob::OutgoingDirection &&
- job->method() == QXmppTransferJob::InBandMethod)
- {
+ job->method() == QXmppTransferJob::InBandMethod) {
ibbResponseReceived(iq);
return;
- }
- else if (job->direction() == QXmppTransferJob::IncomingDirection &&
- job->method() == QXmppTransferJob::SocksMethod)
- {
+ } else if (job->direction() == QXmppTransferJob::IncomingDirection &&
+ job->method() == QXmppTransferJob::SocksMethod) {
byteStreamResponseReceived(iq);
return;
- }
- else if (job->direction() == QXmppTransferJob::OutgoingDirection &&
- iq.type() == QXmppIq::Error)
- {
+ } else if (job->direction() == QXmppTransferJob::OutgoingDirection &&
+ iq.type() == QXmppIq::Error) {
// remote party cancelled stream initiation
job->terminate(QXmppTransferJob::AbortError);
return;
@@ -1139,7 +1081,7 @@ void QXmppTransferManager::_q_iqReceived(const QXmppIq &iq)
void QXmppTransferManager::_q_jobDestroyed(QObject *object)
{
- d->jobs.removeAll(static_cast<QXmppTransferJob*>(object));
+ d->jobs.removeAll(static_cast<QXmppTransferJob *>(object));
}
void QXmppTransferManager::_q_jobError(QXmppTransferJob::Error error)
@@ -1150,8 +1092,7 @@ void QXmppTransferManager::_q_jobError(QXmppTransferJob::Error error)
if (job->direction() == QXmppTransferJob::OutgoingDirection &&
job->method() == QXmppTransferJob::InBandMethod &&
- error == QXmppTransferJob::AbortError)
- {
+ error == QXmppTransferJob::AbortError) {
// close the bytestream
QXmppIbbCloseIq closeIq;
closeIq.setTo(job->d->jid);
@@ -1184,8 +1125,7 @@ void QXmppTransferManager::_q_jobStateChanged(QXmppTransferJob::State state)
this, &QXmppTransferManager::_q_jobStateChanged);
// the job was refused by the local party
- if (state != QXmppTransferJob::StartState || !job->d->iodevice || !job->d->iodevice->isWritable())
- {
+ if (state != QXmppTransferJob::StartState || !job->d->iodevice || !job->d->iodevice->isWritable()) {
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::Forbidden);
error.setCode(403);
@@ -1253,20 +1193,17 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QStri
// open file
QIODevice *device = new QFile(filePath, this);
- if (!device->open(QIODevice::ReadOnly))
- {
+ if (!device->open(QIODevice::ReadOnly)) {
warning(QString("Could not read from %1").arg(filePath));
delete device;
device = nullptr;
}
// hash file
- if (device && !device->isSequential())
- {
+ if (device && !device->isSequential()) {
QCryptographicHash hash(QCryptographicHash::Md5);
QByteArray buffer;
- while (device->bytesAvailable())
- {
+ while (device->bytesAvailable()) {
buffer = device->read(16384);
hash.addData(buffer);
}
@@ -1307,15 +1244,13 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, QIODevice *
job->d->iodevice = device;
// check file is open
- if (!device || !device->isReadable())
- {
+ if (!device || !device->isReadable()) {
job->terminate(QXmppTransferJob::FileAccessError);
return job;
}
// check we support some methods
- if (!d->supportedMethods)
- {
+ if (!d->supportedMethods) {
job->terminate(QXmppTransferJob::ProtocolError);
return job;
}
@@ -1335,7 +1270,7 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, QIODevice *
// start job
d->jobs.append(job);
- connect(job, &QObject::destroyed, this, &QXmppTransferManager::_q_jobDestroyed);
+ connect(job, &QObject::destroyed, this, &QXmppTransferManager::_q_jobDestroyed);
connect(job, QOverload<QXmppTransferJob::Error>::of(&QXmppTransferJob::error), this, &QXmppTransferManager::_q_jobError);
connect(job, &QXmppTransferJob::finished, this, &QXmppTransferManager::_q_jobFinished);
@@ -1390,8 +1325,7 @@ void QXmppTransferManager::socksServerSendOffer(QXmppTransferJob *job)
streamHosts.append(job->d->socksProxy);
// check we have some stream hosts
- if (!streamHosts.size())
- {
+ if (!streamHosts.size()) {
warning("Could not determine local stream hosts");
job->terminate(QXmppTransferJob::ProtocolError);
return;
@@ -1437,8 +1371,7 @@ void QXmppTransferManager::streamInitiationResultReceived(const QXmppStreamIniti
// remote party accepted stream initiation
job->setState(QXmppTransferJob::StartState);
- if (job->method() == QXmppTransferJob::InBandMethod)
- {
+ if (job->method() == QXmppTransferJob::InBandMethod) {
// lower block size for IBB
job->d->blockSize = d->ibbBlockSize;
@@ -1449,8 +1382,7 @@ void QXmppTransferManager::streamInitiationResultReceived(const QXmppStreamIniti
job->d->requestId = openIq.id();
client()->sendPacket(openIq);
} else if (job->method() == QXmppTransferJob::SocksMethod) {
- if (!d->proxy.isEmpty())
- {
+ if (!d->proxy.isEmpty()) {
job->d->socksProxy.setJid(d->proxy);
// query proxy
@@ -1476,8 +1408,7 @@ void QXmppTransferManager::streamInitiationSetReceived(const QXmppStreamInitiati
response.setId(iq.id());
// check we support the profile
- if (iq.profile() != QXmppStreamInitiationIq::FileTransfer)
- {
+ if (iq.profile() != QXmppStreamInitiationIq::FileTransfer) {
// FIXME : we should add:
// <bad-profile xmlns='http://jabber.org/protocol/si'/>
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::BadRequest);
@@ -1527,8 +1458,7 @@ void QXmppTransferManager::streamInitiationSetReceived(const QXmppStreamInitiati
job->d->method = QXmppTransferJob::SocksMethod;
else if (sharedMethods & QXmppTransferJob::InBandMethod)
job->d->method = QXmppTransferJob::InBandMethod;
- else
- {
+ else {
// FIXME : we should add:
// <no-valid-streams xmlns='http://jabber.org/protocol/si'/>
QXmppStanza::Error error(QXmppStanza::Error::Cancel, QXmppStanza::Error::BadRequest);
diff --git a/src/client/QXmppTransferManager.h b/src/client/QXmppTransferManager.h
index b5b098a6..0c48b8b8 100644
--- a/src/client/QXmppTransferManager.h
+++ b/src/client/QXmppTransferManager.h
@@ -24,13 +24,13 @@
#ifndef QXMPPTRANSFERMANAGER_H
#define QXMPPTRANSFERMANAGER_H
+#include "QXmppClientExtension.h"
+
#include <QDateTime>
#include <QSharedData>
#include <QUrl>
#include <QVariant>
-#include "QXmppClientExtension.h"
-
class QTcpSocket;
class QXmppByteStreamIq;
class QXmppIbbCloseIq;
diff --git a/src/client/QXmppUploadRequestManager.cpp b/src/client/QXmppUploadRequestManager.cpp
index b0321150..d65382cd 100644
--- a/src/client/QXmppUploadRequestManager.cpp
+++ b/src/client/QXmppUploadRequestManager.cpp
@@ -214,7 +214,7 @@ void QXmppUploadRequestManager::handleDiscoInfo(const QXmppDiscoveryIq &iq)
for (const QXmppDiscoveryIq::Identity &identity : iq.identities()) {
if (identity.category() == QStringLiteral("store") &&
- identity.type() == QStringLiteral("file")) {
+ identity.type() == QStringLiteral("file")) {
QXmppUploadService service;
service.setJid(iq.from());
@@ -246,7 +246,7 @@ void QXmppUploadRequestManager::setClient(QXmppClient *client)
this, &QXmppUploadRequestManager::handleDiscoInfo);
// on client disconnect remove all upload services
- connect(client, &QXmppClient::disconnected, [=] () {
+ connect(client, &QXmppClient::disconnected, [=]() {
d->uploadServices.clear();
emit serviceFoundChanged();
});
diff --git a/src/client/QXmppVCardManager.cpp b/src/client/QXmppVCardManager.cpp
index 9d8b782a..8a1b4bab 100644
--- a/src/client/QXmppVCardManager.cpp
+++ b/src/client/QXmppVCardManager.cpp
@@ -54,7 +54,7 @@ QXmppVCardManager::~QXmppVCardManager()
QString QXmppVCardManager::requestVCard(const QString& jid)
{
QXmppVCardIq request(jid);
- if(client()->sendPacket(request))
+ if (client()->sendPacket(request))
return request.id();
else
return QString();
@@ -107,10 +107,9 @@ QStringList QXmppVCardManager::discoveryFeatures() const
return QStringList() << ns_vcard;
}
-bool QXmppVCardManager::handleStanza(const QDomElement &element)
+bool QXmppVCardManager::handleStanza(const QDomElement& element)
{
- if(element.tagName() == "iq" && QXmppVCardIq::isVCard(element))
- {
+ if (element.tagName() == "iq" && QXmppVCardIq::isVCard(element)) {
QXmppVCardIq vCardIq;
vCardIq.parse(element);
diff --git a/src/client/QXmppVersionManager.cpp b/src/client/QXmppVersionManager.cpp
index 7c5fbafd..2d1bdb9a 100644
--- a/src/client/QXmppVersionManager.cpp
+++ b/src/client/QXmppVersionManager.cpp
@@ -67,7 +67,7 @@ QString QXmppVersionManager::requestVersion(const QString& jid)
QXmppVersionIq request;
request.setType(QXmppIq::Get);
request.setTo(jid);
- if(client()->sendPacket(request))
+ if (client()->sendPacket(request))
return request.id();
else
return QString();
@@ -137,10 +137,9 @@ QStringList QXmppVersionManager::discoveryFeatures() const
return QStringList() << ns_version;
}
-bool QXmppVersionManager::handleStanza(const QDomElement &element)
+bool QXmppVersionManager::handleStanza(const QDomElement& element)
{
- if (element.tagName() == "iq" && QXmppVersionIq::isVersionIq(element))
- {
+ if (element.tagName() == "iq" && QXmppVersionIq::isVersionIq(element)) {
QXmppVersionIq versionIq;
versionIq.parse(element);