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
|
use crate::message::signalproxy::translation::{Network, NetworkMap};
use libquassel_derive::{NetworkList, NetworkMap};
use std::convert::TryFrom;
#[derive(Debug, Clone, PartialEq, NetworkList)]
pub struct IgnoreListManager {
#[network(rename = "IgnoreList", variant = "VariantMap", network, map)]
ignore_list: Vec<IgnoreListItem>,
// // C->S calls
// requestAddIgnoreListItem(type: Int, ignoreRule: QString,
// isRegEx: Bool, strictness: Int, scope: Int, scopeRule: QString,
// isActive: Bool)
// requestRemoveIgnoreListItem(ignoreRule: QString)
// requestToggleIgnoreRule(ignoreRule: QString)
// /**
// * Replaces all properties of the object with the content of the
// * "properties" parameter. This parameter is in network representation.
// */
// requestUpdate(properties: QVariantMap)
// // S->C calls
// addIgnoreListItem(type: Int, ignoreRule: QString, isRegEx: Bool,
// strictness: Int, scope: Int, scopeRule: QString, isActive: Bool)
// removeIgnoreListItem(ignoreRule: QString)
// toggleIgnoreRule(ignoreRule: QString)
// /**
// * Replaces all properties of the object with the content of the
// * "properties" parameter. This parameter is in network representation.
// */
// update(properties: QVariantMap)
}
#[derive(Debug, Clone, PartialEq, NetworkMap)]
#[network(repr = "maplist")]
pub struct IgnoreListItem {
#[network(rename = "ignoreType", network, type = "u8")]
ignore_type: IgnoreType,
#[network(rename = "ignoreRule")]
ignore_rule: String,
#[network(rename = "isRegEx")]
is_reg_ex: bool,
#[network(rename = "strictness", network, type = "u8")]
strictness: StrictnessType,
#[network(rename = "scope", network, type = "u8")]
scope: ScopeType,
#[network(rename = "scopeRule")]
scope_rule: String,
#[network(rename = "isActive")]
is_active: bool,
}
/////////////////////////////////////
//////////////////////////////////////
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum IgnoreType {
SenderIgnore = 0x00,
MessageIgnore = 0x01,
CtcpIgnore = 0x02,
}
impl TryFrom<u8> for IgnoreType {
type Error = &'static str;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0x00 => Ok(IgnoreType::SenderIgnore),
0x01 => Ok(IgnoreType::MessageIgnore),
0x02 => Ok(IgnoreType::CtcpIgnore),
_ => Err("no matching IgnoreType found"),
}
}
}
impl crate::message::signalproxy::Network for IgnoreType {
type Item = u8;
fn to_network(&self) -> Self::Item {
*self as u8
}
fn from_network(input: &mut Self::Item) -> Self {
IgnoreType::try_from(*input).unwrap()
}
}
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum StrictnessType {
UnmatchedStrictness = 0x00,
SoftStrictness = 0x01,
HardStrictness = 0x02,
}
impl TryFrom<u8> for StrictnessType {
type Error = &'static str;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0x00 => Ok(StrictnessType::UnmatchedStrictness),
0x01 => Ok(StrictnessType::SoftStrictness),
0x02 => Ok(StrictnessType::HardStrictness),
_ => Err("no matching StrictnessType found"),
}
}
}
impl crate::message::signalproxy::Network for StrictnessType {
type Item = u8;
fn to_network(&self) -> Self::Item {
*self as u8
}
fn from_network(input: &mut Self::Item) -> Self {
Self::try_from(*input).unwrap()
}
}
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ScopeType {
GlobalScope = 0x00,
NetworkScope = 0x01,
ChannelScope = 0x02,
}
impl TryFrom<u8> for ScopeType {
type Error = &'static str;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0x00 => Ok(ScopeType::GlobalScope),
0x01 => Ok(ScopeType::NetworkScope),
0x02 => Ok(ScopeType::ChannelScope),
_ => Err("no matching ScopeType found"),
}
}
}
impl crate::message::signalproxy::Network for ScopeType {
type Item = u8;
fn to_network(&self) -> Self::Item {
*self as u8
}
fn from_network(input: &mut Self::Item) -> Self {
Self::try_from(*input).unwrap()
}
}
|