Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit b2292d2

Browse files
committed
Call: Remove own IQ ack handling
Currently the acks (or missing acks) are not used. Also, the result handling from Client::sendIq() should rather be used.
1 parent 775e145 commit b2292d2

File tree

4 files changed

+10
-53
lines changed

4 files changed

+10
-53
lines changed

src/client/QXmppCall.cpp

+7-26
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,6 @@ QXmppCallStream *QXmppCallPrivate::findStreamById(int id)
207207
return nullptr;
208208
}
209209

210-
void QXmppCallPrivate::handleAck(const QXmppIq &ack)
211-
{
212-
auto request = std::ranges::find(requests, ack.id(), &QXmppJingleIq::id);
213-
if (request != requests.end()) {
214-
// process acknowledgement
215-
q->debug(u"Received ACK for packet %1"_s.arg(ack.id()));
216-
requests.erase(request);
217-
}
218-
}
219-
220210
bool QXmppCallPrivate::handleDescription(QXmppCallStream *stream, const QXmppJingleIq::Content &content)
221211
{
222212
stream->d->payloadTypes = content.payloadTypes();
@@ -372,7 +362,7 @@ void QXmppCallPrivate::handleRequest(const QXmppJingleIq &iq)
372362
iq.setAction(QXmppJingleIq::ContentReject);
373363
iq.setSid(q->sid());
374364
iq.reason().setType(QXmppJingleIq::Reason::FailedApplication);
375-
sendRequest(iq);
365+
manager->client()->sendIq(std::move(iq));
376366
streams.removeAll(stream);
377367
delete stream;
378368
return;
@@ -385,7 +375,7 @@ void QXmppCallPrivate::handleRequest(const QXmppJingleIq &iq)
385375
iq.setAction(QXmppJingleIq::ContentAccept);
386376
iq.setSid(q->sid());
387377
iq.addContent(localContent(stream));
388-
sendRequest(iq);
378+
manager->client()->sendIq(std::move(iq));
389379

390380
} else if (iq.action() == QXmppJingleIq::TransportInfo) {
391381

@@ -481,7 +471,7 @@ bool QXmppCallPrivate::sendAck(const QXmppJingleIq &iq)
481471
return manager->client()->sendPacket(ack);
482472
}
483473

484-
bool QXmppCallPrivate::sendInvite()
474+
void QXmppCallPrivate::sendInvite()
485475
{
486476
// create audio stream
487477
QXmppCallStream *stream = findStreamByMedia(AUDIO_MEDIA);
@@ -494,16 +484,7 @@ bool QXmppCallPrivate::sendInvite()
494484
iq.setInitiator(ownJid);
495485
iq.setSid(sid);
496486
iq.addContent(localContent(stream));
497-
return sendRequest(iq);
498-
}
499-
500-
///
501-
/// Sends a Jingle IQ and adds it to outstanding requests.
502-
///
503-
bool QXmppCallPrivate::sendRequest(const QXmppJingleIq &iq)
504-
{
505-
requests << iq;
506-
return manager->client()->sendPacket(iq);
487+
manager->client()->send(std::move(iq));
507488
}
508489

509490
void QXmppCallPrivate::setState(QXmppCall::State newState)
@@ -587,7 +568,7 @@ void QXmppCall::accept()
587568
iq.setResponder(d->ownJid);
588569
iq.setSid(d->sid);
589570
iq.addContent(d->localContent(stream));
590-
d->sendRequest(iq);
571+
d->manager->client()->sendIq(std::move(iq));
591572

592573
// notify user
593574
Q_EMIT d->manager->callStarted(this);
@@ -665,7 +646,7 @@ void QXmppCall::onLocalCandidatesChanged(QXmppCallStream *stream)
665646
iq.setAction(QXmppJingleIq::TransportInfo);
666647
iq.setSid(d->sid);
667648
iq.addContent(d->localContent(stream));
668-
d->sendRequest(iq);
649+
d->manager->client()->sendIq(std::move(iq));
669650
}
670651

