summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_thread.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-04-04 14:13:16 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-04-04 14:13:16 +0000
commite08dd78ccf05f9d5d768e5436fcfc5e8126356fe (patch)
tree3101fdefff844854ea77e2220d62d0cba26cb6b8 /protocols/Steam/src/steam_thread.cpp
parent13a0838f7641f80e3dd166f4a67e6fd43f073456 (diff)
Steam: some improvements
git-svn-id: http://svn.miranda-ng.org/main/trunk@8848 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_thread.cpp')
-rw-r--r--protocols/Steam/src/steam_thread.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/protocols/Steam/src/steam_thread.cpp b/protocols/Steam/src/steam_thread.cpp
index 42b2af3903..d1c6d8a3c0 100644
--- a/protocols/Steam/src/steam_thread.cpp
+++ b/protocols/Steam/src/steam_thread.cpp
@@ -24,52 +24,56 @@ int SteamToMirandaStatus(int state)
}
-int CSteamProto::PollStatus()
+int CSteamProto::PollStatus(const char *sessionId, const char *steamId, UINT32 messageId)
{
- ptrA steamId(getStringA("SteamID"));
- ptrA sessionId(getStringA("SessionID"));
- ptrA messageId(getStringA("MessageID"));
-
- SteamWebApi::PollApi::Poll poll;
- SteamWebApi::PollApi::PollStatus(m_hNetlibUser, sessionId, steamId, messageId, &poll);
+ SteamWebApi::PollApi::PollResult pollResult;
+ SteamWebApi::PollApi::PollStatus(m_hNetlibUser, sessionId, steamId, messageId, &pollResult);
- if (!poll.IsSuccess())
- return -1;
+ if (!pollResult.IsSuccess())
+ return 0;
- //setString
-
- for (int i = 0; i < poll.GetItemCount(); i++)
+ for (int i = 0; i < pollResult.GetItemCount(); i++)
{
- switch (poll[i]->GetType())
+ switch (pollResult[i]->GetType())
{
case SteamWebApi::PollApi::POOL_TYPE::TYPING:
break;
case SteamWebApi::PollApi::POOL_TYPE::MESSAGE:
{
- const wchar_t *text = ((SteamWebApi::PollApi::Message*)poll[i])->GetText();
+ const wchar_t *text = ((SteamWebApi::PollApi::Message*)pollResult[i])->GetText();
}
break;
case SteamWebApi::PollApi::POOL_TYPE::STATE:
{
- int status = ((SteamWebApi::PollApi::State*)poll[i])->GetStatus();
- const wchar_t *nickname = ((SteamWebApi::PollApi::State*)poll[i])->GetNickname();
+ int status = ((SteamWebApi::PollApi::State*)pollResult[i])->GetStatus();
+ const wchar_t *nickname = ((SteamWebApi::PollApi::State*)pollResult[i])->GetNickname();
}
break;
}
}
- return 0;
+ return pollResult.GetMessageId();
}
void CSteamProto::PollingThread(void*)
{
debugLogA("CSteamProto::PollingThread: entering");
+ ptrA token(getStringA("TokenSecret"));
+ ptrA sessionId(getStringA("SessionID"));
+ UINT32 messageId = getDword("MessageID", 0);
+
while (!m_bTerminated)
- if (PollStatus() == -1)
+ {
+ messageId = PollStatus(token, sessionId, messageId);
+ if (messageId == 0)
break;
+ }
+
+ if (messageId > 0)
+ setDword("MessageID", messageId);
m_hPollingThread = NULL;
debugLogA("CSteamProto::PollingThread: leaving");