1 |
pippijn |
1.1 |
/* |
2 |
pippijn |
1.3 |
* Copyright © 2005 William Pitcock, et al. |
3 |
pippijn |
1.2 |
* Rights to this code are as documented in doc/pod/license.pod. |
4 |
pippijn |
1.1 |
* |
5 |
|
|
* Data structures for channel information. |
6 |
|
|
* |
7 |
pippijn |
1.4 |
* $Id: channels.h,v 1.3 2007-08-28 17:08:06 pippijn Exp $ |
8 |
pippijn |
1.1 |
*/ |
9 |
|
|
|
10 |
|
|
#ifndef CHANNELS_H |
11 |
|
|
#define CHANNELS_H |
12 |
|
|
|
13 |
pippijn |
1.4 |
#include <map> |
14 |
|
|
|
15 |
pippijn |
1.3 |
#include <ermyth/callback.h> |
16 |
|
|
|
17 |
pippijn |
1.1 |
#define MAXEXTMODES 5 |
18 |
|
|
|
19 |
pippijn |
1.3 |
class channel_t : public zero_initialised |
20 |
pippijn |
1.1 |
{ |
21 |
pippijn |
1.3 |
struct callbacks |
22 |
|
|
{ |
23 |
|
|
functor::callback1<channel_t *> add; |
24 |
|
|
functor::callback1<channel_t *> akick_add; |
25 |
|
|
functor::callback1<channel_t *> remove; |
26 |
|
|
functor::callback6<channel_t *, user_t *, server_t *, |
27 |
|
|
char const * const /* setter */, |
28 |
|
|
time_t /* ts */, |
29 |
|
|
char const * const /* topic */, |
30 |
|
|
bool /* return value */> can_change_topic; |
31 |
|
|
functor::callback3<channel_t *, user_t *, char const * const> message; |
32 |
|
|
functor::callback1<channel_t *> topic; |
33 |
|
|
functor::callback1<channel_t *> tschange; |
34 |
|
|
}; |
35 |
|
|
|
36 |
|
|
public: |
37 |
pippijn |
1.1 |
char *name; |
38 |
|
|
|
39 |
|
|
unsigned int modes; |
40 |
|
|
char *key; |
41 |
|
|
unsigned int limit; |
42 |
|
|
char *extmodes[MAXEXTMODES]; /* non-standard simple modes with param eg +j */ |
43 |
|
|
|
44 |
|
|
unsigned int nummembers; |
45 |
|
|
|
46 |
|
|
time_t ts; |
47 |
|
|
|
48 |
|
|
char *topic; |
49 |
|
|
char *topic_setter; |
50 |
|
|
time_t topicts; |
51 |
|
|
|
52 |
|
|
list_t members; |
53 |
|
|
list_t bans; |
54 |
pippijn |
1.3 |
|
55 |
|
|
static callbacks callback; |
56 |
pippijn |
1.1 |
}; |
57 |
|
|
|
58 |
|
|
/* struct for channel memberships */ |
59 |
pippijn |
1.3 |
class chanuser_t : public zero_initialised |
60 |
pippijn |
1.1 |
{ |
61 |
pippijn |
1.3 |
struct callbacks |
62 |
|
|
{ |
63 |
|
|
functor::callback1<chanuser_t *, bool> join; |
64 |
|
|
functor::callback1<chanuser_t *> part; |
65 |
|
|
}; |
66 |
|
|
|
67 |
|
|
public: |
68 |
pippijn |
1.1 |
channel_t *chan; |
69 |
|
|
user_t *user; |
70 |
|
|
unsigned int modes; |
71 |
|
|
node_t unode; |
72 |
|
|
node_t cnode; |
73 |
pippijn |
1.3 |
|
74 |
|
|
static callbacks callback; |
75 |
pippijn |
1.1 |
}; |
76 |
|
|
|
77 |
pippijn |
1.3 |
struct chanban_t : zero_initialised |
78 |
pippijn |
1.1 |
{ |
79 |
|
|
channel_t *chan; |
80 |
|
|
char *mask; |
81 |
|
|
int type; /* 'b', 'e', 'I', etc -- jilles */ |
82 |
|
|
}; |
83 |
|
|
|
84 |
|
|
#define CMODE_OP 0x00000020 /* SPECIAL */ |
85 |
|
|
#define CMODE_VOICE 0x00000200 /* SPECIAL */ |
86 |
|
|
|
87 |
|
|
#define CMODE_INVITE 0x00000001 |
88 |
|
|
#define CMODE_KEY 0x00000002 |
89 |
|
|
#define CMODE_LIMIT 0x00000004 |
90 |
|
|
#define CMODE_MOD 0x00000008 |
91 |
|
|
#define CMODE_NOEXT 0x00000010 |
92 |
|
|
#define CMODE_PRIV 0x00000040 /* AKA PARA */ |
93 |
|
|
#define CMODE_SEC 0x00000080 |
94 |
|
|
#define CMODE_TOPIC 0x00000100 |
95 |
|
|
|
96 |
|
|
#define MTYPE_NUL 0 |
97 |
|
|
#define MTYPE_ADD 1 |
98 |
|
|
#define MTYPE_DEL 2 |
99 |
|
|
|
100 |
|
|
struct cmode_t |
101 |
|
|
{ |
102 |
|
|
char mode; |
103 |
|
|
unsigned int value; |
104 |
|
|
}; |
105 |
|
|
|
106 |
|
|
struct extmode |
107 |
|
|
{ |
108 |
|
|
char mode; |
109 |
pippijn |
1.3 |
bool (*check) (char const * const, channel_t *, mychan_t *, user_t *, myuser_t *); |
110 |
pippijn |
1.1 |
}; |
111 |
|
|
|
112 |
pippijn |
1.3 |
#if 0 |
113 |
pippijn |
1.1 |
/* channel related hooks */ |
114 |
|
|
typedef struct |
115 |
|
|
{ |
116 |
|
|
chanuser_t *cu; /* Write NULL here if you kicked the user. |
117 |
|
|
When kicking the last user, you must join a |
118 |
|
|
service first, otherwise the channel may be |
119 |
|
|
destroyed and crashes may occur. The service may |
120 |
|
|
not part until you return; chanserv provides |
121 |
|
|
MC_INHABIT to help with this. |
122 |
|
|
This also prevents kick/rejoin floods. |
123 |
|
|
If this is NULL, a previous function kicked |
124 |
|
|
the user */ |
125 |
|
|
} hook_channel_joinpart_t; |
126 |
|
|
|
127 |
|
|
typedef struct |
128 |
|
|
{ |
129 |
|
|
user_t *u; |
130 |
|
|
channel_t *c; |
131 |
|
|
char *msg; |
132 |
|
|
} hook_cmessage_data_t; |
133 |
|
|
|
134 |
pippijn |
1.3 |
struct hook_channel_topic_check_t |
135 |
pippijn |
1.1 |
{ |
136 |
|
|
user_t *u; /* Online user that changed the topic */ |
137 |
|
|
server_t *s; /* Server that restored a topic */ |
138 |
|
|
channel_t *c; /* Channel still has old topic */ |
139 |
pippijn |
1.3 |
char const * const setter; /* Stored setter string, can be nick, nick!user@host |
140 |
pippijn |
1.1 |
or server */ |
141 |
|
|
time_t ts; /* Time the topic was changed */ |
142 |
pippijn |
1.3 |
char const * const topic; /* New topic */ |
143 |
pippijn |
1.1 |
int approved; /* Write non-zero here to cancel the change */ |
144 |
|
|
|
145 |
pippijn |
1.3 |
hook_channel_topic_check_t (char const * const _setter, char const * const _topic) |
146 |
|
|
: setter (_setter), topic (_topic) |
147 |
|
|
{ |
148 |
|
|
} |
149 |
|
|
}; |
150 |
|
|
#endif |
151 |
|
|
|
152 |
|
|
/* cmode.C */ |
153 |
pippijn |
1.1 |
E char *flags_to_string (int flags); |
154 |
|
|
E int mode_to_flag (char c); |
155 |
pippijn |
1.3 |
E void channel_mode (user_t *source, channel_t *chan, int parc, char const * const parv[]); |
156 |
|
|
E void channel_mode (user_t *source, channel_t *chan, char const * const arg); |
157 |
|
|
E void channel_mode_va (user_t *source, channel_t *chan, int parc, char const * const parv0, ...); |
158 |
pippijn |
1.1 |
E void clear_simple_modes (channel_t *c); |
159 |
|
|
E char *channel_modes (channel_t *c, bool doparams); |
160 |
|
|
E void modestack_flush_channel (channel_t *channel); |
161 |
|
|
E void modestack_forget_channel (channel_t *channel); |
162 |
|
|
E void modestack_finalize_channel (channel_t *channel); |
163 |
|
|
E void modestack_mode_simple (char *source, channel_t *channel, int dir, int flags); |
164 |
|
|
E void modestack_mode_limit (char *source, channel_t *channel, int dir, unsigned int limit); |
165 |
pippijn |
1.3 |
E void modestack_mode_ext (char *source, channel_t *channel, int dir, int i, char const * const value); |
166 |
|
|
E void modestack_mode_param (char *source, channel_t *channel, int dir, char type, char const * const value); |
167 |
pippijn |
1.1 |
E void check_modes (mychan_t *mychan, bool sendnow); |
168 |
|
|
|
169 |
pippijn |
1.3 |
/* channels.C */ |
170 |
pippijn |
1.4 |
typedef std::pair<char const * const, channel_t *> channel_pair; |
171 |
|
|
typedef std::map<char const * const, channel_t *, irccase_lt> channel_map; |
172 |
|
|
E channel_map chanlist; |
173 |
pippijn |
1.1 |
|
174 |
|
|
E void init_channels (void); |
175 |
|
|
|
176 |
pippijn |
1.3 |
E channel_t *channel_add (char const * const name, unsigned int ts, server_t *creator); |
177 |
pippijn |
1.1 |
E void channel_delete (channel_t *c); |
178 |
pippijn |
1.3 |
E channel_t *channel_find (char const * const name); |
179 |
pippijn |
1.1 |
|
180 |
pippijn |
1.3 |
E chanuser_t *chanuser_add (channel_t *chan, char const * const user); |
181 |
pippijn |
1.1 |
E void chanuser_delete (channel_t *chan, user_t *user); |
182 |
|
|
E chanuser_t *chanuser_find (channel_t *chan, user_t *user); |
183 |
|
|
|
184 |
pippijn |
1.3 |
E chanban_t *chanban_add (channel_t *chan, char const * const mask, int type); |
185 |
pippijn |
1.1 |
E void chanban_delete (chanban_t *c); |
186 |
pippijn |
1.3 |
E chanban_t *chanban_find (channel_t *chan, char const * const mask, int type); |
187 |
pippijn |
1.1 |
E void chanban_clear (channel_t *chan); |
188 |
|
|
|
189 |
|
|
#endif |