add more error states for stream errors
This commit is contained in:
		
							parent
							
								
									2803d342e1
								
							
						
					
					
						commit
						1db85e582e
					
				| @ -108,7 +108,9 @@ public class Account extends AbstractEntity { | ||||
| 		TOR_NOT_AVAILABLE(true), | ||||
| 		BIND_FAILURE(true), | ||||
| 		HOST_UNKNOWN(true), | ||||
| 		REGISTRATION_PLEASE_WAIT(true); | ||||
| 		REGISTRATION_PLEASE_WAIT(true), | ||||
| 		STREAM_ERROR(true), | ||||
| 		POLICY_VIOLATION(true); | ||||
| 
 | ||||
| 		private final boolean isError; | ||||
| 
 | ||||
| @ -158,8 +160,12 @@ public class Account extends AbstractEntity { | ||||
| 					return R.string.account_status_bind_failure; | ||||
| 				case HOST_UNKNOWN: | ||||
| 					return R.string.account_status_host_unknown; | ||||
| 				case POLICY_VIOLATION: | ||||
| 					return R.string.account_status_policy_violation; | ||||
| 				case REGISTRATION_PLEASE_WAIT: | ||||
| 					return R.string.registration_please_wait; | ||||
| 				case STREAM_ERROR: | ||||
| 					return R.string.account_status_stream_error; | ||||
| 				default: | ||||
| 					return R.string.account_status_unknown; | ||||
| 			} | ||||
|  | ||||
| @ -361,6 +361,12 @@ public class XmppConnection implements Runnable { | ||||
| 			this.changeStatus(Account.State.SERVER_NOT_FOUND); | ||||
| 		} catch (final SocksSocketFactory.SocksProxyNotFoundException e) { | ||||
| 			this.changeStatus(Account.State.TOR_NOT_AVAILABLE); | ||||
| 		} catch(final StreamErrorHostUnknown e) { | ||||
| 			this.changeStatus(Account.State.HOST_UNKNOWN); | ||||
| 		} catch(final StreamErrorPolicyViolation e) { | ||||
| 			this.changeStatus(Account.State.POLICY_VIOLATION); | ||||
| 		} catch(final StreamError e) { | ||||
| 			this.changeStatus(Account.State.STREAM_ERROR); | ||||
| 		} catch (final IOException | XmlPullParserException | NoSuchAlgorithmException e) { | ||||
| 			Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage()); | ||||
| 			this.changeStatus(Account.State.OFFLINE); | ||||
| @ -1176,17 +1182,21 @@ public class XmppConnection implements Runnable { | ||||
| 		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]; | ||||
| 			account.setResource(resource + "." + nextRandomId()); | ||||
| 			Log.d(Config.LOGTAG, | ||||
| 					account.getJid().toBareJid() + ": switching resource due to conflict (" | ||||
| 					+ account.getResource() + ")"); | ||||
| 			throw new IOException(); | ||||
| 		} else if (streamError.hasChild("host-unknown")) { | ||||
| 			changeStatus(Account.State.HOST_UNKNOWN); | ||||
| 			throw new StreamErrorHostUnknown(); | ||||
| 		} else if (streamError.hasChild("policy-violation")) { | ||||
| 			throw new StreamErrorPolicyViolation(); | ||||
| 		} else { | ||||
| 			Log.d(Config.LOGTAG,account.getJid().toBareJid()+": stream error "+streamError.toString()); | ||||
| 			throw new StreamError(); | ||||
| 		} | ||||
| 		forceCloseSocket(); | ||||
| 	} | ||||
| 
 | ||||
| 	private void sendStartStream() throws IOException { | ||||
| @ -1485,6 +1495,18 @@ public class XmppConnection implements Runnable { | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	private class StreamErrorHostUnknown extends StreamError { | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	private class StreamErrorPolicyViolation extends StreamError { | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	private class StreamError extends IOException { | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	public enum Identity { | ||||
| 		FACEBOOK, | ||||
| 		SLACK, | ||||
|  | ||||
| @ -158,7 +158,9 @@ | ||||
| 	<string name="account_status_regis_success">Registration completed</string> | ||||
| 	<string name="account_status_regis_not_sup">Server does not support registration</string> | ||||
| 	<string name="account_status_security_error">Security error</string> | ||||
| 	<string name="account_status_policy_violation">Policy violation</string> | ||||
| 	<string name="account_status_incompatible_server">Incompatible server</string> | ||||
| 	<string name="account_status_stream_error">Stream error</string> | ||||
| 	<string name="encryption_choice_unencrypted">Unencrypted</string> | ||||
| 	<string name="encryption_choice_otr">OTR</string> | ||||
| 	<string name="encryption_choice_pgp">OpenPGP</string> | ||||
| @ -546,7 +548,7 @@ | ||||
| 	<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_bind_failure">Bind failure</string> | ||||
| 	<string name="account_status_host_unknown">Host unknown</string> | ||||
| 	<string name="account_status_host_unknown">Server not responsible for domain</string> | ||||
| 	<string name="server_info_broken">Broken</string> | ||||
| 	<string name="pref_presence_settings">Presence</string> | ||||
| 	<string name="pref_away_when_screen_off">Away when screen is off</string> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch