blob: 98e5fdc81b77a79bbd7f1e6cd25094e45a3109e2 (
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
|
#ifndef OS_FORBID_H
#define OS_FORBID_H
enum ForbidType
{
FT_NONE,
FT_NICK,
FT_CHAN,
FT_EMAIL
};
struct ForbidData : Serializable
{
Anope::string mask;
Anope::string creator;
Anope::string reason;
time_t created;
time_t expires;
ForbidType type;
Anope::string serialize_name() const { return "ForbidData"; }
serialized_data serialize();
static void unserialize(serialized_data &data);
};
class ForbidService : public Service
{
public:
ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { }
virtual void AddForbid(ForbidData *d) = 0;
virtual void RemoveForbid(ForbidData *d) = 0;
virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0;
virtual const std::vector<ForbidData *> &GetForbids() = 0;
};
static service_reference<ForbidService> forbid_service("ForbidService", "forbid");
Serializable::serialized_data ForbidData::serialize()
{
serialized_data data;
data["mask"] << this->mask;
data["creator"] << this->creator;
data["reason"] << this->reason;
data["created"] << this->created;
data["expires"] << this->expires;
data["type"] << this->type;
return data;
}
void ForbidData::unserialize(serialized_data &data)
{
if (!forbid_service)
return;
ForbidData *fb = new ForbidData;
data["mask"] >> fb->mask;
data["creator"] >> fb->creator;
data["reason"] >> fb->reason;
data["created"] >> fb->created;
data["expires"] >> fb->expires;
unsigned int t;
data["type"] >> t;
fb->type = static_cast<ForbidType>(t);
forbid_service->AddForbid(fb);
}
#endif
|