1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 class CapData : public classbase
24 std::vector<std::string> wanted;
25 std::vector<std::string> ack;
34 const std::string cap;
35 GenericCap(Module* parent, const std::string &Cap) : ext("cap_" + Cap, parent), cap(Cap)
37 Extensible::Register(&ext);
40 void HandleEvent(Event* ev)
42 if (ev->GetEventID() == "cap_req")
44 CapData *data = (CapData *) ev->GetData();
46 std::vector<std::string>::iterator it;
47 if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end())
49 // we can handle this, so ACK it, and remove it from the wanted list
50 data->ack.push_back(*it);
51 data->wanted.erase(it);
52 ext.set(data->user, 1);
56 if (ev->GetEventID() == "cap_ls")
58 CapData *data = (CapData *) ev->GetData();
59 data->wanted.push_back(cap);
62 if (ev->GetEventID() == "cap_list")
64 CapData *data = (CapData *) ev->GetData();
66 if (ext.get(data->user))
67 data->wanted.push_back(cap);
70 if (ev->GetEventID() == "cap_clear")
72 CapData *data = (CapData *) ev->GetData();
73 data->ack.push_back("-" + cap);
74 ext.set(data->user, 0);