diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java index 4bbb6bc16..220d29fe2 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java @@ -28,6 +28,9 @@ public class CallPeerSipImpl extends AbstractCallPeer implements SessionCreatorCallback { + /** + * Our class logger. + */ private static final Logger logger = Logger.getLogger(CallPeerSipImpl.class); @@ -551,4 +554,6 @@ public void fireCallPeerSoundLevelEvent(int level) listener.peerSoundLevelChanged(event); } } + + } 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 65ae7f5b6..16f10a636 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java @@ -734,7 +734,7 @@ public boolean sayBye(CallPeerSipImpl callPeer) */ try { - return DialogUtils.processByeThenIsDialogAlive(dialog); + return EventPackageUtils.processByeThenIsDialogAlive(dialog); } catch (SipException ex) { @@ -1033,7 +1033,7 @@ public void processReInvite(SipProvider jainSipProvider, callPeer.setFirstTransaction(serverTransaction); - // sdp description may be in acks - bug report Laurent Michel + // SDP description may be in ACKs - bug report Laurent Michel ContentLengthHeader cl = invite.getContentLength(); if (cl != null && cl.getContentLength() > 0) { @@ -1328,8 +1328,7 @@ public void processCancel(ServerTransaction serverTransaction, * Sets the state of the corresponding call peer to DISCONNECTED and * sends an OK response. * - * @param tran the ServerTransaction the the BYE request - * arrived in. + * @param tran the ServerTransaction the the BYE request arrived in. * @param byeRequest the BYE request to process * @param callPeer the peer that sent the BYE request */ @@ -1368,21 +1367,20 @@ public void processBye(ServerTransaction tran, boolean dialogIsAlive; try { - dialogIsAlive = DialogUtils.processByeThenIsDialogAlive(tran.getDialog()); + dialogIsAlive = EventPackageUtils.processByeThenIsDialogAlive( + tran.getDialog()); } catch (SipException ex) { dialogIsAlive = false; - logger - .error( - "Failed to determine whether the dialog should stay alive.", - ex); + logger.error( + "Failed to determine whether the dialog should stay alive.",ex); } + if (dialogIsAlive) { - ((CallSipImpl) callPeer.getCall()).getMediaCallSession() - .stopStreaming(); + callPeer.getCall().getMediaCallSession().stopStreaming(); } else { diff --git a/src/net/java/sip/communicator/impl/protocol/sip/DialogUtils.java b/src/net/java/sip/communicator/impl/protocol/sip/DialogUtils.java deleted file mode 100644 index b67a0b396..000000000 --- a/src/net/java/sip/communicator/impl/protocol/sip/DialogUtils.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.protocol.sip; - -import java.util.*; -import javax.sip.*; - -/** - * Implements utility methods to aid the manipulation of {@link Dialog} - * instances and extend the mentioned type with additional functionality. - * - * @author Lubomir Marinov - */ -public final class DialogUtils -{ - - /** - * Associates a specific subscription with the a given Dialog - * in order to allow it to keep the dialog in question alive even after a - * BYE request. - * - * @param dialog the Dialog to associate the subscription with - * and to be kept alive after a BYE request because of the subscription - * @param subscription the subscription to be associated with - * dialog and keep it alive after a BYE request - * - * @return true if the specified subscription was associated with - * the given dialog; false if no changes were applied - * - * @throws SipException if the dialog is already terminated. - */ - public static boolean addSubscription(Dialog dialog, Object subscription) - throws SipException - { - synchronized (dialog) - { - DialogApplicationData appData = - (DialogApplicationData) SipApplicationData.getApplicationData( - dialog, SipApplicationData.KEY_SUBSCRIPTIONS); - if (appData == null) - { - appData = new DialogApplicationData(); - SipApplicationData.setApplicationData( - dialog, SipApplicationData.KEY_SUBSCRIPTIONS, appData); - } - - if (appData.addSubscription(subscription)) - { - try - { - dialog.terminateOnBye(false); - return true; - } - catch (SipException ex) - { - /* - * Since the subscription didn't quite register, undo the - * part of the registration which did succeed. - */ - appData.removeSubscription(subscription); - throw ex; - } - } - return false; - } - } - - /** - * Determines whether a BYE request has already been processed in a specific - * Dialog and thus allows determining whether the dialog in - * question should be terminated when the last associated subscription is - * terminated. - * - * @param dialog the Dialog to be examined - * - * @return true if a BYE request has already been processed in the - * specified dialog; false, otherwise - */ - public static boolean isByeProcessed(Dialog dialog) - { - synchronized (dialog) - { - DialogApplicationData applicationData = - (DialogApplicationData) SipApplicationData.getApplicationData( - dialog, SipApplicationData.KEY_SUBSCRIPTIONS); - return (applicationData == null) ? false : applicationData - .isByeProcessed(); - } - } - - /** - * Processes a BYE request in a specific Dialog for the - * purposes of subscription associations and returns an indicator which - * determines whether the specified dialog should still be considered alive - * after the processing of the BYE request. - * - * @param dialog the Dialog in which a BYE request has arrived - * - * @return true if dialog should still be considered - * alive after processing the mentioned BYE request; false if - * dialog is to be expected to die after processing the request in - * question - * - * @throws SipException if the dialog is already terminated. - */ - public static boolean processByeThenIsDialogAlive(Dialog dialog) - throws SipException - { - synchronized (dialog) - { - DialogApplicationData applicationData = - (DialogApplicationData) SipApplicationData.getApplicationData( - dialog, SipApplicationData.KEY_SUBSCRIPTIONS); - if (applicationData != null) - { - applicationData.setByeProcessed(true); - - if (applicationData.getSubscriptionCount() > 0) - { - dialog.terminateOnBye(false); - return true; - } - } - return false; - } - } - - /** - * Dissociates a specific subscription with a given Dialog in - * order to no longer allow it to keep the dialog in question alive even - * after a BYE request, deletes the dialog if there are no other - * subscriptions associated with it and a BYE request has already been - * received and returns an indicator which determines whether the specified - * dialog is still alive after the dissociation of the given subscription. - * - * @param dialog the Dialog to dissociate the subscription with - * and to no longer be kept alive after a BYE request because of the - * subscription - * @param subscription the subscription to be dissociated with - * dialog and to no longer be kept alive after a BYE request - * because of the subscription - * @return true if the dialog is still alive after the - * dissociation; false if the dialog was terminated because of the - * dissociation - */ - public static boolean removeSubscriptionThenIsDialogAlive(Dialog dialog, - Object subscription) - { - synchronized (dialog) - { - DialogApplicationData applicationData = - (DialogApplicationData) SipApplicationData.getApplicationData( - dialog, SipApplicationData.KEY_SUBSCRIPTIONS); - if ((applicationData != null) - && applicationData.removeSubscription(subscription) - && (applicationData.getSubscriptionCount() <= 0) - && applicationData.isByeProcessed()) - { - dialog.delete(); - return false; - } - return true; - } - } - - /** - * Prevents the creation of DialogUtils instances. - */ - private DialogUtils() - { - } - - /** - * Represents the application-specific data which the SIP protocol provider - * associates with {@link #Dialog} instances. - *

- * The implementation at the time of this writing allows tracking - * subscriptions in a specific Dialog in order to make it - * possible to determine whether a BYE request should terminate the - * respective dialog. - *

- */ - private static class DialogApplicationData - { - - /** - * The indicator which determines whether a BYE request has already been - * processed in the owning Dialog and thus allows - * determining whether the dialog in question should be terminated when - * the last associated subscription is terminated. - */ - private boolean byeIsProcessed; - - /** - * The set of subscriptions not yet terminated in the owning - * Dialog i.e. keeping it alive even after a BYE request. - */ - private final List subscriptions = new ArrayList(); - - /** - * Associates a specific subscription with the owning - * Dialog in order to allow it to keep the dialog in - * question alive even after a BYE request. - * - * @param subscription the subscription with no specific type of - * interest to this implementation to be associated with the - * owning Dialog - * @return true if the specified subscription caused a - * modification of the list of associated subscriptions; false - * if no change to the mentioned list was applied - */ - public boolean addSubscription(Object subscription) - { - if (!subscriptions.contains(subscription)) - { - return subscriptions.add(subscription); - } - return false; - } - - /** - * Determines whether a BYE request has already been processed in the - * owning Dialog and thus allows determining whether the - * dialog in question should be terminated when the last associated - * subscription is terminated. - * - * @return true if a BYE request has already been processed in - * the owning Dialog; false, otherwise - */ - public boolean isByeProcessed() - { - return byeIsProcessed; - } - - /** - * Determines the number of subscriptions associated with the owning - * Dialog i.e. keeping it alive even after a BYE request. - * - * @return the number of subscriptions associated with the owning - * Dialog i.e. keeping it alive even after a BYE request - */ - public int getSubscriptionCount() - { - return subscriptions.size(); - } - - /** - * Dissociates a specific subscription with the owning - * Dialog in order to no longer allow it to keep the dialog - * in question alive even after a BYE request. - * - * @param subscription the subscription with no specific type of - * interest to this implementation to be dissociated with the owning - * Dialog - * @return true if the specified subscription caused a - * modification of the list of associated subscriptions; false - * if no change to the mentioned list was applied - */ - public boolean removeSubscription(Object subscription) - { - return subscriptions.remove(subscription); - } - - /** - * Sets the indicator which determines whether a BYE request has already - * been processed in the owning Dialog and thus allows - * determining whether the dialog in question should be terminated when - * the last associated subscription is terminated. - * - * @param byeIsProcessed true if a BYE request has already been - * processed in the owning Dialog; false, otherwise - */ - public void setByeProcessed(boolean byeIsProcessed) - { - this.byeIsProcessed = byeIsProcessed; - } - } -} 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 ceca5bc5b..54b7f0532 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java @@ -9,7 +9,6 @@ import gov.nist.javax.sip.header.HeaderFactoryImpl; // disambiguates Contact import gov.nist.javax.sip.header.extensions.*; -import java.net.*; import java.text.*; import java.util.*; @@ -38,6 +37,9 @@ public class OperationSetBasicTelephonySipImpl OperationSetAdvancedTelephony, OperationSetSecureTelephony { + /** + * Our class logger. + */ private static final Logger logger = Logger.getLogger(OperationSetBasicTelephonySipImpl.class); @@ -557,7 +559,7 @@ private void processReferAccepted(ClientTransaction clientTransaction, { try { - DialogUtils.addSubscription(clientTransaction.getDialog(), "refer"); + EventPackageUtils.addSubscription(clientTransaction.getDialog(), "refer"); } catch (SipException ex) { @@ -941,7 +943,7 @@ private void processInvite(SipProvider sourceProvider, } else { - //this is a reINVITE. + //this is a reINVITE concerning a particular peer. callSipImpl.processReInvite(sourceProvider, serverTransaction); } } @@ -1132,7 +1134,7 @@ private void processRefer(ServerTransaction serverTransaction, try { removeSubscription = - DialogUtils.addSubscription(dialog, referRequest); + EventPackageUtils.addSubscription(dialog, referRequest); } catch (SipException ex) { @@ -1292,14 +1294,14 @@ private boolean processNotify(ServerTransaction serverTransaction, } if (SubscriptionStateHeader.TERMINATED.equals(ssHeader.getState()) - && !DialogUtils + && !EventPackageUtils .removeSubscriptionThenIsDialogAlive(dialog, "refer")) { peer.setState(CallPeerState.DISCONNECTED); } if (!CallPeerState.DISCONNECTED.equals(peer.getState()) - && !DialogUtils.isByeProcessed(dialog)) + && !EventPackageUtils.isByeProcessed(dialog)) { boolean dialogIsAlive; try @@ -1387,7 +1389,7 @@ private boolean referToCallStateChanged(Call referToCall, * Whatever the status of the REFER is, the subscription created by it * is terminated with the final NOTIFY. */ - if (!DialogUtils.removeSubscriptionThenIsDialogAlive(dialog, + if (!EventPackageUtils.removeSubscriptionThenIsDialogAlive(dialog, subscription)) { CallPeerSipImpl callPeer = diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipStackSharing.java b/src/net/java/sip/communicator/impl/protocol/sip/SipStackSharing.java index ac4dd9dd1..d681046d6 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipStackSharing.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipStackSharing.java @@ -91,6 +91,8 @@ public class SipStackSharing /** * Constructor for this class. Creates the JAIN-SIP stack. + * + * @throws OperationFailedException if creating the stack fails. */ SipStackSharing() throws OperationFailedException @@ -127,6 +129,9 @@ public class SipStackSharing * of new messages received from the JAIN-SIP SipProviders. * * @param listener a new possible target for the dispatching process. + * + * @throws OperationFailedException if creating one of the underlying + * SipProviders fails for whatever reason. */ public void addSipListener(ProtocolProviderServiceSipImpl listener) throws OperationFailedException @@ -202,6 +207,9 @@ public ListeningPoint getLP(String transport) * Put the stack in a state where it can receive data on three UDP/TCP ports * (2 for clear communication, 1 for TLS). That is to say create the related * JAIN-SIP ListeningPoints and SipProviders. + * + * @throws OperationFailedException if creating one of the underlying + * SipProviders fails for whatever reason. */ private void startListening() throws OperationFailedException @@ -210,10 +218,10 @@ private void startListening() { int bindRetriesValue = getBindRetriesValue(); - this.createProvider(this.getPreferredClearPort() - , bindRetriesValue, false); - this.createProvider(this.getPreferredSecurePort() - , bindRetriesValue, true); + this.createProvider(this.getPreferredClearPort(), + bindRetriesValue, false); + this.createProvider(this.getPreferredSecurePort(), + bindRetriesValue, true); this.stack.start(); logger.trace("started listening"); } @@ -241,13 +249,27 @@ private void startListening() * @param retries how many times should we try to find a free port to bind * @param secure whether to create the TLS SipProvider. * or the clear UDP/TCP one. + * + * @throws TransportNotSupportedException in case we try to create a + * provider for a transport not currently supported by jain-sip + * @throws InvalidArgumentException if we try binding to an illegal port + * (which we won't) + * @throws ObjectInUseException if another SipProvider is already + * associated with this ListeningPoint. + * @throws TransportAlreadySupportedException if there is already a + * ListeningPoint associated to this SipProvider with the same + * transport of the ListeningPoint. + * @throws TooManyListenersException if we try to add a new + * SipListener with a SipProvider when one was already + * registered. + * */ private void createProvider(int preferredPort, int retries, boolean secure) - throws TransportNotSupportedException - , InvalidArgumentException - , ObjectInUseException - , TransportAlreadySupportedException - , TooManyListenersException + throws TransportNotSupportedException, + InvalidArgumentException, + ObjectInUseException, + TransportAlreadySupportedException, + TooManyListenersException { String context = (secure ? "TLS: " : "clear UDP/TCP: ");