//
// 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.system_info;

message Computer
{
    string name      = 1;
    string domain    = 2;
    string workgroup = 3;
    uint64 uptime    = 4;
}

message OperatingSystem
{
    string name        = 1;
    string version     = 2;
    string arch        = 3;
    string key         = 4;
    int64 install_date = 5;
}

message Motherboard
{
    string manufacturer = 1;
    string model        = 2;
}

message Bios
{
    string vendor  = 1;
    string version = 2;
    string date    = 3;
}

message Processor
{
    string vendor   = 1;
    string model    = 2;
    uint32 packages = 3;
    uint32 cores    = 4;
    uint32 threads  = 5;
}

message Memory
{
    message Module
    {
        bool present         = 1;
        string location      = 2;
        string manufacturer  = 3;
        uint64 size          = 4;
        string type          = 5;
        string form_factor   = 6;
        string part_number   = 7;
        uint32 speed         = 8;
    }

    repeated Module module = 1;
}

message LogicalDrives
{
    message Drive
    {
        string path        = 1;
        string file_system = 2;
        uint64 total_size  = 3;
        uint64 free_size   = 4;
    }

    repeated Drive drive = 1;
}

message Printers
{
    message Printer
    {
        string name       = 1;
        bool default      = 2;
        bool shared       = 3;
        string port       = 4;
        string driver     = 5;
        uint32 jobs_count = 6;
        string share_name = 7;
    }

    repeated Printer printer = 1;
}

message NetworkAdapters
{
    message Adapter
    {
        message Address
        {
            string ip   = 1;
            string mask = 2;
        }

        string adapter_name      = 1;
        string connection_name   = 2;
        string iface             = 3;
        uint64 speed             = 4;
        string mac               = 5;
        bool dhcp_enabled        = 6;
        repeated string gateway  = 7;
        repeated Address address = 8;
        repeated string dns      = 9;
        repeated string dhcp     = 10;
    }

    repeated Adapter adapter = 1;
}

message NetworkShares
{
    message Share
    {
        string name         = 1;
        string description  = 2;
        string type         = 3;
        string local_path   = 4;
        uint32 current_uses = 5;
        uint32 max_uses     = 6;
    }

    repeated Share share = 1;
}

message WindowsDevices
{
    message Device
    {
        string friendly_name  = 1;
        string description    = 2;
        string driver_version = 3;
        string driver_date    = 4;
        string driver_vendor  = 5;
        string device_id      = 6;
    }

    repeated Device device = 1;
}

message VideoAdapters
{
    message Adapter
    {
        string description     = 1;
        string adapter_string  = 2;
        string bios_string     = 3;
        string chip_type       = 4;
        string dac_type        = 5;
        string driver_date     = 6;
        string driver_version  = 7;
        string driver_provider = 8;
        uint64 memory_size     = 9;
    }

    repeated Adapter adapter = 1;
}

message Monitors
{
    message Monitor
    {
        enum InputSignalType
        {
            INPUT_SIGNAL_TYPE_UNKNOWN = 0;
            INPUT_SIGNAL_TYPE_ANALOG  = 1;
            INPUT_SIGNAL_TYPE_DIGITAL = 2;
        }

        message Timing
        {
            int32 width     = 1;
            int32 height    = 2;
            int32 frequency = 3;
        }

        string system_name                   = 1;
        string monitor_name                  = 2;
        string manufacturer_name             = 3;
        string monitor_id                    = 4;
        string serial_number                 = 5;
        int32 edid_version                   = 6;
        int32 edid_revision                  = 7;
        int32 week_of_manufacture            = 8;
        int32 year_of_manufacture            = 9;
        int32 max_horizontal_image_size      = 10;
        int32 max_vertical_image_size        = 11;
        int32 horizontal_resolution          = 12;
        int32 vertical_resoulution           = 13;
        double gamma                         = 14;
        int32 min_horizontal_rate            = 15;
        int32 max_horizontal_rate            = 16;
        int32 min_vertical_rate              = 17;
        int32 max_vertical_rate              = 18;
        double pixel_clock                   = 19;
        int32 max_pixel_clock                = 20;
        InputSignalType input_signal_type    = 21;
        bool default_gtf_supported           = 22;
        bool suspend_supported               = 23;
        bool standby_supported               = 24;
        bool active_off_supported            = 25;
        bool preferred_timing_mode_supported = 26;
        bool srgb_supported                  = 27;
        repeated Timing timings              = 28;
    }

    repeated Monitor monitor = 1;
}

message PowerOptions
{
    enum PowerSource
    {
        POWER_SOURCE_UNKNOWN    = 0;
        POWER_SOURCE_DC_BATTERY = 1;
        POWER_SOURCE_AC_LINE    = 2;
    }

    enum BatteryStatus
    {
        BATTERY_STATUS_UNKNOWN    = 0;
        BATTERY_STATUS_HIGH       = 1;
        BATTERY_STATUS_LOW        = 2;
        BATTERY_STATUS_CRITICAL   = 3;
        BATTERY_STATUS_CHARGING   = 4;
        BATTERY_STATUS_NO_BATTERY = 5;
    }

    message Battery
    {
        enum State
        {
            STATE_UNKNOWN      = 0;
            STATE_CHARGING     = 1;
            STATE_CRITICAL     = 2;
            STATE_DISCHARGING  = 4;
            STATE_POWER_ONLINE = 8;
        }

        string device_name           = 1;
        string manufacturer          = 2;
        string manufacture_date      = 3;
        string unique_id             = 4;
        string serial_number         = 5;
        string temperature           = 6;
        uint32 design_capacity       = 7;
        string type                  = 8;
        uint32 full_charged_capacity = 9;
        uint32 depreciation          = 10;
        uint32 current_capacity      = 11;
        uint32 voltage               = 12;
        uint32 state                 = 13;
    }

    PowerSource power_source          = 1;
    BatteryStatus battery_status      = 2;
    uint64 full_battery_life_time      = 3;
    uint64 remaining_battery_life_time = 4;
    uint32 battery_life_percent        = 5;
    repeated Battery battery          = 6;
}

