diff --git a/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java index d7583b7cf..03b7b1392 100644 --- a/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/callhistory/CallHistoryServiceImpl.java @@ -550,38 +550,43 @@ public void start(BundleContext bc) { if (logger.isDebugEnabled()) logger.debug("Starting the call history implementation."); + this.bundleContext = bc; // start listening for newly register or removed protocol providers bc.addServiceListener(this); ServiceReference[] protocolProviderRefs = null; + try { - protocolProviderRefs = bc.getServiceReferences( - ProtocolProviderService.class.getName(), - null); + protocolProviderRefs + = bc.getServiceReferences( + ProtocolProviderService.class.getName(), + null); } catch (InvalidSyntaxException ex) { // this shouldn't happen since we're providing no parameter string // but let's log just in case. - logger.error( - "Error while retrieving service refs", ex); - return; + logger.error("Error while retrieving service refs", ex); } // in case we found any if (protocolProviderRefs != null) { if (logger.isDebugEnabled()) - logger.debug("Found " - + protocolProviderRefs.length - + " already installed providers."); - for (int i = 0; i < protocolProviderRefs.length; i++) { - ProtocolProviderService provider = (ProtocolProviderService) bc - .getService(protocolProviderRefs[i]); + logger.debug( + "Found " + + protocolProviderRefs.length + + " already installed providers."); + } + for (ServiceReference protocolProviderRef : protocolProviderRefs) + { + ProtocolProviderService provider + = (ProtocolProviderService) + bc.getService(protocolProviderRef); this.handleProviderAdded(provider); } @@ -598,27 +603,29 @@ public void stop(BundleContext bc) bc.removeServiceListener(this); ServiceReference[] protocolProviderRefs = null; + try { - protocolProviderRefs = bc.getServiceReferences( - ProtocolProviderService.class.getName(), - null); + protocolProviderRefs + = bc.getServiceReferences( + ProtocolProviderService.class.getName(), + null); } catch (InvalidSyntaxException ex) { // this shouldn't happen since we're providing no parameter string // but let's log just in case. logger.error("Error while retrieving service refs", ex); - return; } // in case we found any if (protocolProviderRefs != null) { - for (int i = 0; i < protocolProviderRefs.length; i++) + for (ServiceReference protocolProviderRef : protocolProviderRefs) { - ProtocolProviderService provider = (ProtocolProviderService) bc - .getService(protocolProviderRefs[i]); + ProtocolProviderService provider + = (ProtocolProviderService) + bc.getService(protocolProviderRef); this.handleProviderRemoved(provider); } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java index c00b3628a..9c5282eed 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java @@ -58,7 +58,7 @@ public class OperationSetContactCapabilitiesJabberImpl = new HashMap, String[]>(); /** - * The Map which associates specific additionnal + * The Map which associates specific additional * OperationSet class with the capabilities to be supported by a * Contact in order to consider the Contact to possess the * respective OperationSet capability. diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java index ba2be3039..1dd813409 100644 --- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java @@ -79,23 +79,32 @@ public void stop(BundleContext bundleContext) throws Exception * Returns the ProtocolProviderFactory for the Msn protocol. * @return the ProtocolProviderFactory for the Msn protocol */ - public static ProtocolProviderFactory getMsnProtocolProviderFactory() { - + public static ProtocolProviderFactory getMsnProtocolProviderFactory() + { ServiceReference[] serRefs = null; - - String osgiFilter = "(" - + ProtocolProviderFactory.PROTOCOL - + "="+ProtocolNames.MSN+")"; - - try { - serRefs = bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); + String osgiFilter + = "(" + + ProtocolProviderFactory.PROTOCOL + + "=" + + ProtocolNames.MSN + + ")"; + + try + { + serRefs + = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), + osgiFilter); } catch (InvalidSyntaxException ex){ logger.error("MsnAccRegWizzActivator : " + ex); } - return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + return + (serRefs == null) + ? null + : (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); } /** diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java index f1b458124..6058121ec 100644 --- a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java +++ b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java @@ -438,13 +438,21 @@ static synchronized void start(BundleContext bundleContext) MetaContactListService.class); bundleContext.addServiceListener(serviceListener); - for (ServiceReference reference - : bundleContext.getServiceReferences( - ProtocolProviderService.class.getName(), - null)) + + ServiceReference[] serviceReferences + = bundleContext.getServiceReferences( + ProtocolProviderService.class.getName(), + null); + + if ((serviceReferences != null) && (serviceReferences.length != 0)) { - serviceListener.serviceChanged( - new ServiceEvent(ServiceEvent.REGISTERED, reference)); + for (ServiceReference serviceReference : serviceReferences) + { + serviceListener.serviceChanged( + new ServiceEvent( + ServiceEvent.REGISTERED, + serviceReference)); + } } } diff --git a/src/net/java/sip/communicator/plugin/rssaccregwizz/RssAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/rssaccregwizz/RssAccRegWizzActivator.java index 130adc3bd..b8ff95596 100644 --- a/src/net/java/sip/communicator/plugin/rssaccregwizz/RssAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/rssaccregwizz/RssAccRegWizzActivator.java @@ -86,24 +86,31 @@ public void stop(BundleContext context) */ public static ProtocolProviderFactory getRssProtocolProviderFactory() { - ServiceReference[] serRefs = null; - - String osgiFilter = "(" - + ProtocolProviderFactory.PROTOCOL - + "=" + ProtocolNames.RSS + ")"; + String osgiFilter + = "(" + + ProtocolProviderFactory.PROTOCOL + + "=" + + ProtocolNames.RSS + + ")"; try { - serRefs = bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); + serRefs + = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), + osgiFilter); } catch (InvalidSyntaxException ex) { logger.error(ex); } - return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + return + (serRefs == null) + ? null + : (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); } /** diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java index dee40b161..17bc36531 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java @@ -100,9 +100,8 @@ public void stop(BundleContext bc) throws Exception */ private static boolean hasRegisteredAccounts() { - boolean hasRegisteredAccounts = false; - ServiceReference[] serRefs = null; + try { //get all registered provider factories @@ -114,29 +113,37 @@ private static boolean hasRegisteredAccounts() logger.error("Unable to obtain service references. " + e); } - for (int serRefIndex = 0; serRefIndex < serRefs.length; serRefIndex++) - { - ProtocolProviderFactory providerFactory = - (ProtocolProviderFactory) bundleContext - .getService(serRefs[serRefIndex]); + boolean hasRegisteredAccounts = false; - for (Iterator registeredAccountIter = - providerFactory.getRegisteredAccounts().iterator(); - registeredAccountIter.hasNext();) + if (serRefs != null) + { + for (ServiceReference serRef : serRefs) { - AccountID accountID = registeredAccountIter.next(); - boolean isHidden = accountID.getAccountProperty( - ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; - - if (!isHidden) + ProtocolProviderFactory providerFactory + = (ProtocolProviderFactory) + bundleContext.getService(serRef); + + for (Iterator registeredAccountIter + = providerFactory.getRegisteredAccounts() + .iterator(); + registeredAccountIter.hasNext();) { - hasRegisteredAccounts = true; - break; + AccountID accountID = registeredAccountIter.next(); + boolean isHidden + = accountID.getAccountProperty( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) + != null; + + if (!isHidden) + { + hasRegisteredAccounts = true; + break; + } } - } - if (hasRegisteredAccounts) - break; + if (hasRegisteredAccounts) + break; + } } return hasRegisteredAccounts; diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java index 463187851..d0c9fa735 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccRegWizzActivator.java @@ -92,18 +92,20 @@ public void stop(BundleContext bundleContext) throws Exception */ public static ProtocolProviderFactory getSIPProtocolProviderFactory() { - ServiceReference[] serRefs = null; - - String osgiFilter = - "(" + ProtocolProviderFactory.PROTOCOL + "=" + ProtocolNames.SIP + String osgiFilter + = "(" + + ProtocolProviderFactory.PROTOCOL + + "=" + + ProtocolNames.SIP + ")"; try { - serRefs = - bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); + serRefs + = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), + osgiFilter); } catch (InvalidSyntaxException ex) { @@ -111,7 +113,11 @@ public static ProtocolProviderFactory getSIPProtocolProviderFactory() return null; } - return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + return + (serRefs == null) + ? null + : (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); } /** diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java index d631d19db..c387b911d 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java @@ -96,24 +96,26 @@ public void stop(BundleContext bundleContext) throws Exception */ public static ProtocolProviderFactory getSSHProtocolProviderFactory() { - ServiceReference[] serRefs = null; - - String osgiFilter = "(" - + ProtocolProviderFactory.PROTOCOL - + "=" + "SSH" + ")"; + String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL + "=SSH)"; try { - serRefs = bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); + serRefs + = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), + osgiFilter); } catch (InvalidSyntaxException ex) { logger.error(ex); } - return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + return + (serRefs == null) + ? null + : (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); } /** diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java index 75df8a53c..d688ae166 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java @@ -77,23 +77,31 @@ public void stop(BundleContext bundleContext) throws Exception * Returns the ProtocolProviderFactory for the Yahoo protocol. * @return the ProtocolProviderFactory for the Yahoo protocol */ - public static ProtocolProviderFactory getYahooProtocolProviderFactory() { - + public static ProtocolProviderFactory getYahooProtocolProviderFactory() + { ServiceReference[] serRefs = null; - - String osgiFilter = "(" - + ProtocolProviderFactory.PROTOCOL - + "="+ProtocolNames.YAHOO+")"; + String osgiFilter + = "(" + + ProtocolProviderFactory.PROTOCOL + + "=" + + ProtocolNames.YAHOO + + ")"; try { - serRefs = bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); + serRefs + = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), + osgiFilter); } catch (InvalidSyntaxException ex){ logger.error("YahooAccRegWizzActivator : " + ex); } - return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + return + (serRefs == null) + ? null + : (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); } /** diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java index 15d758f92..b0b91aaff 100644 --- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java +++ b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java @@ -87,26 +87,31 @@ public void stop(BundleContext context) */ public static ProtocolProviderFactory getZeroconfProtocolProviderFactory() { - ServiceReference[] serRefs = null; - - String osgiFilter = "(" - + ProtocolProviderFactory.PROTOCOL - + "=" + ProtocolNames.ZEROCONF + ")"; + String osgiFilter + = "(" + + ProtocolProviderFactory.PROTOCOL + + "=" + + ProtocolNames.ZEROCONF + + ")"; try { - serRefs = bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); + serRefs + = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), + osgiFilter); } catch (InvalidSyntaxException ex) { logger.error(ex); } - - //System.out.println(" SerRefs " +serRefs); - return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + return + (serRefs == null) + ? null + : (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); } /** diff --git a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetContactCapabilities.java b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetContactCapabilities.java index 2e3e40179..1767234dc 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetContactCapabilities.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetContactCapabilities.java @@ -20,7 +20,7 @@ * @param the type of the ProtocolProviderService implementation * providing the AbstractOperationSetContactCapabilities implementation * - * @author Lubomir Marinov + * @author Lyubomir Marinov */ public abstract class AbstractOperationSetContactCapabilities< T extends ProtocolProviderService> @@ -152,7 +152,7 @@ protected void fireContactCapabilitiesEvent( * the specified opsetClass in the Map returned by * {@link #getSupportedOperationSets(Contact)} and returns the associated * OperationSet. Since the implementation is suboptimal due to the - * temporary Map allocations and loopups, extenders are advised to + * temporary Map allocations and lookups, extenders are advised to * override {@link #getOperationSet(Contact, Class, boolean)}. * * @param the type extending OperationSet for which the @@ -188,7 +188,7 @@ public U getOperationSet( * the specified opsetClass in the Map returned by * {@link #getSupportedOperationSets(Contact)} and returns the associated * OperationSet. Since the implementation is suboptimal due to the - * temporary Map allocations and loopups, extenders are advised to + * temporary Map allocations and lookups, extenders are advised to * override. * * @param the type extending OperationSet for which the diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetContactCapabilities.java b/src/net/java/sip/communicator/service/protocol/OperationSetContactCapabilities.java index caddeca8f..c574f4cdb 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetContactCapabilities.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetContactCapabilities.java @@ -17,7 +17,7 @@ * associated protocol provider to be capabilities possessed by the * Contact in question. * - * @author Lubomir Marinov + * @author Lyubomir Marinov */ public interface OperationSetContactCapabilities extends OperationSet diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java index e71de40f2..eec179916 100644 --- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java +++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderActivator.java @@ -116,18 +116,23 @@ public static ResourceManagementService getResourceService() public static ProtocolProviderFactory getProtocolProviderFactory( String protocolName) { - String osgiFilter = "(" - + ProtocolProviderFactory.PROTOCOL - + "="+protocolName+")"; - + String osgiFilter + = "(" + ProtocolProviderFactory.PROTOCOL + "=" + protocolName + ")"; ProtocolProviderFactory protocolProviderFactory = null; + try { ServiceReference[] serRefs = bundleContext.getServiceReferences( - ProtocolProviderFactory.class.getName(), osgiFilter); - protocolProviderFactory = (ProtocolProviderFactory) - bundleContext.getService(serRefs[0]); + ProtocolProviderFactory.class.getName(), + osgiFilter); + + if ((serRefs != null) && (serRefs.length != 0)) + { + protocolProviderFactory + = (ProtocolProviderFactory) + bundleContext.getService(serRefs[0]); + } } catch (InvalidSyntaxException ex) {