From 97d772455be44b3693678bb5192e5c6bc777bc98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Mon, 8 Dec 2014 23:53:49 +0000 Subject: Steam: Refactor statuses support - allow changing own status - change own status when it changes on server - temporary don't distinguish between playing/not playing contacts - fix steam<->miranda status mapping git-svn-id: http://svn.miranda-ng.org/main/trunk@11291 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Steam/src/steam_account.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'protocols/Steam/src/steam_account.cpp') diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index b428896fcc..62e442a032 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -221,7 +221,8 @@ void CSteamProto::OnGotSession(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response, void *arg) { - if (response == NULL) { + if (response == NULL) + { // set status to offline m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE); @@ -262,4 +263,36 @@ void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response, void *arg) // go to online now ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus = m_iDesiredStatus); +} + +void CSteamProto::OnStatusChanged(const NETLIBHTTPREQUEST *response, void *arg) +{ + if (response == NULL) + { + m_iDesiredStatus = m_iStatus; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)m_iStatus, m_iStatus); + return; + } + + JSONROOT root(response->pData); + + /*JSONNODE *node = json_get(root, "success"); + if (!json_as_bool(node)) { + return; + } + + JSONNODE *node = json_get(root, "error"); + ptrW error(json_as_string(node)); + if (lstrcmpi(error, L"OK")/* || response->resultCode == HTTP_STATUS_UNAUTHORIZED*//*) + { + // set status to offline + m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE); + return; + }*/ + + int new_status = (int)arg; + int old_status = m_iStatus; + m_iStatus = m_iDesiredStatus = new_status; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); } \ No newline at end of file -- cgit v1.2.3