Permalink
Browse files

Add CChan::SendBuffer(client, buffer) overload

This allows interested parties eg. modules to to send a partial
buffer playback without reinventing the wheel.
  • Loading branch information...
1 parent a8e7b90 commit 2b0c47aa8e26fd4dcf09d23d1518a96617c8cd7b @jpnurmi jpnurmi committed Mar 4, 2014
Showing with 8 additions and 3 deletions.
  1. +1 −0 include/znc/Chan.h
  2. +7 −3 src/Chan.cpp
View
1 include/znc/Chan.h
@@ -96,6 +96,7 @@ class CChan {
size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); }
void ClearBuffer() { m_Buffer.Clear(); }
void SendBuffer(CClient* pClient);
+ void SendBuffer(CClient* pClient, const CBuffer& Buffer);
// !Buffer
// m_Nick wrappers
View
10 src/Chan.cpp
@@ -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;

0 comments on commit 2b0c47a

Please sign in to comment.