From f725c70b482df377119e2c09b36c9317f86ef494 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 20 Apr 2013 15:52:48 +0000 Subject: ME_MSG_WRITEEVENT - new hookable event to catch the db event creation moment in SRMM git-svn-id: http://svn.miranda-ng.org/main/trunk@4484 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/globals.cpp | 85 ++++++++++++++++++++------------------- plugins/TabSRMM/src/globals.h | 2 +- plugins/TabSRMM/src/msgs.cpp | 1 + plugins/TabSRMM/src/sendqueue.cpp | 26 ++++++------ plugins/TabSRMM/src/srmm.cpp | 1 - 5 files changed, 57 insertions(+), 58 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 76f44eefe7..eb1d7216c1 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -178,9 +178,9 @@ void CGlobals::reloadSystemModulesChanged() } else M->WriteByte(SRMSGMOD_T, "ieview_installed", 0); - g_iButtonsBarGap = M->GetByte("ButtonsBarGap", 1); - m_hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - m_MathModAvail = (ServiceExists(MATH_RTF_REPLACE_FORMULAE) ? 1 : 0); + g_iButtonsBarGap = M->GetByte("ButtonsBarGap", 1); + m_hwndClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + m_MathModAvail = (ServiceExists(MATH_RTF_REPLACE_FORMULAE) ? 1 : 0); if (m_MathModAvail) { char *szDelim = (char *)CallService(MATH_GET_STARTDELIMITER, 0, 0); if (szDelim) { @@ -223,69 +223,69 @@ void CGlobals::reloadSettings(bool fReloadSkins) m_ncm.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m_ncm, 0); - DWORD dwFlags = M->GetDword("mwflags", MWF_LOG_DEFAULT); - - m_SendOnShiftEnter = (int)M->GetByte("sendonshiftenter", 0); - m_SendOnEnter = (int)M->GetByte(SRMSGSET_SENDONENTER, SRMSGDEFSET_SENDONENTER); - m_SendOnDblEnter = (int)M->GetByte("SendOnDblEnter", 0); - m_AutoLocaleSupport = (int)M->GetByte("al", 0); - m_AutoSwitchTabs = (int)M->GetByte("autoswitchtabs", 1); - m_CutContactNameTo = (int)db_get_w(NULL, SRMSGMOD_T, "cut_at", 15); - m_CutContactNameOnTabs = (int)M->GetByte("cuttitle", 0); - m_StatusOnTabs = (int)M->GetByte("tabstatus", 1); - m_LogStatusChanges = (int)M->GetByte("logstatuschanges", 0); - m_UseDividers = (int)M->GetByte("usedividers", 0); - m_DividersUsePopupConfig = (int)M->GetByte("div_popupconfig", 0); - m_MsgTimeout = (int)M->GetDword(SRMSGMOD, SRMSGSET_MSGTIMEOUT, SRMSGDEFSET_MSGTIMEOUT); + DWORD dwFlags = M->GetDword("mwflags", MWF_LOG_DEFAULT); + + m_SendOnShiftEnter = M->GetByte("sendonshiftenter", 0); + m_SendOnEnter = M->GetByte(SRMSGSET_SENDONENTER, SRMSGDEFSET_SENDONENTER); + m_SendOnDblEnter = M->GetByte("SendOnDblEnter", 0); + m_AutoLocaleSupport = M->GetByte("al", 0); + m_AutoSwitchTabs = M->GetByte("autoswitchtabs", 1); + m_CutContactNameTo = db_get_w(NULL, SRMSGMOD_T, "cut_at", 15); + m_CutContactNameOnTabs = M->GetByte("cuttitle", 0); + m_StatusOnTabs = M->GetByte("tabstatus", 1); + m_LogStatusChanges = M->GetByte("logstatuschanges", 0); + m_UseDividers = M->GetByte("usedividers", 0); + m_DividersUsePopupConfig = M->GetByte("div_popupconfig", 0); + m_MsgTimeout = M->GetDword(SRMSGMOD, SRMSGSET_MSGTIMEOUT, SRMSGDEFSET_MSGTIMEOUT); if (m_MsgTimeout < SRMSGSET_MSGTIMEOUT_MIN) m_MsgTimeout = SRMSGSET_MSGTIMEOUT_MIN; - m_EscapeCloses = (int)M->GetByte("escmode", 0); + m_EscapeCloses = M->GetByte("escmode", 0); - m_HideOnClose = (int) M->GetByte("hideonclose", 0); - m_AllowTab = (int) M->GetByte("tabmode", 0); + m_HideOnClose = M->GetByte("hideonclose", 0); + m_AllowTab = M->GetByte("tabmode", 0); - m_FlashOnClist = (int)M->GetByte("flashcl", 0); - m_AlwaysFullToolbarWidth = (int)M->GetByte("alwaysfulltoolbar", 1); - m_LimitStaticAvatarHeight = (int)M->GetDword("avatarheight", 96); - m_SendFormat = (int)M->GetByte("sendformat", 0); + m_FlashOnClist = M->GetByte("flashcl", 0); + m_AlwaysFullToolbarWidth = M->GetByte("alwaysfulltoolbar", 1); + m_LimitStaticAvatarHeight = M->GetDword("avatarheight", 96); + m_SendFormat = M->GetByte("sendformat", 0); m_FormatWholeWordsOnly = 1; - m_RTLDefault = (int)M->GetByte("rtldefault", 0); - m_TabAppearance = (int)M->GetDword("tabconfig", TCF_FLASHICON | TCF_SINGLEROWTABCONTROL); - m_panelHeight = (DWORD)M->GetDword("panelheight", CInfoPanel::DEGRADE_THRESHOLD); - m_MUCpanelHeight = M->GetDword("Chat", "panelheight", CInfoPanel::DEGRADE_THRESHOLD); - m_IdleDetect = (int)M->GetByte("dimIconsForIdleContacts", 1); + m_RTLDefault = M->GetByte("rtldefault", 0); + m_TabAppearance = M->GetDword("tabconfig", TCF_FLASHICON | TCF_SINGLEROWTABCONTROL); + m_panelHeight = (DWORD)M->GetDword("panelheight", CInfoPanel::DEGRADE_THRESHOLD); + m_MUCpanelHeight = M->GetDword("Chat", "panelheight", CInfoPanel::DEGRADE_THRESHOLD); + m_IdleDetect = M->GetByte("dimIconsForIdleContacts", 1); m_smcxicon = 16; m_smcyicon = 16; - m_PasteAndSend = (int)M->GetByte("pasteandsend", 1); - m_szNoStatus = TranslateT("No status message"); - m_LangPackCP = ServiceExists(MS_LANGPACK_GETCODEPAGE) ? CallService(MS_LANGPACK_GETCODEPAGE, 0, 0) : CP_ACP; - m_visualMessageSizeIndicator = M->GetByte("msgsizebar", 0); - m_autoSplit = M->GetByte("autosplit", 0); - m_FlashOnMTN = M->GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINFLASH, SRMSGDEFSET_SHOWTYPINGWINFLASH); + m_PasteAndSend = M->GetByte("pasteandsend", 1); + m_szNoStatus = TranslateT("No status message"); + m_LangPackCP = ServiceExists(MS_LANGPACK_GETCODEPAGE) ? CallService(MS_LANGPACK_GETCODEPAGE, 0, 0) : CP_ACP; + m_visualMessageSizeIndicator = M->GetByte("msgsizebar", 0); + m_autoSplit = M->GetByte("autosplit", 0); + m_FlashOnMTN = M->GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINFLASH, SRMSGDEFSET_SHOWTYPINGWINFLASH); if (m_MenuBar == 0) { m_MenuBar = ::LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENUBAR)); TranslateMenu(m_MenuBar); } - m_ipBackgroundGradient = M->GetDword(FONTMODULE, "ipfieldsbg", 0x62caff); + m_ipBackgroundGradient = M->GetDword(FONTMODULE, "ipfieldsbg", 0x62caff); if (0 == m_ipBackgroundGradient) m_ipBackgroundGradient = 0x62caff; - m_ipBackgroundGradientHigh = M->GetDword(FONTMODULE, "ipfieldsbgHigh", 0xf0f0f0); + m_ipBackgroundGradientHigh = M->GetDword(FONTMODULE, "ipfieldsbgHigh", 0xf0f0f0); if (0 == m_ipBackgroundGradientHigh) m_ipBackgroundGradientHigh = 0xf0f0f0; - m_tbBackgroundHigh = M->GetDword(FONTMODULE, "tbBgHigh", 0); - m_tbBackgroundLow = M->GetDword(FONTMODULE, "tbBgLow", 0); - m_fillColor = M->GetDword(FONTMODULE, "fillColor", 0); + m_tbBackgroundHigh = M->GetDword(FONTMODULE, "tbBgHigh", 0); + m_tbBackgroundLow = M->GetDword(FONTMODULE, "tbBgLow", 0); + m_fillColor = M->GetDword(FONTMODULE, "fillColor", 0); if (CSkin::m_BrushFill) { ::DeleteObject(CSkin::m_BrushFill); CSkin::m_BrushFill = 0; } - m_genericTxtColor = M->GetDword(FONTMODULE, "genericTxtClr", GetSysColor(COLOR_BTNTEXT)); - m_cRichBorders = M->GetDword(FONTMODULE, "cRichBorders", 0); + m_genericTxtColor = M->GetDword(FONTMODULE, "genericTxtClr", GetSysColor(COLOR_BTNTEXT)); + m_cRichBorders = M->GetDword(FONTMODULE, "cRichBorders", 0); ::CopyMemory(&globalContainerSettings, &_cnt_default, sizeof(TContainerSettings)); Utils::ReadContainerSettingsFromDB(0, &globalContainerSettings); @@ -594,6 +594,7 @@ int CGlobals::PreshutdownSendRecv(WPARAM wParam, LPARAM lParam) DestroyHookableEvent(PluginConfig.m_event_MsgWin); DestroyHookableEvent(PluginConfig.m_event_MsgPopup); + DestroyHookableEvent(PluginConfig.m_event_WriteEvent); ::NEN_WriteOptions(&nen_options); ::DestroyWindow(PluginConfig.g_hwndHotkeyHandler); diff --git a/plugins/TabSRMM/src/globals.h b/plugins/TabSRMM/src/globals.h index 6fb727ac6e..6bc4987886 100644 --- a/plugins/TabSRMM/src/globals.h +++ b/plugins/TabSRMM/src/globals.h @@ -190,7 +190,7 @@ public: COLORREF m_tbBackgroundHigh, m_tbBackgroundLow, m_fillColor, m_cRichBorders, m_genericTxtColor; BYTE m_dontUseDefaultKbd; HANDLE hSvc[SERVICE_LAST]; - HANDLE m_event_MsgWin, m_event_MsgPopup; + HANDLE m_event_MsgWin, m_event_MsgPopup, m_event_WriteEvent; HGENMENU m_hMenuItem; BYTE m_useAeroPeek; diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 63daf44ece..fd7300789d 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -540,6 +540,7 @@ static void TSAPI InitAPI() PluginConfig.m_event_MsgWin = CreateHookableEvent(ME_MSG_WINDOWEVENT); PluginConfig.m_event_MsgPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP); + PluginConfig.m_event_WriteEvent = CreateHookableEvent(ME_MSG_WRITEEVENT); } int LoadSendRecvMessageModule(void) diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 2713cd1470..62b31a6a57 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -604,14 +604,13 @@ void SendQueue::recallFailed(const TWindowData *dat, int iEntry) const void SendQueue::UpdateSaveAndSendButton(TWindowData *dat) { if (dat) { - int len; HWND hwndDlg = dat->hwnd; - GETTEXTLENGTHEX gtxl = {0}; + GETTEXTLENGTHEX gtxl = {0}; gtxl.codepage = CP_UTF8; gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMBYTES; - len = SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)& gtxl, 0); + int len = SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)& gtxl, 0); if (len && GetSendButtonState(hwndDlg) == PBS_DISABLED) EnableSendButton(dat, TRUE); else if (len == 0 && GetSendButtonState(hwndDlg) != PBS_DISABLED) @@ -665,21 +664,19 @@ void SendQueue::NotifyDeliveryFailure(const TWindowData *dat) int SendQueue::RTL_Detect(const WCHAR *pszwText) { - WORD *infoTypeC2; - int i, n = 0; - int iLen = lstrlenW(pszwText); - - infoTypeC2 = (WORD *)mir_alloc(sizeof(WORD) * (iLen + 2)); + int i, n = 0; + int iLen = lstrlenW(pszwText); + WORD *infoTypeC2 = (WORD *)mir_alloc(sizeof(WORD) * (iLen + 2)); if (infoTypeC2) { ZeroMemory(infoTypeC2, sizeof(WORD) * (iLen + 2)); GetStringTypeW(CT_CTYPE2, pszwText, iLen, infoTypeC2); - for (i=0; i < iLen; i++) { + for (i=0; i < iLen; i++) if (infoTypeC2[i] == C2_RIGHTTOLEFT) n++; - } + mir_free(infoTypeC2); return(n >= 2 ? 1 : 0); } @@ -766,17 +763,18 @@ inform_and_discard: dbei.pBlob = (PBYTE) m_jobs[iFound].sendBuffer; hNewEvent = db_event_add(m_jobs[iFound].hOwner, &dbei); - if (m_pContainer) { + MessageWindowEvent evt = { sizeof(evt), (int)m_jobs[iFound].hSendId, m_jobs[iFound].hOwner, hNewEvent }; + NotifyEventHooks(PluginConfig.m_event_WriteEvent, 0, (LPARAM)&evt); + + if (m_pContainer) if (!nen_options.iNoSounds && !(m_pContainer->dwFlags & CNT_NOSOUND)) SkinPlaySound("SendMsg"); - } - if (dat && (m_jobs[iFound].hOwner == dat->hContact)) { + if (dat && (m_jobs[iFound].hOwner == dat->hContact)) if (dat->hDbEventFirst == NULL) { dat->hDbEventFirst = hNewEvent; SendMessage(dat->hwnd, DM_REMAKELOG, 0, 0); } - } m_jobs[iFound].hSendId = NULL; m_jobs[iFound].iAcksNeeded--; diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp index 87135cc49e..3012fe6334 100644 --- a/plugins/TabSRMM/src/srmm.cpp +++ b/plugins/TabSRMM/src/srmm.cpp @@ -76,7 +76,6 @@ extern "C" int __declspec(dllexport) Load(void) return 1; } - mir_getTMI(&tmi); mir_getLP(&pluginInfo); -- cgit v1.2.3