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