summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/contacts.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-09-14 18:56:11 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-09-14 18:56:11 +0000
commit25f87650dab37f5a7380ae2121c7529cb3ac801a (patch)
tree377f4ba9fd4d3528aeb05414157948c5abaf376f /protocols/WhatsApp/src/contacts.cpp
parenta8c76fb1f7113f18fda981ae885066d04619571f (diff)
WhatsApp: Fixed reading/storing tiome in database
patch by Cassio: It should also now display the following in the contact list: "Last online TIMESTAMP"; When a user is online currently "Denied: last online TIMESTAMP"; When the user is offline and has blocked "last seen". The time the user was last online simultaneously is used "Last seen TIMESTAMP"; When a user is offline but "last seen" info is available. git-svn-id: http://svn.miranda-ng.org/main/trunk@15352 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/contacts.cpp')
-rw-r--r--protocols/WhatsApp/src/contacts.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/protocols/WhatsApp/src/contacts.cpp b/protocols/WhatsApp/src/contacts.cpp
index 67f9a9a2aa..e657c1d00d 100644
--- a/protocols/WhatsApp/src/contacts.cpp
+++ b/protocols/WhatsApp/src/contacts.cpp
@@ -104,7 +104,7 @@ void WhatsAppProto::ProcessBuddyList(void*)
CODE_BLOCK_CATCH_ALL
}
-void WhatsAppProto::onAvailable(const std::string &paramString, bool paramBoolean, int lastSeenTime)
+void WhatsAppProto::onAvailable(const std::string &paramString, bool paramBoolean, DWORD lastSeenTime)
{
MCONTACT hContact = AddToContactList(paramString);
if (hContact != NULL) {
@@ -114,7 +114,12 @@ void WhatsAppProto::onAvailable(const std::string &paramString, bool paramBoolea
}
else {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
- setDword(hContact, WHATSAPP_KEY_LAST_SEEN, lastSeenTime);
+ if (lastSeenTime != 0) {
+ setDword(hContact, WHATSAPP_KEY_LAST_SEEN, lastSeenTime);
+ setByte(hContact, WHATSAPP_KEY_LAST_SEEN_DENIED, 0);
+ }
+ else
+ setByte(hContact, WHATSAPP_KEY_LAST_SEEN_DENIED, 1);
}
UpdateStatusMsg(hContact);
}
@@ -123,21 +128,19 @@ void WhatsAppProto::onAvailable(const std::string &paramString, bool paramBoolea
void WhatsAppProto::UpdateStatusMsg(MCONTACT hContact)
{
std::wstringstream ss;
-
- int lastSeen = getDword(hContact, WHATSAPP_KEY_LAST_SEEN, -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) {
+ DWORD lastSeen = getDword(hContact, WHATSAPP_KEY_LAST_SEEN, 0);
+ WORD status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+ bool denied = getBool(hContact, WHATSAPP_KEY_LAST_SEEN_DENIED, false);
+ if (lastSeen > 0) {
time_t ts = lastSeen;
TCHAR stzLastSeen[MAX_PATH];
- _tcsftime(stzLastSeen, _countof(stzLastSeen), TranslateT("Last seen on %x at %X"), localtime(&ts));
+ if (status == ID_STATUS_ONLINE)
+ _tcsftime(stzLastSeen, _countof(stzLastSeen), TranslateT("Last online on %x at %X"), localtime(&ts));
+ else
+ _tcsftime(stzLastSeen, _countof(stzLastSeen), denied ? TranslateT("Denied: Last online on %x at %X") : 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());
}