summaryrefslogtreecommitdiff
path: root/protocol/udm.proto
blob: 029183f13a4ccd893f74dad2741a7df096a30618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/*
	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 <http://www.gnu.org/licenses/>.

*/


//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