///////////////////////////////////////////////////////////////////////////// // Name: playerdata.cpp // tag: aBridge player info database // Author: David Roundy // Modified by: // Copyright: (c) 2002 David Roundy // Licence: GPL //--------------------------------------------------------------------------- // Last modified: /* 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 (at your option) 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes . #include #ifndef WX_PRECOMP #include #include #include #endif #include "debug.h" #include "playerdata.h" #include "irc.h" // My dealer constructor aBridgePlayerData::aBridgePlayerData() { if (!info) info = new MyStringList(wxKEY_STRING); if (!pics) pics = new MyStringList(wxKEY_STRING); } aBridgePlayerData::~aBridgePlayerData() { } MyStringList *aBridgePlayerData::info = NULL, *aBridgePlayerData::pics = NULL; void aBridgePlayerData::SetPlayerInfo(wxString player, const wxString &new_info) { if (!info) new aBridgePlayerData(); irc_name(player); MyStringList::Node *node = info->Find(player); if (node) { delete node->GetData(); info->DeleteNode(node); } info->Append(player,new wxString(new_info)); } void aBridgePlayerData::SetPlayerPic(wxString player, const wxString &pic) { if (!pics) new aBridgePlayerData(); irc_name(player); MyStringList::Node *node = pics->Find(player); if (node) { delete node->GetData(); pics->DeleteNode(node); } // Eliminate the path, to avoid a security hole of people deleting files // such as ../bashrc and then replacing them with trojaned versions. wxString picname = wxFileNameFromPath(pic); pics->Append(player,new wxString(picname)); } wxString aBridgePlayerData::GetPlayerInfo(wxString player) { if (!info) new aBridgePlayerData(); irc_name(player); MyStringList::Node *node = info->Find(player); if (node) { return *(node->GetData()); } else { return "I have no info on " + player; } } wxString aBridgePlayerData::GetPlayerPic(wxString player) { if (!pics) new aBridgePlayerData(); irc_name(player); MyStringList::Node *node = pics->Find(player); if (node) { DebugMsg("Found player pic in string list: " + player + " is " + *(node->GetData())); return *(node->GetData()); } else { return "unknown"; } } // The string list... WX_DEFINE_LIST(MyStringList);