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 | |
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')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 19 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/utils.cpp | 5 | ||||
-rw-r--r-- | protocols/FacebookRM/src/utils.h | 1 |
4 files changed, 14 insertions, 12 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);
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index ddb7e5e28d..2d6802bfe8 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -317,7 +317,6 @@ void FacebookProto::ProcessUnreadMessage(void *p) int offset = 0;
int limit = 21;
- // don't use local_timestamp for unread messages by default, use hidden setting to enable it
bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0);
// receive messages from all folders by default, use hidden setting to receive only inbox messages
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp index 8123bc9109..5e8a44ed05 100644 --- a/protocols/FacebookRM/src/utils.cpp +++ b/protocols/FacebookRM/src/utils.cpp @@ -72,11 +72,6 @@ DWORD utils::conversion::to_timestamp(std::string data) return timestamp;
}
-struct tm *utils::conversion::fbtime_to_timeinfo(unsigned __int64 timestamp) {
- time_t time = utils::time::fix_timestamp(timestamp);
- return localtime(&time);
-}
-
std::string utils::conversion::to_string(void* data, WORD type)
{
std::stringstream out;
diff --git a/protocols/FacebookRM/src/utils.h b/protocols/FacebookRM/src/utils.h index c6fade2c49..19ae46b97c 100644 --- a/protocols/FacebookRM/src/utils.h +++ b/protocols/FacebookRM/src/utils.h @@ -72,7 +72,6 @@ namespace utils namespace conversion
{
DWORD to_timestamp(std::string data);
- struct tm *fbtime_to_timeinfo(unsigned __int64 timestamp);
std::string to_string(void*, WORD type);
template <class T>
|