summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/Junk/steam_thread.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-26 19:15:20 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-26 19:15:20 +0000
commitab75f8e4a3968c956425844415237a4fa6fcee63 (patch)
treedf2c209dd0197dc3085546606b0581d63f9114ad /protocols/Steam/src/Junk/steam_thread.cpp
parent4e9e885747b2037c81ce809f7f6505f8bc8b0e2f (diff)
Steam: merge new api
git-svn-id: http://svn.miranda-ng.org/main/trunk@13850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/Junk/steam_thread.cpp')
-rw-r--r--protocols/Steam/src/Junk/steam_thread.cpp171
1 files changed, 0 insertions, 171 deletions
diff --git a/protocols/Steam/src/Junk/steam_thread.cpp b/protocols/Steam/src/Junk/steam_thread.cpp
deleted file mode 100644
index f07541c6d3..0000000000
--- a/protocols/Steam/src/Junk/steam_thread.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-#include "stdafx.h"
-
-void CSteamProto::PollServer(const char *token, const char *umqId, UINT32 messageId, SteamWebApi::PollApi::PollResult *pollResult)
-{
- debugLogA("CSteamProto::PollServer: call SteamWebApi::PollApi::Poll");
- SteamWebApi::PollApi::Poll(m_hNetlibUser, token, umqId, messageId, pollResult);
-
- if (!pollResult->IsSuccess())
- return;
-
- CMStringA updatedIds;
- for (size_t i = 0; i < pollResult->GetItemCount(); i++)
- {
- const SteamWebApi::PollApi::PoolItem *item = pollResult->GetAt(i);
- switch (item->GetType())
- {
- case SteamWebApi::PollApi::POOL_TYPE_TYPING:
- break;
-
- case SteamWebApi::PollApi::POOL_TYPE_MESSAGE:
- {
- SteamWebApi::PollApi::Message *message = (SteamWebApi::PollApi::Message*)item;
-
- MCONTACT hContact = FindContact(message->GetSteamId());
- if (hContact)
- {
- const wchar_t *text = message->GetText();
-
- PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
- recv.timestamp = message->GetTimestamp();
- recv.szMessage = mir_utf8encodeW(text);
-
- ProtoChainRecvMsg(hContact, &recv);
- }
- }
- break;
-
- case SteamWebApi::PollApi::POOL_TYPE_MYMESSAGE:
- {
- SteamWebApi::PollApi::Message *message = (SteamWebApi::PollApi::Message*)item;
-
- MCONTACT hContact = FindContact(message->GetSteamId());
- if (hContact)
- {
- const wchar_t *text = message->GetText();
-
- AddDBEvent(hContact, EVENTTYPE_MESSAGE, time(NULL), DBEF_UTF | DBEF_SENT, mir_tstrlen(text), (BYTE*)mir_utf8encodeW(text));
- }
- }
- break;
-
- case SteamWebApi::PollApi::POOL_TYPE_STATE:
- {
- SteamWebApi::PollApi::State *state = (SteamWebApi::PollApi::State*)item;
-
- WORD status = CSteamProto::SteamToMirandaStatus(state->GetStatus());
- const char *steamId = state->GetSteamId();
- const wchar_t *nickname = state->GetNickname();
-
- if (IsMe(steamId))
- {
- if (status == ID_STATUS_OFFLINE)
- continue;
-
- if (status != m_iStatus)
- {
- debugLogA("Change own status to %i", status);
- WORD oldStatus = m_iStatus;
- m_iStatus = m_iDesiredStatus = status;
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
- }
- }
- /*else
- {
- MCONTACT hContact = FindContact(steamId);
- if (hContact)
- SetContactStatus(hContact, status);
- }*/
-
- if (updatedIds.IsEmpty())
- updatedIds.Append(steamId);
- else
- updatedIds.AppendFormat(",%s", steamId);
- }
- break;
-
- case SteamWebApi::PollApi::POOL_TYPE_CONTACT_ADD:
- {
- SteamWebApi::PollApi::Relationship *crs = (SteamWebApi::PollApi::Relationship*)item;
-
- const char *steamId = crs->GetSteamId();
- if (updatedIds.IsEmpty())
- updatedIds.Append(steamId);
- else
- updatedIds.AppendFormat(",%s", steamId);
- }
- break;
-
- case SteamWebApi::PollApi::POOL_TYPE_CONTACT_REMOVE:
- {
- SteamWebApi::PollApi::Relationship *crs = (SteamWebApi::PollApi::Relationship*)item;
-
- const char *steamId = crs->GetSteamId();
- MCONTACT hContact = FindContact(steamId);
- if (hContact)
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
- }
- break;
-
- case SteamWebApi::PollApi::POOL_TYPE_CONTACT_REQUEST:
- {
- SteamWebApi::PollApi::Relationship *crs = (SteamWebApi::PollApi::Relationship*)item;
-
- const char *steamId = crs->GetSteamId();
-
- MCONTACT hContact = FindContact(steamId);
- if (!hContact)
- hContact = AddContact(steamId, true);
-
- RaiseAuthRequestThread((void*)hContact);
- }
- break;
- }
- }
-
- if (!updatedIds.IsEmpty())
- UpdateContactsThread(mir_strdup(updatedIds));
-}
-
-void CSteamProto::PollingThread(void*)
-{
- debugLogA("CSteamProto::PollingThread: entering");
-
- ptrA token(getStringA("TokenSecret"));
- ptrA umqId(getStringA("UMQID"));
- UINT32 messageId = getDword("MessageID", 0);
-
- SteamWebApi::PollApi::PollResult pollResult;
- while (!m_bTerminated)
- {
- PollServer(token, umqId, messageId, &pollResult);
-
- if (pollResult.IsNeedRelogin())
- {
- debugLogA("CSteamProto::PollingThread: need to relogin");
- SetStatus(ID_STATUS_OFFLINE);
- }
-
- if (!pollResult.IsSuccess())
- {
- debugLogA("CSteamProto::PollServer: call SteamWebApi::PollApi::Poll");
- SetStatus(ID_STATUS_OFFLINE);
-
- // token has expired
- if (pollResult.GetStatus() == HTTP_STATUS_UNAUTHORIZED)
- {
- delSetting("TokenSecret");
- //delSetting("Cookie");
- }
-
- break;
- }
-
- messageId = pollResult.GetMessageId();
- setDword("MessageID", messageId);
- }
-
- m_hPollingThread = NULL;
- debugLogA("CSteamProto::PollingThread: leaving");
-} \ No newline at end of file