diff options
| author | Philipp Sehmisch <tmw@crushnet.org> | 2007-02-27 16:39:07 +0000 |
|---|---|---|
| committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-02-27 16:39:07 +0000 |
| commit | ea7d7df0e8b9e6c148ea9dfb8a56e113b50e008d (patch) | |
| tree | e30ee08b4ff4659205d0bcbb1ab2b3db5f71f650 /src/chat-server/chatchannelmanager.cpp | |
| parent | 8bbaf323aef0c4f124b1a35680c323f833d2d58f (diff) | |
Implementation of chat channels by Trapdoor.
Diffstat (limited to 'src/chat-server/chatchannelmanager.cpp')
| -rw-r--r-- | src/chat-server/chatchannelmanager.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/chat-server/chatchannelmanager.cpp b/src/chat-server/chatchannelmanager.cpp index 9944681..531a009 100644 --- a/src/chat-server/chatchannelmanager.cpp +++ b/src/chat-server/chatchannelmanager.cpp @@ -59,7 +59,7 @@ ChatChannelManager::registerPublicChannel(const std::string& channelName, // Register Channel mChatChannels.insert(std::make_pair(channelId,ChatChannel(channelName, - channelAnnouncement, channelPassword))); + channelAnnouncement, channelPassword, false))); return channelId; } @@ -74,7 +74,7 @@ ChatChannelManager::registerPrivateChannel(const std::string& channelName, { if ( i->second.getName() == channelName ) return 0; // We seek the highest channelId in the private range - if (channelId <= i->first) + if (channelId <= i->first) channelId = i->first + 1; } // Too much channels registered @@ -82,7 +82,7 @@ ChatChannelManager::registerPrivateChannel(const std::string& channelName, // Register Channel mChatChannels.insert(std::make_pair(channelId,ChatChannel(channelName, - channelAnnouncement, channelPassword))); + channelAnnouncement, channelPassword, true))); return channelId; } @@ -95,6 +95,27 @@ bool ChatChannelManager::removeChannel(short channelId) return true; } +std::string ChatChannelManager::getPublicChannelNames(short *numChannels) +{ + std::string channels; + for (std::map<short, ChatChannel>::const_iterator i = mChatChannels.begin(), i_end = mChatChannels.end(); + i != i_end; ++i) { + if(!i->second.getPrivacy()) + { + channels.append(i->second.getName()); + channels += " "; + (*numChannels)++; + } + } + return channels; +} + +short ChatChannelManager::getNumberOfChannelUsers(const std::string &channelName) +{ + ChatChannel channel = _getChannel(getChannelId(channelName)); + short size = channel.getUserList().size(); + return size; +} short ChatChannelManager::getChannelId(std::string const &channelName) { @@ -124,6 +145,12 @@ std::string ChatChannelManager::getChannelPassword(short channelId) return (i != mChatChannels.end()) ? i->second.getPassword() : std::string(); } +bool ChatChannelManager::getChannelPrivacy(short channelId) +{ + std::map<short, ChatChannel>::iterator i = mChatChannels.find(channelId); + return (i != mChatChannels.end()) ? i->second.getPrivacy() : true; +} + bool ChatChannelManager::setChannelAnnouncement(short channelId, std::string const &channelAnnouncement) { std::map<short, ChatChannel>::iterator i = mChatChannels.find(channelId); @@ -144,7 +171,7 @@ ChatChannel ChatChannelManager::_getChannel(short channelId) { std::map<short, ChatChannel>::iterator i = mChatChannels.find(channelId); if (i != mChatChannels.end()) return i->second; - return ChatChannel("", "", ""); + return ChatChannel("", "", "", true); } @@ -167,7 +194,7 @@ void ChatChannelManager::removeUserFromEveryChannels(std::string const &user) { for (std::map<short, ChatChannel>::iterator i = mChatChannels.begin(), i_end = mChatChannels.end(); i != i_end; ++i) { - i->second.removeUserFromChannel(user); + i->second.removeUserFromChannel(user); } } |
