Uses info retriever for retrieving contact avatar, to avoid possible duplicate VCard loads.

Adds property to disable/enable searching buddies for jingle nodes, disabled by default.
cusax-fix
Damian Minkov 14 years ago
parent 0990970b24
commit 2b788a2442

Binary file not shown.

@ -193,6 +193,20 @@ public boolean isJingleNodesAutoDiscoveryEnabled()
true);
}
/**
* Determines whether this account's provider is supposed to auto discover
* JingleNodes relay by searching our contacts.
*
* @return <tt>true</tt> if this provider would need to discover JingleNodes
* relay by searching buddies, <tt>false</tt> otherwise
*/
public boolean isJingleNodesSearchBuddiesEnabled()
{
return getAccountPropertyBoolean(
ProtocolProviderFactory.JINGLE_NODES_SEARCH_BUDDIES,
false);
}
/**
* Determines whether this account's provider uses JingleNodes relay (if
* available).

@ -105,9 +105,11 @@ public class OperationSetPersistentPresenceJabberImpl
/**
* Creates the OperationSet.
* @param provider the parent provider.
* @param infoRetreiver retrieve contact information.
*/
public OperationSetPersistentPresenceJabberImpl(
ProtocolProviderServiceJabberImpl provider)
ProtocolProviderServiceJabberImpl provider,
InfoRetreiver infoRetreiver)
{
super(provider);
@ -115,7 +117,8 @@ public OperationSetPersistentPresenceJabberImpl(
parentProvider.getJabberStatusEnum().getStatus(
JabberStatusEnum.OFFLINE);
ssContactList = new ServerStoredContactListJabberImpl( this , provider);
ssContactList = new ServerStoredContactListJabberImpl(
this , provider, infoRetreiver);
parentProvider.addRegistrationStateChangeListener(
new RegistrationStateListener());

@ -1489,9 +1489,11 @@ protected void initialize(String screenname,
= accountID.getAccountPropertyString(
ProtocolProviderFactory.RESOURCE_PRIORITY);
InfoRetreiver infoRetreiver = new InfoRetreiver(this, screenname);
//initialize the presence operationset
OperationSetPersistentPresenceJabberImpl persistentPresence =
new OperationSetPersistentPresenceJabberImpl(this);
new OperationSetPersistentPresenceJabberImpl(this, infoRetreiver);
if(resourcePriority != null)
{
@ -1559,8 +1561,6 @@ protected void initialize(String screenname,
OperationSetMultiUserChat.class,
new OperationSetMultiUserChatJabberImpl(this));
InfoRetreiver infoRetreiver = new InfoRetreiver(this, screenname);
addSupportedOperationSet(
OperationSetServerStoredContactInfo.class,
new OperationSetServerStoredContactInfoJabberImpl(
@ -2451,7 +2451,7 @@ public InetAddress getNextHop()
public void startJingleNodesDiscovery()
{
// Jingle Nodes Service Initialization
JabberAccountID accID = (JabberAccountID)getAccountID();
final JabberAccountID accID = (JabberAccountID)getAccountID();
final SmackServiceNode service = new SmackServiceNode(connection,
60000);
// make sure SmackServiceNode will clean up when connection is closed
@ -2469,8 +2469,6 @@ public void startJingleNodesDiscovery()
service.addTrackerEntry(entry);
}
final boolean autoDiscover = accID.isJingleNodesAutoDiscoveryEnabled();
new Thread()
{
public void run()
@ -2485,7 +2483,8 @@ public void run()
final SmackServiceNode.MappedNodes nodes =
service.searchServices(
connection, 6, 3, 20, JingleChannelIQ.UDP,
autoDiscover);
accID.isJingleNodesAutoDiscoveryEnabled(),
accID.isJingleNodesSearchBuddiesEnabled());
if(logger.isInfoEnabled())
{

@ -76,16 +76,23 @@ public class ServerStoredContactListJabberImpl
*/
private ChangeListener rosterChangeListener = null;
/**
* Retrieve contact information.
*/
private InfoRetreiver infoRetreiver = null;
/**
* Creates a ServerStoredContactList wrapper for the specified BuddyList.
*
* @param parentOperationSet the operation set that created us and that
* we could use for dispatching subscription events
* @param provider the provider that has instantiated us.
* @param infoRetreiver retrieve contact information.
*/
ServerStoredContactListJabberImpl(
OperationSetPersistentPresenceJabberImpl parentOperationSet,
ProtocolProviderServiceJabberImpl provider)
ProtocolProviderServiceJabberImpl provider,
InfoRetreiver infoRetreiver)
{
//We need to init these as early as possible to ensure that the provider
//and the operationsset would not be null in the incoming events.
@ -93,6 +100,7 @@ public class ServerStoredContactListJabberImpl
this.jabberProvider = provider;
this.rootGroup = new RootContactGroupJabberImpl(this.jabberProvider);
this.infoRetreiver = infoRetreiver;
}
/**
@ -1496,18 +1504,19 @@ void quit()
*/
private byte[] getAvatar(ContactJabberImpl contact)
{
byte[] result;
byte[] result = null;
try
{
XMPPConnection connection = jabberProvider.getConnection();
if(connection == null || !connection.isAuthenticated())
return null;
Iterator<ServerStoredDetails.GenericDetail> iter =
infoRetreiver.getDetails(contact.getAddress(),
ServerStoredDetails.ImageDetail.class);
VCard card = new VCard();
card.load(connection, contact.getAddress());
result = card.getAvatar();
if(iter.hasNext())
{
ServerStoredDetails.ImageDetail imgDetail =
(ServerStoredDetails.ImageDetail)iter.next();
result = imgDetail.getBytes();
}
if(result == null)
{

@ -368,6 +368,12 @@ public abstract class ProtocolProviderFactory
public static final String AUTO_DISCOVER_JINGLE_NODES
= "AUTO_DISCOVER_JINGLE_NODES";
/**
* Indicates if JingleNodes should use buddies to search for nodes.
*/
public static final String JINGLE_NODES_SEARCH_BUDDIES
= "JINGLE_NODES_SEARCH_BUDDIES";
/**
* Indicates if UPnP should be used with ICE.
*/

Loading…
Cancel
Save