From c1a4a6367821b2af15c3bfd1e3ca767abe25902e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 10 Feb 2013 13:13:08 +0300 Subject: Remove channel classes because it was used only in manaserv. --- src/CMakeLists.txt | 6 -- src/Makefile.am | 6 -- src/channel.cpp | 44 -------------- src/channel.h | 98 ------------------------------ src/channelmanager.cpp | 87 --------------------------- src/channelmanager.h | 52 ---------------- src/commands.cpp | 3 - src/game.cpp | 4 -- src/gui/widgets/channeltab.cpp | 131 ----------------------------------------- src/gui/widgets/channeltab.h | 65 -------------------- 10 files changed, 496 deletions(-) delete mode 100644 src/channel.cpp delete mode 100644 src/channel.h delete mode 100644 src/channelmanager.cpp delete mode 100644 src/channelmanager.h delete mode 100644 src/gui/widgets/channeltab.cpp delete mode 100644 src/gui/widgets/channeltab.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a54e06c59..6f10f0712 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,8 +115,6 @@ SET(SRCS gui/widgets/browserbox.h gui/widgets/button.cpp gui/widgets/button.h - gui/widgets/channeltab.cpp - gui/widgets/channeltab.h gui/widgets/chattab.cpp gui/widgets/chattab.h gui/widgets/checkbox.cpp @@ -529,10 +527,6 @@ SET(SRCS chatlogger.h client.cpp client.h - channel.cpp - channel.h - channelmanager.cpp - channelmanager.h commandhandler.cpp commandhandler.h commands.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 9f3b676e5..bd5a5d62e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -113,8 +113,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/browserbox.h \ gui/widgets/button.cpp \ gui/widgets/button.h \ - gui/widgets/channeltab.cpp \ - gui/widgets/channeltab.h \ gui/widgets/chattab.cpp \ gui/widgets/chattab.h \ gui/widgets/checkbox.cpp \ @@ -531,10 +529,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ chatlogger.h \ client.cpp \ client.h \ - channel.cpp \ - channel.h \ - channelmanager.cpp \ - channelmanager.h \ commandhandler.cpp \ commandhandler.h \ commands.cpp \ diff --git a/src/channel.cpp b/src/channel.cpp deleted file mode 100644 index 76a0408ec..000000000 --- a/src/channel.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "channel.h" - -#include "gui/widgets/channeltab.h" - -#include "debug.h" - -Channel::Channel(const Widget2 *const widget, - const short id, - const std::string &name, - const std::string &announcement) : - mId(id), - mName(name), - mAnnouncement(announcement), - mTab(new ChannelTab(widget, this)) -{ -} - -Channel::~Channel() -{ - delete mTab; - mTab = nullptr; -} diff --git a/src/channel.h b/src/channel.h deleted file mode 100644 index 1a1a33579..000000000 --- a/src/channel.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CHANNEL_H -#define CHANNEL_H - -#include "gui/widgets/widget2.h" - -#include - -#include "localconsts.h" - -class ChannelTab; - -class Channel final -{ - public: - /** - * Constructor. - * - * @param id the id associated with the channel. - * @param name the name of the channel. - * @param announcement a welcome message. - */ - Channel(const Widget2 *const widget, - const short id, - const std::string &name, - const std::string &announcement = std::string()); - - A_DELETE_COPY(Channel) - - ~Channel(); - - /** - * Get the id associated witht his channel. - */ - int getId() const A_WARN_UNUSED - { return mId; } - - /** - * Get this channel's name. - */ - const std::string &getName() const A_WARN_UNUSED - { return mName; } - - /** - * Get the announcement message for this channel. - */ - const std::string &getAnnouncement() const A_WARN_UNUSED - { return mAnnouncement; } - - /** - * Sets the name of the channel. - */ - void setName(const std::string &channelName) - { mName = channelName; } - - /** - * Sets the announcement string of the channel. - */ - void setAnnouncement(const std::string &channelAnnouncement) - { mAnnouncement = channelAnnouncement; } - - const ChannelTab *getTab() const A_WARN_UNUSED - { return mTab; } - - protected: - friend class ChannelTab; - void setTab(ChannelTab *const tab) - { mTab = tab; } - - private: - unsigned short mId; - std::string mName; - std::string mAnnouncement; - ChannelTab *mTab; -}; - -#endif // CHANNEL_H diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp deleted file mode 100644 index 48590891b..000000000 --- a/src/channelmanager.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "channelmanager.h" - -#include "channel.h" - -#include "utils/dtor.h" - -#include "debug.h" - -ChannelManager::ChannelManager() -{ -} - -ChannelManager::~ChannelManager() -{ - delete_all(mChannels); - mChannels.clear(); -} - -Channel *ChannelManager::findById(const int id) const -{ - Channel *channel = nullptr; - FOR_EACH (std::list::const_iterator, itr, mChannels) - { - Channel *const c = (*itr); - if (!c) - continue; - if (c->getId() == id) - { - channel = c; - break; - } - } - return channel; -} - -Channel *ChannelManager::findByName(const std::string &name) const -{ - Channel *channel = nullptr; - if (!name.empty()) - { - FOR_EACH (std::list::const_iterator, itr, mChannels) - { - Channel *const c = (*itr); - if (!c) - continue; - if (c->getName() == name) - { - channel = c; - break; - } - } - } - return channel; -} - -void ChannelManager::addChannel(Channel *const channel) -{ - mChannels.push_back(channel); -} - -void ChannelManager::removeChannel(Channel *const channel) -{ - mChannels.remove(channel); - delete channel; -} diff --git a/src/channelmanager.h b/src/channelmanager.h deleted file mode 100644 index edd4bf07e..000000000 --- a/src/channelmanager.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CHANNELMANAGER_H -#define CHANNELMANAGER_H - -#include -#include - -#include "localconsts.h" - -class Channel; - -class ChannelManager final -{ -public: - ChannelManager(); - A_DELETE_COPY(ChannelManager) - ~ChannelManager(); - - Channel *findById(const int id) const A_WARN_UNUSED; - Channel *findByName(const std::string &name) const A_WARN_UNUSED; - - void addChannel(Channel *const channel); - void removeChannel(Channel *const channel); - -private: - std::list mChannels; -}; - -extern ChannelManager *channelManager; - -#endif diff --git a/src/commands.cpp b/src/commands.cpp index eeec00755..73a9f40ce 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -24,8 +24,6 @@ #include "auctionmanager.h" #include "actorspritemanager.h" -#include "channelmanager.h" -#include "channel.h" #include "client.h" #include "configuration.h" #include "game.h" @@ -43,7 +41,6 @@ #include "gui/tradewindow.h" #include "gui/sdlfont.h" -#include "gui/widgets/channeltab.h" #include "gui/widgets/whispertab.h" #include "net/adminhandler.h" diff --git a/src/game.cpp b/src/game.cpp index 7b5413692..26ce9480e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -27,7 +27,6 @@ #include "actorspritemanager.h" #include "auctionmanager.h" #include "animatedsprite.h" -#include "channelmanager.h" #include "client.h" #include "commandhandler.h" #include "effectmanager.h" @@ -141,7 +140,6 @@ QuestsWindow *questsWindow = nullptr; WindowMenu *windowMenu = nullptr; ActorSpriteManager *actorSpriteManager = nullptr; -ChannelManager *channelManager = nullptr; CommandHandler *commandHandler = nullptr; #ifdef USE_MUMBLE MumbleManager *mumbleManager = nullptr; @@ -170,7 +168,6 @@ static void initEngines() actorSpriteManager = new ActorSpriteManager; commandHandler = new CommandHandler; - channelManager = new ChannelManager; effectManager = new EffectManager; AuctionManager::init(); GuildManager::init(); @@ -457,7 +454,6 @@ Game::~Game() del_0(actorSpriteManager) if (Client::getState() != STATE_CHANGE_MAP) del_0(player_node) - del_0(channelManager) del_0(commandHandler) del_0(effectManager) del_0(particleEngine) diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp deleted file mode 100644 index 64bc27e09..000000000 --- a/src/gui/widgets/channeltab.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/channeltab.h" - -#include "channel.h" - -#include "net/chathandler.h" -#include "net/net.h" - -#include "utils/gettext.h" - -#include "debug.h" - -ChannelTab::ChannelTab(const Widget2 *const widget, Channel *const channel) : - ChatTab(widget, channel->getName()), - mChannel(channel) -{ - channel->setTab(this); -} - -ChannelTab::~ChannelTab() -{ -} - -void ChannelTab::handleInput(const std::string &msg) -{ - Net::getChatHandler()->sendToChannel(getChannel()->getId(), msg); -} - -void ChannelTab::showHelp() -{ - chatLog(_("/users > Lists the users in the current channel")); - chatLog(_("/topic > Set the topic of the current channel")); - chatLog(_("/quit > Leave a channel")); - chatLog(_("/op > Make a user a channel operator")); - chatLog(_("/kick > Kick a user from the channel")); -} - -bool ChannelTab::handleCommand(const std::string &type, - const std::string &args) -{ - if (type == "help") - { - if (args == "users") - { - chatLog(_("Command: /users")); - chatLog(_("This command shows the users in this channel.")); - } - else if (args == "topic") - { - chatLog(_("Command: /topic ")); - chatLog(_("This command sets the topic to .")); - } - else if (args == "quit") - { - chatLog(_("Command: /quit")); - chatLog(_("This command leaves the current channel.")); - chatLog(_("If you're the last person in the channel, " - "it will be deleted.")); - } - else if (args == "op") - { - chatLog(_("Command: /op ")); - chatLog(_("This command makes a channel operator.")); - chatLog(_("If the has spaces in it, enclose it in " - "double quotes (\").")); - chatLog(_("Channel operators can kick and op other users " - "from the channel.")); - } - else if (args == "kick") - { - chatLog(_("Command: /kick ")); - chatLog(_("This command makes leave the channel.")); - chatLog(_("If the has spaces in it, enclose it in " - "double quotes (\").")); - } - else - return false; - } - else if (type == "users") - { - Net::getChatHandler()->userList(mChannel->getName()); - } - else if (type == "topic") - { - Net::getChatHandler()->setChannelTopic(mChannel->getId(), args); - } - else if (type == "quit") - { - Net::getChatHandler()->quitChannel(mChannel->getId()); - } - else if (type == "op") - { - // set the user mode 'o' to op a user - if (args != "") - Net::getChatHandler()->setUserMode(mChannel->getId(), args, 'o'); - else - chatLog(_("Need a user to op!"), BY_CHANNEL); - } - else if (type == "kick") - { - if (args != "") - Net::getChatHandler()->kickUser(mChannel->getId(), args); - else - chatLog(_("Need a user to kick!"), BY_CHANNEL); - } - else - return false; - - return true; -} diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h deleted file mode 100644 index bbcdaecaa..000000000 --- a/src/gui/widgets/channeltab.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CHANNELTAB_H -#define CHANNELTAB_H - -#include "chattab.h" - -class Channel; - -/** - * A tab for a chat channel. - */ -class ChannelTab final : public ChatTab -{ - public: - A_DELETE_COPY(ChannelTab) - - Channel *getChannel() const A_WARN_UNUSED - { return mChannel; } - - void showHelp() override; - - bool handleCommand(const std::string &type, - const std::string &args) override; - - protected: - friend class Channel; - - /** - * Constructor. - */ - ChannelTab(const Widget2 *const widget, Channel *const channel); - - /** - * Destructor. - */ - ~ChannelTab(); - - void handleInput(const std::string &msg) override; - - private: - Channel *mChannel; -}; - -#endif // CHANNELTAB_H -- cgit v1.2.3-60-g2f50