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; ...@@ -15,6 +15,7 @@ import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException; import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.wildfire.ClientSession; import org.jivesoftware.wildfire.ClientSession;
import org.jivesoftware.wildfire.SessionManager; import org.jivesoftware.wildfire.SessionManager;
import org.jivesoftware.wildfire.XMPPServer; import org.jivesoftware.wildfire.XMPPServer;
...@@ -71,6 +72,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -71,6 +72,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
this.jid = jid; this.jid = jid;
this.componentManager = componentManager; this.componentManager = componentManager;
sessionManager.startThreadManager(jid); 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 ...@@ -111,6 +120,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
*/ */
public TransportType transportType = null; 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_INFO = "http://jabber.org/protocol/disco#info";
private final String DISCO_ITEMS = "http://jabber.org/protocol/disco#items"; private final String DISCO_ITEMS = "http://jabber.org/protocol/disco#items";
private final String IQ_GATEWAY = "jabber:iq:gateway"; private final String IQ_GATEWAY = "jabber:iq:gateway";
...@@ -1045,11 +1059,18 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -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. // 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"); 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 // Ok, we should now have only new items from the legacy roster
for (TransportBuddy buddy : legacymap.values()) { for (TransportBuddy buddy : legacymap.values()) {
//Log.debug("ROSTERSYNC: We have new, adding " + buddy.getName()); //Log.debug("ROSTERSYNC: We have new, adding " + buddy.getName());
...@@ -1102,20 +1123,21 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -1102,20 +1123,21 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
registrationManager.createRegistration(jid, this.transportType, username, password, nickname); registrationManager.createRegistration(jid, this.transportType, username, password, nickname);
} }
// Clean up any leftover roster items from other transports. // Clean up any leftover roster items from other transports.
try { try {
cleanUpRoster(jid, true); cleanUpRoster(jid, false);
} }
catch (UserNotFoundException ee) { catch (UserNotFoundException ee) {
throw new UserNotFoundException("Unable to find roster."); throw new UserNotFoundException("Unable to find roster.");
} }
try { // Check if the user is logged in to auto-log them in
addOrUpdateRosterItem(jid, this.getJID(), this.getDescription(), "Transports"); SessionManager sessionManager = SessionManager.getInstance();
String user = jid.getNode();
if (sessionManager.getSessionCount(user) > 0) {
for (ClientSession cSession : sessionManager.getSessions(user)) {
presenceChanged(cSession, cSession.getPresence());
} }
catch (UserNotFoundException e) {
throw new UserNotFoundException("User not registered with server.");
} }
} }
...@@ -1246,11 +1268,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -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) * @see org.jivesoftware.wildfire.roster.RosterEventListener#contactUpdated(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/ */
public void contactUpdated(Roster roster, RosterItem item) { public void contactUpdated(Roster roster, RosterItem item) {
Log.debug(getType().toString()+": contactUpdated "+roster.getUsername()+":"+item.getJid());
if (!item.getJid().getDomain().equals(this.getJID().getDomain())) { if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// Not ours, not our problem. // Not ours, not our problem.
return; return;
} }
Log.debug(getType().toString()+": contactUpdated "+roster.getUsername()+":"+item.getJid());
if (item.getJid().getNode() == null) { if (item.getJid().getNode() == null) {
// Gateway itself, don't care. // Gateway itself, don't care.
return; return;
...@@ -1270,11 +1292,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -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) * @see org.jivesoftware.wildfire.roster.RosterEventListener#contactAdded(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/ */
public void contactAdded(Roster roster, RosterItem item) { public void contactAdded(Roster roster, RosterItem item) {
Log.debug(getType().toString()+": contactAdded "+roster.getUsername()+":"+item.getJid());
if (!item.getJid().getDomain().equals(this.getJID().getDomain())) { if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// Not ours, not our problem. // Not ours, not our problem.
return; return;
} }
Log.debug(getType().toString()+": contactAdded "+roster.getUsername()+":"+item.getJid());
if (item.getJid().getNode() == null) { if (item.getJid().getNode() == null) {
// Gateway itself, don't care. // Gateway itself, don't care.
return; return;
...@@ -1294,11 +1316,11 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -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) * @see org.jivesoftware.wildfire.roster.RosterEventListener#contactDeleted(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/ */
public void contactDeleted(Roster roster, RosterItem item) { 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()); 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) { // if (item.getJid().getNode() == null) {
// // TODO: The gateway itself was removed? // // TODO: The gateway itself was removed?
// return; // return;
......
...@@ -161,6 +161,32 @@ public class TransportInstance implements PropertyEventListener { ...@@ -161,6 +161,32 @@ public class TransportInstance implements PropertyEventListener {
running = false; 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. * Retrieves actual transport associated with this instance.
* *
...@@ -195,6 +221,19 @@ public class TransportInstance implements PropertyEventListener { ...@@ -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 { ...@@ -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