From 5537af0508808e86bb28fbb13826a52bda8b5d9b Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Tue, 17 Feb 2009 21:39:38 +0000 Subject: [PATCH] Adds final, fixes warnings. --- .../OperationSetBasicTelephonySipImpl.java | 21 ++++------- .../communicator/service/protocol/Call.java | 35 ++++++++----------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java index cf387d5e0..c6368cad0 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java @@ -127,7 +127,7 @@ public Call createCall(String callee) */ public Call createCall(Contact callee) throws OperationFailedException { - Address toAddress = null; + Address toAddress; try { @@ -263,13 +263,12 @@ private synchronized CallSipImpl createOutgoingCall(Address calleeAddress, // that the media service can choose the most proper local // address to advertise. javax.sip.address.URI calleeURI = calleeAddress.getURI(); - InetAddress intendedDestination = null; if (calleeURI.isSipURI()) { String host = ((SipURI) calleeURI).getHost(); - - intendedDestination = protocolProvider + InetAddress intendedDestination = protocolProvider .resolveSipAddress(host).getAddress(); + invite.setContent(callSession .createSdpOffer(intendedDestination), contentTypeHeader); @@ -2715,7 +2714,7 @@ private boolean sayBye(CallParticipantSipImpl callParticipant) ArrayList viaHeaders = protocolProvider.getLocalViaHeaders(destination); - bye.setHeader((ViaHeader) viaHeaders.get(0)); + bye.setHeader(viaHeaders.get(0)); bye.addHeader(protocolProvider.getSipCommUserAgentHeader()); } catch (SipException ex) @@ -2914,7 +2913,7 @@ public synchronized void answerCallParticipant(CallParticipant participant) .setMediaCallSession(callSession); String sdpOffer = callParticipant.getSdpDescription(); - String sdp = null; + String sdp; // if the offer was in the invite create an sdp answer if ((sdpOffer != null) && (sdpOffer.length() > 0)) { @@ -3147,10 +3146,7 @@ public boolean isSecure(CallParticipant participant) CallSession cs = ((CallSipImpl) participant.getCall()).getMediaCallSession(); - if (cs != null) - return cs.getSecureCommunicationStatus(); - else - return false; + return (cs != null) && cs.getSecureCommunicationStatus(); } /** @@ -3166,10 +3162,7 @@ public boolean setSasVerified( CallParticipant participant, CallSession cs = ((CallSipImpl) participant.getCall()).getMediaCallSession(); - if (cs != null) - return cs.setZrtpSASVerification(isVerified); - else - return false; + return (cs != null) && cs.setZrtpSASVerification(isVerified); } diff --git a/src/net/java/sip/communicator/service/protocol/Call.java b/src/net/java/sip/communicator/service/protocol/Call.java index 7b76d9f22..9675014ee 100644 --- a/src/net/java/sip/communicator/service/protocol/Call.java +++ b/src/net/java/sip/communicator/service/protocol/Call.java @@ -11,7 +11,6 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; - /** * A representation of a Call. The Call class must only be created by users (i.e. * telephony protocols) of the PhoneUIService such as a SIP protocol @@ -23,24 +22,24 @@ */ public abstract class Call { - private static final Logger logger - = Logger.getLogger(Call.class); + private static final Logger logger = Logger.getLogger(Call.class); + /** * An identifier uniquely representing the call. */ - private String callID = null; + private final String callID; /** * A list of all listeners currently registered for * CallChangeEvents */ - private Vector callListeners + private final List callListeners = new Vector(); /** * A reference to the ProtocolProviderService instance that created us. */ - private ProtocolProviderService protocolProvider = null; + private final ProtocolProviderService protocolProvider; /** * If this flag is set to true according to the account properties @@ -57,14 +56,13 @@ public abstract class Call protected Call(ProtocolProviderService sourceProvider) { //create the uid - this.callID = String.valueOf( System.currentTimeMillis()) + this.callID = String.valueOf(System.currentTimeMillis()) + String.valueOf(super.hashCode()); this.protocolProvider = sourceProvider; - AccountID accountID = sourceProvider.getAccountID(); defaultEncryption = - accountID.getAccountPropertyBoolean( + protocolProvider.getAccountID().getAccountPropertyBoolean( ProtocolProviderFactory.DEFAULT_ENCRYPTION, true); } @@ -92,11 +90,8 @@ public boolean equals(Object obj) if(obj == null || !(obj instanceof Call)) return false; - if (obj == this - || ((Call)obj).getCallID().equals( getCallID() )) - return true; - - return false; + return (obj == this) + || ((Call)obj).getCallID().equals(getCallID()); } /** @@ -180,15 +175,15 @@ protected void fireCallParticipantEvent(CallParticipant sourceCallParticipant, + callListeners.size() +" listeners. event is: " + cpEvent.toString()); - Iterator listeners = null; + Iterator listeners; synchronized(callListeners) { - listeners = new ArrayList(callListeners).iterator(); + listeners = new ArrayList(callListeners).iterator(); } while(listeners.hasNext()) { - CallChangeListener listener = (CallChangeListener)listeners.next(); + CallChangeListener listener = listeners.next(); if(eventID == CallParticipantEvent.CALL_PARTICIPANT_ADDED) listener.callParticipantAdded(cpEvent); @@ -232,15 +227,15 @@ protected void fireCallChangeEvent( String type, + callListeners.size() +" listeners. event is: " + ccEvent.toString()); - Iterator listeners = null; + Iterator listeners; synchronized(callListeners) { - listeners = new ArrayList(callListeners).iterator(); + listeners = new ArrayList(callListeners).iterator(); } while(listeners.hasNext()) { - CallChangeListener listener = (CallChangeListener)listeners.next(); + CallChangeListener listener = listeners.next(); if(type.equals(CallChangeEvent.CALL_STATE_CHANGE)) listener.callStateChanged(ccEvent);