summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_events.cpp
blob: 4a61c913efc4197f96428c8135707109dcb7bf4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "common.h"

int CSteamProto::OnModulesLoaded(WPARAM, LPARAM)
{
	HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, this);

	TCHAR name[128];
	mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), m_tszUserName);

	NETLIBUSER nlu = { sizeof(nlu) };
	nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
	nlu.ptszDescriptiveName = name;
	nlu.szSettingsModule = m_szModuleName;
	m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);

	HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSteamProto::PrebuildContactMenu);

	return 0;
}

int CSteamProto::OnPreShutdown(WPARAM, LPARAM)
{
	//SetStatus(ID_STATUS_OFFLINE);

	Netlib_CloseHandle(this->m_hNetlibUser);
	this->m_hNetlibUser = NULL;

	return 0;
}

INT_PTR CSteamProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam)
{
	return (int)CreateDialogParam(
		g_hInstance,
		MAKEINTRESOURCE(IDD_ACCMGR),
		(HWND)lParam,
		CSteamProto::MainOptionsProc,
		(LPARAM)this);
}

int CSteamProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam)
{
	CSteamProto *instance = (CSteamProto*)obj;

	char *title = mir_t2a(instance->m_tszUserName);

	OPTIONSDIALOGPAGE odp = { sizeof(odp) };
	odp.hInstance = g_hInstance;
	odp.pszTitle = title;
	odp.dwInitParam = LPARAM(obj);
	odp.flags = ODPF_BOLDGROUPS;
	odp.pszGroup = LPGEN("Network");

	odp.pszTab = LPGEN("Account");
	odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN);
	odp.pfnDlgProc = MainOptionsProc;
	Options_AddPage(wParam, &odp);

	odp.pszTab = LPGEN("Blocked contacts");
	odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_BLOCK_LIST);
	odp.pfnDlgProc = BlockListOptionsProc;
	Options_AddPage(wParam, &odp);

	mir_free(title);

	return 0;
}