report host-account as account state in UI

This commit is contained in:
Daniel Gultsch 2016-05-10 10:29:02 +02:00
parent 27b245ac35
commit 549be9bb3d
3 changed files with 14 additions and 4 deletions

View File

@ -94,7 +94,8 @@ public class Account extends AbstractEntity {
SECURITY_ERROR(true), SECURITY_ERROR(true),
INCOMPATIBLE_SERVER(true), INCOMPATIBLE_SERVER(true),
TOR_NOT_AVAILABLE(true), TOR_NOT_AVAILABLE(true),
BIND_FAILURE(true); BIND_FAILURE(true),
HOST_UNKNOWN(true);
private final boolean isError; private final boolean isError;
@ -142,6 +143,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_tor_unavailable; return R.string.account_status_tor_unavailable;
case BIND_FAILURE: case BIND_FAILURE:
return R.string.account_status_bind_failure; return R.string.account_status_bind_failure;
case HOST_UNKNOWN:
return R.string.account_status_host_unknown;
default: default:
return R.string.account_status_unknown; return R.string.account_status_unknown;
} }

View File

@ -880,6 +880,7 @@ public class XmppConnection implements Runnable {
} }
public void resetEverything() { public void resetEverything() {
resetAttemptCount();
resetStreamId(); resetStreamId();
clearIqCallbacks(); clearIqCallbacks();
mStanzaQueue.clear(); mStanzaQueue.clear();
@ -1173,15 +1174,20 @@ public class XmppConnection implements Runnable {
private void processStreamError(final Tag currentTag) private void processStreamError(final Tag currentTag)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
final Element streamError = tagReader.readElement(currentTag); final Element streamError = tagReader.readElement(currentTag);
if (streamError != null && streamError.hasChild("conflict")) { if (streamError == null) {
return;
}
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": stream error "+streamError.toString());
if (streamError.hasChild("conflict")) {
final String resource = account.getResource().split("\\.")[0]; final String resource = account.getResource().split("\\.")[0];
account.setResource(resource + "." + nextRandomId()); account.setResource(resource + "." + nextRandomId());
Log.d(Config.LOGTAG, Log.d(Config.LOGTAG,
account.getJid().toBareJid() + ": switching resource due to conflict (" account.getJid().toBareJid() + ": switching resource due to conflict ("
+ account.getResource() + ")"); + account.getResource() + ")");
} else if (streamError != null) { } else if (streamError.hasChild("host-unknown")) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": stream error "+streamError.toString()); changeStatus(Account.State.HOST_UNKNOWN);
} }
forceCloseSocket();
} }
private void sendStartStream() throws IOException { private void sendStartStream() throws IOException {

View File

@ -542,6 +542,7 @@
<string name="pref_use_white_background_summary">Show received messages as black text on a white background</string> <string name="pref_use_white_background_summary">Show received messages as black text on a white background</string>
<string name="account_status_tor_unavailable">Tor network unavailable</string> <string name="account_status_tor_unavailable">Tor network unavailable</string>
<string name="account_status_bind_failure">Bind failure</string> <string name="account_status_bind_failure">Bind failure</string>
<string name="account_status_host_unknown">Domain not recognized</string>
<string name="server_info_broken">Broken</string> <string name="server_info_broken">Broken</string>
<string name="pref_presence_settings">Presence</string> <string name="pref_presence_settings">Presence</string>
<string name="pref_away_when_screen_off">Away when screen is off</string> <string name="pref_away_when_screen_off">Away when screen is off</string>