From d7b15f5f89319f1a9077efb50bd3a242a5dc2b52 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 20 Feb 2013 16:03:04 +0000 Subject: fixes for various hangups & crashes on exit git-svn-id: http://svn.miranda-ng.org/main/trunk@3652 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/src/IEView.cpp | 1 + plugins/Popup/src/actions.cpp | 56 +++------ plugins/Popup/src/common.h | 2 +- plugins/Popup/src/config.h | 7 -- plugins/Popup/src/effects.cpp | 4 +- plugins/Popup/src/font.cpp | 2 +- plugins/Popup/src/headers.h | 1 - plugins/Popup/src/history.cpp | 2 +- plugins/Popup/src/main.cpp | 215 +++++++++++--------------------- plugins/Popup/src/notifications.cpp | 6 +- plugins/Popup/src/opt_adv.cpp | 28 ++--- plugins/Popup/src/opt_class.cpp | 8 +- plugins/Popup/src/opt_contacts.cpp | 4 +- plugins/Popup/src/opt_gen.cpp | 12 +- plugins/Popup/src/opt_skins.cpp | 4 +- plugins/Popup/src/opttree.cpp | 23 +--- plugins/Popup/src/popup_thread.cpp | 18 +-- plugins/Popup/src/popup_wnd2.cpp | 35 +++--- plugins/Popup/src/services.cpp | 16 +-- plugins/TabSRMM/src/chat/window.cpp | 74 ++++++----- protocols/JabberG/src/jabber_icolib.cpp | 47 +++++-- protocols/JabberG/src/jabber_menu.cpp | 8 +- 22 files changed, 237 insertions(+), 336 deletions(-) diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index 25eae345a8..c5bd59681b 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -367,6 +367,7 @@ void IEView::init() { } void IEView::release() { + if (!isInited) return; EnterCriticalSection(&mutex); while (list != NULL) { delete list; diff --git a/plugins/Popup/src/actions.cpp b/plugins/Popup/src/actions.cpp index 72abf53be8..d0ed93e550 100644 --- a/plugins/Popup/src/actions.cpp +++ b/plugins/Popup/src/actions.cpp @@ -108,39 +108,39 @@ DWORD MouseOverride(HWND hCombo, int number) { DWORD dwItem = 0; DWORD ItemActive = 0; - if(number<0 || number >7) + if (number<0 || number >7) number = 0; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("no overwrite")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 0); - if(number == 0) + if (number == 0) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Send message")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 1); - if(number == 1) + if (number == 1) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Quick reply")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 2); - if(number == 2) + if (number == 2) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("User details")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 3); - if(number == 3) + if (number == 3) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Contact menu")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 4); - if(number == 4) + if (number == 4) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dismiss popup")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 5); - if(number == 5) + if (number == 5) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Pin popup")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 6); - if(number == 6) + if (number == 6) ItemActive = dwItem; dwItem = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("Copy to clipboard")); SendMessage(hCombo, CB_SETITEMDATA, dwItem, 7); - if(number == 7) + if (number == 7) ItemActive = dwItem; return ItemActive; } @@ -266,35 +266,19 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM groups.insert(mir_strdup(szGroup), groups.getCount()); } - if (g_popup.isOsUnicode) - { - LVITEMW item = {0}; - item.mask = LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT|LVIF_STATE|LVIF_INDENT; - item.iItem = i; - LPWSTR wszName = mir_a2u(szName); - item.pszText = TranslateW(wszName); - item.iImage = ImageList_AddIcon(hImgList, gActions[i]->lchIcon); - item.lParam = i; - if (IsWinVerXPPlus()) - { - item.mask |= LVIF_GROUPID; - item.iGroupId = grpId; - } - item.iIndent = 0; - ListView_InsertItemW(hwndList, &item); - mir_free(wszName); - } else - { - LVITEMA item = {0}; - item.mask = LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT|LVIF_STATE|LVIF_GROUPID|LVIF_INDENT; - item.iItem = i; - item.pszText = Translate(szName); - item.iImage = ImageList_AddIcon(hImgList, gActions[i]->lchIcon); - item.lParam = i; + LVITEM item = {0}; + item.mask = LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT|LVIF_STATE|LVIF_INDENT; + item.iItem = i; + mir_ptr tszName( mir_a2t(szName)); + item.pszText = TranslateTS(tszName); + item.iImage = ImageList_AddIcon(hImgList, gActions[i]->lchIcon); + item.lParam = i; + if (IsWinVerXPPlus()) { + item.mask |= LVIF_GROUPID; item.iGroupId = grpId; - item.iIndent = 0; - ListView_InsertItem(hwndList, &item); } + item.iIndent = 0; + ListView_InsertItemW(hwndList, &item); ListView_SetItemState(hwndList, i, (gActions[i]->flags & PAF_ENABLED) ? 0x2000 : 0x1000, LVIS_STATEIMAGEMASK); } diff --git a/plugins/Popup/src/common.h b/plugins/Popup/src/common.h index 0f8f571707..3bce58077f 100644 --- a/plugins/Popup/src/common.h +++ b/plugins/Popup/src/common.h @@ -41,7 +41,7 @@ inline void GetBmpSize(HBITMAP hbm, SIZE *sz) } inline void DebugMsg(LPTSTR msg){ - if(PopUpOptions.debug){ + if (PopUpOptions.debug){ MessageBox(NULL, msg, _T("debug"), MB_OK); } } diff --git a/plugins/Popup/src/config.h b/plugins/Popup/src/config.h index 7560223a4e..e13c4c35e0 100644 --- a/plugins/Popup/src/config.h +++ b/plugins/Popup/src/config.h @@ -94,13 +94,6 @@ typedef struct tagPOPUPOPTIONS { WORD MaxPopups; } POPUPOPTIONS; -struct GLOBAL{ - bool isOsUnicode; - bool isMirUnicode; - int MirVer; -}; -extern GLOBAL g_popup; - //===== User wnd class ===== struct GLOBAL_WND_CLASSES{ ATOM cPopupWnd2; diff --git a/plugins/Popup/src/effects.cpp b/plugins/Popup/src/effects.cpp index 69ede49971..c9c5b6800b 100644 --- a/plugins/Popup/src/effects.cpp +++ b/plugins/Popup/src/effects.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h" class MyTestEffect; -HANDLE hSquareFad; class MyTestEffect: public IPopupPlusEffect { @@ -80,6 +79,7 @@ static INT_PTR svcCreateEffect_MyTestEffect(WPARAM, LPARAM) { return (INT_PTR)(n void PopupEfectsInitialize() { - hSquareFad = CreateServiceFunction(MS_POPUP_CREATEVFX "Square fading", svcCreateEffect_MyTestEffect); + CreateServiceFunction(MS_POPUP_CREATEVFX "Square fading", svcCreateEffect_MyTestEffect); + CallService(MS_POPUP_REGISTERVFX, 0, (LPARAM)"Square fading"); } diff --git a/plugins/Popup/src/font.cpp b/plugins/Popup/src/font.cpp index 7a1b367593..6e7026b24a 100644 --- a/plugins/Popup/src/font.cpp +++ b/plugins/Popup/src/font.cpp @@ -133,7 +133,7 @@ void ReloadFonts() //update class popupps(only temp at this point, must rework) char setting[256]; for(int i=0; i < gTreeData.getCount(); i++) { - if(gTreeData[i]->typ == 2) { + if (gTreeData[i]->typ == 2) { mir_snprintf(setting, 256, "%s/TextCol", gTreeData[i]->pupClass.pszName); gTreeData[i]->colorText = gTreeData[i]->pupClass.colorText = (COLORREF)DBGetContactSettingDword(0, PU_MODULCLASS, setting, (DWORD)fonts.clText); diff --git a/plugins/Popup/src/headers.h b/plugins/Popup/src/headers.h index 2530eaf6eb..3575b8c3c7 100644 --- a/plugins/Popup/src/headers.h +++ b/plugins/Popup/src/headers.h @@ -164,6 +164,5 @@ http://miranda-ng.org/distr/ #include "popup_gdiplus.h" INT_PTR svcEnableDisableMenuCommand(WPARAM, LPARAM); -extern HANDLE hSquareFad; #endif //HEADERS_H diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index 1c370c8bff..b5620c99d3 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -388,7 +388,7 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA ieData.next = NULL; CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent); } - else if(logType == LOG_DEFAULT) { + else if (logType == LOG_DEFAULT) { if (arPopupHistory.getCount() <= ListBox_GetCount(hwndLog)) { loadItem = 0; PostMessage(hwnd, UM_RESIZELIST, 0, 0); diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index 12e2c88c9f..7c7986c40b 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -64,58 +64,9 @@ HANDLE hMenuRoot = NULL; HANDLE hMenuItem = NULL; HANDLE hMenuItemHistory = NULL; -//==== ServiceFunctions Handles ==== -HANDLE hShowHistory = NULL; -HANDLE hTogglePopup = NULL; -HANDLE hGetStatus = NULL; - //===== Event Handles ===== -HANDLE hOptionsInitialize; -HANDLE hModulesLoaded; -HANDLE hOkToExit; -HANDLE hIconsChanged, hFontsChanged; -HANDLE hEventStatusChanged; //To automatically disable on status change. HANDLE hTTButton = NULL; -GLOBAL g_popup = {0}; - -static struct { - char *name; - INT_PTR (*func)(WPARAM, LPARAM); - HANDLE handle; -} popupServices[] = -{ - {MS_POPUP_ADDPOPUP, PopUp_AddPopUp, 0}, - {MS_POPUP_ADDPOPUPEX, PopUp_AddPopUpEx, 0}, - {MS_POPUP_ADDPOPUPW, PopUp_AddPopUpW, 0}, - {MS_POPUP_ADDPOPUP2, PopUp_AddPopUp2, 0}, - - {MS_POPUP_CHANGETEXT, PopUp_ChangeText, 0}, - {MS_POPUP_CHANGETEXTW, PopUp_ChangeTextW, 0}, - {MS_POPUP_CHANGE, PopUp_Change, 0}, - {MS_POPUP_CHANGEW, PopUp_ChangeW, 0}, - {MS_POPUP_CHANGEPOPUP2, PopUp_Change2, 0}, - - {MS_POPUP_GETCONTACT, PopUp_GetContact, 0}, - {MS_POPUP_GETPLUGINDATA, PopUp_GetPluginData, 0}, - {MS_POPUP_ISSECONDLINESHOWN, PopUp_IsSecondLineShown, 0}, - - {MS_POPUP_SHOWMESSAGE, PopUp_ShowMessage, 0}, - {MS_POPUP_SHOWMESSAGEW, PopUp_ShowMessageW, 0}, - {MS_POPUP_QUERY, PopUp_Query, 0}, - - {MS_POPUP_REGISTERACTIONS, PopUp_RegisterActions, 0}, - {MS_POPUP_REGISTERNOTIFICATION, PopUp_RegisterNotification, 0}, - - {MS_POPUP_UNHOOKEVENTASYNC, PopUp_UnhookEventAsync, 0}, - - {MS_POPUP_REGISTERVFX, PopUp_RegisterVfx, 0}, - - {MS_POPUP_REGISTERCLASS, PopUp_RegisterPopupClass, 0}, - {MS_POPUP_ADDPOPUPCLASS, PopUp_CreateClassPopup, 0}, - -}; - //===== Options pages ===== static int OptionsInitialize(WPARAM wParam,LPARAM lParam) { @@ -237,10 +188,7 @@ INT_PTR svcEnableDisableMenuCommand(WPARAM wp, LPARAM lp) mi.flags = CMIM_ICON; iResultRoot = CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hMenuRoot,(LPARAM)&mi); TTBLoaded(0,0); - if(iResult && iResultRoot) - return 1; - else - return 0; + return (iResult != 0 && iResultRoot != 0); } INT_PTR svcShowHistory(WPARAM, LPARAM) @@ -263,21 +211,21 @@ void InitMenuItems(void) hMenuRoot = Menu_AddMainMenuItem(&mi); // Add item to main menu - mi.hParentMenu = (HGENMENU)hMenuRoot; + mi.hParentMenu = (HGENMENU)hMenuRoot; - hTogglePopup = CreateServiceFunction(MENUCOMMAND_SVC, svcEnableDisableMenuCommand); - mi.ptszName = PopUpOptions.ModuleIsEnabled ? LPGENT("Disable &popup module") : LPGENT("Enable &popup module"); - mi.pszService = MENUCOMMAND_SVC; - hMenuItem = Menu_AddMainMenuItem(&mi); + CreateServiceFunction(MENUCOMMAND_SVC, svcEnableDisableMenuCommand); + mi.ptszName = PopUpOptions.ModuleIsEnabled ? LPGENT("Disable &popup module") : LPGENT("Enable &popup module"); + mi.pszService = MENUCOMMAND_SVC; + hMenuItem = Menu_AddMainMenuItem(&mi); // Popup History - hShowHistory = CreateServiceFunction(MENUCOMMAND_HISTORY, svcShowHistory); - mi.position = 1000000000; - mi.popupPosition = 1999990000; - mi.ptszName = LPGENT("Popup History"); - mi.hIcon = IcoLib_GetIcon(ICO_HISTORY, 0); - mi.pszService = MENUCOMMAND_HISTORY; - hMenuItemHistory = Menu_AddMainMenuItem(&mi); + CreateServiceFunction(MENUCOMMAND_HISTORY, svcShowHistory); + mi.position = 1000000000; + mi.popupPosition = 1999990000; + mi.ptszName = LPGENT("Popup History"); + mi.hIcon = IcoLib_GetIcon(ICO_HISTORY, 0); + mi.pszService = MENUCOMMAND_HISTORY; + hMenuItemHistory = Menu_AddMainMenuItem(&mi); } @@ -289,21 +237,21 @@ INT_PTR GetStatus(WPARAM wp, LPARAM lp) //register Hotkey -void LoadHotkey() { - HOTKEYDESC hk = {0}; - hk.cbSize = sizeof(hk); - hk.dwFlags = HKD_TCHAR; - hk.pszName = "Toggle Popups"; - hk.ptszDescription = LPGENT("Toggle Popups"); - hk.ptszSection = LPGENT(MODULNAME_PLU); - hk.pszService = MENUCOMMAND_SVC; - Hotkey_Register( &hk); +void LoadHotkey() +{ + HOTKEYDESC hk = { sizeof(hk) }; + hk.dwFlags = HKD_TCHAR; + hk.pszName = "Toggle Popups"; + hk.ptszDescription = LPGENT("Toggle Popups"); + hk.ptszSection = LPGENT(MODULNAME_PLU); + hk.pszService = MENUCOMMAND_SVC; + Hotkey_Register(&hk); // 'Popup History' Hotkey - hk.pszName = "Popup History"; - hk.ptszDescription = LPGENT("Popup History"); - hk.pszService = MENUCOMMAND_HISTORY; - Hotkey_Register( &hk); + hk.pszName = "Popup History"; + hk.ptszDescription = LPGENT("Popup History"); + hk.pszService = MENUCOMMAND_HISTORY; + Hotkey_Register(&hk); } //menu @@ -318,33 +266,24 @@ static int ModulesLoaded(WPARAM wParam,LPARAM lParam) htuText = MText.Register("PopUp Plus/Text", MTEXT_FANCY_DEFAULT); htuTitle = MText.Register("PopUp Plus/Title",MTEXT_FANCY_DEFAULT); } - else { - htuTitle = htuText = NULL; - } + else htuTitle = htuText = NULL; + // init meta contacts INT_PTR ptr = CallService(MS_MC_GETPROTOCOLNAME, 0, 0); - if (ptr != CALLSERVICE_NOTFOUND) { + if (ptr != CALLSERVICE_NOTFOUND) gszMetaProto = (LPCSTR)ptr; - } //check if OptionLoaded - if (!OptionLoaded){ + if (!OptionLoaded) LoadOptions(); - } -/*/deprecatet stuff - notifyLink = ServiceExists(MS_NOTIFY_GETLINK) ? (MNOTIFYLINK *)CallService(MS_NOTIFY_GETLINK, 0, 0) : NULL; - LoadNotifyImp(); - hNotifyOptionsInitialize = HookEvent(ME_NOTIFY_OPT_INITIALISE, NotifyOptionsInitialize); - HookEvent(ME_CONTACTSETTINGS_INITIALISE, ContactSettingsInitialise); -*/ //Uninstalling purposes - if (ServiceExists("PluginSweeper/Add")) { + if (ServiceExists("PluginSweeper/Add")) CallService("PluginSweeper/Add",(WPARAM)Translate(MODULNAME),(LPARAM)MODULNAME); - } + //load fonts / create hook InitFonts(); - hFontsChanged = HookEvent(ME_FONT_RELOAD,FontsChanged); + HookEvent(ME_FONT_RELOAD,FontsChanged); //load actions and notifications LoadActions(); @@ -388,12 +327,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) //@param mirandaVersion - The version of the application calling this function MIRAPI PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { - g_popup.MirVer = mirandaVersion; - return &pluginInfoEx; } -//ME_SYSTEM_OKTOEXIT event +//ME_SYSTEM_PRESHUTDOWN event //called before the app goes into shutdown routine to make sure everyone is happy to exit static int OkToExit(WPARAM wParam, LPARAM lParam) { @@ -407,16 +344,13 @@ static int OkToExit(WPARAM wParam, LPARAM lParam) //Called when the plugin is loaded into Miranda MIRAPI int Load(void) { - g_popup.isOsUnicode = (GetVersion() & 0x80000000) == 0; - g_popup.isMirUnicode = true; - - hGetStatus = CreateServiceFunction(MS_POPUP_GETSTATUS, GetStatus); - DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0); mir_getMTI(&MText); mir_getLP(&pluginInfoEx); + CreateServiceFunction(MS_POPUP_GETSTATUS, GetStatus); + #if defined(_DEBUG) PopUpOptions.debug = DBGetContactSettingByte(NULL, MODULNAME, "debug", FALSE); #else @@ -425,23 +359,14 @@ MIRAPI int Load(void) LoadGDIPlus(); //Transparent and animation routines - OSVERSIONINFO osvi = { 0 }; - BOOL bResult = FALSE; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - bResult = GetVersionEx(&osvi); - - hDwmapiDll = LoadLibrary(_T("dwmapi.dll")); MyDwmEnableBlurBehindWindow = 0; - if (hDwmapiDll) { - MyDwmEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *)) - GetProcAddress(hDwmapiDll, "DwmEnableBlurBehindWindow"); - } + if (hDwmapiDll) + MyDwmEnableBlurBehindWindow = (HRESULT (WINAPI *)(HWND, DWM_BLURBEHIND *))GetProcAddress(hDwmapiDll, "DwmEnableBlurBehindWindow"); PopupHistoryLoad(); LoadPopupThread(); - if (!LoadPopupWnd2()) - { + if (!LoadPopupWnd2()) { MessageBox(0, TranslateT("Error: I could not register the PopUp Window class.\r\nThe plugin will not operate."), _T(MODULNAME_LONG), MB_ICONSTOP | MB_OK); return 0; //We couldn't register our Window Class, don't hook any event: the plugin will act as if it was disabled. } @@ -453,24 +378,48 @@ MIRAPI int Load(void) DBWriteContactSettingString(NULL, "KnownModules", pluginInfoEx.shortName, MODULNAME); DBFreeVariant(&dbv); - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OptionsInitialize); - hOkToExit = HookEvent(ME_SYSTEM_OKTOEXIT, OkToExit); -// hEventStatusChanged = HookEvent(ME_CLIST_STATUSMODECHANGE,StatusModeChanged); + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + HookEvent(ME_OPT_INITIALISE, OptionsInitialize); + HookEvent(ME_SYSTEM_PRESHUTDOWN, OkToExit); hbmNoAvatar = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_NOAVATAR)); - if (!OptionLoaded){ + if (!OptionLoaded) LoadOptions(); - } //Service Functions - for (int i = SIZEOF(popupServices); i--; ) - popupServices[i].handle = CreateServiceFunction(popupServices[i].name, popupServices[i].func); + CreateServiceFunction(MS_POPUP_ADDPOPUP, PopUp_AddPopUp); + CreateServiceFunction(MS_POPUP_ADDPOPUPEX, PopUp_AddPopUpEx); + CreateServiceFunction(MS_POPUP_ADDPOPUPW, PopUp_AddPopUpW); + CreateServiceFunction(MS_POPUP_ADDPOPUP2, PopUp_AddPopUp2); + + CreateServiceFunction(MS_POPUP_CHANGETEXT, PopUp_ChangeText); + CreateServiceFunction(MS_POPUP_CHANGETEXTW, PopUp_ChangeTextW); + CreateServiceFunction(MS_POPUP_CHANGE, PopUp_Change); + CreateServiceFunction(MS_POPUP_CHANGEW, PopUp_ChangeW); + CreateServiceFunction(MS_POPUP_CHANGEPOPUP2, PopUp_Change2); + + CreateServiceFunction(MS_POPUP_GETCONTACT, PopUp_GetContact); + CreateServiceFunction(MS_POPUP_GETPLUGINDATA, PopUp_GetPluginData); + CreateServiceFunction(MS_POPUP_ISSECONDLINESHOWN, PopUp_IsSecondLineShown); + + CreateServiceFunction(MS_POPUP_SHOWMESSAGE, PopUp_ShowMessage); + CreateServiceFunction(MS_POPUP_SHOWMESSAGEW, PopUp_ShowMessageW); + CreateServiceFunction(MS_POPUP_QUERY, PopUp_Query); + + CreateServiceFunction(MS_POPUP_REGISTERACTIONS, PopUp_RegisterActions); + CreateServiceFunction(MS_POPUP_REGISTERNOTIFICATION, PopUp_RegisterNotification); + + CreateServiceFunction(MS_POPUP_UNHOOKEVENTASYNC, PopUp_UnhookEventAsync); + + CreateServiceFunction(MS_POPUP_REGISTERVFX, PopUp_RegisterVfx); + + CreateServiceFunction(MS_POPUP_REGISTERCLASS, PopUp_RegisterPopupClass); + CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, PopUp_CreateClassPopup); //load icons / create hook InitIcons(); - hIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED,IconsChanged); + HookEvent(ME_SKIN2_ICONSCHANGED,IconsChanged); //add menu items InitMenuItems(); @@ -483,25 +432,8 @@ MIRAPI int Load(void) MIRAPI int Unload(void) { - int i; - - for (i = SIZEOF(popupServices); i--; ) - DestroyServiceFunction(popupServices[i].handle); - SrmmMenu_Unload(); - UnhookEvent(hOptionsInitialize); - UnhookEvent(hModulesLoaded); - UnhookEvent(hOkToExit); - UnhookEvent(hEventStatusChanged); - UnhookEvent(hIconsChanged); - UnhookEvent(hFontsChanged); - - DestroyServiceFunction(hShowHistory); - DestroyServiceFunction(hTogglePopup); - DestroyServiceFunction(hGetStatus); - DestroyServiceFunction(hSquareFad); - DeleteObject(fonts.title); DeleteObject(fonts.clock); DeleteObject(fonts.text); @@ -513,10 +445,9 @@ MIRAPI int Unload(void) FreeLibrary(hDwmapiDll); FreeLibrary(hUserDll); FreeLibrary(hMsimgDll); -// FreeLibrary(hKernelDll); FreeLibrary(hGdiDll); - if(PopUpOptions.SkinPack) mir_free(PopUpOptions.SkinPack); + if (PopUpOptions.SkinPack) mir_free(PopUpOptions.SkinPack); mir_free(PopUpOptions.Effect); OptAdv_UnregisterVfx(); diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 6df5fb3003..193baf5ccf 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -74,7 +74,7 @@ void LoadNotifications() void UnloadTreeData() { for (int i=0; i < gTreeData.getCount(); ++i) { - if(gTreeData[i]->typ == 2) { + if (gTreeData[i]->typ == 2) { mir_free(gTreeData[i]->pupClass.pszName); mir_free(gTreeData[i]->pupClass.pszDescription); } @@ -86,7 +86,7 @@ void UnloadTreeData() void SaveNotificationSettings(POPUPTREEDATA *ptd, char* szModul) { - if(ptd->typ == 1) { + if (ptd->typ == 1) { char setting[2*MAXMODULELABELLENGTH]; mir_snprintf(setting, sizeof(setting), "{%s/%s}Timeout", @@ -143,7 +143,7 @@ void SaveNotificationSettings(POPUPTREEDATA *ptd, char* szModul) void LoadNotificationSettings(POPUPTREEDATA *ptd, char* szModul) { - if(ptd->typ == 1) { + if (ptd->typ == 1) { char setting[2*MAXMODULELABELLENGTH]; char *szTmp = NULL; diff --git a/plugins/Popup/src/opt_adv.cpp b/plugins/Popup/src/opt_adv.cpp index 6eca70dbb6..3469238530 100644 --- a/plugins/Popup/src/opt_adv.cpp +++ b/plugins/Popup/src/opt_adv.cpp @@ -391,7 +391,7 @@ INT_PTR CALLBACK DlgProcPopUpAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_MAXPOPUPS: { int maxPop = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); - if(maxPop > 0){ + if (maxPop > 0){ PopUpOptions.MaxPopups = maxPop; SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); } @@ -446,9 +446,9 @@ INT_PTR CALLBACK DlgProcPopUpAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_MAXPOPUPS: { int maxPop = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); - if(maxPop <= 0) + if (maxPop <= 0) PopUpOptions.MaxPopups = 20; - if(maxPop != PopUpOptions.MaxPopups) { + if (maxPop != PopUpOptions.MaxPopups) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.MaxPopups, FALSE); //ErrorMSG(1); SetFocus((HWND)lParam); @@ -458,11 +458,11 @@ INT_PTR CALLBACK DlgProcPopUpAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_HISTORYSIZE: { int histSize = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); - if(histSize <= 0) + if (histSize <= 0) PopUpOptions.HistorySize = SETTING_HISTORYSIZE_DEFAULT; - else if(histSize > SETTING_HISTORYSIZE_MAX) + else if (histSize > SETTING_HISTORYSIZE_MAX) PopUpOptions.HistorySize = SETTING_HISTORYSIZE_MAX; - if(histSize != PopUpOptions.HistorySize) { + if (histSize != PopUpOptions.HistorySize) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.HistorySize, FALSE); ErrorMSG(1, SETTING_HISTORYSIZE_MAX); SetFocus((HWND)lParam); @@ -472,9 +472,9 @@ INT_PTR CALLBACK DlgProcPopUpAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_AVT_RADIUS: { int avtRadius = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); - if(avtRadius > SETTING_AVTSIZE_MAX / 2) + if (avtRadius > SETTING_AVTSIZE_MAX / 2) PopUpOptions.avatarRadius = SETTING_AVTSIZE_MAX / 2; - if(avtRadius != PopUpOptions.avatarRadius) { + if (avtRadius != PopUpOptions.avatarRadius) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.avatarRadius, FALSE); ErrorMSG(0, SETTING_AVTSIZE_MAX / 2); SetFocus((HWND)lParam); @@ -484,11 +484,11 @@ INT_PTR CALLBACK DlgProcPopUpAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_FADEIN: { int fade = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); - if(fade < SETTING_FADEINTIME_MIN) + if (fade < SETTING_FADEINTIME_MIN) PopUpOptions.FadeIn = SETTING_FADEINTIME_MIN; - else if(fade > SETTING_FADEINTIME_MAX) + else if (fade > SETTING_FADEINTIME_MAX) PopUpOptions.FadeIn = SETTING_FADEINTIME_MAX; - if(fade != PopUpOptions.FadeIn) { + if (fade != PopUpOptions.FadeIn) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.FadeIn, FALSE); ErrorMSG(SETTING_FADEINTIME_MIN, SETTING_FADEINTIME_MAX); SetFocus((HWND)lParam); @@ -498,11 +498,11 @@ INT_PTR CALLBACK DlgProcPopUpAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case IDC_FADEOUT: { int fade = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); - if(fade < SETTING_FADEOUTTIME_MIN) + if (fade < SETTING_FADEOUTTIME_MIN) PopUpOptions.FadeOut = SETTING_FADEOUTTIME_MIN; - else if(fade > SETTING_FADEOUTTIME_MAX) + else if (fade > SETTING_FADEOUTTIME_MAX) PopUpOptions.FadeOut = SETTING_FADEOUTTIME_MAX; - if(fade != PopUpOptions.FadeOut) { + if (fade != PopUpOptions.FadeOut) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.FadeOut, FALSE); ErrorMSG(SETTING_FADEOUTTIME_MIN, SETTING_FADEOUTTIME_MAX); SetFocus((HWND)lParam); diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index 51584cbcd4..1069fe2628 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int ComboBox_SelectItem(HWND hwndCtl, int indexStart, char* data) { int i=0; for ( i ; i < ComboBox_GetCount(hwndCtl); i++) { - if(strcmp(data, (char*)ComboBox_GetItemData(hwndCtl, i))==0) { + if (strcmp(data, (char*)ComboBox_GetItemData(hwndCtl, i))==0) { ComboBox_SetCurSel (hwndCtl,i); return i; } @@ -362,7 +362,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l ppd.colorBack = ptd->colorBack; ppd.colorText = ptd->colorText; POPUPTREEDATA *ptdPrev = NULL; - if(ptd->typ == 1) { + if (ptd->typ == 1) { //we work with a copy for preview ptdPrev = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA)); memcpy(ptdPrev, ptd, sizeof(POPUPTREEDATA)); @@ -374,7 +374,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l ppd.lchNotification = (HANDLE)ptdPrev; } - else if(ptd->typ == 2) + else if (ptd->typ == 2) ppd.lchIcon = ptd->pupClass.hIcon; CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY); @@ -455,7 +455,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l ptd->timeoutValue = SETTING_LIFETIME_MAX; else if (seconds < SETTING_LIFETIME_INFINITE) ptd->timeoutValue = SETTING_LIFETIME_INFINITE; - if(seconds != ptd->timeoutValue) { + if (seconds != ptd->timeoutValue) { SetDlgItemInt(hwnd, idCtrl, ptd->timeoutValue, TRUE); ErrorMSG(SETTING_LIFETIME_INFINITE, SETTING_LIFETIME_MAX); SetFocus((HWND)lParam); diff --git a/plugins/Popup/src/opt_contacts.cpp b/plugins/Popup/src/opt_contacts.cpp index d2a5cf6376..46d735dfd4 100644 --- a/plugins/Popup/src/opt_contacts.cpp +++ b/plugins/Popup/src/opt_contacts.cpp @@ -76,9 +76,9 @@ INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l DWORD hitFlags; int iImage; - if(nm->iColumn==-1) break; + if (nm->iColumn==-1) break; hItem=(HANDLE)SendDlgItemMessage(hwnd,IDC_LIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y)); - if(hItem==NULL) break; + if (hItem==NULL) break; if (!(hitFlags&CLCHT_ONITEMEXTRA)) break; iImage = SendDlgItemMessage(hwnd,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0)); diff --git a/plugins/Popup/src/opt_gen.cpp b/plugins/Popup/src/opt_gen.cpp index a878aafcac..ee41be873a 100644 --- a/plugins/Popup/src/opt_gen.cpp +++ b/plugins/Popup/src/opt_gen.cpp @@ -454,7 +454,7 @@ INT_PTR CALLBACK DlgProcPopUpGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM PopUpOptions.Seconds = SETTING_LIFETIME_MAX; else if (seconds < SETTING_LIFETIME_MIN) PopUpOptions.Seconds = SETTING_LIFETIME_MIN; - if(seconds != PopUpOptions.Seconds) { + if (seconds != PopUpOptions.Seconds) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.Seconds, FALSE); ErrorMSG(SETTING_LIFETIME_MIN, SETTING_LIFETIME_MAX); SetFocus((HWND)lParam); @@ -466,9 +466,9 @@ INT_PTR CALLBACK DlgProcPopUpGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM int temp = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); if (temp < SETTING_MINIMUMWIDTH_MIN) PopUpOptions.MinimumWidth = SETTING_MINIMUMWIDTH_MIN; - else if(temp > SETTING_MAXIMUMWIDTH_MAX) + else if (temp > SETTING_MAXIMUMWIDTH_MAX) PopUpOptions.MinimumWidth = SETTING_MAXIMUMWIDTH_MAX; - if(temp != PopUpOptions.MinimumWidth) { + if (temp != PopUpOptions.MinimumWidth) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.MinimumWidth, FALSE); ErrorMSG(SETTING_MINIMUMWIDTH_MIN, SETTING_MAXIMUMWIDTH_MAX); SetFocus((HWND)lParam); @@ -485,9 +485,9 @@ INT_PTR CALLBACK DlgProcPopUpGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM int temp = GetDlgItemInt(hwnd, idCtrl, NULL, FALSE); if (temp >= SETTING_MAXIMUMWIDTH_MAX) PopUpOptions.MaximumWidth = SETTING_MAXIMUMWIDTH_MAX; - else if(temp < SETTING_MINIMUMWIDTH_MIN) + else if (temp < SETTING_MINIMUMWIDTH_MIN) PopUpOptions.MaximumWidth = SETTING_MINIMUMWIDTH_MIN; - if(temp != PopUpOptions.MaximumWidth) { + if (temp != PopUpOptions.MaximumWidth) { SetDlgItemInt(hwnd, idCtrl, PopUpOptions.MaximumWidth, FALSE); ErrorMSG(SETTING_MINIMUMWIDTH_MIN, SETTING_MAXIMUMWIDTH_MAX); SetFocus((HWND)lParam); @@ -646,7 +646,7 @@ void Check_ReorderPopUps(HWND hwnd) { } DBWriteContactSettingByte(NULL, MODULNAME, "ReorderPopUps", PopUpOptions.ReorderPopUps); DBWriteContactSettingByte(NULL, MODULNAME, "ReorderPopUpsWarning", PopUpOptions.ReorderPopUpsWarning); - if(hwnd) CheckDlgButton(hwnd, IDC_REORDERPOPUPS, PopUpOptions.ReorderPopUps); + if (hwnd) CheckDlgButton(hwnd, IDC_REORDERPOPUPS, PopUpOptions.ReorderPopUps); } void ThemeDialogBackground(HWND hwnd) { diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp index eb78935ab9..8d91d6c1aa 100644 --- a/plugins/Popup/src/opt_skins.cpp +++ b/plugins/Popup/src/opt_skins.cpp @@ -324,7 +324,7 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int index = -1; OptTree_ProcessMessage(hwndDlg, msg, wParam, lParam, &index, IDC_SKIN_LIST_OPT, skinOptions, skinOptionsCount); if (index != -1) { - if(lstrcmp(skinOptions[index].pszSettingName, _T("Skin options")) == 0) { + if (lstrcmp(skinOptions[index].pszSettingName, _T("Skin options")) == 0) { const PopupSkin *skin = 0; if (skin = skins.getSkin(PopUpOptions.SkinPack)) { skin->setFlag(skinOptions[index].Data, skinOptions[index].bState ? true : false); @@ -435,7 +435,7 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopUpOptions.SkinPack)); //make shure we have select skin (ListBox_SetCurSel may be fail) ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin); - if(lstrcmp(pszOldSkin, szNewSkin) != 0) { + if (lstrcmp(pszOldSkin, szNewSkin) != 0) { mir_free(PopUpOptions.SkinPack); PopUpOptions.SkinPack = mir_tstrdup(szNewSkin); } diff --git a/plugins/Popup/src/opttree.cpp b/plugins/Popup/src/opttree.cpp index 7e33254ad0..3965987833 100644 --- a/plugins/Popup/src/opttree.cpp +++ b/plugins/Popup/src/opttree.cpp @@ -178,21 +178,10 @@ BOOL OptTree_ProcessMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR|ILC_COLOR32|ILC_MASK, 5, 1); ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); - if (g_popup.MirVer >= PLUGIN_MAKE_VERSION(0,7,0,2)) - { - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_TICK)); - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_TICK)); - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); - } else - { - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPT_CHECK_ON), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); // check buttons - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPT_CHECK_OFF), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); // check buttons - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPT_CHECK_ON), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); // check buttons - ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPT_CHECK_OFF), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); // check buttons -// ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPT_RADIO_ON), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); // radio buttons -// ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPT_RADIO_OFF), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR|LR_SHARED)); // radio buttons - } + ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_TICK)); + ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); + ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_TICK)); + ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN)); ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT)); TreeView_SetImageList(hwndTree, hImgLst, TVSIL_NORMAL); @@ -283,9 +272,9 @@ BOOL OptTree_ProcessMessage(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(lpnmhdr->hwndFrom,&hti.pt); - if(TreeView_HitTest(lpnmhdr->hwndFrom,&hti)) + if (TreeView_HitTest(lpnmhdr->hwndFrom,&hti)) { - if(hti.flags&TVHT_ONITEMICON) + if (hti.flags&TVHT_ONITEMICON) { TVITEM tvi; tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index 5a968fb606..5c7ecfb9d0 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -57,8 +57,7 @@ static void __cdecl PopupThread(void *arg); void LoadPopupThread() { hThreadMutex = CreateMutex(NULL, FALSE, NULL); - _beginthread(PopupThread, 0, NULL); -// _beginthreadex(NULL, 0, PopupThread, NULL, 0, &idPopupThread); + mir_forkthread(PopupThread, NULL); } void StopPopupThread() @@ -299,8 +298,8 @@ static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARA static void __cdecl PopupThread(void *arg) { // grab the mutex - if (WaitForSingleObject(hThreadMutex, INFINITE) != WAIT_OBJECT_0) - { // other thread is already running + if ( WaitForSingleObject(hThreadMutex, INFINITE) != WAIT_OBJECT_0) { + // other thread is already running _endthread(); return; } @@ -335,19 +334,10 @@ static void __cdecl PopupThread(void *arg) SetWindowPos(gHwndManager, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_HIDEWINDOW); MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) - { + while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } ReleaseMutex(hThreadMutex); - - // Decrement Miranda thread counter - Thread_Pop(); - - // Ok, now we can kill this thread - _endthread(); - - return; } diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 7f15ea9356..33e5094e6b 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -1003,26 +1003,23 @@ struct ReplyEditData WNDPROC oldWndProc; }; -bool IsMsgServiceNameW(HANDLE hContact) { - if (g_popup.isMirUnicode) { - char szServiceName[100]; - char *szProto = GetContactProto(hContact); - if (szProto == NULL) - return false; +bool IsMsgServiceNameW(HANDLE hContact) +{ + char szServiceName[100]; + char *szProto = GetContactProto(hContact); + if (szProto == NULL) + return false; - mir_snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE); - if (ServiceExists(szServiceName)) - return true; - } - return false; + mir_snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE); + return ServiceExists(szServiceName) != 0; } BOOL IsUtfSendAvailable(HANDLE hContact) { char* szProto = GetContactProto(hContact); - if(szProto == NULL) return FALSE; + if (szProto == NULL) return FALSE; //check for MetaContact and get szProto from subcontact - if(strcmp(szProto, gszMetaProto)==0) { + if (strcmp(szProto, gszMetaProto)==0) { HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT, (WPARAM)hContact, 0); if (!hSubContact) return FALSE; szProto = GetContactProto(hSubContact); @@ -1038,7 +1035,7 @@ void AddMessageToDB(HANDLE hContact, char *msg, int flag/*bool utf*/) dbei.flags = DBEF_SENT | ((flag&PREF_UTF)==PREF_UTF ? DBEF_UTF : 0); dbei.szModule = GetContactProto(hContact); dbei.timestamp = time(NULL); - if(g_popup.isOsUnicode && !((flag&PREF_UTF)==PREF_UTF) && (flag&PREF_UNICODE)==PREF_UNICODE) + if ( !((flag & PREF_UTF) == PREF_UTF) && (flag & PREF_UNICODE) == PREF_UNICODE) dbei.cbBlob = (lstrlenW((LPWSTR)msg) + 1)*sizeof(WCHAR/*TCHAR*/); else dbei.cbBlob = lstrlenA(msg) + 1; @@ -1081,7 +1078,7 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM SendMessageW(hwnd, WM_GETTEXT, SIZEOF(msg), (LPARAM)msg); - if(wcslen(msg)==0){ + if (wcslen(msg)==0){ DestroyWindow(hwnd); return 0; } @@ -1090,7 +1087,7 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM buf = mir_utf8encodeW(msg); flag = PREF_UTF; } - else if(bSendW){ + else if (bSendW){ bufW = mir_wstrdup(msg) /*mir_tstrdup(msg)*/; buf = (char*)bufW; flag = PREF_UNICODE /*PREF_TCHAR*/; @@ -1103,7 +1100,7 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM else { char msg[2048]; GetWindowTextA(hwnd, msg, SIZEOF(msg)); - if(strlen(msg)==0){ + if (strlen(msg)==0){ DestroyWindow(hwnd); return 0; } @@ -1216,7 +1213,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara dat->oldWndProc = (WNDPROC)GetWindowLongPtr(hwndEditBox, (LONG_PTR)GWLP_WNDPROC); dat->hwndPopup = m_hwnd; dat->hContact = m_hContact; - if(IsWindowUnicode(hwndEditBox)) { + if (IsWindowUnicode(hwndEditBox)) { SendMessageW(hwndEditBox, WM_SETFONT, (WPARAM)fonts.text, TRUE); @@ -1339,7 +1336,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara } if (i == m_actionCount) { - if(PopUpOptions.overrideLeft!=false && (m_hContact!=NULL || PopUpOptions.overrideLeft == 5 || PopUpOptions.overrideLeft == 6)) { + if (PopUpOptions.overrideLeft!=false && (m_hContact!=NULL || PopUpOptions.overrideLeft == 5 || PopUpOptions.overrideLeft == 6)) { switch (PopUpOptions.overrideLeft){ default: case 1:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MESSAGE); break; diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index a068575af2..858f990aae 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -416,7 +416,7 @@ INT_PTR PopUp_Change2(WPARAM wParam, LPARAM lParam) //===== PopUp/ShowMessage INT_PTR PopUp_ShowMessage(WPARAM wParam, LPARAM lParam) { if (!gbPopupLoaded || !wParam || !lParam) return -1; - if(closing) return 0; + if (closing) return 0; POPUPDATA2 ppd2 = {0}; ppd2.cbSize = sizeof(ppd2); @@ -452,7 +452,7 @@ INT_PTR PopUp_ShowMessage(WPARAM wParam, LPARAM lParam) { INT_PTR PopUp_ShowMessageW(WPARAM wParam, LPARAM lParam) { if (!gbPopupLoaded || !wParam || !lParam) return -1; - if(closing) return 0; + if (closing) return 0; POPUPDATA2 ppd2 = {0}; ppd2.cbSize = sizeof(ppd2); @@ -577,7 +577,7 @@ INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) { memcpy(&ptd->pupClass, pc, sizeof(POPUPCLASS)); ptd->pszTreeRoot = mir_a2t(pc->pszName); ptd->pupClass.pszName = mir_strdup(pc->pszName); - if(pc->flags & PCF_UNICODE) { + if (pc->flags & PCF_UNICODE) { ptd->pupClass.pwszDescription = mir_wstrdup(pc->pwszDescription); ptd->pszDescription = mir_u2t(pc->pwszDescription); } @@ -627,18 +627,18 @@ INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) { INT_PTR PopUp_CreateClassPopup(WPARAM wParam, LPARAM lParam) { int ret = 1; POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam; - if(pdc->cbSize != sizeof(POPUPDATACLASS)) return ret; + if (pdc->cbSize != sizeof(POPUPDATACLASS)) return ret; POPUPCLASS *pc = NULL; POPUPTREEDATA *ptd = NULL; - if(wParam) pc = (POPUPCLASS *)wParam; + if (wParam) pc = (POPUPCLASS *)wParam; else { LPTSTR group = mir_a2t(pdc->pszClassName); ptd = (POPUPTREEDATA *)FindTreeData(group, NULL, 2); - if(ptd) pc = &ptd->pupClass; + if (ptd) pc = &ptd->pupClass; } - if(pc) { + if (pc) { POPUPDATA2 ppd2 = {0}; ppd2.cbSize = sizeof(POPUPDATA2); ppd2.colorBack = pc->colorBack; @@ -646,7 +646,7 @@ INT_PTR PopUp_CreateClassPopup(WPARAM wParam, LPARAM lParam) { ppd2.lchIcon = pc->hIcon; ppd2.iSeconds = pc->iSeconds; ppd2.PluginWindowProc = pc->PluginWindowProc; - if(pc->flags & PCF_UNICODE) { + if (pc->flags & PCF_UNICODE) { ppd2.flags = PU2_UNICODE; ppd2.lpwzTitle = (WCHAR*)pdc->pwszTitle; ppd2.lpwzText = (WCHAR*)pdc->pwszText; diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index aab6ad6da4..7a2082e18e 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2188,19 +2188,19 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (dat->pContainer->hwndActive != hwndDlg || dat->pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || dat->szStatusBar[0]) break; + if (si->pszModule != NULL) { TCHAR szFinalStatusBarText[512]; - MODULEINFO* mi=NULL; - int x = 12; //Mad: strange rare crash here... - mi = MM_FindModule(si->pszModule); + MODULEINFO *mi = MM_FindModule(si->pszModule); if (!mi) break; if (!mi->ptszModDispName) break; + int x = 12; x += GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(dat->pContainer->hwndStatus, WM_GETFONT, 0, 0), TRUE); x += GetSystemMetrics(SM_CXSMICON); @@ -2224,7 +2224,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); } mir_sntprintf(szFinalStatusBarText, SIZEOF(szFinalStatusBarText), TranslateT("%s on %s%s"), dat->szMyNickname, mi->ptszModDispName, mi->tszIdleMsg); - } else { + } + else { if (si->ptszStatusbarText) mir_sntprintf(szFinalStatusBarText, SIZEOF(szFinalStatusBarText), _T("%s %s"), mi->ptszModDispName, si->ptszStatusbarText); else { @@ -2241,50 +2242,47 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } break; - case WM_SIZE: { - UTILRESIZEDIALOG urd; - RECT rc; - int panelHeight = dat->Panel->getHeight() + 1; - LONG cx; - + case WM_SIZE: if (dat->ipFieldHeight == 0) dat->ipFieldHeight = CInfoPanel::m_ipConfig.height1; if (wParam == SIZE_MAXIMIZED) PostMessage(hwndDlg, GC_SCROLLTOBOTTOM, 0, 0); - if (IsIconic(hwndDlg)) break; - ZeroMemory(&urd, sizeof(urd)); - urd.cbSize = sizeof(urd); - urd.hInstance = g_hInst; - urd.hwndDlg = hwndDlg; - urd.lParam = (LPARAM)si; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_CHANNEL); - urd.pfnResizer = RoomWndResize; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - //mad - BB_SetButtonsPos(dat); + if ( !IsIconic(hwndDlg)) { + int panelHeight = dat->Panel->getHeight() + 1; - GetClientRect(hwndDlg, &rc); - cx = rc.right; + UTILRESIZEDIALOG urd = { sizeof(urd) }; + urd.hInstance = g_hInst; + urd.hwndDlg = hwndDlg; + urd.lParam = (LPARAM)si; + urd.lpTemplate = MAKEINTRESOURCEA(IDD_CHANNEL); + urd.pfnResizer = RoomWndResize; + CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - rc.left = panelHeight <= CInfoPanel::LEFT_OFFSET_LOGO ? panelHeight : CInfoPanel::LEFT_OFFSET_LOGO; - rc.right = cx; - rc.top = 1; - rc.bottom = (panelHeight > CInfoPanel::DEGRADE_THRESHOLD ? rc.top + dat->ipFieldHeight - 2 : panelHeight - 1); - dat->rcNick = rc; + BB_SetButtonsPos(dat); - rc.left = panelHeight <= CInfoPanel::LEFT_OFFSET_LOGO ? panelHeight : CInfoPanel::LEFT_OFFSET_LOGO; - rc.right = cx; - rc.bottom = panelHeight - 2; - rc.top = dat->rcNick.bottom + 1; - dat->rcUIN = rc; + RECT rc; + GetClientRect(hwndDlg, &rc); + int cx = rc.right; - if (dat->hwndIEView || dat->hwndHPP) - Chat_ResizeIeView(dat); - DetermineMinHeight(dat); - } - break; + rc.left = panelHeight <= CInfoPanel::LEFT_OFFSET_LOGO ? panelHeight : CInfoPanel::LEFT_OFFSET_LOGO; + rc.right = cx; + rc.top = 1; + rc.bottom = (panelHeight > CInfoPanel::DEGRADE_THRESHOLD ? rc.top + dat->ipFieldHeight - 2 : panelHeight - 1); + dat->rcNick = rc; + + rc.left = panelHeight <= CInfoPanel::LEFT_OFFSET_LOGO ? panelHeight : CInfoPanel::LEFT_OFFSET_LOGO; + rc.right = cx; + rc.bottom = panelHeight - 2; + rc.top = dat->rcNick.bottom + 1; + dat->rcUIN = rc; + + if (dat->hwndIEView || dat->hwndHPP) + Chat_ResizeIeView(dat); + DetermineMinHeight(dat); + } + break; case GC_REDRAWWINDOW: InvalidateRect(hwndDlg, NULL, TRUE); diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 94748a39d9..c125213b1b 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -498,7 +498,7 @@ void CJabberProto::CheckAllContactsAreTransported() ///////////////////////////////////////////////////////////////////////////////////////// // Cross-instance shared icons -static IconItem sharedIconList[] = +static IconItem sharedIconList1[] = { { LPGEN("Privacy Lists"), "privacylists", IDI_PRIVACY_LISTS }, { LPGEN("Bookmarks"), "bookmarks", IDI_BOOKMARKS }, @@ -520,24 +520,33 @@ static IconItem sharedIconList[] = { LPGEN("Service Discovery"), "servicediscovery", IDI_SERVICE_DISCOVERY }, { LPGEN("AdHoc Command"), "adhoc", IDI_COMMAND }, { LPGEN("XML Console"), "xmlconsole", IDI_CONSOLE }, - { LPGEN("OpenID Request"), "openid", IDI_HTTP_AUTH }, + { LPGEN("OpenID Request"), "openid", IDI_HTTP_AUTH } +}; +static IconItem sharedIconList2[] = +{ { LPGEN("Discovery succeeded"), "disco_ok", IDI_DISCO_OK }, { LPGEN("Discovery failed"), "disco_fail", IDI_DISCO_FAIL }, { LPGEN("Discovery in progress"), "disco_progress", IDI_DISCO_PROGRESS }, { LPGEN("View as tree"), "sd_view_tree", IDI_VIEW_TREE }, { LPGEN("View as list"), "sd_view_list", IDI_VIEW_LIST }, { LPGEN("Apply filter"), "sd_filter_apply", IDI_FILTER_APPLY }, - { LPGEN("Reset filter"), "sd_filter_reset", IDI_FILTER_RESET }, + { LPGEN("Reset filter"), "sd_filter_reset", IDI_FILTER_RESET } +}; +static IconItem sharedIconList3[] = +{ { LPGEN("Navigate home"), "sd_nav_home", IDI_NAV_HOME }, { LPGEN("Refresh node"), "sd_nav_refresh", IDI_NAV_REFRESH }, { LPGEN("Browse node"), "sd_browse", IDI_BROWSE }, { LPGEN("RSS service"), "node_rss", IDI_NODE_RSS }, { LPGEN("Server"), "node_server", IDI_NODE_SERVER }, { LPGEN("Storage service"), "node_store", IDI_NODE_STORE }, - { LPGEN("Weather service"), "node_weather", IDI_NODE_WEATHER }, + { LPGEN("Weather service"), "node_weather", IDI_NODE_WEATHER } +}; +static IconItem sharedIconList4[] = +{ { LPGEN("Generic privacy list"), "pl_list_any", IDI_PL_LIST_ANY }, { LPGEN("Active privacy list"), "pl_list_active", IDI_PL_LIST_ACTIVE }, { LPGEN("Default privacy list"), "pl_list_default", IDI_PL_LIST_DEFAULT }, @@ -550,22 +559,36 @@ static IconItem sharedIconList[] = { LPGEN("Deny Messages"), "pl_msg_deny", IDI_PL_MSG_DENY }, { LPGEN("Deny Presences (in)"), "pl_prin_deny", IDI_PL_PRIN_DENY }, { LPGEN("Deny Presences (out)"), "pl_prout_deny", IDI_PL_PROUT_DENY }, - { LPGEN("Deny Queries"), "pl_iq_deny", IDI_PL_QUERY_DENY }, + { LPGEN("Deny Queries"), "pl_iq_deny", IDI_PL_QUERY_DENY } }; void g_IconsInit() { - Icon_Register(hInst, "Protocols/Jabber", sharedIconList, 21, GLOBAL_SETTING_PREFIX); - Icon_Register(hInst, "Protocols/Jabber/Dialogs", sharedIconList+21, 7, GLOBAL_SETTING_PREFIX); - Icon_Register(hInst, "Protocols/Dialogs/Discovery", sharedIconList+28, 7, GLOBAL_SETTING_PREFIX); - Icon_Register(hInst, "Protocols/Dialogs/Privacy", sharedIconList+35, 13, GLOBAL_SETTING_PREFIX); + Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("Jabber"), sharedIconList1, SIZEOF(sharedIconList1), GLOBAL_SETTING_PREFIX); + Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("Jabber")"/"LPGEN("Dialogs"), sharedIconList2, SIZEOF(sharedIconList2), GLOBAL_SETTING_PREFIX); + Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("Dialogs")"/"LPGEN("Discovery"), sharedIconList3, SIZEOF(sharedIconList3), GLOBAL_SETTING_PREFIX); + Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("Dialogs")"/"LPGEN("Privacy"), sharedIconList4, SIZEOF(sharedIconList4), GLOBAL_SETTING_PREFIX); } HANDLE g_GetIconHandle(int iconId) { - for (int i=0; i < SIZEOF(sharedIconList); i++) - if (sharedIconList[i].defIconID == iconId) - return sharedIconList[i].hIcolib; + int i; + + for (i=0; i < SIZEOF(sharedIconList1); i++) + if (sharedIconList1[i].defIconID == iconId) + return sharedIconList1[i].hIcolib; + + for (i=0; i < SIZEOF(sharedIconList2); i++) + if (sharedIconList2[i].defIconID == iconId) + return sharedIconList2[i].hIcolib; + + for (i=0; i < SIZEOF(sharedIconList3); i++) + if (sharedIconList3[i].defIconID == iconId) + return sharedIconList3[i].hIcolib; + + for (i=0; i < SIZEOF(sharedIconList4); i++) + if (sharedIconList4[i].defIconID == iconId) + return sharedIconList4[i].hIcolib; return NULL; } diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 3ec7c0b4b3..8e18335d19 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -202,14 +202,10 @@ void g_MenuInit(void) List_InsertPtr(&arServices, CreateServiceFunction("Jabber/MenuChoose", JabberMenuChooseService)); - TMenuParam mnu = {0}; - mnu.cbSize = sizeof(mnu); - mnu.name = "JabberAccountChooser"; - mnu.ExecService = "Jabber/MenuChoose"; + TMenuParam mnu = { sizeof(mnu), "JabberAccountChooser", "Jabber/MenuChoose" }; hChooserMenu = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&mnu); - TMO_MenuItem tmi = { 0 }; - tmi.cbSize = sizeof(tmi); + TMO_MenuItem tmi = { sizeof(tmi) }; tmi.flags = CMIF_ICONFROMICOLIB; tmi.pszName = "Cancel"; tmi.position = 9999999; -- cgit v1.2.3