Permalink
Browse files

Working savebuff saving and loading.

It's even backwards compatible!
  • Loading branch information...
1 parent c36480c commit 355f196bbe700a25d1e9643953a5753e558c53d4 @stephank stephank committed Oct 27, 2011
Showing with 22 additions and 5 deletions.
  1. +1 −1 include/znc/Chan.h
  2. +21 −4 modules/savebuff.cpp
View
@@ -91,7 +91,7 @@ class CChan {
const CBuffer& GetBuffer() const { return m_Buffer; }
unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); }
bool SetBufferCount(unsigned int u, bool bForce = false) { return m_Buffer.SetLineCount(u, bForce); };
- int AddBuffer(const CString& sFormat, const CString& sText = "") { return m_Buffer.AddLine(sFormat, sText); }
+ int AddBuffer(const CString& sFormat, const CString& sText = "", time_t tm = 0) { return m_Buffer.AddLine(sFormat, sText, tm); }
void ClearBuffer() { m_Buffer.Clear(); }
void SendBuffer(CClient* pClient);
// !Buffer
View
@@ -116,8 +116,23 @@ class CSaveBuff : public CModule
for (it = vsLines.begin(); it != vsLines.end(); ++it) {
CString sLine(*it);
sLine.Trim();
- // FIXME: Deserialize other CBufLine attributes.
- pChan->AddBuffer(sLine);
+ if (sLine[0] == '@' && it+1 != vsLines.end())
+ {
+ CString sTimestamp = sLine.Token(0);
+ sTimestamp.TrimLeft("@");
+ time_t tm = sTimestamp.ToLongLong();
+
+ CString sFormat = sLine.Token(1, true);
+
+ CString sText(*++it);
+ sText.Trim();
+
+ pChan->AddBuffer(sFormat, sText, tm);
+ } else
+ {
+ // Old format, escape the line and use as is.
+ pChan->AddBuffer(_NAMEDFMT(sLine));
+ }
}
} else
{
@@ -152,8 +167,10 @@ class CSaveBuff : public CModule
unsigned int uSize = Buffer.Size();
for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) {
const CBufLine& Line = Buffer.GetBufLine(uIdx);
- // FIXME: Serialize other CBufLine attributes.
- sFile += Line.GetFormat() + "\n";
+ sFile +=
+ "@" + CString(Line.GetTime()) + " " +
+ Line.GetFormat() + "\n" +
+ Line.GetText() + "\n";
}
CBlowfish c(m_sPassword, BF_ENCRYPT);

0 comments on commit 355f196

Please sign in to comment.