]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move more stuff into userrec
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 9 Aug 2006 19:56:08 +0000 (19:56 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 9 Aug 2006 19:56:08 +0000 (19:56 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4823 e03df62e-2008-0410-955e-edbf42e46eb7

include/commands.h
include/message.h
include/users.h
src/cmd_whois.cpp
src/message.cpp
src/modules/m_check.cpp
src/users.cpp

index 0a2e9fbd7a7f0e269fa6b71d7b7479213bef3755..81e28fbaf07575a3f4242aafd5fcf561eec48e60 100644 (file)
@@ -35,7 +35,6 @@ bool host_matches_everyone(const std::string &mask, userrec* user);
 bool ip_matches_everyone(const std::string &ip, userrec* user);
 bool nick_matches_everyone(const std::string &nick, userrec* user);    
 int operstrcmp(const char* data,const char* input);
-void split_chlist(userrec* user, userrec* dest, const std::string &cl);
 
 /*       XXX Serious WTFness XXX
  *
index f53f3d9d2670a3544487cccbfa78f5e41256bfb1..b1af53bbc30967b3bf48adf692a9742d2270477a 100644 (file)
@@ -32,7 +32,6 @@ int isident(const char* n);
 int isnick(const char* n);
 const char* cmode(userrec *user, chanrec *chan);
 int cstatus(userrec *user, chanrec *chan);
-std::string chlist(userrec *user, userrec* source);
 int cflags(userrec *user, chanrec *chan);
 
 #endif
index d0ed021a6e68d0a7806ce6b3f9870e040f0cc547..1d8e918aa2b88dd11915a2951b900cad0dc44574 100644 (file)
@@ -646,6 +646,10 @@ class userrec : public connection
 
        void NoticeAll(char* text, ...);
 
+       std::string ChannelList(userrec* source);
+
+       void SplitChanList(userrec* dest, const std::string &cl);
+
        /** Default destructor
         */
        virtual ~userrec();
index 600751585abdd0b0af79efea40b4c5b8f0173bc9..5f980750bc9d3c10c4308b56704ab1b62c291040 100644 (file)
@@ -50,12 +50,12 @@ void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long i
                {
                        user->WriteServ("378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, dest->GetIPString());
                }
-               std::string cl = chlist(dest,user);
+               std::string cl = dest->ChannelList(user);
                if (cl.length())
                {
                        if (cl.length() > 400)
                        {
-                               split_chlist(user,dest,cl);
+                               user->SplitChanList(dest,cl);
                        }
                        else
                        {
index f2a41a59be216a9ae899e0d4858e92e0a9262bf9..6d5941f7e7ea5042eaa1d795e593b552c3c2d0cd 100644 (file)
@@ -183,28 +183,3 @@ int cstatus(userrec *user, chanrec *chan)
        return STATUS_NORMAL;
 }
 
-std::string chlist(userrec *user,userrec* source)
-{
-       std::string list;
-       
-       if (!user || !source)
-               return "";
-       
-       for (std::vector<ucrec*>::const_iterator i = user->chans.begin(); i != user->chans.end(); i++)
-       {
-               ucrec* rec = *i;
-               
-               if(rec->channel && rec->channel->name)
-               {       
-                       /* If the target is the same as the sender, let them see all their channels.
-                        * If the channel is NOT private/secret OR the user shares a common channel
-                        * If the user is an oper, and the <options:operspywhois> option is set.
-                        */
-                       if ((source == user) || (*source->oper && ServerInstance->Config->OperSpyWhois) || (((!rec->channel->modes[CM_PRIVATE]) && (!rec->channel->modes[CM_SECRET])) || (rec->channel->HasUser(source))))
-                       {
-                               list.append(cmode(user, rec->channel)).append(rec->channel->name).append(" ");
-                       }
-               }
-       }
-       return list;
-}
index f697c4670f28c1914416d2456c39a1c293e57095..7dcb86d38a61eb43f775fdc34663561c51f30e56 100644 (file)
@@ -89,7 +89,7 @@ class cmd_check : public command_t
                                user->WriteServ(checkstr + " onport " + ConvToStr(targuser->GetPort()));
                        }
 
-                       chliststr = chlist(targuser, targuser);
+                       chliststr = targuser->ChannelList(targuser);
                        std::stringstream dump(chliststr);
 
                        Srv->DumpText(user,checkstr + " onchans ", dump);
index 35aea8b0f72cad1f91a670723e713a93f5973a4c..4dccb07f0f4a24f5e52b9773cbd6a7a0a96487d4 100644 (file)
@@ -1651,3 +1651,63 @@ void userrec::NoticeAll(char* text, ...)
        }
 }
 
+
+std::string userrec::ChannelList(userrec* source)
+{
+       std::string list;
+       for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
+       {
+               ucrec* rec = *i;
+
+               if(rec->channel && rec->channel->name)
+               {
+                       /* If the target is the same as the sender, let them see all their channels.
+                        * If the channel is NOT private/secret OR the user shares a common channel
+                        * If the user is an oper, and the <options:operspywhois> option is set.
+                        */
+                       if ((source == this) || (*source->oper && ServerInstance->Config->OperSpyWhois) || (((!rec->channel->modes[CM_PRIVATE]) && (!rec->channel->modes[CM_SECRET])) || (rec->channel->HasUser(source))))
+                       {
+                               list.append(cmode(this, rec->channel)).append(rec->channel->name).append(" ");
+                       }
+               }
+       }
+       return list;
+}
+
+void userrec::SplitChanList(userrec* dest, const std::string &cl)
+{
+       std::string line;
+       std::ostringstream prefix;
+       std::string::size_type start, pos, length;
+
+       prefix << ":" << ServerInstance->Config->ServerName << " 319 " << this->nick << " " << dest->nick << " :";
+       line = prefix.str();
+
+       for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
+       {
+               length = (pos == std::string::npos) ? cl.length() : pos;
+
+               if (line.length() + length - start > 510)
+               {
+                       this->Write(line);
+                       line = prefix.str();
+               }
+
+               if(pos == std::string::npos)
+               {
+                       line += cl.substr(start, length - start);
+                       break;
+               }
+               else
+               {
+                       line += cl.substr(start, length - start + 1);
+               }
+       }
+
+       if (line.length())
+       {
+               this->Write(line);
+       }
+}
+
+