Commit 4a9e6f68 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Do not send unavailable presence when unsubscribing from a contact but a...

Do not send unavailable presence when unsubscribing from a contact but a directed presence was sent before. JM-475

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@3128 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1d8521c9
/** /**
* $RCSfile$ * $RCSfile: PresenceManagerImpl.java,v $
* $Revision$ * $Revision$
* $Date$ * $Date$
* *
...@@ -15,6 +15,7 @@ import org.dom4j.Document; ...@@ -15,6 +15,7 @@ import org.dom4j.Document;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.handler.PresenceUpdateHandler;
import org.jivesoftware.messenger.component.InternalComponentManager; import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
...@@ -49,6 +50,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager ...@@ -49,6 +50,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager
private SessionManager sessionManager; private SessionManager sessionManager;
private XMPPServer server; private XMPPServer server;
private PacketDeliverer deliverer; private PacketDeliverer deliverer;
private PresenceUpdateHandler presenceUpdateHandler;
private InternalComponentManager componentManager; private InternalComponentManager componentManager;
...@@ -333,6 +335,10 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager ...@@ -333,6 +335,10 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager
public void sendUnavailableFromSessions(JID recipientJID, JID userJID) { public void sendUnavailableFromSessions(JID recipientJID, JID userJID) {
if (userJID.getNode() != null && !"".equals(userJID.getNode())) { if (userJID.getNode() != null && !"".equals(userJID.getNode())) {
for (ClientSession session : sessionManager.getSessions(userJID.getNode())) { for (ClientSession session : sessionManager.getSessions(userJID.getNode())) {
// Do not send an unavailable presence if the user sent a direct available presence
if (presenceUpdateHandler.hasDirectPresence(session, recipientJID)) {
continue;
}
Presence presencePacket = new Presence(); Presence presencePacket = new Presence();
presencePacket.setType(Presence.Type.unavailable); presencePacket.setType(Presence.Type.unavailable);
presencePacket.setFrom(session.getAddress()); presencePacket.setFrom(session.getAddress());
...@@ -356,6 +362,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager ...@@ -356,6 +362,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager
this.server = server; this.server = server;
deliverer = server.getPacketDeliverer(); deliverer = server.getPacketDeliverer();
sessionManager = server.getSessionManager(); sessionManager = server.getSessionManager();
presenceUpdateHandler = server.getPresenceUpdateHandler();
} }
public Component getPresenceComponent(JID probee) { public Component getPresenceComponent(JID probee) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment