summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:52:12 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:52:12 +0000
commitcdf850dcbbd3153bceaed15ee2d3b42f568c9bf3 (patch)
tree090560df0e4be54d6ef2e35f4d39e29547bba717
parentdf0489220c991cfe106c88fbfaa2a14be0682779 (diff)
Add OnChangeIdent and FIDENT support
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11652 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/modules.h9
-rw-r--r--src/modules.cpp1
-rw-r--r--src/modules/m_setident.cpp4
-rw-r--r--src/modules/m_spanningtree/fident.cpp37
-rw-r--r--src/modules/m_spanningtree/main.cpp19
-rw-r--r--src/modules/m_spanningtree/main.h1
-rw-r--r--src/modules/m_spanningtree/treesocket.h3
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
-rw-r--r--src/users.cpp2
9 files changed, 73 insertions, 7 deletions
diff --git a/include/modules.h b/include/modules.h
index ebfa52b36..ce93f4b16 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -428,7 +428,7 @@ enum Implementation
I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnUserList, I_OnPostCommand, I_OnPostJoin,
I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect, I_OnBufferFlushed,
I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
- I_OnHostCycle, I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine,
+ I_OnHostCycle, I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent,
I_END
};
@@ -914,6 +914,13 @@ class CoreExport Module : public Extensible
*/
virtual void OnChangeName(User* user, const std::string &gecos);
+ /** Called whenever a user's IDENT is changed.
+ * This event triggers after the name has been set.
+ * @param user The user who's IDENT is being changed
+ * @param gecos The new IDENT being set on the user
+ */
+ virtual void OnChangeIdent(User* user, const std::string &ident);
+
/** Called whenever an xline is added by a local user.
* This method is triggered after the line is added.
* @param source The sender of the line or NULL for local server
diff --git a/src/modules.cpp b/src/modules.cpp
index bea9cad0f..9632718ee 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -180,6 +180,7 @@ std::string Module::ProtoTranslate(Extensible*) { return "?"; }
void Module::OnWallops(User*, const std::string&) { }
void Module::OnChangeHost(User*, const std::string&) { }
void Module::OnChangeName(User*, const std::string&) { }
+void Module::OnChangeIdent(User*, const std::string&) { }
void Module::OnAddLine(User*, XLine*) { }
void Module::OnDelLine(User*, XLine*) { }
void Module::OnExpireLine(XLine*) { }
diff --git a/src/modules/m_setident.cpp b/src/modules/m_setident.cpp
index 93099fc74..03d5f69f9 100644
--- a/src/modules/m_setident.cpp
+++ b/src/modules/m_setident.cpp
@@ -49,7 +49,7 @@ class CommandSetident : public Command
user->ChangeIdent(parameters[0].c_str());
ServerInstance->SNO->WriteGlobalSno('a', "%s used SETIDENT to change their ident to '%s'", user->nick.c_str(), user->ident.c_str());
- return CMD_SUCCESS;
+ return CMD_LOCALONLY;
}
};
@@ -70,7 +70,7 @@ class ModuleSetIdent : public Module
virtual Version GetVersion()
{
- return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
+ return Version("$Id$", VF_VENDOR, API_VERSION);
}
};
diff --git a/src/modules/m_spanningtree/fident.cpp b/src/modules/m_spanningtree/fident.cpp
new file mode 100644
index 000000000..0744d9bf2
--- /dev/null
+++ b/src/modules/m_spanningtree/fident.cpp
@@ -0,0 +1,37 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "xline.h"
+
+#include "treesocket.h"
+#include "treeserver.h"
+#include "utils.h"
+
+/* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
+
+
+bool TreeSocket::ChangeIdent(const std::string &prefix, parameterlist &params)
+{
+ if (params.size() < 1)
+ return true;
+ User* u = this->ServerInstance->FindNick(prefix);
+ if (u)
+ {
+ u->ChangeIdent(params[0].c_str());
+ params[0] = ":" + params[0];
+ Utils->DoOneToAllButSender(prefix,"FIDENT",params,u->server);
+ }
+ return true;
+}
+
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index ed0165c0e..b533f5484 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -49,10 +49,10 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
{
I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostLocalTopicChange,
I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin,
- I_OnChangeLocalUserHost, I_OnChangeName, I_OnUserPart, I_OnUnloadModule, I_OnUserQuit,
- I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash, I_OnOper,
- I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, I_OnEvent, I_OnSetAway,
- I_OnPostCommand, I_OnUserConnect
+ I_OnChangeLocalUserHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule,
+ I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash,
+ I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, I_OnEvent,
+ I_OnSetAway, I_OnPostCommand, I_OnUserConnect
};
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
@@ -637,6 +637,17 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos)
Utils->DoOneToMany(user->uuid,"FNAME",params);
}
+void ModuleSpanningTree::OnChangeIdent(User* user, const std::string &ident)
+{
+ // only occurs for local clients
+ if (user->registered != REG_ALL)
+ return;
+
+ parameterlist params;
+ params.push_back(ident);
+ Utils->DoOneToMany(user->uuid,"FIDENT",params);
+}
+
void ModuleSpanningTree::OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
{
if (IS_LOCAL(user))
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index a9cba73af..06b66a5cf 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -170,6 +170,7 @@ class ModuleSpanningTree : public Module
virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created);
virtual ModResult OnChangeLocalUserHost(User* user, const std::string &newhost);
virtual void OnChangeName(User* user, const std::string &gecos);
+ virtual void OnChangeIdent(User* user, const std::string &ident);
virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
virtual void OnUserPostNick(User* user, const std::string &oldnick);
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 1350950eb..77934bc07 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -344,6 +344,9 @@ class TreeSocket : public BufferedSocket
*/
bool ChangeName(const std::string &prefix, parameterlist &params);
+ /** FIDENT */
+ bool ChangeIdent(const std::string &prefix, parameterlist &params);
+
/** WHOIS
*/
bool Whois(const std::string &prefix, parameterlist &params);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 79ab791d3..b5482e42e 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -407,6 +407,10 @@ bool TreeSocket::ProcessLine(std::string &line)
{
return this->ChangeName(prefix,params);
}
+ else if (command == "FIDENT")
+ {
+ return this->ChangeIdent(prefix,params);
+ }
else if (command == "ADDLINE")
{
return this->AddLine(prefix,params);
diff --git a/src/users.cpp b/src/users.cpp
index 8f67278e8..192b4aace 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1631,6 +1631,8 @@ bool User::ChangeIdent(const char* newident)
if (this->ident == newident)
return true;
+ FOREACH_MOD(I_OnChangeIdent, OnChangeIdent(this,newident));
+
std::string quitstr = ":" + GetFullHost() + " QUIT :Changing ident";
this->ident.assign(newident, 0, ServerInstance->Config->Limits.IdentMax + 1);