1 .TH "channels.h" 3 "19 Dec 2005" "Version 1.0Betareleases" "InspIRCd" \" -*- nroff -*-
9 \fC#include 'inspircd_config.h'\fP
11 \fC#include 'base.h'\fP
13 \fC#include <time.h>\fP
15 \fC#include <vector>\fP
17 \fC#include <string>\fP
24 .RI "class \fBHostItem\fP"
26 .RI "\fIHolds an entry for a ban list, exemption list, or invite list. \fP"
28 .RI "class \fBBanItem\fP"
30 .RI "\fIA subclass of \fBHostItem\fP designed to hold channel bans (+b). \fP"
32 .RI "class \fBExemptItem\fP"
34 .RI "\fIA subclass of \fBHostItem\fP designed to hold channel exempts (+e). \fP"
36 .RI "class \fBInviteItem\fP"
38 .RI "\fIA subclass of \fBHostItem\fP designed to hold channel invites (+I). \fP"
40 .RI "class \fBModeParameter\fP"
42 .RI "\fIHolds a custom parameter to a module-defined channel mode e.g. \fP"
44 .RI "class \fBchanrec\fP"
46 .RI "\fIHolds all relevent information for a channel. \fP"
48 .RI "class \fBucrec\fP"
50 .RI "\fIHolds a user's modes on a channel This class associates a users privilages with a channel by creating a pointer link between a userrec and chanrec class. \fP"
56 .RI "#define \fBCM_TOPICLOCK\fP 1"
59 .RI "#define \fBCM_NOEXTERNAL\fP 2"
62 .RI "#define \fBCM_INVITEONLY\fP 4"
65 .RI "#define \fBCM_MODERATED\fP 8"
68 .RI "#define \fBCM_SECRET\fP 16"
71 .RI "#define \fBCM_PRIVATE\fP 32"
74 .RI "#define \fBUCMODE_OP\fP 1"
77 .RI "#define \fBUCMODE_VOICE\fP 2"
80 .RI "#define \fBUCMODE_HOP\fP 4"
83 .RI "#define \fBUCMODE_PROTECT\fP 8"
86 .RI "#define \fBUCMODE_FOUNDER\fP 16"
93 .RI "typedef std::vector< \fBBanItem\fP > \fBBanList\fP"
95 .RI "\fIHolds a complete ban list. \fP"
97 .RI "typedef std::vector< \fBExemptItem\fP > \fBExemptList\fP"
99 .RI "\fIHolds a complete exempt list. \fP"
101 .RI "typedef std::vector< \fBInviteItem\fP > \fBInviteList\fP"
103 .RI "\fIHolds a complete invite list. \fP"
109 .RI "\fBchanrec\fP * \fBadd_channel\fP (\fBuserrec\fP *user, const char *cn, const char *key, bool override)"
112 .RI "\fBchanrec\fP * \fBdel_channel\fP (\fBuserrec\fP *user, const char *cname, const char *reason, bool local)"
115 .RI "void \fBkick_channel\fP (\fBuserrec\fP *src, \fBuserrec\fP *user, \fBchanrec\fP *Ptr, char *reason)"
118 .SH "Define Documentation"
120 .SS "#define CM_INVITEONLY 4"
122 Definition at line 28 of file channels.h.
124 Referenced by add_channel().
125 .SS "#define CM_MODERATED 8"
127 Definition at line 29 of file channels.h.
128 .SS "#define CM_NOEXTERNAL 2"
130 Definition at line 27 of file channels.h.
132 Referenced by add_channel().
133 .SS "#define CM_PRIVATE 32"
135 Definition at line 31 of file channels.h.
136 .SS "#define CM_SECRET 16"
138 Definition at line 30 of file channels.h.
139 .SS "#define CM_TOPICLOCK 1"
141 Definition at line 26 of file channels.h.
143 Referenced by add_channel().
144 .SS "#define UCMODE_FOUNDER 16"
146 Definition at line 236 of file channels.h.
147 .SS "#define UCMODE_HOP 4"
149 Definition at line 234 of file channels.h.
150 .SS "#define UCMODE_OP 1"
152 Definition at line 232 of file channels.h.
154 Referenced by ForceChan().
155 .SS "#define UCMODE_PROTECT 8"
157 Definition at line 235 of file channels.h.
158 .SS "#define UCMODE_VOICE 2"
160 Definition at line 233 of file channels.h.
161 .SH "Typedef Documentation"
163 .SS "typedef std::vector<\fBBanItem\fP> \fBBanList\fP"
165 Holds a complete ban list.
167 Definition at line 89 of file channels.h.
168 .SS "typedef std::vector<\fBExemptItem\fP> \fBExemptList\fP"
170 Holds a complete exempt list.
172 Definition at line 93 of file channels.h.
173 .SS "typedef std::vector<\fBInviteItem\fP> \fBInviteList\fP"
175 Holds a complete invite list.
177 Definition at line 97 of file channels.h.
178 .SH "Function Documentation"
180 .SS "\fBchanrec\fP* add_channel (\fBuserrec\fP * user, const char * cn, const char * key, bool override)"
182 Definition at line 194 of file channels.cpp.
184 References chanrec::bans, chanrec::binarymodes, chanlist, userrec::chans, CM_INVITEONLY, CM_NOEXTERNAL, CM_TOPICLOCK, DEBUG, DEFAULT, connection::fd, FindChan(), ForceChan(), FOREACH_RESULT, userrec::GetFullHost(), has_channel(), userrec::IsInvited(), chanrec::key, chanrec::limit, log(), userrec::modes, chanrec::name, userrec::nick, userrec::RemoveInvite(), TIME, and WriteServ().
186 Referenced by Server::JoinUserToChannel().
190 196 if ((!user) || (!cn))
192 198 log(DEFAULT,'*** BUG *** add_channel was given an invalid parameter');
197 203 char cname[MAXBUF];
198 204 int MOD_RESULT = 0;
199 205 strncpy(cname,cn,CHANMAX);
201 207 log(DEBUG,'add_channel: %s %s',user->nick,cname);
203 209 chanrec* Ptr = FindChan(cname);
207 213 if (user->fd > -1)
210 216 FOREACH_RESULT(OnUserPreJoin(user,NULL,cname));
211 217 if (MOD_RESULT == 1)
214 220 /* create a new one */
215 221 chanlist[cname] = new chanrec();
216 222 strlcpy(chanlist[cname]->name, cname,CHANMAX);
217 223 chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL;
218 224 chanlist[cname]->created = TIME;
219 225 strcpy(chanlist[cname]->topic, '');
220 226 strncpy(chanlist[cname]->setby, user->nick,NICKMAX);
221 227 chanlist[cname]->topicset = 0;
222 228 Ptr = chanlist[cname];
223 229 log(DEBUG,'add_channel: created: %s',cname);
224 230 /* set created to 2 to indicate user
225 231 * is the first in the channel
226 232 * and should be given ops */
231 237 /* Already on the channel */
232 238 if (has_channel(user,Ptr))
235 241 // remote users are allowed us to bypass channel modes
236 242 // and bans (used by servers)
237 243 if (user->fd > -1)
240 246 FOREACH_RESULT(OnUserPreJoin(user,Ptr,cname));
241 247 if (MOD_RESULT == 1)
250 256 FOREACH_RESULT(OnCheckKey(user, Ptr, key ? key : ''));
255 261 log(DEBUG,'add_channel: no key given in JOIN');
256 262 WriteServ(user->fd,'475 %s %s :Cannot join channel (Requires key)',user->nick, Ptr->name);
261 267 if (strcasecmp(key,Ptr->key))
263 269 log(DEBUG,'add_channel: bad key given in JOIN');
264 270 WriteServ(user->fd,'475 %s %s :Cannot join channel (Incorrect key)',user->nick, Ptr->name);
270 276 if (Ptr->binarymodes & CM_INVITEONLY)
273 279 irc::string xname(Ptr->name);
274 280 FOREACH_RESULT(OnCheckInvite(user, Ptr));
277 283 log(DEBUG,'add_channel: channel is +i');
278 284 if (user->IsInvited(xname))
280 286 /* user was invited to channel */
281 287 /* there may be an optional channel NOTICE here */
285 291 WriteServ(user->fd,'473 %s %s :Cannot join channel (Invite only)',user->nick, Ptr->name);
289 295 user->RemoveInvite(xname);
294 300 FOREACH_RESULT(OnCheckLimit(user, Ptr));
297 303 if (usercount(Ptr) >= Ptr->limit)
299 305 WriteServ(user->fd,'471 %s %s :Cannot join channel (Channel is full)',user->nick, Ptr->name);
304 310 if (Ptr->bans.size())
306 312 log(DEBUG,'add_channel: about to walk banlist');
308 314 FOREACH_RESULT(OnCheckBan(user, Ptr));
311 317 for (BanList::iterator i = Ptr->bans.begin(); i != Ptr->bans.end(); i++)
313 319 if (match(user->GetFullHost(),i->data))
315 321 WriteServ(user->fd,'474 %s %s :Cannot join channel (You're banned)',user->nick, Ptr->name);
325 331 log(DEBUG,'Overridden checks');
330 336 log(DEBUG,'Passed channel checks');
332 338 for (unsigned int index =0; index < user->chans.size(); index++)
334 340 if (user->chans[index].channel == NULL)
336 342 return ForceChan(Ptr,user->chans[index],user,created);
339 345 /* XXX: If the user is an oper here, we can just extend their user->chans vector by one
340 346 * and put the channel in here. Same for remote users which are not bound by
341 347 * the channel limits. Otherwise, nope, youre boned.
343 349 if (user->fd < 0)
346 352 chanrec* c = ForceChan(Ptr,a,user,created);
347 353 user->chans.push_back(a);
350 356 else if (strchr(user->modes,'o'))
352 358 /* Oper allows extension up to the OPERMAXCHANS value */
353 359 if (user->chans.size() < OPERMAXCHANS)
356 362 chanrec* c = ForceChan(Ptr,a,user,created);
357 363 user->chans.push_back(a);
361 367 log(DEBUG,'add_channel: user channel max exceeded: %s %s',user->nick,cname);
362 368 WriteServ(user->fd,'405 %s %s :You are on too many channels',user->nick, cname);
367 .SS "\fBchanrec\fP* del_channel (\fBuserrec\fP * user, const char * cname, const char * reason, bool local)"
369 Definition at line 401 of file channels.cpp.
371 References chanlist, userrec::chans, DEBUG, DEFAULT, chanrec::DelUser(), FindChan(), FOREACH_MOD, log(), chanrec::name, userrec::nick, and WriteChannel().
373 Referenced by Server::PartUserFromChannel().
377 403 if ((!user) || (!cname))
379 405 log(DEFAULT,'*** BUG *** del_channel was given an invalid parameter');
383 409 chanrec* Ptr = FindChan(cname);
388 414 FOREACH_MOD OnUserPart(user,Ptr);
389 415 log(DEBUG,'del_channel: removing: %s %s',user->nick,Ptr->name);
391 417 for (unsigned int i =0; i < user->chans.size(); i++)
393 419 /* zap it from the channel list of the user */
394 420 if (user->chans[i].channel == Ptr)
398 424 WriteChannel(Ptr,user,'PART %s :%s',Ptr->name, reason);
402 428 WriteChannel(Ptr,user,'PART :%s',Ptr->name);
404 430 user->chans[i].uc_modes = 0;
405 431 user->chans[i].channel = NULL;
406 432 log(DEBUG,'del_channel: unlinked: %s %s',user->nick,Ptr->name);
411 437 Ptr->DelUser((char*)user);
413 439 /* if there are no users left on the channel */
414 440 if (!usercount(Ptr))
416 442 chan_hash::iterator iter = chanlist.find(Ptr->name);
418 444 log(DEBUG,'del_channel: destroying channel: %s',Ptr->name);
420 446 /* kill the record */
421 447 if (iter != chanlist.end())
423 449 log(DEBUG,'del_channel: destroyed: %s',Ptr->name);
425 451 chanlist.erase(iter);
433 .SS "void kick_channel (\fBuserrec\fP * src, \fBuserrec\fP * user, \fBchanrec\fP * Ptr, char * reason)"
435 Definition at line 459 of file channels.cpp.
437 References AC_KICK, ACR_DEFAULT, ACR_DENY, chanlist, userrec::chans, cstatus(), DEBUG, DEFAULT, chanrec::DelUser(), connection::fd, FOREACH_MOD, FOREACH_RESULT, has_channel(), is_uline(), log(), chanrec::name, userrec::nick, userrec::server, STATUS_HOP, WriteChannel(), and WriteServ().
441 461 if ((!src) || (!user) || (!Ptr) || (!reason))
443 463 log(DEFAULT,'*** BUG *** kick_channel was given an invalid parameter');
447 467 if ((!Ptr) || (!user) || (!src))
452 472 log(DEBUG,'kick_channel: removing: %s %s %s',user->nick,Ptr->name,src->nick);
454 474 if (!has_channel(user,Ptr))
456 476 WriteServ(src->fd,'441 %s %s %s :They are not on that channel',src->nick, user->nick, Ptr->name);
460 480 int MOD_RESULT = 0;
461 481 FOREACH_RESULT(OnAccessCheck(src,user,Ptr,AC_KICK));
462 482 if ((MOD_RESULT == ACR_DENY) && (!is_uline(src->server)))
465 485 if ((MOD_RESULT == ACR_DEFAULT) || (!is_uline(src->server)))
467 487 if ((cstatus(src,Ptr) < STATUS_HOP) || (cstatus(src,Ptr) < cstatus(user,Ptr)))
469 489 if (cstatus(src,Ptr) == STATUS_HOP)
471 491 WriteServ(src->fd,'482 %s %s :You must be a channel operator',src->nick, Ptr->name);
475 495 WriteServ(src->fd,'482 %s %s :You must be at least a half-operator to change modes on this channel',src->nick, Ptr->name);
482 502 if (!is_uline(src->server))
485 505 FOREACH_RESULT(OnUserPreKick(src,user,Ptr,reason));
490 510 FOREACH_MOD OnUserKick(src,user,Ptr,reason);
492 512 for (unsigned int i =0; i < user->chans.size(); i++)
494 514 /* zap it from the channel list of the user */
495 515 if (user->chans[i].channel)
496 516 if (!strcasecmp(user->chans[i].channel->name,Ptr->name))
498 518 WriteChannel(Ptr,src,'KICK %s %s :%s',Ptr->name, user->nick, reason);
499 519 user->chans[i].uc_modes = 0;
500 520 user->chans[i].channel = NULL;
501 521 log(DEBUG,'del_channel: unlinked: %s %s',user->nick,Ptr->name);
506 526 Ptr->DelUser((char*)user);
508 528 /* if there are no users left on the channel */
509 529 if (!usercount(Ptr))
511 531 chan_hash::iterator iter = chanlist.find(Ptr->name);
513 533 log(DEBUG,'del_channel: destroying channel: %s',Ptr->name);
515 535 /* kill the record */
516 536 if (iter != chanlist.end())
518 538 log(DEBUG,'del_channel: destroyed: %s',Ptr->name);
520 540 chanlist.erase(iter);
528 Generated automatically by Doxygen for InspIRCd from the source code.