summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-19 20:36:51 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-19 20:36:51 +0300
commit8faa984a7eaaeb0d06dacd0f42066071ddd786fb (patch)
tree20c1c5fb508c3c846f15fa295975c73a238cc0ce /protocols/JabberG/src
parent13e33b96dab976290ab3438a57f23babf04b3e38 (diff)
dialog code cleaning
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_bookmarks.cpp8
-rw-r--r--protocols/JabberG/src/jabber_console.cpp476
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp948
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp4
-rw-r--r--protocols/JabberG/src/jabber_notes.cpp341
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp8
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp2391
-rw-r--r--protocols/JabberG/src/jabber_xstatus.cpp2
8 files changed, 2025 insertions, 2153 deletions
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp
index 236419b292..73588f4c6f 100644
--- a/protocols/JabberG/src/jabber_bookmarks.cpp
+++ b/protocols/JabberG/src/jabber_bookmarks.cpp
@@ -274,12 +274,12 @@ public:
return CSuper::Resizer(urc);
}
- void lvBookmarks_OnDoubleClick(CCtrlFilterListView *)
+ void lvBookmarks_OnDoubleClick(CCtrlFilterListView*)
{
OpenBookmark();
}
- void btnAdd_OnClick(CCtrlFilterListView *)
+ void btnAdd_OnClick(CCtrlFilterListView*)
{
if (!m_proto->m_bJabberOnline) return;
@@ -289,7 +289,7 @@ public:
DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)&param);
}
- void btnEdit_OnClick(CCtrlFilterListView *)
+ void btnEdit_OnClick(CCtrlFilterListView*)
{
if (!m_proto->m_bJabberOnline)
return;
@@ -312,7 +312,7 @@ public:
DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)&param);
}
- void btnRemove_OnClick(CCtrlFilterListView *)
+ void btnRemove_OnClick(CCtrlFilterListView*)
{
if (!m_proto->m_bJabberOnline)
return;
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp
index 7a57186c18..a8b804c5af 100644
--- a/protocols/JabberG/src/jabber_console.cpp
+++ b/protocols/JabberG/src/jabber_console.cpp
@@ -313,283 +313,271 @@ class CJabberDlgConsole : public CJabberDlgBase
typedef CJabberDlgBase CSuper;
public:
- CJabberDlgConsole(CJabberProto *proto);
+ CJabberDlgConsole(CJabberProto *proto):
+ CJabberDlgBase(proto, IDD_CONSOLE)
+ {}
-protected:
- bool OnInitDialog() override;
- bool OnClose() override;
- void OnDestroy() override;
- int Resizer(UTILRESIZECONTROL *urc) override;
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
- void OnProtoRefresh(WPARAM wParam, LPARAM lParam);
-};
+ Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_CONSOLE));
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR);
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXLIMITTEXT, 0, 0x80000000);
-CJabberDlgConsole::CJabberDlgConsole(CJabberProto *proto) :
- CJabberDlgBase(proto, IDD_CONSOLE)
-{
-}
+ m_proto->m_filterInfo.msg = m_proto->getByte("consoleWnd_msg", TRUE);
+ m_proto->m_filterInfo.presence = m_proto->getByte("consoleWnd_presence", TRUE);
+ m_proto->m_filterInfo.iq = m_proto->getByte("consoleWnd_iq", TRUE);
+ m_proto->m_filterInfo.type = (TFilterInfo::Type)m_proto->getByte("consoleWnd_ftype", TFilterInfo::T_OFF);
-bool CJabberDlgConsole::OnInitDialog()
-{
- CSuper::OnInitDialog();
+ *m_proto->m_filterInfo.pattern = 0;
+ ptrW tszPattern(m_proto->getWStringA("consoleWnd_fpattern"));
+ if (tszPattern != nullptr)
+ mir_wstrncpy(m_proto->m_filterInfo.pattern, tszPattern, _countof(m_proto->m_filterInfo.pattern));
- Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_CONSOLE));
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR);
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXLIMITTEXT, 0, 0x80000000);
+ sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER));
+ SetDlgItemText(m_hwnd, IDC_CB_FILTER, m_proto->m_filterInfo.pattern);
- m_proto->m_filterInfo.msg = m_proto->getByte("consoleWnd_msg", TRUE);
- m_proto->m_filterInfo.presence = m_proto->getByte("consoleWnd_presence", TRUE);
- m_proto->m_filterInfo.iq = m_proto->getByte("consoleWnd_iq", TRUE);
- m_proto->m_filterInfo.type = (TFilterInfo::Type)m_proto->getByte("consoleWnd_ftype", TFilterInfo::T_OFF);
+ struct
+ {
+ int idc;
+ char *title;
+ char *icon;
+ bool push;
+ BOOL pushed;
+ }
+ static buttons[] =
+ {
+ { IDC_BTN_MSG, "Messages", "pl_msg_allow", true, m_proto->m_filterInfo.msg},
+ { IDC_BTN_PRESENCE, "Presences", "pl_prin_allow", true, m_proto->m_filterInfo.presence},
+ { IDC_BTN_IQ, "Queries", "pl_iq_allow", true, m_proto->m_filterInfo.iq},
+ { IDC_BTN_FILTER, "Filter mode", "sd_filter_apply", true, FALSE},
+ { IDC_BTN_FILTER_REFRESH, "Refresh list", "sd_nav_refresh", false, FALSE},
+ };
+
+ for (auto &it : buttons) {
+ SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0);
+ if (it.push)
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASPUSHBTN, TRUE, 0);
+ if (it.pushed)
+ CheckDlgButton(m_hwnd, it.idc, BST_CHECKED);
+ }
- *m_proto->m_filterInfo.pattern = 0;
- ptrW tszPattern(m_proto->getWStringA("consoleWnd_fpattern"));
- if (tszPattern != nullptr)
- mir_wstrncpy(m_proto->m_filterInfo.pattern, tszPattern, _countof(m_proto->m_filterInfo.pattern));
+ for (auto &it : filter_modes)
+ if (it.type == m_proto->m_filterInfo.type) {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
+ SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
+ break;
+ }
- sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER));
- SetDlgItemText(m_hwnd, IDC_CB_FILTER, m_proto->m_filterInfo.pattern);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_CB_FILTER), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTER_REFRESH), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
- struct
- {
- int idc;
- char *title;
- char *icon;
- bool push;
- BOOL pushed;
+ Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "consoleWnd_");
+ return true;
}
- static buttons[] =
+
+ bool OnClose() override
{
- { IDC_BTN_MSG, "Messages", "pl_msg_allow", true, m_proto->m_filterInfo.msg},
- { IDC_BTN_PRESENCE, "Presences", "pl_prin_allow", true, m_proto->m_filterInfo.presence},
- { IDC_BTN_IQ, "Queries", "pl_iq_allow", true, m_proto->m_filterInfo.iq},
- { IDC_BTN_FILTER, "Filter mode", "sd_filter_apply", true, FALSE},
- { IDC_BTN_FILTER_REFRESH, "Refresh list", "sd_nav_refresh", false, FALSE},
- };
-
- for (auto &it : buttons) {
- SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
- SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(m_hwnd, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0);
- if (it.push)
- SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASPUSHBTN, TRUE, 0);
- if (it.pushed)
- CheckDlgButton(m_hwnd, it.idc, BST_CHECKED);
+ m_proto->setByte("consoleWnd_msg", m_proto->m_filterInfo.msg);
+ m_proto->setByte("consoleWnd_presence", m_proto->m_filterInfo.presence);
+ m_proto->setByte("consoleWnd_iq", m_proto->m_filterInfo.iq);
+ m_proto->setByte("consoleWnd_ftype", m_proto->m_filterInfo.type);
+ m_proto->setWString("consoleWnd_fpattern", m_proto->m_filterInfo.pattern);
+
+ Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "consoleWnd_");
+ DestroyWindow(m_hwnd);
+ return CSuper::OnClose();
}
- for (auto &it : filter_modes)
- if (it.type == m_proto->m_filterInfo.type) {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
- SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
- break;
- }
-
- EnableWindow(GetDlgItem(m_hwnd, IDC_CB_FILTER), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTER_REFRESH), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
-
- Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "consoleWnd_");
- return true;
-}
-
-bool CJabberDlgConsole::OnClose()
-{
- m_proto->setByte("consoleWnd_msg", m_proto->m_filterInfo.msg);
- m_proto->setByte("consoleWnd_presence", m_proto->m_filterInfo.presence);
- m_proto->setByte("consoleWnd_iq", m_proto->m_filterInfo.iq);
- m_proto->setByte("consoleWnd_ftype", m_proto->m_filterInfo.type);
- m_proto->setWString("consoleWnd_fpattern", m_proto->m_filterInfo.pattern);
-
- Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "consoleWnd_");
- DestroyWindow(m_hwnd);
- return CSuper::OnClose();
-}
-
-void CJabberDlgConsole::OnDestroy()
-{
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_MSG, BM_SETIMAGE, IMAGE_ICON, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_PRESENCE, BM_SETIMAGE, IMAGE_ICON, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_IQ, BM_SETIMAGE, IMAGE_ICON, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER_REFRESH, BM_SETIMAGE, IMAGE_ICON, 0));
-
- m_proto->m_pDlgConsole = nullptr;
- CSuper::OnDestroy();
-}
-
-void CJabberDlgConsole::OnProtoRefresh(WPARAM, LPARAM lParam)
-{
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_SETREDRAW, FALSE, 0);
-
- StringBuf *buf = (StringBuf *)lParam;
- buf->streamOffset = 0;
-
- EDITSTREAM es = { 0 };
- es.dwCookie = (DWORD_PTR)buf;
- es.pfnCallback = sttStreamInCallback;
-
- SCROLLINFO si = { 0 };
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL;
- GetScrollInfo(GetDlgItem(m_hwnd, IDC_CONSOLE), SB_VERT, &si);
-
- CHARRANGE oldSel, sel;
- POINT ptScroll;
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_GETSCROLLPOS, 0, (LPARAM)&ptScroll);
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXGETSEL, 0, (LPARAM)&oldSel);
- sel.cpMin = sel.cpMax = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLE));
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&sel);
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_STREAMIN, SF_RTF | SFF_SELECTION, (LPARAM)&es);
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&oldSel);
-
- // magic expression from tabsrmm :)
- if ((UINT)si.nPos >= (UINT)si.nMax - si.nPage - 5 || si.nMax - si.nMin - si.nPage < 50) {
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- sel.cpMin = sel.cpMax = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLE));
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&sel);
+ void OnDestroy() override
+ {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_MSG, BM_SETIMAGE, IMAGE_ICON, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_PRESENCE, BM_SETIMAGE, IMAGE_ICON, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_IQ, BM_SETIMAGE, IMAGE_ICON, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER_REFRESH, BM_SETIMAGE, IMAGE_ICON, 0));
+
+ m_proto->m_pDlgConsole = nullptr;
+ CSuper::OnDestroy();
}
- else SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETSCROLLPOS, 0, (LPARAM)&ptScroll);
- SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_SETREDRAW, TRUE, 0);
- InvalidateRect(GetDlgItem(m_hwnd, IDC_CONSOLE), nullptr, FALSE);
-}
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ switch (urc->wId) {
+ case IDC_CONSOLE:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ case IDC_CONSOLEIN:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
-int CJabberDlgConsole::Resizer(UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDC_CONSOLE:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- case IDC_CONSOLEIN:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
-
- case IDC_BTN_MSG:
- case IDC_BTN_PRESENCE:
- case IDC_BTN_IQ:
- case IDC_BTN_FILTER:
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
-
- case IDC_RESET:
- case IDOK:
- case IDC_BTN_FILTER_REFRESH:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
-
- case IDC_CB_FILTER:
- RECT rc;
- GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
- urc->rcItem.right += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx);
- urc->rcItem.top += (urc->dlgNewSize.cy - urc->dlgOriginalSize.cy);
- urc->rcItem.bottom = urc->rcItem.top + rc.bottom - rc.top;
- return 0;
- }
- return CSuper::Resizer(urc);
-}
+ case IDC_BTN_MSG:
+ case IDC_BTN_PRESENCE:
+ case IDC_BTN_IQ:
+ case IDC_BTN_FILTER:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
-INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_GETMINMAXINFO:
- {
- LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
- lpmmi->ptMinTrackSize.x = 300;
- lpmmi->ptMinTrackSize.y = 400;
+ case IDC_RESET:
+ case IDOK:
+ case IDC_BTN_FILTER_REFRESH:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+
+ case IDC_CB_FILTER:
+ RECT rc;
+ GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
+ urc->rcItem.right += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx);
+ urc->rcItem.top += (urc->dlgNewSize.cy - urc->dlgOriginalSize.cy);
+ urc->rcItem.bottom = urc->rcItem.top + rc.bottom - rc.top;
return 0;
}
+ return CSuper::Resizer(urc);
+ }
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- if (!m_proto->m_bJabberOnline)
- MessageBox(m_hwnd, TranslateT("Can't send data while you are offline."), TranslateT("Jabber Error"), MB_ICONSTOP | MB_OK);
- else {
- int length = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLEIN)) + 1;
- wchar_t *textToSend = (wchar_t *)mir_alloc(length * sizeof(wchar_t));
- GetDlgItemText(m_hwnd, IDC_CONSOLEIN, textToSend, length);
-
- TiXmlDocument doc;
- if (0 == doc.Parse(T2Utf(textToSend)))
- m_proto->m_ThreadInfo->send(doc.ToElement());
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
+ {
+ switch (msg) {
+ case WM_GETMINMAXINFO:
+ {
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ lpmmi->ptMinTrackSize.x = 300;
+ lpmmi->ptMinTrackSize.y = 400;
+ return 0;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ if (!m_proto->m_bJabberOnline)
+ MessageBox(m_hwnd, TranslateT("Can't send data while you are offline."), TranslateT("Jabber Error"), MB_ICONSTOP | MB_OK);
else {
- StringBuf buf = {};
- sttAppendBufRaw(&buf, RTF_HEADER);
- sttAppendBufRaw(&buf, RTF_BEGINPLAINXML);
- sttAppendBufT(&buf, TranslateT("Outgoing XML parsing error"));
- sttAppendBufRaw(&buf, RTF_ENDPLAINXML);
- sttAppendBufRaw(&buf, RTF_SEPARATOR);
- sttAppendBufRaw(&buf, RTF_FOOTER);
- SendMessage(m_hwnd, WM_JABBER_REFRESH, 0, (LPARAM)&buf);
- sttEmptyBuf(&buf);
- }
+ int length = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLEIN)) + 1;
+ wchar_t *textToSend = (wchar_t *)mir_alloc(length * sizeof(wchar_t));
+ GetDlgItemText(m_hwnd, IDC_CONSOLEIN, textToSend, length);
+
+ TiXmlDocument doc;
+ if (0 == doc.Parse(T2Utf(textToSend)))
+ m_proto->m_ThreadInfo->send(doc.ToElement());
+ else {
+ StringBuf buf = {};
+ sttAppendBufRaw(&buf, RTF_HEADER);
+ sttAppendBufRaw(&buf, RTF_BEGINPLAINXML);
+ sttAppendBufT(&buf, TranslateT("Outgoing XML parsing error"));
+ sttAppendBufRaw(&buf, RTF_ENDPLAINXML);
+ sttAppendBufRaw(&buf, RTF_SEPARATOR);
+ sttAppendBufRaw(&buf, RTF_FOOTER);
+ SendMessage(m_hwnd, WM_JABBER_REFRESH, 0, (LPARAM)&buf);
+ sttEmptyBuf(&buf);
+ }
- mir_free(textToSend);
+ mir_free(textToSend);
- SetDlgItemText(m_hwnd, IDC_CONSOLEIN, L"");
+ SetDlgItemText(m_hwnd, IDC_CONSOLEIN, L"");
+ }
+ return TRUE;
+
+ case IDC_RESET:
+ SetDlgItemText(m_hwnd, IDC_CONSOLE, L"");
+ break;
+
+ case IDC_BTN_MSG:
+ case IDC_BTN_PRESENCE:
+ case IDC_BTN_IQ:
+ m_proto->m_filterInfo.msg = IsDlgButtonChecked(m_hwnd, IDC_BTN_MSG);
+ m_proto->m_filterInfo.presence = IsDlgButtonChecked(m_hwnd, IDC_BTN_PRESENCE);
+ m_proto->m_filterInfo.iq = IsDlgButtonChecked(m_hwnd, IDC_BTN_IQ);
+ break;
+
+ case IDC_BTN_FILTER_REFRESH:
+ sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER));
+ break;
+
+ case IDC_CB_FILTER:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int idx = SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETCURSEL, 0, 0);
+ int len = SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXTLEN, idx, 0) + 1;
+
+ mir_cslock lck(m_proto->m_filterInfo.csPatternLock);
+
+ if (len > _countof(m_proto->m_filterInfo.pattern)) {
+ wchar_t *buf = (wchar_t *)_alloca(len * sizeof(wchar_t));
+ SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXT, idx, (LPARAM)buf);
+ mir_wstrncpy(m_proto->m_filterInfo.pattern, buf, _countof(m_proto->m_filterInfo.pattern));
+ }
+ else SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXT, idx, (LPARAM)m_proto->m_filterInfo.pattern);
+ }
+ else if (HIWORD(wParam) == CBN_EDITCHANGE) {
+ mir_cslock lck(m_proto->m_filterInfo.csPatternLock);
+ GetDlgItemText(m_hwnd, IDC_CB_FILTER, m_proto->m_filterInfo.pattern, _countof(m_proto->m_filterInfo.pattern));
+ }
+ break;
+
+ case IDC_BTN_FILTER:
+ HMENU hMenu = CreatePopupMenu();
+ for (auto &it : filter_modes)
+ AppendMenu(hMenu, MF_STRING | ((it.type == m_proto->m_filterInfo.type) ? MF_CHECKED : 0), it.type + 1, TranslateW(it.title));
+
+ RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FILTER), &rc);
+ CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_CHECKED);
+ int res = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_BOTTOMALIGN, rc.left, rc.top, 0, m_hwnd, nullptr);
+ CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_UNCHECKED);
+ DestroyMenu(hMenu);
+
+ if (res) {
+ m_proto->m_filterInfo.type = (TFilterInfo::Type)(res - 1);
+ for (auto &it : filter_modes) {
+ if (it.type == m_proto->m_filterInfo.type) {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
+ break;
+ }
+ }
+ EnableWindow(GetDlgItem(m_hwnd, IDC_CB_FILTER), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTER_REFRESH), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
+ }
}
- return TRUE;
-
- case IDC_RESET:
- SetDlgItemText(m_hwnd, IDC_CONSOLE, L"");
break;
+ }
- case IDC_BTN_MSG:
- case IDC_BTN_PRESENCE:
- case IDC_BTN_IQ:
- m_proto->m_filterInfo.msg = IsDlgButtonChecked(m_hwnd, IDC_BTN_MSG);
- m_proto->m_filterInfo.presence = IsDlgButtonChecked(m_hwnd, IDC_BTN_PRESENCE);
- m_proto->m_filterInfo.iq = IsDlgButtonChecked(m_hwnd, IDC_BTN_IQ);
- break;
+ return CSuper::DlgProc(msg, wParam, lParam);
+ }
- case IDC_BTN_FILTER_REFRESH:
- sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER));
- break;
+ void OnProtoRefresh(WPARAM, LPARAM lParam) override
+ {
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_SETREDRAW, FALSE, 0);
- case IDC_CB_FILTER:
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- int idx = SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETCURSEL, 0, 0);
- int len = SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXTLEN, idx, 0) + 1;
+ StringBuf *buf = (StringBuf *)lParam;
+ buf->streamOffset = 0;
- mir_cslock lck(m_proto->m_filterInfo.csPatternLock);
+ EDITSTREAM es = { 0 };
+ es.dwCookie = (DWORD_PTR)buf;
+ es.pfnCallback = sttStreamInCallback;
- if (len > _countof(m_proto->m_filterInfo.pattern)) {
- wchar_t *buf = (wchar_t *)_alloca(len * sizeof(wchar_t));
- SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXT, idx, (LPARAM)buf);
- mir_wstrncpy(m_proto->m_filterInfo.pattern, buf, _countof(m_proto->m_filterInfo.pattern));
- }
- else SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXT, idx, (LPARAM)m_proto->m_filterInfo.pattern);
- }
- else if (HIWORD(wParam) == CBN_EDITCHANGE) {
- mir_cslock lck(m_proto->m_filterInfo.csPatternLock);
- GetDlgItemText(m_hwnd, IDC_CB_FILTER, m_proto->m_filterInfo.pattern, _countof(m_proto->m_filterInfo.pattern));
- }
- break;
+ SCROLLINFO si = { 0 };
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(GetDlgItem(m_hwnd, IDC_CONSOLE), SB_VERT, &si);
- case IDC_BTN_FILTER:
- HMENU hMenu = CreatePopupMenu();
- for (auto &it : filter_modes)
- AppendMenu(hMenu, MF_STRING | ((it.type == m_proto->m_filterInfo.type) ? MF_CHECKED : 0), it.type + 1, TranslateW(it.title));
-
- RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FILTER), &rc);
- CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_CHECKED);
- int res = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_BOTTOMALIGN, rc.left, rc.top, 0, m_hwnd, nullptr);
- CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_UNCHECKED);
- DestroyMenu(hMenu);
-
- if (res) {
- m_proto->m_filterInfo.type = (TFilterInfo::Type)(res - 1);
- for (auto &it : filter_modes) {
- if (it.type == m_proto->m_filterInfo.type) {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
- break;
- }
- }
- EnableWindow(GetDlgItem(m_hwnd, IDC_CB_FILTER), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTER_REFRESH), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
- }
+ CHARRANGE oldSel, sel;
+ POINT ptScroll;
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_GETSCROLLPOS, 0, (LPARAM)&ptScroll);
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXGETSEL, 0, (LPARAM)&oldSel);
+ sel.cpMin = sel.cpMax = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLE));
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&sel);
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_STREAMIN, SF_RTF | SFF_SELECTION, (LPARAM)&es);
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&oldSel);
+
+ // magic expression from tabsrmm :)
+ if ((UINT)si.nPos >= (UINT)si.nMax - si.nPage - 5 || si.nMax - si.nMin - si.nPage < 50) {
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+ sel.cpMin = sel.cpMax = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_CONSOLE));
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXSETSEL, 0, (LPARAM)&sel);
}
- break;
- }
+ else SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETSCROLLPOS, 0, (LPARAM)&ptScroll);
- return CSuper::DlgProc(msg, wParam, lParam);
-}
+ SendDlgItemMessage(m_hwnd, IDC_CONSOLE, WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(GetDlgItem(m_hwnd, IDC_CONSOLE), nullptr, FALSE);
+ }
+};
void __cdecl CJabberProto::ConsoleThread(void*)
{
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index 5edc36a481..f87fc6697e 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -491,21 +491,11 @@ BOOL CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode)
///////////////////////////////////////////////////////////////////////////////
// CJabberDlgDiscovery
+
class CJabberDlgDiscovery : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
-public:
- CJabberDlgDiscovery(CJabberProto *proto, char *jid);
-
-protected:
- bool OnInitDialog() override;
- bool OnClose() override;
- void OnDestroy() override;
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- int Resizer(UTILRESIZECONTROL *urc) override;
-
-private:
char *m_jid;
bool m_focusEditAfterBrowse;
@@ -517,554 +507,544 @@ private:
CCtrlMButton m_btnBrowse;
CCtrlFilterListView m_lstDiscoTree;
- void btnViewAsTree_OnClick(CCtrlButton *);
- void btnViewAsList_OnClick(CCtrlButton *);
- void btnGoHome_OnClick(CCtrlButton *);
- void btnBookmarks_OnClick(CCtrlButton *);
- void btnRefresh_OnClick(CCtrlButton *);
- void btnBrowse_OnClick(CCtrlButton *);
- void lstDiscoTree_OnFilter(CCtrlFilterListView *);
-};
+public:
+ CJabberDlgDiscovery(CJabberProto *proto, char *jid) :
+ CJabberDlgBase(proto, IDD_SERVICE_DISCOVERY),
+ m_jid(jid),
+ m_btnViewAsTree(this, IDC_BTN_VIEWTREE, proto->LoadIconEx("sd_view_tree"), "View as tree"),
+ m_btnViewAsList(this, IDC_BTN_VIEWLIST, proto->LoadIconEx("sd_view_list"), "View as list"),
+ m_btnGoHome(this, IDC_BTN_NAVHOME, proto->LoadIconEx("sd_nav_home"), "Navigate home"),
+ m_btnBookmarks(this, IDC_BTN_FAVORITE, proto->LoadIconEx("bookmarks"), "Favorites"),
+ m_btnRefresh(this, IDC_BTN_REFRESH, proto->LoadIconEx("sd_nav_refresh"), "Refresh node"),
+ m_btnBrowse(this, IDC_BUTTON_BROWSE, proto->LoadIconEx("sd_browse"), "Browse"),
+ m_lstDiscoTree(this, IDC_TREE_DISCO, true, false)
+ {
+ m_btnViewAsTree.OnClick = Callback(this, &CJabberDlgDiscovery::btnViewAsTree_OnClick);
+ m_btnViewAsList.OnClick = Callback(this, &CJabberDlgDiscovery::btnViewAsList_OnClick);
+ m_btnGoHome.OnClick = Callback(this, &CJabberDlgDiscovery::btnGoHome_OnClick);
+ m_btnBookmarks.OnClick = Callback(this, &CJabberDlgDiscovery::btnBookmarks_OnClick);
+ m_btnRefresh.OnClick = Callback(this, &CJabberDlgDiscovery::btnRefresh_OnClick);
+ m_btnBrowse.OnClick = Callback(this, &CJabberDlgDiscovery::btnBrowse_OnClick);
+ m_lstDiscoTree.OnFilterChanged = Callback(this, &CJabberDlgDiscovery::lstDiscoTree_OnFilter);
+ }
-CJabberDlgDiscovery::CJabberDlgDiscovery(CJabberProto *proto, char *jid) :
- CJabberDlgBase(proto, IDD_SERVICE_DISCOVERY),
- m_jid(jid),
- m_btnViewAsTree(this, IDC_BTN_VIEWTREE, proto->LoadIconEx("sd_view_tree"), "View as tree"),
- m_btnViewAsList(this, IDC_BTN_VIEWLIST, proto->LoadIconEx("sd_view_list"), "View as list"),
- m_btnGoHome(this, IDC_BTN_NAVHOME, proto->LoadIconEx("sd_nav_home"), "Navigate home"),
- m_btnBookmarks(this, IDC_BTN_FAVORITE, proto->LoadIconEx("bookmarks"), "Favorites"),
- m_btnRefresh(this, IDC_BTN_REFRESH, proto->LoadIconEx("sd_nav_refresh"), "Refresh node"),
- m_btnBrowse(this, IDC_BUTTON_BROWSE, proto->LoadIconEx("sd_browse"), "Browse"),
- m_lstDiscoTree(this, IDC_TREE_DISCO, true, false)
-{
- m_btnViewAsTree.OnClick = Callback(this, &CJabberDlgDiscovery::btnViewAsTree_OnClick);
- m_btnViewAsList.OnClick = Callback(this, &CJabberDlgDiscovery::btnViewAsList_OnClick);
- m_btnGoHome.OnClick = Callback(this, &CJabberDlgDiscovery::btnGoHome_OnClick);
- m_btnBookmarks.OnClick = Callback(this, &CJabberDlgDiscovery::btnBookmarks_OnClick);
- m_btnRefresh.OnClick = Callback(this, &CJabberDlgDiscovery::btnRefresh_OnClick);
- m_btnBrowse.OnClick = Callback(this, &CJabberDlgDiscovery::btnBrowse_OnClick);
- m_lstDiscoTree.OnFilterChanged = Callback(this, &CJabberDlgDiscovery::lstDiscoTree_OnFilter);
-}
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
-bool CJabberDlgDiscovery::OnInitDialog()
-{
- CSuper::OnInitDialog();
+ Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_SERVICE_DISCOVERY));
- Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_SERVICE_DISCOVERY));
+ if (m_jid) {
+ SetDlgItemTextUtf(m_hwnd, IDC_COMBO_JID, m_jid);
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
+ m_focusEditAfterBrowse = false;
+ }
+ else {
+ SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->conn.server);
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
+ m_focusEditAfterBrowse = true;
+ }
- if (m_jid) {
- SetDlgItemTextUtf(m_hwnd, IDC_COMBO_JID, m_jid);
- SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
- m_focusEditAfterBrowse = false;
+ m_btnViewAsList.MakePush();
+ m_btnViewAsTree.MakePush();
+ m_btnBookmarks.MakePush();
+
+ CheckDlgButton(m_hwnd, m_proto->getByte("discoWnd_useTree", 1) ? IDC_BTN_VIEWTREE : IDC_BTN_VIEWLIST, BST_CHECKED);
+
+ EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTERRESET), FALSE);
+
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_CONFERENCES));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_MYAGENTS));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_AGENTS));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_FAVORITES));
+ m_proto->ComboLoadRecentStrings(m_hwnd, IDC_COMBO_JID, "discoWnd_rcJid");
+ m_proto->ComboLoadRecentStrings(m_hwnd, IDC_COMBO_NODE, "discoWnd_rcNode");
+
+ HWND hwndList = m_lstDiscoTree.GetHwnd();//GetDlgItem(m_hwnd, IDC_TREE_DISCO);
+ LVCOLUMN lvc = { 0 };
+ lvc.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_TEXT;
+ lvc.cx = m_proto->getWord("discoWnd_cx0", 200);
+ lvc.iSubItem = 0;
+ lvc.pszText = TranslateT("Node hierarchy");
+ ListView_InsertColumn(hwndList, 0, &lvc);
+ lvc.cx = m_proto->getWord("discoWnd_cx1", 200);
+ lvc.iSubItem = 1;
+ lvc.pszText = L"JID";
+ ListView_InsertColumn(hwndList, 1, &lvc);
+ lvc.cx = m_proto->getWord("discoWnd_cx2", 200);
+ lvc.iSubItem = 2;
+ lvc.pszText = TranslateT("Node");
+ ListView_InsertColumn(hwndList, 2, &lvc);
+
+ TreeList_Create(hwndList);
+ TreeList_AddIcon(hwndList, m_proto->LoadIconEx("main"), 0);
+ for (auto &it : sttNodeIcons) {
+ bool needDestroy = false;
+ HICON hIcon;
+ if ((it.iconIndex == SKINICON_STATUS_ONLINE) && it.iconName) {
+ hIcon = (HICON)CallProtoService(it.iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ needDestroy = true;
+ }
+ else if (it.iconName)
+ hIcon = m_proto->LoadIconEx(it.iconName);
+ else if (it.iconIndex)
+ hIcon = Skin_LoadIcon(it.iconIndex);
+ else continue;
+ it.listIndex = TreeList_AddIcon(hwndList, hIcon, 0);
+ if (needDestroy) DestroyIcon(hIcon);
+ }
+ TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_fail"), SD_OVERLAY_FAIL);
+ TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_progress"), SD_OVERLAY_PROGRESS);
+ TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_ok"), SD_OVERLAY_REGISTERED);
+
+ TreeList_SetMode(hwndList, m_proto->getByte("discoWnd_useTree", 1) ? TLM_TREE : TLM_REPORT);
+
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+
+ Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "discoWnd_");
+ return true;
}
- else {
- SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->conn.server);
- SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
- m_focusEditAfterBrowse = true;
+
+ bool OnClose() override
+ {
+ m_proto->setByte("discoWnd_useTree", IsDlgButtonChecked(m_hwnd, IDC_BTN_VIEWTREE));
+
+ HWND hwndList = GetDlgItem(m_hwnd, IDC_TREE_DISCO);
+ LVCOLUMN lvc = { 0 };
+ lvc.mask = LVCF_WIDTH;
+ ListView_GetColumn(hwndList, 0, &lvc);
+ m_proto->setWord("discoWnd_cx0", lvc.cx);
+ ListView_GetColumn(hwndList, 1, &lvc);
+ m_proto->setWord("discoWnd_cx1", lvc.cx);
+ ListView_GetColumn(hwndList, 2, &lvc);
+ m_proto->setWord("discoWnd_cx2", lvc.cx);
+
+ Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "discoWnd_");
+ DestroyWindow(m_hwnd);
+
+ return CSuper::OnClose();
}
- m_btnViewAsList.MakePush();
- m_btnViewAsTree.MakePush();
- m_btnBookmarks.MakePush();
-
- CheckDlgButton(m_hwnd, m_proto->getByte("discoWnd_useTree", 1) ? IDC_BTN_VIEWTREE : IDC_BTN_VIEWLIST, BST_CHECKED);
-
- EnableWindow(GetDlgItem(m_hwnd, IDC_BTN_FILTERRESET), FALSE);
-
- SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_CONFERENCES));
- SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_MYAGENTS));
- SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_AGENTS));
- SendDlgItemMessage(m_hwnd, IDC_COMBO_JID, CB_ADDSTRING, 0, (LPARAM)_T(SD_FAKEJID_FAVORITES));
- m_proto->ComboLoadRecentStrings(m_hwnd, IDC_COMBO_JID, "discoWnd_rcJid");
- m_proto->ComboLoadRecentStrings(m_hwnd, IDC_COMBO_NODE, "discoWnd_rcNode");
-
- HWND hwndList = m_lstDiscoTree.GetHwnd();//GetDlgItem(m_hwnd, IDC_TREE_DISCO);
- LVCOLUMN lvc = { 0 };
- lvc.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_TEXT;
- lvc.cx = m_proto->getWord("discoWnd_cx0", 200);
- lvc.iSubItem = 0;
- lvc.pszText = TranslateT("Node hierarchy");
- ListView_InsertColumn(hwndList, 0, &lvc);
- lvc.cx = m_proto->getWord("discoWnd_cx1", 200);
- lvc.iSubItem = 1;
- lvc.pszText = L"JID";
- ListView_InsertColumn(hwndList, 1, &lvc);
- lvc.cx = m_proto->getWord("discoWnd_cx2", 200);
- lvc.iSubItem = 2;
- lvc.pszText = TranslateT("Node");
- ListView_InsertColumn(hwndList, 2, &lvc);
-
- TreeList_Create(hwndList);
- TreeList_AddIcon(hwndList, m_proto->LoadIconEx("main"), 0);
- for (auto &it : sttNodeIcons) {
- bool needDestroy = false;
- HICON hIcon;
- if ((it.iconIndex == SKINICON_STATUS_ONLINE) && it.iconName) {
- hIcon = (HICON)CallProtoService(it.iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
- needDestroy = true;
+ void OnDestroy() override
+ {
+ m_proto->m_pDlgServiceDiscovery = nullptr;
+ {
+ mir_cslock lck(m_proto->m_SDManager.cs());
+ m_proto->m_SDManager.RemoveAll();
}
- else if (it.iconName)
- hIcon = m_proto->LoadIconEx(it.iconName);
- else if (it.iconIndex)
- hIcon = Skin_LoadIcon(it.iconIndex);
- else continue;
- it.listIndex = TreeList_AddIcon(hwndList, hIcon, 0);
- if (needDestroy) DestroyIcon(hIcon);
+ TreeList_Destroy(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
+
+ CSuper::OnDestroy();
}
- TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_fail"), SD_OVERLAY_FAIL);
- TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_progress"), SD_OVERLAY_PROGRESS);
- TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_ok"), SD_OVERLAY_REGISTERED);
- TreeList_SetMode(hwndList, m_proto->getByte("discoWnd_useTree", 1) ? TLM_TREE : TLM_REPORT);
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ RECT rc;
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+ switch (urc->wId) {
+ case IDC_COMBO_JID:
+ GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
+ urc->rcItem.right += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
+ urc->rcItem.bottom = urc->rcItem.top + rc.bottom - rc.top;
+ return 0;
- Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "discoWnd_");
- return true;
-}
+ case IDC_TXT_NODELABEL:
+ urc->rcItem.left += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
+ urc->rcItem.right += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
+ return 0;
-bool CJabberDlgDiscovery::OnClose()
-{
- m_proto->setByte("discoWnd_useTree", IsDlgButtonChecked(m_hwnd, IDC_BTN_VIEWTREE));
-
- HWND hwndList = GetDlgItem(m_hwnd, IDC_TREE_DISCO);
- LVCOLUMN lvc = { 0 };
- lvc.mask = LVCF_WIDTH;
- ListView_GetColumn(hwndList, 0, &lvc);
- m_proto->setWord("discoWnd_cx0", lvc.cx);
- ListView_GetColumn(hwndList, 1, &lvc);
- m_proto->setWord("discoWnd_cx1", lvc.cx);
- ListView_GetColumn(hwndList, 2, &lvc);
- m_proto->setWord("discoWnd_cx2", lvc.cx);
-
- Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "discoWnd_");
- DestroyWindow(m_hwnd);
-
- return CSuper::OnClose();
-}
+ case IDC_COMBO_NODE:
+ GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
+ urc->rcItem.left += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
+ urc->rcItem.right += urc->dlgNewSize.cx - urc->dlgOriginalSize.cx;
+ urc->rcItem.bottom = urc->rcItem.top + rc.bottom - rc.top;
+ return 0;
-void CJabberDlgDiscovery::OnDestroy()
-{
- m_proto->m_pDlgServiceDiscovery = nullptr;
- {
- mir_cslock lck(m_proto->m_SDManager.cs());
- m_proto->m_SDManager.RemoveAll();
+ case IDC_BUTTON_BROWSE:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
+ case IDC_TREE_DISCO:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ case IDC_TXT_FILTER:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+ case IDC_TXT_FILTERTEXT:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+ case IDC_BTN_FILTERAPPLY:
+ case IDC_BTN_FILTERRESET:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ }
+ return CSuper::Resizer(urc);
}
- TreeList_Destroy(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
-
- CSuper::OnDestroy();
-}
-int CJabberDlgDiscovery::Resizer(UTILRESIZECONTROL *urc)
-{
- RECT rc;
-
- switch (urc->wId) {
- case IDC_COMBO_JID:
- GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
- urc->rcItem.right += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
- urc->rcItem.bottom = urc->rcItem.top + rc.bottom - rc.top;
- return 0;
-
- case IDC_TXT_NODELABEL:
- urc->rcItem.left += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
- urc->rcItem.right += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
- return 0;
-
- case IDC_COMBO_NODE:
- GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
- urc->rcItem.left += (urc->dlgNewSize.cx - urc->dlgOriginalSize.cx) / 2;
- urc->rcItem.right += urc->dlgNewSize.cx - urc->dlgOriginalSize.cx;
- urc->rcItem.bottom = urc->rcItem.top + rc.bottom - rc.top;
- return 0;
-
- case IDC_BUTTON_BROWSE:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
- case IDC_TREE_DISCO:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- case IDC_TXT_FILTER:
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
- case IDC_TXT_FILTERTEXT:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
- case IDC_BTN_FILTERAPPLY:
- case IDC_BTN_FILTERRESET:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ void btnViewAsTree_OnClick(CCtrlButton*)
+ {
+ CheckDlgButton(m_hwnd, IDC_BTN_VIEWLIST, BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_BTN_VIEWTREE, BST_CHECKED);
+ TreeList_SetMode(GetDlgItem(m_hwnd, IDC_TREE_DISCO), TLM_TREE);
}
- return CSuper::Resizer(urc);
-}
-
-void CJabberDlgDiscovery::btnViewAsTree_OnClick(CCtrlButton *)
-{
- CheckDlgButton(m_hwnd, IDC_BTN_VIEWLIST, BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_BTN_VIEWTREE, BST_CHECKED);
- TreeList_SetMode(GetDlgItem(m_hwnd, IDC_TREE_DISCO), TLM_TREE);
-}
-void CJabberDlgDiscovery::btnViewAsList_OnClick(CCtrlButton *)
-{
- CheckDlgButton(m_hwnd, IDC_BTN_VIEWLIST, BST_CHECKED);
- CheckDlgButton(m_hwnd, IDC_BTN_VIEWTREE, BST_UNCHECKED);
- TreeList_SetMode(GetDlgItem(m_hwnd, IDC_TREE_DISCO), TLM_REPORT);
-}
+ void btnViewAsList_OnClick(CCtrlButton*)
+ {
+ CheckDlgButton(m_hwnd, IDC_BTN_VIEWLIST, BST_CHECKED);
+ CheckDlgButton(m_hwnd, IDC_BTN_VIEWTREE, BST_UNCHECKED);
+ TreeList_SetMode(GetDlgItem(m_hwnd, IDC_TREE_DISCO), TLM_REPORT);
+ }
-void CJabberDlgDiscovery::btnGoHome_OnClick(CCtrlButton *)
-{
- SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->conn.server);
- SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
-}
+ void btnGoHome_OnClick(CCtrlButton*)
+ {
+ SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->conn.server);
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+ }
-void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *)
-{
- HMENU hMenu = CreatePopupMenu();
+ void btnBookmarks_OnClick(CCtrlButton*)
{
- int count = m_proto->getDword("discoWnd_favCount", 0);
- for (int i = 0; i < count; i++) {
- char setting[MAXMODULELABELLENGTH];
- mir_snprintf(setting, "discoWnd_favName_%d", i);
- ptrW tszName(m_proto->getWStringA(setting));
- if (tszName != nullptr) {
- HMENU hSubMenu = CreatePopupMenu();
- AppendMenu(hSubMenu, MF_STRING, 100 + i * 10 + 0, TranslateT("Navigate"));
- AppendMenu(hSubMenu, MF_SEPARATOR, 0, nullptr);
- AppendMenu(hSubMenu, MF_STRING, 100 + i * 10 + 1, TranslateT("Remove"));
- AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hSubMenu, tszName);
+ HMENU hMenu = CreatePopupMenu();
+ {
+ int count = m_proto->getDword("discoWnd_favCount", 0);
+ for (int i = 0; i < count; i++) {
+ char setting[MAXMODULELABELLENGTH];
+ mir_snprintf(setting, "discoWnd_favName_%d", i);
+ ptrW tszName(m_proto->getWStringA(setting));
+ if (tszName != nullptr) {
+ HMENU hSubMenu = CreatePopupMenu();
+ AppendMenu(hSubMenu, MF_STRING, 100 + i * 10 + 0, TranslateT("Navigate"));
+ AppendMenu(hSubMenu, MF_SEPARATOR, 0, nullptr);
+ AppendMenu(hSubMenu, MF_STRING, 100 + i * 10 + 1, TranslateT("Remove"));
+ AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hSubMenu, tszName);
+ }
}
}
- }
- int res = 0;
- if (GetMenuItemCount(hMenu)) {
- AppendMenu(hMenu, MF_SEPARATOR, 1, nullptr);
- AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_FAVORITES, TranslateT("Browse all favorites"));
- AppendMenu(hMenu, MF_STRING, 1, TranslateT("Remove all favorites"));
- }
- if (GetMenuItemCount(hMenu))
- AppendMenu(hMenu, MF_SEPARATOR, 1, nullptr);
+ int res = 0;
+ if (GetMenuItemCount(hMenu)) {
+ AppendMenu(hMenu, MF_SEPARATOR, 1, nullptr);
+ AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_FAVORITES, TranslateT("Browse all favorites"));
+ AppendMenu(hMenu, MF_STRING, 1, TranslateT("Remove all favorites"));
+ }
+ if (GetMenuItemCount(hMenu))
+ AppendMenu(hMenu, MF_SEPARATOR, 1, nullptr);
- AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_MYAGENTS, TranslateT("Registered transports"));
- AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_AGENTS, TranslateT("Browse local transports"));
- AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_CONFERENCES, TranslateT("Browse chatrooms"));
+ AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_MYAGENTS, TranslateT("Registered transports"));
+ AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_AGENTS, TranslateT("Browse local transports"));
+ AppendMenu(hMenu, MF_STRING, 10 + SD_BROWSE_CONFERENCES, TranslateT("Browse chatrooms"));
- RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FAVORITE), &rc);
- CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_CHECKED);
- res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
- CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_UNCHECKED);
- DestroyMenu(hMenu);
+ RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FAVORITE), &rc);
+ CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_CHECKED);
+ res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
+ CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_UNCHECKED);
+ DestroyMenu(hMenu);
- if (res >= 100) {
- res -= 100;
- if (res % 10) {
- res /= 10;
- char setting[MAXMODULELABELLENGTH];
- mir_snprintf(setting, "discoWnd_favName_%d", res);
- m_proto->delSetting(setting);
- mir_snprintf(setting, "discoWnd_favJID_%d", res);
- m_proto->delSetting(setting);
- mir_snprintf(setting, "discoWnd_favNode_%d", res);
- m_proto->delSetting(setting);
- }
- else {
- res /= 10;
+ if (res >= 100) {
+ res -= 100;
+ if (res % 10) {
+ res /= 10;
+ char setting[MAXMODULELABELLENGTH];
+ mir_snprintf(setting, "discoWnd_favName_%d", res);
+ m_proto->delSetting(setting);
+ mir_snprintf(setting, "discoWnd_favJID_%d", res);
+ m_proto->delSetting(setting);
+ mir_snprintf(setting, "discoWnd_favNode_%d", res);
+ m_proto->delSetting(setting);
+ }
+ else {
+ res /= 10;
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, L"");
- SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, L"");
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
- char setting[MAXMODULELABELLENGTH];
- mir_snprintf(setting, "discoWnd_favJID_%d", res);
- ptrW dbv(m_proto->getWStringA(setting));
- if (dbv) SetDlgItemText(m_hwnd, IDC_COMBO_JID, dbv);
+ char setting[MAXMODULELABELLENGTH];
+ mir_snprintf(setting, "discoWnd_favJID_%d", res);
+ ptrW dbv(m_proto->getWStringA(setting));
+ if (dbv) SetDlgItemText(m_hwnd, IDC_COMBO_JID, dbv);
- mir_snprintf(setting, "discoWnd_favNode_%d", res);
- dbv = m_proto->getWStringA(setting);
- if (dbv) SetDlgItemText(m_hwnd, IDC_COMBO_NODE, dbv);
+ mir_snprintf(setting, "discoWnd_favNode_%d", res);
+ dbv = m_proto->getWStringA(setting);
+ if (dbv) SetDlgItemText(m_hwnd, IDC_COMBO_NODE, dbv);
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+ }
}
- }
- else if (res == 1) {
- int count = m_proto->getDword("discoWnd_favCount", 0);
- for (int i = 0; i < count; i++) {
- char setting[MAXMODULELABELLENGTH];
- mir_snprintf(setting, "discoWnd_favName_%d", i);
- m_proto->delSetting(setting);
- mir_snprintf(setting, "discoWnd_favJID_%d", i);
- m_proto->delSetting(setting);
- mir_snprintf(setting, "discoWnd_favNode_%d", i);
- m_proto->delSetting(setting);
+ else if (res == 1) {
+ int count = m_proto->getDword("discoWnd_favCount", 0);
+ for (int i = 0; i < count; i++) {
+ char setting[MAXMODULELABELLENGTH];
+ mir_snprintf(setting, "discoWnd_favName_%d", i);
+ m_proto->delSetting(setting);
+ mir_snprintf(setting, "discoWnd_favJID_%d", i);
+ m_proto->delSetting(setting);
+ mir_snprintf(setting, "discoWnd_favNode_%d", i);
+ m_proto->delSetting(setting);
+ }
+ m_proto->delSetting("discoWnd_favCount");
}
- m_proto->delSetting("discoWnd_favCount");
- }
- else if ((res >= 10) && (res <= 20)) {
- switch (res - 10) {
- case SD_BROWSE_FAVORITES:
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_FAVORITES));
- break;
- case SD_BROWSE_MYAGENTS:
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_MYAGENTS));
- break;
- case SD_BROWSE_AGENTS:
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_AGENTS));
- break;
- case SD_BROWSE_CONFERENCES:
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_CONFERENCES));
- break;
+ else if ((res >= 10) && (res <= 20)) {
+ switch (res - 10) {
+ case SD_BROWSE_FAVORITES:
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_FAVORITES));
+ break;
+ case SD_BROWSE_MYAGENTS:
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_MYAGENTS));
+ break;
+ case SD_BROWSE_AGENTS:
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_AGENTS));
+ break;
+ case SD_BROWSE_CONFERENCES:
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_CONFERENCES));
+ break;
+ }
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
- SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
- }
- CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_UNCHECKED);
-}
+ CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, BST_UNCHECKED);
+ }
-void CJabberDlgDiscovery::btnRefresh_OnClick(CCtrlButton *)
-{
- HTREELISTITEM hItem = (HTREELISTITEM)TreeList_GetActiveItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
- if (!hItem)
- return;
+ void btnRefresh_OnClick(CCtrlButton*)
+ {
+ HTREELISTITEM hItem = (HTREELISTITEM)TreeList_GetActiveItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
+ if (!hItem)
+ return;
+
+ TiXmlDocument packet;
+ mir_cslockfull lck(m_proto->m_SDManager.cs());
+ CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
+ if (pNode) {
+ TreeList_ResetItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO), hItem);
+ pNode->ResetInfo();
+ m_proto->SendBothRequests(pNode, packet.ToElement());
+ TreeList_MakeFakeParent(hItem, FALSE);
+ }
+ lck.unlock();
- TiXmlDocument packet;
- mir_cslockfull lck(m_proto->m_SDManager.cs());
- CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
- if (pNode) {
- TreeList_ResetItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO), hItem);
- pNode->ResetInfo();
- m_proto->SendBothRequests(pNode, packet.ToElement());
- TreeList_MakeFakeParent(hItem, FALSE);
+ if (packet.FirstChildElement())
+ m_proto->m_ThreadInfo->send(packet.ToElement());
}
- lck.unlock();
- if (packet.FirstChildElement())
- m_proto->m_ThreadInfo->send(packet.ToElement());
-}
-
-void CJabberDlgDiscovery::btnBrowse_OnClick(CCtrlButton *)
-{
- SetFocus(GetDlgItem(m_hwnd, m_focusEditAfterBrowse ? IDC_COMBO_JID : IDC_TREE_DISCO));
- m_focusEditAfterBrowse = false;
+ void btnBrowse_OnClick(CCtrlButton*)
+ {
+ SetFocus(GetDlgItem(m_hwnd, m_focusEditAfterBrowse ? IDC_COMBO_JID : IDC_TREE_DISCO));
+ m_focusEditAfterBrowse = false;
- m_proto->PerformBrowse(m_hwnd);
-}
+ m_proto->PerformBrowse(m_hwnd);
+ }
-void CJabberDlgDiscovery::lstDiscoTree_OnFilter(CCtrlFilterListView *)
-{
- TreeList_SetFilter(GetDlgItem(m_hwnd, IDC_TREE_DISCO), m_lstDiscoTree.GetFilterText());
-}
+ void lstDiscoTree_OnFilter(CCtrlFilterListView *)
+ {
+ TreeList_SetFilter(GetDlgItem(m_hwnd, IDC_TREE_DISCO), m_lstDiscoTree.GetFilterText());
+ }
-INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- BOOL result;
- if (TreeList_ProcessMessage(m_hwnd, msg, wParam, lParam, IDC_TREE_DISCO, &result))
- return result;
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
+ {
+ BOOL result;
+ if (TreeList_ProcessMessage(m_hwnd, msg, wParam, lParam, IDC_TREE_DISCO, &result))
+ return result;
- switch (msg) {
- case WM_GETMINMAXINFO:
- {
- LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
- lpmmi->ptMinTrackSize.x = 538;
- lpmmi->ptMinTrackSize.y = 374;
- return 0;
- }
+ switch (msg) {
+ case WM_GETMINMAXINFO:
+ {
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ lpmmi->ptMinTrackSize.x = 538;
+ lpmmi->ptMinTrackSize.y = 374;
+ return 0;
+ }
- case WM_JABBER_TRANSPORT_REFRESH:
- if (m_proto->m_nSDBrowseMode == SD_BROWSE_MYAGENTS) {
- SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_MYAGENTS));
- SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
- }
- break;
+ case WM_JABBER_TRANSPORT_REFRESH:
+ if (m_proto->m_nSDBrowseMode == SD_BROWSE_MYAGENTS) {
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_MYAGENTS));
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, L"");
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+ }
+ break;
- case WM_JABBER_REFRESH:
- KillTimer(m_hwnd, REFRESH_TIMER);
- if (GetTickCount() - m_proto->m_dwSDLastRefresh < REFRESH_TIMEOUT) {
- SetTimer(m_hwnd, REFRESH_TIMER, REFRESH_TIMEOUT, nullptr);
- return TRUE;
- }
+ case WM_JABBER_REFRESH:
+ KillTimer(m_hwnd, REFRESH_TIMER);
+ if (GetTickCount() - m_proto->m_dwSDLastRefresh < REFRESH_TIMEOUT) {
+ SetTimer(m_hwnd, REFRESH_TIMER, REFRESH_TIMEOUT, nullptr);
+ return TRUE;
+ }
- wParam = REFRESH_TIMER;
- __fallthrough;
-
- case WM_TIMER:
- if (wParam == REFRESH_TIMER) {
- mir_cslockfull lck(m_proto->m_SDManager.cs());
-
- CJabberSDNode *pNode = m_proto->m_SDManager.GetPrimaryNode();
- while (pNode) {
- if (pNode->GetJid()) {
- if (!pNode->GetTreeItemHandle()) {
- HTREELISTITEM hNewItem = TreeList_AddItem(
- GetDlgItem(m_hwnd, IDC_TREE_DISCO), nullptr,
- Utf2T(pNode->GetName() ? pNode->GetName() : pNode->GetJid()),
- (LPARAM)pNode);
- TreeList_AppendColumn(hNewItem, Utf2T(pNode->GetJid()));
- TreeList_AppendColumn(hNewItem, Utf2T(pNode->GetNode()));
- pNode->SetTreeItemHandle(hNewItem);
+ wParam = REFRESH_TIMER;
+ __fallthrough;
+
+ case WM_TIMER:
+ if (wParam == REFRESH_TIMER) {
+ mir_cslockfull lck(m_proto->m_SDManager.cs());
+
+ CJabberSDNode *pNode = m_proto->m_SDManager.GetPrimaryNode();
+ while (pNode) {
+ if (pNode->GetJid()) {
+ if (!pNode->GetTreeItemHandle()) {
+ HTREELISTITEM hNewItem = TreeList_AddItem(
+ GetDlgItem(m_hwnd, IDC_TREE_DISCO), nullptr,
+ Utf2T(pNode->GetName() ? pNode->GetName() : pNode->GetJid()),
+ (LPARAM)pNode);
+ TreeList_AppendColumn(hNewItem, Utf2T(pNode->GetJid()));
+ TreeList_AppendColumn(hNewItem, Utf2T(pNode->GetNode()));
+ pNode->SetTreeItemHandle(hNewItem);
+ }
}
+ m_proto->SyncTree(nullptr, pNode);
+ pNode = pNode->GetNext();
}
- m_proto->SyncTree(nullptr, pNode);
- pNode = pNode->GetNext();
+ lck.unlock();
+ TreeList_Update(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
+ KillTimer(m_hwnd, REFRESH_TIMER);
+ m_proto->m_dwSDLastRefresh = GetTickCount();
+ return TRUE;
}
- lck.unlock();
- TreeList_Update(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
- KillTimer(m_hwnd, REFRESH_TIMER);
- m_proto->m_dwSDLastRefresh = GetTickCount();
- return TRUE;
- }
- else if (wParam == AUTODISCO_TIMER) {
- HWND hwndList = GetDlgItem(m_hwnd, IDC_TREE_DISCO);
- RECT rcCtl; GetClientRect(hwndList, &rcCtl);
- RECT rcHdr; GetClientRect(ListView_GetHeader(hwndList), &rcHdr);
- LVHITTESTINFO lvhti = { 0 };
- lvhti.pt.x = rcCtl.left + 5;
- lvhti.pt.y = rcHdr.bottom + 5;
- int iFirst = ListView_HitTest(hwndList, &lvhti);
- memset(&lvhti, 0, sizeof(lvhti));
- lvhti.pt.x = rcCtl.left + 5;
- lvhti.pt.y = rcCtl.bottom - 5;
- int iLast = ListView_HitTest(hwndList, &lvhti);
- if (iFirst < 0) return FALSE;
- if (iLast < 0) iLast = ListView_GetItemCount(hwndList) - 1;
-
- TiXmlDocument packet;
- {
- mir_cslock lck(m_proto->m_SDManager.cs());
- for (int i = iFirst; i <= iLast; i++) {
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_PARAM;
- lvi.iItem = i;
- ListView_GetItem(hwndList, &lvi);
- if (!lvi.lParam)
- continue;
+ else if (wParam == AUTODISCO_TIMER) {
+ HWND hwndList = GetDlgItem(m_hwnd, IDC_TREE_DISCO);
+ RECT rcCtl; GetClientRect(hwndList, &rcCtl);
+ RECT rcHdr; GetClientRect(ListView_GetHeader(hwndList), &rcHdr);
+ LVHITTESTINFO lvhti = { 0 };
+ lvhti.pt.x = rcCtl.left + 5;
+ lvhti.pt.y = rcHdr.bottom + 5;
+ int iFirst = ListView_HitTest(hwndList, &lvhti);
+ memset(&lvhti, 0, sizeof(lvhti));
+ lvhti.pt.x = rcCtl.left + 5;
+ lvhti.pt.y = rcCtl.bottom - 5;
+ int iLast = ListView_HitTest(hwndList, &lvhti);
+ if (iFirst < 0) return FALSE;
+ if (iLast < 0) iLast = ListView_GetItemCount(hwndList) - 1;
+
+ TiXmlDocument packet;
+ {
+ mir_cslock lck(m_proto->m_SDManager.cs());
+ for (int i = iFirst; i <= iLast; i++) {
+ LVITEM lvi = { 0 };
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = i;
+ ListView_GetItem(hwndList, &lvi);
+ if (!lvi.lParam)
+ continue;
+
+ CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData((HTREELISTITEM)lvi.lParam);
+ if (!pNode || pNode->GetInfoRequestId())
+ continue;
+
+ m_proto->SendInfoRequest(pNode, packet.ToElement());
+ }
+ }
+ if (packet.FirstChildElement())
+ m_proto->m_ThreadInfo->send(packet.ToElement());
+
+ KillTimer(m_hwnd, AUTODISCO_TIMER);
+ m_proto->m_dwSDLastRefresh = GetTickCount();
+ return TRUE;
+ }
+ break;
- CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData((HTREELISTITEM)lvi.lParam);
- if (!pNode || pNode->GetInfoRequestId())
- continue;
+ case WM_CONTEXTMENU:
+ if (GetWindowLongPtr((HWND)wParam, GWL_ID) == IDC_TREE_DISCO) {
+ HWND hwndList = (HWND)wParam;
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
- m_proto->SendInfoRequest(pNode, packet.ToElement());
+ if ((pt.x == -1) && (pt.y == -1)) {
+ LVITEM lvi = { 0 };
+ lvi.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
+ if (lvi.iItem < 0) return FALSE;
+
+ RECT rc;
+ ListView_GetItemRect(hwndList, lvi.iItem, &rc, LVIR_LABEL);
+ pt.x = rc.left;
+ pt.y = rc.bottom;
+ ClientToScreen(hwndList, &pt);
}
- }
- if (packet.FirstChildElement())
- m_proto->m_ThreadInfo->send(packet.ToElement());
- KillTimer(m_hwnd, AUTODISCO_TIMER);
- m_proto->m_dwSDLastRefresh = GetTickCount();
- return TRUE;
- }
- break;
+ HTREELISTITEM hItem = TreeList_GetActiveItem(hwndList);
+ if (!hItem) break;
+ CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData(hItem);
+ if (!pNode) break;
- case WM_CONTEXTMENU:
- if (GetWindowLongPtr((HWND)wParam, GWL_ID) == IDC_TREE_DISCO) {
- HWND hwndList = (HWND)wParam;
- POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
-
- if ((pt.x == -1) && (pt.y == -1)) {
- LVITEM lvi = { 0 };
- lvi.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
- if (lvi.iItem < 0) return FALSE;
-
- RECT rc;
- ListView_GetItemRect(hwndList, lvi.iItem, &rc, LVIR_LABEL);
- pt.x = rc.left;
- pt.y = rc.bottom;
- ClientToScreen(hwndList, &pt);
+ m_proto->ServiceDiscoveryShowMenu(pNode, hItem, pt);
}
+ break;
- HTREELISTITEM hItem = TreeList_GetActiveItem(hwndList);
- if (!hItem) break;
- CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData(hItem);
- if (!pNode) break;
-
- m_proto->ServiceDiscoveryShowMenu(pNode, hItem, pt);
- }
- break;
+ case WM_NOTIFY:
+ if (wParam == IDC_TREE_DISCO) {
+ NMHDR* pHeader = (NMHDR*)lParam;
+ if (pHeader->code == LVN_GETINFOTIP) {
+ NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = pInfoTip->iItem;
+ ListView_GetItem(pHeader->hwndFrom, &lvi);
+ HTREELISTITEM hItem = (HTREELISTITEM)lvi.lParam;
- case WM_NOTIFY:
- if (wParam == IDC_TREE_DISCO) {
- NMHDR* pHeader = (NMHDR*)lParam;
- if (pHeader->code == LVN_GETINFOTIP) {
- NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = pInfoTip->iItem;
- ListView_GetItem(pHeader->hwndFrom, &lvi);
- HTREELISTITEM hItem = (HTREELISTITEM)lvi.lParam;
-
- mir_cslock lck(m_proto->m_SDManager.cs());
- CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
- if (pNode)
- pNode->GetTooltipText(pInfoTip->pszText, pInfoTip->cchTextMax);
- }
- else if (pHeader->code == TVN_ITEMEXPANDED) {
- NMTREEVIEW *pNmTreeView = (NMTREEVIEW *)lParam;
- HTREELISTITEM hItem = (HTREELISTITEM)pNmTreeView->itemNew.hItem;
- XmlNode packet(0);
- {
mir_cslock lck(m_proto->m_SDManager.cs());
CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
- if (pNode) {
- m_proto->SendBothRequests(pNode, packet);
- TreeList_MakeFakeParent(hItem, FALSE);
+ if (pNode)
+ pNode->GetTooltipText(pInfoTip->pszText, pInfoTip->cchTextMax);
+ }
+ else if (pHeader->code == TVN_ITEMEXPANDED) {
+ NMTREEVIEW *pNmTreeView = (NMTREEVIEW *)lParam;
+ HTREELISTITEM hItem = (HTREELISTITEM)pNmTreeView->itemNew.hItem;
+ XmlNode packet(0);
+ {
+ mir_cslock lck(m_proto->m_SDManager.cs());
+ CJabberSDNode *pNode = (CJabberSDNode*)TreeList_GetData(hItem);
+ if (pNode) {
+ m_proto->SendBothRequests(pNode, packet);
+ TreeList_MakeFakeParent(hItem, FALSE);
+ }
}
+ if (packet.FirstChildElement())
+ m_proto->m_ThreadInfo->send(packet);
}
- if (packet.FirstChildElement())
- m_proto->m_ThreadInfo->send(packet);
- }
- else if (pHeader->code == NM_CUSTOMDRAW) {
- LPNMLVCUSTOMDRAW lpnmlvcd = (LPNMLVCUSTOMDRAW)lParam;
- if (lpnmlvcd->nmcd.dwDrawStage != CDDS_PREPAINT)
- return CDRF_DODEFAULT;
+ else if (pHeader->code == NM_CUSTOMDRAW) {
+ LPNMLVCUSTOMDRAW lpnmlvcd = (LPNMLVCUSTOMDRAW)lParam;
+ if (lpnmlvcd->nmcd.dwDrawStage != CDDS_PREPAINT)
+ return CDRF_DODEFAULT;
+
+ KillTimer(m_hwnd, AUTODISCO_TIMER);
+ if (GetTickCount() - sttLastAutoDisco < AUTODISCO_TIMEOUT) {
+ SetTimer(m_hwnd, AUTODISCO_TIMER, AUTODISCO_TIMEOUT, nullptr);
+ return CDRF_DODEFAULT;
+ }
+
+ SendMessage(m_hwnd, WM_TIMER, AUTODISCO_TIMER, 0);
- KillTimer(m_hwnd, AUTODISCO_TIMER);
- if (GetTickCount() - sttLastAutoDisco < AUTODISCO_TIMEOUT) {
- SetTimer(m_hwnd, AUTODISCO_TIMER, AUTODISCO_TIMEOUT, nullptr);
return CDRF_DODEFAULT;
}
+ return TRUE;
+ }
+ break;
- SendMessage(m_hwnd, WM_TIMER, AUTODISCO_TIMER, 0);
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ HWND hwndFocus = GetFocus();
+ if (!hwndFocus) return TRUE;
+ if (GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_TXT_FILTERTEXT)
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BTN_FILTERAPPLY, 0), 0);
+ else if (m_hwnd == (hwndFocus = GetParent(hwndFocus)))
+ break;
+ else if ((GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_COMBO_NODE) || (GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_COMBO_JID))
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
+ }
+ return TRUE;
- return CDRF_DODEFAULT;
+ case IDCANCEL:
+ PostMessage(m_hwnd, WM_CLOSE, 0, 0);
+ return TRUE;
}
- return TRUE;
- }
- break;
+ break;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- {
- HWND hwndFocus = GetFocus();
- if (!hwndFocus) return TRUE;
- if (GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_TXT_FILTERTEXT)
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BTN_FILTERAPPLY, 0), 0);
- else if (m_hwnd == (hwndFocus = GetParent(hwndFocus)))
- break;
- else if ((GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_COMBO_NODE) || (GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_COMBO_JID))
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
- }
- return TRUE;
+ case WM_MEASUREITEM:
+ return Menu_MeasureItem(lParam);
- case IDCANCEL:
- PostMessage(m_hwnd, WM_CLOSE, 0, 0);
- return TRUE;
+ case WM_DRAWITEM:
+ return Menu_DrawItem(lParam);
}
- break;
-
- case WM_MEASUREITEM:
- return Menu_MeasureItem(lParam);
- case WM_DRAWITEM:
- return Menu_DrawItem(lParam);
+ return CSuper::DlgProc(msg, wParam, lParam);
}
+};
- return CSuper::DlgProc(msg, wParam, lParam);
-}
-
-// extern references to used functions:
-void SearchAddToRecent(wchar_t* szAddr, HWND hwndDialog = nullptr);
+/////////////////////////////////////////////////////////////////////////////////////////
void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM hItem, POINT pt)
{
- //ClientToScreen(GetDlgItem(hwndServiceDiscovery, IDC_TREE_DISCO), &pt);
-
enum
{ // This values are below CLISTMENUIDMAX and won't overlap
SD_ACT_REFRESH = 1, SD_ACT_REFRESHCHILDREN, SD_ACT_FAVORITE,
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index ef5c9ba096..e412c42c3a 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -399,9 +399,7 @@ public:
mir_free(m_jid);
}
-protected:
-
- bool OnInitDialog()
+ bool OnInitDialog() override
{
CSuper::OnInitDialog();
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp
index dea6a774e8..67678f107c 100644
--- a/protocols/JabberG/src/jabber_notes.cpp
+++ b/protocols/JabberG/src/jabber_notes.cpp
@@ -147,15 +147,6 @@ class CJabberDlgNoteItem : public CJabberDlgBase
typedef CJabberDlgBase CSuper;
typedef void (CJabberProto::*TFnProcessNote)(CNoteItem *, bool ok);
-public:
- CJabberDlgNoteItem(CJabberDlgBase *parent, CNoteItem *pNote);
- CJabberDlgNoteItem(CJabberProto *proto, CNoteItem *pNote, TFnProcessNote fnProcess);
-
-protected:
- bool OnInitDialog() override;
- int Resizer(UTILRESIZECONTROL *urc);
-
-private:
CNoteItem *m_pNote;
TFnProcessNote m_fnProcess;
@@ -164,7 +155,73 @@ private:
CCtrlEdit m_txtTags;
CCtrlButton m_btnOk;
- void btnOk_OnClick(CCtrlButton *)
+public:
+ CJabberDlgNoteItem(CJabberDlgBase *parent, CNoteItem *pNote) :
+ CSuper(parent->GetProto(), IDD_NOTE_EDIT),
+ m_pNote(pNote),
+ m_fnProcess(nullptr),
+ m_txtTitle(this, IDC_TXT_TITLE),
+ m_txtText(this, IDC_TXT_TEXT),
+ m_txtTags(this, IDC_TXT_TAGS),
+ m_btnOk(this, IDOK)
+ {
+ SetParent(parent->GetHwnd());
+ m_btnOk.OnClick = Callback(this, &CJabberDlgNoteItem::btnOk_OnClick);
+ }
+
+ CJabberDlgNoteItem(CJabberProto *proto, CNoteItem *pNote, TFnProcessNote fnProcess) :
+ CSuper(proto, IDD_NOTE_EDIT),
+ m_pNote(pNote),
+ m_fnProcess(fnProcess),
+ m_txtTitle(this, IDC_TXT_TITLE),
+ m_txtText(this, IDC_TXT_TEXT),
+ m_txtTags(this, IDC_TXT_TAGS),
+ m_btnOk(this, IDOK)
+ {
+ m_btnOk.OnClick = Callback(this, &CJabberDlgNoteItem::btnOk_OnClick);
+ }
+
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
+ Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_NOTES));
+
+ if (m_fnProcess) {
+ CMStringW buf;
+ if (m_fnProcess == &CJabberProto::ProcessIncomingNote)
+ buf.Format(TranslateT("Incoming note from %s"), m_pNote->GetFrom());
+ else
+ buf.Format(TranslateT("Send note to %s"), m_pNote->GetFrom());
+
+ SetWindowText(m_hwnd, buf);
+ }
+
+ m_txtTitle.SetText(Utf2T(m_pNote->GetTitle()));
+ m_txtText.SetText(m_pNote->GetText());
+ m_txtTags.SetText(Utf2T(m_pNote->GetTagsStr()));
+ return true;
+ }
+
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ switch (urc->wId) {
+ case IDC_TXT_TITLE:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+ case IDC_TXT_TEXT:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ case IDC_ST_TAGS:
+ case IDC_TXT_TAGS:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+
+ case IDOK:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ }
+
+ return CSuper::Resizer(urc);
+ }
+
+ void btnOk_OnClick(CCtrlButton*)
{
T2Utf szTitle(ptrW(m_txtTitle.GetText()));
T2Utf szTags(ptrW(m_txtTags.GetText()));
@@ -183,71 +240,6 @@ private:
}
};
-CJabberDlgNoteItem::CJabberDlgNoteItem(CJabberDlgBase *parent, CNoteItem *pNote) :
- CSuper(parent->GetProto(), IDD_NOTE_EDIT),
- m_pNote(pNote),
- m_fnProcess(nullptr),
- m_txtTitle(this, IDC_TXT_TITLE),
- m_txtText(this, IDC_TXT_TEXT),
- m_txtTags(this, IDC_TXT_TAGS),
- m_btnOk(this, IDOK)
-{
- SetParent(parent->GetHwnd());
- m_btnOk.OnClick = Callback(this, &CJabberDlgNoteItem::btnOk_OnClick);
-}
-
-CJabberDlgNoteItem::CJabberDlgNoteItem(CJabberProto *proto, CNoteItem *pNote, TFnProcessNote fnProcess) :
- CSuper(proto, IDD_NOTE_EDIT),
- m_pNote(pNote),
- m_fnProcess(fnProcess),
- m_txtTitle(this, IDC_TXT_TITLE),
- m_txtText(this, IDC_TXT_TEXT),
- m_txtTags(this, IDC_TXT_TAGS),
- m_btnOk(this, IDOK)
-{
- m_btnOk.OnClick = Callback(this, &CJabberDlgNoteItem::btnOk_OnClick);
-}
-
-bool CJabberDlgNoteItem::OnInitDialog()
-{
- CSuper::OnInitDialog();
- Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_NOTES));
-
- if (m_fnProcess) {
- CMStringW buf;
- if (m_fnProcess == &CJabberProto::ProcessIncomingNote)
- buf.Format(TranslateT("Incoming note from %s"), m_pNote->GetFrom());
- else
- buf.Format(TranslateT("Send note to %s"), m_pNote->GetFrom());
-
- SetWindowText(m_hwnd, buf);
- }
-
- m_txtTitle.SetText(Utf2T(m_pNote->GetTitle()));
- m_txtText.SetText(m_pNote->GetText());
- m_txtTags.SetText(Utf2T(m_pNote->GetTagsStr()));
- return true;
-}
-
-int CJabberDlgNoteItem::Resizer(UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDC_TXT_TITLE:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
- case IDC_TXT_TEXT:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- case IDC_ST_TAGS:
- case IDC_TXT_TAGS:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
-
- case IDOK:
- case IDCANCEL:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
- }
-
- return CSuper::Resizer(urc);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Notebook window
@@ -411,20 +403,6 @@ class CJabberDlgNotes : public CJabberDlgBase
{
typedef CJabberDlgBase CSuper;
-public:
- CJabberDlgNotes(CJabberProto *proto);
- void UpdateData();
-
-protected:
- bool OnInitDialog() override;
- bool OnClose() override;
- void OnDestroy();
- int Resizer(UTILRESIZECONTROL *urc);
-
- void OnProtoCheckOnline(WPARAM wParam, LPARAM lParam);
- void OnProtoRefresh(WPARAM wParam, LPARAM lParam);
-
-private:
CCtrlMButton m_btnAdd;
CCtrlMButton m_btnEdit;
CCtrlMButton m_btnRemove;
@@ -511,7 +489,88 @@ private:
EnableControls();
}
- void btnAdd_OnClick(CCtrlFilterListView *)
+public:
+ CJabberDlgNotes(CJabberProto *proto) :
+ CSuper(proto, IDD_NOTEBOOK),
+ m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")),
+ m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")),
+ m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")),
+ m_lstNotes(this, IDC_LST_NOTES),
+ m_tvFilter(this, IDC_TV_FILTER),
+ m_btnSave(this, IDC_APPLY)
+ {
+ m_btnAdd.OnClick = Callback(this, &CJabberDlgNotes::btnAdd_OnClick);
+ m_btnEdit.OnClick = Callback(this, &CJabberDlgNotes::btnEdit_OnClick);
+ m_btnRemove.OnClick = Callback(this, &CJabberDlgNotes::btnRemove_OnClick);
+ m_lstNotes.OnDblClick = Callback(this, &CJabberDlgNotes::btnEdit_OnClick);
+ m_lstNotes.OnSelChange = Callback(this, &CJabberDlgNotes::lstNotes_OnSelChange);
+ m_btnSave.OnClick = Callback(this, &CJabberDlgNotes::btnSave_OnClick);
+
+ m_tvFilter.OnSelChanged = Callback(this, &CJabberDlgNotes::tvFilter_OnSelChanged);
+ m_tvFilter.OnDeleteItem = Callback(this, &CJabberDlgNotes::tvFilter_OnDeleteItem);
+ }
+
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
+ Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_NOTES));
+
+ LOGFONT lf, lfTmp;
+ m_hfntNormal = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ GetObject(m_hfntNormal, sizeof(lf), &lf);
+ lfTmp = lf; lfTmp.lfWeight = FW_BOLD;
+ m_hfntBold = CreateFontIndirect(&lfTmp);
+ lfTmp = lf; lfTmp.lfHeight *= 0.8;
+ m_hfntSmall = CreateFontIndirect(&lfTmp);
+ m_lstNotes.SetFonts(m_hfntNormal, m_hfntSmall, m_hfntBold);
+
+ Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "notesWnd_");
+ return true;
+ }
+
+ bool OnClose() override
+ {
+ if (m_proto->m_notes.IsModified())
+ if (IDYES != MessageBox(m_hwnd, TranslateT("Notes are not saved, close this window without uploading data to server?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
+ return false;
+
+ Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "notesWnd_");
+ DeleteObject(m_hfntSmall);
+ DeleteObject(m_hfntBold);
+ return CSuper::OnClose();
+ }
+
+ void OnDestroy() override
+ {
+ m_tvFilter.DeleteAllItems();
+ m_proto->m_pDlgNotes = nullptr;
+ CSuper::OnDestroy();
+ }
+
+ int Resizer(UTILRESIZECONTROL *urc) override
+ {
+ switch (urc->wId) {
+ case IDC_TV_FILTER:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
+ case IDC_LST_NOTES:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ case IDC_APPLY:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ case IDC_ADD:
+ case IDC_EDIT:
+ case IDC_REMOVE:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+ }
+ return CSuper::Resizer(urc);
+ }
+
+ void OnProtoCheckOnline(WPARAM, LPARAM) override
+ {
+ EnableControls();
+ }
+
+ void btnAdd_OnClick(CCtrlFilterListView*)
{
CNoteItem *pNote = new CNoteItem();
CJabberDlgNoteItem dlg(this, pNote);
@@ -529,7 +588,7 @@ private:
EnableControls();
}
- void btnEdit_OnClick(CCtrlFilterListView *)
+ void btnEdit_OnClick(CCtrlFilterListView*)
{
int idx = m_lstNotes.GetCurSel();
if (idx != LB_ERR) {
@@ -544,7 +603,7 @@ private:
EnableControls();
}
- void btnRemove_OnClick(CCtrlFilterListView *)
+ void btnRemove_OnClick(CCtrlFilterListView*)
{
int idx = m_lstNotes.GetCurSel();
if (idx != LB_ERR) {
@@ -576,7 +635,7 @@ private:
EnableControls();
}
- void btnSave_OnClick(CCtrlButton *)
+ void btnSave_OnClick(CCtrlButton*)
{
XmlNodeIq iq("set");
TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVATE_STORAGE);
@@ -585,97 +644,13 @@ private:
m_proto->m_ThreadInfo->send(iq);
EnableControls();
}
-};
-
-CJabberDlgNotes::CJabberDlgNotes(CJabberProto *proto) :
- CSuper(proto, IDD_NOTEBOOK),
- m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")),
- m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")),
- m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")),
- m_lstNotes(this, IDC_LST_NOTES),
- m_tvFilter(this, IDC_TV_FILTER),
- m_btnSave(this, IDC_APPLY)
-{
- m_btnAdd.OnClick = Callback(this, &CJabberDlgNotes::btnAdd_OnClick);
- m_btnEdit.OnClick = Callback(this, &CJabberDlgNotes::btnEdit_OnClick);
- m_btnRemove.OnClick = Callback(this, &CJabberDlgNotes::btnRemove_OnClick);
- m_lstNotes.OnDblClick = Callback(this, &CJabberDlgNotes::btnEdit_OnClick);
- m_lstNotes.OnSelChange = Callback(this, &CJabberDlgNotes::lstNotes_OnSelChange);
- m_btnSave.OnClick = Callback(this, &CJabberDlgNotes::btnSave_OnClick);
-
- m_tvFilter.OnSelChanged = Callback(this, &CJabberDlgNotes::tvFilter_OnSelChanged);
- m_tvFilter.OnDeleteItem = Callback(this, &CJabberDlgNotes::tvFilter_OnDeleteItem);
-}
-void CJabberDlgNotes::UpdateData()
-{
- RebuildTree();
- EnableControls();
-}
-
-bool CJabberDlgNotes::OnInitDialog()
-{
- CSuper::OnInitDialog();
- Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_NOTES));
-
- LOGFONT lf, lfTmp;
- m_hfntNormal = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- GetObject(m_hfntNormal, sizeof(lf), &lf);
- lfTmp = lf; lfTmp.lfWeight = FW_BOLD;
- m_hfntBold = CreateFontIndirect(&lfTmp);
- lfTmp = lf; lfTmp.lfHeight *= 0.8;
- m_hfntSmall = CreateFontIndirect(&lfTmp);
- m_lstNotes.SetFonts(m_hfntNormal, m_hfntSmall, m_hfntBold);
-
- Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "notesWnd_");
- return true;
-}
-
-bool CJabberDlgNotes::OnClose()
-{
- if (m_proto->m_notes.IsModified())
- if (IDYES != MessageBox(m_hwnd, TranslateT("Notes are not saved, close this window without uploading data to server?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
- return false;
-
- Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "notesWnd_");
- DeleteObject(m_hfntSmall);
- DeleteObject(m_hfntBold);
- return CSuper::OnClose();
-}
-
-void CJabberDlgNotes::OnDestroy()
-{
- m_tvFilter.DeleteAllItems();
- m_proto->m_pDlgNotes = nullptr;
- CSuper::OnDestroy();
-}
-
-void CJabberDlgNotes::OnProtoCheckOnline(WPARAM, LPARAM)
-{
- EnableControls();
-}
-
-void CJabberDlgNotes::OnProtoRefresh(WPARAM, LPARAM)
-{
-}
-
-int CJabberDlgNotes::Resizer(UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDC_TV_FILTER:
- return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
- case IDC_LST_NOTES:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- case IDC_APPLY:
- case IDCANCEL:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
- case IDC_ADD:
- case IDC_EDIT:
- case IDC_REMOVE:
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
- }
- return CSuper::Resizer(urc);
-}
+ void UpdateData()
+ {
+ RebuildTree();
+ EnableControls();
+ }
+};
/////////////////////////////////////////////////////////////////////////////////////////
// Launches the incoming note window
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 598f4c7867..9656608d10 100755
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -536,7 +536,7 @@ protected:
private:
bool m_gotservers;
- void btnRegister_OnClick(CCtrlButton *)
+ void btnRegister_OnClick(CCtrlButton*)
{
PSHNOTIFY pshn = {};
pshn.hdr.code = PSN_APPLY;
@@ -562,7 +562,7 @@ private:
}
}
- void btnUnregister_OnClick(CCtrlButton *)
+ void btnUnregister_OnClick(CCtrlButton*)
{
int res = MessageBox(nullptr,
TranslateT("This operation will kill your account, roster and all other information stored at the server. Are you ready to do that?"),
@@ -574,7 +574,7 @@ private:
<< XCHILD("remove"));
}
- void btnChangePassword_OnClick(CCtrlButton *)
+ void btnChangePassword_OnClick(CCtrlButton*)
{
if (!m_proto->m_bJabberOnline) {
MessageBox(nullptr,
@@ -1801,7 +1801,7 @@ private:
bool m_gotservers;
bool m_canregister;
- void btnRegister_OnClick(CCtrlButton *)
+ void btnRegister_OnClick(CCtrlButton*)
{
PSHNOTIFY pshn = {};
pshn.hdr.code = PSN_APPLY;
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index 52eadfbe2f..35a8b3cbfd 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -402,6 +402,15 @@ public:
return true;
}
+ void OnDestroy() override
+ {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0));
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, 0, 0));
+ m_proto->m_hwndPrivacyRule = nullptr;
+ }
+
void cbType_OnChange(CCtrlData*)
{
if (!m_pRule) return;
@@ -481,7 +490,7 @@ public:
}
}
- void btnOk_OnClick(CCtrlButton *)
+ void btnOk_OnClick(CCtrlButton*)
{
LRESULT nItemData = -1;
LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
@@ -532,93 +541,35 @@ public:
EndDialog(m_hwnd, 1);
}
- void btnCancel_OnClick(CCtrlButton *)
+ void btnCancel_OnClick(CCtrlButton*)
{
EndDialog(m_hwnd, 0);
}
-
- void OnDestroy()
- {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0));
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, 0, 0));
- m_proto->m_hwndPrivacyRule = nullptr;
- }
};
/////////////////////////////////////////////////////////////////////////////////////////
// Main privacy list dialog
-class CJabberDlgPrivacyLists : public CJabberDlgBase
-{
- typedef CJabberDlgBase CSuper;
-
-public:
- CJabberDlgPrivacyLists(CJabberProto *proto);
-
-protected:
- static int idSimpleControls[];
- static int idAdvancedControls[];
- bool OnInitDialog() override;
- bool OnClose() override;
- void OnDestroy();
- void OnProtoRefresh(WPARAM, LPARAM);
- int Resizer(UTILRESIZECONTROL *urc);
+static int idSimpleControls[] =
+{
+ IDC_CLIST, IDC_CANVAS,
+ IDC_TXT_OTHERJID, IDC_NEWJID, IDC_ADDJID,
+ IDC_ICO_MESSAGE, IDC_ICO_QUERY, IDC_ICO_INPRESENCE, IDC_ICO_OUTPRESENCE,
+ IDC_TXT_MESSAGE, IDC_TXT_QUERY, IDC_TXT_INPRESENCE, IDC_TXT_OUTPRESENCE,
+ 0
+};
- UI_MESSAGE_MAP(CJabberDlgPrivacyLists, CSuper);
- UI_MESSAGE(WM_MEASUREITEM, OnWmMeasureItem);
- UI_MESSAGE(WM_DRAWITEM, OnWmDrawItem);
- UI_MESSAGE(WM_GETMINMAXINFO, OnWmGetMinMaxInfo);
- UI_MESSAGE_MAP_END();
+static int idAdvancedControls[] =
+{
+ IDC_PL_RULES_LIST,
+ IDC_ADD_RULE, IDC_EDIT_RULE, IDC_REMOVE_RULE,
+ IDC_UP_RULE, IDC_DOWN_RULE,
+ 0
+};
- BOOL OnWmMeasureItem(UINT msg, WPARAM wParam, LPARAM lParam);
- BOOL OnWmDrawItem(UINT msg, WPARAM wParam, LPARAM lParam);
- BOOL OnWmGetMinMaxInfo(UINT msg, WPARAM wParam, LPARAM lParam);
-
- void btnSimple_OnClick(CCtrlButton *);
- void btnAdvanced_OnClick(CCtrlButton *);
- void btnAddJid_OnClick(CCtrlButton *);
- void btnActivate_OnClick(CCtrlButton *);
- void btnSetDefault_OnClick(CCtrlButton *);
- void lbLists_OnSelChange(CCtrlListBox *);
- void lbLists_OnDblClick(CCtrlListBox *);
- void lbRules_OnSelChange(CCtrlListBox *);
- void lbRules_OnDblClick(CCtrlListBox *);
- void btnEditRule_OnClick(CCtrlButton *);
- void btnAddRule_OnClick(CCtrlButton *);
- void btnRemoveRule_OnClick(CCtrlButton *);
- void btnUpRule_OnClick(CCtrlButton *);
- void btnDownRule_OnClick(CCtrlButton *);
- void btnAddList_OnClick(CCtrlButton *);
- void btnRemoveList_OnClick(CCtrlButton *);
- void btnApply_OnClick(CCtrlButton *);
- void clcClist_OnUpdate(CCtrlClc::TEventInfo *evt);
- void clcClist_OnOptionsChanged(CCtrlClc::TEventInfo *evt);
- void clcClist_OnClick(CCtrlClc::TEventInfo *evt);
-
- void OnCommand_Close(HWND hwndCtrl, WORD idCtrl, WORD idCode);
-
- void ShowAdvancedList(CPrivacyList *pList);
- void DrawNextRulePart(HDC hdc, COLORREF color, const wchar_t *text, RECT *rc);
- void DrawRuleAction(HDC hdc, COLORREF clLine1, COLORREF clLine2, CPrivacyListRule *pRule, RECT *rc);
- void DrawRulesList(LPDRAWITEMSTRUCT lpdis);
- void DrawLists(LPDRAWITEMSTRUCT lpdis);
-
- void CListResetOptions();
- void CListFilter();
- void CListResetIcons(HANDLE hItem, bool hide = false);
- void CListSetupIcons(HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction);
- HANDLE CListAddContact(char *jid);
- void CListApplyList(CPrivacyList *pList = nullptr);
- DWORD CListGetPackets(HANDLE hItem, bool bAction);
- void CListBuildList(CPrivacyList *pList);
-
- void EnableEditorControls();
- BOOL CanExit();
-
- static LRESULT CALLBACK LstListsSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- static LRESULT CALLBACK LstRulesSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+class CJabberDlgPrivacyLists : public CJabberDlgBase
+{
+ typedef CJabberDlgBase CSuper;
struct TCLCInfo
{
@@ -670,1381 +621,1361 @@ protected:
TCLCInfo clc_info;
-private:
- CCtrlMButton m_btnSimple;
- CCtrlMButton m_btnAdvanced;
- CCtrlMButton m_btnAddJid;
- CCtrlMButton m_btnActivate;
- CCtrlMButton m_btnSetDefault;
- CCtrlMButton m_btnEditRule;
- CCtrlMButton m_btnAddRule;
- CCtrlMButton m_btnRemoveRule;
- CCtrlMButton m_btnUpRule;
- CCtrlMButton m_btnDownRule;
- CCtrlMButton m_btnAddList;
- CCtrlMButton m_btnRemoveList;
- CCtrlButton m_btnApply;
- CCtrlListBox m_lbLists;
- CCtrlListBox m_lbRules;
- CCtrlClc m_clcClist;
- CCtrlEdit m_edtNewJid;
-};
-
-int CJabberDlgPrivacyLists::idSimpleControls[] =
-{
- IDC_CLIST, IDC_CANVAS,
- IDC_TXT_OTHERJID, IDC_NEWJID, IDC_ADDJID,
- IDC_ICO_MESSAGE, IDC_ICO_QUERY, IDC_ICO_INPRESENCE, IDC_ICO_OUTPRESENCE,
- IDC_TXT_MESSAGE, IDC_TXT_QUERY, IDC_TXT_INPRESENCE, IDC_TXT_OUTPRESENCE,
- 0
-};
-
-int CJabberDlgPrivacyLists::idAdvancedControls[] =
-{
- IDC_PL_RULES_LIST,
- IDC_ADD_RULE, IDC_EDIT_RULE, IDC_REMOVE_RULE,
- IDC_UP_RULE, IDC_DOWN_RULE,
- 0
-};
-
-CJabberDlgPrivacyLists::CJabberDlgPrivacyLists(CJabberProto *proto) :
- CSuper(proto, IDD_PRIVACY_LISTS),
- m_btnSimple(this, IDC_BTN_SIMPLE, proto->LoadIconEx("group"), LPGEN("Simple mode")),
- m_btnAdvanced(this, IDC_BTN_ADVANCED, proto->LoadIconEx("sd_view_list"), LPGEN("Advanced mode")),
- m_btnAddJid(this, IDC_ADDJID, proto->LoadIconEx("addroster"), LPGEN("Add JID")),
- m_btnActivate(this, IDC_ACTIVATE, proto->LoadIconEx("pl_list_active"), LPGEN("Activate")),
- m_btnSetDefault(this, IDC_SET_DEFAULT, proto->LoadIconEx("pl_list_default"), LPGEN("Set default")),
- m_btnEditRule(this, IDC_EDIT_RULE, SKINICON_OTHER_RENAME, LPGEN("Edit rule")),
- m_btnAddRule(this, IDC_ADD_RULE, SKINICON_OTHER_ADDCONTACT, LPGEN("Add rule")),
- m_btnRemoveRule(this, IDC_REMOVE_RULE, SKINICON_OTHER_DELETE, LPGEN("Delete rule")),
- m_btnUpRule(this, IDC_UP_RULE, proto->LoadIconEx("arrow_up"), LPGEN("Move rule up")),
- m_btnDownRule(this, IDC_DOWN_RULE, proto->LoadIconEx("arrow_down"), LPGEN("Move rule down")),
- m_btnAddList(this, IDC_ADD_LIST, SKINICON_OTHER_ADDCONTACT, LPGEN("Add list...")),
- m_btnRemoveList(this, IDC_REMOVE_LIST, SKINICON_OTHER_DELETE, LPGEN("Remove list")),
- m_btnApply(this, IDC_APPLY),
- m_lbLists(this, IDC_LB_LISTS),
- m_lbRules(this, IDC_PL_RULES_LIST),
- m_clcClist(this, IDC_CLIST),
- m_edtNewJid(this, IDC_NEWJID)
-{
- m_btnSimple.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSimple_OnClick);
- m_btnAdvanced.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAdvanced_OnClick);
- m_btnAddJid.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddJid_OnClick);
- m_btnActivate.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnActivate_OnClick);
- m_btnSetDefault.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSetDefault_OnClick);
- m_btnEditRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnEditRule_OnClick);
- m_btnAddRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddRule_OnClick);
- m_btnRemoveRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveRule_OnClick);
- m_btnUpRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnUpRule_OnClick);
- m_btnDownRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnDownRule_OnClick);
- m_btnAddList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddList_OnClick);
- m_btnRemoveList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveList_OnClick);
- m_btnApply.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnApply_OnClick);
-
- m_lbLists.OnSelChange = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnSelChange);
- m_lbLists.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnDblClick);
- m_lbRules.OnSelChange = Callback(this, &CJabberDlgPrivacyLists::lbRules_OnSelChange);
- m_lbRules.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbRules_OnDblClick);
-
- m_clcClist.OnNewContact =
- m_clcClist.OnListRebuilt = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnUpdate);
- m_clcClist.OnOptionsChanged = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnOptionsChanged);
- m_clcClist.OnClick = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnClick);
-}
-
-bool CJabberDlgPrivacyLists::OnInitDialog()
-{
- CSuper::OnInitDialog();
-
- Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_PRIVACY_LISTS));
-
- EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_RULE), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_UP_RULE), FALSE);
- EnableWindow(GetDlgItem(m_hwnd, IDC_DOWN_RULE), FALSE);
-
- m_proto->QueryPrivacyLists();
-
- LOGFONT lf;
- GetObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_GETFONT, 0, 0), sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- HFONT hfnt = CreateFontIndirect(&lf);
- SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_SETFONT, (WPARAM)hfnt, TRUE);
- SendDlgItemMessage(m_hwnd, IDC_TXT_RULES, WM_SETFONT, (WPARAM)hfnt, TRUE);
-
- SetWindowLongPtr(m_clcClist.GetHwnd(), GWL_STYLE,
- GetWindowLongPtr(m_clcClist.GetHwnd(), GWL_STYLE) | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
- m_clcClist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT);
-
- HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 9, 9);
- ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_msg_allow"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_msg_deny"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prin_allow"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prin_deny"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prout_allow"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prout_deny"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_iq_allow"));
- ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_iq_deny"));
- m_clcClist.SetExtraImageList(hIml);
- m_clcClist.SetExtraColumns(4);
-
- m_btnSimple.MakePush();
- m_btnAdvanced.MakePush();
-
- CLCINFOITEM cii = { 0 };
- cii.cbSize = sizeof(cii);
-
- cii.flags = CLCIIF_GROUPFONT;
- cii.pszText = TranslateT("** Default **");
- clc_info.hItemDefault = m_clcClist.AddInfoItem(&cii);
- cii.pszText = TranslateT("** Subscription: both **");
- clc_info.hItemSubBoth = m_clcClist.AddInfoItem(&cii);
- cii.pszText = TranslateT("** Subscription: to **");
- clc_info.hItemSubTo = m_clcClist.AddInfoItem(&cii);
- cii.pszText = TranslateT("** Subscription: from **");
- clc_info.hItemSubFrom = m_clcClist.AddInfoItem(&cii);
- cii.pszText = TranslateT("** Subscription: none **");
- clc_info.hItemSubNone = m_clcClist.AddInfoItem(&cii);
-
- CListResetOptions();
- CListFilter();
- CListApplyList();
-
- if (m_proto->getByte("plistsWnd_simpleMode", 1)) {
- UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
- UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
- CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_CHECKED);
- }
- else {
- UIShowControls(m_hwnd, idSimpleControls, SW_HIDE);
- UIShowControls(m_hwnd, idAdvancedControls, SW_SHOW);
- CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_CHECKED);
- }
-
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_LB_LISTS), LstListsSubclassProc);
- mir_subclassWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), LstRulesSubclassProc);
-
- SetStatusText(TranslateT("Loading..."));
-
- Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "plistsWnd_sz");
- return true;
-}
+ void ShowAdvancedList(CPrivacyList *pList)
+ {
+ int nLbSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
+
+ BOOL bListEmpty = TRUE;
+
+ CPrivacyListRule* pRule = pList->GetFirstRule();
+ while (pRule) {
+ bListEmpty = FALSE;
+ wchar_t szTypeValue[512];
+ switch (pRule->GetType()) {
+ case Jid:
+ mir_snwprintf(szTypeValue, L"If Jabber ID is '%s' then", pRule->GetValue());
+ break;
+ case Group:
+ mir_snwprintf(szTypeValue, L"If group is '%s' then", pRule->GetValue());
+ break;
+ case Subscription:
+ mir_snwprintf(szTypeValue, L"If subscription is '%s' then", pRule->GetValue());
+ break;
+ case Else:
+ mir_snwprintf(szTypeValue, L"Else");
+ break;
+ }
-bool CJabberDlgPrivacyLists::OnClose()
-{
- if (!CanExit())
- return false;
+ wchar_t szPackets[512];
+ szPackets[0] = '\0';
- DestroyWindow(m_hwnd);
- return CSuper::OnClose();
-}
+ DWORD dwPackets = pRule->GetPackets();
+ if (!dwPackets)
+ dwPackets = JABBER_PL_RULE_TYPE_ALL;
+ if (dwPackets == JABBER_PL_RULE_TYPE_ALL)
+ mir_wstrcpy(szPackets, L"all");
+ else {
+ if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
+ mir_wstrcat(szPackets, L"messages");
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN) {
+ if (mir_wstrlen(szPackets))
+ mir_wstrcat(szPackets, L", ");
+ mir_wstrcat(szPackets, L"presence-in");
+ }
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT) {
+ if (mir_wstrlen(szPackets))
+ mir_wstrcat(szPackets, L", ");
+ mir_wstrcat(szPackets, L"presence-out");
+ }
+ if (dwPackets & JABBER_PL_RULE_TYPE_IQ) {
+ if (mir_wstrlen(szPackets))
+ mir_wstrcat(szPackets, L", ");
+ mir_wstrcat(szPackets, L"queries");
+ }
+ }
-void CJabberDlgPrivacyLists::OnDestroy()
-{
- m_proto->m_pDlgPrivacyLists = nullptr;
+ wchar_t szListItem[512];
+ mir_snwprintf(szListItem, L"%s %s %s", szTypeValue, pRule->GetAction() ? L"allow" : L"deny", szPackets);
- // Wipe all data and query lists without contents
- m_proto->m_privacyListManager.RemoveAllLists();
- m_proto->QueryPrivacyLists();
- m_proto->m_privacyListManager.SetModified(FALSE);
+ LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)szListItem);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETITEMDATA, nItemId, (LPARAM)pRule);
- // Delete custom bold font
- DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_GETFONT, 0, 0));
+ pRule = pRule->GetNext();
+ }
- m_proto->setByte("plistsWnd_simpleMode", IsDlgButtonChecked(m_hwnd, IDC_BTN_SIMPLE));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), !bListEmpty);
+ if (bListEmpty)
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateT("List has no rules, empty lists will be deleted then changes applied"));
+ else
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nLbSel, 0);
- Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "plistsWnd_sz");
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_PL_RULES_LIST, LBN_SELCHANGE), 0);
+ }
- CSuper::OnDestroy();
-}
+ void DrawNextRulePart(HDC hdc, COLORREF color, const wchar_t *text, RECT *rc)
+ {
+ SetTextColor(hdc, color);
+ DrawText(hdc, text, -1, rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
-void CJabberDlgPrivacyLists::OnProtoRefresh(WPARAM, LPARAM)
-{
- LRESULT sel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
- wchar_t *szCurrentSelectedList = nullptr;
- if (sel != LB_ERR) {
- LRESULT len = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXTLEN, sel, 0) + 1;
- szCurrentSelectedList = (wchar_t *)mir_alloc(len * sizeof(wchar_t));
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXT, sel, (LPARAM)szCurrentSelectedList);
+ SIZE sz;
+ GetTextExtentPoint32(hdc, text, (int)mir_wstrlen(text), &sz);
+ rc->left += sz.cx;
}
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_RESETCONTENT, 0, 0);
-
- LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<none>"));
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, 0);
+ void DrawRuleAction(HDC hdc, COLORREF clLine1, COLORREF, CPrivacyListRule *pRule, RECT *rc)
{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
-
- CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
- while (pList) {
- if (!pList->IsDeleted()) {
- nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)pList->GetListName());
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, (LPARAM)pList);
+ DrawNextRulePart(hdc, clLine1, pRule->GetAction() ? TranslateT("allow ") : TranslateT("deny "), rc);
+ if (!pRule->GetPackets() || (pRule->GetPackets() == JABBER_PL_RULE_TYPE_ALL))
+ DrawNextRulePart(hdc, clLine1, TranslateT("all."), rc);
+ else {
+ bool needComma = false;
+ int itemCount =
+ ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE) ? 1 : 0) +
+ ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_IN) ? 1 : 0) +
+ ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT) ? 1 : 0) +
+ ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ) ? 1 : 0);
+
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE) {
+ --itemCount;
+ needComma = true;
+ DrawNextRulePart(hdc, clLine1, TranslateT("messages"), rc);
}
- pList = pList->GetNext();
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_IN) {
+ --itemCount;
+ if (needComma)
+ DrawNextRulePart(hdc, clLine1, itemCount ? L", " : TranslateT(" and "), rc);
+ needComma = true;
+ DrawNextRulePart(hdc, clLine1, TranslateT("incoming presences"), rc);
+ }
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT) {
+ --itemCount;
+ if (needComma)
+ DrawNextRulePart(hdc, clLine1, itemCount ? L", " : TranslateT(" and "), rc);
+ needComma = true;
+ DrawNextRulePart(hdc, clLine1, TranslateT("outgoing presences"), rc);
+ }
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ) {
+ --itemCount;
+ if (needComma)
+ DrawNextRulePart(hdc, clLine1, itemCount ? L", " : TranslateT(" and "), rc);
+ needComma = true;
+ DrawNextRulePart(hdc, clLine1, TranslateT("queries"), rc);
+ }
+ DrawNextRulePart(hdc, clLine1, L".", rc);
}
-
- if (!szCurrentSelectedList || (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)szCurrentSelectedList) == LB_ERR))
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, 0, 0);
- if (szCurrentSelectedList)
- mir_free(szCurrentSelectedList);
}
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
- EnableEditorControls();
-}
+ void DrawRulesList(LPDRAWITEMSTRUCT lpdis)
+ {
+ if (lpdis->itemID == -1)
+ return;
-BOOL CJabberDlgPrivacyLists::OnWmMeasureItem(UINT, WPARAM, LPARAM lParam)
-{
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
- if ((lpmis->CtlID != IDC_PL_RULES_LIST) && (lpmis->CtlID != IDC_LB_LISTS))
- return FALSE;
+ CPrivacyListRule *pRule = (CPrivacyListRule *)lpdis->itemData;
+
+ COLORREF clLine1, clLine2, clBack;
+ if (lpdis->itemState & ODS_SELECTED) {
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
+ clBack = GetSysColor(COLOR_HIGHLIGHT);
+ clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ }
+ else {
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
+ clBack = GetSysColor(COLOR_WINDOW);
+ clLine1 = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ clLine2 = RGB(
+ GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
+ GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
+
+ SetBkMode(lpdis->hDC, TRANSPARENT);
+
+ RECT rc;
+ if (!pRule) {
+ rc = lpdis->rcItem;
+ rc.left += 25;
+
+ int len = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETTEXTLEN, lpdis->itemID, 0) + 1;
+ wchar_t *str = (wchar_t *)_alloca(len * sizeof(wchar_t));
+ SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETTEXT, lpdis->itemID, (LPARAM)str);
+ DrawNextRulePart(lpdis->hDC, clLine1, str, &rc);
+ }
+ else if (pRule->GetType() == Else) {
+ rc = lpdis->rcItem;
+ rc.left += 25;
- TEXTMETRIC tm = { 0 };
- HDC hdc = GetDC(GetDlgItem(m_hwnd, lpmis->CtlID));
- GetTextMetrics(hdc, &tm);
- ReleaseDC(GetDlgItem(m_hwnd, lpmis->CtlID), hdc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("Else "), &rc);
+ DrawRuleAction(lpdis->hDC, clLine1, clLine2, pRule, &rc);
+ }
+ else {
+ rc = lpdis->rcItem;
+ rc.bottom -= (rc.bottom - rc.top) / 2;
+ rc.left += 25;
- if (lpmis->CtlID == IDC_PL_RULES_LIST)
- lpmis->itemHeight = tm.tmHeight * 2;
- else if (lpmis->CtlID == IDC_LB_LISTS)
- lpmis->itemHeight = tm.tmHeight;
+ Utf2T wszRule(pRule->GetValue());
+ switch (pRule->GetType()) {
+ case Jid:
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If Jabber ID is '"), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
- if (lpmis->itemHeight < 18) lpmis->itemHeight = 18;
+ if (MCONTACT hContact = m_proto->HContactFromJID(pRule->GetValue())) {
+ wchar_t *szName = Clist_GetContactDisplayName(hContact);
+ if (szName) {
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (nickname: "), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, szName, &rc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(")"), &rc);
+ }
+ }
+ break;
- return TRUE;
-}
+ case Group:
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If group is '"), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
+ break;
-/////////////////////////////////////////////////////////////////////////////////////////
+ case Subscription:
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If subscription is '"), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
+ break;
+ }
-struct
-{
- wchar_t *textEng;
- char *icon;
- wchar_t *text;
-}
-static drawItems[] =
-{
- { LPGENW("Message"), "pl_msg_allow" },
- { LPGENW("Presence (in)"), "pl_prin_allow" },
- { LPGENW("Presence (out)"), "pl_prout_allow" },
- { LPGENW("Query"), "pl_iq_allow" }
-};
+ rc = lpdis->rcItem;
+ rc.top += (rc.bottom - rc.top) / 2;
+ rc.left += 25;
-BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
-{
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
-
- if (lpdis->CtlID == IDC_PL_RULES_LIST)
- DrawRulesList(lpdis);
- else if (lpdis->CtlID == IDC_LB_LISTS)
- DrawLists(lpdis);
- else if (lpdis->CtlID == IDC_CANVAS) {
- int totalWidth = -5; // spacing for last item
- for (auto &it : drawItems) {
- SIZE sz = { 0 };
- it.text = TranslateW(it.textEng);
- GetTextExtentPoint32(lpdis->hDC, it.text, (int)mir_wstrlen(it.text), &sz);
- totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("then "), &rc);
+ DrawRuleAction(lpdis->hDC, clLine1, clLine2, pRule, &rc);
}
- COLORREF clText = GetSysColor(COLOR_BTNTEXT);
- RECT rc = lpdis->rcItem;
- rc.left = (rc.left + rc.right - totalWidth) / 2;
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ m_proto->LoadIconEx("main"), 16, 16, 0, nullptr, DI_NORMAL);
- for (auto &it : drawItems) {
- DrawIconEx(lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, m_proto->LoadIconEx(it.icon),
+ if (pRule)
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ m_proto->LoadIconEx(pRule->GetAction() ? "disco_ok" : "disco_fail"),
16, 16, 0, nullptr, DI_NORMAL);
- rc.left += 18;
- DrawNextRulePart(lpdis->hDC, clText, it.text, &rc);
- rc.left += 5;
+
+ if (lpdis->itemState & ODS_FOCUS) {
+ LRESULT sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0);
+ if ((sel == LB_ERR) || (sel == (LRESULT)lpdis->itemID))
+ DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
}
}
- else return FALSE;
- return TRUE;
-}
+ void DrawLists(LPDRAWITEMSTRUCT lpdis)
+ {
+ if (lpdis->itemID == -1)
+ return;
-BOOL CJabberDlgPrivacyLists::OnWmGetMinMaxInfo(UINT, WPARAM, LPARAM lParam)
-{
- LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
- lpmmi->ptMinTrackSize.x = 550;
- lpmmi->ptMinTrackSize.y = 390;
- return 0;
-}
+ CPrivacyList *pList = (CPrivacyList *)lpdis->itemData;
-void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList)
-{
- int nLbSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
+ COLORREF clLine1, clLine2, clBack;
+ if (lpdis->itemState & ODS_SELECTED) {
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
+ clBack = GetSysColor(COLOR_HIGHLIGHT);
+ clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ }
+ else {
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
+ clBack = GetSysColor(COLOR_WINDOW);
+ clLine1 = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ clLine2 = RGB(
+ GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
+ GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
- BOOL bListEmpty = TRUE;
+ SetBkMode(lpdis->hDC, TRANSPARENT);
- CPrivacyListRule* pRule = pList->GetFirstRule();
- while (pRule) {
- bListEmpty = FALSE;
- wchar_t szTypeValue[512];
- switch (pRule->GetType()) {
- case Jid:
- mir_snwprintf(szTypeValue, L"If Jabber ID is '%s' then", pRule->GetValue());
- break;
- case Group:
- mir_snwprintf(szTypeValue, L"If group is '%s' then", pRule->GetValue());
- break;
- case Subscription:
- mir_snwprintf(szTypeValue, L"If subscription is '%s' then", pRule->GetValue());
- break;
- case Else:
- mir_snwprintf(szTypeValue, L"Else");
- break;
+ char *szDefault, *szActive;
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ szDefault = NEWSTR_ALLOCA(m_proto->m_privacyListManager.GetDefaultListName());
+ szActive = NEWSTR_ALLOCA(m_proto->m_privacyListManager.GetActiveListName());
}
- wchar_t szPackets[512];
- szPackets[0] = '\0';
+ RECT rc;
+ rc = lpdis->rcItem;
+ rc.left += 3;
- DWORD dwPackets = pRule->GetPackets();
- if (!dwPackets)
- dwPackets = JABBER_PL_RULE_TYPE_ALL;
- if (dwPackets == JABBER_PL_RULE_TYPE_ALL)
- mir_wstrcpy(szPackets, L"all");
+ bool bActive = false;
+ bool bDefault = false;
+ char *szName;
+
+ if (!pList) {
+ if (!szActive) bActive = true;
+ if (!szDefault) bDefault = true;
+ szName = Translate("<none>");
+ }
else {
- if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
- mir_wstrcat(szPackets, L"messages");
- if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN) {
- if (mir_wstrlen(szPackets))
- mir_wstrcat(szPackets, L", ");
- mir_wstrcat(szPackets, L"presence-in");
- }
- if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT) {
- if (mir_wstrlen(szPackets))
- mir_wstrcat(szPackets, L", ");
- mir_wstrcat(szPackets, L"presence-out");
- }
- if (dwPackets & JABBER_PL_RULE_TYPE_IQ) {
- if (mir_wstrlen(szPackets))
- mir_wstrcat(szPackets, L", ");
- mir_wstrcat(szPackets, L"queries");
- }
+ if (!mir_strcmp(pList->GetListName(), szActive)) bActive = true;
+ if (!mir_strcmp(pList->GetListName(), szDefault)) bDefault = true;
+ szName = pList->GetListName();
}
- wchar_t szListItem[512];
- mir_snwprintf(szListItem, L"%s %s %s", szTypeValue, pRule->GetAction() ? L"allow" : L"deny", szPackets);
-
- LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)szListItem);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETITEMDATA, nItemId, (LPARAM)pRule);
+ HFONT hfnt = nullptr;
+ if (bActive) {
+ LOGFONT lf;
+ GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ hfnt = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
+ }
- pRule = pRule->GetNext();
- }
+ DrawNextRulePart(lpdis->hDC, clLine1, Utf2T(szName), &rc);
- EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), !bListEmpty);
- if (bListEmpty)
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateT("List has no rules, empty lists will be deleted then changes applied"));
- else
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nLbSel, 0);
+ if (bActive && bDefault)
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (act., def.)"), &rc);
+ else if (bActive)
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (active)"), &rc);
+ else if (bDefault)
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (default)"), &rc);
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_PL_RULES_LIST, LBN_SELCHANGE), 0);
-}
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ m_proto->LoadIconEx(bActive ? "pl_list_active" : "pl_list_any"),
+ 16, 16, 0, nullptr, DI_NORMAL);
-void CJabberDlgPrivacyLists::DrawNextRulePart(HDC hdc, COLORREF color, const wchar_t *text, RECT *rc)
-{
- SetTextColor(hdc, color);
- DrawText(hdc, text, -1, rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
+ if (bDefault)
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
+ m_proto->LoadIconEx("disco_ok"),
+ 16, 16, 0, nullptr, DI_NORMAL);
- SIZE sz;
- GetTextExtentPoint32(hdc, text, (int)mir_wstrlen(text), &sz);
- rc->left += sz.cx;
-}
+ if (hfnt)
+ DeleteObject(SelectObject(lpdis->hDC, hfnt));
-void CJabberDlgPrivacyLists::DrawRuleAction(HDC hdc, COLORREF clLine1, COLORREF, CPrivacyListRule *pRule, RECT *rc)
-{
- DrawNextRulePart(hdc, clLine1, pRule->GetAction() ? TranslateT("allow ") : TranslateT("deny "), rc);
- if (!pRule->GetPackets() || (pRule->GetPackets() == JABBER_PL_RULE_TYPE_ALL))
- DrawNextRulePart(hdc, clLine1, TranslateT("all."), rc);
- else {
- bool needComma = false;
- int itemCount =
- ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE) ? 1 : 0) +
- ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_IN) ? 1 : 0) +
- ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT) ? 1 : 0) +
- ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ) ? 1 : 0);
-
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE) {
- --itemCount;
- needComma = true;
- DrawNextRulePart(hdc, clLine1, TranslateT("messages"), rc);
+ if (lpdis->itemState & ODS_FOCUS) {
+ int sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0);
+ if ((sel == LB_ERR) || (sel == (int)lpdis->itemID))
+ DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
}
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_IN) {
- --itemCount;
- if (needComma)
- DrawNextRulePart(hdc, clLine1, itemCount ? L", " : TranslateT(" and "), rc);
- needComma = true;
- DrawNextRulePart(hdc, clLine1, TranslateT("incoming presences"), rc);
- }
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT) {
- --itemCount;
- if (needComma)
- DrawNextRulePart(hdc, clLine1, itemCount ? L", " : TranslateT(" and "), rc);
- needComma = true;
- DrawNextRulePart(hdc, clLine1, TranslateT("outgoing presences"), rc);
- }
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ) {
- --itemCount;
- if (needComma)
- DrawNextRulePart(hdc, clLine1, itemCount ? L", " : TranslateT(" and "), rc);
- needComma = true;
- DrawNextRulePart(hdc, clLine1, TranslateT("queries"), rc);
- }
- DrawNextRulePart(hdc, clLine1, L".", rc);
}
-}
-void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis)
-{
- if (lpdis->itemID == -1)
- return;
+ void CListResetOptions()
+ {
+ m_clcClist.SetBkBitmap(0, nullptr);
+ m_clcClist.SetBkColor(GetSysColor(COLOR_WINDOW));
+ m_clcClist.SetGreyoutFlags(0);
+ m_clcClist.SetLeftMargin(4);
+ m_clcClist.SetIndent(10);
+ m_clcClist.SetHideEmptyGroups(false);
+ m_clcClist.SetHideOfflineRoot(false);
+ for (int i = 0; i <= FONTID_MAX; i++)
+ m_clcClist.SetTextColor(i, GetSysColor(COLOR_WINDOWTEXT));
+ }
+
+ void CListFilter()
+ {
+ for (auto &hContact : Contacts()) {
+ char *proto = GetContactProto(hContact);
+ if (!proto || mir_strcmp(proto, m_proto->m_szModuleName))
+ if (HANDLE hItem = m_clcClist.FindContact(hContact))
+ m_clcClist.DeleteItem(hItem);
+ }
+ }
- CPrivacyListRule *pRule = (CPrivacyListRule *)lpdis->itemData;
+ void CListResetIcons(HANDLE hItem, bool hide = false)
+ {
+ for (int i = 0; i < 4; i++)
+ m_clcClist.SetExtraImage(hItem, i, hide ? EMPTY_EXTRA_ICON : 0);
+ }
- COLORREF clLine1, clLine2, clBack;
- if (lpdis->itemState & ODS_SELECTED) {
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
- clBack = GetSysColor(COLOR_HIGHLIGHT);
- clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ void CListSetupIcons(HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction)
+ {
+ if (dwProcess && !m_clcClist.GetExtraImage(hItem, iSlot))
+ m_clcClist.SetExtraImage(hItem, iSlot, iSlot * 2 + (bAction ? 1 : 2));
}
- else {
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
- clBack = GetSysColor(COLOR_WINDOW);
- clLine1 = GetSysColor(COLOR_WINDOWTEXT);
+
+ HANDLE CListAddContact(char *jid)
+ {
+ MCONTACT hContact = m_proto->HContactFromJID(jid);
+ if (hContact)
+ return m_clcClist.FindContact(hContact);
+
+ HANDLE hItem = clc_info.findJid(jid);
+ if (!hItem) {
+ Utf2T wzJid(jid);
+
+ CLCINFOITEM cii = { 0 };
+ cii.cbSize = sizeof(cii);
+ cii.pszText = wzJid;
+ hItem = m_clcClist.AddInfoItem(&cii);
+ CListResetIcons(hItem);
+ clc_info.addJid(hItem, jid);
+ }
+ return hItem;
}
- clLine2 = RGB(
- GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
- GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
- SetBkMode(lpdis->hDC, TRANSPARENT);
+ void CListApplyList(CPrivacyList *pList)
+ {
+ clc_info.pList = pList;
+
+ bool bHideIcons = pList ? false : true;
+ CListResetIcons(clc_info.hItemDefault, bHideIcons);
+ CListResetIcons(clc_info.hItemSubBoth, bHideIcons);
+ CListResetIcons(clc_info.hItemSubFrom, bHideIcons);
+ CListResetIcons(clc_info.hItemSubNone, bHideIcons);
+ CListResetIcons(clc_info.hItemSubTo, bHideIcons);
+
+ // group handles start with 1 (0 is "root")
+ for (MGROUP iGroup = 1; Clist_GroupGetName(iGroup, nullptr) != nullptr; iGroup++) {
+ HANDLE hItem = m_clcClist.FindGroup(iGroup);
+ if (hItem)
+ CListResetIcons(hItem, bHideIcons);
+ }
- RECT rc;
- if (!pRule) {
- rc = lpdis->rcItem;
- rc.left += 25;
+ for (auto &hContact : Contacts()) {
+ HANDLE hItem = m_clcClist.FindContact(hContact);
+ if (hItem)
+ CListResetIcons(hItem, bHideIcons);
+ }
- int len = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETTEXTLEN, lpdis->itemID, 0) + 1;
- wchar_t *str = (wchar_t *)_alloca(len * sizeof(wchar_t));
- SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETTEXT, lpdis->itemID, (LPARAM)str);
- DrawNextRulePart(lpdis->hDC, clLine1, str, &rc);
- }
- else if (pRule->GetType() == Else) {
- rc = lpdis->rcItem;
- rc.left += 25;
+ for (auto &it : clc_info.newJids)
+ CListResetIcons(it->hItem, bHideIcons);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("Else "), &rc);
- DrawRuleAction(lpdis->hDC, clLine1, clLine2, pRule, &rc);
- }
- else {
- rc = lpdis->rcItem;
- rc.bottom -= (rc.bottom - rc.top) / 2;
- rc.left += 25;
+ if (!pList)
+ goto lbl_return;
- Utf2T wszRule(pRule->GetValue());
- switch (pRule->GetType()) {
- case Jid:
- {
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If Jabber ID is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
+ for (CPrivacyListRule *pRule = pList->GetFirstRule(); pRule; pRule = pRule->GetNext()) {
+ HANDLE hItem = nullptr;
+ switch (pRule->GetType()) {
+ case Jid:
+ hItem = CListAddContact(pRule->GetValue());
+ break;
- if (MCONTACT hContact = m_proto->HContactFromJID(pRule->GetValue())) {
- wchar_t *szName = Clist_GetContactDisplayName(hContact);
- if (szName) {
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (nickname: "), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, szName, &rc);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(")"), &rc);
- }
- }
+ case Group:
+ hItem = m_clcClist.FindGroup(Clist_GroupExists(Utf2T(pRule->GetValue())));
+ break;
+
+ case Subscription:
+ if (!mir_strcmp(pRule->GetValue(), "none")) hItem = clc_info.hItemSubNone;
+ else if (!mir_strcmp(pRule->GetValue(), "from")) hItem = clc_info.hItemSubFrom;
+ else if (!mir_strcmp(pRule->GetValue(), "to")) hItem = clc_info.hItemSubTo;
+ else if (!mir_strcmp(pRule->GetValue(), "both")) hItem = clc_info.hItemSubBoth;
+ break;
+
+ case Else:
+ hItem = clc_info.hItemDefault;
break;
}
- case Group:
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If group is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
- break;
+ if (!hItem)
+ continue;
- case Subscription:
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If subscription is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, wszRule, &rc);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
- break;
+ DWORD dwPackets = pRule->GetPackets();
+ if (!dwPackets) dwPackets = JABBER_PL_RULE_TYPE_ALL;
+ CListSetupIcons(hItem, 0, dwPackets & JABBER_PL_RULE_TYPE_MESSAGE, pRule->GetAction());
+ CListSetupIcons(hItem, 1, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN, pRule->GetAction());
+ CListSetupIcons(hItem, 2, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT, pRule->GetAction());
+ CListSetupIcons(hItem, 3, dwPackets & JABBER_PL_RULE_TYPE_IQ, pRule->GetAction());
}
- rc = lpdis->rcItem;
- rc.top += (rc.bottom - rc.top) / 2;
- rc.left += 25;
-
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("then "), &rc);
- DrawRuleAction(lpdis->hDC, clLine1, clLine2, pRule, &rc);
+lbl_return:
+ clc_info.bChanged = false;
}
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- m_proto->LoadIconEx("main"), 16, 16, 0, nullptr, DI_NORMAL);
+ DWORD CListGetPackets(HANDLE hItem, bool bAction)
+ {
+ DWORD result = 0;
- if (pRule)
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- m_proto->LoadIconEx(pRule->GetAction() ? "disco_ok" : "disco_fail"),
- 16, 16, 0, nullptr, DI_NORMAL);
+ int iIcon = m_clcClist.GetExtraImage(hItem, 0);
+ if (bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
+ else if (!bAction && (iIcon == 2)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
- if (lpdis->itemState & ODS_FOCUS) {
- LRESULT sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0);
- if ((sel == LB_ERR) || (sel == (LRESULT)lpdis->itemID))
- DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
- }
-}
+ iIcon = m_clcClist.GetExtraImage(hItem, 1);
+ if (bAction && (iIcon == 3)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ else if (!bAction && (iIcon == 4)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
-void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis)
-{
- if (lpdis->itemID == -1)
- return;
+ iIcon = m_clcClist.GetExtraImage(hItem, 2);
+ if (bAction && (iIcon == 5)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ else if (!bAction && (iIcon == 6)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- CPrivacyList *pList = (CPrivacyList *)lpdis->itemData;
+ iIcon = m_clcClist.GetExtraImage(hItem, 3);
+ if (bAction && (iIcon == 7)) result |= JABBER_PL_RULE_TYPE_IQ;
+ else if (!bAction && (iIcon == 8)) result |= JABBER_PL_RULE_TYPE_IQ;
- COLORREF clLine1, clLine2, clBack;
- if (lpdis->itemState & ODS_SELECTED) {
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
- clBack = GetSysColor(COLOR_HIGHLIGHT);
- clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ return result;
}
- else {
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
- clBack = GetSysColor(COLOR_WINDOW);
- clLine1 = GetSysColor(COLOR_WINDOWTEXT);
- }
- clLine2 = RGB(
- GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
- GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
-
- SetBkMode(lpdis->hDC, TRANSPARENT);
- char *szDefault, *szActive;
+ void CListBuildList(CPrivacyList *pList)
{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- szDefault = NEWSTR_ALLOCA(m_proto->m_privacyListManager.GetDefaultListName());
- szActive = NEWSTR_ALLOCA(m_proto->m_privacyListManager.GetActiveListName());
- }
+ if (!pList || !clc_info.bChanged)
+ return;
- RECT rc;
- rc = lpdis->rcItem;
- rc.left += 3;
+ clc_info.bChanged = false;
- bool bActive = false;
- bool bDefault = false;
- char *szName;
+ DWORD dwOrder = 0;
+ DWORD dwPackets = 0;
- if (!pList) {
- if (!szActive) bActive = true;
- if (!szDefault) bDefault = true;
- szName = Translate("<none>");
- }
- else {
- if (!mir_strcmp(pList->GetListName(), szActive)) bActive = true;
- if (!mir_strcmp(pList->GetListName(), szDefault)) bDefault = true;
- szName = pList->GetListName();
- }
+ HANDLE hItem;
+ char *szJid = nullptr;
- HFONT hfnt = nullptr;
- if (bActive) {
- LOGFONT lf;
- GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- hfnt = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
- }
+ pList->RemoveAllRules();
- DrawNextRulePart(lpdis->hDC, clLine1, Utf2T(szName), &rc);
+ for (auto &it : clc_info.newJids) {
+ hItem = it->hItem;
+ szJid = it->jid;
- if (bActive && bDefault)
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (act., def.)"), &rc);
- else if (bActive)
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (active)"), &rc);
- else if (bDefault)
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (default)"), &rc);
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
+ }
- DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- m_proto->LoadIconEx(bActive ? "pl_list_active" : "pl_list_any"),
- 16, 16, 0, nullptr, DI_NORMAL);
+ for (auto &hContact : Contacts()) {
+ hItem = m_clcClist.FindContact(hContact);
- if (bDefault)
- DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- m_proto->LoadIconEx("disco_ok"),
- 16, 16, 0, nullptr, DI_NORMAL);
-
- if (hfnt)
- DeleteObject(SelectObject(lpdis->hDC, hfnt));
+ ptrW jid(m_proto->getWStringA(hContact, "jid"));
+ if (jid == nullptr)
+ if ((jid = m_proto->getWStringA(hContact, "ChatRoomID")) == nullptr)
+ continue;
- if (lpdis->itemState & ODS_FOCUS) {
- int sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0);
- if ((sel == LB_ERR) || (sel == (int)lpdis->itemID))
- DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
- }
-}
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
+ }
-void CJabberDlgPrivacyLists::CListResetOptions()
-{
- m_clcClist.SetBkBitmap(0, nullptr);
- m_clcClist.SetBkColor(GetSysColor(COLOR_WINDOW));
- m_clcClist.SetGreyoutFlags(0);
- m_clcClist.SetLeftMargin(4);
- m_clcClist.SetIndent(10);
- m_clcClist.SetHideEmptyGroups(false);
- m_clcClist.SetHideOfflineRoot(false);
- for (int i = 0; i <= FONTID_MAX; i++)
- m_clcClist.SetTextColor(i, GetSysColor(COLOR_WINDOWTEXT));
-}
+ // group handles start with 1 (0 is "root")
+ wchar_t *grpName;
+ for (MGROUP iGroup = 1; (grpName = Clist_GroupGetName(iGroup, nullptr)) != nullptr; iGroup++) {
+ hItem = m_clcClist.FindGroup(iGroup);
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Group, T2Utf(grpName), TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Group, T2Utf(grpName), FALSE, dwOrder++, dwPackets);
+ }
-void CJabberDlgPrivacyLists::CListFilter()
-{
- for (auto &hContact : Contacts()) {
- char *proto = GetContactProto(hContact);
- if (!proto || mir_strcmp(proto, m_proto->m_szModuleName))
- if (HANDLE hItem = m_clcClist.FindContact(hContact))
- m_clcClist.DeleteItem(hItem);
- }
-}
+ hItem = clc_info.hItemSubBoth;
+ szJid = "both";
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-void CJabberDlgPrivacyLists::CListResetIcons(HANDLE hItem, bool hide)
-{
- for (int i = 0; i < 4; i++)
- m_clcClist.SetExtraImage(hItem, i, hide ? EMPTY_EXTRA_ICON : 0);
-}
+ hItem = clc_info.hItemSubFrom;
+ szJid = "from";
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-void CJabberDlgPrivacyLists::CListSetupIcons(HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction)
-{
- if (dwProcess && !m_clcClist.GetExtraImage(hItem, iSlot))
- m_clcClist.SetExtraImage(hItem, iSlot, iSlot * 2 + (bAction ? 1 : 2));
-}
+ hItem = clc_info.hItemSubNone;
+ szJid = "none";
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-HANDLE CJabberDlgPrivacyLists::CListAddContact(char *jid)
-{
- MCONTACT hContact = m_proto->HContactFromJID(jid);
- if (hContact)
- return m_clcClist.FindContact(hContact);
+ hItem = clc_info.hItemSubTo;
+ szJid = "to";
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
- HANDLE hItem = clc_info.findJid(jid);
- if (!hItem) {
- Utf2T wzJid(jid);
+ hItem = clc_info.hItemDefault;
+ szJid = nullptr;
+ if (dwPackets = CListGetPackets(hItem, true))
+ pList->AddRule(Else, szJid, TRUE, dwOrder++, dwPackets);
+ if (dwPackets = CListGetPackets(hItem, false))
+ pList->AddRule(Else, szJid, FALSE, dwOrder++, dwPackets);
- CLCINFOITEM cii = { 0 };
- cii.cbSize = sizeof(cii);
- cii.pszText = wzJid;
- hItem = m_clcClist.AddInfoItem(&cii);
- CListResetIcons(hItem);
- clc_info.addJid(hItem, jid);
+ pList->Reorder();
+ pList->SetModified();
}
- return hItem;
-}
-void CJabberDlgPrivacyLists::CListApplyList(CPrivacyList *pList)
-{
- clc_info.pList = pList;
+ void EnableEditorControls()
+ {
+ BOOL bListsLoaded, bListsModified;
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ bListsLoaded = m_proto->m_privacyListManager.IsAllListsLoaded();
+ bListsModified = m_proto->m_privacyListManager.IsModified() || clc_info.bChanged;
+ }
- bool bHideIcons = pList ? false : true;
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
+ BOOL bSelected = nCurSel != CB_ERR;
+ BOOL bListSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCOUNT, 0, 0);
+ bListSelected = bListSelected && (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0) != LB_ERR);
+ bListSelected = bListSelected && SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0), 0);
- CListResetIcons(clc_info.hItemDefault, bHideIcons);
- CListResetIcons(clc_info.hItemSubBoth, bHideIcons);
- CListResetIcons(clc_info.hItemSubFrom, bHideIcons);
- CListResetIcons(clc_info.hItemSubNone, bHideIcons);
- CListResetIcons(clc_info.hItemSubTo, bHideIcons);
+ m_edtNewJid.Enable(bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_TXT_OTHERJID), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ADDJID), bListsLoaded && bListSelected);
- // group handles start with 1 (0 is "root")
- for (MGROUP iGroup = 1; Clist_GroupGetName(iGroup, nullptr) != nullptr; iGroup++) {
- HANDLE hItem = m_clcClist.FindGroup(iGroup);
- if (hItem)
- CListResetIcons(hItem, bHideIcons);
- }
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), bListsLoaded && bSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_RULE), bListsLoaded && bSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_UP_RULE), bListsLoaded && bSelected && nCurSel != 0);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DOWN_RULE), bListsLoaded && bSelected && nCurSel != (nItemCount - 1));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_LIST), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_APPLY), bListsLoaded && bListsModified);
- for (auto &hContact : Contacts()) {
- HANDLE hItem = m_clcClist.FindContact(hContact);
- if (hItem)
- CListResetIcons(hItem, bHideIcons);
+ if (bListsLoaded)
+ SetStatusText(TranslateT("Ready."));
}
- for (auto &it : clc_info.newJids)
- CListResetIcons(it->hItem, bHideIcons);
-
- if (!pList)
- goto lbl_return;
+ static LRESULT CALLBACK LstListsSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg) {
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN:
+ if (wParam == VK_INSERT)
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_ADD_LIST);
+ if (wParam == VK_DELETE)
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_REMOVE_LIST);
+ if (wParam == VK_SPACE) {
+ if (GetAsyncKeyState(VK_CONTROL))
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_SET_DEFAULT);
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_ACTIVATE);
+ }
- for (CPrivacyListRule *pRule = pList->GetFirstRule(); pRule; pRule = pRule->GetNext()) {
- HANDLE hItem = nullptr;
- switch (pRule->GetType()) {
- case Jid:
- hItem = CListAddContact(pRule->GetValue());
break;
+ }
+ return mir_callNextSubclass(hwnd, LstListsSubclassProc, msg, wParam, lParam);
+ }
- case Group:
- hItem = m_clcClist.FindGroup(Clist_GroupExists(Utf2T(pRule->GetValue())));
- break;
+ static LRESULT CALLBACK LstRulesSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg) {
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN:
+ if (wParam == VK_INSERT)
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_ADD_RULE);
+ if (wParam == VK_DELETE)
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_REMOVE_RULE);
+ if ((wParam == VK_UP) && (lParam & (1UL << 29)))
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_UP_RULE);
+ if ((wParam == VK_DOWN) && (lParam & (1UL << 29)))
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_DOWN_RULE);
+ if (wParam == VK_F2)
+ return UIEmulateBtnClick(GetParent(hwnd), IDC_EDIT_RULE);
- case Subscription:
- if (!mir_strcmp(pRule->GetValue(), "none")) hItem = clc_info.hItemSubNone;
- else if (!mir_strcmp(pRule->GetValue(), "from")) hItem = clc_info.hItemSubFrom;
- else if (!mir_strcmp(pRule->GetValue(), "to")) hItem = clc_info.hItemSubTo;
- else if (!mir_strcmp(pRule->GetValue(), "both")) hItem = clc_info.hItemSubBoth;
break;
+ }
+ return mir_callNextSubclass(hwnd, LstRulesSubclassProc, msg, wParam, lParam);
+ }
- case Else:
- hItem = clc_info.hItemDefault;
- break;
+ BOOL CanExit()
+ {
+ BOOL bModified;
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ bModified = m_proto->m_privacyListManager.IsModified();
}
- if (!hItem)
- continue;
+ if (clc_info.bChanged)
+ bModified = TRUE;
+
+ if (!bModified)
+ return TRUE;
+
+ if (IDYES == MessageBox(m_hwnd, TranslateT("Privacy lists are not saved, discard any changes and exit?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
+ return TRUE;
- DWORD dwPackets = pRule->GetPackets();
- if (!dwPackets) dwPackets = JABBER_PL_RULE_TYPE_ALL;
- CListSetupIcons(hItem, 0, dwPackets & JABBER_PL_RULE_TYPE_MESSAGE, pRule->GetAction());
- CListSetupIcons(hItem, 1, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN, pRule->GetAction());
- CListSetupIcons(hItem, 2, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT, pRule->GetAction());
- CListSetupIcons(hItem, 3, dwPackets & JABBER_PL_RULE_TYPE_IQ, pRule->GetAction());
+ return FALSE;
}
-lbl_return:
- clc_info.bChanged = false;
-}
+ CCtrlMButton m_btnSimple, m_btnAdvanced, m_btnAddJid, m_btnActivate, m_btnSetDefault;
+ CCtrlMButton m_btnEditRule, m_btnAddRule, m_btnRemoveRule, m_btnUpRule, m_btnDownRule;
+ CCtrlMButton m_btnAddList, m_btnRemoveList;
+ CCtrlButton m_btnApply;
+ CCtrlListBox m_lbLists, m_lbRules;
+ CCtrlClc m_clcClist;
+ CCtrlEdit m_edtNewJid;
-DWORD CJabberDlgPrivacyLists::CListGetPackets(HANDLE hItem, bool bAction)
-{
- DWORD result = 0;
+public:
+ CJabberDlgPrivacyLists(CJabberProto *proto) :
+ CSuper(proto, IDD_PRIVACY_LISTS),
+ m_btnSimple(this, IDC_BTN_SIMPLE, proto->LoadIconEx("group"), LPGEN("Simple mode")),
+ m_btnAdvanced(this, IDC_BTN_ADVANCED, proto->LoadIconEx("sd_view_list"), LPGEN("Advanced mode")),
+ m_btnAddJid(this, IDC_ADDJID, proto->LoadIconEx("addroster"), LPGEN("Add JID")),
+ m_btnActivate(this, IDC_ACTIVATE, proto->LoadIconEx("pl_list_active"), LPGEN("Activate")),
+ m_btnSetDefault(this, IDC_SET_DEFAULT, proto->LoadIconEx("pl_list_default"), LPGEN("Set default")),
+ m_btnEditRule(this, IDC_EDIT_RULE, SKINICON_OTHER_RENAME, LPGEN("Edit rule")),
+ m_btnAddRule(this, IDC_ADD_RULE, SKINICON_OTHER_ADDCONTACT, LPGEN("Add rule")),
+ m_btnRemoveRule(this, IDC_REMOVE_RULE, SKINICON_OTHER_DELETE, LPGEN("Delete rule")),
+ m_btnUpRule(this, IDC_UP_RULE, proto->LoadIconEx("arrow_up"), LPGEN("Move rule up")),
+ m_btnDownRule(this, IDC_DOWN_RULE, proto->LoadIconEx("arrow_down"), LPGEN("Move rule down")),
+ m_btnAddList(this, IDC_ADD_LIST, SKINICON_OTHER_ADDCONTACT, LPGEN("Add list...")),
+ m_btnRemoveList(this, IDC_REMOVE_LIST, SKINICON_OTHER_DELETE, LPGEN("Remove list")),
+ m_btnApply(this, IDC_APPLY),
+ m_lbLists(this, IDC_LB_LISTS),
+ m_lbRules(this, IDC_PL_RULES_LIST),
+ m_clcClist(this, IDC_CLIST),
+ m_edtNewJid(this, IDC_NEWJID)
+ {
+ m_btnSimple.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSimple_OnClick);
+ m_btnAdvanced.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAdvanced_OnClick);
+ m_btnAddJid.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddJid_OnClick);
+ m_btnActivate.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnActivate_OnClick);
+ m_btnSetDefault.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSetDefault_OnClick);
+ m_btnEditRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnEditRule_OnClick);
+ m_btnAddRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddRule_OnClick);
+ m_btnRemoveRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveRule_OnClick);
+ m_btnUpRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnUpRule_OnClick);
+ m_btnDownRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnDownRule_OnClick);
+ m_btnAddList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddList_OnClick);
+ m_btnRemoveList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveList_OnClick);
+ m_btnApply.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnApply_OnClick);
+
+ m_lbLists.OnSelChange = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnSelChange);
+ m_lbLists.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnDblClick);
+ m_lbRules.OnSelChange = Callback(this, &CJabberDlgPrivacyLists::lbRules_OnSelChange);
+ m_lbRules.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbRules_OnDblClick);
+
+ m_clcClist.OnNewContact =
+ m_clcClist.OnListRebuilt = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnUpdate);
+ m_clcClist.OnOptionsChanged = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnOptionsChanged);
+ m_clcClist.OnClick = Callback(this, &CJabberDlgPrivacyLists::clcClist_OnClick);
+ }
- int iIcon = m_clcClist.GetExtraImage(hItem, 0);
- if (bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
- else if (!bAction && (iIcon == 2)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
+ bool OnInitDialog() override
+ {
+ CSuper::OnInitDialog();
- iIcon = m_clcClist.GetExtraImage(hItem, 1);
- if (bAction && (iIcon == 3)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- else if (!bAction && (iIcon == 4)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_PRIVACY_LISTS));
- iIcon = m_clcClist.GetExtraImage(hItem, 2);
- if (bAction && (iIcon == 5)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- else if (!bAction && (iIcon == 6)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_UP_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DOWN_RULE), FALSE);
- iIcon = m_clcClist.GetExtraImage(hItem, 3);
- if (bAction && (iIcon == 7)) result |= JABBER_PL_RULE_TYPE_IQ;
- else if (!bAction && (iIcon == 8)) result |= JABBER_PL_RULE_TYPE_IQ;
+ m_proto->QueryPrivacyLists();
- return result;
-}
+ LOGFONT lf;
+ GetObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_GETFONT, 0, 0), sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ HFONT hfnt = CreateFontIndirect(&lf);
+ SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_SETFONT, (WPARAM)hfnt, TRUE);
+ SendDlgItemMessage(m_hwnd, IDC_TXT_RULES, WM_SETFONT, (WPARAM)hfnt, TRUE);
+
+ SetWindowLongPtr(m_clcClist.GetHwnd(), GWL_STYLE,
+ GetWindowLongPtr(m_clcClist.GetHwnd(), GWL_STYLE) | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
+ m_clcClist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT);
+
+ HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 9, 9);
+ ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_msg_allow"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_msg_deny"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prin_allow"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prin_deny"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prout_allow"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prout_deny"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_iq_allow"));
+ ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_iq_deny"));
+ m_clcClist.SetExtraImageList(hIml);
+ m_clcClist.SetExtraColumns(4);
+
+ m_btnSimple.MakePush();
+ m_btnAdvanced.MakePush();
-void CJabberDlgPrivacyLists::CListBuildList(CPrivacyList *pList)
-{
- if (!pList || !clc_info.bChanged)
- return;
+ CLCINFOITEM cii = { 0 };
+ cii.cbSize = sizeof(cii);
+ cii.flags = CLCIIF_GROUPFONT;
- clc_info.bChanged = false;
+ cii.pszText = TranslateT("** Default **");
+ clc_info.hItemDefault = m_clcClist.AddInfoItem(&cii);
- DWORD dwOrder = 0;
- DWORD dwPackets = 0;
+ cii.pszText = TranslateT("** Subscription: both **");
+ clc_info.hItemSubBoth = m_clcClist.AddInfoItem(&cii);
- HANDLE hItem;
- char *szJid = nullptr;
+ cii.pszText = TranslateT("** Subscription: to **");
+ clc_info.hItemSubTo = m_clcClist.AddInfoItem(&cii);
- pList->RemoveAllRules();
+ cii.pszText = TranslateT("** Subscription: from **");
+ clc_info.hItemSubFrom = m_clcClist.AddInfoItem(&cii);
- for (auto &it : clc_info.newJids) {
- hItem = it->hItem;
- szJid = it->jid;
+ cii.pszText = TranslateT("** Subscription: none **");
+ clc_info.hItemSubNone = m_clcClist.AddInfoItem(&cii);
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
- }
+ CListResetOptions();
+ CListFilter();
+ CListApplyList(nullptr);
- for (auto &hContact : Contacts()) {
- hItem = m_clcClist.FindContact(hContact);
+ if (m_proto->getByte("plistsWnd_simpleMode", 1)) {
+ UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
+ UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
+ CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_CHECKED);
+ }
+ else {
+ UIShowControls(m_hwnd, idSimpleControls, SW_HIDE);
+ UIShowControls(m_hwnd, idAdvancedControls, SW_SHOW);
+ CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_CHECKED);
+ }
- ptrW jid(m_proto->getWStringA(hContact, "jid"));
- if (jid == nullptr)
- if ((jid = m_proto->getWStringA(hContact, "ChatRoomID")) == nullptr)
- continue;
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_LB_LISTS), LstListsSubclassProc);
+ mir_subclassWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), LstRulesSubclassProc);
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
+ SetStatusText(TranslateT("Loading..."));
+
+ Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "plistsWnd_sz");
+ return true;
}
- // group handles start with 1 (0 is "root")
- wchar_t *grpName;
- for (MGROUP iGroup = 1; (grpName = Clist_GroupGetName(iGroup, nullptr)) != nullptr; iGroup++) {
- hItem = m_clcClist.FindGroup(iGroup);
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Group, T2Utf(grpName), TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Group, T2Utf(grpName), FALSE, dwOrder++, dwPackets);
- }
-
- hItem = clc_info.hItemSubBoth;
- szJid = "both";
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-
- hItem = clc_info.hItemSubFrom;
- szJid = "from";
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-
- hItem = clc_info.hItemSubNone;
- szJid = "none";
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-
- hItem = clc_info.hItemSubTo;
- szJid = "to";
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Subscription, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Subscription, szJid, FALSE, dwOrder++, dwPackets);
-
- hItem = clc_info.hItemDefault;
- szJid = nullptr;
- if (dwPackets = CListGetPackets(hItem, true))
- pList->AddRule(Else, szJid, TRUE, dwOrder++, dwPackets);
- if (dwPackets = CListGetPackets(hItem, false))
- pList->AddRule(Else, szJid, FALSE, dwOrder++, dwPackets);
+ bool OnClose() override
+ {
+ if (!CanExit())
+ return false;
- pList->Reorder();
- pList->SetModified();
-}
+ DestroyWindow(m_hwnd);
+ return CSuper::OnClose();
+ }
-void CJabberDlgPrivacyLists::EnableEditorControls()
-{
- BOOL bListsLoaded, bListsModified;
+ void OnDestroy() override
{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- bListsLoaded = m_proto->m_privacyListManager.IsAllListsLoaded();
- bListsModified = m_proto->m_privacyListManager.IsModified() || clc_info.bChanged;
- }
-
- int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
- BOOL bSelected = nCurSel != CB_ERR;
- BOOL bListSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCOUNT, 0, 0);
- bListSelected = bListSelected && (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0) != LB_ERR);
- bListSelected = bListSelected && SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0), 0);
-
- m_edtNewJid.Enable(bListsLoaded && bListSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_TXT_OTHERJID), bListsLoaded && bListSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_ADDJID), bListsLoaded && bListSelected);
-
- EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), bListsLoaded && bListSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), bListsLoaded && bSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_RULE), bListsLoaded && bSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_UP_RULE), bListsLoaded && bSelected && nCurSel != 0);
- EnableWindow(GetDlgItem(m_hwnd, IDC_DOWN_RULE), bListsLoaded && bSelected && nCurSel != (nItemCount - 1));
- EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_LIST), bListsLoaded && bListSelected);
- EnableWindow(GetDlgItem(m_hwnd, IDC_APPLY), bListsLoaded && bListsModified);
-
- if (bListsLoaded)
- SetStatusText(TranslateT("Ready."));
-}
+ m_proto->m_pDlgPrivacyLists = nullptr;
-LRESULT CALLBACK CJabberDlgPrivacyLists::LstListsSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- if (wParam == VK_INSERT)
- return UIEmulateBtnClick(GetParent(hwnd), IDC_ADD_LIST);
- if (wParam == VK_DELETE)
- return UIEmulateBtnClick(GetParent(hwnd), IDC_REMOVE_LIST);
- if (wParam == VK_SPACE) {
- if (GetAsyncKeyState(VK_CONTROL))
- return UIEmulateBtnClick(GetParent(hwnd), IDC_SET_DEFAULT);
- return UIEmulateBtnClick(GetParent(hwnd), IDC_ACTIVATE);
- }
+ // Wipe all data and query lists without contents
+ m_proto->m_privacyListManager.RemoveAllLists();
+ m_proto->QueryPrivacyLists();
+ m_proto->m_privacyListManager.SetModified(FALSE);
+
+ // Delete custom bold font
+ DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_GETFONT, 0, 0));
- break;
+ m_proto->setByte("plistsWnd_simpleMode", IsDlgButtonChecked(m_hwnd, IDC_BTN_SIMPLE));
+
+ Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "plistsWnd_sz");
+
+ CSuper::OnDestroy();
}
- return mir_callNextSubclass(hwnd, CJabberDlgPrivacyLists::LstListsSubclassProc, msg, wParam, lParam);
-}
-LRESULT CALLBACK CJabberDlgPrivacyLists::LstRulesSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- if (wParam == VK_INSERT)
- return UIEmulateBtnClick(GetParent(hwnd), IDC_ADD_RULE);
- if (wParam == VK_DELETE)
- return UIEmulateBtnClick(GetParent(hwnd), IDC_REMOVE_RULE);
- if ((wParam == VK_UP) && (lParam & (1UL << 29)))
- return UIEmulateBtnClick(GetParent(hwnd), IDC_UP_RULE);
- if ((wParam == VK_DOWN) && (lParam & (1UL << 29)))
- return UIEmulateBtnClick(GetParent(hwnd), IDC_DOWN_RULE);
- if (wParam == VK_F2)
- return UIEmulateBtnClick(GetParent(hwnd), IDC_EDIT_RULE);
-
- break;
- }
- return mir_callNextSubclass(hwnd, CJabberDlgPrivacyLists::LstRulesSubclassProc, msg, wParam, lParam);
-}
+ void OnProtoRefresh(WPARAM, LPARAM) override
+ {
+ LRESULT sel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
+ wchar_t *szCurrentSelectedList = nullptr;
+ if (sel != LB_ERR) {
+ LRESULT len = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXTLEN, sel, 0) + 1;
+ szCurrentSelectedList = (wchar_t *)mir_alloc(len * sizeof(wchar_t));
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXT, sel, (LPARAM)szCurrentSelectedList);
+ }
-BOOL CJabberDlgPrivacyLists::CanExit()
-{
- BOOL bModified;
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_RESETCONTENT, 0, 0);
+
+ LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<none>"));
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, 0);
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
+ while (pList) {
+ if (!pList->IsDeleted()) {
+ nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)pList->GetListName());
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, (LPARAM)pList);
+ }
+ pList = pList->GetNext();
+ }
+
+ if (!szCurrentSelectedList || (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)szCurrentSelectedList) == LB_ERR))
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, 0, 0);
+ if (szCurrentSelectedList)
+ mir_free(szCurrentSelectedList);
+ }
+
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
+ EnableEditorControls();
+ }
+
+ int Resizer(UTILRESIZECONTROL *urc) override
{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- bModified = m_proto->m_privacyListManager.IsModified();
+ switch (urc->wId) {
+ case IDC_HEADERBAR:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH;
+ case IDC_BTN_SIMPLE:
+ case IDC_BTN_ADVANCED:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
+ case IDC_LB_LISTS:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORY_HEIGHT;
+ case IDC_PL_RULES_LIST:
+ case IDC_CLIST:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORY_HEIGHT | RD_ANCHORX_WIDTH;
+ case IDC_NEWJID:
+ case IDC_CANVAS:
+ return RD_ANCHORX_LEFT | RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+ case IDC_ADD_LIST:
+ case IDC_ACTIVATE:
+ case IDC_REMOVE_LIST:
+ case IDC_SET_DEFAULT:
+ case IDC_TXT_OTHERJID:
+ case IDC_ADD_RULE:
+ case IDC_UP_RULE:
+ case IDC_EDIT_RULE:
+ case IDC_DOWN_RULE:
+ case IDC_REMOVE_RULE:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+ case IDC_ADDJID:
+ case IDC_APPLY:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ }
+ return CSuper::Resizer(urc);
}
- if (clc_info.bChanged)
- bModified = TRUE;
+ UI_MESSAGE_MAP(CJabberDlgPrivacyLists, CSuper);
+ UI_MESSAGE(WM_MEASUREITEM, OnWmMeasureItem);
+ UI_MESSAGE(WM_DRAWITEM, OnWmDrawItem);
+ UI_MESSAGE(WM_GETMINMAXINFO, OnWmGetMinMaxInfo);
+ UI_MESSAGE_MAP_END();
+
+ BOOL OnWmMeasureItem(UINT, WPARAM, LPARAM lParam)
+ {
+ LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
+ if ((lpmis->CtlID != IDC_PL_RULES_LIST) && (lpmis->CtlID != IDC_LB_LISTS))
+ return FALSE;
- if (!bModified)
- return TRUE;
+ TEXTMETRIC tm = { 0 };
+ HDC hdc = GetDC(GetDlgItem(m_hwnd, lpmis->CtlID));
+ GetTextMetrics(hdc, &tm);
+ ReleaseDC(GetDlgItem(m_hwnd, lpmis->CtlID), hdc);
+
+ if (lpmis->CtlID == IDC_PL_RULES_LIST)
+ lpmis->itemHeight = tm.tmHeight * 2;
+ else if (lpmis->CtlID == IDC_LB_LISTS)
+ lpmis->itemHeight = tm.tmHeight;
+
+ if (lpmis->itemHeight < 18)
+ lpmis->itemHeight = 18;
- if (IDYES == MessageBox(m_hwnd, TranslateT("Privacy lists are not saved, discard any changes and exit?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
return TRUE;
+ }
- return FALSE;
-}
+ BOOL OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
+ {
+ struct
+ {
+ wchar_t *textEng;
+ char *icon;
+ wchar_t *text;
+ }
+ static drawItems[] =
+ {
+ { LPGENW("Message"), "pl_msg_allow" },
+ { LPGENW("Presence (in)"), "pl_prin_allow" },
+ { LPGENW("Presence (out)"), "pl_prout_allow" },
+ { LPGENW("Query"), "pl_iq_allow" }
+ };
-void CJabberDlgPrivacyLists::btnSimple_OnClick(CCtrlButton *)
-{
- CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_CHECKED);
- CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_UNCHECKED);
- UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
- UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
- CListApplyList(GetSelectedList(m_hwnd));
-}
+ LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
+
+ if (lpdis->CtlID == IDC_PL_RULES_LIST)
+ DrawRulesList(lpdis);
+ else if (lpdis->CtlID == IDC_LB_LISTS)
+ DrawLists(lpdis);
+ else if (lpdis->CtlID == IDC_CANVAS) {
+ int totalWidth = -5; // spacing for last item
+ for (auto &it : drawItems) {
+ SIZE sz = { 0 };
+ it.text = TranslateW(it.textEng);
+ GetTextExtentPoint32(lpdis->hDC, it.text, (int)mir_wstrlen(it.text), &sz);
+ totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
+ }
-void CJabberDlgPrivacyLists::btnAdvanced_OnClick(CCtrlButton *)
-{
- CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_CHECKED);
- UIShowControls(m_hwnd, idSimpleControls, SW_HIDE);
- UIShowControls(m_hwnd, idAdvancedControls, SW_SHOW);
- CListBuildList(GetSelectedList(m_hwnd));
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
-}
+ COLORREF clText = GetSysColor(COLOR_BTNTEXT);
+ RECT rc = lpdis->rcItem;
+ rc.left = (rc.left + rc.right - totalWidth) / 2;
-void CJabberDlgPrivacyLists::btnAddJid_OnClick(CCtrlButton *)
-{
- CListAddContact(ptrA(m_edtNewJid.GetTextU()));
- m_edtNewJid.SetTextA("");
-}
+ for (auto &it : drawItems) {
+ DrawIconEx(lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, m_proto->LoadIconEx(it.icon),
+ 16, 16, 0, nullptr, DI_NORMAL);
+ rc.left += 18;
+ DrawNextRulePart(lpdis->hDC, clText, it.text, &rc);
+ rc.left += 5;
+ }
+ }
+ else return FALSE;
-void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
-{
- if (!m_proto->m_bJabberOnline)
- return;
+ return TRUE;
+ }
- mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+ BOOL OnWmGetMinMaxInfo(UINT, WPARAM, LPARAM lParam)
+ {
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ lpmmi->ptMinTrackSize.x = 550;
+ lpmmi->ptMinTrackSize.y = 390;
+ return 0;
+ }
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- if (pList && pList->IsModified()) {
- lck.unlock();
- MessageBox(m_hwnd, TranslateT("Please save list before activating"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
- return;
+ void btnSimple_OnClick(CCtrlButton*)
+ {
+ CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_CHECKED);
+ CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_UNCHECKED);
+ UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
+ UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
+ CListApplyList(GetSelectedList(m_hwnd));
}
- EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
- TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- TiXmlElement *active = query << XCHILD("active");
- if (pList)
- active << XATTR("name", pList->GetListName());
- lck.unlock();
- SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
- m_proto->m_ThreadInfo->send(iq);
-}
+ void btnAdvanced_OnClick(CCtrlButton*)
+ {
+ CheckDlgButton(m_hwnd, IDC_BTN_SIMPLE, BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_BTN_ADVANCED, BST_CHECKED);
+ UIShowControls(m_hwnd, idSimpleControls, SW_HIDE);
+ UIShowControls(m_hwnd, idAdvancedControls, SW_SHOW);
+ CListBuildList(GetSelectedList(m_hwnd));
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
+ }
-void CJabberDlgPrivacyLists::btnSetDefault_OnClick(CCtrlButton *)
-{
- if (!m_proto->m_bJabberOnline)
- return;
+ void btnAddJid_OnClick(CCtrlButton*)
+ {
+ CListAddContact(ptrA(m_edtNewJid.GetTextU()));
+ m_edtNewJid.SetTextA("");
+ }
- mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+ void btnActivate_OnClick(CCtrlButton*)
+ {
+ if (!m_proto->m_bJabberOnline)
+ return;
+
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList && pList->IsModified()) {
+ lck.unlock();
+ MessageBox(m_hwnd, TranslateT("Please save list before activating"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
+ return;
+ }
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *active = query << XCHILD("active");
+ if (pList)
+ active << XATTR("name", pList->GetListName());
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- if (pList && pList->IsModified()) {
lck.unlock();
- MessageBox(m_hwnd, TranslateT("Please save list before you make it the default list"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
- return;
+ SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
+ m_proto->m_ThreadInfo->send(iq);
}
- EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
- TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- TiXmlElement *defaultTag = query << XCHILD("default");
- if (pList)
- defaultTag->SetAttribute("name", pList->GetListName());
+ void btnSetDefault_OnClick(CCtrlButton*)
+ {
+ if (!m_proto->m_bJabberOnline)
+ return;
- lck.unlock();
- SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
- m_proto->m_ThreadInfo->send(iq);
-}
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
-void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *)
-{
- LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
- if (nCurSel == LB_ERR)
- return;
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList && pList->IsModified()) {
+ lck.unlock();
+ MessageBox(m_hwnd, TranslateT("Please save list before you make it the default list"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
+ return;
+ }
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
- LRESULT nErr = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0);
- if (nErr == LB_ERR)
- return;
- if (nErr == 0) {
- if (IsWindowVisible(m_clcClist.GetHwnd())) {
- CListBuildList(clc_info.pList);
- CListApplyList(nullptr);
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList));
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *defaultTag = query << XCHILD("default");
+ if (pList)
+ defaultTag->SetAttribute("name", pList->GetListName());
+
+ lck.unlock();
+ SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
+ m_proto->m_ThreadInfo->send(iq);
+ }
+
+ void lbLists_OnSelChange(CCtrlListBox *)
+ {
+ LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
+ if (nCurSel == LB_ERR)
+ return;
+
+ LRESULT nErr = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0);
+ if (nErr == LB_ERR)
+ return;
+ if (nErr == 0) {
+ if (IsWindowVisible(m_clcClist.GetHwnd())) {
+ CListBuildList(clc_info.pList);
+ CListApplyList(nullptr);
+ }
+ else {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), FALSE);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateT("No list selected"));
+ }
+ EnableEditorControls();
+ return;
}
- else {
- EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), FALSE);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateT("No list selected"));
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ if (IsWindowVisible(m_clcClist.GetHwnd())) {
+ CListBuildList(clc_info.pList);
+ CListApplyList((CPrivacyList*)nErr);
+ }
+ else ShowAdvancedList((CPrivacyList*)nErr);
}
EnableEditorControls();
- return;
}
+
+ void lbLists_OnDblClick(CCtrlListBox*)
+ {
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_ACTIVATE, 0), 0);
+ }
+
+ void lbRules_OnSelChange(CCtrlListBox*)
+ {
+ EnableEditorControls();
+ }
+
+ void lbRules_OnDblClick(CCtrlListBox*)
+ {
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_EDIT_RULE, 0), 0);
+ }
+
+ void btnEditRule_OnClick(CCtrlButton*)
{
+ // FIXME: potential deadlock due to PLM lock while editing rule
mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- if (IsWindowVisible(m_clcClist.GetHwnd())) {
- CListBuildList(clc_info.pList);
- CListApplyList((CPrivacyList*)nErr);
+
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList && pRule) {
+ CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
+ int nResult = dlgPrivacyRule.DoModal();
+ if (nResult) {
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
}
- else ShowAdvancedList((CPrivacyList*)nErr);
}
- EnableEditorControls();
-}
-void CJabberDlgPrivacyLists::lbLists_OnDblClick(CCtrlListBox*)
-{
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_ACTIVATE, 0), 0);
-}
+ void btnAddRule_OnClick(CCtrlButton*)
+ {
+ // FIXME: potential deadlock due to PLM lock while editing rule
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
-void CJabberDlgPrivacyLists::lbRules_OnSelChange(CCtrlListBox*)
-{
- EnableEditorControls();
-}
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList) {
+ CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, "", FALSE);
+ CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
+ int nResult = dlgPrivacyRule.DoModal();
+ if (nResult) {
+ pList->AddRule(pRule);
+ pList->Reorder();
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
+ else delete pRule;
+ }
+ }
-void CJabberDlgPrivacyLists::lbRules_OnDblClick(CCtrlListBox*)
-{
- PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_EDIT_RULE, 0), 0);
-}
+ void btnRemoveRule_OnClick(CCtrlButton*)
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
-void CJabberDlgPrivacyLists::btnEditRule_OnClick(CCtrlButton*)
-{
- // FIXME: potential deadlock due to PLM lock while editing rule
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
-
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- if (pList && pRule) {
- CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
- int nResult = dlgPrivacyRule.DoModal();
- if (nResult) {
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+
+ if (pList && pRule) {
+ pList->RemoveRule(pRule);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel != nItemCount - 1 ? nCurSel : nCurSel - 1, 0);
+ pList->Reorder();
pList->SetModified();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
}
-}
-void CJabberDlgPrivacyLists::btnAddRule_OnClick(CCtrlButton*)
-{
- // FIXME: potential deadlock due to PLM lock while editing rule
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
-
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- if (pList) {
- CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, "", FALSE);
- CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
- int nResult = dlgPrivacyRule.DoModal();
- if (nResult) {
- pList->AddRule(pRule);
+ void btnUpRule_OnClick(CCtrlButton*)
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+
+ if (pList && pRule && nCurSel) {
+ pRule->SetOrder(pRule->GetOrder() - 11);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel - 1, 0);
pList->Reorder();
pList->SetModified();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
- else delete pRule;
}
-}
-
-void CJabberDlgPrivacyLists::btnRemoveRule_OnClick(CCtrlButton*)
-{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ void btnDownRule_OnClick(CCtrlButton*)
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- if (pList && pRule) {
- pList->RemoveRule(pRule);
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel != nItemCount - 1 ? nCurSel : nCurSel - 1, 0);
- pList->Reorder();
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
- }
-}
-
-void CJabberDlgPrivacyLists::btnUpRule_OnClick(CCtrlButton*)
-{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
- int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
-
- if (pList && pRule && nCurSel) {
- pRule->SetOrder(pRule->GetOrder() - 11);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel - 1, 0);
- pList->Reorder();
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ if (pList && pRule && (nCurSel != (nItemCount - 1))) {
+ pRule->SetOrder(pRule->GetOrder() + 11);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel + 1, 0);
+ pList->Reorder();
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
}
-}
-
-void CJabberDlgPrivacyLists::btnDownRule_OnClick(CCtrlButton*)
-{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
- int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
+ void btnAddList_OnClick(CCtrlButton*)
+ {
+ // FIXME: line length is hard coded in dialog procedure
+ CJabberDlgPrivacyAddList dlgPrivacyAddList(m_proto, m_hwnd);
+ int nRetVal = dlgPrivacyAddList.DoModal();
+ if (nRetVal && mir_strlen(dlgPrivacyAddList.szLine)) {
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
+ if (pList == nullptr) {
+ m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine);
+ pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
+ if (pList) {
+ pList->SetModified(TRUE);
+ pList->SetLoaded(TRUE);
+ }
+ }
+ if (pList)
+ pList->SetDeleted(FALSE);
+ int nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)dlgPrivacyAddList.szLine);
+ if (nSelected == CB_ERR) {
+ nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)dlgPrivacyAddList.szLine);
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList);
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0);
+ }
- if (pList && pRule && (nCurSel != (nItemCount - 1))) {
- pRule->SetOrder(pRule->GetOrder() + 11);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel + 1, 0);
- pList->Reorder();
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ lck.unlock();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
}
-}
-void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton*)
-{
- // FIXME: line length is hard coded in dialog procedure
- CJabberDlgPrivacyAddList dlgPrivacyAddList(m_proto, m_hwnd);
- int nRetVal = dlgPrivacyAddList.DoModal();
- if (nRetVal && mir_strlen(dlgPrivacyAddList.szLine)) {
+ void btnRemoveList_OnClick(CCtrlButton*)
+ {
mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
- CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
- if (pList == nullptr) {
- m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine);
- pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
- if (pList) {
- pList->SetModified(TRUE);
- pList->SetLoaded(TRUE);
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList) {
+ char *szListName = pList->GetListName();
+ if ((m_proto->m_privacyListManager.GetActiveListName() && !mir_strcmp(szListName, m_proto->m_privacyListManager.GetActiveListName())) ||
+ (m_proto->m_privacyListManager.GetDefaultListName() && !mir_strcmp(szListName, m_proto->m_privacyListManager.GetDefaultListName()))) {
+ lck.unlock();
+ MessageBox(m_hwnd, TranslateT("Can't remove active or default list"), TranslateT("Sorry"), MB_OK | MB_ICONSTOP);
+ return;
}
- }
- if (pList)
- pList->SetDeleted(FALSE);
- int nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)dlgPrivacyAddList.szLine);
- if (nSelected == CB_ERR) {
- nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)dlgPrivacyAddList.szLine);
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList);
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0);
+ pList->SetDeleted();
+ pList->SetModified();
}
lck.unlock();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
-}
-void CJabberDlgPrivacyLists::btnRemoveList_OnClick(CCtrlButton *)
-{
- mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
-
- CPrivacyList *pList = GetSelectedList(m_hwnd);
- if (pList) {
- char *szListName = pList->GetListName();
- if ((m_proto->m_privacyListManager.GetActiveListName() && !mir_strcmp(szListName, m_proto->m_privacyListManager.GetActiveListName())) ||
- (m_proto->m_privacyListManager.GetDefaultListName() && !mir_strcmp(szListName, m_proto->m_privacyListManager.GetDefaultListName()))) {
- lck.unlock();
- MessageBox(m_hwnd, TranslateT("Can't remove active or default list"), TranslateT("Sorry"), MB_OK | MB_ICONSTOP);
+ void btnApply_OnClick(CCtrlButton*)
+ {
+ if (!m_proto->m_bJabberOnline) {
+ SetStatusText(TranslateT("Unable to save list because you are currently offline."));
return;
}
- pList->SetDeleted();
- pList->SetModified();
- }
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ if (IsWindowVisible(m_clcClist.GetHwnd()))
+ CListBuildList(clc_info.pList);
+
+ CPrivacyListModifyUserParam *pUserData = nullptr;
+ CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
+ while (pList) {
+ if (pList->IsModified()) {
+ CPrivacyListRule* pRule = pList->GetFirstRule();
+ if (!pRule)
+ pList->SetDeleted();
+ if (pList->IsDeleted()) {
+ pList->RemoveAllRules();
+ pRule = nullptr;
+ }
+ pList->SetModified(FALSE);
+
+ if (!pUserData)
+ pUserData = new CPrivacyListModifyUserParam();
+
+ pUserData->m_dwCount++;
+
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pUserData));
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ TiXmlElement *listTag = query << XCHILD("list") << XATTR("name", pList->GetListName());
+
+ while (pRule) {
+ TiXmlElement *itemTag = listTag << XCHILD("item");
+ switch (pRule->GetType()) {
+ case Jid:
+ itemTag << XATTR("type", "jid");
+ break;
+ case Group:
+ itemTag << XATTR("type", "group");
+ break;
+ case Subscription:
+ itemTag << XATTR("type", "subscription");
+ break;
+ }
+ if (pRule->GetType() != Else)
+ itemTag << XATTR("value", pRule->GetValue());
+ if (pRule->GetAction())
+ itemTag << XATTR("action", "allow");
+ else
+ itemTag << XATTR("action", "deny");
+ itemTag << XATTRI("order", pRule->GetOrder());
+ DWORD dwPackets = pRule->GetPackets();
+ if (dwPackets != JABBER_PL_RULE_TYPE_ALL) {
+ if (dwPackets & JABBER_PL_RULE_TYPE_IQ)
+ itemTag << XCHILD("iq");
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN)
+ itemTag << XCHILD("presence-in");
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT)
+ itemTag << XCHILD("presence-out");
+ if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
+ itemTag << XCHILD("message");
+ }
+ pRule = pRule->GetNext();
+ }
- lck.unlock();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
-}
+ m_proto->m_ThreadInfo->send(iq);
+ }
+ pList = pList->GetNext();
+ }
+ }
-void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
-{
- if (!m_proto->m_bJabberOnline) {
- SetStatusText(TranslateT("Unable to save list because you are currently offline."));
- return;
+ SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
+ void OnCommand_Close(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/)
{
- mir_cslock lck(m_proto->m_privacyListManager.m_cs);
if (IsWindowVisible(m_clcClist.GetHwnd()))
CListBuildList(clc_info.pList);
- CPrivacyListModifyUserParam *pUserData = nullptr;
- CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
- while (pList) {
- if (pList->IsModified()) {
- CPrivacyListRule* pRule = pList->GetFirstRule();
- if (!pRule)
- pList->SetDeleted();
- if (pList->IsDeleted()) {
- pList->RemoveAllRules();
- pRule = nullptr;
- }
- pList->SetModified(FALSE);
-
- if (!pUserData)
- pUserData = new CPrivacyListModifyUserParam();
-
- pUserData->m_dwCount++;
-
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pUserData));
- TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- TiXmlElement *listTag = query << XCHILD("list") << XATTR("name", pList->GetListName());
-
- while (pRule) {
- TiXmlElement *itemTag = listTag << XCHILD("item");
- switch (pRule->GetType()) {
- case Jid:
- itemTag << XATTR("type", "jid");
- break;
- case Group:
- itemTag << XATTR("type", "group");
- break;
- case Subscription:
- itemTag << XATTR("type", "subscription");
- break;
- }
- if (pRule->GetType() != Else)
- itemTag << XATTR("value", pRule->GetValue());
- if (pRule->GetAction())
- itemTag << XATTR("action", "allow");
- else
- itemTag << XATTR("action", "deny");
- itemTag << XATTRI("order", pRule->GetOrder());
- DWORD dwPackets = pRule->GetPackets();
- if (dwPackets != JABBER_PL_RULE_TYPE_ALL) {
- if (dwPackets & JABBER_PL_RULE_TYPE_IQ)
- itemTag << XCHILD("iq");
- if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN)
- itemTag << XCHILD("presence-in");
- if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT)
- itemTag << XCHILD("presence-out");
- if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
- itemTag << XCHILD("message");
- }
- pRule = pRule->GetNext();
- }
-
- m_proto->m_ThreadInfo->send(iq);
- }
- pList = pList->GetNext();
- }
+ if (CanExit())
+ DestroyWindow(m_hwnd);
}
- SetStatusText(TranslateW(JABBER_PL_BUSY_MSG));
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
-}
-
-void CJabberDlgPrivacyLists::OnCommand_Close(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/)
-{
- if (IsWindowVisible(m_clcClist.GetHwnd()))
- CListBuildList(clc_info.pList);
-
- if (CanExit())
- DestroyWindow(m_hwnd);
-}
-
-void CJabberDlgPrivacyLists::clcClist_OnUpdate(CCtrlClc::TEventInfo*)
-{
- CListFilter();
- CListApplyList(GetSelectedList(m_hwnd));
-}
+ void clcClist_OnUpdate(CCtrlClc::TEventInfo*)
+ {
+ CListFilter();
+ CListApplyList(GetSelectedList(m_hwnd));
+ }
-void CJabberDlgPrivacyLists::clcClist_OnOptionsChanged(CCtrlClc::TEventInfo*)
-{
- CListResetOptions();
- CListApplyList(GetSelectedList(m_hwnd));
-}
+ void clcClist_OnOptionsChanged(CCtrlClc::TEventInfo*)
+ {
+ CListResetOptions();
+ CListApplyList(GetSelectedList(m_hwnd));
+ }
-void CJabberDlgPrivacyLists::clcClist_OnClick(CCtrlClc::TEventInfo *evt)
-{
- if (evt->info->iColumn == -1)
- return;
+ void clcClist_OnClick(CCtrlClc::TEventInfo *evt)
+ {
+ if (evt->info->iColumn == -1)
+ return;
- DWORD hitFlags;
- HANDLE hItem = m_clcClist.HitTest(evt->info->pt.x, evt->info->pt.y, &hitFlags);
- if (hItem == nullptr || !(hitFlags & CLCHT_ONITEMEXTRA))
- return;
+ DWORD hitFlags;
+ HANDLE hItem = m_clcClist.HitTest(evt->info->pt.x, evt->info->pt.y, &hitFlags);
+ if (hItem == nullptr || !(hitFlags & CLCHT_ONITEMEXTRA))
+ return;
- int iImage = m_clcClist.GetExtraImage(hItem, evt->info->iColumn);
- if (iImage != EMPTY_EXTRA_ICON) {
- if (iImage == 0)
- iImage = evt->info->iColumn * 2 + 2;
- else if (iImage == evt->info->iColumn * 2 + 2)
- iImage = evt->info->iColumn * 2 + 1;
- else
- iImage = 0;
+ int iImage = m_clcClist.GetExtraImage(hItem, evt->info->iColumn);
+ if (iImage != EMPTY_EXTRA_ICON) {
+ if (iImage == 0)
+ iImage = evt->info->iColumn * 2 + 2;
+ else if (iImage == evt->info->iColumn * 2 + 2)
+ iImage = evt->info->iColumn * 2 + 1;
+ else
+ iImage = 0;
- m_clcClist.SetExtraImage(hItem, evt->info->iColumn, iImage);
+ m_clcClist.SetExtraImage(hItem, evt->info->iColumn, iImage);
- clc_info.bChanged = true;
+ clc_info.bChanged = true;
- EnableEditorControls();
+ EnableEditorControls();
+ }
}
-}
+};
-int CJabberDlgPrivacyLists::Resizer(UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDC_HEADERBAR:
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH;
- case IDC_BTN_SIMPLE:
- case IDC_BTN_ADVANCED:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
- case IDC_LB_LISTS:
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORY_HEIGHT;
- case IDC_PL_RULES_LIST:
- case IDC_CLIST:
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORY_HEIGHT | RD_ANCHORX_WIDTH;
- case IDC_NEWJID:
- case IDC_CANVAS:
- return RD_ANCHORX_LEFT | RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
- case IDC_ADD_LIST:
- case IDC_ACTIVATE:
- case IDC_REMOVE_LIST:
- case IDC_SET_DEFAULT:
- case IDC_TXT_OTHERJID:
- case IDC_ADD_RULE:
- case IDC_UP_RULE:
- case IDC_EDIT_RULE:
- case IDC_DOWN_RULE:
- case IDC_REMOVE_RULE:
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
- case IDC_ADDJID:
- case IDC_APPLY:
- case IDCANCEL:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
- }
- return CSuper::Resizer(urc);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR __cdecl CJabberProto::OnMenuHandlePrivacyLists(WPARAM, LPARAM)
{
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp
index 76e9345491..70fad9c365 100644
--- a/protocols/JabberG/src/jabber_xstatus.cpp
+++ b/protocols/JabberG/src/jabber_xstatus.cpp
@@ -170,7 +170,7 @@ private:
LPARAM m_active;
wchar_t *m_activeText;
- void btnOk_OnClick(CCtrlButton *btn);
+ void btnOk_OnClick(CCtrlButton*btn);
void global_OnChange(CCtrlData *);
void cbModes_OnChange(CCtrlData *);
};