From 1e11f5fc920b54759b2ec16854d8f9e65662cdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sun, 6 Jul 2014 09:00:21 +0000 Subject: Facebook: Fix invisible status (now it's not true-invisible again) It's not fully tested, should be fixed better later. git-svn-id: http://svn.miranda-ng.org/main/trunk@9702 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/communication.cpp | 8 +++++++- protocols/FacebookRM/src/connection.cpp | 16 ++++++++++++---- protocols/FacebookRM/src/proto.cpp | 4 ++++ protocols/FacebookRM/src/proto.h | 5 ++++- 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'protocols/FacebookRM/src') diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 6f14407941..3faf8da535 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -516,7 +516,13 @@ std::string facebook_client::choose_action(RequestType request_type, std::string action += "&partition=" + (this->chat_channel_partition_.empty() ? "0" : this->chat_channel_partition_); action += "&clientid=" + this->chat_clientid_; action += "&cb=" + utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz"); - action += "&idle=0&state=active"; + + // FIXME: fix this as I don't know how it works yet (because of quick stable release) + if (!parent->isInvisible()) + action += "&idle=-1&state=active"; + else + action += "&idle=1"; + if (!this->chat_sticky_num_.empty()) action += "&sticky_token=" + this->chat_sticky_num_; diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index 02699bc1e0..7ecc553f20 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -125,11 +125,18 @@ void FacebookProto::ChangeStatus(void*) debugLogA("***** SignOn complete"); } - facy.chat_state(m_iDesiredStatus != ID_STATUS_INVISIBLE); + m_invisible = (new_status == ID_STATUS_INVISIBLE); - ForkThread(&FacebookProto::ProcessBuddyList, NULL); + facy.chat_state(!m_invisible); - m_iStatus = facy.self_.status_id = m_iDesiredStatus; + if (m_invisible) { + facy.buddies.clear(); + SetAllContactStatuses(ID_STATUS_OFFLINE); + } else { + ForkThread(&FacebookProto::ProcessBuddyList, NULL); + } + + m_iStatus = facy.self_.status_id = new_status; ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); debugLogA("***** ChangeStatus complete"); @@ -181,7 +188,8 @@ void FacebookProto::UpdateLoop(void *) for (int i = -1; !isOffline(); i = ++i % 50) { if (i != -1) { - ProcessBuddyList(NULL); + if (!isInvisible()) + ProcessBuddyList(NULL); if (getByte(FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE)) ProcessFeeds(NULL); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 4a36cc96d4..54cd7f0b10 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -35,6 +35,8 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) : facy.send_message_lock_ = CreateMutex(NULL, FALSE, NULL); facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL); + m_invisible = false; + CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI); CreateProtoService(PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg); CreateProtoService(PS_GETMYAVATART, &FacebookProto::GetMyAvatar); @@ -175,6 +177,8 @@ int FacebookProto::SetStatus(int new_status) return 0; } + m_invisible = (new_status == ID_STATUS_INVISIBLE); + ForkThread(&FacebookProto::ChangeStatus, this); return 0; } diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 0887d402a7..7a1b208707 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -47,9 +47,12 @@ public: inline bool isInvisible() { - return (m_iStatus == ID_STATUS_INVISIBLE); + return m_invisible; + //return (m_iStatus == ID_STATUS_INVISIBLE); } + bool m_invisible; + // DB utils missing in proto_interface __forceinline INT_PTR getStringUtf(const char *name, DBVARIANT *result) { -- cgit v1.2.3