X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_cap.h;h=a375801264218bf345543b95c8fa1979d5ff77ff;hb=4a64082e31c3c3dfa97a1edfb8a3c97fe8d32ea7;hp=1c0ea49fcce540ff398ce9d445206cfe22bd627e;hpb=93425ec211be8185fa9a428dcb24bc8b8121f917;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h index 1c0ea49fc..a37580126 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,15 +17,63 @@ #include #include -class CapData +class CapData : public classbase { public: irc::string type; std::vector wanted; std::vector ack; - std::vector nak; User* user; Module* creator; }; +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) + { + if (ev->GetEventID() == "cap_req") + { + CapData *data = (CapData *) ev->GetData(); + + 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->GetEventID() == "cap_ls") + { + CapData *data = (CapData *) ev->GetData(); + data->wanted.push_back(cap); + } + + if (ev->GetEventID() == "cap_list") + { + CapData *data = (CapData *) ev->GetData(); + + if (ext.get(data->user)) + data->wanted.push_back(cap); + } + + if (ev->GetEventID() == "cap_clear") + { + CapData *data = (CapData *) ev->GetData(); + data->ack.push_back("-" + cap); + ext.set(data->user, 0); + } + } +}; + #endif