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

Lots of code cleanup as per IntelliJ's suggestions. Pretty nifty!

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4794 b35dd754-fafc-0310-a699-88a17e54d16e
parent a2127b23
...@@ -79,7 +79,7 @@ public abstract class BaseTransport implements Component { ...@@ -79,7 +79,7 @@ public abstract class BaseTransport implements Component {
/** /**
* Manages all active sessions. * Manages all active sessions.
* @see org.jivesoftware.wildfire.gateway.SessionManager * @see org.jivesoftware.wildfire.gateway.TransportSessionManager
*/ */
public final TransportSessionManager sessionManager = new TransportSessionManager(); public final TransportSessionManager sessionManager = new TransportSessionManager();
......
...@@ -13,7 +13,6 @@ package org.jivesoftware.wildfire.gateway; ...@@ -13,7 +13,6 @@ package org.jivesoftware.wildfire.gateway;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.container.Plugin; import org.jivesoftware.wildfire.container.Plugin;
import org.jivesoftware.wildfire.container.PluginManager; import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.gateway.TransportInstance;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory; import org.xmpp.component.ComponentManagerFactory;
import org.picocontainer.MutablePicoContainer; import org.picocontainer.MutablePicoContainer;
...@@ -39,12 +38,7 @@ public class GatewayPlugin implements Plugin { ...@@ -39,12 +38,7 @@ public class GatewayPlugin implements Plugin {
/** /**
* Represents all configured transport handlers. * Represents all configured transport handlers.
*/ */
public Hashtable<String,TransportInstance> transports; public Hashtable<String,TransportInstance> transports;
/**
* Represents the base component manager.
*/
private ComponentManager componentManager;
public GatewayPlugin() { public GatewayPlugin() {
picoContainer = new DefaultPicoContainer(); picoContainer = new DefaultPicoContainer();
...@@ -56,7 +50,7 @@ public class GatewayPlugin implements Plugin { ...@@ -56,7 +50,7 @@ public class GatewayPlugin implements Plugin {
picoContainer.start(); picoContainer.start();
transports = new Hashtable<String,TransportInstance>(); transports = new Hashtable<String,TransportInstance>();
componentManager = ComponentManagerFactory.getComponentManager(); ComponentManager componentManager = ComponentManagerFactory.getComponentManager();
/* Set up AIM transport. */ /* Set up AIM transport. */
transports.put("aim", new TransportInstance(TransportType.aim, "AIM Transport", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARTransport", componentManager)); transports.put("aim", new TransportInstance(TransportType.aim, "AIM Transport", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARTransport", componentManager));
...@@ -134,8 +128,7 @@ public class GatewayPlugin implements Plugin { ...@@ -134,8 +128,7 @@ public class GatewayPlugin implements Plugin {
* Returns the transport instance, identified by subdomain. * Returns the transport instance, identified by subdomain.
*/ */
public TransportInstance getTransportInstance(String serviceName) { public TransportInstance getTransportInstance(String serviceName) {
TransportInstance trInstance = transports.get(serviceName); return transports.get(serviceName);
return trInstance;
} }
} }
...@@ -12,9 +12,7 @@ package org.jivesoftware.wildfire.gateway; ...@@ -12,9 +12,7 @@ package org.jivesoftware.wildfire.gateway;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
import org.xmpp.packet.JID;
/** /**
* Transport Instance * Transport Instance
...@@ -26,7 +24,6 @@ import org.xmpp.packet.JID; ...@@ -26,7 +24,6 @@ import org.xmpp.packet.JID;
public class TransportInstance { public class TransportInstance {
private ComponentManager componentManager; private ComponentManager componentManager;
private JID jid = null;
private String description = null; private String description = null;
private String nameOfClass = null; private String nameOfClass = null;
public BaseTransport transport = null; public BaseTransport transport = null;
...@@ -37,9 +34,8 @@ public class TransportInstance { ...@@ -37,9 +34,8 @@ public class TransportInstance {
/** /**
* Creates a new transport instance. * Creates a new transport instance.
* *
* @param jid Full jabber id of the transport.
* @param description Short description of transport.
* @param type Type of transport. * @param type Type of transport.
* @param description Short description of transport.
* @param classname Full name/path of class associated with instance. * @param classname Full name/path of class associated with instance.
* @param componentManager Component manager managing this instance. * @param componentManager Component manager managing this instance.
*/ */
......
...@@ -10,18 +10,12 @@ ...@@ -10,18 +10,12 @@
package org.jivesoftware.wildfire.gateway.protocols.msn; package org.jivesoftware.wildfire.gateway.protocols.msn;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import org.hn.sleek.jmml.Contact; import org.hn.sleek.jmml.Contact;
import org.hn.sleek.jmml.ContactChangeEvent; import org.hn.sleek.jmml.ContactChangeEvent;
import org.hn.sleek.jmml.ContactList;
import org.hn.sleek.jmml.ContactStatus; import org.hn.sleek.jmml.ContactStatus;
import org.hn.sleek.jmml.IncomingMessageEvent; import org.hn.sleek.jmml.IncomingMessageEvent;
import org.hn.sleek.jmml.MessengerClientAdapter; import org.hn.sleek.jmml.MessengerClientAdapter;
import org.hn.sleek.jmml.MSNException;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.gateway.TransportBuddy;
import org.jivesoftware.wildfire.user.UserNotFoundException; import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
...@@ -183,7 +177,6 @@ public class MSNListener extends MessengerClientAdapter { ...@@ -183,7 +177,6 @@ public class MSNListener extends MessengerClientAdapter {
//catch (UserNotFoundException e) { //catch (UserNotFoundException e) {
// Log.error("Unable to sync MSN contact list for " + msnSession.getJID()); // Log.error("Unable to sync MSN contact list for " + msnSession.getJID());
//} //}
return;
} }
} }
...@@ -10,20 +10,13 @@ ...@@ -10,20 +10,13 @@
package org.jivesoftware.wildfire.gateway.protocols.msn; package org.jivesoftware.wildfire.gateway.protocols.msn;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.hn.sleek.jmml.Contact;
import org.hn.sleek.jmml.ContactList;
import org.hn.sleek.jmml.ContactStatus;
import org.hn.sleek.jmml.MessengerServerManager; import org.hn.sleek.jmml.MessengerServerManager;
import org.hn.sleek.jmml.MSNException; import org.hn.sleek.jmml.MSNException;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.gateway.PresenceType; import org.jivesoftware.wildfire.gateway.PresenceType;
import org.jivesoftware.wildfire.gateway.Registration; import org.jivesoftware.wildfire.gateway.Registration;
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.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
......
...@@ -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.snac.SnacRequest; import net.kano.joscar.snac.SnacRequest;
public interface PendingSnacListener { public interface PendingSnacListener {
......
...@@ -12,26 +12,16 @@ ...@@ -12,26 +12,16 @@
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.*;
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.conn.*; import net.kano.joscar.snaccmd.conn.*;
import net.kano.joscar.snaccmd.icon.*; import net.kano.joscar.snaccmd.icon.*;
import net.kano.joscar.snaccmd.search.*; import net.kano.joscar.snaccmd.search.*;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class ServiceConnection extends BasicFlapConnection { public class ServiceConnection extends BasicFlapConnection {
...@@ -89,69 +79,68 @@ public class ServiceConnection extends BasicFlapConnection { ...@@ -89,69 +79,68 @@ public class ServiceConnection extends BasicFlapConnection {
clientReady(); clientReady();
} else if (cmd instanceof InterestListCmd) { } else if (cmd instanceof InterestListCmd) {
InterestListCmd ilc = (InterestListCmd) cmd; // InterestListCmd ilc = (InterestListCmd) cmd;
//
InterestInfo[] infos = ilc.getInterests(); // InterestInfo[] infos = ilc.getInterests();
//
if (infos != null) { // if (infos != null) {
Map children = new HashMap(); // Map children = new HashMap();
//
for (int i = 0; i < infos.length; i++) { // for (InterestInfo info1 : infos) {
if (infos[i].getType() == InterestInfo.TYPE_CHILD) { // if (info1.getType() == InterestInfo.TYPE_CHILD) {
int parentCode = infos[i].getParentId(); // int parentCode = info1.getParentId();
//
List interests = (List) children.get(parentCode); // List interests = (List) children.get(parentCode);
//
if (interests == null) { // if (interests == null) {
interests = new LinkedList(); // interests = new LinkedList();
children.put(parentCode, interests); // children.put(parentCode, interests);
} // }
//
interests.add(infos[i]); // interests.add(info1);
} // }
} // }
for (int i = 0; i < infos.length; i++) { // for (InterestInfo info2 : infos) {
if (infos[i].getType() == InterestInfo.TYPE_PARENT) { // if (info2.getType() == InterestInfo.TYPE_PARENT) {
Integer id = new Integer(infos[i].getParentId()); // Integer id = info2.getParentId();
List interests = (List) children.get(id); // List interests = (List) children.get(id);
//
//Log.debug("- " + infos[i].getName()); // //Log.debug("- " + infos[i].getName());
if (interests != null) { // if (interests != null) {
for (Iterator it = interests.iterator(); // for (Object interest : interests) {
it.hasNext();) { // InterestInfo info = (InterestInfo) interest;
InterestInfo info = (InterestInfo) it.next(); // //Log.debug(" - " + info.getName());
//Log.debug(" - " + info.getName()); // }
} // }
} // }
} // }
} // List toplevels = (List) children.get(0);
List toplevels = (List) children.get(new Integer(0)); // if (toplevels != null) {
if (toplevels != null) { // for (Iterator it = toplevels.iterator(); it.hasNext();) {
for (Iterator it = toplevels.iterator(); it.hasNext();) { // //Log.debug(" "
//Log.debug(" " // // + ((InterestInfo) it.next()).getName());
// + ((InterestInfo) it.next()).getName()); // }
} // }
} // }
}
} else if (cmd instanceof SearchResultsCmd) { } else if (cmd instanceof SearchResultsCmd) {
SearchResultsCmd src = (SearchResultsCmd) cmd; // SearchResultsCmd src = (SearchResultsCmd) cmd;
//
DirInfo[] results = src.getResults(); // DirInfo[] results = src.getResults();
//
for (int i = 0; i < results.length; i++) { // for (DirInfo result : results) {
//Log.debug("result " + (i + 1) + ": " + results[i]); // //Log.debug("result " + (i + 1) + ": " + results[i]);
} // }
} else if (cmd instanceof IconDataCmd) { } else if (cmd instanceof IconDataCmd) {
IconDataCmd idc = (IconDataCmd) cmd; // IconDataCmd idc = (IconDataCmd) cmd;
//
String sn = idc.getScreenname(); // String sn = idc.getScreenname();
//
byte[] data = idc.getIconData().toByteArray(); // byte[] data = idc.getIconData().toByteArray();
Image icon = Toolkit.getDefaultToolkit().createImage(data); // Image icon = Toolkit.getDefaultToolkit().createImage(data);
//
// oscarSession.getUserInfo(sn).setIcon(icon); //// oscarSession.getUserInfo(sn).setIcon(icon);
} }
} }
......
...@@ -17,16 +17,15 @@ import net.kano.joscar.snac.SnacRequest; ...@@ -17,16 +17,15 @@ import net.kano.joscar.snac.SnacRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class SnacManager { public class SnacManager {
protected Map conns = new HashMap(); protected Map<Integer,List<BasicFlapConnection>> conns = new HashMap<Integer,List<BasicFlapConnection>>();
protected PendingSnacMgr pendingSnacs = new PendingSnacMgr(); protected PendingSnacMgr pendingSnacs = new PendingSnacMgr();
protected List listeners = new ArrayList(); protected List<PendingSnacListener> listeners = new ArrayList<PendingSnacListener>();
protected Map supportedFamilies = new IdentityHashMap(); protected Map<BasicFlapConnection,int[]> supportedFamilies = new IdentityHashMap<BasicFlapConnection,int[]>();
public SnacManager() { } public SnacManager() { }
...@@ -38,26 +37,25 @@ public class SnacManager { ...@@ -38,26 +37,25 @@ public class SnacManager {
int[] families = conn.getSnacFamilies(); int[] families = conn.getSnacFamilies();
supportedFamilies.put(conn, families); supportedFamilies.put(conn, families);
for (int i = 0; i < families.length; i++) { for (int familyCode : families) {
int familyCode = families[i]; List<BasicFlapConnection> handlers = conns.get(familyCode);
List handlers = (List) conns.get(familyCode);
if (handlers == null) { if (handlers == null) {
handlers = new LinkedList(); handlers = new LinkedList<BasicFlapConnection>();
conns.put(familyCode, handlers); conns.put(familyCode, handlers);
} }
if (!handlers.contains(conn)) handlers.add(conn); if (!handlers.contains(conn)) {
handlers.add(conn);
}
} }
} }
public void dequeueSnacs(BasicFlapConnection conn) { public void dequeueSnacs(BasicFlapConnection conn) {
int[] infos = (int[]) supportedFamilies.get(conn); int[] infos = supportedFamilies.get(conn);
if (infos != null) { if (infos != null) {
for (int i = 0; i < infos.length; i++) { for (int familyCode : infos) {
int familyCode = infos[i];
if (pendingSnacs.isPending(familyCode)) { if (pendingSnacs.isPending(familyCode)) {
dequeueSnacs(familyCode); dequeueSnacs(familyCode);
} }
...@@ -70,23 +68,21 @@ public class SnacManager { ...@@ -70,23 +68,21 @@ public class SnacManager {
pendingSnacs.setPending(familyCode, false); pendingSnacs.setPending(familyCode, false);
for (Iterator it = listeners.iterator(); it.hasNext();) { for (Object listener1 : listeners) {
PendingSnacListener listener = (PendingSnacListener) it.next(); PendingSnacListener listener = (PendingSnacListener) listener1;
listener.dequeueSnacs(pending); listener.dequeueSnacs(pending);
} }
} }
public void unregister(BasicFlapConnection conn) { public void unregister(BasicFlapConnection conn) {
for (Iterator it = conns.values().iterator(); it.hasNext();) { for (List<BasicFlapConnection> basicFlapConnections : conns.values()) {
List handlers = (List) it.next(); basicFlapConnections.remove(conn);
handlers.remove(conn);
} }
} }
public BasicFlapConnection getConn(int familyCode) { public BasicFlapConnection getConn(int familyCode) {
List handlers = (List) conns.get(familyCode); List handlers = conns.get(familyCode);
if (handlers == null || handlers.size() == 0) { if (handlers == null || handlers.size() == 0) {
return null; return null;
......
...@@ -13,7 +13,6 @@ package org.jivesoftware.wildfire.gateway.protocols.yahoo; ...@@ -13,7 +13,6 @@ package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
...@@ -26,7 +25,6 @@ import org.xmpp.packet.JID; ...@@ -26,7 +25,6 @@ import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import ymsg.network.LoginRefusedException; import ymsg.network.LoginRefusedException;
import ymsg.network.Session; import ymsg.network.Session;
import ymsg.network.StatusConstants;
import ymsg.network.YahooGroup; import ymsg.network.YahooGroup;
import ymsg.network.YahooUser; import ymsg.network.YahooUser;
...@@ -173,7 +171,8 @@ public class YahooSession extends TransportSession { ...@@ -173,7 +171,8 @@ public class YahooSession extends TransportSession {
} }
// Ok, now lets check presence // Ok, now lets check presence
for (YahooUser user : (Collection<YahooUser>)yahooSession.getUsers().values()) { for (Object userObj : yahooSession.getUsers().values()) {
YahooUser user = (YahooUser)userObj;
Presence p = new Presence(); Presence p = new Presence();
p.setTo(getJID()); p.setTo(getJID());
p.setFrom(getTransport().convertIDToJID(user.getId())); p.setFrom(getTransport().convertIDToJID(user.getId()));
......
...@@ -24,7 +24,6 @@ import ymsg.network.event.SessionFriendEvent; ...@@ -24,7 +24,6 @@ import ymsg.network.event.SessionFriendEvent;
import ymsg.network.event.SessionListener; import ymsg.network.event.SessionListener;
import ymsg.network.event.SessionNewMailEvent; import ymsg.network.event.SessionNewMailEvent;
import ymsg.network.event.SessionNotifyEvent; import ymsg.network.event.SessionNotifyEvent;
import ymsg.network.StatusConstants;
import ymsg.support.MessageDecoder; import ymsg.support.MessageDecoder;
/** /**
...@@ -82,7 +81,6 @@ public class YahooSessionListener implements SessionListener { ...@@ -82,7 +81,6 @@ public class YahooSessionListener implements SessionListener {
p.setStatus(custommsg); p.setStatus(custommsg);
} }
long statusid = user.getStatus();
((YahooTransport)yahooSession.getTransport()).setUpPresencePacket(p, user.getStatus()); ((YahooTransport)yahooSession.getTransport()).setUpPresencePacket(p, user.getStatus());
yahooSession.getTransport().sendPacket(p); yahooSession.getTransport().sendPacket(p);
} }
......
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
} }
Collection<regResult> regResults = new ArrayList<regResult>(); Collection<regResult> regResults = new ArrayList<regResult>();
ArrayList filteropts = new ArrayList<String>(); ArrayList<String> filteropts = new ArrayList<String>();
if (ParamUtils.getParameter(request, "filter[]") != null) { if (ParamUtils.getParameter(request, "filter[]") != null) {
String[] optlist = ParamUtils.getParameters(request, "filter[]"); String[] optlist = ParamUtils.getParameters(request, "filter[]");
for (String opt : optlist) { for (String opt : optlist) {
...@@ -336,9 +336,9 @@ below and update the view.</p> ...@@ -336,9 +336,9 @@ below and update the view.</p>
<!-- BEGIN results size (num per page) --> <!-- BEGIN results size (num per page) -->
<div class="jive-registrations-resultsSize"><form action="gateway-registrations.jsp" method="get"> <div class="jive-registrations-resultsSize"><form action="gateway-registrations.jsp" method="get">
<select name="range" id="range" size="1" onchange="this.form.submit()"> <select name="range" id="range" size="1" onchange="this.form.submit()">
<% for (int i=0; i<RANGE_PRESETS.length; i++) { %> <% for (int rangePreset : RANGE_PRESETS) { %>
<option value="<%= RANGE_PRESETS[i] %>"<%= (RANGE_PRESETS[i] == range ? "selected" : "") %>><%= RANGE_PRESETS[i] %></option> <option value="<%= rangePreset %>"<%= (rangePreset== range ? "selected" : "") %>><%= rangePreset %></option>
<% } %> <% } %>
</select> </select>
......
<%@ page import="java.util.*, <%@ page import="org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.util.*, org.jivesoftware.util.*,
org.jivesoftware.wildfire.gateway.GatewayPlugin" org.jivesoftware.wildfire.gateway.GatewayPlugin"
errorPage="error.jsp" errorPage="error.jsp"
......
<%@ page import="java.util.*, <%@ page import="javax.servlet.jsp.JspWriter,
javax.servlet.jsp.JspWriter,
org.jivesoftware.wildfire.XMPPServer, org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.util.*,
org.jivesoftware.wildfire.gateway.GatewayPlugin, org.jivesoftware.wildfire.gateway.GatewayPlugin,
org.jivesoftware.wildfire.gateway.TransportType" org.jivesoftware.wildfire.gateway.TransportType"
errorPage="error.jsp" errorPage="error.jsp"
......
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