Commit 26bd8f33 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

More code cleanup.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4808 b35dd754-fafc-0310-a699-88a17e54d16e
parent 136a81cc
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
package org.jivesoftware.wildfire.gateway.protocols.oscar; package org.jivesoftware.wildfire.gateway.protocols.oscar;
import org.jivesoftware.util.Log;
import net.kano.joscar.*; import net.kano.joscar.*;
import net.kano.joscar.flap.*; import net.kano.joscar.flap.*;
import net.kano.joscar.flapcmd.*; import net.kano.joscar.flapcmd.*;
...@@ -88,16 +86,16 @@ public class BOSConnection extends BasicFlapConnection { ...@@ -88,16 +86,16 @@ public class BOSConnection extends BasicFlapConnection {
0))); 0)));
} else if (cmd instanceof YourInfoCmd) { } else if (cmd instanceof YourInfoCmd) {
YourInfoCmd yic = (YourInfoCmd) cmd; // YourInfoCmd yic = (YourInfoCmd) cmd;
//
FullUserInfo info = yic.getUserInfo(); // FullUserInfo info = yic.getUserInfo();
//Log.debug("got my user info: " + info); //Log.debug("got my user info: " + info);
} else if (cmd instanceof UserInfoCmd) { } else if (cmd instanceof UserInfoCmd) {
UserInfoCmd uic = (UserInfoCmd) cmd; // UserInfoCmd uic = (UserInfoCmd) cmd;
//
String sn = uic.getUserInfo().getScreenname(); // String sn = uic.getUserInfo().getScreenname();
//Log.debug("user info for " + sn + ": " //Log.debug("user info for " + sn + ": "
// + uic.getInfoData()); // + uic.getInfoData());
...@@ -114,13 +112,13 @@ public class BOSConnection extends BasicFlapConnection { ...@@ -114,13 +112,13 @@ public class BOSConnection extends BasicFlapConnection {
SsiDataCmd sdc = (SsiDataCmd) cmd; SsiDataCmd sdc = (SsiDataCmd) cmd;
SsiItem[] items = sdc.getItems(); SsiItem[] items = sdc.getItems();
for (int i = 0; i < items.length; i++) { for (SsiItem item : items) {
SsiItemObj obj = itemFactory.getItemObj(items[i]); SsiItemObj obj = itemFactory.getItemObj(item);
if (obj instanceof BuddyItem) { if (obj instanceof BuddyItem) {
oscarSession.gotBuddy((BuddyItem)obj); oscarSession.gotBuddy((BuddyItem) obj);
} }
else if (obj instanceof GroupItem) { else if (obj instanceof GroupItem) {
oscarSession.gotGroup((GroupItem)obj); oscarSession.gotGroup((GroupItem) obj);
} }
//Log.debug("- " + (obj == null ? (Object) items[i] //Log.debug("- " + (obj == null ? (Object) items[i]
// : (Object) obj)); // : (Object) obj));
......
...@@ -12,18 +12,12 @@ ...@@ -12,18 +12,12 @@
package org.jivesoftware.wildfire.gateway.protocols.oscar; package org.jivesoftware.wildfire.gateway.protocols.oscar;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.InetAddress; import java.net.InetAddress;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import net.kano.joscar.*; import net.kano.joscar.*;
import net.kano.joscar.flap.*; import net.kano.joscar.flap.*;
...@@ -31,22 +25,13 @@ import net.kano.joscar.flapcmd.*; ...@@ -31,22 +25,13 @@ import net.kano.joscar.flapcmd.*;
import net.kano.joscar.ratelim.*; import net.kano.joscar.ratelim.*;
import net.kano.joscar.rv.*; import net.kano.joscar.rv.*;
import net.kano.joscar.rvcmd.*; import net.kano.joscar.rvcmd.*;
import net.kano.joscar.rvcmd.addins.*;
import net.kano.joscar.rvcmd.chatinvite.*;
import net.kano.joscar.rvcmd.directim.*;
import net.kano.joscar.rvcmd.getfile.*;
import net.kano.joscar.rvcmd.icon.*;
import net.kano.joscar.rvcmd.sendbl.*;
import net.kano.joscar.rvcmd.sendfile.*;
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.buddy.*; import net.kano.joscar.snaccmd.buddy.*;
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.rooms.*;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
public abstract class BasicFlapConnection extends BaseFlapConnection { public abstract class BasicFlapConnection extends BaseFlapConnection {
...@@ -69,12 +54,12 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -69,12 +54,12 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
protected RvSessionListener rvSessionListener = new RvSessionListener() { protected RvSessionListener rvSessionListener = new RvSessionListener() {
public void handleRv(RecvRvEvent event) { public void handleRv(RecvRvEvent event) {
RvCommand cmd = event.getRvCommand(); // RvCommand cmd = event.getRvCommand();
//
RvSession session = event.getRvSession(); // RvSession session = event.getRvSession();
SnacCommand snaccmd = event.getSnacCommand(); // SnacCommand snaccmd = event.getSnacCommand();
if (!(snaccmd instanceof RecvRvIcbm)) return; // if (!(snaccmd instanceof RecvRvIcbm)) return;
RecvRvIcbm icbm = (RecvRvIcbm) snaccmd; // RecvRvIcbm icbm = (RecvRvIcbm) snaccmd;
//Log.debug("got rendezvous on session <" + session + ">"); //Log.debug("got rendezvous on session <" + session + ">");
//Log.debug("- command: " + cmd); //Log.debug("- command: " + cmd);
} }
...@@ -124,7 +109,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -124,7 +109,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
} }
protected void handleSnacPacket(SnacPacketEvent e) { protected void handleSnacPacket(SnacPacketEvent e) {
SnacPacket packet = e.getSnacPacket(); // SnacPacket packet = e.getSnacPacket();
//Log.debug("got snac packet type " //Log.debug("got snac packet type "
// + Integer.toHexString(packet.getFamily()) + "/" // + Integer.toHexString(packet.getFamily()) + "/"
// + Integer.toHexString(packet.getCommand()) + ": " // + Integer.toHexString(packet.getCommand()) + ": "
...@@ -152,15 +137,14 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -152,15 +137,14 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
String sn = icbm.getSenderInfo().getScreenname(); String sn = icbm.getSenderInfo().getScreenname();
InstantMessage message = icbm.getMessage(); InstantMessage message = icbm.getMessage();
String msg = null; String msg = OscarTools.stripHtml(message.getMessage());
msg = OscarTools.stripHtml(message.getMessage());
Message jmessage = new Message(); Message jmessage = new Message();
jmessage.setTo(oscarSession.getRegistration().getJID()); jmessage.setTo(oscarSession.getRegistration().getJID());
jmessage.setBody(msg); jmessage.setBody(msg);
jmessage.setType(Message.Type.chat); jmessage.setType(Message.Type.chat);
jmessage.setFrom(this.oscarSession.getTransport().convertIDToJID(sn)); jmessage.setFrom(this.oscarSession.getTransport().convertIDToJID(sn));
oscarSession.getTransport().sendPacket((Packet)jmessage); oscarSession.getTransport().sendPacket(jmessage);
//sendRequest(new SnacRequest(new SendImIcbm(sn, msg), null)); //sendRequest(new SnacRequest(new SendImIcbm(sn, msg), null));
...@@ -189,7 +173,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -189,7 +173,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
p.setTo(oscarSession.getJID()); p.setTo(oscarSession.getJID());
p.setFrom(oscarSession.getTransport().convertIDToJID(info.getScreenname())); p.setFrom(oscarSession.getTransport().convertIDToJID(info.getScreenname()));
if (info.getAwayStatus() == true) { if (info.getAwayStatus()) {
p.setShow(Presence.Show.away); p.setShow(Presence.Show.away);
} }
...@@ -227,7 +211,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -227,7 +211,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
oscarSession.getTransport().sendPacket(p); oscarSession.getTransport().sendPacket(p);
} }
else if (cmd instanceof RateChange) { else if (cmd instanceof RateChange) {
RateChange rc = (RateChange) cmd; // RateChange rc = (RateChange) cmd;
//Log.debug("rate change: current avg is " //Log.debug("rate change: current avg is "
// + rc.getRateInfo().getCurrentAvg()); // + rc.getRateInfo().getCurrentAvg());
...@@ -235,7 +219,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -235,7 +219,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
} }
protected void handleSnacResponse(SnacResponseEvent e) { protected void handleSnacResponse(SnacResponseEvent e) {
SnacPacket packet = e.getSnacPacket(); // SnacPacket packet = e.getSnacPacket();
//Log.debug("got snac response type " //Log.debug("got snac response type "
// + Integer.toHexString(packet.getFamily()) + "/" // + Integer.toHexString(packet.getFamily()) + "/"
// + Integer.toHexString(packet.getCommand()) + ": " // + Integer.toHexString(packet.getCommand()) + ": "
...@@ -261,7 +245,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -261,7 +245,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
public int[] getSnacFamilies() { return snacFamilies; } public int[] getSnacFamilies() { return snacFamilies; }
protected void setSnacFamilies(int[] families) { protected void setSnacFamilies(int[] families) {
this.snacFamilies = (int[]) families.clone(); this.snacFamilies = families.clone();
Arrays.sort(snacFamilies); Arrays.sort(snacFamilies);
} }
...@@ -330,7 +314,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection { ...@@ -330,7 +314,7 @@ public abstract class BasicFlapConnection extends BaseFlapConnection {
p.setTo(oscarSession.getJID()); p.setTo(oscarSession.getJID());
p.setFrom(oscarSession.getTransport().convertIDToJID(info.getScreenname())); p.setFrom(oscarSession.getTransport().convertIDToJID(info.getScreenname()));
if (info.getAwayStatus() == true) { if (info.getAwayStatus()) {
p.setShow(Presence.Show.away); p.setShow(Presence.Show.away);
} }
......
...@@ -33,8 +33,6 @@ import org.jivesoftware.wildfire.gateway.TransportBuddy; ...@@ -33,8 +33,6 @@ import org.jivesoftware.wildfire.gateway.TransportBuddy;
import org.jivesoftware.wildfire.gateway.TransportSession; import org.jivesoftware.wildfire.gateway.TransportSession;
import org.jivesoftware.wildfire.user.UserNotFoundException; import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
/** /**
...@@ -53,30 +51,19 @@ public class OSCARSession extends TransportSession { ...@@ -53,30 +51,19 @@ public class OSCARSession extends TransportSession {
/** /**
* Initialize a new session object for OSCAR * Initialize a new session object for OSCAR
* *
* @param info The subscription information to use during login. * @param registration The registration information to use during login.
* @param gateway The gateway that created this session. * @param transport The transport that created this session.
*/ */
public OSCARSession(Registration registration, JID jid, OSCARTransport transport) { public OSCARSession(Registration registration, JID jid, OSCARTransport transport) {
super(registration, jid, transport); super(registration, jid, transport);
} }
/**
* OSCAR Session Pieces
*/
private LoginConnection loginConn = null;
private BOSConnection bosConn = null; private BOSConnection bosConn = null;
private Set services = new HashSet(); private Set<ServiceConnection> services = new HashSet<ServiceConnection>();
private Boolean loggedIn = false; private Boolean loggedIn = false;
private PresenceType presenceType = null; private PresenceType presenceType = null;
private String verboseStatus = null; private String verboseStatus = null;
/**
* The Screenname, Password, and JID associated with this session.
*/
private JID jid;
private String legacyname = null;
private String legacypass = null;
/** /**
* SSI tracking variables. * SSI tracking variables.
*/ */
...@@ -87,7 +74,7 @@ public class OSCARSession extends TransportSession { ...@@ -87,7 +74,7 @@ public class OSCARSession extends TransportSession {
public void logIn(PresenceType presenceType, String verboseStatus) { public void logIn(PresenceType presenceType, String verboseStatus) {
if (!isLoggedIn()) { if (!isLoggedIn()) {
loginConn = new LoginConnection("login.oscar.aol.com", 5190, this); LoginConnection loginConn = new LoginConnection("login.oscar.aol.com", 5190, this);
loginConn.connect(); loginConn.connect();
loggedIn = true; loggedIn = true;
...@@ -161,8 +148,8 @@ public class OSCARSession extends TransportSession { ...@@ -161,8 +148,8 @@ public class OSCARSession extends TransportSession {
protected SnacManager snacMgr = new SnacManager(new PendingSnacListener() { protected SnacManager snacMgr = new SnacManager(new PendingSnacListener() {
public void dequeueSnacs(SnacRequest[] pending) { public void dequeueSnacs(SnacRequest[] pending) {
//Log.debug("dequeuing " + pending.length + " snacs"); //Log.debug("dequeuing " + pending.length + " snacs");
for (int i = 0; i < pending.length; i++) { for (SnacRequest aPending : pending) {
handleRequest(pending[i]); handleRequest(aPending);
} }
} }
}); });
...@@ -215,6 +202,14 @@ public class OSCARSession extends TransportSession { ...@@ -215,6 +202,14 @@ public class OSCARSession extends TransportSession {
services.add(conn); services.add(conn);
} }
public boolean isServiceConnected(ServiceConnection conn) {
return services.contains(conn);
}
public Set<ServiceConnection> getServiceConnections() {
return services;
}
void serviceReady(ServiceConnection conn) { void serviceReady(ServiceConnection conn) {
snacMgr.dequeueSnacs(conn); snacMgr.dequeueSnacs(conn);
} }
......
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