|
|||
|
|||
|
00001 /* +------------------------------------+ 00002 * | Inspire Internet Relay Chat Daemon | 00003 * +------------------------------------+ 00004 * 00005 * InspIRCd: (C) 2002-2008 InspIRCd Development Team 00006 * See: http://www.inspircd.org/wiki/index.php/Credits 00007 * 00008 * This program is free but copyrighted software; see 00009 * the file COPYING for details. 00010 * 00011 * --------------------------------------------------- 00012 */ 00013 00014 #ifndef __CAP_H__ 00015 #define __CAP_H__ 00016 00017 #include <map> 00018 #include <string> 00019 00020 class CapData : public classbase 00021 { 00022 public: 00023 irc::string type; 00024 std::vector<std::string> wanted; 00025 std::vector<std::string> ack; 00026 User* user; 00027 Module* creator; 00028 }; 00029 00030 void GenericCapHandler(Event* ev, const std::string &extname, const std::string &cap) 00031 { 00032 if (ev->GetEventID() == "cap_req") 00033 { 00034 CapData *data = (CapData *) ev->GetData(); 00035 00036 std::vector<std::string>::iterator it; 00037 if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end()) 00038 { 00039 // we can handle this, so ACK it, and remove it from the wanted list 00040 data->ack.push_back(*it); 00041 data->wanted.erase(it); 00042 data->user->Extend(extname); 00043 } 00044 } 00045 00046 if (ev->GetEventID() == "cap_ls") 00047 { 00048 CapData *data = (CapData *) ev->GetData(); 00049 data->wanted.push_back(cap); 00050 } 00051 00052 if (ev->GetEventID() == "cap_list") 00053 { 00054 CapData *data = (CapData *) ev->GetData(); 00055 00056 if (data->user->GetExt(extname)) 00057 data->wanted.push_back(cap); 00058 } 00059 00060 if (ev->GetEventID() == "cap_clear") 00061 { 00062 CapData *data = (CapData *) ev->GetData(); 00063 data->ack.push_back("-" + cap); 00064 data->user->Shrink(extname); 00065 } 00066 } 00067 00068 #endif