/* * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ package net.java.sip.communicator.plugin.ircaccregwizz; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; import org.osgi.framework.*; /** * Registers the IrcAccountRegistrationWizard in the UI Service. * * @author Lionel Ferreira & Michael Tarantino */ public class IrcAccRegWizzActivator implements BundleActivator { private static Logger logger = Logger.getLogger( IrcAccRegWizzActivator.class.getName()); /** * A currently valid bundle context. */ public static BundleContext bundleContext; public static UIService uiService; /** * Starts this bundle. * @param bc the currently valid BundleContext. */ public void start(BundleContext bc) { logger.info("Loading irc account wizard."); bundleContext = bc; ServiceReference uiServiceRef = bundleContext .getServiceReference(UIService.class.getName()); UIService uiService = (UIService) bundleContext.getService(uiServiceRef); AccountRegistrationWizardContainer wizardContainer = uiService.getAccountRegWizardContainer(); IrcAccountRegistrationWizard ircWizard = new IrcAccountRegistrationWizard(wizardContainer); wizardContainer.addAccountRegistrationWizard(ircWizard); logger.info("IRC account registration wizard [STARTED]."); } /** * Called when this bundle is stopped so the Framework can perform the * bundle-specific activities necessary to stop the bundle. * * @param context The execution context of the bundle being stopped. */ public void stop(BundleContext context) { } /** * Returns the ProtocolProviderFactory for the IRC protocol. * @return the ProtocolProviderFactory for the IRC protocol */ public static ProtocolProviderFactory getIrcProtocolProviderFactory() { ServiceReference[] serRefs = null; String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL + "=" + "IRC" + ")"; try { serRefs = bundleContext.getServiceReferences( ProtocolProviderFactory.class.getName(), osgiFilter); } catch (InvalidSyntaxException ex) { logger.error(ex); } return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); } /** * Returns the bundleContext that we received when we were started. * * @return a currently valid instance of a bundleContext. */ public BundleContext getBundleContext() { return bundleContext; } /** * Returns the UIService. * * @return the UIService */ public static UIService getUIService() { return uiService; } }