From 2fa4d8fd0f2c29517025dfc3bebc8a5e07c3d380 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Apr 2015 14:39:35 +0000 Subject: - nasty crutch removed from Options_AddPage; - HWND hwndParent removed from the CDlgBase constructor; - method CDlgBase::SetParent() added for the rare occasions where it's needed; git-svn-id: http://svn.miranda-ng.org/main/trunk@12785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_options.cpp | 45 +++++++++++++++------------------------ protocols/Tox/src/tox_options.h | 8 ++----- protocols/Tox/src/tox_profile.cpp | 2 +- protocols/Tox/src/tox_proto.h | 3 --- protocols/Tox/src/tox_search.cpp | 4 ++-- 5 files changed, 22 insertions(+), 40 deletions(-) (limited to 'protocols/Tox/src') diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 4e7fb3103e..25443fb59e 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -1,13 +1,15 @@ #include "common.h" CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog, HWND hwndParent) - : CToxDlgBase(proto, idDialog, hwndParent, false), + : CToxDlgBase(proto, idDialog, false), m_toxAddress(this, IDC_TOXID), m_toxAddressCopy(this, IDC_CLIPBOARD), m_profileCreate(this, IDC_PROFILE_NEW), m_profileImport(this, IDC_PROFILE_IMPORT), m_profileExport(this, IDC_PROFILE_EXPORT), m_nickname(this, IDC_NAME), m_password(this, IDC_PASSWORD), m_group(this, IDC_GROUP), m_enableUdp(this, IDC_ENABLE_UDP), m_enableIPv6(this, IDC_ENABLE_IPV6) { + SetParent(hwndParent); + CreateLink(m_toxAddress, TOX_SETTINGS_ID, _T("")); CreateLink(m_nickname, "Nick", _T("")); CreateLink(m_password, "Password", _T("")); @@ -52,7 +54,7 @@ void CToxOptionsMain::OnInitDialog() void CToxOptionsMain::ToxAddressCopy_OnClick(CCtrlButton*) { char *toxAddress = m_toxAddress.GetTextA(); - int toxAddressLength = mir_strlen(toxAddress) + 1; + size_t toxAddressLength = mir_strlen(toxAddress) + 1; if (OpenClipboard(m_toxAddress.GetHwnd())) { EmptyClipboard(); @@ -147,7 +149,7 @@ void CToxOptionsMain::OnApply() ///////////////////////////////////////////////////////////////////////////////// CToxNodeEditor::CToxNodeEditor(int iItem, CCtrlListView *m_nodes) - : CSuper(g_hInstance, IDD_NODE_EDITOR, NULL), + : CSuper(g_hInstance, IDD_NODE_EDITOR), m_ipv4(this, IDC_IPV4), m_ipv6(this, IDC_IPV6), m_port(this, IDC_PORT), m_pkey(this, IDC_PKEY), m_ok(this, IDOK), m_iItem(iItem) @@ -247,7 +249,7 @@ BOOL CCtrlNodeList::OnNotify(int idCtrl, NMHDR *pnmh) /****************************************/ CToxOptionsNodeList::CToxOptionsNodeList(CToxProto *proto) - : CSuper(proto, IDD_OPTIONS_NODES, NULL, false), + : CSuper(proto, IDD_OPTIONS_NODES, false), m_nodes(this, IDC_NODESLIST), m_addNode(this, IDC_ADDNODE) { m_addNode.OnClick = Callback(this, &CToxOptionsNodeList::OnAddNode); @@ -473,31 +475,18 @@ void CToxOptionsNodeList::OnApply() int CToxProto::OnOptionsInit(WPARAM wParam, LPARAM) { - char *title = mir_t2a(m_tszUserName); - - OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.hInstance = g_hInstance; - odp.pszTitle = title; - odp.flags = ODPF_BOLDGROUPS; - odp.pszGroup = LPGEN("Network"); - - odp.pszTab = LPGEN("Account"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&ToxMainOptions; - ToxMainOptions.create = CToxOptionsMain::CreateOptionsPage; - ToxMainOptions.param = this; + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.ptszTitle = m_tszUserName; + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; + odp.ptszGroup = LPGENT("Network"); + + odp.ptszTab = LPGENT("Account"); + odp.pDialog = new CToxOptionsMain(this, IDD_OPTIONS_MAIN); Options_AddPage(wParam, &odp); - odp.pszTab = LPGEN("Nodes"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_NODES); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&ToxNodeListOptions; - ToxNodeListOptions.create = CToxOptionsNodeList::CreateOptionsPage; - ToxNodeListOptions.param = this; + odp.ptszTab = LPGENT("Nodes"); + odp.pDialog = new CToxOptionsNodeList(this); Options_AddPage(wParam, &odp); - - mir_free(title); - return 0; -} \ No newline at end of file +} diff --git a/protocols/Tox/src/tox_options.h b/protocols/Tox/src/tox_options.h index 0b0e111513..afda3aee4e 100644 --- a/protocols/Tox/src/tox_options.h +++ b/protocols/Tox/src/tox_options.h @@ -38,8 +38,6 @@ public: page->Show(); return page; } - - static CDlgBase *CreateOptionsPage(void *param) { return new CToxOptionsMain((CToxProto*)param, IDD_OPTIONS_MAIN); } }; ///////////////////////////////////////////////////////////////////////////////// @@ -94,9 +92,10 @@ private: CCtrlNodeList m_nodes; CCtrlButton m_addNode; -protected: +public: CToxOptionsNodeList(CToxProto *proto); +protected: void OnInitDialog(); void OnApply(); @@ -104,9 +103,6 @@ protected: void OnNodeListDoubleClick(CCtrlBase*); void OnNodeListClick(CCtrlListView::TEventInfo *evt); void OnNodeListKeyDown(CCtrlListView::TEventInfo *evt); - -public: - static CDlgBase *CreateOptionsPage(void *param) { return new CToxOptionsNodeList((CToxProto*)param); } }; #endif //_TOX_OPTIONS_H_ \ No newline at end of file diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 8ca4bf84a4..2affb68422 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -142,7 +142,7 @@ INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM) } CToxPasswordEditor::CToxPasswordEditor(CToxProto *proto) : - CToxDlgBase(proto, IDD_PASSWORD, NULL, false), ok(this, IDOK), + CToxDlgBase(proto, IDD_PASSWORD, false), ok(this, IDOK), password(this, IDC_PASSWORD), savePermanently(this, IDC_SAVEPERMANENTLY) { ok.OnClick = Callback(this, &CToxPasswordEditor::OnOk); diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index a329252fda..82bfe006f3 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -131,9 +131,6 @@ private: INT_PTR __cdecl CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam); // options - CToxDlgBase::CreateParam ToxMainOptions; - CToxDlgBase::CreateParam ToxNodeListOptions; - int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam); // events diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index f5d5b001b3..62671f7ac7 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -30,7 +30,7 @@ ToxHexAddress ResolveToxAddressFromDnsRecordV3(void *dns, uint32_t requestId, co { std::string id = match[1]; uint8_t data[TOX_ADDRESS_SIZE]; - if (tox_decrypt_dns3_TXT(dns, data, (uint8_t*)id.c_str(), id.length(), requestId) != TOX_ERROR) + if (tox_decrypt_dns3_TXT(dns, data, (uint8_t*)id.c_str(), (uint32_t)id.length(), requestId) != TOX_ERROR) { return ToxHexAddress(data, TOX_ADDRESS_SIZE); } @@ -69,7 +69,7 @@ void CToxProto::SearchByNameAsync(void *arg) uint32_t requestId = 0; uint8_t dnsString[MAX_PATH]; - int length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, mir_strlen(name)); + size_t length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, (uint8_t)mir_strlen(name)); if (length != TOX_ERROR) { dnsString[length] = 0; -- cgit v1.2.3