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 CapEvent : public Event
24 std::vector<std::string> wanted;
25 std::vector<std::string> ack;
28 CapEvent(Module* sender, const std::string& t) : Event(sender, t) {}
35 const std::string cap;
36 GenericCap(Module* parent, const std::string &Cap) : ext("cap_" + Cap, parent), cap(Cap)
38 Extensible::Register(&ext);
41 void HandleEvent(Event& ev)
43 CapEvent *data = static_cast<CapEvent*>(&ev);
44 if (ev.id == "cap_req")
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.id == "cap_ls")
58 data->wanted.push_back(cap);
61 if (ev.id == "cap_list")
63 if (ext.get(data->user))
64 data->wanted.push_back(cap);
67 if (ev.id == "cap_clear")
69 data->ack.push_back("-" + cap);
70 ext.set(data->user, 0);