本文整理汇总了C++中CUser::FindNetwork方法的典型用法代码示例。如果您正苦于以下问题:C++ CUser::FindNetwork方法的具体用法?C++ CUser::FindNetwork怎么用?C++ CUser::FindNetwork使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::FindNetwork方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SafeGetNetworkFromParam
CIRCNetwork* SafeGetNetworkFromParam(CWebSock& WebSock) {
CUser* pUser = CZNC::Get().FindUser(SafeGetUserNameParam(WebSock));
CIRCNetwork* pNetwork = NULL;
if (pUser) {
pNetwork = pUser->FindNetwork(SafeGetNetworkParam(WebSock));
}
return pNetwork;
}
示例2: OnWebRequest
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
if (sPageName == "index") {
if (WebSock.IsPost()) {
CUser *pUser = CZNC::Get().FindUser(WebSock.GetParam("user").Token(0, false, "/"));
if (!pUser) {
WebSock.GetSession()->AddError("User not found");
return true;
}
CIRCNetwork *pNetwork = pUser->FindNetwork(WebSock.GetParam("user").Token(1, false, "/"));
if (!pNetwork) {
WebSock.GetSession()->AddError("Network not found");
return true;
}
bool bToServer = WebSock.GetParam("send_to") == "server";
const CString sLine = WebSock.GetParam("line");
Tmpl["user"] = pUser->GetUserName();
Tmpl[bToServer ? "to_server" : "to_client"] = "true";
Tmpl["line"] = sLine;
if (bToServer) {
pNetwork->PutIRC(sLine);
} else {
pNetwork->PutUser(sLine);
}
WebSock.GetSession()->AddSuccess("Line sent");
}
const map<CString,CUser*>& msUsers = CZNC::Get().GetUserMap();
for (map<CString,CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); ++it) {
CTemplate& l = Tmpl.AddRow("UserLoop");
l["Username"] = (*it->second).GetUserName();
vector<CIRCNetwork*> vNetworks = (*it->second).GetNetworks();
for (vector<CIRCNetwork*>::const_iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) {
CTemplate& NetworkLoop = l.AddRow("NetworkLoop");
NetworkLoop["Username"] = (*it->second).GetUserName();
NetworkLoop["Network"] = (*it2)->GetName();
}
}
return true;
}
return false;
}
示例3: SendServer
void SendServer(const CString& sLine) {
CUser *pUser = CZNC::Get().FindUser(sLine.Token(1));
if (pUser) {
CIRCNetwork *pNetwork = pUser->FindNetwork(sLine.Token(2));
if (pNetwork) {
pNetwork->PutIRC(sLine.Token(3, true));
PutModule("Sent [" + sLine.Token(3, true) + "] to IRC Server of " + pUser->GetUserName() + "/" + pNetwork->GetName());
} else {
PutModule("Network [" + sLine.Token(2) + "] not found for user [" + sLine.Token(1) + "]");
}
} else {
PutModule("User [" + sLine.Token(1) + "] not found");
}
}
示例4: CloneNetworks
void CUser::CloneNetworks(const CUser& User) {
const vector<CIRCNetwork*>& vNetworks = User.GetNetworks();
for (CIRCNetwork* pUserNetwork : vNetworks) {
CIRCNetwork* pNetwork = FindNetwork(pUserNetwork->GetName());
if (pNetwork) {
pNetwork->Clone(*pUserNetwork);
} else {
new CIRCNetwork(this, *pUserNetwork);
}
}
set<CString> ssDeleteNetworks;
for (CIRCNetwork* pNetwork : m_vIRCNetworks) {
if (!(User.FindNetwork(pNetwork->GetName()))) {
ssDeleteNetworks.insert(pNetwork->GetName());
}
}
for (const CString& sNetwork : ssDeleteNetworks) {
// The following will move all the clients to the user.
// So the clients are not disconnected. The client could
// have requested the rehash. Then when we do
// client->PutStatus("Rehashing succeeded!") we would
// crash if there was no client anymore.
const vector<CClient*>& vClients = FindNetwork(sNetwork)->GetClients();
while (vClients.begin() != vClients.end()) {
CClient* pClient = vClients.front();
// This line will remove pClient from vClients,
// because it's a reference to the internal Network's vector.
pClient->SetNetwork(nullptr);
}
DeleteNetwork(sNetwork);
}
}
示例5: UserCommand
//.........这里部分代码省略.........
continue;
uEnabled++;
(*it)->Enable();
}
PutStatus("There were [" + CString(uMatches) + "] channels matching [" + sChan + "]");
PutStatus("Enabled [" + CString(uEnabled) + "] channels");
}
} else if (sCommand.Equals("LISTCHANS")) {
if (!m_pNetwork) {
PutStatus("You must be connected with a network to use this command");
return;
}
CUser* pUser = m_pUser;
CIRCNetwork* pNetwork = m_pNetwork;
const CString sNick = sLine.Token(1);
const CString sNetwork = sLine.Token(2);
if (!sNick.empty()) {
if (!m_pUser->IsAdmin()) {
PutStatus("Usage: ListChans");
return;
}
pUser = CZNC::Get().FindUser(sNick);
if (!pUser) {
PutStatus("No such user [" + sNick + "]");
return;
}
pNetwork = pUser->FindNetwork(sNetwork);
if (!pNetwork) {
PutStatus("No such network for user [" + sNetwork + "]");
return;
}
}
const vector<CChan*>& vChans = pNetwork->GetChans();
CIRCSock* pIRCSock = pNetwork->GetIRCSock();
const CString& sPerms = (pIRCSock) ? pIRCSock->GetPerms() : "";
if (!vChans.size()) {
PutStatus("There are no channels defined.");
return;
}
CTable Table;
Table.AddColumn("Name");
Table.AddColumn("Status");
Table.AddColumn("Conf");
Table.AddColumn("Buf");
Table.AddColumn("Modes");
Table.AddColumn("Users");
for (unsigned int p = 0; p < sPerms.size(); p++) {
CString sPerm;
sPerm += sPerms[p];
Table.AddColumn(sPerm);
}
unsigned int uNumDetached = 0, uNumDisabled = 0,
uNumJoined = 0;