summaryrefslogtreecommitdiff
path: root/protocols/Steam
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-05-03 08:57:07 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-05-03 08:57:07 +0000
commit6b0e2e70e2cf701dfb3338379598efe2f168e859 (patch)
treef2de5b3fe9e13d5948ebeb86a18cd9327d729b1d /protocols/Steam
parent70436074ae8f66a092d0212fb8b99b94d0fd03a6 (diff)
Steam: added "Request authorization" contact menu item
git-svn-id: http://svn.miranda-ng.org/main/trunk@9109 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r--protocols/Steam/src/Steam/friend_list.h9
-rw-r--r--protocols/Steam/src/common.h1
-rw-r--r--protocols/Steam/src/steam_account.cpp3
-rw-r--r--protocols/Steam/src/steam_contacts.cpp15
-rw-r--r--protocols/Steam/src/steam_menus.cpp25
-rw-r--r--protocols/Steam/src/steam_proto.cpp24
-rw-r--r--protocols/Steam/src/steam_proto.h10
7 files changed, 69 insertions, 18 deletions
diff --git a/protocols/Steam/src/Steam/friend_list.h b/protocols/Steam/src/Steam/friend_list.h
index 4ce1ae1aec..a7defd8b8e 100644
--- a/protocols/Steam/src/Steam/friend_list.h
+++ b/protocols/Steam/src/Steam/friend_list.h
@@ -120,9 +120,16 @@ namespace SteamWebApi
return;
JSONNODE *root = json_parse(response->pData), *node;
+
+ //{"failed_invites":["xxxxxxxxxxxxxxxxx"], "failed_invites_result" : [41], "success" : 1}
+ /*bool fail = false;
+ node = json_get(root, "failed_invites_result");
+ if (node)
+ fail = true;*/
+
node = json_get(root, "success");
- if ((result->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK || json_as_int(node) == 0)
+ if ((result->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK || json_as_int(node) == 0/* || fail*/)
return;
result->success = true;
diff --git a/protocols/Steam/src/common.h b/protocols/Steam/src/common.h
index fe724a4f93..4069d9e897 100644
--- a/protocols/Steam/src/common.h
+++ b/protocols/Steam/src/common.h
@@ -14,6 +14,7 @@
#include <m_json.h>
#include <m_avatars.h>
#include <m_icolib.h>
+#include <m_skin.h>
#include <m_clist.h>
#include <m_genmenu.h>
#include <m_string.h>
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp
index 13708c50f7..812962db81 100644
--- a/protocols/Steam/src/steam_account.cpp
+++ b/protocols/Steam/src/steam_account.cpp
@@ -177,8 +177,7 @@ void CSteamProto::LogInThread(void* param)
setDword("MessageID", loginResult.GetMessageId());
// set selected status
- m_iStatus = m_iDesiredStatus;
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus);
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus = m_iDesiredStatus);
/*ptrA sessionId(getStringA("SessionID"));
if (!sessionId || lstrlenA(sessionId) == 0)
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index aaccb3bf75..75c85812ce 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -316,7 +316,9 @@ void CSteamProto::AuthDenyThread(void *arg)
void CSteamProto::AddContactThread(void *arg)
{
- MCONTACT hContact = (MCONTACT)arg;
+ SendAuthParam *param = (SendAuthParam*)arg;
+
+ MCONTACT hContact = param->hContact;
if (!hContact)
return;
@@ -331,7 +333,16 @@ void CSteamProto::AddContactThread(void *arg)
debugLogA("CSteamProto::AddContactThread: call SteamWebApi::FriendListApi::AddFriend");
SteamWebApi::FriendListApi::AddFriend(m_hNetlibUser, token, sessionId, steamId, who, &result);
- ProtoBroadcastAck(hContact, ACKTYPE_AUTHREQ, result.IsSuccess() ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)hContact, NULL);
+ if (result.IsSuccess())
+ {
+ delSetting(hContact, "Auth");
+ delSetting(hContact, "Grant");
+ db_unset(hContact, "CList", "NotOnList");
+ }
+
+ ProtoBroadcastAck(hContact, ACKTYPE_AUTHREQ, result.IsSuccess() ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, param->hAuth, 0);
+
+ mir_free(param);
}
void CSteamProto::RemoveContactThread(void *arg)
diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp
index 9ce56ec84c..be3a2ed181 100644
--- a/protocols/Steam/src/steam_menus.cpp
+++ b/protocols/Steam/src/steam_menus.cpp
@@ -18,6 +18,13 @@ INT_PTR CSteamProto::MenuChooseService(WPARAM wParam, LPARAM lParam)
return 0;
}
+int CSteamProto::AuthRequestCommand(WPARAM hContact, LPARAM)
+{
+ CallContactService(hContact, PSS_AUTHREQUEST, 0, 0);
+
+ return 0;
+}
+
int CSteamProto::JoinToGameCommand(WPARAM hContact, LPARAM)
{
char url[MAX_PATH];
@@ -38,6 +45,10 @@ int CSteamProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
return 0;
//bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
+
+ bool authNeeded = getBool(hContact, "Auth", 0);
+ Menu_ShowItem(contactMenuItems[CMI_AUTH_REQUEST], authNeeded);
+
DWORD gameId = getDword(hContact, "GameID", 0);
Menu_ShowItem(contactMenuItems[CMI_JOIN_GAME], gameId > 0);
@@ -61,13 +72,23 @@ void CSteamProto::InitMenus()
// Contact menu initialization
CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(CLISTMENUITEM);
- mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE;
+ mi.flags = CMIF_TCHAR;
+
+ // "Join to game"
+ mi.pszService = MODULE"/AuthRequest";
+ mi.ptszName = LPGENT("Request authorization");
+ mi.position = -201001000 + CMI_AUTH_REQUEST;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST);
+ contactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSteamProto::AuthRequestCommand>);
+
+ mi.flags |= CMIF_NOTOFFLINE;
// "Join to game"
mi.pszService = MODULE"/JoinToGame";
mi.ptszName = LPGENT("Join to game");
mi.position = -200001000 + CMI_JOIN_GAME;
- //mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
+ mi.icolibItem = NULL;
contactMenuItems[CMI_JOIN_GAME] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CSteamProto::JoinToGameCommand>);
}
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index c1258042a0..cc589ec3bc 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -2,6 +2,7 @@
CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName) :
PROTO<CSteamProto>(protoName, userName),
+ hAuthProcess(1),
hMessageProcess(1)
{
CreateProtoService(PS_CREATEACCMGRUI, &CSteamProto::OnAccountManagerInit);
@@ -49,14 +50,12 @@ MCONTACT __cdecl CSteamProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
if (psr->cbSize == sizeof(PROTOSEARCHRESULT))
{
- char *steamId = mir_u2a(psr->id);
+ ptrA steamId(mir_u2a(psr->id));
if (!FindContact(steamId))
{
hContact = AddContact(steamId, true);
- ForkThread(&CSteamProto::UpdateContactsThread, (void*)steamId);
+ ForkThread(&CSteamProto::UpdateContactsThread, (void*)mir_strdup(steamId));
}
- else
- mir_free(steamId);
}
else if (psr->cbSize == sizeof(STEAM_SEARCH_RESULT))
{
@@ -114,9 +113,15 @@ int __cdecl CSteamProto::AuthRequest(MCONTACT hContact, const TCHAR* szMessage)
{
if (IsOnline() && hContact)
{
- ForkThread(&CSteamProto::AddContactThread, (void*)hContact);
+ UINT hAuth = InterlockedIncrement(&hAuthProcess);
- return hContact;
+ SendAuthParam *param = (SendAuthParam*)mir_calloc(sizeof(SendAuthParam));
+ param->hContact = hContact;
+ param->hAuth = (HANDLE)hAuth;
+
+ ForkThread(&CSteamProto::AddContactThread, param);
+
+ return hAuth;
}
return 1;
@@ -147,11 +152,11 @@ DWORD_PTR __cdecl CSteamProto:: GetCaps(int type, MCONTACT hContact)
switch(type)
{
case PFLAGNUM_1:
- return PF1_IM | PF1_BASICSEARCH | PF1_SEARCHBYNAME | PF1_AUTHREQ | PF1_SERVERCLIST;
+ return PF1_IM | PF1_BASICSEARCH | PF1_SEARCHBYNAME | PF1_AUTHREQ | PF1_SERVERCLIST | PF1_ADDSEARCHRES;
case PFLAGNUM_2:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_OUTTOLUNCH;
case PFLAGNUM_4:
- return PF4_NOCUSTOMAUTH | PF4_AVATARS | PF4_NOAUTHDENYREASON;// | PF4_FORCEAUTH | PF4_FORCEADDED;
+ return PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED;// | PF4_IMSENDOFFLINE | PF4_SUPPORTTYPING;
case PFLAGNUM_5:
return PF2_SHORTAWAY | PF2_HEAVYDND | PF2_OUTTOLUNCH;
case PFLAG_UNIQUEIDTEXT:
@@ -300,8 +305,7 @@ int __cdecl CSteamProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM
return this->OnOptionsInit(wParam, lParam);*/
case EV_PROTO_ONCONTACTDELETED:
- if (this->IsOnline())
- ForkThread(&CSteamProto::RemoveContactThread, (void*)getStringA(wParam, "SteamID"));
+ ForkThread(&CSteamProto::RemoveContactThread, (void*)getStringA(wParam, "SteamID"));
return 0;
/*case EV_PROTO_ONMENU:
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 7f188cca14..88a18a74f1 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -17,6 +17,12 @@ struct CaptchaParam
char text[10];
};
+struct SendAuthParam
+{
+ MCONTACT hContact;
+ HANDLE hAuth;
+};
+
struct SendMessageParam
{
MCONTACT hContact;
@@ -32,7 +38,7 @@ struct STEAM_SEARCH_RESULT
enum
{
- //CMI_AUTH_REQUEST,
+ CMI_AUTH_REQUEST,
//CMI_AUTH_GRANT,
//CMI_AUTH_REVOKE,
//CMI_BLOCK,
@@ -106,6 +112,7 @@ public:
protected:
bool m_bTerminated;
HANDLE m_hPollingThread;
+ ULONG hAuthProcess;
ULONG hMessageProcess;
CRITICAL_SECTION contact_search_lock;
@@ -159,6 +166,7 @@ protected:
static HANDLE hChooserMenu;
static HGENMENU contactMenuItems[CMI_MAX];
+ int __cdecl AuthRequestCommand(WPARAM, LPARAM);
int __cdecl JoinToGameCommand(WPARAM, LPARAM);
static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam);