Commit 1c0a31d0 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-55] More festive not-in-roster work. At this point I'm reasonably...

[GATE-55] More festive not-in-roster work.  At this point I'm reasonably confident that the listeners are doing the same work listening for presence packets was doing.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5788 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9a434fd3
...@@ -185,8 +185,13 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -185,8 +185,13 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
} }
} }
catch (NotFoundException e) { catch (NotFoundException e) {
// TODO: Should return an error packet here
Log.debug("Unable to find session."); Log.debug("Unable to find session.");
Message m = new Message();
m.setError(Condition.service_unavailable);
m.setTo(from);
m.setFrom(getJID());
m.setBody("You are not currently logged into the transport.");
reply.add(m);
} }
return reply; return reply;
...@@ -504,12 +509,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -504,12 +509,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
try { try {
this.addNewRegistration(from, username, password, nickname); this.addNewRegistration(from, username, password, nickname);
// Lets ask them what their presence is, maybe log // Lets check what their presence is, maybe log them in immediately.
// them in immediately. SessionManager sessionManager = SessionManager.getInstance();
Presence p = new Presence(Presence.Type.probe); String user = from.getNode();
p.setTo(from); if (sessionManager.getSessionCount(user) > 0) {
p.setFrom(to); for (ClientSession session : sessionManager.getSessions(user)) {
reply.add(p); availableSession(session, session.getPresence());
}
}
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
Log.error("Someone attempted to register with the gateway who is not registered with the server: " + from); Log.error("Someone attempted to register with the gateway who is not registered with the server: " + from);
...@@ -697,14 +704,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -697,14 +704,14 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
public void start() { public void start() {
RosterEventDispatcher.addListener(this); RosterEventDispatcher.addListener(this);
PresenceEventDispatcher.addListener(this); PresenceEventDispatcher.addListener(this);
// Probe all registered users [if they are logged in] to auto-log them in SessionManager sessionManager = SessionManager.getInstance();
// TODO: This is no longer going to work... need to find a way that doesn't involve presence packets or anything like that // Check all registered users to auto-log them in
for (Registration registration : registrationManager.getRegistrations()) { for (Registration registration : registrationManager.getRegistrations()) {
if (SessionManager.getInstance().getSessionCount(registration.getJID().getNode()) > 0) { String user = registration.getJID().getNode();
Presence p = new Presence(Presence.Type.probe); if (sessionManager.getSessionCount(user) > 0) {
p.setFrom(this.getJID()); for (ClientSession session : sessionManager.getSessions(user)) {
p.setTo(registration.getJID()); availableSession(session, session.getPresence());
sendPacket(p); }
} }
} }
} }
...@@ -871,11 +878,9 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -871,11 +878,9 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
} }
catch (UserAlreadyExistsException ee) { catch (UserAlreadyExistsException ee) {
Log.error("getRosterItem claims user exists, but couldn't find via getRosterItem?", ee); Log.error("getRosterItem claims user exists, but couldn't find via getRosterItem?", ee);
// TODO: Should we throw exception or something?
} }
catch (Exception ee) { catch (Exception ee) {
Log.error("Exception while creating roster item:", ee); Log.error("Exception while creating roster item:", ee);
// TODO: Should we throw exception or something?
} }
} }
} }
...@@ -941,7 +946,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -941,7 +946,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
} }
catch (Exception e) { catch (Exception e) {
Log.error("Error removing roster item: " + ri.toString(), e); Log.error("Error removing roster item: " + ri.toString(), e);
// TODO: Should we say something?
} }
} }
} }
...@@ -1015,7 +1019,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -1015,7 +1019,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
this.addOrUpdateRosterItem(userjid, buddy.getName(), buddy.getNickname(), buddy.getGroup()); this.addOrUpdateRosterItem(userjid, buddy.getName(), buddy.getNickname(), buddy.getGroup());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// TODO: Something is quite wrong if we see this.
Log.error("Failed updating roster item", e); Log.error("Failed updating roster item", e);
} }
legacymap.remove(jid); legacymap.remove(jid);
...@@ -1027,7 +1030,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -1027,7 +1030,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
this.removeFromRoster(userjid, jid); this.removeFromRoster(userjid, jid);
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// TODO: Something is quite wrong if we see this.
Log.error("Failed removing roster item", e); Log.error("Failed removing roster item", e);
} }
} }
...@@ -1040,7 +1042,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -1040,7 +1042,6 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
this.addOrUpdateRosterItem(userjid, buddy.getName(), buddy.getNickname(), buddy.getGroup()); this.addOrUpdateRosterItem(userjid, buddy.getName(), buddy.getNickname(), buddy.getGroup());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// TODO: Something is quite wrong if we see this.
Log.error("Failed adding new roster item", e); Log.error("Failed adding new roster item", e);
} }
} }
...@@ -1387,11 +1388,18 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -1387,11 +1388,18 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
// Ooh, the highest resource went offline, drop to next highest. // Ooh, the highest resource went offline, drop to next highest.
session.removeResource(resource); session.removeResource(resource);
// Lets ask the next highest resource what it's presence is. // Lets check the next highest resource for what it's presence is.
Presence p = new Presence(Presence.Type.probe); SessionManager sessionManager = SessionManager.getInstance();
p.setTo(session.getJIDWithHighestPriority()); String user = from.getNode();
p.setFrom(this.getJID()); String nextResource = session.getJIDWithHighestPriority().getResource();
sendPacket(p); if (sessionManager.getSessionCount(user) > 0) {
for (ClientSession cSession : sessionManager.getSessions(user)) {
Presence p = cSession.getPresence();
if (p.getFrom().getResource().equals(nextResource)) {
presenceChanged(cSession, cSession.getPresence());
}
}
}
} }
else { else {
Log.debug("A low priority resource (of multiple) has gone offline: " + from); Log.debug("A low priority resource (of multiple) has gone offline: " + from);
......
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