Commit 8e20b1dc authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Prep for [GATE-147]

Fixed major bug with resource handling.
Misc debugging work with [GATE-49]

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7271 b35dd754-fafc-0310-a699-88a17e54d16e
parent f9b2ca93
......@@ -119,7 +119,7 @@ public abstract class TransportSession implements Runnable {
*/
public void addResource(String resource, Integer priority) {
resources.put(resource, priority);
if (resources.get(highestResource) >= priority) {
if (highestResource == null || resources.get(highestResource) >= priority) {
highestResource = resource;
}
}
......
......@@ -153,9 +153,9 @@ public class BOSConnection extends BasicFlapConnection {
request(new OfflineMsgIcqAckCmd(oscarSession.getUIN(), (int)oscarSession.nextIcqId()));
}
else if (cmd instanceof MetaShortInfoCmd) {
MetaShortInfoCmd msic = (MetaShortInfoCmd)cmd;
Log.debug("RECEIVED META SHORT INFO: "+msic);
oscarSession.updateRosterNickname(String.valueOf(msic.getUIN()), msic.getNickname());
// MetaShortInfoCmd msic = (MetaShortInfoCmd)cmd;
// Log.debug("RECEIVED META SHORT INFO: "+msic);
// oscarSession.updateRosterNickname(String.valueOf(msic.getUIN()), msic.getNickname());
}
}
}
......@@ -58,7 +58,7 @@ public abstract class BaseFlapConnection extends ClientFlapConn {
getFlapProcessor().addExceptionHandler(new ConnProcessorExceptionHandler() {
public void handleException(ConnProcessorExceptionEvent event) {
Log.error(event.getType() + " FLAP ERROR: "
+ event.getException().getMessage());
+ event.getException().getMessage() + " " + event.getReason());
}
});
sp.addPacketListener(new SnacPacketListener() {
......
......@@ -31,6 +31,7 @@ import net.kano.joscar.snaccmd.InfoData;
import net.kano.joscar.snaccmd.CapabilityBlock;
import net.kano.joscar.snaccmd.icq.OfflineMsgIcqRequest;
import net.kano.joscar.snaccmd.icq.MetaShortInfoRequest;
import net.kano.joscar.snaccmd.icq.MetaFullInfoRequest;
import net.kano.joscar.ssiitem.BuddyItem;
import net.kano.joscar.ssiitem.GroupItem;
import org.jivesoftware.util.Log;
......@@ -469,14 +470,14 @@ public class OSCARSession extends TransportSession {
for (BuddyItem buddy : buddies.values()) {
//Log.debug("CompleteSSI: adding "+buddy.getScreenname());
String nickname = buddy.getAlias();
if (nickname == null) {
if (nickname == null || nickname.matches("/^\\s*$/")) {
nickname = buddy.getScreenname();
}
try {
Integer buddyUIN = Integer.parseInt(buddy.getScreenname());
if (nickname.equalsIgnoreCase(buddy.getScreenname())) {
Log.debug("REQUESTING SHORT INFO FOR "+buddy.getScreenname());
request(new MetaShortInfoRequest(getUIN(), (int)nextIcqId(), buddyUIN));
Integer buddyUIN = Integer.parseInt(buddy.getScreenname());
Log.debug("REQUESTING SHORT INFO FOR "+buddyUIN);
request(new MetaFullInfoRequest(getUIN(), (int)nextIcqId(), buddyUIN));
}
}
catch (NumberFormatException e) {
......
......@@ -20,8 +20,10 @@ import org.jivesoftware.wildfire.group.GroupNotFoundException;
import org.jivesoftware.wildfire.gateway.GatewayPlugin;
import org.jivesoftware.wildfire.gateway.TransportType;
import org.jivesoftware.wildfire.gateway.PermissionManager;
import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.NotFoundException;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Attribute;
......@@ -196,4 +198,101 @@ public class ConfigManager {
return errorList;
}
/**
* Adds a new registration via the web interface.
*
* @param user Username or full JID of user who is getting an account registered.
* @param transportType Type of transport to add user to.
* @param legacyUsername User's username on the legacy service.
* @param legacyPassword User's password on the legacy service.
* @param legacyNickname User's nickname on the legacy service.
* @return Error message or null on success.
*/
public String addRegistration(String user, String transportType, String legacyUsername, String legacyPassword, String legacyNickname) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
GatewayPlugin plugin = (GatewayPlugin)pluginManager.getPlugin("gateway");
JID jid;
if (user.contains("@")) {
jid = new JID(user);
}
else {
jid = new JID(user, XMPPServer.getInstance().getServerInfo().getName(), null);
}
if (!plugin.getTransportInstance(transportType).isEnabled()) {
return "Transport is not enabled. Please enable before attempting adds.";
}
try {
plugin.getTransportInstance(transportType).getTransport().addNewRegistration(jid, legacyUsername, legacyPassword, legacyNickname, false);
return null;
}
catch (UserNotFoundException e) {
Log.error("Not found while adding account for "+jid.toString());
return "Unable to find XMPP user account.";
}
catch (IllegalAccessException e) {
Log.error("Domain of JID specified for registration is not on this server: "+jid.toString());
return "XMPP user account domain is not on this server.";
}
catch (IllegalArgumentException e) {
Log.error("Username specified for registration is not valid.");
return "Invalid username specified for legacy service.";
}
}
/**
* Deletes a registration via the web interface.
*
* @param registrationID ID number associated with registration to delete.
* @return Error message or null on success.
*/
public String deleteRegistration(Integer registrationID) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
GatewayPlugin plugin = (GatewayPlugin)pluginManager.getPlugin("gateway");
try {
Registration reg = new Registration(registrationID);
if (!plugin.getTransportInstance(reg.getTransportType().toString()).isEnabled()) {
return "Transport is not enabled. Please enable before attempting deletes.";
}
plugin.getTransportInstance(reg.getTransportType().toString()).getTransport().deleteRegistration(reg.getJID());
return null;
}
catch (NotFoundException e) {
// Ok, nevermind.
Log.error("Not found while deleting id "+registrationID, e);
return "Unable to find XMPP user account.";
}
catch (UserNotFoundException e) {
// Ok, nevermind.
Log.error("Not found while deleting id "+registrationID, e);
return "Unable to find registration.";
}
}
/**
* Updates a registration via the web interface.
*
*
* @param registrationID ID number associated with registration to modify.
* @param legacyUsername User's updated username on the legacy service.
* @param legacyPassword User's updated password on the legacy service, null if no change.
* @param legacyNickname User's updated nickname on the legacy service.
* @return Error message or null on success.
*/
public String updateRegistration(Integer registrationID, String legacyUsername, String legacyPassword, String legacyNickname) {
try {
Registration reg = new Registration(registrationID);
reg.setUsername(legacyUsername);
if (legacyPassword != null) {
reg.setPassword(legacyPassword);
}
reg.setNickname(legacyNickname);
return null;
}
catch (NotFoundException e) {
// Ok, nevermind.
Log.error("Not found while editing id "+registrationID, e);
return "Unable to find registration.";
}
}
}
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