]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_cap.h
Add support for CAP in uhnames, it has the token 'userhost-in-names'. Comments welcome.
[user/henk/code/inspircd.git] / src / modules / m_cap.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __CAP_H__
15 #define __CAP_H__
16
17 #include <map>
18 #include <string>
19
20 class CapData
21 {
22  public:
23         irc::string type;
24         std::vector<std::string> wanted;
25         std::vector<std::string> ack;
26         User* user;
27         Module* creator;
28 };
29
30 void GenericCapHandler(Event* ev, const std::string &extname, const std::string &cap)
31 {
32         if (ev->GetEventID() == "cap_req")
33         {
34                 CapData *data = (CapData *) ev->GetData();
35
36                 std::vector<std::string>::iterator it;
37                 if ((it = std::find(data->wanted.begin(), data->wanted.end(), cap)) != data->wanted.end())
38                 {
39                         // we can handle this, so ACK it, and remove it from the wanted list
40                         data->ack.push_back(*it);
41                         data->wanted.erase(it);
42                         data->user->Extend(extname);
43                 }
44         }
45
46         if (ev->GetEventID() == "cap_ls")
47         {
48                 CapData *data = (CapData *) ev->GetData();
49                 data->wanted.push_back(cap);
50         }
51
52         if (ev->GetEventID() == "cap_list")
53         {
54                 CapData *data = (CapData *) ev->GetData();
55
56                 if (data->user->GetExt(extname))
57                         data->wanted.push_back(cap);
58         }
59
60         if (ev->GetEventID() == "cap_clear")
61         {
62                 CapData *data = (CapData *) ev->GetData();
63                 data->ack.push_back("-" + cap);
64                 data->user->Shrink(extname);
65         }
66 }
67
68 #endif