diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-07-30 23:29:59 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-07-30 23:29:59 +0000 |
commit | 3bdff57b5868e9d333f61297021f7943ed160500 (patch) | |
tree | a2514a7aafecf82d7900371a8550769d6f0bf7af /protocols/Omegle | |
parent | 548bcad3fa31c55c33200c3516a5a537ca5e3f0d (diff) |
Omegle: Fix sending and receiving % in chats
git-svn-id: http://svn.miranda-ng.org/main/trunk@10002 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Omegle')
-rw-r--r-- | protocols/Omegle/src/chat.cpp | 9 | ||||
-rw-r--r-- | protocols/Omegle/src/utils.cpp | 12 | ||||
-rw-r--r-- | protocols/Omegle/src/utils.h | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index 007a8cbd38..cf98c66a32 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -23,10 +23,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void OmegleProto::UpdateChat(const TCHAR *name, const TCHAR *message, bool addtolog)
{
+ // replace % to %% to not interfere with chat color codes
+ std::tstring smessage = message;
+ utils::text::treplace_all(&smessage, _T("%"), _T("%%"));
+
GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
- gce.ptszText = message;
+ gce.ptszText = smessage.c_str();
if (name == NULL) {
gcd.iType = GC_EVENT_INFORMATION;
@@ -56,6 +60,9 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam) {
std::string text = mir_t2a_cp(hook->ptszText,CP_UTF8);
+ // replace %% back to %, because chat automatically does this to sent messages
+ utils::text::replace_all(&text, "%%", "%");
+
if (text.empty())
break;
diff --git a/protocols/Omegle/src/utils.cpp b/protocols/Omegle/src/utils.cpp index fcc45aa502..bc7bac240a 100644 --- a/protocols/Omegle/src/utils.cpp +++ b/protocols/Omegle/src/utils.cpp @@ -49,6 +49,18 @@ void utils::text::replace_all( std::string* data, std::string from, std::string }
}
+void utils::text::treplace_all(std::tstring* data, std::tstring from, std::tstring to)
+{
+ std::tstring::size_type position = 0;
+
+ while ((position = data->find(from, position)) != std::tstring::npos)
+ {
+ data->replace(position, from.size(), to);
+ position++;
+ }
+}
+
+
std::string utils::text::special_expressions_decode( std::string data )
{
utils::text::replace_all( &data, "\\r", "\r" );
diff --git a/protocols/Omegle/src/utils.h b/protocols/Omegle/src/utils.h index 67a071d00c..dc22deffbb 100644 --- a/protocols/Omegle/src/utils.h +++ b/protocols/Omegle/src/utils.h @@ -33,6 +33,7 @@ namespace utils {
void replace_first( std::string* data, std::string from, std::string to );
void replace_all( std::string* data, std::string from, std::string to );
+ void treplace_all(std::tstring* data, std::tstring from, std::tstring to);
std::string special_expressions_decode( std::string data );
std::string slashu_to_utf8( std::string data );
std::string trim( std::string data );
|