summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/messages.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-26 23:21:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-26 23:21:25 +0000
commit88d6662a12f18844e5487c3d35155d3fbbff85a5 (patch)
tree2090b9d565feb3c0004c3373313cf1ebb7c33c3a /protocols/WhatsApp/src/messages.cpp
parente64e17858c88e0b8302a34cebc02be0019422947 (diff)
fix for going offline in WhatsApp
git-svn-id: http://svn.miranda-ng.org/main/trunk@11921 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/messages.cpp')
-rw-r--r--protocols/WhatsApp/src/messages.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/protocols/WhatsApp/src/messages.cpp b/protocols/WhatsApp/src/messages.cpp
index 9fe33b121c..8d774a47d0 100644
--- a/protocols/WhatsApp/src/messages.cpp
+++ b/protocols/WhatsApp/src/messages.cpp
@@ -44,7 +44,7 @@ int WhatsAppProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
if (jid == NULL)
return 0;
- if (m_pConnection != NULL) {
+ if (m_pConnection == NULL) {
debugLogA("No connection");
return 0;
}
@@ -56,10 +56,11 @@ int WhatsAppProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
int msgId = this->m_pConnection->msg_id++;
try {
- std::string id = "msg" + Utilities::intToStr(msgId);
+ time_t now = time(NULL);
+ std::string id = Utilities::intToStr(now) + "-" + Utilities::intToStr(msgId);
FMessage fmsg(new Key((const char*)jid, true, id));
+ fmsg.timestamp = now;
fmsg.data = msg;
- fmsg.timestamp = time(NULL);
m_pConnection->sendMessage(&fmsg);
}
@@ -121,7 +122,11 @@ void WhatsAppProto::onMessageStatusUpdate(FMessage* fmsg)
return;
if (fmsg->status == FMessage::STATUS_RECEIVED_BY_SERVER) {
- int msgId = atoi(fmsg->key->id.substr(3).c_str());
+ size_t delim = fmsg->key->id.find('-');
+ if (delim == string::npos)
+ return;
+
+ int msgId = atoi(fmsg->key->id.substr(delim+1).c_str());
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)msgId, 0);
}
}