From 347246b38a50d6570f3c15c09fc3c78ce4ad2d9c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 30 Jan 2015 22:02:53 +0000 Subject: more fixes for parsing messages git-svn-id: http://svn.miranda-ng.org/main/trunk@11961 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'protocols/WhatsApp/src') diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index c5ae37bb6b..34b0f2a899 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -368,7 +368,7 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio FMessage fmessage(from, false, id); fmessage.wants_receipt = false; fmessage.timestamp = atoi(attribute_t.c_str()); - fmessage.data = messageNode->getAttributeValue("caption"); + fmessage.notifyname = messageNode->getAttributeValue("notify"); fmessage.remote_resource = author; fmessage.media_wa_type = FMessage::getMessage_WA_Type(media->getAttributeValue("type")); fmessage.media_url = media->getAttributeValue("url"); @@ -377,6 +377,7 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio fmessage.media_duration_seconds = atoi(media->getAttributeValue("seconds").c_str()); if (fmessage.media_wa_type == FMessage::WA_TYPE_LOCATION) { + const string &name = media->getAttributeValue("name"); const string &latitudeString = media->getAttributeValue("latitude"); const string &longitudeString = media->getAttributeValue("longitude"); if (latitudeString.empty() || longitudeString.empty()) @@ -384,6 +385,8 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio fmessage.latitude = atof(latitudeString.c_str()); fmessage.longitude = atof(longitudeString.c_str()); + if (!name.empty()) + fmessage.data = name; } else if (fmessage.media_wa_type == FMessage::WA_TYPE_CONTACT) { ProtocolTreeNode *contactChildNode = media->getChild(0); @@ -416,9 +419,12 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio const string &encoding = media->getAttributeValue("encoding"); if (encoding.empty() || encoding == "text") fmessage.data = media->getDataAsString(); - else if (media->data->size() > 0) { - fmessage.bindata = (unsigned char*)malloc(fmessage.bindata_len = media->data->size()); - memcpy(fmessage.bindata, media->data->data(), fmessage.bindata_len); + else { + fmessage.data = media->getAttributeValue("caption"); + if (media->data->size() > 0) { + fmessage.bindata = (unsigned char*)malloc(fmessage.bindata_len = media->data->size()); + memcpy(fmessage.bindata, media->data->data(), fmessage.bindata_len); + } } } -- cgit v1.2.3