00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _TMWSERV_CHATCHANNELMANAGER_H_
00023 #define _TMWSERV_CHATCHANNELMANAGER_H_
00024
00025 #include <list>
00026 #include <map>
00027 #include <deque>
00028
00029 #include "chat-server/chatchannel.hpp"
00030
00035 class ChatChannelManager
00036 {
00037 public:
00041 ChatChannelManager();
00042
00046 ~ChatChannelManager();
00047
00053 int createNewChannel(const std::string &channelName,
00054 const std::string &channelAnnouncement,
00055 const std::string &channelPassword,
00056 bool joinable);
00057
00063 bool tryNewPublicChannel(const std::string &name);
00064
00068 bool removeChannel(int channelId);
00069
00075 std::list<const ChatChannel*> getPublicChannels();
00076
00082 int getChannelId(const std::string &channelName);
00083
00089 ChatChannel* getChannel(int channelId);
00090
00096 ChatChannel* getChannel(const std::string &name);
00097
00103 void removeUserFromAllChannels(ChatClient *);
00104
00110 void setChannelTopic(int channelId, const std::string &name);
00111
00117 bool channelExists(int channelId);
00118 bool channelExists(const std::string &channelName);
00119
00123 int nextUsable();
00124
00125 private:
00126 typedef std::map<unsigned short, ChatChannel> ChatChannels;
00127 typedef ChatChannels::iterator ChatChannelIterator;
00128
00133 ChatChannels mChatChannels;
00134 int mNextChannelId;
00135 std::deque<int> mChannelsNoLongerUsed;
00136 };
00137
00138 extern ChatChannelManager *chatChannelManager;
00139
00140 #endif