Android Open Source - TuxRemote S S H Async Task






From Project

Back to project page TuxRemote.

License

The source code is released under:

GNU General Public License

If you think the Android project TuxRemote listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tuxremote.app;
//w w w  .jav  a  2  s .  c o m
import android.content.Context;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;

import com.tuxremote.app.TuxeRemoteSsh.BashReturn;

public class SSHAsyncTask extends AsyncTask<Void, BashReturn, Boolean> {

    private final Command cmd;
    private Context context;

    public SSHAsyncTask(Command cmd){
        this.cmd = cmd;
    }

    @Override
    protected void onPreExecute () {
        context = Global.getStaticContext();
    }

    @Override
    protected Boolean doInBackground(Void... voids) {
        try {
            if (!cmd.getCmd().contains("&")) {
                BashReturn retour = Global.session.SetCommand(cmd.getCmd());
                if (retour != null) {
                    publishProgress(retour);
                }
            } else {
                Global.session.setCommandNoReturn(cmd.getCmd());
            }
            return true;
        }catch (Exception e){
            e.printStackTrace();
            Toast.makeText(context, "Erreur cmd "+cmd.getName(), Toast.LENGTH_SHORT).show();
            return false;
        }
    }

    @Override
    protected void onProgressUpdate (BashReturn... prog) {}

    @Override
    protected void onPostExecute (Boolean result) {}

    public void execTask() {
        if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
            executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            execute();
        }
    }
}




Java Source Code List

com.tuxremote.app.AppFragment.java
com.tuxremote.app.AppListViewAdapter.java
com.tuxremote.app.App.java
com.tuxremote.app.CmdListViewAdapter.java
com.tuxremote.app.Command.java
com.tuxremote.app.ConfigXML.java
com.tuxremote.app.ConnectFragment.java
com.tuxremote.app.EmptyFragment.java
com.tuxremote.app.FileSelectorDialog.java
com.tuxremote.app.Global.java
com.tuxremote.app.MainActivity.java
com.tuxremote.app.NavigationDrawerFragment.java
com.tuxremote.app.Preference.java
com.tuxremote.app.SSHAsyncTask.java
com.tuxremote.app.Server.java
com.tuxremote.app.TuxRemoteUtils.java
com.tuxremote.app.TuxeRemoteSsh.BashReturn.java
com.tuxremote.app.TuxeRemoteSsh.MyUserInfo.java
com.tuxremote.app.TuxeRemoteSsh.SshSession.java