]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Change more modules to VF_OPTCOMMON and assert identical charsets in m_nationalchars
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index 62404935777766db0b9235a3b79be62519146e04..4961d724bd3336e5feab76775dd3d431c9def4a0 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
 #include "treeserver.h"
 #include "link.h"
 #include "treesocket.h"
-#include "rconnect.h"
-#include "rsquit.h"
+#include "commands.h"
 #include "protocolinterface.h"
 
-/* $ModDep: m_spanningtree/cachetimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h m_spanningtree/protocolinterface.h */
-
 ModuleSpanningTree::ModuleSpanningTree()
-       : max_local(0), max_global(0)
 {
-       ServerInstance->Modules->UseInterface("BufferedSocketHook");
        Utils = new SpanningTreeUtilities(this);
        command_rconnect = new CommandRConnect(this, Utils);
-       ServerInstance->AddCommand(command_rconnect);
        command_rsquit = new CommandRSQuit(this, Utils);
-       ServerInstance->AddCommand(command_rsquit);
+       command_svsjoin = new CommandSVSJoin(this);
+       command_svspart = new CommandSVSPart(this);
+       command_svsnick = new CommandSVSNick(this);
        RefreshTimer = new CacheRefreshTimer(Utils);
+       ServerInstance->AddCommand(command_rconnect);
+       ServerInstance->AddCommand(command_rsquit);
+       ServerInstance->AddCommand(command_svsjoin);
+       ServerInstance->AddCommand(command_svspart);
+       ServerInstance->AddCommand(command_svsnick);
        ServerInstance->Timers->AddTimer(RefreshTimer);
 
        Implementation eventlist[] =
@@ -95,11 +96,6 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
                        Current->GetDesc().c_str());
 }
 
-int ModuleSpanningTree::CountLocalServs()
-{
-       return Utils->TreeRoot->ChildCount();
-}
-
 int ModuleSpanningTree::CountServs()
 {
        return Utils->serverlist.size();
@@ -112,54 +108,6 @@ void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters,
        return;
 }
 