671652
///
@@ -721,5 +702,5 @@ void QXmppCall::addVideo()
721702
iq.setAction(QXmppJingleIq::ContentAdd);
722703
iq.setSid(d->sid);
723704
iq.addContent(d->localContent(stream));
724-
d->sendRequest(iq);
705+
d->manager->client()->sendIq(std::move(iq));
725706
}

src/client/QXmppCallManager.cpp

+2-22
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "QXmppClient.h"
1111
#include "QXmppConstants_p.h"
1212
#include "QXmppJingleIq.h"
13+
#include "QXmppTask.h"
1314
#include "QXmppUtils.h"
1415

1516
#include "StringLiterals.h"
@@ -95,9 +96,6 @@ void QXmppCallManager::onRegistered(QXmppClient *client)
9596
connect(client, &QXmppClient::disconnected,
9697
this, &QXmppCallManager::_q_disconnected);
9798

98-
connect(client, &QXmppClient::iqReceived,
99-
this, &QXmppCallManager::_q_iqReceived);
100-
10199
connect(client, &QXmppClient::presenceReceived,
102100
this, &QXmppCallManager::_q_presenceReceived);
103101
}
@@ -107,9 +105,6 @@ void QXmppCallManager::onUnregistered(QXmppClient *client)
107105
disconnect(client, &QXmppClient::disconnected,
108106
this, &QXmppCallManager::_q_disconnected);
109107

110-
disconnect(client, &QXmppClient::iqReceived,
111-
this, &QXmppCallManager::_q_iqReceived);
112-
113108
disconnect(client, &QXmppClient::presenceReceived,
114109
this, &QXmppCallManager::_q_presenceReceived);
115110
}
@@ -228,21 +223,6 @@ void QXmppCallManager::_q_disconnected()
228223
}
229224
}
230225

231-
///
232-
/// Handles acknowledgements.
233-
///
234-
void QXmppCallManager::_q_iqReceived(const QXmppIq &ack)
235-
{
236-
if (ack.type() != QXmppIq::Result) {
237-
return;
238-
}
239-
240-
// find request
241-
for (auto *call : std::as_const(d->calls)) {
242-
call->d->handleAck(ack);
243-
}
244-
}
245-
246226
///
247227
/// Handles a Jingle IQ.
248228
///
@@ -292,7 +272,7 @@ void QXmppCallManager::_q_jingleIqReceived(const QXmppJingleIq &iq)
292272
ringing.setType(QXmppIq::Set);
293273
ringing.setSid(call->sid());
294274
ringing.setRtpSessionState(QXmppJingleIq::RtpSessionStateRinging());
295-
call->d->sendRequest(ringing);
275+
client()->sendIq(std::move(ringing));
296276

297277
// notify user
298278
Q_EMIT callReceived(call);

src/client/QXmppCallManager.h

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public Q_SLOTS:
8282
private Q_SLOTS:
8383
void _q_callDestroyed(QObject *object);
8484
void _q_disconnected();
85-
void _q_iqReceived(const QXmppIq &iq);
8685
void _q_jingleIqReceived(const QXmppJingleIq &iq);
8786
void _q_presenceReceived(const QXmppPresence &presence);
8887

src/client/QXmppCall_p.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,18 @@ class QXmppCallPrivate : public QObject
6262
QXmppCallStream *findStreamById(int id);
6363
QXmppJingleIq::Content localContent(QXmppCallStream *stream) const;
6464

65-
void handleAck(const QXmppIq &iq);
6665
bool handleDescription(QXmppCallStream *stream, const QXmppJingleIq::Content &content);
6766
void handleRequest(const QXmppJingleIq &iq);
6867
bool handleTransport(QXmppCallStream *stream, const QXmppJingleIq::Content &content);
6968
void setState(QXmppCall::State state);
7069
bool sendAck(const QXmppJingleIq &iq);
71-
bool sendInvite();
72-
bool sendRequest(const QXmppJingleIq &iq);
70+
void sendInvite();
7371
void terminate(QXmppJingleIq::Reason::Type reasonType);
7472

7573
QXmppCall::Direction direction;
7674
QString jid;
7775
QString ownJid;
7876
QXmppCallManager *manager;
79-
QList<QXmppJingleIq> requests;
8077
QString sid;
8178
QXmppCall::State state;
8279

0 commit comments

Comments
 (0)