/* Copyright © 2015 Gluzskiy Alexandr (sss) This file is part of Unknown Download Manager (UDM). UDM 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 2 of the License, or (at your option) any later version. UDM 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 UDM. If not, see . */ //TODO: write readable proto description //ui common proto part begin enum MODULE_UI_ELEMENT_TYPE { UI_EMPTY = 0; //helper type to set empty element UI_STR = 1; //ui elements containing strings UI_INTEGER = 2; //numeric only ui elements (use strings instead ?) UI_PROGRESS_BAR = 3; //generic progress bar UI_WINDOW = 4; //ui window ... UI_GROUP = 5; //empty ui element to group children together in ui (tabs can be implemented using this type) } message module_download_ui_element_info { optional MODULE_UI_ELEMENT_TYPE type = 1 [default = UI_EMPTY]; required int32 id = 2; //internal element id used to get element value (should be unique for every loaded module) optional string name = 3 [default = "not set"]; //can be non unique optional string description = 4; repeated module_download_ui_element_info children = 5; } message module_download_menu_element_info { required int32 id = 1; required string name = 2; optional string description = 3; optional bool data_required = 4 [default = false]; repeated module_download_menu_element_info children = 5; //element with children cannot be executed, it's just container } message module_download_ui_element_data { required int32 ui_id = 1; //should be unique for every loaded module required string data = 2; } message module_download_ui_data { repeated module_download_ui_element_data data = 1; required string download_id = 2; } message server_download_ui_data_reply { required string module_name = 1; required module_download_ui_data data = 2; } message client_download_ui_data_request { required string module_name = 1; required string download_id = 2; repeated int32 ui_id = 3; //should be unique for for every loaded module } //ui common proto part end //TOOD: extended ui updates subscriptions proto part (ui data messages on timer, e.t.c.) //ui subscriptions begin message download_ui_subscription_info { optional client_download_ui_data_request download_ui_data = 1; optional bool one_shot = 3 [default = false]; required int64 interval = 4; } message download_ui_unsubscription_info { required int32 id = 1; //unsubscript from all updates for given id's } //ui subscriptions end //TODO: downloads related proto part //dowloads proto part begin message client_download_add_request { repeated string_pair params = 1; } message client_download_start_request { required int32 download_id = 1; } message client_download_stop_request { required int32 download_id = 1; } message client_download_delete_request { required int32 download_id = 1; optional bool with_data = 2 [default = false]; } message client_download_action_request { required int32 download_id = 1; required int32 action_id = 2; } message int_string_pair { required int32 id = 1; required string value = 2; } message client_downloads_request { repeated int_string_pair params = 1; } message client_download_request { required int32 download_id = 1; repeated int_string_pair params = 2; } enum DOWNLOAD_CONTENT_ENTRY_TYPE { DOWNLOAD_CONTENT_ENTRY_TYPE_FILE = 0; DOWNLOAD_CONTENT_ENTRY_TYPE_DIRECTORY = 1; } message download_content_entry { required string name = 1; optional DOWNLOAD_CONTENT_ENTRY_TYPE type = 2 [default = DOWNLOAD_CONTENT_ENTRY_TYPE_FILE]; repeated download_content_entry children = 3; optional int64 size = 4 [default = 0]; optional int64 downloaded = 5 [default = 0]; } message download { required int32 id = 1; required string name = 2; required string module_name = 3; optional download_content_entry content = 4; required int64 size = 5; required int64 downloaded = 6; } message server_download_reply { required download download = 1; } //downloads proto part end // event subscription part begin enum SUBSCRIPTION_TYPE { SUBSCRIPTION_UI_CHANGE = 0; SUBSCRIPTION_SETTING_CHANGE = 1; } message client_event_subscription_request { required SUBSCRIPTION_TYPE type = 1; required string module_name = 2; optional download_ui_subscription_info download_ui_info = 3; } message client_event_unsubscription_request { required SUBSCRIPTION_TYPE type = 1; required string module_name = 2; optional download_ui_unsubscription_info ui_info = 3; } message server_event_subscription_reply { required SUBSCRIPTION_TYPE type = 1; required string module_name = 2; optional download_ui_subscription_info ui_info = 3; required bool status = 10; optional string status_description = 11; } message server_event_unsubscription_reply { required SUBSCRIPTION_TYPE type = 1; required string module_name = 2; optional download_ui_unsubscription_info ui_info = 3; required bool status = 10; optional string status_description = 11; } //event subscription part end //TODO: settings: // children ? // groups ? //settings common proto part begin message setting_info { optional string default_value = 1 [default = "empty"]; optional string minimal_value = 2 [default = "not set"]; optional string maximal_value = 3 [default = "not set"]; optional string description = 4; repeated string dependencies = 5; //list containing all settings which must be turned on for this setting repeated string blockers = 6; //list of settings which must be turned of for this setting } message setting { required string name = 1 [default = "not set"]; //should be unique for every loaded module optional setting_info info = 2; optional string value = 3 [default = "empty"]; } //settings common proto part end //module related messages begin enum SERVER_MODULE_TYPE { SERVER_MODULE_DOWNLOADER = 0; SERVER_MODULE_METADATA_STORAGE = 1; } message string_pair { required string name = 1; required string value = 2; } message module_info //general module info for client including settings, download info ui and module specific menus { required SERVER_MODULE_TYPE type = 1; required string name = 2; //unique (used as module id) required string version = 3; optional string description = 4 [default = "no description specified"]; repeated setting settings = 5; repeated module_download_ui_element_info download_info_ui = 6; //always complete here repeated module_download_ui_element_info download_creation_ui = 7; repeated module_download_menu_element_info download_menu = 8; repeated module_download_menu_element_info download_children_menu = 9; //menu for files and folders inside download root, may not present repeated string_pair get_downloads_parameters_info = 10; } //module related messages end //core related messages begin message core_info //core info for client currently for editable server settings, server version and proto version only { optional int32 proto_version = 1 [default = 1]; required int32 version = 2; repeated setting settings = 3; } //core related messages end //auth proto part begin enum PASSWD_HASH_TYPE { HASH_NONE = 0; HASH_MD5 = 1; HASH_SHA2 = 2; HASH_SHA512 = 3; } message client_auth_request { required bytes password = 1; optional PASSWD_HASH_TYPE hash_type = 2 [default = HASH_NONE]; } message server_auth_reply { required bool status = 1; //true == success, false == error optional string auth_token = 2; //must be set if no error optional string error_description = 3; //readable description must be set on error } //auth proto part end //TODO: large datatransfer proto part // it should be in separate connection // it should be very simple // it should have as small overhead as possible, better none at all //vaviant 1: client: > request peace of data // server: < reply "peace of data" size or error // client: if no error and data size is sane start reading "data size" // done, server can handle more commands now //message client_data_transfer_request { //} //message server_data_transfer_reply { //} //top level messages begin enum CLIENT_MSG_TYPE { CLIENT_AUTH_REQUEST = 0; CLIENT_DATA_TRANSFER_REQUEST = 1; CLIENT_UI_DATA_REQUEST = 2; CLIENT_MODULES_REQUEST = 3; CLIENT_CORE_INFO_REQUEST = 4; CLIENT_SUBSCRIPTIONS_REQUEST = 5; CLIENT_UNSUBSCRIPTIONS_REQUEST = 6; CLIENT_DOWNLOADS_LIST_REQUEST = 7; CLIENT_DOWNLOAD_ADD = 8; CLIENT_DOWNLOAD_START = 9; CLIENT_DOWNLOAD_STOP = 10; CLIENT_DOWNLOAD_DELETE = 11; CLIENT_DOWNLOAD_EXECUTE_ACTION = 12; CLIENT_DOWNLOAD_INFO_REQUEST = 13; } message client_msg { required CLIENT_MSG_TYPE type = 1; optional string auth_token = 2; //this must be set in all message type's except CLIENT_AUTH_REQUEST optional client_auth_request auth_request = 3; repeated client_download_ui_data_request download_ui_data_request = 4; repeated client_event_subscription_request subscription_request = 5; repeated client_event_unsubscription_request unsubscription_request = 6; repeated client_download_request downloads_request = 7; optional client_download_add_request download_add_request = 8; optional client_download_start_request download_start_request = 9; optional client_download_stop_request download_stop_request = 10; optional client_download_delete_request download_delete_request = 11; optional client_download_action_request download_action_request = 12; optional client_downloads_request download_list_request = 13; } enum SERVER_MSG_TYPE { SERVER_AUTH_REPLY = 0; SERVER_UI_DATA_REPLY = 1; SERVER_MODULES_REPLY = 2; SERVER_CORE_INFO_REPLY = 3; SERVER_SUBSCRIPTIONS_REPLY = 4; SERVER_UNSUBSCRIPTIONS_REPLY = 5; SERVER_DOWNLOADS_LIST_REPLY = 6; SERVER_DOWNLOAD_INFO_REPLY = 7; } message server_msg { required SERVER_MSG_TYPE type = 1; optional server_download_ui_data_reply download_ui_data_reply = 2; optional server_auth_reply auth_reply = 3; repeated module_info server_modules_reply = 4; optional core_info server_core_info_reply = 5; repeated server_event_subscription_reply subscription_reply = 6; repeated server_event_unsubscription_reply unsubscription_reply = 7; optional server_download_reply download = 8; repeated server_download_reply downloads = 9; } //top level messages end