Commit 6170f35e authored by Matt Tucker's avatar Matt Tucker Committed by matt

Code cleanup.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4355 b35dd754-fafc-0310-a699-88a17e54d16e
parent 45ac9d20
package org.jivesoftware.wildfire.gateway; /**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway;
/** /**
* AbstractGatewaySession provides an abstract implementation of * AbstractGatewaySession provides an abstract implementation of
...@@ -8,7 +17,6 @@ package org.jivesoftware.wildfire.gateway; ...@@ -8,7 +17,6 @@ package org.jivesoftware.wildfire.gateway;
* management. * management.
* *
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public abstract class AbstractGatewaySession implements GatewaySession, Endpoint { public abstract class AbstractGatewaySession implements GatewaySession, Endpoint {
......
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.apache.commons.collections.BidiMap;
import org.apache.commons.collections.bidimap.DualHashBidiMap;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.wildfire.gateway.roster.AbstractForeignContact;
import org.jivesoftware.wildfire.gateway.roster.ForeignContact; import org.jivesoftware.wildfire.gateway.roster.ForeignContact;
import org.jivesoftware.wildfire.gateway.roster.NormalizedJID; import org.jivesoftware.wildfire.gateway.roster.NormalizedJID;
import org.jivesoftware.wildfire.gateway.roster.PersistenceManager; import org.jivesoftware.wildfire.gateway.roster.PersistenceManager;
import org.jivesoftware.wildfire.gateway.roster.Roster; import org.jivesoftware.wildfire.gateway.roster.Roster;
import org.jivesoftware.wildfire.gateway.roster.Status; import org.jivesoftware.wildfire.gateway.roster.Status;
import org.jivesoftware.wildfire.gateway.util.BackgroundThreadFactory; import org.jivesoftware.wildfire.gateway.util.BackgroundThreadFactory;
import org.jivesoftware.util.LocaleUtils;
import org.xmpp.component.Component; import org.xmpp.component.Component;
import org.xmpp.component.ComponentException; import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
...@@ -35,7 +29,6 @@ import org.xmpp.packet.Message; ...@@ -35,7 +29,6 @@ import org.xmpp.packet.Message;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.xmpp.packet.PacketError.Condition; import org.xmpp.packet.PacketError.Condition;
import org.xmpp.packet.Presence.Show;
/** /**
* Handle a good share of the tasks for a gateway. Dealing with lookups for ids, * Handle a good share of the tasks for a gateway. Dealing with lookups for ids,
...@@ -52,7 +45,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -52,7 +45,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
public abstract String getName(); public abstract String getName();
/** /**
* @see org.jivesoftware.wildfire.gateway.Gateway#setName() * @see org.jivesoftware.wildfire.gateway.Gateway#setName(String)
*/ */
public abstract void setName(String newname); public abstract void setName(String newname);
...@@ -113,7 +106,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -113,7 +106,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
/** /**
* Handle Foreign Contacts and JID Mapping * Handle Foreign Contacts and JID Mapping
*/ */
private final BidiMap foreignContacts = new DualHashBidiMap(); private final Map<JID, String> foreignContacts = new HashMap<JID, String>();
/** /**
* helper method for getting the ns from a packet. * helper method for getting the ns from a packet.
...@@ -463,13 +456,12 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -463,13 +456,12 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* @see org.xmpp.packet.Message * @see org.xmpp.packet.Message
*/ */
private void processPacket(Message message) throws Exception { private void processPacket(Message message) throws Exception {
logger.finer(message.toString()); logger.finer(message.toString());
GatewaySession session = PersistenceManager.Factory.get(this).getRegistrar().getGatewaySession(message.getFrom()); GatewaySession session = PersistenceManager.Factory.get(this).getRegistrar().getGatewaySession(message.getFrom());
session.getLegacyEndpoint().sendPacket(message); session.getLegacyEndpoint().sendPacket(message);
return;
} }
/** /**
* Proces a presense packet. * Proces a presense packet.
* *
...@@ -492,9 +484,8 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -492,9 +484,8 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
if(!Presence.Type.unavailable.equals(presence.getType())) { if(!Presence.Type.unavailable.equals(presence.getType())) {
logger.log(Level.INFO, "basegateway.unauthorizedrequest", new Object[] { presence.getType(), from.toString() }); logger.log(Level.INFO, "basegateway.unauthorizedrequest", new Object[] { presence.getType(), from.toString() });
Presence result = new Presence(); Presence result = new Presence();
result = new Presence();
result.setError(Condition.not_authorized); result.setError(Condition.not_authorized);
result.setStatus(bundle.getString("basegateway.registerfirst")); result.setStatus(LocaleUtils.getLocalizedString("basegateway.registerfirst", "gateway"));
p.add(result); p.add(result);
} }
return p; return p;
...@@ -508,7 +499,8 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -508,7 +499,8 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
logger.log(Level.WARNING, "basegateway.unabletolocatesession" , from); logger.log(Level.WARNING, "basegateway.unabletolocatesession" , from);
return p; return p;
} }
if(Presence.Type.subscribe.equals(presence.getType())) {
if(Presence.Type.subscribe.equals(presence.getType())) {
if(presence.getTo().equals(this.jid)) { if(presence.getTo().equals(this.jid)) {
sessionInfo.getSubscriptionInfo().serverRegistered = true; sessionInfo.getSubscriptionInfo().serverRegistered = true;
} else { } else {
...@@ -522,14 +514,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -522,14 +514,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
reply.setFrom(presence.getTo()); reply.setFrom(presence.getTo());
p.add(reply); p.add(reply);
} else if (Presence.Type.subscribed.equals(presence.getType())) { }
else if (Presence.Type.subscribed.equals(presence.getType())) {
if(presence.getTo().equals(this.jid)) { // subscribed to server if(presence.getTo().equals(this.jid)) { // subscribed to server
sessionInfo.getSubscriptionInfo().clientRegistered = true; sessionInfo.getSubscriptionInfo().clientRegistered = true;
} else { // subscribe to legacy user } else { // subscribe to legacy user
logger.log(Level.FINE,"basegateway.subscribed"); logger.log(Level.FINE,"basegateway.subscribed");
} }
} else if (Presence.Type.unavailable.equals(presence.getType())){ }
else if (Presence.Type.unavailable.equals(presence.getType())){
/** /**
* If an unavailable presence stanza is received then logout the * If an unavailable presence stanza is received then logout the
* current user and send back and unavailable stanza. * current user and send back and unavailable stanza.
...@@ -542,17 +536,15 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -542,17 +536,15 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
reply.setTo(presence.getFrom()); reply.setTo(presence.getFrom());
reply.setFrom(presence.getTo()); reply.setFrom(presence.getTo());
p.add(reply); p.add(reply);
}
else if (presence.getTo().getNode() == null) { // this is a request to the gateway only.
} else if (presence.getTo().getNode() == null) { // this is a request to the gateway only.
Presence result = new Presence(); Presence result = new Presence();
result.setTo(presence.getFrom()); result.setTo(presence.getFrom());
result.setFrom(this.jid); result.setFrom(this.jid);
p.add(result); p.add(result);
logger.log(Level.FINE, "basegateway.gatewaypresence"); logger.log(Level.FINE, "basegateway.gatewaypresence");
} else { }
else {
GatewaySession session = rosterManager.getRegistrar().getGatewaySession(presence.getFrom()); GatewaySession session = rosterManager.getRegistrar().getGatewaySession(presence.getFrom());
try { try {
...@@ -563,27 +555,20 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -563,27 +555,20 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
p2.setTo(presence.getFrom()); p2.setTo(presence.getFrom());
if(status.isOnline()) { if(status.isOnline()) {
p2.setStatus(status.getValue()); p2.setStatus(status.getValue());
} else { }
else {
p2.setType(Presence.Type.unavailable); p2.setType(Presence.Type.unavailable);
} }
p.add(p2); p.add(p2);
} catch (Exception e) { }
catch (Exception e) {
logger.log(Level.WARNING, "basegateway.statusexception", logger.log(Level.WARNING, "basegateway.statusexception",
new Object[]{presence.getTo(), presence.getFrom(), e.getLocalizedMessage()}); new Object[]{presence.getTo(), presence.getFrom(), e.getLocalizedMessage()});
} }
} }
return p; return p;
} }
/** The resource bundle for this gateway. */
ResourceBundle bundle = PropertyResourceBundle.getBundle("gateway_i18n");
/** The jabberEndpointValve. */
private EndpointValve jabberEndpointValve;
/** /**
* Return the JID of this component. * Return the JID of this component.
* *
...@@ -605,7 +590,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -605,7 +590,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
*/ */
public void initialize(JID jid, ComponentManager componentManager) throws ComponentException { public void initialize(JID jid, ComponentManager componentManager) throws ComponentException {
this.jid = jid; this.jid = jid;
this.jabberEndpointValve = new EndpointValve(false); EndpointValve jabberEndpointValve = new EndpointValve(false);
this.jabberEndpoint = new JabberEndpoint(componentManager, this, jabberEndpointValve); this.jabberEndpoint = new JabberEndpoint(componentManager, this, jabberEndpointValve);
} }
...@@ -617,8 +602,8 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -617,8 +602,8 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* @return jid The JID associated with this contact. * @return jid The JID associated with this contact.
*/ */
public JID whois(String foreignContact) { public JID whois(String foreignContact) {
JID jid = new JID(foreignContact + "@" + this.getName() + "." + this.getDomain()); JID jid = new JID(foreignContact, this.getName() + "." + this.getDomain(), null);
foreignContacts.put(foreignContact, jid); foreignContacts.put(jid, foreignContact);
return jid; return jid;
} }
...@@ -629,7 +614,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -629,7 +614,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* @return contact A String for the foreign contact or null if non is regestered. * @return contact A String for the foreign contact or null if non is regestered.
*/ */
public String whois(JID jid) { public String whois(JID jid) {
return (String)foreignContacts.get(jid); return foreignContacts.get(jid);
} }
/** /**
...@@ -643,6 +628,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable { ...@@ -643,6 +628,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* Shutdown this component * Shutdown this component
*/ */
public void shutdown() { public void shutdown() {
threadPool.shutdown();
} }
/** /**
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import org.xmpp.component.ComponentException; import org.xmpp.component.ComponentException;
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public class EndpointValve { public class EndpointValve {
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import java.util.List; import java.util.List;
...@@ -10,7 +20,6 @@ import org.xmpp.packet.JID; ...@@ -10,7 +20,6 @@ import org.xmpp.packet.JID;
* GatewaySession provides an interface that legacy gateways need to implement. * GatewaySession provides an interface that legacy gateways need to implement.
* *
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public interface GatewaySession { public interface GatewaySession {
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
/** /**
...@@ -15,4 +25,4 @@ public interface SessionFactory { ...@@ -15,4 +25,4 @@ public interface SessionFactory {
* @return gatewaySession The gateway session. * @return gatewaySession The gateway session.
*/ */
public GatewaySession newInstance(SubscriptionInfo info); public GatewaySession newInstance(SubscriptionInfo info);
} }
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway; package org.jivesoftware.wildfire.gateway;
import java.io.Serializable; import java.io.Serializable;
...@@ -11,7 +21,6 @@ import org.xmpp.packet.JID; ...@@ -11,7 +21,6 @@ import org.xmpp.packet.JID;
* information repeatedly. * information repeatedly.
* *
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public class SubscriptionInfo implements Serializable { public class SubscriptionInfo implements Serializable {
...@@ -52,4 +61,4 @@ public class SubscriptionInfo implements Serializable { ...@@ -52,4 +61,4 @@ public class SubscriptionInfo implements Serializable {
*/ */
public transient JID jid; public transient JID jid;
} }
\ No newline at end of file
...@@ -15,13 +15,11 @@ package org.jivesoftware.wildfire.gateway.protocols.oscar; ...@@ -15,13 +15,11 @@ package org.jivesoftware.wildfire.gateway.protocols.oscar;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import net.kano.joscar.*; import net.kano.joscar.*;
import net.kano.joscar.tlv.*;
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.auth.*; import net.kano.joscar.snaccmd.auth.*;
import net.kano.joscar.snaccmd.chat.*;
import java.net.InetAddress; import java.net.InetAddress;
......
...@@ -21,7 +21,6 @@ import net.kano.joscar.ssiitem.*; ...@@ -21,7 +21,6 @@ import net.kano.joscar.ssiitem.*;
/** /**
* @author Daniel Henninger * @author Daniel Henninger
* @version 1.0
*/ */
public class OSCARForeignContact extends AbstractForeignContact { public class OSCARForeignContact extends AbstractForeignContact {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
package org.jivesoftware.wildfire.gateway.protocols.oscar; package org.jivesoftware.wildfire.gateway.protocols.oscar;
import java.util.logging.Logger;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.gateway.BaseGateway; import org.jivesoftware.wildfire.gateway.BaseGateway;
...@@ -23,7 +22,6 @@ import org.xmpp.packet.Packet; ...@@ -23,7 +22,6 @@ import org.xmpp.packet.Packet;
/** /**
* @author Daniel Henninger * @author Daniel Henninger
* @version 1.0
*/ */
public class OSCARGateway extends BaseGateway { public class OSCARGateway extends BaseGateway {
/* Gateway Name String */ /* Gateway Name String */
......
package org.jivesoftware.wildfire.gateway.protocols.oscar; package org.jivesoftware.wildfire.gateway.protocols.oscar;
import java.io.IOException;
import java.net.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.HashSet; import java.util.HashSet;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.gateway.AbstractGatewaySession; import org.jivesoftware.wildfire.gateway.AbstractGatewaySession;
import org.jivesoftware.wildfire.gateway.Endpoint; import org.jivesoftware.wildfire.gateway.Endpoint;
import org.jivesoftware.wildfire.gateway.EndpointValve;
import org.jivesoftware.wildfire.gateway.Gateway; import org.jivesoftware.wildfire.gateway.Gateway;
import org.jivesoftware.wildfire.gateway.JabberEndpoint;
import org.jivesoftware.wildfire.gateway.SubscriptionInfo; import org.jivesoftware.wildfire.gateway.SubscriptionInfo;
import org.jivesoftware.wildfire.gateway.roster.AbstractForeignContact;
import org.jivesoftware.wildfire.gateway.roster.ForeignContact; import org.jivesoftware.wildfire.gateway.roster.ForeignContact;
import org.jivesoftware.wildfire.gateway.roster.NormalizedJID;
import org.jivesoftware.wildfire.gateway.roster.PersistenceManager;
import org.jivesoftware.wildfire.gateway.roster.UnknownForeignContactException; import org.jivesoftware.wildfire.gateway.roster.UnknownForeignContactException;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
import net.kano.joscar.flap.*;
import net.kano.joscar.flapcmd.*; import net.kano.joscar.flapcmd.*;
import net.kano.joscar.snac.*; import net.kano.joscar.snac.*;
import net.kano.joscar.snaccmd.*;
import net.kano.joscar.snaccmd.auth.*;
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.ssi.*; import net.kano.joscar.snaccmd.ssi.*;
...@@ -44,7 +28,6 @@ import net.kano.joscar.ByteBlock; ...@@ -44,7 +28,6 @@ import net.kano.joscar.ByteBlock;
* Manages the session to the underlying legacy system. * Manages the session to the underlying legacy system.
* *
* @author Daniel Henninger * @author Daniel Henninger
* @version 1.0
*/ */
public class OSCARGatewaySession extends AbstractGatewaySession implements Endpoint { public class OSCARGatewaySession extends AbstractGatewaySession implements Endpoint {
...@@ -147,7 +130,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo ...@@ -147,7 +130,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo
public String getStatus(JID to) { public String getStatus(JID to) {
Log.debug("getStatus called"); Log.debug("getStatus called");
for (ForeignContact c : contacts) { for (ForeignContact c : contacts) {
if (c.getName() == to.getNode()) { if (c.getName().equals(to.getNode())) {
return c.getStatus().getValue(); return c.getStatus().getValue();
} }
} }
...@@ -159,7 +142,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo ...@@ -159,7 +142,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo
Integer newBuddyId = highestBuddyId + 1; Integer newBuddyId = highestBuddyId + 1;
Integer groupId = -1; Integer groupId = -1;
for (GroupItem g : groups) { for (GroupItem g : groups) {
if (g.getGroupName() == "Transport Buddies") { if ("Transport Buddies".equals(g.getGroupName())) {
groupId = g.getId(); groupId = g.getId();
} }
} }
...@@ -177,7 +160,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo ...@@ -177,7 +160,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo
public void removeContact(JID jid) throws Exception { public void removeContact(JID jid) throws Exception {
Log.debug("removeContact called"); Log.debug("removeContact called");
for (ForeignContact c : contacts) { for (ForeignContact c : contacts) {
if (c.getName() == jid.getNode()) { if (c.getName().equals(jid.getNode())) {
OSCARForeignContact oc = (OSCARForeignContact)c; OSCARForeignContact oc = (OSCARForeignContact)c;
request(new DeleteItemsCmd(new SsiItem[] { oc.getSSIItem() })); request(new DeleteItemsCmd(new SsiItem[] { oc.getSSIItem() }));
contacts.remove(contacts.indexOf(c)); contacts.remove(contacts.indexOf(c));
...@@ -196,7 +179,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo ...@@ -196,7 +179,7 @@ public class OSCARGatewaySession extends AbstractGatewaySession implements Endpo
public ForeignContact getContact(JID to) throws UnknownForeignContactException { public ForeignContact getContact(JID to) throws UnknownForeignContactException {
Log.debug("getContact called"); Log.debug("getContact called");
for (ForeignContact c : contacts) { for (ForeignContact c : contacts) {
if (c.getName() == to.getNode()) { if (c.getName().equals(to.getNode())) {
return c; return c;
} }
} }
......
...@@ -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;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -22,34 +20,32 @@ import java.util.List; ...@@ -22,34 +20,32 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class PendingSnacMgr { public class PendingSnacMgr {
protected Map snacs = new HashMap();
public boolean isPending(int familyCode) { protected Map<Integer,List<SnacRequest>> snacs = new HashMap<Integer,List<SnacRequest>>();
Integer family = new Integer(familyCode);
return snacs.containsKey(family); public boolean isPending(int familyCode) {
return snacs.containsKey(familyCode);
} }
public void add(SnacRequest request) { public void add(SnacRequest request) {
Integer family = new Integer(request.getCommand().getFamily()); Integer family = request.getCommand().getFamily();
List pending = (List) snacs.get(family); List<SnacRequest> pending = snacs.get(family);
pending.add(request); pending.add(request);
} }
public SnacRequest[] getPending(int familyCode) { public SnacRequest[] getPending(int familyCode) {
Integer family = new Integer(familyCode); List<SnacRequest> pending = snacs.get(familyCode);
return pending.toArray(new SnacRequest[0]);
List pending = (List) snacs.get(family);
return (SnacRequest[]) pending.toArray(new SnacRequest[0]);
} }
public void setPending(int familyCode, boolean pending) { public void setPending(int familyCode, boolean pending) {
Integer family = new Integer(familyCode); if (pending) {
snacs.put(familyCode, new ArrayList<SnacRequest>());
if (pending) snacs.put(family, new ArrayList()); }
else snacs.remove(family); else {
snacs.remove(familyCode);
}
} }
} }
...@@ -34,6 +34,7 @@ import java.util.List; ...@@ -34,6 +34,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class ServiceConnection extends BasicFlapConnection { public class ServiceConnection extends BasicFlapConnection {
protected int serviceFamily; protected int serviceFamily;
public ServiceConnection(OSCARGatewaySession mainSession, ByteBlock cookie, int serviceFamily) { public ServiceConnection(OSCARGatewaySession mainSession, ByteBlock cookie, int serviceFamily) {
...@@ -98,13 +99,12 @@ public class ServiceConnection extends BasicFlapConnection { ...@@ -98,13 +99,12 @@ public class ServiceConnection extends BasicFlapConnection {
for (int i = 0; i < infos.length; i++) { for (int i = 0; i < infos.length; i++) {
if (infos[i].getType() == InterestInfo.TYPE_CHILD) { if (infos[i].getType() == InterestInfo.TYPE_CHILD) {
int parentCode = infos[i].getParentId(); int parentCode = infos[i].getParentId();
Integer parent = new Integer(parentCode);
List interests = (List) children.get(parent); List interests = (List) children.get(parentCode);
if (interests == null) { if (interests == null) {
interests = new LinkedList(); interests = new LinkedList();
children.put(parent, interests); children.put(parentCode, interests);
} }
interests.add(infos[i]); interests.add(infos[i]);
......
...@@ -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;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -42,13 +40,12 @@ public class SnacManager { ...@@ -42,13 +40,12 @@ public class SnacManager {
for (int i = 0; i < families.length; i++) { for (int i = 0; i < families.length; i++) {
int familyCode = families[i]; int familyCode = families[i];
Integer family = new Integer(familyCode);
List handlers = (List) conns.get(family); List handlers = (List) conns.get(familyCode);
if (handlers == null) { if (handlers == null) {
handlers = new LinkedList(); handlers = new LinkedList();
conns.put(family, handlers); conns.put(familyCode, handlers);
} }
if (!handlers.contains(conn)) handlers.add(conn); if (!handlers.contains(conn)) handlers.add(conn);
...@@ -89,11 +86,11 @@ public class SnacManager { ...@@ -89,11 +86,11 @@ public class SnacManager {
} }
public BasicFlapConnection getConn(int familyCode) { public BasicFlapConnection getConn(int familyCode) {
Integer family = new Integer(familyCode); List handlers = (List) conns.get(familyCode);
List handlers = (List) conns.get(family);
if (handlers == null || handlers.size() == 0) return null; if (handlers == null || handlers.size() == 0) {
return null;
}
return (BasicFlapConnection) handlers.get(0); return (BasicFlapConnection) handlers.get(0);
} }
...@@ -108,7 +105,9 @@ public class SnacManager { ...@@ -108,7 +105,9 @@ public class SnacManager {
} }
public void addListener(PendingSnacListener l) { public void addListener(PendingSnacListener l) {
if (!listeners.contains(l)) listeners.add(l); if (!listeners.contains(l)) {
listeners.add(l);
}
} }
public void removeListener(PendingSnacListener l) { public void removeListener(PendingSnacListener l) {
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.protocols.yahoo; package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.logging.Logger; import java.util.logging.Logger;
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.protocols.yahoo; package org.jivesoftware.wildfire.gateway.protocols.yahoo;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.protocols.yahoo; package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -29,7 +39,7 @@ public class YahooGateway extends BaseGateway { ...@@ -29,7 +39,7 @@ public class YahooGateway extends BaseGateway {
} }
/** /**
* @see org.jivesoftware.wildfire.gateway.BaseGateway#setName() * @see org.jivesoftware.wildfire.gateway.BaseGateway#setName(String)
*/ */
@Override @Override
public void setName(String newname) { public void setName(String newname) {
......
package org.jivesoftware.wildfire.gateway.protocols.yahoo; /**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.protocols.yahoo; package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.logging.Level; import java.util.logging.Level;
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.roster;
package org.jivesoftware.wildfire.gateway.roster;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.roster; package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable; import java.io.Serializable;
...@@ -13,11 +23,8 @@ import org.xmpp.packet.JID; ...@@ -13,11 +23,8 @@ import org.xmpp.packet.JID;
* Manage contacts for a paticular JID. * Manage contacts for a paticular JID.
* *
* @author Noah Campbell * @author Noah Campbell
*
*/ */
public class ContactManager implements Serializable { public class ContactManager implements Serializable {
/** /**
* Construct a new <code>ContactManager</code> * Construct a new <code>ContactManager</code>
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.roster; package org.jivesoftware.wildfire.gateway.roster;
import org.jivesoftware.wildfire.gateway.GatewaySession; import org.jivesoftware.wildfire.gateway.GatewaySession;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.roster; package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable; import java.io.Serializable;
......
package org.jivesoftware.wildfire.gateway.roster; /**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.roster;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
......
package org.jivesoftware.wildfire.gateway.roster; /**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.roster;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
......
package org.jivesoftware.wildfire.gateway.roster; /**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
...@@ -22,7 +31,6 @@ import org.jivesoftware.wildfire.gateway.Gateway; ...@@ -22,7 +31,6 @@ import org.jivesoftware.wildfire.gateway.Gateway;
*/ */
public class Roster implements Serializable { public class Roster implements Serializable {
/** /**
* The serialVersionUID. * The serialVersionUID.
*/ */
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.roster; package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable; import java.io.Serializable;
/**
* @author Noah Campbell
* @version 1.0
*/
/** /**
* Status object. * Status object.
* *
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public final class Status implements Serializable { public final class Status implements Serializable {
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.roster; package org.jivesoftware.wildfire.gateway.roster;
import java.text.MessageFormat; import java.text.MessageFormat;
...@@ -9,20 +16,14 @@ import java.util.ResourceBundle; ...@@ -9,20 +16,14 @@ import java.util.ResourceBundle;
/** /**
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public class UnknownForeignContactException extends Exception { public class UnknownForeignContactException extends Exception {
/** The args. */ /** The args. */
private final Object[] args; private final Object[] args;
/** The serialVersionUID. */
private static final long serialVersionUID = 1L;
/** /**
* Construct a new <code>UnknownForeignContactException</code>. * Constructs a new <code>UnknownForeignContactException</code>.
*
*/ */
public UnknownForeignContactException() { public UnknownForeignContactException() {
super(); super();
...@@ -61,19 +62,4 @@ public class UnknownForeignContactException extends Exception { ...@@ -61,19 +62,4 @@ public class UnknownForeignContactException extends Exception {
super(cause); super(cause);
args = new Object[0]; args = new Object[0];
} }
}
/** \ No newline at end of file
* @see java.lang.Throwable#getLocalizedMessage()
*/
@Override
public String getLocalizedMessage() {
return MessageFormat.format(resource.getString(this.getMessage()), args);
}
/** The resource. */
private static ResourceBundle resource = PropertyResourceBundle.getBundle("exceptions");
}
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.util; package org.jivesoftware.wildfire.gateway.util;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
...@@ -9,7 +16,6 @@ import java.util.concurrent.ThreadFactory; ...@@ -9,7 +16,6 @@ import java.util.concurrent.ThreadFactory;
* Generates threads that are of low priority and daemon. * Generates threads that are of low priority and daemon.
* *
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
*/ */
public class BackgroundThreadFactory implements ThreadFactory { public class BackgroundThreadFactory implements ThreadFactory {
......
/** /**
* * $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.util; package org.jivesoftware.wildfire.gateway.util;
import java.util.logging.Level; import java.util.logging.Level;
...@@ -9,7 +16,6 @@ import java.util.logging.Level; ...@@ -9,7 +16,6 @@ import java.util.logging.Level;
* Custom log levels. * Custom log levels.
* *
* @author Noah Campbell * @author Noah Campbell
* @version 1.0
* @see java.util.logging.Level * @see java.util.logging.Level
*/ */
public class GatewayLevel extends Level { public class GatewayLevel extends Level {
...@@ -31,5 +37,4 @@ public class GatewayLevel extends Level { ...@@ -31,5 +37,4 @@ public class GatewayLevel extends Level {
/** The serialVersionUID. */ /** The serialVersionUID. */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
}
} \ No newline at end of file
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