From 9d4f31580817fbd45e1c778218abffc6d362ab3b Mon Sep 17 00:00:00 2001 From: Marin Date: Tue, 10 Dec 2013 15:45:07 +0200 Subject: [PATCH] Fixes a bug in plugin.otr.ScOtrEngineImpl that caused OTR to misbehave when a protocol provider is unregistered --- .../plugin/otr/ScOtrEngineImpl.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java index b1797fd5a..5e0023477 100644 --- a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java +++ b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java @@ -688,6 +688,33 @@ public void cancel(final Contact contact) task.cancel(); tasks.remove(contact); } + + public void serviceChanged(ServiceEvent ev) + { + Object service + = OtrActivator.bundleContext.getService( + ev.getServiceReference()); + + if (!(service instanceof ProtocolProviderService)) + return; + + if (ev.getType() == ServiceEvent.UNREGISTERING) + { + ProtocolProviderService provider + = (ProtocolProviderService) service; + + Iterator i = tasks.keySet().iterator(); + + while (i.hasNext()) + { + Contact contact = i.next(); + if (provider.equals(contact.getProtocolProvider())) { + cancel(contact); + i.remove(); + } + } + } + } } private void setSessionStatus(Contact contact, ScSessionStatus status) @@ -797,8 +824,12 @@ public void serviceChanged(ServiceEvent ev) while (i.hasNext()) { - if (provider.equals(i.next().getProtocolProvider())) + Contact contact = i.next(); + if (provider.equals(contact.getProtocolProvider())) + { + scSessionStatusMap.remove(getSessionID(contact)); i.remove(); + } } } @@ -809,6 +840,7 @@ public void serviceChanged(ServiceEvent ev) if (provider.equals(i.next().getProtocolProvider())) i.remove(); } + scheduler.serviceChanged(ev); } }