-void ModuleSpanningTree::HandleLusers(const std::vector<std::string>& parameters, User* user)
-{
-       unsigned int n_users = ServerInstance->Users->UserCount();
-
-       /* Only update these when someone wants to see them, more efficient */
-       if ((unsigned int)ServerInstance->Users->LocalUserCount() > max_local)
-               max_local = ServerInstance->Users->LocalUserCount();
-       if (n_users > max_global)
-               max_global = n_users;
-
-       unsigned int ulined_count = 0;
-       unsigned int ulined_local_count = 0;
-
-       /* If ulined are hidden and we're not an oper, count the number of ulined servers hidden,
-        * locally and globally (locally means directly connected to us)
-        */
-       if ((Utils->HideULines) && (!IS_OPER(user)))
-       {
-               for (server_hash::iterator q = Utils->serverlist.begin(); q != Utils->serverlist.end(); q++)
-               {
-                       if (ServerInstance->ULine(q->second->GetName().c_str()))
-                       {
-                               ulined_count++;
-                               if (q->second->GetParent() == Utils->TreeRoot)
-                                       ulined_local_count++;
-                       }
-               }
-       }
-       user->WriteNumeric(251, "%s :There are %d users and %d invisible on %d servers",user->nick.c_str(),
-                       n_users-ServerInstance->Users->ModeCount('i'),
-                       ServerInstance->Users->ModeCount('i'),
-                       ulined_count ? this->CountServs() - ulined_count : this->CountServs());
-
-       if (ServerInstance->Users->OperCount())
-               user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount());
-
-       if (ServerInstance->Users->UnregisteredUserCount())
-               user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount());
-
-       if (ServerInstance->ChannelCount())
-               user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount());
-
-       user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
-       user->WriteNumeric(265, "%s :Current Local Users: %d  Max: %d",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),max_local);
-       user->WriteNumeric(266, "%s :Current Global Users: %d  Max: %d",user->nick.c_str(),n_users,max_global);
-       return;
-}
-
 std::string ModuleSpanningTree::TimeToStr(time_t secs)
 {
        time_t mins_up = secs / 60;
@@ -490,7 +438,7 @@ void ModuleSpanningTree::OnUserNotice(User* user, void* dest, int target_type, c
        if (target_type == TYPE_USER)
        {
                User* d = (User*)dest;
-               if ((d->GetFd() < 0) && (IS_LOCAL(user)))
+               if (!IS_LOCAL(d) && IS_LOCAL(user))
                {
                        parameterlist params;
                        params.push_back(d->uuid);
@@ -543,7 +491,7 @@ void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type,
                // route private messages which are targetted at clients only to the server
                // which needs to receive them
                User* d = (User*)dest;
-               if ((d->GetFd() < 0) && (IS_LOCAL(user)))
+               if (!IS_LOCAL(d) && (IS_LOCAL(user)))
                {
                        parameterlist params;
                        params.push_back(d->uuid);
@@ -610,6 +558,14 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user)
        params.push_back(":"+std::string(user->fullname));
        Utils->DoOneToMany(ServerInstance->Config->GetSID(), "UID", params);
 
+       for(Extensible::ExtensibleStore::const_iterator i = user->GetExtList().begin(); i != user->GetExtList().end(); i++)
+       {
+               ExtensionItem* item = i->first;
+               std::string value = item->serialize(FORMAT_NETWORK, user, i->second);
+               if (!value.empty())
+                       ServerInstance->PI->SendMetaData(user, item->name, value);
+       }
+
        Utils->TreeRoot->SetUserCount(1); // increment by 1
 }
 
@@ -731,7 +687,7 @@ void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::s
        {
                Utils->DoOneToMany(source->uuid,"KICK",params);
        }
-       else if (IS_SERVER(source) && source != Utils->ServerUser)
+       else if (source == ServerInstance->FakeClient)
        {
                Utils->DoOneToMany(ServerInstance->Config->GetSID(),"KICK",params);
        }
@@ -773,30 +729,16 @@ void ModuleSpanningTree::OnRehash(User* user)
 
 void ModuleSpanningTree::OnLoadModule(Module* mod)
 {
-       this->RedoConfig(mod);
+       // TODO notify other servers?
 }
 
 void ModuleSpanningTree::OnUnloadModule(Module* mod)
 {
-       this->RedoConfig(mod);
+       // TODO notify other servers?
 }
 
 void ModuleSpanningTree::RedoConfig(Module* mod)
 {
-       /* If m_sha256.so is loaded (we use this for HMAC) or any module implementing a BufferedSocket interface is loaded,
-        * then we need to re-read our config again taking this into account.
-        */
-       modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
-       bool IsBufferSocketModule = false;
-
-       /* Did we find any modules? */
-       if (ml && std::find(ml->begin(), ml->end(), mod) != ml->end())
-               IsBufferSocketModule = true;
-
-       if (mod->ModuleSourceFile == "m_sha256.so" || IsBufferSocketModule)
-       {
-               Utils->ReadConfiguration();
-       }
 }
 
 // note: the protocol does not allow direct umode +o except
@@ -947,7 +889,6 @@ CullResult ModuleSpanningTree::cull()
 {
        Utils->cull();
        ServerInstance->Timers->DelTimer(RefreshTimer);
-       ServerInstance->Modules->DoneWithInterface("BufferedSocketHook");
        return this->Module::cull();
 }
 
@@ -961,6 +902,9 @@ ModuleSpanningTree::~ModuleSpanningTree()
 
        delete command_rconnect;
        delete command_rsquit;
+       delete command_svsjoin;
+       delete command_svspart;
+       delete command_svsnick;
 }
 
 Version ModuleSpanningTree::GetVersion()