summaryrefslogtreecommitdiff
path: root/protocols/Steam
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-06-21 17:46:15 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-06-21 17:46:15 +0000
commit7941d6d1a2ba1fac7abf817149360d73ed79c799 (patch)
treed336c78e18e291ea4e5c755ddf9a5f65fa163a80 /protocols/Steam
parent13ec12177636fb42c9692664d0f48bd3be2a7fc0 (diff)
Steam: first approach to block list support
git-svn-id: http://svn.miranda-ng.org/main/trunk@9546 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r--protocols/Steam/src/Steam/friend_list.h4
-rw-r--r--protocols/Steam/src/steam_contacts.cpp41
-rw-r--r--protocols/Steam/src/steam_menus.cpp57
-rw-r--r--protocols/Steam/src/steam_pooling.cpp8
-rw-r--r--protocols/Steam/src/steam_proto.cpp6
-rw-r--r--protocols/Steam/src/steam_proto.h6
6 files changed, 111 insertions, 11 deletions
diff --git a/protocols/Steam/src/Steam/friend_list.h b/protocols/Steam/src/Steam/friend_list.h
index f13fe6c56c..feed63f706 100644
--- a/protocols/Steam/src/Steam/friend_list.h
+++ b/protocols/Steam/src/Steam/friend_list.h
@@ -6,12 +6,12 @@ namespace SteamWebApi
class GetFriendListRequest : public HttpsGetRequest
{
public:
- GetFriendListRequest(const char *token, const char *steamId) :
+ GetFriendListRequest(const char *token, const char *steamId, const char *relationship = "friend,ignoredfriend,requestrecipient") :
HttpsGetRequest(STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001")
{
AddParameter("access_token", token);
AddParameter("steamid", steamId);
- AddParameter("relationship=friend,ignoredfriend,requestrecipient");
+ AddParameter("relationship", relationship);
}
};
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index 29a4366523..0d8cfb5472 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -244,6 +244,47 @@ void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response, void *arg)
}
}
+void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response, void *arg)
+{
+ JSONNODE *root = json_parse(response->pData), *node, *child;
+
+ if (root == NULL)
+ return;
+
+ //std::string steamIds;
+
+ node = json_get(root, "friends");
+ root = json_as_array(node);
+ if (root != NULL)
+ {
+ for (size_t i = 0; i < json_size(root); i++)
+ {
+ child = json_at(root, i);
+ if (child == NULL)
+ break;
+
+ node = json_get(child, "steamid");
+ ptrA steamId(mir_u2a(json_as_string(node)));
+
+ /*MCONTACT hContact = FindContact(steamId);
+ if (!hContact)
+ {
+ hContact = AddContact(steamId);
+ steamIds.append(steamId).append(",");
+ }*/
+
+ node = json_get(child, "relationship");
+ ptrA relationship(mir_u2a(json_as_string(node)));
+
+ if (!lstrcmpiA(relationship, "ignoredfriend"))
+ {
+ // todo: open block list
+ }
+ else continue;
+ }
+ }
+}
+
void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *arg)
{
JSONNODE *root = json_parse(response->pData), *node, *item;
diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp
index f0a2e19b21..2f5e114cca 100644
--- a/protocols/Steam/src/steam_menus.cpp
+++ b/protocols/Steam/src/steam_menus.cpp
@@ -50,6 +50,18 @@ int CSteamProto::JoinToGameCommand(WPARAM hContact, LPARAM)
return 0;
}
+int CSteamProto::OpenBlockListCommand(WPARAM, LPARAM)
+{
+ ptrA token(getStringA("TokenSecret"));
+ ptrA steamId(getStringA("SteamID"));
+
+ PushRequest(
+ new SteamWebApi::GetFriendListRequest(token, steamId, "ignoredfriend"),
+ &CSteamProto::OnGotBlockList);
+
+ return 0;
+}
+
int CSteamProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
{
MCONTACT hContact = (MCONTACT)wParam;
@@ -82,6 +94,44 @@ int CSteamProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
return (ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0;
}
+void CSteamProto::OnInitStatusMenu()
+{
+ char text[200];
+ strcpy(text, m_szModuleName);
+ char* tDest = text + strlen(text);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.pszService = text;
+
+ HGENMENU hSteamRoot = MO_GetProtoRootMenu(m_szModuleName);
+ if (!hSteamRoot)
+ {
+ mi.ptszName = m_tszUserName;
+ mi.position = -1999901006;
+ mi.hParentMenu = HGENMENU_ROOT;
+ mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
+ //mi.icolibItem = NULL;
+ hSteamRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&mi);
+ }
+ else
+ {
+ if (m_hMenuRoot)
+ CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)m_hMenuRoot, 0);
+ m_hMenuRoot = NULL;
+ }
+
+ mi.hParentMenu = hSteamRoot;
+ mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR;
+
+ // Show block list
+ strcpy(tDest, "/BlockList");
+ CreateProtoService(tDest, &CSteamProto::OpenBlockListCommand);
+ mi.ptszName = LPGENT("Blocked contacts");
+ mi.position = 200000 + SMI_BLOCKED_LIST;
+ //mi.icolibItem = NULL;
+ Menu_AddProtoMenuItem(&mi);
+}
+
void CSteamProto::InitMenus()
{
hChooserMenu = MO_CreateMenuObject("SkypeAccountChooser", LPGEN("Steam menu chooser"), 0, "Steam/MenuChoose");
@@ -121,5 +171,8 @@ void CSteamProto::InitMenus()
void CSteamProto::UninitMenus()
{
- CallService(MS_CLIST_REMOVETRAYMENUITEM, (WPARAM)contactMenuItems[CMI_JOIN_GAME], 0);
-} \ No newline at end of file
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)contactMenuItems[CMI_AUTH_REQUEST], 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)contactMenuItems[CMI_BLOCK], 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)contactMenuItems[CMI_JOIN_GAME], 0);
+}
+
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp
index d780a57210..93ef78e726 100644
--- a/protocols/Steam/src/steam_pooling.cpp
+++ b/protocols/Steam/src/steam_pooling.cpp
@@ -112,10 +112,12 @@ void CSteamProto::ParsePollData(JSONNODE *data)
case 1:
// ignored
// todo
- MCONTACT hContact = FindContact(steamId);
- if (hContact)
{
- setByte(hContact, "Block", 1);
+ MCONTACT hContact = FindContact(steamId);
+ if (hContact)
+ {
+ setByte(hContact, "Block", 1);
+ }
}
break;
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 2e175c8317..9c80dbc390 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -372,8 +372,6 @@ int __cdecl CSteamProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM
case EV_PROTO_ONCONTACTDELETED:
if (IsOnline())
{
- //ForkThread(&CSteamProto::RemoveContactThread, (void*)getStringA(wParam, "SteamID"));
-
ptrA token(getStringA("TokenSecret"));
ptrA sessionId(getStringA("SessionID"));
ptrA steamId(getStringA("SteamID"));
@@ -386,9 +384,9 @@ int __cdecl CSteamProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM
}
return 0;
- /*case EV_PROTO_ONMENU:
+ case EV_PROTO_ONMENU:
this->OnInitStatusMenu();
- break;*/
+ break;
}
return 1;
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index ca66962572..5e307965e8 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -42,6 +42,7 @@ enum
//CMI_AUTH_REVOKE,
CMI_BLOCK,
CMI_JOIN_GAME,
+ SMI_BLOCKED_LIST,
CMI_MAX // this item shall be the last one
};
@@ -199,6 +200,7 @@ protected:
MCONTACT AddContact(const char *steamId, bool isTemporary = false);
void OnGotFriendList(const NETLIBHTTPREQUEST *response, void *arg);
+ void OnGotBlockList(const NETLIBHTTPREQUEST *response, void *arg);
void OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *arg);
void OnGotAvatar(const NETLIBHTTPREQUEST *response, void *arg);
@@ -228,11 +230,15 @@ protected:
int __cdecl BlockCommand(WPARAM, LPARAM);
int __cdecl JoinToGameCommand(WPARAM, LPARAM);
+ int __cdecl OpenBlockListCommand(WPARAM, LPARAM);
+
static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam);
static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
int OnPrebuildContactMenu(WPARAM wParam, LPARAM);
+ void OnInitStatusMenu();
+
// avatars
wchar_t * GetAvatarFilePath(MCONTACT hContact);