show proposal as ongoing call
This commit is contained in:
parent
f7a0d2031a
commit
48163a5604
|
@ -29,6 +29,7 @@ import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.utils.XmppUri;
|
import eu.siacs.conversations.utils.XmppUri;
|
||||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.RtpCapability;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class Account extends AbstractEntity implements AvatarService.Avatarable {
|
public class Account extends AbstractEntity implements AvatarService.Avatarable {
|
||||||
|
@ -426,6 +427,16 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
||||||
return this.getSelfContact().getPresences().size();
|
return this.getSelfContact().getPresences().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int activeDevicesWithRtpCapability() {
|
||||||
|
int i = 0;
|
||||||
|
for(Presence presence : getSelfContact().getPresences().getPresences().values()) {
|
||||||
|
if (RtpCapability.check(presence) != RtpCapability.Capability.NONE) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPgpSignature() {
|
public String getPgpSignature() {
|
||||||
return getKey(KEY_PGP_SIGNATURE);
|
return getKey(KEY_PGP_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,10 @@ import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||||
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
|
||||||
import eu.siacs.conversations.xmpp.jingle.JingleFileTransferConnection;
|
import eu.siacs.conversations.xmpp.jingle.JingleFileTransferConnection;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.Media;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession;
|
||||||
import eu.siacs.conversations.xmpp.jingle.RtpCapability;
|
import eu.siacs.conversations.xmpp.jingle.RtpCapability;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
|
@ -971,7 +974,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
menuCall.setVisible(false);
|
menuCall.setVisible(false);
|
||||||
menuOngoingCall.setVisible(false);
|
menuOngoingCall.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
final Optional<AbstractJingleConnection.Id> ongoingRtpSession = activity.xmppConnectionService.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
final Optional<OngoingRtpSession> ongoingRtpSession = activity.xmppConnectionService.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
||||||
if (ongoingRtpSession.isPresent()) {
|
if (ongoingRtpSession.isPresent()) {
|
||||||
menuOngoingCall.setVisible(true);
|
menuOngoingCall.setVisible(true);
|
||||||
menuCall.setVisible(false);
|
menuCall.setVisible(false);
|
||||||
|
@ -1267,13 +1270,22 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
private void returnToOngoingCall() {
|
private void returnToOngoingCall() {
|
||||||
final Optional<AbstractJingleConnection.Id> ongoingRtpSession = activity.xmppConnectionService.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
final Optional<OngoingRtpSession> ongoingRtpSession = activity.xmppConnectionService.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
||||||
if (ongoingRtpSession.isPresent()) {
|
if (ongoingRtpSession.isPresent()) {
|
||||||
final AbstractJingleConnection.Id id = ongoingRtpSession.get();
|
final OngoingRtpSession id = ongoingRtpSession.get();
|
||||||
final Intent intent = new Intent(getActivity(), RtpSessionActivity.class);
|
final Intent intent = new Intent(getActivity(), RtpSessionActivity.class);
|
||||||
intent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, id.account.getJid().asBareJid().toEscapedString());
|
intent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, id.getAccount().getJid().asBareJid().toEscapedString());
|
||||||
intent.putExtra(RtpSessionActivity.EXTRA_WITH, id.with.toEscapedString());
|
intent.putExtra(RtpSessionActivity.EXTRA_WITH, id.getWith().toEscapedString());
|
||||||
intent.putExtra(RtpSessionActivity.EXTRA_SESSION_ID, id.sessionId);
|
if (id instanceof AbstractJingleConnection.Id) {
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.putExtra(RtpSessionActivity.EXTRA_SESSION_ID, id.getSessionId());
|
||||||
|
} else if (id instanceof JingleConnectionManager.RtpSessionProposal) {
|
||||||
|
if (((JingleConnectionManager.RtpSessionProposal) id).media.contains(Media.VIDEO)) {
|
||||||
|
intent.setAction(RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
|
||||||
|
} else {
|
||||||
|
intent.setAction(RtpSessionActivity.ACTION_MAKE_VOICE_CALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import eu.siacs.conversations.utils.EmojiWrapper;
|
||||||
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
|
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapter.ConversationViewHolder> {
|
public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapter.ConversationViewHolder> {
|
||||||
|
@ -165,7 +166,7 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final Optional<AbstractJingleConnection.Id> ongoingCall;
|
final Optional<OngoingRtpSession> ongoingCall;
|
||||||
if (conversation.getMode() == Conversational.MODE_MULTI) {
|
if (conversation.getMode() == Conversational.MODE_MULTI) {
|
||||||
ongoingCall = Optional.absent();
|
ongoingCall = Optional.absent();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.xmpp.jingle;
|
package eu.siacs.conversations.xmpp.jingle;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -40,7 +41,7 @@ public abstract class AbstractJingleConnection {
|
||||||
abstract void notifyRebound();
|
abstract void notifyRebound();
|
||||||
|
|
||||||
|
|
||||||
public static class Id {
|
public static class Id implements OngoingRtpSession {
|
||||||
public final Account account;
|
public final Account account;
|
||||||
public final Jid with;
|
public final Jid with;
|
||||||
public final String sessionId;
|
public final String sessionId;
|
||||||
|
@ -87,6 +88,21 @@ public abstract class AbstractJingleConnection {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(account.getJid(), with, sessionId);
|
return Objects.hashCode(account.getJid(), with, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Account getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Jid getWith() {
|
||||||
|
return with;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -233,8 +233,8 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring call proposal from stranger " + id.with);
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring call proposal from stranger " + id.with);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int activeDevices = account.countPresences();
|
final int activeDevices = account.activeDevicesWithRtpCapability();
|
||||||
Log.d(Config.LOGTAG, "active devices: " + activeDevices);
|
Log.d(Config.LOGTAG, "active devices with rtp capability: " + activeDevices);
|
||||||
if (activeDevices == 0) {
|
if (activeDevices == 0) {
|
||||||
final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId);
|
final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId);
|
||||||
mXmppConnectionService.sendMessagePacket(account, reject);
|
mXmppConnectionService.sendMessagePacket(account, reject);
|
||||||
|
@ -353,7 +353,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
connection.init(message);
|
connection.init(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<AbstractJingleConnection.Id> getOngoingRtpConnection(final Contact contact) {
|
public Optional<OngoingRtpSession> getOngoingRtpConnection(final Contact contact) {
|
||||||
for (final Map.Entry<AbstractJingleConnection.Id, AbstractJingleConnection> entry : this.connections.entrySet()) {
|
for (final Map.Entry<AbstractJingleConnection.Id, AbstractJingleConnection> entry : this.connections.entrySet()) {
|
||||||
if (entry.getValue() instanceof JingleRtpConnection) {
|
if (entry.getValue() instanceof JingleRtpConnection) {
|
||||||
final AbstractJingleConnection.Id id = entry.getKey();
|
final AbstractJingleConnection.Id id = entry.getKey();
|
||||||
|
@ -362,6 +362,17 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
synchronized (this.rtpSessionProposals) {
|
||||||
|
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : this.rtpSessionProposals.entrySet()) {
|
||||||
|
RtpSessionProposal proposal = entry.getKey();
|
||||||
|
if (proposal.account == contact.getAccount() && contact.getJid().asBareJid().equals(proposal.with)) {
|
||||||
|
final DeviceDiscoveryState preexistingState = entry.getValue();
|
||||||
|
if (preexistingState != null && preexistingState != DeviceDiscoveryState.FAILED) {
|
||||||
|
return Optional.of(proposal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +636,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RtpSessionProposal {
|
public static class RtpSessionProposal implements OngoingRtpSession {
|
||||||
public final Jid with;
|
public final Jid with;
|
||||||
public final String sessionId;
|
public final String sessionId;
|
||||||
public final Set<Media> media;
|
public final Set<Media> media;
|
||||||
|
@ -660,5 +671,20 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(account.getJid(), with, sessionId);
|
return Objects.hashCode(account.getJid(), with, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Account getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Jid getWith() {
|
||||||
|
return with;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package eu.siacs.conversations.xmpp.jingle;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
|
public interface OngoingRtpSession {
|
||||||
|
Account getAccount();
|
||||||
|
Jid getWith();
|
||||||
|
String getSessionId();
|
||||||
|
}
|
Loading…
Reference in a new issue