diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-04-20 15:48:27 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-04-20 15:48:27 +0000 |
commit | 2db0df5813e46fe5e077e014003acbd10698b913 (patch) | |
tree | 8d18035c30623c3dcd677c2b93fd832e6cb3d09d /src | |
parent | 15228d509a36036af6d8ab1f63f0ccbc0eeb0c3d (diff) |
Added module message passing architecture
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1136 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index ca167bef1..50b9bdbc2 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -305,6 +305,59 @@ Version::Version(int major, int minor, int revision, int build, int flags) : Maj Admin::Admin(std::string name, std::string email, std::string nick) : Name(name), Email(email), Nick(nick) { }; +Request::Request(char* anydata, Module* src, Module* dst) : data(anydata), source(src), dest(dst) { }; + +char* Request::GetData() +{ + return this->data; +} + +Module* Request::GetSource() +{ + return this->source; +} + +Module* Request::GetDest() +{ + return this->dest; +} + +char* Request::Send() +{ + if (this->dest) + { + return dest->OnRequest(this); + } + else + { + return NULL; + } +} + +Event::Event(char* anydata, Module* src, std::string eventid) : data(anydata), source(src), id(eventid) { }; + +char* Event::GetData() +{ + return this->data; +} + +Module* Event::GetSource() +{ + return this->source; +} + +char* Event::Send() +{ + FOREACH_MOD OnEvent(this); + return NULL; +} + +std::string Event::GetEventID() +{ + return this->id; +} + + Module::Module() { } Module::~Module() { } void Module::OnUserConnect(userrec* user) { } @@ -350,6 +403,9 @@ int Module::OnChangeLocalUserHost(userrec* user, std::string newhost) { return 0 int Module::OnChangeLocalUserGECOS(userrec* user, std::string newhost) { return 0; }; int Module::OnLocalTopicChange(userrec* user, chanrec* chan, std::string topic) { return 0; }; int Module::OnMeshToken(char token,string_list params,serverrec* source,serverrec* reply, std::string tcp_host,std::string ipaddr,int port) { return 0; }; +void Module::OnEvent(Event* event) { return; }; +char* Module::OnRequest(Request* request) { return NULL; }; + // server is a wrapper class that provides methods to all of the C-style // exports in the core @@ -762,6 +818,18 @@ bool Server::MeshCheckCommon(userrec* u,std::string servername) else return false; } +Module* Server::FindModule(std::string name) +{ + for (int i = 0; i <= MODCOUNT; i++) + { + if (module_names[i] == name) + { + return modules[i]; + } + } + return NULL; +} + ConfigReader::ConfigReader() { this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out); |