summaryrefslogtreecommitdiff
path: root/protocol/events.proto
blob: 6181fbf3b22076bf71b02e24da22fb1efa94ffe6 (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
/*
	Copyright © 2015-2016 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/>.

*/

syntax = "proto2";

import "ui.proto";


//TODO: rework


message subscription_download_ui_info {
	optional client_download_ui_data_request download_ui_data = 1;
	optional bool one_shot = 3 [default = false];
	required int64 interval = 4;
}


message unsubscription_download_ui_info {
	required int32 id = 1; //ui element id
}


//subscription type
enum SUBSCRIPTION_TYPE {
	ST_UI_CHANGE = 0;
	ST_SETTING_CHANGE = 1;
	ST_DOWNLOAD_STATE_CHANGE = 2;
	ST_DOWNLOAD_ADDED = 3;
	ST_DOWNLOAD_DELETED = 4;
}

enum SUBSCRIPTION_MODE {
	SM_EVENT = 0;
	SM_REPEATED = 1;
}

//download state subscription for download state changes (can be module defined)
enum SUBSCRIPTION_DOWNLOAD_STATE {
	SDS_STARTED = 0;
	SDS_STOPPED = 1;
	SDS_DELETED = 2;
	SDS_COMPLETED = 3;
}

message subscription_download_state_change {
	repeated SUBSCRIPTION_DOWNLOAD_STATE states = 1; //list of states on which event should be sent
}

//information about subscription request
message client_event_subscription_request {
	required SUBSCRIPTION_TYPE type = 1; //type must be set
	required SUBSCRIPTION_MODE mode = 2; //mode must be set
	required string module_name = 3; //module name must be set, can be "" for all installed modules supported subscription type
	optional int64 interval = 4 [default = 5000]; //event fire interval in milliseconds, valid for repeated event mode
	optional bool one_time = 5 [default = false]; //is event should fire only once ?
	optional subscription_download_ui_info download_ui_info = 6;
	optional subscription_download_state_change download_state_change = 7;
}


//unsubscript from events of specified type
//here is two variants of unsubscription

//1. can be customized to unsubscript from few aubscriptions at once
message client_event_unsubscription_request {
	required SUBSCRIPTION_TYPE type = 1; //type must be set
	required string module_name = 2; //module name must be set, can be "" for all installed modules supported subscription type
	optional unsubscription_download_ui_info ui_info = 3;
	optional subscription_download_state_change download_state_change = 4; //reusing defined structure to avoid code duplication
}

//2. unsubscript by id given in "server_event_subscription_reply"
message client_event_unsubscription_by_id_request {
	required int32 subscription_id = 1;
}

message server_event_subscription_reply {
	required SUBSCRIPTION_TYPE type = 1;
	required string module_name = 2;
	optional subscription_download_ui_info ui_info = 3;

	required bool status = 1000;
	optional string status_description = 1001;
	optional int32 subscription_id = 1002 [default = -1];
}

message server_event_unsubscription_reply {
	required SUBSCRIPTION_TYPE type = 1;
	required string module_name = 2;
	optional unsubscription_download_ui_info ui_info = 3;

	required bool status = 1000;
	optional string status_description = 1001;
	optional int32 subscription_id = 1002;
}