* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
* ---------------------------------------------------
*/
-#include <stdio.h>
-#include <vector>
-#include <string.h>
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
#include "inspircd.h"
/* $ModDesc: Povides support for the /DCCALLOW command */
DCCAllow(const std::string &nick, const std::string &hm, const time_t so, const long ln) : nickname(nick), hostmask(hm), set_on(so), length(ln) { }
};
-typedef std::vector<userrec *> userlist;
+typedef std::vector<User *> userlist;
userlist ul;
typedef std::vector<DCCAllow> dccallowlist;
dccallowlist* dl;
typedef std::vector<BannedFileList> bannedfilelist;
bannedfilelist bfl;
-class cmd_dccallow : public command_t
+class CommandDccallow : public Command
{
public:
- cmd_dccallow(InspIRCd* Me) : command_t(Me, "DCCALLOW", 0, 0)
+ CommandDccallow(InspIRCd* Me) : Command(Me, "DCCALLOW", 0, 0)
{
this->source = "m_dccallow.so";
syntax = "{[+|-]<nick> <time>|HELP|LIST}";
+ /* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */
}
- CmdResult Handle(const char **parameters, int pcnt, userrec *user)
+ CmdResult Handle(const char **parameters, int pcnt, User *user)
{
/* syntax: DCCALLOW [+|-]<nick> (<time>) */
if (!pcnt)
}
std::string nick = parameters[0] + 1;
- userrec *target = ServerInstance->FindNick(nick);
+ User *target = ServerInstance->FindNick(nick);
if (target)
{
}
else
{
- DELETE(dl);
+ delete dl;
user->Shrink("dccallow_list");
// remove from userlist
for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
{
- userrec* u = (userrec*)(*j);
+ User* u = (User*)(*j);
if (u == user)
{
ul.erase(j);
long length;
if (pcnt < 2)
{
- length = ServerInstance->Duration(default_length.c_str());
+ length = ServerInstance->Duration(default_length);
}
else if (!atoi(parameters[1]))
{
return CMD_FAILURE;
}
- void DisplayHelp(userrec* user)
+ void DisplayHelp(User* user)
{
user->WriteServ("998 %s :DCCALLOW [<+|->nick [time]] [list] [help]", user->nick);
user->WriteServ("998 %s :You may allow DCCs from specific users by specifying a", user->nick);
user->WriteServ("999 %s :End of DCCALLOW HELP", user->nick);
}
- void DisplayDCCAllowList(userrec* user)
+ void DisplayDCCAllowList(User* user)
{
// display current DCCALLOW list
user->WriteServ("990 %s :Users on your DCCALLOW list:", user->nick);
class ModuleDCCAllow : public Module
{
- cmd_dccallow* mycommand;
+ CommandDccallow* mycommand;
public:
ModuleDCCAllow(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
- mycommand = new cmd_dccallow(ServerInstance);
+ mycommand = new CommandDccallow(ServerInstance);
ServerInstance->AddCommand(mycommand);
ReadFileConf();
+ Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPreNick, I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 5);
}
- void Implements(char* List)
- {
- List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnUserQuit] = List[I_OnUserPreNick] = List[I_OnRehash] = 1;
- }
- virtual void OnRehash(userrec* user, const std::string ¶meter)
+ virtual void OnRehash(User* user, const std::string ¶meter)
{
delete Conf;
Conf = new ConfigReader(ServerInstance);
}
- virtual void OnUserQuit(userrec* user, const std::string &reason, const std::string &oper_message)
+ virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
{
dccallowlist* dl;
user->GetExt("dccallow_list", dl);
if (dl)
{
- DELETE(dl);
+ delete dl;
user->Shrink("dccallow_list");
RemoveFromUserlist(user);
}
}
- virtual int OnUserPreNick(userrec* user, const std::string &newnick)
+ virtual int OnUserPreNick(User* user, const std::string &newnick)
{
RemoveNick(user);
return 0;
}
- virtual int OnUserPreMessage(userrec* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
+ virtual int OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreNotice(user, dest, target_type, text, status, exempt_list);
}
- virtual int OnUserPreNotice(userrec* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
+ virtual int OnUserPreNotice(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
{
if (!IS_LOCAL(user))
return 0;
if (target_type == TYPE_USER)
{
- userrec* u = (userrec*)dest;
+ User* u = (User*)dest;
/* Always allow a user to dcc themselves (although... why?) */
if (user == u)
{
for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
{
- userrec* u = (userrec*)(*iter);
+ User* u = (User*)(*iter);
u->GetExt("dccallow_list", dl);
if (dl)
}
}
- void RemoveNick(userrec* user)
+ void RemoveNick(User* user)
{
/* Iterate through all DCCALLOW lists and remove user */
for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
{
- userrec *u = (userrec*)(*iter);
+ User *u = (User*)(*iter);
u->GetExt("dccallow_list", dl);
if (dl)
}
}
- void RemoveFromUserlist(userrec *user)
+ void RemoveFromUserlist(User *user)
{
// remove user from userlist
for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
{
- userrec* u = (userrec*)(*j);
+ User* u = (User*)(*j);
if (u == user)
{
ul.erase(j);
virtual Version GetVersion()
{
- return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
- }
-};
-
-class ModuleDCCAllowFactory : public ModuleFactory
-{
- public:
- ModuleDCCAllowFactory()
- {
+ return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
- ~ModuleDCCAllowFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleDCCAllow(Me);
- }
-
};
-extern "C" void * init_module( void )
-{
- return new ModuleDCCAllowFactory;
-}
+MODULE_INIT(ModuleDCCAllow)