/* * Jitsi, 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.googletalkaccregwizz; import java.util.*; import org.osgi.framework.*; import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; /** * Registers the GoogleTalkAccountRegistrationWizard in the UI Service. * * @author Lubomir Marinov */ public class GoogleTalkAccRegWizzActivator implements BundleActivator { public static BundleContext bundleContext; private static ResourceManagementService resourcesService; /** * The Logger used by the GoogleTalkAccRegWizzActivator * and its instances for logging output. */ private static final Logger logger = Logger.getLogger(GoogleTalkAccRegWizzActivator.class); private static BrowserLauncherService browserLauncherService; private static UIService uiService; /** * Starts this bundle. * @param bc BundleContext * @throws Exception */ public void start(BundleContext bc) throws Exception { bundleContext = bc; uiService = (UIService) bundleContext.getService(bundleContext .getServiceReference(UIService.class.getName())); GoogleTalkAccountRegistrationWizard wizard = new GoogleTalkAccountRegistrationWizard(uiService .getAccountRegWizardContainer()); Hashtable containerFilter = new Hashtable(); containerFilter.put( ProtocolProviderFactory.PROTOCOL, GoogleTalkAccountRegistrationWizard.PROTOCOL); bundleContext.registerService( AccountRegistrationWizard.class.getName(), wizard, containerFilter); } public void stop(BundleContext bundleContext) throws Exception { } /** * Returns the ProtocolProviderFactory for the Google Talk * protocol. * * @return the ProtocolProviderFactory for the Google Talk * protocol */ public static ProtocolProviderFactory getGoogleTalkProtocolProviderFactory() { ServiceReference[] serRefs = null; String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL + "=" + ProtocolNames.JABBER + ")"; try { serRefs = bundleContext.getServiceReferences( ProtocolProviderFactory.class.getName(), osgiFilter); } catch (InvalidSyntaxException ex) { logger.error("GoogleTalkAccRegWizzActivator : " + ex); } return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); } /** * Returns the UIService. * * @return the UIService */ public static UIService getUIService() { return uiService; } /** * Returns the BrowserLauncherService obtained from the bundle * context. * @return the BrowserLauncherService obtained from the bundle * context */ public static BrowserLauncherService getBrowserLauncher() { if (browserLauncherService == null) { browserLauncherService = (BrowserLauncherService) bundleContext .getService(bundleContext .getServiceReference(BrowserLauncherService.class .getName())); } return browserLauncherService; } public static ResourceManagementService getResources() { if (resourcesService == null) resourcesService = ResourceManagementServiceUtils .getService(GoogleTalkAccRegWizzActivator.bundleContext); return resourcesService; } }