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
use crate::framing::CloudProtoError;
use byteorder::{ReadBytesExt, WriteBytesExt, BE};
use std::io::{Read, Write};
use strum_macros::{AsRefStr, Display, FromRepr};
pub(crate) const EVT_HDR_LEN: usize = 4;
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct Event {
pub raw_event_id: u32,
pub event_id: Option<EventId>,
pub data: Vec<u8>,
}
impl Event {
pub fn new(event_id: EventId, data: Vec<u8>) -> Self {
Self {
raw_event_id: event_id as u32,
event_id: Some(event_id),
data,
}
}
pub fn ev_id_string(&self) -> String {
if let Some(id) = self.event_id {
id.to_string()
} else {
self.raw_event_id.to_string()
}
}
pub(crate) fn from_read(reader: &mut dyn Read) -> Result<Self, CloudProtoError> {
let raw_event_id = reader.read_u32::<BE>()?;
let event_id = EventId::from_repr(raw_event_id);
let mut data = Vec::new();
reader.read_to_end(&mut data)?;
Ok(Self {
raw_event_id,
event_id,
data,
})
}
pub(crate) fn into_write(self, writer: &mut dyn Write) -> Result<(), CloudProtoError> {
writer.write_u32::<BE>(self.raw_event_id)?;
writer.write_all(&self.data)?;
writer.flush()?;
Ok(())
}
}
#[derive(Eq, PartialEq, Debug, Copy, Clone, Display, AsRefStr, FromRepr)]
#[repr(u32)]
#[rustfmt::skip]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
#[non_exhaustive]
pub enum EventId {
ConfigurationLoaded = 0x308000AA,
LfoDownloadFromManifestRecord = 0x308000AD,
ChannelDownloadComplete = 0x308001D2,
UNK_SERVER_0x30800207 = 0x30800207, CurrentSystemTags = 0x30800208,
CloudRequestReceived = 0x3080028E,
UNK_0x30800296 = 0x30800296, IpAddressAddedForFamily2 = 0x308002e5, IpAddressAdded = 0x308002e6,
HostnameChanged = 0x3080034D,
CurrentUninstallTokenInfo = 0x30800457,
ChannelRundown = 0x30800550,
ChannelDiffDownload = 0x3080064E,
DiskCapacity = 0x3080069f,
DiskUtilization = 0x30800850,
UNK_0x31000002 = 0x31000002, ChannelVersionRequired = 0x310001D1,
UNK_0x3100053f = 0x3100053f, SystemCapacity = 0x310005AB,
UpdateCloudEvent = 0x318002B1,
OsVersionInfo = 0x3200014e,
UNK_0x32000220 = 0x32000220, UNK_0x320002cf = 0x320002cf, ConnectionStatus = 0x32800139,
AgentOnline = 0x338000ac,
UNK_0x340000ee = 0x340000ee, }