oper.h

Go to the documentation of this file.
00001 /* OperServ support
00002  *
00003  * (C) 2008-2012 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  */
00008 
00009 #ifndef OPER_H
00010 #define OPER_H
00011 
00012 #include "serialize.h"
00013 #include "service.h"
00014 
00015 class CoreExport XLine : public Serializable
00016 {
00017         void InitRegex();
00018  public:
00019         Anope::string Mask;
00020         Regex *regex;
00021         Anope::string By;
00022         time_t Created;
00023         time_t Expires;
00024         Anope::string Reason;
00025         XLineManager *manager;
00026         Anope::string UID;
00027 
00028         XLine(const Anope::string &mask, const Anope::string &reason = "", const Anope::string &uid = "");
00029 
00030         XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid = "");
00031         ~XLine();
00032 
00033         Anope::string GetNick() const;
00034         Anope::string GetUser() const;
00035         Anope::string GetHost() const;
00036         Anope::string GetReal() const;
00037 
00038         Anope::string GetReason() const;
00039 
00040         bool HasNickOrReal() const;
00041         bool IsRegex() const;
00042 
00043         Serialize::Data serialize() const anope_override;
00044         static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
00045 };
00046 
00047 class CoreExport XLineManager : public Service
00048 {
00049         char type;
00050         /* List of XLines in this XLineManager */
00051         serialize_checker<std::vector<XLine *> > XLines;
00052         /* Akills can have the same IDs, sometimes */
00053         static serialize_checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
00054  public:
00055         /* List of XLine managers we check users against in XLineManager::CheckAll */
00056         static std::list<XLineManager *> XLineManagers;
00057 
00064         static void RegisterXLineManager(XLineManager *xlm);
00065 
00069         static void UnregisterXLineManager(XLineManager *xlm);
00070 
00075         static void CheckAll(User *u);
00076 
00080         static Anope::string GenerateUID();
00081 
00084         XLineManager(Module *creator, const Anope::string &name, char t);
00085 
00088         virtual ~XLineManager();
00089 
00093         const char &Type();
00094 
00098         size_t GetCount() const;
00099 
00103         const std::vector<XLine *> &GetList() const;
00104 
00108         void AddXLine(XLine *x);
00109 
00114         bool DelXLine(XLine *x);
00115 
00120         XLine* GetEntry(unsigned index);
00121 
00125         void Clear();
00126 
00134         bool CanAdd(CommandSource &source, const Anope::string &mask, time_t expires, const Anope::string &reason);
00135 
00140         XLine* HasEntry(const Anope::string &mask);
00141 
00146         XLine *CheckAllXLines(User *u);
00147 
00152         virtual bool Check(User *u, const XLine *x) = 0;
00153 
00158         virtual void OnMatch(User *u, XLine *x) = 0;
00159 
00163         virtual void OnExpire(const XLine *x);
00164 
00169         virtual void Send(User *u, XLine *x) = 0;
00170 
00174         virtual void SendDel(XLine *x) = 0;
00175 };
00176 
00177 #endif // OPER_H