diff options
48 files changed, 259 insertions, 177 deletions
diff --git a/include/m_utils.h b/include/m_utils.h index 217eafcac9..b23cd1cdf2 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -136,15 +136,27 @@ struct CountryListEntry { /******************************* Window lists *******************************/
-//allocate a window list v0.1.0.1+
-//wParam = lParam = 0
-//returns a handle to the new window list
+// allocates a window list
+// wParam = lParam = 0 (unused)
+// returns a handle to the new window list
#define MS_UTILS_ALLOCWINDOWLIST "Utils/AllocWindowList"
+__forceinline HANDLE WindowList_Create(void)
+{ return (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+}
-//adds a window to the specified window list v0.1.0.1+
-//wParam = 0
-//lParam = (LPARAM)(WINDOWLISTENTRY*)&wle
-//returns 0 on success, nonzero on failure
+// destroys a window list
+// wParam = (HANDLE) window list handle
+// lParam = 0 (unused)
+// returns a handle to the new window list
+#define MS_UTILS_DESTROYWINDOWLIST "Utils/DestroyWindowList"
+__forceinline HANDLE WindowList_Destroy(HANDLE hList)
+{ return (HANDLE)CallService(MS_UTILS_DESTROYWINDOWLIST, (WPARAM)hList, 0);
+}
+
+// adds a window to the specified window list
+// wParam = 0
+// lParam = (LPARAM)(WINDOWLISTENTRY*)&wle
+// returns 0 on success, nonzero on failure
typedef struct {
HANDLE hList;
HWND hwnd;
@@ -156,29 +168,30 @@ __forceinline INT_PTR WindowList_Add(HANDLE hList, HWND hwnd, HANDLE hContact) { wle.hList = hList; wle.hwnd = hwnd; wle.hContact = hContact;
return CallService(MS_UTILS_ADDTOWINDOWLIST, 0, (LPARAM)&wle);
}
-//removes a window from the specified window list v0.1.0.1+
-//wParam = (WPARAM)(HANDLE)hList
-//lParam = (LPARAM)(HWND)hwnd
-//returns 0 on success, nonzero on failure
+
+// removes a window from the specified window list
+// wParam = (WPARAM)(HANDLE)hList
+// lParam = (LPARAM)(HWND)hwnd
+// returns 0 on success, nonzero on failure
#define MS_UTILS_REMOVEFROMWINDOWLIST "Utils/RemoveFromWindowList"
__forceinline INT_PTR WindowList_Remove(HANDLE hList, HWND hwnd) {
return CallService(MS_UTILS_REMOVEFROMWINDOWLIST, (WPARAM)hList, (LPARAM)hwnd);
}
-//finds a window given the hContact v0.1.0.1+
-//wParam = (WPARAM)(HANDLE)hList
-//lParam = (WPARAM)(HANDLE)hContact
-//returns the window handle on success, or NULL on failure
+// finds a window given the hContact
+// wParam = (WPARAM)(HANDLE)hList
+// lParam = (WPARAM)(HANDLE)hContact
+// returns the window handle on success, or NULL on failure
#define MS_UTILS_FINDWINDOWINLIST "Utils/FindWindowInList"
__forceinline HWND WindowList_Find(HANDLE hList, HANDLE hContact) {
return (HWND)CallService(MS_UTILS_FINDWINDOWINLIST, (WPARAM)hList, (LPARAM)hContact);
}
-//broadcasts a message to all windows in a list v0.1.0.1+
-//wParam = (WPARAM)(HANDLE)hList
-//lParam = (LPARAM)(MSG*)&msg
-//returns 0 on success, nonzero on failure
-//Only msg.message, msg.wParam and msg.lParam are used
+// sends a message to all windows in a list using SendMessage
+// wParam = (WPARAM)(HANDLE)hList
+// lParam = (LPARAM)(MSG*)&msg
+// returns 0 on success, nonzero on failure
+// Only msg.message, msg.wParam and msg.lParam are used
#define MS_UTILS_BROADCASTTOWINDOWLIST "Utils/BroadcastToWindowList"
__forceinline INT_PTR WindowList_Broadcast(HANDLE hList, UINT message, WPARAM wParam, LPARAM lParam) {
MSG msg;
@@ -186,17 +199,11 @@ __forceinline INT_PTR WindowList_Broadcast(HANDLE hList, UINT message, WPARAM wP return CallService(MS_UTILS_BROADCASTTOWINDOWLIST, (WPARAM)hList, (LPARAM)&msg);
}
-/*
- Description: Broadcast a message to all windows in the given list using PostMessage()
- Version: 0.3.0.0+
- Inline helper: WindowList_BroadcastAsync
-
- wParam = (WPARAM)(HANDLE)hList
- lParam = (LPARAM)(MSG*)&msg
-
- Returns 0 on success, nonzero on failure, this service does not fail, even if PostMessage() fails for whatever reason
-
-*/
+// sends a message to all windows in a list using PostMessage
+// wParam = (WPARAM)(HANDLE)hList
+// lParam = (LPARAM)(MSG*)&msg
+// returns 0 on success, nonzero on failure
+// Only msg.message, msg.wParam and msg.lParam are used
#define MS_UTILS_BROADCASTTOWINDOWLIST_ASYNC "Utils/BroadcastToWindowListAsync"
__forceinline INT_PTR WindowList_BroadcastAsync(HANDLE hList, UINT message, WPARAM wParam, LPARAM lParam) {
diff --git a/plugins/Alarms/src/alarm_win.cpp b/plugins/Alarms/src/alarm_win.cpp index 67f8c38958..8d67041b60 100644 --- a/plugins/Alarms/src/alarm_win.cpp +++ b/plugins/Alarms/src/alarm_win.cpp @@ -403,7 +403,7 @@ int AlarmWinModulesLoaded(WPARAM wParam, LPARAM lParam) void InitAlarmWin()
{
- hAlarmWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hAlarmWindowList = WindowList_Create();
HookEvent(ME_SYSTEM_MODULESLOADED, AlarmWinModulesLoaded);
}
@@ -411,6 +411,7 @@ void InitAlarmWin() void DeinitAlarmWin()
{
WindowList_Broadcast(hAlarmWindowList, WM_COMMAND, IDC_SNOOZE, 0);
+ WindowList_Destroy(hAlarmWindowList);
if (hBackgroundBrush) DeleteObject(hBackgroundBrush);
if (hTitleFont) DeleteObject(hTitleFont);
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 721c3a89f5..cc6b049e70 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -357,7 +357,7 @@ extern "C" __declspec(dllexport) int Load(void) SkinAddNewSoundExT("avatar_changed",LPGENT("Avatar History"),LPGENT("Contact changed avatar"));
SkinAddNewSoundExT("avatar_removed",LPGENT("Avatar History"),LPGENT("Contact removed avatar"));
- hAvatarWindowsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hAvatarWindowsList = WindowList_Create();
SetupIcoLib();
InitMenuItem();
@@ -366,5 +366,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hAvatarWindowsList);
return 0;
}
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp index 83f7965ad4..cbca095e37 100644 --- a/plugins/BuddyPounce/src/main.cpp +++ b/plugins/BuddyPounce/src/main.cpp @@ -242,7 +242,7 @@ extern "C" __declspec(dllexport) int Load(void) HookEvent(ME_OPT_INITIALISE, BuddyPounceOptInit);
HookEvent(ME_PROTO_ACK, MsgAck);
CreateServiceFunction("BuddyPounce/MenuCommand", BuddyPounceMenuCommand);
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
/* service funcitons for other devs... */
CreateServiceFunction("BuddyPounce/AddSimplePounce", AddSimpleMessage); // add a simple pounce to a contact
@@ -255,5 +255,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hWindowList);
return 0;
}
diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 5f7b6cbf0e..7d8eb47536 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -267,6 +267,7 @@ HRESULT PreLoadContactListModule(); HRESULT ClcLoadModule();
HRESULT ToolbarLoadModule();
HRESULT ToolbarButtonLoadModule();
+void ToolbarButtonUnloadModule();
// INTERFACES
diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index bf39b955a6..7736c45cf6 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -110,6 +110,7 @@ extern "C" __declspec(dllexport) int Unload(void) if (IsWindow(pcli->hwndContactList)) DestroyWindow(pcli->hwndContactList);
pcli->hwndContactList = NULL;
+ ToolbarButtonUnloadModule();
BackgroundsUnloadModule();
SkinEngineUnloadModule();
XPThemesUnloadModule();
diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index 9d55684139..d9f4fd9e47 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -478,8 +478,13 @@ int Buttons_OnSkinModeSettingsChanged(WPARAM wParam, LPARAM lParam) HRESULT ToolbarButtonLoadModule()
{
- hButtonWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hButtonWindowList = WindowList_Create();
hIconChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
hBkgChangedHook = HookEvent(ME_BACKGROUNDCONFIG_CHANGED,Buttons_OnSkinModeSettingsChanged);
return S_OK;
}
+
+void ToolbarButtonUnloadModule()
+{
+ WindowList_Destroy(hButtonWindowList);
+}
\ No newline at end of file diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index ff5e1df8e6..2e3c9a8f39 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -365,7 +365,7 @@ static INT_PTR SetContactIgnore(WPARAM wParam, LPARAM lParam) HWND hWnd = 0;
if (hWindowListIGN == 0)
- hWindowListIGN = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowListIGN = WindowList_Create();
hWnd = WindowList_Find(hWindowListIGN, (HANDLE)wParam);
if ( wParam ) {
@@ -411,4 +411,5 @@ int InitCustomMenus(void) void UninitCustomMenus(void)
{
+ WindowList_Destroy(hWindowListIGN);
}
diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp index 4590e10d12..7b20a0ace1 100644 --- a/plugins/ContactsPlus/src/main.cpp +++ b/plugins/ContactsPlus/src/main.cpp @@ -149,9 +149,6 @@ static int HookModulesLoaded(WPARAM wParam, LPARAM lParam) HookEvent(ME_CLIST_PREBUILDCONTACTMENU, HookPreBuildContactMenu);
- ghSendWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); // no need to destroy this
- ghRecvWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); // no need to destroy this
-
ProcessUnreadEvents();
return 0;
}
@@ -215,6 +212,9 @@ extern "C" __declspec(dllexport) int Load(void) InitCommonControls();
+ ghSendWindowList = WindowList_Create();
+ ghRecvWindowList = WindowList_Create();
+
//init hooks
HookEvent(ME_SYSTEM_MODULESLOADED, HookModulesLoaded);
HookEvent(ME_DB_EVENT_ADDED, HookDBEventAdded);
@@ -233,5 +233,7 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(ghSendWindowList);
+ WindowList_Destroy(ghRecvWindowList);
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index d45c37eaa8..d30458249c 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -262,7 +262,7 @@ STDMETHODIMP_(BOOL) CDb3Base::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) return 1;
memcpy(dbei->pBlob, pBlob, bytesToCopy);
- if (bytesToCopy > len)
+ if (bytesToCopy > (int)len)
memset(dbei->pBlob + len, 0, bytesToCopy - len);
mir_free(pBlob);
}
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index 9339b613ae..5bb306246c 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -74,6 +74,9 @@ TCHAR g_filter[1024] = {0}; Options g_Options = {0};
+static HANDLE hDialogsList = NULL;
+static HANDLE hContactToActivate = NULL;
+
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
g_hInst = hinstDLL;
@@ -318,9 +321,12 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hDialogsList);
+
if (g_hwndMenuHost) DestroyWindow(g_hwndMenuHost);
if (g_Options.hfntName) DeleteObject(g_Options.hfntName);
if (g_Options.hfntSecond) DeleteObject(g_Options.hfntSecond);
+
delete g_contactCache;
return 0;
}
@@ -884,9 +890,6 @@ INT_PTR svcShowMenuCentered(WPARAM wParam, LPARAM lParam) return 0;
}
-static HANDLE hDialogsList = NULL;
-static HANDLE hContactToActivate = NULL;
-
INT_PTR svcOpenContact(WPARAM wParam, LPARAM lParam)
{
hContactToActivate = (HANDLE)wParam;
@@ -900,7 +903,7 @@ int ProcessSrmmEvent( WPARAM wParam, LPARAM lParam ) if (event->uType == MSG_WINDOW_EVT_OPEN) {
if ( !hDialogsList )
- hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hDialogsList = WindowList_Create();
WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);
BYTE fav = db_get_b(event->hContact, "FavContacts", "IsFavourite", 0);
diff --git a/plugins/FileAsMessage/src/main.cpp b/plugins/FileAsMessage/src/main.cpp index 7574748758..247072897c 100644 --- a/plugins/FileAsMessage/src/main.cpp +++ b/plugins/FileAsMessage/src/main.cpp @@ -196,7 +196,7 @@ extern "C" __declspec(dllexport) int Load(void) Icon_Register(hInst, "fileAsMessage", iconList, SIZEOF(iconList));
- hFileList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hFileList = WindowList_Create();
CreateServiceFunction(SERVICE_NAME PSR_MESSAGE, OnRecvMessage);
CreateServiceFunction(SERVICE_NAME "/FESendFile", OnSendFile);
@@ -221,8 +221,7 @@ extern "C" __declspec(dllexport) int Load(void) //
extern "C" __declspec(dllexport) int Unload(void)
{
-// if(hFileList)
-// WindowList_Broadcast(hFileList, WM_CLOSE, 0,0);
+ WindowList_Destroy(hFileList);
if(hHookSkinIconsChanged != NULL)
UnhookEvent(hHookSkinIconsChanged);
UnhookEvent(hHookDbSettingChange);
diff --git a/plugins/HistoryLinkListPlus/src/linklist.cpp b/plugins/HistoryLinkListPlus/src/linklist.cpp index 84a9b56bfc..c9f96d3a29 100644 --- a/plugins/HistoryLinkListPlus/src/linklist.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist.cpp @@ -76,7 +76,7 @@ extern "C" __declspec(dllexport) int Load(void) mi.pszService = "Linklist/MenuCommand";
Menu_AddContactMenuItem(&mi);
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
WNDCLASS wndclass = { 0 };
wndclass.style = CS_HREDRAW | CS_VREDRAW;
@@ -103,6 +103,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hWindowList);
DestroyCursor(splitCursor);
return 0;
}
diff --git a/plugins/Msg_Export/src/main.cpp b/plugins/Msg_Export/src/main.cpp index 1ecde886e5..898eb2c5c6 100755 --- a/plugins/Msg_Export/src/main.cpp +++ b/plugins/Msg_Export/src/main.cpp @@ -220,7 +220,7 @@ extern "C" __declspec(dllexport) int Load() if ( !hServiceFunñ)
hServiceFunñ = CreateServiceFunction(MS_SHOW_EXPORT_HISTORY, ShowExportHistory);
- hInternalWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hInternalWindowList = WindowList_Create();
return 0;
}
@@ -239,6 +239,7 @@ extern "C" __declspec(dllexport) int Load() extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hInternalWindowList);
Uninitilize();
bUseInternalViewer(false);
return 0;
diff --git a/plugins/NewsAggregator/Src/NewsAggregator.cpp b/plugins/NewsAggregator/Src/NewsAggregator.cpp index cb6ca96129..e1bd14eba6 100644 --- a/plugins/NewsAggregator/Src/NewsAggregator.cpp +++ b/plugins/NewsAggregator/Src/NewsAggregator.cpp @@ -65,7 +65,7 @@ extern "C" __declspec(dllexport) int Load(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, NewsAggrPreShutdown);
hUpdateMutex = CreateMutex(NULL, FALSE, NULL);
- hChangeFeedDlgList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+ hChangeFeedDlgList = WindowList_Create();
// register weather protocol
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
@@ -94,6 +94,7 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hChangeFeedDlgList);
DestroyUpdateList();
CloseHandle(hUpdateMutex);
return 0;
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index 50972b1b36..8523cdf518 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -446,6 +446,7 @@ MIRAPI int Unload(void) UnloadPopupThread();
UnloadPopupWnd2();
PopupHistoryUnload();
+ SrmmMenu_Unload();
UnregisterClass (MAKEINTATOM(g_wndClass.cPopupWnd2),hInst);
UnregisterClassW(L"PopupEditBox",hInst);
diff --git a/plugins/Popup/src/srmm_menu.cpp b/plugins/Popup/src/srmm_menu.cpp index cf4d75738c..ae757444a3 100644 --- a/plugins/Popup/src/srmm_menu.cpp +++ b/plugins/Popup/src/srmm_menu.cpp @@ -54,7 +54,7 @@ static int SrmmMenu_ProcessEvent(WPARAM, LPARAM lParam) if (mwevent->uType == MSG_WINDOW_EVT_OPEN) {
if (!hDialogsList)
- hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hDialogsList = WindowList_Create();
WindowList_Add(hDialogsList, mwevent->hwndWindow, mwevent->hContact);
SrmmMenu_UpdateIcon(mwevent->hContact);
@@ -131,3 +131,8 @@ void SrmmMenu_Load() HookEvent(ME_MSG_ICONPRESSED, SrmmMenu_ProcessIconClick);
HookEvent(ME_MSG_WINDOWEVENT, SrmmMenu_ProcessEvent);
}
+
+void SrmmMenu_Unload()
+{
+ WindowList_Destroy(hDialogsList);
+}
diff --git a/plugins/Popup/src/srmm_menu.h b/plugins/Popup/src/srmm_menu.h index 67ea73cc12..c64d3b303c 100644 --- a/plugins/Popup/src/srmm_menu.h +++ b/plugins/Popup/src/srmm_menu.h @@ -25,5 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __srmm_menu_h__
void SrmmMenu_Load();
+void SrmmMenu_Unload();
#endif // __srmm_menu_h__
diff --git a/plugins/Quotes/src/ModuleInfo.cpp b/plugins/Quotes/src/ModuleInfo.cpp index 1d453d2b5c..27850fd8ef 100644 --- a/plugins/Quotes/src/ModuleInfo.cpp +++ b/plugins/Quotes/src/ModuleInfo.cpp @@ -32,11 +32,9 @@ HANDLE CModuleInfo::GetWindowList(const std::string& rsKey,bool bAllocateIfNonEx }
else if(bAllocateIfNonExist)
{
- hResult = reinterpret_cast<HANDLE>(CallService(MS_UTILS_ALLOCWINDOWLIST,0,0));
+ hResult = WindowList_Create();
if(hResult)
- {
m_ahWindowLists.insert(std::make_pair(rsKey,hResult));
- }
}
return hResult;
diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index 0f66c5587a..d1d129039f 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -532,7 +532,7 @@ extern "C" __declspec(dllexport) int Load(void) mir_getLP( &pluginInfo );
CoInitialize(NULL);
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
Icon_Register(hInst, msLastUC_ShowListName, &icon, 1);
@@ -552,6 +552,7 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
+ WindowList_Destroy(hWindowList);
CoUninitialize();
return 0;
}
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index a090f90916..dcb1ec887f 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -232,8 +232,8 @@ void InitGlobals() HDC hdc = GetDC(NULL);
ZeroMemory(&g_dat, sizeof(struct GlobalMessageData));
- g_dat.hMessageWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
- g_dat.hParentWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ g_dat.hMessageWindowList = WindowList_Create();
+ g_dat.hParentWindowList = WindowList_Create();
HookEvent(ME_PROTO_ACK, ackevent);
ReloadGlobals();
@@ -273,6 +273,9 @@ void FreeGlobals() if (g_dat.hMenuANSIEncoding)
DestroyMenu(g_dat.hMenuANSIEncoding);
mir_free(g_dat.tabIconListUsage);
+
+ WindowList_Destroy(g_dat.hMessageWindowList);
+ WindowList_Destroy(g_dat.hParentWindowList);
ZeroMemory(&g_dat, sizeof(g_dat));
}
diff --git a/plugins/SeenPlugin/src/history.cpp b/plugins/SeenPlugin/src/history.cpp index b431531830..bb269830a7 100644 --- a/plugins/SeenPlugin/src/history.cpp +++ b/plugins/SeenPlugin/src/history.cpp @@ -298,5 +298,10 @@ void ShowHistory(HANDLE hContact, BYTE isAlert) void InitHistoryDialog(void)
{
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+ hWindowList = WindowList_Create();
}
+
+void UninitHistoryDialog(void)
+{
+ WindowList_Destroy(hWindowList);
+}
\ No newline at end of file diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp index d12a3922a1..0fc5128622 100644 --- a/plugins/SeenPlugin/src/main.cpp +++ b/plugins/SeenPlugin/src/main.cpp @@ -50,6 +50,7 @@ BOOL includeIdle; LIST<logthread_info> arContacts(16, HandleKeySortT);
CRITICAL_SECTION csContacts;
+void UninitHistoryDialog(void);
int MainInit(WPARAM,LPARAM)
{
@@ -113,6 +114,7 @@ extern "C" __declspec(dllexport) int Unload(void) DeleteCriticalSection(&csContacts);
CloseHandle(g_hShutdownEvent);
+ UninitHistoryDialog();
return 0;
}
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index d4efe1478c..991384b69a 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -405,16 +405,21 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam) int AwayMsgPreShutdown(void)
{
- if (hWindowList) WindowList_BroadcastAsync(hWindowList, WM_CLOSE, 0, 0);
- if (hWindowList2) WindowList_BroadcastAsync(hWindowList2, WM_CLOSE, 0, 0);
-
+ if (hWindowList) {
+ WindowList_Broadcast(hWindowList, WM_CLOSE, 0, 0);
+ WindowList_Destroy(hWindowList);
+ }
+ if (hWindowList2) {
+ WindowList_Broadcast(hWindowList2, WM_CLOSE, 0, 0);
+ WindowList_Destroy(hWindowList2);
+ }
return 0;
}
int LoadAwayMsgModule(void)
{
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
- hWindowList2 = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
+ hWindowList2 = WindowList_Create();
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_TCHAR;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index bd7d9f9bf1..d7c069a011 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -417,6 +417,9 @@ static INT_PTR TypingMessageCommand(WPARAM wParam, LPARAM lParam) int SplitmsgShutdown(void)
{
+ WindowList_Destroy(M.m_hMessageWindowList);
+ WindowList_Destroy(PluginConfig.hUserPrefsWindowList);
+
DestroyCursor(PluginConfig.hCurSplitNS);
DestroyCursor(PluginConfig.hCurHyperlinkHand);
DestroyCursor(PluginConfig.hCurSplitWE);
@@ -563,8 +566,8 @@ int LoadSendRecvMessageModule(void) Win7Taskbar->updateMetrics();
ZeroMemory(&nen_options, sizeof(nen_options));
- M.m_hMessageWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
- PluginConfig.hUserPrefsWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ M.m_hMessageWindowList = WindowList_Create();
+ PluginConfig.hUserPrefsWindowList = WindowList_Create();
sendQueue = new SendQueue;
Skin = new CSkin;
sendLater = new CSendLater;
diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp index 8d0793e9ca..a5ee6aa901 100644 --- a/plugins/TabSRMM/src/typingnotify.cpp +++ b/plugins/TabSRMM/src/typingnotify.cpp @@ -520,7 +520,7 @@ int TN_OptionsInitialize(WPARAM wParam, LPARAM lParam) int TN_ModuleInit()
{
- hPopupsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hPopupsList = WindowList_Create();
OnePopup = M.GetByte(Module, SET_ONEPOPUP, DEF_ONEPOPUP);
ShowMenu = M.GetByte(Module, SET_SHOWDISABLEMENU, DEF_SHOWDISABLEMENU);
@@ -567,6 +567,7 @@ int TN_ModuleInit() int TN_ModuleDeInit()
{
+ WindowList_Destroy(hPopupsList);
db_set_b(0, Module, SET_DISABLED, (BYTE) (Disabled | StartDisabled | StopDisabled));
return 0;
}
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 0a5f314f70..bade430b5a 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -1221,7 +1221,7 @@ LRESULT CWarning::show(const int uId, DWORD dwFlags, const wchar_t* tszTxt) wchar_t* _s = 0;
if (0 == hWindowList)
- hWindowList = reinterpret_cast<HANDLE>(::CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0));
+ hWindowList = WindowList_Create();
/*
* don't open new warnings when shutdown was initiated (modal ones will otherwise
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index b206b7561f..978da21f4f 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -619,6 +619,7 @@ void DlgContactInfoInitTreeIcons() **/
void DlgContactInfoUnLoadModule()
{
+ WindowList_Destroy(ghWindowList);
DestroyHookableEvent(ghDetailsInitEvent);
}
@@ -638,7 +639,7 @@ void DlgContactInfoLoadModule() HookEvent(ME_DB_CONTACT_DELETED, OnDeleteContact);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
HookEvent(ME_USERINFO_INITIALISE, InitDetails);
- ghWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ ghWindowList = WindowList_Create();
// check whether changing my details via UserInfoEx is basically possible
{
diff --git a/plugins/Weather/src/weather.cpp b/plugins/Weather/src/weather.cpp index e477f1d14e..f93dded751 100644 --- a/plugins/Weather/src/weather.cpp +++ b/plugins/Weather/src/weather.cpp @@ -136,8 +136,8 @@ int WeatherInit(WPARAM wParam,LPARAM lParam) HookEvent(ME_TTB_MODULELOADED, OnToolbarLoaded);
- hDataWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
- hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+ hDataWindowList = WindowList_Create();
+ hWindowList = WindowList_Create();
return 0;
}
@@ -173,6 +173,9 @@ extern "C" int __declspec(dllexport) Unload(void) DestroyOptions();
DestroyWIList(); // unload all ini data from memory
+ WindowList_Destroy(hDataWindowList);
+ WindowList_Destroy(hWindowList);
+
CloseHandle(hUpdateMutex);
return 0;
}
diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp index 0d4ba8317a..6ccbfb19f0 100644 --- a/plugins/Weather/src/weather_mwin.cpp +++ b/plugins/Weather/src/weather_mwin.cpp @@ -325,56 +325,52 @@ void InitMwin(void) if ( !ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
return;
- hMwinWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
-
- {
- WNDCLASS wndclass;
- wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
- wndclass.lpfnWndProc = wndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
- wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = _T("WeatherFrame");
- RegisterClass(&wndclass);
- }
-
- {
- ColourIDT colourid = {0};
- colourid.cbSize = sizeof(ColourIDT);
- strcpy(colourid.dbSettingsGroup, WEATHERPROTONAME);
- strcpy(colourid.setting, "ColorMwinFrame");
- _tcscpy(colourid.name, LPGENT("Frame Background"));
- _tcscpy(colourid.group, _T(WEATHERPROTONAME));
- colourid.defcolour = GetSysColor(COLOR_3DFACE);
- ColourRegisterT(&colourid);
-
- FontIDT fontid = {0};
- fontid.cbSize = sizeof(FontIDT);
- fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
- strcpy(fontid.dbSettingsGroup, WEATHERPROTONAME);
- _tcscpy(fontid.group, _T(WEATHERPROTONAME));
- _tcscpy(fontid.name, LPGENT("Frame Font"));
- strcpy(fontid.prefix, "fnt0");
-
- HDC hdc = GetDC(NULL);
- fontid.deffontsettings.size = -13;
- ReleaseDC(0, hdc);
-
- fontid.deffontsettings.charset = DEFAULT_CHARSET;
- _tcscpy(fontid.deffontsettings.szFace, _T("Verdana"));
- _tcscpy(fontid.backgroundGroup, _T(WEATHERPROTONAME));
- _tcscpy(fontid.backgroundName, LPGENT("Frame Background"));
- FontRegisterT(&fontid);
-
- fontid.deffontsettings.style = DBFONTF_BOLD;
- _tcscpy(fontid.name, LPGENT("Frame Title Font"));
- strcpy(fontid.prefix, "fnt1");
- FontRegisterT(&fontid);
- }
+ hMwinWindowList = WindowList_Create();
+
+ WNDCLASS wndclass;
+ wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
+ wndclass.lpfnWndProc = wndProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = _T("WeatherFrame");
+ RegisterClass(&wndclass);
+
+ ColourIDT colourid = {0};
+ colourid.cbSize = sizeof(ColourIDT);
+ strcpy(colourid.dbSettingsGroup, WEATHERPROTONAME);
+ strcpy(colourid.setting, "ColorMwinFrame");
+ _tcscpy(colourid.name, LPGENT("Frame Background"));
+ _tcscpy(colourid.group, _T(WEATHERPROTONAME));
+ colourid.defcolour = GetSysColor(COLOR_3DFACE);
+ ColourRegisterT(&colourid);
+
+ FontIDT fontid = {0};
+ fontid.cbSize = sizeof(FontIDT);
+ fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
+ strcpy(fontid.dbSettingsGroup, WEATHERPROTONAME);
+ _tcscpy(fontid.group, _T(WEATHERPROTONAME));
+ _tcscpy(fontid.name, LPGENT("Frame Font"));
+ strcpy(fontid.prefix, "fnt0");
+
+ HDC hdc = GetDC(NULL);
+ fontid.deffontsettings.size = -13;
+ ReleaseDC(0, hdc);
+
+ fontid.deffontsettings.charset = DEFAULT_CHARSET;
+ _tcscpy(fontid.deffontsettings.szFace, _T("Verdana"));
+ _tcscpy(fontid.backgroundGroup, _T(WEATHERPROTONAME));
+ _tcscpy(fontid.backgroundName, LPGENT("Frame Background"));
+ FontRegisterT(&fontid);
+
+ fontid.deffontsettings.style = DBFONTF_BOLD;
+ _tcscpy(fontid.name, LPGENT("Frame Title Font"));
+ strcpy(fontid.prefix, "fnt1");
+ FontRegisterT(&fontid);
for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME))
if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0))
@@ -391,5 +387,6 @@ void DestroyMwin(void) CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
}
UnregisterClass( _T("WeatherFrame"), hInst);
+ WindowList_Destroy(hMwinWindowList);
UnhookEvent(hFontHook);
}
diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp index bacec0184a..a627aec43b 100644 --- a/plugins/WebView/src/main.cpp +++ b/plugins/WebView/src/main.cpp @@ -144,6 +144,7 @@ extern "C" int __declspec(dllexport) Unload(void) DeleteObject(h_font);
if (hMenu)
DestroyMenu(hMenu);
+ WindowList_Destroy(hWindowList);
return 0;
}
@@ -153,7 +154,6 @@ extern "C" int __declspec(dllexport) Load() mir_getLP(&pluginInfoEx);
mir_getCLI();
-
HookEvent(ME_CLIST_DOUBLECLICKED, Doubleclick);
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT));
@@ -313,7 +313,7 @@ extern "C" int __declspec(dllexport) Load() mi.ptszName = LPGENT("Stop data processing");
Menu_AddContactMenuItem(&mi);
- hWindowList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hWindowList = WindowList_Create();
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChanged);
diff --git a/plugins/WhenWasIt/src/WhenWasIt.cpp b/plugins/WhenWasIt/src/WhenWasIt.cpp index 022b5cf589..496becd813 100644 --- a/plugins/WhenWasIt/src/WhenWasIt.cpp +++ b/plugins/WhenWasIt/src/WhenWasIt.cpp @@ -67,7 +67,7 @@ extern "C" int __declspec(dllexport) Load(void) Log("%s", "Hooking events ...");
HookEvents();
- hAddBirthdayWndsList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hAddBirthdayWndsList = WindowList_Create();
Log("%s", "Leaving function " __FUNCTION__);
@@ -85,6 +85,7 @@ extern "C" int __declspec(dllexport) Unload() SendMessage(hUpcomingDlg, WM_CLOSE, 0, 0);
WindowList_Broadcast(hAddBirthdayWndsList, WM_CLOSE, 0, 0);
+ WindowList_Destroy(hAddBirthdayWndsList);
Log("%s", "Killing timers ...");
KillTimers();
diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 71178febd6..6f63acaa3b 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -175,7 +175,7 @@ extern "C" int __declspec(dllexport) Load() CreateServiceFunction("XSoundNotify/ContactMenuCommand", ShowDialog);
- hChangeSoundDlgList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hChangeSoundDlgList = WindowList_Create();
HookEvent(ME_PROTO_ACK, ProtoAck);
HookEvent(ME_OPT_INITIALISE, OptInit);
@@ -189,5 +189,6 @@ extern "C" int __declspec(dllexport) Load() extern "C" int __declspec(dllexport) Unload(void)
{
+ WindowList_Destroy(hChangeSoundDlgList);
return 0;
}
diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp index 1f26449162..c26653813b 100644 --- a/plugins/YAMN/src/main.cpp +++ b/plugins/YAMN/src/main.cpp @@ -313,8 +313,8 @@ extern "C" int __declspec(dllexport) Load(void) optDateTime = db_get_b(NULL, YAMN_DBMODULE, YAMN_DBTIMEOPTIONS, optDateTime);
// Create new window queues for broadcast messages
- YAMNVar.MessageWnds = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
- YAMNVar.NewMailAccountWnd = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ YAMNVar.MessageWnds = WindowList_Create();
+ YAMNVar.NewMailAccountWnd = WindowList_Create();
YAMNVar.Shutdown = FALSE;
hCurSplitNS = LoadCursor(NULL, IDC_SIZENS);
@@ -371,6 +371,10 @@ extern "C" int __declspec(dllexport) Unload(void) #ifdef _DEBUG
UnInitDebug();
#endif
+
+ WindowList_Destroy(YAMNVar.MessageWnds);
+ WindowList_Destroy(YAMNVar.NewMailAccountWnd);
+
DestroyCursor(hCurSplitNS);
DestroyCursor(hCurSplitWE);
diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index c8f45d0f2b..663f68d4c4 100644 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -65,6 +65,7 @@ HANDLE hExtraMood = NULL; HANDLE hExtListInit, hDiscoInfoResult;
void JabberUserInfoInit(void);
+void JabberUserInfoUninit(void);
int bSecureIM, bMirOTR, bNewGPG, bPlatform;
@@ -227,6 +228,8 @@ extern "C" int __declspec(dllexport) Load() extern "C" int __declspec(dllexport) Unload(void)
{
+ JabberUserInfoUninit();
+
DestroyHookableEvent(hExtListInit);
DestroyHookableEvent(hDiscoInfoResult);
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 04a1b8c3be..2d0f0beb0b 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MENUITEM_SERVER 2
#define MENUITEM_RESOURCES 10
+static HANDLE hDialogsList = NULL;
static HANDLE hChooserMenu, hStatusMenuInit;
static int iChooserMenuPos = 30000;
@@ -337,6 +338,8 @@ void g_MenuUninit(void) CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuLogin, 0);
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRefresh, 0);
CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuAddBookmark, 0);
+
+ WindowList_Destroy(hDialogsList);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -966,8 +969,6 @@ void CJabberProto::CheckMenuItems() //////////////////////////////////////////////////////////////////////////
// resource menu
-static HANDLE hDialogsList = NULL;
-
void CJabberProto::MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item)
{
if (item->list != LIST_ROSTER)
@@ -989,7 +990,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) if (event->uType == MSG_WINDOW_EVT_OPEN) {
if (!hDialogsList)
- hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hDialogsList = WindowList_Create();
WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);
ptrT jid(getTStringA(event->hContact, "jid"));
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index bd0800245d..836b016cdd 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -79,7 +79,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) : debugLogA("Setting protocol/module name to '%s'", m_szModuleName);
// Jabber dialog list
- m_windowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ m_windowList = WindowList_Create();
// Protocol services and events...
m_hEventNudge = CreateProtoEvent(PE_NUDGE);
@@ -170,6 +170,8 @@ CJabberProto::~CJabberProto() delete m_pInfoFrame;
+ WindowList_Destroy(m_windowList);
+
DestroyHookableEvent(m_hEventNudge);
DestroyHookableEvent(m_hEventXStatusIconChanged);
DestroyHookableEvent(m_hEventXStatusChanged);
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 77262da4f2..bb85ac1f74 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -833,7 +833,12 @@ int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) void JabberUserInfoInit()
{
- hUserInfoList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ hUserInfoList = WindowList_Create();
+}
+
+void JabberUserInfoUninit()
+{
+ WindowList_Destroy(hUserInfoList);
}
/////////////////////////////////////////////////////////////////////////////////////////
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;
-}
|