/** * chanacs.h: Data structures for account information. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005-2006 Atheme Development Group * Rights to this code are as documented in doc/pod/license.pod. * * $Id: chanacs.h,v 1.6 2007/09/16 18:54:42 pippijn Exp $ */ #ifndef ACCOUNT_CHANACS_H #define ACCOUNT_CHANACS_H #include #include /* the new style channel flags */ enum chanacs_flag { CA_NONE = 0x0, CA_VOICE = 1 << 0, /* Ability to use voice/devoice command. */ CA_AUTOVOICE = 1 << 1, /* Gain voice automatically upon entry. */ CA_OP = 1 << 2, /* Ability to use op/deop command. */ CA_AUTOOP = 1 << 3, /* Gain ops automatically upon entry. */ CA_TOPIC = 1 << 4, /* Ability to use /msg X topic */ CA_SET = 1 << 5, /* Ability to use /msg X set */ CA_REMOVE = 1 << 6, /* Ability to use /msg X kick */ CA_INVITE = 1 << 7, /* Ability to use /msg X invite */ CA_RECOVER = 1 << 8, /* Ability to use /msg X recover */ CA_FLAGS = 1 << 9, /* Ability to write to channel flags table */ CA_HALFOP = 1 << 10, /* Ability to use /msg X halfop */ CA_AUTOHALFOP = 1 << 11, /* Gain halfops automatically upon entry. */ CA_ACLVIEW = 1 << 12, /* Can view access lists */ CA_FOUNDER = 1 << 13, /* Is a channel founder */ CA_SUSPENDED = 1 << 30, /* Suspended access entry (not yet implemented) */ CA_AKICK = 1u << 31, /* Automatic kick */ /* xOP defaults, compatible with Atheme 0.3 */ CA_VOP_DEF = CA_VOICE | CA_AUTOVOICE | CA_ACLVIEW, CA_HOP_DEF = CA_VOICE | CA_HALFOP | CA_AUTOHALFOP | CA_TOPIC | CA_ACLVIEW, CA_AOP_DEF = CA_VOICE | CA_HALFOP | CA_OP | CA_AUTOOP | CA_TOPIC | CA_ACLVIEW, CA_SOP_DEF = CA_AOP_DEF | CA_SET | CA_REMOVE | CA_INVITE, /* special values for founder/successor -- jilles */ /* used in shrike flatfile conversion: */ CA_SUCCESSOR_0 = CA_VOICE | CA_OP | CA_AUTOOP | CA_TOPIC | CA_SET | CA_REMOVE | CA_INVITE | CA_RECOVER | CA_FLAGS | CA_HALFOP | CA_ACLVIEW, /* granted to new founder on transfer etc: */ CA_FOUNDER_0 = CA_SUCCESSOR_0 | CA_FLAGS | CA_FOUNDER, /* granted to founder on new channel: */ CA_INITIAL = CA_FOUNDER_0 | CA_AUTOOP, /* joining with one of these flags updates used time */ CA_USEDUPDATE = CA_VOICE | CA_OP | CA_AUTOOP | CA_SET | CA_REMOVE | CA_RECOVER | CA_FLAGS | CA_HALFOP | CA_AUTOHALFOP | CA_FOUNDER, CA_ALLPRIVS = CA_VOICE | CA_AUTOVOICE | CA_OP | CA_AUTOOP | CA_TOPIC | CA_SET | CA_REMOVE | CA_INVITE | CA_RECOVER | CA_FLAGS | CA_HALFOP | CA_AUTOHALFOP | CA_ACLVIEW | CA_FOUNDER, CA_ALL_ALL = CA_ALLPRIVS | CA_AKICK, /* old CA_ flags */ OLD_CA_AOP = CA_VOICE | CA_OP | CA_AUTOOP | CA_TOPIC, /* shrike CA_ flags */ SHRIKE_CA_VOP = 1 << 2, SHRIKE_CA_AOP = 1 << 3, SHRIKE_CA_SOP = 1 << 4, SHRIKE_CA_FOUNDER = 1 << 5, SHRIKE_CA_SUCCESSOR = 1 << 6 }; /* struct for channel access list */ class chanacs_t : public zero_initialised, public has_metadata { struct callbacks : has_metadata::callbacks { functor::callback1 akick_add; }; public: unsigned level; object_t parent; chanacs_t () : has_metadata (metadata::CHANACS) { } myuser_t *myuser; mychan_t *mychan; char host[HOSTLEN]; list_t metadata; time_t ts; static callbacks callback; }; E chanacs_t *chanacs_add (mychan_t *mychan, myuser_t *myuser, unsigned int level, time_t ts); E chanacs_t *chanacs_add_host (mychan_t *mychan, char const * const host, unsigned int level, time_t ts); E chanacs_t *chanacs_find (mychan_t *mychan, myuser_t const * const myuser, unsigned int level); E chanacs_t *chanacs_find_host (mychan_t *mychan, char const * const host, unsigned int level); E unsigned int chanacs_host_flags (mychan_t *mychan, char const * const host); E chanacs_t *chanacs_find_host_literal (mychan_t *mychan, char const * const host, unsigned int level); E chanacs_t *chanacs_find_host_by_user (mychan_t *mychan, user_t *u, unsigned int level); E unsigned int chanacs_host_flags_by_user (mychan_t *mychan, user_t *u); E chanacs_t *chanacs_find_by_mask (mychan_t *mychan, char const * const mask, unsigned int level); E bool chanacs_user_has_flag (mychan_t *mychan, user_t *u, unsigned int level); E unsigned int chanacs_user_flags (mychan_t *mychan, user_t *u); E bool chanacs_source_has_flag (mychan_t *mychan, sourceinfo_t *si, unsigned int level); E unsigned int chanacs_source_flags (mychan_t *mychan, sourceinfo_t *si); E chanacs_t *chanacs_open (mychan_t *mychan, myuser_t *mu, char const * const hostmask, bool create); E void chanacs_close (chanacs_t *ca); E bool chanacs_modify (chanacs_t *ca, unsigned int *addflags, unsigned int *removeflags, unsigned int restrictflags); E bool chanacs_modify_simple (chanacs_t *ca, unsigned int addflags, unsigned int removeflags); E bool chanacs_is_table_full (chanacs_t *ca); E bool chanacs_change (mychan_t *mychan, myuser_t *mu, char const * const hostmask, unsigned int *addflags, unsigned int *removeflags, unsigned int restrictflags); E bool chanacs_change_simple (mychan_t *mychan, myuser_t *mu, char const * const hostmask, unsigned int addflags, unsigned int removeflags); #endif