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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org)
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 version 2
of the License.
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 COptionsDlg : public CProtoDlgBase<CTelegramProto>
{
CCtrlCheck chkHideChats, chkUsePopups;
CCtrlEdit edtGroup, edtPhone, edtDeviceName;
ptrW m_wszOldGroup;
public:
COptionsDlg(CTelegramProto *ppro, int iDlgID, bool bFullDlg) :
CProtoDlgBase<CTelegramProto>(ppro, iDlgID),
chkUsePopups(this, IDC_POPUPS),
chkHideChats(this, IDC_HIDECHATS),
edtPhone(this, IDC_PHONE),
edtGroup(this, IDC_DEFGROUP),
edtDeviceName(this, IDC_DEVICE_NAME),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
CreateLink(edtPhone, ppro->m_szOwnPhone);
CreateLink(edtGroup, ppro->m_wszDefaultGroup);
CreateLink(edtDeviceName, ppro->m_wszDeviceName);
CreateLink(chkHideChats, ppro->m_bHideGroupchats);
if (bFullDlg)
CreateLink(chkUsePopups, ppro->m_bUsePopups);
}
bool OnApply() override
{
if (!mir_wstrlen(m_proto->m_szOwnPhone)) {
SetFocus(edtPhone.GetHwnd());
return false;
}
if (mir_wstrcmp(m_proto->m_wszDefaultGroup, m_wszOldGroup))
Clist_GroupCreate(0, m_proto->m_wszDefaultGroup);
return true;
}
};
/////////////////////////////////////////////////////////////////////////////////////////
// Advanced options
class CAdvOptionsDlg : public CProtoDlgBase<CTelegramProto>
{
CCtrlEdit edtDiff1, edtDiff2;
CCtrlSpin spin1, spin2;
CCtrlCombo cmbStatus1, cmbStatus2;
public:
CAdvOptionsDlg(CTelegramProto *ppro) :
CProtoDlgBase<CTelegramProto>(ppro, IDD_OPTIONS_ADV),
spin1(this, IDC_SPIN1, 32000),
spin2(this, IDC_SPIN2, 32000),
edtDiff1(this, IDC_DIFF1),
edtDiff2(this, IDC_DIFF2),
cmbStatus1(this, IDC_STATUS1),
cmbStatus2(this, IDC_STATUS2)
{
edtDiff1.OnChange = Callback(this, &CAdvOptionsDlg::onChange_Timeout1);
edtDiff2.OnChange = Callback(this, &CAdvOptionsDlg::onChange_Timeout2);
CreateLink(spin1, ppro->m_iTimeDiff1);
CreateLink(spin2, ppro->m_iTimeDiff2);
}
bool OnInitDialog() override
{
if (cmbStatus1.GetHwnd()) {
for (uint32_t iStatus = ID_STATUS_OFFLINE; iStatus <= ID_STATUS_MAX; iStatus++) {
int idx = cmbStatus1.AddString(Clist_GetStatusModeDescription(iStatus, 0));
cmbStatus1.SetItemData(idx, iStatus);
if (iStatus == m_proto->m_iStatus1)
cmbStatus1.SetCurSel(idx);
idx = cmbStatus2.AddString(Clist_GetStatusModeDescription(iStatus, 0));
cmbStatus2.SetItemData(idx, iStatus);
if (iStatus == m_proto->m_iStatus2)
cmbStatus2.SetCurSel(idx);
}
}
return true;
}
bool OnApply() override
{
if (cmbStatus1.GetHwnd()) {
m_proto->m_iStatus1 = cmbStatus1.GetCurData();
m_proto->m_iStatus2 = cmbStatus2.GetCurData();
}
return true;
}
void onChange_Timeout1(CCtrlEdit *)
{
bool bEnabled = edtDiff1.GetInt() != 0;
spin2.Enable(bEnabled);
edtDiff2.Enable(bEnabled);
cmbStatus1.Enable(bEnabled);
cmbStatus2.Enable(bEnabled && edtDiff2.GetInt() != 0);
}
void onChange_Timeout2(CCtrlEdit *)
{
cmbStatus2.Enable(edtDiff1.GetInt() != 0 && edtDiff2.GetInt() != 0);
}
};
/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CTelegramProto::SvcCreateAccMgrUI(WPARAM, LPARAM hwndParent)
{
auto *pDlg = new COptionsDlg(this, IDD_ACCMGRUI, false);
pDlg->SetParent((HWND)hwndParent);
pDlg->Create();
return (INT_PTR)pDlg->GetHwnd();
}
int CTelegramProto::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);
odp.position = 2;
odp.szTab.w = LPGENW("Advanced");
odp.pDialog = new CAdvOptionsDlg(this);
g_plugin.addOptions(wParam, &odp);
return 0;
}
|