blob: 3f1fe9a7fc29ebf76d33a406b1f3daae23de1488 (
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
|
#ifndef OS_FORBID_H
#define OS_FORBID_H
enum ForbidType
{
FT_NICK = 1,
FT_CHAN,
FT_EMAIL,
FT_REGISTER,
FT_SIZE
};
struct ForbidData : Serializable
{
Anope::string mask;
Anope::string creator;
Anope::string reason;
time_t created;
time_t expires;
ForbidType type;
ForbidData() : Serializable("ForbidData") { }
void Serialize(Serialize::Data &data) const anope_override;
static Serializable* Unserialize(Serializable *obj, Serialize::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 std::vector<ForbidData *> GetForbids() = 0;
};
static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid");
void ForbidData::Serialize(Serialize::Data &data) const
{
data["mask"] << this->mask;
data["creator"] << this->creator;
data["reason"] << this->reason;
data["created"] << this->created;
data["expires"] << this->expires;
data["type"] << this->type;
}
Serializable* ForbidData::Unserialize(Serializable *obj, Serialize::Data &data)
{
if (!forbid_service)
return NULL;
ForbidData *fb;
if (obj)
fb = anope_dynamic_static_cast<ForbidData *>(obj);
else
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);
if (t > FT_SIZE - 1)
return NULL;
if (!obj)
forbid_service->AddForbid(fb);
return fb;
}
#endif
|