diff options
author | George Hazan <ghazan@miranda.im> | 2022-06-09 21:26:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-06-09 21:30:54 +0300 |
commit | 856ff580fd9d776c331a6b525fa7d73a24d92f64 (patch) | |
tree | 42c4912b0b9c406c15783af3fc6e8c4857b09de1 | |
parent | 68c2dea66f3e368cc1437f7890c8e62907890fcd (diff) |
UserInfo -> UI classes
64 files changed, 3971 insertions, 4488 deletions
diff --git a/include/m_gui.h b/include/m_gui.h index 08ece9af48..3728037ab4 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -1401,7 +1401,6 @@ protected: // CCtrlPages #define PSN_INFOCHANGED 1 -#define PSN_PARAMCHANGED 2 // force-send a PSN_INFOCHANGED to all pages #define PSM_FORCECHANGED (WM_USER+100) diff --git a/include/m_userinfo.h b/include/m_userinfo.h index 7eac5049cc..897b42ea2b 100644 --- a/include/m_userinfo.h +++ b/include/m_userinfo.h @@ -25,11 +25,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_USERINFO_H__
#define M_USERINFO_H__ 1
-#ifndef M_CORE_H__
-#include <m_core.h>
-#endif
+#include <m_gui.h>
-#include "m_options.h"
+class MIR_APP_EXPORT CUserInfoPageDlg : public CDlgBase
+{
+protected:
+ MCONTACT m_hContact = INVALID_CONTACT_ID;
+
+public:
+ CUserInfoPageDlg(class CMPluginBase &pPlug, int idDialog);
+
+ __forceinline void SetContact(MCONTACT hContact) {
+ m_hContact = hContact;
+ }
+
+ virtual bool OnRefresh();
+};
+
+struct USERINFOPAGE
+{
+ MAllStrings szTitle, szGroup; // [TRANSLATED-BY-CORE]
+ HPLUGIN pPlugin;
+ uint32_t flags;
+ CUserInfoPageDlg *pDialog;
+
+ // used in UInfoEx only
+ int position;
+ INT_PTR dwInitParam;
+};
//show the User Details dialog box
//wParam = (MCONTACT)hContact
@@ -49,31 +72,4 @@ hook. Look up core/m_system.h:me_system_modulesloaded. */
#define ME_USERINFO_INITIALISE "UserInfo/Initialise"
-/* UserInfo/AddPage v0.1.2.0+
-Must only be called during an userinfo/initialise hook
-Adds a page to the details dialog
-wParam = addInfo
-lParam = (LPARAM)(OPTIONSDIALOGPAGE*)odp
-addInfo must have come straight from the wParam of userinfo/initialise
-Pages in the details dialog operate just like pages in property sheets. See the
-Microsoft documentation for info on how they operate.
-When the pages receive WM_INITDIALOG, lParam = (LPARAM)hContact
-Strings in the structure can be released as soon as the service returns, but
-icons must be kept around. This is not a problem if you're loading them from a
-resource
-The 3 'group' elements in the structure are ignored, and will always be ignored
-Unlike the options dialog, the details dialog does not resize to fit its
-largest page. Details dialog pages should be 222x132 dlus.
-The details dialog (currently) has no Cancel button. I'm waiting to see if it's
-sensible to have one.
-Pages will be sent PSN_INFOCHANGED through WM_NOTIFY (idFrom = 0) when a protocol
-ack is broadcast for the correct contact and with type = ACKTYPE_GETINFO.
-To help you out, PSN_INFOCHANGED will also be sent to each page just after it's
-created.
-All PSN_ WM_NOTIFY messages have PSHNOTIFY.lParam = (LPARAM)hContact
-*/
-#define PSN_INFOCHANGED 1
-#define PSN_PARAMCHANGED 2
-#define PSM_FORCECHANGED (WM_USER+100) //force-send a PSN_INFOCHANGED to all pages
-
#endif // M_USERINFO_H__
diff --git a/include/newpluginapi.h b/include/newpluginapi.h index 7b852b7af4..88d72a47d0 100644 --- a/include/newpluginapi.h +++ b/include/newpluginapi.h @@ -216,7 +216,7 @@ public: int addFrame(const struct CLISTFrame*); int addHotkey(const struct HOTKEYDESC*); int addSound(const char *name, const wchar_t *section, const wchar_t *description, const wchar_t *defaultFile = nullptr); - int addUserInfo(WPARAM wParam, struct OPTIONSDIALOGPAGE *odp); + int addUserInfo(WPARAM wParam, struct USERINFOPAGE *odp); //////////////////////////////////////////////////////////////////////////////////////// diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 1d3aa64391..297d572cee 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 12ddef11ff..d825bdc85c 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index ef355a951d..7ab9d4d379 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -732,154 +732,173 @@ int OptInit(WPARAM wParam, LPARAM) } ///////////////////////////////////////////////////////////////////////////////////////// +// User info dialog -static INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +class AvatarUserInfoDlg : public CUserInfoPageDlg { - WindowData *dat = (WindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - MCONTACT hContact = (dat) ? dat->hContact : INVALID_CONTACT_ID; + HANDLE hHook = nullptr; - switch (msg) { - case WM_INITDIALOG: - dat = new WindowData(hContact = lParam, hwndDlg); - { - HWND protopic = GetDlgItem(hwndDlg, IDC_PROTOPIC); - SendMessage(protopic, AVATAR_SETCONTACT, 0, (LPARAM)hContact); - SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); - SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("Contact has no avatar")); - SendMessage(protopic, AVATAR_RESPECTHIDDEN, 0, (LPARAM)FALSE); - SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); - } + CCtrlCheck chkTransparent; + CCtrlButton btnHide, btnChange, btnDefaults, btnProtect, btnReset, btnDelete; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - TranslateDialogDefault(hwndDlg); - SendMessage(hwndDlg, DM_SETAVATARNAME, 0, 0); - CheckDlgButton(hwndDlg, IDC_PROTECTAVATAR, db_get_b(hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_HIDEAVATAR, Contact_IsHidden(hContact) ? BST_CHECKED : BST_UNCHECKED); + void ReloadAvatar() + { + SaveTransparentData(m_hwnd, m_hContact, IsDlgButtonChecked(m_hwnd, IDC_PROTECTAVATAR)); + ChangeAvatar(m_hContact, true); + } - SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_BKG_NUM_POINTS), 0); - SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETRANGE, 0, MAKELONG(8, 2)); + INT_PTR OnChangeAvatar(UINT, WPARAM, LPARAM) + { + InvalidateRect(GetDlgItem(m_hwnd, IDC_PROTOPIC), nullptr, TRUE); + return 0; + } - SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_BKG_COLOR_DIFFERENCE), 0); - SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); + UI_MESSAGE_MAP(AvatarUserInfoDlg, CUserInfoPageDlg); + UI_MESSAGE(DM_AVATARCHANGED, OnChangeAvatar); + UI_MESSAGE_MAP_END(); + +public: + AvatarUserInfoDlg() : + CUserInfoPageDlg(g_plugin, IDD_USER_AVATAR), + btnHide(this, IDC_HIDEAVATAR), + btnReset(this, IDC_RESET), + btnChange(this, IDC_CHANGE), + btnDelete(this, IDC_DELETE), + btnProtect(this, IDC_PROTECTAVATAR), + btnDefaults(this, ID_USE_DEFAULTS), + chkTransparent(this, IDC_MAKETRANSPBKG) + { + btnHide.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Hide); + btnReset.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Reset); + btnChange.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Change); + btnDelete.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Delete); + btnProtect.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Protect); + btnDefaults.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_UseDefaults); + + chkTransparent.OnChange = Callback(this, &AvatarUserInfoDlg::onChange_Transparent); + } - LoadTransparentData(hwndDlg, GetContactThatHaveTheAvatar(hContact)); - break; + bool OnInitDialog() override + { + hHook = HookEventMessage(ME_AV_AVATARCHANGED, m_hwnd, DM_AVATARCHANGED); - case WM_COMMAND: - switch (LOWORD(wParam)) { - case ID_USE_DEFAULTS: - hContact = GetContactThatHaveTheAvatar(hContact); + HWND protopic = GetDlgItem(m_hwnd, IDC_PROTOPIC); + SendMessage(protopic, AVATAR_SETCONTACT, 0, m_hContact); + SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); + SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("Contact has no avatar")); + SendMessage(protopic, AVATAR_RESPECTHIDDEN, 0, (LPARAM)FALSE); + SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); - db_unset(hContact, "ContactPhoto", "MakeTransparentBkg"); - db_unset(hContact, "ContactPhoto", "TranspBkgNumPoints"); - db_unset(hContact, "ContactPhoto", "TranspBkgColorDiff"); + SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); + CheckDlgButton(m_hwnd, IDC_PROTECTAVATAR, db_get_b(m_hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_HIDEAVATAR, Contact_IsHidden(m_hContact) ? BST_CHECKED : BST_UNCHECKED); - LoadTransparentData(hwndDlg, hContact); + SendDlgItemMessage(m_hwnd, IDC_BKG_NUM_POINTS_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS), 0); + SendDlgItemMessage(m_hwnd, IDC_BKG_NUM_POINTS_SPIN, UDM_SETRANGE, 0, MAKELONG(8, 2)); - SendMessage(hwndDlg, DM_REALODAVATAR, 0, 0); - break; + SendDlgItemMessage(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE), 0); + SendDlgItemMessage(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); - case IDC_CHANGE: - SetAvatar(hContact, 0); - SendMessage(hwndDlg, DM_SETAVATARNAME, 0, 0); - CheckDlgButton(hwndDlg, IDC_PROTECTAVATAR, db_get_b(hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); - break; + LoadTransparentData(m_hwnd, GetContactThatHaveTheAvatar(m_hContact)); + return true; + } - case IDC_HIDEAVATAR: - { - bool hidden = IsDlgButtonChecked(hwndDlg, IDC_HIDEAVATAR) != 0; - SetAvatarAttribute(hContact, AVS_HIDEONCLIST, hidden); - if (hidden != Contact_IsHidden(hContact)) - Contact_Hide(hContact, hidden); - } - break; + void OnDestroy() override + { + UnhookEvent(hHook); + } - case IDC_PROTECTAVATAR: - { - BOOL locked = IsDlgButtonChecked(hwndDlg, IDC_PROTECTAVATAR); - SaveTransparentData(hwndDlg, hContact, locked); - ProtectAvatar(hContact, locked ? 1 : 0); - } - break; + void onClick_UseDefaults(CCtrlButton *) + { + m_hContact = GetContactThatHaveTheAvatar(m_hContact); - case IDC_BKG_NUM_POINTS: - case IDC_BKG_COLOR_DIFFERENCE: - if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) - break; + db_unset(m_hContact, "ContactPhoto", "MakeTransparentBkg"); + db_unset(m_hContact, "ContactPhoto", "TranspBkgNumPoints"); + db_unset(m_hContact, "ContactPhoto", "TranspBkgColorDiff"); - case IDC_MAKETRANSPBKG: - { - BOOL enable = IsDlgButtonChecked(hwndDlg, IDC_MAKETRANSPBKG); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_NUM_POINTS_L), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_NUM_POINTS_SPIN), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_NUM_POINTS), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_L), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN), enable); - EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_COLOR_DIFFERENCE), enable); - } - SendMessage(hwndDlg, DM_REALODAVATAR, 0, 0); - break; - case IDC_RESET: - ProtectAvatar(hContact, 0); - if (MessageBox(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { - DBVARIANT dbv = { 0 }; - if (!db_get_ws(hContact, "ContactPhoto", "File", &dbv)) { - DeleteFile(dbv.pwszVal); - db_free(&dbv); - } - } - db_unset(hContact, "ContactPhoto", "Locked"); - db_unset(hContact, "ContactPhoto", "Backup"); - db_unset(hContact, "ContactPhoto", "RFile"); - db_unset(hContact, "ContactPhoto", "File"); - db_unset(hContact, "ContactPhoto", "Format"); - { - char *szProto = Proto_GetBaseAccountName(hContact); - db_unset(hContact, szProto, "AvatarHash"); - DeleteAvatarFromCache(hContact, FALSE); + LoadTransparentData(m_hwnd, m_hContact); + ReloadAvatar(); + } - QueueAdd(hContact); - } - break; + void onClick_Change(CCtrlButton *) + { + SetAvatar(m_hContact, 0); + SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); + CheckDlgButton(m_hwnd, IDC_PROTECTAVATAR, db_get_b(m_hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); + } - case IDC_DELETE: - ProtectAvatar(hContact, 0); - if (MessageBox(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { - DBVARIANT dbv = { 0 }; - if (!db_get_ws(hContact, "ContactPhoto", "File", &dbv)) { - DeleteFile(dbv.pwszVal); - db_free(&dbv); - } + void onClick_Hide(CCtrlButton *) + { + bool hidden = IsDlgButtonChecked(m_hwnd, IDC_HIDEAVATAR) != 0; + SetAvatarAttribute(m_hContact, AVS_HIDEONCLIST, hidden); + if (hidden != Contact_IsHidden(m_hContact)) + Contact_Hide(m_hContact, hidden); + } + + void onClick_Protect(CCtrlButton *) + { + BOOL locked = IsDlgButtonChecked(m_hwnd, IDC_PROTECTAVATAR); + SaveTransparentData(m_hwnd, m_hContact, locked); + ProtectAvatar(m_hContact, locked ? 1 : 0); + } + + void onChange_Transparent(CCtrlCheck *) + { + BOOL enable = IsDlgButtonChecked(m_hwnd, IDC_MAKETRANSPBKG); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS_L), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS_SPIN), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_L), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE), enable); + ReloadAvatar(); + } + + void onClick_Reset(CCtrlButton *) + { + ProtectAvatar(m_hContact, 0); + if (MessageBox(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { + DBVARIANT dbv = { 0 }; + if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) { + DeleteFile(dbv.pwszVal); + db_free(&dbv); } - db_unset(hContact, "ContactPhoto", "Locked"); - db_unset(hContact, "ContactPhoto", "Backup"); - db_unset(hContact, "ContactPhoto", "RFile"); - db_unset(hContact, "ContactPhoto", "File"); - db_unset(hContact, "ContactPhoto", "Format"); - DeleteAvatarFromCache(hContact, FALSE); - SendMessage(hwndDlg, DM_SETAVATARNAME, 0, 0); - break; } - break; + db_unset(m_hContact, "ContactPhoto", "Locked"); + db_unset(m_hContact, "ContactPhoto", "Backup"); + db_unset(m_hContact, "ContactPhoto", "RFile"); + db_unset(m_hContact, "ContactPhoto", "File"); + db_unset(m_hContact, "ContactPhoto", "Format"); - case DM_REALODAVATAR: - SaveTransparentData(hwndDlg, hContact, IsDlgButtonChecked(hwndDlg, IDC_PROTECTAVATAR)); - ChangeAvatar(hContact, true); - break; + char *szProto = Proto_GetBaseAccountName(m_hContact); + db_unset(m_hContact, szProto, "AvatarHash"); + DeleteAvatarFromCache(m_hContact, FALSE); - case DM_AVATARCHANGED: - InvalidateRect(GetDlgItem(hwndDlg, IDC_PROTOPIC), nullptr, TRUE); - break; + QueueAdd(m_hContact); + } - case WM_NCDESTROY: - delete dat; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); - break; + void onClick_Delete(CCtrlButton *) + { + ProtectAvatar(m_hContact, 0); + if (MessageBoxW(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { + DBVARIANT dbv = { 0 }; + if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) { + DeleteFile(dbv.pwszVal); + db_free(&dbv); + } + } + db_unset(m_hContact, "ContactPhoto", "Locked"); + db_unset(m_hContact, "ContactPhoto", "Backup"); + db_unset(m_hContact, "ContactPhoto", "RFile"); + db_unset(m_hContact, "ContactPhoto", "File"); + db_unset(m_hContact, "ContactPhoto", "Format"); + DeleteAvatarFromCache(m_hContact, FALSE); + SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); } - return FALSE; -} +}; ///////////////////////////////////////////////////////////////////////////////////////// +// Protocol avatar dialog static char* GetSelectedProtocol(HWND hwndDlg) { @@ -982,143 +1001,145 @@ static void EnableDisableProtocols(HWND hwndDlg, BOOL init) } } -static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +class AvatarProtoInfoDlg : public CUserInfoPageDlg { - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { - HWND protopic = GetDlgItem(hwndDlg, IDC_PROTOPIC); - SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); - SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("No avatar")); - SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); - - HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS); - ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES); + CCtrlCheck chkPerProto; + CCtrlButton btnChange, btnDelete; + CCtrlListView protocols; + +public: + AvatarProtoInfoDlg() : + CUserInfoPageDlg(g_plugin, IDD_PROTO_AVATARS), + protocols(this, IDC_PROTOCOLS), + btnChange(this, IDC_CHANGE), + btnDelete(this, IDC_DELETE), + chkPerProto(this, IDC_PER_PROTO) + { + btnChange.OnClick = Callback(this, &AvatarProtoInfoDlg::onClick_Change); + btnDelete.OnClick = Callback(this, &AvatarProtoInfoDlg::onClick_Delete); - HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); - ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); + chkPerProto.OnChange = Callback(this, &AvatarProtoInfoDlg::onChange_PerProto); + } - LVCOLUMN lvc = { 0 }; - lvc.mask = LVCF_FMT; - lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; - ListView_InsertColumn(hwndList, 0, &lvc); + bool OnInitDialog() override + { + HWND protopic = GetDlgItem(m_hwnd, IDC_PROTOPIC); + SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); + SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("No avatar")); + SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); - LVITEM item = { 0 }; - item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; - item.iItem = 1000; + protocols.SetExtendedListViewStyleEx(0, LVS_EX_SUBITEMIMAGES); - // List protocols - int num = 0; - for (auto &it : Accounts()) { - if (!ProtoServiceExists(it->szModuleName, PS_GETMYAVATAR)) - continue; + HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); + protocols.SetImageList(hIml, LVSIL_SMALL); - if (!Proto_IsAvatarsEnabled(it->szModuleName)) - continue; + LVCOLUMN lvc = { 0 }; + lvc.mask = LVCF_FMT; + lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; + protocols.InsertColumn(0, &lvc); - ImageList_AddIcon(hIml, Skin_LoadProtoIcon(it->szModuleName, ID_STATUS_ONLINE)); - item.pszText = it->tszAccountName; - item.iImage = num; - item.lParam = (LPARAM)it->szModuleName; + LVITEM item = { 0 }; + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + item.iItem = 1000; - ListView_InsertItem(hwndList, &item); - num++; - } + // List protocols + int num = 0; + for (auto &it : Accounts()) { + if (!ProtoServiceExists(it->szModuleName, PS_GETMYAVATAR)) + continue; - ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE); - ListView_Arrange(hwndList, LVA_ALIGNLEFT | LVA_ALIGNTOP); + if (!Proto_IsAvatarsEnabled(it->szModuleName)) + continue; - // Check if should show per protocol avatars - CheckDlgButton(hwndDlg, IDC_PER_PROTO, g_plugin.getByte("PerProtocolUserAvatars", 1) ? BST_CHECKED : BST_UNCHECKED); - EnableDisableProtocols(hwndDlg, TRUE); + ImageList_AddIcon(hIml, Skin_LoadProtoIcon(it->szModuleName, ID_STATUS_ONLINE)); + item.pszText = it->tszAccountName; + item.iImage = num; + item.lParam = (LPARAM)it->szModuleName; + protocols.InsertItem(&item); + num++; } - break; - case WM_NOTIFY: - { - LPNMHDR nm = (LPNMHDR)lParam; - switch (nm->idFrom) { - case IDC_PROTOCOLS: - switch (nm->code) { - case LVN_ITEMCHANGED: - LPNMLISTVIEW li = (LPNMLISTVIEW)nm; - if (li->uNewState & LVIS_SELECTED) { - SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, li->lParam); - EnableDisableControls(hwndDlg, (char*)li->lParam); - } - } - break; + protocols.SetColumnWidth(0, LVSCW_AUTOSIZE); + protocols.Arrange(LVA_ALIGNLEFT | LVA_ALIGNTOP); - case IDC_PROTOPIC: - if (nm->code == NM_AVATAR_CHANGED) { - EnableDisableControls(hwndDlg, GetSelectedProtocol(hwndDlg)); - break; - } - } + // Check if should show per protocol avatars + CheckDlgButton(m_hwnd, IDC_PER_PROTO, g_plugin.getByte("PerProtocolUserAvatars", 1) ? BST_CHECKED : BST_UNCHECKED); + EnableDisableProtocols(m_hwnd, TRUE); + return true; + } + + void onItemChanged_List(CCtrlListView::TEventInfo *ev) + { + LPNMLISTVIEW li = ev->nmlv; + if (li->uNewState & LVIS_SELECTED) { + SendDlgItemMessage(m_hwnd, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, li->lParam); + EnableDisableControls(m_hwnd, (char*)li->lParam); } - break; + } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_CHANGE: - if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO)) - SetMyAvatar(NULL, NULL); - else { - char *proto = GetSelectedProtocol(hwndDlg); - if (proto != nullptr) - SetMyAvatar((WPARAM)proto, NULL); - } - break; + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override + { + if (msg == WM_NOTIFY) { + LPNMHDR hdr = (LPNMHDR)lParam; + if (hdr->idFrom == IDC_PROTOPIC && hdr->code == NM_AVATAR_CHANGED) + EnableDisableControls(m_hwnd, GetSelectedProtocol(m_hwnd)); + } + return CDlgBase::DlgProc(msg, wParam, lParam); + } - case IDC_DELETE: - if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO)) { - if (MessageBox(hwndDlg, TranslateT("Are you sure you want to remove your avatar?"), TranslateT("Global avatar"), MB_YESNO) == IDYES) - SetMyAvatar(NULL, (LPARAM)L""); - } - else { - char *proto = GetSelectedProtocol(hwndDlg); - if (proto == nullptr) - break; + void onClick_Change(CCtrlButton *) + { + if (BST_UNCHECKED == IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO)) + SetMyAvatar(NULL, NULL); + else { + char *proto = GetSelectedProtocol(m_hwnd); + if (proto != nullptr) + SetMyAvatar((WPARAM)proto, NULL); + } + } + void onClick_Delete(CCtrlButton *) + { + if (BST_UNCHECKED == IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO)) { + if (MessageBox(m_hwnd, TranslateT("Are you sure you want to remove your avatar?"), TranslateT("Global avatar"), MB_YESNO) == IDYES) + SetMyAvatar(NULL, (LPARAM)L""); + } + else { + if (char *proto = GetSelectedProtocol(m_hwnd)) { char description[256]; CallProtoService(proto, PS_GETNAME, _countof(description), (LPARAM)description); wchar_t *descr = mir_a2u(description); - if (MessageBox(hwndDlg, TranslateT("Are you sure you want to remove your avatar?"), descr, MB_YESNO) == IDYES) + if (MessageBox(m_hwnd, TranslateT("Are you sure you want to remove your avatar?"), descr, MB_YESNO) == IDYES) SetMyAvatar((WPARAM)proto, (LPARAM)L""); mir_free(descr); } - break; - - case IDC_PER_PROTO: - g_plugin.setByte("PerProtocolUserAvatars", IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO) ? 1 : 0); - EnableDisableProtocols(hwndDlg, FALSE); - break; } - break; } - return FALSE; -} + + void onChange_PerProto(CCtrlCheck*) + { + g_plugin.setByte("PerProtocolUserAvatars", IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO) ? 1 : 0); + EnableDisableProtocols(m_hwnd, FALSE); + } +}; int OnDetailsInit(WPARAM wParam, LPARAM hContact) { - OPTIONSDIALOGPAGE odp = {}; - odp.szTitle.a = LPGEN("Avatar"); + USERINFOPAGE uip = {}; + uip.szTitle.a = LPGEN("Avatar"); if (hContact == NULL) { // User dialog - odp.pfnDlgProc = DlgProcAvatarProtoInfo; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO_AVATARS); - g_plugin.addUserInfo(wParam, &odp); + uip.pDialog = new AvatarProtoInfoDlg(); + g_plugin.addUserInfo(wParam, &uip); } else { char *szProto = Proto_GetBaseAccountName(hContact); if (szProto == nullptr || g_plugin.getByte(szProto, 1)) { // Contact dialog - odp.pfnDlgProc = DlgProcAvatarUserInfo; - odp.position = -2000000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_USER_AVATAR); - g_plugin.addUserInfo(wParam, &odp); + uip.position = -2000000000; + uip.pDialog = new AvatarUserInfoDlg(); + g_plugin.addUserInfo(wParam, &uip); } } return 0; diff --git a/plugins/BuddyExpectator/src/options.cpp b/plugins/BuddyExpectator/src/options.cpp index 06e1e9560a..07bcdc9562 100644 --- a/plugins/BuddyExpectator/src/options.cpp +++ b/plugins/BuddyExpectator/src/options.cpp @@ -439,88 +439,66 @@ int OptionsInit(WPARAM wParam, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
// UserInfo initalization
-INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+struct UserinfoDlg : public CUserInfoPageDlg
{
- switch (msg) {
- case WM_INITDIALOG:
+ UserinfoDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_USERINFO)
+ {}
+
+ bool OnInitDialog() override
{
time_t tmpTime;
wchar_t tmpBuf[51] = { 0 };
- tmpTime = getLastSeen((MCONTACT)lparam);
+ tmpTime = getLastSeen(m_hContact);
if (tmpTime == -1)
- SetDlgItemText(hdlg, IDC_EDIT_LASTSEEN, TranslateT("not detected"));
+ SetDlgItemTextW(m_hwnd, IDC_EDIT_LASTSEEN, TranslateT("not detected"));
else {
wcsftime(tmpBuf, 50, L"%#x, %#X", gmtime(&tmpTime));
- SetDlgItemText(hdlg, IDC_EDIT_LASTSEEN, tmpBuf);
+ SetDlgItemTextW(m_hwnd, IDC_EDIT_LASTSEEN, tmpBuf);
}
- tmpTime = getLastInputMsg((MCONTACT)lparam);
+ tmpTime = getLastInputMsg(m_hContact);
if (tmpTime == -1)
- SetDlgItemText(hdlg, IDC_EDIT_LASTINPUT, TranslateT("not found"));
+ SetDlgItemTextW(m_hwnd, IDC_EDIT_LASTINPUT, TranslateT("not found"));
else {
wcsftime(tmpBuf, 50, L"%#x, %#X", gmtime(&tmpTime));
- SetDlgItemText(hdlg, IDC_EDIT_LASTINPUT, tmpBuf);
+ SetDlgItemTextW(m_hwnd, IDC_EDIT_LASTINPUT, tmpBuf);
}
- unsigned int AbsencePeriod = g_plugin.getDword(lparam, "iAbsencePeriod", options.iAbsencePeriod);
+ unsigned int AbsencePeriod = g_plugin.getDword(m_hContact, "iAbsencePeriod", options.iAbsencePeriod);
- SendDlgItemMessage(hdlg, IDC_SPINABSENCE, UDM_SETRANGE, 0, MAKELONG(999, 1));
- SetDlgItemInt(hdlg, IDC_EDITABSENCE, AbsencePeriod, FALSE);
+ SendDlgItemMessage(m_hwnd, IDC_SPINABSENCE, UDM_SETRANGE, 0, MAKELONG(999, 1));
+ SetDlgItemInt(m_hwnd, IDC_EDITABSENCE, AbsencePeriod, FALSE);
- if (isContactGoneFor((MCONTACT)lparam, options.iAbsencePeriod2))
- SetDlgItemText(hdlg, IDC_EDIT_WILLNOTICE, TranslateT("This contact has been absent for an extended period of time."));
+ if (isContactGoneFor(m_hContact, options.iAbsencePeriod2))
+ SetDlgItemText(m_hwnd, IDC_EDIT_WILLNOTICE, TranslateT("This contact has been absent for an extended period of time."));
else
- SetDlgItemText(hdlg, IDC_EDIT_WILLNOTICE, L"");
+ SetDlgItemText(m_hwnd, IDC_EDIT_WILLNOTICE, L"");
- CheckDlgButton(hdlg, IDC_CHECK_MISSYOU, g_plugin.getByte(lparam, "MissYou") ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_NOTIFYALWAYS, g_plugin.getByte(lparam, "MissYouNotifyAlways") ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_NEVERHIDE, g_plugin.getByte(lparam, "NeverHide") ? BST_CHECKED : BST_UNCHECKED);
-
- TranslateDialogDefault(hdlg);
- return TRUE;
+ CheckDlgButton(m_hwnd, IDC_CHECK_MISSYOU, g_plugin.getByte(m_hContact, "MissYou") ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_CHECK_NOTIFYALWAYS, g_plugin.getByte(m_hContact, "MissYouNotifyAlways") ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_CHECK_NEVERHIDE, g_plugin.getByte(m_hContact, "NeverHide") ? BST_CHECKED : BST_UNCHECKED);
+ return true;
}
- case WM_NOTIFY:
- switch (((LPNMHDR)lparam)->idFrom)
- {
- case 0:
- switch (((LPNMHDR)lparam)->code)
- {
- case (PSN_APPLY) :
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lparam)->lParam;
- if (hContact)
- {
- g_plugin.setDword(hContact, "iAbsencePeriod", GetDlgItemInt(hdlg, IDC_EDITABSENCE, nullptr, FALSE));
- g_plugin.setByte(hContact, "MissYou", (IsDlgButtonChecked(hdlg, IDC_CHECK_MISSYOU) == BST_CHECKED) ? 1 : 0);
- g_plugin.setByte(hContact, "MissYouNotifyAlways", (IsDlgButtonChecked(hdlg, IDC_CHECK_NOTIFYALWAYS) == BST_CHECKED) ? 1 : 0);
- g_plugin.setByte(hContact, "NeverHide", (IsDlgButtonChecked(hdlg, IDC_CHECK_NEVERHIDE) == BST_CHECKED) ? 1 : 0);
- }
- break;
- }
- }
- break;
+ bool OnApply() override
+ {
+ if (m_hContact) {
+ g_plugin.setDword(m_hContact, "iAbsencePeriod", GetDlgItemInt(m_hwnd, IDC_EDITABSENCE, nullptr, FALSE));
+ g_plugin.setByte(m_hContact, "MissYou", (IsDlgButtonChecked(m_hwnd, IDC_CHECK_MISSYOU) == BST_CHECKED) ? 1 : 0);
+ g_plugin.setByte(m_hContact, "MissYouNotifyAlways", (IsDlgButtonChecked(m_hwnd, IDC_CHECK_NOTIFYALWAYS) == BST_CHECKED) ? 1 : 0);
+ g_plugin.setByte(m_hContact, "NeverHide", (IsDlgButtonChecked(m_hwnd, IDC_CHECK_NEVERHIDE) == BST_CHECKED) ? 1 : 0);
}
- break;
-
- case WM_COMMAND:
- if (wparam == MAKEWPARAM(IDC_EDITABSENCE, EN_CHANGE))
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- else if (LOWORD(wparam) == IDCANCEL)
- SendMessage(GetParent(hdlg), msg, wparam, lparam);
- break;
+ return true;
}
+};
- return FALSE;
-}
-
-int UserinfoInit(WPARAM wparam, LPARAM lparam)
+int UserinfoInit(WPARAM wparam, LPARAM hContact)
{
- if (lparam > 0) {
- OPTIONSDIALOGPAGE uip = { sizeof(uip) };
- uip.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
+ if (hContact > 0) {
+ USERINFOPAGE uip = {};
uip.szTitle.a = LPGEN("Buddy Expectator");
- uip.pfnDlgProc = UserinfoDlgProc;
+ uip.pDialog = new UserinfoDlg();
g_plugin.addUserInfo(wparam, &uip);
}
return 0;
diff --git a/plugins/ExternalAPI/m_userinfoex.h b/plugins/ExternalAPI/m_userinfoex.h index 1e263085c5..973c06f3c2 100644 --- a/plugins/ExternalAPI/m_userinfoex.h +++ b/plugins/ExternalAPI/m_userinfoex.h @@ -44,7 +44,6 @@ called this message. Because UserinfoEx now looks for changes in the settings of shown inforamtion up to date.
*/
#define PSP_CHANGED 2
-#define PSN_ICONCHANGED 2000
/* PSM_GETBOLDFONT v0.1.0.3+
wParam=NULL
diff --git a/plugins/FavContacts/src/stdafx.h b/plugins/FavContacts/src/stdafx.h index afe031f56b..ace1a328cf 100644 --- a/plugins/FavContacts/src/stdafx.h +++ b/plugins/FavContacts/src/stdafx.h @@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_protosvc.h>
#include <m_skin.h>
#include <m_contacts.h>
-#include <m_userinfo.h>
+#include <m_options.h>
#include <m_message.h>
#include <m_icolib.h>
#include <m_avatars.h>
diff --git a/plugins/FingerprintNG/src/stdafx.h b/plugins/FingerprintNG/src/stdafx.h index f2a48ade19..6a62fb57e8 100644 --- a/plugins/FingerprintNG/src/stdafx.h +++ b/plugins/FingerprintNG/src/stdafx.h @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_database.h>
#include <m_langpack.h>
#include <m_icolib.h>
+#include <m_options.h>
#include <m_protocols.h>
#include <m_userinfo.h>
#include <m_extraicons.h>
diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h index 15d5636943..d312715361 100644 --- a/plugins/HTTPServer/src/Glob.h +++ b/plugins/HTTPServer/src/Glob.h @@ -31,7 +31,7 @@ using namespace std; #include <m_database.h>
#include <m_clistint.h>
#include <m_langpack.h>
-#include <m_userinfo.h>
+#include <m_options.h>
#include <m_netlib.h>
#include <m_message.h>
#include <m_popup.h>
diff --git a/plugins/NewXstatusNotify/src/indsnd.cpp b/plugins/NewXstatusNotify/src/indsnd.cpp index 2cbf75bd2d..d99edfa59a 100644 --- a/plugins/NewXstatusNotify/src/indsnd.cpp +++ b/plugins/NewXstatusNotify/src/indsnd.cpp @@ -21,44 +21,7 @@ #include "stdafx.h"
-void PreviewSound(HWND hList)
-{
- wchar_t buff[MAX_PATH], stzSoundPath[MAX_PATH];
-
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- lvi.iItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
- ListView_GetItem(hList, &lvi);
-
- int hlpStatus = lvi.lParam;
-
- ListView_GetItemText(hList, lvi.iItem, 1, buff, _countof(buff));
- if (!mir_wstrcmp(buff, TranslateW(DEFAULT_SOUND))) {
- if (hlpStatus < ID_STATUS_MIN)
- Skin_PlaySound(StatusListEx[hlpStatus].lpzSkinSoundName);
- else
- Skin_PlaySound(StatusList[Index(hlpStatus)].lpzSkinSoundName);
- }
- else {
- PathToAbsoluteW(buff, stzSoundPath);
- Skin_PlaySoundFile(stzSoundPath);
- }
-}
-
-BOOL RemoveSoundFromList(HWND hList)
-{
- int iSel = ListView_GetSelectionMark(hList);
- if (iSel != -1) {
- iSel = -1;
- while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1)
- ListView_SetItemText(hList, iSel, 1, TranslateW(DEFAULT_SOUND));
- return TRUE;
- }
-
- return FALSE;
-}
-
-wchar_t *SelectSound(HWND hwndDlg, wchar_t *buff, size_t bufflen)
+wchar_t* SelectSound(HWND hwndDlg, wchar_t *buff, size_t bufflen)
{
OPENFILENAME ofn = { 0 };
@@ -102,186 +65,6 @@ HIMAGELIST GetStatusIconsImgList(char *szProto) return hList;
}
-INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static MCONTACT hContact = NULL;
- HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- hContact = lParam;
- char *szProto = Proto_GetBaseAccountName(hContact);
-
- ListView_SetImageList(hList, GetStatusIconsImgList(szProto), LVSIL_SMALL);
- ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
-
- RECT rc = { 0 };
- GetClientRect(hList, &rc);
-
- LV_COLUMN lvc = { 0 };
- lvc.mask = LVCF_WIDTH | LVCF_TEXT;
- lvc.cx = STATUS_COLUMN;
- lvc.pszText = TranslateT("Status");
- ListView_InsertColumn(hList, 0, &lvc);
-
- lvc.cx = rc.right - STATUS_COLUMN - GetSystemMetrics(SM_CXVSCROLL);
- lvc.pszText = TranslateT("Sound file");
- ListView_InsertColumn(hList, 1, &lvc);
-
- if (szProto) {
- DBVARIANT dbv;
- wchar_t buff[MAX_PATH];
-
- for (int i = ID_STATUS_MAX; i >= ID_STATUS_MIN; i--) {
- int flags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0);
- if (flags == 0)
- flags = PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT;
-
- if ((flags & Proto_Status2Flag(i)) || i == ID_STATUS_OFFLINE) {
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- lvi.iItem = 0;
- lvi.iSubItem = 0;
- lvi.iImage = Index(i);
- lvi.lParam = (LPARAM)i;
- lvi.pszText = TranslateW(StatusList[Index(i)].lpzSkinSoundDesc);
- lvi.iItem = ListView_InsertItem(hList, &lvi);
-
- if (!g_plugin.getWString(hContact, StatusList[Index(i)].lpzSkinSoundName, &dbv)) {
- mir_wstrcpy(buff, dbv.pwszVal);
- db_free(&dbv);
- }
- else mir_wstrcpy(buff, TranslateW(DEFAULT_SOUND));
-
- ListView_SetItemText(hList, lvi.iItem, 1, buff);
- }
- }
-
- for (int i = 0; i <= ID_STATUSEX_MAX; i++) {
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- lvi.iItem = 0;
- lvi.iSubItem = 0;
- lvi.iImage = Index(ID_STATUS_MAX) + 1; // additional icon
- lvi.lParam = (LPARAM)i;
- lvi.pszText = TranslateW(StatusListEx[i].lpzSkinSoundDesc);
- lvi.iItem = ListView_InsertItem(hList, &lvi);
-
- if (!g_plugin.getWString(hContact, StatusList[i].lpzSkinSoundName, &dbv)) {
- wcsncpy(buff, dbv.pwszVal, _countof(buff)-1);
- db_free(&dbv);
- }
- else wcsncpy(buff, TranslateW(DEFAULT_SOUND), _countof(buff)-1);
-
- ListView_SetItemText(hList, lvi.iItem, 1, buff);
- }
- }
-
- CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYSOUNDS, g_plugin.getByte(hContact, "EnableSounds", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYPOPUPS, g_plugin.getByte(hContact, "EnablePopups", 1) ? BST_CHECKED : BST_UNCHECKED);
-
- ShowWindow(GetDlgItem(hwndDlg, IDC_INDSNDLIST), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TEXT_ENABLE_IS), opt.UseIndSnd ? SW_HIDE : SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHANGE), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_DELETE), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_PREVIEW:
- if (ListView_GetSelectionMark(hList) != -1)
- PreviewSound(hList);
- break;
- case IDC_CHANGE:
- {
- int iSel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_INDSNDLIST), -1, LVNI_SELECTED);
- if (iSel != -1) {
- wchar_t stzFilePath[MAX_PATH];
- if (SelectSound(hwndDlg, stzFilePath, MAX_PATH - 1) != nullptr) {
- iSel = -1;
- while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1)
- ListView_SetItemText(hList, iSel, 1, stzFilePath);
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- }
- break;
- case IDC_DELETE:
- if (ListView_GetSelectionMark(hList) != -1)
- if (RemoveSoundFromList(GetDlgItem(hwndDlg, IDC_INDSNDLIST)))
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_CHECK_NOTIFYSOUNDS:
- g_plugin.setByte(hContact, "EnableSounds", IsDlgButtonChecked(hwndDlg, IDC_CHECK_NOTIFYSOUNDS) ? 1 : 0);
- break;
- case IDC_CHECK_NOTIFYPOPUPS:
- g_plugin.setByte(hContact, "EnablePopups", IsDlgButtonChecked(hwndDlg, IDC_CHECK_NOTIFYPOPUPS) ? 1 : 0);
- break;
- }
- break;
-
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- wchar_t buff[MAX_PATH];
-
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- //Cycle through the list reading the text associated to each status.
- for (lvi.iItem = ListView_GetItemCount(hList) - 1; lvi.iItem >= 0; lvi.iItem--) {
- ListView_GetItem(hList, &lvi);
- ListView_GetItemText(hList, lvi.iItem, 1, buff, _countof(buff));
-
- if (!mir_wstrcmp(buff, TranslateW(DEFAULT_SOUND))) {
- if (lvi.lParam < ID_STATUS_MIN)
- g_plugin.delSetting(hContact, StatusListEx[lvi.lParam].lpzSkinSoundName);
- else
- g_plugin.delSetting(hContact, StatusList[Index(lvi.lParam)].lpzSkinSoundName);
- }
- else {
- wchar_t stzSoundPath[MAX_PATH] = { 0 };
- PathToRelativeW(buff, stzSoundPath);
- if (lvi.lParam < ID_STATUS_MIN)
- g_plugin.setWString(hContact, StatusListEx[lvi.lParam].lpzSkinSoundName, stzSoundPath);
- else
- g_plugin.setWString(hContact, StatusList[Index(lvi.lParam)].lpzSkinSoundName, stzSoundPath);
- }
- }
-
- return TRUE;
- }
-
- int hlpControlID = (int)wParam;
- switch (hlpControlID) {
- case IDC_INDSNDLIST:
- if (((LPNMHDR)lParam)->code == NM_DBLCLK) {
- wchar_t stzFilePath[MAX_PATH];
- if (SelectSound(hwndDlg, stzFilePath, MAX_PATH - 1) != nullptr) {
- int iSel = -1;
- while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1)
- ListView_SetItemText(hList, iSel, 1, stzFilePath);
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- return TRUE;
- }
- else if (((LPNMHDR)lParam)->code == LVN_KEYDOWN) {
- LPNMLVKEYDOWN pnkd = (LPNMLVKEYDOWN)lParam;
- if (pnkd->wVKey == VK_DELETE)
- RemoveSoundFromList(GetDlgItem(hwndDlg, IDC_INDSNDLIST));
- }
-
- break;
- }
- break;
- }
- return FALSE;
-}
-
void ResetListOptions(HWND hwndList)
{
SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE) | CLS_SHOWHIDDEN);
@@ -592,15 +375,240 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) return FALSE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// User info dialog
+
+class SoundUIPageDlg : public CUserInfoPageDlg
+{
+ CCtrlCheck chkSounds, chkPopups;
+ CCtrlButton btnPreview, btnChange, btnDelete;
+ CCtrlListView m_list;
+
+ void PreviewSound()
+ {
+ LVITEM lvi = { 0 };
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = m_list.GetNextItem(-1, LVNI_SELECTED);
+ m_list.GetItem(&lvi);
+
+ int hlpStatus = lvi.lParam;
+
+ wchar_t buff[MAX_PATH], stzSoundPath[MAX_PATH];
+ m_list.GetItemText(lvi.iItem, 1, buff, _countof(buff));
+ if (!mir_wstrcmp(buff, TranslateW(DEFAULT_SOUND))) {
+ if (hlpStatus < ID_STATUS_MIN)
+ Skin_PlaySound(StatusListEx[hlpStatus].lpzSkinSoundName);
+ else
+ Skin_PlaySound(StatusList[Index(hlpStatus)].lpzSkinSoundName);
+ }
+ else {
+ PathToAbsoluteW(buff, stzSoundPath);
+ Skin_PlaySoundFile(stzSoundPath);
+ }
+ }
+
+ BOOL RemoveSoundFromList()
+ {
+ int iSel = m_list.GetSelectionMark();
+ if (iSel != -1) {
+ iSel = -1;
+ while ((iSel = m_list.GetNextItem(iSel, LVNI_SELECTED)) != -1)
+ m_list.SetItemText(iSel, 1, TranslateW(DEFAULT_SOUND));
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+public:
+ SoundUIPageDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_SOUNDS),
+ m_list(this, IDC_INDSNDLIST),
+ chkPopups(this, IDC_CHECK_NOTIFYPOPUPS),
+ chkSounds(this, IDC_CHECK_NOTIFYSOUNDS),
+ btnChange(this, IDC_CHANGE),
+ btnDelete(this, IDC_DELETE),
+ btnPreview(this, IDC_PREVIEW)
+ {
+ m_list.OnDoubleClick = Callback(this, &SoundUIPageDlg::onDblClick_List);
+
+ chkPopups.OnChange = Callback(this, &SoundUIPageDlg::onChange_Popups);
+ chkSounds.OnChange = Callback(this, &SoundUIPageDlg::onChange_Sounds);
+
+ btnChange.OnClick = Callback(this, &SoundUIPageDlg::onClick_Change);
+ btnDelete.OnClick = Callback(this, &SoundUIPageDlg::onClick_Delete);
+ btnPreview.OnClick = Callback(this, &SoundUIPageDlg::onClick_Preview);
+ }
+
+ bool OnInitDialog() override
+ {
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+
+ m_list.SetImageList(GetStatusIconsImgList(szProto), LVSIL_SMALL);
+ m_list.SetExtendedListViewStyleEx(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+
+ RECT rc = { 0 };
+ GetClientRect(m_list.GetHwnd(), &rc);
+
+ LV_COLUMN lvc = { 0 };
+ lvc.mask = LVCF_WIDTH | LVCF_TEXT;
+ lvc.cx = STATUS_COLUMN;
+ lvc.pszText = TranslateT("Status");
+ m_list.InsertColumn(0, &lvc);
+
+ lvc.cx = rc.right - STATUS_COLUMN - GetSystemMetrics(SM_CXVSCROLL);
+ lvc.pszText = TranslateT("Sound file");
+ m_list.InsertColumn(1, &lvc);
+
+ if (szProto) {
+ DBVARIANT dbv;
+ wchar_t buff[MAX_PATH];
+
+ for (int i = ID_STATUS_MAX; i >= ID_STATUS_MIN; i--) {
+ int flags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0);
+ if (flags == 0)
+ flags = PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT;
+
+ if ((flags & Proto_Status2Flag(i)) || i == ID_STATUS_OFFLINE) {
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ lvi.iItem = 0;
+ lvi.iSubItem = 0;
+ lvi.iImage = Index(i);
+ lvi.lParam = (LPARAM)i;
+ lvi.pszText = TranslateW(StatusList[Index(i)].lpzSkinSoundDesc);
+ lvi.iItem = m_list.InsertItem(&lvi);
+
+ if (!g_plugin.getWString(m_hContact, StatusList[Index(i)].lpzSkinSoundName, &dbv)) {
+ mir_wstrcpy(buff, dbv.pwszVal);
+ db_free(&dbv);
+ }
+ else mir_wstrcpy(buff, TranslateW(DEFAULT_SOUND));
+
+ m_list.SetItemText(lvi.iItem, 1, buff);
+ }
+ }
+
+ for (int i = 0; i <= ID_STATUSEX_MAX; i++) {
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ lvi.iItem = 0;
+ lvi.iSubItem = 0;
+ lvi.iImage = Index(ID_STATUS_MAX) + 1; // additional icon
+ lvi.lParam = (LPARAM)i;
+ lvi.pszText = TranslateW(StatusListEx[i].lpzSkinSoundDesc);
+ lvi.iItem = m_list.InsertItem(&lvi);
+
+ if (!g_plugin.getWString(m_hContact, StatusList[i].lpzSkinSoundName, &dbv)) {
+ wcsncpy(buff, dbv.pwszVal, _countof(buff) - 1);
+ db_free(&dbv);
+ }
+ else wcsncpy(buff, TranslateW(DEFAULT_SOUND), _countof(buff) - 1);
+
+ m_list.SetItemText(lvi.iItem, 1, buff);
+ }
+ }
+
+ chkSounds.SetState(g_plugin.getByte(m_hContact, "EnableSounds", 1));
+ chkPopups.SetState(g_plugin.getByte(m_hContact, "EnablePopups", 1));
+
+ ShowWindow(GetDlgItem(m_hwnd, IDC_INDSNDLIST), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_TEXT_ENABLE_IS), opt.UseIndSnd ? SW_HIDE : SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_CHANGE), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_PREVIEW), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_DELETE), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ wchar_t buff[MAX_PATH];
+
+ LVITEM lvi = { 0 };
+ lvi.mask = LVIF_PARAM;
+ //Cycle through the list reading the text associated to each status.
+ for (lvi.iItem = m_list.GetItemCount() - 1; lvi.iItem >= 0; lvi.iItem--) {
+ m_list.GetItem(&lvi);
+ m_list.GetItemText(lvi.iItem, 1, buff, _countof(buff));
+
+ if (!mir_wstrcmp(buff, TranslateW(DEFAULT_SOUND))) {
+ if (lvi.lParam < ID_STATUS_MIN)
+ g_plugin.delSetting(m_hContact, StatusListEx[lvi.lParam].lpzSkinSoundName);
+ else
+ g_plugin.delSetting(m_hContact, StatusList[Index(lvi.lParam)].lpzSkinSoundName);
+ }
+ else {
+ wchar_t stzSoundPath[MAX_PATH] = { 0 };
+ PathToRelativeW(buff, stzSoundPath);
+ if (lvi.lParam < ID_STATUS_MIN)
+ g_plugin.setWString(m_hContact, StatusListEx[lvi.lParam].lpzSkinSoundName, stzSoundPath);
+ else
+ g_plugin.setWString(m_hContact, StatusList[Index(lvi.lParam)].lpzSkinSoundName, stzSoundPath);
+ }
+ }
+
+ return true;
+ }
+
+ void onClick_Preview(CCtrlButton*)
+ {
+ if (m_list.GetSelectionMark() != -1)
+ PreviewSound();
+ }
+
+ void onClick_Change(CCtrlButton*)
+ {
+ int iSel = m_list.GetNextItem(-1, LVNI_SELECTED);
+ if (iSel != -1) {
+ wchar_t stzFilePath[MAX_PATH];
+ if (SelectSound(m_hwnd, stzFilePath, MAX_PATH - 1) != nullptr) {
+ iSel = -1;
+ while ((iSel = m_list.GetNextItem(iSel, LVNI_SELECTED)) != -1)
+ m_list.SetItemText(iSel, 1, stzFilePath);
+
+ NotifyChange();
+ }
+ }
+ }
+
+ void onClick_Delete(CCtrlButton*)
+ {
+ if (m_list.GetSelectionMark() != -1)
+ if (RemoveSoundFromList())
+ NotifyChange();
+ }
+
+ void onChange_Popups(CCtrlCheck*)
+ {
+ g_plugin.setByte(m_hContact, "EnableSounds", chkPopups.GetState());
+ }
+
+ void onChange_Sounds(CCtrlCheck*)
+ {
+ g_plugin.setByte(m_hContact, "EnablePopups", chkSounds.GetState());
+ }
+
+ void onDblClick_List(CCtrlListView::TEventInfo*)
+ {
+ wchar_t stzFilePath[MAX_PATH];
+ if (SelectSound(m_hwnd, stzFilePath, MAX_PATH - 1) != nullptr) {
+ int iSel = -1;
+ while ((iSel = m_list.GetNextItem(iSel, LVNI_SELECTED)) != -1)
+ m_list.SetItemText(iSel, 1, stzFilePath);
+
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
+ }
+ }
+};
+
int UserInfoInitialise(WPARAM wParam, LPARAM lParam)
{
if (lParam) {
- OPTIONSDIALOGPAGE odp = {};
- odp.position = 100000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SOUNDS);
- odp.szTitle.a = LPGEN("Status Notify");
- odp.pfnDlgProc = DlgProcSoundUIPage;
- g_plugin.addUserInfo(wParam, &odp);
+ USERINFOPAGE uip = {};
+ uip.position = 100000000;
+ uip.szTitle.a = LPGEN("Status Notify");
+ uip.pDialog = new SoundUIPageDlg();
+ g_plugin.addUserInfo(wParam, &uip);
}
return 0;
}
diff --git a/plugins/QuickContacts/src/stdafx.h b/plugins/QuickContacts/src/stdafx.h index 3f40173ac1..1d5b42e5f5 100644 --- a/plugins/QuickContacts/src/stdafx.h +++ b/plugins/QuickContacts/src/stdafx.h @@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. #include <m_protosvc.h>
#include <m_clist.h>
#include <m_message.h>
+#include <m_options.h>
#include <m_userinfo.h>
#include <m_genmenu.h>
#include <m_skin.h>
diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 1f72d10d64..778229d2ca 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_protosvc.h>
#include <m_skin.h>
#include <m_contacts.h>
+#include <m_options.h>
#include <m_userinfo.h>
#include <m_history.h>
#include <m_message.h>
diff --git a/plugins/SeenPlugin/src/stdafx.h b/plugins/SeenPlugin/src/stdafx.h index c636358661..9172cce71d 100644 --- a/plugins/SeenPlugin/src/stdafx.h +++ b/plugins/SeenPlugin/src/stdafx.h @@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_skin.h>
#include <m_userinfo.h>
#include <m_icolib.h>
+#include <m_options.h>
#include <m_clistint.h>
#include <m_contacts.h>
#include <m_message.h>
diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp index 2f2966d25a..1a323a5e11 100644 --- a/plugins/SeenPlugin/src/userinfo.cpp +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+static LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg) {
case WM_SETCURSOR:
@@ -30,47 +30,43 @@ LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) return mir_callNextSubclass(hdlg, EditProc, msg, wparam, lparam);
}
-INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+struct UserinfoDlg : public CUserInfoPageDlg
{
- switch (msg) {
- case WM_INITDIALOG:
- mir_subclassWindow(GetDlgItem(hdlg, IDC_INFOTEXT), EditProc);
- WindowList_Add(g_pUserInfo, hdlg, lparam);
- SendMessage(hdlg, WM_REFRESH_UI, lparam, 0);
- break;
-
- case WM_REFRESH_UI:
- {
- ptrW szout(g_plugin.getWStringA("UserStamp"));
- CMStringW str = ParseString((szout != NULL) ? szout : DEFAULT_USERSTAMP, wparam);
- SetDlgItemText(hdlg, IDC_INFOTEXT, str);
+ UserinfoDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_USERINFO)
+ {}
- if (!mir_wstrcmp(str, TranslateT("<unknown>")))
- EnableWindow(GetDlgItem(hdlg, IDC_INFOTEXT), FALSE);
- }
- break;
+ bool OnInitDialog() override
+ {
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_INFOTEXT), EditProc);
+ WindowList_Add(g_pUserInfo, m_hwnd, m_hContact);
+ return true;
+ }
- case WM_COMMAND:
- if (HIWORD(wparam) == EN_SETFOCUS)
- SetFocus(GetParent(hdlg));
- break;
+ bool OnRefresh() override
+ {
+ ptrW szout(g_plugin.getWStringA("UserStamp"));
+ CMStringW str = ParseString((szout != NULL) ? szout : DEFAULT_USERSTAMP, m_hContact);
+ SetDlgItemText(m_hwnd, IDC_INFOTEXT, str);
- case WM_DESTROY:
- WindowList_Remove(g_pUserInfo, hdlg);
- break;
+ if (!mir_wstrcmp(str, TranslateT("<unknown>")))
+ EnableWindow(GetDlgItem(m_hwnd, IDC_INFOTEXT), FALSE);
+ return false;
}
- return 0;
-}
+ void OnDestroy() override
+ {
+ WindowList_Remove(g_pUserInfo, m_hwnd);
+ }
+};
int UserinfoInit(WPARAM wparam, LPARAM hContact)
{
char *szProto = Proto_GetBaseAccountName(hContact);
if (IsWatchedProtocol(szProto) && !db_get_b(hContact, szProto, "ChatRoom", false)) {
- OPTIONSDIALOGPAGE uip = { sizeof(uip) };
- uip.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
+ USERINFOPAGE uip = {};
uip.szTitle.a = LPGEN("Last seen");
- uip.pfnDlgProc = UserinfoDlgProc;
+ uip.pDialog = new UserinfoDlg();
g_plugin.addUserInfo(wparam, &uip);
}
return 0;
diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index 41f5fede3a..8c95d3a86c 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -70,6 +70,7 @@ #include <m_acc.h>
#include <m_chat_int.h>
#include <m_hotkeys.h>
+#include <m_options.h>
#include <m_genmenu.h>
#include <m_popup.h>
#include <m_timezones.h>
diff --git a/plugins/UserInfoEx/src/classMAnnivDate.cpp b/plugins/UserInfoEx/src/classMAnnivDate.cpp index b1c4a8f9ee..940ddcda6c 100644 --- a/plugins/UserInfoEx/src/classMAnnivDate.cpp +++ b/plugins/UserInfoEx/src/classMAnnivDate.cpp @@ -588,7 +588,7 @@ int MAnnivDate::DBGetAnniversaryDate(MCONTACT hContact, uint16_t iIndex) // read description
mir_snprintf(szStamp, "Anniv%dDesc", iIndex);
DBVARIANT dbv;
- if (!DB::Setting::GetTString(hContact, USERINFO, szStamp, &dbv)) {
+ if (!DB::Setting::GetWString(hContact, USERINFO, szStamp, &dbv)) {
_strDesc = dbv.pwszVal;
db_free(&dbv);
}
diff --git a/plugins/UserInfoEx/src/classPsTree.cpp b/plugins/UserInfoEx/src/classPsTree.cpp index f4b55fa027..ac023b5b83 100644 --- a/plugins/UserInfoEx/src/classPsTree.cpp +++ b/plugins/UserInfoEx/src/classPsTree.cpp @@ -115,12 +115,12 @@ int CPsTree::AddDummyItem(LPCSTR pszGroup) psh._pszProto = _pPs->pszProto; psh._hImages = _hImages; - OPTIONSDIALOGPAGE odp = {}; - odp.flags = ODPF_UNICODE; - odp.szTitle.w = mir_utf8decodeW(pszGroup); + USERINFOPAGE uip = {}; + uip.flags = ODPF_UNICODE; + uip.szTitle.w = mir_utf8decodeW(pszGroup); auto *p = new CPsTreeItem(); - p->Create(&psh, &odp); + p->Create(&psh, &uip); _pages.insert(p); return _pages.indexOf(&p); @@ -810,21 +810,17 @@ void CPsTree::OnIconsChanged() uint8_t CPsTree::OnInfoChanged() { - PSHNOTIFY pshn; uint8_t bChanged = 0; - pshn.hdr.idFrom = 0; - pshn.hdr.code = PSN_INFOCHANGED; for (auto &it : _pages) { - pshn.hdr.hwndFrom = it->Wnd(); - if (pshn.hdr.hwndFrom != nullptr) { - pshn.lParam = (LPARAM)it->hContact(); - SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn); - if (PSP_CHANGED == GetWindowLongPtr(pshn.hdr.hwndFrom, DWLP_MSGRESULT)) - bChanged |= 1; - else - it->RemoveFlags(PSPF_CHANGED); - } + if (it->Wnd() == nullptr) + continue; + + it->Dialog()->SetContact(it->hContact()); + if (it->Dialog()->OnRefresh()) + bChanged |= 1; + else + it->RemoveFlags(PSPF_CHANGED); } return bChanged; } diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index 12d3ceef79..914e80da31 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -44,18 +44,7 @@ BOOL CALLBACK BoldGroupTitlesEnumChildren(HWND hWnd, LPARAM lParam) * odp - optiondialogpage structure with the info about the item to add
* return: nothing
**/
-CPsTreeItem::CPsTreeItem() : _idDlg(NULL), _pTemplate(nullptr), _hInst(nullptr), _pfnDlgProc(nullptr), _hWnd(nullptr), _dwFlags(NULL),
- _hItem(nullptr), // handle to the treeview item
- _iParent(-1), // index to the parent item
- _iImage(-1), // index of treeview item's image
- _bState(NULL), // initial state of this treeitem
- _pszName(nullptr), // original name, given by plugin (not customized)
- _ptszLabel(nullptr),
- _pszProto(nullptr),
- _pszPrefix(nullptr),
- _hContact(NULL),
- _iPosition(0),
- _initParam(0)
+CPsTreeItem::CPsTreeItem()
{
}
@@ -245,7 +234,7 @@ int CPsTreeItem::ItemLabel(const uint8_t bReadDBValue) mir_free(_ptszLabel);
// try to get custom label from database
- if (!bReadDBValue || DB::Setting::GetTString(0, MODULENAME, GlobalPropertyKey(SET_ITEM_LABEL), &dbv) || (_ptszLabel = dbv.pwszVal) == nullptr) {
+ if (!bReadDBValue || DB::Setting::GetWString(0, MODULENAME, GlobalPropertyKey(SET_ITEM_LABEL), &dbv) || (_ptszLabel = dbv.pwszVal) == nullptr) {
// extract the name
LPSTR pszName = mir_strrchr(_pszName, '\\');
if (pszName && pszName[1])
@@ -294,14 +283,14 @@ HICON CPsTreeItem::ProtoIcon() * class: CPsTreeItem
* desc: load the icon, add to icolib if required and add to imagelist of treeview
* params: hIml - treeview's imagelist to add the icon to
- * odp - pointer to OPTIONSDIALOGPAGE providing the information about the icon to load
+ * odp - pointer to USERINFOPAGE providing the information about the icon to load
* hDefaultIcon - default icon to use
* return: nothing
**/
-int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIconsOnly)
+int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, uint8_t bInitIconsOnly)
{
// check parameter
- if (!_pszName || !odp)
+ if (!_pszName || !uip)
return 1;
// load the icon if no icolib is installed or creating the required settingname failed
@@ -320,16 +309,16 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIcon sid.section.w = pwszSection;
// the item to insert brings along an icon?
- if (odp->flags & ODPF_ICON) {
+ if (uip->flags & ODPF_ICON) {
// is it uinfoex item?
- if (odp->pPlugin == &g_plugin) {
+ if (uip->pPlugin == &g_plugin) {
// the pszGroup holds the iconfile for items added by uinfoex
- sid.defaultFile.w = odp->szGroup.w;
+ sid.defaultFile.w = uip->szGroup.w;
// icon library exists?
if (sid.defaultFile.w)
- sid.iDefaultIndex = odp->dwInitParam;
+ sid.iDefaultIndex = uip->dwInitParam;
// no valid icon library
else {
bNeedFree = true;
@@ -374,20 +363,20 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIcon * class: CPsTreeItem
* desc: inits the treeitem's attributes
* params: pPsh - pointer to the property page's header structure
- * odp - OPTIONSDIALOGPAGE structure with the information about the page to add
+ * odp - USERINFOPAGE structure with the information about the page to add
* return: 0 on success, 1 on failure
**/
-int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp)
+int CPsTreeItem::Create(CPsHdr* pPsh, USERINFOPAGE *uip)
{
int err;
wchar_t szTitle[ MAXSETTING ];
// check parameter
- if (pPsh && odp && PtrIsValid(odp->pPlugin)) {
+ if (pPsh && uip && PtrIsValid(uip->pPlugin)) {
// instance value
- _hInst = odp->pPlugin->getInst();
- _dwFlags = odp->flags;
- _initParam = odp->dwInitParam;
+ _hInst = uip->pPlugin->getInst();
+ _dwFlags = uip->flags;
+ _initParam = uip->dwInitParam;
// init page owning contact
_hContact = pPsh->_hContact;
@@ -398,15 +387,15 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) if (pPsh->_dwFlags & PSF_PROTOPAGESONLY) {
if (_dwFlags & ODPF_USERINFOTAB)
- mir_snwprintf(szTitle, L"%s %d\\%s", odp->szTitle.w, pPsh->_nSubContact+1, odp->szTab.w);
+ mir_snwprintf(szTitle, L"%s %d\\%s", uip->szTitle.w, pPsh->_nSubContact+1, uip->szGroup.w);
else
- mir_snwprintf(szTitle, L"%s %d", odp->szTitle.w, pPsh->_nSubContact+1);
+ mir_snwprintf(szTitle, L"%s %d", uip->szTitle.w, pPsh->_nSubContact+1);
}
else {
if (_dwFlags & ODPF_USERINFOTAB)
- mir_snwprintf(szTitle, L"%s\\%s", odp->szTitle.w, odp->szTab.w);
+ mir_snwprintf(szTitle, L"%s\\%s", uip->szTitle.w, uip->szGroup.w);
else
- mir_wstrcpy(szTitle, odp->szTitle.w);
+ mir_wstrcpy(szTitle, uip->szTitle.w);
}
// set the unique utf8 encoded name for the item
if (err = Name(szTitle, (_dwFlags & ODPF_UNICODE) == ODPF_UNICODE))
@@ -415,9 +404,10 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) // read label from database or create it
else if (err = ItemLabel(TRUE))
MsgErr(nullptr, LPGENW("Creating the label for a page failed with %d and error code %d"), err, GetLastError());
+
else {
// load icon for the item
- Icon(pPsh->_hImages, odp, (pPsh->_dwFlags & PSTVF_INITICONS) == PSTVF_INITICONS);
+ Icon(pPsh->_hImages, uip, (pPsh->_dwFlags & PSTVF_INITICONS) == PSTVF_INITICONS);
// the rest is not needed if only icons are loaded
if (pPsh->_dwFlags & PSTVF_INITICONS)
@@ -425,33 +415,16 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) // load custom order
if (!(pPsh->_dwFlags & PSTVF_SORTTREE)) {
- _iPosition = (int)g_plugin.getByte(PropertyKey(SET_ITEM_POS), odp->position);
+ _iPosition = g_plugin.getByte(PropertyKey(SET_ITEM_POS), uip->position);
if ((_iPosition < 0) || (_iPosition > 0x800000A))
_iPosition = 0;
}
// read visibility state
- _bState = g_plugin.getByte(PropertyKey(SET_ITEM_STATE), DBTVIS_EXPANDED);
+ _bState = g_plugin.getByte(PropertyKey(SET_ITEM_STATE), DBTVIS_EXPANDED);
- // error for no longer supported dialog template type
- if (((UINT_PTR)odp->pszTemplate & 0xFFFF0000))
- MsgErr(nullptr, LPGENW("The dialog template type is no longer supported"));
- else {
- // fetch dialog resource id
- _idDlg = (INT_PTR)odp->pszTemplate;
- // dialog procedure
- _pfnDlgProc = odp->pfnDlgProc;
-
- // is dummy item?
- if (!_idDlg && !_pfnDlgProc)
- return 0;
-
- if (_idDlg && _pfnDlgProc) {
- // lock the property pages dialog resource
- _pTemplate = (DLGTEMPLATE*)LockResource(LoadResource(_hInst, FindResource(_hInst, (LPCTSTR)(UINT_PTR)_idDlg, RT_DIALOG)));
- if (_pTemplate)
- return 0;
- }
- }
+ // fetch dialog
+ _pDialog = uip->pDialog;
+ return 0;
}
}
return 1;
@@ -501,20 +474,15 @@ uint16_t CPsTreeItem::DBSaveItemState(LPCSTR pszGroup, int iItemPosition, UINT i **/
HWND CPsTreeItem::CreateWnd(LPPS pPs)
{
- if (pPs && !_hWnd && _pTemplate && _pfnDlgProc) {
- _hWnd = CreateDialogIndirectParam(_hInst, _pTemplate, pPs->hDlg, _pfnDlgProc, (LPARAM)_hContact);
+ if (pPs && !_hWnd && _pDialog) {
+ _pDialog->SetParent(pPs->hDlg);
+ _pDialog->SetContact(_hContact);
+ _pDialog->Create();
+ _hWnd = _pDialog->GetHwnd();
if (_hWnd != nullptr) {
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_PARAMCHANGED;
- pshn.hdr.hwndFrom = _hWnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)_initParam;
- SendMessage(_hWnd, WM_NOTIFY, 0, (LPARAM)&pshn);
-
// force child window (mainly for AIM property page)
SetWindowLongPtr(_hWnd, GWL_STYLE, (GetWindowLongPtr(_hWnd, GWL_STYLE) & ~(WS_POPUP|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME)) | WS_CHILD);
SetWindowLongPtr(_hWnd, GWL_EXSTYLE, GetWindowLongPtr(_hWnd, GWL_EXSTYLE) & ~(WS_EX_APPWINDOW|WS_EX_STATICEDGE|WS_EX_CLIENTEDGE));
- SetParent(_hWnd, pPs->hDlg);
// move dialog into the display area
SetWindowPos(_hWnd, HWND_TOP,
@@ -547,15 +515,8 @@ HWND CPsTreeItem::CreateWnd(LPPS pPs) **/
void CPsTreeItem::OnInfoChanged()
{
- if (_hWnd) {
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_INFOCHANGED;
- pshn.hdr.hwndFrom = _hWnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)_hContact;
- if (PSP_CHANGED != SendMessage(_hWnd, WM_NOTIFY, 0, (LPARAM)&pshn))
- _dwFlags &= ~PSPF_CHANGED;
- }
+ if (_hWnd)
+ _pDialog->OnRefresh();
}
/**
@@ -567,13 +528,9 @@ void CPsTreeItem::OnInfoChanged() **/
void CPsTreeItem::OnPageIconsChanged()
{
- if (_hWnd) {
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_ICONCHANGED;
- pshn.hdr.hwndFrom = _hWnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)_hContact;
- SendMessage(_hWnd, WM_NOTIFY, 0, (LPARAM)&pshn);
+ if (_hWnd && _initParam) {
+ auto *pDlg = (PSPBaseDlg *)_pDialog;
+ pDlg->OnIconsChanged();
}
}
diff --git a/plugins/UserInfoEx/src/ctrl_combo.cpp b/plugins/UserInfoEx/src/ctrl_combo.cpp index 81d82220f0..512371116a 100644 --- a/plugins/UserInfoEx/src/ctrl_combo.cpp +++ b/plugins/UserInfoEx/src/ctrl_combo.cpp @@ -149,7 +149,7 @@ BOOL CCombo::OnInfoChanged(MCONTACT hContact, LPCSTR pszProto) int iVal = CB_ERR;
_Flags.B.hasCustom = _Flags.B.hasProto = _Flags.B.hasMeta = false;
- _Flags.W |= DB::Setting::GetTStringCtrl(hContact, USERINFO, USERINFO, pszProto, _pszSetting, &dbv);
+ _Flags.W |= DB::Setting::GetWStringCtrl(hContact, USERINFO, USERINFO, pszProto, _pszSetting, &dbv);
EnableWindow(_hwnd, !hContact || _Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0));
if (_Flags.B.hasCustom || _Flags.B.hasProto || _Flags.B.hasMeta) {
diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index 66c153a110..7ce07cdb30 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -1292,7 +1292,7 @@ int CtrlContactAddItemFromDB( cbi.pszVal = nullptr;
cbi.dwID = mir_hashstr(szSettingVal);
- cbi.wFlags = CBEXIF_CATREADONLY | DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv);
+ cbi.wFlags = CBEXIF_CATREADONLY | DB::Setting::GetWStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv);
if (dbv.type >= DBVT_WCHAR) {
// no value read from database
if (cbi.wFlags == CBEXIF_CATREADONLY)
@@ -1352,7 +1352,7 @@ int CtrlContactAddMyItemsFromDB( for (i = 0;
SUCCEEDED(mir_snprintf(pszSetting, szFormatVal, i)) &&
- (cbi.wFlags = DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, pszSetting, &dbv));
+ (cbi.wFlags = DB::Setting::GetWStringCtrl(hContact, pszModule, pszModule, pszProto, pszSetting, &dbv));
i++) {
// read value
cbi.dwID = mir_hashstr(pszSetting);
@@ -1363,12 +1363,12 @@ int CtrlContactAddMyItemsFromDB( // read category
if (SUCCEEDED(mir_snprintf(pszSetting, szFormatCat, i))) {
if (cbi.wFlags & CTRLF_HASCUSTOM) {
- if (DB::Setting::GetTString(hContact, pszModule, pszSetting, &dbv))
+ if (DB::Setting::GetWString(hContact, pszModule, pszSetting, &dbv))
dbv.type = DBVT_DELETED;
}
else
if (cbi.wFlags & CTRLF_HASPROTO) {
- if (DB::Setting::GetTString(hContact, pszProto, pszSetting, &dbv))
+ if (DB::Setting::GetWString(hContact, pszProto, pszSetting, &dbv))
dbv.type = DBVT_DELETED;
}
diff --git a/plugins/UserInfoEx/src/ctrl_edit.cpp b/plugins/UserInfoEx/src/ctrl_edit.cpp index fb3b5d9e83..99d8f22b75 100644 --- a/plugins/UserInfoEx/src/ctrl_edit.cpp +++ b/plugins/UserInfoEx/src/ctrl_edit.cpp @@ -111,7 +111,7 @@ BOOL CEditCtrl::OnInfoChanged(MCONTACT hContact, LPCSTR pszProto) wchar_t szText[64]; _Flags.B.hasCustom = _Flags.B.hasProto = _Flags.B.hasMeta = false; - _Flags.W |= DB::Setting::GetTStringCtrl(hContact, _pszModule, _pszModule, pszProto, _pszSetting, &dbv); + _Flags.W |= DB::Setting::GetWStringCtrl(hContact, _pszModule, _pszModule, pszProto, _pszSetting, &dbv); EnableWindow(_hwnd, !hContact || _Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0)); diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index 24fb405c45..e254162217 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -304,18 +304,18 @@ static INT_PTR ShowDialog(WPARAM wParam, LPARAM) static INT_PTR AddPage(WPARAM wParam, LPARAM lParam)
{
CPsHdr *pPsh = (CPsHdr *)wParam;
- OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE *)lParam;
+ USERINFOPAGE *uip = (USERINFOPAGE*)lParam;
// check size of the handled structures
- if (pPsh == nullptr || odp == nullptr)
+ if (pPsh == nullptr || uip == nullptr)
return 1;
// try to check whether the flag member is initialized or not
- odp->flags = odp->flags > (ODPF_UNICODE | ODPF_BOLDGROUPS | ODPF_ICON | PSPF_PROTOPREPENDED) ? 0 : odp->flags;
+ uip->flags = uip->flags > (ODPF_UNICODE | ODPF_BOLDGROUPS | ODPF_ICON | PSPF_PROTOPREPENDED) ? 0 : uip->flags;
if (pPsh->_dwFlags & (PSF_PROTOPAGESONLY | PSF_PROTOPAGESONLY_INIT)) {
- uint8_t bIsUnicode = (odp->flags & ODPF_UNICODE) == ODPF_UNICODE;
- wchar_t *ptszTitle = bIsUnicode ? mir_wstrdup(odp->szTitle.w) : mir_a2u(odp->szTitle.a);
+ uint8_t bIsUnicode = (uip->flags & ODPF_UNICODE) == ODPF_UNICODE;
+ wchar_t *ptszTitle = bIsUnicode ? mir_wstrdup(uip->szTitle.w) : mir_a2u(uip->szTitle.a);
// avoid adding pages for a meta subcontact, which have been added for a metacontact.
if (pPsh->_dwFlags & PSF_PROTOPAGESONLY) {
@@ -334,7 +334,7 @@ static INT_PTR AddPage(WPARAM wParam, LPARAM lParam) // create the new tree item
CPsTreeItem *pNew = new CPsTreeItem();
if (pNew) {
- if (pNew->Create(pPsh, odp)) {
+ if (pNew->Create(pPsh, uip)) {
MIR_DELETE(pNew);
return 1;
}
@@ -384,79 +384,23 @@ static int InitDetails(WPARAM wParam, LPARAM lParam) if (!(pPsh->_dwFlags & PSF_PROTOPAGESONLY)) {
uint8_t bChangeDetailsEnabled = myGlobals.CanChangeDetails && g_plugin.getByte(SET_PROPSHEET_CHANGEMYDETAILS, FALSE);
if (lParam || bChangeDetailsEnabled) {
- OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_ICON | ODPF_UNICODE;
- odp.szGroup.w = IcoLib_GetDefaultIconFileName();
- odp.pPlugin = &g_plugin;
+ USERINFOPAGE uip = {};
+ uip.flags = ODPF_ICON | ODPF_UNICODE;
+ uip.szGroup.w = IcoLib_GetDefaultIconFileName();
+ uip.pPlugin = &g_plugin;
if (lParam) {
// ignore common pages for weather contacts
if (!pPsh->_pszProto || _stricmp(pPsh->_pszProto, "weather")) {
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_GENERAL);
- odp.position = 0x8000000;
- odp.pfnDlgProc = PSPProcGeneral;
- odp.dwInitParam = ICONINDEX(IDI_TREE_GENERAL);
- odp.szTitle.w = LPGENW("General");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ADDRESS);
- odp.position = 0x8000001;
- odp.pfnDlgProc = PSPProcContactHome;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
- odp.szTitle.w = LPGENW("General") L"\\" LPGENW("Contact (private)");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ORIGIN);
- odp.position = 0x8000002;
- odp.pfnDlgProc = PSPProcOrigin;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ADVANCED);
- odp.szTitle.w = LPGENW("General") L"\\" LPGENW("Origin");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ANNIVERSARY);
- odp.position = 0x8000003;
- odp.pfnDlgProc = PSPProcAnniversary;
- odp.dwInitParam = ICONINDEX(IDI_BIRTHDAY);
- odp.szTitle.w = LPGENW("General") L"\\" LPGENW("Anniversaries");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COMPANY);
- odp.position = 0x8000004;
- odp.pfnDlgProc = PSPProcCompany;
- odp.dwInitParam = ICONINDEX(IDI_TREE_COMPANY);
- odp.szTitle.w = LPGENW("Work");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ADDRESS);
- odp.position = 0x8000005;
- odp.pfnDlgProc = PSPProcContactWork;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
- odp.szTitle.w = LPGENW("Work") L"\\" LPGENW("Contact (work)");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ABOUT);
- odp.position = 0x8000006;
- odp.pfnDlgProc = PSPProcAbout;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ABOUT);
- odp.szTitle.w = LPGENW("About");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_PROFILE);
- odp.position = 0x8000007;
- odp.pfnDlgProc = PSPProcContactProfile;
- odp.dwInitParam = ICONINDEX(IDI_TREE_PROFILE);
- odp.szTitle.w = LPGENW("About") L"\\" LPGENW("Profile");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.szTitle.w = LPGENW("About") L"\\" LPGENW("Notes");
+ InitGeneralDlg(wParam, uip);
+ InitContactDlg(wParam, uip);
+ InitOriginDlg(wParam, uip);
+ InitAnniversaryDlg(wParam, uip);
+ InitCompanyDlg(wParam, uip);
+ InitOriginDlg(wParam, uip, false);
+ InitProfileDlg(wParam, uip);
}
- else odp.szTitle.w = LPGENW("Notes");
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ABOUT);
- odp.position = 0x8000008;
- odp.pfnDlgProc = PSPProcMyNotes;
- odp.dwInitParam = ICONINDEX(IDI_TREE_NOTES);
- AddPage(wParam, (LPARAM)&odp);
+ else InitOriginDlg(wParam, uip, true);
}
}
}
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.h b/plugins/UserInfoEx/src/dlg_propsheet.h index d8aea78665..615c98102b 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.h +++ b/plugins/UserInfoEx/src/dlg_propsheet.h @@ -32,28 +32,27 @@ class CPsTree; class CPsTreeItem
{
- int _idDlg; // resource id of the property page
- LPDLGTEMPLATE _pTemplate; // locked template for the property page
- HINSTANCE _hInst; // instance handle of the owning plugin dll
- DLGPROC _pfnDlgProc; // dialog procedure for the property page
- HWND _hWnd; // window handle for the property page if shown jet
- uint32_t _dwFlags; // some flags
- int _iPosition; // initiating position if custom (used for sorting)
- LPARAM _initParam;
- MCONTACT _hContact; // contact the page is accociated with (may be a meta subcontact if details dialog is shown for a meta contact)
- LPCSTR _pszProto; // protocol the page is accociated with (is the contact's protocol if _hContact is not NULL)
- LPCSTR _pszPrefix; // pointer to the dialog owning contact's protocol
-
- HTREEITEM _hItem; // handle to the treeview item if visible (NULL if this item is hidden)
- int _iParent; // index of the owning tree item
- int _iImage; // index of treeview item's image
- uint8_t _bState; // initial state of this treeitem
- LPSTR _pszName; // original name, given by plugin (not customized)
- LPTSTR _ptszLabel; // string to setting in db holding information about this treeitem
+ int _idDlg = 0; // resource id of the property page
+ HINSTANCE _hInst = 0; // instance handle of the owning plugin dll
+ CUserInfoPageDlg *_pDialog = 0; // pointer to a page dialog
+ HWND _hWnd = 0; // window handle for the property page if shown jet
+ uint32_t _dwFlags = 0; // some flags
+ int _iPosition = 0; // initiating position if custom (used for sorting)
+ MCONTACT _hContact = 0; // contact the page is accociated with (may be a meta subcontact if details dialog is shown for a meta contact)
+ LPCSTR _pszProto = 0; // protocol the page is accociated with (is the contact's protocol if _hContact is not NULL)
+ LPCSTR _pszPrefix = 0; // pointer to the dialog owning contact's protocol
+ INT_PTR _initParam = 0;
+
+ HTREEITEM _hItem = 0; // handle to the treeview item if visible (NULL if this item is hidden)
+ int _iParent = -1; // index of the owning tree item
+ int _iImage = -1; // index of treeview item's image
+ uint8_t _bState = 0; // initial state of this treeitem
+ LPSTR _pszName = 0; // original name, given by plugin (not customized)
+ LPTSTR _ptszLabel= 0; // string to setting in db holding information about this treeitem
LPCSTR GlobalName();
- int Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIconsOnly);
+ int Icon(HIMAGELIST hIml, USERINFOPAGE *uip, uint8_t bInitIconsOnly);
int ItemLabel(const uint8_t bReadDBValue);
int Name(LPTSTR pszTitle, const uint8_t bIsUnicode);
HICON ProtoIcon();
@@ -62,30 +61,31 @@ public: CPsTreeItem();
~CPsTreeItem();
- int Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp);
+ int Create(CPsHdr* pPsh, USERINFOPAGE *uip);
void Rename(const LPTSTR pszLabel);
- __inline LPSTR Name() const { return _pszName; };
- __inline LPCSTR Proto() const { return _pszProto; };
- __inline LPTSTR Label() const { return _ptszLabel; };
- __inline MCONTACT hContact() const { return _hContact; };
+ __inline LPSTR Name() const { return _pszName; }
+ __inline LPCSTR Proto() const { return _pszProto; }
+ __inline LPTSTR Label() const { return _ptszLabel; }
+ __inline MCONTACT hContact() const { return _hContact; }
- __inline HWND Wnd() const { return _hWnd; };
- __inline int DlgId() const { return _idDlg; };
- __inline HINSTANCE Inst() const { return _hInst; };
+ __inline HWND Wnd() const { return _hWnd; }
+ __inline int DlgId() const { return _idDlg; }
+ __inline HINSTANCE Inst() const { return _hInst; }
+ __inline CUserInfoPageDlg* Dialog() const { return _pDialog; }
- __inline int Image() const { return _iImage; };
- __inline int Pos() const { return _iPosition; };
- __inline uint8_t State() const { return _bState; };
- __inline HTREEITEM Hti() const { return _hItem; };
- __inline void Hti(HTREEITEM hti) { _hItem = hti; };
- __inline int Parent() const { return _iParent; };
- __inline void Parent(const int iParent) { _iParent = iParent; };
+ __inline int Image() const { return _iImage; }
+ __inline int Pos() const { return _iPosition; }
+ __inline uint8_t State() const { return _bState; }
+ __inline HTREEITEM Hti() const { return _hItem; }
+ __inline void Hti(HTREEITEM hti) { _hItem = hti; }
+ __inline int Parent() const { return _iParent; }
+ __inline void Parent(const int iParent) { _iParent = iParent; }
- __inline uint32_t Flags() const { return _dwFlags; };
- __inline void Flags(uint32_t dwFlags) { _dwFlags = dwFlags; };
- __inline void AddFlags(uint32_t dwFlags) { _dwFlags |= dwFlags; };
- __inline void RemoveFlags(uint32_t dwFlags) { _dwFlags &= ~dwFlags; };
+ __inline uint32_t Flags() const { return _dwFlags; }
+ __inline void Flags(uint32_t dwFlags) { _dwFlags = dwFlags; }
+ __inline void AddFlags(uint32_t dwFlags) { _dwFlags |= dwFlags; }
+ __inline void RemoveFlags(uint32_t dwFlags) { _dwFlags &= ~dwFlags; }
uint8_t HasName(const LPCSTR pszName) const;
@@ -246,7 +246,7 @@ struct TPropSheet {
// dialogs owner
MCONTACT hContact;
- CHAR pszProto[MAXMODULELABELLENGTH];
+ char pszProto[MAXMODULELABELLENGTH];
HANDLE hProtoAckEvent; // eventhook for protocol acks
HANDLE hSettingChanged; // eventhook searching for changed contact information
diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp index 666fd84b78..773edbab63 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp @@ -282,7 +282,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar case EXIM_GROUP:
break;
case EXIM_SUBGROUP:
- if (mir_wstrncmp(pDat->ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(pDat->ExImContact->ptszName))) {
+ if (mir_wstrncmp(pDat->ExImContact->ptszName, DB::Setting::GetWString(hContact, "CList", "Group"), mir_wstrlen(pDat->ExImContact->ptszName))) {
continue;
}
break;
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index 1d008719ad..f4ea0a1e10 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -152,7 +152,7 @@ int CFileXml::Export(lpExImParam ExImContact, const wchar_t *pszFileName) // dont export meta subcontacts by default and
// export only contact with selectet group name
if (!db_mc_isSub(hContact) &&
- mir_wstrncmp(ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(ExImContact->ptszName)) == 0) {
+ mir_wstrncmp(ExImContact->ptszName, DB::Setting::GetWString(hContact, "CList", "Group"), mir_wstrlen(ExImContact->ptszName)) == 0) {
if (vContact.fromDB(hContact)) {
vContact.Export(xmlfile, &Modules);
}
diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h index e00052a450..bfb3faf468 100644 --- a/plugins/UserInfoEx/src/mir_db.h +++ b/plugins/UserInfoEx/src/mir_db.h @@ -29,12 +29,12 @@ namespace DB { **/
namespace Contact {
- uint32_t WhenAdded(uint32_t dwUIN, LPCSTR szBaseProto);
+ uint32_t WhenAdded(uint32_t dwUIN, LPCSTR szBaseProto);
} /* namespace Contact */
namespace Module {
- bool IsMeta(LPCSTR pszModule);
- bool IsMetaAndScan(LPCSTR pszModule);
+ bool IsMeta(LPCSTR pszModule);
+ bool IsMetaAndScan(LPCSTR pszModule);
} /* namespace Module */
@@ -43,7 +43,7 @@ namespace Module { **/
namespace Setting {
- uint8_t Get(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv, const uint8_t nType);
+ uint8_t Get(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv, const uint8_t nType);
static FORCEINLINE uint8_t GetAsIs(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv)
{ return Get(hContact, pszModule, pszSetting, dbv, 0); }
static FORCEINLINE uint8_t GetAString(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv)
@@ -77,11 +77,6 @@ namespace Setting { static FORCEINLINE uint16_t GetUStringCtrl(MCONTACT hContact, LPCSTR pszModule, LPCSTR szSubModule, LPCSTR szProto, LPCSTR pszSetting, DBVARIANT *dbv)
{ return GetCtrl(hContact, pszModule, szSubModule, szProto, pszSetting, dbv, DBVT_UTF8); }
- #define GetTString GetWString
- #define GetTStringEx GetWStringEx
- #define GetTStringCtrl GetWStringCtrl
- #define WriteTString WriteWString
-
/**
* misc operations
**/
diff --git a/plugins/UserInfoEx/src/psp_about.cpp b/plugins/UserInfoEx/src/psp_about.cpp index bacc975bd2..05b14573a0 100644 --- a/plugins/UserInfoEx/src/psp_about.cpp +++ b/plugins/UserInfoEx/src/psp_about.cpp @@ -21,83 +21,84 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the about/nodes information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcEdit(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, const CHAR *pszSetting)
+struct PSPEditDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- if (!mir_strcmp(pszSetting, SET_CONTACT_MYNOTES))
- SetDlgItemText(hDlg, IDC_PAGETITLE, LPGENW("My notes:"));
- else
- SetDlgItemText(hDlg, IDC_PAGETITLE, LPGENW("About:"));
-
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ABOUT, pszSetting, DBVT_WCHAR));
-
- // remove static edge in aero mode
- if (IsAeroMode())
- SetWindowLongPtr(GetDlgItem(hDlg, EDIT_ABOUT), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hDlg, EDIT_ABOUT), GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
-
- SendDlgItemMessage(hDlg, EDIT_ABOUT, EM_SETEVENTMASK, 0, /*ENM_KEYEVENTS | */ENM_LINK | ENM_CHANGE);
- SendDlgItemMessage(hDlg, EDIT_ABOUT, EM_AUTOURLDETECT, TRUE, NULL);
- if (!lParam) SendDlgItemMessage(hDlg, EDIT_ABOUT, EM_LIMITTEXT, 1024, NULL);
- }
- }
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
+ const char *m_szSetting;
+
+ PSPEditDlg(const char *szSetting) :
+ PSPBaseDlg(IDD_CONTACT_ABOUT),
+ m_szSetting(szSetting)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ if (!mir_strcmp(m_szSetting, SET_CONTACT_MYNOTES))
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, TranslateT("My notes:"));
+ else
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, TranslateT("About:"));
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ABOUT, m_szSetting, DBVT_WCHAR));
+
+ // remove static edge in aero mode
+ if (IsAeroMode())
+ SetWindowLongPtr(GetDlgItem(m_hwnd, EDIT_ABOUT), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(m_hwnd, EDIT_ABOUT), GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
+
+ SendDlgItemMessage(m_hwnd, EDIT_ABOUT, EM_SETEVENTMASK, 0, /*ENM_KEYEVENTS | */ENM_LINK | ENM_CHANGE);
+ SendDlgItemMessage(m_hwnd, EDIT_ABOUT, EM_AUTOURLDETECT, TRUE, NULL);
+ if (!m_hContact)
+ SendDlgItemMessage(m_hwnd, EDIT_ABOUT, EM_LIMITTEXT, 1024, NULL);
+ return true;
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ switch (uMsg) {
+ case WM_NOTIFY:
// notification handler for richedit control
+ switch (((LPNMHDR)lParam)->idFrom) {
case EDIT_ABOUT:
- {
- switch (((LPNMHDR)lParam)->code) {
-
- // notification handler for a link within the richedit control
- case EN_LINK:
- return CEditCtrl::GetObj(((LPNMHDR)lParam)->hwndFrom)->LinkNotificationHandler((ENLINK *)lParam);
- }
+ // notification handler for a link within the richedit control
+ switch (((LPNMHDR)lParam)->code) {
+ case EN_LINK:
+ return CEditCtrl::GetObj(((LPNMHDR)lParam)->hwndFrom)->LinkNotificationHandler((ENLINK *)lParam);
}
return FALSE;
}
- }
- break;
+ break;
- case WM_COMMAND:
- {
+ case WM_COMMAND:
switch (LOWORD(wParam)) {
case EDIT_ABOUT:
- {
- if (HIWORD(wParam) == EN_CHANGE)
- {
- CBaseCtrl *pResult;
-
- pResult = CBaseCtrl::GetObj((HWND)lParam);
- if (PtrIsValid(pResult) && (pResult->_cbSize == sizeof(CBaseCtrl)))
- pResult->OnChangedByUser(HIWORD(wParam));
- }
+ if (HIWORD(wParam) == EN_CHANGE) {
+ CBaseCtrl *pResult = CBaseCtrl::GetObj((HWND)lParam);
+ if (PtrIsValid(pResult) && (pResult->_cbSize == sizeof(CBaseCtrl)))
+ pResult->OnChangedByUser(HIWORD(wParam));
}
}
+ return FALSE;
}
- return FALSE;
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip, bool bReadOnly)
+{
+ if (!bReadOnly) {
+ uip.position = 0x8000006;
+ uip.pDialog = new PSPEditDlg(SET_CONTACT_ABOUT);
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ABOUT);
+ uip.szTitle.w = LPGENW("About");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.szTitle.w = LPGENW("About") L"\\" LPGENW("Notes");
+ }
+ else uip.szTitle.w = LPGENW("Notes");
+
+ uip.position = 0x8000008;
+ uip.pDialog = new PSPEditDlg(SET_CONTACT_MYNOTES);
+ uip.dwInitParam = ICONINDEX(IDI_TREE_NOTES);
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_anniversary.cpp b/plugins/UserInfoEx/src/psp_anniversary.cpp index a185512b59..5e929ace4e 100644 --- a/plugins/UserInfoEx/src/psp_anniversary.cpp +++ b/plugins/UserInfoEx/src/psp_anniversary.cpp @@ -21,19 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the anniversary add/edit dialog
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND m_hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- MAnnivDate *pDlgEditAnniv = (MAnnivDate *)GetUserData(hDlg);
+ MAnnivDate *pDlgEditAnniv = (MAnnivDate *)GetUserData(m_hwnd);
switch (uMsg) {
case WM_INITDIALOG:
@@ -41,23 +31,23 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w if (!PtrIsValid(pDlgEditAnniv))
break;
- SetUserData(hDlg, lParam);
+ SetUserData(m_hwnd, lParam);
// set icons
if (g_plugin.getByte(SET_ICONS_BUTTONS, 1)) {
- SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK));
- SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE));
+ SendDlgItemMessage(m_hwnd, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK));
+ SendDlgItemMessage(m_hwnd, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE));
}
- SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_ANNIVERSARY, true));
+ SendDlgItemMessage(m_hwnd, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_ANNIVERSARY, true));
// translate controls
- SendDlgItemMessage(hDlg, IDOK, BUTTONTRANSLATE, NULL, NULL);
- SendDlgItemMessage(hDlg, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
- TranslateDialogDefault(hDlg);
+ SendDlgItemMessage(m_hwnd, IDOK, BUTTONTRANSLATE, NULL, NULL);
+ SendDlgItemMessage(m_hwnd, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
+ TranslateDialogDefault(m_hwnd);
// init controls
- EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), pDlgEditAnniv->Id() != ANID_BIRTHDAY);
- SetDlgItemText(hDlg, EDIT_CATEGORY, pDlgEditAnniv->Description());
+ EnableWindow(GetDlgItem(m_hwnd, EDIT_CATEGORY), pDlgEditAnniv->Id() != ANID_BIRTHDAY);
+ SetDlgItemText(m_hwnd, EDIT_CATEGORY, pDlgEditAnniv->Description());
return TRUE;
case WM_CTLCOLORSTATIC:
@@ -68,13 +58,13 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w switch (LOWORD(wParam)) {
case EDIT_CATEGORY:
if (HIWORD(wParam) == EN_UPDATE)
- EnableWindow(GetDlgItem(hDlg, IDOK), GetWindowTextLength((HWND)lParam) > 0);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), GetWindowTextLength((HWND)lParam) > 0);
break;
case IDOK:
{
// read new description
- HWND hEdit = GetDlgItem(hDlg, EDIT_CATEGORY);
+ HWND hEdit = GetDlgItem(m_hwnd, EDIT_CATEGORY);
int len = Edit_GetTextLength(hEdit);
LPTSTR pszText;
@@ -82,7 +72,7 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w || (pszText = (LPTSTR)_alloca((len + 1) * sizeof(wchar_t))) == nullptr
|| !Edit_GetText(hEdit, pszText, len + 1))
{
- MsgErr(hDlg, LPGENW("Please enter a valid description first!"));
+ MsgErr(m_hwnd, LPGENW("Please enter a valid description first!"));
break;
}
@@ -94,167 +84,162 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w __fallthrough;
case IDCANCEL:
- return EndDialog(hDlg, LOWORD(wParam));
+ return EndDialog(m_hwnd, LOWORD(wParam));
}
}
return FALSE;
}
-/**
-* Dialog procedure for the anniversary propertysheetpage
-*
-* @param hDlg - handle to the dialog window
-* @param uMsg - the message to handle
-* @param wParam - parameter
-* @param lParam - parameter
-*
-* @return different values
-**/
-
-INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct PSPAnniversaryDlg : public PSPBaseDlg
{
- CAnnivEditCtrl *pDateCtrl = CAnnivEditCtrl::GetObj(hDlg, EDIT_ANNIVERSARY_DATE);
+ PSPAnniversaryDlg() :
+ PSPBaseDlg(IDD_CONTACT_ANNIVERSARY)
+ {}
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
- TranslateDialogDefault(hDlg);
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_AGE, SET_CONTACT_AGE, DBVT_BYTE));
+ m_ctrlList->insert(CAnnivEditCtrl::CreateObj(m_hwnd, EDIT_ANNIVERSARY_DATE, nullptr));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_AGE, SET_CONTACT_AGE, DBVT_BYTE));
- pCtrlList->insert(CAnnivEditCtrl::CreateObj(hDlg, EDIT_ANNIVERSARY_DATE, nullptr));
+ // hContact == NULL or reminder disabled
+ CAnnivEditCtrl::GetObj(m_hwnd, EDIT_ANNIVERSARY_DATE)->EnableReminderCtrl(m_hContact != NULL);
- // hContact == NULL or reminder disabled
- CAnnivEditCtrl::GetObj(hDlg, EDIT_ANNIVERSARY_DATE)->EnableReminderCtrl(lParam != NULL);
+ SendDlgItemMessage(m_hwnd, EDIT_AGE, EM_LIMITTEXT, 3, 0);
+ SendDlgItemMessage(m_hwnd, SPIN_AGE, UDM_SETRANGE32, 0, 200);
+ return true;
+ }
- SendDlgItemMessage(hDlg, EDIT_AGE, EM_LIMITTEXT, 3, 0);
- SendDlgItemMessage(hDlg, SPIN_AGE, UDM_SETRANGE32, 0, 200);
- }
- }
- break;
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_BIRTHDAY, STM_SETIMAGE, ICO_BIRTHDAY },
+ { IDI_BTN_ADD, BM_SETIMAGE, BTN_ADD },
+ { IDI_BTN_DELETE, BM_SETIMAGE, BTN_DELETE }
+ };
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ CAnnivEditCtrl *pDateCtrl = CAnnivEditCtrl::GetObj(m_hwnd, EDIT_ANNIVERSARY_DATE);
+
+ switch(LOWORD(wParam)) {
+ case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) {
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_BIRTHDAY, STM_SETIMAGE, ICO_BIRTHDAY },
- { IDI_BTN_ADD, BM_SETIMAGE, BTN_ADD },
- { IDI_BTN_DELETE, BM_SETIMAGE, BTN_DELETE }
- };
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
+ case EDIT_ANNIVERSARY_DATE:
+ if (!PspIsLocked(m_hwnd) && PtrIsValid(pDateCtrl)) {
+ LPNMHDR lpNmhdr = (LPNMHDR)lParam;
+ switch (lpNmhdr->code) {
+ case DTN_DATETIMECHANGE:
+ pDateCtrl->OnDateChanged((LPNMDATETIMECHANGE)lParam);
+ break;
+ case DTN_DROPDOWN:
+ HWND hMonthCal = DateTime_GetMonthCal(lpNmhdr->hwndFrom);
+ SetWindowLongPtr(hMonthCal, GWL_STYLE, GetWindowLongPtr(hMonthCal, GWL_STYLE) | MCS_WEEKNUMBERS);
+ InvalidateRect(hMonthCal, nullptr, TRUE);
+ }
}
return FALSE;
}
- break; /* case 0 */
-
- case EDIT_ANNIVERSARY_DATE:
- if (!PspIsLocked(hDlg) && PtrIsValid(pDateCtrl)) {
- LPNMHDR lpNmhdr = (LPNMHDR)lParam;
- switch (lpNmhdr->code) {
- case DTN_DATETIMECHANGE:
- pDateCtrl->OnDateChanged((LPNMDATETIMECHANGE)lParam);
- break;
- case DTN_DROPDOWN:
- HWND hMonthCal = DateTime_GetMonthCal(lpNmhdr->hwndFrom);
- SetWindowLongPtr(hMonthCal, GWL_STYLE, GetWindowLongPtr(hMonthCal, GWL_STYLE) | MCS_WEEKNUMBERS);
- InvalidateRect(hMonthCal, nullptr, TRUE);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case EDIT_REMIND:
+ if (!PspIsLocked(m_hwnd) && HIWORD(wParam) == EN_UPDATE)
+ if (PtrIsValid(pDateCtrl))
+ pDateCtrl->OnRemindEditChanged();
+ return FALSE;
+
+ /**
+ * name: BTN_MENU
+ * desc: the button to dropdown the list to show all items is pressed
+ **/
+ case BTN_MENU:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (PtrIsValid(pDateCtrl))
+ pDateCtrl->OnMenuPopup();
}
- }
- return FALSE;
- }
- break;
+ return FALSE;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case EDIT_REMIND:
- if (!PspIsLocked(hDlg) && HIWORD(wParam) == EN_UPDATE)
- if (PtrIsValid(pDateCtrl))
- pDateCtrl->OnRemindEditChanged();
- return FALSE;
-
- /**
- * name: BTN_MENU
- * desc: the button to dropdown the list to show all items is pressed
- **/
- case BTN_MENU:
- if (HIWORD(wParam) == BN_CLICKED) {
- if (PtrIsValid(pDateCtrl))
- pDateCtrl->OnMenuPopup();
- }
- return FALSE;
-
- /**
- * name: BTN_ADD
- * desc: creates a new dialog to add a new anniversary
- **/
- case BTN_ADD:
- if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
- MAnnivDate Date;
- if (IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), hDlg, DlgProc_AnniversaryEditor, (LPARAM)&Date)) {
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- if (!pDateCtrl->AddDate(Date))
- pDateCtrl->SetCurSel(pDateCtrl->NumDates() - 1);
+ /**
+ * name: BTN_ADD
+ * desc: creates a new dialog to add a new anniversary
+ **/
+ case BTN_ADD:
+ if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
+ MAnnivDate Date;
+ if (IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), m_hwnd, DlgProc_AnniversaryEditor, (LPARAM)&Date)) {
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, NULL, NULL);
+ if (!pDateCtrl->AddDate(Date))
+ pDateCtrl->SetCurSel(pDateCtrl->NumDates() - 1);
+ }
}
- }
- return FALSE;
-
- /**
- * name: BTN_EDIT
- * desc: edit the currently selected anniversary
- **/
- case BTN_EDIT:
- if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
- MAnnivDate *pDate = pDateCtrl->Current();
- if (!pDate)
- MsgErr(hDlg, LPGENW("No valid date selected for editing!"));
- else if (
- IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), hDlg, DlgProc_AnniversaryEditor, (LPARAM)pDate) &&
- (pDate->Flags() & (MAnnivDate::MADF_CHANGED | MAnnivDate::MADF_REMINDER_CHANGED)))
- {
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- pDateCtrl->SetCurSel(pDateCtrl->CurrentIndex());
+ return FALSE;
+
+ /**
+ * name: BTN_EDIT
+ * desc: edit the currently selected anniversary
+ **/
+ case BTN_EDIT:
+ if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
+ MAnnivDate *pDate = pDateCtrl->Current();
+ if (!pDate)
+ MsgErr(m_hwnd, LPGENW("No valid date selected for editing!"));
+ else if (
+ IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), m_hwnd, DlgProc_AnniversaryEditor, (LPARAM)pDate) &&
+ (pDate->Flags() & (MAnnivDate::MADF_CHANGED | MAnnivDate::MADF_REMINDER_CHANGED)))
+ {
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, NULL, NULL);
+ pDateCtrl->SetCurSel(pDateCtrl->CurrentIndex());
+ }
}
- }
- return FALSE;
-
- /**
- * name: BTN_DELETE
- * desc: user wants to delete an anniversary
- **/
- case BTN_DELETE:
- if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
- MAnnivDate *pCurrent = pDateCtrl->Current();
- if (pCurrent) {
- int rc = MsgBox(hDlg, MB_YESNO | MB_ICON_QUESTION | MB_NOPOPUP, LPGENW("Delete"), nullptr,
- LPGENW("Do you really want to delete the %s?"), pCurrent->Description());
-
- if (rc == IDYES)
- pDateCtrl->DeleteDate(pDateCtrl->CurrentIndex());
+ return FALSE;
+
+ /**
+ * name: BTN_DELETE
+ * desc: user wants to delete an anniversary
+ **/
+ case BTN_DELETE:
+ if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
+ MAnnivDate *pCurrent = pDateCtrl->Current();
+ if (pCurrent) {
+ int rc = MsgBox(m_hwnd, MB_YESNO | MB_ICON_QUESTION | MB_NOPOPUP, LPGENW("Delete"), nullptr,
+ LPGENW("Do you really want to delete the %s?"), pCurrent->Description());
+
+ if (rc == IDYES)
+ pDateCtrl->DeleteDate(pDateCtrl->CurrentIndex());
+ }
}
+ return FALSE;
+
+ /**
+ * name: CHECK_REMIND
+ * desc: state of reminder checkbox is changed
+ **/
+ case RADIO_REMIND1:
+ case RADIO_REMIND2:
+ case RADIO_REMIND3:
+ if (PtrIsValid(pDateCtrl) && HIWORD(wParam) == BN_CLICKED)
+ pDateCtrl->OnReminderChecked();
+ return FALSE;
}
- return FALSE;
-
- /**
- * name: CHECK_REMIND
- * desc: state of reminder checkbox is changed
- **/
- case RADIO_REMIND1:
- case RADIO_REMIND2:
- case RADIO_REMIND3:
- if (PtrIsValid(pDateCtrl) && HIWORD(wParam) == BN_CLICKED)
- pDateCtrl->OnReminderChecked();
- return FALSE;
- } /* switch (LOWORD(wParam)) */
- break;
+ }
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitAnniversaryDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000003;
+ uip.pDialog = new PSPAnniversaryDlg();
+ uip.dwInitParam = ICONINDEX(IDI_BIRTHDAY);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Anniversaries");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_base.cpp b/plugins/UserInfoEx/src/psp_base.cpp index d8d07bd9ea..0737807bcc 100644 --- a/plugins/UserInfoEx/src/psp_base.cpp +++ b/plugins/UserInfoEx/src/psp_base.cpp @@ -29,64 +29,76 @@ void UpDate_CountryIcon(HWND hCtrl, int countryID) IcoLib_ReleaseIcon(hOld);
}
+PSPBaseDlg::PSPBaseDlg(int idDialog) :
+ CUserInfoPageDlg(g_plugin, idDialog),
+ m_ctrlList(nullptr)
+{
+}
+
+bool PSPBaseDlg::OnInitDialog()
+{
+ m_ctrlList = CCtrlList::CreateObj(m_hwnd);
+
+ HFONT hBoldFont;
+ PSGetBoldFont(m_hwnd, hBoldFont);
+ SendDlgItemMessage(m_hwnd, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
+ return true;
+}
+
+void PSPBaseDlg::OnDestroy()
+{
+ m_ctrlList->Release();
+}
+
// Default dialog procedure, which handles common functions
-INT_PTR CALLBACK PSPBaseProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+INT_PTR PSPBaseDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- CCtrlList *pCtrlList;
-
- pCtrlList = CCtrlList::GetObj(hDlg);
- if (PtrIsValid(pCtrlList)) {
- switch (uMsg) {
- case WM_INITDIALOG:
- return TRUE;
-
- // set propertysheet page's background white in aero mode
- case WM_CTLCOLORSTATIC:
- case WM_CTLCOLORDLG:
- if (IsAeroMode())
- return (INT_PTR)GetStockBrush(WHITE_BRUSH);
- break;
+ switch (uMsg) {
+ // set propertysheet page's background white in aero mode
+ case WM_CTLCOLORSTATIC:
+ case WM_CTLCOLORDLG:
+ if (IsAeroMode())
+ return (INT_PTR)GetStockBrush(WHITE_BRUSH);
+ break;
+
+ // Set text color of edit boxes according to the source of information they display.
+ case WM_CTLCOLOREDIT:
+ if (m_ctrlList)
+ return m_ctrlList->OnSetTextColour((HWND)lParam, (HDC)wParam);
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
+ LPSTR pszProto;
+
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_RESET:
+ m_ctrlList->OnReset();
+ break;
- // Set text color of edit boxes according to the source of information they display.
- case WM_CTLCOLOREDIT:
- return pCtrlList->OnSetTextColour((HWND)lParam, (HDC)wParam);
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPSTR pszProto;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_RESET:
- pCtrlList->OnReset();
- break;
-
- case PSN_INFOCHANGED:
- if (PSGetBaseProto(hDlg, pszProto) && *pszProto) {
- BOOL bChanged = (GetWindowLongPtr(hDlg, DWLP_MSGRESULT)&PSP_CHANGED) | pCtrlList->OnInfoChanged(hContact, pszProto);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
- }
- break;
-
- case PSN_APPLY:
- if (PSGetBaseProto(hDlg, pszProto) && *pszProto)
- pCtrlList->OnApply(hContact, pszProto);
- break;
+ case PSN_INFOCHANGED:
+ if (PSGetBaseProto(m_hwnd, pszProto) && *pszProto) {
+ BOOL bChanged = (GetWindowLongPtr(m_hwnd, DWLP_MSGRESULT)&PSP_CHANGED) | m_ctrlList->OnInfoChanged(hContact, pszProto);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
}
break;
- }
- break;
- case WM_COMMAND:
- if (!PspIsLocked(hDlg))
- pCtrlList->OnChangedByUser(LOWORD(wParam), HIWORD(wParam));
+ case PSN_APPLY:
+ if (PSGetBaseProto(m_hwnd, pszProto) && *pszProto)
+ m_ctrlList->OnApply(hContact, pszProto);
+ break;
+ }
break;
-
- case WM_DESTROY:
- // destroy all control objects and the list
- pCtrlList->Release();
}
+ break;
+
+ case WM_COMMAND:
+ if (m_ctrlList && !PspIsLocked(m_hwnd))
+ m_ctrlList->OnChangedByUser(LOWORD(wParam), HIWORD(wParam));
+ break;
}
- return 0;
+
+ return CUserInfoPageDlg::DlgProc(uMsg, wParam, lParam);
}
diff --git a/plugins/UserInfoEx/src/psp_base.h b/plugins/UserInfoEx/src/psp_base.h index 6f8702b99f..55c4529120 100644 --- a/plugins/UserInfoEx/src/psp_base.h +++ b/plugins/UserInfoEx/src/psp_base.h @@ -22,20 +22,35 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _UI_PSP_BASE_INCLUDE_
#define _UI_PSP_BASE_INCLUDE_
-INT_PTR CALLBACK PSPBaseProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcCompany(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcEdit(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, const CHAR* pszSetting);
-static FORCEINLINE INT_PTR CALLBACK PSPProcMyNotes(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{ return PSPProcEdit(hDlg, uMsg, wParam, lParam, SET_CONTACT_MYNOTES); }
-static FORCEINLINE INT_PTR CALLBACK PSPProcAbout(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{ return PSPProcEdit(hDlg, uMsg, wParam, lParam, SET_CONTACT_ABOUT); }
+/////////////////////////////////////////////////////////////////////////////////////////
+// Base page dialog class
+
+class PSPBaseDlg : public CUserInfoPageDlg
+{
+ friend class CPsTreeItem;
+
+protected:
+ CCtrlList *m_ctrlList;
+
+ PSPBaseDlg(int idDialog);
+
+ virtual void OnIconsChanged() {}
+
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM, LPARAM) override;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void InitGeneralDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitContactDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitCompanyDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitAnniversaryDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip, bool bReadOnly);
+void InitProfileDlg(WPARAM wParam, USERINFOPAGE &uip);
void UpDate_CountryIcon(HWND hCtrl, int countryID);
diff --git a/plugins/UserInfoEx/src/psp_company.cpp b/plugins/UserInfoEx/src/psp_company.cpp index 06328e885f..d55e01db2b 100644 --- a/plugins/UserInfoEx/src/psp_company.cpp +++ b/plugins/UserInfoEx/src/psp_company.cpp @@ -21,42 +21,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the company contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcCompany(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+struct PSPCompanyDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_COMPANY, SET_CONTACT_COMPANY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_DEPARTMENT, SET_CONTACT_COMPANY_DEPARTMENT, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_OFFICE, SET_CONTACT_COMPANY_OFFICE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_POSITION, SET_CONTACT_COMPANY_POSITION, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_SUPERIOR, SET_CONTACT_COMPANY_SUPERIOR, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ASSISTENT, SET_CONTACT_COMPANY_ASSISTENT, DBVT_WCHAR));
-
- GetOccupationList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_OCCUPATION, SET_CONTACT_COMPANY_OCCUPATION, DBVT_WORD, pList, nList));
- }
- }
+ PSPCompanyDlg() :
+ PSPBaseDlg(IDD_CONTACT_COMPANY)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_COMPANY, SET_CONTACT_COMPANY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_DEPARTMENT, SET_CONTACT_COMPANY_DEPARTMENT, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_OFFICE, SET_CONTACT_COMPANY_OFFICE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_POSITION, SET_CONTACT_COMPANY_POSITION, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_SUPERIOR, SET_CONTACT_COMPANY_SUPERIOR, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ASSISTENT, SET_CONTACT_COMPANY_ASSISTENT, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetOccupationList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_OCCUPATION, SET_CONTACT_COMPANY_OCCUPATION, DBVT_WORD, pList, nList));
+ return true;
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitCompanyDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000004;
+ uip.pDialog = new PSPCompanyDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_COMPANY);
+ uip.szTitle.w = LPGENW("Work");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_contact.cpp b/plugins/UserInfoEx/src/psp_contact.cpp index f4e8b4ef65..5088972e12 100644 --- a/plugins/UserInfoEx/src/psp_contact.cpp +++ b/plugins/UserInfoEx/src/psp_contact.cpp @@ -21,291 +21,260 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the home contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Home contact info
+
+struct PSPContactHomeDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- wchar_t szAddr[MAX_PATH];
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address"), TranslateT("home"));
- SetDlgItemText(hDlg, IDC_PAGETITLE, szAddr);
- SendDlgItemMessage(hDlg, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_STATE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_HOMEPAGE, SET_CONTACT_HOMEPAGE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_COUNTRY, DBVT_WORD, pList, nList));
+ PSPContactHomeDlg() :
+ PSPBaseDlg(IDD_CONTACT_ADDRESS)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ wchar_t szAddr[MAX_PATH];
+ mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address"), TranslateT("home"));
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, szAddr);
+
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_STATE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_HOMEPAGE, SET_CONTACT_HOMEPAGE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_COUNTRY, DBVT_WORD, pList, nList));
+ return true;
+ }
- break;
- }
- }
- return FALSE;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
- HWND hCtrl;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t bChanged = 0;
-
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- // phone numbers
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_FAX);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
-
- // emails
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
- }
- break;
-
- case PSN_APPLY:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_FAX);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
-
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
- SendDlgItemMessage(hDlg, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- SetDlgItemText(hDlg, BTN_GOTO, hIcon ? L"" : L"->");
-
- hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
- SendDlgItemMessage(hDlg, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- ShowWindow(GetDlgItem(hDlg, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
-
- SendDlgItemMessage(hDlg, EDIT_PHONE, WM_SETICON, NULL, NULL);
- SendDlgItemMessage(hDlg, EDIT_EMAIL, WM_SETICON, NULL, NULL);
- }
- break;
- }
- }
- }
- }
- break;
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ uint8_t bChanged = 0;
+
+ // phone numbers
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), m_hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), m_hContact, USERINFO, pszProto, SET_CONTACT_FAX);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), m_hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+
+ // emails
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+ return bChanged != 0;
+ }
- case WM_COMMAND:
- {
+ bool OnApply() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_FAX);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+ return true;
+ }
+
+ void OnIconsChanged() override
+ {
+ HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ SetDlgItemText(m_hwnd, BTN_GOTO, hIcon ? L"" : L"->");
+
+ hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
+ SendDlgItemMessage(m_hwnd, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ ShowWindow(GetDlgItem(m_hwnd, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
+
+ SendDlgItemMessage(m_hwnd, EDIT_PHONE, WM_SETICON, NULL, NULL);
+ SendDlgItemMessage(m_hwnd, EDIT_EMAIL, WM_SETICON, NULL, NULL);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_HOMEPAGE:
if (HIWORD(wParam) == EN_UPDATE)
- EnableWindow(GetDlgItem(hDlg, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
+ EnableWindow(GetDlgItem(m_hwnd, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
break;
case BTN_GOTO:
- CEditCtrl::GetObj(hDlg, EDIT_HOMEPAGE)->OpenUrl();
+ CEditCtrl::GetObj(m_hwnd, EDIT_HOMEPAGE)->OpenUrl();
break;
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
-}
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Work contact info
-/**
- * Dialog procedure for the company's contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+struct PSPContactWorkDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList)
- {
- wchar_t szAddr[MAX_PATH];
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address and contact"), TranslateT("company"));
- SetDlgItemText(hDlg, IDC_PAGETITLE, szAddr);
- SendDlgItemMessage(hDlg, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_COMPANY_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_COMPANY_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_COMPANY_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_COMPANY_STATE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_HOMEPAGE, SET_CONTACT_COMPANY_HOMEPAGE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_COMPANY_COUNTRY, DBVT_WORD, pList, nList));
- }
- }
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
- HWND hCtrl;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t bChanged = 0;
-
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- // phone numbers
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
-
- // emails
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
- }
- break;
-
- case PSN_APPLY:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
-
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
- SendDlgItemMessage(hDlg, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- SetDlgItemText(hDlg, BTN_GOTO, hIcon ? L"" : L"->");
-
- hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
- SendDlgItemMessage(hDlg, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- ShowWindow(GetDlgItem(hDlg, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
-
- SendDlgItemMessage(hDlg, EDIT_PHONE, WM_SETICON, NULL, NULL);
- SendDlgItemMessage(hDlg, EDIT_EMAIL, WM_SETICON, NULL, NULL);
- }
- break;
- }
- }
- }
- }
- break;
+ PSPContactWorkDlg() :
+ PSPBaseDlg(IDD_CONTACT_ADDRESS)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ wchar_t szAddr[MAX_PATH];
+ mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address and contact"), TranslateT("company"));
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, szAddr);
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
+ TranslateDialogDefault(m_hwnd);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_COMPANY_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_COMPANY_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_COMPANY_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_COMPANY_STATE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_HOMEPAGE, SET_CONTACT_COMPANY_HOMEPAGE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_COMPANY_COUNTRY, DBVT_WORD, pList, nList));
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+ return true;
+ }
- case WM_COMMAND:
- {
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ uint8_t bChanged = 0;
+
+ // phone numbers
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+
+ // emails
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+ return bChanged != 0;
+ }
+
+ void OnIconsChanged() override
+ {
+ HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ SetDlgItemText(m_hwnd, BTN_GOTO, hIcon ? L"" : L"->");
+
+ hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
+ SendDlgItemMessage(m_hwnd, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ ShowWindow(GetDlgItem(m_hwnd, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
+
+ SendDlgItemMessage(m_hwnd, EDIT_PHONE, WM_SETICON, NULL, NULL);
+ SendDlgItemMessage(m_hwnd, EDIT_EMAIL, WM_SETICON, NULL, NULL);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_HOMEPAGE:
if (HIWORD(wParam) == EN_UPDATE)
- EnableWindow(GetDlgItem(hDlg, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
+ EnableWindow(GetDlgItem(m_hwnd, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
break;
case BTN_GOTO:
- CEditCtrl::GetObj(hDlg, EDIT_HOMEPAGE)->OpenUrl();
+ CEditCtrl::GetObj(m_hwnd, EDIT_HOMEPAGE)->OpenUrl();
break;
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module entry point
+
+void InitContactDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000001;
+ uip.pDialog = new PSPContactHomeDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Contact (private)");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.position = 0x8000005;
+ uip.pDialog = new PSPContactWorkDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
+ uip.szTitle.w = LPGENW("Work") L"\\" LPGENW("Contact (work)");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_general.cpp b/plugins/UserInfoEx/src/psp_general.cpp index 05c8d229fd..44c8576d85 100644 --- a/plugins/UserInfoEx/src/psp_general.cpp +++ b/plugins/UserInfoEx/src/psp_general.cpp @@ -21,162 +21,96 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+struct PSPGeneralDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
- HFONT hBoldFont;
-
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_TITLE, SET_CONTACT_TITLE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_FIRSTNAME, SET_CONTACT_FIRSTNAME, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_SECONDNAME, SET_CONTACT_SECONDNAME, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_LASTNAME, SET_CONTACT_LASTNAME, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_NICK, SET_CONTACT_NICK, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_DISPLAYNAME, "CList", SET_CONTACT_MYHANDLE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_PARTNER, SET_CONTACT_PARTNER, DBVT_WCHAR));
-
- GetNamePrefixList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_PREFIX, SET_CONTACT_PREFIX, DBVT_BYTE, pList, nList));
-
- // marital groupbox
- GetMaritalList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_MARITAL, SET_CONTACT_MARITAL, DBVT_BYTE, pList, nList));
-
- GetLanguageList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG1, SET_CONTACT_LANG1, DBVT_WCHAR, pList, nList));
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG2, SET_CONTACT_LANG2, DBVT_WCHAR, pList, nList));
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG3, SET_CONTACT_LANG3, DBVT_WCHAR, pList, nList));
- }
- }
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- char* pszProto;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t bEnable;
- DBVARIANT dbv;
- CCtrlFlags Flags;
-
- if (PSGetBaseProto(hDlg, pszProto) && *pszProto) {
- Flags.W = DB::Setting::GetTStringCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv);
- if (Flags.B.hasCustom || Flags.B.hasProto || Flags.B.hasMeta) {
- if (dbv.type == DBVT_BYTE) {
- CheckDlgButton(hDlg, RADIO_FEMALE, (dbv.bVal == 'F') ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hDlg, RADIO_MALE, (dbv.bVal == 'M') ? BST_CHECKED : BST_UNCHECKED);
-
- bEnable = !hContact || Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0);
- EnableWindow(GetDlgItem(hDlg, RADIO_FEMALE), bEnable);
- EnableWindow(GetDlgItem(hDlg, RADIO_MALE), bEnable);
- }
- else
- db_free(&dbv);
- }
- }
- }
- break;
-
- case PSN_APPLY:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- // gender
- {
- uint8_t gender
- = IsDlgButtonChecked(hDlg, RADIO_FEMALE)
- ? 'F'
- : IsDlgButtonChecked(hDlg, RADIO_MALE)
- ? 'M'
- : 0;
-
- if (gender)
- db_set_b(hContact, hContact ? USERINFO : pszProto, SET_CONTACT_GENDER, gender);
- else
- db_unset(hContact, hContact ? USERINFO : pszProto, SET_CONTACT_GENDER);
- }
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_FEMALE, STM_SETIMAGE, ICO_FEMALE },
- { IDI_MALE, STM_SETIMAGE, ICO_MALE },
- { IDI_MARITAL, STM_SETIMAGE, ICO_MARITAL },
- };
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
- }
- }
- }
- }
- }
- break;
-
- case WM_COMMAND:
- {
- MCONTACT hContact;
- LPCSTR pszProto;
-
- switch (LOWORD(wParam)) {
- case RADIO_FEMALE:
- {
- if (!PspIsLocked(hDlg) && HIWORD(wParam) == BN_CLICKED) {
- DBVARIANT dbv;
-
- PSGetContact(hDlg, hContact);
- PSGetBaseProto(hDlg, pszProto);
-
- if (!DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv)
- || dbv.type != DBVT_BYTE
- || (dbv.bVal != 'F' && SendMessage((HWND)lParam, BM_GETCHECK, NULL, NULL)))
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- }
- }
- break;
-
- case RADIO_MALE:
- {
- if (!PspIsLocked(hDlg) && HIWORD(wParam) == BN_CLICKED) {
- DBVARIANT dbv;
+ PSPGeneralDlg() :
+ PSPBaseDlg(IDD_CONTACT_GENERAL)
+ {
+ }
- PSGetContact(hDlg, hContact);
- PSGetBaseProto(hDlg, pszProto);
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_TITLE, SET_CONTACT_TITLE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_FIRSTNAME, SET_CONTACT_FIRSTNAME, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_SECONDNAME, SET_CONTACT_SECONDNAME, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_LASTNAME, SET_CONTACT_LASTNAME, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_NICK, SET_CONTACT_NICK, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_DISPLAYNAME, "CList", SET_CONTACT_MYHANDLE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_PARTNER, SET_CONTACT_PARTNER, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetNamePrefixList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_PREFIX, SET_CONTACT_PREFIX, DBVT_BYTE, pList, nList));
+
+ // marital groupbox
+ GetMaritalList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_MARITAL, SET_CONTACT_MARITAL, DBVT_BYTE, pList, nList));
+
+ GetLanguageList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_LANG1, SET_CONTACT_LANG1, DBVT_WCHAR, pList, nList));
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_LANG2, SET_CONTACT_LANG2, DBVT_WCHAR, pList, nList));
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_LANG3, SET_CONTACT_LANG3, DBVT_WCHAR, pList, nList));
+ return true;
+ }
- if (!DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv)
- || dbv.type != DBVT_BYTE
- || (dbv.bVal != 'M' && SendMessage((HWND)lParam, BM_GETCHECK, NULL, NULL)))
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- }
+ bool OnRefresh() override
+ {
+ char *pszProto;
+ if (PSGetBaseProto(m_hwnd, pszProto) && *pszProto) {
+ DBVARIANT dbv;
+ CCtrlFlags Flags;
+ Flags.W = DB::Setting::GetWStringCtrl(m_hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv);
+ if (Flags.B.hasCustom || Flags.B.hasProto || Flags.B.hasMeta) {
+ if (dbv.type == DBVT_BYTE) {
+ CheckDlgButton(m_hwnd, RADIO_FEMALE, (dbv.bVal == 'F') ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, RADIO_MALE, (dbv.bVal == 'M') ? BST_CHECKED : BST_UNCHECKED);
+
+ bool bEnable = !m_hContact || Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0);
+ EnableWindow(GetDlgItem(m_hwnd, RADIO_FEMALE), bEnable);
+ EnableWindow(GetDlgItem(m_hwnd, RADIO_MALE), bEnable);
}
+ else db_free(&dbv);
}
}
+ return false;
+ }
+
+ bool OnApply() override
+ {
+ char *pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ // gender
+ uint8_t gender = IsDlgButtonChecked(m_hwnd, RADIO_FEMALE) ? 'F' :
+ IsDlgButtonChecked(m_hwnd, RADIO_MALE) ? 'M' : 0;
+
+ if (gender)
+ db_set_b(m_hContact, m_hContact ? USERINFO : pszProto, SET_CONTACT_GENDER, gender);
+ else
+ db_unset(m_hContact, m_hContact ? USERINFO : pszProto, SET_CONTACT_GENDER);
+ return true;
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_FEMALE, STM_SETIMAGE, ICO_FEMALE },
+ { IDI_MALE, STM_SETIMAGE, ICO_MALE },
+ { IDI_MARITAL, STM_SETIMAGE, ICO_MARITAL },
+ };
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
+};
+
+void InitGeneralDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000000;
+ uip.pDialog = new PSPGeneralDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_GENERAL);
+ uip.szTitle.w = LPGENW("General");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_origin.cpp b/plugins/UserInfoEx/src/psp_origin.cpp index c10d4c0fc0..78b85cc707 100644 --- a/plugins/UserInfoEx/src/psp_origin.cpp +++ b/plugins/UserInfoEx/src/psp_origin.cpp @@ -21,126 +21,109 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * This is the dialog procedure for the advanced contact information propertysheetpage.
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+class PSPOriginDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- TranslateDialogDefault(hDlg);
- SetTimer(hDlg, 1, 5000, nullptr);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_ORIGIN_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_ORIGIN_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_ORIGIN_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_ORIGIN_STATE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_ORIGIN_COUNTRY, DBVT_WORD, pList, nList));
-
- pCtrlList->insert(CTzCombo::CreateObj(hDlg, EDIT_TIMEZONE, nullptr));
- }
+ CTimer timer;
+
+public:
+ PSPOriginDlg() :
+ PSPBaseDlg(IDD_CONTACT_ORIGIN),
+ timer(this, 1)
+ {
+ timer.OnEvent = Callback(this, &PSPOriginDlg::onTimer);
+ }
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ timer.Start(5000);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_ORIGIN_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_ORIGIN_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_ORIGIN_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_ORIGIN_STATE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_ORIGIN_COUNTRY, DBVT_WORD, pList, nList));
+
+ m_ctrlList->insert(CTzCombo::CreateObj(m_hwnd, EDIT_TIMEZONE, nullptr));
+ return true;
+ }
+
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ if (!m_hContact)
+ return false;
+
+ MTime mt;
+ if (mt.DBGetStamp(m_hContact, USERINFO, SET_CONTACT_ADDEDTIME) && strstr(pszProto, "ICQ")) {
+ uint32_t dwStamp;
+
+ dwStamp = DB::Contact::WhenAdded(db_get_dw(m_hContact, pszProto, "UIN", 0), pszProto);
+ if (dwStamp > 0)
+ mt.FromStampAsUTC(dwStamp);
}
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
-
- switch (((LPNMHDR) lParam)->code) {
- case PSN_INFOCHANGED:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- if (hContact) {
- MTime mt;
-
- if (mt.DBGetStamp(hContact, USERINFO, SET_CONTACT_ADDEDTIME) && strstr(pszProto, "ICQ")) {
- uint32_t dwStamp;
-
- dwStamp = DB::Contact::WhenAdded(db_get_dw(hContact, pszProto, "UIN", 0), pszProto);
- if (dwStamp > 0)
- mt.FromStampAsUTC(dwStamp);
- }
- if (mt.IsValid()) {
- wchar_t szTime[MAX_PATH];
- LPTSTR ptr;
-
- mt.UTCToLocal();
- mt.DateFormatLong(szTime, _countof(szTime));
-
- mir_wstrcat(szTime, L" - ");
- ptr = szTime + mir_wstrlen(szTime);
- mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime));
- SetDlgItemText(hDlg, TXT_DATEADDED, szTime);
- }
- }
-
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS },
- { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK },
- };
-
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
- }
- }
- }
- } /* switch (((LPNMHDR)lParam)->idFrom) */
+ if (mt.IsValid()) {
+ wchar_t szTime[MAX_PATH];
+ LPTSTR ptr;
+
+ mt.UTCToLocal();
+ mt.DateFormatLong(szTime, _countof(szTime));
+
+ mir_wstrcat(szTime, L" - ");
+ ptr = szTime + mir_wstrlen(szTime);
+ mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime));
+ SetDlgItemText(m_hwnd, TXT_DATEADDED, szTime);
}
- break;
+ return false;
+ }
+
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS },
+ { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK },
+ };
+
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
- case WM_COMMAND:
- {
+ void onTimer(CTimer *)
+ {
+ wchar_t szTime[32];
+ CTzCombo::GetObj(m_hwnd, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime));
+ SetDlgItemText(m_hwnd, TXT_TIME, szTime);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
- break;
-
- case WM_TIMER:
- {
- wchar_t szTime[32];
- CTzCombo::GetObj(hDlg, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime));
- SetDlgItemText(hDlg, TXT_TIME, szTime);
- break;
- }
-
- case WM_DESTROY:
- KillTimer(hDlg, 1);
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000002;
+ uip.pDialog = new PSPOriginDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADVANCED);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Origin");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_profile.cpp b/plugins/UserInfoEx/src/psp_profile.cpp index 9101d41d13..38ee787e90 100644 --- a/plugins/UserInfoEx/src/psp_profile.cpp +++ b/plugins/UserInfoEx/src/psp_profile.cpp @@ -274,7 +274,7 @@ static HWND ProfileList_BeginLabelEdit(LPLISTCTRL pList, int iItem, int iSubItem {
LVITEM lvi;
LPLCITEM pItem;
- MCONTACT hContact;
+ MCONTACT m_hContact;
RECT rcList;
if (!PtrIsValid(pList))
@@ -292,10 +292,10 @@ static HWND ProfileList_BeginLabelEdit(LPLISTCTRL pList, int iItem, int iSubItem pItem = (LPLCITEM)lvi.lParam;
- PSGetContact(GetParent(pList->hList), hContact);
+ PSGetContact(GetParent(pList->hList), m_hContact);
// do not edit deviders or protocol based contact information
- if (!(lvi.state & LVIS_SELECTED) || !PtrIsValid(pItem) || (hContact && (pItem->wFlags & CTRLF_HASPROTO)))
+ if (!(lvi.state & LVIS_SELECTED) || !PtrIsValid(pItem) || (m_hContact && (pItem->wFlags & CTRLF_HASPROTO)))
return nullptr;
ListView_EnsureVisible(pList->hList, iItem, FALSE);
@@ -423,12 +423,12 @@ static uint8_t ProfileList_AddNewItem(HWND hDlg, LPLISTCTRL pList, const PROFILE {
LPLCITEM pItem;
LVITEM lvi;
- MCONTACT hContact;
+ MCONTACT m_hContact;
if (PtrIsValid(pList) && (pItem = (LPLCITEM)mir_alloc(sizeof(LCITEM)))) {
- PSGetContact(hDlg, hContact);
+ PSGetContact(hDlg, m_hContact);
pItem->nType = CTRL_LIST_ITEM;
- pItem->wFlags = hContact ? CTRLF_HASCUSTOM : 0;
+ pItem->wFlags = m_hContact ? CTRLF_HASCUSTOM : 0;
pItem->iListItem = 0;
pItem->pszText[0] = nullptr;
pItem->pszText[1] = nullptr;
@@ -457,7 +457,7 @@ static uint8_t ProfileList_AddNewItem(HWND hDlg, LPLISTCTRL pList, const PROFILE * param: hList - HANDLE to the list to fill with two columns
* iItem - index of new listviewitem
* iImage - image to draw from a imagelist associated with the listview
- * hContact - handle to the contact, whose information are read
+ * m_hContact - handle to the contact, whose information are read
* pszModule - the module the information are stored in
* szCatFormat - name of a database setting that holds the categorytext
* szValFormat - name of a database setting that holds the valuetext
@@ -470,7 +470,7 @@ static int ProfileList_AddItemlistFromDB( int &iItem,
LPIDSTRLIST idList,
UINT nList,
- MCONTACT hContact,
+ MCONTACT m_hContact,
LPCSTR pszModule,
LPCSTR szCatFormat,
LPCSTR szValFormat,
@@ -488,12 +488,12 @@ static int ProfileList_AddItemlistFromDB( for (i = 0, lvi.iItem = iItem; ; i++) {
// read the setting from db
mir_snprintf(pszSetting, szValFormat, i);
- if (DB::Setting::GetTString(hContact, pszModule, pszSetting, &dbvVal))
+ if (DB::Setting::GetWString(m_hContact, pszModule, pszSetting, &dbvVal))
break;
if (dbvVal.type != DBVT_WCHAR)
continue;
mir_snprintf(pszSetting, szCatFormat, i);
- DB::Setting::GetAString(hContact, pszModule, pszSetting, &dbvCat);
+ DB::Setting::GetAString(m_hContact, pszModule, pszSetting, &dbvCat);
// create the itemobject
if (!(pItem = (LPLCITEM)mir_alloc(sizeof(LCITEM)))) {
db_free(&dbvCat);
@@ -1016,359 +1016,352 @@ static LRESULT CALLBACK ProfileList_SubclassProc(HWND hwnd, UINT msg, WPARAM wPa *
* return: 0 or 1
**/
-INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+
+struct PSPContactProfileDlg : public PSPBaseDlg
{
- HWND hList = GetDlgItem(hDlg, LIST_PROFILE);
+ PSPContactProfileDlg() :
+ PSPBaseDlg(IDD_CONTACT_PROFILE)
+ {}
+
+ HWND hList;
LPLISTCTRL pList;
- LVHITTESTINFO hi;
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- LVCOLUMN lvc;
- RECT rc;
- LOGFONT lf;
- HFONT hFont;
- TOOLINFO ti;
+ bool OnInitDialog() override
+ {
+ LVCOLUMN lvc;
+ RECT rc;
+ LOGFONT lf;
+ HFONT hFont;
- if (!hList || !(pList = (LPLISTCTRL)mir_alloc(sizeof(LISTCTRL))))
- return FALSE;
- memset(pList, 0, sizeof(LISTCTRL));
+ hList = GetDlgItem(m_hwnd, LIST_PROFILE);
+ if (!hList || !(pList = (LPLISTCTRL)mir_calloc(sizeof(LISTCTRL))))
+ return FALSE;
+
+ Ctrl_InitTextColours();
- TranslateDialogDefault(hDlg);
- Ctrl_InitTextColours();
+ // init info structure
+ pList->hList = hList;
+ pList->nType = CTRL_LIST_PROFILE;
+ memset(&pList->labelEdit, 0, sizeof(pList->labelEdit));
+ SetUserData(hList, pList);
- // init info structure
- pList->hList = hList;
- pList->nType = CTRL_LIST_PROFILE;
- memset(&pList->labelEdit, 0, sizeof(pList->labelEdit));
- SetUserData(hList, pList);
+ // set new window procedure
+ mir_subclassWindow(hList, ProfileList_SubclassProc);
- // set new window procedure
- mir_subclassWindow(hList, ProfileList_SubclassProc);
+ // remove static edge in aero mode
+ if (IsAeroMode())
+ SetWindowLongPtr(hList, GWL_EXSTYLE, GetWindowLongPtr(hList, GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
- // remove static edge in aero mode
- if (IsAeroMode())
- SetWindowLongPtr(hList, GWL_EXSTYLE, GetWindowLongPtr(hList, GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
-
- // insert columns into the listboxes
- ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
-
-
- PSGetBoldFont(hDlg, hFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hFont, 0);
-
- // set listfont
- pList->hFont = (HFONT)SendMessage(hList, WM_GETFONT, 0, 0);
- pList->wFlags |= LVF_EDITLABEL;
- GetObject(pList->hFont, sizeof(lf), &lf);
- lf.lfHeight -= 6;
- hFont = CreateFontIndirect(&lf);
- SendMessage(hList, WM_SETFONT, (WPARAM)hFont, 0);
-
- GetClientRect(hList, &rc);
- rc.right -= GetSystemMetrics(SM_CXVSCROLL);
-
- // initiate the tooltips
- pList->hTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_BALLOON | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hList, nullptr, g_plugin.getInst(), nullptr);
- if (pList->hTip) {
- SetWindowPos(pList->hTip, HWND_TOPMOST, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
-
- memset(&ti, 0, sizeof(TOOLINFO));
- ti.cbSize = sizeof(TOOLINFO);
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS | TTF_TRANSPARENT;
- ti.hinst = g_plugin.getInst();
- ti.hwnd = hList;
- ti.uId = (UINT_PTR)hList;
- SendMessage(pList->hTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
- SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti);
- }
+ // insert columns into the listboxes
+ ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
- // insert columns into the listboxes
- lvc.mask = LVCF_WIDTH;
- lvc.cx = rc.right / 8 * 3;
- ListView_InsertColumn(hList, 0, &lvc);
- lvc.cx = rc.right / 8 * 5;
- ListView_InsertColumn(hList, 1, &lvc);
- return TRUE;
+ PSGetBoldFont(m_hwnd, hFont);
+ SendDlgItemMessage(m_hwnd, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hFont, 0);
+
+ // set listfont
+ pList->hFont = (HFONT)SendMessage(hList, WM_GETFONT, 0, 0);
+ pList->wFlags |= LVF_EDITLABEL;
+ GetObject(pList->hFont, sizeof(lf), &lf);
+ lf.lfHeight -= 6;
+ hFont = CreateFontIndirect(&lf);
+ SendMessage(hList, WM_SETFONT, (WPARAM)hFont, 0);
+
+ GetClientRect(hList, &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ // initiate the tooltips
+ pList->hTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_BALLOON | TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hList, nullptr, g_plugin.getInst(), nullptr);
+ if (pList->hTip) {
+ SetWindowPos(pList->hTip, HWND_TOPMOST, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+
+ TOOLINFO ti;
+ memset(&ti, 0, sizeof(TOOLINFO));
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS | TTF_TRANSPARENT;
+ ti.hinst = g_plugin.getInst();
+ ti.hwnd = hList;
+ ti.uId = (UINT_PTR)hList;
+ SendMessage(pList->hTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
+ SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti);
}
- case WM_CTLCOLORSTATIC:
- case WM_CTLCOLORDLG:
- if (IsAeroMode())
- return (INT_PTR)GetStockBrush(WHITE_BRUSH);
- break;
+ // insert columns into the listboxes
+ lvc.mask = LVCF_WIDTH;
+ lvc.cx = rc.right / 8 * 3;
+ ListView_InsertColumn(hList, 0, &lvc);
+ lvc.cx = rc.right / 8 * 5;
+ ListView_InsertColumn(hList, 1, &lvc);
+ return true;
+ }
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
+ bool OnApply() override
+ {
+ if (pList->wFlags & CTRLF_CHANGED) {
+ uint8_t iFmt = -1;
+ wchar_t szGroup[MAX_PATH];
+ CHAR pszSetting[MAXSETTING];
+ LPLCITEM pItem;
+ int iItem;
+ LPSTR pszModule = USERINFO;
- if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hList)))
- break;
+ if (!m_hContact)
+ PSGetBaseProto(m_hwnd, pszModule);
- // some account data may have changed so reread database
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t msgResult = 0;
- LPIDSTRLIST idList;
- UINT nList;
- uint8_t i;
- int iItem = 0, iGrp = 0, numProtoItems, numUserItems;
-
- if (!(pList->wFlags & CTRLF_CHANGED) && PSGetBaseProto(hDlg, pszProto) && *pszProto != 0) {
- ProfileList_Clear(hList);
-
- // insert the past information
- for (i = 0; i < 3; i++) {
- pFmt[i].GetList((WPARAM)&nList, (LPARAM)&idList);
- if ((numProtoItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hContact, pszProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASPROTO)) < 0)
- return FALSE;
-
- // scan all basic protocols for the subcontacts
- if (DB::Module::IsMetaAndScan(pszProto)) {
- int iDefault = db_mc_getDefaultNum(hContact);
- MCONTACT hSubContact, hDefContact;
- LPCSTR pszSubBaseProto;
-
- if ((hDefContact = db_mc_getSub(hContact, iDefault)) && (pszSubBaseProto = Proto_GetBaseAccountName(hDefContact))) {
- if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hDefContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
- return FALSE;
-
- // copy the missing settings from the other subcontacts
- int numSubs = db_mc_getSubCount(hContact);
- for (int j = 0; j < numSubs; j++) {
- if (j == iDefault)
- continue;
- if (!(hSubContact = db_mc_getSub(hContact, j)))
- continue;
- if (!(pszSubBaseProto = Proto_GetBaseAccountName(hSubContact)))
- continue;
- if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
- return FALSE;
- //if ((numUserItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
- // return FALSE;
- }
- }
- }
- if ((numUserItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASCUSTOM)) < 0)
- return FALSE;
- if (numUserItems || numProtoItems) {
- msgResult = PSP_CHANGED;
- ProfileList_AddGroup(hList, pFmt[i].szGroup, iGrp);
- iGrp = ++iItem;
- }
- }
- }
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, msgResult);
- break;
- }
- // user swiches to another propertysheetpage
- case PSN_KILLACTIVE:
- ProfileList_EndLabelEdit(hList, TRUE);
- break;
- // user selected to apply settings to the database
- case PSN_APPLY:
- if (pList->wFlags & CTRLF_CHANGED) {
- uint8_t iFmt = -1;
- int iItem;
- LVITEM lvi;
- wchar_t szGroup[MAX_PATH];
- CHAR pszSetting[MAXSETTING];
- LPLCITEM pItem;
- LPSTR pszModule = USERINFO;
-
- if (!hContact)
- PSGetBaseProto(hDlg, pszModule);
+ *szGroup = 0;
+ LVITEM lvi;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.pszText = szGroup;
+ lvi.cchTextMax = _countof(szGroup);
+
+ for (iItem = lvi.iItem = lvi.iSubItem = 0; ListView_GetItem(hList, &lvi); lvi.iItem++) {
+ if (!PtrIsValid(pItem = (LPLCITEM)lvi.lParam)) {
+ // delete reluctant items
+ if (iFmt < _countof(pFmt)) {
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
+ }
+ // find information about the group
+ for (iFmt = 0; iFmt < _countof(pFmt); iFmt++) {
+ if (!mir_wstrcmp(szGroup, pFmt[iFmt].szGroup))
+ break;
+ }
+ // indicate, no group was found. should not happen!!
+ if (iFmt == _countof(pFmt)) {
*szGroup = 0;
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.pszText = szGroup;
- lvi.cchTextMax = _countof(szGroup);
-
- for (iItem = lvi.iItem = lvi.iSubItem = 0; ListView_GetItem(hList, &lvi); lvi.iItem++) {
- if (!PtrIsValid(pItem = (LPLCITEM)lvi.lParam)) {
- // delete reluctant items
- if (iFmt < _countof(pFmt)) {
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
- }
- // find information about the group
- for (iFmt = 0; iFmt < _countof(pFmt); iFmt++) {
- if (!mir_wstrcmp(szGroup, pFmt[iFmt].szGroup))
- break;
- }
- // indicate, no group was found. should not happen!!
- if (iFmt == _countof(pFmt)) {
- *szGroup = 0;
- iFmt = -1;
- }
- iItem = 0;
- }
- else if (iFmt >= 0 && iFmt < _countof(pFmt)) {
- // save value
- if (!pItem->pszText[1] || !*pItem->pszText[1])
- continue;
- if (!(pItem->wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA))) {
- mir_snprintf(pszSetting, pFmt[iFmt].szValFmt, iItem);
- db_set_ws(hContact, pszModule, pszSetting, pItem->pszText[1]);
- // save category
- mir_snprintf(pszSetting, pFmt[iFmt].szCatFmt, iItem);
- if (pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount)
- db_set_s(hContact, pszModule, pszSetting, (LPSTR)pItem->idstrList[pItem->iListItem].pszText);
- else if (pItem->pszText[0] && *pItem->pszText[0])
- db_set_ws(hContact, pszModule, pszSetting, (LPTSTR)pItem->pszText[0]);
- else
- db_unset(hContact, pszModule, pszSetting);
- // redraw the item if required
- if (pItem->wFlags & CTRLF_CHANGED) {
- pItem->wFlags &= ~CTRLF_CHANGED;
- ListView_RedrawItems(hList, lvi.iItem, lvi.iItem);
- }
- iItem++;
- }
- }
- }
- // delete reluctant items
- if (iFmt >= 0 && iFmt < _countof(pFmt)) {
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
+ iFmt = -1;
+ }
+ iItem = 0;
+ }
+ else if (iFmt >= 0 && iFmt < _countof(pFmt)) {
+ // save value
+ if (!pItem->pszText[1] || !*pItem->pszText[1])
+ continue;
+ if (!(pItem->wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA))) {
+ mir_snprintf(pszSetting, pFmt[iFmt].szValFmt, iItem);
+ db_set_ws(m_hContact, pszModule, pszSetting, pItem->pszText[1]);
+ // save category
+ mir_snprintf(pszSetting, pFmt[iFmt].szCatFmt, iItem);
+ if (pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount)
+ db_set_s(m_hContact, pszModule, pszSetting, (LPSTR)pItem->idstrList[pItem->iListItem].pszText);
+ else if (pItem->pszText[0] && *pItem->pszText[0])
+ db_set_ws(m_hContact, pszModule, pszSetting, (LPTSTR)pItem->pszText[0]);
+ else
+ db_unset(m_hContact, pszModule, pszSetting);
+ // redraw the item if required
+ if (pItem->wFlags & CTRLF_CHANGED) {
+ pItem->wFlags &= ~CTRLF_CHANGED;
+ ListView_RedrawItems(hList, lvi.iItem, lvi.iItem);
}
-
- pList->wFlags &= ~CTRLF_CHANGED;
+ iItem++;
}
}
}
- break;
+ // delete reluctant items
+ if (iFmt >= 0 && iFmt < _countof(pFmt)) {
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
+ }
- // handle notification messages from the list control
- case LIST_PROFILE:
- pList = (LPLISTCTRL)GetUserData(((LPNMHDR)lParam)->hwndFrom);
+ pList->wFlags &= ~CTRLF_CHANGED;
+ }
+ return true;
+ }
- switch (((LPNMHDR)lParam)->code) {
- case NM_RCLICK:
- {
- HMENU hMenu = CreatePopupMenu();
- MCONTACT hContact;
- LPLCITEM pItem;
- POINT pt;
-
- if (!hMenu)
- return 1;
- PSGetContact(hDlg, hContact);
- GetCursorPos(&pt);
- hi.pt = pt;
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hi.pt);
- ListView_SubItemHitTest(((LPNMHDR)lParam)->hwndFrom, &hi);
- pItem = ProfileList_GetItemData(((LPNMHDR)lParam)->hwndFrom, hi.iItem);
-
- // insert menuitems
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_ID|MIIM_STRING;
- // insert "Add" Menuitem
- mii.wID = BTN_ADD_intEREST;
- mii.dwTypeData = TranslateT("Add interest");
- InsertMenuItem(hMenu, 0, TRUE, &mii);
- mii.wID = BTN_ADD_AFFLIATION;
- mii.dwTypeData = TranslateT("Add affiliation");
- InsertMenuItem(hMenu, 1, TRUE, &mii);
- mii.wID = BTN_ADD_PAST;
- mii.dwTypeData = TranslateT("Add past");
- InsertMenuItem(hMenu, 2, TRUE, &mii);
-
- if (hi.iItem != -1 && PtrIsValid(pItem) && !(hContact && (pItem->wFlags & CTRLF_HASPROTO))) {
- // insert separator
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- InsertMenuItem(hMenu, 3, TRUE, &mii);
- // insert "Delete" Menuitem
- mii.fMask = MIIM_ID | MIIM_STRING;
- mii.wID = BTN_EDIT_CAT;
- mii.dwTypeData = TranslateT("Edit category");
- InsertMenuItem(hMenu, 4, TRUE, &mii);
- mii.wID = BTN_EDIT_VAL;
- mii.dwTypeData = TranslateT("Edit value");
- InsertMenuItem(hMenu, 5, TRUE, &mii);
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- InsertMenuItem(hMenu, 6, TRUE, &mii);
- // insert "Delete" Menuitem
- mii.fMask = MIIM_ID | MIIM_STRING;
- mii.wID = BTN_DEL;
- mii.dwTypeData = TranslateT("Delete");
- InsertMenuItem(hMenu, 7, TRUE, &mii);
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ uint8_t msgResult = 0;
+ LPIDSTRLIST idList;
+ UINT nList;
+ uint8_t i;
+ int iItem = 0, iGrp = 0, numProtoItems, numUserItems;
+
+ if (!(pList->wFlags & CTRLF_CHANGED) && PSGetBaseProto(m_hwnd, pszProto) && *pszProto != 0) {
+ ProfileList_Clear(hList);
+
+ // insert the past information
+ for (i = 0; i < 3; i++) {
+ pFmt[i].GetList((WPARAM)&nList, (LPARAM)&idList);
+ if ((numProtoItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, m_hContact, pszProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASPROTO)) < 0)
+ return false;
+
+ // scan all basic protocols for the subcontacts
+ if (DB::Module::IsMetaAndScan(pszProto)) {
+ int iDefault = db_mc_getDefaultNum(m_hContact);
+ MCONTACT hSubContact, hDefContact;
+ LPCSTR pszSubBaseProto;
+
+ if ((hDefContact = db_mc_getSub(m_hContact, iDefault)) && (pszSubBaseProto = Proto_GetBaseAccountName(hDefContact))) {
+ if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hDefContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
+ return false;
+
+ // copy the missing settings from the other subcontacts
+ int numSubs = db_mc_getSubCount(m_hContact);
+ for (int j = 0; j < numSubs; j++) {
+ if (j == iDefault)
+ continue;
+ if (!(hSubContact = db_mc_getSub(m_hContact, j)))
+ continue;
+ if (!(pszSubBaseProto = Proto_GetBaseAccountName(hSubContact)))
+ continue;
+ if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
+ return false;
+ }
}
- TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hDlg, nullptr);
- DestroyMenu(hMenu);
}
- return 0;
+ if ((numUserItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, m_hContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASCUSTOM)) < 0)
+ return false;
- case LVN_GETDISPINFO:
- if (pList->labelEdit.iTopIndex != ListView_GetTopIndex(hList))
- ProfileList_EndLabelEdit(((LPNMHDR)lParam)->hwndFrom, FALSE);
+ if (numUserItems || numProtoItems) {
+ msgResult = PSP_CHANGED;
+ ProfileList_AddGroup(hList, pFmt[i].szGroup, iGrp);
+ iGrp = ++iItem;
+ }
+ }
+ }
+ return false;
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ LVHITTESTINFO hi;
+
+ switch (uMsg) {
+ case WM_CTLCOLORSTATIC:
+ case WM_CTLCOLORDLG:
+ if (IsAeroMode())
+ return (INT_PTR)GetStockBrush(WHITE_BRUSH);
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ // some account data may have changed so reread database
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_KILLACTIVE: // user swiches to another propertysheetpage
+ ProfileList_EndLabelEdit(hList, TRUE);
+ break;
+ }
break;
- case NM_CUSTOMDRAW:
- {
- LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam;
- LPLCITEM pItem = (LPLCITEM)cd->nmcd.lItemlParam;
- RECT rc;
-
- switch (cd->nmcd.dwDrawStage) {
- case CDDS_PREPAINT:
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
- return TRUE;
-
- case CDDS_ITEMPREPAINT:
- ListView_GetItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, &rc, LVIR_BOUNDS);
- if (!PtrIsValid(pItem)) {
- HFONT hBold, hFont;
- wchar_t szText[MAX_PATH];
-
- PSGetBoldFont(hDlg, hBold);
- hFont = (HFONT)SelectObject(cd->nmcd.hdc, hBold);
- SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_3DSHADOW));
- ProfileList_GetItemText(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, 0, szText, MAX_PATH);
- rc.left += 6;
- DrawText(cd->nmcd.hdc, TranslateW(szText), -1, &rc, DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
-
- rc.bottom -= 2;
- rc.top = rc.bottom - 1;
- rc.left -= 6;
- DrawEdge(cd->nmcd.hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
-
- SelectObject(cd->nmcd.hdc, hFont);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
- // draw selected item
- if ((cd->nmcd.uItemState & CDIS_SELECTED) || (pList->labelEdit.iItem == (int)cd->nmcd.dwItemSpec)) {
- SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
- FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
- }
- // draw background of unselected item
- else {
- SetTextColor(cd->nmcd.hdc,
- (pItem->wFlags & CTRLF_CHANGED)
- ? clrChanged : (pItem->wFlags & CTRLF_HASMETA)
- ? clrMeta : ((pItem->wFlags & (CTRLF_HASCUSTOM)) && (pItem->wFlags & CTRLF_HASPROTO))
- ? clrBoth : (pItem->wFlags & CTRLF_HASCUSTOM)
- ? clrCustom : clrNormal);
- FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
+ // handle notification messages from the list control
+ case LIST_PROFILE:
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_RCLICK:
+ {
+ HMENU hMenu = CreatePopupMenu();
+ if (!hMenu)
+ return 1;
+
+ POINT pt;
+ GetCursorPos(&pt);
+ hi.pt = pt;
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hi.pt);
+ ListView_SubItemHitTest(((LPNMHDR)lParam)->hwndFrom, &hi);
+ LPLCITEM pItem = ProfileList_GetItemData(((LPNMHDR)lParam)->hwndFrom, hi.iItem);
+
+ // insert menuitems
+ MENUITEMINFO mii = { 0 };
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_ID|MIIM_STRING;
+ // insert "Add" Menuitem
+ mii.wID = BTN_ADD_intEREST;
+ mii.dwTypeData = TranslateT("Add interest");
+ InsertMenuItem(hMenu, 0, TRUE, &mii);
+ mii.wID = BTN_ADD_AFFLIATION;
+ mii.dwTypeData = TranslateT("Add affiliation");
+ InsertMenuItem(hMenu, 1, TRUE, &mii);
+ mii.wID = BTN_ADD_PAST;
+ mii.dwTypeData = TranslateT("Add past");
+ InsertMenuItem(hMenu, 2, TRUE, &mii);
+
+ if (hi.iItem != -1 && PtrIsValid(pItem) && !(m_hContact && (pItem->wFlags & CTRLF_HASPROTO))) {
+ // insert separator
+ mii.fMask = MIIM_FTYPE;
+ mii.fType = MFT_SEPARATOR;
+ InsertMenuItem(hMenu, 3, TRUE, &mii);
+ // insert "Delete" Menuitem
+ mii.fMask = MIIM_ID | MIIM_STRING;
+ mii.wID = BTN_EDIT_CAT;
+ mii.dwTypeData = TranslateT("Edit category");
+ InsertMenuItem(hMenu, 4, TRUE, &mii);
+ mii.wID = BTN_EDIT_VAL;
+ mii.dwTypeData = TranslateT("Edit value");
+ InsertMenuItem(hMenu, 5, TRUE, &mii);
+ mii.fMask = MIIM_FTYPE;
+ mii.fType = MFT_SEPARATOR;
+ InsertMenuItem(hMenu, 6, TRUE, &mii);
+ // insert "Delete" Menuitem
+ mii.fMask = MIIM_ID | MIIM_STRING;
+ mii.wID = BTN_DEL;
+ mii.dwTypeData = TranslateT("Delete");
+ InsertMenuItem(hMenu, 7, TRUE, &mii);
}
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT | CDRF_NOTIFYSUBITEMDRAW);
- return TRUE;
+ TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hwnd, nullptr);
+ DestroyMenu(hMenu);
+ }
+ return 0;
- case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
- {
-// HFONT hoFont = (HFONT)SelectObject(cd->nmcd.hdc, pList->hFont);
+ case LVN_GETDISPINFO:
+ if (pList->labelEdit.iTopIndex != ListView_GetTopIndex(hList))
+ ProfileList_EndLabelEdit(((LPNMHDR)lParam)->hwndFrom, FALSE);
+ break;
+
+ case NM_CUSTOMDRAW:
+ {
+ LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam;
+ LPLCITEM pItem = (LPLCITEM)cd->nmcd.lItemlParam;
+ RECT rc;
+ switch (cd->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
+ return TRUE;
+
+ case CDDS_ITEMPREPAINT:
+ ListView_GetItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, &rc, LVIR_BOUNDS);
+ if (!PtrIsValid(pItem)) {
+ HFONT hBold, hFont;
+ wchar_t szText[MAX_PATH];
+
+ PSGetBoldFont(m_hwnd, hBold);
+ hFont = (HFONT)SelectObject(cd->nmcd.hdc, hBold);
+ SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_3DSHADOW));
+ ProfileList_GetItemText(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, 0, szText, MAX_PATH);
+ rc.left += 6;
+ DrawText(cd->nmcd.hdc, TranslateW(szText), -1, &rc, DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
+
+ rc.bottom -= 2;
+ rc.top = rc.bottom - 1;
+ rc.left -= 6;
+ DrawEdge(cd->nmcd.hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
+
+ SelectObject(cd->nmcd.hdc, hFont);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+ return TRUE;
+ }
+ // draw selected item
+ if ((cd->nmcd.uItemState & CDIS_SELECTED) || (pList->labelEdit.iItem == (int)cd->nmcd.dwItemSpec)) {
+ SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
+ }
+ // draw background of unselected item
+ else {
+ SetTextColor(cd->nmcd.hdc,
+ (pItem->wFlags & CTRLF_CHANGED)
+ ? clrChanged : (pItem->wFlags & CTRLF_HASMETA)
+ ? clrMeta : ((pItem->wFlags & (CTRLF_HASCUSTOM)) && (pItem->wFlags & CTRLF_HASPROTO))
+ ? clrBoth : (pItem->wFlags & CTRLF_HASCUSTOM)
+ ? clrCustom : clrNormal);
+ FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
+ }
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NEWFONT | CDRF_NOTIFYSUBITEMDRAW);
+ return TRUE;
+
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
ListView_GetSubItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, cd->iSubItem, LVIR_BOUNDS, &rc);
if (cd->iSubItem == 0) {
RECT rc2;
@@ -1383,47 +1376,55 @@ INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR ? pItem->idstrList[pItem->iListItem].ptszTranslated
: TranslateT("<empty>"),
-1, &rc, DT_END_ELLIPSIS | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
return TRUE;
- }
- } /* switch (cd->nmcd.dwDrawStage) */
- break;
- } /* case NM_CUSTOMDRAW: */
- } /* (((LPNMHDR)lParam)->code) */
- break;
- }
- break; /* case WM_NOTIFY: */
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case BTN_ADD_intEREST:
- return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[2]);
- case BTN_ADD_AFFLIATION:
- return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[1]);
- case BTN_ADD_PAST:
- return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[0]);
- case BTN_EDIT_CAT:
- ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 0);
- break;
- case BTN_EDIT_VAL:
- ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 1);
- break;
- case BTN_DEL:
- if (IDYES == MsgBox(hDlg, MB_YESNO | MB_ICON_QUESTION, LPGENW("Question"), LPGENW("Delete an entry"), LPGENW("Do you really want to delete this entry?"))) {
- int iItem = ListView_GetSelectionMark(hList);
- pList = (LPLISTCTRL)GetUserData(hList);
-
- ProfileList_DeleteItem(hList, iItem);
- if (PtrIsValid(pList))
- pList->wFlags |= CTRLF_CHANGED;
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- // check if to delete any devider
- if (!ProfileList_GetItemData(hList, iItem--) && !ProfileList_GetItemData(hList, iItem))
- ListView_DeleteItem(hList, iItem);
+ } /* switch (cd->nmcd.dwDrawStage) */
+ break;
+ } /* case NM_CUSTOMDRAW: */
+ } /* (((LPNMHDR)lParam)->code) */
+ break;
+ }
+ break; /* case WM_NOTIFY: */
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case BTN_ADD_intEREST:
+ return ProfileList_AddNewItem(m_hwnd, (LPLISTCTRL)GetUserData(hList), &pFmt[2]);
+ case BTN_ADD_AFFLIATION:
+ return ProfileList_AddNewItem(m_hwnd, (LPLISTCTRL)GetUserData(hList), &pFmt[1]);
+ case BTN_ADD_PAST:
+ return ProfileList_AddNewItem(m_hwnd, (LPLISTCTRL)GetUserData(hList), &pFmt[0]);
+ case BTN_EDIT_CAT:
+ ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 0);
+ break;
+ case BTN_EDIT_VAL:
+ ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 1);
+ break;
+ case BTN_DEL:
+ if (IDYES == MsgBox(m_hwnd, MB_YESNO | MB_ICON_QUESTION, LPGENW("Question"), LPGENW("Delete an entry"), LPGENW("Do you really want to delete this entry?"))) {
+ int iItem = ListView_GetSelectionMark(hList);
+ ProfileList_DeleteItem(hList, iItem);
+
+ if (PtrIsValid(pList))
+ pList->wFlags |= CTRLF_CHANGED;
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, NULL, NULL);
+ // check if to delete any devider
+ if (!ProfileList_GetItemData(hList, iItem--) && !ProfileList_GetItemData(hList, iItem))
+ ListView_DeleteItem(hList, iItem);
+ }
+ break;
}
break;
}
- break;
+ return FALSE;
}
- return FALSE;
+};
+
+void InitProfileDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000007;
+ uip.pDialog = new PSPContactProfileDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_PROFILE);
+ uip.szTitle.w = LPGENW("About") L"\\" LPGENW("Profile");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/stdafx.h b/plugins/UserInfoEx/src/stdafx.h index cafc703717..2d71b7698a 100644 --- a/plugins/UserInfoEx/src/stdafx.h +++ b/plugins/UserInfoEx/src/stdafx.h @@ -103,6 +103,14 @@ using namespace std; #define GetUserData(p) GetWindowLongPtr((p), GWLP_USERDATA)
#define SetUserData(p, l) SetWindowLongPtr((p), GWLP_USERDATA, (LONG_PTR) (l))
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin();
+
+ int Load() override;
+ int Unload() override;
+};
+
#include "resource.h"
#include "version.h"
#include "../IconPacks/default/src/icons.h"
@@ -150,14 +158,6 @@ using namespace std; * UserInfoEx global variables
***********************************************************************************************************/
-struct CMPlugin : public PLUGIN<CMPlugin>
-{
- CMPlugin();
-
- int Load() override;
- int Unload() override;
-};
-
typedef struct _MGLOBAL
{
uint8_t CanChangeDetails : 1; // is service to upload own contact information for icq present?
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)¶m);
- else
- res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
- 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)¶m);
- else
- res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
- 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)¶m);
+ else
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), m_hwnd, EditEmailDlgProc, (LPARAM)¶m);
+ 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)¶m);
+ else
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), m_hwnd, EditEmailDlgProc, (LPARAM)¶m);
+ 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; } diff --git a/src/core/stdfile/res/resource.rc b/src/core/stdfile/res/resource.rc index d989716f8c..28dba7a490 100644 --- a/src/core/stdfile/res/resource.rc +++ b/src/core/stdfile/res/resource.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script.
//
-#include "..\..\mir_app\src\resource.h"
+#include "..\..\..\mir_app\src\resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@@ -270,7 +270,7 @@ END 1 TEXTINCLUDE
BEGIN
- "..\\..\\mir_app\\src\\resource.h\0"
+ "..\\..\\..\\mir_app\\src\\resource.h\0"
END
2 TEXTINCLUDE
diff --git a/src/core/stduserinfo/res/resource.rc b/src/core/stduserinfo/res/resource.rc index 880b1583cc..6ec5cfbd2b 100644 --- a/src/core/stduserinfo/res/resource.rc +++ b/src/core/stduserinfo/res/resource.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script.
//
-#include "..\..\mir_app\src\resource.h"
+#include "..\..\..\mir_app\src\resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@@ -27,6 +27,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US IDC_HYPERLINKHAND CURSOR "cursor_hyperlink.cur"
+
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
@@ -61,7 +62,7 @@ BEGIN END
IDD_DETAILS DIALOGEX 0, 0, 318, 210
-STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_CONTROLPARENT
CAPTION "%s: user details"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -69,10 +70,10 @@ BEGIN CONTROL "View personal user details and more",IDC_HEADERBAR,
"MHeaderbarCtrl",0x0,0,0,318,25
CONTROL "",IDC_PAGETREE,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_TRACKSELECT | TVS_FULLROWSELECT | TVS_NONEVENHEIGHT | WS_HSCROLL | WS_TABSTOP,3,30,76,176,WS_EX_STATICEDGE
- CONTROL "Tab1",IDC_TABS,"SysTabControl32",TCS_HOTTRACK | TCS_MULTILINE | WS_TABSTOP,85,29,228,158
PUSHBUTTON "Update now",IDC_UPDATE,85,191,55,14,WS_DISABLED
CTEXT "Updating",IDC_UPDATING,145,194,113,8,SS_NOPREFIX | SS_CENTERIMAGE
DEFPUSHBUTTON "OK",IDOK,263,191,50,14
+ LTEXT "",IDC_TABS,87,30,225,155,NOT WS_VISIBLE | WS_BORDER
END
IDD_INFO_SUMMARY DIALOGEX 0, 0, 222, 132
@@ -187,7 +188,6 @@ BEGIN CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,57,109,160,8
END
-#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -197,6 +197,26 @@ END #ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
+ IDD_ADDPHONE, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 205
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 86
+ END
+
+ IDD_ADDEMAIL, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 182
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 37
+ END
+
+ IDD_DETAILS, DIALOG
+ BEGIN
+ END
+
IDD_INFO_CONTACT, DIALOG
BEGIN
LEFTMARGIN, 5
@@ -256,24 +276,7 @@ BEGIN HORZGUIDE, 94
HORZGUIDE, 105
END
-
- IDD_ADDEMAIL, DIALOG
- BEGIN
- LEFTMARGIN, 5
- RIGHTMARGIN, 182
- TOPMARGIN, 5
- BOTTOMMARGIN, 37
- END
-
- IDD_ADDPHONE, DIALOG
- BEGIN
- LEFTMARGIN, 5
- RIGHTMARGIN, 205
- TOPMARGIN, 5
- BOTTOMMARGIN, 86
- END
END
-
#endif // APSTUDIO_INVOKED
@@ -283,22 +286,49 @@ END // TEXTINCLUDE
//
-1 TEXTINCLUDE
+1 TEXTINCLUDE
BEGIN
- "..\..\mir_app\src\resource.h\0"
+ "..\\..\\..\\mir_app\\src\\resource.h\0"
END
-2 TEXTINCLUDE
+2 TEXTINCLUDE
BEGIN
"#include <windows.h>\r\n"
"#include <winres.h>\r\n"
"\0"
END
-3 TEXTINCLUDE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_DETAILS AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index 8e501e399e..df0895005b 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -214,23 +214,26 @@ static int IsOverEmail(HWND hwndDlg, wchar_t *szEmail, int cchEmail) return 0;
}
-#define M_REMAKELISTS (WM_USER+1)
-INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+class CContactPage : public CUserInfoPageDlg
{
- int i;
- RECT rc;
- LOGFONT lf;
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ CCtrlListView m_emails, m_phones;
+
+public:
+ CContactPage() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_CONTACT),
+ m_emails(this, IDC_EMAILS),
+ m_phones(this, IDC_PHONES)
+ {
+ m_emails.OnCustomDraw = m_phones.OnCustomDraw = Callback(this, &CContactPage::onCustomDraw);
+ }
+ bool OnInitDialog() override
+ {
if (hEmailFont)
DeleteObject(hEmailFont);
+ hEmailFont = (HFONT)m_emails.SendMsg(WM_GETFONT, 0, 0);
- hEmailFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_EMAILS, WM_GETFONT, 0, 0);
+ LOGFONT lf;
GetObject(hEmailFont, sizeof(lf), &lf);
lf.lfUnderline = 1;
hEmailFont = CreateFontIndirect(&lf);
@@ -238,304 +241,296 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (hHandCursor == nullptr)
hHandCursor = LoadCursor(nullptr, IDC_HAND);
- GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc);
+ RECT rc;
+ GetClientRect(m_emails.GetHwnd(), &rc);
rc.right -= GetSystemMetrics(SM_CXVSCROLL);
LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH;
- ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
- ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+ m_emails.SetExtendedListViewStyleEx(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+ m_phones.SetExtendedListViewStyleEx(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
lvc.cx = rc.right / 4;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc);
+ m_emails.InsertColumn(0, &lvc);
+ m_phones.InsertColumn(0, &lvc);
lvc.cx = rc.right - rc.right / 4 - 40;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc);
+ m_emails.InsertColumn(1, &lvc);
lvc.cx = rc.right - rc.right / 4 - 90;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc);
+ m_phones.InsertColumn(1, &lvc);
lvc.cx = 50;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc);
+ m_phones.InsertColumn(2, &lvc);
lvc.cx = 20;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 2, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 3, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 4, &lvc);
- break;
-
- case M_REMAKELISTS:
- if (hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr)
- break;
-
- //e-mails
- ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS));
-
- char idstr[33];
- wchar_t idstr2[33];
- DBVARIANT dbv;
-
- LVITEM lvi;
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.lParam = -1;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- for (i = -1;; i++) {
- if (i == -1) {
- if (db_get_ws(hContact, szProto, "e-mail", &dbv))
- continue;
- lvi.pszText = TranslateT("Primary");
- }
- else {
- mir_snprintf(idstr, "e-mail%d", i);
- if (db_get_ws(hContact, szProto, idstr, &dbv))
- break;
+ m_emails.InsertColumn(2, &lvc);
+ m_emails.InsertColumn(3, &lvc);
+ m_phones.InsertColumn(3, &lvc);
+ m_phones.InsertColumn(4, &lvc);
+ return true;
+ }
- lvi.pszText = idstr2;
- mir_snwprintf(idstr2, L"%d", i + 2);
- }
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
+ bool OnRefresh() override
+ {
+ if (m_hContact == 0)
+ return false;
+
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ return false;
+
+ // e-mails
+ m_emails.DeleteAllItems();
+
+ char idstr[33];
+ wchar_t idstr2[33];
+ DBVARIANT dbv;
+
+ LVITEM lvi;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = -1;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ for (int i = -1;; i++) {
+ if (i == -1) {
+ if (db_get_ws(m_hContact, szProto, "e-mail", &dbv))
+ continue;
+ lvi.pszText = TranslateT("Primary");
}
- lvi.iSubItem = 0;
- for (i = 0;; i++) {
- lvi.lParam = i;
- mir_snprintf(idstr, "Mye-mail%d", i);
- if (g_plugin.getWString(hContact, idstr, &dbv))
+ else {
+ mir_snprintf(idstr, "e-mail%d", i);
+ if (db_get_ws(m_hContact, szProto, idstr, &dbv))
break;
+
lvi.pszText = idstr2;
- mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1);
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
+ mir_snwprintf(idstr2, L"%d", i + 2);
}
- lvi.mask = LVIF_PARAM;
- lvi.lParam = -2;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
- //phones
- ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES));
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.lParam = -1;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- if (!db_get_ws(hContact, szProto, "Phone", &dbv)) {
- lvi.pszText = TranslateT("Primary");
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
- }
- if (!db_get_ws(hContact, szProto, "Fax", &dbv)) {
- lvi.pszText = TranslateT("Fax");
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
- }
- if (!db_get_ws(hContact, szProto, "Cellular", &dbv)) {
- lvi.pszText = TranslateT("Mobile");
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- if (mir_strlen(dbv.pszVal) > 4 && !mir_strcmp(dbv.pszVal + mir_strlen(dbv.pszVal) - 4, " SMS")) {
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, L"y");
- dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0';
- }
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
- }
- if (!db_get_ws(hContact, szProto, "CompanyPhone", &dbv)) {
- lvi.pszText = TranslateT("Work phone");
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
- }
- if (!db_get_ws(hContact, szProto, "CompanyFax", &dbv)) {
- lvi.pszText = TranslateT("Work fax");
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
+ m_emails.InsertItem(&lvi);
+ m_emails.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ lvi.iSubItem = 0;
+ for (int i = 0;; i++) {
+ lvi.lParam = i;
+ mir_snprintf(idstr, "Mye-mail%d", i);
+ if (g_plugin.getWString(m_hContact, idstr, &dbv))
+ break;
+ lvi.pszText = idstr2;
+ mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1);
+ m_emails.InsertItem(&lvi);
+ m_emails.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ lvi.mask = LVIF_PARAM;
+ lvi.lParam = -2;
+ m_emails.InsertItem(&lvi);
+
+ // phones
+ m_phones.DeleteAllItems();
+
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = -1;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ if (!db_get_ws(m_hContact, szProto, "Phone", &dbv)) {
+ lvi.pszText = TranslateT("Primary");
+ m_phones.InsertItem(&lvi);
+ m_phones.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ if (!db_get_ws(m_hContact, szProto, "Fax", &dbv)) {
+ lvi.pszText = TranslateT("Fax");
+ m_phones.InsertItem(&lvi);
+ m_phones.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ if (!db_get_ws(m_hContact, szProto, "Cellular", &dbv)) {
+ lvi.pszText = TranslateT("Mobile");
+ m_phones.InsertItem(&lvi);
+ if (mir_strlen(dbv.pszVal) > 4 && !mir_strcmp(dbv.pszVal + mir_strlen(dbv.pszVal) - 4, " SMS")) {
+ m_phones.SetItemText(lvi.iItem, 2, L"y");
+ dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0';
}
- lvi.iSubItem = 0;
- for (i = 0;; i++) {
- lvi.lParam = i;
- mir_snprintf(idstr, "MyPhone%d", i);
- if (g_plugin.getWString(hContact, idstr, &dbv))
- break;
- lvi.pszText = idstr2;
- mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1);
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- if (mir_wstrlen(dbv.pwszVal) > 4 && !mir_wstrcmp(dbv.pwszVal + mir_wstrlen(dbv.pwszVal) - 4, L" SMS")) {
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, L"y");
- dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0';
- }
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal);
- db_free(&dbv);
- lvi.iItem++;
+ m_phones.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ if (!db_get_ws(m_hContact, szProto, "CompanyPhone", &dbv)) {
+ lvi.pszText = TranslateT("Work phone");
+ m_phones.InsertItem(&lvi);
+ m_phones.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ if (!db_get_ws(m_hContact, szProto, "CompanyFax", &dbv)) {
+ lvi.pszText = TranslateT("Work fax");
+ m_phones.InsertItem(&lvi);
+ m_phones.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
+ }
+ lvi.iSubItem = 0;
+ for (int i = 0;; i++) {
+ lvi.lParam = i;
+ mir_snprintf(idstr, "MyPhone%d", i);
+ if (g_plugin.getWString(m_hContact, idstr, &dbv))
+ break;
+ lvi.pszText = idstr2;
+ mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1);
+ m_phones.InsertItem(&lvi);
+ if (mir_wstrlen(dbv.pwszVal) > 4 && !mir_wstrcmp(dbv.pwszVal + mir_wstrlen(dbv.pwszVal) - 4, L" SMS")) {
+ m_phones.SetItemText(lvi.iItem, 2, L"y");
+ dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0';
}
- lvi.mask = LVIF_PARAM;
- lvi.lParam = -2;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
+ m_phones.SetItemText(lvi.iItem, 1, dbv.pwszVal);
+ db_free(&dbv);
+ lvi.iItem++;
}
- break;
+ lvi.mask = LVIF_PARAM;
+ lvi.lParam = -2;
+ m_phones.InsertItem(&lvi);
+ return false;
+ }
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED)
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
+ void onCustomDraw(CCtrlListView::TEventInfo *ev)
+ {
+ NMLVCUSTOMDRAW *nm = ev->nmcd;
+ switch (nm->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ case CDDS_ITEMPREPAINT:
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
break;
- case IDC_EMAILS:
- case IDC_PHONES:
- switch (((LPNMHDR)lParam)->code) {
- case NM_CUSTOMDRAW:
- {
- NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW *)lParam;
- switch (nm->nmcd.dwDrawStage) {
- case CDDS_PREPAINT:
- case CDDS_ITEMPREPAINT:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
- return TRUE;
-
- case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
- ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
- if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) {
- HFONT hoFont;
- wchar_t szText[256] = { 0 };
- ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
- hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont);
- SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255));
- DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_TOP);
- SelectObject(nm->nmcd.hdc, hoFont);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
-
- HICON hIcon = NULL;
- if (nm->nmcd.lItemlParam == -2 && nm->iSubItem - 3 == (nm->nmcd.hdr.idFrom == IDC_PHONES))
- hIcon = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
- else if (nm->iSubItem > 1 && nm->nmcd.lItemlParam != -1 && nm->nmcd.lItemlParam != -2) {
- static int iconResources[3] = { SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE };
- if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) {
- wchar_t szText[2];
- ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
- if (szText[0]) hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
- }
- else hIcon = Skin_LoadIcon(iconResources[nm->iSubItem - 3 + (nm->nmcd.hdr.idFrom == IDC_EMAILS)]);
- }
- else break;
- DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
- IcoLib_ReleaseIcon(hIcon, 0);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
- }
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
+ RECT rc;
+ ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
+ if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) {
+ HFONT hoFont;
+ wchar_t szText[256] = { 0 };
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
+ hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont);
+ SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255));
+ DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_TOP);
+ SelectObject(nm->nmcd.hdc, hoFont);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
break;
+ }
- case NM_CLICK:
- NMLISTVIEW *nm = (NMLISTVIEW *)lParam;
- char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d";
-
- wchar_t szEmail[256];
- if (IsOverEmail(hwndDlg, szEmail, _countof(szEmail))) {
- wchar_t szExec[264];
- mir_snwprintf(szExec, L"mailto:%s", szEmail);
- ShellExecute(hwndDlg, L"open", szExec, NULL, NULL, SW_SHOW);
- break;
+ HICON hIcon = NULL;
+ if (nm->nmcd.lItemlParam == -2 && nm->iSubItem - 3 == (nm->nmcd.hdr.idFrom == IDC_PHONES))
+ hIcon = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
+ else if (nm->iSubItem > 1 && nm->nmcd.lItemlParam != -1 && nm->nmcd.lItemlParam != -2) {
+ static int iconResources[3] = { SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE };
+ if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) {
+ wchar_t szText[2];
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
+ if (szText[0]) hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
}
- if (nm->iSubItem < 2)
- break;
-
- 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)
- break;
+ else hIcon = Skin_LoadIcon(iconResources[nm->iSubItem - 3 + (nm->nmcd.hdr.idFrom == IDC_EMAILS)]);
+ }
+ else break;
+ DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ IcoLib_ReleaseIcon(hIcon, 0);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+ }
+ }
- if (lvi.lParam == -2) {
- if (hti.iSubItem - 3 == (nm->hdr.idFrom == IDC_PHONES)) {
- // add
- char szNewData[256] = "", idstr[33];
- DBVARIANT dbv;
- if (IDOK != DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES ? IDD_ADDPHONE : IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES ? EditUserPhoneDlgProc : EditUserEmailDlgProc, (LPARAM)szNewData))
- break;
- for (i = 0;; i++) {
- mir_snprintf(idstr, szIdTemplate, i);
- if (g_plugin.getString(hContact, idstr, &dbv)) break;
- db_free(&dbv);
- }
- g_plugin.setString(hContact, idstr, szNewData);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- }
- }
- else if (hti.iSubItem - 3 == (nm->hdr.idFrom == IDC_PHONES)) {
- // delete
- char idstr[33];
- DBVARIANT dbv;
- for (i = lvi.lParam;; i++) {
- mir_snprintf(idstr, szIdTemplate, i + 1);
- if (g_plugin.getString(hContact, idstr, &dbv)) break;
- mir_snprintf(idstr, szIdTemplate, i);
- g_plugin.setString(hContact, idstr, dbv.pszVal);
- db_free(&dbv);
- }
+ void onClick(CCtrlListView::TEventInfo *ev)
+ {
+ NMLISTVIEW *nm = ev->nmlv;
+ char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d";
+ int i;
+
+ wchar_t szEmail[256];
+ if (IsOverEmail(m_hwnd, szEmail, _countof(szEmail))) {
+ wchar_t szExec[264];
+ mir_snwprintf(szExec, L"mailto:%s", szEmail);
+ ShellExecute(m_hwnd, L"open", szExec, NULL, NULL, SW_SHOW);
+ return;
+ }
+ if (nm->iSubItem < 2)
+ return;
+
+ 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)
+ return;
+
+ if (lvi.lParam == -2) {
+ if (hti.iSubItem - 3 == (nm->hdr.idFrom == IDC_PHONES)) {
+ // add
+ char szNewData[256] = "", idstr[33];
+ DBVARIANT dbv;
+ if (IDOK != DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES ? IDD_ADDPHONE : IDD_ADDEMAIL), m_hwnd, nm->hdr.idFrom == IDC_PHONES ? EditUserPhoneDlgProc : EditUserEmailDlgProc, (LPARAM)szNewData))
+ return;
+
+ for (i = 0;; i++) {
mir_snprintf(idstr, szIdTemplate, i);
- g_plugin.delSetting(hContact, idstr);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- }
- else if (hti.iSubItem - 2 == (nm->hdr.idFrom == IDC_PHONES)) {
- // edit
- char szText[256], idstr[33];
- DBVARIANT dbv;
- mir_snprintf(idstr, szIdTemplate, lvi.lParam);
- if (g_plugin.getString(hContact, idstr, &dbv)) break;
- mir_strncpy(szText, dbv.pszVal, _countof(szText));
+ if (g_plugin.getString(m_hContact, idstr, &dbv)) break;
db_free(&dbv);
- if (IDOK != DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES ? IDD_ADDPHONE : IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES ? EditUserPhoneDlgProc : EditUserEmailDlgProc, (LPARAM)szText))
- break;
- g_plugin.setString(hContact, idstr, szText);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
}
+ g_plugin.setString(m_hContact, idstr, szNewData);
+ OnRefresh();
}
}
- break;
-
- case WM_SETCURSOR:
- if (LOWORD(lParam) != HTCLIENT)
- break;
-
- if (GetForegroundWindow() == GetParent(hwndDlg)) {
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwndDlg, &pt);
+ else if (hti.iSubItem - 3 == (nm->hdr.idFrom == IDC_PHONES)) {
+ // delete
+ char idstr[33];
+ DBVARIANT dbv;
+ for (i = lvi.lParam;; i++) {
+ mir_snprintf(idstr, szIdTemplate, i + 1);
+ if (g_plugin.getString(m_hContact, idstr, &dbv)) break;
+ mir_snprintf(idstr, szIdTemplate, i);
+ g_plugin.setString(m_hContact, idstr, dbv.pszVal);
+ db_free(&dbv);
+ }
+ mir_snprintf(idstr, szIdTemplate, i);
+ g_plugin.delSetting(m_hContact, idstr);
+ OnRefresh();
}
- if (IsOverEmail(hwndDlg, nullptr, 0)) {
- SetCursor(hHandCursor);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
+ else if (hti.iSubItem - 2 == (nm->hdr.idFrom == IDC_PHONES)) {
+ // edit
+ char szText[256], idstr[33];
+ DBVARIANT dbv;
+ mir_snprintf(idstr, szIdTemplate, lvi.lParam);
+ if (g_plugin.getString(m_hContact, idstr, &dbv))
+ return;
+ mir_strncpy(szText, dbv.pszVal, _countof(szText));
+ db_free(&dbv);
+ if (IDOK != DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES ? IDD_ADDPHONE : IDD_ADDEMAIL), m_hwnd, nm->hdr.idFrom == IDC_PHONES ? EditUserPhoneDlgProc : EditUserEmailDlgProc, (LPARAM)szText))
+ return;
+ g_plugin.setString(m_hContact, idstr, szText);
+ OnRefresh();
}
- break;
+ }
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (msg == WM_SETCURSOR && LOWORD(lParam) == HTCLIENT) {
+ if (IsOverEmail(m_hwnd, nullptr, 0)) {
+ SetCursor(hHandCursor);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
}
- break;
+
+ return CDlgBase::DlgProc(msg, wParam, lParam);
}
- return FALSE;
+};
+
+void InitContactInfo(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.pDialog = new CContactPage();
+ uip.szTitle.a = LPGEN("Contact");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/src/core/stduserinfo/src/main.cpp b/src/core/stduserinfo/src/main.cpp index d46195576a..5334c9727f 100644 --- a/src/core/stduserinfo/src/main.cpp +++ b/src/core/stduserinfo/src/main.cpp @@ -41,7 +41,7 @@ PLUGININFOEX pluginInfoEx = { };
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>("UserInfo", pluginInfoEx)
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/stduserinfo/src/stdafx.h b/src/core/stduserinfo/src/stdafx.h index 43b1528d9a..d5e61f94f5 100644 --- a/src/core/stduserinfo/src/stdafx.h +++ b/src/core/stduserinfo/src/stdafx.h @@ -41,6 +41,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <direct.h>
#include <malloc.h>
+#include <map>
+
#include <m_system.h>
#include <m_core.h>
#include <newpluginapi.h>
@@ -67,6 +69,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../../mir_app/src/resource.h"
+#define MODULENAME "UserInfo"
+
struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index 93e1648872..da987d8039 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
#define SVS_NORMAL 0
#define SVS_GENDER 1
#define SVS_ZEROISUNSPEC 2
@@ -36,7 +34,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP #define SVS_TIMEZONE 7
#define SVS_MARITAL 8
-static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special)
+static void SetValue(HWND m_hwnd, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special)
{
char *pstr = nullptr;
wchar_t *pwstr = nullptr, wstr[80];
@@ -162,7 +160,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule case DBVT_UTF8:
unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0');
if (!unspecified) {
- SetDlgItemTextW(hwndDlg, idCtrl, TranslateW(ptrW(mir_utf8decodeW(dbv.pszVal))));
+ SetDlgItemTextW(m_hwnd, idCtrl, TranslateW(ptrW(mir_utf8decodeW(dbv.pszVal))));
goto LBL_Exit;
}
@@ -178,398 +176,362 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule }
if (unspecified)
- SetDlgItemText(hwndDlg, idCtrl, TranslateT("<not specified>"));
+ SetDlgItemText(m_hwnd, idCtrl, TranslateT("<not specified>"));
else if (pwstr != nullptr)
- SetDlgItemText(hwndDlg, idCtrl, pwstr);
+ SetDlgItemText(m_hwnd, idCtrl, pwstr);
else
- SetDlgItemTextA(hwndDlg, idCtrl, pstr);
+ SetDlgItemTextA(m_hwnd, idCtrl, pstr);
LBL_Exit:
- EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified);
+ EnableWindow(GetDlgItem(m_hwnd, idCtrl), !unspecified);
db_free(&dbv);
}
-static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Summary dlg page
+
+class CSummaryDlg : public CUserInfoPageDlg
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- if (hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr)
- break;
+ CCtrlHyperlink m_email;
+
+public:
+ CSummaryDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_SUMMARY),
+ m_email(this, IDC_EMAIL)
+ {
+ m_email.OnClick = Callback(this, &CSummaryDlg::onClick_Email);
+ }
- SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0);
- SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", 0);
- SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", 0);
- SetValue(hwndDlg, IDC_EMAIL, hContact, szProto, "e-mail", 0);
- SetValue(hwndDlg, IDC_AGE, hContact, szProto, "Age", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER);
- SetValue(hwndDlg, IDC_DOBDAY, hContact, szProto, "BirthDay", 0);
- SetValue(hwndDlg, IDC_DOBMONTH, hContact, szProto, "BirthMonth", SVS_MONTH);
- SetValue(hwndDlg, IDC_DOBYEAR, hContact, szProto, "BirthYear", 0);
- SetValue(hwndDlg, IDC_MARITAL, hContact, szProto, "MaritalStatus", SVS_MARITAL);
- }
- }
- break;
- }
- break;
+ bool OnRefresh() override
+ {
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ return false;
+
+ SetValue(m_hwnd, IDC_NICK, m_hContact, szProto, "Nick", 0);
+ SetValue(m_hwnd, IDC_FIRSTNAME, m_hContact, szProto, "FirstName", 0);
+ SetValue(m_hwnd, IDC_LASTNAME, m_hContact, szProto, "LastName", 0);
+ SetValue(m_hwnd, IDC_EMAIL, m_hContact, szProto, "e-mail", 0);
+ SetValue(m_hwnd, IDC_AGE, m_hContact, szProto, "Age", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_GENDER, m_hContact, szProto, "Gender", SVS_GENDER);
+ SetValue(m_hwnd, IDC_DOBDAY, m_hContact, szProto, "BirthDay", 0);
+ SetValue(m_hwnd, IDC_DOBMONTH, m_hContact, szProto, "BirthMonth", SVS_MONTH);
+ SetValue(m_hwnd, IDC_DOBYEAR, m_hContact, szProto, "BirthYear", 0);
+ SetValue(m_hwnd, IDC_MARITAL, m_hContact, szProto, "MaritalStatus", SVS_MARITAL);
+ return false;
+ }
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
- case IDC_EMAIL:
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) {
- wchar_t szExec[264], szEmail[256];
- GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, _countof(szEmail));
- mir_snwprintf(szExec, L"mailto:%s", szEmail);
- ShellExecute(hwndDlg, L"open", szExec, NULL, NULL, SW_SHOW);
- }
- break;
+ void onClick_Email(CCtrlHyperlink *pLink)
+ {
+ if (IsWindowEnabled(pLink->GetHwnd())) {
+ wchar_t szExec[264];
+ mir_snwprintf(szExec, L"mailto:%s", ptrW(m_email.GetText()).get());
+ ShellExecute(m_hwnd, L"open", szExec, NULL, NULL, SW_SHOW);
}
- break;
}
- return FALSE;
-}
+};
-static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Location dlg page
+
+class CLocationDlg : public CUserInfoPageDlg
{
- switch (msg) {
- case WM_INITDIALOG:
-
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault(hwndDlg);
- SetTimer(hwndDlg, 1, 1000, nullptr);
-
- TimeZone_PrepareList(lParam, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB);
- SendMessage(hwndDlg, WM_TIMER, 0, 0);
- break;
-
- case WM_TIMER:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (hContact != NULL) {
- wchar_t szTime[80];
- if (printDateTimeByContact(hContact, L"s", szTime, _countof(szTime), TZF_KNOWNONLY)) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE);
- SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("<not specified>"));
- }
- else {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), TRUE);
- SetDlgItemText(hwndDlg, IDC_LOCALTIME, szTime);
- }
- }
- }
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- if (hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr)
- break;
+ CTimer m_timer;
+ CCtrlCombo cmbTimezone;
+
+public:
+ CLocationDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_LOCATION),
+ m_timer(this, 1),
+ cmbTimezone(this, IDC_TIMEZONESELECT)
+ {
+ m_timer.OnEvent = Callback(this, &CLocationDlg::onTimer);
+
+ cmbTimezone.OnSelChanged = Callback(this, &CLocationDlg::onSelChange_Timezone);
+ }
- SetValue(hwndDlg, IDC_STREET, hContact, szProto, "Street", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_CITY, hContact, szProto, "City", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_STATE, hContact, szProto, "State", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "ZIP", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "Country", SVS_COUNTRY);
- SetValue(hwndDlg, IDC_LANGUAGE1, hContact, szProto, "Language1", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_LANGUAGE2, hContact, szProto, "Language2", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_LANGUAGE3, hContact, szProto, "Language3", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_TIMEZONE, hContact, szProto, "Timezone", SVS_TIMEZONE);
- }
- }
- }
- break;
+ bool OnInitDialog() override
+ {
+ m_timer.Start(1000);
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
+ TimeZone_PrepareList(m_hContact, NULL, cmbTimezone.GetHwnd(), TZF_PLF_CB);
+ onTimer(0);
+ return true;
+ }
- case IDC_TIMEZONESELECT:
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ void onTimer(CTimer *)
+ {
+ if (m_hContact == 0)
+ return;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- TimeZone_StoreListResult(hContact, NULL, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB);
- }
+ wchar_t szTime[80];
+ if (printDateTimeByContact(m_hContact, L"s", szTime, _countof(szTime), TZF_KNOWNONLY)) {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_LOCALTIME), FALSE);
+ SetDlgItemText(m_hwnd, IDC_LOCALTIME, TranslateT("<not specified>"));
+ }
+ else {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_LOCALTIME), TRUE);
+ SetDlgItemText(m_hwnd, IDC_LOCALTIME, szTime);
}
- break;
}
- return FALSE;
-}
-static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+ bool OnRefresh() override
+ {
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ return false;
+
+ SetValue(m_hwnd, IDC_STREET, m_hContact, szProto, "Street", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_CITY, m_hContact, szProto, "City", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_STATE, m_hContact, szProto, "State", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_ZIP, m_hContact, szProto, "ZIP", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_COUNTRY, m_hContact, szProto, "Country", SVS_COUNTRY);
+ SetValue(m_hwnd, IDC_LANGUAGE1, m_hContact, szProto, "Language1", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_LANGUAGE2, m_hContact, szProto, "Language2", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_LANGUAGE3, m_hContact, szProto, "Language3", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_TIMEZONE, m_hContact, szProto, "Timezone", SVS_TIMEZONE);
+ return false;
+ }
+
+ void onSelChange_Timezone(CCtrlCombo *)
+ {
+ TimeZone_StoreListResult(m_hContact, NULL, cmbTimezone.GetHwnd(), TZF_PLF_CB);
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Work dlg page
+
+class CWorkDlg : public CUserInfoPageDlg
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- if (hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr) break;
- SetValue(hwndDlg, IDC_COMPANY, hContact, szProto, "Company", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_DEPARTMENT, hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_POSITION, hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_STREET, hContact, szProto, "CompanyStreet", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_CITY, hContact, szProto, "CompanyCity", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_STATE, hContact, szProto, "CompanyState", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "CompanyZIP", SVS_ZEROISUNSPEC);
- SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "CompanyCountry", SVS_COUNTRY);
- SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "CompanyHomepage", SVS_ZEROISUNSPEC);
- }
- }
- break;
- }
- break;
+ CCtrlHyperlink m_url;
+
+public:
+ CWorkDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_WORK),
+ m_url(this, IDC_WEBPAGE)
+ {
+ m_url.OnClick = Callback(this, &CWorkDlg::onClick_Page);
+ }
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
+ bool OnRefresh() override
+ {
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ return false;
+
+ SetValue(m_hwnd, IDC_COMPANY, m_hContact, szProto, "Company", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_DEPARTMENT, m_hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_POSITION, m_hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_STREET, m_hContact, szProto, "CompanyStreet", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_CITY, m_hContact, szProto, "CompanyCity", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_STATE, m_hContact, szProto, "CompanyState", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_ZIP, m_hContact, szProto, "CompanyZIP", SVS_ZEROISUNSPEC);
+ SetValue(m_hwnd, IDC_COUNTRY, m_hContact, szProto, "CompanyCountry", SVS_COUNTRY);
+ SetValue(m_hwnd, IDC_WEBPAGE, m_hContact, szProto, "CompanyHomepage", SVS_ZEROISUNSPEC);
+ return false;
+ }
- case IDC_WEBPAGE:
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) {
- char szPage[256];
- GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, _countof(szPage));
- Utils_OpenUrl(szPage);
- }
- }
- break;
+ void onClick_Page(CCtrlHyperlink *pLink)
+ {
+ if (IsWindowEnabled(pLink->GetHwnd()))
+ Utils_OpenUrl(ptrA(pLink->GetTextA()));
}
- return FALSE;
-}
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Work dlg page
// Resizes all columns in a listview (report style)
// to make all text visible
-void ResizeColumns(HWND hwndLV)
+void ResizeColumns(CCtrlListView &ctrl)
{
- int nCol = 0; LVCOLUMN lvCol;
- lvCol.mask = LVCF_WIDTH;
- while (ListView_GetColumn(hwndLV, nCol++, &lvCol))
- ListView_SetColumnWidth(hwndLV, nCol - 1, LVSCW_AUTOSIZE);
+ ctrl.SetColumnWidth(0, LVSCW_AUTOSIZE);
+ ctrl.SetColumnWidth(1, LVSCW_AUTOSIZE);
}
-static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+class CBackgroundDlg : public CUserInfoPageDlg
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- RECT rc;
- GetClientRect(GetDlgItem(hwndDlg, IDC_PAST), &rc);
- rc.right -= GetSystemMetrics(SM_CXVSCROLL);
-
- LVCOLUMN lvc;
- lvc.mask = LVCF_WIDTH;
- lvc.cx = rc.right / 3;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 0, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 0, &lvc);
-
- lvc.cx = rc.right - rc.right / 3;
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 1, &lvc);
- ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 1, &lvc);
- }
- ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PAST), LVS_EX_LABELTIP, LVS_EX_LABELTIP);
- ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_INTERESTS), LVS_EX_LABELTIP, LVS_EX_LABELTIP);
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) {
- LVITEM lvi;
- char idstr[33];
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- if (hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto == nullptr)
- break;
+ CCtrlHyperlink m_link;
+ CCtrlListView m_past, m_interest;
+
+public:
+ CBackgroundDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_BACKGROUND),
+ m_link(this, IDC_WEBPAGE),
+ m_past(this, IDC_PAST),
+ m_interest(this, IDC_INTERESTS)
+ {
+ m_link.OnClick = Callback(this, &CBackgroundDlg::onClick_Url);
+ }
- SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC);
-
- // past
- ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PAST));
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- for (int i = 0;; i++) {
- mir_snprintf(idstr, "Past%d", i);
- ptrW tszColText(db_get_wsa(hContact, szProto, idstr));
- if (tszColText == NULL)
- break;
- mir_snprintf(idstr, "Past%dText", i);
- ptrW tszText(db_get_wsa(hContact, szProto, idstr));
- if (tszText == NULL)
- break;
-
- lvi.pszText = tszColText;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, tszText);
- lvi.iItem++;
- }
+ bool OnInitDialog() override
+ {
+ RECT rc;
+ GetClientRect(m_past.GetHwnd(), &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_WIDTH;
+ lvc.cx = rc.right / 3;
+ m_past.InsertColumn(0, &lvc);
+ m_interest.InsertColumn(0, &lvc);
+
+ lvc.cx = rc.right - rc.right / 3;
+ m_past.InsertColumn(1, &lvc);
+ m_interest.InsertColumn(1, &lvc);
+
+ m_past.SetExtendedListViewStyleEx(LVS_EX_LABELTIP, LVS_EX_LABELTIP);
+ m_interest.SetExtendedListViewStyleEx(LVS_EX_LABELTIP, LVS_EX_LABELTIP);
+ return true;
+ }
- // affiliation
- for (int i = 0;; i++) {
- mir_snprintf(idstr, "Affiliation%d", i);
- ptrW tszColText(db_get_wsa(hContact, szProto, idstr));
- if (tszColText == NULL)
- break;
- mir_snprintf(idstr, "Affiliation%dText", i);
- ptrW tszText(db_get_wsa(hContact, szProto, idstr));
- if (tszText == NULL)
- break;
-
- lvi.pszText = tszColText;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, tszText);
- lvi.iItem++;
- }
+ bool OnRefresh() override
+ {
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ return false;
+
+ SetValue(m_hwnd, IDC_WEBPAGE, m_hContact, szProto, "Homepage", SVS_ZEROISUNSPEC);
+
+ // past
+ m_past.DeleteAllItems();
+
+ char idstr[33];
+ LVITEM lvi;
+ lvi.mask = LVIF_TEXT;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ for (int i = 0;; i++) {
+ mir_snprintf(idstr, "Past%d", i);
+ ptrW tszColText(db_get_wsa(m_hContact, szProto, idstr));
+ if (tszColText == NULL)
+ break;
+ mir_snprintf(idstr, "Past%dText", i);
+ ptrW tszText(db_get_wsa(m_hContact, szProto, idstr));
+ if (tszText == NULL)
+ break;
- ResizeColumns(GetDlgItem(hwndDlg, IDC_PAST));
-
- // interests
- ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_INTERESTS));
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- for (int i = 0;; i++) {
- mir_snprintf(idstr, "Interest%dCat", i);
- ptrW tszColText(db_get_wsa(hContact, szProto, idstr));
- if (tszColText == NULL)
- break;
- mir_snprintf(idstr, "Interest%dText", i);
- ptrW tszText(db_get_wsa(hContact, szProto, idstr));
- if (tszText == NULL)
- break;
-
- lvi.pszText = tszColText;
- ListView_InsertItem(GetDlgItem(hwndDlg, IDC_INTERESTS), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_INTERESTS), lvi.iItem, 1, tszText);
- lvi.iItem++;
- }
- ResizeColumns(GetDlgItem(hwndDlg, IDC_INTERESTS));
- }
- }
- break;
+ lvi.pszText = tszColText;
+ m_past.InsertItem(&lvi);
+ m_past.SetItemText(lvi.iItem, 1, tszText);
+ lvi.iItem++;
}
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
- case IDC_WEBPAGE:
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) {
- char szPage[256];
- GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, _countof(szPage));
- Utils_OpenUrl(szPage);
- }
- break;
- }
- break;
- }
- return FALSE;
-}
+ // affiliation
+ for (int i = 0;; i++) {
+ mir_snprintf(idstr, "Affiliation%d", i);
+ ptrW tszColText(db_get_wsa(m_hContact, szProto, idstr));
+ if (tszColText == NULL)
+ break;
+ mir_snprintf(idstr, "Affiliation%dText", i);
+ ptrW tszText(db_get_wsa(m_hContact, szProto, idstr));
+ if (tszText == NULL)
+ break;
-static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- MCONTACT hContact;
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- HDC hDC = GetDC(hwndDlg);
- LOGFONT lf;
- lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72);
- ReleaseDC(hwndDlg, hDC);
- lf.lfWidth = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- lf.lfWeight = FW_NORMAL;
- lf.lfItalic = 0;
- lf.lfUnderline = 0;
- lf.lfStrikeOut = 0;
- lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = DEFAULT_QUALITY;
- lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- mir_wstrcpy(lf.lfFaceName, L"Courier New");
- lf.lfCharSet = DEFAULT_CHARSET;
- HFONT hFont = CreateFontIndirect(&lf);
- SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
-
- ptrW szNotes(g_plugin.getWStringA(lParam, "MyNotes"));
- if (szNotes != nullptr)
- SetDlgItemText(hwndDlg, IDC_MYNOTES, szNotes);
+ lvi.pszText = tszColText;
+ m_past.InsertItem(&lvi);
+ m_past.SetItemText(lvi.iItem, 1, tszText);
+ lvi.iItem++;
}
- SendDlgItemMessage(hwndDlg, IDC_MYNOTES, EM_LIMITTEXT, 2048, 0);
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- if (hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(hContact);
- if (szProto != NULL)
- SetValue(hwndDlg, IDC_ABOUT, hContact, szProto, "About", 0);
- }
- break;
- case PSN_APPLY:
- hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) {
- wchar_t text[2048];
- GetDlgItemText(hwndDlg, IDC_MYNOTES, text, _countof(text));
- g_plugin.setWString(hContact, "MyNotes", text);
- }
- else g_plugin.delSetting(hContact, "MyNotes");
+ ResizeColumns(m_past);
+
+ // interests
+ m_interest.DeleteAllItems();
+
+ lvi.mask = LVIF_TEXT;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ for (int i = 0;; i++) {
+ mir_snprintf(idstr, "Interest%dCat", i);
+ ptrW tszColText(db_get_wsa(m_hContact, szProto, idstr));
+ if (tszColText == NULL)
break;
- }
- break;
+ mir_snprintf(idstr, "Interest%dText", i);
+ ptrW tszText(db_get_wsa(m_hContact, szProto, idstr));
+ if (tszText == NULL)
+ break;
+
+ lvi.pszText = tszColText;
+ m_interest.InsertItem(&lvi);
+ m_interest.SetItemText(lvi.iItem, 1, tszText);
+ lvi.iItem++;
}
- break;
-
- case WM_COMMAND:
- if (wParam == MAKEWPARAM(IDC_MYNOTES, EN_CHANGE))
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if (LOWORD(wParam) == IDCANCEL)
- SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
- break;
-
- case WM_DESTROY:
- DeleteObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_GETFONT, 0, 0));
- break;
+ ResizeColumns(m_interest);
+ return false;
}
- return FALSE;
-}
+
+ void onClick_Url(CCtrlHyperlink *pLink)
+ {
+ if (IsWindowEnabled(pLink->GetHwnd()))
+ Utils_OpenUrl(ptrA(pLink->GetTextA()));
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Notes dlg page
+
+class CNotesDlg : public CUserInfoPageDlg
+{
+ CCtrlEdit mynotes;
+
+public:
+ CNotesDlg() :
+ CUserInfoPageDlg(g_plugin, IDD_INFO_NOTES),
+ mynotes(this, IDC_MYNOTES)
+ {
+ }
+
+ bool OnInitDialog() override
+ {
+ HDC hDC = GetDC(m_hwnd);
+ LOGFONT lf = {};
+ lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72);
+ ReleaseDC(m_hwnd, hDC);
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lf.lfWeight = FW_NORMAL;
+ mir_wstrcpy(lf.lfFaceName, L"Courier New");
+ HFONT hFont = CreateFontIndirect(&lf);
+ SendDlgItemMessage(m_hwnd, IDC_ABOUT, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
+
+ ptrW szNotes(g_plugin.getWStringA(m_hContact, "MyNotes"));
+ if (szNotes != nullptr)
+ mynotes.SetText(szNotes);
+
+ mynotes.SetMaxLength(2048);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ ptrW wszText(mynotes.GetText());
+ if (mir_wstrlen(wszText))
+ g_plugin.setWString(m_hContact, "MyNotes", wszText);
+ else
+ g_plugin.delSetting(m_hContact, "MyNotes");
+
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_ABOUT, WM_GETFONT, 0, 0));
+ }
+
+ bool OnRefresh() override
+ {
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto != NULL)
+ SetValue(m_hwnd, IDC_ABOUT, m_hContact, szProto, "About", 0);
+ return false;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module entry point
+
+void InitContactInfo(WPARAM, USERINFOPAGE &uip);
int DetailsInit(WPARAM wParam, LPARAM lParam)
{
@@ -579,41 +541,28 @@ int DetailsInit(WPARAM wParam, LPARAM lParam) if (Proto_GetBaseAccountName(lParam) == nullptr)
return 0;
- OPTIONSDIALOGPAGE odp = {};
- odp.pfnDlgProc = SummaryDlgProc;
- odp.position = -2100000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SUMMARY);
- odp.szTitle.a = LPGEN("Summary");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = ContactDlgProc;
- odp.position = -1800000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_CONTACT);
- odp.szTitle.a = LPGEN("Contact");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = LocationDlgProc;
- odp.position = -1500000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_LOCATION);
- odp.szTitle.a = LPGEN("Location");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = WorkDlgProc;
- odp.position = -1200000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_WORK);
- odp.szTitle.a = LPGEN("Work");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = BackgroundDlgProc;
- odp.position = -900000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_BACKGROUND);
- odp.szTitle.a = LPGEN("Background info");
- g_plugin.addUserInfo(wParam, &odp);
-
- odp.pfnDlgProc = NotesDlgProc;
- odp.position = 0;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_NOTES);
- odp.szTitle.a = LPGEN("Notes");
- g_plugin.addUserInfo(wParam, &odp);
+ USERINFOPAGE uip = {};
+ uip.pDialog = new CSummaryDlg();
+ uip.szGroup.a = LPGEN("General");
+ uip.szTitle.a = LPGEN("Summary");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ InitContactInfo(wParam, uip);
+
+ uip.pDialog = new CLocationDlg();
+ uip.szTitle.a = LPGEN("Location");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new CWorkDlg();
+ uip.szTitle.a = LPGEN("Work");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new CBackgroundDlg();
+ uip.szTitle.a = LPGEN("Background info");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.pDialog = new CNotesDlg();
+ uip.szTitle.a = LPGEN("Notes");
+ g_plugin.addUserInfo(wParam, &uip);
return 0;
}
diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index d66a37574a..ebbd18a6fe 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -26,44 +26,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define UPDATEANIMFRAMES 20
-int DetailsInit(WPARAM wParam, LPARAM lParam);
-
-static MWindowList hWindowList = nullptr;
-static HANDLE hDetailsInitEvent;
-
-struct DetailsPageInit
-{
- int pageCount;
- OPTIONSDIALOGPAGE *odp;
-};
-
-struct DetailsPageData : public MNonCopyable
+struct DetailsPageData : public MNonCopyable, public MZeroedObject
{
- DLGTEMPLATE *pTemplate;
- HINSTANCE hInst;
- DLGPROC dlgProc;
- LPARAM dlgParam;
- HWND hwnd;
- HTREEITEM hItem;
- HPLUGIN pPlugin;
- int changed;
- uint32_t dwFlags;
- wchar_t *pwszTitle, *pwszTab;
+ CUserInfoPageDlg *pDialog;
+ HWND hwnd;
+ HTREEITEM hItem;
+ HPLUGIN pPlugin;
+ int changed;
+ uint32_t dwFlags;
+ wchar_t *pwszTitle, *pwszGroup;
~DetailsPageData()
{
if (hwnd != nullptr)
DestroyWindow(hwnd);
mir_free(pwszTitle);
- mir_free(pwszTab);
+ mir_free(pwszGroup);
}
__forceinline wchar_t *getTitle() const {
return (dwFlags & ODPF_DONTTRANSLATE) ? pwszTitle : TranslateW_LP(pwszTitle, pPlugin);
}
+
+ __forceinline wchar_t* getGroup() const
+ { return (dwFlags & ODPF_DONTTRANSLATE) ? pwszGroup : TranslateW_LP(pwszGroup, pPlugin);
+ }
};
/////////////////////////////////////////////////////////////////////////////////////////
+
+int DetailsInit(WPARAM wParam, LPARAM lParam);
+
+static MWindowList hWindowList = nullptr;
+static HANDLE hDetailsInitEvent;
+
+/////////////////////////////////////////////////////////////////////////////////////////
// User info dialog
static void ThemeDialogBackground(HWND hwnd)
@@ -80,7 +77,6 @@ static int UserInfoContactDelete(WPARAM wParam, LPARAM) }
#define M_PROTOACK (WM_USER+10)
-#define M_CHECKONLINE (WM_USER+11)
#define M_DLLUNLOAD (WM_USER+12)
class CUserInfoDlg : public CDlgBase
@@ -88,8 +84,6 @@ class CUserInfoDlg : public CDlgBase MCONTACT m_hContact;
HINSTANCE m_hInstIcmp = 0;
HFONT m_hBoldFont = 0;
- int m_currentPage = -1;
- RECT m_rcDisplay, m_rcDisplayTab;
int m_updateAnimFrame = 0;
wchar_t m_szUpdating[64];
int *m_infosUpdated = 0;
@@ -97,130 +91,124 @@ class CUserInfoDlg : public CDlgBase HANDLE m_hProtoAckEvent = 0;
HANDLE m_hDllUnloadEvent = 0;
- HWND m_tabs;
OBJLIST<DetailsPageData> m_pages;
+ DetailsPageData *m_pCurrent = nullptr;
void BuildTree()
{
ptrW ptszLastTab(g_plugin.getWStringA("LastTab"));
- m_currentPage = -1;
-
- for (int i = 0; i < m_pages.getCount(); i++) {
- auto &p = m_pages[i];
- if (i && p.pwszTab && !mir_wstrcmp(m_pages[i - 1].pwszTitle, p.pwszTitle)) {
- p.hItem = m_pages[i - 1].hItem;
- continue;
+ m_pCurrent = nullptr;
+
+ std::map<const wchar_t*, HTREEITEM> parents;
+
+ for (auto &it : m_pages) {
+ wchar_t *pwszGroup = (it->getGroup() == nullptr) ? TranslateT("General") : it->getGroup();
+
+ HTREEITEM hParent;
+ auto p = parents.find(pwszGroup);
+ if (p == parents.end()) {
+ TVINSERTSTRUCT tvis = {};
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.lParam = (LPARAM)it;
+ tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
+ tvis.item.pszText = pwszGroup;
+ hParent = parents[pwszGroup] = m_tree.InsertItem(&tvis);
}
+ else hParent = p->second;
TVINSERTSTRUCT tvis;
- tvis.hParent = nullptr;
+ tvis.hParent = hParent;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
- tvis.item.lParam = (LPARAM)i;
- tvis.item.pszText = p.getTitle();
+ tvis.item.lParam = (LPARAM)it;
+ tvis.item.pszText = it->getTitle();
if (ptszLastTab && !mir_wstrcmp(tvis.item.pszText, ptszLastTab))
- m_currentPage = i;
- p.hItem = m_tree.InsertItem(&tvis);
+ m_pCurrent = it;
+ it->hItem = m_tree.InsertItem(&tvis);
}
- if (m_currentPage == -1)
- m_currentPage = 0;
+ if (!m_pCurrent)
+ m_pCurrent = &m_pages[0];
}
- void CreateDetailsTabs(DetailsPageData *ppg)
+ void CheckOnline()
{
- int sel = 0, pages = 0;
-
- TCITEM tie;
- tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
- tie.iImage = -1;
- TabCtrl_DeleteAllItems(m_tabs);
-
- for (auto &odp : m_pages) {
- if (!odp->pwszTab || mir_wstrcmp(odp->pwszTitle, ppg->pwszTitle))
- continue;
-
- tie.pszText = TranslateW_LP(odp->pwszTab, odp->pPlugin);
- tie.lParam = m_pages.indexOf(&odp);
- TabCtrl_InsertItem(m_tabs, pages, &tie);
- if (!mir_wstrcmp(odp->pwszTab, ppg->pwszTab))
- sel = pages;
- pages++;
+ if (m_hContact == 0)
+ return;
+
+ char *szProto = Proto_GetBaseAccountName(m_hContact);
+ if (szProto == nullptr)
+ btnUpdate.Disable();
+ else {
+ if (Proto_GetStatus(szProto) < ID_STATUS_ONLINE)
+ btnUpdate.Disable();
+ else
+ btnUpdate.Enable(!IsWindowVisible(GetDlgItem(m_hwnd, IDC_UPDATING)));
}
- TabCtrl_SetCurSel(m_tabs, sel);
-
- LONG style = GetWindowLongPtr(m_tabs, GWL_STYLE);
- SetWindowLongPtr(m_tabs, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP);
}
void CreateDetailsPageWindow(DetailsPageData *ppg)
{
- RECT *rc = ppg->pwszTab ? &m_rcDisplayTab : &m_rcDisplay;
- ppg->hwnd = CreateDialogIndirectParam(ppg->hInst, ppg->pTemplate, m_hwnd, ppg->dlgProc, (LPARAM)m_hContact);
+ auto *pDlg = ppg->pDialog;
+ if (pDlg == nullptr)
+ return;
+
+ pDlg->SetParent(m_hwnd);
+ pDlg->SetContact(m_hContact);
+ pDlg->Create();
+ ppg->hwnd = pDlg->GetHwnd();
+
::ThemeDialogBackground(ppg->hwnd);
- SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0);
- SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0);
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_PARAMCHANGED;
- pshn.hdr.hwndFrom = ppg->hwnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)ppg->dlgParam;
- SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
+ pDlg->OnRefresh();
+ }
- pshn.hdr.code = PSN_INFOCHANGED;
- pshn.hdr.hwndFrom = ppg->hwnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)m_hContact;
- SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn);
+ void ResizeCurrent()
+ {
+ RECT rc;
+ GetWindowRect(m_place.GetHwnd(), &rc);
+
+ POINT pt = { 0, 0 };
+ ClientToScreen(m_hwnd, &pt);
+ OffsetRect(&rc, -pt.x, -pt.y);
+ SetWindowPos(m_pCurrent->hwnd, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0);
}
- CCtrlBase m_white;
+ CCtrlBase m_white, m_place;
+ CCtrlButton btnUpdate;
CCtrlTreeView m_tree;
CTimer updateTimer;
public:
- CUserInfoDlg(MCONTACT hContact, int count, OPTIONSDIALOGPAGE *odp) :
+ CUserInfoDlg(MCONTACT hContact, const LIST<DetailsPageData> &items) :
CDlgBase(g_plugin, IDD_DETAILS),
m_hContact(hContact),
m_pages(1),
m_tree(this, IDC_PAGETREE),
+ m_place(this, IDC_TABS),
m_white(this, IDC_WHITERECT),
+ btnUpdate(this, IDC_UPDATE),
updateTimer(this, 1)
{
+ SetMinSize(480, 382);
+
m_white.UseSystemColors();
m_tree.OnSelChanged = Callback(this, &CUserInfoDlg::onSelChanged_Tree);
m_tree.OnSelChanging = Callback(this, &CUserInfoDlg::onSelChanging);
- updateTimer.OnEvent = Callback(this, &CUserInfoDlg::onTimer);
+ btnUpdate.OnClick = Callback(this, &CUserInfoDlg::onClick_Update);
- for (int i = 0; i < count; i++, odp++) {
- HINSTANCE hInst = odp->pPlugin->getInst();
- if (hInst != nullptr) {
- auto *p = new DetailsPageData();
- p->pTemplate = (LPDLGTEMPLATE)LockResource(LoadResource(hInst, FindResourceA(hInst, odp->pszTemplate, MAKEINTRESOURCEA(5))));
- p->dlgProc = odp->pfnDlgProc;
- p->dlgParam = odp->dwInitParam;
- p->hInst = hInst;
- p->dwFlags = odp->flags;
-
- p->pwszTitle = odp->szTitle.w;
- p->pwszTab = odp->szTab.w;
- p->pPlugin = odp->pPlugin;
- m_pages.insert(p);
- }
+ updateTimer.OnEvent = Callback(this, &CUserInfoDlg::onTimer);
- if (odp->szGroup.a != nullptr)
- mir_free(odp->szGroup.a);
- if ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000)
- mir_free((char *)odp->pszTemplate);
- }
+ for (auto odp: items)
+ m_pages.insert(odp);
}
bool OnInitDialog() override
{
Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_USERDETAILS);
+ Utils_RestoreWindowPosition(m_hwnd, 0, MODULENAME, "main");
m_hProtoAckEvent = HookEventMessage(ME_PROTO_ACK, m_hwnd, M_PROTOACK);
m_hDllUnloadEvent = HookEventMessage(ME_SYSTEM_MODULEUNLOAD, m_hwnd, M_DLLUNLOAD);
@@ -248,38 +236,15 @@ public: BuildTree();
//////////////////////////////////////////////////////////////////////
- m_tabs = GetDlgItem(m_hwnd, IDC_TABS);
-
- TCITEM tci;
- tci.mask = TCIF_TEXT | TCIF_IMAGE;
- tci.iImage = -1;
- tci.pszText = L"X";
- TabCtrl_InsertItem(m_tabs, 0, &tci);
-
- GetWindowRect(m_tabs, &m_rcDisplayTab);
- TabCtrl_AdjustRect(m_tabs, FALSE, &m_rcDisplayTab);
-
- POINT pt = { 0, 0 };
- ClientToScreen(m_hwnd, &pt);
- OffsetRect(&m_rcDisplayTab, -pt.x, -pt.y);
-
- TabCtrl_DeleteAllItems(m_tabs);
-
- GetWindowRect(m_tabs, &m_rcDisplay);
- TabCtrl_AdjustRect(m_tabs, FALSE, &m_rcDisplay);
- memset(&pt, 0, sizeof(pt));
- ClientToScreen(m_hwnd, &pt);
- OffsetRect(&m_rcDisplay, -pt.x, -pt.y);
-
- m_tree.SelectItem(m_pages[m_currentPage].hItem);
+ m_tree.SelectItem(m_pCurrent->hItem);
//////////////////////////////////////////////////////////////////////
m_updateAnimFrame = 0;
GetDlgItemText(m_hwnd, IDC_UPDATING, m_szUpdating, _countof(m_szUpdating));
- SendMessage(m_hwnd, M_CHECKONLINE, 0, 0);
+ CheckOnline();
if (!ProtoChainSend(m_hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) {
- EnableWindow(GetDlgItem(m_hwnd, IDC_UPDATE), FALSE);
+ btnUpdate.Disable();
SetTimer(m_hwnd, 1, 100, nullptr);
}
else ShowWindow(GetDlgItem(m_hwnd, IDC_UPDATING), SW_HIDE);
@@ -293,10 +258,10 @@ public: PSHNOTIFY pshn;
pshn.hdr.idFrom = 0;
pshn.lParam = (LPARAM)m_hContact;
- if (m_currentPage != -1) {
+ if (m_pCurrent) {
pshn.hdr.code = PSN_KILLACTIVE;
- pshn.hdr.hwndFrom = m_pages[m_currentPage].hwnd;
- if (SendMessage(m_pages[m_currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn))
+ pshn.hdr.hwndFrom = m_pCurrent->hwnd;
+ if (SendMessage(m_pCurrent->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn))
return false;
}
@@ -307,25 +272,50 @@ public: pshn.hdr.hwndFrom = odp->hwnd;
if (SendMessage(odp->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) {
m_tree.Select(odp->hItem, TVGN_CARET);
- if (m_currentPage != -1) ShowWindow(m_pages[m_currentPage].hwnd, SW_HIDE);
- m_currentPage = m_pages.indexOf(&odp);
- ShowWindow(m_pages[m_currentPage].hwnd, SW_SHOW);
+ if (m_pCurrent)
+ ShowWindow(m_pCurrent->hwnd, SW_HIDE);
+ m_pCurrent = odp;
+ ShowWindow(m_pCurrent->hwnd, SW_SHOW);
return false;
}
}
return true;
}
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ switch (urc->wId) {
+ case IDC_TABS:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ case IDOK:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+
+ case IDC_HEADERBAR:
+ case IDC_WHITERECT:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+
+ case IDC_PAGETREE:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
+ }
+
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+ }
+
void OnDestroy() override
{
- wchar_t name[128];
- TVITEMEX tvi;
- tvi.mask = TVIF_TEXT;
- tvi.hItem = m_pages[m_currentPage].hItem;
- tvi.pszText = name;
- tvi.cchTextMax = _countof(name);
- m_tree.GetItem(&tvi);
- g_plugin.setWString("LastTab", name);
+ if (m_pCurrent) {
+ wchar_t name[128];
+ TVITEMEX tvi;
+ tvi.mask = TVIF_TEXT;
+ tvi.hItem = m_pCurrent->hItem;
+ tvi.pszText = name;
+ tvi.cchTextMax = _countof(name);
+ m_tree.GetItem(&tvi);
+ g_plugin.setWString("LastTab", name);
+ }
+
+ Utils_SaveWindowPosition(m_hwnd, 0, MODULENAME, "main");
Window_FreeIcon_IcoLib(m_hwnd);
SendDlgItemMessage(m_hwnd, IDC_NAME, WM_SETFONT, SendDlgItemMessage(m_hwnd, IDC_WHITERECT, WM_GETFONT, 0, 0), 0);
@@ -345,7 +335,8 @@ public: switch (uMsg) {
case PSM_CHANGED:
- m_pages[m_currentPage].changed = 1;
+ if (m_pCurrent)
+ m_pCurrent->changed = 1;
return TRUE;
case PSM_FORCECHANGED:
@@ -359,26 +350,12 @@ public: }
break;
- case M_CHECKONLINE:
- if (m_hContact != NULL) {
- char *szProto = Proto_GetBaseAccountName(m_hContact);
- if (szProto == nullptr)
- EnableWindow(GetDlgItem(m_hwnd, IDC_UPDATE), FALSE);
- else {
- if (Proto_GetStatus(szProto) < ID_STATUS_ONLINE)
- EnableWindow(GetDlgItem(m_hwnd, IDC_UPDATE), FALSE);
- else
- EnableWindow(GetDlgItem(m_hwnd, IDC_UPDATE), !IsWindowVisible(GetDlgItem(m_hwnd, IDC_UPDATING)));
- }
- }
- break;
-
case M_DLLUNLOAD:
{
bool bRemoved = false;
HINSTANCE hInst = (HINSTANCE)lParam;
for (auto &odp : m_pages.rev_iter()) {
- if (odp->hInst == hInst) {
+ if (odp->pPlugin->getInst() == hInst) {
if (!bRemoved) {
m_tree.DeleteAllItems();
bRemoved = true;
@@ -390,12 +367,13 @@ public: if (bRemoved)
BuildTree();
}
+ break;
case M_PROTOACK:
{
ACKDATA *ack = (ACKDATA *)lParam;
if (ack->hContact == NULL && ack->type == ACKTYPE_STATUS) {
- SendMessage(m_hwnd, M_CHECKONLINE, 0, 0);
+ CheckOnline();
break;
}
if (ack->hContact != m_hContact || ack->type != ACKTYPE_GETINFO)
@@ -406,11 +384,13 @@ public: if (!ack->hProcess && !ack->lParam) {
ShowWindow(GetDlgItem(m_hwnd, IDC_UPDATING), SW_HIDE);
updateTimer.Stop();
- SendMessage(m_hwnd, M_CHECKONLINE, 0, 0);
+ CheckOnline();
break;
- } //if
+ }
+
if (m_infosUpdated == nullptr)
m_infosUpdated = (int *)mir_calloc(sizeof(int) * (INT_PTR)ack->hProcess);
+
if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED)
m_infosUpdated[ack->lParam] = 1;
@@ -422,72 +402,49 @@ public: if (i == (INT_PTR)ack->hProcess) {
ShowWindow(GetDlgItem(m_hwnd, IDC_UPDATING), SW_HIDE);
updateTimer.Stop();
- SendMessage(m_hwnd, M_CHECKONLINE, 0, 0);
+ CheckOnline();
}
}
break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case TCN_SELCHANGING:
- onSelChanging(0);
- break;
-
- case TCN_SELCHANGE:
- if (m_currentPage != -1 && m_pages[m_currentPage].hwnd != NULL) {
- ShowWindow(m_pages[m_currentPage].hwnd, SW_HIDE);
-
- TCITEM tie;
- tie.mask = TCIF_PARAM;
- TabCtrl_GetItem(m_tabs, TabCtrl_GetCurSel(m_tabs), &tie);
- m_currentPage = tie.lParam;
-
- TVITEMEX tvi;
- tvi.hItem = m_tree.GetNextItem(NULL, TVGN_CARET);
- tvi.mask = TVIF_PARAM;
- tvi.lParam = m_currentPage;
- m_tree.SetItem(&tvi);
-
- if (m_currentPage != -1) {
- if (m_pages[m_currentPage].hwnd == NULL)
- CreateDetailsPageWindow(&m_pages[m_currentPage]);
- ShowWindow(m_pages[m_currentPage].hwnd, SW_SHOWNA);
- }
- }
- break;
- }
}
- return CDlgBase::DlgProc(uMsg, wParam, lParam);
+ INT_PTR res = CDlgBase::DlgProc(uMsg, wParam, lParam);
+
+ if (uMsg == WM_SIZE && m_pCurrent)
+ ResizeCurrent();
+
+ return res;
+
}
void onSelChanging(CCtrlTreeView *)
{
- if (m_currentPage != -1 && m_pages[m_currentPage].hwnd != NULL) {
+ if (m_pCurrent && m_pCurrent->hwnd != NULL) {
PSHNOTIFY pshn;
pshn.hdr.code = PSN_KILLACTIVE;
- pshn.hdr.hwndFrom = m_pages[m_currentPage].hwnd;
+ pshn.hdr.hwndFrom = m_pCurrent->hwnd;
pshn.hdr.idFrom = 0;
pshn.lParam = (LPARAM)m_hContact;
- if (SendMessage(m_pages[m_currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn))
+ if (SendMessage(m_pCurrent->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn))
SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
}
}
void onSelChanged_Tree(CCtrlTreeView::TEventInfo *ev)
{
- if (m_currentPage != -1 && m_pages[m_currentPage].hwnd != NULL)
- ShowWindow(m_pages[m_currentPage].hwnd, SW_HIDE);
+ if (m_pCurrent && m_pCurrent->hwnd != NULL)
+ ShowWindow(m_pCurrent->hwnd, SW_HIDE);
LPNMTREEVIEW pnmtv = ev->nmtv;
TVITEM tvi = pnmtv->itemNew;
- m_currentPage = tvi.lParam;
+ m_pCurrent = (DetailsPageData*)tvi.lParam;
+
+ if (m_pCurrent) {
+ if (m_pCurrent->hwnd == NULL)
+ CreateDetailsPageWindow(m_pCurrent);
- if (m_currentPage != -1) {
- CreateDetailsTabs(&m_pages[m_currentPage]);
- if (m_pages[m_currentPage].hwnd == NULL)
- CreateDetailsPageWindow(&m_pages[m_currentPage]);
- ShowWindow(m_pages[m_currentPage].hwnd, SW_SHOWNA);
+ ResizeCurrent();
+ ShowWindow(m_pCurrent->hwnd, SW_SHOWNA);
}
}
@@ -515,7 +472,7 @@ public: if (m_hContact != NULL) {
if (!ProtoChainSend(m_hContact, PSS_GETINFO, 0, 0)) {
- EnableWindow(GetDlgItem(m_hwnd, IDC_UPDATE), FALSE);
+ btnUpdate.Disable();
ShowWindow(GetDlgItem(m_hwnd, IDC_UPDATING), SW_SHOW);
updateTimer.Start(100);
}
@@ -537,62 +494,43 @@ public: static INT_PTR AddDetailsPage(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE *)lParam;
- struct DetailsPageInit *opi = (struct DetailsPageInit *)wParam;
-
- if (odp == nullptr || opi == nullptr)
+ auto *uip = (USERINFOPAGE*)lParam;
+ auto *pList = (LIST<DetailsPageData>*)wParam;
+ if (uip == nullptr || pList == nullptr)
return 1;
- opi->odp = (OPTIONSDIALOGPAGE *)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE) * (opi->pageCount + 1));
- OPTIONSDIALOGPAGE *dst = opi->odp + opi->pageCount;
- memset(dst, 0, sizeof(OPTIONSDIALOGPAGE));
- dst->pPlugin = odp->pPlugin;
- dst->pfnDlgProc = odp->pfnDlgProc;
- dst->position = odp->position;
- dst->pszTemplate = ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) ? mir_strdup(odp->pszTemplate) : odp->pszTemplate;
-
- if (odp->flags & ODPF_UNICODE) {
- dst->szTitle.w = (odp->szTitle.w == nullptr) ? nullptr : mir_wstrdup(odp->szTitle.w);
- dst->szTab.w = (odp->flags & ODPF_USERINFOTAB) ? mir_wstrdup(odp->szTab.w) : nullptr;
+ auto *pNew = new DetailsPageData();
+ pNew->pPlugin = uip->pPlugin;
+ pNew->pDialog = uip->pDialog;
+
+ if (uip->flags & ODPF_UNICODE) {
+ pNew->pwszTitle = (uip->szTitle.w == nullptr) ? nullptr : mir_wstrdup(uip->szTitle.w);
+ pNew->pwszGroup = (uip->flags & ODPF_USERINFOTAB) ? mir_wstrdup(uip->szGroup.w) : nullptr;
}
else {
- dst->szTitle.w = mir_a2u(odp->szTitle.a);
- dst->szTab.w = (odp->flags & ODPF_USERINFOTAB) ? mir_a2u(odp->szTab.a) : nullptr;
+ pNew->pwszTitle = mir_a2u(uip->szTitle.a);
+ pNew->pwszGroup = (uip->flags & ODPF_USERINFOTAB) ? mir_a2u(uip->szGroup.a) : nullptr;
}
- dst->flags = odp->flags;
- dst->dwInitParam = odp->dwInitParam;
- opi->pageCount++;
+ pNew->dwFlags = uip->flags;
+ pList->insert(pNew);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
-static wchar_t *getTab(OPTIONSDIALOGPAGE *p)
-{
- return (p->flags & ODPF_DONTTRANSLATE) ? p->szTab.w : TranslateW_LP(p->szTab.w, p->pPlugin);
-}
-
-static wchar_t *getTitle(OPTIONSDIALOGPAGE *p)
+static int PageSortProc(const DetailsPageData *item1, const DetailsPageData *item2)
{
- return (p->flags & ODPF_DONTTRANSLATE) ? p->szTitle.w : TranslateW_LP(p->szTitle.w, p->pPlugin);
-}
-
-static int PageSortProc(OPTIONSDIALOGPAGE *item1, OPTIONSDIALOGPAGE *item2)
-{
- int res;
- wchar_t *s1 = getTitle(item1), *s2 = getTitle(item2);
- if (!mir_wstrcmp(s1, TranslateT("Summary"))) return -1;
- if (!mir_wstrcmp(s2, TranslateT("Summary"))) return 1;
- if (res = mir_wstrcmp(s1, s2)) return res;
-
- s1 = getTab(item1), s2 = getTab(item2);
+ wchar_t *s1 = item1->getGroup(), *s2 = item2->getGroup();
if (s1 && !s2) return -1;
if (!s1 && s2) return 1;
if (!s1 && !s2) return 0;
- if (s1 && !mir_wstrcmp(s1, TranslateT("General"))) return -1;
- if (s2 && !mir_wstrcmp(s2, TranslateT("General"))) return 1;
+ s1 = item1->getTitle(), s2 = item2->getTitle();
+ if (!mir_wstrcmp(s1, TranslateT("Summary"))) return -1;
+ if (!mir_wstrcmp(s2, TranslateT("Summary"))) return 1;
+ if (int res = mir_wstrcmp(s1, s2)) return res;
+
return mir_wstrcmp(s1, s2);
}
@@ -604,17 +542,13 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM hContact, LPARAM) return 0;
}
- DetailsPageInit opi = {};
- NotifyEventHooks(hDetailsInitEvent, (WPARAM)&opi, hContact);
- if (opi.pageCount == 0)
+ LIST<DetailsPageData> items(1, PageSortProc);
+ NotifyEventHooks(hDetailsInitEvent, (WPARAM)&items, hContact);
+ if (items.getCount() == 0)
return 0;
- qsort(opi.odp, opi.pageCount, sizeof(OPTIONSDIALOGPAGE), (int(*)(const void *, const void *))PageSortProc);
-
- auto *pDlg = new CUserInfoDlg(hContact, opi.pageCount, opi.odp);
+ auto *pDlg = new CUserInfoDlg(hContact, items);
pDlg->Show();
-
- mir_free(opi.odp);
return 0;
}
diff --git a/src/core/stduserinfo/stduserinfo.vcxproj b/src/core/stduserinfo/stduserinfo.vcxproj index 61abde3715..90b5de2fb9 100644 --- a/src/core/stduserinfo/stduserinfo.vcxproj +++ b/src/core/stduserinfo/stduserinfo.vcxproj @@ -40,4 +40,7 @@ <ResourceCompile Include="res\resource.rc" />
<ResourceCompile Include="res\version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\cursor_hyperlink.cur" />
+ </ItemGroup>
</Project>
\ No newline at end of file diff --git a/src/core/stduserinfo/stduserinfo.vcxproj.filters b/src/core/stduserinfo/stduserinfo.vcxproj.filters index bc7d03c062..21fb202501 100644 --- a/src/core/stduserinfo/stduserinfo.vcxproj.filters +++ b/src/core/stduserinfo/stduserinfo.vcxproj.filters @@ -34,4 +34,9 @@ <Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\cursor_hyperlink.cur">
+ <Filter>Resource Files</Filter>
+ </None>
+ </ItemGroup>
</Project>
\ No newline at end of file diff --git a/src/mir_app/mir_app.vcxproj b/src/mir_app/mir_app.vcxproj index cf8eec0f0c..6845887cac 100644 --- a/src/mir_app/mir_app.vcxproj +++ b/src/mir_app/mir_app.vcxproj @@ -160,6 +160,7 @@ <ClCompile Include="src\usedIcons.cpp" />
<ClCompile Include="src\utils.cpp" />
<ClCompile Include="src\visibility.cpp" />
+ <ClCompile Include="W:\miranda-ng\src\mir_app\src\userInfo.cpp" />
<ClInclude Include="src\chat.h" />
<ClInclude Include="src\clc.h" />
<ClInclude Include="src\database.h" />
diff --git a/src/mir_app/mir_app.vcxproj.filters b/src/mir_app/mir_app.vcxproj.filters index 0a5e9fb1c5..d09bf9ff5a 100644 --- a/src/mir_app/mir_app.vcxproj.filters +++ b/src/mir_app/mir_app.vcxproj.filters @@ -398,6 +398,9 @@ <ClCompile Include="src\pluginopts.cpp">
<Filter>Source Files\Plugins</Filter>
</ClCompile>
+ <ClCompile Include="W:\miranda-ng\src\mir_app\src\userInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\filter.h">
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index 3561132c44..ee5628f1d0 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -257,10 +257,10 @@ HANDLE CMPluginBase::addTTB(const struct TTBButton *pButton) return (HANDLE)CallService(MS_TTB_ADDBUTTON, (WPARAM)pButton, (LPARAM)this); } -int CMPluginBase::addUserInfo(WPARAM wParam, OPTIONSDIALOGPAGE *odp) +int CMPluginBase::addUserInfo(WPARAM wParam, USERINFOPAGE *uip) { - odp->pPlugin = this; - return CallService("UserInfo/AddPage", wParam, (LPARAM)odp); + uip->pPlugin = this; + return CallService("UserInfo/AddPage", wParam, (LPARAM)uip); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index df78be57f1..6b3cc265a2 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -535,7 +535,7 @@ Contact_GetStatus @609 ?addSound@CMPluginBase@@QAEHPBDPB_W11@Z @623 NONAME
GetInstByAddress @625
GetPluginByInstance @626
-?addUserInfo@CMPluginBase@@QAEHIPAUOPTIONSDIALOGPAGE@@@Z @627 NONAME
+?addUserInfo@CMPluginBase@@QAEHIPAUUSERINFOPAGE@@@Z @627 NONAME
?addOptions@CMPluginBase@@QAEHIPAUOPTIONSDIALOGPAGE@@@Z @628 NONAME
?openOptions@CMPluginBase@@QAEXPB_W00@Z @629 NONAME
?openOptionsPage@CMPluginBase@@QAEXPB_W00@Z @630 NONAME
@@ -791,3 +791,10 @@ Srmm_GetButtonGap @883 ?addPopupOption@CMPluginBase@@QAEHPBDAAV?$CMOption@_N@@@Z @884 NONAME
?addPopupOption@CMPluginBase@@QAEHPB_WAAV?$CMOption@_N@@@Z @885 NONAME
Srmm_CreateHotkey @886 NONAME
+??0CUserInfoPageDlg@@QAE@$$QAV0@@Z @887 NONAME
+??0CUserInfoPageDlg@@QAE@AAVCMPluginBase@@H@Z @888 NONAME
+??0CUserInfoPageDlg@@QAE@ABV0@@Z @889 NONAME
+??1CUserInfoPageDlg@@UAE@XZ @890 NONAME
+??_7CUserInfoPageDlg@@6B@ @891 NONAME
+?OnRefresh@CUserInfoPageDlg@@UAE_NXZ @892 NONAME
+?SetContact@CUserInfoPageDlg@@QAEXI@Z @893 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 8239aaa864..229b99bbc1 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -535,7 +535,7 @@ Contact_GetStatus @609 ?addSound@CMPluginBase@@QEAAHPEBDPEB_W11@Z @623 NONAME
GetInstByAddress @625
GetPluginByInstance @626
-?addUserInfo@CMPluginBase@@QEAAH_KPEAUOPTIONSDIALOGPAGE@@@Z @627 NONAME
+?addUserInfo@CMPluginBase@@QEAAH_KPEAUUSERINFOPAGE@@@Z @627 NONAME
?addOptions@CMPluginBase@@QEAAH_KPEAUOPTIONSDIALOGPAGE@@@Z @628 NONAME
?openOptions@CMPluginBase@@QEAAXPEB_W00@Z @629 NONAME
?openOptionsPage@CMPluginBase@@QEAAXPEB_W00@Z @630 NONAME
@@ -791,3 +791,10 @@ Srmm_GetButtonGap @883 ?addPopupOption@CMPluginBase@@QEAAHPEBDAEAV?$CMOption@_N@@@Z @884 NONAME
?addPopupOption@CMPluginBase@@QEAAHPEB_WAEAV?$CMOption@_N@@@Z @885 NONAME
Srmm_CreateHotkey @886 NONAME
+??0CUserInfoPageDlg@@QEAA@$$QEAV0@@Z @887 NONAME
+??0CUserInfoPageDlg@@QEAA@AEAVCMPluginBase@@H@Z @888 NONAME
+??0CUserInfoPageDlg@@QEAA@AEBV0@@Z @889 NONAME
+??1CUserInfoPageDlg@@UEAA@XZ @890 NONAME
+??_7CUserInfoPageDlg@@6B@ @891 NONAME
+?OnRefresh@CUserInfoPageDlg@@UEAA_NXZ @892 NONAME
+?SetContact@CUserInfoPageDlg@@QEAAXI@Z @893 NONAME
diff --git a/src/mir_app/src/userInfo.cpp b/src/mir_app/src/userInfo.cpp new file mode 100644 index 0000000000..c7e6bfa647 --- /dev/null +++ b/src/mir_app/src/userInfo.cpp @@ -0,0 +1,40 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (C) 2012-22 Miranda NG team (https://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" + +///////////////////////////////////////////////////////////////////////////////////////// +// User info page base dialog + +CUserInfoPageDlg::CUserInfoPageDlg(class CMPluginBase &pPlug, int idDialog) : + CDlgBase(pPlug, idDialog) +{ + m_forceResizable = true; +} + +bool CUserInfoPageDlg::OnRefresh() +{ + return false; +} + |