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