Fixes a possible NullPointerException which could prevent the successful integration of Jitsi presence, IM and VoIP into MS Outlook.

cusax-fix
Lyubomir Marinov 14 years ago
parent 9016956e44
commit 59c2b9d390

@ -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);
}

@ -58,7 +58,7 @@ public class OperationSetContactCapabilitiesJabberImpl
= new HashMap<Class<? extends OperationSet>, String[]>();
/**
* The <tt>Map</tt> which associates specific additionnal
* The <tt>Map</tt> which associates specific additional
* <tt>OperationSet</tt> class with the capabilities to be supported by a
* <tt>Contact</tt> in order to consider the <tt>Contact</tt> to possess the
* respective <tt>OperationSet</tt> capability.

@ -79,23 +79,32 @@ public void stop(BundleContext bundleContext) throws Exception
* Returns the <tt>ProtocolProviderFactory</tt> for the Msn protocol.
* @return the <tt>ProtocolProviderFactory</tt> 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]);
}
/**

@ -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));
}
}
}

@ -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]);
}
/**

@ -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<AccountID> 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<AccountID> 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;

@ -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]);
}
/**

@ -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]);
}
/**

@ -77,23 +77,31 @@ public void stop(BundleContext bundleContext) throws Exception
* Returns the <tt>ProtocolProviderFactory</tt> for the Yahoo protocol.
* @return the <tt>ProtocolProviderFactory</tt> 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]);
}
/**

@ -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]);
}
/**

@ -20,7 +20,7 @@
* @param <T> the type of the <tt>ProtocolProviderService</tt> implementation
* providing the <tt>AbstractOperationSetContactCapabilities</tt> implementation
*
* @author Lubomir Marinov
* @author Lyubomir Marinov
*/
public abstract class AbstractOperationSetContactCapabilities<
T extends ProtocolProviderService>
@ -152,7 +152,7 @@ protected void fireContactCapabilitiesEvent(
* the specified <tt>opsetClass</tt> in the <tt>Map</tt> returned by
* {@link #getSupportedOperationSets(Contact)} and returns the associated
* <tt>OperationSet</tt>. Since the implementation is suboptimal due to the
* temporary <tt>Map</tt> allocations and loopups, extenders are advised to
* temporary <tt>Map</tt> allocations and lookups, extenders are advised to
* override {@link #getOperationSet(Contact, Class, boolean)}.
*
* @param <U> the type extending <tt>OperationSet</tt> for which the
@ -188,7 +188,7 @@ public <U extends OperationSet> U getOperationSet(
* the specified <tt>opsetClass</tt> in the <tt>Map</tt> returned by
* {@link #getSupportedOperationSets(Contact)} and returns the associated
* <tt>OperationSet</tt>. Since the implementation is suboptimal due to the
* temporary <tt>Map</tt> allocations and loopups, extenders are advised to
* temporary <tt>Map</tt> allocations and lookups, extenders are advised to
* override.
*
* @param <U> the type extending <tt>OperationSet</tt> for which the

@ -17,7 +17,7 @@
* associated protocol provider to be capabilities possessed by the
* <tt>Contact</tt> in question.
*
* @author Lubomir Marinov
* @author Lyubomir Marinov
*/
public interface OperationSetContactCapabilities
extends OperationSet

@ -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)
{

Loading…
Cancel
Save