From 285d86b375e6d8ccd10ae8ff830fc055fb123c43 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 19 Aug 2016 21:47:08 +0200 Subject: display error status for missing internet permission --- src/main/java/eu/siacs/conversations/entities/Account.java | 5 ++++- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 14 ++++++++------ src/main/res/values/strings.xml | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index b77d85c4..b3694108 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -112,7 +112,8 @@ public class Account extends AbstractEntity { STREAM_ERROR(true), POLICY_VIOLATION(true), REGISTRATION_PASSWORD_TOO_WEAK(true), - PAYMENT_REQUIRED(true); + PAYMENT_REQUIRED(true), + MISSING_INTERNET_PERMISSION(true); private final boolean isError; @@ -172,6 +173,8 @@ public class Account extends AbstractEntity { return R.string.account_status_stream_error; case PAYMENT_REQUIRED: return R.string.payment_required; + case MISSING_INTERNET_PERMISSION: + return R.string.missing_internet_permission; default: return R.string.account_status_unknown; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 6e36a546..528c14ed 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -284,7 +284,7 @@ public class XmppConnection implements Runnable { socket = tlsFactoryVerifier.factory.createSocket(); socket.connect(address, Config.SOCKET_TIMEOUT * 1000); final SSLSession session = ((SSLSocket) socket).getSession(); - if (!tlsFactoryVerifier.verifier.verify(account.getServer().getDomainpart(),session)) { + if (!tlsFactoryVerifier.verifier.verify(account.getServer().getDomainpart(), session)) { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": TLS certificate verification failed"); throw new SecurityException(); } @@ -310,10 +310,10 @@ public class XmppConnection implements Runnable { startXmpp(); } else { final Bundle result = DNSHelper.getSRVRecord(account.getServer(), mXmppConnectionService); - final ArrayListvalues = result.getParcelableArrayList("values"); - for(Iterator iterator = values.iterator(); iterator.hasNext();) { + final ArrayList values = result.getParcelableArrayList("values"); + for (Iterator iterator = values.iterator(); iterator.hasNext(); ) { if (Thread.currentThread().isInterrupted()) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": Thread was interrupted"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": Thread was interrupted"); return; } final Bundle namePort = (Bundle) iterator.next(); @@ -367,10 +367,10 @@ public class XmppConnection implements Runnable { if (startXmpp()) break; // successfully connected to server that speaks xmpp - } catch(final SecurityException e) { + } catch (final SecurityException e) { throw e; } catch (final Throwable e) { - Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage() +"("+e.getClass().getName()+")"); + Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage() + "(" + e.getClass().getName() + ")"); if (!iterator.hasNext()) { throw new UnknownHostException(); } @@ -378,6 +378,8 @@ public class XmppConnection implements Runnable { } } processStream(); + } catch (final java.lang.SecurityException e) { + this.changeStatus(Account.State.MISSING_INTERNET_PERMISSION); } catch (final IncompatibleServerException e) { this.changeStatus(Account.State.INCOMPATIBLE_SERVER); } catch (final SecurityException e) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index ab175a36..3148cacb 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -675,4 +675,5 @@ Web browser Console Payment required + Missing internet permission -- cgit v1.2.3