summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-05-15 15:54:01 +0000
committerRobert Pösel <robyer@seznam.cz>2013-05-15 15:54:01 +0000
commita24c54b1c68eac0bc187a60192b6691912b34472 (patch)
tree66bbedb41c694ba95aa15dc5a677705a73a987be /protocols
parent83a3c975e9cdf5895cb45c3f91c12986b5cdb539 (diff)
Facebook: Show info in statusbar when user read your message.
git-svn-id: http://svn.miranda-ng.org/main/trunk@4662 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/src/json.cpp23
-rw-r--r--protocols/FacebookRM/src/utils.cpp5
-rw-r--r--protocols/FacebookRM/src/utils.h5
3 files changed, 29 insertions, 4 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 1c67e55dcd..4da26c5d93 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -329,11 +329,30 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
proto->Log(msg.c_str());
}
}
- else if (type.Value() == "messaging") // inbox message (multiuser or direct)
+ else if (type.Value() == "messaging")
{
const String& type = objMember["event"];
- if (type.Value() == "deliver") {
+ if (type.Value() == "read_receipt") {
+ // user read message
+ const Number& reader = objMember["reader"];
+ const Number& time = objMember["time"];
+
+ char user_id[32];
+ lltoa(reader.Value(), user_id, 10);
+
+ // TODO: add check for chat contacts
+ HANDLE hContact = proto->ContactIDToHContact(user_id);
+ if (hContact) {
+ TCHAR ttime[100], tstr[200];
+ _tcsftime(ttime, SIZEOF(ttime), _T("%X"), utils::conversion::fbtime_to_timeinfo(time.Value()));
+ mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("Message read at %s"), ttime);
+
+ CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)tstr);
+ }
+
+ } else if (type.Value() == "deliver") {
+ // inbox message (multiuser or direct)
const Object& messageContent = objMember["message"];
const Number& sender_fbid = messageContent["sender_fbid"];
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp
index a7d22d441d..46c56cafd1 100644
--- a/protocols/FacebookRM/src/utils.cpp
+++ b/protocols/FacebookRM/src/utils.cpp
@@ -71,6 +71,11 @@ DWORD utils::conversion::to_timestamp(std::string data)
return timestamp;
}
+struct tm *utils::conversion::fbtime_to_timeinfo(double 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 9918eb917f..f0b3b68d96 100644
--- a/protocols/FacebookRM/src/utils.h
+++ b/protocols/FacebookRM/src/utils.h
@@ -99,8 +99,9 @@ namespace utils
namespace conversion
{
DWORD to_timestamp(std::string data);
- std::string to_string(void*, WORD type);
-
+ struct tm *fbtime_to_timeinfo(double timestamp);
+ std::string to_string(void*, WORD type);
+
template <class T>
bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) {
std::istringstream iss(s);