1 // DCCManager.H -*- C++ -*-
2 // Copyright (c) 2002 Clinton Ebadi
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 #include "DCCManager.H"
21 DCCManager::addConnection (DCCConnection *cnx)
23 DCCPerson *person = new DCCPerson (cnx);
24 String temp = person->getAddress ();
27 dcc_map[person->getAddress ()] = person;
31 DCCManager::sendMessage (String to, String message)
33 DCCPerson *person = dcc_map[to];
37 person->sendNotice (message);
42 // checks for stale connections and removes them
44 DCCManager::checkStale ()
46 DCC_MAP::iterator it, it2;
47 DCCConnection const* temp_cnx;
49 for (it = dcc_map.begin (),it2 = dcc_map.end ();
52 temp_cnx = it->second->DCC ();
53 if (temp_cnx->autoRemove && std::time (0) >=
54 (std::time_t)(temp_cnx->lastSpoken + Bot::DCC_DELAY))
64 DCCManager::checkInput (int rd)
66 DCCManager::checkInput (fd_set rd)
70 DCC_MAP::iterator it = dcc_map.begin();
71 DCC_MAP::iterator it2;
73 while (it != dcc_map.end ())
78 if (rd & it2->second->DCC()->getFileDescriptor())
80 if (FD_ISSET(it2->second->DCC()->getFileDescriptor(), &rd))
83 if (it2->second->handleInput())
85 // I am an evil, evil person
86 delete const_cast<DCCConnection*> (it2->second->DCC());
94 DCCManager::~DCCManager ()
96 DCC_MAP::iterator it, it2;
97 it = dcc_map.begin ();
100 for (; it != it2; ++it)
102 // I am an evil, evil person
103 delete const_cast<DCCConnection*> (it->second->DCC());