diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-11 12:27:21 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-11 12:27:21 +0300 |
commit | e02f1e05b363226a48fe9a4b151748a5cbb295d9 (patch) | |
tree | e49e428ab703459d65ef7829187dd17b9af4154c /plugins/TabSRMM | |
parent | 432b115c1eaf6f74d7d4d8ac580f5de39c16a533 (diff) |
GC_UPDATETITLE replaced with CSrmmBaseDlg::UpdateTitle
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat_tools.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_window.cpp | 131 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 85 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 105 | ||||
-rw-r--r-- | plugins/TabSRMM/src/globals.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 110 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 6 |
8 files changed, 222 insertions, 223 deletions
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index 75d08d6aa3..d316bbd744 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -257,7 +257,7 @@ void DoFlashAndSoundWorker(FLASH_PARAMS *p) TabCtrl_SetCurSel(hwndTab, iItem);
ShowWindow(dat->m_pContainer->hwndActive, SW_HIDE);
dat->m_pContainer->hwndActive = si->pDlg->GetHwnd();
- SendMessage(dat->m_pContainer->hwnd, DM_UPDATETITLE, dat->m_hContact, 0);
+ dat->m_pContainer->UpdateTitle(dat->m_hContact);
dat->m_pContainer->dwFlags |= CNT_DEFERREDTABSELECT;
}
}
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 8022bdb1a5..219613964d 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -197,7 +197,8 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) if (pcli->pfnGetEvent(m_si->hContact, 0)) pcli->pfnRemoveEvent(m_si->hContact, GC_FAKE_EVENT); - SendMessage(m_hwnd, GC_UPDATETITLE, 0, 1); + UpdateTitle(); + m_hTabIcon = m_hTabStatusIcon; m_dwTickLastEvent = 0; m_dwFlags &= ~MWF_DIVIDERSET; if (KillTimer(m_hwnd, TIMERID_FLASHWND) || m_iFlashIcon) { @@ -1651,7 +1652,8 @@ void CChatRoomDlg::OnInitDialog() SendMessage(m_hwnd, GC_SETWNDPROPS, 0, 0); SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - SendMessage(m_hwnd, GC_UPDATETITLE, 0, 1); + UpdateTitle(); + m_hTabIcon = m_hTabStatusIcon; RECT rc; SendMessage(m_pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); @@ -1781,7 +1783,7 @@ void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton) return; } SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0); - SendMessage(m_hwnd, GC_UPDATETITLE, 0, 0); + UpdateTitle(); db_set_b(m_si->hContact, CHAT_MODULE, "FilterEnabled", m_bFilterEnabled); } @@ -1946,6 +1948,66 @@ void CChatRoomDlg::onDblClick_List(CCtrlListBox*) else DoEventHook(GC_USER_PRIVMESS, ui, nullptr, 0); } +///////////////////////////////////////////////////////////////////////////////////////// + +void CChatRoomDlg::UpdateTitle() +{ + m_wStatus = m_si->wStatus; + + const wchar_t *szNick = m_cache->getNick(); + if (mir_wstrlen(szNick) > 0) { + if (M.GetByte("cuttitle", 0)) + CutContactName(szNick, m_wszTitle, _countof(m_wszTitle)); + else + wcsncpy_s(m_wszTitle, szNick, _TRUNCATE); + } + + wchar_t szTemp[100]; + HICON hIcon = 0; + + switch (m_si->iType) { + case GCW_CHATROOM: + hIcon = Skin_LoadProtoIcon(m_si->pszModule, (m_wStatus <= ID_STATUS_OFFLINE) ? ID_STATUS_OFFLINE : m_wStatus); + mir_snwprintf(szTemp, + (m_si->nUsersInNicklist == 1) ? TranslateT("%s: chat room (%u user%s)") : TranslateT("%s: chat room (%u users%s)"), + szNick, m_si->nUsersInNicklist, m_bFilterEnabled ? TranslateT(", event filter active") : L""); + break; + case GCW_PRIVMESS: + hIcon = Skin_LoadProtoIcon(m_si->pszModule, (m_wStatus <= ID_STATUS_OFFLINE) ? ID_STATUS_OFFLINE : m_wStatus); + if (m_si->nUsersInNicklist == 1) + mir_snwprintf(szTemp, TranslateT("%s: message session"), szNick); + else + mir_snwprintf(szTemp, TranslateT("%s: message session (%u users)"), szNick, m_si->nUsersInNicklist); + break; + case GCW_SERVER: + mir_snwprintf(szTemp, L"%s: Server", szNick); + hIcon = LoadIconEx("window"); + break; + } + + if (m_pWnd) { + m_pWnd->updateTitle(m_wszTitle); + m_pWnd->updateIcon(hIcon); + } + m_hTabStatusIcon = hIcon; + + if (m_cache->getStatus() != m_cache->getOldStatus()) { + wcsncpy_s(m_wszStatus, pcli->pfnGetStatusModeDescription(m_wStatus, 0), _TRUNCATE); + + TCITEM item = {}; + item.mask = TCIF_TEXT; + item.pszText = m_wszTitle; + TabCtrl_SetItem(m_hwndParent, m_iTabID, &item); + } + SetWindowText(m_hwnd, szTemp); + if (m_pContainer->hwndActive == m_hwnd) { + m_pContainer->UpdateTitle(0, this); + SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (m_si == nullptr && (uMsg == WM_ACTIVATE || uMsg == WM_SETFOCUS)) @@ -1996,66 +2058,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SendMessage(m_hwnd, GC_REDRAWLOG2, 0, 0); break; - case DM_UPDATETITLE: - case GC_UPDATETITLE: - m_wStatus = m_si->wStatus; - { - const wchar_t *szNick = m_cache->getNick(); - if (mir_wstrlen(szNick) > 0) { - if (M.GetByte("cuttitle", 0)) - CutContactName(szNick, m_wszTitle, _countof(m_wszTitle)); - else - wcsncpy_s(m_wszTitle, szNick, _TRUNCATE); - } - - wchar_t szTemp[100]; - HICON hIcon = 0; - - switch (m_si->iType) { - case GCW_CHATROOM: - hIcon = Skin_LoadProtoIcon(m_si->pszModule, (m_wStatus <= ID_STATUS_OFFLINE) ? ID_STATUS_OFFLINE : m_wStatus); - mir_snwprintf(szTemp, - (m_si->nUsersInNicklist == 1) ? TranslateT("%s: chat room (%u user%s)") : TranslateT("%s: chat room (%u users%s)"), - szNick, m_si->nUsersInNicklist, m_bFilterEnabled ? TranslateT(", event filter active") : L""); - break; - case GCW_PRIVMESS: - hIcon = Skin_LoadProtoIcon(m_si->pszModule, (m_wStatus <= ID_STATUS_OFFLINE) ? ID_STATUS_OFFLINE : m_wStatus); - if (m_si->nUsersInNicklist == 1) - mir_snwprintf(szTemp, TranslateT("%s: message session"), szNick); - else - mir_snwprintf(szTemp, TranslateT("%s: message session (%u users)"), szNick, m_si->nUsersInNicklist); - break; - case GCW_SERVER: - mir_snwprintf(szTemp, L"%s: Server", szNick); - hIcon = LoadIconEx("window"); - break; - } - - if (m_pWnd) { - m_pWnd->updateTitle(m_wszTitle); - m_pWnd->updateIcon(hIcon); - } - m_hTabStatusIcon = hIcon; - - if (lParam) - m_hTabIcon = m_hTabStatusIcon; - - if (m_cache->getStatus() != m_cache->getOldStatus()) { - wcsncpy_s(m_wszStatus, pcli->pfnGetStatusModeDescription(m_wStatus, 0), _TRUNCATE); - - TCITEM item = {}; - item.mask = TCIF_TEXT; - item.pszText = m_wszTitle; - TabCtrl_SetItem(m_hwndParent, m_iTabID, &item); - } - SetWindowText(m_hwnd, szTemp); - if (m_pContainer->hwndActive == m_hwnd) { - SendMessage(m_pContainer->hwnd, DM_UPDATETITLE, (WPARAM)m_hwnd, 1); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - } - } - break; - case GC_UPDATESTATUSBAR: if (m_pContainer->hwndActive != m_hwnd || m_pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || m_wszStatusBar[0]) break; @@ -2342,7 +2344,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) int i = m_list.SendMsg(LB_GETTOPINDEX, 0, 0); m_list.SendMsg(LB_SETCOUNT, m_si->nUsersInNicklist, 0); m_list.SendMsg(LB_SETTOPINDEX, i, 0); - SendMessage(m_hwnd, GC_UPDATETITLE, 0, 0); + UpdateTitle(); + m_hTabIcon = m_hTabStatusIcon; } break; diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index fcbd5be40f..4f33d16414 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -41,6 +41,45 @@ static TContainerData* TSAPI RemoveContainerFromList(TContainerData*); static bool fForceOverlayIcons = false;
+void TContainerData::UpdateTitle(MCONTACT hContact, CTabBaseDlg *pDlg)
+{
+ if (pDlg) { // lParam != 0 means sent by a chat window
+ wchar_t szText[512];
+ GetWindowText(pDlg->GetHwnd(), szText, _countof(szText));
+ szText[_countof(szText) - 1] = 0;
+ SetWindowText(hwnd, szText);
+ SendMessage(hwnd, DM_SETICON, (WPARAM)pDlg, (LPARAM)(pDlg->m_hTabIcon != pDlg->m_hTabStatusIcon ? pDlg->m_hTabIcon : pDlg->m_hTabStatusIcon));
+ return;
+ }
+
+ CTabBaseDlg *dat = nullptr;
+ if (hContact == 0) { // no hContact given - obtain the hContact for the active tab
+ if (hwndActive && IsWindow(hwndActive))
+ SendMessage(hwndActive, DM_QUERYHCONTACT, 0, (LPARAM)&hContact);
+ else
+ return;
+ dat = (CTabBaseDlg*)GetWindowLongPtr(hwndActive, GWLP_USERDATA);
+ }
+ else {
+ HWND hwnd = M.FindWindow(hContact);
+ if (hwnd == nullptr) {
+ SESSION_INFO *si = SM_FindSessionByHCONTACT(hContact);
+ if (si) {
+ si->pDlg->UpdateTitle();
+ return;
+ }
+ }
+ if (hwnd && hContact)
+ dat = (CTabBaseDlg*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ }
+ if (dat) {
+ SendMessage(hwnd, DM_SETICON, (WPARAM)dat, (LPARAM)(dat->m_hXStatusIcon ? dat->m_hXStatusIcon : dat->m_hTabStatusIcon));
+ CMStringW szTitle;
+ if (Utils::FormatTitleBar(dat, settings->szTitleFormat, szTitle))
+ SetWindowText(hwnd, szTitle);
+ }
+}
+
// Windows Vista+
// extend the glassy area to get aero look for the status bar, tab bar, info panel
// and outer margins.
@@ -1183,48 +1222,6 @@ panel_found: }
return 0;
- case DM_UPDATETITLE:
- hContact = 0;
- dat = nullptr;
-
- if (lParam) { // lParam != 0 means sent by a chat window
- wchar_t szText[512];
- dat = (CTabBaseDlg*)GetWindowLongPtr((HWND)wParam, GWLP_USERDATA);
- GetWindowText((HWND)wParam, szText, _countof(szText));
- szText[_countof(szText) - 1] = 0;
- SetWindowText(hwndDlg, szText);
- if (dat)
- SendMessage(hwndDlg, DM_SETICON, (WPARAM)dat, (LPARAM)(dat->m_hTabIcon != dat->m_hTabStatusIcon ? dat->m_hTabIcon : dat->m_hTabStatusIcon));
- return 0;
- }
- if (wParam == 0) { // no hContact given - obtain the hContact for the active tab
- if (pContainer->hwndActive && IsWindow(pContainer->hwndActive))
- SendMessage(pContainer->hwndActive, DM_QUERYHCONTACT, 0, (LPARAM)&hContact);
- else
- break;
- dat = (CTabBaseDlg*)GetWindowLongPtr(pContainer->hwndActive, GWLP_USERDATA);
- }
- else {
- HWND hwnd = M.FindWindow(wParam);
- if (hwnd == 0) {
- SESSION_INFO *si = SM_FindSessionByHCONTACT(wParam);
- if (si) {
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATETITLE, 0, 0);
- return 0;
- }
- }
- hContact = wParam;
- if (hwnd && hContact)
- dat = (CTabBaseDlg*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- }
- if (dat) {
- SendMessage(hwndDlg, DM_SETICON, (WPARAM)dat, (LPARAM)(dat->m_hXStatusIcon ? dat->m_hXStatusIcon : dat->m_hTabStatusIcon));
- CMStringW szTitle;
- if (Utils::FormatTitleBar(dat, pContainer->settings->szTitleFormat, szTitle))
- SetWindowText(hwndDlg, szTitle);
- }
- return 0;
-
case WM_TIMER:
if (wParam == TIMERID_HEARTBEAT) {
if (GetForegroundWindow() != hwndDlg && (pContainer->settings->autoCloseSeconds > 0) && !pContainer->fHidden) {
@@ -1392,7 +1389,7 @@ panel_found: hContact = 0;
SendMessage(pContainer->hwndActive, DM_QUERYHCONTACT, 0, (LPARAM)&hContact);
if (hContact)
- SendMessage(hwndDlg, DM_UPDATETITLE, hContact, 0);
+ pContainer->UpdateTitle(hContact);
}
}
memset(&item, 0, sizeof(item));
@@ -1619,7 +1616,7 @@ panel_found: hContact = 0;
SendMessage(pContainer->hwndActive, DM_QUERYHCONTACT, 0, (LPARAM)&hContact);
if (hContact)
- SendMessage(hwndDlg, DM_UPDATETITLE, hContact, 0);
+ pContainer->UpdateTitle(hContact);
}
SendMessage(hwndDlg, WM_SIZE, 0, 1);
BroadCastContainer(pContainer, DM_CONFIGURETOOLBAR, 0, 1);
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 88cc78091c..40bcd17ce3 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1080,9 +1080,9 @@ void CTabBaseDlg::DM_Typing(bool fForceOff) HandleIconFeedback(this, (HICON)-1); CTabBaseDlg *dat_active = (CTabBaseDlg*)GetWindowLongPtr(m_pContainer->hwndActive, GWLP_USERDATA); if (dat_active && !dat_active->isChat()) - SendMessage(hwndContainer, DM_UPDATETITLE, 0, 0); + m_pContainer->UpdateTitle(0); else - SendMessage(hwndContainer, DM_UPDATETITLE, (WPARAM)m_pContainer->hwndActive, 1); + m_pContainer->UpdateTitle(0, dat_active); if (!(m_pContainer->dwFlags & CNT_NOFLASH) && PluginConfig.m_FlashOnMTN) ReflashContainer(m_pContainer); } @@ -1302,7 +1302,7 @@ void CTabBaseDlg::DM_EventAdded(WPARAM hContact, LPARAM lParam) TabCtrl_SetCurSel(m_hwndParent, iItem); ShowWindow(m_pContainer->hwndActive, SW_HIDE); m_pContainer->hwndActive = m_hwnd; - SendMessage(m_pContainer->hwnd, DM_UPDATETITLE, m_hContact, 0); + m_pContainer->UpdateTitle(m_hContact); m_pContainer->dwFlags |= CNT_DEFERREDTABSELECT; } } @@ -1365,105 +1365,6 @@ void CTabBaseDlg::DM_HandleAutoSizeRequest(REQRESIZE* rr) DM_ScrollToBottom(1, 0); } -void CTabBaseDlg::DM_UpdateTitle(WPARAM, LPARAM lParam) -{ - DWORD dwOldIdle = m_idle; - const char *szActProto = 0; - - m_wszStatus[0] = 0; - - if (m_iTabID == -1) - return; - - TCITEM item = {}; - - wchar_t newtitle[128]; - if (m_hContact) { - const wchar_t *szNick = m_cache->getNick(); - - if (m_szProto) { - szActProto = m_cache->getProto(); - - bool bHasName = (m_cache->getUIN()[0] != 0); - m_idle = m_cache->getIdleTS(); - m_dwFlagsEx = m_idle ? m_dwFlagsEx | MWF_SHOW_ISIDLE : m_dwFlagsEx & ~MWF_SHOW_ISIDLE; - - m_wStatus = m_cache->getStatus(); - wcsncpy_s(m_wszStatus, pcli->pfnGetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : m_wStatus, 0), _TRUNCATE); - - if (lParam != 0) { - wchar_t newcontactname[128]; newcontactname[0] = 0; - if (PluginConfig.m_bCutContactNameOnTabs) - CutContactName(szNick, newcontactname, _countof(newcontactname)); - else - wcsncpy_s(newcontactname, szNick, _TRUNCATE); - - Utils::DoubleAmpersands(newcontactname, _countof(newcontactname)); - - if (newcontactname[0] != 0) { - if (PluginConfig.m_bStatusOnTabs) - mir_snwprintf(newtitle, L"%s (%s)", newcontactname, m_wszStatus); - else - wcsncpy_s(newtitle, newcontactname, _TRUNCATE); - } - else wcsncpy_s(newtitle, L"Forward", _TRUNCATE); - - item.mask |= TCIF_TEXT; - } - SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0); - - wchar_t fulluin[256]; - if (m_bIsMeta) - mir_snwprintf(fulluin, - TranslateT("UID: %s (SHIFT click -> copy to clipboard)\nClick for user's details\nRight click for metacontact control\nClick dropdown to add or remove user from your favorites."), - bHasName ? m_cache->getUIN() : TranslateT("No UID")); - else - mir_snwprintf(fulluin, - TranslateT("UID: %s (SHIFT click -> copy to clipboard)\nClick for user's details\nClick dropdown to change this contact's favorite status."), - bHasName ? m_cache->getUIN() : TranslateT("No UID")); - - SendDlgItemMessage(m_hwnd, IDC_NAME, BUTTONADDTOOLTIP, (WPARAM)fulluin, BATF_UNICODE); - } - } - else wcsncpy_s(newtitle, L"Message Session", _TRUNCATE); - - if (m_idle != dwOldIdle || lParam != 0) { - if (item.mask & TCIF_TEXT) { - item.pszText = m_wszTitle; - wcsncpy_s(m_wszTitle, newtitle, _TRUNCATE); - if (m_pWnd) - m_pWnd->updateTitle(m_cache->getNick()); - } - if (m_iTabID >= 0) { - TabCtrl_SetItem(m_hwndParent, m_iTabID, &item); - if (m_pContainer->dwFlags & CNT_SIDEBAR) - m_pContainer->SideBar->updateSession(this); - } - if (m_pContainer->hwndActive == m_hwnd && lParam) - SendMessage(m_pContainer->hwnd, DM_UPDATETITLE, m_hContact, 0); - - UpdateTrayMenuState(this, TRUE); - if (m_cache->isFavorite()) - AddContactToFavorites(m_hContact, m_cache->getNick(), szActProto, m_wszStatus, m_wStatus, - Skin_LoadProtoIcon(m_cache->getProto(), m_cache->getStatus()), 0, PluginConfig.g_hMenuFavorites); - - if (m_cache->isRecent()) - AddContactToFavorites(m_hContact, m_cache->getNick(), szActProto, m_wszStatus, m_wStatus, - Skin_LoadProtoIcon(m_cache->getProto(), m_cache->getStatus()), 0, PluginConfig.g_hMenuRecent); - - m_pPanel.Invalidate(); - if (m_pWnd) - m_pWnd->Invalidate(); - } - - // care about MetaContacts and update the statusbar icon with the currently "most online" contact... - if (m_bIsMeta) { - PostMessage(m_hwnd, DM_OWNNICKCHANGED, 0, 0); - if (m_pContainer->dwFlags & CNT_UINSTATUSBAR) - DM_UpdateLastMessage(); - } -} - ///////////////////////////////////////////////////////////////////////////////////////// // status icon stuff (by sje, used for indicating encryption status in the status bar // this is now part of the message window api diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index f7be82207b..3634081ff7 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -405,7 +405,7 @@ int CGlobals::DBSettingChanged(WPARAM hContact, LPARAM lParam) if (!strcmp(setting, "MirVer"))
PostMessage(hwnd, DM_CLIENTCHANGED, 0, 0);
if (fChanged || fExtendedStatusChange)
- PostMessage(hwnd, DM_UPDATETITLE, 0, 1);
+ c->getDat()->UpdateTitle();
if (fExtendedStatusChange)
PostMessage(hwnd, DM_UPDATESTATUSMSG, 0, 0);
if (fChanged) {
@@ -449,7 +449,7 @@ int CGlobals::MetaContactEvent(WPARAM hContact, LPARAM) c->updateMeta();
CTabBaseDlg *pDlg = c->getDat();
if (pDlg) {
- ::PostMessage(pDlg->GetHwnd(), DM_UPDATETITLE, 0, 1);
+ pDlg->UpdateTitle();
::PostMessage(pDlg->GetHwnd(), DM_UPDATEPICLAYOUT, 0, 0);
InvalidateRect(pDlg->GetHwnd(), 0, TRUE); // force redraw
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index dde75b1e75..9968b46906 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -310,7 +310,7 @@ void CSrmmWindow::MsgWindowUpdateState(UINT msg) }
m_pContainer->hIconTaskbarOverlay = 0;
- SendMessage(m_pContainer->hwnd, DM_UPDATETITLE, m_hContact, 0);
+ m_pContainer->UpdateTitle(m_hContact);
UpdateStatusBar();
m_dwLastActivity = GetTickCount();
@@ -420,7 +420,7 @@ void TSAPI SetDialogToType(HWND hwndDlg) Utils::showDlgControl(hwndDlg, IDC_MULTISPLITTER, (dat->m_sendMode & SMODE_MULTIPLE) ? SW_SHOW : SW_HIDE);
dat->EnableSendButton(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)) != 0);
- SendMessage(hwndDlg, DM_UPDATETITLE, 0, 1);
+ dat->UpdateTitle();
SendMessage(hwndDlg, WM_SIZE, 0, 0);
Utils::enableDlgControl(hwndDlg, IDC_CONTACTPIC, false);
@@ -1207,7 +1207,7 @@ void CSrmmWindow::OnInitDialog() m_pContainer->hwndActive = m_hwnd;
m_pContainer->dwFlags |= CNT_DEFERREDCONFIGURE;
}
- PostMessage(m_pContainer->hwnd, DM_UPDATETITLE, m_hContact, 0);
+ m_pContainer->UpdateTitle(m_hContact);
DM_RecalcPictureSize();
m_dwLastActivity = GetTickCount() - 1000;
@@ -1335,6 +1335,106 @@ void CSrmmWindow::ReplayQueue() TranslateT("Auto scrolling is disabled (press F12 to enable it)"));
}
+void CSrmmWindow::UpdateTitle()
+{
+ DWORD dwOldIdle = m_idle;
+ const char *szActProto = 0;
+
+ m_wszStatus[0] = 0;
+
+ if (m_iTabID == -1)
+ return;
+
+ TCITEM item = {};
+
+ bool bChanged = false;
+ wchar_t newtitle[128];
+ if (m_hContact) {
+ if (m_szProto) {
+ szActProto = m_cache->getProto();
+
+ bool bHasName = (m_cache->getUIN()[0] != 0);
+ m_idle = m_cache->getIdleTS();
+ m_dwFlagsEx = m_idle ? m_dwFlagsEx | MWF_SHOW_ISIDLE : m_dwFlagsEx & ~MWF_SHOW_ISIDLE;
+
+ m_wStatus = m_cache->getStatus();
+ wcsncpy_s(m_wszStatus, pcli->pfnGetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : m_wStatus, 0), _TRUNCATE);
+
+ wchar_t newcontactname[128]; newcontactname[0] = 0;
+ if (PluginConfig.m_bCutContactNameOnTabs)
+ CutContactName(m_cache->getNick(), newcontactname, _countof(newcontactname));
+ else
+ wcsncpy_s(newcontactname, m_cache->getNick(), _TRUNCATE);
+
+ Utils::DoubleAmpersands(newcontactname, _countof(newcontactname));
+
+ if (newcontactname[0] != 0) {
+ if (PluginConfig.m_bStatusOnTabs)
+ mir_snwprintf(newtitle, L"%s (%s)", newcontactname, m_wszStatus);
+ else
+ wcsncpy_s(newtitle, newcontactname, _TRUNCATE);
+ }
+ else wcsncpy_s(newtitle, L"Forward", _TRUNCATE);
+
+ if (mir_wstrcmp(newtitle, m_wszTitle)) {
+ bChanged = true;
+ item.mask |= TCIF_TEXT;
+ }
+
+ SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
+
+ wchar_t fulluin[256];
+ if (m_bIsMeta)
+ mir_snwprintf(fulluin,
+ TranslateT("UID: %s (SHIFT click -> copy to clipboard)\nClick for user's details\nRight click for metacontact control\nClick dropdown to add or remove user from your favorites."),
+ bHasName ? m_cache->getUIN() : TranslateT("No UID"));
+ else
+ mir_snwprintf(fulluin,
+ TranslateT("UID: %s (SHIFT click -> copy to clipboard)\nClick for user's details\nClick dropdown to change this contact's favorite status."),
+ bHasName ? m_cache->getUIN() : TranslateT("No UID"));
+
+ SendDlgItemMessage(m_hwnd, IDC_NAME, BUTTONADDTOOLTIP, (WPARAM)fulluin, BATF_UNICODE);
+ }
+ }
+ else wcsncpy_s(newtitle, L"Message Session", _TRUNCATE);
+
+ if (m_idle != dwOldIdle || bChanged) {
+ if (bChanged) {
+ item.pszText = m_wszTitle;
+ wcsncpy_s(m_wszTitle, newtitle, _TRUNCATE);
+ if (m_pWnd)
+ m_pWnd->updateTitle(m_cache->getNick());
+ }
+ if (m_iTabID >= 0) {
+ TabCtrl_SetItem(m_hwndParent, m_iTabID, &item);
+ if (m_pContainer->dwFlags & CNT_SIDEBAR)
+ m_pContainer->SideBar->updateSession(this);
+ }
+ if (m_pContainer->hwndActive == m_hwnd && bChanged)
+ m_pContainer->UpdateTitle(m_hContact);
+
+ UpdateTrayMenuState(this, TRUE);
+ if (m_cache->isFavorite())
+ AddContactToFavorites(m_hContact, m_cache->getNick(), szActProto, m_wszStatus, m_wStatus,
+ Skin_LoadProtoIcon(m_cache->getProto(), m_cache->getStatus()), 0, PluginConfig.g_hMenuFavorites);
+
+ if (m_cache->isRecent())
+ AddContactToFavorites(m_hContact, m_cache->getNick(), szActProto, m_wszStatus, m_wStatus,
+ Skin_LoadProtoIcon(m_cache->getProto(), m_cache->getStatus()), 0, PluginConfig.g_hMenuRecent);
+
+ m_pPanel.Invalidate();
+ if (m_pWnd)
+ m_pWnd->Invalidate();
+ }
+
+ // care about MetaContacts and update the statusbar icon with the currently "most online" contact...
+ if (m_bIsMeta) {
+ PostMessage(m_hwnd, DM_OWNNICKCHANGED, 0, 0);
+ if (m_pContainer->dwFlags & CNT_UINSTATUSBAR)
+ DM_UpdateLastMessage();
+ }
+}
+
void CSrmmWindow::onClick_Ok(CCtrlButton*)
{
if (m_bEditNotesActive) {
@@ -2412,10 +2512,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) DM_OptionsApplied(wParam, lParam);
return 0;
- case DM_UPDATETITLE:
- DM_UpdateTitle(wParam, lParam);
- return 0;
-
case DM_UPDATESTATUSMSG:
m_pPanel.Invalidate();
return 0;
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index d2b5330478..9049314a48 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -602,7 +602,7 @@ int TSAPI ActivateExistingTab(TContainerData *pContainer, HWND hwndChild) SendMessage(pContainer->hwnd, WM_NOTIFY, 0, (LPARAM)&nmhdr); // just select the tab and let WM_NOTIFY do the rest
}
if (!dat->isChat())
- SendMessage(pContainer->hwnd, DM_UPDATETITLE, dat->m_hContact, 0);
+ pContainer->UpdateTitle(dat->m_hContact);
if (IsIconic(pContainer->hwnd)) {
SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
SetForegroundWindow(pContainer->hwnd);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 1b7699b447..a2777ce4aa 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -224,6 +224,8 @@ struct TContainerData CTaskbarInteract* TaskBar;
CMenuBar *MenuBar;
CSideBar *SideBar;
+
+ void UpdateTitle(MCONTACT, class CTabBaseDlg* = nullptr);
};
struct SESSION_INFO;
@@ -241,7 +243,6 @@ protected: bool DM_GenericHotkeysCheck(MSG *message);
int DM_SplitterGlobalEvent(WPARAM wParam, LPARAM lParam);
void DM_UpdateLastMessage() const;
- void DM_UpdateTitle(WPARAM wParam, LPARAM lParam);
void DetermineMinHeight();
void FindFirstEvent();
@@ -454,6 +455,7 @@ public: virtual void OnDestroy() override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+ virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -494,6 +496,7 @@ public: virtual void OnDestroy() override;
virtual int Resizer(UTILRESIZECONTROL *urc) override;
+ virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -662,7 +665,6 @@ struct TIconDescW #define DM_SETINFOPANEL (TM_USER+13)
#define DM_OPTIONSAPPLIED (TM_USER+14)
#define DM_SPLITTERMOVED (TM_USER+15)
-#define DM_UPDATETITLE (TM_USER+16)
#define DM_SPLITSENDACK (TM_USER+19)
#define DM_TYPING (TM_USER+20)
#define DM_UPDATEWINICON (TM_USER+21)
|