diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-01-05 15:20:17 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-01-05 15:20:17 +0100 |
commit | 9136136ac373a922cd0875f77d3212a419fb9100 (patch) | |
tree | 385afcb56e62de5a39bed1d7bf6d5311cc001df9 | |
parent | 11916574f67962dce1d7a2fdf7ef6a3d2d1fa49f (diff) |
Move server description field from TreeServer into Server; remove OnGetServerDescription hook
-rw-r--r-- | include/inspircd.h | 9 | ||||
-rw-r--r-- | include/modules.h | 12 | ||||
-rw-r--r-- | include/server.h | 13 | ||||
-rw-r--r-- | include/users.h | 4 | ||||
-rw-r--r-- | src/commands/cmd_whois.cpp | 3 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 17 | ||||
-rw-r--r-- | src/inspircd.cpp | 2 | ||||
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 5 |
12 files changed, 21 insertions, 70 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index a2815b8a5..d69d1b46b 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -446,15 +446,6 @@ class CoreExport InspIRCd */ bool BindSocket(int sockfd, int port, const char* addr, bool dolisten = true); - /** Gets the GECOS (description) field of the given server. - * If the servername is not that of the local server, the name - * is passed to handling modules which will attempt to determine - * the GECOS that bleongs to the given servername. - * @param servername The servername to find the description of - * @return The description of this server, or of the local server - */ - std::string GetServerDescription(const std::string& servername); - /** Find a user in the nick hash. * If the user cant be found in the nick hash check the uuid hash * @param nick The nickname to find diff --git a/include/modules.h b/include/modules.h index 7ceb9f631..0be1ea294 100644 --- a/include/modules.h +++ b/include/modules.h @@ -253,7 +253,7 @@ enum Implementation I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick, - I_OnUserMessage, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, + I_OnUserMessage, I_OnMode, I_OnSyncUser, I_OnSyncChannel, I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit, I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule, @@ -611,16 +611,6 @@ class CoreExport Module : public classbase, public usecountbase */ virtual void OnMode(User* user, User* usertarget, Channel* chantarget, const std::vector<std::string>& modes, const std::vector<TranslateType>& translate); - /** Allows modules to alter or create server descriptions - * Whenever a module requires a server description, for example for display in - * WHOIS, this function is called in all modules. You may change or define the - * description given in std::string &description. If you do, this description - * will be shown in the WHOIS fields. - * @param servername The servername being searched for - * @param description Alterable server description for this server - */ - virtual void OnGetServerDescription(const std::string &servername,std::string &description); - /** Allows modules to synchronize data which relates to users during a netburst. * When this function is called, it will be called from the module which implements * the linking protocol. This currently is m_spanningtree.so. diff --git a/include/server.h b/include/server.h index e6e96593d..3d8854734 100644 --- a/include/server.h +++ b/include/server.h @@ -26,6 +26,10 @@ class CoreExport Server : public classbase */ const std::string name; + /** The description of this server + */ + const std::string description; + /** True if this server is ulined */ bool uline; @@ -35,8 +39,8 @@ class CoreExport Server : public classbase bool silentuline; public: - Server(const std::string& srvname) - : name(srvname), uline(false), silentuline(false) { } + Server(const std::string& srvname, const std::string& srvdesc) + : name(srvname), description(srvdesc), uline(false), silentuline(false) { } /** * Returns the name of this server @@ -44,6 +48,11 @@ class CoreExport Server : public classbase */ const std::string& GetName() const { return name; } + /** Returns the description (GECOS) of this server + * @return The description of this server + */ + const std::string& GetDesc() const { return description; } + /** * Checks whether this server is ulined * @return True if this server is ulined, false otherwise. diff --git a/include/users.h b/include/users.h index bf4ba4de2..f8bfb5a6e 100644 --- a/include/users.h +++ b/include/users.h @@ -832,8 +832,8 @@ class CoreExport FakeUser : public User nick = srv->GetName(); } - FakeUser(const std::string& uid, const std::string& sname) - : User(uid, new Server(sname), USERTYPE_SERVER) + FakeUser(const std::string& uid, const std::string& sname, const std::string& sdesc) + : User(uid, new Server(sname, sdesc), USERTYPE_SERVER) { nick = sname; } diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index fdc2ad045..7e67676ed 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -144,8 +144,7 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne } else { - std::string serverdesc = ServerInstance->GetServerDescription(dest->server->GetName()); - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s :%s", dest->nick.c_str(), dest->server->GetName().c_str(), serverdesc.c_str()); + ServerInstance->SendWhoisLine(user, dest, 312, "%s %s :%s", dest->nick.c_str(), dest->server->GetName().c_str(), dest->server->GetDesc().c_str()); } if (dest->IsAway()) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 655bf9ae4..6a831bb04 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -32,23 +32,6 @@ #include "exitcodes.h" #include <iostream> -std::string InspIRCd::GetServerDescription(const std::string& servername) -{ - std::string description; - - FOREACH_MOD(OnGetServerDescription, (servername,description)); - - if (!description.empty()) - { - return description; - } - else - { - // not a remote server that can be found, it must be me. - return Config->ServerDesc; - } -} - /* Find a user record by nickname and return a pointer to it */ User* InspIRCd::FindNick(const std::string &nick) { diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 50feab459..75e9f3699 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -460,7 +460,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : this->UIDGen.init(Config->sid); // Create the server user for this server - this->FakeClient = new FakeUser(Config->sid, Config->ServerName); + this->FakeClient = new FakeUser(Config->sid, Config->ServerName, Config->ServerDesc); // This is needed as all new XLines are marked pending until ApplyLines() is called this->XLines->ApplyLines(); diff --git a/src/modules.cpp b/src/modules.cpp index 2157d1948..5c5e4febc 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -132,7 +132,6 @@ void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); } void Module::OnUserInvite(User*, User*, Channel*, time_t) { DetachEvent(I_OnUserInvite); } void Module::OnPostTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPostTopicChange); } -void Module::OnGetServerDescription(const std::string&, std::string&) { DetachEvent(I_OnGetServerDescription); } void Module::OnSyncUser(User*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncUser); } void Module::OnSyncChannel(Channel*, ProtocolInterface::Server&) { DetachEvent(I_OnSyncChannel); } void Module::OnSyncNetwork(ProtocolInterface::Server&) { DetachEvent(I_OnSyncNetwork); } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 3efd012ba..9a7cddec3 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -408,15 +408,6 @@ void ModuleSpanningTree::On005Numeric(std::map<std::string, std::string>& tokens tokens["MAP"]; } -void ModuleSpanningTree::OnGetServerDescription(const std::string &servername,std::string &description) -{ - TreeServer* s = Utils->FindServer(servername); - if (s) - { - description = s->GetDesc(); - } -} - void ModuleSpanningTree::OnUserInvite(User* source,User* dest,Channel* channel, time_t expiry) { if (IS_LOCAL(source)) @@ -754,7 +745,7 @@ ModuleSpanningTree::~ModuleSpanningTree() delete ServerInstance->PI; ServerInstance->PI = new ProtocolInterface; - Server* newsrv = new Server(ServerInstance->Config->ServerName); + Server* newsrv = new Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); SetLocalUsersServer(newsrv); /* This will also free the listeners */ diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index bef94a53b..513e86a2f 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -140,7 +140,6 @@ class ModuleSpanningTree : public Module ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE; void OnPostCommand(Command*, const std::vector<std::string>& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE; - void OnGetServerDescription(const std::string &servername,std::string &description) CXX11_OVERRIDE; void OnUserConnect(LocalUser* source) CXX11_OVERRIDE; void OnUserInvite(User* source,User* dest,Channel* channel, time_t) CXX11_OVERRIDE; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE; diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 34b71e07f..ecde17261 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -33,8 +33,8 @@ * no socket associated with it. Its version string is our own local version. */ TreeServer::TreeServer() - : Server(ServerInstance->Config->ServerName) - , Parent(NULL), Route(NULL), ServerDesc(ServerInstance->Config->ServerDesc) + : Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc) + , Parent(NULL), Route(NULL) , VersionString(ServerInstance->GetVersionString()), Socket(NULL), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient) , age(ServerInstance->Time()), Warned(false), bursting(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(false) { @@ -46,8 +46,8 @@ TreeServer::TreeServer() * its ping counters so that it will be pinged one minute from now. */ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide) - : Server(Name) - , Parent(Above), ServerDesc(Desc), Socket(Sock), sid(id), ServerUser(new FakeUser(id, this)) + : Server(Name, Desc) + , Parent(Above), Socket(Sock), sid(id), ServerUser(new FakeUser(id, this)) , age(ServerInstance->Time()), Warned(false), bursting(true), UserCount(0), OperCount(0), rtt(0), Hidden(Hide) { CheckULine(); @@ -186,11 +186,6 @@ TreeServer* TreeServer::GetRoute() return Route; } -const std::string& TreeServer::GetDesc() -{ - return ServerDesc; -} - const std::string& TreeServer::GetVersion() { return VersionString; diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 67ce96e63..ab47012b0 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -42,7 +42,6 @@ class TreeServer : public Server TreeServer* Parent; /* Parent entry */ TreeServer* Route; /* Route entry */ std::vector<TreeServer*> Children; /* List of child objects */ - std::string ServerDesc; /* Server's description */ std::string VersionString; /* Version string or empty string */ TreeSocket* Socket; /* Socket used to communicate with this server */ time_t NextPing; /* After this time, the server should be PINGed*/ @@ -93,10 +92,6 @@ class TreeServer : public Server */ bool IsLocal() const { return (this->Route == this); } - /** Get server description (GECOS) - */ - const std::string& GetDesc(); - /** Get server version string */ const std::string& GetVersion(); |