//
// Aspia Project
// Copyright (C) 2016-2024 Dmitry Chapyshev <dmitry@aspia.ru>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

syntax = "proto3";

option optimize_for = LITE_RUNTIME;

package proto.task_manager;

message Process
{
    uint64 process_id             = 1;
    uint64 session_id             = 2;
    string process_name           = 3;
    string user_name              = 4;
    string file_path              = 5;
    int32 cpu_usage               = 6;
    int64 mem_working_set         = 7;
    int64 mem_peak_working_set    = 8;
    int64 mem_working_set_delta   = 9;
    int64 mem_private_working_set = 10;
    uint32 thread_count           = 11;
}

message ProcessList
{
    repeated Process process = 1;
    int32 cpu_usage          = 2;
    int32 memory_usage       = 3;
}

message ProcessListRequest
{
    enum Flags
    {
        NONE        = 0;
        RESET_CACHE = 1;
    }

    uint32 flags = 1;
}

message EndProcessRequest
{
    uint64 pid = 1;
}

message Service
{
    enum Status
    {
        STATUS_UNKNOWN          = 0;
        STATUS_CONTINUE_PENDING = 1;
        STATUS_PAUSE_PENDING    = 2;
        STATUS_PAUSED           = 3;
        STATUS_RUNNING          = 4;
        STATUS_START_PENDING    = 5;
        STATUS_STOP_PENDING     = 6;
        STATUS_STOPPED          = 7;
    }

    enum StartupType
    {
        STARTUP_TYPE_UNKNOWN      = 0;
        STARTUP_TYPE_AUTO_START   = 1;
        STARTUP_TYPE_DEMAND_START = 2;
        STARTUP_TYPE_DISABLED     = 3;
        STARTUP_TYPE_BOOT_START   = 4;
        STARTUP_TYPE_SYSTEM_START = 5;
    }

    string name              = 1;
    string display_name      = 2;
    string description       = 3;
    Status status            = 4;
    StartupType startup_type = 5;
}

message ServiceList
{
    repeated Service service = 1;
}

message ServiceListRequest
{
    uint32 dummy = 1;
}

message ServiceRequest
{
    enum Command
    {
        COMMAND_UNKNOWN = 0;
        COMMAND_START   = 1;
        COMMAND_STOP    = 2;
    }

    string name     = 1;
    Command command = 2;
}

message User
{
    enum ConnectState
    {
        CONNECT_STATE_UNKNOWN       = 0;
        CONNECT_STATE_ACTIVE        = 1;
        CONNECT_STATE_CONNECTED     = 2;
        CONNECT_STATE_CONNECT_QUERY = 3;
        CONNECT_STATE_SHADOW        = 4;
        CONNECT_STATE_DISCONNECTED  = 5;
        CONNECT_STATE_IDLE          = 6;
        CONNECT_STATE_LISTEN        = 7;
        CONNECT_STATE_RESET         = 8;
        CONNECT_STATE_DOWN          = 9;
        CONNECT_STATE_INIT          = 10;
    }

    string user_name           = 1;
    uint32 session_id          = 2;
    string client_name         = 3;
    string session_name        = 4;
    ConnectState connect_state = 5;
}

message UserList
{
    repeated User user = 1;
}

message UserListRequest
{
    uint32 dummy = 1;
}

message UserRequest
{
    enum Command
    {
        COMMAND_UNKNOWN    = 0;
        COMMAND_DISCONNECT = 1;
        COMMAND_LOGOFF     = 2;
    }

    uint32 session_id = 1;
    Command command   = 2;
}

message ClientToHost
{
    ProcessListRequest process_list_request = 1;
    EndProcessRequest end_process_request   = 2;
    ServiceListRequest service_list_request = 3;
    ServiceRequest service_request          = 4;
    UserListRequest user_list_request       = 5;
    UserRequest user_request                = 6;
}

message HostToClient
{
    ProcessList process_list = 1;
    ServiceList service_list = 2;
    UserList user_list       = 3;
}
