From 70fd2c5e12fe865b652683b7850349a2c07651a0 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Tue, 22 Dec 2009 11:57:33 +0000 Subject: [PATCH] Attempts to fix an incorrect removal of the presence SUBSCRIBE and NOTIFY handler upon adding such a conference handler. Reported by Damian Minkov. --- .../protocol/sip/EventPackageSupport.java | 14 ++++++- .../sip/ProtocolProviderServiceSipImpl.java | 42 +++++++++++++++---- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java b/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java index 74b06f6ca..1e7dcdf0a 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/EventPackageSupport.java @@ -104,7 +104,7 @@ public class EventPackageSupport * the Timer support which is to execute the * time-based tasks of the new instance */ - public EventPackageSupport( + protected EventPackageSupport( ProtocolProviderServiceSipImpl protocolProvider, String eventPackage, int subscriptionDuration, @@ -153,6 +153,18 @@ protected void addSubscription(String callId, Subscription subscription) } } + /** + * Gets the name of the event package this instance implements and carried + * in the Event and Allow-Events headers. + * + * @return the name of the event package this instance implements and + * carried in the Event and Allow-Events headers + */ + public final String getEventPackage() + { + return eventPackage; + } + /** * Safely returns the ServerTransaction associated with a * specific RequestEvent or creates a new one if the specified diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index 7cd0cfc5e..dcf45e1c3 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -1790,16 +1790,40 @@ public void registerMethodProcessor(String method, } else { - Class methodProcessorClass = - methodProcessor.getClass(); - for (Iterator processorIter = - processors.iterator(); processorIter.hasNext();) + /* + * Prevent the registering of multiple instances of one and the same + * OperationSet class and take only the latest registration into + * account. + */ + Iterator processorIter = processors.iterator(); + Class methodProcessorClass + = methodProcessor.getClass(); + /* + * EventPackageSupport and its extenders provide a generic mechanizm + * for building support for a specific event package so allow them + * to register multiple instances of one and the same class as long + * as they are handling different event packages. + */ + String eventPackage + = (methodProcessor instanceof EventPackageSupport) + ? ((EventPackageSupport) methodProcessor).getEventPackage() + : null; + + while (processorIter.hasNext()) { - if (processorIter.next().getClass() - .equals(methodProcessorClass)) - { - processorIter.remove(); - } + MethodProcessor processor = processorIter.next(); + + if (!processor.getClass().equals(methodProcessorClass)) + continue; + if ((eventPackage != null) + && (processor instanceof EventPackageSupport) + && !eventPackage + .equals( + ((EventPackageSupport) processor) + .getEventPackage())) + continue; + + processorIter.remove(); } } processors.add(methodProcessor);