message Drivers
{
    message Driver
    {
        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;
        string binary_path       = 6;
    }

    repeated Driver driver = 1;
}

message Services
{
    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;
        string binary_path       = 6;
        string start_name        = 7;
    }

    repeated Service service = 1;
}

message EnvironmentVariables
{
    message Variable
    {
        string name  = 1;
        string value = 2;
    }

    repeated Variable variable = 1;
}

message EventLogs
{
    message Event
    {
        enum Type
        {
            TYPE_UNKNOWN     = 0;
            TYPE_APPLICATION = 1;
            TYPE_SECURITY    = 2;
            TYPE_SYSTEM      = 3;
        }

        enum Level
        {
            LEVEL_UNKNOWN       = 0;
            LEVEL_SUCCESS       = 1;
            LEVEL_INFORMATION   = 2;
            LEVEL_WARNING       = 4;
            LEVEL_ERROR         = 8;
            LEVEL_AUDIT_SUCCESS = 16;
            LEVEL_AUDIT_FAILURE = 32;
        }

        Level level        = 1;
        int64 time         = 2;
        string category    = 3;
        uint32 event_id    = 4;
        string source      = 5;
        string description = 6;
    }

    Event.Type type = 1;
    uint32 total_records = 2;
    repeated Event event = 3;
}

message EventLogsData
{
    EventLogs.Event.Type type = 1;
    uint32 record_start = 2;
    uint32 record_count = 3;
}

message Routes
{
    message Route
    {
        string destonation = 1;
        string mask        = 2;
        string gateway     = 3;
        uint32 metric      = 4;
    }

    repeated Route route = 1;
}

message Connections
{
    message Connection
    {
        string process_name   = 1;
        string protocol       = 2;
        string local_address  = 3;
        string remote_address = 4;
        uint32 local_port     = 5;
        uint32 remote_port    = 6;
        string state          = 7;
    }

    repeated Connection connection = 1;
}

message Licenses
{
    message License
    {
        message Field
        {
            enum Type
            {
                TYPE_UNKNOWN         = 0;
                TYPE_OWNER           = 2;
                TYPE_ORGANIZATION    = 3;
                TYPE_PRODUCT_KEY     = 4;
                TYPE_PRODUCT_ID      = 5;
                TYPE_LICENSE_VERSION = 6;
                TYPE_LICENSE_TYPE    = 7;
            }

            Type type    = 1;
            string value = 2;
        }

        string product_name  = 1;
        repeated Field field = 2;
    }

    repeated License license = 1;
}

message Applications
{
    message Application
    {
        string name             = 1;
        string version          = 2;
        string publisher        = 3;
        string install_date     = 4;
        string install_location = 5;
    }

    repeated Application application = 1;
}

message OpenFiles
{
    message OpenFile
    {
        uint32 id         = 1;
        string user_name  = 2;
        uint32 lock_count = 3;
        string file_path  = 4;
    }

    repeated OpenFile open_file = 1;
}

message LocalUsers
{
    message LocalUser
    {
        message LocalUserGroup
        {
            string name    = 1;
            string comment = 2;
        }

        string name                   = 1;
        string full_name              = 2;
        string comment                = 3;
        string home_dir               = 4;
        repeated LocalUserGroup group = 5;
        bool disabled                 = 6;
        bool password_cant_change     = 7;
        bool password_expired         = 8;
        bool dont_expire_password     = 9;
        bool lockout                  = 10;
        uint32 number_logons          = 11;
        uint32 bad_password_count     = 12;
        uint64 last_logon_time        = 13;
    }

    repeated LocalUser local_user = 1;
}

message LocalUserGroups
{
    message LocalUserGroup
    {
        string name    = 1;
        string comment = 2;
    }

    repeated LocalUserGroup local_user_group = 1;
}

message Processes
{
    message Process
    {
        string name  = 1;
        uint32 pid   = 2;
        uint32 sid   = 3;
        string user  = 4;
        string path  = 5;
        int32 cpu    = 6;
        int64 memory = 7;
    }

    repeated Process process = 1;
}

message SystemInfoRequest
{
    string category = 1;
    // Fields 2 - 10: Reserved.
    EventLogsData event_logs_data = 11;
}

message SystemInfoFooter
{
    string category = 1;
}

message SystemInfo
{
    Computer computer                 = 1;
    OperatingSystem operating_system  = 2;
    Motherboard motherboard           = 3;
    Bios bios                         = 4;
    Processor processor               = 5;
    Memory memory                     = 6;
    LogicalDrives logical_drives      = 7;
    Printers printers                 = 8;
    NetworkAdapters network_adapters  = 9;
    NetworkShares network_shares      = 10;
    WindowsDevices windows_devices    = 11;
    VideoAdapters video_adapters      = 12;
    Monitors monitors                 = 13;
    PowerOptions power_options        = 14;
    Drivers drivers                   = 15;
    Services services                 = 16;
    EnvironmentVariables env_vars     = 17;
    EventLogs event_logs              = 18;
    Routes routes                     = 19;
    Connections connections           = 20;
    Licenses licenses                 = 21;
    Applications applications         = 22;
    OpenFiles open_files              = 23;
    LocalUsers local_users            = 24;
    LocalUserGroups local_user_groups = 25;
    Processes processes               = 26;
    SystemInfoFooter footer           = 128000;
}
