mirror of
https://github.com/moparisthebest/SSLDroid
synced 2024-11-23 01:12:15 -05:00
Added Clone tunnel functionality
Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
parent
27b08ae528
commit
72f5efd826
@ -18,10 +18,11 @@
|
||||
<string name="pkcsfile_pick">Pick a PKCS12 file from SD card</string>
|
||||
<string name="alert_sdcard_absent">No SD card present, please insert one to continue</string>
|
||||
<string name="menu_readlogs">Read logs</string>
|
||||
<string name="reading_logs">Reading log messages...</string>
|
||||
<string name="reading_logs">Reading log messages…</string>
|
||||
<string name="menu_provision">Provisioning</string>
|
||||
<string name="provision">Please enter the URL for remote XML configuration</string>
|
||||
<string name="back">Back</string>
|
||||
<string name="refresh">Refresh</string>
|
||||
<string name="share">Share logs</string>
|
||||
<string name="menu_clone">Clone tunnel</string>
|
||||
</resources>
|
||||
|
@ -21,6 +21,7 @@ public class SSLDroidGui extends ListActivity {
|
||||
private static final int ACTIVITY_CREATE = 0;
|
||||
private static final int ACTIVITY_EDIT = 1;
|
||||
private static final int DELETE_ID = Menu.FIRST + 1;
|
||||
private static final int CLONE_ID = Menu.FIRST + 2;
|
||||
private Cursor cursor;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@ -103,13 +104,17 @@ public class SSLDroidGui extends ListActivity {
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case DELETE_ID:
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||
.getMenuInfo();
|
||||
switch (item.getItemId()) {
|
||||
case DELETE_ID:
|
||||
dbHelper.deleteTunnel(info.id);
|
||||
fillData();
|
||||
return true;
|
||||
case CLONE_ID:
|
||||
cloneTunnel(info.id);
|
||||
fillData();
|
||||
return true;
|
||||
}
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
@ -119,6 +124,13 @@ public class SSLDroidGui extends ListActivity {
|
||||
startActivityForResult(i, ACTIVITY_CREATE);
|
||||
}
|
||||
|
||||
public void cloneTunnel(long id) {
|
||||
Intent i = new Intent(this, SSLDroidTunnelDetails.class);
|
||||
i.putExtra(SSLDroidDbAdapter.KEY_ROWID, id);
|
||||
i.putExtra("doClone", true);
|
||||
startActivityForResult(i, ACTIVITY_EDIT);
|
||||
}
|
||||
|
||||
private void readLogs() {
|
||||
Intent i = new Intent(this, SSLDroidReadLogs.class);
|
||||
startActivity(i);
|
||||
@ -170,6 +182,7 @@ public class SSLDroidGui extends ListActivity {
|
||||
ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.add(0, DELETE_ID, 0, R.string.menu_delete);
|
||||
menu.add(0, CLONE_ID, 0, R.string.menu_clone);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +48,7 @@ public class SSLDroidTunnelDetails extends Activity {
|
||||
private EditText pkcsfile;
|
||||
private EditText pkcspass;
|
||||
private Long rowId;
|
||||
private Boolean doClone = false;
|
||||
private SSLDroidDbAdapter dbHelper;
|
||||
|
||||
@Override
|
||||
@ -78,6 +79,7 @@ public class SSLDroidTunnelDetails extends Activity {
|
||||
.getSerializable(SSLDroidDbAdapter.KEY_ROWID);
|
||||
if (extras != null) {
|
||||
rowId = extras.getLong(SSLDroidDbAdapter.KEY_ROWID);
|
||||
doClone = extras.getBoolean("doClone", false);
|
||||
}
|
||||
populateFields();
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@ -275,10 +277,12 @@ public class SSLDroidTunnelDetails extends Activity {
|
||||
Cursor Tunnel = dbHelper.fetchTunnel(rowId);
|
||||
startManagingCursor(Tunnel);
|
||||
|
||||
if(!doClone){
|
||||
name.setText(Tunnel.getString(Tunnel
|
||||
.getColumnIndexOrThrow(SSLDroidDbAdapter.KEY_NAME)));
|
||||
localport.setText(Tunnel.getString(Tunnel
|
||||
.getColumnIndexOrThrow(SSLDroidDbAdapter.KEY_LOCALPORT)));
|
||||
}
|
||||
remotehost.setText(Tunnel.getString(Tunnel
|
||||
.getColumnIndexOrThrow(SSLDroidDbAdapter.KEY_REMOTEHOST)));
|
||||
remoteport.setText(Tunnel.getString(Tunnel
|
||||
@ -383,7 +387,7 @@ public class SSLDroidTunnelDetails extends Activity {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rowId == null) {
|
||||
if (rowId == null || doClone) {
|
||||
long id = dbHelper.createTunnel(sName, sLocalport, sRemotehost,
|
||||
sRemoteport, sPkcsfile, sPkcspass);
|
||||
if (id > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user