当前位置: 首页>>代码示例>>C++>>正文


C++ CUser::FindNetwork方法代码示例

本文整理汇总了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;
	}
开发者ID:luser,项目名称:znc,代码行数:10,代码来源:webadmin.cpp

示例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;
	}
开发者ID:HaleBob,项目名称:znc,代码行数:49,代码来源:send_raw.cpp

示例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");
		}
	}
开发者ID:HaleBob,项目名称:znc,代码行数:16,代码来源:send_raw.cpp

示例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);
    }
}
开发者ID:Un1matr1x,项目名称:znc,代码行数:37,代码来源:User.cpp

示例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;
开发者ID:IshaqAzmi,项目名称:GKZNC,代码行数:66,代码来源:ClientCommand.cpp


注:本文中的CUser::FindNetwork方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。