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