Fixes warnings.

cefexperiments
Lyubomir Marinov 11 years ago
parent 6a23358a8d
commit a613195ef4

@ -8,6 +8,7 @@
import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*; import org.jitsi.service.configuration.*;
import org.osgi.framework.*; import org.osgi.framework.*;
@ -15,7 +16,7 @@
* Implements <tt>BundleActivator</tt> for the browserlauncher bundle. * Implements <tt>BundleActivator</tt> for the browserlauncher bundle.
* *
* @author Yana Stamcheva * @author Yana Stamcheva
* @author Lubomir Marinov * @author Lyubomir Marinov
* @author Pawel Domas * @author Pawel Domas
*/ */
public class BrowserLauncherActivator public class BrowserLauncherActivator
@ -73,11 +74,10 @@ public static ConfigurationService getConfigurationService()
{ {
if (configService == null && bundleContext != null) if (configService == null && bundleContext != null)
{ {
ServiceReference serviceReference = bundleContext configService
.getServiceReference(ConfigurationService.class.getName()); = ServiceUtils.getService(
bundleContext,
configService = (ConfigurationService)bundleContext ConfigurationService.class);
.getService(serviceReference);
} }
return configService; return configService;

@ -68,11 +68,8 @@ public void start(BundleContext bc) throws Exception
try{ try{
logger.logEntry(); logger.logEntry();
ServiceReference refHistory = bundleContext.getServiceReference( HistoryService historyService
HistoryService.class.getName()); = ServiceUtils.getService(bundleContext, HistoryService.class);
HistoryService historyService = (HistoryService)
bundleContext.getService(refHistory);
//Create and start the call history service. //Create and start the call history service.
callHistoryService = callHistoryService =
@ -150,27 +147,28 @@ public static ResourceManagementService getResources()
public static Map<Object, ProtocolProviderFactory> public static Map<Object, ProtocolProviderFactory>
getProtocolProviderFactories() getProtocolProviderFactories()
{ {
ServiceReference[] serRefs = null; Collection<ServiceReference<ProtocolProviderFactory>> serRefs;
try try
{ {
// get all registered provider factories // get all registered provider factories
serRefs = serRefs
bundleContext.getServiceReferences( = bundleContext.getServiceReferences(
ProtocolProviderFactory.class.getName(), null); ProtocolProviderFactory.class,
null);
} }
catch (InvalidSyntaxException e) catch (InvalidSyntaxException e)
{ {
serRefs = null;
logger.error("LoginManager : " + e); logger.error("LoginManager : " + e);
} }
if (serRefs != null) if (serRefs != null)
{ {
for (ServiceReference serRef : serRefs) for (ServiceReference<ProtocolProviderFactory> serRef : serRefs)
{ {
ProtocolProviderFactory providerFactory ProtocolProviderFactory providerFactory
= (ProtocolProviderFactory) = bundleContext.getService(serRef);
bundleContext.getService(serRef);
providerFactoriesMap.put( providerFactoriesMap.put(
serRef.getProperty(ProtocolProviderFactory.PROTOCOL), serRef.getProperty(ProtocolProviderFactory.PROTOCOL),

@ -618,39 +618,35 @@ public void start(BundleContext bc)
// start listening for newly register or removed protocol providers // start listening for newly register or removed protocol providers
bc.addServiceListener(this); bc.addServiceListener(this);
ServiceReference[] protocolProviderRefs = null; Collection<ServiceReference<ProtocolProviderService>> ppsRefs;
try try
{ {
protocolProviderRefs ppsRefs
= bc.getServiceReferences( = bc.getServiceReferences(ProtocolProviderService.class, null);
ProtocolProviderService.class.getName(),
null);
} }
catch (InvalidSyntaxException ex) catch (InvalidSyntaxException ex)
{ {
ppsRefs = null;
// this shouldn't happen since we're providing no parameter string // this shouldn't happen since we're providing no parameter string
// but let's log just in case. // but let's log just in case.
logger.error("Error while retrieving service refs", ex); logger.error("Error while retrieving service refs", ex);
} }
// in case we found any // in case we found any
if (protocolProviderRefs != null) if (ppsRefs != null)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug( logger.debug(
"Found " "Found " + ppsRefs.size()
+ protocolProviderRefs.length
+ " already installed providers."); + " already installed providers.");
} }
for (ServiceReference protocolProviderRef : protocolProviderRefs) for (ServiceReference<ProtocolProviderService> ppsRef : ppsRefs)
{ {
ProtocolProviderService provider ProtocolProviderService pps = bc.getService(ppsRef);
= (ProtocolProviderService)
bc.getService(protocolProviderRef);
this.handleProviderAdded(provider); this.handleProviderAdded(pps);
} }
} }
} }
@ -664,32 +660,29 @@ public void stop(BundleContext bc)
{ {
bc.removeServiceListener(this); bc.removeServiceListener(this);
ServiceReference[] protocolProviderRefs = null; Collection<ServiceReference<ProtocolProviderService>> ppsRefs;
try try
{ {
protocolProviderRefs ppsRefs
= bc.getServiceReferences( = bc.getServiceReferences(ProtocolProviderService.class, null);
ProtocolProviderService.class.getName(),
null);
} }
catch (InvalidSyntaxException ex) catch (InvalidSyntaxException ex)
{ {
ppsRefs = null;
// this shouldn't happen since we're providing no parameter string // this shouldn't happen since we're providing no parameter string
// but let's log just in case. // but let's log just in case.
logger.error("Error while retrieving service refs", ex); logger.error("Error while retrieving service refs", ex);
} }
// in case we found any // in case we found any
if (protocolProviderRefs != null) if (ppsRefs != null)
{ {
for (ServiceReference protocolProviderRef : protocolProviderRefs) for (ServiceReference<ProtocolProviderService> ppsRef : ppsRefs)
{ {
ProtocolProviderService provider ProtocolProviderService pps = bc.getService(ppsRef);
= (ProtocolProviderService)
bc.getService(protocolProviderRef);
this.handleProviderRemoved(provider); this.handleProviderRemoved(pps);
} }
} }
} }

@ -91,10 +91,10 @@ public void startCandidateHarvest(SessionDescription ourOffer,
iceAgent.setControlling(true); iceAgent.setControlling(true);
//add the candidate attributes and set default candidates //add the candidate attributes and set default candidates
for(MediaDescription mLine : SdpUtils.extractMediaDescriptions(ourOffer)) for(MediaDescription mLine
: SdpUtils.extractMediaDescriptions(ourOffer))
{ {
IceMediaStream iceStream = createIceStream( createIceStream(SdpUtils.getMediaType(mLine).toString(), iceAgent);
SdpUtils.getMediaType(mLine).toString(), iceAgent);
} }
//now that our iceAgent is ready, reflect it on our offer. //now that our iceAgent is ready, reflect it on our offer.
@ -134,7 +134,7 @@ public void startCandidateHarvest( SessionDescription theirOffer,
* @return the content list that we received earlier (possibly cloned into * @return the content list that we received earlier (possibly cloned into
* a new instance) and that we have updated with transport lists. * a new instance) and that we have updated with transport lists.
*/ */
public List<Candidate> wrapupCandidateHarvest() public List<Candidate<?>> wrapupCandidateHarvest()
{ {
return null; return null;
} }

@ -11,7 +11,7 @@
import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.Base64; // disambiguation import net.java.sip.communicator.util.Base64;
import org.jitsi.service.configuration.*; import org.jitsi.service.configuration.*;
import org.osgi.framework.*; import org.osgi.framework.*;
@ -20,7 +20,7 @@
* Represents an implementation of <tt>AccountManager</tt> which loads the * Represents an implementation of <tt>AccountManager</tt> which loads the
* accounts in a separate thread. * accounts in a separate thread.
* *
* @author Lubomir Marinov * @author Lyubomir Marinov
* @author Yana Stamcheva * @author Yana Stamcheva
*/ */
public class AccountManager public class AccountManager
@ -286,35 +286,37 @@ public boolean hasStoredAccount(String protocolName,
boolean includeHidden, boolean includeHidden,
String userID) String userID)
{ {
ServiceReference[] factoryRefs = null; Collection<ServiceReference<ProtocolProviderFactory>> factoryRefs;
boolean hasStoredAccounts = false; boolean hasStoredAccounts = false;
try try
{ {
factoryRefs factoryRefs
= bundleContext.getServiceReferences( = bundleContext.getServiceReferences(
ProtocolProviderFactory.class.getName(), null); ProtocolProviderFactory.class,
null);
} }
catch (InvalidSyntaxException ex) catch (InvalidSyntaxException ex)
{ {
factoryRefs = null;
logger.error( logger.error(
"Failed to retrieve the registered ProtocolProviderFactories", "Failed to retrieve the registered ProtocolProviderFactories",
ex); ex);
} }
if ((factoryRefs != null) && (factoryRefs.length > 0)) if ((factoryRefs != null) && !factoryRefs.isEmpty())
{ {
ConfigurationService configService ConfigurationService configService
= ProtocolProviderActivator.getConfigurationService(); = ProtocolProviderActivator.getConfigurationService();
for (ServiceReference factoryRef : factoryRefs) for (ServiceReference<ProtocolProviderFactory> factoryRef
: factoryRefs)
{ {
ProtocolProviderFactory factory ProtocolProviderFactory factory
= (ProtocolProviderFactory) = bundleContext.getService(factoryRef);
bundleContext.getService(factoryRef);
if ((protocolName != null) if ((protocolName != null)
&& !protocolName.equals(factory.getProtocolName())) && !protocolName.equals(factory.getProtocolName()))
{ {
continue; continue;
} }
@ -397,31 +399,33 @@ else if(userID == null)
*/ */
public AccountID findAccountID(String uid) public AccountID findAccountID(String uid)
{ {
ServiceReference[] factoryRefs = null; Collection<ServiceReference<ProtocolProviderFactory>> factoryRefs;
try try
{ {
factoryRefs factoryRefs
= bundleContext.getServiceReferences( = bundleContext.getServiceReferences(
ProtocolProviderFactory.class.getName(), null); ProtocolProviderFactory.class,
null);
} }
catch (InvalidSyntaxException ex) catch (InvalidSyntaxException ex)
{ {
factoryRefs = null;
logger.error( logger.error(
"Failed to retrieve the registered ProtocolProviderFactories", "Failed to retrieve the registered ProtocolProviderFactories",
ex); ex);
} }
if ((factoryRefs != null) && (factoryRefs.length > 0)) if ((factoryRefs != null) && !factoryRefs.isEmpty())
{ {
ConfigurationService configService ConfigurationService configService
= ProtocolProviderActivator.getConfigurationService(); = ProtocolProviderActivator.getConfigurationService();
for (ServiceReference factoryRef : factoryRefs) for (ServiceReference<ProtocolProviderFactory> factoryRef
: factoryRefs)
{ {
ProtocolProviderFactory factory ProtocolProviderFactory factory
= (ProtocolProviderFactory) = bundleContext.getService(factoryRef);
bundleContext.getService(factoryRef);
String factoryPackage = getFactoryImplPackageName(factory); String factoryPackage = getFactoryImplPackageName(factory);
List<String> storedAccountsProps List<String> storedAccountsProps
@ -508,8 +512,8 @@ public void run()
} }
}; };
loadStoredAccountsThread.setDaemon(true); loadStoredAccountsThread.setDaemon(true);
loadStoredAccountsThread loadStoredAccountsThread.setName(
.setName("AccountManager.loadStoredAccounts"); "AccountManager.loadStoredAccounts");
loadStoredAccountsThread.start(); loadStoredAccountsThread.start();
} }
} }
@ -1022,15 +1026,15 @@ public void unloadAccount(AccountID accountID)
accountID.getProtocolName()); accountID.getProtocolName());
// Obtain the protocol provider. // Obtain the protocol provider.
ServiceReference serRef ServiceReference<ProtocolProviderService> serRef
= providerFactory.getProviderForAccount(accountID); = providerFactory.getProviderForAccount(accountID);
// If there's no such provider we have nothing to do here. // If there's no such provider we have nothing to do here.
if (serRef == null) if (serRef == null)
return; return;
ProtocolProviderService protocolProvider = ProtocolProviderService protocolProvider
(ProtocolProviderService) bundleContext.getService(serRef); = bundleContext.getService(serRef);
// Set the account icon path for unloaded accounts. // Set the account icon path for unloaded accounts.
String iconPathProperty = accountID.getAccountPropertyString( String iconPathProperty = accountID.getAccountPropertyString(

@ -6,6 +6,8 @@
*/ */
package net.java.sip.communicator.service.protocol; package net.java.sip.communicator.service.protocol;
import java.util.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import org.osgi.framework.*; import org.osgi.framework.*;
@ -13,17 +15,15 @@
/** /**
* Provides utilities to aid the manipulation of {@link AccountManager}. * Provides utilities to aid the manipulation of {@link AccountManager}.
* *
* @author Lubomir Marinov * @author Lyubomir Marinov
*/ */
public final class AccountManagerUtils public final class AccountManagerUtils
{ {
private static AccountManager getAccountManager(BundleContext bundleContext) private static AccountManager getAccountManager(BundleContext bundleContext)
{ {
return return
(AccountManager) bundleContext.getService(
bundleContext.getService( bundleContext.getServiceReference(AccountManager.class));
bundleContext.getServiceReference(
AccountManager.class.getName()));
} }
/** /**
@ -92,14 +92,13 @@ public void handleAccountManagerEvent(AccountManagerEvent event)
if (bundleContext == null) if (bundleContext == null)
return; return;
ServiceReference[] factoryRefs; Collection<ServiceReference<ProtocolProviderFactory>> factoryRefs;
try try
{ {
factoryRefs factoryRefs
= bundleContext = bundleContext.getServiceReferences(
.getServiceReferences( ProtocolProviderFactory.class,
ProtocolProviderFactory.class.getName(),
"(" "("
+ ProtocolProviderFactory.PROTOCOL + ProtocolProviderFactory.PROTOCOL
+ "=" + "="
@ -119,13 +118,15 @@ public void handleAccountManagerEvent(AccountManagerEvent event)
{ {
boolean factoryIsRegistered = false; boolean factoryIsRegistered = false;
for (ServiceReference factoryRef : factoryRefs) for (ServiceReference<ProtocolProviderFactory> factoryRef
: factoryRefs)
{
if (factory == bundleContext.getService(factoryRef)) if (factory == bundleContext.getService(factoryRef))
{ {
factoryIsRegistered = true; factoryIsRegistered = true;
break; break;
} }
}
if (!factoryIsRegistered) if (!factoryIsRegistered)
return; return;
} }

Loading…
Cancel
Save