aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java
diff options
context:
space:
mode:
authorpaweldomas <pawel.domas@jitsi.org>2014-11-20 15:48:12 +0100
committerpaweldomas <pawel.domas@jitsi.org>2014-11-20 15:52:23 +0100
commit6cb3c0e2dea8015e31a281d21f47861e31105ab4 (patch)
treea8669230b37491fbce9d381c2515dd9f7bcef8b1 /src/net/java
parentdbee8d4db7a66ebc85d8d0e2570706477f0238e6 (diff)
downloadjitsi-6cb3c0e2dea8015e31a281d21f47861e31105ab4.zip
jitsi-6cb3c0e2dea8015e31a281d21f47861e31105ab4.tar.gz
jitsi-6cb3c0e2dea8015e31a281d21f47861e31105ab4.tar.bz2
Removes dependency on running ProtocolProviderServiceJabberImpl from ScServiceDiscoveryManager.
Diffstat (limited to 'src/net/java')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java3
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java1
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java11
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java46
4 files changed, 52 insertions, 9 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java b/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java
index c4491ce..6e2d574 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/JabberActivator.java
@@ -8,6 +8,7 @@ package net.java.sip.communicator.impl.protocol.jabber;
import java.util.*;
+import net.java.sip.communicator.impl.protocol.jabber.extensions.caps.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.globaldisplaydetails.*;
import net.java.sip.communicator.service.googlecontacts.*;
@@ -138,6 +139,7 @@ public class JabberActivator
public void start(BundleContext context) throws Exception
{
JabberActivator.bundleContext = context;
+ EntityCapsManager.setBundleContext(context);
Hashtable<String, String> hashtable = new Hashtable<String, String>();
hashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.JABBER);
@@ -247,6 +249,7 @@ public class JabberActivator
mediaService = null;
networkAddressManagerService = null;
credentialsService = null;
+ EntityCapsManager.setBundleContext(null);
}
/**
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
index 62b2370..6230118 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
@@ -1406,6 +1406,7 @@ public class ProtocolProviderServiceJabberImpl
discoveryManager
= new ScServiceDiscoveryManager(
this,
+ connection,
new String[] { "http://jabber.org/protocol/commands"},
// Add features Jitsi supports in addition to smack.
supportedFeatures.toArray(
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java
index 7a1c21c..d9761c6 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java
@@ -65,7 +65,7 @@ public class ScServiceDiscoveryManager
/**
* The parent provider
*/
- private final ProtocolProviderServiceJabberImpl parentProvider;
+ private final ProtocolProviderService parentProvider;
/**
* The {@link XMPPConnection} that this manager is responsible for.
@@ -104,6 +104,8 @@ public class ScServiceDiscoveryManager
* discovery manager of the specified <tt>connection</tt>.
*
* @param parentProvider the parent provider that creates discovery manager.
+ * @param connection Smack connection object that will be used by this
+ * instance to handle XMPP connection.
* @param featuresToRemove an array of <tt>String</tt>s representing the
* features to be removed from the <tt>ServiceDiscoveryManager</tt> of the
* specified <tt>connection</tt> which is to be wrapped by the new instance
@@ -113,12 +115,13 @@ public class ScServiceDiscoveryManager
* which is to be wrapped by the new instance
*/
public ScServiceDiscoveryManager(
- ProtocolProviderServiceJabberImpl parentProvider,
+ ProtocolProviderService parentProvider,
+ XMPPConnection connection,
String[] featuresToRemove,
String[] featuresToAdd)
{
this.parentProvider = parentProvider;
- this.connection = parentProvider.getConnection();
+ this.connection = connection;
this.discoveryManager
= ServiceDiscoveryManager.getInstanceFor(connection);
@@ -560,7 +563,7 @@ public class ScServiceDiscoveryManager
*
* @throws XMPPException if the operation failed for some reason.
*/
- private DiscoverInfo discoverInfo(String entityID, String node)
+ public DiscoverInfo discoverInfo(String entityID, String node)
throws XMPPException
{
return discoveryManager.discoverInfo(entityID, node);
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java
index d070d71..658a071 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java
@@ -12,7 +12,6 @@ import java.security.*;
import java.util.*;
import java.util.concurrent.*;
-import net.java.sip.communicator.impl.protocol.jabber.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@@ -26,6 +25,7 @@ import org.jivesoftware.smack.util.Base64;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.*;
import org.jivesoftware.smackx.packet.*;
+import org.osgi.framework.*;
import org.xmlpull.mxp1.*;
import org.xmlpull.v1.*;
@@ -47,6 +47,16 @@ public class EntityCapsManager
= Logger.getLogger(EntityCapsManager.class);
/**
+ * Static OSGi bundle context used by this class.
+ */
+ private static BundleContext bundleContext;
+
+ /**
+ * Configuration service instance used by this class.
+ */
+ private static ConfigurationService configService;
+
+ /**
* The prefix of the <tt>ConfigurationService</tt> properties which persist
* {@link #caps2discoverInfo}.
*/
@@ -152,9 +162,8 @@ public class EntityCapsManager
if ((xml != null) && (xml.length() != 0))
{
- JabberActivator
- .getConfigurationService()
- .setProperty(getCapsPropertyName(caps), xml);
+ getConfigService()
+ .setProperty(getCapsPropertyName(caps), xml);
}
}
}
@@ -177,6 +186,33 @@ public class EntityCapsManager
}
/**
+ * Returns cached instance of {@link ConfigurationService}.
+ */
+ private static ConfigurationService getConfigService()
+ {
+ if (configService == null)
+ {
+ configService = ServiceUtils.getService(
+ bundleContext, ConfigurationService.class);
+ }
+ return configService;
+ }
+
+ /**
+ * Sets OSGi bundle context instance that will be used by this class.
+ * @param bundleContext the <tt>BundleContext</tt> instance to be used by
+ * this class or <tt>null</tt> to clear the reference.
+ */
+ public static void setBundleContext(BundleContext bundleContext)
+ {
+ if (bundleContext == null)
+ {
+ configService = null;
+ }
+ EntityCapsManager.bundleContext = bundleContext;
+ }
+
+ /**
* Add a record telling what entity caps node a user has.
*
* @param user the user (Full JID)
@@ -422,7 +458,7 @@ public class EntityCapsManager
if (discoverInfo == null)
{
ConfigurationService configurationService
- = JabberActivator.getConfigurationService();
+ = getConfigService();
String capsPropertyName = getCapsPropertyName(caps);
String xml = configurationService.getString(capsPropertyName);