summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-02-07 08:43:50 +0000
committerRobert Pösel <robyer@seznam.cz>2015-02-07 08:43:50 +0000
commitbca544e48bda364d28bf3d732e0b578683870ebf (patch)
tree64b710b5777cf5c83ab583e277111c26ff9fe381 /protocols/FacebookRM
parentcaaf768bfac9eec37f9461c8354cb62a1216f773 (diff)
Facebook: Correct implementation of idle time reporting, update channel request
git-svn-id: http://svn.miranda-ng.org/main/trunk@12036 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/client.h3
-rw-r--r--protocols/FacebookRM/src/communication.cpp19
-rw-r--r--protocols/FacebookRM/src/proto.cpp46
-rw-r--r--protocols/FacebookRM/src/proto.h6
4 files changed, 50 insertions, 24 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 3e0d43c937..f26ab107ee 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -39,7 +39,7 @@ public:
{
msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = 0;
- https_ = is_idle_ = is_typing_ = false;
+ https_ = is_typing_ = false;
buddies_lock_ = send_message_lock_ = notifications_lock_ = cookies_lock_ = NULL;
hMsgCon = NULL;
@@ -78,7 +78,6 @@ public:
std::string chat_clientid_;
std::string chat_traceid_;
bool is_typing_;
- bool is_idle_;
bool https_;
time_t last_feeds_update_;
time_t last_notification_time_;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 0f7ff0e9ec..2399dbfad7 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright © 2009-11 Michal Zelinka, 2011-15 Robert Pösel
+Copyright � 2009-11 Michal Zelinka, 2011-15 Robert P�sel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -535,13 +535,13 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
action += "&clientid=" + this->chat_clientid_;
action += "&cb=" + utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz");
- // 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";
-
+ int idleSeconds = parent->IdleSeconds();
+ action += "&idle=" + utils::conversion::to_string(&idleSeconds, UTILS_CONV_UNSIGNED_NUMBER);
action += "&cap=0";
+ // action += "&wtc=0,0,0.000,0,0"; // TODO: what's this item? It's numbers grows with every new request...
+
+ action += "&uid=" + self_.user_id;
+ action += "&viewer_uid=" + self_.user_id;
if (!this->chat_sticky_num_.empty())
action += "&sticky_token=" + this->chat_sticky_num_;
@@ -552,6 +552,11 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
if (!this->chat_traceid_.empty())
action += "&traceid=" + this->chat_traceid_;
+ if (parent->isInvisible())
+ action += "&state=offline";
+ else if (idleSeconds < 60)
+ action += "&state=active";
+
return action;
}
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index eea0c9d45f..561313a2f6 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright � 2009-11 Michal Zelinka, 2011-15 Robert P�sel
+Copyright © 2009-11 Michal Zelinka, 2011-15 Robert Pösel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -43,6 +43,7 @@ FacebookProto::FacebookProto(const char* proto_name, const TCHAR* username) :
m_invisible = false;
m_signingOut = false;
m_enableChat = DEFAULT_ENABLE_CHATS;
+ m_idleTS = 0;
// Load custom locale, if set
ptrA locale(getStringA(FACEBOOK_KEY_LOCALE));
@@ -188,7 +189,6 @@ int FacebookProto::SetStatus(int new_status)
m_iDesiredStatus = new_status;
break;
- case ID_STATUS_IDLE:
default:
m_iDesiredStatus = ID_STATUS_INVISIBLE;
if (getByte(FACEBOOK_KEY_MAP_STATUSES, DEFAULT_MAP_STATUSES))
@@ -380,23 +380,39 @@ INT_PTR FacebookProto::GetMyAwayMsg(WPARAM, LPARAM lParam)
return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(statusMsg) : (INT_PTR)mir_t2a(statusMsg);
}
-int FacebookProto::OnIdleChanged(WPARAM, LPARAM lParam)
+int FacebookProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
{
- if (m_iStatus == ID_STATUS_INVISIBLE || m_iStatus <= ID_STATUS_OFFLINE)
+ bool idle = (lParam & IDF_ISIDLE) != 0;
+ bool privacy = (lParam & IDF_PRIVACY) != 0;
+
+ // Respect user choice about (not) notifying idle to protocols
+ if (privacy) {
+ // Reset it to 0 if there is some time already
+ if (m_idleTS)
+ {
+ m_idleTS = 0;
+ delSetting("IdleTS");
+ }
+
return 0;
+ }
- bool bIdle = (lParam & IDF_ISIDLE) != 0;
- bool bPrivacy = (lParam & IDF_PRIVACY) != 0;
+ // We don't want to reset idle time when we're already in idle state
+ if (idle && m_idleTS > 0)
+ return 0;
- if (facy.is_idle_ && !bIdle)
- {
- facy.is_idle_ = false;
- SetStatus(m_iDesiredStatus);
- }
- else if (!facy.is_idle_ && bIdle && !bPrivacy && m_iDesiredStatus != ID_STATUS_INVISIBLE)
- {
- facy.is_idle_ = true;
- SetStatus(ID_STATUS_IDLE);
+ if (idle) {
+ // User started being idle
+ MIRANDA_IDLE_INFO mii = { sizeof(mii) };
+ CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii);
+
+ // Compute time when user really became idle
+ m_idleTS = time(0) - mii.idleTime * 60;
+ setDword("IdleTS", m_idleTS);
+ } else {
+ // User stopped being idle
+ m_idleTS = 0;
+ delSetting("IdleTS");
}
return 0;
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 28ee25429c..fec92279d2 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -51,9 +51,15 @@ public:
//return (m_iStatus == ID_STATUS_INVISIBLE);
}
+ inline int IdleSeconds()
+ {
+ return m_idleTS ? time(0) - m_idleTS : 0;
+ }
+
bool m_invisible;
bool m_enableChat;
bool m_signingOut;
+ time_t m_idleTS;
std::string m_locale;
// DB utils missing in proto_interface