From 0bf2bc15b71b0df5a0cc2d733535c62dfa19748e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 26 Nov 2014 09:00:49 +0000 Subject: Facebook: Real fix for corrupted newsfeeds in chatroom Problem was text.str().c_str() because .str() returns temporary object and c_str() pointer to it, so it was probably destructed before really using it in chatroom. git-svn-id: http://svn.miranda-ng.org/main/trunk@11084 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/chat.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'protocols') diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 2ceaeec16d..1e81e1ffaa 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -424,14 +424,23 @@ void FacebookProto::PrepareNotificationsChatRoom() { } void FacebookProto::UpdateNotificationsChatRoom(facebook_notification *notification) { - ScopedLock s(facy.notifications_lock_); - if (!getBool(FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM)) return; - char *name = _T2A(TranslateT("Notification"), CP_UTF8); - std::stringstream text; text << notification->text << "\n\n" << notification->link; - UpdateChat(_T(FACEBOOK_NOTIFICATIONS_CHATROOM), name /*notification->second->user_id.c_str()*/, name, text.str().c_str(), notification->time, notification->seen); + + std::string smessage = text.str(); + utils::text::replace_all(&smessage, "%", "%%"); + + GCDEST gcd = { m_szModuleName, _T(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_MESSAGE }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.ptszText = _A2T(smessage.c_str(), CP_UTF8); + gce.time = notification->time ? notification->time : ::time(NULL); + gce.bIsMe = true; + gce.dwFlags |= GCEF_ADDTOLOG; + gce.ptszNick = TranslateT("Notifications"); + gce.ptszUID = _T(FACEBOOK_NOTIFICATIONS_CHATROOM); + + CallServiceSync(MS_GC_EVENT, 0, reinterpret_cast(&gce)); } \ No newline at end of file -- cgit v1.2.3