]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix for correct display when removing snomask
[user/henk/code/inspircd.git] / src / users.cpp
index 085440367ac3f868ec1be07db101558ec68f6839..b919ae759937bcc6e72ba0e7ed499cd2a2767700 100644 (file)
@@ -92,31 +92,47 @@ bool DoneClassesAndTypes(ServerConfig* conf, const char* tag)
        return true;
 }
 
-bool userrec::ProcessNoticeMasks(const char *sm)
+std::string userrec::ProcessNoticeMasks(const char *sm)
 {
-       bool adding = true;
+       bool adding = true, oldadding = false;
        const char *c = sm;
+       std::string output = "";
+
+       ServerInstance->Log(DEBUG,"Process notice masks");
 
        while (c && *c)
        {
+               ServerInstance->Log(DEBUG,"Process notice mask %c",*c);
+               
                switch (*c)
                {
                        case '+':
                                adding = true;
-                               break;
+                       break;
                        case '-':
                                adding = false;
-                               break;
+                       break;
                        default:
-                               if ((*c >= 'A') && (*c <= 'z'))
-                                       this->SetNoticeMask(*c, adding);
-                               break;
+                               if ((*c >= 'A') && (*c <= 'z') && (ServerInstance->SNO->IsEnabled(*c)))
+                               {
+                                       if ((!IsNoticeMaskSet(*c) && adding) || (IsNoticeMaskSet(*c) && !adding))
+                                       {
+                                               if ((oldadding != adding) || (sm == (c+1)))
+                                                       output += (adding ? '+' : '-');
+
+                                               this->SetNoticeMask(*c, adding);
+
+                                               output += *c;
+                                       }
+                               }
+                               oldadding = adding;
+                       break;
                }
 
                *c++;
        }
 
-       return true;
+       return output;
 }
 
 void userrec::StartDNSLookup()
@@ -275,6 +291,7 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
        invites.clear();
        chans.resize(MAXCHANS);
        memset(modes,0,sizeof(modes));
+       memset(snomasks,0,sizeof(snomasks));
        
        for (unsigned int n = 0; n < MAXCHANS; n++)
        {
@@ -696,17 +713,15 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
        }
 
        /*
-        * this must come before the ServerInstance->WriteOpers so that it doesnt try to fill their buffer with anything
-        * if they were an oper with +s.
-        *
-        * XXX -
-        * In the current implementation, we only show local quits, as we only show local connects. With 
-        * the proposed implmentation of snomasks however, this will likely change in the (near?) future.
+        * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
+        * if they were an oper with +sn +qQ.
         */
        if (user->registered == REG_ALL)
        {
                if (IS_LOCAL(user))
-                       Instance->WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
+                       Instance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
+               else
+                       Instance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,reason.c_str());
                user->AddToWhoWas();
        }
 
@@ -1062,7 +1077,7 @@ void userrec::FullConnect(CullList* Goners)
        FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
        FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
        this->registered = REG_ALL;
-       ServerInstance->WriteOpers("*** Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
+       ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
 }
 
 /** userrec::UpdateNick()
@@ -1460,7 +1475,7 @@ void userrec::WriteCommonExcept(const char* text, ...)
 
 void userrec::WriteCommonExcept(const std::string &text)
 {
-       bool quit_munge = true;
+       bool quit_munge = false;
        char oper_quit[MAXBUF];
        char textbuffer[MAXBUF];
 
@@ -1632,14 +1647,55 @@ bool userrec::ChangeDisplayedHost(const char* host)
                        return false;
                FOREACH_MOD(I_OnChangeHost,OnChangeHost(this,host));
        }
+       if (this->ServerInstance->Config->CycleHosts)
+               this->WriteCommonExcept("%s","QUIT :Changing hosts");
+
        strlcpy(this->dhost,host,63);
 
+       if (this->ServerInstance->Config->CycleHosts)
+       {
+               for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
+               {
+                       if ((*i)->channel)
+                       {
+                               (*i)->channel->WriteAllExceptSender(this, 0, "JOIN %s", (*i)->channel->name);
+                               std::string n = this->ServerInstance->Modes->ModeString(this, (*i)->channel);
+                               if (n.length())
+                                       (*i)->channel->WriteChannelWithServ(this->ServerInstance->Config->ServerName, "MODE %s +%s", (*i)->channel->name, n.c_str());
+                       }
+               }
+       }
+
        if (IS_LOCAL(this))
                this->WriteServ("396 %s %s :is now your hidden host",this->nick,this->dhost);
 
        return true;
 }
 
+bool userrec::ChangeIdent(const char* newident)
+{
+       if (this->ServerInstance->Config->CycleHosts)
+               this->WriteCommonExcept("%s","QUIT :Changing ident");
+
+       strlcpy(this->ident, newident, IDENTMAX+2);
+
+       if (this->ServerInstance->Config->CycleHosts)
+       {
+               for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
+               {
+                       if ((*i)->channel)
+                       {
+                               (*i)->channel->WriteAllExceptSender(this, 0, "JOIN %s", (*i)->channel->name);
+                               std::string n = this->ServerInstance->Modes->ModeString(this, (*i)->channel);
+                               if (n.length())
+                                       (*i)->channel->WriteChannelWithServ(this->ServerInstance->Config->ServerName, "MODE %s +%s", (*i)->channel->name, n.c_str());
+                       }
+               }
+       }
+
+       return true;
+}
+
 void userrec::NoticeAll(char* text, ...)
 {
        char textbuffer[MAXBUF];