Split user list from Channel into ChannelUserList
[clinton/bobotpp.git] / source / Channel.H
CommitLineData
cb21075d 1// Channel.H -*- C++ -*-
2// Copyright (c) 1997, 1998 Etienne BERNARD
71cf2688 3// Copyright (C) 2002,2008,2009 Clinton Ebadi
cb21075d 4
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// any later version.
9
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
7b564711 17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18// 02110-1301, USA.
cb21075d 19
20#ifndef CHANNEL_H
21#define CHANNEL_H
22
f9723c92 23#include <algorithm>
24#include <functional>
71cf2688 25#include <list>
26#include <string>
cb21075d 27#include <vector>
28
f9723c92 29#include <ctime>
30
31#include "BanList.H"
71cf2688 32#include "ChannelUserList.H"
33#include "Utils.H"
cb21075d 34
cfa82921 35class BanEntry;
cb21075d 36class Bot;
cb21075d 37class Commands;
f9723c92 38class Mask;
cfa82921 39class Parser;
40class Person;
41class ServerConnection;
42class User;
cb21075d 43class UserCommands;
cfa82921 44class UserList;
45
cb21075d 46
47#define DEFAULT_KEEPMODES "iklmnpst"
48
49// This struct is used to keep information about
50// the channel we want to join, the modes we
51// want to set/keep on these channels, and the
52// channel keys
53struct wantedChannel {
71cf2688 54 std::string mode;
55 std::string keep;
56 std::string key;
cb21075d 57
71cf2688 58 wantedChannel(std::string m, std::string kp, std::string ky)
cb21075d 59 : mode(m), keep(kp), key(ky) { }
60};
61
62class Channel {
71cf2688 63 std::string channelName;
64 std::string channelTopic;
cb21075d 65 bool lockedTopic;
66 int channelMode;
67 int channelLimit;
71cf2688 68 std::string channelKey;
69 std::string keepModes;
70 std::string wantedModes;
cb21075d 71
cb21075d 72 bool joined;
73 bool doMode;
74 bool gotWho;
71cf2688 75 ChannelUserList channelUserlist;
f9723c92 76 BanList channelBanlist;
cb21075d 77 ServerConnection * cnx;
78
79public:
80
81 enum {
82 PRIVATE = 1, // +p
83 SECRET = 2, // +s
84 INVITE_ONLY = 4, // +i
85 TOPIC_RESTRICTED = 8, // +t
86 EXTMSG_RESTRICTED = 16, // +n
87 MODERATED = 32, // +m
88 HAS_KEY = 64, // +k <key>
89 IS_LIMITED = 128 // +l <limit>
90 };
91
71cf2688 92 Channel(ServerConnection *, std::string, std::string);
cb21075d 93 ~Channel();
94
71cf2688 95 void addNick(std::string, std::string, int, UserList *, bool = false);
96 void delNick(std::string);
97 void changeNick(std::string, std::string);
98 void change_user_key (std::string, std::string);
99 bool hasNick(const std::string &) const;
100 const User getUser(const std::string &) const;
101 unsigned int user_count () const throw ();
102 unsigned int operator_count () const throw ();
103 template<typename T> void for_each_channel_users (const T & fun)
104 { channelUserlist.foreach (fun); }
cb21075d 105
f9723c92 106 void addBan(const Mask&, std::time_t = -1);
107 void delBan(const Mask&);
108 void purge_expired_bans ();
109 template<typename T> void for_each_ban_entry (const T & fun)
110 { channelBanlist.foreach (fun); }
cb21075d 111
71cf2688 112 void parseMode(Person *, std::string);
cb21075d 113 void resynchModes();
114
115 friend class Bot;
116 friend class Parser;
117 friend class Commands;
118 friend class UserCommands;
119};
120
121#endif