From bed0da01408d35c9a5a311748e9f5266805c8965 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Dec 2014 19:18:28 +0000 Subject: files structure changed git-svn-id: http://svn.miranda-ng.org/main/trunk@11636 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stduserinfo/commonheaders.cpp | 2 - src/core/stduserinfo/commonheaders.h | 78 --- src/core/stduserinfo/contactinfo.cpp | 531 ----------------- src/core/stduserinfo/main.cpp | 71 --- src/core/stduserinfo/res/resource.rc | 304 ++++++++++ src/core/stduserinfo/res/version.rc | 38 ++ src/core/stduserinfo/resource.rc | 304 ---------- src/core/stduserinfo/src/commonheaders.cpp | 2 + src/core/stduserinfo/src/commonheaders.h | 78 +++ src/core/stduserinfo/src/contactinfo.cpp | 531 +++++++++++++++++ src/core/stduserinfo/src/main.cpp | 71 +++ src/core/stduserinfo/src/stdinfo.cpp | 621 ++++++++++++++++++++ src/core/stduserinfo/src/userinfo.cpp | 650 +++++++++++++++++++++ src/core/stduserinfo/src/version.h | 12 + src/core/stduserinfo/stdinfo.cpp | 621 -------------------- src/core/stduserinfo/stduserinfo_10.vcxproj | 22 +- .../stduserinfo/stduserinfo_10.vcxproj.filters | 19 +- src/core/stduserinfo/stduserinfo_12.vcxproj | 22 +- .../stduserinfo/stduserinfo_12.vcxproj.filters | 19 +- src/core/stduserinfo/userinfo.cpp | 650 --------------------- src/core/stduserinfo/version.h | 14 - src/core/stduserinfo/version.rc | 42 -- 22 files changed, 2349 insertions(+), 2353 deletions(-) delete mode 100644 src/core/stduserinfo/commonheaders.cpp delete mode 100644 src/core/stduserinfo/commonheaders.h delete mode 100644 src/core/stduserinfo/contactinfo.cpp delete mode 100644 src/core/stduserinfo/main.cpp create mode 100644 src/core/stduserinfo/res/resource.rc create mode 100644 src/core/stduserinfo/res/version.rc delete mode 100644 src/core/stduserinfo/resource.rc create mode 100644 src/core/stduserinfo/src/commonheaders.cpp create mode 100644 src/core/stduserinfo/src/commonheaders.h create mode 100644 src/core/stduserinfo/src/contactinfo.cpp create mode 100644 src/core/stduserinfo/src/main.cpp create mode 100644 src/core/stduserinfo/src/stdinfo.cpp create mode 100644 src/core/stduserinfo/src/userinfo.cpp create mode 100644 src/core/stduserinfo/src/version.h delete mode 100644 src/core/stduserinfo/stdinfo.cpp delete mode 100644 src/core/stduserinfo/userinfo.cpp delete mode 100644 src/core/stduserinfo/version.h delete mode 100644 src/core/stduserinfo/version.rc (limited to 'src/core/stduserinfo') diff --git a/src/core/stduserinfo/commonheaders.cpp b/src/core/stduserinfo/commonheaders.cpp deleted file mode 100644 index 95b2201163..0000000000 --- a/src/core/stduserinfo/commonheaders.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "commonheaders.h" - diff --git a/src/core/stduserinfo/commonheaders.h b/src/core/stduserinfo/commonheaders.h deleted file mode 100644 index f531d749f3..0000000000 --- a/src/core/stduserinfo/commonheaders.h +++ /dev/null @@ -1,78 +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 "version.h" - -#include "../../resource.h" -#include "../stdplug.h" - -extern HINSTANCE hInst; diff --git a/src/core/stduserinfo/contactinfo.cpp b/src/core/stduserinfo/contactinfo.cpp deleted file mode 100644 index dd3984b1c8..0000000000 --- a/src/core/stduserinfo/contactinfo.cpp +++ /dev/null @@ -1,531 +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" - -static HFONT hEmailFont = NULL; -static HCURSOR hHandCursor = NULL; - -static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (*(char*)lParam) SetWindowText(hwndDlg, TranslateT("Edit E-Mail address")); - TranslateDialogDefault(hwndDlg); - SetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)lParam); - EnableWindow(GetDlgItem(hwndDlg, IDOK), *(char*)lParam); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256); - //fall through - case IDCANCEL: - EndDialog(hwndDlg, wParam); - case IDC_EMAIL: - if (HIWORD(wParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EMAIL))); - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int noRecursion = 0; - - switch(msg) { - case WM_INITDIALOG: - { - char *szText = (char*)lParam; - int i, item, countryCount; - struct CountryListEntry *countries; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (szText[0]) SetWindowText(hwndDlg, TranslateT("Edit phone number")); - TranslateDialogDefault(hwndDlg); - if (mir_strlen(szText)>4 && !mir_strcmp(szText+mir_strlen(szText)-4, " SMS")) { - CheckDlgButton(hwndDlg, IDC_SMS, BST_CHECKED); - szText[mir_strlen(szText)-4] = '\0'; - } - EnableWindow(GetDlgItem(hwndDlg, IDOK), szText[0]); - SendDlgItemMessage(hwndDlg, IDC_AREA, EM_LIMITTEXT, 31, 0); - SendDlgItemMessage(hwndDlg, IDC_NUMBER, EM_LIMITTEXT, 63, 0); - CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); - for (i=0;i 4) - isValid = 0; - else { - for (i = SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0)-1; i >= 0; i--) - if (country == SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, i, 0)) { - SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, i, 0); - break; - } - if (i < 0) - isValid = 0; - } - } - if (isValid) { - pArea = pText+strcspn(pText, "0123456789"); - pText = pArea+strspn(pArea, "0123456789"); - if (*pText) { - *pText = '\0'; - pNumber = pText+1+strcspn(pText+1, "0123456789"); - SetDlgItemTextA(hwndDlg, IDC_NUMBER, pNumber); - } - SetDlgItemTextA(hwndDlg, IDC_AREA, pArea); - } - if ( !isValid) { - SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, -1, 0); - SetDlgItemTextA(hwndDlg, IDC_AREA, ""); - SetDlgItemTextA(hwndDlg, IDC_NUMBER, ""); - } - } - noRecursion = 0; - EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PHONE))); - break; - } - break; - } - return FALSE; -} - -static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) -{ - HWND hwndEmails = GetDlgItem(hwndDlg, IDC_EMAILS); - - LVHITTESTINFO hti; - GetCursorPos(&hti.pt); - ScreenToClient(hwndEmails, &hti.pt); - - RECT rc; - GetClientRect(hwndEmails, &rc); - if ( !PtInRect(&rc, hti.pt)) - return 0; - if (ListView_SubItemHitTest(hwndEmails, &hti) == -1) - return 0; - if (hti.iSubItem != 1 || !(hti.flags & LVHT_ONITEMLABEL)) - return 0; - - ListView_GetSubItemRect(hwndEmails, hti.iItem, 1, LVIR_LABEL, &rc); - - TCHAR szText[256]; szText[0] = 0; - ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, SIZEOF(szText)); - - HDC hdc = GetDC(hwndEmails); - SelectObject(hdc, hEmailFont); - - SIZE textSize; - GetTextExtentPoint32(hdc, szText, (int)mir_tstrlen(szText), &textSize); - ReleaseDC(hwndEmails, hdc); - if (hti.pt.x < rc.left+textSize.cx) { - if (szEmail && cchEmail) - mir_tstrncpy(szEmail, szText, cchEmail); - return 1; - } - return 0; -} - -#define M_REMAKELISTS (WM_USER+1) -INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int i; - - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (hEmailFont) DeleteObject(hEmailFont); - { - LOGFONT lf; - hEmailFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_EMAILS, WM_GETFONT, 0, 0); - GetObject(hEmailFont, sizeof(lf), &lf); - lf.lfUnderline = 1; - hEmailFont = CreateFontIndirect(&lf); - } - if (hHandCursor == NULL) - hHandCursor = LoadCursor(NULL, IDC_HAND); - { - LVCOLUMN lvc; - RECT rc; - GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc); - rc.right-=GetSystemMetrics(SM_CXVSCROLL); - lvc.mask = LVCF_WIDTH; - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); - lvc.cx = rc.right/4; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc); - lvc.cx = rc.right-rc.right/4-40; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc); - lvc.cx = rc.right-rc.right/4-90; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc); - lvc.cx = 50; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc); - lvc.cx = 20; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 2, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 3, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 4, &lvc); - } - break; - - case M_REMAKELISTS: - { - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (hContact != NULL) { - char *szProto = GetContactProto(hContact); - if (szProto == NULL) - break; - - //e-mails - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS)); - - char idstr[33]; - TCHAR idstr2[33]; - DBVARIANT dbv; - - LVITEM lvi; - lvi.mask = LVIF_TEXT|LVIF_PARAM; - lvi.lParam = (LPARAM)(-1); - lvi.iSubItem = 0; - lvi.iItem = 0; - for (i = -1;; i++) { - if (i == -1) { - if (db_get_ts(hContact, szProto, "e-mail", &dbv)) - continue; - lvi.pszText = TranslateT("Primary"); - } - else { - mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i); - if (db_get_ts(hContact, szProto, idstr, &dbv)) - break; - - lvi.pszText = idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), _T("%d"), i+2); - } - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - lvi.iSubItem = 0; - for (i=0;;i++) { - lvi.lParam = i; - mir_snprintf(idstr, SIZEOF(idstr), "Mye-mail%d", i); - if (db_get_ts(hContact, "UserInfo", idstr, &dbv)) - break; - lvi.pszText = idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - lvi.mask = LVIF_PARAM; - lvi.lParam = (LPARAM)(-2); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); - //phones - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES)); - lvi.mask = LVIF_TEXT|LVIF_PARAM; - lvi.lParam = (LPARAM)(-1); - lvi.iSubItem = 0; - lvi.iItem = 0; - if ( !db_get_ts(hContact, szProto, "Phone", &dbv)) { - lvi.pszText = TranslateT("Primary"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - if ( !db_get_ts(hContact, szProto, "Fax", &dbv)) { - lvi.pszText = TranslateT("Fax"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - if ( !db_get_ts(hContact, szProto, "Cellular", &dbv)) { - lvi.pszText = TranslateT("Mobile"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - if (mir_strlen(dbv.pszVal)>4 && !mir_strcmp(dbv.pszVal+mir_strlen(dbv.pszVal)-4, " SMS")) { - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); - dbv.ptszVal[mir_tstrlen(dbv.ptszVal)-4] = '\0'; - } - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - if ( !db_get_ts(hContact, szProto, "CompanyPhone", &dbv)) { - lvi.pszText = TranslateT("Work phone"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - if ( !db_get_ts(hContact, szProto, "CompanyFax", &dbv)) { - lvi.pszText = TranslateT("Work fax"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - lvi.iSubItem = 0; - for (i=0;; i++) { - lvi.lParam = i; - mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d", i); - if (db_get_ts(hContact, "UserInfo", idstr, &dbv)) - break; - lvi.pszText = idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - if (mir_tstrlen(dbv.ptszVal)>4 && !mir_tstrcmp(dbv.ptszVal+mir_tstrlen(dbv.ptszVal)-4, _T(" SMS"))) { - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); - dbv.ptszVal[mir_tstrlen(dbv.ptszVal)-4] = '\0'; - } - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - db_free(&dbv); - lvi.iItem++; - } - lvi.mask = LVIF_PARAM; - lvi.lParam = (LPARAM)(-2); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - } - } - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - break; - - case IDC_EMAILS: - case IDC_PHONES: - switch (((LPNMHDR)lParam)->code) { - case NM_CUSTOMDRAW: - { - NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW*)lParam; - switch(nm->nmcd.dwDrawStage) { - case CDDS_PREPAINT: - case CDDS_ITEMPREPAINT: - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW); - return TRUE; - - case CDDS_SUBITEM|CDDS_ITEMPREPAINT: - { - RECT rc; - ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc); - if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) { - HFONT hoFont; - TCHAR szText[256] = {0}; - ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); - hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont); - SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255)); - DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); - SelectObject(nm->nmcd.hdc, hoFont); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); - return TRUE; - } - - HICON hIcon = NULL; - if (nm->nmcd.lItemlParam == (LPARAM)(-2) && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES)) - hIcon = LoadSkinIcon(SKINICON_OTHER_ADDCONTACT); - else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != (LPARAM)(-1) && nm->nmcd.lItemlParam != (LPARAM)(-2)) { - static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE}; - if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) { - TCHAR szText[2]; - ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); - if (szText[0]) hIcon = LoadSkinIcon(SKINICON_OTHER_SMS); - } - else hIcon = LoadSkinIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]); - } - else break; - DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); - IcoLib_ReleaseIcon(hIcon, 0); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); - return TRUE; - } - } - } - break; - - case NM_CLICK: - { - NMLISTVIEW *nm = (NMLISTVIEW*)lParam; - LVITEM lvi; - TCHAR szEmail[256]; - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d"; - LVHITTESTINFO hti; - - if (IsOverEmail(hwndDlg, szEmail, SIZEOF(szEmail))) { - TCHAR szExec[264]; - mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); - ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); - break; - } - if (nm->iSubItem<2) break; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(nm->hdr.hwndFrom, &hti.pt); - if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break; - lvi.mask = LVIF_PARAM; - lvi.iItem = hti.iItem; - lvi.iSubItem = 0; - ListView_GetItem(nm->hdr.hwndFrom, &lvi); - if (lvi.lParam == (LPARAM)(-1)) break; - if (lvi.lParam == (LPARAM)(-2)) { - if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { - //add - char szNewData[256] = "", idstr[33]; - DBVARIANT dbv; - if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData)) - break; - for (int i=0;; i++) { - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); - if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; - db_free(&dbv); - } - db_set_s(hContact, "UserInfo", idstr, szNewData); - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - } - } - else if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { - //delete - char idstr[33]; - DBVARIANT dbv; - for (i = lvi.lParam;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i+1); - if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); - db_set_s(hContact, "UserInfo", idstr, dbv.pszVal); - db_free(&dbv); - } - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); - db_unset(hContact, "UserInfo", idstr); - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - } - else if (hti.iSubItem-2 == (nm->hdr.idFrom == IDC_PHONES)) { - //edit - char szText[256], idstr[33]; - DBVARIANT dbv; - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, lvi.lParam); - if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; - mir_strncpy(szText, dbv.pszVal, SIZEOF(szText)); - db_free(&dbv); - if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText)) - break; - db_set_s(hContact, "UserInfo", idstr, szText); - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - } - } - } - } - break; - - case WM_SETCURSOR: - if (LOWORD(lParam) != HTCLIENT) break; - if (GetForegroundWindow() == GetParent(hwndDlg)) { - POINT pt; - GetCursorPos(&pt); - ScreenToClient(hwndDlg, &pt); - } - if (IsOverEmail(hwndDlg, NULL, 0)) { - SetCursor(hHandCursor); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); - return TRUE; - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - } - break; - } - return FALSE; -} diff --git a/src/core/stduserinfo/main.cpp b/src/core/stduserinfo/main.cpp deleted file mode 100644 index b0e4e60776..0000000000 --- a/src/core/stduserinfo/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - -Standard User Info 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 LoadUserInfoModule(void); - -CLIST_INTERFACE* pcli; -TIME_API tmi; -HINSTANCE hInst; -int hLangpack; - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - MIRANDA_VERSION_DWORD, - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {8198DC94-0BC4-448A-8495-8FE832C1D333} - {0x8198dc94, 0xbc4, 0x448a, {0x84, 0x95, 0x8f, 0xe8, 0x32, 0xc1, 0xd3, 0x33 }} -}; - -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_UIUSERINFO, MIID_LAST}; - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - mir_getTMI(&tmi); - mir_getCLI(); - - LoadUserInfoModule(); - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - return 0; -} diff --git a/src/core/stduserinfo/res/resource.rc b/src/core/stduserinfo/res/resource.rc new file mode 100644 index 0000000000..9964d2943d --- /dev/null +++ b/src/core/stduserinfo/res/resource.rc @@ -0,0 +1,304 @@ +// 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) + +///////////////////////////////////////////////////////////////////////////// +// +// Cursor +// + +IDC_HYPERLINKHAND CURSOR "res/cursor_hyperlink.cur" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ADDPHONE DIALOGEX 0, 0, 210, 91 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Add phone number" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Enter country, area code and phone number:",IDC_STATIC,5,5,200,8 + COMBOBOX IDC_COUNTRY,21,15,66,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_AREA,91,15,36,12,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_NUMBER,131,15,74,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Or enter a full international number:",IDC_STATIC,5,30,200,8 + EDITTEXT IDC_PHONE,21,40,184,12,ES_AUTOHSCROLL + CONTROL "Phone can receive SMS text messages",IDC_SMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,56,200,10 + DEFPUSHBUTTON "OK",IDOK,47,72,50,14 + PUSHBUTTON "Cancel",IDCANCEL,113,72,50,14 +END + +IDD_ADDEMAIL DIALOGEX 0, 0, 187, 42 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Add e-mail address" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_EMAIL,5,5,177,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,36,23,50,14 + PUSHBUTTON "Cancel",IDCANCEL,102,23,50,14 +END + +IDD_DETAILS DIALOGEX 0, 0, 318, 210 +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 "%s: user details" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "%s\nView personal user details and more",IDC_HEADERBAR, + "MHeaderbarCtrl",0x0,0,0,318,25 + CONTROL "",IDC_PAGETREE,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_TRACKSELECT | TVS_FULLROWSELECT | TVS_NONEVENHEIGHT | WS_HSCROLL | WS_TABSTOP,3,30,76,176,WS_EX_STATICEDGE + CONTROL "Tab1",IDC_TABS,"SysTabControl32",TCS_HOTTRACK | TCS_MULTILINE | WS_TABSTOP,85,29,228,158 + PUSHBUTTON "Update now",IDC_UPDATE,85,191,55,14,WS_DISABLED + CTEXT "Updating",IDC_UPDATING,145,194,113,8,SS_NOPREFIX | SS_CENTERIMAGE + DEFPUSHBUTTON "OK",IDOK,263,191,50,14 +END + +IDD_INFO_SUMMARY DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Nickname:",IDC_STATIC,5,5,46,8 + EDITTEXT IDC_NICK,51,5,166,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "First name:",IDC_STATIC,5,18,46,8 + EDITTEXT IDC_FIRSTNAME,51,18,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Gender:",IDC_STATIC,126,18,44,8 + EDITTEXT IDC_GENDER,170,18,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Last name:",IDC_STATIC,5,31,46,8 + EDITTEXT IDC_LASTNAME,51,31,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Age:",IDC_STATIC,126,31,44,8 + EDITTEXT IDC_AGE,170,31,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "E-mail:",IDC_STATIC,5,44,46,8 + CONTROL "",IDC_EMAIL,"Hyperlink",WS_TABSTOP,51,44,166,8 + LTEXT "Date of birth:",IDC_STATIC,5,58,59,8 + EDITTEXT IDC_DOBDAY,66,58,8,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_DOBMONTH,76,58,16,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_DOBYEAR,94,58,20,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Marital status:",IDC_STATIC,5,71,76,8 + EDITTEXT IDC_MARITAL,83,71,87,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER +END + +IDD_INFO_CONTACT DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "E-mail:",IDC_STATIC,5,5,212,8 + CONTROL "List1",IDC_EMAILS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,14,212,50 + LTEXT "Phone:",IDC_STATIC,5,68,212,8 + CONTROL "List1",IDC_PHONES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,77,212,50 +END + +IDD_INFO_BACKGROUND DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Web page:",IDC_STATIC,5,5,44,8 + CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,49,5,168,8 + LTEXT "Past background:",IDC_STATIC,5,18,212,8 + CONTROL "List1",IDC_PAST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,27,212,44 + LTEXT "Interests:",IDC_STATIC,5,74,212,8 + CONTROL "List1",IDC_INTERESTS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,83,212,44 +END + +IDD_INFO_NOTES DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "About:",IDC_STATIC,5,5,212,8 + EDITTEXT IDC_ABOUT,5,13,212,45,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL + LTEXT "My notes:",IDC_STATIC,5,61,212,8 + EDITTEXT IDC_MYNOTES,5,69,212,58,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL +END + +IDD_INFO_LOCATION DIALOGEX 0, 0, 222, 147 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Street:",IDC_STATIC,5,5,51,8 + EDITTEXT IDC_STREET,56,5,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "City:",IDC_STATIC,5,22,51,8 + EDITTEXT IDC_CITY,56,22,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "State:",IDC_STATIC,5,33,51,8 + EDITTEXT IDC_STATE,56,33,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Postal code:",IDC_STATIC,5,44,51,8 + EDITTEXT IDC_ZIP,56,44,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Country:",IDC_STATIC,5,55,51,8 + EDITTEXT IDC_COUNTRY,56,55,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Spoken languages:",IDC_STATIC,5,70,51,16 + EDITTEXT IDC_LANGUAGE1,56,70,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_LANGUAGE2,56,78,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_LANGUAGE3,56,86,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Timezone:",IDC_STATIC,5,97,51,8 + EDITTEXT IDC_TIMEZONE,56,97,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Local time:",IDC_STATIC,5,108,51,8 + EDITTEXT IDC_LOCALTIME,56,108,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + COMBOBOX IDC_TIMEZONESELECT,4,132,214,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Set custom time zone",IDC_STATIC,5,121,212,8 +END + +IDD_INFO_WORK DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Company:",IDC_STATIC,5,5,51,8 + EDITTEXT IDC_COMPANY,56,5,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Department:",IDC_STATIC,5,17,51,8 + EDITTEXT IDC_DEPARTMENT,56,17,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Position:",IDC_STATIC,5,28,51,8 + EDITTEXT IDC_POSITION,56,28,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Street:",IDC_STATIC,5,48,51,8 + EDITTEXT IDC_STREET,56,48,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "City:",IDC_STATIC,5,65,51,8 + EDITTEXT IDC_CITY,56,65,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "State:",IDC_STATIC,5,76,51,8 + EDITTEXT IDC_STATE,56,76,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Postal code:",IDC_STATIC,5,87,51,8 + EDITTEXT IDC_ZIP,56,87,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Country:",IDC_STATIC,5,98,51,8 + EDITTEXT IDC_COUNTRY,56,98,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Website:",IDC_STATIC,5,109,51,8 + CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,57,109,160,8 +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_INFO_CONTACT, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + END + + IDD_INFO_BACKGROUND, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 49 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + END + + IDD_INFO_NOTES, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + END + + IDD_INFO_LOCATION, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 56 + TOPMARGIN, 5 + BOTTOMMARGIN, 142 + HORZGUIDE, 22 + HORZGUIDE, 33 + HORZGUIDE, 45 + HORZGUIDE, 56 + HORZGUIDE, 70 + HORZGUIDE, 95 + HORZGUIDE, 106 + END + + IDD_INFO_WORK, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 56 + VERTGUIDE, 126 + VERTGUIDE, 170 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + HORZGUIDE, 16 + HORZGUIDE, 27 + HORZGUIDE, 44 + HORZGUIDE, 61 + HORZGUIDE, 72 + HORZGUIDE, 83 + HORZGUIDE, 94 + HORZGUIDE, 105 + END + + IDD_ADDEMAIL, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 182 + TOPMARGIN, 5 + BOTTOMMARGIN, 37 + END + + IDD_ADDPHONE, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 205 + TOPMARGIN, 5 + BOTTOMMARGIN, 86 + 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/stduserinfo/res/version.rc b/src/core/stduserinfo/res/version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/src/core/stduserinfo/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/stduserinfo/resource.rc b/src/core/stduserinfo/resource.rc deleted file mode 100644 index 9964d2943d..0000000000 --- a/src/core/stduserinfo/resource.rc +++ /dev/null @@ -1,304 +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) - -///////////////////////////////////////////////////////////////////////////// -// -// Cursor -// - -IDC_HYPERLINKHAND CURSOR "res/cursor_hyperlink.cur" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ADDPHONE DIALOGEX 0, 0, 210, 91 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Add phone number" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Enter country, area code and phone number:",IDC_STATIC,5,5,200,8 - COMBOBOX IDC_COUNTRY,21,15,66,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_AREA,91,15,36,12,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_NUMBER,131,15,74,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Or enter a full international number:",IDC_STATIC,5,30,200,8 - EDITTEXT IDC_PHONE,21,40,184,12,ES_AUTOHSCROLL - CONTROL "Phone can receive SMS text messages",IDC_SMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,56,200,10 - DEFPUSHBUTTON "OK",IDOK,47,72,50,14 - PUSHBUTTON "Cancel",IDCANCEL,113,72,50,14 -END - -IDD_ADDEMAIL DIALOGEX 0, 0, 187, 42 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Add e-mail address" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_EMAIL,5,5,177,12,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,36,23,50,14 - PUSHBUTTON "Cancel",IDCANCEL,102,23,50,14 -END - -IDD_DETAILS DIALOGEX 0, 0, 318, 210 -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 "%s: user details" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "%s\nView personal user details and more",IDC_HEADERBAR, - "MHeaderbarCtrl",0x0,0,0,318,25 - CONTROL "",IDC_PAGETREE,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_TRACKSELECT | TVS_FULLROWSELECT | TVS_NONEVENHEIGHT | WS_HSCROLL | WS_TABSTOP,3,30,76,176,WS_EX_STATICEDGE - CONTROL "Tab1",IDC_TABS,"SysTabControl32",TCS_HOTTRACK | TCS_MULTILINE | WS_TABSTOP,85,29,228,158 - PUSHBUTTON "Update now",IDC_UPDATE,85,191,55,14,WS_DISABLED - CTEXT "Updating",IDC_UPDATING,145,194,113,8,SS_NOPREFIX | SS_CENTERIMAGE - DEFPUSHBUTTON "OK",IDOK,263,191,50,14 -END - -IDD_INFO_SUMMARY DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Nickname:",IDC_STATIC,5,5,46,8 - EDITTEXT IDC_NICK,51,5,166,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "First name:",IDC_STATIC,5,18,46,8 - EDITTEXT IDC_FIRSTNAME,51,18,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Gender:",IDC_STATIC,126,18,44,8 - EDITTEXT IDC_GENDER,170,18,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Last name:",IDC_STATIC,5,31,46,8 - EDITTEXT IDC_LASTNAME,51,31,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Age:",IDC_STATIC,126,31,44,8 - EDITTEXT IDC_AGE,170,31,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "E-mail:",IDC_STATIC,5,44,46,8 - CONTROL "",IDC_EMAIL,"Hyperlink",WS_TABSTOP,51,44,166,8 - LTEXT "Date of birth:",IDC_STATIC,5,58,59,8 - EDITTEXT IDC_DOBDAY,66,58,8,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_DOBMONTH,76,58,16,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_DOBYEAR,94,58,20,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Marital status:",IDC_STATIC,5,71,76,8 - EDITTEXT IDC_MARITAL,83,71,87,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER -END - -IDD_INFO_CONTACT DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "E-mail:",IDC_STATIC,5,5,212,8 - CONTROL "List1",IDC_EMAILS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,14,212,50 - LTEXT "Phone:",IDC_STATIC,5,68,212,8 - CONTROL "List1",IDC_PHONES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,77,212,50 -END - -IDD_INFO_BACKGROUND DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Web page:",IDC_STATIC,5,5,44,8 - CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,49,5,168,8 - LTEXT "Past background:",IDC_STATIC,5,18,212,8 - CONTROL "List1",IDC_PAST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,27,212,44 - LTEXT "Interests:",IDC_STATIC,5,74,212,8 - CONTROL "List1",IDC_INTERESTS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,83,212,44 -END - -IDD_INFO_NOTES DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "About:",IDC_STATIC,5,5,212,8 - EDITTEXT IDC_ABOUT,5,13,212,45,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - LTEXT "My notes:",IDC_STATIC,5,61,212,8 - EDITTEXT IDC_MYNOTES,5,69,212,58,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL -END - -IDD_INFO_LOCATION DIALOGEX 0, 0, 222, 147 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Street:",IDC_STATIC,5,5,51,8 - EDITTEXT IDC_STREET,56,5,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "City:",IDC_STATIC,5,22,51,8 - EDITTEXT IDC_CITY,56,22,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "State:",IDC_STATIC,5,33,51,8 - EDITTEXT IDC_STATE,56,33,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Postal code:",IDC_STATIC,5,44,51,8 - EDITTEXT IDC_ZIP,56,44,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Country:",IDC_STATIC,5,55,51,8 - EDITTEXT IDC_COUNTRY,56,55,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Spoken languages:",IDC_STATIC,5,70,51,16 - EDITTEXT IDC_LANGUAGE1,56,70,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_LANGUAGE2,56,78,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_LANGUAGE3,56,86,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Timezone:",IDC_STATIC,5,97,51,8 - EDITTEXT IDC_TIMEZONE,56,97,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Local time:",IDC_STATIC,5,108,51,8 - EDITTEXT IDC_LOCALTIME,56,108,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - COMBOBOX IDC_TIMEZONESELECT,4,132,214,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Set custom time zone",IDC_STATIC,5,121,212,8 -END - -IDD_INFO_WORK DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Company:",IDC_STATIC,5,5,51,8 - EDITTEXT IDC_COMPANY,56,5,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Department:",IDC_STATIC,5,17,51,8 - EDITTEXT IDC_DEPARTMENT,56,17,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Position:",IDC_STATIC,5,28,51,8 - EDITTEXT IDC_POSITION,56,28,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Street:",IDC_STATIC,5,48,51,8 - EDITTEXT IDC_STREET,56,48,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "City:",IDC_STATIC,5,65,51,8 - EDITTEXT IDC_CITY,56,65,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "State:",IDC_STATIC,5,76,51,8 - EDITTEXT IDC_STATE,56,76,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Postal code:",IDC_STATIC,5,87,51,8 - EDITTEXT IDC_ZIP,56,87,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Country:",IDC_STATIC,5,98,51,8 - EDITTEXT IDC_COUNTRY,56,98,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Website:",IDC_STATIC,5,109,51,8 - CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,57,109,160,8 -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_INFO_CONTACT, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - END - - IDD_INFO_BACKGROUND, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - VERTGUIDE, 49 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - END - - IDD_INFO_NOTES, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - END - - IDD_INFO_LOCATION, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - VERTGUIDE, 56 - TOPMARGIN, 5 - BOTTOMMARGIN, 142 - HORZGUIDE, 22 - HORZGUIDE, 33 - HORZGUIDE, 45 - HORZGUIDE, 56 - HORZGUIDE, 70 - HORZGUIDE, 95 - HORZGUIDE, 106 - END - - IDD_INFO_WORK, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - VERTGUIDE, 56 - VERTGUIDE, 126 - VERTGUIDE, 170 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - HORZGUIDE, 16 - HORZGUIDE, 27 - HORZGUIDE, 44 - HORZGUIDE, 61 - HORZGUIDE, 72 - HORZGUIDE, 83 - HORZGUIDE, 94 - HORZGUIDE, 105 - END - - IDD_ADDEMAIL, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 182 - TOPMARGIN, 5 - BOTTOMMARGIN, 37 - END - - IDD_ADDPHONE, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 205 - TOPMARGIN, 5 - BOTTOMMARGIN, 86 - 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/stduserinfo/src/commonheaders.cpp b/src/core/stduserinfo/src/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stduserinfo/src/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stduserinfo/src/commonheaders.h b/src/core/stduserinfo/src/commonheaders.h new file mode 100644 index 0000000000..f531d749f3 --- /dev/null +++ b/src/core/stduserinfo/src/commonheaders.h @@ -0,0 +1,78 @@ +/* + +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 "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp new file mode 100644 index 0000000000..dd3984b1c8 --- /dev/null +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -0,0 +1,531 @@ +/* + +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" + +static HFONT hEmailFont = NULL; +static HCURSOR hHandCursor = NULL; + +static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + if (*(char*)lParam) SetWindowText(hwndDlg, TranslateT("Edit E-Mail address")); + TranslateDialogDefault(hwndDlg); + SetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)lParam); + EnableWindow(GetDlgItem(hwndDlg, IDOK), *(char*)lParam); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256); + //fall through + case IDCANCEL: + EndDialog(hwndDlg, wParam); + case IDC_EMAIL: + if (HIWORD(wParam) == EN_CHANGE) + EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EMAIL))); + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int noRecursion = 0; + + switch(msg) { + case WM_INITDIALOG: + { + char *szText = (char*)lParam; + int i, item, countryCount; + struct CountryListEntry *countries; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + if (szText[0]) SetWindowText(hwndDlg, TranslateT("Edit phone number")); + TranslateDialogDefault(hwndDlg); + if (mir_strlen(szText)>4 && !mir_strcmp(szText+mir_strlen(szText)-4, " SMS")) { + CheckDlgButton(hwndDlg, IDC_SMS, BST_CHECKED); + szText[mir_strlen(szText)-4] = '\0'; + } + EnableWindow(GetDlgItem(hwndDlg, IDOK), szText[0]); + SendDlgItemMessage(hwndDlg, IDC_AREA, EM_LIMITTEXT, 31, 0); + SendDlgItemMessage(hwndDlg, IDC_NUMBER, EM_LIMITTEXT, 63, 0); + CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); + for (i=0;i 4) + isValid = 0; + else { + for (i = SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0)-1; i >= 0; i--) + if (country == SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, i, 0)) { + SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, i, 0); + break; + } + if (i < 0) + isValid = 0; + } + } + if (isValid) { + pArea = pText+strcspn(pText, "0123456789"); + pText = pArea+strspn(pArea, "0123456789"); + if (*pText) { + *pText = '\0'; + pNumber = pText+1+strcspn(pText+1, "0123456789"); + SetDlgItemTextA(hwndDlg, IDC_NUMBER, pNumber); + } + SetDlgItemTextA(hwndDlg, IDC_AREA, pArea); + } + if ( !isValid) { + SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, -1, 0); + SetDlgItemTextA(hwndDlg, IDC_AREA, ""); + SetDlgItemTextA(hwndDlg, IDC_NUMBER, ""); + } + } + noRecursion = 0; + EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PHONE))); + break; + } + break; + } + return FALSE; +} + +static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) +{ + HWND hwndEmails = GetDlgItem(hwndDlg, IDC_EMAILS); + + LVHITTESTINFO hti; + GetCursorPos(&hti.pt); + ScreenToClient(hwndEmails, &hti.pt); + + RECT rc; + GetClientRect(hwndEmails, &rc); + if ( !PtInRect(&rc, hti.pt)) + return 0; + if (ListView_SubItemHitTest(hwndEmails, &hti) == -1) + return 0; + if (hti.iSubItem != 1 || !(hti.flags & LVHT_ONITEMLABEL)) + return 0; + + ListView_GetSubItemRect(hwndEmails, hti.iItem, 1, LVIR_LABEL, &rc); + + TCHAR szText[256]; szText[0] = 0; + ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, SIZEOF(szText)); + + HDC hdc = GetDC(hwndEmails); + SelectObject(hdc, hEmailFont); + + SIZE textSize; + GetTextExtentPoint32(hdc, szText, (int)mir_tstrlen(szText), &textSize); + ReleaseDC(hwndEmails, hdc); + if (hti.pt.x < rc.left+textSize.cx) { + if (szEmail && cchEmail) + mir_tstrncpy(szEmail, szText, cchEmail); + return 1; + } + return 0; +} + +#define M_REMAKELISTS (WM_USER+1) +INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int i; + + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + if (hEmailFont) DeleteObject(hEmailFont); + { + LOGFONT lf; + hEmailFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_EMAILS, WM_GETFONT, 0, 0); + GetObject(hEmailFont, sizeof(lf), &lf); + lf.lfUnderline = 1; + hEmailFont = CreateFontIndirect(&lf); + } + if (hHandCursor == NULL) + hHandCursor = LoadCursor(NULL, IDC_HAND); + { + LVCOLUMN lvc; + RECT rc; + GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc); + rc.right-=GetSystemMetrics(SM_CXVSCROLL); + lvc.mask = LVCF_WIDTH; + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); + lvc.cx = rc.right/4; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc); + lvc.cx = rc.right-rc.right/4-40; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc); + lvc.cx = rc.right-rc.right/4-90; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc); + lvc.cx = 50; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc); + lvc.cx = 20; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 2, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 3, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 4, &lvc); + } + break; + + case M_REMAKELISTS: + { + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + if (hContact != NULL) { + char *szProto = GetContactProto(hContact); + if (szProto == NULL) + break; + + //e-mails + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS)); + + char idstr[33]; + TCHAR idstr2[33]; + DBVARIANT dbv; + + LVITEM lvi; + lvi.mask = LVIF_TEXT|LVIF_PARAM; + lvi.lParam = (LPARAM)(-1); + lvi.iSubItem = 0; + lvi.iItem = 0; + for (i = -1;; i++) { + if (i == -1) { + if (db_get_ts(hContact, szProto, "e-mail", &dbv)) + continue; + lvi.pszText = TranslateT("Primary"); + } + else { + mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i); + if (db_get_ts(hContact, szProto, idstr, &dbv)) + break; + + lvi.pszText = idstr2; + mir_sntprintf(idstr2, SIZEOF(idstr2), _T("%d"), i+2); + } + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.iSubItem = 0; + for (i=0;;i++) { + lvi.lParam = i; + mir_snprintf(idstr, SIZEOF(idstr), "Mye-mail%d", i); + if (db_get_ts(hContact, "UserInfo", idstr, &dbv)) + break; + lvi.pszText = idstr2; + mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.mask = LVIF_PARAM; + lvi.lParam = (LPARAM)(-2); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); + //phones + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES)); + lvi.mask = LVIF_TEXT|LVIF_PARAM; + lvi.lParam = (LPARAM)(-1); + lvi.iSubItem = 0; + lvi.iItem = 0; + if ( !db_get_ts(hContact, szProto, "Phone", &dbv)) { + lvi.pszText = TranslateT("Primary"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + if ( !db_get_ts(hContact, szProto, "Fax", &dbv)) { + lvi.pszText = TranslateT("Fax"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + if ( !db_get_ts(hContact, szProto, "Cellular", &dbv)) { + lvi.pszText = TranslateT("Mobile"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + if (mir_strlen(dbv.pszVal)>4 && !mir_strcmp(dbv.pszVal+mir_strlen(dbv.pszVal)-4, " SMS")) { + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); + dbv.ptszVal[mir_tstrlen(dbv.ptszVal)-4] = '\0'; + } + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + if ( !db_get_ts(hContact, szProto, "CompanyPhone", &dbv)) { + lvi.pszText = TranslateT("Work phone"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + if ( !db_get_ts(hContact, szProto, "CompanyFax", &dbv)) { + lvi.pszText = TranslateT("Work fax"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.iSubItem = 0; + for (i=0;; i++) { + lvi.lParam = i; + mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d", i); + if (db_get_ts(hContact, "UserInfo", idstr, &dbv)) + break; + lvi.pszText = idstr2; + mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + if (mir_tstrlen(dbv.ptszVal)>4 && !mir_tstrcmp(dbv.ptszVal+mir_tstrlen(dbv.ptszVal)-4, _T(" SMS"))) { + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); + dbv.ptszVal[mir_tstrlen(dbv.ptszVal)-4] = '\0'; + } + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.mask = LVIF_PARAM; + lvi.lParam = (LPARAM)(-2); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + } + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + break; + + case IDC_EMAILS: + case IDC_PHONES: + switch (((LPNMHDR)lParam)->code) { + case NM_CUSTOMDRAW: + { + NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW*)lParam; + switch(nm->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + case CDDS_ITEMPREPAINT: + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW); + return TRUE; + + case CDDS_SUBITEM|CDDS_ITEMPREPAINT: + { + RECT rc; + ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc); + if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) { + HFONT hoFont; + TCHAR szText[256] = {0}; + ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); + hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont); + SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255)); + DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); + SelectObject(nm->nmcd.hdc, hoFont); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); + return TRUE; + } + + HICON hIcon = NULL; + if (nm->nmcd.lItemlParam == (LPARAM)(-2) && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES)) + hIcon = LoadSkinIcon(SKINICON_OTHER_ADDCONTACT); + else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != (LPARAM)(-1) && nm->nmcd.lItemlParam != (LPARAM)(-2)) { + static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE}; + if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) { + TCHAR szText[2]; + ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); + if (szText[0]) hIcon = LoadSkinIcon(SKINICON_OTHER_SMS); + } + else hIcon = LoadSkinIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]); + } + else break; + DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + IcoLib_ReleaseIcon(hIcon, 0); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); + return TRUE; + } + } + } + break; + + case NM_CLICK: + { + NMLISTVIEW *nm = (NMLISTVIEW*)lParam; + LVITEM lvi; + TCHAR szEmail[256]; + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d"; + LVHITTESTINFO hti; + + if (IsOverEmail(hwndDlg, szEmail, SIZEOF(szEmail))) { + TCHAR szExec[264]; + mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); + ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); + break; + } + if (nm->iSubItem<2) break; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(nm->hdr.hwndFrom, &hti.pt); + if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break; + lvi.mask = LVIF_PARAM; + lvi.iItem = hti.iItem; + lvi.iSubItem = 0; + ListView_GetItem(nm->hdr.hwndFrom, &lvi); + if (lvi.lParam == (LPARAM)(-1)) break; + if (lvi.lParam == (LPARAM)(-2)) { + if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { + //add + char szNewData[256] = "", idstr[33]; + DBVARIANT dbv; + if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData)) + break; + for (int i=0;; i++) { + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); + if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; + db_free(&dbv); + } + db_set_s(hContact, "UserInfo", idstr, szNewData); + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + } + } + else if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { + //delete + char idstr[33]; + DBVARIANT dbv; + for (i = lvi.lParam;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i+1); + if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); + db_set_s(hContact, "UserInfo", idstr, dbv.pszVal); + db_free(&dbv); + } + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); + db_unset(hContact, "UserInfo", idstr); + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + } + else if (hti.iSubItem-2 == (nm->hdr.idFrom == IDC_PHONES)) { + //edit + char szText[256], idstr[33]; + DBVARIANT dbv; + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, lvi.lParam); + if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break; + mir_strncpy(szText, dbv.pszVal, SIZEOF(szText)); + db_free(&dbv); + if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText)) + break; + db_set_s(hContact, "UserInfo", idstr, szText); + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + } + } + } + } + break; + + case WM_SETCURSOR: + if (LOWORD(lParam) != HTCLIENT) break; + if (GetForegroundWindow() == GetParent(hwndDlg)) { + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hwndDlg, &pt); + } + if (IsOverEmail(hwndDlg, NULL, 0)) { + SetCursor(hHandCursor); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); + return TRUE; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + } + break; + } + return FALSE; +} diff --git a/src/core/stduserinfo/src/main.cpp b/src/core/stduserinfo/src/main.cpp new file mode 100644 index 0000000000..b0e4e60776 --- /dev/null +++ b/src/core/stduserinfo/src/main.cpp @@ -0,0 +1,71 @@ +/* + +Standard User Info 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 LoadUserInfoModule(void); + +CLIST_INTERFACE* pcli; +TIME_API tmi; +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {8198DC94-0BC4-448A-8495-8FE832C1D333} + {0x8198dc94, 0xbc4, 0x448a, {0x84, 0x95, 0x8f, 0xe8, 0x32, 0xc1, 0xd3, 0x33 }} +}; + +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_UIUSERINFO, MIID_LAST}; + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getTMI(&tmi); + mir_getCLI(); + + LoadUserInfoModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp new file mode 100644 index 0000000000..44b81671a5 --- /dev/null +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -0,0 +1,621 @@ +/* + +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 ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +#define SVS_NORMAL 0 +#define SVS_GENDER 1 +#define SVS_ZEROISUNSPEC 2 +#define SVS_IP 3 +#define SVS_COUNTRY 4 +#define SVS_MONTH 5 +#define SVS_SIGNED 6 +#define SVS_TIMEZONE 7 + +static int Proto_GetContactInfoSetting(MCONTACT hContact, const char *szProto, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType) +{ + DBCONTACTGETSETTING cgs = {szModule, szSetting, dbv}; + dbv->type = (BYTE)nType; + + return CallProtoService(szProto, PS_GETINFOSETTING, hContact, (LPARAM)&cgs); +} + +static void Proto_FreeInfoVariant(DBVARIANT *dbv) +{ + switch (dbv->type) { + case DBVT_ASCIIZ: + case DBVT_UTF8: + case DBVT_WCHAR: + mir_free(dbv->pszVal); + dbv->pszVal = 0; + break; + + case DBVT_BLOB: + mir_free(dbv->pbVal); + dbv->pbVal = 0; + break; + } + dbv->type = 0; +} + +static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special) +{ + char str[80], *pstr = NULL; + TCHAR *ptstr = NULL; + char *szProto = GetContactProto(hContact); + bool proto_service = szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC); + + DBVARIANT dbv = { DBVT_DELETED }; + + int unspecified; + if (szModule == NULL) + unspecified = 1; + else if (proto_service) + unspecified = Proto_GetContactInfoSetting(hContact, szProto, szModule, szSetting, &dbv, 0); + else + unspecified = db_get_s(hContact, szModule, szSetting, &dbv, 0); + + if (!unspecified) { + switch (dbv.type) { + case DBVT_BYTE: + if (special == SVS_GENDER) { + if (dbv.cVal == 'M') ptstr = TranslateT("Male"); + else if (dbv.cVal == 'F') ptstr = TranslateT("Female"); + else unspecified = 1; + } + else if (special == SVS_MONTH) { + if (dbv.bVal > 0 && dbv.bVal <= 12) { + pstr = str; + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1 + dbv.bVal, str, SIZEOF(str)); + } + else unspecified = 1; + } + else if (special == SVS_TIMEZONE) { + if (dbv.cVal == -100) unspecified = 1; + else { + pstr = str; + mir_snprintf(str, SIZEOF(str), dbv.cVal ? "UTC%+d:%02d" : "UTC", -dbv.cVal / 2, (dbv.cVal & 1) * 30); + } + } + else { + unspecified = (special == SVS_ZEROISUNSPEC && dbv.bVal == 0); + pstr = _itoa(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, str, 10); + } + break; + + case DBVT_WORD: + if (special == SVS_COUNTRY) { + WORD wSave = dbv.wVal; + if (wSave == (WORD)-1) { + char szSettingName[100]; + mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sName", szSetting); + if (!db_get_ts(hContact, szModule, szSettingName, &dbv)) { + ptstr = dbv.ptszVal; + unspecified = false; + break; + } + } + + pstr = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0)); + unspecified = pstr == NULL; + } + else { + unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0); + pstr = _itoa(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, str, 10); + } + break; + + case DBVT_DWORD: + unspecified = (special == SVS_ZEROISUNSPEC && dbv.dVal == 0); + if (special == SVS_IP) { + struct in_addr ia; + ia.S_un.S_addr = htonl(dbv.dVal); + pstr = inet_ntoa(ia); + if (dbv.dVal == 0) unspecified = 1; + } + else pstr = _itoa(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, str, 10); + break; + + case DBVT_ASCIIZ: + unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); + pstr = dbv.pszVal; + break; + + case DBVT_UTF8: + unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); + if (!unspecified) { + WCHAR *wszStr; + Utf8Decode(dbv.pszVal, &wszStr); + SetDlgItemTextW(hwndDlg, idCtrl, TranslateTS(wszStr)); + mir_free(wszStr); + goto LBL_Exit; + } + + pstr = dbv.pszVal; + Utf8Decode(dbv.pszVal, NULL); + break; + + default: + pstr = str; + mir_strcpy(str, "???"); + break; + } + } + + if (unspecified) + SetDlgItemText(hwndDlg, idCtrl, TranslateT("")); + else if (ptstr != NULL) + SetDlgItemText(hwndDlg, idCtrl, ptstr); + else + SetDlgItemTextA(hwndDlg, idCtrl, pstr); + +LBL_Exit: + EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + db_free(&dbv); +} + +static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + char *szProto = GetContactProto(hContact); + if (szProto == NULL) + break; + + SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0); + SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", 0); + SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", 0); + SetValue(hwndDlg, IDC_EMAIL, hContact, szProto, "e-mail", 0); + SetValue(hwndDlg, IDC_AGE, hContact, szProto, "Age", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER); + SetValue(hwndDlg, IDC_DOBDAY, hContact, szProto, "BirthDay", 0); + SetValue(hwndDlg, IDC_DOBMONTH, hContact, szProto, "BirthMonth", SVS_MONTH); + SetValue(hwndDlg, IDC_DOBYEAR, hContact, szProto, "BirthYear", 0); + SetValue(hwndDlg, IDC_MARITAL, hContact, szProto, "MaritalStatus", 0); + } + } + break; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case IDC_EMAIL: + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) { + TCHAR szExec[264], szEmail[256]; + GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); + mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); + ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); + } + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + TranslateDialogDefault(hwndDlg); + SetTimer(hwndDlg, 1, 1000, NULL); + + tmi.prepareList(lParam, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); + SendMessage(hwndDlg, WM_TIMER, 0, 0); + break; + + case WM_TIMER: + { + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + if (hContact != NULL) { + TCHAR szTime[80]; + if (tmi.printDateTimeByContact(hContact, _T("s"), szTime, SIZEOF(szTime), TZF_KNOWNONLY)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE); + SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("")); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), TRUE); + SetDlgItemText(hwndDlg, IDC_LOCALTIME, szTime); + } + } + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + char *szProto = GetContactProto(hContact); + if (szProto == NULL) + break; + + SetValue(hwndDlg, IDC_STREET, hContact, szProto, "Street", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_CITY, hContact, szProto, "City", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_STATE, hContact, szProto, "State", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "ZIP", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "Country", SVS_COUNTRY); + SetValue(hwndDlg, IDC_LANGUAGE1, hContact, szProto, "Language1", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_LANGUAGE2, hContact, szProto, "Language2", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_LANGUAGE3, hContact, szProto, "Language3", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_TIMEZONE, hContact, szProto, "Timezone", SVS_TIMEZONE); + } + } + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + + case IDC_TIMEZONESELECT: + if (HIWORD(wParam) == CBN_SELCHANGE) { + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + tmi.storeListResults(hContact, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); + } + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + char *szProto = GetContactProto(hContact); + if (szProto == NULL) break; + SetValue(hwndDlg, IDC_COMPANY, hContact, szProto, "Company", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_DEPARTMENT, hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_POSITION, hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_STREET, hContact, szProto, "CompanyStreet", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_CITY, hContact, szProto, "CompanyCity", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_STATE, hContact, szProto, "CompanyState", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "CompanyZIP", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "CompanyCountry", SVS_COUNTRY); + SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "CompanyHomepage", SVS_ZEROISUNSPEC); + } + } + break; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + + case IDC_WEBPAGE: + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { + char szPage[256]; + GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); + CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage); + } + } + break; + } + return FALSE; +} + +// Resizes all columns in a listview (report style) +// to make all text visible +void ResizeColumns(HWND hwndLV) +{ + int nCol = 0; LVCOLUMN lvCol; + lvCol.mask = LVCF_WIDTH; + while (ListView_GetColumn(hwndLV, nCol++, &lvCol)) + ListView_SetColumnWidth(hwndLV, nCol-1, LVSCW_AUTOSIZE); +} + +static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { LVCOLUMN lvc; + RECT rc; + GetClientRect(GetDlgItem(hwndDlg, IDC_PAST), &rc); + rc.right-=GetSystemMetrics(SM_CXVSCROLL); + lvc.mask = LVCF_WIDTH; + lvc.cx = rc.right/3; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 0, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 0, &lvc); + lvc.cx = rc.right-rc.right/3; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 1, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 1, &lvc); + } + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PAST), LVS_EX_LABELTIP, LVS_EX_LABELTIP); + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_INTERESTS), LVS_EX_LABELTIP, LVS_EX_LABELTIP); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + { LVITEM lvi; + int i; + char idstr[33]; + DBVARIANT dbv, dbvText; + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + + if (hContact != NULL) { + char *szProto = GetContactProto(hContact); + if (szProto == NULL) break; + bool proto_service = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC; + SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC); + + //past + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PAST)); + lvi.mask = LVIF_TEXT; + lvi.iSubItem = 0; + lvi.iItem = 0; + for (i=0;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), "Past%d", i); + if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || + ( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv))) + break; + mir_snprintf(idstr, SIZEOF(idstr), "Past%dText", i); + if (db_get_ts(hContact, szProto, idstr, &dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;} + lvi.pszText = dbv.ptszVal; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); + db_free(&dbvText); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + db_free(&dbv); + lvi.iItem++; + } + + for (i=0;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%d", i); + if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || + ( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv))) + break; + mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%dText", i); + if (db_get_ts(hContact, szProto, idstr, &dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;} + lvi.pszText = dbv.ptszVal; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); + db_free(&dbvText); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + db_free(&dbv); + lvi.iItem++; + } + + ResizeColumns(GetDlgItem(hwndDlg, IDC_PAST)); + + //interests + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_INTERESTS)); + lvi.mask = LVIF_TEXT; + lvi.iSubItem = 0; + lvi.iItem = 0; + for (i=0;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), "Interest%dCat", i); + if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || + ( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv))) + break; + mir_snprintf(idstr, SIZEOF(idstr), "Interest%dText", i); + if (db_get_ts(hContact, szProto, idstr, &dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;} + lvi.pszText = dbv.ptszVal; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_INTERESTS), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_INTERESTS), lvi.iItem, 1, dbvText.ptszVal); + db_free(&dbvText); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + db_free(&dbv); + lvi.iItem++; + } + ResizeColumns(GetDlgItem(hwndDlg, IDC_INTERESTS)); + } } + break; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case IDC_WEBPAGE: + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { + char szPage[256]; + GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); + CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage); + } + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { DBVARIANT dbv; + HFONT hFont; + LOGFONT lf; + HDC hDC = GetDC(hwndDlg); + lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72); + ReleaseDC(hwndDlg, hDC); + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = FW_NORMAL; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + mir_tstrcpy(lf.lfFaceName, _T("Courier New")); + lf.lfCharSet = DEFAULT_CHARSET; + hFont = CreateFontIndirect(&lf); + SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0)); + + if (!db_get_s(lParam, "UserInfo", "MyNotes", &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_MYNOTES, dbv.pszVal); + db_free(&dbv); + } + } + SendDlgItemMessage(hwndDlg, IDC_MYNOTES, EM_LIMITTEXT, 2048, 0); + break; + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_INFOCHANGED: + { + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + char *szProto = GetContactProto(hContact); + if (szProto != NULL) + SetValue(hwndDlg, IDC_ABOUT, hContact, szProto, "About", 0); + } + } + break; + case PSN_APPLY: + { + MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; + if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) { + char text[2048]; + GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text)); + db_set_s(hContact, "UserInfo", "MyNotes", text); + } + else db_unset(hContact, "UserInfo", "MyNotes"); + } + break; + } + break; + } + break; + case WM_COMMAND: + if (wParam == MAKEWPARAM(IDC_MYNOTES, EN_CHANGE)) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + else if (LOWORD(wParam) == IDCANCEL) + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case WM_DESTROY: + { + HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_GETFONT, 0, 0); + DeleteObject(hFont); + } + break; + } + return FALSE; +} + +int DetailsInit(WPARAM wParam, LPARAM lParam) +{ + if (lParam == NULL) + return 0; + + if (GetContactProto(lParam) == 0) + return 0; + + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.hInstance = hInst; + + odp.pfnDlgProc = SummaryDlgProc; + odp.position = -2100000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SUMMARY); + odp.pszTitle = LPGEN("Summary"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = ContactDlgProc; + odp.position = -1800000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_CONTACT); + odp.pszTitle = LPGEN("Contact"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = LocationDlgProc; + odp.position = -1500000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_LOCATION); + odp.pszTitle = LPGEN("Location"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = WorkDlgProc; + odp.position = -1200000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_WORK); + odp.pszTitle = LPGEN("Work"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = BackgroundDlgProc; + odp.position = -900000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_BACKGROUND); + odp.pszTitle = LPGEN("Background info"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = NotesDlgProc; + odp.position = 0; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_NOTES); + odp.pszTitle = LPGEN("Notes"); + UserInfo_AddPage(wParam, &odp); + return 0; +} diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp new file mode 100644 index 0000000000..e3a48d3837 --- /dev/null +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -0,0 +1,650 @@ +/* + +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 UPDATEANIMFRAMES 20 + +int DetailsInit(WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +static HANDLE hWindowList = NULL; +static HANDLE hDetailsInitEvent; + +struct DetailsPageInit +{ + int pageCount; + OPTIONSDIALOGPAGE *odp; +}; + +struct DetailsPageData +{ + DLGTEMPLATE *pTemplate; + HINSTANCE hInst; + DLGPROC dlgProc; + LPARAM dlgParam; + HWND hwnd; + HTREEITEM hItem; + int changed, hLangpack; + TCHAR *ptszTitle, *ptszTab; +}; + +struct DetailsData +{ + MCONTACT hContact; + HANDLE hProtoAckEvent; + HINSTANCE hInstIcmp; + HFONT hBoldFont; + int pageCount; + int currentPage; + DetailsPageData *opd; + RECT rcDisplay, rcDisplayTab; + int updateAnimFrame; + TCHAR szUpdating[64]; + int *infosUpdated; +}; + +TCHAR* getTitle(OPTIONSDIALOGPAGE *p) +{ + return (p->flags & ODPF_DONTTRANSLATE) ? p->ptszTitle : TranslateTH(p->hLangpack, p->ptszTitle); +} + +TCHAR* getTab(OPTIONSDIALOGPAGE *p) +{ + return (p->flags & ODPF_DONTTRANSLATE) ? p->ptszTab : TranslateTH(p->hLangpack, p->ptszTab); +} + +static int PageSortProc(OPTIONSDIALOGPAGE *item1, OPTIONSDIALOGPAGE *item2) +{ + int res; + TCHAR *s1 = getTitle(item1), *s2 = getTitle(item2); + if (!mir_tstrcmp(s1, TranslateT("Summary"))) return -1; + if (!mir_tstrcmp(s2, TranslateT("Summary"))) return 1; + if (res = mir_tstrcmp(s1, s2)) return res; + + s1 = getTab(item1), s2 = getTab(item2); + if (s1 && !s2) return -1; + if (!s1 && s2) return 1; + if (!s1 && !s2) return 0; + + if (s1 && !mir_tstrcmp(s1, TranslateT("General"))) return -1; + if (s2 && !mir_tstrcmp(s2, TranslateT("General"))) return 1; + return mir_tstrcmp(s1, s2); +} + +static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM) +{ + HWND hwnd; + if (hwnd = WindowList_Find(hWindowList, wParam)) { + SetForegroundWindow(hwnd); + SetFocus(hwnd); + return 0; + } + + DetailsPageInit opi = { 0 }; + opi.pageCount = 0; + opi.odp = NULL; + NotifyEventHooks(hDetailsInitEvent, (WPARAM)&opi, wParam); + if (opi.pageCount == 0) + return 0; + + qsort(opi.odp, opi.pageCount, sizeof(OPTIONSDIALOGPAGE), (int(*)(const void*, const void*))PageSortProc); + + PROPSHEETHEADER psh = { sizeof(psh) }; + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; + psh.hwndParent = NULL; + psh.nPages = opi.pageCount; + psh.pStartPage = 0; + psh.pszCaption = (TCHAR*)wParam; //more abuses of structure: this is hContact + psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell + + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh); + for (int i = 0; i < opi.pageCount; i++) { + //cleanup moved to WM_DESTROY + if (opi.odp[i].pszGroup != NULL) + mir_free(opi.odp[i].pszGroup); + if ((DWORD_PTR)opi.odp[i].pszTemplate & 0xFFFF0000) + mir_free((char*)opi.odp[i].pszTemplate); + } + mir_free(opi.odp); + return 0; +} + +static INT_PTR AddDetailsPage(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)lParam; + struct DetailsPageInit *opi = (struct DetailsPageInit*)wParam; + + if (odp == NULL || opi == NULL) return 1; + if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE)) + return 1; + + opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount + 1)); + OPTIONSDIALOGPAGE *dst = opi->odp + opi->pageCount; + memset(dst, 0, sizeof(OPTIONSDIALOGPAGE)); + dst->cbSize = sizeof(OPTIONSDIALOGPAGE); + dst->hInstance = odp->hInstance; + dst->pfnDlgProc = odp->pfnDlgProc; + dst->position = odp->position; + dst->pszTemplate = ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) ? mir_strdup(odp->pszTemplate) : odp->pszTemplate; + + if (odp->flags & ODPF_UNICODE) { + dst->ptszTitle = (odp->ptszTitle == 0) ? NULL : mir_wstrdup(odp->ptszTitle); + dst->ptszTab = (!(odp->flags & ODPF_USERINFOTAB) || !odp->ptszTab) ? NULL : mir_wstrdup(odp->ptszTab); + } + else { + dst->ptszTitle = mir_a2t(odp->pszTitle); + dst->ptszTab = (!(odp->flags & ODPF_USERINFOTAB) || !odp->pszTab) ? NULL : mir_a2t(odp->pszTab); + } + + dst->hLangpack = odp->hLangpack; + dst->flags = odp->flags; + dst->groupPosition = odp->groupPosition; + dst->hGroupIcon = odp->hGroupIcon; + dst->hIcon = odp->hIcon; + dst->dwInitParam = odp->dwInitParam; + opi->pageCount++; + return 0; +} + +static void ThemeDialogBackground(HWND hwnd) +{ + EnableThemeDialogTexture(hwnd, ETDT_ENABLETAB); +} + +static void CreateDetailsTabs(HWND hwndDlg, DetailsData *dat, DetailsPageData *ppg) +{ + HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); + int sel = 0, pages = 0; + TCITEM tie; + tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; + tie.iImage = -1; + TabCtrl_DeleteAllItems(hwndTab); + for (int i = 0; i < dat->pageCount; i++) { + DetailsPageData &odp = dat->opd[i]; + if (!odp.ptszTab || mir_tstrcmp(odp.ptszTitle, ppg->ptszTitle)) + continue; + + tie.pszText = TranslateTH(odp.hLangpack, odp.ptszTab); + tie.lParam = i; + TabCtrl_InsertItem(hwndTab, pages, &tie); + if (!mir_tstrcmp(odp.ptszTab, ppg->ptszTab)) + sel = pages; + pages++; + } + TabCtrl_SetCurSel(hwndTab, sel); + + LONG style = GetWindowLongPtr(hwndTab, GWL_STYLE); + SetWindowLongPtr(hwndTab, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP); +} + +static void CreateDetailsPageWindow(HWND hwndDlg, DetailsData *dat, DetailsPageData *ppg) +{ + RECT *rc = ppg->ptszTab ? &dat->rcDisplayTab : &dat->rcDisplay; + ppg->hwnd = CreateDialogIndirectParam(ppg->hInst, ppg->pTemplate, hwndDlg, ppg->dlgProc, (LPARAM)dat->hContact); + ThemeDialogBackground(ppg->hwnd); + SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); + SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); + + PSHNOTIFY pshn; + pshn.hdr.code = PSN_PARAMCHANGED; + pshn.hdr.hwndFrom = ppg->hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)ppg->dlgParam; + SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + + pshn.hdr.code = PSN_INFOCHANGED; + pshn.hdr.hwndFrom = ppg->hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); +} + +static int UserInfoContactDelete(WPARAM wParam, LPARAM) +{ + HWND hwnd = WindowList_Find(hWindowList, wParam); + if (hwnd != NULL) + DestroyWindow(hwnd); + return 0; +} + +#define HM_PROTOACK (WM_USER+10) +#define M_CHECKONLINE (WM_USER+11) +static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PSHNOTIFY pshn; + int i; + + DetailsData *dat = (DetailsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_USERDETAILS); + { + PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam; + dat = (DetailsData*)mir_calloc(sizeof(DetailsData)); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + dat->hContact = (MCONTACT)psh->pszCaption; + dat->hProtoAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_PROTOACK); + WindowList_Add(hWindowList, hwndDlg, dat->hContact); + + ////////////////////////////////////////////////////////////////////// + TCHAR *name, oldTitle[256], newTitle[256]; + if (dat->hContact == NULL) + name = TranslateT("Owner"); + else + name = pcli->pfnGetContactDisplayName(dat->hContact, 0); + + GetWindowText(hwndDlg, oldTitle, SIZEOF(oldTitle)); + mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); + SetWindowText(hwndDlg, newTitle); + + GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); + mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); + SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); + + ////////////////////////////////////////////////////////////////////// + LOGFONT lf; + HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_NAME, WM_GETFONT, 0, 0); + GetObject(hNormalFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + dat->hBoldFont = CreateFontIndirect(&lf); + SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, (WPARAM)dat->hBoldFont, 0); + + LPTSTR ptszLastTab; + DBVARIANT dbv; + if (!db_get_ts(NULL, "UserInfo", "LastTab", &dbv)) { + ptszLastTab = NEWTSTR_ALLOCA(dbv.ptszVal); + db_free(&dbv); + } + else ptszLastTab = NULL; + + dat->currentPage = 0; + dat->pageCount = psh->nPages; + dat->opd = (DetailsPageData*)mir_calloc(sizeof(DetailsPageData) * dat->pageCount); + OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp; + + ////////////////////////////////////////////////////////////////////// + HWND hwndTree = GetDlgItem(hwndDlg, IDC_PAGETREE); + for (i = 0; i < dat->pageCount; i++) { + DetailsPageData &p = dat->opd[i]; + p.pTemplate = (LPDLGTEMPLATE)LockResource(LoadResource(odp[i].hInstance, + FindResourceA(odp[i].hInstance, odp[i].pszTemplate, MAKEINTRESOURCEA(5)))); + p.dlgProc = odp[i].pfnDlgProc; + p.dlgParam = odp[i].dwInitParam; + p.hInst = odp[i].hInstance; + + p.ptszTitle = odp[i].ptszTitle; + p.ptszTab = odp[i].ptszTab; + p.hLangpack = odp[i].hLangpack; + + if (i && p.ptszTab && !mir_tstrcmp(dat->opd[i - 1].ptszTitle, p.ptszTitle)) { + p.hItem = dat->opd[i - 1].hItem; + continue; + } + + TVINSERTSTRUCT tvis; + tvis.hParent = NULL; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_TEXT | TVIF_PARAM; + tvis.item.lParam = (LPARAM)i; + if (odp[i].flags & ODPF_DONTTRANSLATE) + tvis.item.pszText = p.ptszTitle; + else + tvis.item.pszText = TranslateTH(p.hLangpack, p.ptszTitle); + if (ptszLastTab && !mir_tstrcmp(tvis.item.pszText, ptszLastTab)) + dat->currentPage = i; + p.hItem = TreeView_InsertItem(hwndTree, &tvis); + } + + ////////////////////////////////////////////////////////////////////// + HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); + + TCITEM tci; + tci.mask = TCIF_TEXT | TCIF_IMAGE; + tci.iImage = -1; + tci.pszText = _T("X"); + TabCtrl_InsertItem(hwndTab, 0, &tci); + + GetWindowRect(hwndTab, &dat->rcDisplayTab); + TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplayTab); + + POINT pt = { 0, 0 }; + ClientToScreen(hwndDlg, &pt); + OffsetRect(&dat->rcDisplayTab, -pt.x, -pt.y); + + TabCtrl_DeleteAllItems(hwndTab); + + GetWindowRect(hwndTab, &dat->rcDisplay); + TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplay); + + memset(&pt, 0, sizeof(pt)); + ClientToScreen(hwndDlg, &pt); + OffsetRect(&dat->rcDisplay, -pt.x, -pt.y); + + TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_PAGETREE), dat->opd[dat->currentPage].hItem); + + ////////////////////////////////////////////////////////////////////// + dat->updateAnimFrame = 0; + GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, SIZEOF(dat->szUpdating)); + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + if (!CallContactService(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); + SetTimer(hwndDlg, 1, 100, NULL); + } + else ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); + + SetFocus(GetDlgItem(hwndDlg, IDC_PAGETREE)); + } + return TRUE; + + case WM_TIMER: + TCHAR str[128]; + mir_sntprintf(str, SIZEOF(str), _T("%.*s%s%.*s"), dat->updateAnimFrame % 10, _T("........."), dat->szUpdating, dat->updateAnimFrame % 10, _T(".........")); + SetDlgItemText(hwndDlg, IDC_UPDATING, str); + if (++dat->updateAnimFrame == UPDATEANIMFRAMES) + dat->updateAnimFrame = 0; + break; + + case WM_CTLCOLORSTATIC: + switch (GetDlgCtrlID((HWND)lParam)) { + case IDC_WHITERECT: + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); + + case IDC_UPDATING: + { + COLORREF textCol = GetSysColor(COLOR_BTNTEXT); + COLORREF bgCol = GetSysColor(COLOR_3DFACE); + int ratio = abs(UPDATEANIMFRAMES / 2 - dat->updateAnimFrame) * 510 / UPDATEANIMFRAMES; + COLORREF newCol = RGB(GetRValue(bgCol) + (GetRValue(textCol) - GetRValue(bgCol))*ratio / 256, + GetGValue(bgCol) + (GetGValue(textCol) - GetGValue(bgCol))*ratio / 256, + GetBValue(bgCol) + (GetBValue(textCol) - GetBValue(bgCol))*ratio / 256); + SetTextColor((HDC)wParam, newCol); + SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE)); + } + return (INT_PTR)GetSysColorBrush(COLOR_3DFACE); + + default: + SetBkMode((HDC)wParam, TRANSPARENT); + return (INT_PTR)GetStockObject(NULL_BRUSH); + } + break; + + case PSM_CHANGED: + dat->opd[dat->currentPage].changed = 1; + return TRUE; + + case PSM_FORCECHANGED: + pshn.hdr.code = PSN_INFOCHANGED; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + for (i = 0; i < dat->pageCount; i++) { + DetailsPageData &odp = dat->opd[i]; + pshn.hdr.hwndFrom = odp.hwnd; + if (odp.hwnd != NULL) + SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + } + break; + + case M_CHECKONLINE: + if (dat->hContact != NULL) { + char *szProto = GetContactProto(dat->hContact); + if (szProto == NULL) + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); + else { + if (CallProtoService(szProto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); + else + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), !IsWindowVisible(GetDlgItem(hwndDlg, IDC_UPDATING))); + } + } + break; + + case HM_PROTOACK: + { + ACKDATA *ack = (ACKDATA*)lParam; + if (ack->hContact == NULL && ack->type == ACKTYPE_STATUS) { + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + break; + } + if (ack->hContact != dat->hContact || ack->type != ACKTYPE_GETINFO) + break; + + SendMessage(hwndDlg, PSM_FORCECHANGED, 0, 0); + /* if they're not gonna send any more ACK's don't let that mean we should crash */ + if (!ack->hProcess && !ack->lParam) { + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); + KillTimer(hwndDlg, 1); + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + break; + } //if + if (dat->infosUpdated == NULL) + dat->infosUpdated = (int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); + if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED) + dat->infosUpdated[ack->lParam] = 1; + + for (i = 0; i < (int)ack->hProcess; i++) + if (dat->infosUpdated[i] == 0) + break; + if (i == (int)ack->hProcess) { + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); + KillTimer(hwndDlg, 1); + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + } + } + break; + + case WM_NOTIFY: + switch (wParam) { + case IDC_TABS: + case IDC_PAGETREE: + switch (((LPNMHDR)lParam)->code) { + case TCN_SELCHANGING: + case TVN_SELCHANGING: + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) { + pshn.hdr.code = PSN_KILLACTIVE; + pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) { + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); + return TRUE; + } + } + break; + + case TCN_SELCHANGE: + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) { + HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); + + TCITEM tie; + TVITEM tvi; + + tie.mask = TCIF_PARAM; + TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tie); + dat->currentPage = tie.lParam; + + tvi.hItem = TreeView_GetNextItem(GetDlgItem(hwndDlg, IDC_PAGETREE), NULL, TVGN_CARET); + tvi.mask = TVIF_PARAM; + tvi.lParam = dat->currentPage; + TreeView_SetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); + + if (dat->currentPage != -1) { + if (dat->opd[dat->currentPage].hwnd == NULL) + CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); + } + } + break; + + case TVN_SELCHANGED: + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); + { + LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; + TVITEM tvi = pnmtv->itemNew; + dat->currentPage = tvi.lParam; + + if (dat->currentPage != -1) { + CreateDetailsTabs(hwndDlg, dat, &dat->opd[dat->currentPage]); + if (dat->opd[dat->currentPage].hwnd == NULL) + CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); + + } + } + } + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + pshn.hdr.idFrom = 0; + pshn.hdr.code = PSN_RESET; + pshn.lParam = (LPARAM)dat->hContact; + + for (i = 0; i < dat->pageCount; i++) { + DetailsPageData &odp = dat->opd[i]; + if (odp.hwnd == NULL || !odp.changed) + continue; + pshn.hdr.hwndFrom = odp.hwnd; + SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + } + DestroyWindow(hwndDlg); + break; + + case IDOK: + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + if (dat->currentPage != -1) { + pshn.hdr.code = PSN_KILLACTIVE; + pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; + if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) + break; + } + + pshn.hdr.code = PSN_APPLY; + for (i = 0; i < dat->pageCount; i++) { + DetailsPageData &odp = dat->opd[i]; + if (odp.hwnd == NULL || !odp.changed) + continue; + pshn.hdr.hwndFrom = odp.hwnd; + if (SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) { + TreeView_Select(GetDlgItem(hwndDlg, IDC_PAGETREE), odp.hItem, TVGN_CARET); + if (dat->currentPage != -1) ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); + dat->currentPage = i; + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); + return 0; + } + } + DestroyWindow(hwndDlg); + break; + + case IDC_UPDATE: + if (dat->infosUpdated != NULL) { + mir_free(dat->infosUpdated); + dat->infosUpdated = NULL; + } + if (dat->hContact != NULL) { + if (!CallContactService(dat->hContact, PSS_GETINFO, 0, 0)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_SHOW); + SetTimer(hwndDlg, 1, 100, NULL); + } + } + break; + } + break; + + case WM_CLOSE: + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); + break; + + case WM_DESTROY: + TCHAR name[128]; + TVITEM tvi; + tvi.mask = TVIF_TEXT; + tvi.hItem = dat->opd[dat->currentPage].hItem; + tvi.pszText = name; + tvi.cchTextMax = SIZEOF(name); + TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); + db_set_ts(NULL, "UserInfo", "LastTab", name); + + Window_FreeIcon_IcoLib(hwndDlg); + SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDC_WHITERECT, WM_GETFONT, 0, 0), 0); + DeleteObject(dat->hBoldFont); + WindowList_Remove(hWindowList, hwndDlg); + UnhookEvent(dat->hProtoAckEvent); + + for (i = 0; i < dat->pageCount; i++) { + DetailsPageData &odp = dat->opd[i]; + if (odp.hwnd != NULL) + DestroyWindow(odp.hwnd); + mir_free(odp.ptszTitle); + mir_free(odp.ptszTab); + } + + mir_free(dat->infosUpdated); + mir_free(dat->opd); + mir_free(dat); + break; + } + return FALSE; +} + +static int ShutdownUserInfo(WPARAM, LPARAM) +{ + WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); + WindowList_Destroy(hWindowList); + return 0; +} + +int LoadUserInfoModule(void) +{ + CreateServiceFunction("UserInfo/AddPage", AddDetailsPage); + CreateServiceFunction(MS_USERINFO_SHOWDIALOG, ShowDetailsDialogCommand); + + hDetailsInitEvent = CreateHookableEvent(ME_USERINFO_INITIALISE); + + HookEvent(ME_USERINFO_INITIALISE, DetailsInit); + HookEvent(ME_DB_CONTACT_DELETED, UserInfoContactDelete); + HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownUserInfo); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.position = 1000050000; + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_USERDETAILS); + mi.pszName = LPGEN("User &details"); + mi.pszService = MS_USERINFO_SHOWDIALOG; + Menu_AddContactMenuItem(&mi); + + mi.position = 500050000; + mi.pszName = LPGEN("View/change my &details..."); + Menu_AddMainMenuItem(&mi); + + hWindowList = WindowList_Create(); + return 0; +} diff --git a/src/core/stduserinfo/src/version.h b/src/core/stduserinfo/src/version.h new file mode 100644 index 0000000000..4a01547508 --- /dev/null +++ b/src/core/stduserinfo/src/version.h @@ -0,0 +1,12 @@ +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "Standard User Info module" +#define __FILENAME "stduserinfo.dll" +#define __DESCRIPTION "Core module for providing user information." +#define __AUTHOR "Miranda NG Development Team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://miranda-ng.org/p/StdUserInfo/" +#define __COPYRIGHT "© 2012 Miranda NG Development Team" diff --git a/src/core/stduserinfo/stdinfo.cpp b/src/core/stduserinfo/stdinfo.cpp deleted file mode 100644 index 44b81671a5..0000000000 --- a/src/core/stduserinfo/stdinfo.cpp +++ /dev/null @@ -1,621 +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 ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -#define SVS_NORMAL 0 -#define SVS_GENDER 1 -#define SVS_ZEROISUNSPEC 2 -#define SVS_IP 3 -#define SVS_COUNTRY 4 -#define SVS_MONTH 5 -#define SVS_SIGNED 6 -#define SVS_TIMEZONE 7 - -static int Proto_GetContactInfoSetting(MCONTACT hContact, const char *szProto, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType) -{ - DBCONTACTGETSETTING cgs = {szModule, szSetting, dbv}; - dbv->type = (BYTE)nType; - - return CallProtoService(szProto, PS_GETINFOSETTING, hContact, (LPARAM)&cgs); -} - -static void Proto_FreeInfoVariant(DBVARIANT *dbv) -{ - switch (dbv->type) { - case DBVT_ASCIIZ: - case DBVT_UTF8: - case DBVT_WCHAR: - mir_free(dbv->pszVal); - dbv->pszVal = 0; - break; - - case DBVT_BLOB: - mir_free(dbv->pbVal); - dbv->pbVal = 0; - break; - } - dbv->type = 0; -} - -static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special) -{ - char str[80], *pstr = NULL; - TCHAR *ptstr = NULL; - char *szProto = GetContactProto(hContact); - bool proto_service = szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC); - - DBVARIANT dbv = { DBVT_DELETED }; - - int unspecified; - if (szModule == NULL) - unspecified = 1; - else if (proto_service) - unspecified = Proto_GetContactInfoSetting(hContact, szProto, szModule, szSetting, &dbv, 0); - else - unspecified = db_get_s(hContact, szModule, szSetting, &dbv, 0); - - if (!unspecified) { - switch (dbv.type) { - case DBVT_BYTE: - if (special == SVS_GENDER) { - if (dbv.cVal == 'M') ptstr = TranslateT("Male"); - else if (dbv.cVal == 'F') ptstr = TranslateT("Female"); - else unspecified = 1; - } - else if (special == SVS_MONTH) { - if (dbv.bVal > 0 && dbv.bVal <= 12) { - pstr = str; - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1 + dbv.bVal, str, SIZEOF(str)); - } - else unspecified = 1; - } - else if (special == SVS_TIMEZONE) { - if (dbv.cVal == -100) unspecified = 1; - else { - pstr = str; - mir_snprintf(str, SIZEOF(str), dbv.cVal ? "UTC%+d:%02d" : "UTC", -dbv.cVal / 2, (dbv.cVal & 1) * 30); - } - } - else { - unspecified = (special == SVS_ZEROISUNSPEC && dbv.bVal == 0); - pstr = _itoa(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, str, 10); - } - break; - - case DBVT_WORD: - if (special == SVS_COUNTRY) { - WORD wSave = dbv.wVal; - if (wSave == (WORD)-1) { - char szSettingName[100]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sName", szSetting); - if (!db_get_ts(hContact, szModule, szSettingName, &dbv)) { - ptstr = dbv.ptszVal; - unspecified = false; - break; - } - } - - pstr = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0)); - unspecified = pstr == NULL; - } - else { - unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0); - pstr = _itoa(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, str, 10); - } - break; - - case DBVT_DWORD: - unspecified = (special == SVS_ZEROISUNSPEC && dbv.dVal == 0); - if (special == SVS_IP) { - struct in_addr ia; - ia.S_un.S_addr = htonl(dbv.dVal); - pstr = inet_ntoa(ia); - if (dbv.dVal == 0) unspecified = 1; - } - else pstr = _itoa(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, str, 10); - break; - - case DBVT_ASCIIZ: - unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); - pstr = dbv.pszVal; - break; - - case DBVT_UTF8: - unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); - if (!unspecified) { - WCHAR *wszStr; - Utf8Decode(dbv.pszVal, &wszStr); - SetDlgItemTextW(hwndDlg, idCtrl, TranslateTS(wszStr)); - mir_free(wszStr); - goto LBL_Exit; - } - - pstr = dbv.pszVal; - Utf8Decode(dbv.pszVal, NULL); - break; - - default: - pstr = str; - mir_strcpy(str, "???"); - break; - } - } - - if (unspecified) - SetDlgItemText(hwndDlg, idCtrl, TranslateT("")); - else if (ptstr != NULL) - SetDlgItemText(hwndDlg, idCtrl, ptstr); - else - SetDlgItemTextA(hwndDlg, idCtrl, pstr); - -LBL_Exit: - EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - db_free(&dbv); -} - -static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { - MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - char *szProto = GetContactProto(hContact); - if (szProto == NULL) - break; - - SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0); - SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", 0); - SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", 0); - SetValue(hwndDlg, IDC_EMAIL, hContact, szProto, "e-mail", 0); - SetValue(hwndDlg, IDC_AGE, hContact, szProto, "Age", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER); - SetValue(hwndDlg, IDC_DOBDAY, hContact, szProto, "BirthDay", 0); - SetValue(hwndDlg, IDC_DOBMONTH, hContact, szProto, "BirthMonth", SVS_MONTH); - SetValue(hwndDlg, IDC_DOBYEAR, hContact, szProto, "BirthYear", 0); - SetValue(hwndDlg, IDC_MARITAL, hContact, szProto, "MaritalStatus", 0); - } - } - break; - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case IDC_EMAIL: - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) { - TCHAR szExec[264], szEmail[256]; - GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); - mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); - ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); - } - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - TranslateDialogDefault(hwndDlg); - SetTimer(hwndDlg, 1, 1000, NULL); - - tmi.prepareList(lParam, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); - SendMessage(hwndDlg, WM_TIMER, 0, 0); - break; - - case WM_TIMER: - { - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (hContact != NULL) { - TCHAR szTime[80]; - if (tmi.printDateTimeByContact(hContact, _T("s"), szTime, SIZEOF(szTime), TZF_KNOWNONLY)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE); - SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("")); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), TRUE); - SetDlgItemText(hwndDlg, IDC_LOCALTIME, szTime); - } - } - } - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { - MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - char *szProto = GetContactProto(hContact); - if (szProto == NULL) - break; - - SetValue(hwndDlg, IDC_STREET, hContact, szProto, "Street", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_CITY, hContact, szProto, "City", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_STATE, hContact, szProto, "State", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "ZIP", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "Country", SVS_COUNTRY); - SetValue(hwndDlg, IDC_LANGUAGE1, hContact, szProto, "Language1", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_LANGUAGE2, hContact, szProto, "Language2", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_LANGUAGE3, hContact, szProto, "Language3", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_TIMEZONE, hContact, szProto, "Timezone", SVS_TIMEZONE); - } - } - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - - case IDC_TIMEZONESELECT: - if (HIWORD(wParam) == CBN_SELCHANGE) { - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - tmi.storeListResults(hContact, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); - } - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { - MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - char *szProto = GetContactProto(hContact); - if (szProto == NULL) break; - SetValue(hwndDlg, IDC_COMPANY, hContact, szProto, "Company", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_DEPARTMENT, hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_POSITION, hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_STREET, hContact, szProto, "CompanyStreet", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_CITY, hContact, szProto, "CompanyCity", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_STATE, hContact, szProto, "CompanyState", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "CompanyZIP", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "CompanyCountry", SVS_COUNTRY); - SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "CompanyHomepage", SVS_ZEROISUNSPEC); - } - } - break; - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - - case IDC_WEBPAGE: - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { - char szPage[256]; - GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); - CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage); - } - } - break; - } - return FALSE; -} - -// Resizes all columns in a listview (report style) -// to make all text visible -void ResizeColumns(HWND hwndLV) -{ - int nCol = 0; LVCOLUMN lvCol; - lvCol.mask = LVCF_WIDTH; - while (ListView_GetColumn(hwndLV, nCol++, &lvCol)) - ListView_SetColumnWidth(hwndLV, nCol-1, LVSCW_AUTOSIZE); -} - -static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { LVCOLUMN lvc; - RECT rc; - GetClientRect(GetDlgItem(hwndDlg, IDC_PAST), &rc); - rc.right-=GetSystemMetrics(SM_CXVSCROLL); - lvc.mask = LVCF_WIDTH; - lvc.cx = rc.right/3; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 0, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 0, &lvc); - lvc.cx = rc.right-rc.right/3; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 1, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 1, &lvc); - } - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PAST), LVS_EX_LABELTIP, LVS_EX_LABELTIP); - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_INTERESTS), LVS_EX_LABELTIP, LVS_EX_LABELTIP); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) - { LVITEM lvi; - int i; - char idstr[33]; - DBVARIANT dbv, dbvText; - MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - - if (hContact != NULL) { - char *szProto = GetContactProto(hContact); - if (szProto == NULL) break; - bool proto_service = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC; - SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC); - - //past - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PAST)); - lvi.mask = LVIF_TEXT; - lvi.iSubItem = 0; - lvi.iItem = 0; - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), "Past%d", i); - if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || - ( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv))) - break; - mir_snprintf(idstr, SIZEOF(idstr), "Past%dText", i); - if (db_get_ts(hContact, szProto, idstr, &dbvText)) - {if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;} - lvi.pszText = dbv.ptszVal; - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); - db_free(&dbvText); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - db_free(&dbv); - lvi.iItem++; - } - - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%d", i); - if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || - ( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv))) - break; - mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%dText", i); - if (db_get_ts(hContact, szProto, idstr, &dbvText)) - {if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;} - lvi.pszText = dbv.ptszVal; - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); - db_free(&dbvText); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - db_free(&dbv); - lvi.iItem++; - } - - ResizeColumns(GetDlgItem(hwndDlg, IDC_PAST)); - - //interests - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_INTERESTS)); - lvi.mask = LVIF_TEXT; - lvi.iSubItem = 0; - lvi.iItem = 0; - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), "Interest%dCat", i); - if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || - ( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv))) - break; - mir_snprintf(idstr, SIZEOF(idstr), "Interest%dText", i); - if (db_get_ts(hContact, szProto, idstr, &dbvText)) - {if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;} - lvi.pszText = dbv.ptszVal; - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_INTERESTS), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_INTERESTS), lvi.iItem, 1, dbvText.ptszVal); - db_free(&dbvText); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - db_free(&dbv); - lvi.iItem++; - } - ResizeColumns(GetDlgItem(hwndDlg, IDC_INTERESTS)); - } } - break; - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case IDC_WEBPAGE: - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { - char szPage[256]; - GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); - CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szPage); - } - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { DBVARIANT dbv; - HFONT hFont; - LOGFONT lf; - HDC hDC = GetDC(hwndDlg); - lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72); - ReleaseDC(hwndDlg, hDC); - lf.lfWidth = 0; - lf.lfEscapement = 0; - lf.lfOrientation = 0; - lf.lfWeight = FW_NORMAL; - lf.lfItalic = 0; - lf.lfUnderline = 0; - lf.lfStrikeOut = 0; - lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - mir_tstrcpy(lf.lfFaceName, _T("Courier New")); - lf.lfCharSet = DEFAULT_CHARSET; - hFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0)); - - if (!db_get_s(lParam, "UserInfo", "MyNotes", &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_MYNOTES, dbv.pszVal); - db_free(&dbv); - } - } - SendDlgItemMessage(hwndDlg, IDC_MYNOTES, EM_LIMITTEXT, 2048, 0); - break; - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_INFOCHANGED: - { - MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - char *szProto = GetContactProto(hContact); - if (szProto != NULL) - SetValue(hwndDlg, IDC_ABOUT, hContact, szProto, "About", 0); - } - } - break; - case PSN_APPLY: - { - MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; - if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) { - char text[2048]; - GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text)); - db_set_s(hContact, "UserInfo", "MyNotes", text); - } - else db_unset(hContact, "UserInfo", "MyNotes"); - } - break; - } - break; - } - break; - case WM_COMMAND: - if (wParam == MAKEWPARAM(IDC_MYNOTES, EN_CHANGE)) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - else if (LOWORD(wParam) == IDCANCEL) - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case WM_DESTROY: - { - HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_GETFONT, 0, 0); - DeleteObject(hFont); - } - break; - } - return FALSE; -} - -int DetailsInit(WPARAM wParam, LPARAM lParam) -{ - if (lParam == NULL) - return 0; - - if (GetContactProto(lParam) == 0) - return 0; - - OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.hInstance = hInst; - - odp.pfnDlgProc = SummaryDlgProc; - odp.position = -2100000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SUMMARY); - odp.pszTitle = LPGEN("Summary"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = ContactDlgProc; - odp.position = -1800000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_CONTACT); - odp.pszTitle = LPGEN("Contact"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = LocationDlgProc; - odp.position = -1500000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_LOCATION); - odp.pszTitle = LPGEN("Location"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = WorkDlgProc; - odp.position = -1200000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_WORK); - odp.pszTitle = LPGEN("Work"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = BackgroundDlgProc; - odp.position = -900000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_BACKGROUND); - odp.pszTitle = LPGEN("Background info"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = NotesDlgProc; - odp.position = 0; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_NOTES); - odp.pszTitle = LPGEN("Notes"); - UserInfo_AddPage(wParam, &odp); - return 0; -} diff --git a/src/core/stduserinfo/stduserinfo_10.vcxproj b/src/core/stduserinfo/stduserinfo_10.vcxproj index 719d641237..d04fcf9a96 100644 --- a/src/core/stduserinfo/stduserinfo_10.vcxproj +++ b/src/core/stduserinfo/stduserinfo_10.vcxproj @@ -199,24 +199,22 @@ - - Create - Create - Create - Create + + Create - - - - + + + + - + + - - + + diff --git a/src/core/stduserinfo/stduserinfo_10.vcxproj.filters b/src/core/stduserinfo/stduserinfo_10.vcxproj.filters index ac101b1384..dd6ca7bfcf 100644 --- a/src/core/stduserinfo/stduserinfo_10.vcxproj.filters +++ b/src/core/stduserinfo/stduserinfo_10.vcxproj.filters @@ -15,19 +15,19 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files @@ -35,15 +35,18 @@ Header Files - + + Header Files + + Header Files - + Resource Files - + Resource Files diff --git a/src/core/stduserinfo/stduserinfo_12.vcxproj b/src/core/stduserinfo/stduserinfo_12.vcxproj index ee355ee519..d6df81b469 100644 --- a/src/core/stduserinfo/stduserinfo_12.vcxproj +++ b/src/core/stduserinfo/stduserinfo_12.vcxproj @@ -202,24 +202,22 @@ - - Create - Create - Create - Create + + Create - - - - + + + + - + + - - + + diff --git a/src/core/stduserinfo/stduserinfo_12.vcxproj.filters b/src/core/stduserinfo/stduserinfo_12.vcxproj.filters index ac101b1384..dd6ca7bfcf 100644 --- a/src/core/stduserinfo/stduserinfo_12.vcxproj.filters +++ b/src/core/stduserinfo/stduserinfo_12.vcxproj.filters @@ -15,19 +15,19 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files @@ -35,15 +35,18 @@ Header Files - + + Header Files + + Header Files - + Resource Files - + Resource Files diff --git a/src/core/stduserinfo/userinfo.cpp b/src/core/stduserinfo/userinfo.cpp deleted file mode 100644 index e3a48d3837..0000000000 --- a/src/core/stduserinfo/userinfo.cpp +++ /dev/null @@ -1,650 +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 UPDATEANIMFRAMES 20 - -int DetailsInit(WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static HANDLE hWindowList = NULL; -static HANDLE hDetailsInitEvent; - -struct DetailsPageInit -{ - int pageCount; - OPTIONSDIALOGPAGE *odp; -}; - -struct DetailsPageData -{ - DLGTEMPLATE *pTemplate; - HINSTANCE hInst; - DLGPROC dlgProc; - LPARAM dlgParam; - HWND hwnd; - HTREEITEM hItem; - int changed, hLangpack; - TCHAR *ptszTitle, *ptszTab; -}; - -struct DetailsData -{ - MCONTACT hContact; - HANDLE hProtoAckEvent; - HINSTANCE hInstIcmp; - HFONT hBoldFont; - int pageCount; - int currentPage; - DetailsPageData *opd; - RECT rcDisplay, rcDisplayTab; - int updateAnimFrame; - TCHAR szUpdating[64]; - int *infosUpdated; -}; - -TCHAR* getTitle(OPTIONSDIALOGPAGE *p) -{ - return (p->flags & ODPF_DONTTRANSLATE) ? p->ptszTitle : TranslateTH(p->hLangpack, p->ptszTitle); -} - -TCHAR* getTab(OPTIONSDIALOGPAGE *p) -{ - return (p->flags & ODPF_DONTTRANSLATE) ? p->ptszTab : TranslateTH(p->hLangpack, p->ptszTab); -} - -static int PageSortProc(OPTIONSDIALOGPAGE *item1, OPTIONSDIALOGPAGE *item2) -{ - int res; - TCHAR *s1 = getTitle(item1), *s2 = getTitle(item2); - if (!mir_tstrcmp(s1, TranslateT("Summary"))) return -1; - if (!mir_tstrcmp(s2, TranslateT("Summary"))) return 1; - if (res = mir_tstrcmp(s1, s2)) return res; - - s1 = getTab(item1), s2 = getTab(item2); - if (s1 && !s2) return -1; - if (!s1 && s2) return 1; - if (!s1 && !s2) return 0; - - if (s1 && !mir_tstrcmp(s1, TranslateT("General"))) return -1; - if (s2 && !mir_tstrcmp(s2, TranslateT("General"))) return 1; - return mir_tstrcmp(s1, s2); -} - -static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM) -{ - HWND hwnd; - if (hwnd = WindowList_Find(hWindowList, wParam)) { - SetForegroundWindow(hwnd); - SetFocus(hwnd); - return 0; - } - - DetailsPageInit opi = { 0 }; - opi.pageCount = 0; - opi.odp = NULL; - NotifyEventHooks(hDetailsInitEvent, (WPARAM)&opi, wParam); - if (opi.pageCount == 0) - return 0; - - qsort(opi.odp, opi.pageCount, sizeof(OPTIONSDIALOGPAGE), (int(*)(const void*, const void*))PageSortProc); - - PROPSHEETHEADER psh = { sizeof(psh) }; - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; - psh.hwndParent = NULL; - psh.nPages = opi.pageCount; - psh.pStartPage = 0; - psh.pszCaption = (TCHAR*)wParam; //more abuses of structure: this is hContact - psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell - - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh); - for (int i = 0; i < opi.pageCount; i++) { - //cleanup moved to WM_DESTROY - if (opi.odp[i].pszGroup != NULL) - mir_free(opi.odp[i].pszGroup); - if ((DWORD_PTR)opi.odp[i].pszTemplate & 0xFFFF0000) - mir_free((char*)opi.odp[i].pszTemplate); - } - mir_free(opi.odp); - return 0; -} - -static INT_PTR AddDetailsPage(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)lParam; - struct DetailsPageInit *opi = (struct DetailsPageInit*)wParam; - - if (odp == NULL || opi == NULL) return 1; - if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE)) - return 1; - - opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount + 1)); - OPTIONSDIALOGPAGE *dst = opi->odp + opi->pageCount; - memset(dst, 0, sizeof(OPTIONSDIALOGPAGE)); - dst->cbSize = sizeof(OPTIONSDIALOGPAGE); - dst->hInstance = odp->hInstance; - dst->pfnDlgProc = odp->pfnDlgProc; - dst->position = odp->position; - dst->pszTemplate = ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) ? mir_strdup(odp->pszTemplate) : odp->pszTemplate; - - if (odp->flags & ODPF_UNICODE) { - dst->ptszTitle = (odp->ptszTitle == 0) ? NULL : mir_wstrdup(odp->ptszTitle); - dst->ptszTab = (!(odp->flags & ODPF_USERINFOTAB) || !odp->ptszTab) ? NULL : mir_wstrdup(odp->ptszTab); - } - else { - dst->ptszTitle = mir_a2t(odp->pszTitle); - dst->ptszTab = (!(odp->flags & ODPF_USERINFOTAB) || !odp->pszTab) ? NULL : mir_a2t(odp->pszTab); - } - - dst->hLangpack = odp->hLangpack; - dst->flags = odp->flags; - dst->groupPosition = odp->groupPosition; - dst->hGroupIcon = odp->hGroupIcon; - dst->hIcon = odp->hIcon; - dst->dwInitParam = odp->dwInitParam; - opi->pageCount++; - return 0; -} - -static void ThemeDialogBackground(HWND hwnd) -{ - EnableThemeDialogTexture(hwnd, ETDT_ENABLETAB); -} - -static void CreateDetailsTabs(HWND hwndDlg, DetailsData *dat, DetailsPageData *ppg) -{ - HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); - int sel = 0, pages = 0; - TCITEM tie; - tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; - tie.iImage = -1; - TabCtrl_DeleteAllItems(hwndTab); - for (int i = 0; i < dat->pageCount; i++) { - DetailsPageData &odp = dat->opd[i]; - if (!odp.ptszTab || mir_tstrcmp(odp.ptszTitle, ppg->ptszTitle)) - continue; - - tie.pszText = TranslateTH(odp.hLangpack, odp.ptszTab); - tie.lParam = i; - TabCtrl_InsertItem(hwndTab, pages, &tie); - if (!mir_tstrcmp(odp.ptszTab, ppg->ptszTab)) - sel = pages; - pages++; - } - TabCtrl_SetCurSel(hwndTab, sel); - - LONG style = GetWindowLongPtr(hwndTab, GWL_STYLE); - SetWindowLongPtr(hwndTab, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP); -} - -static void CreateDetailsPageWindow(HWND hwndDlg, DetailsData *dat, DetailsPageData *ppg) -{ - RECT *rc = ppg->ptszTab ? &dat->rcDisplayTab : &dat->rcDisplay; - ppg->hwnd = CreateDialogIndirectParam(ppg->hInst, ppg->pTemplate, hwndDlg, ppg->dlgProc, (LPARAM)dat->hContact); - ThemeDialogBackground(ppg->hwnd); - SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); - SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); - - PSHNOTIFY pshn; - pshn.hdr.code = PSN_PARAMCHANGED; - pshn.hdr.hwndFrom = ppg->hwnd; - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)ppg->dlgParam; - SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - - pshn.hdr.code = PSN_INFOCHANGED; - pshn.hdr.hwndFrom = ppg->hwnd; - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)dat->hContact; - SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); -} - -static int UserInfoContactDelete(WPARAM wParam, LPARAM) -{ - HWND hwnd = WindowList_Find(hWindowList, wParam); - if (hwnd != NULL) - DestroyWindow(hwnd); - return 0; -} - -#define HM_PROTOACK (WM_USER+10) -#define M_CHECKONLINE (WM_USER+11) -static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - PSHNOTIFY pshn; - int i; - - DetailsData *dat = (DetailsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_USERDETAILS); - { - PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam; - dat = (DetailsData*)mir_calloc(sizeof(DetailsData)); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->hContact = (MCONTACT)psh->pszCaption; - dat->hProtoAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_PROTOACK); - WindowList_Add(hWindowList, hwndDlg, dat->hContact); - - ////////////////////////////////////////////////////////////////////// - TCHAR *name, oldTitle[256], newTitle[256]; - if (dat->hContact == NULL) - name = TranslateT("Owner"); - else - name = pcli->pfnGetContactDisplayName(dat->hContact, 0); - - GetWindowText(hwndDlg, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); - SetWindowText(hwndDlg, newTitle); - - GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); - SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); - - ////////////////////////////////////////////////////////////////////// - LOGFONT lf; - HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_NAME, WM_GETFONT, 0, 0); - GetObject(hNormalFont, sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - dat->hBoldFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, (WPARAM)dat->hBoldFont, 0); - - LPTSTR ptszLastTab; - DBVARIANT dbv; - if (!db_get_ts(NULL, "UserInfo", "LastTab", &dbv)) { - ptszLastTab = NEWTSTR_ALLOCA(dbv.ptszVal); - db_free(&dbv); - } - else ptszLastTab = NULL; - - dat->currentPage = 0; - dat->pageCount = psh->nPages; - dat->opd = (DetailsPageData*)mir_calloc(sizeof(DetailsPageData) * dat->pageCount); - OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp; - - ////////////////////////////////////////////////////////////////////// - HWND hwndTree = GetDlgItem(hwndDlg, IDC_PAGETREE); - for (i = 0; i < dat->pageCount; i++) { - DetailsPageData &p = dat->opd[i]; - p.pTemplate = (LPDLGTEMPLATE)LockResource(LoadResource(odp[i].hInstance, - FindResourceA(odp[i].hInstance, odp[i].pszTemplate, MAKEINTRESOURCEA(5)))); - p.dlgProc = odp[i].pfnDlgProc; - p.dlgParam = odp[i].dwInitParam; - p.hInst = odp[i].hInstance; - - p.ptszTitle = odp[i].ptszTitle; - p.ptszTab = odp[i].ptszTab; - p.hLangpack = odp[i].hLangpack; - - if (i && p.ptszTab && !mir_tstrcmp(dat->opd[i - 1].ptszTitle, p.ptszTitle)) { - p.hItem = dat->opd[i - 1].hItem; - continue; - } - - TVINSERTSTRUCT tvis; - tvis.hParent = NULL; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_PARAM; - tvis.item.lParam = (LPARAM)i; - if (odp[i].flags & ODPF_DONTTRANSLATE) - tvis.item.pszText = p.ptszTitle; - else - tvis.item.pszText = TranslateTH(p.hLangpack, p.ptszTitle); - if (ptszLastTab && !mir_tstrcmp(tvis.item.pszText, ptszLastTab)) - dat->currentPage = i; - p.hItem = TreeView_InsertItem(hwndTree, &tvis); - } - - ////////////////////////////////////////////////////////////////////// - HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); - - TCITEM tci; - tci.mask = TCIF_TEXT | TCIF_IMAGE; - tci.iImage = -1; - tci.pszText = _T("X"); - TabCtrl_InsertItem(hwndTab, 0, &tci); - - GetWindowRect(hwndTab, &dat->rcDisplayTab); - TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplayTab); - - POINT pt = { 0, 0 }; - ClientToScreen(hwndDlg, &pt); - OffsetRect(&dat->rcDisplayTab, -pt.x, -pt.y); - - TabCtrl_DeleteAllItems(hwndTab); - - GetWindowRect(hwndTab, &dat->rcDisplay); - TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplay); - - memset(&pt, 0, sizeof(pt)); - ClientToScreen(hwndDlg, &pt); - OffsetRect(&dat->rcDisplay, -pt.x, -pt.y); - - TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_PAGETREE), dat->opd[dat->currentPage].hItem); - - ////////////////////////////////////////////////////////////////////// - dat->updateAnimFrame = 0; - GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, SIZEOF(dat->szUpdating)); - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - if (!CallContactService(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - SetTimer(hwndDlg, 1, 100, NULL); - } - else ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); - - SetFocus(GetDlgItem(hwndDlg, IDC_PAGETREE)); - } - return TRUE; - - case WM_TIMER: - TCHAR str[128]; - mir_sntprintf(str, SIZEOF(str), _T("%.*s%s%.*s"), dat->updateAnimFrame % 10, _T("........."), dat->szUpdating, dat->updateAnimFrame % 10, _T(".........")); - SetDlgItemText(hwndDlg, IDC_UPDATING, str); - if (++dat->updateAnimFrame == UPDATEANIMFRAMES) - dat->updateAnimFrame = 0; - break; - - case WM_CTLCOLORSTATIC: - switch (GetDlgCtrlID((HWND)lParam)) { - case IDC_WHITERECT: - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - - case IDC_UPDATING: - { - COLORREF textCol = GetSysColor(COLOR_BTNTEXT); - COLORREF bgCol = GetSysColor(COLOR_3DFACE); - int ratio = abs(UPDATEANIMFRAMES / 2 - dat->updateAnimFrame) * 510 / UPDATEANIMFRAMES; - COLORREF newCol = RGB(GetRValue(bgCol) + (GetRValue(textCol) - GetRValue(bgCol))*ratio / 256, - GetGValue(bgCol) + (GetGValue(textCol) - GetGValue(bgCol))*ratio / 256, - GetBValue(bgCol) + (GetBValue(textCol) - GetBValue(bgCol))*ratio / 256); - SetTextColor((HDC)wParam, newCol); - SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE)); - } - return (INT_PTR)GetSysColorBrush(COLOR_3DFACE); - - default: - SetBkMode((HDC)wParam, TRANSPARENT); - return (INT_PTR)GetStockObject(NULL_BRUSH); - } - break; - - case PSM_CHANGED: - dat->opd[dat->currentPage].changed = 1; - return TRUE; - - case PSM_FORCECHANGED: - pshn.hdr.code = PSN_INFOCHANGED; - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)dat->hContact; - for (i = 0; i < dat->pageCount; i++) { - DetailsPageData &odp = dat->opd[i]; - pshn.hdr.hwndFrom = odp.hwnd; - if (odp.hwnd != NULL) - SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - } - break; - - case M_CHECKONLINE: - if (dat->hContact != NULL) { - char *szProto = GetContactProto(dat->hContact); - if (szProto == NULL) - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - else { - if (CallProtoService(szProto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - else - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), !IsWindowVisible(GetDlgItem(hwndDlg, IDC_UPDATING))); - } - } - break; - - case HM_PROTOACK: - { - ACKDATA *ack = (ACKDATA*)lParam; - if (ack->hContact == NULL && ack->type == ACKTYPE_STATUS) { - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - break; - } - if (ack->hContact != dat->hContact || ack->type != ACKTYPE_GETINFO) - break; - - SendMessage(hwndDlg, PSM_FORCECHANGED, 0, 0); - /* if they're not gonna send any more ACK's don't let that mean we should crash */ - if (!ack->hProcess && !ack->lParam) { - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); - KillTimer(hwndDlg, 1); - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - break; - } //if - if (dat->infosUpdated == NULL) - dat->infosUpdated = (int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); - if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED) - dat->infosUpdated[ack->lParam] = 1; - - for (i = 0; i < (int)ack->hProcess; i++) - if (dat->infosUpdated[i] == 0) - break; - if (i == (int)ack->hProcess) { - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); - KillTimer(hwndDlg, 1); - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - } - } - break; - - case WM_NOTIFY: - switch (wParam) { - case IDC_TABS: - case IDC_PAGETREE: - switch (((LPNMHDR)lParam)->code) { - case TCN_SELCHANGING: - case TVN_SELCHANGING: - if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) { - pshn.hdr.code = PSN_KILLACTIVE; - pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)dat->hContact; - if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) { - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); - return TRUE; - } - } - break; - - case TCN_SELCHANGE: - if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) { - HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); - - TCITEM tie; - TVITEM tvi; - - tie.mask = TCIF_PARAM; - TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tie); - dat->currentPage = tie.lParam; - - tvi.hItem = TreeView_GetNextItem(GetDlgItem(hwndDlg, IDC_PAGETREE), NULL, TVGN_CARET); - tvi.mask = TVIF_PARAM; - tvi.lParam = dat->currentPage; - TreeView_SetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); - - if (dat->currentPage != -1) { - if (dat->opd[dat->currentPage].hwnd == NULL) - CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); - } - } - break; - - case TVN_SELCHANGED: - if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); - { - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; - TVITEM tvi = pnmtv->itemNew; - dat->currentPage = tvi.lParam; - - if (dat->currentPage != -1) { - CreateDetailsTabs(hwndDlg, dat, &dat->opd[dat->currentPage]); - if (dat->opd[dat->currentPage].hwnd == NULL) - CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); - - } - } - } - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDCANCEL: - pshn.hdr.idFrom = 0; - pshn.hdr.code = PSN_RESET; - pshn.lParam = (LPARAM)dat->hContact; - - for (i = 0; i < dat->pageCount; i++) { - DetailsPageData &odp = dat->opd[i]; - if (odp.hwnd == NULL || !odp.changed) - continue; - pshn.hdr.hwndFrom = odp.hwnd; - SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - } - DestroyWindow(hwndDlg); - break; - - case IDOK: - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)dat->hContact; - if (dat->currentPage != -1) { - pshn.hdr.code = PSN_KILLACTIVE; - pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; - if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) - break; - } - - pshn.hdr.code = PSN_APPLY; - for (i = 0; i < dat->pageCount; i++) { - DetailsPageData &odp = dat->opd[i]; - if (odp.hwnd == NULL || !odp.changed) - continue; - pshn.hdr.hwndFrom = odp.hwnd; - if (SendMessage(odp.hwnd, WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) { - TreeView_Select(GetDlgItem(hwndDlg, IDC_PAGETREE), odp.hItem, TVGN_CARET); - if (dat->currentPage != -1) ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); - dat->currentPage = i; - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); - return 0; - } - } - DestroyWindow(hwndDlg); - break; - - case IDC_UPDATE: - if (dat->infosUpdated != NULL) { - mir_free(dat->infosUpdated); - dat->infosUpdated = NULL; - } - if (dat->hContact != NULL) { - if (!CallContactService(dat->hContact, PSS_GETINFO, 0, 0)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_SHOW); - SetTimer(hwndDlg, 1, 100, NULL); - } - } - break; - } - break; - - case WM_CLOSE: - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); - break; - - case WM_DESTROY: - TCHAR name[128]; - TVITEM tvi; - tvi.mask = TVIF_TEXT; - tvi.hItem = dat->opd[dat->currentPage].hItem; - tvi.pszText = name; - tvi.cchTextMax = SIZEOF(name); - TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); - db_set_ts(NULL, "UserInfo", "LastTab", name); - - Window_FreeIcon_IcoLib(hwndDlg); - SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDC_WHITERECT, WM_GETFONT, 0, 0), 0); - DeleteObject(dat->hBoldFont); - WindowList_Remove(hWindowList, hwndDlg); - UnhookEvent(dat->hProtoAckEvent); - - for (i = 0; i < dat->pageCount; i++) { - DetailsPageData &odp = dat->opd[i]; - if (odp.hwnd != NULL) - DestroyWindow(odp.hwnd); - mir_free(odp.ptszTitle); - mir_free(odp.ptszTab); - } - - mir_free(dat->infosUpdated); - mir_free(dat->opd); - mir_free(dat); - break; - } - return FALSE; -} - -static int ShutdownUserInfo(WPARAM, LPARAM) -{ - WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); - WindowList_Destroy(hWindowList); - return 0; -} - -int LoadUserInfoModule(void) -{ - CreateServiceFunction("UserInfo/AddPage", AddDetailsPage); - CreateServiceFunction(MS_USERINFO_SHOWDIALOG, ShowDetailsDialogCommand); - - hDetailsInitEvent = CreateHookableEvent(ME_USERINFO_INITIALISE); - - HookEvent(ME_USERINFO_INITIALISE, DetailsInit); - HookEvent(ME_DB_CONTACT_DELETED, UserInfoContactDelete); - HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownUserInfo); - - CLISTMENUITEM mi = { sizeof(mi) }; - mi.position = 1000050000; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_USERDETAILS); - mi.pszName = LPGEN("User &details"); - mi.pszService = MS_USERINFO_SHOWDIALOG; - Menu_AddContactMenuItem(&mi); - - mi.position = 500050000; - mi.pszName = LPGEN("View/change my &details..."); - Menu_AddMainMenuItem(&mi); - - hWindowList = WindowList_Create(); - return 0; -} diff --git a/src/core/stduserinfo/version.h b/src/core/stduserinfo/version.h deleted file mode 100644 index 4d33057048..0000000000 --- a/src/core/stduserinfo/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 User Info module" -#define __INTERNAL_NAME "stduserinfo" -#define __FILENAME "stduserinfo.dll" -#define __DESCRIPTION "Core module for providing user information." -#define __AUTHOR "Miranda NG Development Team" -#define __AUTHOREMAIL "" -#define __AUTHORWEB "http://miranda-ng.org/p/StdUserInfo/" -#define __COPYRIGHT "© 2012 Miranda NG Development Team" diff --git a/src/core/stduserinfo/version.rc b/src/core/stduserinfo/version.rc deleted file mode 100644 index d1da5e8d6a..0000000000 --- a/src/core/stduserinfo/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