diff options
Diffstat (limited to 'src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java')
-rw-r--r-- | src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java | 89 |
1 files changed, 81 insertions, 8 deletions
diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java index 13a689d..b9408dc 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java @@ -25,7 +25,8 @@ import javax.swing.*; * @author Yana Stamcheva */ public class SimpleAccountRegistrationActivator - implements BundleActivator + implements BundleActivator, + ServiceListener { private static final Logger logger = Logger.getLogger(SimpleAccountRegistrationActivator.class); @@ -57,6 +58,10 @@ public class SimpleAccountRegistrationActivator private static ResourceManagementService resourcesService; + private int numWizardsRegistered = 0; + + private String[] protocolNames; + public void start(BundleContext bc) throws Exception { @@ -78,6 +83,20 @@ public class SimpleAccountRegistrationActivator } /** + * Handles registration of a new account wizard. + */ + public void serviceChanged(ServiceEvent event) + { + if (event.getType() == ServiceEvent.REGISTERED) + { + if (++numWizardsRegistered == protocolNames.length) + { + showDialog(); + } + } + } + + /** * Initialize and displays the initial registration frame. */ private void init() @@ -93,21 +112,75 @@ public class SimpleAccountRegistrationActivator && !getConfigService().getBoolean(DISABLED_PROP, false)) { // If no preferred wizard is specified we launch the default wizard. - InitialAccountRegistrationFrame accountRegFrame = - new InitialAccountRegistrationFrame(); + String protocolOrder + = SimpleAccountRegistrationActivator.getConfigService() + .getString("plugin.simpleaccreg.PROTOCOL_ORDER"); + if (protocolOrder == null) + { + return; + } + + String protocolFilter = ""; + protocolNames = protocolOrder.split("\\|"); + for (int i = 0; i < protocolNames.length; i++) + { + if (i > 0) + { + protocolFilter = "(|" + protocolFilter; + } + + protocolFilter += "(" + ProtocolProviderFactory.PROTOCOL + + "=" + protocolNames[i] + ")"; + if (i > 0) + { + protocolFilter += ")"; + } + } - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - accountRegFrame.setLocation(screenSize.width / 2 - - accountRegFrame.getWidth() / 2, screenSize.height / 2 - - accountRegFrame.getHeight() / 2); + try + { + ServiceReference[] refs = bundleContext.getAllServiceReferences( + AccountRegistrationWizard.class.getName(), protocolFilter); + if (refs != null) + { + numWizardsRegistered = refs.length; + } - accountRegFrame.setVisible(true); + // not all requested wizard are available, wait for them + if (numWizardsRegistered < protocolNames.length) + { + bundleContext.addServiceListener(this, "(&(objectclass=" + + AccountRegistrationWizard.class.getName() + ")" + + protocolFilter + ")"); + } + else + { + showDialog(); + } + } + catch (InvalidSyntaxException e) + { + logger.error(e); + } } if (logger.isInfoEnabled()) logger.info("SIMPLE ACCOUNT REGISTRATION ...[STARTED]"); } + private void showDialog() + { + InitialAccountRegistrationFrame accountRegFrame = + new InitialAccountRegistrationFrame(); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + accountRegFrame.setLocation(screenSize.width / 2 + - accountRegFrame.getWidth() / 2, screenSize.height / 2 + - accountRegFrame.getHeight() / 2); + + accountRegFrame.setVisible(true); + } + public void stop(BundleContext bc) throws Exception { } |