// Channel.H -*- C++ -*-
// Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2008,2009 Clinton Ebadi
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifndef CHANNEL_H
#define CHANNEL_H
-#include <ctime>
-#include <map>
+#include <algorithm>
+#include <functional>
+#include <list>
+#include <string>
#include <vector>
-#include "User.H"
-#include "Person.H"
-#include "ServerConnection.H"
-#include "BanEntry.H"
+#include <ctime>
+
+#include "BanList.H"
+#include "ChannelUserList.H"
+#include "Utils.H"
+class BanEntry;
class Bot;
-class Parser;
class Commands;
+class Mask;
+class Parser;
+class Person;
+class ServerConnection;
+class User;
class UserCommands;
+class UserList;
+
#define DEFAULT_KEEPMODES "iklmnpst"
// want to set/keep on these channels, and the
// channel keys
struct wantedChannel {
- String mode;
- String keep;
- String key;
+ std::string mode;
+ std::string keep;
+ std::string key;
- wantedChannel(String m, String kp, String ky)
+ wantedChannel(std::string m, std::string kp, std::string ky)
: mode(m), keep(kp), key(ky) { }
};
class Channel {
- String channelName;
- String channelTopic;
+ std::string channelName;
+ std::string channelTopic;
bool lockedTopic;
int channelMode;
int channelLimit;
- String channelKey;
- String keepModes;
- String wantedModes;
+ std::string channelKey;
+ std::string keepModes;
+ std::string wantedModes;
- int count;
- int countOp;
bool joined;
bool doMode;
bool gotWho;
- std::map<String, User *, std::less<String> > channelMemory;
- std::vector<BanEntry *> channelBanlist;
+ ChannelUserList channelUserlist;
+ BanList channelBanlist;
ServerConnection * cnx;
public:
IS_LIMITED = 128 // +l <limit>
};
- Channel(ServerConnection *, String, String);
+ Channel(ServerConnection *, std::string, std::string);
~Channel();
- void addNick(String, String, int, UserList *, bool = false);
- void delNick(String);
- void changeNick(String, String);
- bool hasNick(String);
- User * getUser(String);
+ void addNick(std::string, std::string, int, UserList *, bool = false);
+ void delNick(std::string);
+ void changeNick(std::string, std::string);
+ void change_user_key (std::string, std::string);
+ bool hasNick(const std::string &) const;
+ const User getUser(const std::string &) const;
+ unsigned int user_count () const throw ();
+ unsigned int operator_count () const throw ();
+ template<typename T> void for_each_channel_users (const T & fun)
+ { channelUserlist.foreach (fun); }
- void addBan(String, std::time_t = -1);
- void delBan(String);
+ void addBan(const Mask&, std::time_t = -1);
+ void delBan(const Mask&);
+ void purge_expired_bans ();
+ template<typename T> void for_each_ban_entry (const T & fun)
+ { channelBanlist.foreach (fun); }
- void parseMode(Person *, String);
+ void parseMode(Person *, std::string);
void resynchModes();
friend class Bot;