Commit b8535cad authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Better handling of yahoo incoming mail messages. Improvements to resource handling.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5070 b35dd754-fafc-0310-a699-88a17e54d16e
parent 58cd4842
Gateway Plugin
Main Todo List:
- Use threads for transport sessions
- DB files for other DB types
- Add/remove buddies from legacy contact list
- AIM/ICQ is not pulling entire buddy list?
- Add support for nicknames for Yahoo [not server stored like others]
- AIM/ICQ may be leaving you logged in after disconnect, not sure yet
- Add access restriction support
- Add handling of options from web interface
- MSN doesn't know the status of other contacts upon login
Future Todo List:
- Buddy icons
- File transfer
- MUC/Groupchat support
- Typing notifications
...@@ -196,13 +196,25 @@ public abstract class BaseTransport implements Component { ...@@ -196,13 +196,25 @@ public abstract class BaseTransport implements Component {
// This packet is to the transport itself. // This packet is to the transport itself.
if (packet.getType() == null) { if (packet.getType() == null) {
// User has come online. // A user's resource has come online.
TransportSession session; TransportSession session;
try { try {
session = sessionManager.getSession(from); session = sessionManager.getSession(from);
// Well, this could represent a status change. if (session.hasResource(from.getResource())) {
session.updateStatus(getPresenceType(packet), packet.getStatus()); // Well, this could represent a status change.
session.updateStatus(getPresenceType(packet), packet.getStatus());
}
else {
// This is a new resource, lets send them what we know.
session.addResource(from.getResource(), packet.getPriority());
// Tell the new resource what the state of their buddy list is.
session.resendContactStatuses(from);
// If this priority is the highest, treat it's status as golden
if (session.isHighestPriority(from.getResource())) {
session.updateStatus(getPresenceType(packet), packet.getStatus());
}
}
} }
catch (NotFoundException e) { catch (NotFoundException e) {
// TODO: TEMPORARY: Since we are using shared groups now, we will clean up our testers rosters for them. // TODO: TEMPORARY: Since we are using shared groups now, we will clean up our testers rosters for them.
...@@ -214,22 +226,42 @@ public abstract class BaseTransport implements Component { ...@@ -214,22 +226,42 @@ public abstract class BaseTransport implements Component {
} }
session = this.registrationLoggedIn(registration, from, getPresenceType(packet), packet.getStatus(), packet.getPriority()); session = this.registrationLoggedIn(registration, from, getPresenceType(packet), packet.getStatus(), packet.getPriority());
//sessionManager.storeSession(registration.getJID(), session);
sessionManager.storeSession(from, session); sessionManager.storeSession(from, session);
} }
} }
else if (packet.getType() == Presence.Type.unavailable) { else if (packet.getType() == Presence.Type.unavailable) {
// User has gone offline. // A user's resource has gone offline.
TransportSession session; TransportSession session;
try { try {
session = sessionManager.getSession(from); session = sessionManager.getSession(from);
if (session.isLoggedIn()) { if (session.getResourceCount() > 1) {
this.registrationLoggedOut(session); String resource = from.getResource();
// Just one of the resources, lets adjust accordingly.
if (session.isHighestPriority(resource)) {
// Ooh, the highest resource went offline, drop to next highest.
session.removeResource(resource);
// Lets ask the next highest resource what it's presence is.
Presence p = new Presence(Presence.Type.probe);
p.setTo(session.getJIDWithHighestPriority());
p.setFrom(this.getJID());
sendPacket(p);
}
else {
// Meh, lower priority, big whoop.
session.removeResource(resource);
}
} }
else {
// No more resources, byebye.
if (session.isLoggedIn()) {
this.registrationLoggedOut(session);
}
//sessionManager.removeSession(registration.getJID()); sessionManager.removeSession(from);
sessionManager.removeSession(from); }
} }
catch (NotFoundException e) { catch (NotFoundException e) {
Log.debug("Ignoring unavailable presence for inactive seession."); Log.debug("Ignoring unavailable presence for inactive seession.");
......
...@@ -142,6 +142,26 @@ public abstract class TransportSession implements Runnable { ...@@ -142,6 +142,26 @@ public abstract class TransportSession implements Runnable {
return new JID(jid.getNode(),jid.getDomain(),resources.get(resources.lastKey())); return new JID(jid.getNode(),jid.getDomain(),resources.get(resources.lastKey()));
} }
/**
* Given a resource, returns whether it's priority is the highest.
*
* @param resource Resource to be checked.
* @return True or false if the resource is the highest priority.
*/
public Boolean isHighestPriority(String resource) {
return (resources.get(resources.lastKey()).equals(resource));
}
/**
* Given a resource, returns whether the resource is currently associated with this session.
*
* @param resource Resource to be checked.
* @return True of false if the resource is associated with this session.
*/
public Boolean hasResource(String resource) {
return (resources.containsValue(resource));
}
/** /**
* Handles monitoring of whether session is still valid. * Handles monitoring of whether session is still valid.
*/ */
......
...@@ -83,12 +83,14 @@ public class YahooSessionListener implements SessionListener { ...@@ -83,12 +83,14 @@ public class YahooSessionListener implements SessionListener {
* @see ymsg.network.event.SessionListener#newMailReceived(ymsg.network.event.SessionNewMailEvent) * @see ymsg.network.event.SessionListener#newMailReceived(ymsg.network.event.SessionNewMailEvent)
*/ */
public void newMailReceived(SessionNewMailEvent event) { public void newMailReceived(SessionNewMailEvent event) {
Message m = new Message(); if (event.getMailCount() > 0) {
m.setType(Message.Type.headline); Message m = new Message();
m.setTo(yahooSession.getJIDWithHighestPriority()); m.setType(Message.Type.headline);
m.setFrom(yahooSession.getTransport().getJID()); m.setTo(yahooSession.getJIDWithHighestPriority());
m.setBody("You have "+event.getMailCount()+" message(s) waiting in your Yahoo! mail."); m.setFrom(yahooSession.getTransport().getJID());
yahooSession.getTransport().sendPacket(m); m.setBody("You have "+event.getMailCount()+" message(s) waiting in your Yahoo! mail.");
yahooSession.getTransport().sendPacket(m);
}
} }
/** /**
......
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