Working savebuff saving and loading.

It's even backwards compatible!
This commit is contained in:
Stéphan Kochen
2011-10-27 19:17:17 +02:00
parent c36480c8a1
commit 355f196bbe
2 changed files with 22 additions and 5 deletions

View File

@@ -91,7 +91,7 @@ public:
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 File

@@ -116,8 +116,23 @@ public:
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 @@ public:
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);