support reject

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java               | 18 
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java | 18 
src/main/res/drawable-hdpi/ic_clear_white_48dp.png                            |  0 
src/main/res/drawable-mdpi/ic_clear_white_48dp.png                            |  0 
src/main/res/drawable-xhdpi/ic_clear_white_48dp.png                           |  0 
src/main/res/drawable-xxhdpi/ic_clear_white_48dp.png                          |  0 
src/main/res/drawable-xxxhdpi/ic_clear_white_48dp.png                         |  0 
src/main/res/values/strings.xml                                               |  1 
8 files changed, 34 insertions(+), 3 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java 🔗

@@ -162,6 +162,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
                 break;
             case RINGING:
                 binding.status.setText(R.string.rtp_state_ringing);
+                break;
+            case DECLINED_OR_BUSY:
+                binding.status.setText(R.string.rtp_state_declined_or_busy);
+                break;
         }
     }
 
@@ -174,13 +178,25 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
             this.binding.rejectCall.hide();
             this.binding.endCall.hide();
             this.binding.acceptCall.hide();
+        } else if (state == RtpEndUserState.DECLINED_OR_BUSY) {
+            this.binding.rejectCall.hide();
+            this.binding.endCall.setImageResource(R.drawable.ic_clear_white_48dp);
+            this.binding.endCall.show();
+            this.binding.endCall.setOnClickListener(this::exit);
+            this.binding.acceptCall.hide();
         } else {
             this.binding.rejectCall.hide();
+            this.binding.endCall.setImageResource(R.drawable.ic_call_end_white_48dp);
             this.binding.endCall.show();
+            this.binding.endCall.setOnClickListener(this::endCall);
             this.binding.acceptCall.hide();
         }
     }
 
+    private void exit(View view) {
+        finish();
+    }
+
     private Contact getWith() {
         final AbstractJingleConnection.Id id = requireRtpConnection().getId();
         final Account account = id.account;
@@ -197,7 +213,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
 
     @Override
     public void onJingleRtpConnectionUpdate(Account account, Jid with, final String sessionId, RtpEndUserState state) {
-        Log.d(Config.LOGTAG,"onJingleRtpConnectionUpdate("+state+")");
+        Log.d(Config.LOGTAG, "onJingleRtpConnectionUpdate(" + state + ")");
         if (with.isBareJid()) {
             updateRtpSessionProposalState(with, state);
             return;

src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java 🔗

@@ -77,6 +77,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
         if (sessionId == null) {
             return;
         }
+        final boolean carbonCopy = from.asBareJid().equals(account.getJid().asBareJid());
         final Jid with;
         if (account.getJid().asBareJid().equals(from.asBareJid())) {
             with = to;
@@ -103,7 +104,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
                 Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to react to proposed " + namespace + " session");
             }
         } else if ("proceed".equals(message.getName())) {
-            if (!with.equals(from)) {
+            if (carbonCopy) {
                 Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignore carbon copied proceed");
                 return;
             }
@@ -115,7 +116,20 @@ public class JingleConnectionManager extends AbstractConnectionManager {
                     rtpConnection.transitionOrThrow(AbstractJingleConnection.State.PROPOSED);
                     rtpConnection.deliveryMessage(from, message);
                 } else {
-                    Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + with);
+                    Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + with + " to deliver proceed");
+                }
+            }
+        } else if ("reject".equals(message.getName())) {
+            if (carbonCopy) {
+                Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignore carbon copied reject");
+                return;
+            }
+            final RtpSessionProposal proposal = new RtpSessionProposal(account, with.asBareJid(), sessionId);
+            synchronized (rtpSessionProposals) {
+                if (rtpSessionProposals.remove(proposal) != null) {
+                    mXmppConnectionService.notifyJingleRtpConnectionUpdate(account, proposal.with, proposal.sessionId, RtpEndUserState.DECLINED_OR_BUSY);
+                } else {
+                    Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": no rtp session proposal found for " + with + " to deliver reject");
                 }
             }
         } else {

src/main/res/values/strings.xml 🔗

@@ -896,6 +896,7 @@
     <string name="dismiss_call">Dismiss</string>
     <string name="rtp_state_finding_device">Locating devices</string>
     <string name="rtp_state_ringing">Ringing</string>
+    <string name="rtp_state_declined_or_busy">Busy</string>
     <plurals name="view_users">
         <item quantity="one">View %1$d Participant</item>
         <item quantity="other">View %1$d Participants</item>