]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Hacked-up culllist: stores user pointers rather than CullItem, as creating them seems...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 16 Jan 2008 07:59:09 +0000 (07:59 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 16 Jan 2008 07:59:09 +0000 (07:59 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8714 e03df62e-2008-0410-955e-edbf42e46eb7

include/cull_list.h
include/users.h
src/cull_list.cpp
src/users.cpp

index eb670580e941e40e7ab68f5a40031ae53b5a401b..25c4b48a50ed6cc3a0ad815b3ead8dc73f336c70 100644 (file)
@@ -115,7 +115,7 @@ class CoreExport CullList : public classbase
         * See the information for CullItem for
         * more information.
         */
-       std::vector<CullItem *> list;
+       std::vector<User *> list;
 
  public:
        /** Constructor.
@@ -131,15 +131,7 @@ class CoreExport CullList : public classbase
         * @param reason The quit reason of the user being added
         * @param o_reason The quit reason to show only to opers
         */
-       void AddItem(User* user, std::string &reason, const char* o_reason = "");
-
-       /** Adds a user to the cull list for later
-        * removal via QUIT.
-        * @param user The user to add
-        * @param reason The quit reason of the user being added
-        * @param o_reason The quit reason to show only to opers
-        */
-       void AddItem(User* user, const char* reason, const char* o_reason = "");
+       void AddItem(User* user);
 
        /* Turn an item into a silent item (don't send out QUIT for this user)
         */
index c795ae1a4a8ce048b70eead3f94da949be4906f6..9d210931c03f477098b67143702846697cb2211b 100644 (file)
@@ -481,10 +481,6 @@ class CoreExport User : public connection
         */
        void DecrementModes();
 
-       /** Oper-only quit message for this user if non-null
-        */
-       char* operquit;
-
        /** Max channels for this user
         */
        unsigned int MaxChans;
@@ -616,6 +612,14 @@ class CoreExport User : public connection
         */
        std::string sendq;
 
+       /** Message user will quit with. Not to be set externally.
+        */
+       std::string quitmsg;
+
+       /** Quit message shown to opers - not to be set externally.
+        */
+       std::string operquitmsg;
+
        /** Flood counters - lines received
         */
        unsigned int lines_in;
index 3f2050679fb8899d523787cd249e9e68a3f54608..9a3c088e81e95d7fd9e75a487ef40399afeb72b2 100644 (file)
 #include "inspircd.h"
 #include "cull_list.h"
 
-CullItem::CullItem(User* u, std::string &r, const char* o_reason)
-{
-       this->user = u;
-       this->reason = r;
-       this->silent = false;
-       /* Seperate oper reason not set, use the user reason */
-       if (*o_reason)
-               this->oper_reason = o_reason;
-       else
-               this->oper_reason = r;
-}
-
-CullItem::CullItem(User* u, const char* r, const char* o_reason)
-{
-       this->user = u;
-       this->reason = r;
-       this->silent = false;
-       /* Seperate oper reason not set, use the user reason */
-       if (*o_reason)
-               this->oper_reason = o_reason;
-       else
-               this->oper_reason = r;
-}
-
-void CullItem::MakeSilent()
-{
-       this->silent = true;
-}
-
-bool CullItem::IsSilent()
-{
-       return this->silent;
-}
-
-CullItem::~CullItem()
-{
-}
-
-User* CullItem::GetUser()
-{
-       return this->user;
-}
-
-std::string& CullItem::GetReason()
-{
-       return this->reason;
-}
-
-std::string& CullItem::GetOperReason()
-{
-       return this->oper_reason;
-}
-
 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
 {
        list.clear();
        exempt.clear();
 }
 
-void CullList::AddItem(User* user, std::string &reason, const char* o_reason)
-{
-       AddItem(user, reason.c_str(), o_reason);
-}
-
-
-void CullList::AddItem(User* user, const char* reason, const char* o_reason)
+void CullList::AddItem(User* user)
 {
        if (exempt.find(user) == exempt.end())
        {
-               CullItem *item = new CullItem(user, reason, o_reason);
-               list.push_back(item);
+               list.push_back(user);
                exempt[user] = user;
        }
 }
 
 void CullList::MakeSilent(User* user)
 {
-       for (std::vector<CullItem *>::iterator a = list.begin(); a != list.end(); ++a)
+/*     for (std::vector<CullItem *>::iterator a = list.begin(); a != list.end(); ++a)
        {
                if ((*a)->GetUser() == user)
                {
@@ -101,6 +41,7 @@ void CullList::MakeSilent(User* user)
                        break;
                }
        }
+*/
        return;
 }
 
@@ -111,14 +52,14 @@ int CullList::Apply()
 
        while (list.size() && i++ != 100)
        {
-               std::vector<CullItem *>::iterator a = list.begin();
+               std::vector<User *>::iterator a = list.begin();
 
-               User *u = (*a)->GetUser();
+               User *u = (*a);
                user_hash::iterator iter = ServerInstance->clientlist->find(u->nick);
                std::map<User*, User*>::iterator exemptiter = exempt.find(u);
                const char* preset_reason = u->GetOperQuit();
-               std::string reason = (*a)->GetReason();
-               std::string oper_reason = *preset_reason ? preset_reason : (*a)->GetOperReason();
+               std::string reason = u->operquitmsg;
+               std::string oper_reason = *preset_reason ? preset_reason : u->operquitmsg;
 
                if (reason.length() > MAXQUIT - 1)
                        reason.resize(MAXQUIT - 1);
@@ -170,17 +111,18 @@ int CullList::Apply()
                {
                        if (IS_LOCAL(u))
                        {
-                               if (!(*a)->IsSilent())
-                               {
-                                       ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",u->nick,u->ident,u->host,oper_reason.c_str());
-                               }
+       // XXX
+       //                      if (!(*a)->IsSilent())
+       //                      {
+       //                              ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",u->nick,u->ident,u->host,oper_reason.c_str());
+       //                      }
                        }
                        else
                        {
-                               if ((!ServerInstance->SilentULine(u->server)) && (!(*a)->IsSilent()))
-                               {
+       //                      if ((!ServerInstance->SilentULine(u->server)) && (!(*a)->IsSilent()))
+       //                      {
                                        ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",u->server,u->nick,u->ident,u->host,oper_reason.c_str());
-                               }
+       //                      }
                        }
                        u->AddToWhoWas();
                }
@@ -197,7 +139,7 @@ int CullList::Apply()
                        delete u;
                }
 
-               delete *list.begin();
+       //      delete *list.begin();
                list.erase(list.begin());
                exempt.erase(exemptiter);
        }
index d7671de3c8a5a6496cdb26ec1aaebb145a6ba908..1d2b16deedf40c21d2bd7eb9b9841b5d679f0da3 100644 (file)
@@ -196,7 +196,7 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
        memset(modes,0,sizeof(modes));
        memset(snomasks,0,sizeof(snomasks));
        /* Invalidate cache */
-       operquit = cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
+       cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
 
        if (uid.empty())
                strlcpy(uuid, Instance->GetUID().c_str(), UUID_LENGTH);
@@ -228,8 +228,7 @@ User::~User()
 
        this->InvalidateCache();
        this->DecrementModes();
-       if (operquit)
-               free(operquit);
+
        if (ip)
        {
                ServerInstance->Users->RemoveCloneCounts(this);
@@ -710,7 +709,9 @@ void User::QuitUser(InspIRCd* Instance, User *user, const std::string &quitreaso
        Instance->Log(DEBUG,"QuitUser: %s '%s'", user->nick, quitreason.c_str());
        user->Write("ERROR :Closing link (%s@%s) [%s]", user->ident, user->host, *operreason ? operreason : quitreason.c_str());
        user->muted = true;
-       Instance->GlobalCulls.AddItem(user, quitreason.c_str(), operreason);
+       user->quitmsg = quitreason;
+       user->operquitmsg = operreason;
+       Instance->GlobalCulls.AddItem(user);
 }
 
 /* adds or updates an entry in the whowas list */
@@ -1736,15 +1737,12 @@ void User::HandleEvent(EventType et, int errornum)
 
 void User::SetOperQuit(const std::string &oquit)
 {
-       if (operquit)
-               return;
-
-       operquit = strdup(oquit.c_str());
+       operquitmsg = oquit;
 }
 
 const char* User::GetOperQuit()
 {
-       return operquit ? operquit : "";
+       return operquitmsg.c_str();
 }
 
 void User::IncreasePenalty(int increase)