All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.eliux.mega.cmd.MegaCmdLogin Maven / Gradle / Ivy

Go to download

Java client library that works on top of MEGAcmd to provide access to the services of Mega.nz

The newest version!
package io.github.eliux.mega.cmd;

import io.github.eliux.mega.MegaUtils;
import io.github.eliux.mega.error.MegaLoginException;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class MegaCmdLogin extends AbstractMegaCmdRunnerWithParams {

    private final List cmdParams;

    public MegaCmdLogin(String... cmdParams) {
        super();
        this.cmdParams = Arrays.asList(cmdParams);
    }

    @Override
    public String getCmd() {
        return "login";
    }

    @Override
    protected void executeSysCmd(String... cmdStr) {
        try {
            final int result = MegaUtils.execCmd(cmdStr);
            MegaUtils.handleResult(result);
        } catch (IOException e) {
            throw new MegaLoginException(
                    "Error while executing login command in Mega"
            );
        } catch (InterruptedException e) {
            throw new MegaLoginException("The login was interrupted");
        }
    }

    @Override
    protected List cmdParams() {
        return cmdParams;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy