// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandEnd.java
// public class SshCommandEnd {
//     private SshCommandStatus status;
// 
//     public SshCommandEnd(SshCommandStatus status) {
//         this.status = status;
//     }
// 
//     public SshCommandStatus getStatus() {
//         return status;
//     }
// }
// 
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandStart.java
// public class SshCommandStart {
// }


import com.jcraft.jsch.*;
import it.skarafaz.mercury.model.event.SshCommandEnd;
import it.skarafaz.mercury.model.event.SshCommandStart;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
            SshCommandStatus status = execute();
            afterExecute(status);
        }
    }

    protected boolean beforeExecute() {
        EventBus.getDefault().postSticky(new SshCommandStart());
        return true;
    }

    private SshCommandStatus execute() {
        SshCommandStatus status = SshCommandStatus.COMMAND_SENT;

        if (initConnection()) {
            if (connect()) {
                if (!send(formatCmd(cmd))) {
                    status = SshCommandStatus.EXECUTION_FAILED;
                }
                disconnect();
            } else {
                status = SshCommandStatus.CONNECTION_FAILED;
            }
        } else {
            status = SshCommandStatus.CONNECTION_INIT_ERROR;
        }

        return status;
    }

    protected void afterExecute(SshCommandStatus status) {
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandEnd.java
// public class SshCommandEnd {
//     private SshCommandStatus status;
// 
//     public SshCommandEnd(SshCommandStatus status) {
//         this.status = status;
//     }
// 
//     public SshCommandStatus getStatus() {
//         return status;
//     }
// }
// 
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandStart.java
// public class SshCommandStart {
// }


// Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommand.java
import com.jcraft.jsch.*;
import it.skarafaz.mercury.model.event.SshCommandEnd;
import it.skarafaz.mercury.model.event.SshCommandStart;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

            SshCommandStatus status = execute();
            afterExecute(status);
        }
    }

    protected boolean beforeExecute() {
        EventBus.getDefault().postSticky(new SshCommandStart());
        return true;
    }

    private SshCommandStatus execute() {
        SshCommandStatus status = SshCommandStatus.COMMAND_SENT;

        if (initConnection()) {
            if (connect()) {
                if (!send(formatCmd(cmd))) {
                    status = SshCommandStatus.EXECUTION_FAILED;
                }
                disconnect();
            } else {
                status = SshCommandStatus.CONNECTION_FAILED;
            }
        } else {
            status = SshCommandStatus.CONNECTION_INIT_ERROR;
        }

        return status;
    }

    protected void afterExecute(SshCommandStatus status) {
        EventBus.getDefault().postSticky(new SshCommandEnd(status));