Jabber fix accepting subscription request in other client while waiting for authorization approval by user.

cusax-fix
Damian Minkov 16 years ago
parent a51ac61aca
commit 2ca42660f6

@ -995,45 +995,54 @@ public void processPacket(Packet packet)
return;
Presence.Type presenceType = presence.getType();
String fromID = presence.getFrom();
final String fromID = presence.getFrom();
if (presenceType == Presence.Type.subscribe)
{
if (logger.isTraceEnabled())
logger.trace(fromID + " wants to add you to its contact list");
// run waiting for user response in different thread
// as this seems to block the packet dispatch thread
// and we don't receive anything till we unblock it
new Thread(new Runnable() {
public void run()
{
if (logger.isTraceEnabled())
logger.trace(fromID + " wants to add you to its contact list");
// buddy want to add you to its roster
ContactJabberImpl srcContact
= ssContactList.findContactById(fromID);
// buddy want to add you to its roster
ContactJabberImpl srcContact
= ssContactList.findContactById(fromID);
if(srcContact == null)
srcContact = createVolatileContact(fromID);
if(srcContact == null)
srcContact = createVolatileContact(fromID);
AuthorizationRequest req = new AuthorizationRequest();
AuthorizationResponse response
= handler.processAuthorisationRequest(req, srcContact);
Presence.Type responsePresenceType;
AuthorizationRequest req = new AuthorizationRequest();
AuthorizationResponse response
= handler.processAuthorisationRequest(req, srcContact);
Presence.Type responsePresenceType;
if(response != null
&& response.getResponseCode()
.equals(AuthorizationResponse.ACCEPT))
{
responsePresenceType = Presence.Type.subscribed;
if (logger.isInfoEnabled())
logger.info("Sending Accepted Subscription");
}
else
{
responsePresenceType = Presence.Type.unsubscribed;
if (logger.isInfoEnabled())
logger.info("Sending Rejected Subscription");
}
if(response != null
&& response.getResponseCode()
.equals(AuthorizationResponse.ACCEPT))
{
responsePresenceType = Presence.Type.subscribed;
if (logger.isInfoEnabled())
logger.info("Sending Accepted Subscription");
}
else
{
responsePresenceType = Presence.Type.unsubscribed;
if (logger.isInfoEnabled())
logger.info("Sending Rejected Subscription");
}
Presence responsePacket = new Presence(responsePresenceType);
Presence responsePacket = new Presence(responsePresenceType);
responsePacket.setTo(fromID);
parentProvider.getConnection().sendPacket(responsePacket);
responsePacket.setTo(fromID);
parentProvider.getConnection().sendPacket(responsePacket);
}
}
).start();
}
else if (presenceType == Presence.Type.unsubscribed)
{

@ -72,6 +72,9 @@ public class ServerStoredContactListJabberImpl
*/
private ImageRetriever imageRetriever = null;
/**
* Listens for roster changes.
*/
private ChangeListener rosterChangeListener = null;
/**
@ -883,12 +886,28 @@ public void entriesAdded(Collection<String> addresses)
ContactJabberImpl contact =
findContactById(entry.getUser());
if(contact != null)
if(contact != null && contact.isPersistent())
{
contact.setResolved(entry);
continue;
}
else
{
ContactGroup oldParentGroup =
contact.getParentContactGroup();
// if contact is in not in contact list
// we must remove it from there in order to correctlly
// process adding contact
// this happens if we accept subscribe request
// not from sip-communicator
if(oldParentGroup instanceof ContactGroupJabberImpl
&& !oldParentGroup.isPersistent())
{
((ContactGroupJabberImpl)oldParentGroup)
.removeContact(contact);
fireContactRemoved(oldParentGroup, contact);
}
}
contact = new ContactJabberImpl(roster.getEntry(id),
ServerStoredContactListJabberImpl.this,
true,

Loading…
Cancel
Save