mirror of
http://galexander.org/git/simplesshd.git
synced 2025-01-01 02:40:52 +00:00
now it compiles
This commit is contained in:
parent
84f9f31c14
commit
31fd0b37d0
@ -1,13 +1,18 @@
|
|||||||
package org.galexander.sshd;
|
package org.galexander.sshd;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.text.InputType;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class AuthKeys extends Activity {
|
public class AuthKeys extends Activity {
|
||||||
private EditText authtext;
|
private EditText authtext;
|
||||||
@ -34,16 +39,16 @@ public class AuthKeys extends Activity {
|
|||||||
AlertDialog.Builder ab = new AlertDialog.Builder(this);
|
AlertDialog.Builder ab = new AlertDialog.Builder(this);
|
||||||
ab.setTitle("Fetch authorized_keys");
|
ab.setTitle("Fetch authorized_keys");
|
||||||
final EditText url = new EditText(this);
|
final EditText url = new EditText(this);
|
||||||
url.setInputType(EditText.TYPE_CLASS_TEXT |
|
url.setInputType(InputType.TYPE_CLASS_TEXT |
|
||||||
EditText.TYPE_TEXT_VARIATION_URI);
|
InputType.TYPE_TEXT_VARIATION_URI);
|
||||||
ab.setView(url);
|
ab.setView(url);
|
||||||
ab.setPositiveButton("OK",
|
ab.setPositiveButton("OK",
|
||||||
new DialogInterface.onClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface d, int which) {
|
public void onClick(DialogInterface d, int which) {
|
||||||
start_fetch(url.getText().toString());
|
start_fetch(url.getText().toString());
|
||||||
} });
|
} });
|
||||||
ab.setNegativeButton("Cancel",
|
ab.setNegativeButton("Cancel",
|
||||||
new DialogInterface.onClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface d, int which) {
|
public void onClick(DialogInterface d, int which) {
|
||||||
d.cancel();
|
d.cancel();
|
||||||
} });
|
} });
|
||||||
@ -62,7 +67,7 @@ public class AuthKeys extends Activity {
|
|||||||
|
|
||||||
private void save_authtext() {
|
private void save_authtext() {
|
||||||
String s = get_authtext();
|
String s = get_authtext();
|
||||||
if ((authtext_orig_str != null) && (s != null) &&
|
if ((authtext_orig != null) && (s != null) &&
|
||||||
!s.equals(authtext_orig)) {
|
!s.equals(authtext_orig)) {
|
||||||
Intent i = new Intent(this, AuthKeysSave.class);
|
Intent i = new Intent(this, AuthKeysSave.class);
|
||||||
i.putExtra("s", s);
|
i.putExtra("s", s);
|
||||||
@ -102,8 +107,9 @@ public class AuthKeys extends Activity {
|
|||||||
|
|
||||||
private void start_fetch(String url) {
|
private void start_fetch(String url) {
|
||||||
Intent i = new Intent(this, AuthKeysFetch.class);
|
Intent i = new Intent(this, AuthKeysFetch.class);
|
||||||
i.putExtra("url", url.getText().toString());
|
final Context ctx = this;
|
||||||
i.putExtra("m", Messenger m = new Messenger(new Handler() {
|
i.putExtra("url", url);
|
||||||
|
i.putExtra("m", new Messenger(new Handler() {
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
Object o = msg.obj;
|
Object o = msg.obj;
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
@ -116,7 +122,7 @@ public class AuthKeys extends Activity {
|
|||||||
append_authtext(s);
|
append_authtext(s);
|
||||||
} else {
|
} else {
|
||||||
/* s must be an error message */
|
/* s must be an error message */
|
||||||
Toast.makeText(this, s,
|
Toast.makeText(ctx, s,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} } ));
|
} } ));
|
||||||
|
@ -4,18 +4,19 @@ import android.app.IntentService;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
|
||||||
|
|
||||||
public class AuthKeysSave extends IntentService {
|
public class AuthKeysFetch extends IntentService {
|
||||||
public AuthKeysSave() {
|
public AuthKeysFetch() {
|
||||||
super("SimpleSSHDAuthKeysSave");
|
super("SimpleSSHDAuthKeysFetch");
|
||||||
}
|
}
|
||||||
protected void onHandleIntent(Intent i) {
|
protected void onHandleIntent(Intent i) {
|
||||||
Messenger m = (Messenger)i.getExtra("m");
|
Messenger m = (Messenger)i.getParcelableExtra("m");
|
||||||
Message msg = m.obtain();
|
Message msg = Message.obtain();
|
||||||
String url = i.getStringExtra("url", null);
|
String url = i.getStringExtra("url");
|
||||||
|
|
||||||
String result = "";
|
String result = "";
|
||||||
byte[] b = new byte[1024];
|
byte[] b = new byte[1024];
|
||||||
@ -26,7 +27,7 @@ public class AuthKeysSave extends IntentService {
|
|||||||
}
|
}
|
||||||
URL u = new URL(url);
|
URL u = new URL(url);
|
||||||
HttpURLConnection conn = (HttpURLConnection)
|
HttpURLConnection conn = (HttpURLConnection)
|
||||||
url.openConnection();
|
u.openConnection();
|
||||||
try {
|
try {
|
||||||
InputStream in = conn.getInputStream();
|
InputStream in = conn.getInputStream();
|
||||||
try {
|
try {
|
||||||
|
@ -2,6 +2,10 @@ package org.galexander.sshd;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
|
|
||||||
public class AuthKeysLoad extends AsyncTask<Void,Void,Void> {
|
public class AuthKeysLoad extends AsyncTask<Void,Void,Void> {
|
||||||
private AuthKeys act = null;
|
private AuthKeys act = null;
|
||||||
@ -13,8 +17,8 @@ public class AuthKeysLoad extends AsyncTask<Void,Void,Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuthKeysLoad(AuthKeys act_) {
|
AuthKeysLoad(AuthKeys act_) {
|
||||||
act = act_;
|
|
||||||
super();
|
super();
|
||||||
|
act = act_;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Void doInBackground(Void... v) {
|
protected Void doInBackground(Void... v) {
|
||||||
|
@ -10,7 +10,7 @@ public class AuthKeysSave extends IntentService {
|
|||||||
super("SimpleSSHDAuthKeysSave");
|
super("SimpleSSHDAuthKeysSave");
|
||||||
}
|
}
|
||||||
protected void onHandleIntent(Intent i) {
|
protected void onHandleIntent(Intent i) {
|
||||||
String s = i.getStringExtra("s", null);
|
String s = i.getStringExtra("s");
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -226,12 +227,12 @@ public class SimpleSSHD extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* called from AuthKeysSave (in its own worker thread) if it fails */
|
/* called from AuthKeysSave (in its own worker thread) if it fails */
|
||||||
public static void toast(String s) {
|
public static void toast(final String s) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (curr != null) {
|
if (curr != null) {
|
||||||
curr.runOnUiThread(new Runnable() {
|
curr.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(this, s,
|
Toast.makeText(curr, s,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
} });
|
} });
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user