diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-10 18:37:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-10 18:37:52 +0000 |
commit | ef05f20f8191c1c3d93df3356969ce016119487e (patch) | |
tree | 44e204e1f947bf80d5ae20af1fae82c18da0be03 /plugins/TabSRMM/src/mim.cpp | |
parent | 2b481b820ddd7a7edecda35a214029add7996371 (diff) |
- we don't broadcast added events anymore;
- fix for User Typing notifications;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9759 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/mim.cpp')
-rw-r--r-- | plugins/TabSRMM/src/mim.cpp | 163 |
1 files changed, 85 insertions, 78 deletions
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 61265797a3..6c5e558047 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -227,92 +227,93 @@ void CMimAPI::InitAPI() ///////////////////////////////////////////////////////////////////////////////////////// // hook subscriber function for incoming message typing events -int CMimAPI::TypingMessage(WPARAM hContact, LPARAM lParam) +int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode) { - HWND hwnd = 0; - int issplit = 1, foundWin = 0, preTyping = 0; - BOOL fShowOnClist = TRUE; + int issplit = 1, foundWin = 0, preTyping = 0; + BOOL fShowOnClist = TRUE; - if (hContact) { - if ((hwnd = M.FindWindow(hContact)) && M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPING, SRMSGDEFSET_SHOWTYPING)) - preTyping = SendMessage(hwnd, DM_TYPING, 0, lParam); + HWND hwnd = M.FindWindow(hContact); + if (hwnd == NULL && db_mc_isSub(hContact)) + hwnd = M.FindWindow(db_mc_getMeta(hContact)); - if (hwnd && IsWindowVisible(hwnd)) - foundWin = MessageWindowOpened(0, (LPARAM)hwnd); - else - foundWin = 0; + if (hwnd && M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPING, SRMSGDEFSET_SHOWTYPING)) + preTyping = SendMessage(hwnd, DM_TYPING, 0, mode); - TContainerData *pContainer = NULL; - if (hwnd) { - SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); - if (pContainer == NULL) - return 0; // should never happen - } - - if (M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGCLIST, SRMSGDEFSET_SHOWTYPINGCLIST)) { - if (!hwnd && !M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGNOWINOPEN, 1)) - fShowOnClist = FALSE; - if (hwnd && !M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINOPEN, 1)) - fShowOnClist = FALSE; - } - else fShowOnClist = FALSE; + if (hwnd && IsWindowVisible(hwnd)) + foundWin = MessageWindowOpened(0, (LPARAM)hwnd); + else + foundWin = 0; - if ((!foundWin || !(pContainer->dwFlags & CNT_NOSOUND)) && preTyping != (lParam != 0)) - SkinPlaySound((lParam) ? "TNStart" : "TNStop"); - - if (M.GetByte(SRMSGMOD, "ShowTypingPopup", 0)) { - BOOL fShow = FALSE; - int iMode = M.GetByte("MTN_PopupMode", 0); + TContainerData *pContainer = NULL; + if (hwnd) { + SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); + if (pContainer == NULL) // should never happen + return 0; + } - switch (iMode) { - case 0: - fShow = TRUE; - break; - case 1: - if (!foundWin || !(pContainer && pContainer->hwndActive == hwnd && GetForegroundWindow() == pContainer->hwnd)) - fShow = TRUE; - break; - case 2: - if (hwnd == 0) - fShow = TRUE; - else { - if (PluginConfig.m_HideOnClose) { - TContainerData *pContainer = 0; - SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); - if (pContainer && pContainer->fHidden) - fShow = TRUE; - } + if (M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGCLIST, SRMSGDEFSET_SHOWTYPINGCLIST)) { + if (!hwnd && !M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGNOWINOPEN, 1)) + fShowOnClist = false; + if (hwnd && !M.GetByte(SRMSGMOD, SRMSGSET_SHOWTYPINGWINOPEN, 1)) + fShowOnClist = false; + } + else fShowOnClist = false; + + if ((!foundWin || !(pContainer->dwFlags & CNT_NOSOUND)) && preTyping != (mode != 0)) + SkinPlaySound(mode ? "TNStart" : "TNStop"); + + if (M.GetByte(SRMSGMOD, "ShowTypingPopup", 0)) { + BOOL fShow = false; + int iMode = M.GetByte("MTN_PopupMode", 0); + + switch (iMode) { + case 0: + fShow = true; + break; + case 1: + if (!foundWin || !(pContainer && pContainer->hwndActive == hwnd && GetForegroundWindow() == pContainer->hwnd)) + fShow = true; + break; + case 2: + if (hwnd == 0) + fShow = true; + else { + if (PluginConfig.m_HideOnClose) { + TContainerData *pContainer = 0; + SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); + if (pContainer && pContainer->fHidden) + fShow = true; } - break; } - if (fShow) - TN_TypingMessage(hContact, lParam); + break; } + if (fShow) + TN_TypingMessage(hContact, mode); + } - if (lParam) { - TCHAR szTip[256]; - mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); - if (fShowOnClist && ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && M.GetByte(SRMSGMOD, "ShowTypingBalloon", 0)) { - MIRANDASYSTRAYNOTIFY tn; - tn.szProto = NULL; - tn.cbSize = sizeof(tn); - tn.tszInfoTitle = TranslateT("Typing Notification"); - tn.tszInfo = szTip; - tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE; - tn.uTimeout = 1000 * 4; - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); - } - if (fShowOnClist) { - CLISTEVENT cle = { sizeof(cle) }; - cle.hContact = hContact; - cle.hDbEvent = (HANDLE)1; - cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; - cle.hIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]; - cle.pszService = "SRMsg/TypingMessage"; - cle.ptszTooltip = szTip; - CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1); - CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle); - } + if (mode) { + TCHAR szTip[256]; + mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); + if (fShowOnClist && ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && M.GetByte(SRMSGMOD, "ShowTypingBalloon", 0)) { + MIRANDASYSTRAYNOTIFY tn; + tn.szProto = NULL; + tn.cbSize = sizeof(tn); + tn.tszInfoTitle = TranslateT("Typing Notification"); + tn.tszInfo = szTip; + tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE; + tn.uTimeout = 1000 * 4; + CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); + } + if (fShowOnClist) { + CLISTEVENT cle = { sizeof(cle) }; + cle.hContact = hContact; + cle.hDbEvent = (HANDLE)1; + cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; + cle.hIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]; + cle.pszService = "SRMsg/TypingMessage"; + cle.ptszTooltip = szTip; + CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1); + CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle); } } return 0; @@ -389,8 +390,14 @@ int CMimAPI::PrebuildContactMenu(WPARAM hContact, LPARAM lParam) int CMimAPI::DispatchNewEvent(WPARAM hContact, LPARAM lParam) { - if (hContact) - M.BroadcastMessageAsync(HM_DBEVENTADDED, hContact, lParam); + if (hContact) { + Utils::sendContactMessage(hContact, HM_DBEVENTADDED, hContact, lParam); + + // we're in meta and an event belongs to a sub + MCONTACT hReal = db_event_getContact(HANDLE(lParam)); + if (hReal != hContact) + Utils::sendContactMessage(hReal, HM_DBEVENTADDED, hContact, lParam); + } return 0; } |