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_OnPostCommand, I_OnUserConnect
};
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
ServerInstance->PI = new SpanningTreeProtocolInterface(this, Utils, ServerInstance);
loopCall = false;
- for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
- {
- ServerInstance->PI->Introduce(*i);
- }
+ // update our local user count
+ Utils->TreeRoot->SetUserCount(ServerInstance->Users->local_users.size());
}
void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
DoConnectTimeout(curtime);
}
+void ModuleSpanningTree::OnUserConnect(User* user)
+{
+ if (user->quitting)
+ return;
+
+ parameterlist params;
+ params.push_back(user->uuid);
+ params.push_back(ConvToStr(user->age));
+ params.push_back(user->nick);
+ params.push_back(user->host);
+ params.push_back(user->dhost);
+ params.push_back(user->ident);
+ params.push_back(user->GetIPString());
+ params.push_back(ConvToStr(user->signon));
+ params.push_back("+"+std::string(user->FormatModes(true)));
+ params.push_back(":"+std::string(user->fullname));
+ Utils->DoOneToMany(ServerInstance->Config->GetSID(), "UID", params);
+
+ Utils->TreeRoot->SetUserCount(1); // increment by 1
+}
+
void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created)
{
// Only do this for local users
}
}
-void ModuleSpanningTree::ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata)
+void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata)
{
- TreeSocket* s = (TreeSocket*)opaque;
- if (target)
- {
- if (target_type == TYPE_USER)
- {
- User* u = (User*)target;
- s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata);
- }
- else if (target_type == TYPE_CHANNEL)
- {
- Channel* c = (Channel*)target;
- s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+extname+" :"+extdata);
- }
- }
- if (target_type == TYPE_OTHER)
- {
+ TreeSocket* s = static_cast<TreeSocket*>(opaque);
+ User* u = dynamic_cast<User*>(target);
+ Channel* c = dynamic_cast<Channel*>(target);
+ if (u)
+ s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata);
+ else if (c)
+ s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+extname+" :"+extdata);
+ else if (!target)
s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata);
- }
+}
+
+std::string ModuleSpanningTree::ProtoTranslate(Extensible* item)
+{
+ User* u = dynamic_cast<User*>(item);
+ Channel* c = dynamic_cast<Channel*>(item);
+ if (u)
+ return u->uuid;
+ if (c)
+ return c->name;
+ return "*";
}
void ModuleSpanningTree::OnEvent(Event* event)