]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
namespace fix0rz
[user/henk/code/inspircd.git] / src / users.cpp
index adf32b752771cad620ce71cb1450edd79b6885d9..01a973deae90a7b444736f0572cdc25b78377a8b 100644 (file)
@@ -99,6 +99,7 @@ void User::StartDNSLookup()
        {
                bool cached = false;
                const char* sip = this->GetIPString(false);
+               UserResolver *res_reverse;
 
                /* Special case for 4in6 (Have i mentioned i HATE 4in6?) */
                if (!strncmp(sip, "0::ffff:", 8))
@@ -157,16 +158,28 @@ void User::SetMode(unsigned char m, bool value)
        modes[m-65] = value;
 }
 
-const char* User::FormatModes()
+const char* User::FormatModes(bool showparameters)
 {
        static char data[MAXBUF];
+       std::string params;
        int offset = 0;
-       for (int n = 0; n < 64; n++)
+
+       for (unsigned char n = 0; n < 64; n++)
        {
                if (modes[n])
-                       data[offset++] = n+65;
+               {
+                       data[offset++] = n + 65;
+                       ModeHandler* mh = ServerInstance->Modes->FindMode(n + 65, MODETYPE_USER);
+                       if (showparameters && mh && mh->GetNumParams(true))
+                       {
+                               std::string p = mh->GetUserParameter(this);
+                               if (p.length())
+                                       params.append(" ").append(p);
+                       }
+               }
        }
        data[offset] = 0;
+       strlcat(data, params.c_str(), MAXBUF);
        return data;
 }
 
@@ -200,11 +213,9 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
        fd = -1;
        recvq.clear();
        sendq.clear();
-       res_forward = res_reverse = NULL;
        Visibility = NULL;
        ip = NULL;
        MyClass = NULL;
-       io = NULL;
        AllowedUserModes = NULL;
        AllowedChanModes = NULL;
        AllowedOperCommands = NULL;
@@ -784,6 +795,13 @@ void User::UnOper()
 {
        if (IS_OPER(this))
        {
+               /*
+                * unset their oper type (what IS_OPER checks).
+                * note, order is important - this must come before modes as -o attempts
+                * to call UnOper. -- w00t
+                */
+               this->oper.clear();
+
                /* Remove all oper only modes from the user when the deoper - Bug #466*/
                std::string moderemove("-");
 
@@ -799,9 +817,6 @@ void User::UnOper()
                parameters.push_back(moderemove);
 
                ServerInstance->Parser->CallHandler("MODE", parameters, this);
-
-               /* unset their oper type (what IS_OPER checks), and remove +o */
-               this->oper.clear();
                        
                /* remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 */
                ServerInstance->Users->all_opers.remove(this);
@@ -1264,14 +1279,14 @@ void User::Write(std::string text)
                return;
        }
 
-       if (this->io)
+       if (this->GetIOHook())
        {
                /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
                 * implement their own buffering mechanisms
                 */
                try
                {
-                       this->io->OnRawSocketWrite(this->fd, text.data(), text.length());
+                       this->GetIOHook()->OnRawSocketWrite(this->fd, text.data(), text.length());
                }
                catch (CoreException& modexcept)
                {