From cd3ab10b3fb0774f057b1ae4e8f6af7efc85bf60 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 2 Oct 2014 20:33:07 +0000 Subject: Tox: added ability to chage contact dns name git-svn-id: http://svn.miranda-ng.org/main/trunk@10672 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_contacts.cpp | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'protocols/Tox/src/tox_contacts.cpp') diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index c474b0a89a..02549f4abb 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -268,4 +268,96 @@ void CToxProto::OnConnectionStatusChanged(Tox *tox, const int number, const uint proto->delSetting(hContact, "Auth"); } } +} + +int CToxProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) +{ + if (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)m_szModuleName)) + { + return 0; + } + + MCONTACT hContact = lParam; + char *szProto = GetContactProto(hContact); + if (szProto != NULL && !strcmp(szProto, m_szModuleName)) + { + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.flags = ODPF_TCHAR | ODPF_DONTTRANSLATE; + odp.hInstance = g_hInstance; + odp.dwInitParam = (LPARAM)this; + odp.ptszTitle = m_tszUserName; + + odp.pfnDlgProc = UserInfoProc; + odp.position = -2000000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_USER_INFO); + UserInfo_AddPage(wParam, &odp); + } + + return 0; +} + +INT_PTR CToxProto::UserInfoProc(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); + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) + { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_INFOCHANGED: + { + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + char *szProto = (hContact == NULL) ? szProto = proto->m_szModuleName : (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); + if (szProto == NULL) + { + break; + } + + SetDlgItemText(hwnd, IDC_DNS_ID, ptrT(proto->getTStringA(hContact, TOX_SETTINGS_DNS))); + } + break; + + case PSN_PARAMCHANGED: + SetWindowLongPtr(hwnd, GWLP_USERDATA, ((PSHNOTIFY*)lParam)->lParam); + break; + + case PSN_APPLY: + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + char *szProto = (hContact == NULL) ? szProto = proto->m_szModuleName : (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); + if (szProto == NULL) + { + break; + } + TCHAR dnsId[MAX_PATH]; + GetDlgItemText(hwnd, IDC_DNS_ID, dnsId, MAX_PATH); + proto->setTString(hContact, TOX_SETTINGS_DNS, dnsId); + break; + } + break; + } + break; + + case WM_COMMAND: + if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) + { + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + + break; + } + + return FALSE; } \ No newline at end of file -- cgit v1.2.3