From 3c5efcd9b67b26ac0f1d965e157823990b9426c0 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Dec 2014 17:56:59 +0000 Subject: files structure changed git-svn-id: http://svn.miranda-ng.org/main/trunk@11627 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdauth/auth.cpp | 122 ------------ src/core/stdauth/authdialogs.cpp | 286 ---------------------------- src/core/stdauth/commonheaders.cpp | 2 - src/core/stdauth/commonheaders.h | 79 -------- src/core/stdauth/main.cpp | 67 ------- src/core/stdauth/res/resource.rc | 110 +++++++++++ src/core/stdauth/res/version.rc | 38 ++++ src/core/stdauth/resource.rc | 110 ----------- src/core/stdauth/src/auth.cpp | 122 ++++++++++++ src/core/stdauth/src/authdialogs.cpp | 286 ++++++++++++++++++++++++++++ src/core/stdauth/src/commonheaders.cpp | 2 + src/core/stdauth/src/commonheaders.h | 79 ++++++++ src/core/stdauth/src/main.cpp | 67 +++++++ src/core/stdauth/src/version.h | 12 ++ src/core/stdauth/stdauth_10.vcxproj | 20 +- src/core/stdauth/stdauth_10.vcxproj.filters | 17 +- src/core/stdauth/stdauth_12.vcxproj | 20 +- src/core/stdauth/stdauth_12.vcxproj.filters | 17 +- src/core/stdauth/version.h | 14 -- src/core/stdauth/version.rc | 42 ---- 20 files changed, 754 insertions(+), 758 deletions(-) delete mode 100644 src/core/stdauth/auth.cpp delete mode 100644 src/core/stdauth/authdialogs.cpp delete mode 100644 src/core/stdauth/commonheaders.cpp delete mode 100644 src/core/stdauth/commonheaders.h delete mode 100644 src/core/stdauth/main.cpp create mode 100644 src/core/stdauth/res/resource.rc create mode 100644 src/core/stdauth/res/version.rc delete mode 100644 src/core/stdauth/resource.rc create mode 100644 src/core/stdauth/src/auth.cpp create mode 100644 src/core/stdauth/src/authdialogs.cpp create mode 100644 src/core/stdauth/src/commonheaders.cpp create mode 100644 src/core/stdauth/src/commonheaders.h create mode 100644 src/core/stdauth/src/main.cpp create mode 100644 src/core/stdauth/src/version.h delete mode 100644 src/core/stdauth/version.h delete mode 100644 src/core/stdauth/version.rc diff --git a/src/core/stdauth/auth.cpp b/src/core/stdauth/auth.cpp deleted file mode 100644 index df3ea40221..0000000000 --- a/src/core/stdauth/auth.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-14 Miranda NG project (http://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 "commonheaders.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) -{ - TCHAR szUid[128] = _T(""); - TCHAR szTooltip[256]; - const HANDLE hDbEvent = (HANDLE)lParam; - - DBEVENTINFO dbei = { sizeof(dbei) }; - db_event_get((HANDLE)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 = { 0 }; - cli.cbSize = sizeof(cli); - cli.hContact = hContact; - cli.ptszTooltip = szTooltip; - cli.flags = CLEF_TCHAR; - cli.lParam = lParam; - cli.hDbEvent = hDbEvent; - - CONTACTINFO ci = { 0 }; - ci.cbSize = sizeof(ci); - ci.hContact = hContact; - ci.szProto = GetContactProto(hContact); - ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { - switch (ci.type) { - case CNFT_ASCIIZ: - _tcsncpy_s(szUid, ci.pszVal, _TRUNCATE); - mir_free(ci.pszVal); - break; - - case CNFT_DWORD: - mir_sntprintf(szUid, SIZEOF(szUid), _T("%u"), ci.dVal); - break; - } - } - - if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { - SkinPlaySound("AuthRequest"); - if (szUid[0]) - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%s requests authorization"), szUid); - else - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob); - - cli.hIcon = LoadSkinIcon(SKINICON_AUTH_REQUEST); - cli.pszService = MS_AUTH_SHOWREQUEST; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cli); - } - else if (dbei.eventType == EVENTTYPE_ADDED) { - SkinPlaySound("AddedEvent"); - if (szUid[0]) - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%s added you to their contact list"), szUid); - else - mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob); - - cli.hIcon = LoadSkinIcon(SKINICON_AUTH_ADD); - cli.pszService = MS_AUTH_SHOWADDED; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cli); - } - return 0; -} - -int LoadSendRecvAuthModule(void) -{ - CreateServiceFunction(MS_AUTH_SHOWREQUEST, ShowReqWindow); - CreateServiceFunction(MS_AUTH_SHOWADDED, ShowAddedWindow); - HookEvent(ME_DB_EVENT_ADDED, AuthEventAdded); - - SkinAddNewSoundEx("AuthRequest", LPGEN("Alerts"), LPGEN("Authorization request")); - SkinAddNewSoundEx("AddedEvent", LPGEN("Alerts"), LPGEN("Added event")); - return 0; -} diff --git a/src/core/stdauth/authdialogs.cpp b/src/core/stdauth/authdialogs.cpp deleted file mode 100644 index fbbc377047..0000000000 --- a/src/core/stdauth/authdialogs.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-14 Miranda NG project (http://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 "commonheaders.h" - -INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HANDLE hDbEvent = (HANDLE)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 = (HANDLE)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - { - //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) - DBEVENTINFO dbei = { sizeof(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 + strlen(nick) + 1; - char* last = first + strlen(first) + 1; - char* email = last + 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 = ProtoGetAccount(dbei.szModule); - - TCHAR* lastT = dbei.flags & DBEF_UTF ? Utf8DecodeT(last) : mir_a2t(last); - TCHAR* firstT = dbei.flags & DBEF_UTF ? Utf8DecodeT(first) : mir_a2t(first); - TCHAR* nickT = dbei.flags & DBEF_UTF ? Utf8DecodeT(nick) : mir_a2t(nick); - TCHAR* emailT = dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email); - - TCHAR name[128] = _T(""); - int off = 0; - if (firstT[0] && lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), firstT, lastT); - else if (firstT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), firstT); - else if (lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), lastT); - if (nickT[0]) { - if (off) - mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), nickT); - else - _tcsncpy_s(name, nickT, _TRUNCATE); - } - if (!name[0]) - _tcsncpy_s(name, TranslateT(""), _TRUNCATE); - - TCHAR hdr[256]; - if (uin && emailT[0]) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); - else if (uin) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); - else - mir_sntprintf(hdr, SIZEOF(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) -{ - HANDLE hDbEvent = (HANDLE)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 = (HANDLE)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - - //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) - DBEVENTINFO dbei = { sizeof(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 + strlen(nick) + 1; - char *last = first + strlen(first) + 1; - char *email = last + strlen(last) + 1; - char *reason = email + 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 = ProtoGetAccount(dbei.szModule); - - ptrT lastT(dbei.flags & DBEF_UTF ? Utf8DecodeT(last) : mir_a2t(last)); - ptrT firstT(dbei.flags & DBEF_UTF ? Utf8DecodeT(first) : mir_a2t(first)); - ptrT nickT(dbei.flags & DBEF_UTF ? Utf8DecodeT(nick) : mir_a2t(nick)); - ptrT emailT(dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email)); - ptrT reasonT(dbei.flags & DBEF_UTF ? Utf8DecodeT(reason) : mir_a2t(reason)); - - TCHAR name[128] = _T(""); - int off = 0; - if (firstT[0] && lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), (TCHAR*)firstT, (TCHAR*)lastT); - else if (firstT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)firstT); - else if (lastT[0]) - off = mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)lastT); - if (mir_tstrlen(nickT)) { - if (off) - mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), (TCHAR*)nickT); - else - _tcsncpy_s(name, nickT, _TRUNCATE); - } - if (!name[0]) - _tcsncpy_s(name, TranslateT(""), _TRUNCATE); - - TCHAR hdr[256]; - if (uin && emailT[0]) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (TCHAR*)emailT, acc->tszAccountName); - else if (uin) - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); - else - mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (TCHAR*)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 = { sizeof(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 = { sizeof(dbei) }; - db_event_get(hDbEvent, &dbei); - - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON))) { - TCHAR szReason[256]; - GetDlgItemText(hwndDlg, IDC_DENYREASON, szReason, SIZEOF(szReason)); - CallProtoService(dbei.szModule, PS_AUTHDENYT, (WPARAM)hDbEvent, (LPARAM)szReason); - } - else CallProtoService(dbei.szModule, PS_AUTHDENYT, (WPARAM)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/commonheaders.cpp b/src/core/stdauth/commonheaders.cpp deleted file mode 100644 index 95b2201163..0000000000 --- a/src/core/stdauth/commonheaders.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "commonheaders.h" - diff --git a/src/core/stdauth/commonheaders.h b/src/core/stdauth/commonheaders.h deleted file mode 100644 index b40dc69020..0000000000 --- a/src/core/stdauth/commonheaders.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-14 Miranda NG project (http://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. -*/ - -#define WINVER 0x0700 -#define _WIN32_WINNT 0x0700 -#define _WIN32_IE 0x0601 - -#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 -#include -#include -#include -#include -#include - -#include "version.h" - -#include "../../resource.h" -#include "../stdplug.h" - -extern HINSTANCE hInst; diff --git a/src/core/stdauth/main.cpp b/src/core/stdauth/main.cpp deleted file mode 100644 index be9486dcfe..0000000000 --- a/src/core/stdauth/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - -Standard Send/Recv Auth plugin for Miranda NG - -Copyright (C) 2012-14 George Hazan - -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 "commonheaders.h" - -int LoadSendRecvAuthModule(void); - -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 fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAUTH, MIID_LAST }; - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - - LoadSendRecvAuthModule(); - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - return 0; -} diff --git a/src/core/stdauth/res/resource.rc b/src/core/stdauth/res/resource.rc new file mode 100644 index 0000000000..56c32d6d3f --- /dev/null +++ b/src/core/stdauth/res/resource.rc @@ -0,0 +1,110 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\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 + "..\..\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 new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/src/core/stdauth/res/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + 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 diff --git a/src/core/stdauth/resource.rc b/src/core/stdauth/resource.rc deleted file mode 100644 index 56c32d6d3f..0000000000 --- a/src/core/stdauth/resource.rc +++ /dev/null @@ -1,110 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "..\..\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 - "..\..\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/src/auth.cpp b/src/core/stdauth/src/auth.cpp new file mode 100644 index 0000000000..df3ea40221 --- /dev/null +++ b/src/core/stdauth/src/auth.cpp @@ -0,0 +1,122 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://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 "commonheaders.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) +{ + TCHAR szUid[128] = _T(""); + TCHAR szTooltip[256]; + const HANDLE hDbEvent = (HANDLE)lParam; + + DBEVENTINFO dbei = { sizeof(dbei) }; + db_event_get((HANDLE)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 = { 0 }; + cli.cbSize = sizeof(cli); + cli.hContact = hContact; + cli.ptszTooltip = szTooltip; + cli.flags = CLEF_TCHAR; + cli.lParam = lParam; + cli.hDbEvent = hDbEvent; + + CONTACTINFO ci = { 0 }; + ci.cbSize = sizeof(ci); + ci.hContact = hContact; + ci.szProto = GetContactProto(hContact); + ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; + if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { + switch (ci.type) { + case CNFT_ASCIIZ: + _tcsncpy_s(szUid, ci.pszVal, _TRUNCATE); + mir_free(ci.pszVal); + break; + + case CNFT_DWORD: + mir_sntprintf(szUid, SIZEOF(szUid), _T("%u"), ci.dVal); + break; + } + } + + if (dbei.eventType == EVENTTYPE_AUTHREQUEST) { + SkinPlaySound("AuthRequest"); + if (szUid[0]) + mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%s requests authorization"), szUid); + else + mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob); + + cli.hIcon = LoadSkinIcon(SKINICON_AUTH_REQUEST); + cli.pszService = MS_AUTH_SHOWREQUEST; + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cli); + } + else if (dbei.eventType == EVENTTYPE_ADDED) { + SkinPlaySound("AddedEvent"); + if (szUid[0]) + mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%s added you to their contact list"), szUid); + else + mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob); + + cli.hIcon = LoadSkinIcon(SKINICON_AUTH_ADD); + cli.pszService = MS_AUTH_SHOWADDED; + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cli); + } + return 0; +} + +int LoadSendRecvAuthModule(void) +{ + CreateServiceFunction(MS_AUTH_SHOWREQUEST, ShowReqWindow); + CreateServiceFunction(MS_AUTH_SHOWADDED, ShowAddedWindow); + HookEvent(ME_DB_EVENT_ADDED, AuthEventAdded); + + SkinAddNewSoundEx("AuthRequest", LPGEN("Alerts"), LPGEN("Authorization request")); + SkinAddNewSoundEx("AddedEvent", LPGEN("Alerts"), LPGEN("Added event")); + return 0; +} diff --git a/src/core/stdauth/src/authdialogs.cpp b/src/core/stdauth/src/authdialogs.cpp new file mode 100644 index 0000000000..fbbc377047 --- /dev/null +++ b/src/core/stdauth/src/authdialogs.cpp @@ -0,0 +1,286 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://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 "commonheaders.h" + +INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HANDLE hDbEvent = (HANDLE)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 = (HANDLE)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + { + //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) + DBEVENTINFO dbei = { sizeof(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 + strlen(nick) + 1; + char* last = first + strlen(first) + 1; + char* email = last + 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 = ProtoGetAccount(dbei.szModule); + + TCHAR* lastT = dbei.flags & DBEF_UTF ? Utf8DecodeT(last) : mir_a2t(last); + TCHAR* firstT = dbei.flags & DBEF_UTF ? Utf8DecodeT(first) : mir_a2t(first); + TCHAR* nickT = dbei.flags & DBEF_UTF ? Utf8DecodeT(nick) : mir_a2t(nick); + TCHAR* emailT = dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email); + + TCHAR name[128] = _T(""); + int off = 0; + if (firstT[0] && lastT[0]) + off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), firstT, lastT); + else if (firstT[0]) + off = mir_sntprintf(name, SIZEOF(name), _T("%s"), firstT); + else if (lastT[0]) + off = mir_sntprintf(name, SIZEOF(name), _T("%s"), lastT); + if (nickT[0]) { + if (off) + mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), nickT); + else + _tcsncpy_s(name, nickT, _TRUNCATE); + } + if (!name[0]) + _tcsncpy_s(name, TranslateT(""), _TRUNCATE); + + TCHAR hdr[256]; + if (uin && emailT[0]) + mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); + else if (uin) + mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); + else + mir_sntprintf(hdr, SIZEOF(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) +{ + HANDLE hDbEvent = (HANDLE)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 = (HANDLE)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) + DBEVENTINFO dbei = { sizeof(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 + strlen(nick) + 1; + char *last = first + strlen(first) + 1; + char *email = last + strlen(last) + 1; + char *reason = email + 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 = ProtoGetAccount(dbei.szModule); + + ptrT lastT(dbei.flags & DBEF_UTF ? Utf8DecodeT(last) : mir_a2t(last)); + ptrT firstT(dbei.flags & DBEF_UTF ? Utf8DecodeT(first) : mir_a2t(first)); + ptrT nickT(dbei.flags & DBEF_UTF ? Utf8DecodeT(nick) : mir_a2t(nick)); + ptrT emailT(dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email)); + ptrT reasonT(dbei.flags & DBEF_UTF ? Utf8DecodeT(reason) : mir_a2t(reason)); + + TCHAR name[128] = _T(""); + int off = 0; + if (firstT[0] && lastT[0]) + off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), (TCHAR*)firstT, (TCHAR*)lastT); + else if (firstT[0]) + off = mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)firstT); + else if (lastT[0]) + off = mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)lastT); + if (mir_tstrlen(nickT)) { + if (off) + mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), (TCHAR*)nickT); + else + _tcsncpy_s(name, nickT, _TRUNCATE); + } + if (!name[0]) + _tcsncpy_s(name, TranslateT(""), _TRUNCATE); + + TCHAR hdr[256]; + if (uin && emailT[0]) + mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (TCHAR*)emailT, acc->tszAccountName); + else if (uin) + mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); + else + mir_sntprintf(hdr, SIZEOF(hdr), TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (TCHAR*)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 = { sizeof(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 = { sizeof(dbei) }; + db_event_get(hDbEvent, &dbei); + + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON))) { + TCHAR szReason[256]; + GetDlgItemText(hwndDlg, IDC_DENYREASON, szReason, SIZEOF(szReason)); + CallProtoService(dbei.szModule, PS_AUTHDENYT, (WPARAM)hDbEvent, (LPARAM)szReason); + } + else CallProtoService(dbei.szModule, PS_AUTHDENYT, (WPARAM)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/commonheaders.cpp b/src/core/stdauth/src/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdauth/src/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdauth/src/commonheaders.h b/src/core/stdauth/src/commonheaders.h new file mode 100644 index 0000000000..b40dc69020 --- /dev/null +++ b/src/core/stdauth/src/commonheaders.h @@ -0,0 +1,79 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://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. +*/ + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#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 +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stdauth/src/main.cpp b/src/core/stdauth/src/main.cpp new file mode 100644 index 0000000000..be9486dcfe --- /dev/null +++ b/src/core/stdauth/src/main.cpp @@ -0,0 +1,67 @@ +/* + +Standard Send/Recv Auth plugin for Miranda NG + +Copyright (C) 2012-14 George Hazan + +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 "commonheaders.h" + +int LoadSendRecvAuthModule(void); + +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 fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAUTH, MIID_LAST }; + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + LoadSendRecvAuthModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stdauth/src/version.h b/src/core/stdauth/src/version.h new file mode 100644 index 0000000000..970d3e1b02 --- /dev/null +++ b/src/core/stdauth/src/version.h @@ -0,0 +1,12 @@ +#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 "http://miranda-ng.org/p/StdAuth/" +#define __COPYRIGHT "© 2012 Miranda NG Development Team" diff --git a/src/core/stdauth/stdauth_10.vcxproj b/src/core/stdauth/stdauth_10.vcxproj index dd407230d2..c5a14dc7e2 100644 --- a/src/core/stdauth/stdauth_10.vcxproj +++ b/src/core/stdauth/stdauth_10.vcxproj @@ -199,23 +199,21 @@ - - - - Create - Create - Create - Create + + + + Create - + - + + - - + + diff --git a/src/core/stdauth/stdauth_10.vcxproj.filters b/src/core/stdauth/stdauth_10.vcxproj.filters index cb87b64c31..fc99a6f1b1 100644 --- a/src/core/stdauth/stdauth_10.vcxproj.filters +++ b/src/core/stdauth/stdauth_10.vcxproj.filters @@ -15,16 +15,16 @@ - + Source Files - + Source Files - + Source Files - + Source Files @@ -32,15 +32,18 @@ Header Files - + + Header Files + + Header Files - + Resource Files - + Resource Files diff --git a/src/core/stdauth/stdauth_12.vcxproj b/src/core/stdauth/stdauth_12.vcxproj index 045b5c88f3..ff5b5fca31 100644 --- a/src/core/stdauth/stdauth_12.vcxproj +++ b/src/core/stdauth/stdauth_12.vcxproj @@ -202,23 +202,21 @@ - - - - Create - Create - Create - Create + + + + Create - + - + + - - + + diff --git a/src/core/stdauth/stdauth_12.vcxproj.filters b/src/core/stdauth/stdauth_12.vcxproj.filters index cb87b64c31..fc99a6f1b1 100644 --- a/src/core/stdauth/stdauth_12.vcxproj.filters +++ b/src/core/stdauth/stdauth_12.vcxproj.filters @@ -15,16 +15,16 @@ - + Source Files - + Source Files - + Source Files - + Source Files @@ -32,15 +32,18 @@ Header Files - + + Header Files + + Header Files - + Resource Files - + Resource Files diff --git a/src/core/stdauth/version.h b/src/core/stdauth/version.h deleted file mode 100644 index 7078e297c0..0000000000 --- a/src/core/stdauth/version.h +++ /dev/null @@ -1,14 +0,0 @@ - -#include - -#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION -#define __VERSION_STRING MIRANDA_VERSION_STRING - -#define __PLUGIN_NAME "Standard Auth module" -#define __INTERNAL_NAME "stdauth" -#define __FILENAME "stdauth.dll" -#define __DESCRIPTION "Core module for sending/receiving auth requests." -#define __AUTHOR "Miranda NG Development Team" -#define __AUTHOREMAIL "" -#define __AUTHORWEB "http://miranda-ng.org/p/StdAuth/" -#define __COPYRIGHT "© 2012 Miranda NG Development Team" diff --git a/src/core/stdauth/version.rc b/src/core/stdauth/version.rc deleted file mode 100644 index d1da5e8d6a..0000000000 --- a/src/core/stdauth/version.rc +++ /dev/null @@ -1,42 +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 "afxres.h" -#include "version.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#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 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __DESCRIPTION - 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 -- cgit v1.2.3