From 1b803834c3f1736e658477a042b51d1926e11e7b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Dec 2017 18:28:41 +0300 Subject: StdAuth plugin merged back with mir_app.dll --- src/core/stdauth/CMakeLists.txt | 2 - src/core/stdauth/res/resource.rc | 110 ------------ src/core/stdauth/res/version.rc | 55 ------ src/core/stdauth/src/auth.cpp | 104 ----------- src/core/stdauth/src/authdialogs.cpp | 286 ------------------------------- src/core/stdauth/src/main.cpp | 69 -------- src/core/stdauth/src/stdafx.cxx | 1 - src/core/stdauth/src/stdafx.h | 68 -------- src/core/stdauth/src/version.h | 12 -- src/core/stdauth/stdauth.vcxproj | 28 --- src/core/stdauth/stdauth.vcxproj.filters | 4 - src/mir_app/res/resource.rc | 45 +++++ src/mir_app/src/auth.cpp | 104 +++++++++++ src/mir_app/src/authdialogs.cpp | 286 +++++++++++++++++++++++++++++++ src/mir_app/src/modules.cpp | 2 + src/mir_app/src/newplugins.cpp | 32 ++-- 16 files changed, 453 insertions(+), 755 deletions(-) delete mode 100644 src/core/stdauth/CMakeLists.txt delete mode 100644 src/core/stdauth/res/resource.rc delete mode 100644 src/core/stdauth/res/version.rc delete mode 100644 src/core/stdauth/src/auth.cpp delete mode 100644 src/core/stdauth/src/authdialogs.cpp delete mode 100644 src/core/stdauth/src/main.cpp delete mode 100644 src/core/stdauth/src/stdafx.cxx delete mode 100644 src/core/stdauth/src/stdafx.h delete mode 100644 src/core/stdauth/src/version.h delete mode 100644 src/core/stdauth/stdauth.vcxproj delete mode 100644 src/core/stdauth/stdauth.vcxproj.filters create mode 100644 src/mir_app/src/auth.cpp create mode 100644 src/mir_app/src/authdialogs.cpp (limited to 'src') diff --git a/src/core/stdauth/CMakeLists.txt b/src/core/stdauth/CMakeLists.txt deleted file mode 100644 index eb455710b9..0000000000 --- a/src/core/stdauth/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -set(TARGET StdAuth) -include(${CMAKE_SOURCE_DIR}/cmake/core.cmake) \ No newline at end of file diff --git a/src/core/stdauth/res/resource.rc b/src/core/stdauth/res/resource.rc deleted file mode 100644 index d909dfcb98..0000000000 --- a/src/core/stdauth/res/resource.rc +++ /dev/null @@ -1,110 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "..\..\mir_app\src\resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include -#include - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_AUTHREQ DIALOGEX 0, 0, 271, 197 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Authorization request" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,271,25 - DEFPUSHBUTTON "&Authorize",IDOK,17,176,50,14 - PUSHBUTTON "&Deny",IDCANCEL,97,176,50,14 - PUSHBUTTON "Decide &later",IDC_DECIDELATER,175,176,74,14 - CONTROL "User &details",IDC_DETAILS,"MButtonClass",WS_TABSTOP,248,29,16,14,WS_EX_NOACTIVATE | 0x10000000L - LTEXT "Reason:",IDC_STATIC,7,39,101,10,SS_CENTERIMAGE - EDITTEXT IDC_REASON,7,50,257,54,ES_MULTILINE | ES_READONLY | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL,WS_EX_STATICEDGE - LTEXT "Denial reason:",IDC_STATIC,7,111,89,10,SS_CENTERIMAGE | SS_REALSIZECONTROL - EDITTEXT IDC_DENYREASON,7,124,257,32,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE - CONTROL "Add to contact list if authorized",IDC_ADDCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,162,239,10 -END - -IDD_ADDED DIALOGEX 0, 0, 241, 70 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "You were added" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,241,25 - PUSHBUTTON "&Close",IDCANCEL,90,51,60,14 - CONTROL "User &details",IDC_DETAILS,"MButtonClass",WS_TABSTOP,217,29,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&Add",IDC_ADD,"MButtonClass",WS_TABSTOP,197,29,16,14,WS_EX_NOACTIVATE | 0x10000000L -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_AUTHREQ, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 264 - BOTTOMMARGIN, 190 - END - - IDD_ADDED, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 233 - TOPMARGIN, 3 - BOTTOMMARGIN, 65 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "..\..\mir_app\src\resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include \r\n" - "#include \r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED diff --git a/src/core/stdauth/res/version.rc b/src/core/stdauth/res/version.rc deleted file mode 100644 index fdeb14668c..0000000000 --- a/src/core/stdauth/res/version.rc +++ /dev/null @@ -1,55 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "..\src\version.h" - -#define APSTUDIO_READONLY_SYMBOLS -#include "afxres.h" -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Author", __AUTHOR - VALUE "FileDescription", __DESCRIPTION - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// diff --git a/src/core/stdauth/src/auth.cpp b/src/core/stdauth/src/auth.cpp deleted file mode 100644 index ec7f829ce5..0000000000 --- a/src/core/stdauth/src/auth.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-17 Miranda NG project (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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; either version 2 -of the License, or (at your option) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" - -#define MS_AUTH_SHOWREQUEST "Auth/ShowRequest" -#define MS_AUTH_SHOWADDED "Auth/ShowAdded" - -INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -INT_PTR ShowReqWindow(WPARAM, LPARAM lParam) -{ - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_AUTHREQ), NULL, DlgProcAuthReq, (LPARAM)((CLISTEVENT *)lParam)->hDbEvent); - return 0; -} - -INT_PTR ShowAddedWindow(WPARAM, LPARAM lParam) -{ - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDED), NULL, DlgProcAdded, (LPARAM)((CLISTEVENT *)lParam)->hDbEvent); - return 0; -} - -static int AuthEventAdded(WPARAM, LPARAM lParam) -{ - wchar_t szTooltip[256]; - MEVENT hDbEvent = (MEVENT)lParam; - - DBEVENTINFO dbei = {}; - db_event_get(lParam, &dbei); - if (dbei.flags & (DBEF_SENT | DBEF_READ) || (dbei.eventType != EVENTTYPE_AUTHREQUEST && dbei.eventType != EVENTTYPE_ADDED)) - return 0; - - dbei.cbBlob = db_event_getBlobSize(hDbEvent); - dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); - db_event_get(hDbEvent, &dbei); - - MCONTACT hContact = DbGetAuthEventContact(&dbei); - - CLISTEVENT cli = {}; - cli.hContact = hContact; - cli.szTooltip.w = szTooltip; - cli.flags = CLEF_UNICODE; - cli.lParam = lParam; - cli.hDbEvent = hDbEvent; - - ptrW szUid(Contact_GetInfo(CNF_UNIQUEID, hContact)); - - if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { - Skin_PlaySound("AuthRequest"); - if (szUid) - mir_snwprintf(szTooltip, TranslateT("%s requests authorization"), szUid); - else - mir_snwprintf(szTooltip, TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob); - - cli.hIcon = Skin_LoadIcon(SKINICON_AUTH_REQUEST); - cli.pszService = MS_AUTH_SHOWREQUEST; - pcli->pfnAddEvent(&cli); - } - else if (dbei.eventType == EVENTTYPE_ADDED) { - Skin_PlaySound("AddedEvent"); - if (szUid) - mir_snwprintf(szTooltip, TranslateT("%s added you to their contact list"), szUid); - else - mir_snwprintf(szTooltip, TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob); - - cli.hIcon = Skin_LoadIcon(SKINICON_AUTH_ADD); - cli.pszService = MS_AUTH_SHOWADDED; - pcli->pfnAddEvent(&cli); - } - return 0; -} - -int LoadSendRecvAuthModule(void) -{ - CreateServiceFunction(MS_AUTH_SHOWREQUEST, ShowReqWindow); - CreateServiceFunction(MS_AUTH_SHOWADDED, ShowAddedWindow); - HookEvent(ME_DB_EVENT_ADDED, AuthEventAdded); - - Skin_AddSound("AuthRequest", LPGENW("Alerts"), LPGENW("Authorization request")); - Skin_AddSound("AddedEvent", LPGENW("Alerts"), LPGENW("Added event")); - return 0; -} diff --git a/src/core/stdauth/src/authdialogs.cpp b/src/core/stdauth/src/authdialogs.cpp deleted file mode 100644 index 9eaa6f2877..0000000000 --- a/src/core/stdauth/src/authdialogs.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-17 Miranda NG project (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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; either version 2 -of the License, or (at your option) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" - -INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - MEVENT hDbEvent = (MEVENT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); - Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); - - hDbEvent = lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - { - //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) - DBEVENTINFO dbei = {}; - dbei.cbBlob = db_event_getBlobSize(hDbEvent); - dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); - db_event_get(hDbEvent, &dbei); - - DWORD uin = *(PDWORD)dbei.pBlob; - MCONTACT hContact = DbGetAuthEventContact(&dbei); - char* nick = (char*)dbei.pBlob + sizeof(DWORD) * 2; - char* first = nick + mir_strlen(nick) + 1; - char* last = first + mir_strlen(first) + 1; - char* email = last + mir_strlen(last) + 1; - - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); - - PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule); - - wchar_t* lastT = dbei.flags & DBEF_UTF ? Utf8DecodeW(last) : mir_a2u(last); - wchar_t* firstT = dbei.flags & DBEF_UTF ? Utf8DecodeW(first) : mir_a2u(first); - wchar_t* nickT = dbei.flags & DBEF_UTF ? Utf8DecodeW(nick) : mir_a2u(nick); - wchar_t* emailT = dbei.flags & DBEF_UTF ? Utf8DecodeW(email) : mir_a2u(email); - - wchar_t name[128] = L""; - int off = 0; - if (firstT[0] && lastT[0]) - off = mir_snwprintf(name, L"%s %s", firstT, lastT); - else if (firstT[0]) - off = mir_snwprintf(name, L"%s", firstT); - else if (lastT[0]) - off = mir_snwprintf(name, L"%s", lastT); - if (nickT[0]) { - if (off) - mir_snwprintf(name + off, _countof(name) - off, L" (%s)", nickT); - else - wcsncpy_s(name, nickT, _TRUNCATE); - } - if (!name[0]) - wcsncpy_s(name, TranslateT(""), _TRUNCATE); - - wchar_t hdr[256]; - if (uin && emailT[0]) - mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); - else if (uin) - mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); - else - mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT : TranslateT("(Unknown)"), acc->tszAccountName); - - SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); - - mir_free(lastT); - mir_free(firstT); - mir_free(nickT); - mir_free(emailT); - - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA, (LONG_PTR)hContact); - - if (hContact == INVALID_CONTACT_ID || !db_get_b(hContact, "CList", "NotOnList", 0)) - ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); - } - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ADD: - { - ADDCONTACTSTRUCT acs = { 0 }; - acs.hDbEvent = hDbEvent; - acs.handleType = HANDLE_EVENT; - acs.szProto = ""; - CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); - - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA); - if ((hContact == INVALID_CONTACT_ID) || !db_get_b(hContact, "CList", "NotOnList", 0)) - ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); - } - break; - - case IDC_DETAILS: - { - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA); - CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); - } - break; - - case IDOK: - { - ADDCONTACTSTRUCT acs = { 0 }; - acs.hDbEvent = hDbEvent; - acs.handleType = HANDLE_EVENT; - acs.szProto = ""; - CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); - } - //fall through - case IDCANCEL: - DestroyWindow(hwndDlg); - break; - } - break; - - case WM_DESTROY: - Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); - Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); - DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); - DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); - break; - } - return FALSE; -} - -INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - MEVENT hDbEvent = (MEVENT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); - Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); - { - hDbEvent = lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - - //blob is: uin(DWORD), hcontact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) - DBEVENTINFO dbei = {}; - dbei.cbBlob = db_event_getBlobSize(hDbEvent); - dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); - db_event_get(hDbEvent, &dbei); - - DWORD uin = *(PDWORD)dbei.pBlob; - MCONTACT hContact = DbGetAuthEventContact(&dbei); - char *nick = (char*)dbei.pBlob + sizeof(DWORD) * 2; - char *first = nick + mir_strlen(nick) + 1; - char *last = first + mir_strlen(first) + 1; - char *email = last + mir_strlen(last) + 1; - char *reason = email + mir_strlen(email) + 1; - - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); - - PROTOACCOUNT *acc = Proto_GetAccount(dbei.szModule); - - ptrW lastT(dbei.flags & DBEF_UTF ? Utf8DecodeW(last) : mir_a2u(last)); - ptrW firstT(dbei.flags & DBEF_UTF ? Utf8DecodeW(first) : mir_a2u(first)); - ptrW nickT(dbei.flags & DBEF_UTF ? Utf8DecodeW(nick) : mir_a2u(nick)); - ptrW emailT(dbei.flags & DBEF_UTF ? Utf8DecodeW(email) : mir_a2u(email)); - ptrW reasonT(dbei.flags & DBEF_UTF ? Utf8DecodeW(reason) : mir_a2u(reason)); - - wchar_t name[128] = L""; - int off = 0; - if (firstT[0] && lastT[0]) - off = mir_snwprintf(name, L"%s %s", (wchar_t*)firstT, (wchar_t*)lastT); - else if (firstT[0]) - off = mir_snwprintf(name, L"%s", (wchar_t*)firstT); - else if (lastT[0]) - off = mir_snwprintf(name, L"%s", (wchar_t*)lastT); - if (mir_wstrlen(nickT)) { - if (off) - mir_snwprintf(name + off, _countof(name) - off, L" (%s)", (wchar_t*)nickT); - else - wcsncpy_s(name, nickT, _TRUNCATE); - } - if (!name[0]) - wcsncpy_s(name, TranslateT(""), _TRUNCATE); - - wchar_t hdr[256]; - if (uin && emailT[0]) - mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (wchar_t*)emailT, acc->tszAccountName); - else if (uin) - mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); - else - mir_snwprintf(hdr, TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (wchar_t*)emailT : TranslateT("(Unknown)"), acc->tszAccountName); - - SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); - SetDlgItemText(hwndDlg, IDC_REASON, reasonT); - - if (hContact == INVALID_CONTACT_ID || !db_get_b(hContact, "CList", "NotOnList", 0)) - ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); - - SendDlgItemMessage(hwndDlg, IDC_DENYREASON, EM_LIMITTEXT, 255, 0); - if (CallProtoService(dbei.szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_NOAUTHDENYREASON) { - EnableWindow(GetDlgItem(hwndDlg, IDC_DENYREASON), FALSE); - SetDlgItemText(hwndDlg, IDC_DENYREASON, TranslateT("Feature is not supported by protocol")); - } - if (!db_get_b(hContact, "CList", "NotOnList", 0)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_ADDCHECK), FALSE); - CheckDlgButton(hwndDlg, IDC_ADDCHECK, BST_UNCHECKED); - } - else CheckDlgButton(hwndDlg, IDC_ADDCHECK, BST_CHECKED); - - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA, (LONG_PTR)hContact); - } - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_DETAILS: - CallService(MS_USERINFO_SHOWDIALOG, GetWindowLongPtr((HWND)lParam, GWLP_USERDATA), 0); - break; - - case IDC_DECIDELATER: - DestroyWindow(hwndDlg); - break; - - case IDOK: - { - DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); - CallProtoService(dbei.szModule, PS_AUTHALLOW, (WPARAM)hDbEvent, 0); - - if (IsDlgButtonChecked(hwndDlg, IDC_ADDCHECK)) { - ADDCONTACTSTRUCT acs = { 0 }; - acs.hDbEvent = hDbEvent; - acs.handleType = HANDLE_EVENT; - acs.szProto = ""; - CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); - } - } - DestroyWindow(hwndDlg); - break; - - case IDCANCEL: - { - DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); - - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON))) { - wchar_t tszReason[256]; - GetDlgItemText(hwndDlg, IDC_DENYREASON, tszReason, _countof(tszReason)); - CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)tszReason); - } - else CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, 0); - } - DestroyWindow(hwndDlg); - break; - } - break; - - case WM_DESTROY: - Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); - Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); - DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); - DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); - break; - } - return FALSE; -} diff --git a/src/core/stdauth/src/main.cpp b/src/core/stdauth/src/main.cpp deleted file mode 100644 index b776f55c54..0000000000 --- a/src/core/stdauth/src/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - -Standard Send/Recv Auth plugin for Miranda NG - -Copyright (c) 2012-17 Miranda NG project (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; either version 2 of the License, or -(at your option) any later version. - -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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "stdafx.h" - -int LoadSendRecvAuthModule(void); - -CLIST_INTERFACE *pcli; -HINSTANCE hInst; -int hLangpack; - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - MIRANDA_VERSION_DWORD, - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - /* 8d0a046d-8ea9-4c55-b568-38da520564fd */ - { 0x8d0a046d, 0x8ea9, 0x4c55, {0xb5, 0x68, 0x38, 0xda, 0x52, 0x05, 0x64, 0xfd}} -}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAUTH, MIID_LAST }; - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - pcli = Clist_GetInterface(); - - LoadSendRecvAuthModule(); - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - return 0; -} diff --git a/src/core/stdauth/src/stdafx.cxx b/src/core/stdauth/src/stdafx.cxx deleted file mode 100644 index a27b824da7..0000000000 --- a/src/core/stdauth/src/stdafx.cxx +++ /dev/null @@ -1 +0,0 @@ -#include "stdafx.h" diff --git a/src/core/stdauth/src/stdafx.h b/src/core/stdauth/src/stdafx.h deleted file mode 100644 index 0392d9bcf1..0000000000 --- a/src/core/stdauth/src/stdafx.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-17 Miranda NG project (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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; either version 2 -of the License, or (at your option) any later version. - -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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "version.h" - -#include "../../mir_app/src/resource.h" - -extern HINSTANCE hInst; diff --git a/src/core/stdauth/src/version.h b/src/core/stdauth/src/version.h deleted file mode 100644 index 1151141425..0000000000 --- a/src/core/stdauth/src/version.h +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION -#define __VERSION_STRING MIRANDA_VERSION_STRING - -#define __PLUGIN_NAME "Standard Auth module" -#define __FILENAME "stdauth.dll" -#define __DESCRIPTION "Core module for sending/receiving auth requests." -#define __AUTHOR "Miranda NG Development Team" -#define __AUTHOREMAIL "" -#define __AUTHORWEB "https://miranda-ng.org/p/StdAuth/" -#define __COPYRIGHT "© 2012-17 Miranda NG Development Team" diff --git a/src/core/stdauth/stdauth.vcxproj b/src/core/stdauth/stdauth.vcxproj deleted file mode 100644 index e4e5d4090b..0000000000 --- a/src/core/stdauth/stdauth.vcxproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - StdAuth - {86E0715E-C769-11E1-A41D-6CED6188709B} - - - - - \ No newline at end of file diff --git a/src/core/stdauth/stdauth.vcxproj.filters b/src/core/stdauth/stdauth.vcxproj.filters deleted file mode 100644 index e39f86d5d6..0000000000 --- a/src/core/stdauth/stdauth.vcxproj.filters +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index ba1f6d591c..992351183a 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -727,6 +727,36 @@ BEGIN PUSHBUTTON "Insert separator",IDC_SEPARATOR,137,211,103,15,BS_MULTILINE END +IDD_AUTHREQ DIALOGEX 0, 0, 271, 197 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Authorization request" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,271,25 + DEFPUSHBUTTON "&Authorize",IDOK,17,176,50,14 + PUSHBUTTON "&Deny",IDCANCEL,97,176,50,14 + PUSHBUTTON "Decide &later",IDC_DECIDELATER,175,176,74,14 + CONTROL "User &details",IDC_DETAILS,"MButtonClass",WS_TABSTOP,248,29,16,14,WS_EX_NOACTIVATE | 0x10000000L + LTEXT "Reason:",IDC_STATIC,7,39,101,10,SS_CENTERIMAGE + EDITTEXT IDC_REASON,7,50,257,54,ES_MULTILINE | ES_READONLY | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL,WS_EX_STATICEDGE + LTEXT "Denial reason:",IDC_STATIC,7,111,89,10,SS_CENTERIMAGE | SS_REALSIZECONTROL + EDITTEXT IDC_DENYREASON,7,124,257,32,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE + CONTROL "Add to contact list if authorized",IDC_ADDCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,162,239,10 +END + +IDD_ADDED DIALOGEX 0, 0, 241, 70 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "You were added" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,241,25 + PUSHBUTTON "&Close",IDCANCEL,90,51,60,14 + CONTROL "User &details",IDC_DETAILS,"MButtonClass",WS_TABSTOP,217,29,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&Add",IDC_ADD,"MButtonClass",WS_TABSTOP,197,29,16,14,WS_EX_NOACTIVATE | 0x10000000L +END + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -998,6 +1028,21 @@ BEGIN VERTGUIDE, 296 BOTTOMMARGIN, 186 END + + IDD_AUTHREQ, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 264 + BOTTOMMARGIN, 190 + END + + IDD_ADDED, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 233 + TOPMARGIN, 3 + BOTTOMMARGIN, 65 + END END #endif // APSTUDIO_INVOKED diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp new file mode 100644 index 0000000000..119b86e061 --- /dev/null +++ b/src/mir_app/src/auth.cpp @@ -0,0 +1,104 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-17 Miranda NG project (https://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" + +#define MS_AUTH_SHOWREQUEST "Auth/ShowRequest" +#define MS_AUTH_SHOWADDED "Auth/ShowAdded" + +INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +INT_PTR ShowReqWindow(WPARAM, LPARAM lParam) +{ + CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AUTHREQ), NULL, DlgProcAuthReq, (LPARAM)((CLISTEVENT *)lParam)->hDbEvent); + return 0; +} + +INT_PTR ShowAddedWindow(WPARAM, LPARAM lParam) +{ + CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_ADDED), NULL, DlgProcAdded, (LPARAM)((CLISTEVENT *)lParam)->hDbEvent); + return 0; +} + +static int AuthEventAdded(WPARAM, LPARAM lParam) +{ + wchar_t szTooltip[256]; + MEVENT hDbEvent = (MEVENT)lParam; + + DBEVENTINFO dbei = {}; + db_event_get(lParam, &dbei); + if (dbei.flags & (DBEF_SENT | DBEF_READ) || (dbei.eventType != EVENTTYPE_AUTHREQUEST && dbei.eventType != EVENTTYPE_ADDED)) + return 0; + + dbei.cbBlob = db_event_getBlobSize(hDbEvent); + dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); + db_event_get(hDbEvent, &dbei); + + MCONTACT hContact = DbGetAuthEventContact(&dbei); + + CLISTEVENT cle = {}; + cle.hContact = hContact; + cle.szTooltip.w = szTooltip; + cle.flags = CLEF_UNICODE; + cle.lParam = lParam; + cle.hDbEvent = hDbEvent; + + ptrW szUid(Contact_GetInfo(CNF_UNIQUEID, hContact)); + + if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { + Skin_PlaySound("AuthRequest"); + if (szUid) + mir_snwprintf(szTooltip, TranslateT("%s requests authorization"), szUid); + else + mir_snwprintf(szTooltip, TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob); + + cle.hIcon = Skin_LoadIcon(SKINICON_AUTH_REQUEST); + cle.pszService = MS_AUTH_SHOWREQUEST; + cli.pfnAddEvent(&cle); + } + else if (dbei.eventType == EVENTTYPE_ADDED) { + Skin_PlaySound("AddedEvent"); + if (szUid) + mir_snwprintf(szTooltip, TranslateT("%s added you to their contact list"), szUid); + else + mir_snwprintf(szTooltip, TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob); + + cle.hIcon = Skin_LoadIcon(SKINICON_AUTH_ADD); + cle.pszService = MS_AUTH_SHOWADDED; + cli.pfnAddEvent(&cle); + } + return 0; +} + +int LoadSendRecvAuthModule(void) +{ + CreateServiceFunction(MS_AUTH_SHOWREQUEST, ShowReqWindow); + CreateServiceFunction(MS_AUTH_SHOWADDED, ShowAddedWindow); + HookEvent(ME_DB_EVENT_ADDED, AuthEventAdded); + + Skin_AddSound("AuthRequest", LPGENW("Alerts"), LPGENW("Authorization request")); + Skin_AddSound("AddedEvent", LPGENW("Alerts"), LPGENW("Added event")); + return 0; +} diff --git a/src/mir_app/src/authdialogs.cpp b/src/mir_app/src/authdialogs.cpp new file mode 100644 index 0000000000..81ab47bfd3 --- /dev/null +++ b/src/mir_app/src/authdialogs.cpp @@ -0,0 +1,286 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-17 Miranda NG project (https://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" + +INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + MEVENT hDbEvent = (MEVENT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); + Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); + + hDbEvent = lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + { + //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) + DBEVENTINFO dbei = {}; + dbei.cbBlob = db_event_getBlobSize(hDbEvent); + dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); + db_event_get(hDbEvent, &dbei); + + DWORD uin = *(PDWORD)dbei.pBlob; + MCONTACT hContact = DbGetAuthEventContact(&dbei); + char* nick = (char*)dbei.pBlob + sizeof(DWORD) * 2; + char* first = nick + mir_strlen(nick) + 1; + char* last = first + mir_strlen(first) + 1; + char* email = last + mir_strlen(last) + 1; + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); + SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); + + PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule); + + wchar_t* lastT = dbei.flags & DBEF_UTF ? Utf8DecodeW(last) : mir_a2u(last); + wchar_t* firstT = dbei.flags & DBEF_UTF ? Utf8DecodeW(first) : mir_a2u(first); + wchar_t* nickT = dbei.flags & DBEF_UTF ? Utf8DecodeW(nick) : mir_a2u(nick); + wchar_t* emailT = dbei.flags & DBEF_UTF ? Utf8DecodeW(email) : mir_a2u(email); + + wchar_t name[128] = L""; + int off = 0; + if (firstT[0] && lastT[0]) + off = mir_snwprintf(name, L"%s %s", firstT, lastT); + else if (firstT[0]) + off = mir_snwprintf(name, L"%s", firstT); + else if (lastT[0]) + off = mir_snwprintf(name, L"%s", lastT); + if (nickT[0]) { + if (off) + mir_snwprintf(name + off, _countof(name) - off, L" (%s)", nickT); + else + wcsncpy_s(name, nickT, _TRUNCATE); + } + if (!name[0]) + wcsncpy_s(name, TranslateT(""), _TRUNCATE); + + wchar_t hdr[256]; + if (uin && emailT[0]) + mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); + else if (uin) + mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); + else + mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT : TranslateT("(Unknown)"), acc->tszAccountName); + + SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); + + mir_free(lastT); + mir_free(firstT); + mir_free(nickT); + mir_free(emailT); + + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA, (LONG_PTR)hContact); + + if (hContact == INVALID_CONTACT_ID || !db_get_b(hContact, "CList", "NotOnList", 0)) + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); + } + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_ADD: + { + ADDCONTACTSTRUCT acs = { 0 }; + acs.hDbEvent = hDbEvent; + acs.handleType = HANDLE_EVENT; + acs.szProto = ""; + CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); + + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA); + if ((hContact == INVALID_CONTACT_ID) || !db_get_b(hContact, "CList", "NotOnList", 0)) + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); + } + break; + + case IDC_DETAILS: + { + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA); + CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); + } + break; + + case IDOK: + { + ADDCONTACTSTRUCT acs = { 0 }; + acs.hDbEvent = hDbEvent; + acs.handleType = HANDLE_EVENT; + acs.szProto = ""; + CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); + } + //fall through + case IDCANCEL: + DestroyWindow(hwndDlg); + break; + } + break; + + case WM_DESTROY: + Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); + Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); + DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + break; + } + return FALSE; +} + +INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + MEVENT hDbEvent = (MEVENT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); + Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); + { + hDbEvent = lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + //blob is: uin(DWORD), hcontact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) + DBEVENTINFO dbei = {}; + dbei.cbBlob = db_event_getBlobSize(hDbEvent); + dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); + db_event_get(hDbEvent, &dbei); + + DWORD uin = *(PDWORD)dbei.pBlob; + MCONTACT hContact = DbGetAuthEventContact(&dbei); + char *nick = (char*)dbei.pBlob + sizeof(DWORD) * 2; + char *first = nick + mir_strlen(nick) + 1; + char *last = first + mir_strlen(first) + 1; + char *email = last + mir_strlen(last) + 1; + char *reason = email + mir_strlen(email) + 1; + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); + SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); + + PROTOACCOUNT *acc = Proto_GetAccount(dbei.szModule); + + ptrW lastT(dbei.flags & DBEF_UTF ? Utf8DecodeW(last) : mir_a2u(last)); + ptrW firstT(dbei.flags & DBEF_UTF ? Utf8DecodeW(first) : mir_a2u(first)); + ptrW nickT(dbei.flags & DBEF_UTF ? Utf8DecodeW(nick) : mir_a2u(nick)); + ptrW emailT(dbei.flags & DBEF_UTF ? Utf8DecodeW(email) : mir_a2u(email)); + ptrW reasonT(dbei.flags & DBEF_UTF ? Utf8DecodeW(reason) : mir_a2u(reason)); + + wchar_t name[128] = L""; + int off = 0; + if (firstT[0] && lastT[0]) + off = mir_snwprintf(name, L"%s %s", (wchar_t*)firstT, (wchar_t*)lastT); + else if (firstT[0]) + off = mir_snwprintf(name, L"%s", (wchar_t*)firstT); + else if (lastT[0]) + off = mir_snwprintf(name, L"%s", (wchar_t*)lastT); + if (mir_wstrlen(nickT)) { + if (off) + mir_snwprintf(name + off, _countof(name) - off, L" (%s)", (wchar_t*)nickT); + else + wcsncpy_s(name, nickT, _TRUNCATE); + } + if (!name[0]) + wcsncpy_s(name, TranslateT(""), _TRUNCATE); + + wchar_t hdr[256]; + if (uin && emailT[0]) + mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (wchar_t*)emailT, acc->tszAccountName); + else if (uin) + mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); + else + mir_snwprintf(hdr, TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (wchar_t*)emailT : TranslateT("(Unknown)"), acc->tszAccountName); + + SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); + SetDlgItemText(hwndDlg, IDC_REASON, reasonT); + + if (hContact == INVALID_CONTACT_ID || !db_get_b(hContact, "CList", "NotOnList", 0)) + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); + + SendDlgItemMessage(hwndDlg, IDC_DENYREASON, EM_LIMITTEXT, 255, 0); + if (CallProtoService(dbei.szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_NOAUTHDENYREASON) { + EnableWindow(GetDlgItem(hwndDlg, IDC_DENYREASON), FALSE); + SetDlgItemText(hwndDlg, IDC_DENYREASON, TranslateT("Feature is not supported by protocol")); + } + if (!db_get_b(hContact, "CList", "NotOnList", 0)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_ADDCHECK), FALSE); + CheckDlgButton(hwndDlg, IDC_ADDCHECK, BST_UNCHECKED); + } + else CheckDlgButton(hwndDlg, IDC_ADDCHECK, BST_CHECKED); + + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA, (LONG_PTR)hContact); + } + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_DETAILS: + CallService(MS_USERINFO_SHOWDIALOG, GetWindowLongPtr((HWND)lParam, GWLP_USERDATA), 0); + break; + + case IDC_DECIDELATER: + DestroyWindow(hwndDlg); + break; + + case IDOK: + { + DBEVENTINFO dbei = {}; + db_event_get(hDbEvent, &dbei); + CallProtoService(dbei.szModule, PS_AUTHALLOW, (WPARAM)hDbEvent, 0); + + if (IsDlgButtonChecked(hwndDlg, IDC_ADDCHECK)) { + ADDCONTACTSTRUCT acs = { 0 }; + acs.hDbEvent = hDbEvent; + acs.handleType = HANDLE_EVENT; + acs.szProto = ""; + CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); + } + } + DestroyWindow(hwndDlg); + break; + + case IDCANCEL: + { + DBEVENTINFO dbei = {}; + db_event_get(hDbEvent, &dbei); + + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON))) { + wchar_t tszReason[256]; + GetDlgItemText(hwndDlg, IDC_DENYREASON, tszReason, _countof(tszReason)); + CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)tszReason); + } + else CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, 0); + } + DestroyWindow(hwndDlg); + break; + } + break; + + case WM_DESTROY: + Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); + Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); + DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + break; + } + return FALSE; +} diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp index 78f03c90a7..6795b63318 100644 --- a/src/mir_app/src/modules.cpp +++ b/src/mir_app/src/modules.cpp @@ -31,6 +31,7 @@ INT_PTR CheckRestart(); // core: IDD_WAITRESTART int LoadSystemModule(void); // core: m_system.h services int LoadNewPluginsModuleInfos(void); // core: preloading plugins +int LoadSendRecvAuthModule(void); // core: auth dialogs int LoadNewPluginsModule(void); // core: N.O. plugins int LoadNetlibModule(void); // core: network int LoadSslModule(void); @@ -140,6 +141,7 @@ int LoadDefaultModules(void) if (LoadFontserviceModule()) return 1; if (LoadSrmmModule()) return 1; if (LoadChatModule()) return 1; + if (LoadSendRecvAuthModule()) return 1; if (LoadDescButtonModule()) return 1; if (LoadOptionsModule()) return 1; if (LoadNetlibModule()) return 1; diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index de3f0a685e..595a0a0be3 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -119,8 +119,9 @@ static const MUUID pluginBannedList[] = { 0x621f886b, 0xa7f6, 0x457f, { 0x9d, 0x62, 0x8e, 0xe8, 0x4c, 0x27, 0x59, 0x93 } }, // modernopt { 0x08B86253, 0xEC6E, 0x4d09, { 0xB7, 0xA9, 0x64, 0xAC, 0xDF, 0x06, 0x27, 0xB8 } }, // gtalkext { 0x4f1ff7fa, 0x4d75, 0x44b9, { 0x93, 0xb0, 0x2c, 0xed, 0x2e, 0x4f, 0x9e, 0x3e } }, // whatsapp - { 0xb908773a, 0x86f7, 0x4a91, { 0x86, 0x74, 0x6a, 0x20, 0xba, 0xe, 0x67, 0xd1 } }, // dropbox (0xe isn't typo - it's from original plugin) + { 0xb908773a, 0x86f7, 0x4a91, { 0x86, 0x74, 0x6a, 0x20, 0xba, 0x0e, 0x67, 0xd1 } }, // dropbox { 0x748f8934, 0x781a, 0x528d, { 0x52, 0x08, 0x00, 0x12, 0x65, 0x40, 0x4a, 0xb3 } }, // tlen + { 0x8d0a046d, 0x8ea9, 0x4c55, { 0xb5, 0x68, 0x38, 0xda, 0x52, 0x05, 0x64, 0xfd } }, // stdauth }; static bool isPluginBanned(const MUUID& u1) @@ -137,18 +138,17 @@ static bool isPluginBanned(const MUUID& u1) static MuuidReplacement pluginDefault[] = { - { MIID_UIUSERINFO, L"stduserinfo", nullptr }, // 0 - { MIID_SREMAIL, L"stdemail", nullptr }, // 1 - { MIID_SRAUTH, L"stdauth", nullptr }, // 2 - { MIID_SRFILE, L"stdfile", nullptr }, // 3 - { MIID_UIHELP, L"stdhelp", nullptr }, // 4 - { MIID_UIHISTORY, L"stduihist", nullptr }, // 5 - { MIID_IDLE, L"stdidle", nullptr }, // 6 - { MIID_AUTOAWAY, L"stdautoaway", nullptr }, // 7 - { MIID_USERONLINE, L"stduseronline", nullptr }, // 8 - { MIID_SRAWAY, L"stdaway", nullptr }, // 9 - { MIID_CLIST, L"stdclist", nullptr }, // 10 - { MIID_SRMM, L"stdmsg", nullptr } // 11 + { MIID_CLIST, L"stdclist", nullptr }, // 0 + { MIID_SRMM, L"stdmsg", nullptr }, // 1 + { MIID_UIUSERINFO, L"stduserinfo", nullptr }, // 2 + { MIID_SREMAIL, L"stdemail", nullptr }, // 3 + { MIID_SRFILE, L"stdfile", nullptr }, // 4 + { MIID_UIHELP, L"stdhelp", nullptr }, // 5 + { MIID_UIHISTORY, L"stduihist", nullptr }, // 6 + { MIID_IDLE, L"stdidle", nullptr }, // 7 + { MIID_AUTOAWAY, L"stdautoaway", nullptr }, // 8 + { MIID_USERONLINE, L"stduseronline", nullptr }, // 9 + { MIID_SRAWAY, L"stdaway", nullptr }, // 10 }; int getDefaultPluginIdx(const MUUID &muuid) @@ -170,7 +170,7 @@ int LoadStdPlugins() return 1; } - if (pluginDefault[11].pImpl == nullptr) + if (pluginDefault[1].pImpl == nullptr) MessageBox(nullptr, TranslateT("No messaging plugins loaded. Please install/enable one of the messaging plugins, for instance, \"StdMsg.dll\""), L"Miranda NG", MB_OK | MB_ICONWARNING); return 0; @@ -627,7 +627,7 @@ static bool loadClistModule(wchar_t* exe, pluginEntry *p) if (bpi.clistlink() == 0) { p->bpi = bpi; p->pclass |= PCLASS_LOADED; - pluginDefault[10].pImpl = p; + pluginDefault[0].pImpl = p; LoadExtraIconsModule(); return true; @@ -651,7 +651,7 @@ static pluginEntry* getCListModule(wchar_t *exe) return p; } - MuuidReplacement& stdClist = pluginDefault[10]; + MuuidReplacement& stdClist = pluginDefault[0]; if (LoadCorePlugin(stdClist)) { mir_snwprintf(tszFullPath, L"%s\\Core\\%s.dll", exe, stdClist.stdplugname); if (loadClistModule(tszFullPath, stdClist.pImpl)) -- cgit v1.2.3