diff options
2 files changed, 82 insertions, 34 deletions
diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java index d80d8b7..51ea685 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java @@ -34,7 +34,6 @@ import org.osgi.framework.*; */
public class InitialAccountRegistrationFrame
extends SIPCommFrame
- implements ServiceListener
{
/**
* Serial version UID.
@@ -157,7 +156,7 @@ public class InitialAccountRegistrationFrame if (scroller.getViewport().getHeight()
< Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 230)
{
- this.setSize(this.getSize().width,
+ this.setSize(scroller.getViewport().getWidth() + 100,
scroller.getViewport().getHeight() + 150);
}
else
@@ -269,9 +268,6 @@ public class InitialAccountRegistrationFrame logger.error("GuiActivator : ", ex);
}
}
-
- SimpleAccountRegistrationActivator.bundleContext
- .addServiceListener(this);
}
/**
@@ -504,27 +500,6 @@ public class InitialAccountRegistrationFrame }
/**
- * Handles registration of a new account wizard.
- */
- public void serviceChanged(ServiceEvent event)
- {
- Object sService = SimpleAccountRegistrationActivator.bundleContext.
- getService(event.getServiceReference());
-
- // we don't care if the source service is not a plugin component
- if (! (sService instanceof AccountRegistrationWizard))
- return;
-
- AccountRegistrationWizard wizard
- = (AccountRegistrationWizard) sService;
-
- if (event.getType() == ServiceEvent.REGISTERED)
- {
- this.addAccountRegistrationForm(wizard);
- }
- }
-
- /**
* Adds a simple account registration form corresponding to the given
* <tt>AccountRegistrationWizard</tt>.
*
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 { } |