1 |
/** |
2 |
* chanacs.h: Data structures for account information. |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Copyright © 2005-2006 Atheme Development Group |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: chanacs.h,v 1.5 2007-09-05 11:23:13 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#ifndef ACCOUNT_CHANACS_H |
16 |
#define ACCOUNT_CHANACS_H |
17 |
|
18 |
#include <account/metadata.h> |
19 |
#include <ermyth/callback.h> |
20 |
|
21 |
/* the new style channel flags */ |
22 |
enum chanacs_flag |
23 |
{ |
24 |
CA_NONE = 0x0, |
25 |
|
26 |
CA_VOICE = 1 << 0, /* Ability to use voice/devoice command. */ |
27 |
CA_AUTOVOICE = 1 << 1, /* Gain voice automatically upon entry. */ |
28 |
CA_OP = 1 << 2, /* Ability to use op/deop command. */ |
29 |
CA_AUTOOP = 1 << 3, /* Gain ops automatically upon entry. */ |
30 |
CA_TOPIC = 1 << 4, /* Ability to use /msg X topic */ |
31 |
CA_SET = 1 << 5, /* Ability to use /msg X set */ |
32 |
CA_REMOVE = 1 << 6, /* Ability to use /msg X kick */ |
33 |
CA_INVITE = 1 << 7, /* Ability to use /msg X invite */ |
34 |
CA_RECOVER = 1 << 8, /* Ability to use /msg X recover */ |
35 |
CA_FLAGS = 1 << 9, /* Ability to write to channel flags table */ |
36 |
CA_HALFOP = 1 << 10, /* Ability to use /msg X halfop */ |
37 |
CA_AUTOHALFOP = 1 << 11, /* Gain halfops automatically upon entry. */ |
38 |
CA_ACLVIEW = 1 << 12, /* Can view access lists */ |
39 |
CA_FOUNDER = 1 << 13, /* Is a channel founder */ |
40 |
|
41 |
CA_SUSPENDED = 1 << 30, /* Suspended access entry (not yet implemented) */ |
42 |
CA_AKICK = 1u << 31, /* Automatic kick */ |
43 |
|
44 |
/* xOP defaults, compatible with Atheme 0.3 */ |
45 |
CA_VOP_DEF = CA_VOICE | CA_AUTOVOICE | CA_ACLVIEW, |
46 |
CA_HOP_DEF = CA_VOICE | CA_HALFOP | CA_AUTOHALFOP | CA_TOPIC | CA_ACLVIEW, |
47 |
CA_AOP_DEF = CA_VOICE | CA_HALFOP | CA_OP | CA_AUTOOP | CA_TOPIC | CA_ACLVIEW, |
48 |
CA_SOP_DEF = CA_AOP_DEF | CA_SET | CA_REMOVE | CA_INVITE, |
49 |
|
50 |
/* special values for founder/successor -- jilles */ |
51 |
/* used in shrike flatfile conversion: */ |
52 |
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, |
53 |
/* granted to new founder on transfer etc: */ |
54 |
CA_FOUNDER_0 = CA_SUCCESSOR_0 | CA_FLAGS | CA_FOUNDER, |
55 |
/* granted to founder on new channel: */ |
56 |
CA_INITIAL = CA_FOUNDER_0 | CA_AUTOOP, |
57 |
|
58 |
/* joining with one of these flags updates used time */ |
59 |
CA_USEDUPDATE = CA_VOICE | CA_OP | CA_AUTOOP | CA_SET | CA_REMOVE | CA_RECOVER | CA_FLAGS | CA_HALFOP | CA_AUTOHALFOP | CA_FOUNDER, |
60 |
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, |
61 |
CA_ALL_ALL = CA_ALLPRIVS | CA_AKICK, |
62 |
|
63 |
/* old CA_ flags */ |
64 |
OLD_CA_AOP = CA_VOICE | CA_OP | CA_AUTOOP | CA_TOPIC, |
65 |
|
66 |
/* shrike CA_ flags */ |
67 |
SHRIKE_CA_VOP = 1 << 2, |
68 |
SHRIKE_CA_AOP = 1 << 3, |
69 |
SHRIKE_CA_SOP = 1 << 4, |
70 |
SHRIKE_CA_FOUNDER = 1 << 5, |
71 |
SHRIKE_CA_SUCCESSOR = 1 << 6 |
72 |
}; |
73 |
|
74 |
/* struct for channel access list */ |
75 |
class chanacs_t : public zero_initialised, public has_metadata |
76 |
{ |
77 |
struct callbacks : has_metadata::callbacks |
78 |
{ |
79 |
functor::callback1<chanacs_t *> akick_add; |
80 |
}; |
81 |
|
82 |
public: |
83 |
unsigned level; |
84 |
|
85 |
object_t parent; |
86 |
|
87 |
chanacs_t () |
88 |
: has_metadata (metadata::CHANACS) |
89 |
{ |
90 |
} |
91 |
|
92 |
myuser_t *myuser; |
93 |
mychan_t *mychan; |
94 |
char host[HOSTLEN]; |
95 |
list_t metadata; |
96 |
time_t ts; |
97 |
|
98 |
static callbacks callback; |
99 |
}; |
100 |
|
101 |
E chanacs_t *chanacs_add (mychan_t *mychan, myuser_t *myuser, unsigned int level, time_t ts); |
102 |
E chanacs_t *chanacs_add_host (mychan_t *mychan, char const * const host, unsigned int level, time_t ts); |
103 |
|
104 |
E chanacs_t *chanacs_find (mychan_t *mychan, myuser_t const * const myuser, unsigned int level); |
105 |
E chanacs_t *chanacs_find_host (mychan_t *mychan, char const * const host, unsigned int level); |
106 |
E unsigned int chanacs_host_flags (mychan_t *mychan, char const * const host); |
107 |
E chanacs_t *chanacs_find_host_literal (mychan_t *mychan, char const * const host, unsigned int level); |
108 |
E chanacs_t *chanacs_find_host_by_user (mychan_t *mychan, user_t *u, unsigned int level); |
109 |
E unsigned int chanacs_host_flags_by_user (mychan_t *mychan, user_t *u); |
110 |
E chanacs_t *chanacs_find_by_mask (mychan_t *mychan, char const * const mask, unsigned int level); |
111 |
E bool chanacs_user_has_flag (mychan_t *mychan, user_t *u, unsigned int level); |
112 |
E unsigned int chanacs_user_flags (mychan_t *mychan, user_t *u); |
113 |
E bool chanacs_source_has_flag (mychan_t *mychan, sourceinfo_t *si, unsigned int level); |
114 |
E unsigned int chanacs_source_flags (mychan_t *mychan, sourceinfo_t *si); |
115 |
|
116 |
E chanacs_t *chanacs_open (mychan_t *mychan, myuser_t *mu, char const * const hostmask, bool create); |
117 |
E void chanacs_close (chanacs_t *ca); |
118 |
E bool chanacs_modify (chanacs_t *ca, unsigned int *addflags, unsigned int *removeflags, unsigned int restrictflags); |
119 |
E bool chanacs_modify_simple (chanacs_t *ca, unsigned int addflags, unsigned int removeflags); |
120 |
|
121 |
E bool chanacs_is_table_full (chanacs_t *ca); |
122 |
|
123 |
E bool chanacs_change (mychan_t *mychan, myuser_t *mu, char const * const hostmask, unsigned int *addflags, unsigned int *removeflags, unsigned int restrictflags); |
124 |
E bool chanacs_change_simple (mychan_t *mychan, myuser_t *mu, char const * const hostmask, unsigned int addflags, unsigned int removeflags); |
125 |
|
126 |
#endif |