summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-03-06 16:46:10 +0000
committerRobert Pösel <robyer@seznam.cz>2015-03-06 16:46:10 +0000
commit615a53f6195f25a3d1b517f10f8957d0f0583768 (patch)
tree4304cd2cf21ad431bc2029170ce50f7e41a1f038
parent4d7709c7b8fc466d21158670bb94aaea23ecb2e5 (diff)
Steam: Add support for setting Away and N/A (= snooze) statuses
This is pseudo support as on server it is determined by our idle time which is sent with poll request. That means we must wait up to 30 seconds to status being changed on server. Also this change disables reporting real idle time. git-svn-id: http://svn.miranda-ng.org/main/trunk@12352 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Steam/src/Steam/poll.h51
-rw-r--r--protocols/Steam/src/common.h3
-rw-r--r--protocols/Steam/src/steam_proto.cpp16
-rw-r--r--protocols/Steam/src/steam_proto.h15
4 files changed, 60 insertions, 25 deletions
diff --git a/protocols/Steam/src/Steam/poll.h b/protocols/Steam/src/Steam/poll.h
index 35d8330385..9e095c0b44 100644
--- a/protocols/Steam/src/Steam/poll.h
+++ b/protocols/Steam/src/Steam/poll.h
@@ -1,24 +1,29 @@
-#ifndef _STEAM_POLL_H_
-#define _STEAM_POLL_H_
-
-namespace SteamWebApi
-{
- class PollRequest : public HttpsPostRequest
- {
- public:
- PollRequest(const char *token, const char *umqId, UINT32 messageId, int idleSeconds) :
- HttpsPostRequest(STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001")
- {
- timeout = 30000;
- flags |= NLHRF_PERSISTENT;
-
- char data[256];
- mir_snprintf(data, SIZEOF(data), "access_token=%s&umqid=%s&message=%u&secidletime=%d", token, umqId, messageId, idleSeconds);
-
- SetData(data, strlen(data));
- AddHeader("Connection", "keep-alive");
- }
- };
-}
-
+#ifndef _STEAM_POLL_H_
+#define _STEAM_POLL_H_
+
+namespace SteamWebApi
+{
+ class PollRequest : public HttpsPostRequest
+ {
+ public:
+ PollRequest(const char *token, const char *umqId, UINT32 messageId, int idleSeconds) :
+ HttpsPostRequest(STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001")
+ {
+ timeout = 30000;
+ flags |= NLHRF_PERSISTENT;
+
+ CMStringA data;
+ data.AppendFormat("access_token=%s&umqid=%s&message=%u&secidletime=%d",
+ token,
+ umqId,
+ messageId,
+ idleSeconds);
+
+ SetData(data, data.GetLength());
+
+ AddHeader("Connection", "keep-alive");
+ }
+ };
+}
+
#endif //_STEAM_POLL_H_ \ No newline at end of file
diff --git a/protocols/Steam/src/common.h b/protocols/Steam/src/common.h
index d19f25ab3e..64303c9404 100644
--- a/protocols/Steam/src/common.h
+++ b/protocols/Steam/src/common.h
@@ -40,6 +40,9 @@
#define MODULE "Steam"
+#define STEAM_API_IDLEOUT_AWAY 600
+#define STEAM_API_IDLEOUT_SNOOZE 8000
+
class CSteamProto;
extern HINSTANCE g_hInstance;
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index e7efc9f510..8a80a2e235 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -240,7 +240,7 @@ DWORD_PTR __cdecl CSteamProto:: GetCaps(int type, MCONTACT hContact)
case PFLAGNUM_4:
return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED | PF4_IMSENDUTF | PF4_SUPPORTIDLE | PF4_SUPPORTTYPING;// | PF4_IMSENDOFFLINE;
case PFLAGNUM_5:
- return PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_OUTTOLUNCH | PF2_FREECHAT;
+ return PF2_HEAVYDND | PF2_OUTTOLUNCH | PF2_FREECHAT;
case PFLAG_UNIQUEIDTEXT:
return (DWORD_PTR)Translate("SteamID");
case PFLAG_UNIQUEIDSETTING:
@@ -381,6 +381,15 @@ int CSteamProto::SetStatus(int new_status)
switch (new_status)
{
case ID_STATUS_OFFLINE:
+ case ID_STATUS_AWAY:
+ case ID_STATUS_NA:
+ break;
+
+ case ID_STATUS_DND:
+ case ID_STATUS_OCCUPIED:
+ case ID_STATUS_ONTHEPHONE:
+ case ID_STATUS_OUTTOLUNCH:
+ new_status = ID_STATUS_NA;
break;
default:
@@ -413,6 +422,11 @@ int CSteamProto::SetStatus(int new_status)
StartQueue();
}
+ else
+ {
+ m_iStatus = new_status;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+ }
return 0;
}
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index e2a76fa44b..6ee5b79a8a 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -316,7 +316,20 @@ protected:
static INT_PTR CALLBACK BlockListOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
// helpers
- inline int IdleSeconds() { return m_idleTS ? time(0) - m_idleTS : 0; }
+ inline int IdleSeconds() {
+ // Based on idle time we report Steam server will mark us as online/away/snooze
+ switch (this->m_iStatus) {
+ case ID_STATUS_AWAY:
+ return STEAM_API_IDLEOUT_AWAY;
+ case ID_STATUS_NA:
+ return STEAM_API_IDLEOUT_SNOOZE;
+ default:
+ return 0;
+ }
+
+ // ... or we can report real idle info
+ // return m_idleTS ? time(0) - m_idleTS : 0;
+ }
};
int OnReloadIcons(WPARAM wParam, LPARAM lParam);