//..............................................................................
//
// SSH log representer
//

import "log_Representation.jnc"
import "SshLogRecordCode.jnc"
import "SocketLog/SocketLogRecordCode.jnc"

//..............................................................................

bool representSshLog(
	log.Representation* representation,
	uint64_t recordCode,
	void const* p,
	size_t size,
	uint_t foldFlags
	)
{
	switch (recordCode)
	{
	case SshLogRecordCode.TcpConnectCompleted:
		representation.m_lineAttr.m_flags = log.LineAttrFlags.TileIcon;
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.ConnectCompleted, "ok");
		representation.addHyperText(SocketLogPartCode.Connecting, "Performing SSH handshake...");
		break;

	case SshLogRecordCode.SshHandshakeCompleted:
		representation.m_lineAttr.m_flags = log.LineAttrFlags.TileIcon;
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.ConnectCompleted, "ok");
		representation.addHyperText(SocketLogPartCode.Connecting, "Performing SSH authentification...");
		break;

	case SshLogRecordCode.SshAuthenticating:
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.Connecting, "Performing SSH authentification...");
		break;

	case SshLogRecordCode.SshAuthCompleted:
		representation.m_lineAttr.m_flags = log.LineAttrFlags.TileIcon;
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.ConnectCompleted, "ok");
		representation.addHyperText(SocketLogPartCode.Connecting, "Opening SSH channel...");
		break;

	case SshLogRecordCode.SshChannelOpened:
		representation.m_lineAttr.m_flags = log.LineAttrFlags.TileIcon;
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.ConnectCompleted, "ok");
		representation.addHyperText(SocketLogPartCode.Connecting, "Requesting PTY...");
		break;

	case SshLogRecordCode.SshPtyRequested:
		representation.m_lineAttr.m_flags = log.LineAttrFlags.TileIcon;
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.ConnectCompleted, "ok");
		representation.addHyperText(SocketLogPartCode.Connecting, "Starting process...");
		break;

	case SshLogRecordCode.SshProcessStarted:
		representation.addHyperText(SocketLogPartCode.ConnectCompleted, "ok");
		break;

	case SshLogRecordCode.ConnectCompleted:
		representation.m_lineAttr.m_iconIdx  = log.StdLogIcon.Connect;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Connect;
		representation.addHyperText("SSH channel established");
		break;

	case SshLogRecordCode.Reconnecting:
		representation.m_lineAttr.m_iconIdx = log.StdLogIcon.Info;
		representation.m_lineAttr.m_backColor = log.StdLogColor.Info;
		representation.addHyperText(SocketLogPartCode.Connecting, "Reconnecting...");
		break;

	default:
		return false;
	}

	return true;
}

//..............................................................................
