summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-21 23:24:02 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-21 23:24:02 +0000
commitef0abe4f9f67eeff4007f4839ba08a503472c74c (patch)
tree6b3e4e878aabab3c1b0995d62fab9257772cd39e /src
parentc5427646b03c73c179a31505671a9ad785709eb3 (diff)
- new typed helper, WindowList_Create, to create a window list
- new service, WindowList_Destroy, to destroy a window list - internal windowlist.cpp implementation rewritten to LIST<> git-svn-id: http://svn.miranda-ng.org/main/trunk@7823 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdaway/awaymsg.cpp7
-rw-r--r--src/core/stdmsg/src/globals.cpp4
-rw-r--r--src/core/stdmsg/src/msgs.cpp1
-rw-r--r--src/core/stduihist/history.cpp8
-rw-r--r--src/core/stdurl/url.cpp9
-rw-r--r--src/core/stduserinfo/userinfo.cpp3
-rw-r--r--src/modules/chat/chat_svc.cpp1
-rw-r--r--src/modules/clist/clc.cpp3
-rw-r--r--src/modules/utils/utils.cpp3
-rw-r--r--src/modules/utils/windowlist.cpp67
10 files changed, 60 insertions, 46 deletions
diff --git a/src/core/stdaway/awaymsg.cpp b/src/core/stdaway/awaymsg.cpp
index 08d841275c..119fe411b4 100644
--- a/src/core/stdaway/awaymsg.cpp
+++ b/src/core/stdaway/awaymsg.cpp
@@ -158,13 +158,16 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM)
static int AwayMsgPreShutdown(WPARAM, LPARAM)
{
- if (hWindowList) WindowList_BroadcastAsync(hWindowList, WM_CLOSE, 0, 0);
+ if (hWindowList) {
+ WindowList_BroadcastAsync(hWindowList, WM_CLOSE, 0, 0);
+ WindowList_Destroy(hWindowList);
+ }
return 0;
}
int LoadAwayMsgModule(void)
{
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetMessageCommand);
CLISTMENUITEM mi = { sizeof(mi) };
diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp
index 2260f2d0db..466001fb5d 100644
--- a/src/core/stdmsg/src/globals.cpp
+++ b/src/core/stdmsg/src/globals.cpp
@@ -48,13 +48,13 @@ static int IconsChanged(WPARAM wParam, LPARAM lParam)
static int OnShutdown(WPARAM, LPARAM)
{
- WindowList_Broadcast(g_dat.hMessageWindowList, WM_CLOSE, 0, 0);
+ WindowList_Destroy(g_dat.hMessageWindowList);
return 0;
}
void InitGlobals()
{
- g_dat.hMessageWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ g_dat.hMessageWindowList = WindowList_Create();
HookEvent(ME_DB_EVENT_ADDED, dbaddedevent);
HookEvent(ME_PROTO_ACK, ackevent);
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index fa04cab531..53a2314fa8 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -298,6 +298,7 @@ static int SplitmsgModulesLoaded(WPARAM, LPARAM)
int PreshutdownSendRecv(WPARAM, LPARAM)
{
WindowList_Broadcast(g_dat.hMessageWindowList, WM_CLOSE, 0, 0);
+
DeinitStatusIcons();
return 0;
}
diff --git a/src/core/stduihist/history.cpp b/src/core/stduihist/history.cpp
index 0152d177bf..55795e62bc 100644
--- a/src/core/stduihist/history.cpp
+++ b/src/core/stduihist/history.cpp
@@ -398,8 +398,10 @@ static int HistoryContactDelete(WPARAM wParam, LPARAM)
int PreShutdownHistoryModule(WPARAM, LPARAM)
{
- if (hWindowList)
- WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0);
+ if (hWindowList) {
+ WindowList_Broadcast(hWindowList, WM_DESTROY, 0, 0);
+ WindowList_Destroy(hWindowList);
+ }
return 0;
}
@@ -413,7 +415,7 @@ int LoadHistoryModule(void)
Menu_AddContactMenuItem(&mi);
CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, UserHistoryCommand);
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
HookEvent(ME_DB_CONTACT_DELETED, HistoryContactDelete);
HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdownHistoryModule);
return 0;
diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp
index eae566e402..ee096ac8df 100644
--- a/src/core/stdurl/url.cpp
+++ b/src/core/stdurl/url.cpp
@@ -138,9 +138,10 @@ static int SRUrlShutdown(WPARAM, LPARAM)
if (hContactDeleted)
UnhookEvent(hContactDeleted);
- if (hUrlWindowList)
- WindowList_BroadcastAsync(hUrlWindowList, WM_CLOSE, 0, 0);
-
+ if (hUrlWindowList) {
+ WindowList_Broadcast(hUrlWindowList, WM_CLOSE, 0, 0);
+ WindowList_Destroy(hUrlWindowList);
+ }
return 0;
}
@@ -155,7 +156,7 @@ int UrlContactDeleted(WPARAM wParam, LPARAM)
int LoadSendRecvUrlModule(void)
{
- hUrlWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hUrlWindowList = WindowList_Create();
HookEvent(ME_SYSTEM_MODULESLOADED, SRUrlModulesLoaded);
HookEvent(ME_DB_EVENT_ADDED, UrlEventAdded);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SRUrlPreBuildMenu);
diff --git a/src/core/stduserinfo/userinfo.cpp b/src/core/stduserinfo/userinfo.cpp
index bd958a9202..adb844c56e 100644
--- a/src/core/stduserinfo/userinfo.cpp
+++ b/src/core/stduserinfo/userinfo.cpp
@@ -621,6 +621,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP
static int ShutdownUserInfo(WPARAM, LPARAM)
{
WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0);
+ WindowList_Destroy(hWindowList);
return 0;
}
@@ -646,6 +647,6 @@ int LoadUserInfoModule(void)
mi.pszName = LPGEN("View/change my &details...");
Menu_AddMainMenuItem(&mi);
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
return 0;
}
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp
index 0644d3e983..73b77c48f7 100644
--- a/src/modules/chat/chat_svc.cpp
+++ b/src/modules/chat/chat_svc.cpp
@@ -610,6 +610,7 @@ int LoadChatModule(void)
void UnloadChatModule(void)
{
+ FreeMsgLogBitmaps();
OptionsUnInit();
DeleteCriticalSection(&cs);
diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp
index 6e24efeb82..d223f59307 100644
--- a/src/modules/clist/clc.cpp
+++ b/src/modules/clist/clc.cpp
@@ -212,7 +212,7 @@ int LoadCLCModule(void)
g_IconWidth = GetSystemMetrics(SM_CXSMICON);
g_IconHeight = GetSystemMetrics(SM_CYSMICON);
- hClcWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hClcWindowList = WindowList_Create();
hShowInfoTipEvent = CreateHookableEvent(ME_CLC_SHOWINFOTIP);
hHideInfoTipEvent = CreateHookableEvent(ME_CLC_HIDEINFOTIP);
CreateServiceFunction(MS_CLC_SETINFOTIPHOVERTIME, SetInfoTipHoverTime);
@@ -238,6 +238,7 @@ void UnloadClcModule()
if (!bModuleInitialized) return;
mir_free(cli.clcProto);
+ WindowList_Destroy(hClcWindowList);
FreeDisplayNameCache();
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp
index 36815e0a26..deb41b3e90 100644
--- a/src/modules/utils/utils.cpp
+++ b/src/modules/utils/utils.cpp
@@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INT_PTR ResizeDialog(WPARAM wParam, LPARAM lParam);
-void FreeWindowList(void);
-
int InitOpenUrl(void);
int InitWindowList(void);
int InitPathUtils(void);
@@ -493,5 +491,4 @@ void UnloadUtilsModule(void)
return;
UninitCrypt();
- FreeWindowList();
}
diff --git a/src/modules/utils/windowlist.cpp b/src/modules/utils/windowlist.cpp
index 04f5963ca9..1b3c3493ab 100644
--- a/src/modules/utils/windowlist.cpp
+++ b/src/modules/utils/windowlist.cpp
@@ -24,62 +24,79 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
-static WINDOWLISTENTRY *windowList = NULL;
-static int windowListCount = 0;
-static int nextWindowListId = 1;
+struct TWindowListItem
+{
+ TWindowListItem(HANDLE _contact, HWND _wnd) :
+ hContact(_contact),
+ hWnd(_wnd)
+ {}
+
+ HANDLE hContact;
+ HWND hWnd;
+};
+
+typedef OBJLIST<TWindowListItem> TWindowList;
static INT_PTR AllocWindowList(WPARAM, LPARAM)
{
- return nextWindowListId++;
+ return (INT_PTR)new TWindowList(10, HandleKeySortT);
+}
+
+static INT_PTR DestroyWindowList(WPARAM wParam, LPARAM)
+{
+ delete (TWindowList*)wParam;
+ return 0;
}
static INT_PTR AddToWindowList(WPARAM, LPARAM lParam)
{
- windowList = (WINDOWLISTENTRY*)mir_realloc(windowList, sizeof(WINDOWLISTENTRY)*(windowListCount + 1));
- windowList[windowListCount++] = *(WINDOWLISTENTRY*)lParam;
+ WINDOWLISTENTRY *pEntry = (WINDOWLISTENTRY*)lParam;
+ TWindowList *pList = (TWindowList*)pEntry->hList;
+ pList->insert(new TWindowListItem(pEntry->hContact, pEntry->hwnd));
return 0;
}
static INT_PTR RemoveFromWindowList(WPARAM wParam, LPARAM lParam)
{
- for (int i = 0; i < windowListCount; i++)
- if (windowList[i].hwnd == (HWND)lParam && windowList[i].hList == (HANDLE)wParam) {
- MoveMemory(&windowList[i], &windowList[i + 1], sizeof(WINDOWLISTENTRY)*(windowListCount - i - 1));
- windowListCount--;
+ TWindowList &pList = *(TWindowList*)wParam;
+ for (int i = 0; i < pList.getCount(); i++) {
+ if (pList[i].hWnd == (HWND)lParam) {
+ pList.remove(i);
return 0;
}
+ }
return 1;
}
static INT_PTR FindInWindowList(WPARAM wParam, LPARAM lParam)
{
- for (int i = 0; i < windowListCount; i++)
- if (windowList[i].hContact == (HANDLE)lParam && windowList[i].hList == (HANDLE)wParam)
- return (INT_PTR)windowList[i].hwnd;
- return 0;
+ TWindowList &pList = *(TWindowList*)wParam;
+ TWindowListItem *p = pList.find((TWindowListItem*)&lParam);
+ return (p == NULL) ? 0 : (INT_PTR)p->hWnd;
}
static INT_PTR BroadcastToWindowList(WPARAM wParam, LPARAM lParam)
{
MSG *msg = (MSG*)lParam;
- for (int i = windowListCount-1; i >= 0; i--)
- if (windowList[i].hList == (HANDLE)wParam)
- SendMessage(windowList[i].hwnd, msg->message, msg->wParam, msg->lParam);
+ TWindowList &pList = *(TWindowList*)wParam;
+ for (int i = pList.getCount()-1; i >= 0; i--)
+ SendMessage(pList[i].hWnd, msg->message, msg->wParam, msg->lParam);
return 0;
}
static INT_PTR BroadcastToWindowListAsync(WPARAM wParam, LPARAM lParam)
{
MSG *msg = (MSG*)lParam;
- for (int i = windowListCount - 1; i >= 0; i--)
- if (windowList[i].hList == (HANDLE)wParam)
- PostMessage(windowList[i].hwnd, msg->message, msg->wParam, msg->lParam);
+ TWindowList &pList = *(TWindowList*)wParam;
+ for (int i = pList.getCount()-1; i >= 0; i--)
+ PostMessage(pList[i].hWnd, msg->message, msg->wParam, msg->lParam);
return 0;
}
int InitWindowList(void)
{
CreateServiceFunction(MS_UTILS_ALLOCWINDOWLIST, AllocWindowList);
+ CreateServiceFunction(MS_UTILS_DESTROYWINDOWLIST, DestroyWindowList);
CreateServiceFunction(MS_UTILS_ADDTOWINDOWLIST, AddToWindowList);
CreateServiceFunction(MS_UTILS_REMOVEFROMWINDOWLIST, RemoveFromWindowList);
CreateServiceFunction(MS_UTILS_BROADCASTTOWINDOWLIST, BroadcastToWindowList);
@@ -87,13 +104,3 @@ int InitWindowList(void)
CreateServiceFunction(MS_UTILS_FINDWINDOWINLIST, FindInWindowList);
return 0;
}
-
-void FreeWindowList(void)
-{
- if (windowList) {
- mir_free(windowList);
- windowList = NULL;
- }
- windowListCount = 0;
- nextWindowListId = 1;
-}