1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 23:06:38 +02:00
Files
anope/include/access.h
T
2011-12-15 01:14:13 -05:00

85 lines
2.0 KiB
C++

#ifndef ACCESS_H
#define ACCESS_H
enum
{
ACCESS_INVALID = -10000,
ACCESS_FOUNDER = 10001
};
struct CoreExport Privilege
{
Anope::string name;
Anope::string desc;
Privilege(const Anope::string &n, const Anope::string &d);
bool operator==(const Privilege &other);
};
class CoreExport PrivilegeManager
{
static std::vector<Privilege> privs;
public:
static void AddPrivilege(Privilege p, int pos = -1, int def = 0);
static void RemovePrivilege(Privilege &p);
static Privilege *FindPrivilege(const Anope::string &name);
static std::vector<Privilege> &GetPrivileges();
static void ClearPrivileges();
};
class ChanAccess;
class CoreExport AccessProvider : public Service<AccessProvider>
{
public:
AccessProvider(Module *o, const Anope::string &n);
virtual ~AccessProvider();
virtual ChanAccess *Create() = 0;
};
class CoreExport ChanAccess : public Serializable
{
public:
AccessProvider *provider;
ChannelInfo *ci;
Anope::string mask;
Anope::string creator;
time_t last_seen;
time_t created;
ChanAccess(AccessProvider *p);
virtual ~ChanAccess();
Anope::string serialize_name() const;
serialized_data serialize();
static void unserialize(serialized_data &);
virtual bool Matches(User *u, NickCore *nc) = 0;
virtual bool HasPriv(const Anope::string &name) const = 0;
virtual Anope::string Serialize() = 0;
virtual void Unserialize(const Anope::string &data) = 0;
bool operator>(const ChanAccess &other) const;
bool operator<(const ChanAccess &other) const;
bool operator>=(const ChanAccess &other) const;
bool operator<=(const ChanAccess &other) const;
};
class CoreExport AccessGroup : public std::vector<ChanAccess *>
{
public:
ChannelInfo *ci;
NickCore *nc;
bool SuperAdmin, Founder;
AccessGroup();
bool HasPriv(const Anope::string &priv) const;
ChanAccess *Highest() const;
bool operator>(const AccessGroup &other) const;
bool operator<(const AccessGroup &other) const;
bool operator>=(const AccessGroup &other) const;
bool operator<=(const AccessGroup &other) const;
};
#endif