diff options
Diffstat (limited to 'plugins/TabSRMM/src/chat_main.cpp')
-rw-r--r-- | plugins/TabSRMM/src/chat_main.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 8d81611f87..acd23cd324 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -203,6 +203,134 @@ static void CheckUpdate() }
/////////////////////////////////////////////////////////////////////////////////////////
+// chat session creator
+
+void ShowRoom(TContainerData *pContainer, SESSION_INFO *si)
+{
+ if (si == nullptr)
+ return;
+
+ if (si->pDlg != nullptr) {
+ ActivateExistingTab(si->pDlg->m_pContainer, si->pDlg->GetHwnd());
+ return;
+ }
+
+ wchar_t szName[CONTAINER_NAMELEN + 2]; szName[0] = 0;
+
+ if (pContainer == nullptr)
+ if (si->pDlg != nullptr)
+ pContainer = si->pDlg->m_pContainer;
+
+ if (pContainer == nullptr) {
+ GetContainerNameForContact(si->hContact, szName, CONTAINER_NAMELEN);
+ if (!g_Settings.bOpenInDefault && !mir_wstrcmp(szName, L"default"))
+ wcsncpy(szName, L"Chat Rooms", CONTAINER_NAMELEN);
+ szName[CONTAINER_NAMELEN] = 0;
+ pContainer = FindContainerByName(szName);
+ }
+
+ if (pContainer == nullptr)
+ pContainer = CreateContainer(szName, FALSE, si->hContact);
+ if (pContainer == nullptr)
+ return; // smth went wrong, nothing to do here
+
+ MCONTACT hContact = si->hContact;
+ if (Srmm_FindWindow(hContact) != nullptr)
+ return;
+
+ if (hContact != 0 && M.GetByte("limittabs", 0) && !wcsncmp(pContainer->m_wszName, L"default", 6))
+ if ((pContainer = FindMatchingContainer(L"default")) == nullptr)
+ if ((pContainer = CreateContainer(L"default", CNT_CREATEFLAG_CLONED, hContact)) == nullptr)
+ return;
+
+ wchar_t *contactName = Clist_GetContactDisplayName(hContact);
+
+ // cut nickname if larger than x chars...
+ wchar_t newcontactname[128];
+ if (mir_wstrlen(contactName) > 0) {
+ if (M.GetByte("cuttitle", 0))
+ CutContactName(contactName, newcontactname, _countof(newcontactname));
+ else
+ wcsncpy_s(newcontactname, contactName, _TRUNCATE);
+ }
+ else wcsncpy_s(newcontactname, L"_U_", _TRUNCATE);
+
+ HWND hwndTab = GetDlgItem(pContainer->m_hwnd, IDC_MSGTABS);
+
+ // hide the active tab
+ if (pContainer->m_hwndActive)
+ ShowWindow(pContainer->m_hwndActive, SW_HIDE);
+
+ int iTabIndex_wanted = M.GetDword(hContact, "tabindex", pContainer->m_iChilds * 100);
+ int iCount = TabCtrl_GetItemCount(hwndTab);
+
+ pContainer->m_iTabIndex = iCount;
+ if (iCount > 0) {
+ for (int i = iCount - 1; i >= 0; i--) {
+ HWND hwnd = GetTabWindow(hwndTab, i);
+ CMsgDialog *dat = (CMsgDialog *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (dat) {
+ int relPos = M.GetDword(dat->m_hContact, "tabindex", i * 100);
+ if (iTabIndex_wanted <= relPos)
+ pContainer->m_iTabIndex = i;
+ }
+ }
+ }
+
+ TCITEM item = {};
+ item.pszText = newcontactname;
+ item.mask = TCIF_TEXT | TCIF_IMAGE;
+ int iTabId = TabCtrl_InsertItem(hwndTab, pContainer->m_iTabIndex, &item);
+
+ SendMessage(hwndTab, EM_REFRESHWITHOUTCLIP, 0, 0);
+ TabCtrl_SetCurSel(hwndTab, iTabId);
+ pContainer->m_iChilds++;
+
+ CMsgDialog *pDlg = new CMsgDialog(si);
+ pDlg->m_iTabID = iTabId;
+ pDlg->m_pContainer = pContainer;
+ pDlg->SetParent(hwndTab);
+ pDlg->Create();
+
+ HWND hwndNew = pDlg->GetHwnd();
+ item.lParam = (LPARAM)hwndNew;
+ TabCtrl_SetItem(hwndTab, iTabId, &item);
+
+ if (pContainer->m_dwFlags & CNT_SIDEBAR)
+ pContainer->m_pSideBar->addSession(pDlg, pContainer->m_iTabIndex);
+
+ SendMessage(pContainer->m_hwnd, WM_SIZE, 0, 0);
+ // if the container is minimized, then pop it up...
+ if (IsIconic(pContainer->m_hwnd)) {
+ SendMessage(pContainer->m_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
+ SetFocus(pContainer->m_hwndActive);
+ }
+
+ if (PluginConfig.m_bHideOnClose && !IsWindowVisible(pContainer->m_hwnd)) {
+ WINDOWPLACEMENT wp = { 0 };
+ wp.length = sizeof(wp);
+ GetWindowPlacement(pContainer->m_hwnd, &wp);
+
+ BroadCastContainer(pContainer, DM_CHECKSIZE, 0, 0); // make sure all tabs will re-check layout on activation
+ if (wp.showCmd == SW_SHOWMAXIMIZED)
+ ShowWindow(pContainer->m_hwnd, SW_SHOWMAXIMIZED);
+ else {
+ ShowWindow(pContainer->m_hwnd, SW_SHOWNORMAL);
+ }
+ SendMessage(pContainer->m_hwndActive, WM_SIZE, 0, 0);
+ SetFocus(hwndNew);
+ }
+ else {
+ SetFocus(hwndNew);
+ RedrawWindow(pContainer->m_hwnd, nullptr, nullptr, RDW_INVALIDATE);
+ UpdateWindow(pContainer->m_hwnd);
+ if (GetForegroundWindow() != pContainer->m_hwnd)
+ SetForegroundWindow(pContainer->m_hwnd);
+ }
+
+ if (IsWinVer7Plus() && PluginConfig.m_useAeroPeek && CSkin::m_skinEnabled && !M.GetByte("forceAeroPeek", 0))
+ CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING | MB_OK);
+}
static void stubShowRoom(SESSION_INFO *si)
{
|