diff options
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 7 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 2a2fe90333..047a71a0d9 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -450,7 +450,8 @@ std::string facebook_client::choose_action(RequestType request_type, std::string */ int idleSeconds = parent->IdleSeconds(); - action += "&idle=" + utils::conversion::to_string(&idleSeconds, UTILS_CONV_UNSIGNED_NUMBER); + if (idleSeconds > 0 && !parent->isInvisible()) + action += "&idle=" + utils::conversion::to_string(&idleSeconds, UTILS_CONV_UNSIGNED_NUMBER); action += "&cap=0"; // TODO: what's this item? Sometimes it's 0, sometimes 8 // action += "&wtc=0,0,0.000,0,0"; // TODO: what's this item? It's numbers grows with every new request... @@ -1207,6 +1208,10 @@ bool facebook_client::channel() bool facebook_client::activity_ping() { + // Don't send ping when we are not online + if (parent->m_iStatus != ID_STATUS_ONLINE) + return true; + handle_entry("activity_ping"); http::response resp = flap(REQUEST_ACTIVE_PING); diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 97c9c21477..864c37ab90 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -72,6 +72,8 @@ int facebook_json_parser::parse_buddy_list(std::string *data, List::List< facebo current->client = CLIENT_MOBILE; } + time_t now = ::time(NULL); + // Find now available contacts const JSONNode &nowAvailable = list["nowAvailableList"]; for (auto it = nowAvailable.begin(); it != nowAvailable.end(); ++it) { @@ -98,6 +100,12 @@ int facebook_json_parser::parse_buddy_list(std::string *data, List::List< facebo current->status_id = (current->client == CLIENT_MOBILE || current->client == CLIENT_MESSENGER) ? ID_STATUS_ONTHEPHONE : ID_STATUS_ONLINE; + // Set contacts that were last active more than 1 minute ago as away + if (current->status_id == ID_STATUS_ONLINE && current->last_active > 0 && (now - current->last_active) > 60) { + current->status_id = ID_STATUS_AWAY; + current->idle = true; + } + // Facebook is not sending this info anymore, it should be removed const JSONNode &p = (*it)["p"]; if (p) { @@ -729,7 +737,10 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector< facebo bool isVisible = visibility && visibility.as_bool(); proto->debugLogA(" Requested chat switch to %s", isVisible ? "Online" : "Offline"); - proto->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE); + + // If actual status is not what server says, change it (handle also local away status, which means online) + if (isVisible != (proto->m_iStatus != ID_STATUS_INVISIBLE)) + proto->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE); } } else if (t == "buddylist_overlay") { |