/** send all users and their oper state/modes */ void TreeSocket::SendUsers(BurstState& bs) { ProtocolInterface::Server& piserver = bs.server; for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { User* user = u->second; if (user->registered != REG_ALL) continue; this->WriteLine(CommandUID::Builder(user)); if (user->IsOper()) this->WriteLine(CommandOpertype::Builder(user)); if (user->IsAway()) this->WriteLine(CommandAway::Builder(user)); const Extensible::ExtensibleStore& exts = user->GetExtList(); for (Extensible::ExtensibleStore::const_iterator i = exts.begin(); i != exts.end(); ++i) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, u->second, i->second); if (!value.empty()) this->WriteLine(CommandMetadata::Builder(user, item->name, value)); } FOREACH_MOD(OnSyncUser, (user, piserver)); } }
void DumpMeta(std::stringstream& data, Extensible* ext) { data << "<metadata>"; for(Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); if (!value.empty()) data << "<meta name=\"" << item->name << "\">" << Sanitize(value) << "</meta>"; else if (!item->name.empty()) data << "<meta name=\"" << item->name << "\"/>"; } data << "</metadata>"; }
void dumpExt(User* user, const std::string& checkstr, Extensible* ext) { std::stringstream dumpkeys; for(Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); if (!value.empty()) user->SendText(checkstr + " meta:" + item->name + " " + value); else if (!item->name.empty()) dumpkeys << " " << item->name; } if (!dumpkeys.str().empty()) user->SendText(checkstr + " metadata", dumpkeys); }
/** send all users and their oper state/modes */ void TreeSocket::SendUsers() { char data[MAXBUF]; std::string dataline; for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { if (u->second->registered == REG_ALL) { TreeServer* theirserver = Utils->FindServer(u->second->server); if (theirserver) { snprintf(data,MAXBUF,":%s UID %s %lu %s %s %s %s %s %lu +%s :%s", theirserver->GetID().c_str(), /* Prefix: SID */ u->second->uuid.c_str(), /* 0: UUID */ (unsigned long)u->second->age, /* 1: TS */ u->second->nick.c_str(), /* 2: Nick */ u->second->host.c_str(), /* 3: Displayed Host */ u->second->dhost.c_str(), /* 4: Real host */ u->second->ident.c_str(), /* 5: Ident */ u->second->GetIPString().c_str(), /* 6: IP string */ (unsigned long)u->second->signon, /* 7: Signon time for WHOWAS */ u->second->FormatModes(true), /* 8...n: Modes and params */ u->second->fullname.c_str()); /* size-1: GECOS */ this->WriteLine(data); if (u->second->IsOper()) { snprintf(data,MAXBUF,":%s OPERTYPE %s", u->second->uuid.c_str(), u->second->oper->name.c_str()); this->WriteLine(data); } if (u->second->IsAway()) { snprintf(data,MAXBUF,":%s AWAY %ld :%s", u->second->uuid.c_str(), (long)u->second->awaytime, u->second->awaymsg.c_str()); this->WriteLine(data); } } for(Extensible::ExtensibleStore::const_iterator i = u->second->GetExtList().begin(); i != u->second->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, u->second, i->second); if (!value.empty()) Utils->Creator->ProtoSendMetaData(this, u->second, item->name, value); } FOREACH_MOD(I_OnSyncUser,OnSyncUser(u->second,Utils->Creator,this)); } } }
void ModuleSpanningTree::OnUserConnect(LocalUser* user) { if (user->quitting) return; CommandUID::Builder(user).Broadcast(); if (user->IsOper()) CommandOpertype::Builder(user).Broadcast(); 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->UserCount++; }
/** Send channel topic, modes and metadata */ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) { SendFJoins(chan); // If the topic was ever set, send it, even if it's empty now // because a new empty topic should override an old non-empty topic if (chan->topicset != 0) this->WriteLine(CommandFTopic::Builder(chan)); SendListModes(chan); for (Extensible::ExtensibleStore::const_iterator i = chan->GetExtList().begin(); i != chan->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, chan, i->second); if (!value.empty()) this->WriteLine(CommandMetadata::Builder(chan, item->name, value)); } FOREACH_MOD(OnSyncChannel, (chan, bs.server)); }
/** Send channel topic, modes and metadata */ void TreeSocket::SyncChannel(Channel* chan) { char data[MAXBUF]; SendFJoins(chan); // If the topic was ever set, send it, even if it's empty now // because a new empty topic should override an old non-empty topic if (chan->topicset != 0) { snprintf(data,MAXBUF,":%s FTOPIC %s %lu %lu %s :%s", ServerInstance->Config->GetSID().c_str(), chan->name.c_str(), (unsigned long) chan->age, (unsigned long)chan->topicset, chan->setby.c_str(), chan->topic.c_str()); this->WriteLine(data); } for (Extensible::ExtensibleStore::const_iterator i = chan->GetExtList().begin(); i != chan->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, chan, i->second); if (!value.empty()) Utils->Creator->ProtoSendMetaData(this, chan, item->name, value); } FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(chan, Utils->Creator, this)); }