package com.jscape.inet.ssh.protocol.v2.connection;

import com.jscape.inet.ssh.protocol.v2.marshaling.*;
import com.jscape.inet.ssh.protocol.v2.messages.*;

/**
 * @author Alex Usun
 */
public class SessionConnectionMessages {

    public static final Class[] CHANNEL_TYPES = {
            SshMsgChannelOpenSession.class,
            SshMsgChannelOpenDirectTcpIp.class,
    };

    public static final Class[] REQUEST_TYPES = {
            SshMsgChannelRequestPtyReq.class,
            SshMsgChannelRequestEnv.class,
            SshMsgChannelRequestShell.class,
            SshMsgChannelRequestExec.class,
            SshMsgChannelRequestSubsystem.class,
            SshMsgChannelRequestWindowChange.class,
            SshMsgChannelRequestSignal.class,
            SshMsgChannelRequestBreak.class,
            SshMsgChannelRequestExitStatus.class,
    };

    public static final SshMsgChannelOpenCodec.Entry[] CHANNEL_ENTRIES = {
            new SshMsgChannelOpenCodec.Entry("session", new SshMsgChannelOpenSessionCodec(), SshMsgChannelOpenSession.class),
            new SshMsgChannelOpenCodec.Entry("direct-tcpip", new SshMsgChannelOpenDirectTcpIpCodec(), SshMsgChannelOpenDirectTcpIp.class),
    };

    public static final SshMsgChannelRequestCodec.Entry[] REQUEST_ENTRIES = {
            new SshMsgChannelRequestCodec.Entry("pty-req", new SshMsgChannelRequestPtyReqCodec(), SshMsgChannelRequestPtyReq.class),
            new SshMsgChannelRequestCodec.Entry("env", new SshMsgChannelRequestEnvCodec(), SshMsgChannelRequestEnv.class),
            new SshMsgChannelRequestCodec.Entry("shell", new SshMsgChannelRequestShellCodec(), SshMsgChannelRequestShell.class),
            new SshMsgChannelRequestCodec.Entry("exec", new SshMsgChannelRequestExecCodec(), SshMsgChannelRequestExec.class),
            new SshMsgChannelRequestCodec.Entry("subsystem", new SshMsgChannelRequestSubsystemCodec(), SshMsgChannelRequestSubsystem.class),
            new SshMsgChannelRequestCodec.Entry("window-change", new SshMsgChannelRequestWindowChangeCodec(), SshMsgChannelRequestWindowChange.class),
            new SshMsgChannelRequestCodec.Entry("signal", new SshMsgChannelRequestSignalCodec(), SshMsgChannelRequestSignal.class),
            new SshMsgChannelRequestCodec.Entry("break", new SshMsgChannelRequestBreakCodec(), SshMsgChannelRequestBreak.class),
            new SshMsgChannelRequestCodec.Entry("exit-status", new SshMsgChannelRequestExitStatusCodec(), SshMsgChannelRequestExitStatus.class),
    };

    public static final MessageCodec.Entry[] ENTRIES = {
            new MessageCodec.Entry(90, new SshMsgChannelOpenCodec(CHANNEL_ENTRIES), CHANNEL_TYPES),
            new MessageCodec.Entry(91, new SshMsgChannelOpenConfirmationCodec(), SshMsgChannelOpenConfirmation.class),
            new MessageCodec.Entry(98, new SshMsgChannelRequestCodec(REQUEST_ENTRIES), REQUEST_TYPES),
    };

    public static MessageCodec init(MessageCodec codec) {
        return ConnectionMessages.init(codec.set(ENTRIES));
    }

    private SessionConnectionMessages() {
        // empty
    }
}
