From 4f0e30cdf56fbafdf955bbe8b93930bab9e39bd0 Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Sun, 30 Nov 2014 18:33:56 +0000 Subject: Fix buf size for Get/Set text, open/save file name SMS: SIZE_T -> size_t MRA: small code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@11175 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_options.cpp | 212 +++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 106 deletions(-) (limited to 'protocols/Tox') diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 0cc3f16297..8b6331a8a7 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -1,107 +1,107 @@ -#include "common.h" - -INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - - switch (uMsg) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwnd); - { - proto = (CToxProto*)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); - - ptrT nick(proto->getTStringA("Nick")); - SetDlgItemText(hwnd, IDC_NAME, nick); - - ptrT pass(proto->getTStringA("Password")); - SetDlgItemText(hwnd, IDC_PASSWORD, pass); - - ptrA address(proto->getStringA(TOX_SETTINGS_ID)); - if (address != NULL) - { - SetDlgItemTextA(hwnd, IDC_TOXID, address); - } - - ptrT group(proto->getTStringA(TOX_SETTINGS_GROUP)); - SetDlgItemText(hwnd, IDC_GROUP, group); - SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, 64, 0); - - CheckDlgButton(hwnd, IDC_DISABLE_UDP, proto->getBool("DisableUDP", 0)); - CheckDlgButton(hwnd, IDC_DISABLE_IPV6, proto->getBool("DisableIPv6", 0)); - } - return TRUE; - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_NAME: - case IDC_GROUP: - case IDC_PASSWORD: - if ((HWND)lParam == GetFocus()) - { - if (HIWORD(wParam) != EN_CHANGE) return 0; - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } - break; - - case IDC_DISABLE_UDP: - case IDC_DISABLE_IPV6: - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - } - - case IDC_CLIPBOARD: - { - char toxId[TOX_FRIEND_ADDRESS_SIZE * 2 + 1]; - GetDlgItemTextA(hwnd, IDC_TOXID, toxId, SIZEOF(toxId)); - if (OpenClipboard(GetDlgItem(hwnd, IDC_TOXID))) - { - EmptyClipboard(); - HGLOBAL hMem = GlobalAlloc(GMEM_FIXED, SIZEOF(toxId)); - memcpy(GlobalLock(hMem), toxId, SIZEOF(toxId)); - GlobalUnlock(hMem); - SetClipboardData(CF_TEXT, hMem); - CloseClipboard(); - } - } - break; - } - break; - - case WM_NOTIFY: - if (reinterpret_cast(lParam)->code == PSN_APPLY) - { - TCHAR nick[TOX_MAX_NAME_LENGTH], pass[MAX_PATH]; - GetDlgItemText(hwnd, IDC_NAME, nick, TOX_MAX_NAME_LENGTH); - proto->setTString("Nick", nick); - - GetDlgItemText(hwnd, IDC_PASSWORD, pass, SIZEOF(pass)); - proto->setTString("Password", pass); - - proto->setByte("DisableUDP", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_UDP)); - proto->setByte("DisableIPv6", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_IPV6)); - - TCHAR group[64]; - GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group)); - if (_tcslen(group) > 0) - { - proto->setTString(NULL, TOX_SETTINGS_GROUP, group); - Clist_CreateGroup(0, group); - } - else - { - proto->delSetting(NULL, TOX_SETTINGS_GROUP); - } - - proto->SaveToxProfile(); - - return TRUE; - } - break; - } - - return FALSE; +#include "common.h" + +INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + switch (uMsg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwnd); + { + proto = (CToxProto*)lParam; + SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); + + ptrT nick(proto->getTStringA("Nick")); + SetDlgItemText(hwnd, IDC_NAME, nick); + + ptrT pass(proto->getTStringA("Password")); + SetDlgItemText(hwnd, IDC_PASSWORD, pass); + + ptrA address(proto->getStringA(TOX_SETTINGS_ID)); + if (address != NULL) + { + SetDlgItemTextA(hwnd, IDC_TOXID, address); + } + + ptrT group(proto->getTStringA(TOX_SETTINGS_GROUP)); + SetDlgItemText(hwnd, IDC_GROUP, group); + SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, 64, 0); + + CheckDlgButton(hwnd, IDC_DISABLE_UDP, proto->getBool("DisableUDP", 0)); + CheckDlgButton(hwnd, IDC_DISABLE_IPV6, proto->getBool("DisableIPv6", 0)); + } + return TRUE; + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_NAME: + case IDC_GROUP: + case IDC_PASSWORD: + if ((HWND)lParam == GetFocus()) + { + if (HIWORD(wParam) != EN_CHANGE) return 0; + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_DISABLE_UDP: + case IDC_DISABLE_IPV6: + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; + } + + case IDC_CLIPBOARD: + { + char toxId[TOX_FRIEND_ADDRESS_SIZE * 2 + 1]; + GetDlgItemTextA(hwnd, IDC_TOXID, toxId, SIZEOF(toxId)); + if (OpenClipboard(GetDlgItem(hwnd, IDC_TOXID))) + { + EmptyClipboard(); + HGLOBAL hMem = GlobalAlloc(GMEM_FIXED, sizeof(toxId)); + memcpy(GlobalLock(hMem), toxId, sizeof(toxId)); + GlobalUnlock(hMem); + SetClipboardData(CF_TEXT, hMem); + CloseClipboard(); + } + } + break; + } + break; + + case WM_NOTIFY: + if (reinterpret_cast(lParam)->code == PSN_APPLY) + { + TCHAR nick[TOX_MAX_NAME_LENGTH], pass[MAX_PATH]; + GetDlgItemText(hwnd, IDC_NAME, nick, TOX_MAX_NAME_LENGTH); + proto->setTString("Nick", nick); + + GetDlgItemText(hwnd, IDC_PASSWORD, pass, SIZEOF(pass)); + proto->setTString("Password", pass); + + proto->setByte("DisableUDP", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_UDP)); + proto->setByte("DisableIPv6", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_IPV6)); + + TCHAR group[64]; + GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group)); + if (_tcslen(group) > 0) + { + proto->setTString(NULL, TOX_SETTINGS_GROUP, group); + Clist_CreateGroup(0, group); + } + else + { + proto->delSetting(NULL, TOX_SETTINGS_GROUP); + } + + proto->SaveToxProfile(); + + return TRUE; + } + break; + } + + return FALSE; } \ No newline at end of file -- cgit v1.2.3