diff options
author | George Hazan <george.hazan@gmail.com> | 2024-09-20 16:21:13 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-09-20 16:21:13 +0300 |
commit | 382079ff3bb4b59381234355226fc84f09a46168 (patch) | |
tree | 61cc3c4b4b754501e73a20846f7fba38d363dbc7 /plugins/TabSRMM | |
parent | 81c4c58099694dec4a7234b6c6028d478f08262f (diff) |
useless code removed
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat_main.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/functions.h | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/hotkeyhandler.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 18 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 38 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 2 |
7 files changed, 30 insertions, 44 deletions
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 8c53bc0fb4..ee0ea0d942 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -199,7 +199,7 @@ static void CheckUpdate() void ShowRoom(TContainerData *pContainer, SESSION_INFO *si)
{
if (si)
- AutoCreateWindow(pContainer, si->hContact, 0);
+ AutoCreateWindow(pContainer, si->hContact);
}
static void stubShowRoom(SESSION_INFO *si)
@@ -211,7 +211,7 @@ static void stubShowRoom(SESSION_INFO *si) if (si->pDlg)
si->pDlg->ActivateTab();
else
- AutoCreateWindow(nullptr, si->hContact, 0, true);
+ AutoCreateWindow(nullptr, si->hContact, true);
}
static MODULEINFO* MM_CreateModule()
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index c51ea191c2..abec648c45 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -2292,7 +2292,7 @@ int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd) /////////////////////////////////////////////////////////////////////////////////////////
-CMsgDialog* TSAPI AutoCreateWindow(TContainerData *pContainer, MCONTACT hContact, MEVENT hDbEvent, bool bActivate)
+CMsgDialog* TSAPI AutoCreateWindow(TContainerData *pContainer, MCONTACT hContact, bool bActivate)
{
wchar_t szName[CONTAINER_NAMELEN + 1];
GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN);
@@ -2331,7 +2331,7 @@ CMsgDialog* TSAPI AutoCreateWindow(TContainerData *pContainer, MCONTACT hContact if (pContainer == nullptr && g_plugin.bAutoContainer)
pContainer = CreateContainer(szName, CNT_CREATEFLAG_MINIMIZED, hContact);
- return CreateNewTabForContact(pContainer, hContact, bActivate, g_plugin.bPopupContainer, hDbEvent);
+ return CreateNewTabForContact(pContainer, hContact, bActivate, g_plugin.bPopupContainer);
}
return nullptr;
diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index 062d7ac829..a168f28323 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -53,9 +53,7 @@ CMsgDialog* TSAPI CreateNewTabForContact( MCONTACT hContact,
bool bActivateTAb,
bool bPopupContainer,
- MEVENT hdbEvent = 0,
- bool bIsWchar = false,
- const char *pszInitialText = nullptr);
+ MEVENT hdbEvent = 0);
int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd);
void TSAPI CreateImageList(bool bInitial);
@@ -64,7 +62,7 @@ TContainerData* TSAPI FindMatchingContainer(const wchar_t *szName); TContainerData* TSAPI CreateContainer(const wchar_t *name, int iTemp, MCONTACT hContactFrom);
TContainerData* TSAPI FindContainerByName(const wchar_t *name);
-CMsgDialog* TSAPI AutoCreateWindow(TContainerData*, MCONTACT, MEVENT, bool bActivate = false);
+CMsgDialog* TSAPI AutoCreateWindow(TContainerData*, MCONTACT hContact, bool bActivate = false);
int TSAPI GetTabIndexFromHWND(HWND hwndTab, HWND hwnd);
HWND TSAPI GetTabWindow(HWND hwndTab, int idx);
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 706a3d6192..54b77c5bb5 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -225,7 +225,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break;
case DM_CREATECONTAINER:
- if (!AutoCreateWindow(0, wParam, lParam)) {
+ if (!AutoCreateWindow(0, wParam)) {
// no window created, simply add an unread event to contact list
DB::EventInfo dbei(lParam, false);
if (dbei && !(dbei.flags & DBEF_READ)) {
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index f2747ceaea..b76cb19c9d 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -154,6 +154,15 @@ void CMsgDialog::SetDialogToType() m_pPanel.Configure();
}
+void CMsgDialog::SetInitMessage(const wchar_t *pwszInitMessage)
+{
+ m_message.SetText(pwszInitMessage);
+ int len = GetWindowTextLength(m_message.GetHwnd());
+ PostMessage(m_message.GetHwnd(), EM_SETSEL, len, len);
+ if (len)
+ EnableSendButton(true);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// subclasses the avatar display controls, needed for skinning and to prevent
// it from flickering during resize/move operations.
@@ -606,15 +615,6 @@ bool CMsgDialog::OnInitDialog() UpdateReadChars();
}
- if (wszInitialText) {
- m_message.SetText(wszInitialText);
- int len = GetWindowTextLength(m_message.GetHwnd());
- PostMessage(m_message.GetHwnd(), EM_SETSEL, len, len);
- if (len)
- EnableSendButton(true);
- mir_free(wszInitialText);
- }
-
m_pContainer->QueryClientArea(rc);
SetWindowPos(m_hwnd, nullptr, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), m_bActivate ? 0 : SWP_NOZORDER | SWP_NOACTIVATE);
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 50a897dc0c..359fcf67ad 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -115,7 +115,7 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) if (pContainer == nullptr)
pContainer = CreateContainer(szName, FALSE, hContact);
if (pContainer)
- CreateNewTabForContact(pContainer, hContact, true, true, 0);
+ CreateNewTabForContact(pContainer, hContact, true, true);
}
return 0;
}
@@ -126,15 +126,11 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) // it is implemented as a service, so external plugins can use it to open a message window.
// contacts handle must be passed in wParam.
-INT_PTR SendMessageCommand_Worker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar)
+INT_PTR SendMessageCommand_Worker(MCONTACT hContact, const wchar_t *pwszInitMsg)
{
// make sure that only the main UI thread will handle window creation
if (GetCurrentThreadId() != PluginConfig.dwThreadID) {
- if (pszMsg) {
- wchar_t *tszText = (isWchar) ? mir_wstrdup((wchar_t*)pszMsg) : mir_a2u(pszMsg);
- PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, (LPARAM)tszText);
- }
- else PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, 0);
+ PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, hContact, LPARAM(mir_wstrdup(pwszInitMsg)));
return 0;
}
@@ -145,17 +141,9 @@ INT_PTR SendMessageCommand_Worker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar if (0 == (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND))
return 0;
- if (auto *pDlg = Srmm_FindDialog(hContact)) {
- if (pszMsg) {
- HWND hEdit = GetDlgItem(pDlg->GetHwnd(), IDC_SRMM_MESSAGE);
- SendMessage(hEdit, EM_SETSEL, -1, GetWindowTextLength(hEdit));
- if (isWchar)
- SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
- else
- SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
- }
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg)
pDlg->ActivateTab();
- }
else {
wchar_t szName[CONTAINER_NAMELEN + 1];
GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN);
@@ -164,19 +152,23 @@ INT_PTR SendMessageCommand_Worker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar if (pContainer == nullptr)
pContainer = CreateContainer(szName, FALSE, hContact);
if (pContainer)
- CreateNewTabForContact(pContainer, hContact, true, true, 0, isWchar, pszMsg);
+ pDlg = CreateNewTabForContact(pContainer, hContact, true, true);
}
+
+ if (pDlg && pwszInitMsg)
+ pDlg->SetInitMessage(pwszInitMsg);
+
return 0;
}
INT_PTR SendMessageCommand(WPARAM hContact, LPARAM lParam)
{
- return SendMessageCommand_Worker(hContact, LPCSTR(lParam), false);
+ return SendMessageCommand_Worker(hContact, _A2T((const char*)lParam));
}
INT_PTR SendMessageCommand_W(WPARAM hContact, LPARAM lParam)
{
- return SendMessageCommand_Worker(hContact, LPCSTR(lParam), true);
+ return SendMessageCommand_Worker(hContact, (const wchar_t*)lParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -250,9 +242,7 @@ CMsgDialog* TSAPI CreateNewTabForContact( MCONTACT hContact,
bool bActivateTab,
bool bPopupContainer,
- MEVENT hdbEvent,
- bool bIsUnicode,
- const char *pszInitialText)
+ MEVENT hdbEvent)
{
if (pContainer == nullptr)
return nullptr;
@@ -340,8 +330,6 @@ CMsgDialog* TSAPI CreateNewTabForContact( pWindow->m_bActivate = bActivateTab;
pWindow->m_bWantPopup = !bActivateTab;
pWindow->m_hDbEventFirst = hdbEvent;
- if (pszInitialText)
- pWindow->wszInitialText = (bIsUnicode) ? mir_wstrdup((const wchar_t *)pszInitialText) : mir_a2u(pszInitialText);
pWindow->SetParent(pContainer->m_hwndTabs);
pWindow->Create();
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index acc98e2e62..f713b470b8 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -535,7 +535,6 @@ public: int rcLogBottom;
bool m_bActivate, m_bWantPopup, m_bIsMeta;
- wchar_t* wszInitialText;
TOOLINFO ti;
CInfoPanel m_pPanel;
CProxyWindow *m_pWnd; // proxy window object (win7+, for taskbar support).
@@ -646,6 +645,7 @@ public: void SaveSplitter(void);
void SelectContainer(void);
void SetDialogToType(void);
+ void SetInitMessage(const wchar_t *pwszInitMessage);
void ShowPicture(bool showNewPic);
void SplitterMoved(int x, HWND hwnd);
void SwitchToContainer(const wchar_t *szNewName);
|