From 48eb3373ebbacd68eb580d907b260763bebeac96 Mon Sep 17 00:00:00 2001 From: prozacx Date: Thu, 21 Apr 2005 21:37:35 +0000 Subject: [PATCH] Added GetCommonChans() git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@159 726aef4b-f618-498e-8847-2d620e286838 --- Nick.cpp | 22 ++++++++++++++++++++++ Nick.h | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/Nick.cpp b/Nick.cpp index 5caeaf68..28b23ce9 100644 --- a/Nick.cpp +++ b/Nick.cpp @@ -1,4 +1,6 @@ #include "Nick.h" +#include "Chan.h" +#include "User.h" CNick::CNick() { m_bIsOp = false; @@ -34,6 +36,26 @@ void CNick::Parse(const string& sNickMask) { } } +unsigned int CNick::GetCommonChans(vector& vRetChans, CUser* pUser) const { + vRetChans.clear(); + + const vector& vChans = pUser->GetChans(); + + for (unsigned int a = 0; a < vChans.size(); a++) { + CChan* pChan = vChans[a]; + const map& msNicks = pChan->GetNicks(); + + for (map::const_iterator it = msNicks.begin(); it != msNicks.end(); it++) { + if (strcasecmp(it->first.c_str(), m_sNick.c_str()) == 0) { + vRetChans.push_back(pChan); + continue; + } + } + } + + return vRetChans.size(); +} + void CNick::SetNick(const string& s) { m_sNick = s; } void CNick::SetIdent(const string& s) { m_sIdent = s; } void CNick::SetHost(const string& s) { m_sHost = s; } diff --git a/Nick.h b/Nick.h index b97227bf..5edfc607 100644 --- a/Nick.h +++ b/Nick.h @@ -1,8 +1,15 @@ #ifndef _NICK_H #define _NICK_H +#include #include using std::string; +using std::vector; + +// Forward Decl +class CUser; +class CChan; +// !Forward Decl class CNick { @@ -13,6 +20,7 @@ public: void Parse(const string& sNickMask); string GetHostMask() const; + unsigned int GetCommonChans(vector& vChans, CUser* pUser) const; // Setters void SetNick(const string& s);