From e9ee16a7ba9255fc719eea7e02558fb4dfc2156e Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 5 Nov 2015 11:55:12 -0600 Subject: Adds option to set custom headers to the sip call. --- .../impl/protocol/sip/CallSipImpl.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java') diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java index fa0e08e..0471d1a 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java @@ -78,6 +78,24 @@ public class CallSipImpl public static final String DS_SHARING_HEADER = "X-Desktop-Share"; /** + * Custom header name prefix that can be added to the call instance. + * Several headers can be specified in the form of: + * EXTRA_HEADER_NAME.1=... + * EXTRA_HEADER_NAME.2=... + * Index starting from 1. + */ + public static final String EXTRA_HEADER_NAME = "EXTRA_HEADER_NAME"; + + /** + * Custom header value prefix that can be added to the call instance. + * Several headers can be specified in the form of: + * EXTRA_HEADER_VALUE.1=... + * EXTRA_HEADER_VALUE.2=... + * Index starting from 1. + */ + public static final String EXTRA_HEADER_VALUE = "EXTRA_HEADER_VALUE"; + + /** * When starting call we may have quality preferences we must use * for the call. */ @@ -706,6 +724,22 @@ public class CallSipImpl protected void processExtraHeaders(javax.sip.message.Message message) throws ParseException { + // If there are custom headers added to the call instance, add those + // headers + int extraHeaderIx = 1; + + Object name = getData(EXTRA_HEADER_NAME + "." + extraHeaderIx); + while(name != null) + { + Object value = getData(EXTRA_HEADER_VALUE + "." + extraHeaderIx); + + Header header = getProtocolProvider().getHeaderFactory() + .createHeader((String) name, (String) value); + message.setHeader(header); + + extraHeaderIx++; + name = getData(EXTRA_HEADER_NAME + "." + extraHeaderIx); + } } /** -- cgit v1.1 From 3961c5df59d60e0edc0f9ab02fb07b24d122cff6 Mon Sep 17 00:00:00 2001 From: Nik Date: Tue, 5 Jul 2016 23:48:14 +0200 Subject: code clean up (#277) * code cleanup * code cleanup * code cleanup * code cleanup --- .../impl/protocol/sip/CallSipImpl.java | 66 +++++++++++----------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java') diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java index 0471d1a..bae70a2 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java @@ -96,16 +96,9 @@ public class CallSipImpl public static final String EXTRA_HEADER_VALUE = "EXTRA_HEADER_VALUE"; /** - * When starting call we may have quality preferences we must use - * for the call. - */ - private QualityPreset initialQualityPreferences; - - /** - * A reference to the SipMessageFactory instance that we should - * use when creating requests. + * Maximum number of retransmissions that will be sent. */ - private final SipMessageFactory messageFactory; + private static final int MAX_RETRANSMISSIONS = 3; /** * The name of the property under which the user may specify the number of @@ -113,19 +106,27 @@ public class CallSipImpl * 180. */ private static final String RETRANSMITS_RINGING_INTERVAL - = "net.java.sip.communicator.impl.protocol.sip" - + ".RETRANSMITS_RINGING_INTERVAL"; + = "net.java.sip.communicator.impl.protocol.sip" + + ".RETRANSMITS_RINGING_INTERVAL"; /** - * The default amount of time (in milliseconds) for the initial interval for - * retransmissions of response 180. - */ + * The default amount of time (in milliseconds) for the initial interval for + * retransmissions of response 180. + */ private static final int DEFAULT_RETRANSMITS_RINGING_INTERVAL = 500; /** - * Maximum number of retransmissions that will be sent. + * When starting call we may have quality preferences we must use + * for the call. */ - private static final int MAX_RETRANSMISSIONS = 3; + private QualityPreset initialQualityPreferences; + + /** + * A reference to the SipMessageFactory instance that we should + * use when creating requests. + */ + private final SipMessageFactory messageFactory; + /** * The amount of time (in milliseconds) for the initial interval for @@ -405,24 +406,21 @@ public class CallSipImpl logger.trace("Looking for peer with dialog: " + dialog + "among " + getCallPeerCount() + " calls"); } - while (callPeers.hasNext()) + for (CallPeerSipImpl callPeer : getCallPeerList()) { - CallPeerSipImpl cp = callPeers.next(); - - if (cp.getDialog() == dialog) + if (callPeer.getDialog() == dialog) { if (logger.isTraceEnabled()) - logger.trace("Returning cp=" + cp); - return cp; + logger.trace("Returning cp=" + callPeer); + return callPeer; } else { if (logger.isTraceEnabled()) - logger.trace("Ignoring cp=" + cp + " because cp.dialog=" - + cp.getDialog() + " while dialog=" + dialog); + logger.trace("Ignoring cp=" + callPeer + " because cp.dialog=" + + callPeer.getDialog() + " while dialog=" + dialog); } } - return null; } @@ -467,7 +465,7 @@ public class CallSipImpl // Transport preference String forceTransport = null; javax.sip.address.URI calleeURI = calleeAddress.getURI(); - if(calleeURI.getScheme().toLowerCase().equals("sips")) + if("sips".equals(calleeURI.getScheme().toLowerCase())) { // MUST use TLS forceTransport = "TLS"; @@ -571,7 +569,7 @@ public class CallSipImpl String alternativeIMPPAddress = null; if (infoHeader != null && infoHeader.getParameter("purpose") != null - && infoHeader.getParameter("purpose").equals("impp")) + && "impp".equals(infoHeader.getParameter("purpose"))) { alternativeIMPPAddress = infoHeader.getInfo().toString(); } @@ -603,7 +601,7 @@ public class CallSipImpl { if (logger.isTraceEnabled()) logger.trace("will send ringing response: "); - if(peer.getState().equals(CallPeerState.INCOMING_CALL)) + if( CallPeerState.INCOMING_CALL.equals(peer.getState()) ) { response = messageFactory.createResponse(Response.RINGING, invite); @@ -698,10 +696,10 @@ public class CallSipImpl */ public void reInvite() throws OperationFailedException { - Iterator peers = getCallPeers(); - - while (peers.hasNext()) - peers.next().sendReInvite(); + for(CallPeerSipImpl peer : getCallPeerList()) + { + peer.sendReInvite(); + } } /** @@ -792,8 +790,8 @@ public class CallSipImpl { try { - if(!peer.getState().equals( - CallPeerState.INCOMING_CALL)) + if( !CallPeerState.INCOMING_CALL.equals( + peer.getState()) ) { timer.cancel(); } -- cgit v1.1 From 402ad5c9e7fa9af06fbb9152ec8d693f62228b38 Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 8 Dec 2016 18:04:59 -0600 Subject: Adds an option to specify custom header names for meet room name. --- .../impl/protocol/sip/CallSipImpl.java | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java') diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java index bae70a2..62711c7 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java @@ -61,15 +61,27 @@ public class CallSipImpl * Name of extra INVITE header which specifies name of MUC room that is * hosting the Jitsi Meet conference. */ - public static final String JITSI_MEET_ROOM_HEADER - = "Jitsi-Conference-Room"; + public String JITSI_MEET_ROOM_HEADER = "Jitsi-Conference-Room"; + + /** + * Property name of extra INVITE header which specifies name of MUC room + * that is hosting the Jitsi Meet conference. + */ + private static final String JITSI_MEET_ROOM_HEADER_PROPERTY + = "JITSI_MEET_ROOM_HEADER_NAME"; + + /** + * Property name of extra INVITE header which specifies password required + * to enter MUC room that is hosting the Jitsi Meet conference. + */ + public String JITSI_MEET_ROOM_PASS_HEADER = "Jitsi-Conference-Room-Pass"; /** * Name of extra INVITE header which specifies password required to enter * MUC room that is hosting the Jitsi Meet conference. */ - public static final String JITSI_MEET_ROOM_PASS_HEADER - = "Jitsi-Conference-Room-Pass"; + private static final String JITSI_MEET_ROOM_PASS_HEADER_PROPERTY + = "JITSI_MEET_ROOM_PASS_HEADER_NAME"; /** * Custom header included in initial desktop sharing call creation. @@ -159,6 +171,13 @@ public class CallSipImpl } this.retransmitsRingingInterval = retransmitsRingingInterval; + AccountID account = parentOpSet.getProtocolProvider().getAccountID(); + // Specify custom header names + JITSI_MEET_ROOM_HEADER = account.getAccountPropertyString( + JITSI_MEET_ROOM_HEADER_PROPERTY, JITSI_MEET_ROOM_HEADER); + JITSI_MEET_ROOM_PASS_HEADER = account.getAccountPropertyString( + JITSI_MEET_ROOM_PASS_HEADER_PROPERTY, JITSI_MEET_ROOM_PASS_HEADER); + //let's add ourselves to the calls repo. we are doing it ourselves just //to make sure that no one ever forgets. parentOpSet.getActiveCallsRepository().addCall(this); -- cgit v1.1