diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-12-08 23:53:49 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-12-08 23:53:49 +0000 |
commit | 97d772455be44b3693678bb5192e5c6bc777bc98 (patch) | |
tree | 3729e0320c19d4a6d888d2003119e707d27104d1 /protocols/Steam/src/steam_account.cpp | |
parent | 13eb656152eb83e6b246293da72294ce22c6cc48 (diff) |
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
Diffstat (limited to 'protocols/Steam/src/steam_account.cpp')
-rw-r--r-- | protocols/Steam/src/steam_account.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
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 |