From 7348c1cb5981a322214517112bc1540d1604b5ad Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 4 Aug 2015 22:45:18 -0500 Subject: [PATCH] Don't launch the ssh client if the knock failed. Fixes #17 --- .../biz/incomsystems/fwknop2/SendSPA.java | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/biz/incomsystems/fwknop2/SendSPA.java b/app/src/main/java/biz/incomsystems/fwknop2/SendSPA.java index 9e8be66..1e2345f 100644 --- a/app/src/main/java/biz/incomsystems/fwknop2/SendSPA.java +++ b/app/src/main/java/biz/incomsystems/fwknop2/SendSPA.java @@ -289,33 +289,35 @@ protected String doInBackground(Void... params) { @Override protected void onPostExecute(String result) { super.onPostExecute(result); + pdLoading.dismiss(); + Toast.makeText(mActivity, result, Toast.LENGTH_LONG).show(); Log.v("fwknop2", result); - if (config.SSH_CMD.contains("juice:")) { - ready = false; //probably not needed - client = new PluginClient(); - client.start(mActivity, new OnClientStartedListener() { - @Override - public void onClientStarted() { - SendSPA.this.isConnected = true; - try { - client.connect(mActivity, config.juice_uuid, SendSPA.this, 2585); - } catch (ServiceNotConnectedException ex) { - Log.e("fwknop2", "not connected error"); + if (result.contains("Success")) { + if (config.SSH_CMD.contains("juice:")) { + ready = false; //probably not needed + client = new PluginClient(); + client.start(mActivity, new OnClientStartedListener() { + @Override + public void onClientStarted() { + SendSPA.this.isConnected = true; + try { + client.connect(mActivity, config.juice_uuid, SendSPA.this, 2585); + } catch (ServiceNotConnectedException ex) { + Log.e("fwknop2", "not connected error"); + } } - } - @Override - public void onClientStopped() { - Log.v("fwknop2", "client stopped"); - } - }); - } + @Override + public void onClientStopped() { + Log.v("fwknop2", "client stopped"); + } + }); - pdLoading.dismiss(); - if (!config.SSH_CMD.equalsIgnoreCase("") && !(config.SSH_CMD.contains("juice:")) ) { - String ssh_uri = "ssh://" + config.SSH_CMD + "/#" + config.NICK_NAME; - Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(ssh_uri)); - mActivity.startActivity(i); + } else if (!config.SSH_CMD.equalsIgnoreCase("")) { + String ssh_uri = "ssh://" + config.SSH_CMD + "/#" + config.NICK_NAME; + Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(ssh_uri)); + mActivity.startActivity(i); + } } } }