summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-06-09 21:26:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-06-09 21:30:54 +0300
commit856ff580fd9d776c331a6b525fa7d73a24d92f64 (patch)
tree42c4912b0b9c406c15783af3fc6e8c4857b09de1 /protocols
parent68c2dea66f3e368cc1437f7890c8e62907890fcd (diff)
UserInfo -> UI classes
Diffstat (limited to 'protocols')
-rw-r--r--protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp227
-rw-r--r--protocols/Gadu-Gadu/src/dialogs.cpp623
-rw-r--r--protocols/ICQ-WIM/src/userinfo.cpp56
-rw-r--r--protocols/ICQCorp/src/user.cpp80
-rw-r--r--protocols/IRCG/src/userinfo.cpp277
-rw-r--r--protocols/JabberG/src/jabber_proto.h4
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp1173
-rw-r--r--protocols/Tox/src/tox_contacts.cpp101
-rw-r--r--protocols/Weather/src/stdafx.h16
-rw-r--r--protocols/Weather/src/weather_info.cpp63
-rw-r--r--protocols/Weather/src/weather_userinfo.cpp141
11 files changed, 1239 insertions, 1522 deletions
diff --git a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp
index c24045470c..bb59292a77 100644
--- a/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp
+++ b/protocols/CurrencyRates/src/CurrencyRateInfoDlg.cpp
@@ -17,74 +17,57 @@ inline bool IsMyContact(MCONTACT hContact)
return nullptr != GetContactProviderPtr(hContact);
}
-inline MCONTACT get_contact(HWND hWnd)
-{
- return MCONTACT(GetWindowLongPtr(hWnd, GWLP_USERDATA));
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// User info dialog
-static bool get_fetch_time(time_t& rTime, MCONTACT hContact)
+class CurrencyRateInfoDlg : public CUserInfoPageDlg
{
- rTime = g_plugin.getDword(hContact, DB_STR_CURRENCYRATE_FETCH_TIME, -1);
- return (rTime != -1);
-}
+ CCtrlHyperlink url;
-INT_PTR CALLBACK CurrencyRateInfoDlgProcImpl(MCONTACT hContact, HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- assert(hContact);
-
- TranslateDialogDefault(hdlg);
- {
- ::SetDlgItemTextW(hdlg, IDC_STATIC_CURRENCYRATE_NAME, GetContactName(hContact));
-
- double dRate = 0.0;
- if (true == CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_PREV_VALUE, dRate)) {
- wchar_t str[40];
- swprintf_s(str, L"%.6lf", dRate);
- ::SetDlgItemTextW(hdlg, IDC_EDIT_PREVIOUS_RATE, str);
- }
+public:
+ CurrencyRateInfoDlg(int idDialog) :
+ CUserInfoPageDlg(g_plugin, idDialog),
+ url(this, IDC_SYSLINK_PROVIDER)
+ {
+ }
- dRate = 0.0;
- if (true == CurrencyRates_DBReadDouble(hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate)) {
- wchar_t str[40];
- swprintf_s(str, L"%.6lf", dRate);
- ::SetDlgItemTextW(hdlg, IDC_EDIT_RATE, str);
- }
+ bool OnRefresh() override
+ {
+ ::SetDlgItemTextW(m_hwnd, IDC_STATIC_CURRENCYRATE_NAME, GetContactName(m_hContact));
- time_t nFetchTime;
- if (true == get_fetch_time(nFetchTime, hContact)) {
- wchar_t szTime[50] = { 0 };
- if (0 == _tctime_s(szTime, 50, &nFetchTime)) {
- ::SetDlgItemTextW(hdlg, IDC_EDIT_RATE_FETCH_TIME, szTime);
- }
- }
+ double dRate = 0.0;
+ if (true == CurrencyRates_DBReadDouble(m_hContact, MODULENAME, DB_STR_CURRENCYRATE_PREV_VALUE, dRate)) {
+ wchar_t str[40];
+ swprintf_s(str, L"%.6lf", dRate);
+ ::SetDlgItemTextW(m_hwnd, IDC_EDIT_PREVIOUS_RATE, str);
+ }
- const ICurrencyRatesProvider::CProviderInfo& pi = GetContactProviderPtr(hContact)->GetInfo();
- CMStringW provInfo(FORMAT, L"%s <a href=\"%s\">%s</a>", TranslateT("Info provided by"), pi.m_sURL.c_str(), pi.m_sName.c_str());
- ::SetDlgItemTextW(hdlg, IDC_SYSLINK_PROVIDER, provInfo);
+ dRate = 0.0;
+ if (true == CurrencyRates_DBReadDouble(m_hContact, MODULENAME, DB_STR_CURRENCYRATE_CURR_VALUE, dRate)) {
+ wchar_t str[40];
+ swprintf_s(str, L"%.6lf", dRate);
+ ::SetDlgItemTextW(m_hwnd, IDC_EDIT_RATE, str);
}
- return TRUE;
-
- case WM_NOTIFY:
- LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam);
- switch (pNMHDR->code) {
- case NM_CLICK:
- if (IDC_SYSLINK_PROVIDER == wParam) {
- PNMLINK pNMLink = reinterpret_cast<PNMLINK>(pNMHDR);
- ::ShellExecute(hdlg, L"open", pNMLink->item.szUrl, nullptr, nullptr, SW_SHOWNORMAL);
+
+ time_t nFetchTime = g_plugin.getDword(m_hContact, DB_STR_CURRENCYRATE_FETCH_TIME, -1);
+ if (nFetchTime != -1) {
+ wchar_t szTime[50] = { 0 };
+ if (0 == _tctime_s(szTime, 50, &nFetchTime)) {
+ ::SetDlgItemTextW(m_hwnd, IDC_EDIT_RATE_FETCH_TIME, szTime);
}
- break;
}
- break;
+
+ auto &pi = GetContactProviderPtr(m_hContact)->GetInfo();
+ CMStringW provInfo(FORMAT, L"%s <a href=\"%s\">%s</a>", TranslateT("Info provided by"), pi.m_sURL.c_str(), pi.m_sName.c_str());
+ ::SetDlgItemTextW(m_hwnd, IDC_SYSLINK_PROVIDER, provInfo);
+ return false;
}
- return FALSE;
-}
-INT_PTR CALLBACK CurrencyRateInfoDlgProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- return CurrencyRateInfoDlgProcImpl(g_hContact, hdlg, msg, wParam, lParam);
-}
+ void onClick_Url(CCtrlHyperlink *pLink)
+ {
+ ::ShellExecute(m_hwnd, L"open", ptrW(pLink->GetText()), nullptr, nullptr, SW_SHOWNORMAL);
+ }
+};
int CurrencyRatesEventFunc_OnUserInfoInit(WPARAM wp, LPARAM hContact)
{
@@ -96,15 +79,65 @@ int CurrencyRatesEventFunc_OnUserInfoInit(WPARAM wp, LPARAM hContact)
g_hContact = hContact;
- OPTIONSDIALOGPAGE odp = {};
- odp.pfnDlgProc = CurrencyRateInfoDlgProc;
- odp.position = -2000000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_CURRENCYRATE_INFO);
- odp.szTitle.a = LPGEN("Currency Rate");
- g_plugin.addUserInfo(wp, &odp);
+ USERINFOPAGE uip = {};
+ uip.position = -2000000000;
+ uip.pDialog = new CurrencyRateInfoDlg(IDD_DIALOG_CURRENCYRATE_INFO);
+ uip.szTitle.a = LPGEN("Currency Rate");
+ g_plugin.addUserInfo(wp, &uip);
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Additional info dialog
+
+struct CurrencyRateInfoDlg2 : public CurrencyRateInfoDlg
+{
+ CurrencyRateInfoDlg2(MCONTACT hContact) :
+ CurrencyRateInfoDlg(IDD_DIALOG_CURRENCYRATE_INFO_1)
+ {
+ m_hContact = hContact;
+ }
+
+ bool OnInitDialog() override
+ {
+ MWindowList hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, false);
+ WindowList_Add(hWL, m_hwnd, m_hContact);
+
+ Utils_RestoreWindowPositionNoSize(m_hwnd, m_hContact, MODULENAME, WINDOW_PREFIX_INFO);
+ OnRefresh();
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ MWindowList hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, false);
+ WindowList_Remove(hWL, m_hwnd);
+
+ Utils_SaveWindowPosition(m_hwnd, m_hContact, MODULENAME, WINDOW_PREFIX_INFO);
+ }
+};
+
+int CurrencyRates_OnContactDoubleClick(WPARAM wp, LPARAM/* lp*/)
+{
+ MCONTACT hContact = MCONTACT(wp);
+ if (GetContactProviderPtr(hContact)) {
+ MWindowList hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, true);
+ assert(hWL);
+ HWND hWnd = WindowList_Find(hWL, hContact);
+ if (nullptr != hWnd) {
+ SetForegroundWindow(hWnd);
+ SetFocus(hWnd);
+ }
+ else if (true == IsMyContact(hContact))
+ (new CurrencyRateInfoDlg2(hContact))->Show();
+
+ return 1;
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CurrencyRatesMenu_EditSettings(WPARAM wp, LPARAM)
{
@@ -148,72 +181,6 @@ INT_PTR CurrencyRatesMenu_RefreshContact(WPARAM wp, LPARAM)
return 0;
}
-static INT_PTR CALLBACK CurrencyRateInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- MCONTACT hContact = NULL;
- MWindowList hWL;
-
- switch (msg) {
- case WM_INITDIALOG:
- hContact = MCONTACT(lParam);
- hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, false);
- assert(hWL);
- WindowList_Add(hWL, hdlg, hContact);
-
- ::SetWindowLongPtr(hdlg, GWLP_USERDATA, hContact);
- Utils_RestoreWindowPositionNoSize(hdlg, hContact, MODULENAME, WINDOW_PREFIX_INFO);
- ::ShowWindow(hdlg, SW_SHOW);
- break;
-
- case WM_CLOSE:
- DestroyWindow(hdlg);
- return FALSE;
-
- case WM_DESTROY:
- hContact = get_contact(hdlg);
- if (hContact) {
- SetWindowLongPtr(hdlg, GWLP_USERDATA, 0);
-
- hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, false);
- assert(hWL);
- WindowList_Remove(hWL, hdlg);
- Utils_SaveWindowPosition(hdlg, hContact, MODULENAME, WINDOW_PREFIX_INFO);
- }
- return FALSE;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK) {
- ::DestroyWindow(hdlg);
- return FALSE;
- }
-
- default:
- hContact = get_contact(hdlg);
- break;
- }
-
- return CurrencyRateInfoDlgProcImpl(hContact, hdlg, msg, wParam, lParam);
-}
-
-int CurrencyRates_OnContactDoubleClick(WPARAM wp, LPARAM/* lp*/)
-{
- MCONTACT hContact = MCONTACT(wp);
- if (GetContactProviderPtr(hContact)) {
- MWindowList hWL = CModuleInfo::GetWindowList(WINDOW_PREFIX_INFO, true);
- assert(hWL);
- HWND hWnd = WindowList_Find(hWL, hContact);
- if (nullptr != hWnd) {
- SetForegroundWindow(hWnd);
- SetFocus(hWnd);
- }
- else if (true == IsMyContact(hContact))
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG_CURRENCYRATE_INFO_1), nullptr, CurrencyRateInfoDlgProc1, LPARAM(hContact));
-
- return 1;
- }
-
- return 0;
-}
int CurrencyRates_PrebuildContactMenu(WPARAM wp, LPARAM)
{
@@ -239,7 +206,7 @@ int CurrencyRates_PrebuildContactMenu(WPARAM wp, LPARAM)
CMStringW sLogFileName;
if (get_log_file(hContact, sLogFileName) && !sLogFileName.IsEmpty() && !_waccess(sLogFileName, 04)) {
#ifdef CHART_IMPLEMENT
- Menu_EnableItem(g_hMenuChart, true);
+ Menu_EnableItem(g_hMenuChart, true);
#endif
Menu_EnableItem(g_hMenuOpenLogFile, true);
}
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp
index 77e90dea4a..dcc4292fd7 100644
--- a/protocols/Gadu-Gadu/src/dialogs.cpp
+++ b/protocols/Gadu-Gadu/src/dialogs.cpp
@@ -20,7 +20,7 @@
#include "gg.h"
-extern INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+extern INT_PTR CALLBACK gg_userutildlgproc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
#define SVS_NORMAL 0
#define SVS_GENDER 1
@@ -35,7 +35,7 @@ extern INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam
////////////////////////////////////////////////////////////////////////////////
// SetValue
//
-static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special, int disableIfUndef)
+static void SetValue(HWND m_hwnd, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special, int disableIfUndef)
{
DBVARIANT dbv = { 0 };
wchar_t str[256];
@@ -145,16 +145,16 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule
}
if (disableIfUndef) {
- EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified);
+ EnableWindow(GetDlgItem(m_hwnd, idCtrl), !unspecified);
if (unspecified)
- SetDlgItemText(hwndDlg, idCtrl, TranslateT("<not specified>"));
+ SetDlgItemText(m_hwnd, idCtrl, TranslateT("<not specified>"));
else
- SetDlgItemText(hwndDlg, idCtrl, ptstr);
+ SetDlgItemText(m_hwnd, idCtrl, ptstr);
}
else {
- EnableWindow(GetDlgItem(hwndDlg, idCtrl), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, idCtrl), TRUE);
if (!unspecified)
- SetDlgItemText(hwndDlg, idCtrl, ptstr);
+ SetDlgItemText(m_hwnd, idCtrl, ptstr);
}
db_free(&dbv);
}
@@ -182,36 +182,36 @@ void GaduProto::checknewuser(uin_t uin, const char* passwd)
////////////////////////////////////////////////////////////////////////////////
// Options Page : Proc
//
-static void gg_optsdlgcheck(HWND hwndDlg)
+static void gg_optsdlgcheck(HWND m_hwnd)
{
wchar_t text[128];
- GetDlgItemText(hwndDlg, IDC_UIN, text, _countof(text));
+ GetDlgItemText(m_hwnd, IDC_UIN, text, _countof(text));
if (text[0]) {
- GetDlgItemText(hwndDlg, IDC_EMAIL, text, _countof(text));
+ GetDlgItemText(m_hwnd, IDC_EMAIL, text, _countof(text));
if (text[0])
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHEMAIL), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHEMAIL), SW_SHOW);
else
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHEMAIL), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHPASS), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_REMOVEACCOUNT), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CREATEACCOUNT), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHEMAIL), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHPASS), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_LOSTPASS), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVEACCOUNT), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CREATEACCOUNT), SW_HIDE);
}
else {
- ShowWindow(GetDlgItem(hwndDlg, IDC_REMOVEACCOUNT), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHPASS), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHEMAIL), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CREATEACCOUNT), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVEACCOUNT), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_LOSTPASS), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHPASS), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHEMAIL), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CREATEACCOUNT), SW_SHOW);
}
}
////////////////////////////////////////////////////////////////////////////////////////////
// Proc: General options dialog
//
-static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK gg_genoptsdlgproc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- GaduProto *gg = (GaduProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GaduProto *gg = (GaduProto *)GetWindowLongPtr(m_hwnd, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
@@ -219,77 +219,77 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
DBVARIANT dbv;
uint32_t num;
gg = (GaduProto *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
- TranslateDialogDefault(hwndDlg);
+ TranslateDialogDefault(m_hwnd);
if (num = gg->getDword(GG_KEY_UIN, 0)) {
- SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
- ShowWindow(GetDlgItem(hwndDlg, IDC_CREATEACCOUNT), SW_HIDE);
+ SetDlgItemTextA(m_hwnd, IDC_UIN, ditoa(num));
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CREATEACCOUNT), SW_HIDE);
}
else {
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHPASS), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_REMOVEACCOUNT), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHPASS), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVEACCOUNT), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_LOSTPASS), SW_HIDE);
}
if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
else {
- ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHPASS), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_LOSTPASS), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHPASS), SW_HIDE);
}
- CheckDlgButton(hwndDlg, IDC_FRIENDSONLY, gg->getByte(GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLE, gg->getByte(GG_KEY_SHOWINVISIBLE, GG_KEYDEF_SHOWINVISIBLE) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_LEAVESTATUSMSG, gg->getByte(GG_KEY_LEAVESTATUSMSG, GG_KEYDEF_LEAVESTATUSMSG) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_FRIENDSONLY, gg->getByte(GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_SHOWINVISIBLE, gg->getByte(GG_KEY_SHOWINVISIBLE, GG_KEYDEF_SHOWINVISIBLE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_LEAVESTATUSMSG, gg->getByte(GG_KEY_LEAVESTATUSMSG, GG_KEYDEF_LEAVESTATUSMSG) ? BST_CHECKED : BST_UNCHECKED);
if (gg->gc_enabled)
- CheckDlgButton(hwndDlg, IDC_IGNORECONF, gg->getByte(GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_IGNORECONF, gg->getByte(GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF) ? BST_CHECKED : BST_UNCHECKED);
else {
- EnableWindow(GetDlgItem(hwndDlg, IDC_IGNORECONF), FALSE);
- CheckDlgButton(hwndDlg, IDC_IGNORECONF, BST_CHECKED);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_IGNORECONF), FALSE);
+ CheckDlgButton(m_hwnd, IDC_IGNORECONF, BST_CHECKED);
}
- CheckDlgButton(hwndDlg, IDC_IMGRECEIVE, gg->getByte(GG_KEY_IMGRECEIVE, GG_KEYDEF_IMGRECEIVE) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SHOWLINKS, gg->getByte(GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ENABLEAVATARS, gg->getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS) ? BST_CHECKED : BST_UNCHECKED);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_LEAVESTATUS), IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
- EnableWindow(GetDlgItem(hwndDlg, IDC_IMGMETHOD), IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Last Status>")); // 0
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_ONLINE, 0));
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_AWAY, 0));
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_DND, 0));
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_FREECHAT, 0));
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_INVISIBLE, 0));
+ CheckDlgButton(m_hwnd, IDC_IMGRECEIVE, gg->getByte(GG_KEY_IMGRECEIVE, GG_KEYDEF_IMGRECEIVE) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_SHOWLINKS, gg->getByte(GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_ENABLEAVATARS, gg->getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS) ? BST_CHECKED : BST_UNCHECKED);
+
+ EnableWindow(GetDlgItem(m_hwnd, IDC_LEAVESTATUS), IsDlgButtonChecked(m_hwnd, IDC_LEAVESTATUSMSG));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_IMGMETHOD), IsDlgButtonChecked(m_hwnd, IDC_IMGRECEIVE));
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Last Status>")); // 0
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_ONLINE, 0));
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_AWAY, 0));
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_DND, 0));
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_FREECHAT, 0));
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)Clist_GetStatusModeDescription(ID_STATUS_INVISIBLE, 0));
switch (gg->getWord(GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
case ID_STATUS_ONLINE:
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 1, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_SETCURSEL, 1, 0);
break;
case ID_STATUS_AWAY:
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 2, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_SETCURSEL, 2, 0);
break;
case ID_STATUS_DND:
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 3, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_SETCURSEL, 3, 0);
break;
case ID_STATUS_FREECHAT:
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 4, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_SETCURSEL, 4, 0);
break;
case ID_STATUS_INVISIBLE:
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 5, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_SETCURSEL, 5, 0);
break;
default:
- SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_SETCURSEL, 0, 0);
}
- SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("System tray icon"));
- SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("Popup window"));
- SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("Message with [img] BBCode"));
- SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_SETCURSEL, gg->getByte(GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD), 0);
+ SendDlgItemMessage(m_hwnd, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("System tray icon"));
+ SendDlgItemMessage(m_hwnd, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("Popup window"));
+ SendDlgItemMessage(m_hwnd, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("Message with [img] BBCode"));
+ SendDlgItemMessage(m_hwnd, IDC_IMGMETHOD, CB_SETCURSEL, gg->getByte(GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD), 0);
}
break;
@@ -301,24 +301,24 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
switch (LOWORD(wParam)) {
case IDC_EMAIL:
case IDC_UIN:
- gg_optsdlgcheck(hwndDlg);
+ gg_optsdlgcheck(m_hwnd);
break;
case IDC_LEAVESTATUSMSG:
- EnableWindow(GetDlgItem(hwndDlg, IDC_LEAVESTATUS), IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_LEAVESTATUS), IsDlgButtonChecked(m_hwnd, IDC_LEAVESTATUSMSG));
break;
case IDC_IMGRECEIVE:
- EnableWindow(GetDlgItem(hwndDlg, IDC_IMGMETHOD), IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_IMGMETHOD), IsDlgButtonChecked(m_hwnd, IDC_IMGRECEIVE));
break;
case IDC_LOSTPASS:
{
char email[128];
uin_t uin;
- GetDlgItemTextA(hwndDlg, IDC_UIN, email, _countof(email));
+ GetDlgItemTextA(m_hwnd, IDC_UIN, email, _countof(email));
uin = atoi(email);
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, _countof(email));
+ GetDlgItemTextA(m_hwnd, IDC_EMAIL, email, _countof(email));
if (!mir_strlen(email))
MessageBox(nullptr, TranslateT("You need to specify your registration e-mail first."),
gg->m_tszUserName, MB_OK | MB_ICONEXCLAMATION);
@@ -348,58 +348,58 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
GGUSERUTILDLGDATA dat;
int ret;
char pass[128], email[128];
- GetDlgItemTextA(hwndDlg, IDC_UIN, pass, _countof(pass));
+ GetDlgItemTextA(m_hwnd, IDC_UIN, pass, _countof(pass));
dat.uin = atoi(pass);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, pass, _countof(pass));
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, _countof(email));
+ GetDlgItemTextA(m_hwnd, IDC_PASSWORD, pass, _countof(pass));
+ GetDlgItemTextA(m_hwnd, IDC_EMAIL, email, _countof(email));
dat.pass = pass;
dat.email = email;
dat.gg = gg;
if (LOWORD(wParam) == IDC_CREATEACCOUNT) {
dat.mode = GG_USERUTIL_CREATE;
- ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CREATEACCOUNT), m_hwnd, gg_userutildlgproc, (LPARAM)&dat);
}
else if (LOWORD(wParam) == IDC_CHPASS) {
dat.mode = GG_USERUTIL_PASS;
- ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHPASS), m_hwnd, gg_userutildlgproc, (LPARAM)&dat);
}
else if (LOWORD(wParam) == IDC_CHEMAIL) {
dat.mode = GG_USERUTIL_EMAIL;
- ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHEMAIL), m_hwnd, gg_userutildlgproc, (LPARAM)&dat);
}
else {
dat.mode = GG_USERUTIL_REMOVE;
- ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_REMOVEACCOUNT), m_hwnd, gg_userutildlgproc, (LPARAM)&dat);
}
if (ret == IDOK) {
DBVARIANT dbv;
uint32_t num;
// Show reload required window
- ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_RELOADREQD), SW_SHOW);
// Update uin
if (num = gg->getDword(GG_KEY_UIN, 0))
- SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
+ SetDlgItemTextA(m_hwnd, IDC_UIN, ditoa(num));
else
- SetDlgItemTextA(hwndDlg, IDC_UIN, "");
+ SetDlgItemTextA(m_hwnd, IDC_UIN, "");
// Update password
if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
- else SetDlgItemTextA(hwndDlg, IDC_PASSWORD, "");
+ else SetDlgItemTextA(m_hwnd, IDC_PASSWORD, "");
// Update e-mail
if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
- else SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
+ else SetDlgItemTextA(m_hwnd, IDC_EMAIL, "");
// Update links
- gg_optsdlgcheck(hwndDlg);
+ gg_optsdlgcheck(m_hwnd);
// Remove details
if (LOWORD(wParam) != IDC_CHPASS && LOWORD(wParam) != IDC_CHEMAIL) {
@@ -418,7 +418,7 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
break;
}
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
break;
case WM_NOTIFY:
@@ -428,36 +428,36 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
char str[128];
// Write Gadu-Gadu number & password
- GetDlgItemTextA(hwndDlg, IDC_UIN, str, _countof(str));
+ GetDlgItemTextA(m_hwnd, IDC_UIN, str, _countof(str));
uin_t uin = atoi(str);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(str));
+ GetDlgItemTextA(m_hwnd, IDC_PASSWORD, str, _countof(str));
gg->checknewuser(uin, str);
gg->setDword(GG_KEY_UIN, uin);
gg->setString(GG_KEY_PASSWORD, str);
// Write Gadu-Gadu email
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, str, _countof(str));
+ GetDlgItemTextA(m_hwnd, IDC_EMAIL, str, _countof(str));
gg->setString(GG_KEY_EMAIL, str);
// Write checkboxes
- gg->setByte(GG_KEY_FRIENDSONLY, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_FRIENDSONLY));
- gg->setByte(GG_KEY_SHOWINVISIBLE, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_SHOWINVISIBLE));
- gg->setByte(GG_KEY_LEAVESTATUSMSG, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
+ gg->setByte(GG_KEY_FRIENDSONLY, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_FRIENDSONLY));
+ gg->setByte(GG_KEY_SHOWINVISIBLE, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_SHOWINVISIBLE));
+ gg->setByte(GG_KEY_LEAVESTATUSMSG, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_LEAVESTATUSMSG));
if (gg->gc_enabled)
- gg->setByte(GG_KEY_IGNORECONF, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_IGNORECONF));
- gg->setByte(GG_KEY_IMGRECEIVE, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
- gg->setByte(GG_KEY_SHOWLINKS, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS));
- if (IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS))
+ gg->setByte(GG_KEY_IGNORECONF, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_IGNORECONF));
+ gg->setByte(GG_KEY_IMGRECEIVE, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_IMGRECEIVE));
+ gg->setByte(GG_KEY_SHOWLINKS, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_SHOWLINKS));
+ if (IsDlgButtonChecked(m_hwnd, IDC_SHOWLINKS))
status_flags |= GG_STATUS_FLAG_SPAM;
gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, "sess_mutex", 1);
gg_change_status_flags(gg->m_sess, status_flags);
gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, 1, "sess_mutex", 1);
- gg->setByte(GG_KEY_ENABLEAVATARS, (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_ENABLEAVATARS));
+ gg->setByte(GG_KEY_ENABLEAVATARS, (uint8_t)IsDlgButtonChecked(m_hwnd, IDC_ENABLEAVATARS));
- gg->setByte(GG_KEY_IMGMETHOD, (uint8_t)SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_GETCURSEL, 0, 0));
+ gg->setByte(GG_KEY_IMGMETHOD, (uint8_t)SendDlgItemMessage(m_hwnd, IDC_IMGMETHOD, CB_GETCURSEL, 0, 0));
// Write leave status
- switch (SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_GETCURSEL, 0, 0)) {
+ switch (SendDlgItemMessage(m_hwnd, IDC_LEAVESTATUS, CB_GETCURSEL, 0, 0)) {
case 1:
gg->setWord(GG_KEY_LEAVESTATUS, ID_STATUS_ONLINE);
break;
@@ -483,212 +483,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
////////////////////////////////////////////////////////////////////////////////
-// Info Page : Data
-struct GGDETAILSDLGDATA
-{
- GaduProto *gg;
- MCONTACT hContact;
- int disableUpdate;
- int updating;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// Info Page : Proc
-// lParam: 0 if current user (account owner) details, hContact if on list user details
-//
-static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- struct GGDETAILSDLGDATA *dat = (struct GGDETAILSDLGDATA *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
-
- dat = (struct GGDETAILSDLGDATA *)mir_alloc(sizeof(struct GGDETAILSDLGDATA));
- dat->hContact = lParam;
- dat->disableUpdate = FALSE;
- dat->updating = FALSE;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- // Add genders
- if (!dat->hContact) {
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)L""); // 0
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Female")); // 1
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Male")); // 2
- }
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- dat->gg = (GaduProto *)((LPPSHNOTIFY)lParam)->lParam;
- break;
-
- case PSN_INFOCHANGED:
- if (dat) {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- GaduProto *gg = dat->gg;
-
- // Show updated message
- if (dat->updating) {
- MessageBox(nullptr, TranslateT("Your details has been uploaded to the public directory."),
- gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
- dat->updating = FALSE;
- break;
- }
-
- char *szProto = (hContact == NULL) ? gg->m_szModuleName : Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr)
- break;
-
- // Disable when updating
- dat->disableUpdate = TRUE;
-
- SetValue(hwndDlg, IDC_UIN, hContact, szProto, GG_KEY_UIN, 0, hContact != NULL);
- SetValue(hwndDlg, IDC_REALIP, hContact, szProto, GG_KEY_CLIENTIP, SVS_IP, hContact != NULL);
- SetValue(hwndDlg, IDC_PORT, hContact, szProto, GG_KEY_CLIENTPORT, SVS_ZEROISUNSPEC, hContact != NULL);
- SetValue(hwndDlg, IDC_VERSION, hContact, szProto, GG_KEY_CLIENTVERSION, SVS_GGVERSION, hContact != NULL);
-
- SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, GG_KEY_PD_FIRSTNAME, SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, GG_KEY_PD_LASTNAME, SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_NICKNAME, hContact, szProto, GG_KEY_PD_NICKNAME, SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_BIRTHYEAR, hContact, szProto, GG_KEY_PD_BIRTHYEAR, SVS_ZEROISUNSPEC, hContact != NULL);
- SetValue(hwndDlg, IDC_CITY, hContact, szProto, GG_KEY_PD_CITY, SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_FAMILYNAME, hContact, szProto, GG_KEY_PD_FAMILYNAME, SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_CITYORIGIN, hContact, szProto, GG_KEY_PD_FAMILYCITY, SVS_NORMAL, hContact != NULL);
-
- if (hContact) {
- SetValue(hwndDlg, IDC_GENDER, hContact, szProto, GG_KEY_PD_GANDER, SVS_GENDER, hContact != NULL);
- SetValue(hwndDlg, IDC_STATUSDESCR, hContact, "CList", GG_KEY_STATUSDESCR, SVS_NORMAL, hContact != NULL);
- }
- else switch ((char)db_get_b(hContact, gg->m_szModuleName, GG_KEY_PD_GANDER, (uint8_t)'?')) {
- case 'F':
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 1, 0);
- break;
- case 'M':
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 2, 0);
- break;
- default:
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 0, 0);
- }
-
- // Disable when updating
- dat->disableUpdate = FALSE;
- break;
- }
- }
- break;
- }
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
- case IDC_NICKNAME:
- case IDC_FIRSTNAME:
- case IDC_LASTNAME:
- case IDC_FAMILYNAME:
- case IDC_CITY:
- case IDC_CITYORIGIN:
- case IDC_BIRTHYEAR:
- if (HIWORD(wParam) == EN_CHANGE) {
- if (!dat || dat->hContact || dat->disableUpdate)
- break;
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), TRUE);
- break;
- }
- case IDC_GENDER:
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- if (!dat || dat->hContact || dat->disableUpdate)
- break;
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), TRUE);
- break;
- }
- case IDC_SAVE: // Save current user data
- if (HIWORD(wParam) == BN_CLICKED) {
- if (!dat || dat->hContact || dat->disableUpdate)
- break;
- {
- wchar_t text[256];
- GaduProto *gg = dat->gg;
-
- if (!gg->isonline()) {
- MessageBox(nullptr,
- TranslateT("You have to be logged in before you can change your details."),
- gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- break;
- }
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), FALSE);
-
- gg_pubdir50_t req = gg_pubdir50_new(GG_PUBDIR50_WRITE);
- if (req == nullptr)
- break;
-
- GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, T2Utf(text));
-
- GetDlgItemText(hwndDlg, IDC_LASTNAME, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, T2Utf(text));
-
- GetDlgItemText(hwndDlg, IDC_NICKNAME, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, T2Utf(text));
-
- GetDlgItemText(hwndDlg, IDC_CITY, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_CITY, T2Utf(text));
-
- // Gadu-Gadu Female <-> Male
- switch (SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0)) {
- case 1:
- gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_FEMALE);
- break;
- case 2:
- gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_MALE);
- break;
- default:
- gg_pubdir50_add(req, GG_PUBDIR50_GENDER, "");
- }
-
- GetDlgItemText(hwndDlg, IDC_BIRTHYEAR, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, T2Utf(text));
-
- GetDlgItemText(hwndDlg, IDC_FAMILYNAME, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, T2Utf(text));
-
- GetDlgItemText(hwndDlg, IDC_CITYORIGIN, text, _countof(text));
- if (mir_wstrlen(text))
- gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, T2Utf(text));
-
- // Run update
- gg_pubdir50_seq_set(req, GG_SEQ_CHINFO);
- gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_detailsdlgproc", 35, "sess_mutex", 1);
- gg_pubdir50(gg->m_sess, req);
- gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 35, 1, "sess_mutex", 1);
- dat->updating = TRUE;
-
- gg_pubdir50_free(req);
- }
- break;
- }
- }
- break;
-
- case WM_DESTROY:
- if (dat) mir_free(dat);
- break;
- }
- return FALSE;
-}
-
-////////////////////////////////////////////////////////////////////////////////
// Options Page : Init
//
int GaduProto::options_init(WPARAM wParam, LPARAM)
@@ -721,36 +515,185 @@ int GaduProto::options_init(WPARAM wParam, LPARAM)
return 0;
}
-
////////////////////////////////////////////////////////////////////////////////
-// Info Page : Init
-//
+// Info Page UI dialog
+
+class GaduUserInfoDlg : public CUserInfoPageDlg
+{
+ GaduProto *gg;
+ MCONTACT hContact;
+ bool disableUpdate = false;
+ bool updating = false;
+
+ CCtrlCombo cmbGender;
+ CCtrlButton btnSave;
+
+public:
+ GaduUserInfoDlg(GaduProto *_gg, int idDialog) :
+ CUserInfoPageDlg(g_plugin, idDialog),
+ gg(_gg),
+ btnSave(this, IDC_SAVE),
+ cmbGender(this, IDC_GENDER)
+ {
+ btnSave.OnClick = Callback(this, &GaduUserInfoDlg::onClick_Save);
+ }
+
+ bool OnInitDialog() override
+ {
+ // Add genders
+ cmbGender.AddString(L"", 0);
+ cmbGender.AddString(TranslateT("Female"), 1);
+ cmbGender.AddString(TranslateT("Male"), 2);
+ return true;
+ }
+
+ bool OnRefresh() override
+ {
+ // Show updated message
+ if (updating) {
+ MessageBox(nullptr, TranslateT("Your details has been uploaded to the public directory."),
+ gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
+ updating = false;
+ return false;
+ }
+
+ char *szProto = (m_hContact == NULL) ? gg->m_szModuleName : Proto_GetBaseAccountName(hContact);
+ if (szProto == nullptr)
+ return false;
+
+ // Disable when updating
+ disableUpdate = true;
+
+ SetValue(m_hwnd, IDC_UIN, hContact, szProto, GG_KEY_UIN, 0, hContact != NULL);
+ SetValue(m_hwnd, IDC_REALIP, hContact, szProto, GG_KEY_CLIENTIP, SVS_IP, hContact != NULL);
+ SetValue(m_hwnd, IDC_PORT, hContact, szProto, GG_KEY_CLIENTPORT, SVS_ZEROISUNSPEC, hContact != NULL);
+ SetValue(m_hwnd, IDC_VERSION, hContact, szProto, GG_KEY_CLIENTVERSION, SVS_GGVERSION, hContact != NULL);
+
+ SetValue(m_hwnd, IDC_FIRSTNAME, hContact, szProto, GG_KEY_PD_FIRSTNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(m_hwnd, IDC_LASTNAME, hContact, szProto, GG_KEY_PD_LASTNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(m_hwnd, IDC_NICKNAME, hContact, szProto, GG_KEY_PD_NICKNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(m_hwnd, IDC_BIRTHYEAR, hContact, szProto, GG_KEY_PD_BIRTHYEAR, SVS_ZEROISUNSPEC, hContact != NULL);
+ SetValue(m_hwnd, IDC_CITY, hContact, szProto, GG_KEY_PD_CITY, SVS_NORMAL, hContact != NULL);
+ SetValue(m_hwnd, IDC_FAMILYNAME, hContact, szProto, GG_KEY_PD_FAMILYNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(m_hwnd, IDC_CITYORIGIN, hContact, szProto, GG_KEY_PD_FAMILYCITY, SVS_NORMAL, hContact != NULL);
+
+ if (hContact) {
+ SetValue(m_hwnd, IDC_GENDER, hContact, szProto, GG_KEY_PD_GANDER, SVS_GENDER, hContact != NULL);
+ SetValue(m_hwnd, IDC_STATUSDESCR, hContact, "CList", GG_KEY_STATUSDESCR, SVS_NORMAL, hContact != NULL);
+ }
+ else switch ((char)db_get_b(hContact, gg->m_szModuleName, GG_KEY_PD_GANDER, (uint8_t)'?')) {
+ case 'F':
+ SendDlgItemMessage(m_hwnd, IDC_GENDER, CB_SETCURSEL, 1, 0);
+ break;
+ case 'M':
+ SendDlgItemMessage(m_hwnd, IDC_GENDER, CB_SETCURSEL, 2, 0);
+ break;
+ default:
+ SendDlgItemMessage(m_hwnd, IDC_GENDER, CB_SETCURSEL, 0, 0);
+ }
+
+ // Disable when updating
+ disableUpdate = false;
+ return false;
+ }
+
+ void OnChange() override
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SAVE), TRUE);
+ }
+
+ void onClick_Save(CCtrlButton*)
+ {
+ wchar_t text[256];
+
+ if (!gg->isonline()) {
+ MessageBox(nullptr,
+ TranslateT("You have to be logged in before you can change your details."),
+ gg->m_tszUserName, MB_OK | MB_ICONSTOP);
+ return;
+ }
+
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SAVE), FALSE);
+
+ gg_pubdir50_t req = gg_pubdir50_new(GG_PUBDIR50_WRITE);
+ if (req == nullptr)
+ return;
+
+ GetDlgItemText(m_hwnd, IDC_FIRSTNAME, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, T2Utf(text));
+
+ GetDlgItemText(m_hwnd, IDC_LASTNAME, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, T2Utf(text));
+
+ GetDlgItemText(m_hwnd, IDC_NICKNAME, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, T2Utf(text));
+
+ GetDlgItemText(m_hwnd, IDC_CITY, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_CITY, T2Utf(text));
+
+ // Gadu-Gadu Female <-> Male
+ switch (SendDlgItemMessage(m_hwnd, IDC_GENDER, CB_GETCURSEL, 0, 0)) {
+ case 1:
+ gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_FEMALE);
+ break;
+ case 2:
+ gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_MALE);
+ break;
+ default:
+ gg_pubdir50_add(req, GG_PUBDIR50_GENDER, "");
+ }
+
+ GetDlgItemText(m_hwnd, IDC_BIRTHYEAR, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, T2Utf(text));
+
+ GetDlgItemText(m_hwnd, IDC_FAMILYNAME, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, T2Utf(text));
+
+ GetDlgItemText(m_hwnd, IDC_CITYORIGIN, text, _countof(text));
+ if (mir_wstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, T2Utf(text));
+
+ // Run update
+ gg_pubdir50_seq_set(req, GG_SEQ_CHINFO);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_detailsdlgproc", 35, "sess_mutex", 1);
+ gg_pubdir50(gg->m_sess, req);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 35, 1, "sess_mutex", 1);
+ updating = true;
+
+ gg_pubdir50_free(req);
+ }
+};
+
int GaduProto::details_init(WPARAM wParam, LPARAM hContact)
{
- char* pszTemplate;
+ int idDialog;
+ // View/Change My Details
if (hContact == NULL) {
- // View/Change My Details
- pszTemplate = MAKEINTRESOURCEA(IDD_CHINFO_GG);
+ idDialog = IDD_CHINFO_GG;
}
+ // Other user details
else {
- // Other user details
char* szProto = Proto_GetBaseAccountName(hContact);
if (szProto == nullptr)
return 0;
if (mir_strcmp(szProto, m_szModuleName) || isChatRoom(hContact))
return 0;
- pszTemplate = MAKEINTRESOURCEA(IDD_INFO_GG);
+ idDialog = IDD_INFO_GG;
}
- OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_DONTTRANSLATE | ODPF_UNICODE;
- odp.pfnDlgProc = gg_detailsdlgproc;
- odp.position = -1900000000;
- odp.pszTemplate = pszTemplate;
- odp.szTitle.w = m_tszUserName;
- odp.dwInitParam = (LPARAM)this;
- g_plugin.addUserInfo(wParam, &odp);
+ USERINFOPAGE uip = {};
+ uip.flags = ODPF_DONTTRANSLATE | ODPF_UNICODE;
+ uip.position = -1900000000;
+ uip.pDialog = new GaduUserInfoDlg(this, idDialog);
+ uip.szTitle.w = m_tszUserName;
+ g_plugin.addUserInfo(wParam, &uip);
// Start search for user data
if (hContact == NULL)
@@ -762,27 +705,27 @@ int GaduProto::details_init(WPARAM wParam, LPARAM hContact)
////////////////////////////////////////////////////////////////////////////////////////////
// Proc: Account manager options dialog
//
-INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- GaduProto *gg = (GaduProto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GaduProto *gg = (GaduProto *)GetWindowLongPtr(m_hwnd, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
{
DBVARIANT dbv;
gg = (GaduProto *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
- TranslateDialogDefault(hwndDlg);
+ TranslateDialogDefault(m_hwnd);
uint32_t num = gg->getDword(GG_KEY_UIN, 0);
if (num)
- SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
+ SetDlgItemTextA(m_hwnd, IDC_UIN, ditoa(num));
if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
break;
@@ -794,41 +737,41 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
// Readup data
GGUSERUTILDLGDATA dat;
char pass[128], email[128];
- GetDlgItemTextA(hwndDlg, IDC_UIN, pass, _countof(pass));
+ GetDlgItemTextA(m_hwnd, IDC_UIN, pass, _countof(pass));
dat.uin = atoi(pass);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, pass, _countof(pass));
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, _countof(email));
+ GetDlgItemTextA(m_hwnd, IDC_PASSWORD, pass, _countof(pass));
+ GetDlgItemTextA(m_hwnd, IDC_EMAIL, email, _countof(email));
dat.pass = pass;
dat.email = email;
dat.gg = gg;
dat.mode = GG_USERUTIL_CREATE;
- int ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ int ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CREATEACCOUNT), m_hwnd, gg_userutildlgproc, (LPARAM)&dat);
if (ret == IDOK) {
DBVARIANT dbv;
uint32_t num;
// Show reload required window
- ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_RELOADREQD), SW_SHOW);
// Update uin
if (num = gg->getDword(GG_KEY_UIN, 0))
- SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
+ SetDlgItemTextA(m_hwnd, IDC_UIN, ditoa(num));
else
- SetDlgItemTextA(hwndDlg, IDC_UIN, "");
+ SetDlgItemTextA(m_hwnd, IDC_UIN, "");
// Update password
if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
- else SetDlgItemTextA(hwndDlg, IDC_PASSWORD, "");
+ else SetDlgItemTextA(m_hwnd, IDC_PASSWORD, "");
// Update e-mail
if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
+ SetDlgItemTextA(m_hwnd, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
- else SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
+ else SetDlgItemTextA(m_hwnd, IDC_EMAIL, "");
}
}
break;
@@ -837,7 +780,7 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case IDC_PASSWORD:
case IDC_EMAIL:
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
break;
}
}
@@ -851,15 +794,15 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
char str[128];
// Write Gadu-Gadu number & password
- GetDlgItemTextA(hwndDlg, IDC_UIN, str, _countof(str));
+ GetDlgItemTextA(m_hwnd, IDC_UIN, str, _countof(str));
uin_t uin = atoi(str);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(str));
+ GetDlgItemTextA(m_hwnd, IDC_PASSWORD, str, _countof(str));
gg->checknewuser(uin, str);
gg->setDword(GG_KEY_UIN, uin);
gg->setString(GG_KEY_PASSWORD, str);
// Write Gadu-Gadu email
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, str, _countof(str));
+ GetDlgItemTextA(m_hwnd, IDC_EMAIL, str, _countof(str));
gg->setString(GG_KEY_EMAIL, str);
}
}
diff --git a/protocols/ICQ-WIM/src/userinfo.cpp b/protocols/ICQ-WIM/src/userinfo.cpp
index 92c517a637..259796a268 100644
--- a/protocols/ICQ-WIM/src/userinfo.cpp
+++ b/protocols/ICQ-WIM/src/userinfo.cpp
@@ -20,32 +20,28 @@
#include "stdafx.h"
-static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
+struct IcqUserInfoDlg : public CUserInfoPageDlg
{
- switch(msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- break;
+ CIcqProto *ppro;
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_PARAMCHANGED) {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- CIcqProto *ppro = (CIcqProto*)((PSHNOTIFY*)lParam)->lParam;
+ IcqUserInfoDlg(CIcqProto *_ppro) :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_ICQ),
+ ppro(_ppro)
+ {
+ }
- SetDlgItemTextW(hwndDlg, IDC_UIN, ppro->GetUserId(hContact));
- SetDlgItemTextW(hwndDlg, IDC_NICK, ppro->getMStringW(hContact, DB_KEY_ICQNICK));
+ bool OnRefresh() override
+ {
+ SetDlgItemTextW(m_hwnd, IDC_UIN, ppro->GetUserId(m_hContact));
+ SetDlgItemTextW(m_hwnd, IDC_NICK, ppro->getMStringW(m_hContact, DB_KEY_ICQNICK));
- SetDlgItemTextA(hwndDlg, IDC_IDLETIME, time2text(ppro->getDword(hContact, DB_KEY_IDLE)));
- SetDlgItemTextA(hwndDlg, IDC_LASTSEEN, time2text(ppro->getDword(hContact, DB_KEY_LASTSEEN)));
- SetDlgItemTextA(hwndDlg, IDC_MEMBERSINCE, time2text(ppro->getDword(hContact, DB_KEY_MEMBERSINCE)));
- SetDlgItemTextA(hwndDlg, IDC_ONLINESINCE, time2text(time(0) - ppro->getDword(hContact, DB_KEY_ONLINETS)));
- }
- break;
+ SetDlgItemTextA(m_hwnd, IDC_IDLETIME, time2text(ppro->getDword(m_hContact, DB_KEY_IDLE)));
+ SetDlgItemTextA(m_hwnd, IDC_LASTSEEN, time2text(ppro->getDword(m_hContact, DB_KEY_LASTSEEN)));
+ SetDlgItemTextA(m_hwnd, IDC_MEMBERSINCE, time2text(ppro->getDword(m_hContact, DB_KEY_MEMBERSINCE)));
+ SetDlgItemTextA(m_hwnd, IDC_ONLINESINCE, time2text(time(0) - ppro->getDword(m_hContact, DB_KEY_ONLINETS)));
+ return false;
}
-
- return 0;
-}
+};
int CIcqProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact)
{
@@ -55,18 +51,16 @@ int CIcqProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact)
if (isChatRoom(hContact))
return 0;
- OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_UNICODE;
- odp.dwInitParam = LPARAM(this);
+ USERINFOPAGE uip = {};
+ uip.flags = ODPF_UNICODE;
if (hContact == 0) {
- odp.flags |= ODPF_DONTTRANSLATE;
- odp.szTitle.w = m_tszUserName;
+ uip.flags |= ODPF_DONTTRANSLATE;
+ uip.szTitle.w = m_tszUserName;
}
- else odp.szTitle.w = L"ICQ";
+ else uip.szTitle.w = L"ICQ";
- odp.pfnDlgProc = IcqDlgProc;
- odp.position = -1900000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_ICQ);
- g_plugin.addUserInfo(wParam, &odp);
+ uip.position = -1900000000;
+ uip.pDialog = new IcqUserInfoDlg(this);
+ g_plugin.addUserInfo(wParam, &uip);
return 0;
}
diff --git a/protocols/ICQCorp/src/user.cpp b/protocols/ICQCorp/src/user.cpp
index fe986a4224..ff6c160fac 100644
--- a/protocols/ICQCorp/src/user.cpp
+++ b/protocols/ICQCorp/src/user.cpp
@@ -100,49 +100,36 @@ static void setTextValue(HWND hWnd, int id, const wchar_t *value)
///////////////////////////////////////////////////////////////////////////////
-static INT_PTR CALLBACK icqUserInfoDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+struct UserInfoDlg : public CUserInfoPageDlg
{
- LPNMHDR hdr;
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hWnd);
- return TRUE;
-
- case WM_NOTIFY:
- hdr = (LPNMHDR)lParam;
- if (hdr->idFrom == 0 && hdr->code == PSN_INFOCHANGED) {
- wchar_t buffer[64];
- unsigned long ip, port;
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
-
- _itow(g_plugin.getDword(hContact, "UIN", 0), buffer, 10);
- setTextValue(hWnd, IDC_INFO_UIN, buffer);
-
- ip = g_plugin.getDword(hContact, "IP", 0);
- setTextValue(hWnd, IDC_INFO_IP, ip ? _A2T(iptoa(ip)) : nullptr);
-
- ip = g_plugin.getDword(hContact, "RealIP", 0);
- setTextValue(hWnd, IDC_INFO_REALIP, ip ? _A2T(iptoa(ip)) : nullptr);
-
- port = g_plugin.getWord(hContact, "Port", 0);
- _itow(port, buffer, 10);
- setTextValue(hWnd, IDC_INFO_PORT, port ? buffer : nullptr);
-
- setTextValue(hWnd, IDC_INFO_VERSION, nullptr);
- setTextValue(hWnd, IDC_INFO_MIRVER, nullptr);
- setTextValue(hWnd, IDC_INFO_PING, nullptr);
- }
- break;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDCANCEL) SendMessage(GetParent(hWnd), msg, wParam, lParam);
- break;
- }
- return FALSE;
-}
+ UserInfoDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_ICQCORP)
+ {}
-///////////////////////////////////////////////////////////////////////////////
+ bool OnRefresh() override
+ {
+ wchar_t buffer[64];
+ unsigned long ip, port;
+
+ _itow(g_plugin.getDword(m_hContact, "UIN", 0), buffer, 10);
+ setTextValue(m_hwnd, IDC_INFO_UIN, buffer);
+
+ ip = g_plugin.getDword(m_hContact, "IP", 0);
+ setTextValue(m_hwnd, IDC_INFO_IP, ip ? _A2T(iptoa(ip)) : nullptr);
+
+ ip = g_plugin.getDword(m_hContact, "RealIP", 0);
+ setTextValue(m_hwnd, IDC_INFO_REALIP, ip ? _A2T(iptoa(ip)) : nullptr);
+
+ port = g_plugin.getWord(m_hContact, "Port", 0);
+ _itow(port, buffer, 10);
+ setTextValue(m_hwnd, IDC_INFO_PORT, port ? buffer : nullptr);
+
+ setTextValue(m_hwnd, IDC_INFO_VERSION, nullptr);
+ setTextValue(m_hwnd, IDC_INFO_MIRVER, nullptr);
+ setTextValue(m_hwnd, IDC_INFO_PING, nullptr);
+ return false;
+ }
+};
int icqUserInfoInitialise(WPARAM wParam, LPARAM lParam)
{
@@ -150,11 +137,10 @@ int icqUserInfoInitialise(WPARAM wParam, LPARAM lParam)
if ((proto == nullptr || mir_strcmp(proto, protoName)) && lParam)
return 0;
- OPTIONSDIALOGPAGE odp = {};
- odp.position = -1900000000;
- odp.szTitle.a = protoName;
- odp.pfnDlgProc = icqUserInfoDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_ICQCORP);
- g_plugin.addUserInfo(wParam, &odp);
+ USERINFOPAGE uip = {};
+ uip.position = -1900000000;
+ uip.szTitle.a = protoName;
+ uip.pDialog = new UserInfoDlg();
+ g_plugin.addUserInfo(wParam, &uip);
return 0;
}
diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp
index fa9620e4ee..c0e18fa0eb 100644
--- a/protocols/IRCG/src/userinfo.cpp
+++ b/protocols/IRCG/src/userinfo.cpp
@@ -24,167 +24,166 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
// 'User details' dialog
-struct UserDetailsDlgProcParam
-{
- UserDetailsDlgProcParam(CIrcProto* _pro, MCONTACT _info) :
- ppro(_pro),
- hContact(_info)
- {}
-
- CIrcProto *ppro;
- MCONTACT hContact;
-};
-
const wchar_t *STR_BASIC = LPGENW("Faster! Searches the network for an exact match of the nickname only. The hostmask is optional and provides further security if used. Wildcards (? and *) are allowed.");
const wchar_t *STR_ADVANCED = LPGENW("Slower! Searches the network for nicknames matching a wildcard string. The hostmask is mandatory and a minimum of 4 characters is necessary in the \"Nick\" field. Wildcards (? and *) are allowed.");
const wchar_t *STR_ERROR = LPGENW("Settings could not be saved!\n\nThe \"Nick\" field must contain at least four characters including wildcards,\n and it must also match the default nickname for this contact.");
const wchar_t *STR_ERROR2 = LPGENW("Settings could not be saved!\n\nA full hostmask must be set for this online detection mode to work.");
-INT_PTR CALLBACK UserDetailsDlgProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+class IrcUserInfoDlg : public CUserInfoPageDlg
{
- UserDetailsDlgProcParam *p = (UserDetailsDlgProcParam*)GetWindowLongPtr(m_hwnd, GWLP_USERDATA);
- switch (msg) {
- case WM_INITDIALOG:
- p = new UserDetailsDlgProcParam(nullptr, lParam);
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LPARAM)p);
- break;
-
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_PARAMCHANGED) {
- p->ppro = (CIrcProto*)((PSHNOTIFY*)lParam)->lParam;
-
- DBVARIANT dbv;
- uint8_t bAdvanced = p->ppro->getByte(p->hContact, "AdvancedMode", 0);
+ CIrcProto *ppro;
+ CCtrlButton btn1, btn2;
+ CCtrlCheck radio1, radio2;
+
+public:
+ IrcUserInfoDlg(CIrcProto *_ppro) :
+ CUserInfoPageDlg(g_plugin, IDD_USERINFO),
+ ppro(_ppro),
+ btn1(this, IDC_BUTTON),
+ btn2(this, IDC_BUTTON2),
+ radio1(this, IDC_RADIO1),
+ radio2(this, IDC_RADIO2)
+ {
+ btn1.OnClick = Callback(this, &IrcUserInfoDlg::onClick_Button1);
+ btn2.OnClick = Callback(this, &IrcUserInfoDlg::onClick_Button2);
+
+ radio1.OnChange = Callback(this, &IrcUserInfoDlg::onChange_Radio1);
+ radio2.OnChange = Callback(this, &IrcUserInfoDlg::onChange_Radio2);
+ }
- TranslateDialogDefault(m_hwnd);
+ bool OnRefresh() override
+ {
+ DBVARIANT dbv;
+ uint8_t bAdvanced = ppro->getByte(m_hContact, "AdvancedMode", 0);
- CheckDlgButton(m_hwnd, IDC_RADIO1, bAdvanced ? BST_UNCHECKED : BST_CHECKED);
- CheckDlgButton(m_hwnd, IDC_RADIO2, bAdvanced ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), bAdvanced);
+ TranslateDialogDefault(m_hwnd);
- if (!bAdvanced) {
- SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_BASIC));
- if (!p->ppro->getWString(p->hContact, "Default", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
- db_free(&dbv);
- }
- }
- else {
- SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_ADVANCED));
- if (!p->ppro->getWString(p->hContact, "UWildcard", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
- db_free(&dbv);
- }
- }
+ radio1.SetState(!bAdvanced);
+ radio2.SetState(bAdvanced);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), bAdvanced);
- if (!p->ppro->getWString(p->hContact, "UUser", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_USER, dbv.pwszVal);
+ if (!bAdvanced) {
+ SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_BASIC));
+ if (!ppro->getWString(m_hContact, "Default", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
db_free(&dbv);
}
-
- if (!p->ppro->getWString(p->hContact, "UHost", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_HOST, dbv.pwszVal);
+ }
+ else {
+ SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_ADVANCED));
+ if (!ppro->getWString(m_hContact, "UWildcard", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
db_free(&dbv);
}
- ProtoBroadcastAck(p->ppro->m_szModuleName, p->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1);
}
- break;
- case WM_COMMAND:
- if ((LOWORD(wParam) == IDC_WILDCARD || LOWORD(wParam) == IDC_USER || LOWORD(wParam) == IDC_HOST) &&
- (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
- return true;
+ if (!ppro->getWString(m_hContact, "UUser", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_USER, dbv.pwszVal);
+ db_free(&dbv);
+ }
- EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON), true);
- EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON2), true);
+ if (!ppro->getWString(m_hContact, "UHost", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_HOST, dbv.pwszVal);
+ db_free(&dbv);
+ }
+ ProtoBroadcastAck(ppro->m_szModuleName, m_hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1);
+ return false;
+ }
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON) {
- wchar_t temp[500];
- GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, _countof(temp));
+ void OnChange() override
+ {
+ btn1.Enable();
+ btn2.Enable();
+ }
- uint8_t bAdvanced = IsDlgButtonChecked(m_hwnd, IDC_RADIO1) ? 0 : 1;
- if (bAdvanced) {
- if (GetWindowTextLength(GetDlgItem(m_hwnd, IDC_WILDCARD)) == 0 ||
- GetWindowTextLength(GetDlgItem(m_hwnd, IDC_USER)) == 0 ||
- GetWindowTextLength(GetDlgItem(m_hwnd, IDC_HOST)) == 0) {
- MessageBox(nullptr, TranslateW(STR_ERROR2), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
- return FALSE;
- }
+ void onClick_Button1(CCtrlButton *)
+ {
+ wchar_t temp[500];
+ GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, _countof(temp));
+
+ bool bAdvanced = !radio1.GetState();
+ if (bAdvanced) {
+ if (GetWindowTextLength(GetDlgItem(m_hwnd, IDC_WILDCARD)) == 0 ||
+ GetWindowTextLength(GetDlgItem(m_hwnd, IDC_USER)) == 0 ||
+ GetWindowTextLength(GetDlgItem(m_hwnd, IDC_HOST)) == 0) {
+ MessageBox(nullptr, TranslateW(STR_ERROR2), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
+ return;
+ }
- DBVARIANT dbv;
- if (!p->ppro->getWString(p->hContact, "Default", &dbv)) {
- CMStringW S = STR_ERROR;
- S += L" (";
- S += dbv.pwszVal;
- S += L")";
- if ((mir_wstrlen(temp) < 4 && mir_wstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.pwszVal))) {
- MessageBox(nullptr, TranslateW(S.c_str()), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
- db_free(&dbv);
- return FALSE;
- }
+ DBVARIANT dbv;
+ if (!ppro->getWString(m_hContact, "Default", &dbv)) {
+ CMStringW S = STR_ERROR;
+ S += L" (";
+ S += dbv.pwszVal;
+ S += L")";
+ if ((mir_wstrlen(temp) < 4 && mir_wstrlen(temp)) || !WCCmp(CharLower(temp), CharLower(dbv.pwszVal))) {
+ MessageBox(nullptr, TranslateW(S.c_str()), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
db_free(&dbv);
+ return;
}
-
- GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, _countof(temp));
- if (mir_wstrlen(GetWord(temp, 0).c_str()))
- p->ppro->setWString(p->hContact, "UWildcard", GetWord(temp, 0).c_str());
- else
- db_unset(p->hContact, p->ppro->m_szModuleName, "UWildcard");
+ db_free(&dbv);
}
- p->ppro->setByte(p->hContact, "AdvancedMode", bAdvanced);
-
- GetDlgItemText(m_hwnd, IDC_USER, temp, _countof(temp));
+ GetDlgItemText(m_hwnd, IDC_WILDCARD, temp, _countof(temp));
if (mir_wstrlen(GetWord(temp, 0).c_str()))
- p->ppro->setWString(p->hContact, "UUser", GetWord(temp, 0).c_str());
+ ppro->setWString(m_hContact, "UWildcard", GetWord(temp, 0).c_str());
else
- db_unset(p->hContact, p->ppro->m_szModuleName, "UUser");
+ db_unset(m_hContact, ppro->m_szModuleName, "UWildcard");
+ }
- GetDlgItemText(m_hwnd, IDC_HOST, temp, _countof(temp));
- if (mir_wstrlen(GetWord(temp, 0).c_str()))
- p->ppro->setWString(p->hContact, "UHost", GetWord(temp, 0).c_str());
- else
- db_unset(p->hContact, p->ppro->m_szModuleName, "UHost");
+ ppro->setByte(m_hContact, "AdvancedMode", bAdvanced);
- EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON), FALSE);
- }
+ GetDlgItemText(m_hwnd, IDC_USER, temp, _countof(temp));
+ if (mir_wstrlen(GetWord(temp, 0).c_str()))
+ ppro->setWString(m_hContact, "UUser", GetWord(temp, 0).c_str());
+ else
+ db_unset(m_hContact, ppro->m_szModuleName, "UUser");
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BUTTON2) {
- if (IsDlgButtonChecked(m_hwnd, IDC_RADIO2))
- SetDlgItemTextA(m_hwnd, IDC_WILDCARD, "");
- SetDlgItemTextA(m_hwnd, IDC_HOST, "");
- SetDlgItemTextA(m_hwnd, IDC_USER, "");
- db_unset(p->hContact, p->ppro->m_szModuleName, "UWildcard");
- db_unset(p->hContact, p->ppro->m_szModuleName, "UUser");
- db_unset(p->hContact, p->ppro->m_szModuleName, "UHost");
- EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON2), FALSE);
- }
+ GetDlgItemText(m_hwnd, IDC_HOST, temp, _countof(temp));
+ if (mir_wstrlen(GetWord(temp, 0).c_str()))
+ ppro->setWString(m_hContact, "UHost", GetWord(temp, 0).c_str());
+ else
+ db_unset(m_hContact, ppro->m_szModuleName, "UHost");
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO1) {
- SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_BASIC));
+ btn1.Disable();
+ }
- DBVARIANT dbv;
- if (!p->ppro->getWString(p->hContact, "Default", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
- db_free(&dbv);
- }
- EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), FALSE);
+ void onClick_Button2(CCtrlButton *)
+ {
+ if (radio2.GetState())
+ SetDlgItemTextA(m_hwnd, IDC_WILDCARD, "");
+ SetDlgItemTextA(m_hwnd, IDC_HOST, "");
+ SetDlgItemTextA(m_hwnd, IDC_USER, "");
+ db_unset(m_hContact, ppro->m_szModuleName, "UWildcard");
+ db_unset(m_hContact, ppro->m_szModuleName, "UUser");
+ db_unset(m_hContact, ppro->m_szModuleName, "UHost");
+ btn1.Disable();
+ btn2.Disable();
+ }
+
+ void onChange_Radio1(CCtrlButton *)
+ {
+ SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_BASIC));
+
+ DBVARIANT dbv;
+ if (!ppro->getWString(m_hContact, "Default", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
+ db_free(&dbv);
}
+ EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), FALSE);
+ }
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_RADIO2) {
- DBVARIANT dbv;
- SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_ADVANCED));
- if (!p->ppro->getWString(p->hContact, "UWildcard", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
- db_free(&dbv);
- }
- EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), true);
+ void onChange_Radio2(CCtrlButton *)
+ {
+ DBVARIANT dbv;
+ SetDlgItemText(m_hwnd, IDC_DEFAULT, TranslateW(STR_ADVANCED));
+ if (!ppro->getWString(m_hContact, "UWildcard", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_WILDCARD, dbv.pwszVal);
+ db_free(&dbv);
}
- break;
+ EnableWindow(GetDlgItem(m_hwnd, IDC_WILDCARD), true);
}
- return FALSE;
-}
+};
int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM hContact)
{
@@ -198,23 +197,15 @@ int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM hContact)
if (getByte(hContact, "DCC", 0) != 0)
return 0;
- DBVARIANT dbv;
- if (!getWString(hContact, "Default", &dbv)) {
- if (IsChannel(dbv.pwszVal)) {
- db_free(&dbv);
- return 0;
- }
- db_free(&dbv);
- }
+ ptrW wszChannel(getWStringA(hContact, "Default"));
+ if (!wszChannel || !IsChannel(wszChannel))
+ return 0;
- OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_DONTTRANSLATE;
- odp.szTitle.a = m_szModuleName;
- odp.dwInitParam = (LPARAM)this;
- odp.position = -1900000000;
- odp.pfnDlgProc = UserDetailsDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
- odp.szTitle.a = m_szModuleName;
- g_plugin.addUserInfo(wParam, &odp);
+ USERINFOPAGE uip = {};
+ uip.position = -1900000000;
+ uip.flags = ODPF_DONTTRANSLATE | ODPF_UNICODE;
+ uip.pDialog = new IrcUserInfoDlg(this);
+ uip.szTitle.w = m_tszUserName;
+ g_plugin.addUserInfo(wParam, &uip);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index bbf8fee6ce..bc1c604c9c 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -849,6 +849,10 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
bool ProcessCaptcha(const TiXmlElement *node, const TiXmlElement *parentNode, ThreadData *info);
+ //---- jabber_userinfo.c -------------------------------------------------------------
+
+ void CheckOmemoUserInfo(WPARAM, USERINFOPAGE&);
+
//---- jabber_util.c -----------------------------------------------------------------
pResourceStatus ResourceInfoFromJID(const char *jid);
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index 6bd987f2a0..d8754b240b 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -33,7 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int CJabberProto::SendGetVcard(MCONTACT hContact)
{
- if (!m_bJabberOnline) return 0;
+ if (!m_bJabberOnline)
+ return 0;
CJabberIqInfo *pInfo;
@@ -66,248 +67,211 @@ static void SetDialogField(CJabberProto *ppro, HWND hwndDlg, int nDlgItem, char
SetDlgItemTextA(hwndDlg, nDlgItem, "");
}
-static INT_PTR CALLBACK PersonalDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+class JabberVcardBaseDlg : public CUserInfoPageDlg
{
- const unsigned long iPageId = 0;
- CJabberProto *ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int iPageId;
- switch (msg) {
- case WM_INITDIALOG:
- if (lParam) {
- ppro = (CJabberProto*)lParam;
- TranslateDialogDefault(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Male"));
- SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Female"));
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
- ppro->WindowSubscribe(hwndDlg);
- }
- break;
+protected:
+ CJabberProto *ppro;
- case WM_JABBER_REFRESH_VCARD:
- SetDialogField(ppro, hwndDlg, IDC_FULLNAME, "FullName");
- SetDialogField(ppro, hwndDlg, IDC_NICKNAME, "Nick");
- SetDialogField(ppro, hwndDlg, IDC_FIRSTNAME, "FirstName");
- SetDialogField(ppro, hwndDlg, IDC_MIDDLE, "MiddleName");
- SetDialogField(ppro, hwndDlg, IDC_LASTNAME, "LastName");
- SetDialogField(ppro, hwndDlg, IDC_BIRTH, "BirthDate");
- SetDialogField(ppro, hwndDlg, IDC_GENDER, "GenderString", true);
- SetDialogField(ppro, hwndDlg, IDC_OCCUPATION, "Role");
- SetDialogField(ppro, hwndDlg, IDC_HOMEPAGE, "Homepage");
- break;
+public:
+ JabberVcardBaseDlg(CJabberProto *_ppro, int dlgId, int pageId) :
+ CUserInfoPageDlg(g_plugin, dlgId),
+ ppro(_ppro),
+ iPageId(pageId)
+ {}
+
+ bool OnInitDialog() override
+ {
+ ppro->WindowSubscribe(m_hwnd);
+ return true;
+ }
- case WM_COMMAND:
- if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
- ((HWND)lParam == GetDlgItem(hwndDlg, IDC_GENDER) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE))) {
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
+ bool OnApply() override
+ {
+ ppro->SaveVcardToDB(m_hwnd, iPageId);
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0) {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
- break;
- case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL << iPageId);
- ppro->SaveVcardToDB(hwndDlg, iPageId);
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
- break;
- }
- }
- break;
+ ppro->m_vCardUpdates &= ~(1UL << iPageId);
+ if (!ppro->m_vCardUpdates)
+ ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
+ return true;
+ }
- case WM_DESTROY:
- ppro->WindowUnsubscribe(hwndDlg);
- break;
+ void OnDestroy() override
+ {
+ ppro->WindowUnsubscribe(m_hwnd);
}
- return FALSE;
-}
+};
-static INT_PTR CALLBACK HomeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct JabberVcardPersonalDlg : public JabberVcardBaseDlg
{
- const unsigned long iPageId = 1;
- CJabberProto *ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ JabberVcardPersonalDlg(CJabberProto *_ppro) :
+ JabberVcardBaseDlg(_ppro, IDD_VCARD_PERSONAL, 0)
+ {}
+
+ bool OnInitDialog() override
+ {
+ JabberVcardBaseDlg::OnInitDialog();
+ SendDlgItemMessage(m_hwnd, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Male"));
+ SendDlgItemMessage(m_hwnd, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Female"));
+ return true;
+ }
- switch (msg) {
- case WM_INITDIALOG:
- if (lParam) {
- ppro = (CJabberProto*)lParam;
- TranslateDialogDefault(hwndDlg);
- for (int i = 0; i < g_cbCountries; i++) {
- if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
- wchar_t *country = mir_a2u(g_countries[i].szName);
- SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateW(country));
- mir_free(country);
- }
- }
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
- ppro->WindowSubscribe(hwndDlg);
- }
- break;
+ bool OnRefresh() override
+ {
+ SetDialogField(ppro, m_hwnd, IDC_FULLNAME, "FullName");
+ SetDialogField(ppro, m_hwnd, IDC_NICKNAME, "Nick");
+ SetDialogField(ppro, m_hwnd, IDC_FIRSTNAME, "FirstName");
+ SetDialogField(ppro, m_hwnd, IDC_MIDDLE, "MiddleName");
+ SetDialogField(ppro, m_hwnd, IDC_LASTNAME, "LastName");
+ SetDialogField(ppro, m_hwnd, IDC_BIRTH, "BirthDate");
+ SetDialogField(ppro, m_hwnd, IDC_GENDER, "GenderString", true);
+ SetDialogField(ppro, m_hwnd, IDC_OCCUPATION, "Role");
+ SetDialogField(ppro, m_hwnd, IDC_HOMEPAGE, "Homepage");
+ return false;
+ }
+};
- case WM_JABBER_REFRESH_VCARD:
- SetDialogField(ppro, hwndDlg, IDC_ADDRESS1, "Street");
- SetDialogField(ppro, hwndDlg, IDC_ADDRESS2, "Street2");
- SetDialogField(ppro, hwndDlg, IDC_CITY, "City");
- SetDialogField(ppro, hwndDlg, IDC_STATE, "State");
- SetDialogField(ppro, hwndDlg, IDC_ZIP, "ZIP");
- SetDialogField(ppro, hwndDlg, IDC_COUNTRY, "Country", true);
- break;
+/////////////////////////////////////////////////////////////////////////////////////////
+// Home vcard dialog
- case WM_COMMAND:
- if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
- ((HWND)lParam == GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE))) {
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
+struct JabberVcardHomeDlg : public JabberVcardBaseDlg
+{
+ JabberVcardHomeDlg(CJabberProto *_ppro) :
+ JabberVcardBaseDlg(_ppro, IDD_VCARD_HOME, 1)
+ {
+ }
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0) {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
- break;
- case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL << iPageId);
- ppro->SaveVcardToDB(hwndDlg, iPageId);
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
- break;
+ bool OnInitDialog() override
+ {
+ JabberVcardBaseDlg::OnInitDialog();
+ for (int i = 0; i < g_cbCountries; i++) {
+ if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
+ wchar_t *country = mir_a2u(g_countries[i].szName);
+ SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateW(country));
+ mir_free(country);
}
}
- break;
-
- case WM_DESTROY:
- ppro->WindowUnsubscribe(hwndDlg);
- break;
+ return true;
}
- return FALSE;
-}
-static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- const unsigned long iPageId = 2;
- CJabberProto *ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ bool OnRefresh() override
+ {
+ SetDialogField(ppro, m_hwnd, IDC_ADDRESS1, "Street");
+ SetDialogField(ppro, m_hwnd, IDC_ADDRESS2, "Street2");
+ SetDialogField(ppro, m_hwnd, IDC_CITY, "City");
+ SetDialogField(ppro, m_hwnd, IDC_STATE, "State");
+ SetDialogField(ppro, m_hwnd, IDC_ZIP, "ZIP");
+ SetDialogField(ppro, m_hwnd, IDC_COUNTRY, "Country", true);
+ return false;
+ }
+};
- switch (msg) {
- case WM_INITDIALOG:
- if (lParam) { // proto info is available
- ppro = (CJabberProto*)lParam;
- TranslateDialogDefault(hwndDlg);
- for (int i = 0; i < g_cbCountries; i++) {
- if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
- wchar_t *country = mir_a2u(g_countries[i].szName);
- SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateW(country));
- mir_free(country);
- }
- }
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
- ppro->WindowSubscribe(hwndDlg);
- }
- break;
+/////////////////////////////////////////////////////////////////////////////////////////
+// Work vcard dialog
- case WM_JABBER_REFRESH_VCARD:
- SetDialogField(ppro, hwndDlg, IDC_COMPANY, "Company");
- SetDialogField(ppro, hwndDlg, IDC_DEPARTMENT, "CompanyDepartment");
- SetDialogField(ppro, hwndDlg, IDC_TITLE, "CompanyPosition");
- SetDialogField(ppro, hwndDlg, IDC_ADDRESS1, "CompanyStreet");
- SetDialogField(ppro, hwndDlg, IDC_ADDRESS2, "CompanyStreet2");
- SetDialogField(ppro, hwndDlg, IDC_CITY, "CompanyCity");
- SetDialogField(ppro, hwndDlg, IDC_STATE, "CompanyState");
- SetDialogField(ppro, hwndDlg, IDC_ZIP, "CompanyZIP");
- SetDialogField(ppro, hwndDlg, IDC_COUNTRY, "CompanyCountry", true);
- break;
+struct JabberVcardWorkDlg : public JabberVcardBaseDlg
+{
+ JabberVcardWorkDlg(CJabberProto *_ppro) :
+ JabberVcardBaseDlg(_ppro, IDD_VCARD_WORK, 2)
+ {
+ }
- case WM_COMMAND:
- if (((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) ||
- ((HWND)lParam == GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE))) {
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
+ bool OnInitDialog() override
+ {
+ JabberVcardBaseDlg::OnInitDialog();
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0) {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
- break;
- case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL << iPageId);
- ppro->SaveVcardToDB(hwndDlg, iPageId);
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
- break;
+ for (int i = 0; i < g_cbCountries; i++) {
+ if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
+ wchar_t *country = mir_a2u(g_countries[i].szName);
+ SendDlgItemMessage(m_hwnd, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)TranslateW(country));
+ mir_free(country);
}
}
- break;
+ return true;
+ }
- case WM_DESTROY:
- ppro->WindowUnsubscribe(hwndDlg);
- break;
+ bool OnRefresh() override
+ {
+ SetDialogField(ppro, m_hwnd, IDC_COMPANY, "Company");
+ SetDialogField(ppro, m_hwnd, IDC_DEPARTMENT, "CompanyDepartment");
+ SetDialogField(ppro, m_hwnd, IDC_TITLE, "CompanyPosition");
+ SetDialogField(ppro, m_hwnd, IDC_ADDRESS1, "CompanyStreet");
+ SetDialogField(ppro, m_hwnd, IDC_ADDRESS2, "CompanyStreet2");
+ SetDialogField(ppro, m_hwnd, IDC_CITY, "CompanyCity");
+ SetDialogField(ppro, m_hwnd, IDC_STATE, "CompanyState");
+ SetDialogField(ppro, m_hwnd, IDC_ZIP, "CompanyZIP");
+ SetDialogField(ppro, m_hwnd, IDC_COUNTRY, "CompanyCountry", true);
+ return false;
}
- return FALSE;
-}
+};
/////////////////////////////////////////////////////////////////////////////////////////
+// Photo vcard dialog
-struct PhotoDlgProcData
+class JabberVcardPhotoDlg : public JabberVcardBaseDlg
{
- CJabberProto *ppro;
HBITMAP hBitmap;
-};
-static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- const unsigned long iPageId = 3;
+ UI_MESSAGE_MAP(JabberVcardPhotoDlg, JabberVcardBaseDlg);
+ UI_MESSAGE(WM_PAINT, OnPaint);
+ UI_MESSAGE_MAP_END();
- wchar_t szAvatarFileName[MAX_PATH], szTempPath[MAX_PATH], szTempFileName[MAX_PATH];
- PhotoDlgProcData *dat = (PhotoDlgProcData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+public:
+ JabberVcardPhotoDlg(CJabberProto *_ppro) :
+ JabberVcardBaseDlg(_ppro, IDD_VCARD_PHOTO, 3)
+ {
+ }
- switch (msg) {
- case WM_INITDIALOG:
- if (!lParam) break; // Launched from userinfo
- TranslateDialogDefault(hwndDlg);
- Button_SetIcon_IcoLib(hwndDlg, IDC_LOAD, g_plugin.getIconHandle(IDI_OPEN));
- Button_SetIcon_IcoLib(hwndDlg, IDC_DELETE, g_plugin.getIconHandle(IDI_DELETE));
- ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE);
- {
- dat = new PhotoDlgProcData;
- dat->ppro = (CJabberProto*)lParam;
- dat->hBitmap = nullptr;
- dat->ppro->m_bPhotoChanged = false;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- dat->ppro->WindowSubscribe(hwndDlg);
+ bool OnInitDialog() override
+ {
+ JabberVcardBaseDlg::OnInitDialog();
+
+ Button_SetIcon_IcoLib(m_hwnd, IDC_LOAD, g_plugin.getIconHandle(IDI_OPEN));
+ Button_SetIcon_IcoLib(m_hwnd, IDC_DELETE, g_plugin.getIconHandle(IDI_DELETE));
+ ShowWindow(GetDlgItem(m_hwnd, IDC_SAVE), SW_HIDE);
+
+ ppro->m_bPhotoChanged = false;
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ JabberVcardBaseDlg::OnDestroy();
+
+ Button_FreeIcon_IcoLib(m_hwnd, IDC_LOAD);
+ Button_FreeIcon_IcoLib(m_hwnd, IDC_DELETE);
+ if (hBitmap) {
+ ppro->debugLogA("Delete bitmap");
+ DeleteObject(hBitmap);
+ DeleteFile(ppro->m_szPhotoFileName);
}
- SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
- break;
+ }
- case WM_JABBER_REFRESH_VCARD:
- if (dat->hBitmap) {
- DeleteObject(dat->hBitmap);
- dat->hBitmap = nullptr;
- DeleteFile(dat->ppro->m_szPhotoFileName);
- dat->ppro->m_szPhotoFileName[0] = '\0';
+ bool OnRefresh() override
+ {
+ if (hBitmap) {
+ DeleteObject(hBitmap);
+ hBitmap = nullptr;
+ DeleteFile(ppro->m_szPhotoFileName);
+ ppro->m_szPhotoFileName[0] = '\0';
}
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
- dat->ppro->GetAvatarFileName(0, szAvatarFileName, _countof(szAvatarFileName));
+
+ wchar_t szAvatarFileName[MAX_PATH], szTempPath[MAX_PATH], szTempFileName[MAX_PATH];
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DELETE), FALSE);
+ ppro->GetAvatarFileName(0, szAvatarFileName, _countof(szAvatarFileName));
if (_waccess(szAvatarFileName, 0) == 0) {
if (GetTempPath(_countof(szTempPath), szTempPath) <= 0)
mir_wstrcpy(szTempPath, L".\\");
if (GetTempFileName(szTempPath, L"jab", 0, szTempFileName) > 0) {
- dat->ppro->debugLogW(L"Temp file = %s", szTempFileName);
+ ppro->debugLogW(L"Temp file = %s", szTempFileName);
if (CopyFile(szAvatarFileName, szTempFileName, FALSE) == TRUE) {
- if ((dat->hBitmap = Bitmap_Load(szTempFileName)) != nullptr) {
- FreeImage_Premultiply(dat->hBitmap);
- mir_wstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
+ if ((hBitmap = Bitmap_Load(szTempFileName)) != nullptr) {
+ FreeImage_Premultiply(hBitmap);
+ mir_wstrcpy(ppro->m_szPhotoFileName, szTempFileName);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DELETE), TRUE);
}
else DeleteFile(szTempFileName);
}
@@ -315,226 +279,165 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
}
}
- dat->ppro->m_bPhotoChanged = false;
- InvalidateRect(hwndDlg, nullptr, TRUE);
- UpdateWindow(hwndDlg);
- break;
+ ppro->m_bPhotoChanged = false;
+ InvalidateRect(m_hwnd, nullptr, TRUE);
+ UpdateWindow(m_hwnd);
+ return false;
+ }
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_DELETE:
- if (dat->hBitmap) {
- DeleteObject(dat->hBitmap);
- dat->hBitmap = nullptr;
- DeleteFile(dat->ppro->m_szPhotoFileName);
- dat->ppro->m_szPhotoFileName[0] = '\0';
- dat->ppro->m_bPhotoChanged = true;
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
- InvalidateRect(hwndDlg, nullptr, TRUE);
- UpdateWindow(hwndDlg);
- dat->ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ void onClick_Delete(CCtrlButton *)
+ {
+ if (hBitmap == nullptr)
+ return;
+
+ DeleteObject(hBitmap);
+ hBitmap = nullptr;
+ DeleteFile(ppro->m_szPhotoFileName);
+ ppro->m_szPhotoFileName[0] = '\0';
+ ppro->m_bPhotoChanged = true;
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DELETE), FALSE);
+ InvalidateRect(m_hwnd, nullptr, TRUE);
+ UpdateWindow(m_hwnd);
+ NotifyChange();
+ }
+
+ void onClick_Load(CCtrlButton *)
+ {
+ wchar_t szFilter[512], szFileName[MAX_PATH];
+ Bitmap_GetFilter(szFilter, _countof(szFilter));
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = m_hwnd;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrCustomFilter = nullptr;
+ ofn.lpstrFile = szFileName;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_DONTADDTORECENT;
+ szFileName[0] = '\0';
+ if (GetOpenFileName(&ofn)) {
+ struct _stat st;
+ HBITMAP hNewBitmap;
+
+ ppro->debugLogW(L"File selected is %s", szFileName);
+ if (_wstat(szFileName, &st) < 0 || st.st_size > 40 * 1024) {
+ MessageBox(m_hwnd, TranslateT("Only JPG, GIF, and BMP image files smaller than 40 KB are supported."), TranslateT("Jabber vCard"), MB_OK | MB_SETFOREGROUND);
+ return;
}
- break;
- case IDC_LOAD:
- wchar_t szFilter[512], szFileName[MAX_PATH];
- Bitmap_GetFilter(szFilter, _countof(szFilter));
-
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hwndDlg;
- ofn.lpstrFilter = szFilter;
- ofn.lpstrCustomFilter = nullptr;
- ofn.lpstrFile = szFileName;
- ofn.nMaxFile = MAX_PATH;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_DONTADDTORECENT;
- szFileName[0] = '\0';
- if (GetOpenFileName(&ofn)) {
- struct _stat st;
- HBITMAP hNewBitmap;
-
- dat->ppro->debugLogW(L"File selected is %s", szFileName);
- if (_wstat(szFileName, &st) < 0 || st.st_size > 40 * 1024) {
- MessageBox(hwndDlg, TranslateT("Only JPG, GIF, and BMP image files smaller than 40 KB are supported."), TranslateT("Jabber vCard"), MB_OK | MB_SETFOREGROUND);
- break;
- }
- if (GetTempPath(_countof(szTempPath), szTempPath) <= 0)
- mir_wstrcpy(szTempPath, L".\\");
-
- if (GetTempFileName(szTempPath, L"jab", 0, szTempFileName) > 0) {
- dat->ppro->debugLogW(L"Temp file = %s", szTempFileName);
- if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) {
- if ((hNewBitmap = Bitmap_Load(szTempFileName)) != nullptr) {
- if (dat->hBitmap) {
- DeleteObject(dat->hBitmap);
- DeleteFile(dat->ppro->m_szPhotoFileName);
- }
+ wchar_t szTempFileName[MAX_PATH], szTempPath[MAX_PATH];
+ if (GetTempPath(_countof(szTempPath), szTempPath) <= 0)
+ mir_wstrcpy(szTempPath, L".\\");
- dat->hBitmap = hNewBitmap;
- mir_wstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName);
- dat->ppro->m_bPhotoChanged = true;
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
- InvalidateRect(hwndDlg, nullptr, TRUE);
- UpdateWindow(hwndDlg);
- dat->ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ if (GetTempFileName(szTempPath, L"jab", 0, szTempFileName) > 0) {
+ ppro->debugLogW(L"Temp file = %s", szTempFileName);
+ if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) {
+ if ((hNewBitmap = Bitmap_Load(szTempFileName)) != nullptr) {
+ if (hBitmap) {
+ DeleteObject(hBitmap);
+ DeleteFile(ppro->m_szPhotoFileName);
}
- else DeleteFile(szTempFileName);
+
+ hBitmap = hNewBitmap;
+ mir_wstrcpy(ppro->m_szPhotoFileName, szTempFileName);
+ ppro->m_bPhotoChanged = true;
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DELETE), TRUE);
+ InvalidateRect(m_hwnd, nullptr, TRUE);
+ UpdateWindow(m_hwnd);
+ NotifyChange();
}
else DeleteFile(szTempFileName);
}
+ else DeleteFile(szTempFileName);
}
- break;
}
- break;
-
- case WM_PAINT:
- if (dat->hBitmap) {
- BITMAP bm;
- POINT ptSize, ptOrg, pt, ptFitSize;
- RECT rect;
-
- HWND hwndCanvas = GetDlgItem(hwndDlg, IDC_CANVAS);
- HDC hdcCanvas = GetDC(hwndCanvas);
- HDC hdcMem = CreateCompatibleDC(hdcCanvas);
- SelectObject(hdcMem, dat->hBitmap);
- SetMapMode(hdcMem, GetMapMode(hdcCanvas));
- GetObject(dat->hBitmap, sizeof(BITMAP), (LPVOID)&bm);
- ptSize.x = bm.bmWidth;
- ptSize.y = bm.bmHeight;
- DPtoLP(hdcCanvas, &ptSize, 1);
- ptOrg.x = ptOrg.y = 0;
- DPtoLP(hdcMem, &ptOrg, 1);
- GetClientRect(hwndCanvas, &rect);
- InvalidateRect(hwndCanvas, nullptr, TRUE);
- UpdateWindow(hwndCanvas);
- if (ptSize.x <= rect.right && ptSize.y <= rect.bottom) {
- pt.x = (rect.right - ptSize.x) / 2;
- pt.y = (rect.bottom - ptSize.y) / 2;
- ptFitSize = ptSize;
- }
- else {
- if (((float)(ptSize.x - rect.right)) / ptSize.x > ((float)(ptSize.y - rect.bottom)) / ptSize.y) {
- ptFitSize.x = rect.right;
- ptFitSize.y = (ptSize.y * rect.right) / ptSize.x;
- pt.x = 0;
- pt.y = (rect.bottom - ptFitSize.y) / 2;
- }
- else {
- ptFitSize.x = (ptSize.x * rect.bottom) / ptSize.y;
- ptFitSize.y = rect.bottom;
- pt.x = (rect.right - ptFitSize.x) / 2;
- pt.y = 0;
- }
- }
+ }
- RECT rc;
- GetClientRect(hwndCanvas, &rc);
- if (IsThemeActive())
- DrawThemeParentBackground(hwndCanvas, hdcCanvas, &rc);
- else
- FillRect(hdcCanvas, &rc, (HBRUSH)GetSysColorBrush(COLOR_BTNFACE));
-
- if (bm.bmBitsPixel == 32) {
- BLENDFUNCTION bf = { 0 };
- bf.AlphaFormat = AC_SRC_ALPHA;
- bf.BlendOp = AC_SRC_OVER;
- bf.SourceConstantAlpha = 255;
- GdiAlphaBlend(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, bf);
+ INT_PTR OnPaint(UINT, WPARAM, LPARAM)
+ {
+ if (hBitmap == nullptr)
+ return FALSE;
+
+ BITMAP bm;
+ POINT ptSize, ptOrg, pt, ptFitSize;
+ RECT rect;
+
+ HWND hwndCanvas = GetDlgItem(m_hwnd, IDC_CANVAS);
+ HDC hdcCanvas = GetDC(hwndCanvas);
+ HDC hdcMem = CreateCompatibleDC(hdcCanvas);
+ SelectObject(hdcMem, hBitmap);
+ SetMapMode(hdcMem, GetMapMode(hdcCanvas));
+ GetObject(hBitmap, sizeof(BITMAP), (LPVOID)&bm);
+ ptSize.x = bm.bmWidth;
+ ptSize.y = bm.bmHeight;
+ DPtoLP(hdcCanvas, &ptSize, 1);
+ ptOrg.x = ptOrg.y = 0;
+ DPtoLP(hdcMem, &ptOrg, 1);
+ GetClientRect(hwndCanvas, &rect);
+ InvalidateRect(hwndCanvas, nullptr, TRUE);
+ UpdateWindow(hwndCanvas);
+ if (ptSize.x <= rect.right && ptSize.y <= rect.bottom) {
+ pt.x = (rect.right - ptSize.x) / 2;
+ pt.y = (rect.bottom - ptSize.y) / 2;
+ ptFitSize = ptSize;
+ }
+ else {
+ if (((float)(ptSize.x - rect.right)) / ptSize.x > ((float)(ptSize.y - rect.bottom)) / ptSize.y) {
+ ptFitSize.x = rect.right;
+ ptFitSize.y = (ptSize.y * rect.right) / ptSize.x;
+ pt.x = 0;
+ pt.y = (rect.bottom - ptFitSize.y) / 2;
}
else {
- SetStretchBltMode(hdcCanvas, COLORONCOLOR);
- StretchBlt(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, SRCCOPY);
+ ptFitSize.x = (ptSize.x * rect.bottom) / ptSize.y;
+ ptFitSize.y = rect.bottom;
+ pt.x = (rect.right - ptFitSize.x) / 2;
+ pt.y = 0;
}
-
- DeleteDC(hdcMem);
}
- break;
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0) {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
- break;
-
- case PSN_APPLY:
- dat->ppro->m_vCardUpdates &= ~(1UL << iPageId);
- dat->ppro->SaveVcardToDB(hwndDlg, iPageId);
- if (!dat->ppro->m_vCardUpdates)
- dat->ppro->SetServerVcard(dat->ppro->m_bPhotoChanged, dat->ppro->m_szPhotoFileName);
- break;
- }
+ RECT rc;
+ GetClientRect(hwndCanvas, &rc);
+ if (IsThemeActive())
+ DrawThemeParentBackground(hwndCanvas, hdcCanvas, &rc);
+ else
+ FillRect(hdcCanvas, &rc, (HBRUSH)GetSysColorBrush(COLOR_BTNFACE));
+
+ if (bm.bmBitsPixel == 32) {
+ BLENDFUNCTION bf = { 0 };
+ bf.AlphaFormat = AC_SRC_ALPHA;
+ bf.BlendOp = AC_SRC_OVER;
+ bf.SourceConstantAlpha = 255;
+ GdiAlphaBlend(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, bf);
}
- break;
-
- case WM_DESTROY:
- Button_FreeIcon_IcoLib(hwndDlg, IDC_LOAD);
- Button_FreeIcon_IcoLib(hwndDlg, IDC_DELETE);
- dat->ppro->WindowUnsubscribe(hwndDlg);
- if (dat->hBitmap) {
- dat->ppro->debugLogA("Delete bitmap");
- DeleteObject(dat->hBitmap);
- DeleteFile(dat->ppro->m_szPhotoFileName);
+ else {
+ SetStretchBltMode(hdcCanvas, COLORONCOLOR);
+ StretchBlt(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, SRCCOPY);
}
- delete dat;
- break;
+
+ DeleteDC(hdcMem);
+ return FALSE;
}
- return FALSE;
-}
+};
/////////////////////////////////////////////////////////////////////////////////////////
+// Note vcard dialog
-static INT_PTR CALLBACK NoteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+struct JabberVcardNoteDlg : public JabberVcardBaseDlg
{
- const unsigned long iPageId = 4;
- CJabberProto *ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
-
- switch (msg) {
- case WM_INITDIALOG:
- if (!lParam) break; // Launched from userinfo
- ppro = (CJabberProto*)lParam;
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
- ppro->WindowSubscribe(hwndDlg);
- break;
-
- case WM_JABBER_REFRESH_VCARD:
- SetDialogField(ppro, hwndDlg, IDC_DESC, "About");
- break;
-
- case WM_COMMAND:
- if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE) {
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
-
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0) {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
- break;
- case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL << iPageId);
- ppro->SaveVcardToDB(hwndDlg, iPageId);
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
- break;
- }
- }
- break;
- case WM_DESTROY:
- ppro->WindowUnsubscribe(hwndDlg);
- break;
+ JabberVcardNoteDlg(CJabberProto *_ppro) :
+ JabberVcardBaseDlg(_ppro, IDD_VCARD_WORK, 4)
+ {}
+
+ bool OnRefresh() override
+ {
+ SetDialogField(ppro, m_hwnd, IDC_DESC, "About");
+ return false;
}
- return FALSE;
-}
+};
/////////////////////////////////////////////////////////////////////////////////////////
+// Email vcard dialog
struct EditDlgParam
{
@@ -685,239 +588,202 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
return FALSE;
}
-#define M_REMAKELISTS (WM_USER+1)
-static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
+class JabberVcardContactDlg : public JabberVcardBaseDlg
{
- const unsigned long iPageId = 5;
- CJabberProto *ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ CCtrlListView phones, emails;
+
+public:
+ JabberVcardContactDlg(CJabberProto *_ppro) :
+ JabberVcardBaseDlg(_ppro, IDD_VCARD_CONTACT, 5),
+ phones(this, IDC_PHONES),
+ emails(this, IDC_EMAILS)
+ {
+ phones.OnClick = emails.OnClick = Callback(this, &JabberVcardContactDlg::onClick_Lists);
+ phones.OnCustomDraw = emails.OnCustomDraw = Callback(this, &JabberVcardContactDlg::onDraw_Lists);
+ }
- switch (msg) {
- case WM_INITDIALOG:
- if (!lParam) break; // Launched from userinfo
- ppro = (CJabberProto*)lParam;
- {
- LVCOLUMN lvc;
- RECT rc;
+ bool OnInitDialog() override
+ {
+ JabberVcardBaseDlg::OnInitDialog();
+
+ RECT rc;
+ GetClientRect(emails.GetHwnd(), &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_WIDTH;
+ lvc.cx = 30;
+ emails.InsertColumn(0, &lvc);
+ phones.InsertColumn(0, &lvc);
+ lvc.cx = rc.right - 30 - 40;
+ emails.InsertColumn(1, &lvc);
+ phones.InsertColumn(1, &lvc);
+ lvc.cx = 20;
+ emails.InsertColumn(2, &lvc);
+ emails.InsertColumn(3, &lvc);
+ phones.InsertColumn(2, &lvc);
+ phones.InsertColumn(3, &lvc);
+ return true;
+ }
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
-
- TranslateDialogDefault(hwndDlg);
- GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc);
- rc.right -= GetSystemMetrics(SM_CXVSCROLL);
- lvc.mask = LVCF_WIDTH;
- lvc.cx = 30;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc);
- lvc.cx = rc.right - 30 - 40;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &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), 2, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
-
- ppro->WindowSubscribe(hwndDlg);
+ bool OnRefresh() override
+ {
+ int i;
+ char idstr[33];
+ wchar_t number[20];
+
+ //e-mails
+ emails.DeleteAllItems();
+
+ LVITEM lvi;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ for (i=0;;i++) {
+ mir_snprintf(idstr, "e-mail%d", i);
+ ptrW email(ppro->getWStringA(idstr));
+ if (email == nullptr) break;
+
+ mir_snwprintf(number, L"%d", i + 1);
+ lvi.pszText = number;
+ lvi.lParam = (LPARAM)i;
+ emails.InsertItem(&lvi);
+ emails.SetItemText(lvi.iItem, 1, email);
+ lvi.iItem++;
}
- break;
- case M_REMAKELISTS:
- {
- int i;
- char idstr[33];
- wchar_t number[20];
-
- //e-mails
- ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS));
-
- LVITEM lvi;
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- for (i=0;;i++) {
- mir_snprintf(idstr, "e-mail%d", i);
- ptrW email(ppro->getWStringA(idstr));
- if (email == nullptr) break;
-
- mir_snwprintf(number, L"%d", i + 1);
- lvi.pszText = number;
- lvi.lParam = (LPARAM)i;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, email);
- lvi.iItem++;
- }
- lvi.mask = LVIF_PARAM;
- lvi.lParam = -1;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
-
- //phones
- ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES));
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- for (i=0;;i++) {
- mir_snprintf(idstr, "Phone%d", i);
- ptrW phone(ppro->getWStringA(idstr));
- if (phone == nullptr) break;
-
- mir_snwprintf(number, L"%d", i + 1);
- lvi.pszText = number;
- lvi.lParam = (LPARAM)i;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, phone);
- lvi.iItem++;
- }
- lvi.mask = LVIF_PARAM;
- lvi.lParam = -1;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
+ lvi.mask = LVIF_PARAM;
+ lvi.lParam = -1;
+ emails.InsertItem(&lvi);
+
+ //phones
+ phones.DeleteAllItems();
+
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ for (i=0;;i++) {
+ mir_snprintf(idstr, "Phone%d", i);
+ ptrW phone(ppro->getWStringA(idstr));
+ if (phone == nullptr) break;
+
+ mir_snwprintf(number, L"%d", i + 1);
+ lvi.pszText = number;
+ lvi.lParam = (LPARAM)i;
+ phones.InsertItem(&lvi);
+ phones.SetItemText(lvi.iItem, 1, phone);
+ lvi.iItem++;
}
- break;
+ lvi.mask = LVIF_PARAM;
+ lvi.lParam = -1;
+ phones.InsertItem(&lvi);
+ return false;
+ }
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_PARAMCHANGED:
- SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
- break;
-
- case PSN_APPLY:
- ppro->m_vCardUpdates &= ~(1UL << iPageId);
- ppro->SaveVcardToDB(hwndDlg, iPageId);
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
- break;
- }
- break;
+ void onDraw_Lists(CCtrlListView::TEventInfo *ev)
+ {
+ NMLVCUSTOMDRAW *nm = ev->nmcd;
- 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;
- HICON hIcon;
-
- ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
- if (nm->nmcd.lItemlParam == -1 && nm->iSubItem == 3)
- hIcon = g_plugin.getIcon(IDI_ADDCONTACT);
- else if (nm->iSubItem == 2 && nm->nmcd.lItemlParam != -1)
- hIcon = g_plugin.getIcon(IDI_EDIT);
- else if (nm->iSubItem == 3 && nm->nmcd.lItemlParam != -1)
- hIcon = g_plugin.getIcon(IDI_DELETE);
- 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, nullptr, DI_NORMAL);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
- }
- break;
-
- case NM_CLICK:
- NMLISTVIEW *nm = (NMLISTVIEW *)lParam;
- if (nm->iSubItem < 2)
- break;
-
- const char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "Phone%d" : "e-mail%d";
- const char *szFlagTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "PhoneFlag%d" : "e-mailFlag%d";
-
- LVHITTESTINFO hti;
- 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;
-
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hti.iItem;
- lvi.iSubItem = 0;
- ListView_GetItem(nm->hdr.hwndFrom, &lvi);
- if (lvi.lParam == -1) {
- if (hti.iSubItem == 3) {
- //add
- EditDlgParam param = { -1, ppro };
- int res;
- if (nm->hdr.idFrom == IDC_PHONES)
- res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)&param);
- else
- res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)&param);
- if (res != IDOK)
- break;
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- else {
- if (hti.iSubItem == 3) {
- //delete
- char idstr[33];
-
- int i;
- for (i = lvi.lParam;; i++) {
- mir_snprintf(idstr, szIdTemplate, i + 1);
- ptrA fieldVal(ppro->getStringA(idstr));
- if (fieldVal == nullptr) break;
- mir_snprintf(idstr, szIdTemplate, i);
- ppro->setString(idstr, fieldVal);
-
- mir_snprintf(idstr, szFlagTemplate, i + 1);
- uint16_t nFlag = ppro->getWord(idstr, 0);
- mir_snprintf(idstr, szFlagTemplate, i);
- ppro->setWord(idstr, nFlag);
- }
- mir_snprintf(idstr, szIdTemplate, i);
- ppro->delSetting(idstr);
- mir_snprintf(idstr, szFlagTemplate, i);
- ppro->delSetting(idstr);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- else if (hti.iSubItem == 2) {
- EditDlgParam param = { (int)lvi.lParam, ppro };
- int res;
- if (nm->hdr.idFrom == IDC_PHONES)
- res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)&param);
- else
- res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)&param);
- if (res != IDOK)
- break;
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- ppro->m_vCardUpdates |= (1UL << iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- }
- }
- break;
+ switch (nm->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ case CDDS_ITEMPREPAINT:
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
+ return;
- case WM_SETCURSOR:
- if (LOWORD(lParam) != HTCLIENT) break;
- if (GetForegroundWindow() == GetParent(hwndDlg)) {
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwndDlg, &pt);
- SetFocus(ChildWindowFromPoint(hwndDlg, pt)); //ugly hack because listviews ignore their first click
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
+ RECT rc;
+ HICON hIcon;
+
+ ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
+ if (nm->nmcd.lItemlParam == -1 && nm->iSubItem == 3)
+ hIcon = g_plugin.getIcon(IDI_ADDCONTACT);
+ else if (nm->iSubItem == 2 && nm->nmcd.lItemlParam != -1)
+ hIcon = g_plugin.getIcon(IDI_EDIT);
+ else if (nm->iSubItem == 3 && nm->nmcd.lItemlParam != -1)
+ hIcon = g_plugin.getIcon(IDI_DELETE);
+ 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, nullptr, DI_NORMAL);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
}
- break;
+ }
- case WM_DESTROY:
- ppro->WindowUnsubscribe(hwndDlg);
- break;
+ void onClick_Lists(CCtrlListView::TEventInfo *ev)
+ {
+ NMLISTVIEW *nm = ev->nmlv;
+ if (nm->iSubItem < 2)
+ return;
+
+ const char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "Phone%d" : "e-mail%d";
+ const char *szFlagTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "PhoneFlag%d" : "e-mailFlag%d";
+
+ LVHITTESTINFO hti;
+ 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)
+ return;
+
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hti.iItem;
+ lvi.iSubItem = 0;
+ ListView_GetItem(nm->hdr.hwndFrom, &lvi);
+ if (lvi.lParam == -1) {
+ if (hti.iSubItem == 3) {
+ //add
+ EditDlgParam param = { -1, ppro };
+ int res;
+ if (nm->hdr.idFrom == IDC_PHONES)
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), m_hwnd, EditPhoneDlgProc, (LPARAM)&param);
+ else
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), m_hwnd, EditEmailDlgProc, (LPARAM)&param);
+ if (res != IDOK)
+ return;
+ OnRefresh();
+ NotifyChange();
+ }
+ }
+ else {
+ if (hti.iSubItem == 3) {
+ //delete
+ char idstr[33];
+
+ int i;
+ for (i = lvi.lParam;; i++) {
+ mir_snprintf(idstr, szIdTemplate, i + 1);
+ ptrA fieldVal(ppro->getStringA(idstr));
+ if (fieldVal == nullptr) break;
+ mir_snprintf(idstr, szIdTemplate, i);
+ ppro->setString(idstr, fieldVal);
+
+ mir_snprintf(idstr, szFlagTemplate, i + 1);
+ uint16_t nFlag = ppro->getWord(idstr, 0);
+ mir_snprintf(idstr, szFlagTemplate, i);
+ ppro->setWord(idstr, nFlag);
+ }
+ mir_snprintf(idstr, szIdTemplate, i);
+ ppro->delSetting(idstr);
+ mir_snprintf(idstr, szFlagTemplate, i);
+ ppro->delSetting(idstr);
+ OnRefresh();
+ NotifyChange();
+ }
+ else if (hti.iSubItem == 2) {
+ EditDlgParam param = { (int)lvi.lParam, ppro };
+ int res;
+ if (nm->hdr.idFrom == IDC_PHONES)
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), m_hwnd, EditPhoneDlgProc, (LPARAM)&param);
+ else
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), m_hwnd, EditEmailDlgProc, (LPARAM)&param);
+ if (res != IDOK)
+ return;
+ OnRefresh();
+ NotifyChange();
+ }
+ }
}
- return FALSE;
-}
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage)
{
@@ -1174,55 +1040,40 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t *szPhotoFileName)
/////////////////////////////////////////////////////////////////////////////////////////
-INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam);
-
void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM)
{
m_vCardUpdates = 0;
m_bPhotoChanged = false;
m_szPhotoFileName[0] = 0;
- OPTIONSDIALOGPAGE odp = {};
- odp.dwInitParam = (LPARAM)this;
- odp.flags = ODPF_UNICODE | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
- odp.szTitle.w = m_tszUserName;
-
- odp.pfnDlgProc = PersonalDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_PERSONAL);
- odp.szTab.w = LPGENW("General");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = ContactDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_CONTACT);
- odp.szTab.w = LPGENW("Contacts");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = HomeDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_HOME);
- odp.szTab.w = LPGENW("Home");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = WorkDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_WORK);
- odp.szTab.w = LPGENW("Work");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = PhotoDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_PHOTO);
- odp.szTab.w = LPGENW("Photo");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = NoteDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_NOTE);
- odp.szTab.w = LPGENW("Note");
- g_plugin.addUserInfo(wParam, &odp);
-
- if (m_bUseOMEMO) {
- odp.pfnDlgProc = JabberUserOmemoDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_OMEMO);
- odp.szTab.w = LPGENW("OMEMO");
- g_plugin.addUserInfo(wParam, &odp);
- }
+ USERINFOPAGE uip = {};
+ uip.flags = ODPF_UNICODE | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
+ uip.szGroup.w = m_tszUserName;
+
+ uip.pDialog = new JabberVcardPersonalDlg(this);
+ uip.szTitle.w = LPGENW("General");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new JabberVcardContactDlg(this);
+ uip.szTitle.w = LPGENW("Contacts");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new JabberVcardHomeDlg(this);
+ uip.szTitle.w = LPGENW("Home");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new JabberVcardWorkDlg(this);
+ uip.szTitle.w = LPGENW("Work");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new JabberVcardPhotoDlg(this);
+ uip.szTitle.w = LPGENW("Photo");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new JabberVcardNoteDlg(this);
+ uip.szTitle.w = LPGENW("Note");
+ g_plugin.addUserInfo(wParam, &uip);
+ CheckOmemoUserInfo(wParam, uip);
SendGetVcard(0);
}
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp
index be5fd11d3c..e4c3f36bb6 100644
--- a/protocols/Tox/src/tox_contacts.cpp
+++ b/protocols/Tox/src/tox_contacts.cpp
@@ -343,6 +343,41 @@ void CToxProto::OnConnectionStatusChanged(Tox *tox, uint32_t friendNumber, TOX_C
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// User info dialog
+
+class ToxUserInfoDlg : public CUserInfoPageDlg
+{
+ CToxProto *ppro;
+
+public:
+ ToxUserInfoDlg(CToxProto *_ppro) :
+ CUserInfoPageDlg(g_plugin, IDD_USER_INFO),
+ ppro(_ppro)
+ {
+ }
+
+ bool OnRefresh() override
+ {
+ char *szProto = (m_hContact == NULL) ? ppro->m_szModuleName : Proto_GetBaseAccountName(m_hContact);
+ if (szProto != nullptr)
+ SetDlgItemText(m_hwnd, IDC_DNS_ID, ptrW(ppro->getWStringA(m_hContact, TOX_SETTINGS_DNS)));
+ return false;
+ }
+
+ bool OnApply() override
+ {
+ char *szProto = (m_hContact == NULL) ? ppro->m_szModuleName : Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ return false;
+
+ wchar_t dnsId[MAX_PATH];
+ GetDlgItemText(m_hwnd, IDC_DNS_ID, dnsId, MAX_PATH);
+ ppro->setWString(m_hContact, TOX_SETTINGS_DNS, dnsId);
+ return true;
+ }
+};
+
int CToxProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact)
{
if (!Proto_IsProtocolLoaded(m_szModuleName))
@@ -350,68 +385,12 @@ int CToxProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact)
char *szProto = Proto_GetBaseAccountName(hContact);
if (szProto != nullptr && !mir_strcmp(szProto, m_szModuleName)) {
- OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.flags = ODPF_UNICODE | ODPF_DONTTRANSLATE;
- odp.dwInitParam = (LPARAM)this;
- odp.szTitle.w = m_tszUserName;
-
- odp.pfnDlgProc = UserInfoProc;
- odp.position = -2000000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_USER_INFO);
- g_plugin.addUserInfo(wParam, &odp);
+ USERINFOPAGE uip = {};
+ uip.flags = ODPF_UNICODE | ODPF_DONTTRANSLATE;
+ uip.szTitle.w = m_tszUserName;
+ uip.pDialog = new ToxUserInfoDlg(this);
+ g_plugin.addUserInfo(wParam, &uip);
}
return 0;
}
-
-INT_PTR CToxProto::UserInfoProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
-
- switch (uMsg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwnd);
- proto = (CToxProto*)lParam;
- SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- char *szProto = (hContact == NULL) ? proto->m_szModuleName : Proto_GetBaseAccountName(hContact);
- if (szProto != nullptr)
- SetDlgItemText(hwnd, IDC_DNS_ID, ptrW(proto->getWStringA(hContact, TOX_SETTINGS_DNS)));
- }
- break;
-
- case PSN_PARAMCHANGED:
- SetWindowLongPtr(hwnd, GWLP_USERDATA, ((PSHNOTIFY*)lParam)->lParam);
- break;
-
- case PSN_APPLY:
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- char *szProto = (hContact == NULL) ? proto->m_szModuleName : Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr)
- break;
-
- wchar_t dnsId[MAX_PATH];
- GetDlgItemText(hwnd, IDC_DNS_ID, dnsId, MAX_PATH);
- proto->setWString(hContact, TOX_SETTINGS_DNS, dnsId);
- break;
- }
- break;
- }
- break;
-
- case WM_COMMAND:
- if ((HWND)lParam == GetFocus() && HIWORD(wParam) == EN_CHANGE)
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- }
-
- return FALSE;
-}
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h
index ea25f3f28c..c0cee1d62e 100644
--- a/protocols/Weather/src/stdafx.h
+++ b/protocols/Weather/src/stdafx.h
@@ -512,13 +512,27 @@ void removeWindow(MCONTACT hContact);
// functions in weather_userinfo.c
int UserInfoInit(WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
#define WM_UPDATEDATA WM_USER + 2687
int BriefInfo(WPARAM wParam, LPARAM lParam);
INT_PTR BriefInfoSvc(WPARAM wParam, LPARAM lParam);
+///////////////////////////////////////////////////////////////////////////////
+// UI Classes
+
+class WeatherMyDetailsDlg : public CUserInfoPageDlg
+{
+ CCtrlButton btnReload;
+
+public:
+ WeatherMyDetailsDlg();
+
+ bool OnInitDialog() override;
+
+ void onClick_Reload(CCtrlButton *);
+};
+
//============ Plugin Class ============
struct CMPlugin : public PLUGIN<CMPlugin>
diff --git a/protocols/Weather/src/weather_info.cpp b/protocols/Weather/src/weather_info.cpp
index d9d76afe7f..5e4c79fb4a 100644
--- a/protocols/Weather/src/weather_info.cpp
+++ b/protocols/Weather/src/weather_info.cpp
@@ -74,12 +74,12 @@ static void INIInfo(HWND hwndDlg)
SetDlgItemText(hwndDlg, IDC_MEMUSED, _ltow((long)memused, str, 10));
}
-static const struct tag_Columns
+struct
{
const wchar_t *name;
unsigned size;
}
-columns[] =
+static columns[] =
{
{ LPGENW("Name"), 70 },
{ LPGENW("Author"), 100 },
@@ -90,44 +90,37 @@ columns[] =
{ LPGENW("File Name"), 150 },
};
-
-INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
+WeatherMyDetailsDlg::WeatherMyDetailsDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO),
+ btnReload(this, IDC_RELOADINI)
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
- LVCOLUMN lvc = {};
-
- lvc.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
- lvc.fmt = LVCFMT_LEFT;
- for (int i = 0; i < 7; ++i) {
- lvc.iSubItem = i;
- lvc.pszText = TranslateW(columns[i].name);
- lvc.cx = columns[i].size;
- ListView_InsertColumn(hIniList, i, &lvc);
- }
- INIInfo(hwndDlg);
- }
-
- break;
-
- case WM_DESTROY:
- break;
+ btnReload.OnClick = Callback(this, &WeatherMyDetailsDlg::onClick_Reload);
+}
- case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED &&
- LOWORD(wParam) == IDC_RELOADINI) {
- DestroyWIList();
- LoadWIData(true);
- INIInfo(hwndDlg);
- }
- break;
+bool WeatherMyDetailsDlg::OnInitDialog()
+{
+ HWND hIniList = GetDlgItem(m_hwnd, IDC_INFOLIST);
+
+ LVCOLUMN lvc = {};
+ lvc.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
+ lvc.fmt = LVCFMT_LEFT;
+ for (auto &it : columns) {
+ lvc.iSubItem = int(&it - columns);
+ lvc.pszText = TranslateW(it.name);
+ lvc.cx = it.size;
+ ListView_InsertColumn(hIniList, lvc.iSubItem, &lvc);
}
- return 0;
+
+ INIInfo(m_hwnd);
+ return true;
}
+void WeatherMyDetailsDlg::onClick_Reload(CCtrlButton*)
+{
+ DestroyWIList();
+ LoadWIData(true);
+ INIInfo(m_hwnd);
+}
// get the info of individual ini file
// pszSvc = the internal name of the service to get the data
diff --git a/protocols/Weather/src/weather_userinfo.cpp b/protocols/Weather/src/weather_userinfo.cpp
index 1008a6c44e..f17f797f73 100644
--- a/protocols/Weather/src/weather_userinfo.cpp
+++ b/protocols/Weather/src/weather_userinfo.cpp
@@ -239,98 +239,93 @@ static INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, L
return FALSE;
}
-// dialog process for the weather tab under user info
-// lParam = current contact
-static INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// User info dialog
+
+class WeatherUserInfoDlg : public CUserInfoPageDlg
{
- WEATHERINFO w;
- wchar_t str[MAX_TEXT_SIZE];
+ CCtrlButton btnDetail;
+
+public:
+ WeatherUserInfoDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_USERINFO),
+ btnDetail(this, IDC_MOREDETAIL)
+ {
+ }
+
+ bool OnInitDialog() override
+ {
+ SendDlgItemMessage(m_hwnd, IDC_MOREDETAIL, BUTTONSETASFLATBTN, TRUE, 0);
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_MOREDETAIL, BUTTONSETASFLATBTN, TRUE, 0);
- // save the contact handle for later use
- hContact = lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact);
// load weather info for the contact
- w = LoadWeatherInfo(lParam);
- SetDlgItemText(hwndDlg, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str));
+ wchar_t str[MAX_TEXT_SIZE];
+ WEATHERINFO w = LoadWeatherInfo(m_hContact);
+ SetDlgItemText(m_hwnd, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str));
+
+ SendDlgItemMessage(m_hwnd, IDC_INFOICON, STM_SETICON, (WPARAM)GetStatusIconBig(m_hContact), 0);
+
+ // bold and enlarge the current condition
+ LOGFONT lf;
+ HFONT hNormalFont = (HFONT)SendDlgItemMessage(m_hwnd, IDC_INFO2, WM_GETFONT, 0, 0);
+ GetObject(hNormalFont, sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ lf.lfWidth = 7;
+ lf.lfHeight = 15;
+ SendDlgItemMessage(m_hwnd, IDC_INFO2, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
- SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, (WPARAM)GetStatusIconBig(hContact), 0);
- {
- // bold and enlarge the current condition
- LOGFONT lf;
- HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_GETFONT, 0, 0);
- GetObject(hNormalFont, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- lf.lfWidth = 7;
- lf.lfHeight = 15;
- SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
- }
// set the text for displaying other current weather conditions data
GetDisplay(&w, L"%c %t", str);
- SetDlgItemText(hwndDlg, IDC_INFO2, str);
- SetDlgItemText(hwndDlg, IDC_INFO3, w.feel);
- SetDlgItemText(hwndDlg, IDC_INFO4, w.pressure);
+ SetDlgItemText(m_hwnd, IDC_INFO2, str);
+ SetDlgItemText(m_hwnd, IDC_INFO3, w.feel);
+ SetDlgItemText(m_hwnd, IDC_INFO4, w.pressure);
GetDisplay(&w, L"%i %w", str);
- SetDlgItemText(hwndDlg, IDC_INFO5, str);
- SetDlgItemText(hwndDlg, IDC_INFO6, w.dewpoint);
- SetDlgItemText(hwndDlg, IDC_INFO7, w.sunrise);
- SetDlgItemText(hwndDlg, IDC_INFO8, w.sunset);
- SetDlgItemText(hwndDlg, IDC_INFO9, w.high);
- SetDlgItemText(hwndDlg, IDC_INFO10, w.low);
+ SetDlgItemText(m_hwnd, IDC_INFO5, str);
+ SetDlgItemText(m_hwnd, IDC_INFO6, w.dewpoint);
+ SetDlgItemText(m_hwnd, IDC_INFO7, w.sunrise);
+ SetDlgItemText(m_hwnd, IDC_INFO8, w.sunset);
+ SetDlgItemText(m_hwnd, IDC_INFO9, w.high);
+ SetDlgItemText(m_hwnd, IDC_INFO10, w.low);
GetDisplay(&w, TranslateT("Last update on: %u"), str);
- SetDlgItemText(hwndDlg, IDC_INFO11, str);
- SetDlgItemText(hwndDlg, IDC_INFO12, w.humid);
- SetDlgItemText(hwndDlg, IDC_INFO13, w.vis);
- break;
+ SetDlgItemText(m_hwnd, IDC_INFO11, str);
+ SetDlgItemText(m_hwnd, IDC_INFO12, w.humid);
+ SetDlgItemText(m_hwnd, IDC_INFO13, w.vis);
+ return true;
+ }
- case WM_DESTROY:
- DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, 0, 0));
- DeleteObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_GETFONT, 0, 0));
- break;
+ void OnDestroy() override
+ {
+ DestroyIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_INFOICON, STM_SETICON, 0, 0));
+ DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_INFO2, WM_GETFONT, 0, 0));
+ }
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_MOREDETAIL:
- HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
- if (hMoreDataDlg == nullptr)
- hMoreDataDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BRIEF), nullptr, DlgProcMoreData, hContact);
- else {
- SetForegroundWindow(hMoreDataDlg);
- SetFocus(hMoreDataDlg);
- }
- ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 0);
- ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 1);
+ void onClick_Detail(CCtrlButton *)
+ {
+ HWND hMoreDataDlg = WindowList_Find(hDataWindowList, m_hContact);
+ if (hMoreDataDlg == nullptr)
+ hMoreDataDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BRIEF), nullptr, DlgProcMoreData, m_hContact);
+ else {
+ SetForegroundWindow(hMoreDataDlg);
+ SetFocus(hMoreDataDlg);
}
- break;
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 0);
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 1);
}
- return 0;
-}
+};
-//============ CONTACT INFORMATION ============
-//
-// initialize user info
-// lParam = current contact
int UserInfoInit(WPARAM wParam, LPARAM hContact)
{
- OPTIONSDIALOGPAGE odp = {};
- odp.position = 100000000;
- odp.szTitle.a = MODULENAME;
+ USERINFOPAGE uip = {};
+ uip.szTitle.a = MODULENAME;
+ uip.position = 100000000;
if (hContact == 0) {
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO);
- odp.pfnDlgProc = DlgProcINIPage;
- g_plugin.addUserInfo(wParam, &odp);
+ uip.pDialog = new WeatherMyDetailsDlg();
+ g_plugin.addUserInfo(wParam, &uip);
}
else if (IsMyContact(hContact)) { // check if it is a weather contact
- // register the contact info page
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
- odp.pfnDlgProc = DlgProcUIPage;
- odp.flags = ODPF_BOLDGROUPS;
- g_plugin.addUserInfo(wParam, &odp);
+ uip.pDialog = new WeatherUserInfoDlg();
+ uip.flags = ODPF_BOLDGROUPS;
+ g_plugin.addUserInfo(wParam, &uip);
}
return 0;
}