summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-04-04 00:20:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-04-04 00:20:24 +0300
commit5c3ab50ab27ba9a517cf56d0626c641883e3fd39 (patch)
tree553f38fa4a7673d710ee18f570201d177e2f64ac /src
parent7f513673b523ecfbf6ded0a2d0e5cdf5496bd6b0 (diff)
SRMM window list completely incapsulated into mir_app to avoid corrupting it by someone's dirty hands
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/globals.cpp8
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp2
-rw-r--r--src/core/stdmsg/src/msgoptions.cpp6
-rw-r--r--src/core/stdmsg/src/msgs.cpp26
-rw-r--r--src/core/stdmsg/src/msgtimedout.cpp4
-rw-r--r--src/core/stdmsg/src/statusicon.cpp4
-rw-r--r--src/core/stdmsg/src/tabs.cpp2
-rw-r--r--src/mir_app/src/chat.h1
-rw-r--r--src/mir_app/src/chat_svc.cpp7
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/srmm_base.cpp4
-rw-r--r--src/mir_app/src/srmm_toolbar.cpp17
-rw-r--r--src/mir_app/src/srmm_util.cpp11
14 files changed, 56 insertions, 40 deletions
diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp
index 73a5562008..4675677588 100644
--- a/src/core/stdmsg/src/globals.cpp
+++ b/src/core/stdmsg/src/globals.cpp
@@ -58,7 +58,7 @@ static int OnShutdown(WPARAM, LPARAM)
static int OnMetaChanged(WPARAM hMeta, LPARAM)
{
if (hMeta) {
- HWND hwnd = WindowList_Find(pci->hWindowList, hMeta);
+ HWND hwnd = Srmm_FindWindow(hMeta);
if (hwnd != nullptr)
SendMessage(hwnd, DM_GETAVATAR, 0, 0);
}
@@ -68,13 +68,13 @@ static int OnMetaChanged(WPARAM hMeta, LPARAM)
static int dbaddedevent(WPARAM hContact, LPARAM hDbEvent)
{
if (hContact) {
- HWND h = WindowList_Find(pci->hWindowList, hContact);
+ HWND h = Srmm_FindWindow(hContact);
if (h)
SendMessage(h, HM_DBEVENTADDED, hContact, hDbEvent);
MCONTACT hEventContact = db_event_getContact(hDbEvent);
if (hEventContact != hContact)
- if ((h = WindowList_Find(pci->hWindowList, hEventContact)) != nullptr)
+ if ((h = Srmm_FindWindow(hEventContact)) != nullptr)
SendMessage(h, HM_DBEVENTADDED, hEventContact, hDbEvent);
}
return 0;
@@ -94,7 +94,7 @@ static int ackevent(WPARAM, LPARAM lParam)
static int AvatarChanged(WPARAM hContact, LPARAM lParam)
{
- HWND h = WindowList_Find(pci->hWindowList, hContact);
+ HWND h = Srmm_FindWindow(hContact);
if (h)
SendMessage(h, HM_AVATARACK, hContact, lParam);
return 0;
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 8b6ae10ed8..4ae0a330dd 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -264,7 +264,7 @@ void CSrmmWindow::OnInitDialog()
}
if (!g_dat.bSavePerContact && g_dat.bCascade)
- WindowList_Broadcast(pci->hWindowList, DM_CASCADENEWWINDOW, (WPARAM)m_hwnd, (LPARAM)&m_windowWasCascaded);
+ Srmm_Broadcast(DM_CASCADENEWWINDOW, (WPARAM)m_hwnd, (LPARAM)&m_windowWasCascaded);
if (m_bNoActivate) {
SetWindowPos(m_hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index 83e4707513..de0f3dbe79 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -313,7 +313,7 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP
db_set_dw(0, SRMMMOD, SRMSGSET_MSGTIMEOUT, msgTimeout);
ReloadGlobals();
- WindowList_Broadcast(pci->hWindowList, DM_OPTIONSAPPLIED, TRUE, 0);
+ Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
return TRUE;
}
}
@@ -410,7 +410,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
FreeMsgLogIcons();
LoadMsgLogIcons();
ReloadGlobals();
- WindowList_Broadcast(pci->hWindowList, DM_OPTIONSAPPLIED, TRUE, 0);
+ Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
return TRUE;
}
break;
@@ -539,7 +539,7 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam
db_set_b(0, SRMMMOD, SRMSGSET_SHOWTYPINGNOWIN, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_TYPETRAY));
db_set_b(0, SRMMMOD, SRMSGSET_SHOWTYPINGCLIST, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTIFYTRAY));
ReloadGlobals();
- WindowList_Broadcast(pci->hWindowList, DM_OPTIONSAPPLIED, TRUE, 0);
+ Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
}
}
break;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index 1af01ed518..f050209d20 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -61,7 +61,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
pcli->pfnRemoveEvent(hContact, 1);
/* does a window for the contact exist? */
- HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
+ HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd) {
if (!g_dat.bDoNotStealFocus) {
ShowWindow(hwnd, SW_RESTORE);
@@ -110,7 +110,7 @@ INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *pwszInitialText)
hContact = db_mc_tryMeta(hContact);
- HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
+ HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd) {
if (pwszInitialText) {
SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, EM_SETSEL, -1, SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, WM_GETTEXTLENGTH, 0, 0));
@@ -158,7 +158,7 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam)
SkinPlaySound((lParam) ? "TNStart" : "TNStop");
- HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
+ HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd)
SendMessage(hwnd, DM_TYPING, 0, lParam);
else if (lParam && g_dat.bShowTypingTray) {
@@ -191,14 +191,14 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam)
return 0;
if (!strcmp(cws->szModule, "CList"))
- WindowList_Broadcast(pci->hWindowList, DM_UPDATETITLE, (WPARAM)cws, 0);
+ Srmm_Broadcast(DM_UPDATETITLE, (WPARAM)cws, 0);
else if (hContact) {
if (cws->szSetting && !strcmp(cws->szSetting, "Timezone"))
- WindowList_Broadcast(pci->hWindowList, DM_NEWTIMEZONE, (WPARAM)cws, 0);
+ Srmm_Broadcast(DM_NEWTIMEZONE, (WPARAM)cws, 0);
else {
char *szProto = GetContactProto(hContact);
if (szProto && !strcmp(cws->szModule, szProto))
- WindowList_Broadcast(pci->hWindowList, DM_UPDATETITLE, (WPARAM)cws, 0);
+ Srmm_Broadcast(DM_UPDATETITLE, (WPARAM)cws, 0);
}
}
return 0;
@@ -207,7 +207,7 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam)
// If a contact gets deleted, close its message window if there is any
static int ContactDeleted(WPARAM wParam, LPARAM)
{
- HWND hwnd = WindowList_Find(pci->hWindowList, wParam);
+ HWND hwnd = Srmm_FindWindow(wParam);
if (hwnd)
SendMessage(hwnd, WM_CLOSE, 0, 0);
@@ -240,7 +240,7 @@ static void RestoreUnreadMessageAlerts(void)
dbei.cbBlob = 0;
db_event_get(hDbEvent, &dbei);
if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
- int windowAlreadyExists = WindowList_Find(pci->hWindowList, hContact) != nullptr;
+ int windowAlreadyExists = Srmm_FindWindow(hContact) != nullptr;
if (windowAlreadyExists)
continue;
@@ -415,7 +415,7 @@ void SetButtonsPos(HWND hwndDlg, bool bIsChat)
static int FontsChanged(WPARAM, LPARAM)
{
- WindowList_Broadcast(pci->hWindowList, DM_OPTIONSAPPLIED, TRUE, 0);
+ Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
return 0;
}
@@ -443,7 +443,7 @@ static int SplitmsgModulesLoaded(WPARAM, LPARAM)
int PreshutdownSendRecv(WPARAM, LPARAM)
{
- WindowList_Broadcast(pci->hWindowList, WM_CLOSE, 0, 0);
+ Srmm_Broadcast(WM_CLOSE, 0, 0);
DeinitStatusIcons();
return 0;
@@ -455,8 +455,8 @@ static int IconsChanged(WPARAM, LPARAM)
LoadMsgLogIcons();
// change all the icons
- WindowList_Broadcast(pci->hWindowList, DM_REMAKELOG, 0, 0);
- WindowList_Broadcast(pci->hWindowList, DM_UPDATEWINICON, 0, 0);
+ Srmm_Broadcast(DM_REMAKELOG, 0, 0);
+ Srmm_Broadcast(DM_UPDATEWINICON, 0, 0);
return 0;
}
@@ -483,7 +483,7 @@ static INT_PTR SetStatusText(WPARAM wParam, LPARAM lParam)
if (st == nullptr)
return 1;
- HWND hwnd = WindowList_Find(pci->hWindowList, wParam);
+ HWND hwnd = Srmm_FindWindow(wParam);
if (hwnd == nullptr)
return 1;
diff --git a/src/core/stdmsg/src/msgtimedout.cpp b/src/core/stdmsg/src/msgtimedout.cpp
index d7bfb30d1b..7596198ce5 100644
--- a/src/core/stdmsg/src/msgtimedout.cpp
+++ b/src/core/stdmsg/src/msgtimedout.cpp
@@ -85,11 +85,11 @@ void MessageFailureProcess(TMsgQueue *item, const char* err)
{
MCONTACT hContact = db_mc_tryMeta(item->hContact);
- HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
+ HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd == nullptr) {
// If message window doesn't already exist, open a new one
SendMessageCmd(item->hContact, nullptr);
- hwnd = WindowList_Find(pci->hWindowList, hContact);
+ hwnd = Srmm_FindWindow(hContact);
}
else SendMessage(hwnd, DM_REMAKELOG, 0, 0);
diff --git a/src/core/stdmsg/src/statusicon.cpp b/src/core/stdmsg/src/statusicon.cpp
index c82669f941..057a544e41 100644
--- a/src/core/stdmsg/src/statusicon.cpp
+++ b/src/core/stdmsg/src/statusicon.cpp
@@ -27,9 +27,9 @@ HANDLE hHookIconPressedEvt;
static int OnSrmmIconChanged(WPARAM hContact, LPARAM)
{
if (hContact == 0)
- WindowList_Broadcast(pci->hWindowList, DM_STATUSICONCHANGE, 0, 0);
+ Srmm_Broadcast(DM_STATUSICONCHANGE, 0, 0);
else {
- HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
+ HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd != nullptr)
PostMessage(hwnd, DM_STATUSICONCHANGE, 0, 0);
}
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index a7830b494f..2336e068ad 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -245,7 +245,7 @@ void CTabbedWindow::SetWindowPosition()
}
if (!g_dat.bSavePerContact && g_dat.bCascade)
- WindowList_Broadcast(pci->hWindowList, DM_CASCADENEWWINDOW, (WPARAM)m_hwnd, (LPARAM)&m_windowWasCascaded);
+ Srmm_Broadcast(DM_CASCADENEWWINDOW, (WPARAM)m_hwnd, (LPARAM)&m_windowWasCascaded);
}
void CTabbedWindow::TabClicked()
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 5f408fb215..fca1458400 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -42,6 +42,7 @@ extern HMENU g_hMenu;
extern HCURSOR g_hCurHyperlinkHand;
extern char* pLogIconBmpBits[14];
extern LIST<SESSION_INFO> g_arSessions;
+extern MWindowList g_hWindowList;
// log.c
void LoadMsgLogBitmaps(void);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 1dd20900a8..002742a66c 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -27,9 +27,10 @@ INT_PTR SvcGetChatManager(WPARAM, LPARAM);
#include "chat.h"
#include "resource.h"
+mir_cs csChat;
HMENU g_hMenu = nullptr;
HGENMENU hJoinMenuItem, hLeaveMenuItem;
-mir_cs csChat;
+MWindowList g_hWindowList;
static HANDLE
hServiceRegister = nullptr,
@@ -777,7 +778,7 @@ int LoadChatModule(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
- chatApi.hWindowList = WindowList_Create();
+ g_hWindowList = WindowList_Create();
chatApi.hSendEvent = CreateHookableEvent(ME_GC_EVENT);
chatApi.hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
hHookEvent = CreateHookableEvent(ME_GC_HOOK_EVENT);
@@ -803,7 +804,7 @@ void UnloadChatModule(void)
FreeMsgLogBitmaps();
OptionsUnInit();
- WindowList_Destroy(chatApi.hWindowList);
+ WindowList_Destroy(g_hWindowList);
DestroyHookableEvent(chatApi.hSendEvent);
DestroyHookableEvent(chatApi.hBuildMenuEvent);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 67645af6f5..156ea679c2 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -446,3 +446,5 @@ _stubNicklistProc@16 @448 NONAME
Chat_GetTextPixelSize @449 NONAME
?NotifyEvent@CSrmmBaseDialog@@IAEHH@Z @450 NONAME
Srmm_GetWindowData @451
+Srmm_FindWindow @452
+Srmm_Broadcast @453
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 563b920ab4..11b740223e 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -446,3 +446,5 @@ stubNicklistProc @448 NONAME
Chat_GetTextPixelSize @449 NONAME
?NotifyEvent@CSrmmBaseDialog@@IEAAHH@Z @450 NONAME
Srmm_GetWindowData @451
+Srmm_FindWindow @452
+Srmm_Broadcast @453
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 62d744f540..0bf810aa5f 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -577,7 +577,7 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam
void CSrmmBaseDialog::OnInitDialog()
{
- WindowList_Add(chatApi.hWindowList, m_hwnd, m_hContact);
+ WindowList_Add(g_hWindowList, m_hwnd, m_hContact);
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
SetWindowLongPtr(m_log.GetHwnd(), GWLP_USERDATA, LPARAM(this));
@@ -598,7 +598,7 @@ void CSrmmBaseDialog::OnInitDialog()
void CSrmmBaseDialog::OnDestroy()
{
- WindowList_Remove(chatApi.hWindowList, m_hwnd);
+ WindowList_Remove(g_hWindowList, m_hwnd);
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
mir_unsubclassWindow(m_log.GetHwnd(), stubLogProc);
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp
index 8517637822..1469628d70 100644
--- a/src/mir_app/src/srmm_toolbar.cpp
+++ b/src/mir_app/src/srmm_toolbar.cpp
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
+#include "chat.h"
#define MODULENAME "SRMM_Toolbar"
@@ -148,7 +149,7 @@ MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang)
if (cbd->m_dwArrowCID == LastCID)
LastCID++;
- WindowList_Broadcast(chatApi.hWindowList, WM_CBD_UPDATED, 0, 0);
+ WindowList_Broadcast(g_hWindowList, WM_CBD_UPDATED, 0, 0);
return 0;
}
@@ -190,7 +191,7 @@ MIR_APP_DLL(int) Srmm_SetButtonState(MCONTACT hContact, BBButton *bbdi)
if (!tempCID)
return 1;
- HWND hwndDlg = WindowList_Find(chatApi.hWindowList, hContact);
+ HWND hwndDlg = WindowList_Find(g_hWindowList, hContact);
if (hwndDlg == nullptr)
return 1;
@@ -231,7 +232,7 @@ MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi)
}
if (pFound) {
- WindowList_Broadcast(chatApi.hWindowList, WM_CBD_REMOVED, pFound->m_dwButtonCID, (LPARAM)pFound);
+ WindowList_Broadcast(g_hWindowList, WM_CBD_REMOVED, pFound->m_dwButtonCID, (LPARAM)pFound);
delete pFound;
}
return 0;
@@ -272,7 +273,7 @@ MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi)
}
if (bFound)
- WindowList_Broadcast(chatApi.hWindowList, WM_CBD_UPDATED, 0, (LPARAM)cbd);
+ WindowList_Broadcast(g_hWindowList, WM_CBD_UPDATED, 0, (LPARAM)cbd);
return 0;
}
@@ -403,8 +404,8 @@ static void CB_ReInitCustomButtons()
}
qsort(arButtonsList.getArray(), arButtonsList.getCount(), sizeof(void*), sstSortButtons);
- WindowList_Broadcast(chatApi.hWindowList, WM_CBD_UPDATED, 0, 0);
- WindowList_Broadcast(chatApi.hWindowList, WM_CBD_LOADICONS, 0, 0);
+ WindowList_Broadcast(g_hWindowList, WM_CBD_UPDATED, 0, 0);
+ WindowList_Broadcast(g_hWindowList, WM_CBD_LOADICONS, 0, 0);
}
static void CB_WriteButtonSettings(MCONTACT hContact, CustomButtonData *cbd)
@@ -618,7 +619,7 @@ public:
WORD newGap = m_gap.GetPosition();
if (newGap != db_get_b(0, MODULENAME, "ButtonsBarGap", 1)) {
- WindowList_BroadcastAsync(chatApi.hWindowList, WM_SIZE, 0, 0);
+ WindowList_BroadcastAsync(g_hWindowList, WM_SIZE, 0, 0);
db_set_b(0, MODULENAME, "ButtonsBarGap", newGap);
}
@@ -638,7 +639,7 @@ public:
void btnResetClicked(void*)
{
db_delete_module(0, MODULENAME);
- WindowList_Broadcast(chatApi.hWindowList, WM_CBD_REMOVED, 0, 0);
+ WindowList_Broadcast(g_hWindowList, WM_CBD_REMOVED, 0, 0);
Srmm_ResetToolbar();
NotifyEventHooks(hHookToolBarLoadedEvt, 0, 0);
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index 482e3c3fb0..864f8ca00f 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -78,7 +78,7 @@ MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd)
if (hContact == 0)
return 1;
- HWND hwnd = WindowList_Find(chatApi.hWindowList, hContact);
+ HWND hwnd = WindowList_Find(g_hWindowList, hContact);
if (hwnd == nullptr)
return 1;
@@ -94,3 +94,12 @@ MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd)
return 0;
}
+MIR_APP_DLL(void) Srmm_Broadcast(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WindowList_Broadcast(g_hWindowList, msg, wParam, lParam);
+}
+
+MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact)
+{
+ return WindowList_Find(g_hWindowList, hContact);
+}