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

[GATE-142] Detecting MSN IO error and handling properly.

[GATE-182] Handling multiple resources properly now.
Misc tweak to registration page.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7269 b35dd754-fafc-0310-a699-88a17e54d16e
parent b9f17530
......@@ -224,6 +224,7 @@ gateway.msn.registration=Please enter your MSN Passport e-mail address and passw
gateway.msn.passwordincorrect=The password you registered with is incorrect. Please re-register with the correct password.
gateway.msn.sendmsgfailed=Unable to send MSN message. Reason:
gateway.msn.illegalaccount=You are registered with the MSN transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
gateway.msn.disconnect=You were disconnected from the MSN service.
# Yahoo Transport
gateway.yahoo.shortservice=Yahoo
......
......@@ -149,4 +149,5 @@ gateway.sip.password=Password
gateway.sip.registration=Please enter your SIMPLE username and password.
gateway.sip.passwordincorrect=The password you registered with is incorrect. Please re-register with the correct password.
gateway.sip.sendmsgfailed=Unable to send SIMPLE message. Reason:
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
\ No newline at end of file
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
gateway.msn.disconnect=You were disconnected from the MSN service.
\ No newline at end of file
......@@ -149,4 +149,5 @@ gateway.sip.password=Password
gateway.sip.registration=Please enter your SIMPLE username and password.
gateway.sip.passwordincorrect=The password you registered with is incorrect. Please re-register with the correct password.
gateway.sip.sendmsgfailed=Unable to send SIMPLE message. Reason:
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
\ No newline at end of file
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
gateway.msn.disconnect=You were disconnected from the MSN service.
\ No newline at end of file
......@@ -149,4 +149,5 @@ gateway.sip.password=Password
gateway.sip.registration=Please enter your SIMPLE username and password.
gateway.sip.passwordincorrect=The password you registered with is incorrect. Please re-register with the correct password.
gateway.sip.sendmsgfailed=Unable to send SIMPLE message. Reason:
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
\ No newline at end of file
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
gateway.msn.disconnect=You were disconnected from the MSN service.
\ No newline at end of file
......@@ -149,4 +149,5 @@ gateway.sip.password=Password
gateway.sip.registration=Please enter your SIMPLE username and password.
gateway.sip.passwordincorrect=The password you registered with is incorrect. Please re-register with the correct password.
gateway.sip.sendmsgfailed=Unable to send SIMPLE message. Reason:
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
\ No newline at end of file
gateway.sip.illegalaccount=You are registered with the SIP/SIMPLE transport with an illegal account name.\nThe account name should look like an email address.\nYou registered as:
gateway.msn.disconnect=You were disconnected from the MSN service.
\ No newline at end of file
......@@ -16,8 +16,8 @@ import org.jivesoftware.wildfire.roster.RosterItem;
import org.jivesoftware.wildfire.roster.Roster;
import org.jivesoftware.util.Log;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
/**
* Interface for a transport session.
......@@ -79,7 +79,12 @@ public abstract class TransportSession implements Runnable {
/**
* All JIDs (including resources) that are associated with this session.
*/
public TreeMap<Integer,String> resources = new TreeMap<Integer,String>();
public ConcurrentHashMap<String,Integer> resources = new ConcurrentHashMap<String,Integer>();
/**
* Current highest resource.
*/
public String highestResource = null;
/**
* Is this session valid? Set to false when session is done.
......@@ -113,7 +118,10 @@ public abstract class TransportSession implements Runnable {
* @param priority Priority of resource
*/
public void addResource(String resource, Integer priority) {
resources.put(priority, resource);
resources.put(resource, priority);
if (resources.get(highestResource) >= priority) {
highestResource = resource;
}
}
/**
......@@ -122,17 +130,23 @@ public abstract class TransportSession implements Runnable {
* @param resource Resource string
*/
public void removeResource(String resource) {
for (Integer i : resources.keySet()) {
if (resources.get(i).equals(resource)) {
resources.remove(i);
try {
getTransport().notifyRosterOffline(new JID(getJID().getNode(),getJID().getDomain(),resource));
}
catch (UserNotFoundException e) {
// Don't care
resources.remove(resource);
try {
getTransport().notifyRosterOffline(new JID(getJID().getNode(),getJID().getDomain(),resource));
}
catch (UserNotFoundException e) {
// Don't care
}
if (resource.equals(highestResource)) {
Integer highestPriority = -255;
String tmpHighestResource = null;
for (String res : resources.keySet()) {
if (resources.get(res) > highestPriority) {
tmpHighestResource = res;
highestPriority = resources.get(res);
}
break;
}
highestResource = tmpHighestResource;
}
}
......@@ -143,20 +157,23 @@ public abstract class TransportSession implements Runnable {
* @param priority New priority
*/
public void updateResource(String resource, Integer priority) {
for (Integer i : resources.keySet()) {
if (resources.get(i).equals(resource)) {
resources.remove(i);
break;
resources.put(resource, priority);
Integer highestPriority = -255;
String tmpHighestResource = null;
for (String res : resources.keySet()) {
if (resources.get(res) > highestPriority) {
tmpHighestResource = res;
highestPriority = resources.get(res);
}
}
resources.put(priority, resource);
highestResource = tmpHighestResource;
}
/**
* Removes all resources associated with a session.
*/
public void removeAllResources() {
for (String resource : resources.values()) {
for (String resource : resources.keySet()) {
removeResource(resource);
}
}
......@@ -274,7 +291,7 @@ public abstract class TransportSession implements Runnable {
* @return Full JID including resource with highest priority.
*/
public JID getJIDWithHighestPriority() {
return new JID(jid.getNode(),jid.getDomain(),resources.get(resources.lastKey()));
return new JID(jid.getNode(),jid.getDomain(),highestResource);
}
/**
......@@ -284,7 +301,7 @@ public abstract class TransportSession implements Runnable {
* @return True or false if the resource is the highest priority.
*/
public Boolean isHighestPriority(String resource) {
return (resources.get(resources.lastKey()).equals(resource));
return (highestResource.equals(resource));
}
/**
......@@ -305,12 +322,7 @@ public abstract class TransportSession implements Runnable {
* @return Priority of the resource, or null if not found.
*/
public Integer getPriority(String resource) {
for (Integer i : resources.keySet()) {
if (resources.get(i).equals(resource)) {
return i;
}
}
return null;
return resources.get(resource);
}
/**
......@@ -320,7 +332,7 @@ public abstract class TransportSession implements Runnable {
* @return True of false if the resource is associated with this session.
*/
public Boolean hasResource(String resource) {
return (resources.containsValue(resource));
return (resources.containsKey(resource));
}
/**
......
......@@ -269,6 +269,16 @@ public class MSNListener extends MsnAdapter {
// m.setBody("MSN protocol error: "+throwable.toString());
// msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("java.io.IOException")) {
Log.debug("MSN: IO error: "+throwable.toString());
msnSession.getTransport().sendMessage(
msnSession.getJIDWithHighestPriority(),
msnSession.getTransport().getJID(),
LocaleUtils.getLocalizedString("gateway.msn.disconnect", "gateway"),
Message.Type.error
);
msnSession.logOut();
}
else {
Log.debug("MSN: Unknown error: "+throwable.toString());
// Message m = new Message();
......
......@@ -437,32 +437,32 @@
<strong>Filter by:</strong>
<label for="filterAIMcheckbox">
<input type="checkbox" name="filter[]" value="aim" <%= ((filteropts.contains("aim")) ? "checked" : "") %> id="filterAIMcheckbox">
<img src="images/aim.gif" alt="" border="0" alt="<fmt:message key="gateway.aim.shortservice" />">
<img src="images/aim.gif" border="0" alt="<fmt:message key="gateway.aim.shortservice" />">
<!--<span><fmt:message key="gateway.aim.shortservice" /></span>-->
</label>
<label for="filterICQcheckbox">
<input type="checkbox" name="filter[]" value="icq" <%= ((filteropts.contains("icq")) ? "checked" : "") %> id="filterICQcheckbox">
<img src="images/icq.gif" alt="" border="0" alt="<fmt:message key="gateway.icq.shortservice" />">
<img src="images/icq.gif" border="0" alt="<fmt:message key="gateway.icq.shortservice" />">
<!--<span><fmt:message key="gateway.icq.shortservice" /></span>-->
</label>
<label for="filterIRCcheckbox">
<input type="checkbox" name="filter[]" value="irc" <%= ((filteropts.contains("irc")) ? "checked" : "") %> id="filterIRCcheckbox">
<img src="images/irc.gif" alt="" border="0" alt="<fmt:message key="gateway.irc.shortservice" />">
<img src="images/irc.gif" border="0" alt="<fmt:message key="gateway.irc.shortservice" />">
<!--<span><fmt:message key="gateway.irc.shortservice" /></span>-->
</label>
<label for="filterMSNcheckbox">
<input type="checkbox" name="filter[]" value="msn" <%= ((filteropts.contains("msn")) ? "checked" : "") %> id="filterMSNcheckbox">
<img src="images/msn.gif" alt="" border="0" alt="<fmt:message key="gateway.msn.shortservice" />">
<img src="images/msn.gif" border="0" alt="<fmt:message key="gateway.msn.shortservice" />">
<!--<span><fmt:message key="gateway.msn.shortservice" /></span>-->
</label>
<label for="filterSIPcheckbox">
<input type="checkbox" name="filter[]" value="sip" <%= ((filteropts.contains("sip")) ? "checked" : "") %> id="filterSIPcheckbox">
<img src="images/sipsimple.gif" alt="" border="0" alt="<fmt:message key="gateway.sip.shortservice" />">
<img src="images/sipsimple.gif" border="0" alt="<fmt:message key="gateway.sip.shortservice" />">
<!--<span><fmt:message key="gateway.sip.shortservice" /></span>-->
</label>
<label for="filterYAHOOcheckbox">
<input type="checkbox" name="filter[]" value="yahoo" <%= ((filteropts.contains("yahoo")) ? "checked" : "") %> id="filterYAHOOcheckbox">
<img src="images/yahoo.gif" alt="" border="0" alt="<fmt:message key="gateway.yahoo.shortservice" />">
<img src="images/yahoo.gif" border="0" alt="<fmt:message key="gateway.yahoo.shortservice" />">
<!--<span><fmt:message key="gateway.yahoo.shortservice" /></span>-->
</label>
<label for="filterActiveOnly">
......
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