]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_uhnames.cpp
Removed superfluous semicolons
[user/henk/code/inspircd.git] / src / modules / m_uhnames.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 #include "inspircd.h"
15 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18
19 static const char* dummy = "ON";
20
21 /* $ModDesc: Provides aliases of commands. */
22
23 class ModuleUHNames : public Module
24 {
25         CUList nl;
26  public:
27         
28         ModuleUHNames(InspIRCd* Me)
29                 : Module(Me)
30         {
31         }
32
33         void Implements(char* List)
34         {
35                 List[I_OnSyncUserMetaData] = List[I_OnPreCommand] = List[I_OnUserList] = List[I_On005Numeric] = 1;
36         }
37
38         virtual ~ModuleUHNames()
39         {
40         }
41
42         void OnSyncUserMetaData(userrec* user, Module* proto,void* opaque, const std::string &extname, bool displayable)
43         {
44                 if ((displayable) && (extname == "UHNAMES"))
45                         proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, "Enabled");
46         }
47
48         virtual Version GetVersion()
49         {
50                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
51         }
52
53         virtual void On005Numeric(std::string &output)
54         {
55                 output.append(" UHNAMES");
56         }
57
58         Priority Prioritize()
59         {
60                 return (Priority)ServerInstance->PriorityBefore("m_namesx.so");
61         }
62
63         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
64         {
65                 irc::string c = command.c_str();
66                 /* We don't actually create a proper command handler class for PROTOCTL,
67                  * because other modules might want to have PROTOCTL hooks too.
68                  * Therefore, we just hook its as an unvalidated command therefore we
69                  * can capture it even if it doesnt exist! :-)
70                  */
71                 if (c == "PROTOCTL")
72                 {
73                         if ((pcnt) && (!strcasecmp(parameters[0],"UHNAMES")))
74                         {
75                                 user->Extend("UHNAMES",dummy);
76                                 return 1;
77                         }
78                 }
79                 return 0;
80         }
81
82         /* IMPORTANT: This must be prioritized above NAMESX! */
83         virtual int OnUserList(userrec* user, chanrec* Ptr, CUList* &ulist)
84         {
85                 if (user->GetExt("UHNAMES"))
86                 {
87                         if (!ulist)
88                                 ulist = Ptr->GetUsers();
89
90                         for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
91                                 i->second = i->first->GetFullHost();
92                 }
93                 return 0;               
94         }
95 };
96
97 MODULE_INIT(ModuleUHNames)
98