summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-04-03 19:45:30 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-04-03 19:45:30 +0000
commit9149e4c655c6e810ed9cb7a85b8be0eedb201a66 (patch)
tree4bd6238c79eb60cf7502ac47a858c961b35cfc17 /protocols
parentce6e09d0d0d42580b6d1ad6747ac54d82dc821da (diff)
Steam: first approach of server polling
git-svn-id: http://svn.miranda-ng.org/main/trunk@8843 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Steam/Steam_12.vcxproj15
-rw-r--r--protocols/Steam/Steam_12.vcxproj.filters38
-rw-r--r--protocols/Steam/res/Resource.apsbin40908 -> 0 bytes
-rw-r--r--protocols/Steam/src/Steam/authorization.h3
-rw-r--r--protocols/Steam/src/Steam/friend.h12
-rw-r--r--protocols/Steam/src/Steam/friend_list.h2
-rw-r--r--protocols/Steam/src/Steam/login.h6
-rw-r--r--protocols/Steam/src/Steam/poll.h175
-rw-r--r--protocols/Steam/src/Steam/steam.h1
-rw-r--r--protocols/Steam/src/steam.cpp54
-rw-r--r--protocols/Steam/src/steam_account.cpp8
-rw-r--r--protocols/Steam/src/steam_accounts.cpp45
-rw-r--r--protocols/Steam/src/steam_contacts.cpp2
-rw-r--r--protocols/Steam/src/steam_proto.cpp3
-rw-r--r--protocols/Steam/src/steam_thread.cpp58
15 files changed, 301 insertions, 121 deletions
diff --git a/protocols/Steam/Steam_12.vcxproj b/protocols/Steam/Steam_12.vcxproj
index 03bdb203db..27e8bf8acf 100644
--- a/protocols/Steam/Steam_12.vcxproj
+++ b/protocols/Steam/Steam_12.vcxproj
@@ -88,7 +88,7 @@
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
- <PrecompiledHeaderFile>steam.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
@@ -194,19 +194,28 @@
<ItemGroup>
<ClInclude Include="src\http_request.h" />
<ClInclude Include="src\steam.h" />
+ <ClInclude Include="src\Steam\authorization.h" />
+ <ClInclude Include="src\Steam\crypto.h" />
+ <ClInclude Include="src\Steam\friend.h" />
+ <ClInclude Include="src\Steam\friend_list.h" />
+ <ClInclude Include="src\Steam\login.h" />
+ <ClInclude Include="src\Steam\poll.h" />
+ <ClInclude Include="src\Steam\steam.h" />
<ClInclude Include="src\steam_proto.h" />
<ClInclude Include="src\version.h" />
<ClInclude Include="src\resource.h" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\steam.cpp" />
- <ClCompile Include="src\steam_accounts.cpp" />
+ <ClCompile Include="src\steam_account.cpp" />
+ <ClCompile Include="src\steam_contacts.cpp" />
<ClCompile Include="src\steam_events.cpp" />
<ClCompile Include="src\steam_dialogs.cpp" />
+ <ClCompile Include="src\steam_instances.cpp" />
<ClCompile Include="src\steam_proto.cpp" />
<ClCompile Include="src\stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
+ <ClCompile Include="src\steam_thread.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\Version.rc" />
diff --git a/protocols/Steam/Steam_12.vcxproj.filters b/protocols/Steam/Steam_12.vcxproj.filters
index 9dd3117f32..0dc0ba34af 100644
--- a/protocols/Steam/Steam_12.vcxproj.filters
+++ b/protocols/Steam/Steam_12.vcxproj.filters
@@ -13,6 +13,9 @@
<Filter Include="Resource Files\Icon">
<UniqueIdentifier>{4df49e9a-8abc-4fcc-978b-8a6e6f86d70f}</UniqueIdentifier>
</Filter>
+ <Filter Include="Header Files\Steam">
+ <UniqueIdentifier>{d01fa53f-d17d-468f-988d-ab1a2d154af5}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\stdafx.cpp">
@@ -21,16 +24,22 @@
<ClCompile Include="src\steam_proto.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\steam.cpp">
+ <ClCompile Include="src\steam_events.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\steam_accounts.cpp">
+ <ClCompile Include="src\steam_dialogs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\steam_events.cpp">
+ <ClCompile Include="src\steam_account.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\steam_dialogs.cpp">
+ <ClCompile Include="src\steam_instances.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\steam_thread.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\steam_contacts.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -50,6 +59,27 @@
<ClInclude Include="src\http_request.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\Steam\authorization.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\crypto.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\friend.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\friend_list.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\login.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\steam.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Steam\poll.h">
+ <Filter>Header Files\Steam</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">
diff --git a/protocols/Steam/res/Resource.aps b/protocols/Steam/res/Resource.aps
deleted file mode 100644
index e37a9e8d2e..0000000000
--- a/protocols/Steam/res/Resource.aps
+++ /dev/null
Binary files differ
diff --git a/protocols/Steam/src/Steam/authorization.h b/protocols/Steam/src/Steam/authorization.h
index 376781ba94..049afbf55c 100644
--- a/protocols/Steam/src/Steam/authorization.h
+++ b/protocols/Steam/src/Steam/authorization.h
@@ -19,6 +19,7 @@ namespace SteamWebApi
std::string emailsteamid;
bool emailauth_needed;
+// bool emailauth_needed;
public:
bool IsEmailAuthNeeded() { return emailauth_needed; }
@@ -81,7 +82,6 @@ namespace SteamWebApi
{
node = json_get(root, "emailsteamid");
auth->emailsteamid = ptrA(mir_u2a(json_as_string(node)));
- auth->emailauth_needed = false;
/*node = json_get(root, "emaildomain");
result->emaildomain = json_as_string(node);*/
@@ -114,6 +114,7 @@ namespace SteamWebApi
auth->token = ptrA(mir_u2a(json_as_string(node)));
auth->success = true;
+ auth->emailauth_needed = false;
}
}
};
diff --git a/protocols/Steam/src/Steam/friend.h b/protocols/Steam/src/Steam/friend.h
index c6ec704b84..b5f544523f 100644
--- a/protocols/Steam/src/Steam/friend.h
+++ b/protocols/Steam/src/Steam/friend.h
@@ -14,17 +14,20 @@ namespace SteamWebApi
private:
std::string steamId;
- CMStringW nick;
+ std::wstring nickname;
std::string homepage;
std::string avatarUrl;
+ int status;
+
DWORD lastEvent;
public:
const char *GetSteamId() const { return steamId.c_str(); }
- const wchar_t *GetNick() const { return nick.c_str(); }
+ const wchar_t *GetNickname() const { return nickname.c_str(); }
const char *GetHomepage() const { return homepage.c_str(); }
const char *GetAvatarUrl() const { return avatarUrl.c_str(); }
+ int GetStatus() const { return status; }
const DWORD GetLastEvent() const { return lastEvent; }
};
@@ -63,7 +66,10 @@ namespace SteamWebApi
result->steamId = steamId;
node = json_get(child, "personaname");
- result->nick = json_as_string(node);
+ result->nickname = json_as_string(node);
+
+ node = json_get(child, "personastate");
+ result->status = json_as_int(node);
node = json_get(child, "profileurl");
result->homepage = ptrA(mir_u2a(json_as_string(node)));
diff --git a/protocols/Steam/src/Steam/friend_list.h b/protocols/Steam/src/Steam/friend_list.h
index 6b0a5adf50..5cd683fa9b 100644
--- a/protocols/Steam/src/Steam/friend_list.h
+++ b/protocols/Steam/src/Steam/friend_list.h
@@ -16,7 +16,7 @@ namespace SteamWebApi
public:
int GetCount() const { return friendIds.size(); }
- const char * operator[](int idx) const { return friendIds[idx].c_str(); }
+ const char * operator[](int idx) const { return friendIds.at(idx).c_str(); }
};
static void Load(HANDLE hConnection, const char *token, const char *steamId, FriendList *friendList)
diff --git a/protocols/Steam/src/Steam/login.h b/protocols/Steam/src/Steam/login.h
index e12d942f7b..4d0c172681 100644
--- a/protocols/Steam/src/Steam/login.h
+++ b/protocols/Steam/src/Steam/login.h
@@ -13,13 +13,13 @@ namespace SteamWebApi
private:
std::string steamid;
std::string umqid;
- std::string message;
+ UINT32 messageId;
public:
const char *GetSteamId() { return steamid.c_str(); }
const char *GetSessionId() { return umqid.c_str(); }
- const char *GetMessageId() { return message.c_str(); }
+ UINT32 GetMessageId() { return messageId; }
};
static void LogOn(HANDLE hConnection, const char *token, LogIn *login)
@@ -51,7 +51,7 @@ namespace SteamWebApi
login->umqid = ptrA(mir_u2a(json_as_string(node)));
node = json_get(root, "message");
- login->message = ptrA(mir_u2a(json_as_string(node)));
+ login->messageId = json_as_int(node);
login->success = true;
}
diff --git a/protocols/Steam/src/Steam/poll.h b/protocols/Steam/src/Steam/poll.h
new file mode 100644
index 0000000000..eec2e71453
--- /dev/null
+++ b/protocols/Steam/src/Steam/poll.h
@@ -0,0 +1,175 @@
+#ifndef _STEAM_POOL_H_
+#define _STEAM_POOL_H_
+
+namespace SteamWebApi
+{
+ class PollApi : public BaseApi
+ {
+ public:
+ enum POOL_TYPE
+ {
+ MESSAGE = 0,
+ TYPING = 2,
+ STATE = 3,
+ //POOL_TYPE_RELATIONSHIP = 4
+ };
+
+ class PoolItem : public Result
+ {
+ friend PollApi;
+
+ private:
+ std::string steamId;
+ DWORD timestamp;
+ POOL_TYPE type;
+ bool send;
+
+ public:
+ const char *GetSteamId() const { return steamId.c_str(); }
+ const DWORD GetTimestamp() const { return timestamp; }
+ POOL_TYPE GetType() const { return type; }
+ bool IsSend() const { return send; }
+ };
+
+ class Typing : PoolItem { friend PollApi; };
+
+ class Message : PoolItem
+ {
+ friend PollApi;
+
+ private:
+ std::wstring text;
+
+ public:
+ const wchar_t *GetText() const { return text.c_str(); }
+ };
+
+ class State : PoolItem
+ {
+ friend PollApi;
+
+ private:
+ int status;
+ std::wstring nickname;
+
+ public:
+ int GetStatus() const { return status; }
+ const wchar_t *GetNickname() const { return nickname.c_str(); }
+ };
+
+ class Poll : public Result
+ {
+ friend PollApi;
+
+ private:
+ UINT32 messageId;
+ std::vector<PoolItem*> items;
+
+ public:
+ UINT32 GetMessageId() const { return messageId; }
+ int GetItemCount() const { return items.size(); }
+ const PoolItem * operator[](int idx) const { return items.at(idx); }
+ };
+
+ static void PollStatus(HANDLE hConnection, const char *sessionId, const char *steamId, UINT32 messageId, Poll *poll)
+ {
+ poll->success = false;
+
+ CMStringA data;
+ data.AppendFormat("steamid=%s", steamId);
+ data.AppendFormat("&umqid=%s", sessionId);
+ data.AppendFormat("&message=%ui", messageId);
+
+ HttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/PollStatus/v0001");
+ request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ request.SetData(data.GetBuffer(), data.GetLength());
+
+ mir_ptr<NETLIBHTTPREQUEST> response(request.Send());
+ if (!response || response->resultCode != HTTP_STATUS_OK)
+ return;
+
+ JSONNODE *root = json_parse(response->pData), *node, *child;
+ node = json_get(root, "error");
+ ptrW error(json_as_string(node));
+ if (lstrcmpi(error, L"OK"))
+ return;
+
+ node = json_get(root, "messagelast");
+ poll->messageId = json_as_int(node);
+
+ node = json_get(root, "messages");
+ root = json_as_array(node);
+ if (root != NULL)
+ {
+ for (int i = 0;; i++)
+ {
+ child = json_at(root, i);
+ if (child == NULL)
+ break;
+
+ node = json_get(child, "steamid_from");
+ ptrA cSteamId(mir_u2a(json_as_string(node)));
+
+ node = json_get(child, "utc_timestamp");
+ DWORD timestamp = atol(ptrA(mir_u2a(json_as_string(node))));
+
+ PoolItem *item = NULL;
+
+ node = json_get(child, "type");
+ ptrW type(json_as_string(node));
+ if (!lstrcmpi(type, L"saytext") || !lstrcmpi(type, L"emote"))
+ {
+ Message *message = new Message();
+ message->type = POOL_TYPE::MESSAGE;
+
+ node = json_get(child, "text");
+ if (node != NULL) message->text = json_as_string(node);
+
+ item = message;
+ }
+ /*if (!lstrcmpi(type, L"my_saytext") || !lstrcmpi(type, L"my_emote"))
+ {
+ poll->type = POOL_TYPE::MESSAGE;
+ }*/
+ else if(!lstrcmpi(type, L"typing"))
+ {
+ item = new Typing();
+ item->type = POOL_TYPE::TYPING;
+ }
+ else if (!lstrcmpi(type, L"personastate"))
+ {
+ State *state = new State();
+ state->type = POOL_TYPE::STATE;
+
+ node = json_get(child, "persona_state");
+ if (node != NULL) state->status = json_as_int(node);
+
+ node = json_get(child, "personaname");
+ if (node != NULL) state->nickname = json_as_string(node);
+
+ item = state;
+ }
+ /*else if (!lstrcmpi(type, L"personarelationship"))
+ {
+ type = (int)POOL_TYPE::RELATIONSHIP;
+ }*/
+ /*else if (!lstrcmpi(type, L"leftconversation"))
+ {
+ }*/
+ else
+ {
+ int z = 0;
+ }
+
+ if (item != NULL)
+ poll->items.push_back(item);
+ }
+ }
+
+ poll->success = true;
+ }
+ };
+}
+
+
+#endif //_STEAM_POOL_H_ \ No newline at end of file
diff --git a/protocols/Steam/src/Steam/steam.h b/protocols/Steam/src/Steam/steam.h
index ac995f8314..e035310755 100644
--- a/protocols/Steam/src/Steam/steam.h
+++ b/protocols/Steam/src/Steam/steam.h
@@ -33,5 +33,6 @@ namespace SteamWebApi
#include "Steam\login.h"
#include "Steam\friend_list.h"
#include "Steam\friend.h"
+#include "Steam\poll.h"
#endif //_STEAM_H_ \ No newline at end of file
diff --git a/protocols/Steam/src/steam.cpp b/protocols/Steam/src/steam.cpp
deleted file mode 100644
index b052681433..0000000000
--- a/protocols/Steam/src/steam.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "steam.h"
-
-int hLangpack;
-HINSTANCE g_hInstance;
-
-PLUGININFOEX pluginInfo =
-{
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __AUTHOREMAIL,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- // {68F5A030-BA32-48EC-9507-5C2FBDEA5217}
- { 0x68f5a030, 0xba32, 0x48ec, { 0x95, 0x7, 0x5c, 0x2f, 0xbd, 0xea, 0x52, 0x17 }}
-};
-
-DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
-
- return TRUE;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
-{
- return &pluginInfo;
-}
-
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
-
-extern "C" int __declspec(dllexport) Load(void)
-{
- mir_getLP(&pluginInfo);
-
- PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
- pd.szName = "STEAM";
- pd.type = PROTOTYPE_PROTOCOL;
- pd.fnInit = (pfnInitProto)CSteamProto::InitAccount;
- pd.fnUninit = (pfnUninitProto)CSteamProto::UninitAccount;
- CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
-
- return 0;
-}
-
-extern "C" int __declspec(dllexport) Unload(void)
-{
- CSteamProto::UninitAccounts();
-
- return 0;
-} \ No newline at end of file
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp
index 632969ad67..8f9b932347 100644
--- a/protocols/Steam/src/steam_account.cpp
+++ b/protocols/Steam/src/steam_account.cpp
@@ -45,6 +45,7 @@ void CSteamProto::LogInThread(void* param)
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE);
return;
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
}
token = authResult.GetToken();
@@ -63,13 +64,16 @@ void CSteamProto::LogInThread(void* param)
}
setString("SessionID", login.GetSessionId());
- setString("MessageID", login.GetMessageId());
+ setDword("MessageID", login.GetMessageId());
m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iDesiredStatus);
- if (m_hPollingThread == NULL)
+ if (m_hPollingThread == NULL && !m_bTerminated)
+ {
+ m_bTerminated = false;
m_hPollingThread = ForkThreadEx(&CSteamProto::PollingThread, NULL, NULL);
+ }
SteamWebApi::FriendListApi::FriendList friendList;
SteamWebApi::FriendListApi::Load(m_hNetlibUser, token, login.GetSteamId(), &friendList);
diff --git a/protocols/Steam/src/steam_accounts.cpp b/protocols/Steam/src/steam_accounts.cpp
deleted file mode 100644
index 7c77af01c7..0000000000
--- a/protocols/Steam/src/steam_accounts.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "steam.h"
-
-int CSteamProto::CompareProtos(const CSteamProto *p1, const CSteamProto *p2)
-{
- return lstrcmp(p1->m_tszUserName, p2->m_tszUserName);
-}
-
-LIST<CSteamProto> CSteamProto::InstanceList(1, CSteamProto::CompareProtos);
-
-CSteamProto* CSteamProto::InitAccount(const char* protoName, const wchar_t* userName)
-{
- CSteamProto *ppro = new CSteamProto(protoName, userName);
- InstanceList.insert(ppro);
-
- return ppro;
-}
-
-int CSteamProto::UninitAccount(CSteamProto* ppro)
-{
- InstanceList.remove(ppro);
- delete ppro;
-
- return 0;
-}
-
-void CSteamProto::UninitAccounts()
-{
- for (int i = InstanceList.getCount(); i > 0; i--)
- UninitAccount(InstanceList[i]);
- InstanceList.destroy();
-}
-
-CSteamProto* CSteamProto::GetContactAccount(MCONTACT hContact)
-{
- char *proto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0);
-
- if (proto == NULL)
- return NULL;
-
- for (int i = 0; i < InstanceList.getCount(); i++)
- if (!strcmp(proto, InstanceList[i]->m_szModuleName))
- return InstanceList[i];
-
- return NULL;
-} \ No newline at end of file
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index 83731165c9..8929d25bec 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -27,7 +27,7 @@ MCONTACT CSteamProto::AddContact(const SteamWebApi::FriendApi::Friend &contact)
CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)this->m_szModuleName);
this->setString(hContact, "SteamID", contact.GetSteamId());
- this->setWString(hContact, "Nick", contact.GetNick());
+ this->setWString(hContact, "Nick", contact.GetNickname());
this->setString(hContact, "Homepage", contact.GetHomepage());
this->setDword(hContact, "LastEventDateTS", contact.GetLastEvent());
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index ad87d64f29..187b9f577b 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -164,9 +164,6 @@ int CSteamProto::SetStatus(int new_status)
{
if (old_status == ID_STATUS_OFFLINE/* && !this->IsOnline()*/)
{
- UINT64 id = 76561197960435530;
- DWORD in_db = id;
- id = in_db;
m_iStatus = ID_STATUS_CONNECTING;
ForkThread(&CSteamProto::LogInThread, NULL);
diff --git a/protocols/Steam/src/steam_thread.cpp b/protocols/Steam/src/steam_thread.cpp
index 04b631a41c..42b2af3903 100644
--- a/protocols/Steam/src/steam_thread.cpp
+++ b/protocols/Steam/src/steam_thread.cpp
@@ -1,8 +1,64 @@
#include "common.h"
+int SteamToMirandaStatus(int state)
+{
+ switch (state)
+ {
+ case 0: //Offline
+ return ID_STATUS_OFFLINE;
+ case 2: //Busy
+ return ID_STATUS_DND;
+ case 3: //Away
+ return ID_STATUS_AWAY;
+ /*case 4: //Snoozing
+ prim = PURPLE_STATUS_EXTENDED_AWAY;
+ break;
+ case 5: //Looking to trade
+ return "trade";
+ case 6: //Looking to play
+ return "play";*/
+ //case 1: //Online
+ default:
+ return ID_STATUS_ONLINE;
+ }
+}
+
+
int CSteamProto::PollStatus()
{
- Sleep(2000);
+ 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);
+
+ if (!poll.IsSuccess())
+ return -1;
+
+ //setString
+
+ for (int i = 0; i < poll.GetItemCount(); i++)
+ {
+ switch (poll[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();
+ }
+ 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();
+ }
+ break;
+ }
+ }
return 0;
}