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