summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-11-30 22:00:34 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-11-30 22:00:34 +0000
commite1a92daeb657da58dcfcc2f1256193cb72295635 (patch)
treea93211dba5725729e5a442b0061d2d20aee602c8
parent1b6bcd432ac77865e14a8046f0a4b29eeaa2bcd8 (diff)
Added opaque protocol functions
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2069 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd.h1
-rw-r--r--include/modules.h6
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/m_spanningtree.cpp35
4 files changed, 45 insertions, 1 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index b3e05b651..9bf0b8878 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -65,6 +65,7 @@
#define TYPE_USER 1
#define TYPE_CHANNEL 2
+#define TYPE_SERVER 3
typedef std::deque<std::string> file_cache;
diff --git a/include/modules.h b/include/modules.h
index dd141ae61..008604d9f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -427,6 +427,12 @@ class Module : public classbase
virtual void OnMode(userrec* user, void* dest, int target_type, std::string text);
virtual void OnGetServerDescription(std::string servername,std::string &description);
+
+ virtual void OnSyncUser(userrec* user, Module* proto, void* opaque);
+
+ virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque);
+
+ virtual void ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline);
virtual int OnUserPreNick(userrec* user, std::string newnick);
diff --git a/src/modules.cpp b/src/modules.cpp
index 0541c266d..8a5fa052a 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -366,6 +366,10 @@ void Module::OnRemoteKill(userrec* source, userrec* dest, std::string reason)
void Module::OnUserInvite(userrec* source,userrec* dest,chanrec* channel) { };
void Module::OnPostLocalTopicChange(userrec* user, chanrec* chan, std::string topic) { };
void Module::OnGetServerDescription(std::string servername,std::string &description) { };
+void Module::OnSyncUser(userrec* user, Module* proto, void* opaque) { };
+void Module::OnSyncChannel(chanrec* chan, Module* proto, void* opaque) { };
+void Module::ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline) { };
+
// server is a wrapper class that provides methods to all of the C-style
// exports in the core
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 124ae0be7..35a0d77e4 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -42,6 +42,8 @@ using namespace std;
#define nspace std
#endif
+static Module* TreeProtocolModule;
+
enum ServerState { LISTENER, CONNECTING, WAIT_AUTH_1, WAIT_AUTH_2, CONNECTED };
typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
@@ -604,6 +606,7 @@ class TreeSocket : public InspSocket
snprintf(data,MAXBUF,":%s FMODE %s +b %s",Srv->GetServerName().c_str(),c->second->name,b->data);
this->WriteLine(data);
}
+ FOREACH_MOD OnSyncChannel(c->second,TreeProtocolModule,this);
}
}
@@ -626,6 +629,7 @@ class TreeSocket : public InspSocket
{
this->WriteLine(":"+std::string(u->second->nick)+" FJOIN "+std::string(chl));
}
+ FOREACH_MOD OnSyncUser(u->second,TreeProtocolModule,this);
}
}
}
@@ -1051,6 +1055,16 @@ class TreeSocket : public InspSocket
return true;
}
+ virtual std::string GetName()
+ {
+ std::string sourceserv = this->myhost;
+ if (this->InboundServerName != "")
+ {
+ sourceserv = this->InboundServerName;
+ }
+ return sourceserv;
+ }
+
virtual void OnTimeout()
{
if (this->LinkState == CONNECTING)
@@ -1621,6 +1635,24 @@ class ModuleSpanningTree : public Module
}
}
+ virtual void ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline);
+ {
+ TreeSocket* s = (TreeSocket*)opaque;
+ if (target)
+ {
+ if (target_type == TYPE_USER)
+ {
+ userrec* u = (userrec*)target;
+ opaque->WriteLine(":"+opaque->GetName()+" FMODE "+u->nick+" "+modeline);
+ }
+ else (target_type == TYPE_CHANNEL)
+ {
+ chanrec* c = (chanrec*)target;
+ opaque->WriteLine(":"+opaque->GetName()+" FMODE "+c->name+" "+modeline);
+ }
+ }
+ }
+
virtual ~ModuleSpanningTree()
{
delete Srv;
@@ -1654,6 +1686,7 @@ class ModuleSpanningTreeFactory : public ModuleFactory
extern "C" void * init_module( void )
{
- return new ModuleSpanningTreeFactory;
+ TreeProtocolModule = new ModuleSpanningTreeFactory;
+ return TreeProtocolModule;
}