added special error state for dns timeout

This commit is contained in:
Daniel Gultsch 2015-09-01 22:37:52 +02:00
parent 91b0605bc2
commit fc594e249a
4 changed files with 13 additions and 4 deletions

View File

@ -62,7 +62,8 @@ public class Account extends AbstractEntity {
REGISTRATION_SUCCESSFUL, REGISTRATION_SUCCESSFUL,
REGISTRATION_NOT_SUPPORTED(true), REGISTRATION_NOT_SUPPORTED(true),
SECURITY_ERROR(true), SECURITY_ERROR(true),
INCOMPATIBLE_SERVER(true); INCOMPATIBLE_SERVER(true),
DNS_TIMEOUT(true);
private final boolean isError; private final boolean isError;
@ -106,6 +107,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_security_error; return R.string.account_status_security_error;
case INCOMPATIBLE_SERVER: case INCOMPATIBLE_SERVER:
return R.string.account_status_incompatible_server; return R.string.account_status_incompatible_server;
case DNS_TIMEOUT:
return R.string.account_status_dns_timeout;
default: default:
return R.string.account_status_unknown; return R.string.account_status_unknown;
} }

View File

@ -1881,8 +1881,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
MessagePacket packet = new MessagePacket(); MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_CHAT); packet.setType(MessagePacket.TYPE_CHAT);
packet.setFrom(account.getJid()); packet.setFrom(account.getJid());
packet.addChild("private", "urn:xmpp:carbons:2"); MessageGenerator.addMessageHints(packet);
packet.addChild("no-copy", "urn:xmpp:hints");
packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/" packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/"
+ otrSession.getSessionID().getUserID()); + otrSession.getSessionID().getUserID());
try { try {

View File

@ -165,7 +165,7 @@ public class XmppConnection implements Runnable {
} }
final ArrayList<Parcelable> values = result.getParcelableArrayList("values"); final ArrayList<Parcelable> values = result.getParcelableArrayList("values");
if ("timeout".equals(result.getString("error"))) { if ("timeout".equals(result.getString("error"))) {
throw new IOException("timeout in dns"); throw new DnsTimeoutException();
} else if (values != null) { } else if (values != null) {
int i = 0; int i = 0;
boolean socketError = true; boolean socketError = true;
@ -234,6 +234,8 @@ public class XmppConnection implements Runnable {
this.changeStatus(Account.State.UNAUTHORIZED); this.changeStatus(Account.State.UNAUTHORIZED);
} catch (final UnknownHostException | ConnectException e) { } catch (final UnknownHostException | ConnectException e) {
this.changeStatus(Account.State.SERVER_NOT_FOUND); this.changeStatus(Account.State.SERVER_NOT_FOUND);
} catch (final DnsTimeoutException e) {
this.changeStatus(Account.State.DNS_TIMEOUT);
} catch (final IOException | XmlPullParserException | NoSuchAlgorithmException e) { } catch (final IOException | XmlPullParserException | NoSuchAlgorithmException e) {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage()); Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
this.changeStatus(Account.State.OFFLINE); this.changeStatus(Account.State.OFFLINE);
@ -1163,6 +1165,10 @@ public class XmppConnection implements Runnable {
} }
private class DnsTimeoutException extends IOException {
}
public class Features { public class Features {
XmppConnection connection; XmppConnection connection;
private boolean carbonsEnabled = false; private boolean carbonsEnabled = false;

View File

@ -512,4 +512,5 @@
<string name="download_failed_could_not_connect">Download failed: Could not connect to host</string> <string name="download_failed_could_not_connect">Download failed: Could not connect to host</string>
<string name="pref_use_white_background">Use white background</string> <string name="pref_use_white_background">Use white background</string>
<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_dns_timeout">Timeout in DNS</string>
</resources> </resources>