summaryrefslogtreecommitdiff
path: root/protocols/WhatsAppWeb/src/options.cpp
blob: c3a5c5b875676369e37d8e4e2f975b4a993a505b (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
/*

WhatsAppWeb plugin for Miranda NG
Copyright © 2019-21 George Hazan

*/

#include "stdafx.h"

/////////////////////////////////////////////////////////////////////////////////////////

class COptionsDlg : public CProtoDlgBase<WhatsAppProto>
{
	CCtrlCheck chkHideChats;
	CCtrlEdit edtGroup;
	ptrW m_wszOldGroup;

public:
	COptionsDlg(WhatsAppProto *ppro, int iDlgID, bool bFullDlg) :
		CProtoDlgBase<WhatsAppProto>(ppro, iDlgID),
		chkHideChats(this, IDC_HIDECHATS),
		edtGroup(this, IDC_DEFGROUP),
		m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
	{
		CreateLink(edtGroup, ppro->m_wszDefaultGroup);

		if (bFullDlg)
			CreateLink(chkHideChats, ppro->m_bHideGroupchats);
	}

	bool OnApply() override
	{
		if (mir_wstrcmp(m_proto->m_wszDefaultGroup, m_wszOldGroup))
			Clist_GroupCreate(0, m_proto->m_wszDefaultGroup);
		return true;
	}
};

/////////////////////////////////////////////////////////////////////////////////////////

INT_PTR WhatsAppProto::SvcCreateAccMgrUI(WPARAM, LPARAM hwndParent)
{
	auto *pDlg = new COptionsDlg(this, IDD_ACCMGRUI, false);
	pDlg->SetParent((HWND)hwndParent);
	pDlg->Create();
	return (INT_PTR)pDlg->GetHwnd();
}

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

	odp.position = 1;
	odp.szTab.w = LPGENW("Account");
	odp.pDialog = new COptionsDlg(this, IDD_OPTIONS, true);
	g_plugin.addOptions(wParam, &odp);
	return 0;
}