make rtp proposal tracked by SM. fixes #3983

This commit is contained in:
Daniel Gultsch 2021-02-12 10:35:13 +01:00
parent 9f869d3895
commit 6cab0ad496
4 changed files with 34 additions and 11 deletions

View File

@ -152,6 +152,7 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
import eu.siacs.conversations.xmpp.jingle.Media;
import eu.siacs.conversations.xmpp.jingle.RtpEndUserState;
import eu.siacs.conversations.xmpp.mam.MamReference;
@ -251,10 +252,23 @@ public class XmppConnectionService extends Service {
private final OnMessageAcknowledged mOnMessageAcknowledgedListener = new OnMessageAcknowledged() {
@Override
public boolean onMessageAcknowledged(Account account, String uuid) {
public boolean onMessageAcknowledged(final Account account, final Jid to, final String id) {
if (id.startsWith(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX)) {
final String sessionId = id.substring(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX.length());
mJingleConnectionManager.updateProposedSessionDiscovered(
account,
to,
sessionId,
JingleConnectionManager.DeviceDiscoveryState.SEARCHING_ACKNOWLEDGED
);
}
final Jid bare = to.asBareJid();
for (final Conversation conversation : getConversations()) {
if (conversation.getAccount() == account) {
Message message = conversation.findUnsentMessageWithUuid(uuid);
if (conversation.getAccount() == account && conversation.getJid().asBareJid().equals(bare)) {
final Message message = conversation.findUnsentMessageWithUuid(id);
if (message != null) {
message.setStatus(Message.STATUS_SEND);
message.setErrorMessage(null);
@ -4281,7 +4295,7 @@ public class XmppConnectionService extends Service {
}
public void sendMessagePacket(Account account, MessagePacket packet) {
XmppConnection connection = account.getXmppConnection();
final XmppConnection connection = account.getXmppConnection();
if (connection != null) {
connection.sendMessagePacket(packet);
}

View File

@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp;
import eu.siacs.conversations.entities.Account;
public interface OnMessageAcknowledged {
boolean onMessageAcknowledged(Account account, String id);
boolean onMessageAcknowledged(Account account, Jid to, String id);
}

View File

@ -661,10 +661,14 @@ public class XmppConnection implements Runnable {
if (Config.EXTENDED_SM_LOGGING) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server acknowledged stanza #" + mStanzaQueue.keyAt(i));
}
AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i);
final AbstractAcknowledgeableStanza stanza = mStanzaQueue.valueAt(i);
if (stanza instanceof MessagePacket && acknowledgedListener != null) {
MessagePacket packet = (MessagePacket) stanza;
acknowledgedMessages |= acknowledgedListener.onMessageAcknowledged(account, packet.getId());
final MessagePacket packet = (MessagePacket) stanza;
final String id = packet.getId();
final Jid to = packet.getTo();
if (id != null && to != null) {
acknowledgedMessages |= acknowledgedListener.onMessageAcknowledged(account, to, id);
}
}
mStanzaQueue.removeAt(i);
i--;

View File

@ -133,7 +133,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
}
}
synchronized (this.rtpSessionProposals) {
return this.rtpSessionProposals.containsValue(DeviceDiscoveryState.DISCOVERED) || this.rtpSessionProposals.containsValue(DeviceDiscoveryState.SEARCHING);
return this.rtpSessionProposals.containsValue(DeviceDiscoveryState.DISCOVERED)
|| this.rtpSessionProposals.containsValue(DeviceDiscoveryState.SEARCHING)
|| this.rtpSessionProposals.containsValue(DeviceDiscoveryState.SEARCHING_ACKNOWLEDGED);
}
}
@ -154,7 +156,9 @@ public class JingleConnectionManager extends AbstractConnectionManager {
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : this.rtpSessionProposals.entrySet()) {
final RtpSessionProposal proposal = entry.getKey();
final DeviceDiscoveryState state = entry.getValue();
final boolean openProposal = state == DeviceDiscoveryState.DISCOVERED || state == DeviceDiscoveryState.SEARCHING;
final boolean openProposal = state == DeviceDiscoveryState.DISCOVERED
|| state == DeviceDiscoveryState.SEARCHING
|| state == DeviceDiscoveryState.SEARCHING_ACKNOWLEDGED;
if (openProposal
&& proposal.account == account
&& proposal.with.equals(with.asBareJid())
@ -772,11 +776,12 @@ public class JingleConnectionManager extends AbstractConnectionManager {
}
public enum DeviceDiscoveryState {
SEARCHING, DISCOVERED, FAILED;
SEARCHING, SEARCHING_ACKNOWLEDGED, DISCOVERED, FAILED;
public RtpEndUserState toEndUserState() {
switch (this) {
case SEARCHING:
case SEARCHING_ACKNOWLEDGED:
return RtpEndUserState.FINDING_DEVICE;
case DISCOVERED:
return RtpEndUserState.RINGING;