summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/messages.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-05-16 14:55:16 +0000
committerRobert Pösel <robyer@seznam.cz>2013-05-16 14:55:16 +0000
commiteec9743cc90715180fec9b184ae343dc5083e780 (patch)
treeac804835491fdd565596864347afe9255b8a97ee /protocols/FacebookRM/src/messages.cpp
parent016efa8dd058f9af5a57a33a6541736ce710a5a7 (diff)
Facebook:
- fixed getting login error message - cleanup of close_chat method and related things - added Poke support (contact menu) - support for sending "Seen" info (add in db "MarkRead" (byte) with value "1") - support for language specific fb errors (add in db "Locale" (string) with locale value ("en_US", "cs_CZ" etc.) - mir_a2t_cp(..., CP_UTF8) changed to mir_utf8decodeT(...) git-svn-id: http://svn.miranda-ng.org/main/trunk@4677 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/messages.cpp')
-rw-r--r--protocols/FacebookRM/src/messages.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index 0ef3bdb325..29fbbcdcca 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -24,14 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int FacebookProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre)
{
- DBVARIANT dbv;
-
- if (!db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
- {
- ForkThread(&FacebookProto::MessagingWorker, this, new send_messaging(dbv.pszVal, FACEBOOK_RECV_MESSAGE));
- db_free(&dbv);
- }
-
+ ForkThread(&FacebookProto::ReadMessageWorker, this, hContact);
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
return Proto_RecvMessage(hContact, pre);
@@ -66,7 +59,6 @@ void FacebookProto::SendMsgWorker(void *p)
if (result) {
ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS, data->msgid,0);
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)data->hContact, NULL);
- MessagingWorker(new send_messaging(dbv.pszVal, FACEBOOK_SEND_MESSAGE));
} else {
char *err = mir_utf8decodeA(error_text.c_str());
ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_FAILED, data->msgid,(LPARAM)err);
@@ -171,17 +163,38 @@ void FacebookProto::SendTypingWorker(void *p)
delete typing;
}
-void FacebookProto::MessagingWorker(void *p)
+void FacebookProto::ReadMessageWorker(void *p)
{
if (p == NULL)
return;
- send_messaging *data = static_cast<send_messaging*>(p);
+ return;
- if (data->type == FACEBOOK_RECV_MESSAGE)
- facy.chat_mark_read(data->user_id);
+ HANDLE hContact = static_cast<HANDLE>(p);
- delete data;
+ if (!db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_MARK_READ, 0)) {
+ // old variant - no seen info updated
+ mir_ptr<char> id = db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_ID);
+ if (id == NULL) return;
+
+ std::string data = "action=chatMarkRead";
+ data += "&other_user=" + std::string(id);
+ data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
+ data += "&lsd=&__user=" + facy.self_.user_id;
+
+ http::response resp = facy.flap(FACEBOOK_REQUEST_ASYNC, &data);
+ } else {
+ // new variant - with seen info
+ mir_ptr<char> mid = db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_MESSAGE_ID);
+ if (mid == NULL) return;
+
+ std::string data = "ids[" + std::string(mid) + "]=true";
+ data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
+ data += "&__user=" + facy.self_.user_id;
+ data += "&__a=1&__dyn=&__req=j&phstamp=0";
+
+ http::response resp = facy.flap(FACEBOOK_REQUEST_MARK_READ, &data);
+ }
}
void FacebookProto::parseSmileys(std::string message, HANDLE hContact)