diff options
Diffstat (limited to 'src/org/theb/ssh')
-rw-r--r-- | src/org/theb/ssh/ConnectionThread.java | 30 | ||||
-rw-r--r-- | src/org/theb/ssh/FeedbackUI.java | 25 | ||||
-rw-r--r-- | src/org/theb/ssh/HostDbProvider.java | 257 | ||||
-rw-r--r-- | src/org/theb/ssh/HostEditor.java | 177 | ||||
-rw-r--r-- | src/org/theb/ssh/HostsList.java | 406 | ||||
-rw-r--r-- | src/org/theb/ssh/InteractiveHostKeyVerifier.java | 32 | ||||
-rw-r--r-- | src/org/theb/ssh/JCTerminalView.java | 330 | ||||
-rw-r--r-- | src/org/theb/ssh/JTATerminalView.java | 375 | ||||
-rw-r--r-- | src/org/theb/ssh/PasswordDialog.java | 52 | ||||
-rw-r--r-- | src/org/theb/ssh/Pubkey.java | 133 | ||||
-rw-r--r-- | src/org/theb/ssh/SecureShell.java | 236 | ||||
-rw-r--r-- | src/org/theb/ssh/Terminal.java | 32 | ||||
-rw-r--r-- | src/org/theb/ssh/TouchEntropy.java | 91 | ||||
-rw-r--r-- | src/org/theb/ssh/TrileadConnectionThread.java | 160 |
14 files changed, 0 insertions, 2336 deletions
diff --git a/src/org/theb/ssh/ConnectionThread.java b/src/org/theb/ssh/ConnectionThread.java deleted file mode 100644 index a201e62..0000000 --- a/src/org/theb/ssh/ConnectionThread.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.io.InputStream; -import java.io.OutputStream; - -public abstract class ConnectionThread extends Thread { - public ConnectionThread(FeedbackUI ui, String hostname, String username, int port) {} - public abstract void finish(); - public abstract InputStream getReader(); - public abstract OutputStream getWriter(); - public abstract void setPassword(String password); -} diff --git a/src/org/theb/ssh/FeedbackUI.java b/src/org/theb/ssh/FeedbackUI.java deleted file mode 100644 index ba4ae03..0000000 --- a/src/org/theb/ssh/FeedbackUI.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -public interface FeedbackUI { - public void connectionLost(Throwable reason); - public void setWaiting(boolean isWaiting, String title, String message); - public void askPassword(); -} diff --git a/src/org/theb/ssh/HostDbProvider.java b/src/org/theb/ssh/HostDbProvider.java deleted file mode 100644 index f3bdbd5..0000000 --- a/src/org/theb/ssh/HostDbProvider.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.util.HashMap; - -import org.theb.provider.HostDb; - -import android.content.ContentProvider; -import android.content.ContentUris; -import android.content.ContentValues; -import android.content.Context; -import android.content.UriMatcher; -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.database.sqlite.SQLiteQueryBuilder; -import android.database.sqlite.SQLiteDatabase.CursorFactory; -import android.net.Uri; -import android.text.TextUtils; -import android.util.Log; - -public class HostDbProvider extends ContentProvider { - - private SQLiteDatabase mDB; - - private static final String TAG = "HostDbProvider"; - private static final String DATABASE_NAME = "ssh_hosts.db"; - private static final int DATABASE_VERSION = 3; - - private static HashMap<String, String> HOSTS_LIST_PROJECTION_MAP; - - private static final int HOSTS = 1; - private static final int HOST_ID = 2; - - private static final UriMatcher URL_MATCHER; - - private static class DatabaseHelper extends SQLiteOpenHelper { - - public DatabaseHelper(Context context, String name, - CursorFactory factory, int version) { - super(context, name, factory, version); - } - - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL("CREATE TABLE hosts (_id INTEGER PRIMARY KEY," + - "nickname TEXT," + - "hostname TEXT," + - "username TEXT," + - "port INTEGER," + - "emulation TEXT," + - "scrollback INTEGER," + - "hostkey TEXT" + - ")"); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.w(TAG, "Upgrading database from version " + oldVersion + " to " - + newVersion + ", which will destroy all old data"); - db.execSQL("DROP TABLE IF EXISTS hosts"); - onCreate(db); - } - - } - - @Override - public int delete(Uri uri, String where, String[] whereArgs) { - int count; - switch (URL_MATCHER.match(uri)) { - case HOSTS: - count = mDB.delete("ssh_hosts", where, whereArgs); - break; - - case HOST_ID: - String segment = uri.getPathSegments().get(1); - count = mDB.delete("hosts", "_id=" - + segment - + (!TextUtils.isEmpty(where) ? " AND (" + where - + ')' : ""), whereArgs); - break; - - default: - throw new IllegalArgumentException("Unknown Delete " + uri); - } - - getContext().getContentResolver().notifyChange(uri, null); - return count; - } - - @Override - public String getType(Uri uri) { - switch (URL_MATCHER.match(uri)) { - case HOSTS: - return "vnd.android.cursor.dir/vnd.theb.host"; - case HOST_ID: - return "vnd.android.cursor.item/vnd.theb.host"; - default: - throw new IllegalArgumentException("Unknown getType " + uri); - } - } - - @Override - public Uri insert(Uri uri, ContentValues initialValues) { - long rowID; - - ContentValues values; - if (initialValues != null) { - values = new ContentValues(initialValues); - } else { - values = new ContentValues(); - } - /* - if (URL_MATCHER.match(uri) != HOSTS) { - throw new IllegalArgumentException("Unknown Insert " + uri); - } - */ - if (values.containsKey(HostDb.Hosts.NICKNAME) == false) { - values.put(HostDb.Hosts.NICKNAME, ""); - } - - if (values.containsKey(HostDb.Hosts.HOSTNAME) == false) { - values.put(HostDb.Hosts.HOSTNAME, ""); - } - - if (values.containsKey(HostDb.Hosts.USERNAME) == false) { - values.put(HostDb.Hosts.USERNAME, ""); - } - - if (values.containsKey(HostDb.Hosts.PORT) == false) { - values.put(HostDb.Hosts.PORT, 22); - } - - if (values.containsKey(HostDb.Hosts.HOSTKEY) == false) { - values.put(HostDb.Hosts.HOSTKEY, ""); - } - - if (values.containsKey(HostDb.Hosts.EMULATION) == false) { - values.put(HostDb.Hosts.EMULATION, ""); - } - - if (values.containsKey(HostDb.Hosts.SCROLLBACK) == false) { - values.put(HostDb.Hosts.SCROLLBACK, ""); - } - - rowID = mDB.insert("hosts", "host", values); - if (rowID > 0) { - Uri newUri = ContentUris.withAppendedId(HostDb.Hosts.CONTENT_URI, rowID); - getContext().getContentResolver().notifyChange(newUri, null); - return newUri; - } - - throw new SQLException("Failed to insert row into " + uri); - } - - @Override - public boolean onCreate() { - DatabaseHelper dbHelper = new DatabaseHelper(getContext(), DATABASE_NAME, null, DATABASE_VERSION); - mDB = dbHelper.getWritableDatabase(); - return (mDB == null) ? false : true; - } - - @Override - public Cursor query(Uri uri, String[] projection, String selection, - String[] selectionArgs, String sortOrder) { - SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - - switch (URL_MATCHER.match(uri)) { - case HOSTS: - qb.setTables("hosts"); - qb.setProjectionMap(HOSTS_LIST_PROJECTION_MAP); - break; - - case HOST_ID: - qb.setTables("hosts"); - qb.appendWhere("_id=" + uri.getPathSegments().get(1)); - break; - - default: - throw new IllegalArgumentException("Unknown Query " + uri); - } - - String orderBy; - if (TextUtils.isEmpty(sortOrder)) { - orderBy = HostDb.Hosts.DEFAULT_SORT_ORDER; - } else { - orderBy = sortOrder; - } - - Cursor c = qb.query(mDB, projection, selection, selectionArgs, null, - null, orderBy); - c.setNotificationUri(getContext().getContentResolver(), uri); - return c; - } - - @Override - public int update(Uri uri, ContentValues values, String where, - String[] whereArgs) { - int count; - - switch (URL_MATCHER.match(uri)) { - case HOSTS: - count = mDB.update("hosts", values, where, whereArgs); - break; - - case HOST_ID: - String segment = uri.getPathSegments().get(1); - count = mDB - .update("hosts", values, "_id=" - + segment - + (!TextUtils.isEmpty(where) ? " AND (" + where - + ')' : ""), whereArgs); - break; - - default: - throw new IllegalArgumentException("Unknown Update " + uri); - } - - getContext().getContentResolver().notifyChange(uri, null); - return count; - - } - - static { - URL_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); - URL_MATCHER.addURI("org.theb.provider.HostDb", "hosts", HOSTS); - URL_MATCHER.addURI("org.theb.provider.HostDb", "hosts/#", HOST_ID); - - HOSTS_LIST_PROJECTION_MAP = new HashMap<String, String>(); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts._ID, "_id"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.NICKNAME, "nickname"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.HOSTNAME, "hostname"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.USERNAME, "username"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.PORT, "port"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.HOSTKEY, "hostkey"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.EMULATION, "emulation"); - HOSTS_LIST_PROJECTION_MAP.put(HostDb.Hosts.SCROLLBACK, "scrollback"); - } -} diff --git a/src/org/theb/ssh/HostEditor.java b/src/org/theb/ssh/HostEditor.java deleted file mode 100644 index 128d827..0000000 --- a/src/org/theb/ssh/HostEditor.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import org.connectbot.R; -import org.theb.provider.HostDb; -import org.theb.provider.HostDb.Hosts; - -import android.app.Activity; -import android.content.ContentValues; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -import android.util.Log; -import android.widget.EditText; -import android.widget.Spinner; - -public class HostEditor extends Activity { - public static final String EDIT_HOST_ACTION = "org.theb.ssh.action.EDIT_HOST"; - - private static final String[] PROJECTION = new String[] { HostDb.Hosts._ID, - HostDb.Hosts.NICKNAME, HostDb.Hosts.HOSTNAME, - HostDb.Hosts.USERNAME, HostDb.Hosts.PORT, HostDb.Hosts.EMULATION, - HostDb.Hosts.SCROLLBACK, }; - - private static final int INDEX_NICKNAME = 1, INDEX_HOSTNAME = 2, - INDEX_USERNAME = 3, INDEX_PORT = 4, INDEX_EMULATION = 5, - INDEX_SCROLLBACK = 6; - - // Set up distinct states that the activity can be run in. - private static final int STATE_EDIT = 0; - private static final int STATE_INSERT = 1; - - private EditText mNickname, mHostname, mUsername, mPort, mScrollback; - private Spinner mEmulation; - - // Cursor that will provide access to the host data we are editing - private Cursor mCursor; - - private int mState; - private Uri mURI; - - @Override - public void onCreate(Bundle savedValues) { - super.onCreate(savedValues); - this.setContentView(R.layout.act_hosteditor); - - // Set up click handlers for text fields and button - this.mNickname = (EditText) findViewById(R.id.edit_nickname); - this.mHostname = (EditText) findViewById(R.id.edit_hostname); - this.mUsername = (EditText) findViewById(R.id.edit_username); - this.mPort = (EditText) findViewById(R.id.edit_port); - this.mEmulation = (Spinner) findViewById(R.id.edit_emulation); - this.mScrollback = (EditText) findViewById(R.id.edit_scrollback); - - // Do some setup based on the action being performed. - final Intent intent = getIntent(); - final String action = intent.getAction(); - - if (Intent.ACTION_INSERT.equals(action)) { - mState = STATE_INSERT; - mURI = getContentResolver().insert(intent.getData(), null); - - // If we were unable to create a new note, then just finish - // this activity. A RESULT_CANCELED will be sent back to the - // original activity if they requested a result. - if (mURI == null) { - Log.e("SSH", "Failed to insert new host into " + getIntent().getData()); - finish(); - return; - } - - // The new entry was created, so assume all will end well and - // set the result to be returned. - intent.putExtra(Intent.EXTRA_TEXT, mURI.toString()); - setResult(RESULT_OK, intent); - } else { - // Editing is the default state. - mState = STATE_EDIT; - - // Get the URI of the host whose properties we want to edit - mURI = getIntent().getData(); - } - - // Get a cursor to access the host data - //this.mCursor = managedQuery(mURI, PROJECTION, null, null); - } - - @Override - protected void onResume() { - super.onResume(); - - // Initialize the text with the host data - if(mCursor != null) { - mCursor.moveToFirst(); - - this.mNickname.setText(mCursor.getString(HostEditor.INDEX_NICKNAME)); - this.mHostname.setText(mCursor.getString(HostEditor.INDEX_HOSTNAME)); - this.mUsername.setText(mCursor.getString(HostEditor.INDEX_USERNAME)); - this.mPort.setText(mCursor.getString(HostEditor.INDEX_PORT)); - //this.emulation.setText(cursor.getString(this.INDEX_EMULATION)); - this.mScrollback.setText(mCursor.getString(HostEditor.INDEX_SCROLLBACK)); - - } - } - - @Override - protected void onPause() { - super.onPause(); - - // Write the text back into the cursor - if(mCursor != null) { - ContentValues values = new ContentValues(); - values.put(Hosts.NICKNAME, mNickname.getText().toString()); - values.put(Hosts.HOSTNAME, mHostname.getText().toString()); - values.put(Hosts.USERNAME, mUsername.getText().toString()); - //mEmulation.getSelectedItemPosition(); - int port; - try { - port = Integer.parseInt(mPort.getText().toString()); - } catch (Exception e) { - port = 22; - } - values.put(Hosts.PORT, port); - - int scrollback; - try { - scrollback = Integer.parseInt(mScrollback.getText().toString()); - } catch (Exception e) { - scrollback = 1000; // TODO: grab from R.whatever - } - values.put(Hosts.SCROLLBACK, scrollback); - - getContentResolver().update(mURI, values, null, null); - } - } - - private final void cancelEdit() { - if (mCursor != null) { - if (mState == STATE_EDIT) { - mCursor.deactivate(); - mCursor = null; - } else if (mState == STATE_INSERT) { - deleteHost(); - } - } - } - - private final void deleteHost() { - if (mCursor != null) { - mHostname.setText(""); - mUsername.setText(""); - mPort.setText(""); - getContentResolver().delete(mURI, null, null); - mCursor.deactivate(); - mCursor = null; - } - } - -} diff --git a/src/org/theb/ssh/HostsList.java b/src/org/theb/ssh/HostsList.java deleted file mode 100644 index 888d629..0000000 --- a/src/org/theb/ssh/HostsList.java +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.util.concurrent.Semaphore; - -import org.connectbot.Console; -import org.connectbot.service.TerminalBridge; -import org.connectbot.service.TerminalManager; -import org.connectbot.R; -import org.theb.provider.HostDb; - -import com.trilead.ssh2.Connection; - -import android.app.Dialog; -import android.app.ListActivity; -import android.content.ComponentName; -import android.content.ContentUris; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.database.Cursor; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.Bundle; -import android.os.IBinder; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.SubMenu; -import android.view.View; -import android.view.WindowManager; -import android.view.View.MeasureSpec; -import android.widget.ListAdapter; -import android.widget.ListView; -import android.widget.SimpleCursorAdapter; -import android.widget.TextView; - -public class HostsList extends ListActivity { - public static final int CONNECT_ID = Menu.FIRST; - public static final int EDIT_ID = Menu.FIRST + 1; - public static final int DELETE_ID = Menu.FIRST + 2; - public static final int INSERT_ID = Menu.FIRST + 3; - public static final int PREFERENCES_ID = Menu.FIRST + 4; - public static final int ABOUT_ID = Menu.FIRST + 5; - - // Preferences submenu - public static final int PUBKEY_ID = SubMenu.FIRST + 4; - - private static final String[] PROJECTION = new String[] { - HostDb.Hosts._ID, - HostDb.Hosts.HOSTNAME, - HostDb.Hosts.USERNAME, - HostDb.Hosts.PORT, - HostDb.Hosts.NICKNAME - }; - - private Cursor mCursor; - - /** - * @author kenny - * Imparts a more informative view of the host list. - * - * Displays as "username@hostname:port" but only includes the port if it is - * not on the default port 22. - */ - public class HostListCursorAdapter extends SimpleCursorAdapter { - - public HostListCursorAdapter(Context context, int layout, Cursor c, - String[] from, int[] to) { - super(context, layout, c, from, to); - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - String label; - TextView textView = (TextView) view; - -// label = cursor.getString(2) + "@" + cursor.getString(1); -// int port = cursor.getInt(3); -// if (port != 22) { -// label = label + ":" + String.valueOf(port); -// } - - label = cursor.getString(4); - textView.setText(label); - } - - } - - public TerminalManager bound = null; - - private ServiceConnection connection = new ServiceConnection() { - public void onServiceConnected(ComponentName className, IBinder service) { - Log.d(this.getClass().toString(), "yay we bound to our terminalmanager"); - bound = ((TerminalManager.TerminalBinder) service).getService(); - - // TODO: update our green bulb icons by checking for existing bridges - // open up some test sessions -// try { -// bound.openConnection("192.168.254.230", 22, "connectbot", "b0tt", "screen", 100); -// bound.openConnection("192.168.254.230", 22, "connectbot", "b0tt", "screen", 100); -// bound.openConnection("192.168.254.230", 22, "connectbot", "b0tt", "screen", 100); -// } catch(Exception e) { -// e.printStackTrace(); -// } - - } - - public void onServiceDisconnected(ComponentName className) { - Log.d(this.getClass().toString(), "oops our terminalmanager was lost"); - bound = null; - } - }; - - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - // start the terminal manager service and bind locally - this.startService(new Intent(this, TerminalManager.class)); - this.bindService(new Intent(this, TerminalManager.class), connection, Context.BIND_AUTO_CREATE); - - - //setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); - - Intent intent = getIntent(); - if (intent.getData() == null) { - intent.setData(HostDb.Hosts.CONTENT_URI); - } - - //setupListStripes(); - - //mCursor = managedQuery(getIntent().getData(), PROJECTION, null, null); - - ListAdapter adapter = new HostListCursorAdapter(this, - android.R.layout.simple_list_item_1, mCursor, - new String[] {HostDb.Hosts.HOSTNAME}, new int[] {android.R.id.text1}); - - setListAdapter(adapter); - } - -// /** -// * Add stripes to the list view. -// */ -// private void setupListStripes() { -// // Get Drawables for alternating stripes -// Drawable[] lineBackgrounds = new Drawable[2]; -// -// lineBackgrounds[0] = getResources().getDrawable(R.drawable.even_stripe); -// lineBackgrounds[1] = getResources().getDrawable(R.drawable.odd_stripe); -// -// // Make and measure a sample TextView of the sort our adapter will -// // return -// View view = getViewInflate().inflate( -// android.R.layout.simple_list_item_1, null, null); -// -// TextView v = (TextView) view.findViewById(android.R.id.text1); -// v.setText("X"); -// // Make it 100 pixels wide, and let it choose its own height. -// v.measure(MeasureSpec.makeMeasureSpec(View.MeasureSpec.EXACTLY, 100), -// MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, 0)); -// int height = v.getMeasuredHeight(); -// getListView().setStripes(lineBackgrounds, height); -// } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - - // This is our one standard application action -- inserting a - // new host into the list. - menu.add(0, INSERT_ID, INSERT_ID, R.string.menu_insert) - .setShortcut('3', 'a'); - - // The preferences link allows users to e.g. set the pubkey - SubMenu prefs = menu.addSubMenu(0, 0, PREFERENCES_ID, R.string.menu_preferences); - prefs.add(0, PUBKEY_ID, Menu.NONE, R.string.menu_pubkey) - .setShortcut('4', 'p'); - - // This links to the about dialog for the program. - menu.add(0, ABOUT_ID, ABOUT_ID, R.string.menu_about); - - // Generate any additional actions that can be performed on the - // overall list. In a normal install, there are no additional - // actions found here, but this allows other applications to extend - // our menu with their own actions. - Intent intent = new Intent(null, getIntent().getData()); - intent.addCategory(Intent.CATEGORY_ALTERNATIVE); - menu.addIntentOptions( - Menu.CATEGORY_ALTERNATIVE, 0, Menu.NONE, new ComponentName(this, HostsList.class), - null, intent, 0, null); - - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - final boolean haveItems = mCursor.getCount() > 0; - - // If there are any notes in the list (which does not necessarily imply one of - // them is selected), then we need to generate the actions that - // can be performed on the current selection. This will be a combination - // of our own specific actions along with any extensions that can be - // found. - if (haveItems && getSelectedItemId() >= 0) { - // This is the selected item. - Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); - - // Build menu... always starts with the PICK action... - Intent[] specifics = new Intent[1]; - specifics[0] = new Intent(Intent.ACTION_PICK, uri); - MenuItem[] items = new MenuItem[1]; - - // ... is followed by whatever other actions are available... - Intent intent = new Intent(null, uri); - intent.addCategory(Intent.CATEGORY_ALTERNATIVE); - menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, Menu.NONE, null, specifics, - intent, 0, items); - - // ... and ends with the delete command. - menu.add(Menu.CATEGORY_ALTERNATIVE, DELETE_ID, DELETE_ID, R.string.menu_delete) - .setShortcut('2', 'd'); - - // Give a shortcut to the connect action. - if (items[0] != null) { - items[0].setShortcut('1', 'c'); - } - } else { - menu.removeGroup(Menu.CATEGORY_ALTERNATIVE); - } - - // Make sure the delete action is disabled if there are no items. - //menu.setItemShown(DELETE_ID, haveItems); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case DELETE_ID: - deleteItem(); - return true; - case INSERT_ID: - insertItem(); - return true; - case PUBKEY_ID: - showPubkey(); - return true; - case ABOUT_ID: - showAbout(); - return true; - } - return super.onOptionsItemSelected(item); - } - - private void showPubkey() { - Intent intent = new Intent(this, Pubkey.class); - this.startActivity(intent); - } - - private void showAbout() { - Dialog about = new Dialog(this); - //about.setContentView(R.layout.about_dialog); - about.setTitle(getResources().getString(R.string.app_name) - + " " - + getResources().getString(R.string.msg_version)); - - // TODO: update or remove - // Everything looks cooler when you blur the window behind it. - //about.getWindow().setFlags(WindowManager.LayoutParams.BLUR_BEHIND_FLAG, - // WindowManager.LayoutParams.BLUR_BEHIND_FLAG); - WindowManager.LayoutParams lp = about.getWindow().getAttributes(); - //lp.tintBehind = 0x60000820; - about.getWindow().setAttributes(lp); - - about.show(); - } - - @Override - protected void onListItemClick(ListView l, View v, int position, long id) { - Uri url = ContentUris.withAppendedId(getIntent().getData(), id); - - String action = getIntent().getAction(); - if (Intent.ACTION_PICK.equals(action) - || Intent.ACTION_GET_CONTENT.equals(action)) { - // The caller is waiting for us to return a note selected by - // the user. The have clicked on one, so return it now. - Intent intent = this.getIntent(); - intent.putExtra(Intent.EXTRA_TEXT, url.toString()); - setResult(RESULT_OK, intent); - } else { - // Launch activity to view/edit the currently selected item - //startActivity(new Intent(Intent.ACTION_PICK, url)); - - // collect all connection details - Cursor cursor = null; -// managedQuery(url, new String[] { "nickname", -// "username", "hostname", "port", "emulation", "scrollback", -// "hostkey" }, null, null); - cursor.moveToFirst(); - - // try finding an already-open bridge for this connection - 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 - 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 { - // 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); - if (password != null) { - //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); - } - - - } - } - - 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) { - if (data != null) { - this.password = data.getStringExtra(Intent.EXTRA_TEXT); - } else { - this.password = null; - } - this.waitPassword.release(); - } - } - - private final void deleteItem() { - mCursor.move(getSelectedItemPosition()); - Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId()); - getContentResolver().delete(uri, null, null); - } - - private final void insertItem() { - // Launch activity to insert a new item - startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData())); - } -}
\ No newline at end of file diff --git a/src/org/theb/ssh/InteractiveHostKeyVerifier.java b/src/org/theb/ssh/InteractiveHostKeyVerifier.java deleted file mode 100644 index 7c21f80..0000000 --- a/src/org/theb/ssh/InteractiveHostKeyVerifier.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import com.trilead.ssh2.ServerHostKeyVerifier; - -public class InteractiveHostKeyVerifier implements ServerHostKeyVerifier { - - public boolean verifyServerHostKey(String hostname, int port, - String serverHostKeyAlgorithm, byte[] serverHostKey) - throws Exception { - // TODO Auto-generated method stub - return true; - } - -} diff --git a/src/org/theb/ssh/JCTerminalView.java b/src/org/theb/ssh/JCTerminalView.java deleted file mode 100644 index b76794f..0000000 --- a/src/org/theb/ssh/JCTerminalView.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PixelXorXfermode; -import android.graphics.Typeface; -import android.graphics.Bitmap.Config; -import android.graphics.Paint.FontMetricsInt; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; - -import com.jcraft.jcterm.Emulator; -import com.jcraft.jcterm.EmulatorVT100; -import com.jcraft.jcterm.Term; - -public class JCTerminalView extends View implements Term, Terminal { - private final Paint mPaint; - private Bitmap mBitmap; - private Canvas mCanvas; - - private final Paint mCursorPaint; - - private Emulator emulator = null; - - private boolean mBold = false; - private boolean mUnderline = false; - private boolean mReverse = false; - - private int mDefaultForeground = Color.WHITE; - private int mDefaultBackground = Color.BLACK; - private int mForeground = Color.WHITE; - private int mBackground = Color.BLACK; - - private boolean mAntialias = true; - - private int mTermWidth = 80; - private int mTermHeight = 24; - - private int mCharHeight; - private int mCharWidth; - private int mDescent; - - - // Cursor location - private int x = 0; - private int y = 0; - - private final Object[] mColors = {Color.BLACK, Color.RED, Color.GREEN, Color.YELLOW, - Color.BLUE, Color.MAGENTA, Color.CYAN, Color.WHITE}; - - public JCTerminalView(Context c) { - super(c); - mPaint = new Paint(); - mPaint.setAntiAlias(mAntialias); - mPaint.setColor(mDefaultForeground); - - mCursorPaint = new Paint(); - mCursorPaint.setAntiAlias(mAntialias); - mCursorPaint.setColor(mDefaultForeground); - mCursorPaint.setXfermode(new PixelXorXfermode(mDefaultBackground)); - - setFont(Typeface.MONOSPACE); - } - - @Override - protected void onDraw(Canvas canvas) { - if (mBitmap != null) { - canvas.drawBitmap(mBitmap, 0, 0, null); - - if (mCharHeight > 0 && y > mCharHeight) { - // Invert pixels for cursor position. - canvas.drawRect(x, y - mCharHeight, x + mCharWidth, y, mCursorPaint); - } - } - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - Log.d("SSH/TerminalView", "onSizeChanged called"); - Bitmap newBitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888); - Canvas newCanvas = new Canvas(); - - newCanvas.setBitmap(newBitmap); - - if (mBitmap != null) - newCanvas.drawBitmap(mBitmap, 0, 0, mPaint); - - mBitmap = newBitmap; - mCanvas = newCanvas; - - setSize(w, h); - } - - private void setSize(int w, int h) { - int column = w / getCharWidth(); - int row = h / getCharHeight(); - - mTermWidth = column; - mTermHeight = row; - - if (emulator != null) - emulator.reset(); - - clear_area(0, 0, w, h); - - // TODO: finish this method - } - - private void setFont(Typeface typeface) { - mPaint.setTypeface(typeface); - mPaint.setTextSize(8); - FontMetricsInt fm = mPaint.getFontMetricsInt(); - mDescent = fm.descent; - - float[] widths = new float[1]; - mPaint.getTextWidths("X", widths); - mCharWidth = (int)widths[0]; - - // Is this right? - mCharHeight = Math.abs(fm.top) + Math.abs(fm.descent); - Log.d("SSH", "character height is " + mCharHeight); - // mCharHeight += mLineSpace * 2; - // mDescent += mLineSpace; - } - - public void beep() { - // TODO Auto-generated method stub - - } - - public void clear() { - mPaint.setColor(getBackgroundColor()); - mCanvas.drawRect(0, 0, mCanvas.getWidth(), - mCanvas.getHeight(), mPaint); - mPaint.setColor(getForegroundColor()); - } - - private int getBackgroundColor() { - if (mReverse) - return mForeground; - return mBackground; - } - - private int getForegroundColor() { - if (mReverse) - return mBackground; - return mForeground; - } - - public void clear_area(int x1, int y1, int x2, int y2) { - mPaint.setColor(getBackgroundColor()); - if (mCanvas != null) - mCanvas.drawRect(x1, y1, x2, y2, mPaint); - mPaint.setColor(getForegroundColor()); - } - - public void drawBytes(byte[] buf, int s, int len, int x, int y) { - String chars = null; - try { - chars = new String(buf, "ASCII"); - drawString(chars.substring(s, s+len), x, y); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - Log.e("SSH", "Can't convert bytes to ASCII"); - } - } - - public void drawString(String str, int x, int y) { - mPaint.setFakeBoldText(mBold); - mPaint.setUnderlineText(mUnderline); - mCanvas.drawText(str, x, y - mDescent, mPaint); - } - - public void draw_cursor() { - postInvalidate(); - } - - public int getCharHeight() { - return mCharHeight; - } - - public int getCharWidth() { - return mCharWidth; - } - - public Object getColor(int index) { - if (mColors == null || index < 0 || mColors.length <= index) - return null; - return mColors[index]; - } - - public int getColumnCount() { - return mTermWidth; - } - - public int getRowCount() { - return mTermHeight; - } - - public int getTermHeight() { - return mTermHeight * mCharHeight; - } - - public int getTermWidth() { - return mTermWidth * mCharWidth; - } - - public void redraw(int x, int y, int width, int height) { - //invalidate(x, y, x+width, y+height); - postInvalidate(); - } - - public void resetAllAttributes() { - mBold = false; - mUnderline = false; - mReverse = false; - - mBackground = mDefaultBackground; - mForeground = mDefaultForeground; - - if (mPaint != null) - mPaint.setColor(mForeground); - } - - public void scroll_area(int x, int y, int w, int h, int dx, int dy) { - // TODO: make scrolling more efficient (memory-wise) - mCanvas.drawBitmap(Bitmap.createBitmap(mBitmap, x, y, w, h), x+dx, y+dy, null); - } - - private int toColor(Object o) { - if (o instanceof Integer) { - return ((Integer)o).intValue(); - } - - if (o instanceof String) { - return Color.parseColor((String)o); - } - - return Color.WHITE; - } - - public void setBackGround(Object background) { - mBackground = toColor(background); - } - - public void setBold() { - mBold = true; - } - - public void setCursor(int x, int y) { - // Make sure we don't go outside the bounds of the window. - this.x = Math.max( - Math.min(x, getWidth() - mCharWidth), - 0); - this.y = Math.max( - Math.min(y, getHeight()), - mCharHeight); - } - - public void setDefaultBackGround(Object background) { - mDefaultBackground = toColor(background); - } - - public void setDefaultForeGround(Object foreground) { - mDefaultForeground = toColor(foreground); - } - - public void setForeGround(Object foreground) { - mForeground = toColor(foreground); - } - - public void setReverse() { - mReverse = true; - if (mPaint != null) - mPaint.setColor(getForegroundColor()); - } - - public void setUnderline() { - mUnderline = true; - } - - public void start(InputStream in, OutputStream out) { - emulator = new EmulatorVT100(this, in); - emulator.reset(); - emulator.start(); - - clear(); - } - - public byte[] getKeyCode(int keyCode, int meta) { - if (keyCode == KeyEvent.KEYCODE_ENTER) - return emulator.getCodeENTER(); - else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) - return emulator.getCodeLEFT(); - else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) - return emulator.getCodeUP(); - else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) - return emulator.getCodeDOWN(); - else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) - return emulator.getCodeRIGHT(); - else - return null; - } -} diff --git a/src/org/theb/ssh/JTATerminalView.java b/src/org/theb/ssh/JTATerminalView.java deleted file mode 100644 index c28e609..0000000 --- a/src/org/theb/ssh/JTATerminalView.java +++ /dev/null @@ -1,375 +0,0 @@ -package org.theb.ssh; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import de.mud.terminal.SoftFont; -import de.mud.terminal.VDUBuffer; -import de.mud.terminal.VDUDisplay; -import de.mud.terminal.vt320; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PixelXorXfermode; -import android.graphics.Typeface; -import android.graphics.Bitmap.Config; -import android.graphics.Paint.FontMetricsInt; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; - -public class JTATerminalView extends View implements VDUDisplay, Terminal, Runnable { - private Paint paint; - private Paint cursorPaint; - - private Canvas canvas; - private Bitmap bitmap; - - protected vt320 emulation; - private VDUBuffer buffer; - - private InputStream in; - private OutputStream out; - - private String encoding = "ASCII"; - private SoftFont sf = new SoftFont(); - - private Thread reader = null; - - private int charWidth; - private int charHeight; - private int charDescent; - - private int xoffset = 0; - private int yoffset = 0; - - private int color[] = { - Color.BLACK, - Color.RED, - Color.GREEN, - Color.YELLOW, - Color.BLUE, - Color.MAGENTA, - Color.CYAN, - Color.WHITE, - }; - - private final static int COLOR_FG_STD = 7; - private final static int COLOR_BG_STD = 0; - - public JTATerminalView(Context context) { - super(context); - - paint = new Paint(); - paint.setAntiAlias(true); - - cursorPaint = new Paint(); - cursorPaint.setAntiAlias(true); - cursorPaint.setColor(darken(color[COLOR_FG_STD])); - cursorPaint.setXfermode(new PixelXorXfermode(color[COLOR_BG_STD])); - - setFont(Typeface.MONOSPACE, 10); - - emulation = new vt320() { - public void write(byte[] b) { - try { - JTATerminalView.this.write(b); - } catch (IOException e) { - Log.e("SSH", "couldn't write" + b.toString()); - reader = null; - } - } - - public void sendTelnetCommand(byte cmd) { - // TODO: implement telnet command sending - } - - public void setWindowSize(int c, int r) { - // TODO: implement window sizing - } - }; - - setVDUBuffer(emulation); - } - - @Override - protected void onDraw(Canvas canvas) { - if (bitmap != null) { - canvas.drawBitmap(bitmap, 0, 0, null); - - if (buffer.isCursorVisible() && - (buffer.screenBase + buffer.getCursorRow() >= buffer.windowBase && - buffer.screenBase + buffer.getCursorRow() < buffer.windowBase + buffer.height)) { - int x = buffer.getCursorColumn() * charWidth + xoffset; - int y = (buffer.getCursorRow() + buffer.screenBase - buffer.windowBase) * charHeight + yoffset; - canvas.drawRect(x, y, x + charWidth, y + charHeight, cursorPaint); - } - } - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - Log.d("SSH/TerminalView", "onSizeChanged called"); - Bitmap newBitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888); - Canvas newCanvas = new Canvas(); - - newCanvas.setBitmap(newBitmap); - - if (bitmap != null) - newCanvas.drawBitmap(bitmap, 0, 0, paint); - - bitmap = newBitmap; - canvas = newCanvas; - - setSize(w, h); - - // Make sure the buffer is in the center of the screen. - xoffset = (getWidth() - buffer.width * charWidth) / 2; - yoffset = (getHeight() - buffer.height * charHeight) / 2; - } - - private void setSize(int w, int h) { - int termWidth = w / charWidth; - int termHeight = h / charHeight; - - buffer.setScreenSize(termWidth, buffer.height = termHeight, true); - } - - private void setFont(Typeface typeface, int size) { - paint.setTypeface(typeface); - paint.setTextSize(size); - - FontMetricsInt fm = paint.getFontMetricsInt(); - - charDescent = fm.descent; - - float[] widths = new float[1]; - paint.getTextWidths("X", widths); - charWidth = (int)widths[0]; - - charHeight = Math.abs(fm.top) + Math.abs(fm.descent); - } - - public void write(byte[] b) throws IOException { - Log.e("SSH/JTATerm/write", "Trying to write" + b.toString()); - out.write(b); - } - - public int getColumnCount() { - return buffer.width; - } - - public int getRowCount() { - return buffer.height; - } - - public InputStream getInput() { - return in; - } - - public byte[] getKeyCode(int keyCode, int meta) { - switch (keyCode) { - case KeyEvent.KEYCODE_ENTER: - emulation.keyTyped(vt320.KEY_ENTER, ' ', meta); - break; - case KeyEvent.KEYCODE_DPAD_LEFT: - emulation.keyPressed(vt320.KEY_LEFT, ' ', meta); - break; - case KeyEvent.KEYCODE_DPAD_UP: - emulation.keyPressed(vt320.KEY_UP, ' ', meta); - break; - case KeyEvent.KEYCODE_DPAD_DOWN: - emulation.keyPressed(vt320.KEY_DOWN, ' ', meta) ; - break; - case KeyEvent.KEYCODE_DPAD_RIGHT: - emulation.keyPressed(vt320.KEY_RIGHT, ' ', meta); - break; - } - return null; - } - - public OutputStream getOutput() { - return out; - } - - private int darken(int color) { - return Color.argb(0xFF, - (int)(Color.red(color) * 0.8), - (int)(Color.green(color) * 0.8), - (int)(Color.blue(color) * 0.8) - ); - } - - /* Not used. - private int brighten(int color) { - return Color.argb(0xFF, - (int)(Color.red(color) * 1.2), - (int)(Color.green(color) * 1.2), - (int)(Color.blue(color) * 1.2) - ); - } - */ - - public void redraw() { - // Draw the mouse-selection - //int selectStartLine = selectBegin.y - buffer.windowBase; - //int selectEndLine = selectEnd.y - buffer.windowBase; - - int fg, bg; - - int lines = 0; - long time = System.currentTimeMillis() + 0; - - // paint.setColor(color[COLOR_BG_STD]); - // canvas.drawRect(0, 0, bitmap.getWidth(), bitmap.getHeight(), paint); - // paint.setColor(color[COLOR_FG_STD]); - - - for (int l = 0; l < buffer.height; l++) { - // Check to see if the entire buffer is dirty or if this line is dirty. - // If neither is dirty, continue. - if (!buffer.update[0] && !buffer.update[l + 1]) continue; - buffer.update[l + 1] = false; - - lines++; - - // assume that we can blindly dump the terminal string - // canvas.drawText(buffer.charArray[buffer.windowBase + l], - // 0, buffer.charArray[buffer.windowBase + l].length, - // 0 * charWidth + xoffset, - // (l + 1) * charHeight - charDescent + yoffset, - // paint); - - - for (int c = 0; c < buffer.width; c++) { - int addr = 0; - int currAttr = buffer.charAttributes[buffer.windowBase + l][c]; - - fg = darken(color[COLOR_FG_STD]); - bg = darken(color[COLOR_BG_STD]); - - // Check if foreground color attribute is set. - if ((currAttr & VDUBuffer.COLOR_FG) != 0) - fg = (color[((currAttr & VDUBuffer.COLOR_FG) >> VDUBuffer.COLOR_FG_SHIFT) - 1]); - - // Check if background color attribute is set. - if ((currAttr & VDUBuffer.COLOR_BG) != 0) - bg = (darken(color[((currAttr & VDUBuffer.COLOR_BG) >> VDUBuffer.COLOR_BG_SHIFT) - 1])); - - // Check if bold attribute is set. - paint.setFakeBoldText((currAttr & VDUBuffer.BOLD) != 0); - - if ((currAttr & VDUBuffer.LOW) != 0) - fg = darken(fg); - - // Support character inversion by swapping background and foreground color. - if ((currAttr & VDUBuffer.INVERT) != 0) { - int swapc = bg; - bg = fg; - fg = swapc; - } - - // If this character is in the special font, print it and continue to the next character. - // We can't use the optimization below for special characters. -// if (sf.inSoftFont(buffer.charArray[buffer.windowBase + l][c])) { -// // Clear out the space where the character will be printed. -// paint.setColor(bg); -// canvas.drawRect(c * charWidth + xoffset, l * charHeight + yoffset, -// c * (charWidth + 1) + xoffset, (l+1) * charHeight + yoffset, paint); -// paint.setColor(fg); -// -// // FIXME: this won't work since we're not calling drawText() -// paint.setUnderlineText((currAttr & VDUBuffer.UNDERLINE) != 0); -// -// // Draw the text if it's not invisible. -// if ((currAttr & VDUBuffer.INVISIBLE) == 0) -// sf.drawChar(canvas, paint, buffer.charArray[buffer.windowBase + l][c], xoffset + c * charWidth, l * charHeight + yoffset, charWidth, charHeight); -// continue; -// } - - // Determine the amount of continuous characters with the same settings and print them all at once. -// while ((c + addr < buffer.width) && -// ((buffer.charArray[buffer.windowBase + l][c + addr] < ' ') || -// (buffer.charAttributes[buffer.windowBase + l][c + addr] == currAttr)) && -// !sf.inSoftFont(buffer.charArray[buffer.windowBase + l][c + addr])) { -// if (buffer.charArray[buffer.windowBase + l][c + addr] < ' ') { -// buffer.charArray[buffer.windowBase + l][c + addr] = ' '; -// buffer.charAttributes[buffer.windowBase + l][c + addr] = 0; -// continue; -// } -// addr++; -// } - - while(c + addr < buffer.width && buffer.charAttributes[buffer.windowBase + l][c + addr] == currAttr) { - addr++; - } - - // Clear the background in preparation for writing text. - paint.setColor(bg); - canvas.drawRect(c * charWidth + xoffset, l * charHeight + yoffset, - (c + addr) * charWidth + xoffset, (l+1) * charHeight + yoffset, paint); - paint.setColor(fg); - - // Check for the underline attribute and set the brush accordingly. - paint.setUnderlineText((currAttr & VDUBuffer.UNDERLINE) != 0); - - // Write the text string starting at 'c' for 'addr' number of characters. - if ((currAttr & VDUBuffer.INVISIBLE) == 0) - canvas.drawText(buffer.charArray[buffer.windowBase + l], - c, addr, - c * charWidth + xoffset, - (l + 1) * charHeight - charDescent + yoffset, - paint); - - // Advance to the next text block with different characteristics. - c += addr - 1; - } - } - - buffer.update[0] = false; - - time = System.currentTimeMillis() - time; - Log.d("redraw", "redraw called and updated lines=" + lines + " taking ms=" + time); - - postInvalidate(); - } - - public void updateScrollBar() { - // TODO Auto-generated method stub - } - - public void start(InputStream in, OutputStream out) { - this.in = in; - this.out = out; - - reader = new Thread(this); - reader.start(); - } - - public VDUBuffer getVDUBuffer() { - return buffer; - } - - public void setVDUBuffer(VDUBuffer buffer) { - this.buffer = buffer; - buffer.setDisplay(this); - } - - public void run() { - byte[] b = new byte[256]; - int n = 0; - while (n >= 0) - try { - n = in.read(b); - if (n > 0) emulation.putString(new String(b, 0, n, encoding)); - redraw(); - } catch (IOException e) { - reader = null; - break; - } - } -} diff --git a/src/org/theb/ssh/PasswordDialog.java b/src/org/theb/ssh/PasswordDialog.java deleted file mode 100644 index 4bbe89e..0000000 --- a/src/org/theb/ssh/PasswordDialog.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import org.connectbot.R; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.EditText; - -public class PasswordDialog extends Activity implements OnClickListener { - private EditText mPassword; - private Button mOK; - - @Override - public void onCreate(Bundle savedValues) { - super.onCreate(savedValues); - - setContentView(R.layout.password_dialog); - - mPassword = (EditText) findViewById(R.id.password); - mOK = (Button) findViewById(R.id.ok); - mOK.setOnClickListener(this); - } - - public void onClick(View arg0) { - Intent intent = this.getIntent(); - intent.putExtra(Intent.EXTRA_TEXT, mPassword.getText().toString()); - setResult(RESULT_OK, intent); - finish(); - } -} diff --git a/src/org/theb/ssh/Pubkey.java b/src/org/theb/ssh/Pubkey.java deleted file mode 100644 index a8ccb7b..0000000 --- a/src/org/theb/ssh/Pubkey.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.Security; -import java.util.concurrent.Semaphore; - -import org.connectbot.R; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; - -public class Pubkey extends Activity { - private static SecureRandom mSecRand = null; - //private static KeyStore mKeyStore = null; - private Thread kgThread = null; - - private static final int GATHER_ENTROPY = 0; - - protected Semaphore entropyGathered; - protected String entropySeed; - - protected Button generateButton; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - setContentView(R.layout.pubkey); - - generateButton = (Button) findViewById(R.id.generate); - generateButton.setOnClickListener(mGenerateListener); - - Button okButton = (Button) findViewById(R.id.ok); - okButton.setOnClickListener(mCommitListener); - - Button cancelButton = (Button) findViewById(R.id.cancel); - cancelButton.setOnClickListener(mCancelListener); - } - - final Runnable mKeyGen = new Runnable() { - public void run() { - // TODO Auto-generated method stub -// Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); - try { - mSecRand = SecureRandom.getInstance("SHA1PRNG"); - - entropyGathered = new Semaphore(0); - gatherEntropy(); - entropyGathered.acquire(); - mSecRand.setSeed(entropySeed.getBytes()); - entropyGathered = null; - - KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA"); - keyGen.initialize(512, mSecRand); - - KeyPair pair = keyGen.generateKeyPair(); - PrivateKey priv = pair.getPrivate(); - PublicKey pub = pair.getPublic(); - - byte[] encPriv = priv.getEncoded(); - byte[] encPub = pub.getEncoded(); - Log.e("SSH/priv", new String(encPriv)); - Log.d("SSH/pub", new String(encPub)); - } catch (Exception ex) { - Log.e("SSH/keygen", ex.getMessage()); - } - } - }; - - OnClickListener mGenerateListener = new OnClickListener() { - public void onClick(View v) { - kgThread = new Thread(mKeyGen); - kgThread.start(); - } - }; - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == GATHER_ENTROPY) { - entropySeed = data.getStringExtra(Intent.EXTRA_TEXT); - entropyGathered.release(); - } - } - - protected void gatherEntropy() { - generateButton.setEnabled(false); - Intent intent = new Intent(this, TouchEntropy.class); - this.startActivityForResult(intent, GATHER_ENTROPY); - } - - OnClickListener mCommitListener = new OnClickListener() { - public void onClick(View v) { - // When the user clicks, just finish this activity. - // onPause will be called, and we save our data there. - finish(); - } - }; - - OnClickListener mCancelListener = new OnClickListener() { - public void onClick(View v) { - //cancelEdit(); - finish(); - } - }; -} diff --git a/src/org/theb/ssh/SecureShell.java b/src/org/theb/ssh/SecureShell.java deleted file mode 100644 index 32a8b10..0000000 --- a/src/org/theb/ssh/SecureShell.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.io.IOException; -import java.io.OutputStream; - -import org.connectbot.R; -import org.theb.provider.HostDb; - -import com.trilead.ssh2.ConnectionMonitor; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.ProgressDialog; -import android.content.Intent; -import android.database.Cursor; -import android.os.Bundle; -import android.os.Handler; -import android.view.KeyCharacterMap; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.view.Window; - -public class SecureShell extends Activity implements FeedbackUI, ConnectionMonitor { - private ConnectionThread mConn; - - // Activities we support. - static final int PASSWORD_REQUEST = 0; - - // Database projection indices. - private static final int HOSTNAME_INDEX = 1; - private static final int USERNAME_INDEX = 2; - private static final int PORT_INDEX = 3; - - private static final String[] PROJECTION = new String[] { - HostDb.Hosts._ID, // 0 - HostDb.Hosts.HOSTNAME, // 1 - HostDb.Hosts.USERNAME, // 2 - HostDb.Hosts.PORT, // 3 - }; - - private Cursor mCursor; - - // Map to convert from keyboard presses to actual characters. - private KeyCharacterMap mKMap; - - // Terminal window - private Terminal mTerminal; - - // We change the meta state when the user presses the center button. - private boolean mMetaState = false; - - // Store the username, hostname, and port from the database. - private String mHostname; - private String mUsername; - private int mPort; - - // The toggle for the original thread to release the indeterminate waiting graphic. - private ProgressDialog progress; - private boolean mIsWaiting; - private String mWaitingTitle; - private String mWaitingMessage; - - final Handler mHandler = new Handler(); - - // Tell the user why we disconnected. - private String mDisconnectReason; - - @Override - public void onCreate(Bundle savedValues) { - super.onCreate(savedValues); - - // TODO: enable opengl for testing on real devices - //requestWindowFeature(Window.FEATURE_OPENGL); - requestWindowFeature(Window.FEATURE_PROGRESS); - mTerminal = new JTATerminalView(this); - - // TODO: implement scroll bar on right. - setContentView((View)mTerminal); - - Log.d("SSH", "using URI " + getIntent().getData().toString()); - -// mCursor = managedQuery(getIntent().getData(), PROJECTION, null, null); - mCursor.moveToFirst(); - - mHostname = mCursor.getString(HOSTNAME_INDEX); - mUsername = mCursor.getString(USERNAME_INDEX); - mPort = mCursor.getInt(PORT_INDEX); - - String title = "SSH: " + mUsername + "@" + mHostname; - if (mPort != 22) - title += Integer.toString(mPort); - - this.setTitle(title); - - mConn = new TrileadConnectionThread(this, mTerminal, mHostname, mUsername, mPort); - - mKMap = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD); - - Log.d("SSH", "Starting new ConnectionThread"); - mConn.start(); - } - - public void setWaiting(boolean isWaiting, String title, String message) { - mIsWaiting = isWaiting; - mWaitingTitle = title; - mWaitingMessage = message; - mHandler.post(mUpdateWaiting); - } - - final Runnable mUpdateWaiting = new Runnable() { - public void run() { - if (mIsWaiting) { - if (progress == null) - progress = ProgressDialog.show(SecureShell.this, mWaitingTitle, mWaitingMessage, true, false); - else { - progress.setTitle(mWaitingTitle); - progress.setMessage(mWaitingMessage); - } - } else { - if (progress != null) { - progress.dismiss(); - progress = null; - } - } - } - }; - - public void askPassword() { - Intent intent = new Intent(this, PasswordDialog.class); - this.startActivityForResult(intent, PASSWORD_REQUEST); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == PASSWORD_REQUEST) { - mConn.setPassword(data.getStringExtra(Intent.EXTRA_TEXT)); - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - - mConn.finish(); - mConn = null; - - finish(); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent msg) { - final OutputStream out = mConn.getWriter(); - if (out != null) { - try { - if (mKMap.isPrintingKey(keyCode) - || keyCode == KeyEvent.KEYCODE_SPACE) { - int c = mKMap.get(keyCode, msg.getMetaState()); - if (mMetaState) { - // Support CTRL-A through CTRL-Z - if (c >= 0x61 && c <= 0x79) - c -= 0x60; - else if (c >= 0x40 && c <= 0x59) - c -= 0x39; - mMetaState = false; - } - out.write(c); - } else if (keyCode == KeyEvent.KEYCODE_DEL) { - out.write(0x08); // CTRL-H - } else if (keyCode == KeyEvent.KEYCODE_ENTER - || keyCode == KeyEvent.KEYCODE_DPAD_LEFT - || keyCode == KeyEvent.KEYCODE_DPAD_UP - || keyCode == KeyEvent.KEYCODE_DPAD_DOWN - || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { - byte[] output = mTerminal.getKeyCode(keyCode, msg.getMetaState()); - if (output != null) - out.write(output); - } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { - if (mMetaState) { - out.write(0x1B); // ESCAPE - mMetaState = false; - } else { - mMetaState = true; - } - } else { - // This is not something we handle. - return super.onKeyDown(keyCode, msg); - } - return true; - } catch (IOException e) { - Log.e("SSH", "Can't write to stdout: "+ e.getMessage()); - } - } - return super.onKeyDown(keyCode, msg); - } - - final Runnable mDisconnectAlert = new Runnable() { - public void run() { - if (SecureShell.this.isFinishing()) - return; - -// AlertDialog d = AlertDialog.show(SecureShell.this, -// "Connection Lost", mDisconnectReason, "Ok", false); - new AlertDialog.Builder(SecureShell.this) - .setIcon(R.drawable.icon) - .setTitle(R.string.alert_disconnect_msg) - .setPositiveButton(R.string.button_ok, null) - .show(); - // TODO: Return to previous activity if connection fails. - } - }; - - public void connectionLost(Throwable reason) { - Log.d("SSH", "Connection ended."); - mDisconnectReason = reason.getMessage(); - mHandler.post(mDisconnectAlert); - } -} diff --git a/src/org/theb/ssh/Terminal.java b/src/org/theb/ssh/Terminal.java deleted file mode 100644 index 890f6b0..0000000 --- a/src/org/theb/ssh/Terminal.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.io.InputStream; -import java.io.OutputStream; - -public interface Terminal { - - public int getWidth(); - public int getHeight(); - public int getRowCount(); - public int getColumnCount(); - public void start(InputStream in, OutputStream out); - public byte[] getKeyCode(int keyCode, int meta); -} diff --git a/src/org/theb/ssh/TouchEntropy.java b/src/org/theb/ssh/TouchEntropy.java deleted file mode 100644 index 772585e..0000000 --- a/src/org/theb/ssh/TouchEntropy.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.theb.ssh; - -import org.connectbot.R; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.graphics.Paint.FontMetrics; -import android.os.Bundle; -import android.util.Log; -import android.view.MotionEvent; -import android.view.View; - -public class TouchEntropy extends Activity { - protected String mEntropy; - - @Override - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - - mEntropy = new String(); - setContentView(new TouchView(this)); - } - - class TouchView extends View { - Paint mPaint; - FontMetrics mFontMetrics; - - private boolean mFlipFlop = false; - private long mLastTime = 0; - - public TouchView(Context c) { - super(c); - - mPaint = new Paint(); - mPaint.setAntiAlias(true); - mPaint.setTypeface(Typeface.DEFAULT); - mPaint.setTextAlign(Paint.Align.CENTER); - mPaint.setTextSize(16); - mPaint.setColor(Color.WHITE); - mFontMetrics = mPaint.getFontMetrics(); - } - - @Override - public void onDraw(Canvas c) { - String prompt = getResources().getString(R.string.prompt_touch); - c.drawText(prompt + " " + (int)(100.0 * (mEntropy.length() / 20.0)) + "% done", - getWidth() / 2, - getHeight() / 2 - (mFontMetrics.ascent + mFontMetrics.descent) / 2, - mPaint); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - // Only get entropy every 200 milliseconds to ensure the user has moved around. - long now = System.currentTimeMillis(); - if ((now - mLastTime) < 200) - return true; - else - mLastTime = now; - - Log.d("SSH", "Last time was " + mLastTime); - - - // Get the lowest 4 bits of each X, Y input and concat to the entropy-gathering - // string. - if (mFlipFlop) - mEntropy += (byte)(((int)event.getX() & 0xF0) | ((int)event.getY() & 0x0F)); - else - mEntropy += (byte)(((int)event.getY() & 0xF0) | ((int)event.getX() & 0x0F)); - - mFlipFlop = !mFlipFlop; - - // SHA1PRNG only keeps 20 bytes (160 bits) of entropy. - if (mEntropy.length() > 20) { - Intent intent = TouchEntropy.this.getIntent(); - intent.putExtra(Intent.EXTRA_TEXT, mEntropy); - TouchEntropy.this.setResult(RESULT_OK, intent); - TouchEntropy.this.finish(); - } - - invalidate(); - - return true; - } - } -} diff --git a/src/org/theb/ssh/TrileadConnectionThread.java b/src/org/theb/ssh/TrileadConnectionThread.java deleted file mode 100644 index b874756..0000000 --- a/src/org/theb/ssh/TrileadConnectionThread.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2007 Kenny Root (kenny at the-b.org) - * - * This file is part of Connectbot. - * - * Connectbot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Connectbot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Connectbot. If not, see <http://www.gnu.org/licenses/>. - */ -package org.theb.ssh; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.concurrent.Semaphore; - -import com.trilead.ssh2.Connection; -import com.trilead.ssh2.ConnectionMonitor; -import com.trilead.ssh2.Session; - -public class TrileadConnectionThread extends ConnectionThread { - private String hostname; - private String username; - private String password; - private int port; - - private Connection connection; - private Session session; - - private InputStream stdOut; - private OutputStream stdIn; - - private Semaphore sPass; - - //protected FeedbackUI ui; - protected Terminal term; - - public TrileadConnectionThread(FeedbackUI ui, Terminal term, String hostname, String username, int port) { - super(ui, hostname, username, port); - //this.ui = ui; - this.term = term; - this.hostname = hostname; - this.username = username; - this.port = port; - } - - @Override - public void finish() { - if (session != null) { - session.close(); - session = null; - } - - if (connection != null) { - connection.close(); - connection = null; - } - } - - @Override - public InputStream getReader() { - return stdOut; - } - - @Override - public OutputStream getWriter() { - return stdIn; - } - - @Override - public void run() { - connection = new Connection(hostname, port); - - //connection.addConnectionMonitor((ConnectionMonitor) ui); - //ui.setWaiting(true, "Connection", "Connecting to " + hostname + "..."); - - try { - connection.connect(new InteractiveHostKeyVerifier()); - - //ui.setWaiting(true, "Authenticating", "Trying to authenticate..."); - - // boolean enableKeyboardInteractive = true; - // boolean enableDSA = true; - // boolean enableRSA = true; - - while (true) { - /* - * if ((enableDSA || enableRSA ) && - * mConn.isAuthMethodAvailable(username, "publickey"); - */ - - if (connection.isAuthMethodAvailable(username, "password")) { - //ui.setWaiting(true, "Authenticating","Trying to authenticate using password..."); - - // Set a semaphore that is unset by the returning dialog. -// sPass = new Semaphore(0); -// ui.askPassword(); -// -// // Wait for the user to answer. -// sPass.acquire(); -// sPass = null; -// if (password == null) -// continue; - - password = "b0tt"; - - boolean res = connection.authenticateWithPassword(username, password); - password = null; - if (res == true) - break; - - continue; - } - - throw new IOException( - "No supported authentication methods available."); - } - - //ui.setWaiting(true, "Session", "Requesting shell..."); - - session = connection.openSession(); - - session.requestPTY("xterm", // BUGFIX: allow colors with xterm instead of vt100 - term.getColumnCount(), term.getRowCount(), - term.getWidth(), term.getHeight(), - null); - - session.startShell(); - - stdIn = session.getStdin(); - // stderr = session.getStderr(); - stdOut = session.getStdout(); - - //ui.setWaiting(false, null, null); - } catch (IOException e) { - //ui.setWaiting(false, null, null); - return; - } - - term.start(stdOut, stdIn); - } - - @Override - public void setPassword(String password) { - if (password == null) - this.password = ""; - else - this.password = password; - sPass.release(); - } -} |