summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src/options.cpp
blob: a7e7b1f78002b3c775c6966b074212590c9505e0 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*

Facebook plugin for Miranda NG
Copyright © 2019-21 Miranda NG team

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#include "stdafx.h"

class CFacebookAccOptsDlg : public CFBDlgBase
{
	CCtrlEdit edtGroup;
	CCtrlCheck chkEnableChats, chkHideChats, chkKeepUnread, chkLoginInvis, chkLoadAll;
	CCtrlHyperlink linkMainPage;

public:
	CFacebookAccOptsDlg(FacebookProto *pThis) :
		CFBDlgBase(pThis, IDD_OPTIONS),
		edtGroup(this, IDC_GROUP),
		chkLoadAll(this, IDC_LOADALL),
		chkHideChats(this, IDC_HIDECHATS),
		chkKeepUnread(this, IDC_KEEP_UNREAD),
		chkLoginInvis(this, IDC_INVIS_LOGIN),
		chkEnableChats(this, IDC_ENABLECHATS),
		linkMainPage(this, IDC_NEWACCOUNTLINK, "https://www.facebook.com")
	{
		CreateLink(edtGroup, pThis->m_wszDefaultGroup);
		CreateLink(chkLoadAll, pThis->m_bLoadAll);
		CreateLink(chkHideChats, pThis->m_bHideGroupchats);
		CreateLink(chkKeepUnread, pThis->m_bKeepUnread);
		CreateLink(chkLoginInvis, pThis->m_bLoginInvisible);
		CreateLink(chkEnableChats, pThis->m_bUseGroupchats);
	}

	bool OnInitDialog() override
	{
		ptrA login(m_proto->getStringA(DBKEY_LOGIN));
		if (login != nullptr)
			SetDlgItemTextA(m_hwnd, IDC_UN, login);

		ptrA password(m_proto->getStringA(DBKEY_PASS));
		if (password != nullptr)
			SetDlgItemTextA(m_hwnd, IDC_PW, password);
		return true;
	}

	bool OnApply() override
	{
		char str[128];

		GetDlgItemTextA(m_hwnd, IDC_UN, str, _countof(str));
		m_proto->setString(DBKEY_LOGIN, str);

		GetDlgItemTextA(m_hwnd, IDC_PW, str, _countof(str));
		m_proto->setString(DBKEY_PASS, str);
		return true;
	}
};

int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
	OPTIONSDIALOGPAGE odp = {};
	odp.position = -790000000;
	odp.szTitle.w = m_tszUserName;
	odp.szGroup.w = LPGENW("Network");
	odp.flags = ODPF_UNICODE;

	odp.szTab.w = LPGENW("Account");
	odp.pDialog = new CFacebookAccOptsDlg(this);
	g_plugin.addOptions(wParam, &odp);
	return 0;
}