diff options
author | Robert Pösel <robyer@seznam.cz> | 2013-05-23 15:35:31 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2013-05-23 15:35:31 +0000 |
commit | 1100cf0fc0aa447cb2390409c8dcea9deebe3d4f (patch) | |
tree | 569c28d3028d3122d87495ccb754d0ef03756b64 /protocols | |
parent | d9c995acca09460e8b8533c7efdb5eddd6e61d73 (diff) |
Facebook: Load sent messages from browser into Miranda.
git-svn-id: http://svn.miranda-ng.org/main/trunk@4811 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/client.h | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/common.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 35 |
4 files changed, 45 insertions, 3 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 9f51ebe2f6..ce49743ea8 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -90,7 +90,7 @@ public: HANDLE cookies_lock_;
- std::map< std::string, std::string > cookies;
+ std::map<std::string, std::string> cookies;
std::string get_newsfeed_type();
std::string get_server_type();
@@ -137,7 +137,7 @@ public: // Updates handling
- List::List< facebook_user > buddies;
+ List::List<facebook_user> buddies;
HANDLE buddies_lock_;
HANDLE send_message_lock_;
@@ -149,6 +149,8 @@ public: // Messages handling
+ std::set<std::string> messages_sent;
+
bool channel();
bool send_message(std::string message_recipient, std::string message_text, std::string *error_text, int method);
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/common.h b/protocols/FacebookRM/src/common.h index 3f91242fa7..2abb3a3cc0 100644 --- a/protocols/FacebookRM/src/common.h +++ b/protocols/FacebookRM/src/common.h @@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <list>
#include <map>
#include <vector>
+#include <set>
#include <algorithm>
#include <stdarg.h>
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 5cfd9fab99..cb2e0a3f4a 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -1164,7 +1164,11 @@ bool facebook_client::send_message(std::string message_recipient, std::string me switch (resp.error_number)
{
case 0: // Everything is OK
- break;
+ {
+ // Remember this message id
+ std::string mid = utils::text::source_get_value(&resp.data, 2, "\"message_id\":\"", "\"");
+ messages_sent.insert(mid);
+ } break;
//case 1356002: // You are offline - wtf??
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 8d705b4323..ee1a2ed62a 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -310,6 +310,41 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa const Number& time_sent = messageContent["time"];
// proto->Log("????? Checking time %15.2f > %15.2f", time_sent.Value(), proto->facy.last_message_time_);
+
+ if (was_id == proto->facy.self_.user_id) {
+ // ignore messages sent from Miranda
+ std::set<std::string>::iterator it = proto->facy.messages_sent.find(message_id.Value());
+ if (it != proto->facy.messages_sent.end()) {
+ proto->facy.messages_sent.erase(it);
+ continue;
+ }
+
+ std::string message_text = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(text.Value()));
+
+ const Number& to = objMember["to"];
+ char to_id[32];
+ lltoa(to.Value(), to_id, 10);
+
+ HANDLE hContact = proto->ContactIDToHContact(to_id);
+ if (!hContact)
+ continue;
+
+ DBEVENTINFO dbei = {0};
+ dbei.cbSize = sizeof(dbei);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
+ dbei.szModule = proto->m_szModuleName;
+
+ bool local_time = db_get_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_LOCAL_TIMESTAMP, 0) != 0;
+ dbei.timestamp = local_time ? ::time(NULL) : utils::time::fix_timestamp(time_sent.Value());
+
+ dbei.cbBlob = (DWORD)message_text.length() + 1;
+ dbei.pBlob = (PBYTE)message_text.c_str();
+ db_event_add(hContact, &dbei);
+
+ continue;
+ }
+
if ((messageContent.Find("truncated") != messageContent.End())
&& (((const Number &)messageContent["truncated"]).Value() == 1)) {
// If we got truncated message, we can ignore it, because we should get it again as "messaging" type
|