diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-04-14 08:11:09 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-04-14 08:11:09 +0000 |
commit | 1e8ce03c8fe14ee1238e15c41391e1c7a5346d7c (patch) | |
tree | bcc266a4abdd30e828a207ef5ee6b1fb5266679c /protocols/FacebookRM/src/json.cpp | |
parent | b71efb96a849d2a5a1bf07e07fe1a9e4eb61a8e7 (diff) |
Facebook: respect "use local timestamp" setting also for "message read" events
git-svn-id: http://svn.miranda-ng.org/main/trunk@8968 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 110a82d127..65e2658dd7 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -415,6 +415,13 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa if (reader == NULL || time == NULL)
continue;
+ // check if we should use use local_timestamp for unread messages and use it for read time too
+ bool local_timestamp = proto->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0);
+ time_t timestamp = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(json_as_float(time));
+
+ TCHAR ttime[64];
+ _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(×tamp));
+
JSONNODE *threadid = json_get(it, "tid");
if (threadid != NULL) { // multi user chat
std::tstring tid = json_as_string(threadid);
@@ -424,6 +431,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa if (chatroom != proto->facy.chat_rooms.end()) {
std::map<std::string, std::string>::const_iterator participant = chatroom->second.participants.find(reader_id);
if (participant == chatroom->second.participants.end()) {
+ // TODO: remove or write better all of this
std::string tidA = _T2A(tid.c_str());
std::string search = utils::url::encode(tidA) + "?";
http::response resp = proto->facy.flap(REQUEST_USER_INFO, NULL, &search);
@@ -458,17 +466,18 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa chatroom->second.message_readers += ", ";
chatroom->second.message_readers += participant_name;
- TCHAR ttime[64], tstr[100];
- _tcsftime(ttime, SIZEOF(ttime), _T("%X"), utils::conversion::fbtime_to_timeinfo(json_as_float(time)));
- mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("Message read: %s by %s"), ttime, ptrT(mir_utf8decodeT(chatroom->second.message_readers.c_str())));
+ ptrT readers(mir_utf8decodeT(chatroom->second.message_readers.c_str()));
+
+ TCHAR tstr[200];
+ mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("Message read: %s by %s"), ttime, readers);
+
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)tstr);
}
}
} else { // classic contact
MCONTACT hContact = proto->ContactIDToHContact(json_as_pstring(reader));
if (hContact) {
- TCHAR ttime[64], tstr[100];
- _tcsftime(ttime, SIZEOF(ttime), _T("%X"), utils::conversion::fbtime_to_timeinfo(json_as_float(time)));
+ TCHAR tstr[100];
mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("Message read: %s"), ttime);
CallService(MS_MSG_SETSTATUSTEXT, hContact, (LPARAM)tstr);
|