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 ();
25 cnx->get_bot()->logLine (temp);
28 dcc_map[person->getAddress ()] = person;
32 DCCManager::sendMessage (String to, String message)
34 DCCPerson *person = dcc_map[to];
38 person->sendNotice (message);
43 // checks for stale connections and removes them
45 DCCManager::checkStale ()
47 DCC_MAP::iterator it, it2;
48 DCCConnection const* temp_cnx;
50 for (it = dcc_map.begin (),it2 = dcc_map.end ();
53 temp_cnx = it->second->dcc;
54 if (temp_cnx->get_autoRemove () && std::time (0) >=
55 (std::time_t)(temp_cnx->get_lastSpoken () + Bot::DCC_DELAY))
65 DCCManager::checkInput (int rd)
67 DCCManager::checkInput (fd_set rd)
71 DCC_MAP::iterator it = dcc_map.begin();
72 DCC_MAP::iterator it2;
74 while (it != dcc_map.end ())
79 if (rd & it2->second->dcc->getFileDescriptor())
81 if (FD_ISSET(it2->second->dcc->getFileDescriptor(), &rd))
84 if (it2->second->handleInput())
86 delete it2->second->dcc;
94 DCCManager::~DCCManager ()
96 DCC_MAP::iterator it, it2;
97 it = dcc_map.begin ();
100 for (; it != it2; ++it)
102 delete it->second->dcc;