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

[GATE-113] Added support for retrieval of offline messages from ICQ.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7180 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6fe103bf
...@@ -18,6 +18,9 @@ import net.kano.joscar.flapcmd.*; ...@@ -18,6 +18,9 @@ import net.kano.joscar.flapcmd.*;
import net.kano.joscar.net.*; import net.kano.joscar.net.*;
import net.kano.joscar.snac.*; import net.kano.joscar.snac.*;
import net.kano.joscar.snaccmd.*; import net.kano.joscar.snaccmd.*;
import net.kano.joscar.snaccmd.icq.OfflineMsgIcqCmd;
import net.kano.joscar.snaccmd.icq.OfflineMsgDoneCmd;
import net.kano.joscar.snaccmd.icq.OfflineMsgIcqAckCmd;
import net.kano.joscar.snaccmd.conn.*; import net.kano.joscar.snaccmd.conn.*;
import net.kano.joscar.snaccmd.icbm.*; import net.kano.joscar.snaccmd.icbm.*;
import net.kano.joscar.snaccmd.loc.*; import net.kano.joscar.snaccmd.loc.*;
...@@ -132,5 +135,22 @@ public class BOSConnection extends BasicFlapConnection { ...@@ -132,5 +135,22 @@ public class BOSConnection extends BasicFlapConnection {
oscarSession.gotCompleteSSI(); oscarSession.gotCompleteSSI();
} }
} }
else if (cmd instanceof OfflineMsgIcqCmd) {
Log.debug("Found offline message:"+cmd);
OfflineMsgIcqCmd omic = (OfflineMsgIcqCmd)cmd;
String sn = String.valueOf(omic.getFromUIN());
//String msg = "Offline message sent at "+new Date(omic.getDate().getTime()).toString()+"\n"+OscarTools.stripHtml(omic.getContents()).trim();
String msg = "Offline message received:\n"+OscarTools.stripHtml(omic.getContents()).trim();
oscarSession.getTransport().sendMessage(
oscarSession.getJIDWithHighestPriority(),
oscarSession.getTransport().convertIDToJID(sn),
msg
);
}
else if (cmd instanceof OfflineMsgDoneCmd) {
request(new OfflineMsgIcqAckCmd(oscarSession.getUIN(), (int)oscarSession.nextIcqId()));
}
} }
} }
...@@ -15,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -15,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
import net.kano.joscar.ByteBlock; import net.kano.joscar.ByteBlock;
import net.kano.joscar.OscarTools; import net.kano.joscar.OscarTools;
import net.kano.joscar.SeqNum;
import net.kano.joscar.net.ConnDescriptor; import net.kano.joscar.net.ConnDescriptor;
import net.kano.joscar.flapcmd.SnacCommand; import net.kano.joscar.flapcmd.SnacCommand;
import net.kano.joscar.snac.SnacRequest; import net.kano.joscar.snac.SnacRequest;
...@@ -28,6 +29,7 @@ import net.kano.joscar.snaccmd.conn.ServiceRequest; ...@@ -28,6 +29,7 @@ import net.kano.joscar.snaccmd.conn.ServiceRequest;
import net.kano.joscar.snaccmd.loc.SetInfoCmd; import net.kano.joscar.snaccmd.loc.SetInfoCmd;
import net.kano.joscar.snaccmd.InfoData; import net.kano.joscar.snaccmd.InfoData;
import net.kano.joscar.snaccmd.CapabilityBlock; import net.kano.joscar.snaccmd.CapabilityBlock;
import net.kano.joscar.snaccmd.icq.OfflineMsgIcqRequest;
import net.kano.joscar.ssiitem.BuddyItem; import net.kano.joscar.ssiitem.BuddyItem;
import net.kano.joscar.ssiitem.GroupItem; import net.kano.joscar.ssiitem.GroupItem;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
...@@ -75,6 +77,9 @@ public class OSCARSession extends TransportSession { ...@@ -75,6 +77,9 @@ public class OSCARSession extends TransportSession {
private PresenceType presenceType = null; private PresenceType presenceType = null;
private String verboseStatus = null; private String verboseStatus = null;
private String propertyPrefix; private String propertyPrefix;
private static final String DEFAULT_AIM_GROUP = " "; // We're using 3 spaces to indicated main group, invalid in real aim
private static final String DEFAULT_ICQ_GROUP = "General";
private SeqNum icqSeqNum = new SeqNum(0, Integer.MAX_VALUE);
/** /**
* SSI tracking variables. * SSI tracking variables.
...@@ -172,7 +177,12 @@ public class OSCARSession extends TransportSession { ...@@ -172,7 +177,12 @@ public class OSCARSession extends TransportSession {
*/ */
public void syncContactGroupsAndNickname(String contact, String nickname, List<String> grouplist) { public void syncContactGroupsAndNickname(String contact, String nickname, List<String> grouplist) {
if (grouplist.isEmpty()) { if (grouplist.isEmpty()) {
grouplist.add(" "); // We're using 3 spaces to indicated main group, invalid in real aim if (transport.getType().equals(TransportType.icq)) {
grouplist.add(DEFAULT_ICQ_GROUP);
}
else {
grouplist.add(DEFAULT_AIM_GROUP);
}
} }
Log.debug("contact = "+contact+", grouplist = "+grouplist); Log.debug("contact = "+contact+", grouplist = "+grouplist);
// First, lets take the known good list of groups and add whatever is missing on the server. // First, lets take the known good list of groups and add whatever is missing on the server.
...@@ -192,7 +202,7 @@ public class OSCARSession extends TransportSession { ...@@ -192,7 +202,7 @@ public class OSCARSession extends TransportSession {
// Now, lets clean up any groups this contact should no longer be a member of. // Now, lets clean up any groups this contact should no longer be a member of.
for (BuddyItem buddy : buddies.values()) { for (BuddyItem buddy : buddies.values()) {
if (buddy.getScreenname().equalsIgnoreCase(contact)) { if (buddy.getScreenname().equalsIgnoreCase(contact)) {
if (buddy.getGroupId() == 0 && !grouplist.contains(" ")) { if (buddy.getGroupId() == 0 && !grouplist.equals(DEFAULT_AIM_GROUP)) {
// Ok this group is the "main group", but contact isn't in it. // Ok this group is the "main group", but contact isn't in it.
Log.debug("Removing "+buddy+" from main group"); Log.debug("Removing "+buddy+" from main group");
request(new DeleteItemsCmd(buddy.toSsiItem())); request(new DeleteItemsCmd(buddy.toSsiItem()));
...@@ -481,6 +491,10 @@ public class OSCARSession extends TransportSession { ...@@ -481,6 +491,10 @@ public class OSCARSession extends TransportSession {
} }
updateStatus(this.presenceType, this.verboseStatus); updateStatus(this.presenceType, this.verboseStatus);
if (getTransport().getType().equals(TransportType.icq)) {
request(new OfflineMsgIcqRequest(getUIN(), (int)nextIcqId()));
}
} }
/** /**
...@@ -494,9 +508,9 @@ public class OSCARSession extends TransportSession { ...@@ -494,9 +508,9 @@ public class OSCARSession extends TransportSession {
} }
} }
private static final List<CapabilityBlock> MY_CAPS = Arrays.asList(new CapabilityBlock[] { private static final List<CapabilityBlock> MY_CAPS = Arrays.asList(
CapabilityBlock.BLOCK_ICQCOMPATIBLE, CapabilityBlock.BLOCK_ICQCOMPATIBLE
}); );
/** /**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus(org.jivesoftware.wildfire.gateway.PresenceType, String) * @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus(org.jivesoftware.wildfire.gateway.PresenceType, String)
...@@ -535,4 +549,15 @@ public class OSCARSession extends TransportSession { ...@@ -535,4 +549,15 @@ public class OSCARSession extends TransportSession {
} }
} }
public long nextIcqId() { return icqSeqNum.next(); }
public int getUIN() {
try {
return Integer.parseInt(getRegistration().getUsername());
}
catch (Exception e) {
return -1;
}
}
} }
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