diff options
author | Jeffrey Sharkey <jsharkey@jsharkey.org> | 2008-08-27 11:07:56 +0000 |
---|---|---|
committer | Jeffrey Sharkey <jsharkey@jsharkey.org> | 2008-08-27 11:07:56 +0000 |
commit | b2d4605baaec564315832c0358ccf6e824952632 (patch) | |
tree | 3fd596b2c91ca4a8857dfdee6f5ed75f02f9f2e4 /src | |
parent | cbf1af86640c76facfc140b5dfb83f2393c02d19 (diff) | |
download | connectbot-b2d4605baaec564315832c0358ccf6e824952632.tar.gz connectbot-b2d4605baaec564315832c0358ccf6e824952632.tar.bz2 connectbot-b2d4605baaec564315832c0358ccf6e824952632.zip |
* fixed password prompting, still messy solution
Diffstat (limited to 'src')
-rw-r--r-- | src/org/theb/ssh/HostsList.java | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/src/org/theb/ssh/HostsList.java b/src/org/theb/ssh/HostsList.java index 703d09c..4b6fdf0 100644 --- a/src/org/theb/ssh/HostsList.java +++ b/src/org/theb/ssh/HostsList.java @@ -18,6 +18,8 @@ */ package org.theb.ssh; +import java.util.concurrent.Semaphore; + import org.connectbot.Console; import org.connectbot.service.TerminalBridge; import org.connectbot.service.TerminalManager; @@ -319,36 +321,74 @@ public class HostsList extends ListActivity { cursor.moveToFirst(); // try finding an already-open bridge for this connection - String nickname = cursor.getString(0); + final String nickname = cursor.getString(0); TerminalBridge bridge = bound.findBridge(nickname); if(bridge == null) { // too bad, looks like we have to open the bridge ourselves - String username = cursor.getString(1); - String hostname = cursor.getString(2); - int port = cursor.getInt(3); - String emulation = cursor.getString(4); - int scrollback = cursor.getInt(5); - String hostkey = cursor.getString(6); + final String username = cursor.getString(1); + final String hostname = cursor.getString(2); + final int port = cursor.getInt(3); + final String emulation = cursor.getString(4); + final int scrollback = cursor.getInt(5); + final String hostkey = cursor.getString(6); try { - //Connection conn; - //bound.openConnection(conn, nickname, emulation, scrollback); - bound.openConnection(nickname, hostname, port, username, "moocow", "screen", 100); + // TODO: this is horridly messy lol + // TODO: finish copying over logic from TrileadConnectionThread here + + this.startActivityForResult(new Intent(this, PasswordDialog.class), PASSWORD_REQUEST); + + Thread connect = new Thread(new Runnable() { + + public void run() { + try { + waitPassword.acquire(); + //Connection conn; + //bound.openConnection(conn, nickname, emulation, scrollback); + bound.openConnection(nickname, hostname, port, username, password, "screen", 100); + + // open the console view and select this specific terminal + Intent intent = new Intent(HostsList.this, Console.class); + intent.putExtra(Intent.EXTRA_TEXT, nickname); + startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + password = null; + } + }); + connect.start(); + } catch(Exception e) { e.printStackTrace(); } + } else { + // we found an existing terminal, so open it + // open the console view and select this specific terminal + Intent intent = new Intent(this, Console.class); + intent.putExtra(Intent.EXTRA_TEXT, nickname); + this.startActivity(intent); } - // open the console view and select this specific terminal - Intent intent = new Intent(this, Console.class); - intent.putExtra(Intent.EXTRA_TEXT, nickname); - this.startActivity(intent); } } + public final static int PASSWORD_REQUEST = 42; + public Semaphore waitPassword = new Semaphore(0); + public String password = null; + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if(requestCode == PASSWORD_REQUEST) { + this.password = data.getStringExtra(Intent.EXTRA_TEXT); + this.waitPassword.release(); + } + } + + private final void deleteItem() { mCursor.move(getSelectedItemPosition()); Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); |