From eac530cf8f1c8b79e7225f4b541a25ec8a3eb215 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 1 Oct 2012 14:03:20 +0000 Subject: fix for message encoding git-svn-id: http://svn.miranda-ng.org/main/trunk@1745 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Twitter/chat.cpp | 36 ++++++++++++++++-------------------- protocols/Twitter/proto.cpp | 2 +- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/protocols/Twitter/chat.cpp b/protocols/Twitter/chat.cpp index 5c247f6bdb..f73b885034 100644 --- a/protocols/Twitter/chat.cpp +++ b/protocols/Twitter/chat.cpp @@ -62,32 +62,28 @@ void TwitterProto::UpdateChat(const twitter_user &update) int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam) { GCHOOK *hook = reinterpret_cast(lParam); - char *text; - - if(strcmp(hook->pDest->pszModule,m_szModuleName)) + if ( strcmp(hook->pDest->pszModule, m_szModuleName)) return 0; - switch(hook->pDest->iType) - { - case GC_USER_MESSAGE: { - text = mir_t2a_cp(hook->ptszText,CP_UTF8); - LOG (_T("**Chat - Outgoing message: %s"), hook->ptszText); - - std::string tweet(text); - replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/ + switch(hook->pDest->iType) { + case GC_USER_MESSAGE: + LOG ( _T("**Chat - Outgoing message: %s"), hook->ptszText); + { + mir_ptr text( mir_utf8encodeT(hook->ptszText)); - char *varTweet; - varTweet = mir_utf8encode(tweet.c_str()); - //strncpy(varTweet, tweet.c_str(), tweet.length()+1); + std::string tweet(text); + replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/ - ForkThread(&TwitterProto::SendTweetWorker, this,varTweet); + char *varTweet = mir_strdup( tweet.c_str()); + ForkThread(&TwitterProto::SendTweetWorker, this, varTweet); + } break; - } + case GC_USER_PRIVMESS: - text = mir_t2a(hook->ptszUID); - CallService(MS_MSG_SENDMESSAGE,reinterpret_cast( - UsernameToHContact(text)),0); - mir_free(text); + { + mir_ptr text( mir_t2a(hook->ptszUID)); + CallService(MS_MSG_SENDMESSAGE, WPARAM(UsernameToHContact(text)), 0); + } break; } diff --git a/protocols/Twitter/proto.cpp b/protocols/Twitter/proto.cpp index 40f0e30ec4..f5b0698867 100644 --- a/protocols/Twitter/proto.cpp +++ b/protocols/Twitter/proto.cpp @@ -527,7 +527,7 @@ void TwitterProto::LOG(TCHAR *fmt,...) // be in MessageLoop void TwitterProto::SendTweetWorker(void *p) { - if(p == 0) + if (p == 0) return; char *text = static_cast(p); -- cgit v1.2.3