From 65ef9d3aaa306361f039679fcf73cdfbf10ec6b4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 7 Feb 2015 20:46:03 +0000 Subject: fix for sending media messages to group chats git-svn-id: http://svn.miranda-ng.org/main/trunk@12046 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/chat.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'protocols/WhatsApp/src/chat.cpp') diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 1f855f9b55..0f574b2c93 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -319,17 +319,24 @@ void WhatsAppProto::onGroupInfo(const std::string &jid, const std::string &owner CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce); } -void WhatsAppProto::onGroupMessage(const FMessage &msg) +void WhatsAppProto::onGroupMessage(const FMessage &pMsg) { - WAChatInfo *pInfo = SafeGetChat(msg.key.remote_jid); + WAChatInfo *pInfo = SafeGetChat(pMsg.key.remote_jid); if (pInfo == NULL) { - pInfo = InitChat(msg.key.remote_jid, ""); + pInfo = InitChat(pMsg.key.remote_jid, ""); pInfo->bActive = true; } - ptrT tszText(str2t(msg.data)); - ptrT tszUID(str2t(msg.remote_resource)); - ptrT tszNick(GetChatUserNick(msg.remote_resource)); + std::string msg(pMsg.data); + if (!pMsg.media_url.empty()) { + if (!msg.empty()) + msg.append("\n"); + msg += pMsg.media_url; + } + + ptrT tszText(str2t(msg)); + ptrT tszUID(str2t(pMsg.remote_resource)); + ptrT tszNick(GetChatUserNick(pMsg.remote_resource)); GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_MESSAGE }; @@ -337,13 +344,13 @@ void WhatsAppProto::onGroupMessage(const FMessage &msg) gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = tszUID; gce.ptszNick = tszNick; - gce.time = msg.timestamp; + gce.time = pMsg.timestamp; gce.ptszText = tszText; - gce.bIsMe = m_szJid == msg.remote_resource; + gce.bIsMe = m_szJid == pMsg.remote_resource; CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); if (isOnline()) - m_pConnection->sendMessageReceived(msg); + m_pConnection->sendMessageReceived(pMsg); } void WhatsAppProto::onGroupNewSubject(const std::string &gjid, const std::string &author, const std::string &newSubject, int ts) -- cgit v1.2.3