Commit 011d1433 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-33] Fixed problem with buddies being removed. Wasn't tracking group list properly.

Hopefully catching an exception when offline messages are sent after user disconnects.
Upgraded JML to fix problem receiving messages that have no formatting. (not connecting right though...
Downgraded commons-logging.jar and cindy.jar to keep with jml 'approved' version for the moment.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5390 b35dd754-fafc-0310-a699-88a17e54d16e
parent fa5bb3be
......@@ -23,7 +23,6 @@ import org.jivesoftware.wildfire.roster.Roster;
import org.jivesoftware.wildfire.user.UserAlreadyExistsException;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
......@@ -317,7 +316,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
if (packet.getType() == Presence.Type.probe) {
// Presence probe, lets try to tell them.
session.retrieveContactStatus(packet.getTo());
session.retrieveContactStatus(to);
}
else if (packet.getType() == Presence.Type.subscribe) {
// User wants to add someone to their legacy roster.
......@@ -559,7 +558,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
if (nickEl != null) {
nickname = nickEl.getTextTrim();
}
username = (username == null || username.equals("")) ? null : username;
password = (password == null || password.equals("")) ? null : password;
nickname = (nickname == null || nickname.equals("")) ? null : nickname;
......@@ -1133,7 +1132,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
catch (UserNotFoundException ee) {
throw new UserNotFoundException("Unable to find roster.");
}
try {
addOrUpdateRosterItem(jid, this.getJID(), this.getDescription(), "Transports");
}
......@@ -1239,7 +1238,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
try {
this.componentManager.sendPacket(this, packet);
}
catch (ComponentException e) {
catch (Exception e) {
Log.error("Failed to deliver packet: " + packet.toString());
}
}
......@@ -1304,18 +1303,17 @@ public abstract class BaseTransport implements Component, RosterEventListener {
* @see org.jivesoftware.wildfire.roster.RosterEventListener#contactDeleted(org.jivesoftware.wildfire.roster.Roster, org.jivesoftware.wildfire.roster.RosterItem)
*/
public void contactDeleted(Roster roster, RosterItem item) {
// TODO: This is hella dangerous and I need to reevaluate it.
// if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// // Not ours, not our problem.
// return;
// }
// try {
// TransportSession session = sessionManager.getSession(roster.getUsername());
// session.removeContact(item);
// }
// catch (NotFoundException e) {
// //
// }
if (!item.getJid().getDomain().equals(this.getJID().getDomain())) {
// Not ours, not our problem.
return;
}
try {
TransportSession session = sessionManager.getSession(roster.getUsername());
session.removeContact(item);
}
catch (NotFoundException e) {
// TODO: Should maybe do something about this
}
}
/**
......
......@@ -48,7 +48,7 @@ public class MSNSession extends TransportSession {
super(registration, jid, transport, priority);
msnMessenger = MsnMessengerFactory.createMsnMessenger(registration.getUsername(), registration.getPassword());
msnMessenger.setSupportedProtocol(new MsnProtocol[] { MsnProtocol.MSNP12 });
msnMessenger.setSupportedProtocol(new MsnProtocol[] { MsnProtocol.MSNP11 });
}
/**
......@@ -80,8 +80,8 @@ public class MSNSession extends TransportSession {
public void logIn(PresenceType presenceType, String verboseStatus) {
if (!this.isLoggedIn()) {
msnMessenger.getOwner().setInitStatus(((MSNTransport)getTransport()).convertJabStatusToMSN(presenceType));
msnMessenger.setLogIncoming(false);
msnMessenger.setLogOutgoing(false);
msnMessenger.setLogIncoming(true);
msnMessenger.setLogOutgoing(true);
msnMessenger.addListener(new MSNListener(this));
msnMessenger.login();
}
......
......@@ -96,7 +96,59 @@ public class LoginConnection extends BaseFlapConnection {
if (ar.getErrorUrl() != null) {
Log.error("Error URL: " + ar.getErrorUrl());
}
} else {
String errormsg;
switch (error) {
case (AuthResponse.ERROR_ACCOUNT_DELETED): {
errormsg = "This account has been deleted.";
break;
}
case (AuthResponse.ERROR_BAD_INPUT): {
errormsg = "Illegal screen name/uin specified.";
break;
}
case (AuthResponse.ERROR_BAD_PASSWORD): {
errormsg = "Incorrect password specified.";
break;
}
case (AuthResponse.ERROR_CLIENT_TOO_OLD): {
errormsg = "Plugin is identifying itself as too old of a client. Please contact the develop.";
break;
}
case (AuthResponse.ERROR_CONNECTING_TOO_MUCH_A):
case (AuthResponse.ERROR_CONNECTING_TOO_MUCH_B): {
errormsg = "You have connected too many times in too short of a time frame. Please wait around 15 minutes before trying again.";
break;
}
case (AuthResponse.ERROR_INVALID_SN_OR_PASS_A):
case (AuthResponse.ERROR_INVALID_SN_OR_PASS_B): {
errormsg = "Invalid screen name or password specified. Please re-register with a valid screen name and password.";
break;
}
case (AuthResponse.ERROR_SIGNON_BLOCKED): {
errormsg = "Your account has been temporarily suspended.";
break;
}
default: {
errormsg = "Unknown error code returned from AIM: "+error+"\nURL: "+ar.getErrorUrl();
}
}
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(getMainSession().getJID());
m.setFrom(getMainSession().getTransport().getJID());
m.setBody(errormsg);
getMainSession().getTransport().sendPacket(m);
}
else {
loggedin = true;
oscarSession.startBosConn(ar.getServer(), ar.getPort(), ar.getCookie());
Log.info("OSCAR connection to " + ar.getServer() + ":"
......
......@@ -120,7 +120,7 @@ public class OSCARSession extends TransportSession {
*/
public Integer getGroupIdOrCreateNew(String groupName) {
for (GroupItem g : groups.values()) {
if (groupName.equals(g.getGroupName())) {
if (groupName.equalsIgnoreCase(g.getGroupName())) {
return g.getId();
}
}
......@@ -129,8 +129,7 @@ public class OSCARSession extends TransportSession {
Integer newGroupId = highestGroupId + 1;
GroupItem newGroup = new GroupItem(groupName, newGroupId);
request(new CreateItemsCmd(newGroup.toSsiItem()));
highestGroupId = newGroupId;
groups.put(newGroupId, newGroup);
gotGroup(newGroup);
return newGroupId;
}
......@@ -147,6 +146,7 @@ public class OSCARSession extends TransportSession {
if (grouplist.isEmpty()) {
grouplist.add("Transport Buddies");
}
Log.debug("contact = "+contact+", grouplist = "+grouplist);
// First, lets take the known good list of groups and sync things up server side.
for (String group : grouplist) {
Integer groupId = getGroupIdOrCreateNew(group);
......@@ -155,29 +155,31 @@ public class OSCARSession extends TransportSession {
if (highestBuddyIdPerGroup.containsKey(groupId)) {
newBuddyId = highestBuddyIdPerGroup.get(groupId) + 1;
}
highestBuddyIdPerGroup.put(groupId, newBuddyId);
BuddyItem newBuddy = new BuddyItem(contact, newBuddyId, groupId);
BuddyItem newBuddy = new BuddyItem(contact, groupId, newBuddyId);
newBuddy.setAlias(nickname);
request(new CreateItemsCmd(newBuddy.toSsiItem()));
buddies.put(groupId+"."+newBuddyId, newBuddy);
gotBuddy(newBuddy);
}
// Now, lets clean up any groups this contact should no longer be a member of.
for (BuddyItem buddy : buddies.values()) {
if (buddy.getScreenname().equals(contact)) {
if (buddy.getScreenname().equalsIgnoreCase(contact)) {
if (buddy.getGroupId() == 0) {
// Ok this group is the "main group", which we can cheerfully remove from.
Log.debug("Removing "+buddy+" because of in main group");
request(new DeleteItemsCmd(buddy.toSsiItem()));
buddies.remove(buddy.getGroupId()+"."+buddy.getId());
buddies.remove(""+buddy.getGroupId()+"."+buddy.getId());
}
else if (!groups.contains(buddy.getGroupId())) {
else if (!groups.containsKey(buddy.getGroupId())) {
// Well this is odd, a group we don't know about? Nuke it.
Log.debug("Removing "+buddy+" because of unknown group");
request(new DeleteItemsCmd(buddy.toSsiItem()));
buddies.remove(buddy.getGroupId()+"."+buddy.getId());
buddies.remove(""+buddy.getGroupId()+"."+buddy.getId());
}
else if (!grouplist.contains(groups.get(buddy.getGroupId()).getGroupName())) {
Log.debug("Removing "+buddy+" because not in list of groups");
request(new DeleteItemsCmd(buddy.toSsiItem()));
buddies.remove(buddy.getGroupId()+"."+buddy.getId());
buddies.remove(""+buddy.getGroupId()+"."+buddy.getId());
}
else {
if (!buddy.getAlias().equals(nickname)) {
......@@ -193,6 +195,7 @@ public class OSCARSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.jivesoftware.wildfire.roster.RosterItem)
*/
public void addContact(RosterItem item) {
Log.debug("Add contact: "+item.getJid());
String legacyId = getTransport().convertJIDToID(item.getJid());
String nickname = item.getNickname();
if (nickname == null || nickname.equals("")) {
......@@ -207,11 +210,12 @@ public class OSCARSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.jivesoftware.wildfire.roster.RosterItem)
*/
public void removeContact(RosterItem item) {
Log.debug("Remove contact: "+item.getJid());
String legacyId = getTransport().convertJIDToID(item.getJid());
for (BuddyItem i : buddies.values()) {
if (i.getScreenname().equals(legacyId)) {
if (i.getScreenname().equalsIgnoreCase(legacyId)) {
request(new DeleteItemsCmd(i.toSsiItem()));
buddies.remove(i.getGroupId()+"."+i.getId());
buddies.remove(""+i.getGroupId()+"."+i.getId());
}
}
}
......@@ -220,6 +224,7 @@ public class OSCARSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateContact(org.jivesoftware.wildfire.roster.RosterItem)
*/
public void updateContact(RosterItem item) {
Log.debug("Update contact: "+item.getJid());
String legacyId = getTransport().convertJIDToID(item.getJid());
String nickname = item.getNickname();
if (nickname == null || nickname.equals("")) {
......@@ -348,9 +353,9 @@ public class OSCARSession extends TransportSession {
*/
void gotBuddy(BuddyItem buddy) {
Log.debug("Found buddy item: " + buddy.toString() + " at id " + buddy.getId());
buddies.put(buddy.getGroupId()+"."+buddy.getId(), buddy);
buddies.put(""+buddy.getGroupId()+"."+buddy.getId(), buddy);
if (!highestBuddyIdPerGroup.containsKey(buddy.getGroupId())) {
highestBuddyIdPerGroup.put(buddy.getGroupId(), -1);
highestBuddyIdPerGroup.put(buddy.getGroupId(), 0);
}
if (buddy.getId() > highestBuddyIdPerGroup.get(buddy.getGroupId())) {
highestBuddyIdPerGroup.put(buddy.getGroupId(), buddy.getId());
......@@ -366,7 +371,7 @@ public class OSCARSession extends TransportSession {
Log.debug("Found group item: " + group.toString() + " at id " + group.getId());
groups.put(group.getId(), group);
if (!highestBuddyIdPerGroup.containsKey(group.getId())) {
highestBuddyIdPerGroup.put(group.getId(), -1);
highestBuddyIdPerGroup.put(group.getId(), 0);
}
if (group.getId() > highestGroupId) {
highestGroupId = group.getId();
......@@ -387,11 +392,11 @@ public class OSCARSession extends TransportSession {
}
int groupid = buddy.getGroupId();
String groupname = "Buddies";
String groupname = "Transport Buddies";
if (groups.containsKey(groupid)) {
groupname = groups.get(groupid).getGroupName();
if (groupname.length() < 1) {
groupname = "Buddies";
groupname = "Transport Buddies";
}
}
......@@ -411,7 +416,9 @@ public class OSCARSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*/
public void retrieveContactStatus(JID jid) {
bosConn.getAndSendStatus(getTransport().convertJIDToID(jid));
if (bosConn != null) {
bosConn.getAndSendStatus(getTransport().convertJIDToID(jid));
}
}
private static final List<CapabilityBlock> MY_CAPS = Arrays.asList(new CapabilityBlock[] {
......@@ -441,7 +448,9 @@ public class OSCARSession extends TransportSession {
* @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID)
*/
public void resendContactStatuses(JID jid) {
bosConn.getAndSendAllStatuses(jid);
if (bosConn != null) {
bosConn.getAndSendAllStatuses(jid);
}
}
}
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