diff options
| author | JBB <jbb.prv@gmx.de> | 2020-01-20 00:19:38 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-01-20 00:19:38 +0100 |
| commit | 8557bc3a605e5d2b1a7dae5999501b19c1c99b58 (patch) | |
| tree | f17fefa61a26e01c99884c7d3e458b8ea70b181b /examples | |
| parent | cccb7675e0eb9d411c736d1ff3f189fb75ef33dd (diff) | |
| download | qxmpp-8557bc3a605e5d2b1a7dae5999501b19c1c99b58.tar.gz | |
Port majority of old-style connects (#237)
This provides more type safety and is future-proof.
Diffstat (limited to 'examples')
4 files changed, 24 insertions, 51 deletions
diff --git a/examples/example_1_echoClient/example_1_echoClient.cpp b/examples/example_1_echoClient/example_1_echoClient.cpp index a89e6d3d..86c33049 100644 --- a/examples/example_1_echoClient/example_1_echoClient.cpp +++ b/examples/example_1_echoClient/example_1_echoClient.cpp @@ -32,10 +32,7 @@ echoClient::echoClient(QObject *parent) : QXmppClient(parent) { - bool check = connect(this, SIGNAL(messageReceived(QXmppMessage)), - SLOT(messageReceived(QXmppMessage))); - Q_ASSERT(check); - Q_UNUSED(check); + connect(this, &QXmppClient::messageReceived, this, &echoClient::messageReceived); } echoClient::~echoClient() diff --git a/examples/example_3_transferHandling/example_3_transferHandling.cpp b/examples/example_3_transferHandling/example_3_transferHandling.cpp index cd909787..c533fd18 100644 --- a/examples/example_3_transferHandling/example_3_transferHandling.cpp +++ b/examples/example_3_transferHandling/example_3_transferHandling.cpp @@ -37,8 +37,6 @@ xmppClient::xmppClient(QObject *parent) : QXmppClient(parent), transferManager(nullptr) { - bool check; - Q_UNUSED(check); // add transfer manager transferManager = new QXmppTransferManager; @@ -50,13 +48,11 @@ xmppClient::xmppClient(QObject *parent) // transferManager->setSupportedMethods(QXmppTransferJob::InBandMethod); // transferManager->setSupportedMethods(QXmppTransferJob::SocksMethod); - check = connect(this, SIGNAL(presenceReceived(QXmppPresence)), - this, SLOT(slotPresenceReceived(QXmppPresence))); - Q_ASSERT(check); + connect(this, &QXmppClient::presenceReceived, + this, &xmppClient::slotPresenceReceived); - check = connect(transferManager, SIGNAL(fileReceived(QXmppTransferJob*)), - this, SLOT(slotFileReceived(QXmppTransferJob*))); - Q_ASSERT(check); + connect(transferManager, &QXmppTransferManager::fileReceived, + this, &xmppClient::slotFileReceived); } void xmppClient::setRecipient(const QString &recipient) @@ -75,22 +71,16 @@ void xmppClient::slotError(QXmppTransferJob::Error error) void xmppClient::slotFileReceived(QXmppTransferJob *job) { - bool check; - Q_UNUSED(check); - qDebug() << "Got transfer request from:" << job->jid(); - check = connect(job, SIGNAL(error(QXmppTransferJob::Error)), + connect(job, SIGNAL(error(QXmppTransferJob::Error)), this, SLOT(slotError(QXmppTransferJob::Error))); - Q_ASSERT(check); - check = connect(job, SIGNAL(finished()), - this, SLOT(slotFinished())); - Q_ASSERT(check); + connect(job, &QXmppTransferJob::finished, + this, &xmppClient::slotFinished); - check = connect(job, SIGNAL(progress(qint64,qint64)), - this, SLOT(slotProgress(qint64,qint64))); - Q_ASSERT(check); + connect(job, &QXmppTransferJob::progress, + this, &xmppClient::slotProgress); // allocate a buffer to receive the file auto *buffer = new QBuffer(this); @@ -109,9 +99,6 @@ void xmppClient::slotFinished() void xmppClient::slotPresenceReceived(const QXmppPresence &presence) { - bool check; - Q_UNUSED(check); - // if we don't have a recipient, or if the presence is not from the recipient, // do nothing if (m_recipient.isEmpty() || @@ -122,17 +109,13 @@ void xmppClient::slotPresenceReceived(const QXmppPresence &presence) // send the file and connect to the job's signals QXmppTransferJob *job = transferManager->sendFile(presence.from(), ":/example_3_transferHandling.cpp", "example source code"); - check = connect(job, SIGNAL(error(QXmppTransferJob::Error)), + connect(job, SIGNAL(error(QXmppTransferJob::Error)), this, SLOT(slotError(QXmppTransferJob::Error))); - Q_ASSERT(check); - - check = connect(job, SIGNAL(finished()), - this, SLOT(slotFinished())); - Q_ASSERT(check); + connect(job, &QXmppTransferJob::finished, + this, &xmppClient::slotFinished); - check = connect(job, SIGNAL(progress(qint64,qint64)), - this, SLOT(slotProgress(qint64,qint64))); - Q_ASSERT(check); + connect(job, &QXmppTransferJob::progress, + this, &xmppClient::slotProgress); } /// A file transfer has made progress. diff --git a/examples/example_6_rpcClient/rpcClient.cpp b/examples/example_6_rpcClient/rpcClient.cpp index ca49e480..0179231a 100644 --- a/examples/example_6_rpcClient/rpcClient.cpp +++ b/examples/example_6_rpcClient/rpcClient.cpp @@ -38,10 +38,8 @@ rpcClient::rpcClient(QObject *parent) addExtension(m_rpcManager); // observe incoming presences - bool check = connect(this, SIGNAL(presenceReceived(QXmppPresence)), - this, SLOT(slotPresenceReceived(QXmppPresence))); - Q_ASSERT(check); - Q_UNUSED(check); + connect(this, &QXmppClient::presenceReceived, + this, &rpcClient::slotPresenceReceived); } rpcClient::~rpcClient() @@ -73,6 +71,6 @@ void rpcClient::slotPresenceReceived(const QXmppPresence &presence) // invoke the remote method in 1 second m_remoteJid = presence.from(); - QTimer::singleShot(1000, this, SLOT(slotInvokeRemoteMethod())); + QTimer::singleShot(1000, this, &rpcClient::slotInvokeRemoteMethod); } diff --git a/examples/example_7_archiveHandling/example_7_archiveHandling.cpp b/examples/example_7_archiveHandling/example_7_archiveHandling.cpp index 9c49bd40..8ee77626 100644 --- a/examples/example_7_archiveHandling/example_7_archiveHandling.cpp +++ b/examples/example_7_archiveHandling/example_7_archiveHandling.cpp @@ -45,25 +45,20 @@ xmppClient::xmppClient(QObject *parent) , m_pageDirection(PageForwards) , m_pageSize(10) { - bool check; - Q_UNUSED(check); // add archive manager archiveManager = new QXmppArchiveManager; addExtension(archiveManager); // connect signals - check = connect(this, SIGNAL(connected()), - this, SLOT(clientConnected())); - Q_ASSERT(check); + connect(this, &QXmppClient::connected, + this, &xmppClient::clientConnected); - check = connect(archiveManager, SIGNAL(archiveChatReceived(QXmppArchiveChat, QXmppResultSetReply)), - SLOT(archiveChatReceived(QXmppArchiveChat, QXmppResultSetReply))); - Q_ASSERT(check); + connect(archiveManager, &QXmppArchiveManager::archiveChatReceived, + this, &xmppClient::archiveChatReceived); - check = connect(archiveManager, SIGNAL(archiveListReceived(QList<QXmppArchiveChat>, QXmppResultSetReply)), - SLOT(archiveListReceived(QList<QXmppArchiveChat>, QXmppResultSetReply))); - Q_ASSERT(check); + connect(archiveManager, &QXmppArchiveManager::archiveListReceived, + this, &xmppClient::archiveListReceived); // set limits m_startDate = QDateTime::currentDateTime().addDays(-21); |
