From b71ad6f750cb271721eb000fafd2ad56d6e0c825 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Thu, 16 Feb 2012 11:32:56 +0000 Subject: Adds property which can make provisioning mandatory, and if user cancels application will exit. --- .../plugin/provisioning/ProvisioningActivator.java | 2 +- .../provisioning/ProvisioningServiceImpl.java | 51 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'src/net/java/sip/communicator/plugin/provisioning') diff --git a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java index b5aac39..bb9a772 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java +++ b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningActivator.java @@ -36,7 +36,7 @@ public class ProvisioningActivator /** * The current BundleContext. */ - private static BundleContext bundleContext = null; + static BundleContext bundleContext = null; /** * A reference to the ConfigurationService implementation instance that diff --git a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java index 58d2e57..ad58de3 100644 --- a/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java +++ b/src/net/java/sip/communicator/plugin/provisioning/ProvisioningServiceImpl.java @@ -13,6 +13,7 @@ import net.java.sip.communicator.service.httputil.*; import net.java.sip.communicator.service.provisioning.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; +import org.osgi.framework.*; /** * Provisioning service. @@ -62,6 +63,12 @@ public class ProvisioningServiceImpl = "net.java.sip.communicator.plugin.provisioning.METHOD"; /** + * Name of the property, whether provisioning is mandatory. + */ + private static final String PROPERTY_PROVISIONING_MANDATORY + = "net.java.sip.communicator.plugin.provisioning.MANDATORY"; + + /** * Name of the property that contains enforce prefix list (separated by * pipe) for the provisioning. The retrieved configuration properties will * be checked against these prefixes to avoid having incorrect content in @@ -420,7 +427,51 @@ public class ProvisioningServiceImpl // if there was an error in retrieving stop if(res == null) + { + // if canceled, lets check whether provisioning is + // mandatory + boolean provisioningMandatory = false; + + String defaultSettingsProp = + ProvisioningActivator.getResourceService() + .getSettingsString(PROPERTY_PROVISIONING_MANDATORY); + if(defaultSettingsProp != null + && Boolean.parseBoolean(defaultSettingsProp)) + provisioningMandatory = true; + + if(ProvisioningActivator.getConfigurationService().getBoolean( + PROPERTY_PROVISIONING_MANDATORY, provisioningMandatory)) + { + // as shutdown service is not started and other bundles + // are scheduled to start, stop all of them + { + for(Bundle b : ProvisioningActivator.bundleContext + .getBundles()) + { + try + { + // skip our Bundle avoiding stopping us while + // starting and NPE in felix + if(ProvisioningActivator.bundleContext + .equals(b.getBundleContext())) + { + continue; + } + b.stop(); + } + catch (BundleException ex) + { + logger.error( + "Failed to being gentle stop " + + b.getLocation(), ex); + } + } + } + } + + // stop processing return null; + } String userPass[] = res.getCredentials(); if(userPass[0] != null && userPass[1] != null) -- cgit v1.1