do not offer jingle calls when using Tor
This commit is contained in:
parent
9d83981f2c
commit
07e671d7c3
|
@ -34,14 +34,6 @@ public abstract class AbstractGenerator {
|
|||
Namespace.JINGLE_TRANSPORTS_IBB,
|
||||
Namespace.JINGLE_ENCRYPTED_TRANSPORT,
|
||||
Namespace.JINGLE_ENCRYPTED_TRANSPORT_OMEMO,
|
||||
|
||||
//VoIP
|
||||
Namespace.JINGLE_TRANSPORT_ICE_UDP,
|
||||
Namespace.JINGLE_FEATURE_AUDIO,
|
||||
Namespace.JINGLE_FEATURE_VIDEO,
|
||||
Namespace.JINGLE_APPS_RTP,
|
||||
Namespace.JINGLE_APPS_DTLS,
|
||||
|
||||
"http://jabber.org/protocol/muc",
|
||||
"jabber:x:conference",
|
||||
Namespace.OOB,
|
||||
|
@ -63,6 +55,14 @@ public abstract class AbstractGenerator {
|
|||
private final String[] PRIVACY_SENSITIVE = {
|
||||
"urn:xmpp:time" //XEP-0202: Entity Time leaks time zone
|
||||
};
|
||||
|
||||
private final String[] VOIP_NAMESPACES = {
|
||||
Namespace.JINGLE_TRANSPORT_ICE_UDP,
|
||||
Namespace.JINGLE_FEATURE_AUDIO,
|
||||
Namespace.JINGLE_FEATURE_VIDEO,
|
||||
Namespace.JINGLE_APPS_RTP,
|
||||
Namespace.JINGLE_APPS_DTLS,
|
||||
};
|
||||
private String mVersion = null;
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||
|
@ -132,6 +132,7 @@ public abstract class AbstractGenerator {
|
|||
}
|
||||
if (!mXmppConnectionService.useTorToConnect() && !account.isOnion()) {
|
||||
features.addAll(Arrays.asList(PRIVACY_SENSITIVE));
|
||||
features.addAll(Arrays.asList(VOIP_NAMESPACES));
|
||||
}
|
||||
if (mXmppConnectionService.broadcastLastActivity()) {
|
||||
features.add(Namespace.IDLE);
|
||||
|
|
|
@ -1244,11 +1244,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
|
||||
private void checkPermissionAndTriggerRtpSession() {
|
||||
if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) {
|
||||
Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) {
|
||||
triggerRtpSession();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void triggerRtpSession() {
|
||||
final Contact contact = conversation.getContact();
|
||||
final Intent intent = new Intent(activity, RtpSessionActivity.class);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
|||
final AbstractJingleConnection connection;
|
||||
if (FileTransferDescription.NAMESPACES.contains(descriptionNamespace)) {
|
||||
connection = new JingleFileTransferConnection(this, id, from);
|
||||
} else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace)) { //and not using Tor
|
||||
} else if (Namespace.JINGLE_APPS_RTP.equals(descriptionNamespace) && !usesTor(account)) {
|
||||
if (isBusy()) {
|
||||
mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
|
||||
final JinglePacket sessionTermination = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
|
||||
|
@ -82,6 +82,10 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean usesTor(final Account account) {
|
||||
return account.isOnion() || mXmppConnectionService.useTorToConnect();
|
||||
}
|
||||
|
||||
private boolean isBusy() {
|
||||
for (AbstractJingleConnection connection : this.connections.values()) {
|
||||
if (connection instanceof JingleRtpConnection) {
|
||||
|
@ -147,7 +151,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
|||
if ("propose".equals(message.getName())) {
|
||||
final Element description = message.findChild("description");
|
||||
final String namespace = description == null ? null : description.getNamespace();
|
||||
if (Namespace.JINGLE_APPS_RTP.equals(namespace)) { //and not using Tor
|
||||
if (Namespace.JINGLE_APPS_RTP.equals(namespace) && !usesTor(account)) {
|
||||
if (isBusy()) {
|
||||
final MessagePacket reject = mXmppConnectionService.getMessageGenerator().sessionReject(from, sessionId);
|
||||
mXmppConnectionService.sendMessagePacket(account, reject);
|
||||
|
|
|
@ -902,6 +902,7 @@
|
|||
<string name="rtp_state_application_failure">Application failure</string>
|
||||
<string name="hang_up">Hang up</string>
|
||||
<string name="ongoing_call">Ongoing call</string>
|
||||
<string name="disable_tor_to_make_call">Disable Tor to make calls</string>
|
||||
<plurals name="view_users">
|
||||
<item quantity="one">View %1$d Participant</item>
|
||||
<item quantity="other">View %1$d Participants</item>
|
||||
|
|
Loading…
Reference in a new issue