]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Refactor userrec::chans.
[user/henk/code/inspircd.git] / src / modules.cpp
index f10c96b2039730cdfd2731aef055383b30dac378..16631c1f2c28d171c650547bf2b2e91d9570dfc2 100644 (file)
@@ -122,8 +122,8 @@ void                Module::OnPostOper(userrec* user, const std::string &opertype) { };
 void           Module::OnInfo(userrec* user) { };
 void           Module::OnWhois(userrec* source, userrec* dest) { };
 int            Module::OnUserPreInvite(userrec* source,userrec* dest,chanrec* channel) { return 0; };
-int            Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text,char status) { return 0; };
-int            Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text,char status) { return 0; };
+int            Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list) { return 0; };
+int            Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list) { return 0; };
 int            Module::OnUserPreNick(userrec* user, const std::string &newnick) { return 0; };
 void           Module::OnUserPostNick(userrec* user, const std::string &oldnick) { };
 int            Module::OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { return ACR_DEFAULT; };
@@ -135,10 +135,9 @@ void               Module::OnBackgroundTimer(time_t curtime) { };
 int            Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) { return 0; };
 void           Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line) { };
 bool           Module::OnCheckReady(userrec* user) { return true; };
-void           Module::OnUserRegister(userrec* user) { };
+int            Module::OnUserRegister(userrec* user) { return 0; };
 int            Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; };
 void           Module::OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { };
-int            Module::OnRawMode(userrec* user, chanrec* chan, char mode, const std::string &param, bool adding, int pcnt) { return 0; };
 int            Module::OnCheckInvite(userrec* user, chanrec* chan) { return 0; };
 int            Module::OnCheckKey(userrec* user, chanrec* chan, const std::string &keygiven) { return 0; };
 int            Module::OnCheckLimit(userrec* user, chanrec* chan) { return 0; };
@@ -149,7 +148,7 @@ int         Module::OnChangeLocalUserGECOS(userrec* user, const std::string &newhost) {
 int            Module::OnLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic) { return 0; };
 void           Module::OnEvent(Event* event) { return; };
 char*          Module::OnRequest(Request* request) { return NULL; };
-int            Module::OnOperCompare(const std::string &password, const std::string &input) { return 0; };
+int            Module::OnOperCompare(const std::string &password, const std::string &input, int tagnumber) { return 0; };
 void           Module::OnGlobalOper(userrec* user) { };
 void           Module::OnPostConnect(userrec* user) { };
 int            Module::OnAddBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
@@ -157,9 +156,10 @@ int                Module::OnDelBan(userrec* source, chanrec* channel,const std::string &banma
 void           Module::OnRawSocketAccept(int fd, const std::string &ip, int localport) { };
 int            Module::OnRawSocketWrite(int fd, const char* buffer, int count) { return 0; };
 void           Module::OnRawSocketClose(int fd) { };
+void           Module::OnRawSocketConnect(int fd) { };
 int            Module::OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult) { return 0; };
-void           Module::OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status) { };
-void           Module::OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status) { };
+void           Module::OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) { };
+void           Module::OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) { };
 void           Module::OnRemoteKill(userrec* source, userrec* dest, const std::string &reason) { };
 void           Module::OnUserInvite(userrec* source,userrec* dest,chanrec* channel) { };
 void           Module::OnPostLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic) { };
@@ -193,6 +193,7 @@ void                Module::OnSetAway(userrec* user) { };
 void           Module::OnCancelAway(userrec* user) { };
 int            Module::OnUserList(userrec* user, chanrec* Ptr) { return 0; };
 int            Module::OnWhoisLine(userrec* user, userrec* dest, int &numeric, std::string &text) { return 0; };
+void           Module::OnBuildExemptList(MessageType message_type, chanrec* chan, userrec* sender, char status, CUList &exempt_list) { };
 
 long InspIRCd::PriorityAfter(const std::string &modulename)
 {
@@ -249,6 +250,84 @@ Module* InspIRCd::FindFeature(const std::string &FeatureName)
        return iter->second;
 }
 
+bool InspIRCd::PublishInterface(const std::string &InterfaceName, Module* Mod)
+{
+       interfacelist::iterator iter = Interfaces.find(InterfaceName);
+
+       if (iter == Interfaces.end())
+       {
+               modulelist ml;
+               ml.push_back(Mod);
+               Interfaces[InterfaceName] = std::make_pair(0, ml);
+               return true;
+       }
+       else
+       {
+               iter->second.second.push_back(Mod);
+               return true;
+       }
+       return false;
+}
+
+bool InspIRCd::UnpublishInterface(const std::string &InterfaceName, Module* Mod)
+{
+       interfacelist::iterator iter = Interfaces.find(InterfaceName);
+
+       if (iter == Interfaces.end())
+               return false;
+
+       for (modulelist::iterator x = iter->second.second.begin(); x != iter->second.second.end(); x++)
+       {
+               if (*x == Mod)
+               {
+                       iter->second.second.erase(x);
+                       if (iter->second.second.empty())
+                               Interfaces.erase(InterfaceName);
+                       return true;
+               }
+       }
+       return false;
+}
+
+modulelist* InspIRCd::FindInterface(const std::string &InterfaceName)
+{
+       interfacelist::iterator iter = Interfaces.find(InterfaceName);
+       if (iter == Interfaces.end())
+               return NULL;
+       else
+               return &(iter->second.second);
+}
+
+void InspIRCd::UseInterface(const std::string &InterfaceName)
+{
+       interfacelist::iterator iter = Interfaces.find(InterfaceName);
+       if (iter != Interfaces.end())
+               iter->second.first++;
+
+}
+
+void InspIRCd::DoneWithInterface(const std::string &InterfaceName)
+{
+       interfacelist::iterator iter = Interfaces.find(InterfaceName);
+       if (iter != Interfaces.end())
+               iter->second.first--;
+}
+
+std::pair<int,std::string> InspIRCd::GetInterfaceInstanceCount(Module* m)
+{
+       for (interfacelist::iterator iter = Interfaces.begin(); iter != Interfaces.end(); iter++)
+       {
+               for (modulelist::iterator x = iter->second.second.begin(); x != iter->second.second.end(); x++)
+               {
+                       if (*x == m)
+                       {
+                               return std::make_pair(iter->second.first, iter->first);
+                       }
+               }
+       }
+       return std::make_pair(0, "");
+}
+
 const std::string& InspIRCd::GetModuleName(Module* m)
 {
        static std::string nothing = ""; /* Prevent compiler warning */
@@ -393,20 +472,17 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
        }
        // Fix by brain - cant write the user until their fd table entry is updated
        zombie->Write(":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
-       for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
+       for (UCListIter i = zombie->chans.begin(); i != zombie->chans.end(); i++)
        {
-               if (((ucrec*)(*i))->channel != NULL)
+               chanrec* Ptr = i->first;
+               zombie->WriteFrom(zombie,"JOIN %s",Ptr->name);
+               if (Ptr->topicset)
                {
-                               chanrec* Ptr = ((ucrec*)(*i))->channel;
-                               zombie->WriteFrom(zombie,"JOIN %s",Ptr->name);
-                               if (Ptr->topicset)
-                               {
-                                       zombie->WriteServ("332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
-                                       zombie->WriteServ("333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
-                               }
-                               Ptr->UserList(zombie);
-                               zombie->WriteServ("366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
+                       zombie->WriteServ("332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
+                       zombie->WriteServ("333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
                }
+               Ptr->UserList(zombie);
+               zombie->WriteServ("366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
        }
        if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->GetFd() != FD_MAGIC_NUMBER))
                local_users.push_back(zombie);