Anope IRC Services  Version 2.0
xline.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2008-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  */
9 
10 #ifndef XLINE_H
11 #define XLINE_H
12 
13 #include "serialize.h"
14 #include "service.h"
15 #include "sockets.h"
16 
17 /* An Xline, eg, anything added with operserv/akill, or any of the operserv/sxline commands */
19 {
20  void Init();
21  Anope::string nick, user, host, real;
22  public:
23  cidr *c;
27  time_t created;
28  time_t expires;
32 
33  XLine(const Anope::string &mask, const Anope::string &reason = "", const Anope::string &uid = "");
34 
35  XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid = "");
36  ~XLine();
37 
38  const Anope::string &GetNick() const;
39  const Anope::string &GetUser() const;
40  const Anope::string &GetHost() const;
41  const Anope::string &GetReal() const;
42 
43  Anope::string GetReason() const;
44 
45  bool HasNickOrReal() const;
46  bool IsRegex() const;
47 
48  void Serialize(Serialize::Data &data) const anope_override;
49  static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
50 };
51 
52 /* Managers XLines. There is one XLineManager per type of XLine. */
54 {
55  char type;
56  /* List of XLines in this XLineManager */
58  /* Akills can have the same IDs, sometimes */
60  public:
61  /* List of XLine managers we check users against in XLineManager::CheckAll */
62  static std::list<XLineManager *> XLineManagers;
63 
70  static void RegisterXLineManager(XLineManager *xlm);
71 
75  static void UnregisterXLineManager(XLineManager *xlm);
76 
81  static void CheckAll(User *u);
82 
86  static Anope::string GenerateUID();
87 
90  XLineManager(Module *creator, const Anope::string &name, char t);
91 
94  virtual ~XLineManager();
95 
99  const char &Type();
100 
104  size_t GetCount() const;
105 
109  const std::vector<XLine *> &GetList() const;
110 
114  void AddXLine(XLine *x);
115 
120  bool DelXLine(XLine *x);
121 
126  XLine* GetEntry(unsigned index);
127 
131  void Clear();
132 
140  bool CanAdd(CommandSource &source, const Anope::string &mask, time_t expires, const Anope::string &reason);
141 
146  XLine* HasEntry(const Anope::string &mask);
147 
152  XLine *CheckAllXLines(User *u);
153 
158  virtual bool Check(User *u, const XLine *x) = 0;
159 
164  virtual void OnMatch(User *u, XLine *x) = 0;
165 
169  virtual void OnExpire(const XLine *x);
170 
175  virtual void Send(User *u, XLine *x) = 0;
176 
180  virtual void SendDel(XLine *x) = 0;
181 };
182 
183 #endif // XLINE_H
cidr * c
Definition: xline.h:23
Anope::string reason
Definition: xline.h:29
Anope::string mask
Definition: xline.h:24
XLineManager * manager
Definition: xline.h:30
void Init(int ac, char **av)
Definition: init.cpp:284
char type
Definition: xline.h:55
Definition: users.h:34
Definition: sockets.h:87
Definition: regexpr.h:28
Regex * regex
Definition: xline.h:25
Anope::string user
Definition: xline.h:21
virtual void Serialize(Serialize::Data &data) const =0
CoreExport bool Send(User *from, NickCore *to, BotInfo *service, const Anope::string &subject, const Anope::string &message)
Definition: mail.cpp:54
Anope::string by
Definition: xline.h:26
time_t expires
Definition: xline.h:28
#define anope_override
Definition: services.h:56
Anope::string id
Definition: xline.h:31
static std::list< XLineManager * > XLineManagers
Definition: xline.h:62
#define CoreExport
Definition: services.h:62
Serialize::Checker< std::vector< XLine * > > xlines
Definition: xline.h:57
Definition: xline.h:18
Anope::string name
Definition: access.cpp:22
time_t created
Definition: xline.h:27
static Serialize::Checker< std::multimap< Anope::string, XLine *, ci::less > > XLinesByUID
Definition: xline.h:59