diff options
Diffstat (limited to 'src/main/java/eu/siacs')
3 files changed, 40 insertions, 11 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index a295b2ce..d4fda1b8 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1969,7 +1969,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } } } - Element form = query.findChild("x","jabber:x:data"); + Element form = query.findChild("x", "jabber:x:data"); if (form != null) { conversation.getMucOptions().updateFormData(Data.parse(form)); } @@ -2378,7 +2378,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa updateConversationUi(); updateRosterUi(); } else { - Conversation conversation = find(account,avatar.owner.toBareJid()); + Conversation conversation = find(account, avatar.owner.toBareJid()); if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { MucOptions.User user = conversation.getMucOptions().findUser(avatar.owner.getResourcepart()); if (user != null) { @@ -2586,6 +2586,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false); } + public boolean showExtendedConnectionOptions() { + return getPreferences().getBoolean("show_connection_options", false); + } + public int unreadCount() { int count = 0; for (Conversation conversation : getConversations()) { diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 24490699..5c783f54 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -5,6 +5,7 @@ import android.app.AlertDialog.Builder; import android.app.PendingIntent; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; @@ -91,7 +92,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate private Jid jidToEdit; private boolean mInitMode = false; - private boolean mUseTor = false; + private boolean mShowOptions = false; private Account mAccount; private String messageFingerprint; @@ -133,7 +134,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } String hostname = null; int numericPort = 5222; - if (mUseTor) { + if (mShowOptions) { hostname = mHostname.getText().toString(); final String port = mPort.getText().toString(); if (hostname.contains(" ")) { @@ -511,8 +512,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } } } - this.mUseTor = Config.FORCE_ORBOT || getPreferences().getBoolean("use_tor", false); - this.mNamePort.setVisibility(mUseTor ? View.VISIBLE : View.GONE); + SharedPreferences preferences = getPreferences(); + boolean useTor = Config.FORCE_ORBOT || preferences.getBoolean("use_tor", false); + this.mShowOptions = useTor || preferences.getBoolean("show_connection_options", false); + mHostname.setHint(useTor ? R.string.hostname_or_onion : R.string.hostname_example); + this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE); } @Override @@ -598,7 +602,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate this.mHostname.getEditableText().append(this.mAccount.getHostname()); this.mPort.setText(""); this.mPort.getEditableText().append(String.valueOf(this.mAccount.getPort())); - this.mNamePort.setVisibility(mUseTor ? View.VISIBLE : View.GONE); + this.mNamePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE); } if (!mInitMode) { @@ -740,12 +744,24 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } } else { if (this.mAccount.errorStatus()) { - this.mAccountJid.setError(getString(this.mAccount.getStatus().getReadableId())); + final EditText errorTextField; + if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED) { + errorTextField = this.mPassword; + } else if (mShowOptions + && this.mAccount.getStatus() == Account.State.SERVER_NOT_FOUND + && this.mHostname.getText().length() > 0) { + errorTextField = this.mHostname; + } else { + errorTextField = this.mAccountJid; + } + errorTextField.setError(getString(this.mAccount.getStatus().getReadableId())); if (init || !accountInfoEdited()) { - this.mAccountJid.requestFocus(); + errorTextField.requestFocus(); } } else { this.mAccountJid.setError(null); + this.mPassword.setError(null); + this.mHostname.setError(null); } this.mStats.setVisibility(View.GONE); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index a3dd0644..a39ccc37 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -243,6 +243,7 @@ public class XmppConnection implements Runnable { tagWriter = new TagWriter(); this.changeStatus(Account.State.CONNECTING); final boolean useTor = mXmppConnectionService.useTorToConnect() || account.isOnion(); + final boolean extended = mXmppConnectionService.showExtendedConnectionOptions(); if (useTor) { String destination; if (account.getHostname() == null || account.getHostname().isEmpty()) { @@ -250,8 +251,16 @@ public class XmppConnection implements Runnable { } else { destination = account.getHostname(); } - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": connect to "+destination+" via TOR"); - socket = SocksSocketFactory.createSocketOverTor(destination,account.getPort()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": connect to " + destination + " via TOR"); + socket = SocksSocketFactory.createSocketOverTor(destination, account.getPort()); + startXmpp(); + } else if (extended && account.getHostname() != null && !account.getHostname().isEmpty()) { + socket = new Socket(); + try { + socket.connect(new InetSocketAddress(account.getHostname(), account.getPort()), Config.SOCKET_TIMEOUT * 1000); + } catch (IOException e) { + throw new UnknownHostException(); + } startXmpp(); } else if (DNSHelper.isIp(account.getServer().toString())) { socket = new Socket(); |