Commit 5f21472e authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-55] Transports are no longer in user rosters unless legacymode is...

[GATE-55] Transports are no longer in user rosters unless legacymode is enabled via system properties.
[GATE-105] Checking for login status after registration occurs.
Added WEB-INF directory for future ajax stuff.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5924 b35dd754-fafc-0310-a699-88a17e54d16e
parent bda22935
......@@ -15,6 +15,7 @@ import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.wildfire.ClientSession;
import org.jivesoftware.wildfire.SessionManager;
import org.jivesoftware.wildfire.XMPPServer;
......@@ -71,6 +72,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
this.jid = jid;
this.componentManager = componentManager;
sessionManager.startThreadManager(jid);
legacyMode = JiveGlobals.getBooleanProperty("plugin.gateway.legacymode", false);
}
/**
* Sets legacy roster mode for the transport.
*/
public void setLegacyMode(boolean mode) {
this.legacyMode = mode;
}
/**
......@@ -111,6 +120,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
*/
public TransportType transportType = null;
/**
* Legacy roster mode enabled or disabled.
*/
public boolean legacyMode = false;
private final String DISCO_INFO = "http://jabber.org/protocol/disco#info";
private final String DISCO_ITEMS = "http://jabber.org/protocol/disco#items";
private final String IQ_GATEWAY = "jabber:iq:gateway";
......@@ -1045,11 +1059,18 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
}
}
if (!hasTransport) {
if (!hasTransport && legacyMode) {
// This person doesn't have the transport in their roster, lets put it there.
// We only do this if we are in legacy mode. Otherwise, no transports in roster.
this.addOrUpdateRosterItem(userjid, this.getJID(), this.getDescription(), "Transports");
}
if (hasTransport && !legacyMode) {
// We are not in legacy mode but this person has the transport in their roster.
// Ditch it.
this.removeFromRoster(userjid, this.getJID());
}
// Ok, we should now have only new items from the legacy roster
for (TransportBuddy buddy : legacymap.values()) {
//Log.debug("ROSTERSYNC: We have new, adding " + buddy.getName());
......@@ -1102,20 +1123,21 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
registrationManager.createRegistration(jid, this.transportType, username, password, nickname);
}
// Clean up any leftover roster items from other transports.
try {
cleanUpRoster(jid, true);
cleanUpRoster(jid, false);
}
catch (UserNotFoundException ee) {
throw new UserNotFoundException("Unable to find roster.");
}
try {
addOrUpdateRosterItem(jid, this.getJID(), this.getDescription(), "Transports");
}
catch (UserNotFoundException e) {
throw new UserNotFoundException("User not registered with server.");
// Check if the user is logged in to auto-log them in
SessionManager sessionManager = SessionManager.getInstance();
String user = jid.getNode();
if (sessionManager.getSessionCount(user) > 0) {
for (ClientSession cSession : sessionManager.getSessions(user)) {
presenceChanged(cSession, cSession.getPresence());
}
}
}
......@@ -1246,11 +1268,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
* @see org.jivesoftware.wildfire.roster.RosterEventListener#contactUpdated(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/
public void contactUpdated(Roster roster, RosterItem item) {
Log.debug(getType().toString()+": contactUpdated "+roster.getUsername()+":"+item.getJid());
if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// Not ours, not our problem.
return;
}
Log.debug(getType().toString()+": contactUpdated "+roster.getUsername()+":"+item.getJid());
if (item.getJid().getNode() == null) {
// Gateway itself, don't care.
return;
......@@ -1270,11 +1292,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
* @see org.jivesoftware.wildfire.roster.RosterEventListener#contactAdded(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/
public void contactAdded(Roster roster, RosterItem item) {
Log.debug(getType().toString()+": contactAdded "+roster.getUsername()+":"+item.getJid());
if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// Not ours, not our problem.
return;
}
Log.debug(getType().toString()+": contactAdded "+roster.getUsername()+":"+item.getJid());
if (item.getJid().getNode() == null) {
// Gateway itself, don't care.
return;
......@@ -1294,11 +1316,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
* @see org.jivesoftware.wildfire.roster.RosterEventListener#contactDeleted(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/
public void contactDeleted(Roster roster, RosterItem item) {
if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// Not ours, not our problem.
return;
}
Log.debug(getType().toString()+": contactDeleted "+roster.getUsername()+":"+item.getJid());
// if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// // Not ours, not our problem.
// return;
// }
// if (item.getJid().getNode() == null) {
// // TODO: The gateway itself was removed?
// return;
......
......@@ -161,6 +161,32 @@ public class TransportInstance implements PropertyEventListener {
running = false;
}
/**
* Enables legacy roster mode on the transport.
*/
public void enableLegacyMode() {
if (!running || transport == null) {
return;
}
Log.info("Enabling legacy mode: "+type.toString());
transport.setLegacyMode(true);
}
/**
* Disables legacy roster mode on the transport.
*/
public void disableLegacyMode() {
if (!running || transport == null) {
return;
}
Log.info("Disabling legacy mode: "+type.toString());
transport.setLegacyMode(false);
}
/**
* Retrieves actual transport associated with this instance.
*
......@@ -195,6 +221,19 @@ public class TransportInstance implements PropertyEventListener {
}
}
}
else if (property.equals("plugin.gateway.legacymode")) {
enabled = Boolean.parseBoolean((String)params.get("value"));
if (enabled) {
if (!running) {
enableLegacyMode();
}
}
else {
if (running) {
disableLegacyMode();
}
}
}
}
}
......@@ -215,6 +254,11 @@ public class TransportInstance implements PropertyEventListener {
}
}
}
else if (property.equals("plugin.gateway.legacymode")) {
if (running) {
disableLegacyMode();
}
}
}
}
......
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