X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_services_account.cpp;h=5ffb48f98bfbe5caefe24e911979d9047e8523b3;hb=fea1a27cb96a114f698eedcf90401b78406108fb;hp=2fceb6780409087636f493fb9b6b8eacdaaf6b7f;hpb=cd767403e9cce6cc0749160fddb9e7c82042d23c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 2fceb6780..5ffb48f98 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -136,12 +136,12 @@ class ModuleServicesAccount : public Module /* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */ virtual void OnWhois(userrec* source, userrec* dest) { - char *account = dest->GetExt("accountname"); + std::string *account; + dest->GetExt("accountname", account); if (account) { - std::string* accountn = (std::string*)account; - WriteServ(source->fd, "330 %s %s %s :is logged in as", source->nick, dest->nick, accountn->c_str()); + source->WriteServ("330 %s %s %s :is logged in as", source->nick, dest->nick, account->c_str()); } } @@ -153,7 +153,8 @@ class ModuleServicesAccount : public Module virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status) { - char *account = user->GetExt("accountname"); + std::string *account; + user->GetExt("accountname", account); if (target_type == TYPE_CHANNEL) { @@ -168,7 +169,7 @@ class ModuleServicesAccount : public Module } // user messaging a +M channel and is not registered - Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need to be identified to a registered account to message this channel"); + user->WriteServ("477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need to be identified to a registered account to message this channel"); return 1; } } @@ -185,7 +186,7 @@ class ModuleServicesAccount : public Module } // user messaging a +R user and is not registered - Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need to be identified to a registered account to message this user"); + user->WriteServ("477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need to be identified to a registered account to message this user"); return 1; } } @@ -199,7 +200,8 @@ class ModuleServicesAccount : public Module virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { - char *account = user->GetExt("accountname"); + std::string *account; + user->GetExt("accountname", account); if (chan) { @@ -213,7 +215,7 @@ class ModuleServicesAccount : public Module return 0; } // joining a +R channel and not identified - Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(chan->name)+" :You need to be identified to a registered account to join this channel"); + user->WriteServ("477 "+std::string(user->nick)+" "+std::string(chan->name)+" :You need to be identified to a registered account to join this channel"); return 1; } } @@ -232,11 +234,10 @@ class ModuleServicesAccount : public Module if (extname == "accountname") { // check if this user has an swhois field to send - char* field = user->GetExt("accountname"); - if (field) + std::string* account; + user->GetExt("accountname", account); + if (account) { - // get our extdata out with a cast - std::string* account = (std::string*)field; // call this function in the linking module, let it format the data how it // sees fit, and send it on its way. We dont need or want to know how. proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*account); @@ -247,10 +248,10 @@ class ModuleServicesAccount : public Module // when a user quits, tidy up their metadata virtual void OnUserQuit(userrec* user, const std::string &message) { - char* field = user->GetExt("accountname"); - if (field) + std::string* account; + user->GetExt("accountname", account); + if (account) { - std::string* account = (std::string*)field; user->Shrink("accountname"); delete account; } @@ -262,10 +263,10 @@ class ModuleServicesAccount : public Module if (target_type == TYPE_USER) { userrec* user = (userrec*)item; - char* field = user->GetExt("accountname"); - if (field) + std::string* account; + user->GetExt("accountname", account); + if (account) { - std::string* account = (std::string*)field; user->Shrink("accountname"); delete account; } @@ -288,10 +289,10 @@ class ModuleServicesAccount : public Module /* logging them out? */ if (extdata == "") { - char* field = dest->GetExt("accountname"); - if (field) + std::string* account; + dest->GetExt("accountname", account); + if (account) { - std::string* account = (std::string*)field; dest->Shrink("accountname"); delete account; } @@ -299,10 +300,11 @@ class ModuleServicesAccount : public Module else { // if they dont already have an accountname field, accept the remote server's - if (!dest->GetExt("accountname")) + std::string* text; + if (!dest->GetExt("accountname", text)) { - std::string* text = new std::string(extdata); - dest->Extend("accountname",(char*)text); + text = new std::string(extdata); + dest->Extend("accountname", text); } } }