Add CChan::SendBuffer(client, buffer) overload

This allows interested parties eg. modules to to send a partial
buffer playback without reinventing the wheel.
This commit is contained in:
J-P Nurmi
2014-03-04 08:27:10 +01:00
parent a8e7b908c0
commit 2b0c47aa8e
2 changed files with 8 additions and 3 deletions

View File

@@ -526,6 +526,10 @@ CNick* CChan::FindNick(const CString& sNick) {
}
void CChan::SendBuffer(CClient* pClient) {
SendBuffer(pClient, m_Buffer);
}
void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// in the event that pClient is NULL, need to send this to all clients for the user
// I'm presuming here that pClient is listed inside vClients thus vClients at this
@@ -541,7 +545,7 @@ void CChan::SendBuffer(CClient* pClient) {
// if pClient is not NULL, the loops break after the first iteration.
//
// Rework this if you like ...
if (!m_Buffer.IsEmpty()) {
if (!Buffer.IsEmpty()) {
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for (size_t uClient = 0; uClient < vClients.size(); ++uClient) {
CClient * pUseClient = (pClient ? pClient : vClients[uClient]);
@@ -553,9 +557,9 @@ void CChan::SendBuffer(CClient* pClient) {
m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient);
}
size_t uSize = m_Buffer.Size();
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
CString sLine = m_Buffer.GetLine(uIdx, *pUseClient);
CString sLine = Buffer.GetLine(uIdx, *pUseClient);
bool bNotShowThisLine = false;
NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, &bNotShowThisLine);
if (bNotShowThisLine) continue;