00001 /* 00002 * The Mana World 00003 * Copyright (C) 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #include "net/ea/adminhandler.h" 00023 00024 #include "net/ea/chathandler.h" 00025 #include "net/ea/protocol.h" 00026 00027 #include "net/messagein.h" 00028 #include "net/messageout.h" 00029 00030 #include "being.h" 00031 #include "beingmanager.h" 00032 #include "game.h" 00033 #include "player_relations.h" 00034 00035 #include "gui/widgets/chattab.h" 00036 00037 #include "utils/gettext.h" 00038 #include "utils/stringutils.h" 00039 #include "utils/strprintf.h" 00040 00041 #include <string> 00042 00043 extern Net::ChatHandler *chatHandler; 00044 00045 Net::AdminHandler *adminHandler; 00046 00047 namespace EAthena { 00048 00049 AdminHandler::AdminHandler() 00050 { 00051 static const Uint16 _messages[] = { 00052 SMSG_ADMIN_KICK_ACK, 00053 0 00054 }; 00055 handledMessages = _messages; 00056 adminHandler = this; 00057 } 00058 00059 void AdminHandler::handleMessage(MessageIn &msg) 00060 { 00061 int id; 00062 switch (msg.getId()) 00063 { 00064 case SMSG_ADMIN_KICK_ACK: 00065 id = msg.readInt32(); 00066 if (id == 0) 00067 localChatTab->chatLog(_("Kick failed!"), BY_SERVER); 00068 else 00069 localChatTab->chatLog(_("Kick succeeded!"), BY_SERVER); 00070 break; 00071 } 00072 } 00073 00074 void AdminHandler::announce(const std::string &text) 00075 { 00076 MessageOut outMsg(CMSG_ADMIN_ANNOUNCE); 00077 outMsg.writeInt16(text.length() + 4); 00078 outMsg.writeString(text, text.length()); 00079 } 00080 00081 void AdminHandler::localAnnounce(const std::string &text) 00082 { 00083 MessageOut outMsg(CMSG_ADMIN_LOCAL_ANNOUNCE); 00084 outMsg.writeInt16(text.length() + 4); 00085 outMsg.writeString(text, text.length()); 00086 } 00087 00088 void AdminHandler::hide(bool hide) 00089 { 00090 MessageOut outMsg(CMSG_ADMIN_HIDE); 00091 outMsg.writeInt32(0); //unused 00092 } 00093 00094 void AdminHandler::kick(int playerId) 00095 { 00096 MessageOut outMsg(CMSG_ADMIN_KICK); 00097 outMsg.writeInt32(playerId); 00098 } 00099 00100 void AdminHandler::kick(const std::string &name) 00101 { 00102 chatHandler->talk("@kick " + name); 00103 } 00104 00105 void AdminHandler::ban(int playerId) 00106 { 00107 // Not supported 00108 } 00109 00110 void AdminHandler::ban(const std::string &name) 00111 { 00112 chatHandler->talk("@ban " + name); 00113 } 00114 00115 void AdminHandler::unban(int playerId) 00116 { 00117 // Not supported 00118 } 00119 00120 void AdminHandler::unban(const std::string &name) 00121 { 00122 chatHandler->talk("@unban " + name); 00123 } 00124 00125 void AdminHandler::mute(int playerId, int type, int limit) 00126 { 00127 return; // Still looking into this 00128 00129 MessageOut outMsg(CMSG_ADMIN_MUTE); 00130 outMsg.writeInt32(playerId); 00131 outMsg.writeInt8(type); 00132 outMsg.writeInt16(limit); 00133 } 00134 00135 } // namespace EAthena