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,14 +196,26 @@ public abstract class BaseTransport implements Component {
// This packet is to the transport itself.
if (packet.getType() == null) {
// User has come online.
// A user's resource has come online.
TransportSession session;
try {
session = sessionManager.getSession(from);
if (session.hasResource(from.getResource())) {
// 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) {
// TODO: TEMPORARY: Since we are using shared groups now, we will clean up our testers rosters for them.
try {
......@@ -214,23 +226,43 @@ public abstract class BaseTransport implements Component {
}
session = this.registrationLoggedIn(registration, from, getPresenceType(packet), packet.getStatus(), packet.getPriority());
//sessionManager.storeSession(registration.getJID(), session);
sessionManager.storeSession(from, session);
}
}
else if (packet.getType() == Presence.Type.unavailable) {
// User has gone offline.
// A user's resource has gone offline.
TransportSession session;
try {
session = sessionManager.getSession(from);
if (session.getResourceCount() > 1) {
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);
}
}
catch (NotFoundException e) {
Log.debug("Ignoring unavailable presence for inactive seession.");
}
......
......@@ -142,6 +142,26 @@ public abstract class TransportSession implements Runnable {
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.
*/
......
......@@ -83,6 +83,7 @@ public class YahooSessionListener implements SessionListener {
* @see ymsg.network.event.SessionListener#newMailReceived(ymsg.network.event.SessionNewMailEvent)
*/
public void newMailReceived(SessionNewMailEvent event) {
if (event.getMailCount() > 0) {
Message m = new Message();
m.setType(Message.Type.headline);
m.setTo(yahooSession.getJIDWithHighestPriority());
......@@ -90,6 +91,7 @@ public class YahooSessionListener implements SessionListener {
m.setBody("You have "+event.getMailCount()+" message(s) waiting in your Yahoo! mail.");
yahooSession.getTransport().sendPacket(m);
}
}
/**
* @see ymsg.network.event.SessionListener#friendsUpdateReceived(ymsg.network.event.SessionFriendEvent)
......
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