summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/contacts.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-09-13 14:32:53 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-09-13 14:32:53 +0000
commitcf0be00671d56bb18118e1491e7c1f0e131e7b3d (patch)
tree407d1760615f4cf22a4e664f242ae045a4cf8408 /protocols/WhatsApp/src/contacts.cpp
parent6f20ee4beb6b840ed81489358bca01ed41a0ea56 (diff)
Patch by Cassio:
Another patch, which fixes last seen timestamps/presence due to a change in WA protocol: There is no longer a last seen request/response as this info is now received within the presence response. git-svn-id: http://svn.miranda-ng.org/main/trunk@15345 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/contacts.cpp')
-rw-r--r--protocols/WhatsApp/src/contacts.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp
index 2d94f0228b..67f9a9a2aa 100644
--- a/protocols/WhatsApp/src/contacts.cpp
+++ b/protocols/WhatsApp/src/contacts.cpp
@@ -104,28 +104,20 @@ void WhatsAppProto::ProcessBuddyList(void*)
CODE_BLOCK_CATCH_ALL
}
-void WhatsAppProto::onAvailable(const std::string &paramString, bool paramBoolean)
+void WhatsAppProto::onAvailable(const std::string &paramString, bool paramBoolean, int lastSeenTime)
{
MCONTACT hContact = AddToContactList(paramString);
if (hContact != NULL) {
- if (paramBoolean)
+ if (paramBoolean) {
setWord(hContact, "Status", ID_STATUS_ONLINE);
+ setDword(hContact, WHATSAPP_KEY_LAST_SEEN, time(NULL));
+ }
else {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
- UpdateStatusMsg(hContact);
+ setDword(hContact, WHATSAPP_KEY_LAST_SEEN, lastSeenTime);
}
+ UpdateStatusMsg(hContact);
}
-
- setDword(hContact, WHATSAPP_KEY_LAST_SEEN, time(NULL));
- UpdateStatusMsg(hContact);
-}
-
-void WhatsAppProto::onLastSeen(const std::string &paramString1, int paramInt, const string &paramString2)
-{
- MCONTACT hContact = AddToContactList(paramString1);
- setDword(hContact, WHATSAPP_KEY_LAST_SEEN, time(NULL) - paramInt);
-
- UpdateStatusMsg(hContact);
}
void WhatsAppProto::UpdateStatusMsg(MCONTACT hContact)
@@ -133,12 +125,19 @@ void WhatsAppProto::UpdateStatusMsg(MCONTACT hContact)
std::wstringstream ss;
int lastSeen = getDword(hContact, WHATSAPP_KEY_LAST_SEEN, -1);
- if (lastSeen != -1) {
+ // TODO define these somewhere
+ // lastSeen -1: no time available in DB
+ // lastSeen -2: last seen denied by user
+ // lastSeen >= 0: timestamp
+ if (lastSeen >= 0) {
time_t ts = lastSeen;
TCHAR stzLastSeen[MAX_PATH];
_tcsftime(stzLastSeen, _countof(stzLastSeen), TranslateT("Last seen on %x at %X"), localtime(&ts));
ss << stzLastSeen;
}
+ else if (lastSeen == -2) {
+ ss << TranslateT("Last seen denied");
+ }
db_set_ws(hContact, "CList", "StatusMsg", ss.str().c_str());
}