Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
licq: Replace newlines before writing history
Browse files Browse the repository at this point in the history
  • Loading branch information
flynd committed Jan 14, 2013
1 parent dd9c41c commit 94c5ce5
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions licq/src/userevents.cpp
@@ -1,6 +1,6 @@
/*
* This file is part of Licq, an instant messaging client for UNIX.
* Copyright (C) 2010-2012 Licq developers <licq-dev@googlegroups.com>
* Copyright (C) 2010-2013 Licq developers <licq-dev@googlegroups.com>
*
* Licq is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -145,6 +145,15 @@ string addStrWithColons(const string& oldStr)
return str;
}

static string addSingleLine(const string& oldStr)
{
string str = ":" + oldStr;
size_t pos = 0;
while ((pos = str.find('\n', pos)) < str.size())
str[pos] = ' ';
return str + '\n';
}


//-----CUserEvent::AddToHistory-------------------------------------------------
string UserEvent::historyHeader(bool isReceiver) const
Expand Down Expand Up @@ -270,7 +279,7 @@ void Licq::EventFile::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myFilename << '\n';
buf << addSingleLine(myFilename);
buf << ':' << m_nFileSize << '\n';
buf << addStrWithColons(myFileDescription);
writeUserHistory(u, buf.str());
Expand Down Expand Up @@ -309,9 +318,7 @@ void Licq::EventUrl::AddToHistory(User* u, bool isReceiver) const
{
string str;
str = historyHeader(isReceiver);
str += ':';
str += myUrl;
str += '\n';
str += addSingleLine(myUrl);
str += addStrWithColons(myUrlDescription);
writeUserHistory(u, str);
}
Expand Down Expand Up @@ -403,11 +410,11 @@ void Licq::EventAdded::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myUserId.accountId() << '\n';
buf << ':' << myAlias << '\n';
buf << ':' << myFirstName << '\n';
buf << ':' << myLastName << '\n';
buf << ':' << myEmail << '\n';
buf << addSingleLine(myUserId.accountId());
buf << addSingleLine(myAlias);
buf << addSingleLine(myFirstName);
buf << addSingleLine(myLastName);
buf << addSingleLine(myEmail);
writeUserHistory(u, buf.str());
}

Expand Down Expand Up @@ -452,11 +459,11 @@ void Licq::EventAuthRequest::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myUserId.accountId() << '\n';
buf << ':' << myAlias << '\n';
buf << ':' << myFirstName << '\n';
buf << ':' << myLastName << '\n';
buf << ':' << myEmail << '\n';
buf << addSingleLine(myUserId.accountId());
buf << addSingleLine(myAlias);
buf << addSingleLine(myFirstName);
buf << addSingleLine(myLastName);
buf << addSingleLine(myEmail);
buf << addStrWithColons(myReason);
writeUserHistory(u, buf.str());
}
Expand Down Expand Up @@ -496,9 +503,7 @@ void Licq::EventAuthGranted::AddToHistory(User* u, bool isReceiver) const
{
string str;
str = historyHeader(isReceiver);
str += ':';
str += myUserId.accountId();
str += '\n';
str += addSingleLine(myUserId.accountId());
str += addStrWithColons(myMessage);
writeUserHistory(u, str);
}
Expand Down Expand Up @@ -537,9 +542,7 @@ void Licq::EventAuthRefused::AddToHistory(User* u, bool isReceiver) const
{
string str;
str = historyHeader(isReceiver);
str += ':';
str += myUserId.accountId();
str += '\n';
str += addSingleLine(myUserId.accountId());
str += addStrWithColons(myMessage);
writeUserHistory(u, str);
}
Expand Down Expand Up @@ -578,8 +581,8 @@ void Licq::EventWebPanel::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myName << '\n';
buf << ':' << myEmail << '\n';
buf << addSingleLine(myName);
buf << addSingleLine(myEmail);
buf << addStrWithColons(myMessage);
writeUserHistory(u, buf.str());
}
Expand Down Expand Up @@ -617,8 +620,8 @@ void Licq::EventEmailPager::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myName << '\n';
buf << ':' << myEmail << '\n';
buf << addSingleLine(myName);
buf << addSingleLine(myEmail);
buf << addStrWithColons(myMessage);
writeUserHistory(u, buf.str());
}
Expand Down Expand Up @@ -676,8 +679,8 @@ void Licq::EventContactList::AddToHistory(User* u, bool isReceiver) const
ContactList::const_iterator iter;
for (iter = m_vszFields.begin(); iter != m_vszFields.end(); ++iter)
{
buf << ':' << (*iter)->userId().accountId() << '\n';
buf << ':' << (*iter)->alias() << '\n';
buf << addSingleLine((*iter)->userId().accountId());
buf << addSingleLine((*iter)->alias());
}
writeUserHistory(u, buf.str());
}
Expand Down Expand Up @@ -713,9 +716,7 @@ void Licq::EventSms::AddToHistory(User* u, bool isReceiver) const
{
string str;
str = historyHeader(isReceiver);
str += ':';
str += myNumber;
str += '\n';
str += addSingleLine(myNumber);
str += addStrWithColons(myMessage);
writeUserHistory(u, str);
}
Expand Down Expand Up @@ -754,8 +755,8 @@ void Licq::EventServerMessage::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myName << '\n';
buf << ':' << myEmail << '\n';
buf << addSingleLine(myName);
buf << addSingleLine(myEmail);
buf << addStrWithColons(myMessage);
writeUserHistory(u, buf.str());
}
Expand Down Expand Up @@ -809,8 +810,8 @@ void Licq::EventEmailAlert::AddToHistory(User* u, bool isReceiver) const
{
stringstream buf;
buf << historyHeader(isReceiver);
buf << ':' << myName << '\n';
buf << ':' << myEmail << '\n';
buf << addSingleLine(myName);
buf << addSingleLine(myEmail);
buf << addStrWithColons(mySubject);
writeUserHistory(u, buf.str());
}
Expand Down Expand Up @@ -854,9 +855,7 @@ void Licq::EventUnknownSysMsg::AddToHistory(User* /* u */, bool /* isReceiver */
/*
string str;
str = historyHeader(isReceiver);
str += ':';
str += myUserId.accountId();
str += '\n';
str += addSingleLine(myUserId.accountId());
str += addStrWithColons(myMessage);
writeUserHistory(u, str);
*/
Expand Down

0 comments on commit 94c5ce5

Please sign in to comment.