X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_cap.h;h=809b0f4cf2eb3062f6537b9351a1ca3d124d1d64;hb=26cd5393c9308fabe73c41870f06f73a5b001cd7;hp=9f17bd3d05ffedcf187526e8785cfd3c17d90ada;hpb=625b14a83ca139b50b6d0978612482b1691e6a78;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h index 9f17bd3d0..809b0f4cf 100644 --- a/src/modules/m_cap.h +++ b/src/modules/m_cap.h @@ -2,11 +2,11 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ @@ -17,7 +17,7 @@ #include #include -class CapData +class CapEvent : public Event { public: irc::string type; @@ -25,6 +25,51 @@ class CapData std::vector ack; User* user; Module* creator; + CapEvent(Module* sender, const std::string& t) : Event(sender, t) {} +}; + +class GenericCap +{ + public: + LocalIntExt ext; + const std::string cap; + GenericCap(Module* parent, const std::string &Cap) : ext("cap_" + Cap, parent), cap(Cap) + { + Extensible::Register(&ext); + } + + void HandleEvent(Event& ev) + { + CapEvent *data = static_cast(&ev); + if (ev.id == "cap_req") + { + std::vector::iterator it; + if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end()) + { + // we can handle this, so ACK it, and remove it from the wanted list + data->ack.push_back(*it); + data->wanted.erase(it); + ext.set(data->user, 1); + } + } + + if (ev.id == "cap_ls") + { + data->wanted.push_back(cap); + } + + if (ev.id == "cap_list") + { + if (ext.get(data->user)) + data->wanted.push_back(cap); + } + + if (ev.id == "cap_clear") + { + data->ack.push_back("-" + cap); + ext.set(data->user, 0); + } + } }; #endif