From b0226b2361bfca3d57ec3d10e35ba33bde207d71 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 9 Jan 2013 15:52:37 +0000 Subject: minor code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@3030 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/tools.cpp | 701 +++++++++++++++++----------------- plugins/TabSRMM/src/hotkeyhandler.cpp | 688 ++++++++++++++++----------------- 2 files changed, 681 insertions(+), 708 deletions(-) diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 89848ea829..8388350d2c 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -39,11 +39,11 @@ #include "..\commonheaders.h" // externs -extern HICON hIcons[30]; -extern FONTINFO aFonts[OPTIONS_FONTCOUNT]; -extern HMENU g_hMenu; -extern HANDLE hBuildMenuEvent ; -extern HANDLE hSendEvent; +extern HICON hIcons[30]; +extern FONTINFO aFonts[OPTIONS_FONTCOUNT]; +extern HMENU g_hMenu; +extern HANDLE hBuildMenuEvent ; +extern HANDLE hSendEvent; int GetRichTextLength(HWND hwnd) { @@ -93,37 +93,38 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord, bool fToLower, bool fStripCR, TCHA while (j < _buflen && i <= wordlen) { if (pszWord[i] == '%') { switch (pszWord[i+1]) { - case '%': - szTemp[j] = '%'; - j++; - i++; - i++; - break; - case 'b': - case 'u': - case 'i': - case 'B': - case 'U': - case 'I': - case 'r': - case 'C': - case 'F': - i++; - i++; - break; + case '%': + szTemp[j] = '%'; + j++; + i++; + i++; + break; + case 'b': + case 'u': + case 'i': + case 'B': + case 'U': + case 'I': + case 'r': + case 'C': + case 'F': + i++; + i++; + break; - case 'c': - case 'f': - i += 4; - break; + case 'c': + case 'f': + i += 4; + break; - default: - szTemp[j] = pszWord[i]; - j++; - i++; - break; + default: + szTemp[j] = pszWord[i]; + j++; + i++; + break; } - } else { + } + else { if (fStripCR) { if (0x0a == pszWord[i] || 0x0c == pszWord[i]) { szTemp[j++] = ' '; @@ -169,29 +170,27 @@ static void TSAPI Chat_DismissPopup(const SESSION_INFO* si, HWND hwndPopup) static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) { - case WM_COMMAND: - if (HIWORD(wParam) == STN_CLICKED) { - SESSION_INFO* si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);; - - if (si) { - if (nen_options.maskActL & MASK_OPEN) - Chat_OpenPopup(si, hWnd); - else - Chat_DismissPopup(si, hWnd); - } - return TRUE; - } - break; - case WM_CONTEXTMENU: { - SESSION_INFO* si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0); + SESSION_INFO* si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);; - if (si && si->hContact) { - if (nen_options.maskActR & MASK_OPEN) + switch (message) { + case WM_COMMAND: + if ( HIWORD(wParam) == STN_CLICKED) { + if (si) { + if (nen_options.maskActL & MASK_OPEN) Chat_OpenPopup(si, hWnd); else Chat_DismissPopup(si, hWnd); } + return TRUE; + } + break; + + case WM_CONTEXTMENU: + if (si && si->hContact) { + if (nen_options.maskActR & MASK_OPEN) + Chat_OpenPopup(si, hWnd); + else + Chat_DismissPopup(si, hWnd); } break; } @@ -245,59 +244,59 @@ static BOOL DoTrayIcon(SESSION_INFO* si, GCEVENT * gce) if (si && (iEvent & si->iLogTrayFlags)) { switch (iEvent) { - case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT : - case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT : - CList_AddEvent(si->hContact, PluginConfig.g_IconMsgEvent, szChatIconString, 0, - TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName); - break; - case GC_EVENT_MESSAGE : - CList_AddEvent(si->hContact, hIcons[ICON_MESSAGE], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName); - break; - case GC_EVENT_ACTION: - CList_AddEvent(si->hContact, hIcons[ICON_ACTION], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName); - break; - case GC_EVENT_JOIN: - CList_AddEvent(si->hContact, hIcons[ICON_JOIN], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName); - break; - case GC_EVENT_PART: - CList_AddEvent(si->hContact, hIcons[ICON_PART], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s has left %s"), gce->ptszNick, si->ptszName); - break; - case GC_EVENT_QUIT: - CList_AddEvent(si->hContact, hIcons[ICON_QUIT], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s has disconnected"), gce->ptszNick); - break; - case GC_EVENT_NICK: - CList_AddEvent(si->hContact, hIcons[ICON_NICK], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s is now known as %s"), gce->ptszNick, gce->pszText); - break; - case GC_EVENT_KICK: - CList_AddEvent(si->hContact, hIcons[ICON_KICK], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s kicked %s from %s"), gce->pszStatus, gce->ptszNick, si->ptszName); - break; - case GC_EVENT_NOTICE: - CList_AddEvent(si->hContact, hIcons[ICON_NOTICE], szChatIconString, CLEF_ONLYAFEW, - TranslateT("Notice from %s"), gce->ptszNick); - break; - case GC_EVENT_TOPIC: - CList_AddEvent(si->hContact, hIcons[ICON_TOPIC], szChatIconString, CLEF_ONLYAFEW, - TranslateT("Topic change in %s"), si->ptszName); - break; - case GC_EVENT_INFORMATION: - CList_AddEvent(si->hContact, hIcons[ICON_INFO], szChatIconString, CLEF_ONLYAFEW, - TranslateT("Information in %s"), si->ptszName); - break; - case GC_EVENT_ADDSTATUS: - CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s enables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); - break; - case GC_EVENT_REMOVESTATUS: - CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], szChatIconString, CLEF_ONLYAFEW, - TranslateT("%s disables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); - break; + case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT : + case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT : + CList_AddEvent(si->hContact, PluginConfig.g_IconMsgEvent, szChatIconString, 0, + TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName); + break; + case GC_EVENT_MESSAGE : + CList_AddEvent(si->hContact, hIcons[ICON_MESSAGE], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName); + break; + case GC_EVENT_ACTION: + CList_AddEvent(si->hContact, hIcons[ICON_ACTION], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName); + break; + case GC_EVENT_JOIN: + CList_AddEvent(si->hContact, hIcons[ICON_JOIN], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName); + break; + case GC_EVENT_PART: + CList_AddEvent(si->hContact, hIcons[ICON_PART], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s has left %s"), gce->ptszNick, si->ptszName); + break; + case GC_EVENT_QUIT: + CList_AddEvent(si->hContact, hIcons[ICON_QUIT], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s has disconnected"), gce->ptszNick); + break; + case GC_EVENT_NICK: + CList_AddEvent(si->hContact, hIcons[ICON_NICK], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s is now known as %s"), gce->ptszNick, gce->pszText); + break; + case GC_EVENT_KICK: + CList_AddEvent(si->hContact, hIcons[ICON_KICK], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s kicked %s from %s"), gce->pszStatus, gce->ptszNick, si->ptszName); + break; + case GC_EVENT_NOTICE: + CList_AddEvent(si->hContact, hIcons[ICON_NOTICE], szChatIconString, CLEF_ONLYAFEW, + TranslateT("Notice from %s"), gce->ptszNick); + break; + case GC_EVENT_TOPIC: + CList_AddEvent(si->hContact, hIcons[ICON_TOPIC], szChatIconString, CLEF_ONLYAFEW, + TranslateT("Topic change in %s"), si->ptszName); + break; + case GC_EVENT_INFORMATION: + CList_AddEvent(si->hContact, hIcons[ICON_INFO], szChatIconString, CLEF_ONLYAFEW, + TranslateT("Information in %s"), si->ptszName); + break; + case GC_EVENT_ADDSTATUS: + CList_AddEvent(si->hContact, hIcons[ICON_ADDSTATUS], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s enables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + break; + case GC_EVENT_REMOVESTATUS: + CList_AddEvent(si->hContact, hIcons[ICON_REMSTATUS], szChatIconString, CLEF_ONLYAFEW, + TranslateT("%s disables \'%s\' status for %s in %s"), gce->pszText, gce->pszStatus, gce->ptszNick, si->ptszName); + break; } } return TRUE; @@ -310,17 +309,13 @@ static BOOL DoPopup(SESSION_INFO* si, GCEVENT* gce, struct TWindowData* dat) char *szProto = dat ? dat->szProto : si->pszModule; TCHAR *bbStart, *bbEnd; - if (g_Settings.BBCodeInPopups) - { + if (g_Settings.BBCodeInPopups) { bbStart = _T("[b]"); bbEnd = _T("[/b]"); - } else - { - bbStart = bbEnd = _T(""); } + else bbStart = bbEnd = _T(""); if (si && (iEvent & si->iLogPopupFlags)) { - if (nen_options.iMUCDisable) // no popups at all. Period return 0; /* @@ -368,69 +363,70 @@ passed: clr = aFonts[16].color; iNewEvent &= ~GC_EVENT_HIGHLIGHT; } + switch (iNewEvent) { - case GC_EVENT_MESSAGE : - ShowPopup(si->hContact, si, hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : aFonts[9].color, - TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_ACTION: - ShowPopup(si->hContact, si, hIcons[ICON_ACTION], si->pszModule, si->ptszName, clr ? clr : aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_JOIN: - ShowPopup(si->hContact, si, hIcons[ICON_JOIN], si->pszModule, si->ptszName, clr ? clr : aFonts[3].color, - TranslateT("%s has joined"), gce->ptszNick); - break; - case GC_EVENT_PART: - if (!gce->pszText) - ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : aFonts[4].color, - TranslateT("%s has left"), gce->ptszNick); - else - ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : aFonts[4].color, - TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_QUIT: - if (!gce->pszText) - ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color, - TranslateT("%s has disconnected"), gce->ptszNick); - else - ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color, - TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_NICK: - ShowPopup(si->hContact, si, hIcons[ICON_NICK], si->pszModule, si->ptszName, clr ? clr : aFonts[7].color, - TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); - break; - case GC_EVENT_KICK: - if (!gce->pszText) - ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color, - TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); - else - ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color, - TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_NOTICE: - ShowPopup(si->hContact, si, hIcons[ICON_NOTICE], si->pszModule, si->ptszName, clr ? clr : aFonts[8].color, - TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_TOPIC: - if (!gce->ptszNick) - ShowPopup(si->hContact, si, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, clr ? clr : aFonts[11].color, - TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText)); - else - ShowPopup(si->hContact, si, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, clr ? clr : aFonts[11].color, - TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick); - break; - case GC_EVENT_INFORMATION: - ShowPopup(si->hContact, si, hIcons[ICON_INFO], si->pszModule, si->ptszName, clr ? clr : aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_ADDSTATUS: - ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[13].color, - TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); - break; - case GC_EVENT_REMOVESTATUS: - ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[14].color, - TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); - break; + case GC_EVENT_MESSAGE : + ShowPopup(si->hContact, si, hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, clr ? clr : aFonts[9].color, + TranslateT("%s%s says:%s %s"), bbStart, gce->ptszNick, bbEnd, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_ACTION: + ShowPopup(si->hContact, si, hIcons[ICON_ACTION], si->pszModule, si->ptszName, clr ? clr : aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_JOIN: + ShowPopup(si->hContact, si, hIcons[ICON_JOIN], si->pszModule, si->ptszName, clr ? clr : aFonts[3].color, + TranslateT("%s has joined"), gce->ptszNick); + break; + case GC_EVENT_PART: + if (!gce->pszText) + ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : aFonts[4].color, + TranslateT("%s has left"), gce->ptszNick); + else + ShowPopup(si->hContact, si, hIcons[ICON_PART], si->pszModule, si->ptszName, clr ? clr : aFonts[4].color, + TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_QUIT: + if (!gce->pszText) + ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color, + TranslateT("%s has disconnected"), gce->ptszNick); + else + ShowPopup(si->hContact, si, hIcons[ICON_QUIT], si->pszModule, si->ptszName, clr ? clr : aFonts[5].color, + TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_NICK: + ShowPopup(si->hContact, si, hIcons[ICON_NICK], si->pszModule, si->ptszName, clr ? clr : aFonts[7].color, + TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); + break; + case GC_EVENT_KICK: + if (!gce->pszText) + ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color, + TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); + else + ShowPopup(si->hContact, si, hIcons[ICON_KICK], si->pszModule, si->ptszName, clr ? clr : aFonts[6].color, + TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_NOTICE: + ShowPopup(si->hContact, si, hIcons[ICON_NOTICE], si->pszModule, si->ptszName, clr ? clr : aFonts[8].color, + TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_TOPIC: + if (!gce->ptszNick) + ShowPopup(si->hContact, si, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, clr ? clr : aFonts[11].color, + TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText)); + else + ShowPopup(si->hContact, si, hIcons[ICON_TOPIC], si->pszModule, si->ptszName, clr ? clr : aFonts[11].color, + TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick); + break; + case GC_EVENT_INFORMATION: + ShowPopup(si->hContact, si, hIcons[ICON_INFO], si->pszModule, si->ptszName, clr ? clr : aFonts[12].color, _T("%s"), RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_ADDSTATUS: + ShowPopup(si->hContact, si, hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[13].color, + TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + break; + case GC_EVENT_REMOVESTATUS: + ShowPopup(si->hContact, si, hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, clr ? clr : aFonts[14].color, + TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + break; } } @@ -500,19 +496,18 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p) FlashContainer(dat->pContainer, 1, 0); if (p->hNotifyIcon && p->bInactive && ((p->iEvent & si->iLogTrayFlags) || bForcedIcon)) { - HICON hIcon; - if (p->bMustFlash) dat->hTabIcon = p->hNotifyIcon; else if (dat->iFlashIcon) { - TCITEM item = {0}; - dat->hTabIcon = dat->iFlashIcon; + + TCITEM item = {0}; item.mask = TCIF_IMAGE; item.iImage = 0; TabCtrl_SetItem(GetParent(si->hWnd), dat->iTabID, &item); } - hIcon = (HICON)SendMessage(dat->pContainer->hwnd, WM_GETICON, ICON_BIG, 0); + + HICON hIcon = (HICON)SendMessage(dat->pContainer->hwnd, WM_GETICON, ICON_BIG, 0); if (p->hNotifyIcon == hIcons[ICON_HIGHLIGHT] || (hIcon != hIcons[ICON_MESSAGE] && hIcon != hIcons[ICON_HIGHLIGHT])) { SendMessage(dat->pContainer->hwnd, DM_SETICON, (WPARAM)dat, (LPARAM)p->hNotifyIcon); dat->pContainer->dwFlags |= CNT_NEED_UPDATETITLE; @@ -591,92 +586,93 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO* si, GCEVENT * gce, BOOL bHighligh // do sounds and flashing switch (params->iEvent) { - case GC_EVENT_JOIN: - params->sound = "ChatJoin"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_JOIN]; - break; - case GC_EVENT_PART: - params->sound = "ChatPart"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_PART]; - break; - case GC_EVENT_QUIT: - params->sound = "ChatQuit"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_QUIT]; - break; - case GC_EVENT_ADDSTATUS: - case GC_EVENT_REMOVESTATUS: - params->sound = "ChatMode"; - if (params->bInactive) - params->hNotifyIcon = hIcons[params->iEvent == GC_EVENT_ADDSTATUS ? ICON_ADDSTATUS : ICON_REMSTATUS]; - break; - case GC_EVENT_KICK: - params->sound = "ChatKick"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_KICK]; - break; - case GC_EVENT_MESSAGE: - params->sound = "ChatMessage"; - if (params->bInactive && !(si->wState&STATE_TALK)) { - si->wState |= STATE_TALK; - DBWriteContactSettingWord(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD) 40071); - } - break; - case GC_EVENT_ACTION: - params->sound = "ChatAction"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_ACTION]; - break; - case GC_EVENT_NICK: - params->sound = "ChatNick"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_NICK]; - break; - case GC_EVENT_NOTICE: - params->sound = "ChatNotice"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_NOTICE]; - break; - case GC_EVENT_TOPIC: - params->sound = "ChatTopic"; - if (params->bInactive) - params->hNotifyIcon = hIcons[ICON_TOPIC]; - break; - } - } else { - switch (params->iEvent) { - case GC_EVENT_JOIN: + case GC_EVENT_JOIN: + params->sound = "ChatJoin"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_JOIN]; - break; - case GC_EVENT_PART: + break; + case GC_EVENT_PART: + params->sound = "ChatPart"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_PART]; - break; - case GC_EVENT_QUIT: + break; + case GC_EVENT_QUIT: + params->sound = "ChatQuit"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_QUIT]; - break; - case GC_EVENT_KICK: + break; + case GC_EVENT_ADDSTATUS: + case GC_EVENT_REMOVESTATUS: + params->sound = "ChatMode"; + if (params->bInactive) + params->hNotifyIcon = hIcons[params->iEvent == GC_EVENT_ADDSTATUS ? ICON_ADDSTATUS : ICON_REMSTATUS]; + break; + case GC_EVENT_KICK: + params->sound = "ChatKick"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_KICK]; - break; - case GC_EVENT_ACTION: + break; + case GC_EVENT_MESSAGE: + params->sound = "ChatMessage"; + if (params->bInactive && !(si->wState&STATE_TALK)) { + si->wState |= STATE_TALK; + DBWriteContactSettingWord(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD) 40071); + } + break; + case GC_EVENT_ACTION: + params->sound = "ChatAction"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_ACTION]; - break; - case GC_EVENT_NICK: + break; + case GC_EVENT_NICK: + params->sound = "ChatNick"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_NICK]; - break; - case GC_EVENT_NOTICE: + break; + case GC_EVENT_NOTICE: + params->sound = "ChatNotice"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_NOTICE]; - break; - case GC_EVENT_TOPIC: + break; + case GC_EVENT_TOPIC: + params->sound = "ChatTopic"; + if (params->bInactive) params->hNotifyIcon = hIcons[ICON_TOPIC]; - break; - case GC_EVENT_ADDSTATUS: - params->hNotifyIcon = hIcons[ICON_ADDSTATUS]; - break; - case GC_EVENT_REMOVESTATUS: - params->hNotifyIcon = hIcons[ICON_REMSTATUS]; - break; + break; + } + } + else { + switch (params->iEvent) { + case GC_EVENT_JOIN: + params->hNotifyIcon = hIcons[ICON_JOIN]; + break; + case GC_EVENT_PART: + params->hNotifyIcon = hIcons[ICON_PART]; + break; + case GC_EVENT_QUIT: + params->hNotifyIcon = hIcons[ICON_QUIT]; + break; + case GC_EVENT_KICK: + params->hNotifyIcon = hIcons[ICON_KICK]; + break; + case GC_EVENT_ACTION: + params->hNotifyIcon = hIcons[ICON_ACTION]; + break; + case GC_EVENT_NICK: + params->hNotifyIcon = hIcons[ICON_NICK]; + break; + case GC_EVENT_NOTICE: + params->hNotifyIcon = hIcons[ICON_NOTICE]; + break; + case GC_EVENT_TOPIC: + params->hNotifyIcon = hIcons[ICON_TOPIC]; + break; + case GC_EVENT_ADDSTATUS: + params->hNotifyIcon = hIcons[ICON_ADDSTATUS]; + break; + case GC_EVENT_REMOVESTATUS: + params->hNotifyIcon = hIcons[ICON_REMSTATUS]; + break; } } @@ -699,12 +695,10 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO* si, GCEVENT * gce, BOOL bHighligh int Chat_GetColorIndex(const char* pszModule, COLORREF cr) { MODULEINFO * pMod = MM_FindModule(pszModule); - int i = 0; - if (!pMod || pMod->nColorCount == 0) return -1; - for (i=0; i < pMod->nColorCount; i++) + for (int i=0; i < pMod->nColorCount; i++) if (pMod->crColors[i] == cr) return i; @@ -719,7 +713,6 @@ int Chat_GetColorIndex(const char* pszModule, COLORREF cr) void CheckColorsInModule(const char* pszModule) { MODULEINFO * pMod = MM_FindModule(pszModule); - int i = 0; COLORREF crFG; COLORREF crBG = (COLORREF)M->GetDword(FONTMODULE, "inputbg", SRMSGDEFSET_BKGCOLOUR); @@ -728,7 +721,7 @@ void CheckColorsInModule(const char* pszModule) if (!pMod) return; - for (i=0; i < pMod->nColorCount; i++) { + for (int i=0; i < pMod->nColorCount; i++) { if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) { if (pMod->crColors[i] == RGB(255, 255, 255)) pMod->crColors[i]--; @@ -757,7 +750,6 @@ TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) */ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) { - MODULEINFO * mi = NULL; TCHAR szBuffer[4096]; TCHAR szLine[4096]; TCHAR szTime[100]; @@ -769,7 +761,7 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) if (!si || !gce) return FALSE; - mi = MM_FindModule(si->pszModule); + MODULEINFO *mi = MM_FindModule(si->pszModule); if (!mi) return FALSE; @@ -800,7 +792,8 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) if (g_Settings.LogLimitNames && lstrlen(gce->ptszNick) > 20) { lstrcpyn(szTemp2, gce->ptszNick, 20); lstrcpyn(szTemp2 + 20, _T("..."), 4); - } else lstrcpyn(szTemp2, gce->ptszNick, 511); + } + else lstrcpyn(szTemp2, gce->ptszNick, 511); if (gce->pszUserInfo) mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, gce->pszUserInfo); @@ -808,70 +801,72 @@ BOOL LogToFile(SESSION_INFO* si, GCEVENT * gce) mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), szTemp2); pszNick = szTemp; } + switch (gce->pDest->iType) { - case GC_EVENT_MESSAGE: - case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: - p = '*'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_ACTION: - case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT: - p = '*'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_JOIN: - p = '>'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char *)pszNick); - break; - case GC_EVENT_PART: - p = '<'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick); - else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_QUIT: - p = '<'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick); - else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_NICK: - p = '^'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); - break; - case GC_EVENT_KICK: - p = '~'; - if (!gce->pszText) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); - else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_NOTICE: - p = 'o'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_TOPIC: - p = '#'; - if (!gce->pszNick) - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText)); - else - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick); - break; - case GC_EVENT_INFORMATION: - p = '!'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), RemoveFormatting(gce->ptszText)); - break; - case GC_EVENT_ADDSTATUS: - p = '+'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); - break; - case GC_EVENT_REMOVESTATUS: - p = '-'; - mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); - break; + case GC_EVENT_MESSAGE: + case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: + p = '*'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_ACTION: + case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT: + p = '*'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_JOIN: + p = '>'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has joined"), (char *)pszNick); + break; + case GC_EVENT_PART: + p = '<'; + if (!gce->pszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char *)pszNick); + else + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_QUIT: + p = '<'; + if (!gce->pszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char *)pszNick); + else + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char *)pszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_NICK: + p = '^'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText); + break; + case GC_EVENT_KICK: + p = '~'; + if (!gce->pszText) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s"), (char *)gce->pszStatus, gce->ptszNick); + else + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s kicked %s (%s)"), (char *)gce->pszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_NOTICE: + p = 'o'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_TOPIC: + p = '#'; + if (!gce->pszNick) + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\'"), RemoveFormatting(gce->ptszText)); + else + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("The topic is \'%s\' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick); + break; + case GC_EVENT_INFORMATION: + p = '!'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), RemoveFormatting(gce->ptszText)); + break; + case GC_EVENT_ADDSTATUS: + p = '+'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s enables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + break; + case GC_EVENT_REMOVESTATUS: + p = '-'; + mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s disables \'%s\' status for %s"), gce->ptszText, (char *)gce->pszStatus, gce->ptszNick); + break; } + /* * formatting strings don't need to be translatable - changing them via language pack would * only screw up the log format. @@ -967,7 +962,8 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText); } else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up")); gcmi.Type = MENU_ON_LOG; - } else if (iIndex == 0) { + } + else if (iIndex == 0) { TCHAR szTemp[30], szTemp2[30]; lstrcpyn(szTemp, TranslateT("&Message"), 24); if (pszUID) @@ -1042,8 +1038,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO void DestroyGCMenu(HMENU *hMenu, int iIndex) { - MENUITEMINFO mi; - mi.cbSize = sizeof(mi); + MENUITEMINFO mi = { sizeof(mi) }; mi.fMask = MIIM_SUBMENU; while (GetMenuItemInfo(*hMenu, iIndex, TRUE, &mi)) { if (mi.hSubMenu != NULL) @@ -1115,32 +1110,32 @@ BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCH BOOL IsEventSupported(int eventType) { + // Supported events switch (eventType) { - // Supported events - case GC_EVENT_JOIN: - case GC_EVENT_PART: - case GC_EVENT_QUIT: - case GC_EVENT_KICK: - case GC_EVENT_NICK: - case GC_EVENT_NOTICE: - case GC_EVENT_MESSAGE: - case GC_EVENT_TOPIC: - case GC_EVENT_INFORMATION: - case GC_EVENT_ACTION: - case GC_EVENT_ADDSTATUS: - case GC_EVENT_REMOVESTATUS: - case GC_EVENT_CHUID: - case GC_EVENT_CHANGESESSIONAME: - case GC_EVENT_ADDGROUP: - case GC_EVENT_SETITEMDATA: - case GC_EVENT_GETITEMDATA: - case GC_EVENT_SETSBTEXT: - case GC_EVENT_ACK: - case GC_EVENT_SENDMESSAGE: - case GC_EVENT_SETSTATUSEX: - case GC_EVENT_CONTROL: - case GC_EVENT_SETCONTACTSTATUS: - return TRUE; + case GC_EVENT_JOIN: + case GC_EVENT_PART: + case GC_EVENT_QUIT: + case GC_EVENT_KICK: + case GC_EVENT_NICK: + case GC_EVENT_NOTICE: + case GC_EVENT_MESSAGE: + case GC_EVENT_TOPIC: + case GC_EVENT_INFORMATION: + case GC_EVENT_ACTION: + case GC_EVENT_ADDSTATUS: + case GC_EVENT_REMOVESTATUS: + case GC_EVENT_CHUID: + case GC_EVENT_CHANGESESSIONAME: + case GC_EVENT_ADDGROUP: + case GC_EVENT_SETITEMDATA: + case GC_EVENT_GETITEMDATA: + case GC_EVENT_SETSBTEXT: + case GC_EVENT_ACK: + case GC_EVENT_SENDMESSAGE: + case GC_EVENT_SETSTATUSEX: + case GC_EVENT_CONTROL: + case GC_EVENT_SETCONTACTSTATUS: + return TRUE; } // Other events diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 48bafd5e2b..5ff1997886 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -92,15 +92,12 @@ LRESULT ProcessHotkeysByMsgFilter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa return(SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&mf)); } + static INT_PTR HotkeyProcessor(WPARAM wParam, LPARAM lParam) { - switch(lParam) { - case TABSRMM_HK_LASTUNREAD: - PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, WM_MBUTTONDOWN); - break; - default: - break; - } + if (lParam == TABSRMM_HK_LASTUNREAD) + PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, WM_MBUTTONDOWN); + return 0; } @@ -113,18 +110,19 @@ void TSAPI HandleMenuEntryFromhContact(int iSelection) return; if (hWnd && IsWindow(hWnd)) { - struct TContainerData *pContainer = 0; + TContainerData *pContainer = 0; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { ActivateExistingTab(pContainer, hWnd); pContainer->hwndSaved = 0; SetForegroundWindow(pContainer->hwnd); - } else - CallService(MS_MSG_SENDMESSAGE, (WPARAM)iSelection, 0); - } else if ((si = SM_FindSessionByHCONTACT((HANDLE)iSelection)) != NULL) { - if (si->hWnd) { // session does exist, but no window is open for it - struct TContainerData *pContainer = 0; - + } + else CallService(MS_MSG_SENDMESSAGE, (WPARAM)iSelection, 0); + } + else if ((si = SM_FindSessionByHCONTACT((HANDLE)iSelection)) != NULL) { + // session does exist, but no window is open for it + if (si->hWnd) { + TContainerData *pContainer = 0; SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { ActivateExistingTab(pContainer, si->hWnd); @@ -144,9 +142,9 @@ nothing_open: void TSAPI DrawMenuItem(DRAWITEMSTRUCT *dis, HICON hIcon, DWORD dwIdle) { FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_MENU)); - if (dwIdle) { + if (dwIdle) CSkin::DrawDimmedIcon(dis->hDC, 2, (dis->rcItem.bottom + dis->rcItem.top - 16) / 2, 16, 16, hIcon, 180); - } else + else DrawIconEx(dis->hDC, 2, (dis->rcItem.bottom + dis->rcItem.top - 16) / 2, hIcon, 16, 16, 0, 0, DI_NORMAL | DI_COMPAT); } @@ -154,31 +152,33 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { static POINT ptLast; static int iMousedown; - + if (msg == WM_TASKBARCREATED) { CreateSystrayIcon(FALSE); if (nen_options.bTraySupport) CreateSystrayIcon(TRUE); return 0; } - switch (msg) { - case WM_CREATE: - int i; - for (i=0; i < safe_sizeof(_hotkeydescs); i++) { - _hotkeydescs[i].cbSize = sizeof(HOTKEYDESC); - Hotkey_Register(&_hotkeydescs[i]); - } + TContainerData *pContainer = pFirstContainer; + int iSelection; - WM_TASKBARCREATED = RegisterWindowMessageA("TaskbarCreated"); - ShowWindow(hwndDlg, SW_HIDE); - hSvcHotkeyProcessor = CreateServiceFunction(MS_TABMSG_HOTKEYPROCESS, HotkeyProcessor); - SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, NULL); - break; - case WM_HOTKEY: { - CLISTEVENT *cli = 0; + switch (msg) { + case WM_CREATE: + for (int i=0; i < safe_sizeof(_hotkeydescs); i++) { + _hotkeydescs[i].cbSize = sizeof(HOTKEYDESC); + Hotkey_Register(&_hotkeydescs[i]); + } - cli = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, (WPARAM)INVALID_HANDLE_VALUE, 0); + WM_TASKBARCREATED = RegisterWindowMessageA("TaskbarCreated"); + ShowWindow(hwndDlg, SW_HIDE); + hSvcHotkeyProcessor = CreateServiceFunction(MS_TABMSG_HOTKEYPROCESS, HotkeyProcessor); + SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, NULL); + break; + + case WM_HOTKEY: + { + CLISTEVENT *cli = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, (WPARAM)INVALID_HANDLE_VALUE, 0); if (cli != NULL) { if (strncmp(cli->pszService, "SRMsg/TypingMessage", strlen(cli->pszService))) { CallService(cli->pszService, 0, (LPARAM)cli); @@ -187,20 +187,23 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } if (wParam == 0xc001) SendMessage(hwndDlg, DM_TRAYICONNOTIFY, 101, WM_MBUTTONDOWN); - - break; } + break; + /* - * handle the popup menus (session list, favorites, recents... - * just draw some icons, nothing more :) - */ - case WM_MEASUREITEM: { + * handle the popup menus (session list, favorites, recents... + * just draw some icons, nothing more :) + */ + case WM_MEASUREITEM: + { LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT) lParam; lpmi->itemHeight = 0; lpmi->itemWidth = 6; - return TRUE; } - case WM_DRAWITEM: { + return TRUE; + + case WM_DRAWITEM: + { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam; struct TWindowData *dat = 0; if (dis->CtlType == ODT_MENU && (dis->hwndItem == (HWND)PluginConfig.g_hMenuFavorites || dis->hwndItem == (HWND)PluginConfig.g_hMenuRecent)) { @@ -208,13 +211,13 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP DrawMenuItem(dis, hIcon, 0); return TRUE; - } else if (dis->CtlType == ODT_MENU) { + } + else if (dis->CtlType == ODT_MENU) { HWND hWnd = M->FindWindow((HANDLE)dis->itemID); DWORD idle = 0; if (hWnd == NULL) { SESSION_INFO *si = SM_FindSessionByHCONTACT((HANDLE)dis->itemID); - hWnd = si ? si->hWnd : 0; } @@ -223,201 +226,187 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (dis->itemData >= 0) { HICON hIcon; - BOOL fNeedFree = FALSE; if (dis->itemData > 0) hIcon = dis->itemData & 0x10000000 ? hIcons[ICON_HIGHLIGHT] : PluginConfig.g_IconMsgEvent; else if (dat != NULL) { hIcon = MY_GetContactIcon(dat); idle = dat->idle; - } else - hIcon = PluginConfig.g_iconContainer; + } + else hIcon = PluginConfig.g_iconContainer; DrawMenuItem(dis, hIcon, idle); - if (fNeedFree) - DestroyIcon(hIcon); - return TRUE; } } } break; - case DM_TRAYICONNOTIFY: { - int iSelection; - - if (wParam == 100 || wParam == 101) { - switch (lParam) { - case WM_LBUTTONUP: { - POINT pt; - GetCursorPos(&pt); - if (wParam == 100) - SetForegroundWindow(hwndDlg); - if (GetMenuItemCount(PluginConfig.g_hMenuTrayUnread) > 0) { - iSelection = TrackPopupMenu(PluginConfig.g_hMenuTrayUnread, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); - HandleMenuEntryFromhContact(iSelection); - } else - TrackPopupMenu(GetSubMenu(PluginConfig.g_hMenuContext, 8), TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); - if (wParam == 100) - PostMessage(hwndDlg, WM_NULL, 0, 0); - break; + + case DM_TRAYICONNOTIFY: + if (wParam == 100 || wParam == 101) { + switch (lParam) { + case WM_LBUTTONUP: + { + POINT pt; + GetCursorPos(&pt); + if (wParam == 100) + SetForegroundWindow(hwndDlg); + if (GetMenuItemCount(PluginConfig.g_hMenuTrayUnread) > 0) { + iSelection = TrackPopupMenu(PluginConfig.g_hMenuTrayUnread, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); + HandleMenuEntryFromhContact(iSelection); } - case WM_MBUTTONDOWN: { + else TrackPopupMenu(GetSubMenu(PluginConfig.g_hMenuContext, 8), TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); + + if (wParam == 100) + PostMessage(hwndDlg, WM_NULL, 0, 0); + } + break; + + case WM_MBUTTONDOWN: + { + if (wParam == 100) + SetForegroundWindow(hwndDlg); + + int iCount = GetMenuItemCount(PluginConfig.g_hMenuTrayUnread); + if (iCount > 0) { + UINT uid = 0; MENUITEMINFOA mii = {0}; - int i, iCount = GetMenuItemCount(PluginConfig.g_hMenuTrayUnread); - - if (wParam == 100) - SetForegroundWindow(hwndDlg); - - if (iCount > 0) { - UINT uid = 0; - mii.fMask = MIIM_DATA; - mii.cbSize = sizeof(mii); - i = iCount - 1; - do { - GetMenuItemInfoA(PluginConfig.g_hMenuTrayUnread, i, TRUE, &mii); - if (mii.dwItemData > 0) { - uid = GetMenuItemID(PluginConfig.g_hMenuTrayUnread, i); - HandleMenuEntryFromhContact(uid); - break; - } - } while (--i >= 0); - if (uid == 0 && pLastActiveContainer != NULL) { // no session found, restore last active container - if (IsIconic(pLastActiveContainer->hwnd) || !IsWindowVisible(pLastActiveContainer->hwnd)) { - SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); - SetForegroundWindow(pLastActiveContainer->hwnd); - SetFocus(GetDlgItem(pLastActiveContainer->hwndActive, IDC_MESSAGE)); - } else if (GetForegroundWindow() != pLastActiveContainer->hwnd) { - SetForegroundWindow(pLastActiveContainer->hwnd); - SetFocus(GetDlgItem(pLastActiveContainer->hwndActive, IDC_MESSAGE)); - } else { - if (PluginConfig.m_HideOnClose) - ShowWindow(pLastActiveContainer->hwnd, SW_HIDE); - else - SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); - } + mii.fMask = MIIM_DATA; + mii.cbSize = sizeof(mii); + int i = iCount - 1; + do { + GetMenuItemInfoA(PluginConfig.g_hMenuTrayUnread, i, TRUE, &mii); + if (mii.dwItemData > 0) { + uid = GetMenuItemID(PluginConfig.g_hMenuTrayUnread, i); + HandleMenuEntryFromhContact(uid); + break; + } + } + while (--i >= 0); + + if (uid == 0 && pLastActiveContainer != NULL) { // no session found, restore last active container + if (IsIconic(pLastActiveContainer->hwnd) || !IsWindowVisible(pLastActiveContainer->hwnd)) { + SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); + SetForegroundWindow(pLastActiveContainer->hwnd); + SetFocus(GetDlgItem(pLastActiveContainer->hwndActive, IDC_MESSAGE)); + } + else if (GetForegroundWindow() != pLastActiveContainer->hwnd) { + SetForegroundWindow(pLastActiveContainer->hwnd); + SetFocus(GetDlgItem(pLastActiveContainer->hwndActive, IDC_MESSAGE)); + } + else { + if (PluginConfig.m_HideOnClose) + ShowWindow(pLastActiveContainer->hwnd, SW_HIDE); + else + SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); } } - if (wParam == 100) - PostMessage(hwndDlg, WM_NULL, 0, 0); - break; } - case WM_RBUTTONUP: { - HMENU submenu = PluginConfig.g_hMenuTrayContext; - POINT pt; - - if (wParam == 100) - SetForegroundWindow(hwndDlg); - GetCursorPos(&pt); - CheckMenuItem(submenu, ID_TRAYCONTEXT_DISABLEALLPOPUPS, MF_BYCOMMAND | (nen_options.iDisable ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(submenu, ID_TRAYCONTEXT_DON40223, MF_BYCOMMAND | (nen_options.iNoSounds ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(submenu, ID_TRAYCONTEXT_DON, MF_BYCOMMAND | (nen_options.iNoAutoPopup ? MF_CHECKED : MF_UNCHECKED)); - EnableMenuItem(submenu, ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS, MF_BYCOMMAND | (nen_options.bTraySupport) ? MF_ENABLED : MF_GRAYED); - CheckMenuItem(submenu, ID_TRAYCONTEXT_SHOWTHETRAYICON, MF_BYCOMMAND | (nen_options.bTraySupport ? MF_CHECKED : MF_UNCHECKED)); - iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); - - if (iSelection) { - MENUITEMINFO mii = {0}; - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_DATA | MIIM_ID; - GetMenuItemInfo(submenu, (UINT_PTR)iSelection, FALSE, &mii); - if (mii.dwItemData != 0) { // this must be an itm of the fav or recent menu - HandleMenuEntryFromhContact(iSelection); - } else { - switch (iSelection) { - case ID_TRAYCONTEXT_SHOWTHETRAYICON: - nen_options.bTraySupport = !nen_options.bTraySupport; - CreateSystrayIcon(nen_options.bTraySupport ? TRUE : FALSE); - break; - case ID_TRAYCONTEXT_DISABLEALLPOPUPS: - nen_options.iDisable ^= 1; - break; - case ID_TRAYCONTEXT_DON40223: - nen_options.iNoSounds ^= 1; - break; - case ID_TRAYCONTEXT_DON: - nen_options.iNoAutoPopup ^= 1; - break; - case ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS: { - struct TContainerData *pContainer = pFirstContainer; - - while (pContainer) { - ShowWindow(pContainer->hwnd, SW_HIDE); - pContainer = pContainer->pNextContainer; - } - break; - } - case ID_TRAYCONTEXT_RESTOREALLMESSAGECONTAINERS: { - struct TContainerData *pContainer = pFirstContainer; - - while (pContainer) { - ShowWindow(pContainer->hwnd, SW_SHOW); - pContainer = pContainer->pNextContainer; - } - break; - } - case ID_TRAYCONTEXT_BE: { - struct TContainerData *pContainer = pFirstContainer; - - nen_options.iDisable = 1; - nen_options.iNoSounds = 1; - nen_options.iNoAutoPopup = 1; - - while (pContainer) { - SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 1); - pContainer = pContainer->pNextContainer; - } - break; - } + if (wParam == 100) + PostMessage(hwndDlg, WM_NULL, 0, 0); + } + break; + + case WM_RBUTTONUP: + { + HMENU submenu = PluginConfig.g_hMenuTrayContext; + POINT pt; + + if (wParam == 100) + SetForegroundWindow(hwndDlg); + GetCursorPos(&pt); + CheckMenuItem(submenu, ID_TRAYCONTEXT_DISABLEALLPOPUPS, MF_BYCOMMAND | (nen_options.iDisable ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(submenu, ID_TRAYCONTEXT_DON40223, MF_BYCOMMAND | (nen_options.iNoSounds ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(submenu, ID_TRAYCONTEXT_DON, MF_BYCOMMAND | (nen_options.iNoAutoPopup ? MF_CHECKED : MF_UNCHECKED)); + EnableMenuItem(submenu, ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS, MF_BYCOMMAND | (nen_options.bTraySupport) ? MF_ENABLED : MF_GRAYED); + CheckMenuItem(submenu, ID_TRAYCONTEXT_SHOWTHETRAYICON, MF_BYCOMMAND | (nen_options.bTraySupport ? MF_CHECKED : MF_UNCHECKED)); + iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); + if (iSelection) { + MENUITEMINFO mii = {0}; + + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_DATA | MIIM_ID; + GetMenuItemInfo(submenu, (UINT_PTR)iSelection, FALSE, &mii); + if (mii.dwItemData != 0) // this must be an itm of the fav or recent menu + HandleMenuEntryFromhContact(iSelection); + else { + switch (iSelection) { + case ID_TRAYCONTEXT_SHOWTHETRAYICON: + nen_options.bTraySupport = !nen_options.bTraySupport; + CreateSystrayIcon(nen_options.bTraySupport ? TRUE : FALSE); + break; + case ID_TRAYCONTEXT_DISABLEALLPOPUPS: + nen_options.iDisable ^= 1; + break; + case ID_TRAYCONTEXT_DON40223: + nen_options.iNoSounds ^= 1; + break; + case ID_TRAYCONTEXT_DON: + nen_options.iNoAutoPopup ^= 1; + break; + case ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS: + while (pContainer) { + ShowWindow(pContainer->hwnd, SW_HIDE); + pContainer = pContainer->pNextContainer; + } + break; + case ID_TRAYCONTEXT_RESTOREALLMESSAGECONTAINERS: + while (pContainer) { + ShowWindow(pContainer->hwnd, SW_SHOW); + pContainer = pContainer->pNextContainer; } + break; + case ID_TRAYCONTEXT_BE: + nen_options.iDisable = 1; + nen_options.iNoSounds = 1; + nen_options.iNoAutoPopup = 1; + + while (pContainer) { + SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 1); + pContainer = pContainer->pNextContainer; + } + break; } } - if (wParam == 100) - PostMessage(hwndDlg, WM_NULL, 0, 0); - break; } - default: - break; + if (wParam == 100) + PostMessage(hwndDlg, WM_NULL, 0, 0); + break; } } - break; } + break; + + /* + * handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message + * is posted to our invisible hotkey handler which does always run within the main thread. + * wParam is the hContact + * lParam the event handle + */ + case DM_HANDLECLISTEVENT: /* - * handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message - * is posted to our invisible hotkey handler which does always run within the main thread. - * wParam is the hContact - * lParam the event handle - */ - case DM_HANDLECLISTEVENT: { + * if lParam == NULL, don't consider clist events, just open the message tab + */ + if (lParam == 0) + HandleMenuEntryFromhContact((int)wParam); + else { CLISTEVENT *cle = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, wParam, 0); - - /* - * if lParam == NULL, don't consider clist events, just open the message tab - */ - - if (lParam == 0) { - HandleMenuEntryFromhContact((int)wParam); - break; - } - - /* - * first try, if the clist returned an event... - */ if (cle) { if (ServiceExists(cle->pszService)) { CallService(cle->pszService, 0, (LPARAM)cle); CallService(MS_CLIST_REMOVEEVENT, (WPARAM)cle->hContact, (LPARAM)cle->hDbEvent); } - } else { // still, we got that message posted.. the event may be waiting in tabSRMMs tray... - HandleMenuEntryFromhContact((int)wParam); } - break; + // still, we got that message posted.. the event may be waiting in tabSRMMs tray... + else HandleMenuEntryFromhContact((int)wParam); } - case DM_DOCREATETAB: { + break; + + case DM_DOCREATETAB: + { HWND hWnd = M->FindWindow((HANDLE)lParam); if (hWnd && IsWindow(hWnd)) { - struct TContainerData *pContainer = 0; - + pContainer = 0; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS)); @@ -429,14 +418,14 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP CreateNewTabForContact((struct TContainerData *)wParam, (HANDLE)lParam, 0, NULL, TRUE, TRUE, FALSE, 0); } } - break; } - case DM_DOCREATETAB_CHAT: { - SESSION_INFO *si = SM_FindSessionByHWND((HWND)lParam); + break; + case DM_DOCREATETAB_CHAT: + { + SESSION_INFO *si = SM_FindSessionByHWND((HWND)lParam); if (si && IsWindow(si->hWnd)) { - struct TContainerData *pContainer = 0; - + pContainer = 0; SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, 1159)); @@ -448,42 +437,44 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP si->hWnd = CreateNewRoom((struct TContainerData *)wParam, si, TRUE, 0, 0); } } - break; } - case DM_SENDMESSAGECOMMANDW: - SendMessageCommand_W(wParam, lParam); - if (lParam) - free((void*)lParam); - return 0; - - case DM_SENDMESSAGECOMMAND: - SendMessageCommand(wParam, lParam); - if (lParam) - free((void*)lParam); - return 0; - /* - * sent from the popup to "dismiss" the event. we should do this in the main thread - */ - case DM_REMOVECLISTEVENT: - CallService(MS_CLIST_REMOVEEVENT, wParam, lParam); - CallService(MS_DB_EVENT_MARKREAD, wParam, lParam); - return 0; + break; - case DM_SETLOCALE: { - HKL hkl = (HKL)lParam; - HANDLE hContact = (HANDLE)wParam; + case DM_SENDMESSAGECOMMANDW: + SendMessageCommand_W(wParam, lParam); + if (lParam) + free((void*)lParam); + return 0; - HWND hWnd = M->FindWindow(hContact); + case DM_SENDMESSAGECOMMAND: + SendMessageCommand(wParam, lParam); + if (lParam) + free((void*)lParam); + return 0; + /* + * sent from the popup to "dismiss" the event. we should do this in the main thread + */ + case DM_REMOVECLISTEVENT: + CallService(MS_CLIST_REMOVEEVENT, wParam, lParam); + CallService(MS_DB_EVENT_MARKREAD, wParam, lParam); + return 0; + + case DM_SETLOCALE: + { + HKL hkl = (HKL)lParam; + HANDLE hContact = (HANDLE)wParam; + + HWND hWnd = M->FindWindow(hContact); if (hWnd) { TWindowData *dat = (TWindowData *)GetWindowLongPtr(hWnd, GWLP_USERDATA); if (dat) { - DBVARIANT dbv; - if (hkl) { dat->hkl = hkl; PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0); } + + DBVARIANT dbv; if (0 == M->GetTString(hContact, SRMSGMOD_T, "locale", &dbv)) { GetLocaleID(dat, dbv.ptszVal); DBFreeVariant(&dbv); @@ -491,24 +482,23 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } } } - return 0; } + return 0; /* - * react to changes in the desktop composition state - * (enable/disable DWM, change to a non-aero visual style - * or classic Windows theme - */ - case WM_DWMCOMPOSITIONCHANGED: { + * react to changes in the desktop composition state + * (enable/disable DWM, change to a non-aero visual style + * or classic Windows theme + */ + case WM_DWMCOMPOSITIONCHANGED: + { bool fNewAero = M->getAeroState(); // refresh dwm state SendMessage(hwndDlg, WM_THEMECHANGED, 0, 0); - TContainerData *pContainer = pFirstContainer; while (pContainer) { if (fNewAero) SetAeroMargins(pContainer); else { MARGINS m = {0}; - if (M->m_pfnDwmExtendFrameIntoClientArea) M->m_pfnDwmExtendFrameIntoClientArea(pContainer->hwnd, &m); } @@ -517,49 +507,46 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); pContainer = pContainer->pNextContainer; } - M->BroadcastMessage(WM_DWMCOMPOSITIONCHANGED, 0, 0); - break; } + M->BroadcastMessage(WM_DWMCOMPOSITIONCHANGED, 0, 0); + break; /* - * this message is fired when the user changes desktop color - * settings (Desktop->personalize) - * the handler reconfigures the aero-related skin images for - * tabs and buttons to match the new desktop color theme. - */ - case WM_DWMCOLORIZATIONCOLORCHANGED: { - M->getAeroState(); - Skin->setupAeroSkins(); - CSkin::initAeroEffect(); - break; - } + * this message is fired when the user changes desktop color + * settings (Desktop->personalize) + * the handler reconfigures the aero-related skin images for + * tabs and buttons to match the new desktop color theme. + */ + case WM_DWMCOLORIZATIONCOLORCHANGED: + M->getAeroState(); + Skin->setupAeroSkins(); + CSkin::initAeroEffect(); + break; /* - * user has changed the visual style or switched to/from - * classic Windows theme - */ - case WM_THEMECHANGED: { - struct TContainerData *pContainer = pFirstContainer; - - M->getAeroState(); - Skin->setupTabCloseBitmap(); - CSkin::initAeroEffect(); - PluginConfig.m_ncm.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &PluginConfig.m_ncm, 0); - FreeTabConfig(); - ReloadTabConfig(); - while (pContainer) { - SendMessage(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), EM_THEMECHANGED, 0, 0); - BroadCastContainer(pContainer, EM_THEMECHANGED, 0, 0); - pContainer = pContainer->pNextContainer; - } - break; + * user has changed the visual style or switched to/from + * classic Windows theme + */ + case WM_THEMECHANGED: + M->getAeroState(); + Skin->setupTabCloseBitmap(); + CSkin::initAeroEffect(); + PluginConfig.m_ncm.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &PluginConfig.m_ncm, 0); + FreeTabConfig(); + ReloadTabConfig(); + while (pContainer) { + SendMessage(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), EM_THEMECHANGED, 0, 0); + BroadCastContainer(pContainer, EM_THEMECHANGED, 0, 0); + pContainer = pContainer->pNextContainer; } + break; - case DM_SPLITSENDACK: { - ACKDATA ack = {0}; - struct SendJob *job = sendQueue->getJobByIndex((int)wParam); + case DM_SPLITSENDACK: + { + SendJob *job = sendQueue->getJobByIndex((int)wParam); + ACKDATA ack = {0}; ack.hContact = job->hOwner; ack.hProcess = job->hSendId; ack.type = ACKTYPE_MESSAGE; @@ -571,14 +558,15 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP else sendQueue->ackMessage(0, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack); } - return 0; } + return 0; - case DM_LOGSTATUSCHANGE: - CGlobals::logStatusChange(wParam, reinterpret_cast(lParam)); - return 0; + case DM_LOGSTATUSCHANGE: + CGlobals::logStatusChange(wParam, reinterpret_cast(lParam)); + return 0; - case DM_MUCFLASHWORKER: { + case DM_MUCFLASHWORKER: + { FLASH_PARAMS *p = reinterpret_cast(lParam); if (1 == wParam) { @@ -595,94 +583,84 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(p->hWnd, DM_ACTIVATEME, 0, 0); } DoFlashAndSoundWorker(p); - return 0; } + return 0; - case WM_POWERBROADCAST: - case WM_DISPLAYCHANGE: { - struct TContainerData *pContainer = pFirstContainer; - - while (pContainer) { - if (CSkin::m_skinEnabled) { // invalidate cached background DCs for skinned containers - pContainer->oldDCSize.cx = pContainer->oldDCSize.cy = 0; - SelectObject(pContainer->cachedDC, pContainer->oldHBM); - DeleteObject(pContainer->cachedHBM); - DeleteDC(pContainer->cachedDC); - pContainer->cachedDC = 0; - RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME); - } - pContainer = pContainer->pNextContainer; + case WM_POWERBROADCAST: + case WM_DISPLAYCHANGE: + while (pContainer) { + if (CSkin::m_skinEnabled) { // invalidate cached background DCs for skinned containers + pContainer->oldDCSize.cx = pContainer->oldDCSize.cy = 0; + SelectObject(pContainer->cachedDC, pContainer->oldHBM); + DeleteObject(pContainer->cachedHBM); + DeleteDC(pContainer->cachedDC); + pContainer->cachedDC = 0; + RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME); } - break; + pContainer = pContainer->pNextContainer; } + break; - case WM_ACTIVATE: - if (LOWORD(wParam) != WA_ACTIVE) - SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); - return 0; + case WM_ACTIVATE: + if (LOWORD(wParam) != WA_ACTIVE) + SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); + return 0; - case WM_CLOSE: - return 0; + case WM_CLOSE: + return 0; - case WM_TIMER: - if (wParam == TIMERID_SENDLATER) { - /* - * send heartbeat to each open container (to manage autoclose - * feature) - */ - TContainerData *pContainer = pFirstContainer; - /* - * send heartbeat to each container, they use this to update - * dynamic content (i.e. local time in the info panel). - */ - while(pContainer) { - SendMessage(pContainer->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0); - pContainer = pContainer->pNextContainer; - } - /* - * process send later contacts and jobs, if enough time has elapsed - */ - if (sendLater->isAvail() && !sendLater->isInteractive() && (time(0) - sendLater->lastProcessed()) > CSendLater::SENDLATER_PROCESS_INTERVAL) { - sendLater->setLastProcessed(time(0)); - - /* - * check the list of contacts that may have new send later jobs - * (added on user's request) - */ - sendLater->processContacts(); - - /* - * start processing the job list - */ - if (!sendLater->isJobListEmpty()) { - KillTimer(hwndDlg, wParam); - sendLater->startJobListProcess(); - SetTimer(hwndDlg, TIMERID_SENDLATER_TICK, TIMEOUT_SENDLATER_TICK, 0); - } - } + case WM_TIMER: + if (wParam == TIMERID_SENDLATER) { + /* + * send heartbeat to each container, they use this to update + * dynamic content (i.e. local time in the info panel). + */ + while(pContainer) { + SendMessage(pContainer->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0); + pContainer = pContainer->pNextContainer; } /* - * process one entry per tick (default: 200ms) - * TODO better timings, possibly slow down when many jobs are in the - * queue. - */ - else if (wParam == TIMERID_SENDLATER_TICK) { - if (!sendLater->haveJobs()) { + * process send later contacts and jobs, if enough time has elapsed + */ + if (sendLater->isAvail() && !sendLater->isInteractive() && (time(0) - sendLater->lastProcessed()) > CSendLater::SENDLATER_PROCESS_INTERVAL) { + sendLater->setLastProcessed(time(0)); + + /* + * check the list of contacts that may have new send later jobs + * (added on user's request) + */ + sendLater->processContacts(); + + /* + * start processing the job list + */ + if (!sendLater->isJobListEmpty()) { KillTimer(hwndDlg, wParam); - SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, 0); - sendLater->qMgrUpdate(true); + sendLater->startJobListProcess(); + SetTimer(hwndDlg, TIMERID_SENDLATER_TICK, TIMEOUT_SENDLATER_TICK, 0); } - else - sendLater->processCurrentJob(); } - break; - - case WM_DESTROY: { - KillTimer(hwndDlg, TIMERID_SENDLATER_TICK); - KillTimer(hwndDlg, TIMERID_SENDLATER); - DestroyServiceFunction(hSvcHotkeyProcessor); - break; } + /* + * process one entry per tick (default: 200ms) + * TODO better timings, possibly slow down when many jobs are in the + * queue. + */ + else if (wParam == TIMERID_SENDLATER_TICK) { + if ( !sendLater->haveJobs()) { + KillTimer(hwndDlg, wParam); + SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, 0); + sendLater->qMgrUpdate(true); + } + else sendLater->processCurrentJob(); + } + break; + + case WM_DESTROY: + KillTimer(hwndDlg, TIMERID_SENDLATER_TICK); + KillTimer(hwndDlg, TIMERID_SENDLATER); + DestroyServiceFunction(hSvcHotkeyProcessor); + break; } - return(DefWindowProc(hwndDlg, msg, wParam, lParam)); + return DefWindowProc(hwndDlg, msg, wParam, lParam); } -- cgit v1.2.3