Skip to content

Commit

Permalink
Don't launch the ssh client if the knock failed. Fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Aug 5, 2015
1 parent 68585cd commit 7348c1c
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions app/src/main/java/biz/incomsystems/fwknop2/SendSPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit 7348c1c

Please sign in to comment.