summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-05-12 12:47:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-05-12 12:47:35 +0300
commit002aca2fb53de2d7593e305c99190c52c3d72391 (patch)
treec5a8dd3155d751ec63bc6ee1f8c022253ba44ca5
parent2093ff88d5badf348372057c59453175412f0dd7 (diff)
tabSRMM: some unused/obsoleted events removed
-rw-r--r--plugins/TabSRMM/src/container.cpp10
-rw-r--r--plugins/TabSRMM/src/containeroptions.cpp8
-rw-r--r--plugins/TabSRMM/src/functions.h9
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp3
-rw-r--r--plugins/TabSRMM/src/hotkeyhandler.cpp9
-rw-r--r--plugins/TabSRMM/src/mim.cpp50
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp45
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp46
-rw-r--r--plugins/TabSRMM/src/msgs.cpp18
-rw-r--r--plugins/TabSRMM/src/msgs.h11
-rw-r--r--plugins/TabSRMM/src/selectcontainer.cpp77
11 files changed, 132 insertions, 154 deletions
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp
index acebc25dc2..1c9a0122bb 100644
--- a/plugins/TabSRMM/src/container.cpp
+++ b/plugins/TabSRMM/src/container.cpp
@@ -1369,7 +1369,7 @@ panel_found:
if (iSelection - IDM_CONTAINERMENU >= 0) {
ptrW tszName(db_get_wsa(0, CONTAINER_KEY, szIndex));
if (hDlg && tszName != nullptr)
- SendMessage(hDlg, DM_CONTAINERSELECTED, 0, tszName);
+ dat->SwitchToContainer(tszName);
}
return 1;
}
@@ -1403,11 +1403,10 @@ panel_found:
case ID_TABMENU_ATTACHTOCONTAINER:
hDlg = GetTabWindow(pContainer->m_hwndTabs, GetTabItemFromMouse(pContainer->m_hwndTabs, &pt));
if (hDlg)
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SELECTCONTAINER), hwndDlg, SelectContainerDlgProc, (LPARAM)hDlg);
+ ((CMsgDialog *)GetWindowLongPtr(hDlg, GWLP_USERDATA))->SelectContainer();
break;
case ID_TABMENU_CONTAINEROPTIONS:
- if (pContainer->m_hWndOptions == nullptr)
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTAINEROPTIONS), hwndDlg, DlgProcContainerOptions, (LPARAM)pContainer);
+ pContainer->OptionsDialog();
break;
case ID_TABMENU_CLOSECONTAINER:
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
@@ -1750,8 +1749,7 @@ panel_found:
case IDM_MOREOPTIONS:
if (IsIconic(pContainer->m_hwnd))
SendMessage(pContainer->m_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
- if (pContainer->m_hWndOptions == nullptr)
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTAINEROPTIONS), hwndDlg, DlgProcContainerOptions, (LPARAM)pContainer);
+ pContainer->OptionsDialog();
break;
case SC_MAXIMIZE:
pContainer->m_oldSize.cx = pContainer->m_oldSize.cy = 0;
diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp
index b2764b4b0f..dbbdeb682c 100644
--- a/plugins/TabSRMM/src/containeroptions.cpp
+++ b/plugins/TabSRMM/src/containeroptions.cpp
@@ -107,7 +107,7 @@ static void ShowPage(HWND hwndDlg, int iPage, BOOL fShow)
Utils::showDlgControl(hwndDlg, IDC_AVATARSONTASKBAR, SW_HIDE);
}
-INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndTree = GetDlgItem(hwndDlg, IDC_SECTIONTREE);
TContainerData *pContainer = (TContainerData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
@@ -518,3 +518,9 @@ do_apply: Utils::enableDlgControl(hwndDlg, IDC_APPLY, true);
}
return FALSE;
}
+
+void TContainerData::OptionsDialog()
+{
+ if (m_hWndOptions == nullptr)
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTAINEROPTIONS), m_hwnd, DlgProcContainerOptions, (LPARAM)this);
+}
diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h
index d2ecbf6a5c..397799465f 100644
--- a/plugins/TabSRMM/src/functions.h
+++ b/plugins/TabSRMM/src/functions.h
@@ -77,7 +77,7 @@ void TSAPI RenameContainer(int iIndex, const wchar_t *newName);
void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen);
HMENU TSAPI BuildContainerMenu();
-int TSAPI MessageWindowOpened(MCONTACT hContact, HWND hwnd);
+int TSAPI MessageWindowOpened(MCONTACT hContact, CMsgDialog *pDlg);
LRESULT CALLBACK IEViewSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK HPPKFSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -127,11 +127,4 @@ void TN_TypingMessage(MCONTACT hContact, int iMode);
void TSAPI DrawMenuItem(DRAWITEMSTRUCT *dis, HICON hIcon, DWORD dwIdle);
-/*
- * dialog procedures
- */
-
-INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
#endif /* _TABSRMM_FUNCTIONS_H */
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 04bed928fb..3466ec327b 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -132,8 +132,7 @@ bool CMsgDialog::DM_GenericHotkeysCheck(MSG *message)
return true;
case TABSRMM_HK_CONTAINEROPTIONS:
- if (m_pContainer->m_hWndOptions == nullptr)
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTAINEROPTIONS), m_pContainer->m_hwnd, DlgProcContainerOptions, (LPARAM)m_pContainer);
+ m_pContainer->OptionsDialog();
return true;
case TABSRMM_HK_SEND:
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp
index 2cf4330eb0..f395031df3 100644
--- a/plugins/TabSRMM/src/hotkeyhandler.cpp
+++ b/plugins/TabSRMM/src/hotkeyhandler.cpp
@@ -238,16 +238,15 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case DM_DOCREATETAB:
{
- HWND hWnd = Srmm_FindWindow(lParam);
- if (hWnd && IsWindow(hWnd)) {
- TContainerData *pContainer = nullptr;
- SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
+ auto *pDlg = Srmm_FindDialog(lParam);
+ if (pDlg) {
+ TContainerData *pContainer = pDlg->m_pContainer;
if (pContainer) {
int iTabs = TabCtrl_GetItemCount(pContainer->m_hwndTabs);
if (iTabs == 1)
SendMessage(pContainer->m_hwnd, WM_CLOSE, 0, 1);
else
- SendMessage(hWnd, WM_CLOSE, 0, 1);
+ SendMessage(pDlg->GetHwnd(), WM_CLOSE, 0, 1);
char *szProto = Proto_GetBaseAccountName(lParam);
if (szProto != nullptr && db_get_b(lParam, szProto, "ChatRoom", 0))
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp
index 110a4a2c73..00054758b2 100644
--- a/plugins/TabSRMM/src/mim.cpp
+++ b/plugins/TabSRMM/src/mim.cpp
@@ -216,44 +216,44 @@ void CMimAPI::InitAPI()
/////////////////////////////////////////////////////////////////////////////////////////
// hook subscriber function for incoming message typing events
-int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode)
+int CMimAPI::TypingMessage(WPARAM hContact, LPARAM nSecs)
{
int foundWin = 0, preTyping = 0;
BOOL fShowOnClist = TRUE;
- HWND hwnd = Srmm_FindWindow(hContact);
+ auto *pDlg = Srmm_FindDialog(hContact);
MCONTACT hMeta = db_mc_getMeta(hContact);
if (hMeta) {
- if (!hwnd)
- hwnd = Srmm_FindWindow(hMeta);
+ if (!pDlg)
+ pDlg = Srmm_FindDialog(hMeta);
hContact = hMeta;
}
- if (hwnd && g_plugin.getByte(SRMSGSET_SHOWTYPING, SRMSGDEFSET_SHOWTYPING))
- preTyping = SendMessage(hwnd, DM_TYPING, 0, mode);
+ if (pDlg && g_plugin.getByte(SRMSGSET_SHOWTYPING, SRMSGDEFSET_SHOWTYPING))
+ preTyping = pDlg->Typing(nSecs);
- if (hwnd && IsWindowVisible(hwnd))
- foundWin = MessageWindowOpened(0, hwnd);
+ if (pDlg && IsWindowVisible(pDlg->GetHwnd()))
+ foundWin = MessageWindowOpened(0, pDlg);
else
foundWin = 0;
TContainerData *pContainer = nullptr;
- if (hwnd) {
- SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
+ if (pDlg) {
+ pContainer = pDlg->m_pContainer;
if (pContainer == nullptr) // should never happen
return 0;
}
if (g_plugin.getByte(SRMSGSET_SHOWTYPINGCLIST, SRMSGDEFSET_SHOWTYPINGCLIST)) {
- if (!hwnd && !g_plugin.getByte(SRMSGSET_SHOWTYPINGNOWINOPEN, 1))
+ if (!pDlg && !g_plugin.getByte(SRMSGSET_SHOWTYPINGNOWINOPEN, 1))
fShowOnClist = false;
- if (hwnd && !g_plugin.getByte(SRMSGSET_SHOWTYPINGWINOPEN, 1))
+ if (pDlg && !g_plugin.getByte(SRMSGSET_SHOWTYPINGWINOPEN, 1))
fShowOnClist = false;
}
else fShowOnClist = false;
- if ((!foundWin || !pContainer->m_flags.m_bNoSound) && preTyping != (mode != 0))
- Skin_PlaySound(mode ? "TNStart" : "TNStop");
+ if ((!foundWin || !pContainer->m_flags.m_bNoSound) && preTyping != (nSecs != 0))
+ Skin_PlaySound(nSecs ? "TNStart" : "TNStop");
if (g_plugin.getByte("ShowTypingPopup", 0)) {
BOOL fShow = false;
@@ -264,16 +264,15 @@ int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode)
fShow = true;
break;
case 1:
- if (!foundWin || !(pContainer && pContainer->m_hwndActive == hwnd && GetForegroundWindow() == pContainer->m_hwnd))
+ if (!foundWin || !(pContainer && pContainer->m_hwndActive == pDlg->GetHwnd() && GetForegroundWindow() == pContainer->m_hwnd))
fShow = true;
break;
case 2:
- if (hwnd == nullptr)
+ if (pDlg == nullptr)
fShow = true;
else {
if (PluginConfig.m_bHideOnClose) {
- TContainerData *pCont = nullptr;
- SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pCont);
+ TContainerData *pCont = pDlg->m_pContainer;
if (pCont && pCont->m_bHidden)
fShow = true;
}
@@ -281,10 +280,10 @@ int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode)
break;
}
if (fShow)
- TN_TypingMessage(hContact, mode);
+ TN_TypingMessage(hContact, nSecs);
}
- if (mode) {
+ if (nSecs) {
wchar_t szTip[256];
mir_snwprintf(szTip, TranslateT("%s is typing a message"), Clist_GetContactDisplayName(hContact));
if (fShowOnClist && g_plugin.getByte("ShowTypingBalloon", 0))
@@ -394,9 +393,9 @@ int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
- HWND hwnd = Srmm_FindWindow(hContact);
- if (hwnd == nullptr)
- hwnd = Srmm_FindWindow(db_event_getContact(hDbEvent));
+ auto *pDlg = Srmm_FindDialog(hContact);
+ if (pDlg == nullptr)
+ pDlg = Srmm_FindDialog(db_event_getContact(hDbEvent));
BOOL isCustomEvent = IsCustomEvent(dbei.eventType);
BOOL isShownCustomEvent = DbEventIsForMsgWindow(&dbei);
@@ -409,9 +408,8 @@ int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
bool bAutoCreate = M.GetBool("autotabs", true);
bool bAutoContainer = M.GetBool("autocontainer", true);
- if (hwnd) {
- TContainerData *pTargetContainer = nullptr;
- SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pTargetContainer);
+ if (pDlg) {
+ TContainerData *pTargetContainer = pDlg->m_pContainer;
if (pTargetContainer == nullptr || !PluginConfig.m_bHideOnClose || IsWindowVisible(pTargetContainer->m_hwnd))
return 0;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 69f9d20f17..c0acfbd068 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -2636,18 +2636,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
SetBkColor((HDC)wParam, g_Settings.crUserListBGColor);
return (INT_PTR)g_chatApi.hListBkgBrush;
- case DM_TYPING:
- if (m_si == nullptr || m_si->iType == GCW_PRIVMESS) {
- int preTyping = m_nTypeSecs != 0;
- m_nTypeSecs = (int)lParam > 0 ? (int)lParam : 0;
-
- if (m_nTypeSecs)
- m_bShowTyping = 0;
-
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, preTyping);
- }
- return TRUE;
-
case DM_UPDATEWINICON:
UpdateWindowIcon();
return 0;
@@ -2884,7 +2872,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (iSelection - IDM_CONTAINERMENU >= 0) {
ptrW val(db_get_wsa(0, szKey, szIndex));
if (val)
- SendMessage(m_hwnd, DM_CONTAINERSELECTED, 0, (LPARAM)val);
+ SwitchToContainer(val);
}
break;
}
@@ -3217,11 +3205,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
ActivateTab();
return 0;
- case DM_QUERYCONTAINER: // container API support functions
- if (lParam)
- *(TContainerData **)lParam = m_pContainer;
- return 0;
-
case DM_QUERYHCONTACT:
if (lParam)
*(MCONTACT *)lParam = m_hContact;
@@ -3231,32 +3214,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_bNeedCheckSize = true;
return 0;
- case DM_CONTAINERSELECTED:
- // sent by the select container dialog box when a container was selected...
- // lParam = (wchar_t*)selected name...
- {
- wchar_t *szNewName = (wchar_t *)lParam;
- if (!mir_wstrcmp(szNewName, TranslateT("Default container")))
- szNewName = CGlobals::m_default_container_name;
-
- int iOldItems = TabCtrl_GetItemCount(m_hwndParent);
- if (!wcsncmp(m_pContainer->m_wszName, szNewName, CONTAINER_NAMELEN))
- break;
-
- TContainerData *pNewContainer = FindContainerByName(szNewName);
- if (pNewContainer == nullptr)
- if ((pNewContainer = CreateContainer(szNewName, FALSE, m_hContact)) == nullptr)
- break;
-
- db_set_ws(m_hContact, SRMSGMOD_T, "containerW", szNewName);
- PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_DOCREATETAB, (WPARAM)pNewContainer, m_hContact);
- if (iOldItems > 1) // there were more than 1 tab, container is still valid
- SendMessage(m_pContainer->m_hwndActive, WM_SIZE, 0, 0);
- SetForegroundWindow(pNewContainer->m_hwnd);
- SetActiveWindow(pNewContainer->m_hwnd);
- }
- return 0;
-
case DM_STATUSBARCHANGED:
tabUpdateStatusBar();
break;
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index ee45e05116..67e85f43b8 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -45,7 +45,7 @@ void CMsgDialog::AddLog()
{
if (PluginConfig.m_bUseDividers) {
if (PluginConfig.m_bDividersUsePopupConfig) {
- if (!MessageWindowOpened(0, m_hwnd))
+ if (!MessageWindowOpened(0, this))
DM_AddDivider();
}
else {
@@ -1089,11 +1089,10 @@ int CMsgDialog::MsgWindowMenuHandler(int selection, int menuId)
if (menuId == MENU_PICMENU || menuId == MENU_PANELPICMENU || menuId == MENU_TABCONTEXT) {
switch (selection) {
case ID_TABMENU_ATTACHTOCONTAINER:
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SELECTCONTAINER), m_hwnd, SelectContainerDlgProc, (LPARAM)m_hwnd);
+ SelectContainer();
return 1;
case ID_TABMENU_CONTAINEROPTIONS:
- if (m_pContainer->m_hWndOptions == nullptr)
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTAINEROPTIONS), m_hwnd, DlgProcContainerOptions, (LPARAM)m_pContainer);
+ m_pContainer->OptionsDialog();
return 1;
case ID_TABMENU_CLOSECONTAINER:
SendMessage(m_pContainer->m_hwnd, WM_CLOSE, 0, 0);
@@ -1711,6 +1710,31 @@ void CMsgDialog::StreamEvents(MEVENT hDbEventFirst, int count, bool bAppend)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// sent by the select container dialog box when a container was selected...
+
+void CMsgDialog::SwitchToContainer(const wchar_t *szNewName)
+{
+ if (!mir_wstrcmp(szNewName, TranslateT("Default container")))
+ szNewName = CGlobals::m_default_container_name;
+
+ int iOldItems = TabCtrl_GetItemCount(m_hwndParent);
+ if (!wcsncmp(m_pContainer->m_wszName, szNewName, CONTAINER_NAMELEN))
+ return;
+
+ TContainerData *pNewContainer = FindContainerByName(szNewName);
+ if (pNewContainer == nullptr)
+ if ((pNewContainer = CreateContainer(szNewName, FALSE, m_hContact)) == nullptr)
+ return;
+
+ db_set_ws(m_hContact, SRMSGMOD_T, "containerW", szNewName);
+ PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_DOCREATETAB, (WPARAM)pNewContainer, m_hContact);
+ if (iOldItems > 1) // there were more than 1 tab, container is still valid
+ SendMessage(m_pContainer->m_hwndActive, WM_SIZE, 0, 0);
+ SetForegroundWindow(pNewContainer->m_hwnd);
+ SetActiveWindow(pNewContainer->m_hwnd);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
bool CMsgDialog::TabAutoComplete()
{
@@ -1860,6 +1884,20 @@ void CMsgDialog::tabUpdateStatusBar() const
}
}
+int CMsgDialog::Typing(int secs)
+{
+ if (m_si != nullptr && m_si->iType != GCW_PRIVMESS)
+ return 0;
+
+ int preTyping = m_nTypeSecs != 0;
+
+ m_nTypeSecs = (secs > 0) ? secs : 0;
+ if (m_nTypeSecs)
+ m_bShowTyping = 0;
+
+ return preTyping;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void CMsgDialog::UpdateNickList()
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index 492e9072e1..2f106f009b 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -70,22 +70,14 @@ int SmileyAddOptionsChanged(WPARAM, LPARAM)
// 0 if there is none (or the popup mode of the target container was configured to "hide"
// the window..
-int TSAPI MessageWindowOpened(MCONTACT hContact, HWND _hwnd)
+int TSAPI MessageWindowOpened(MCONTACT hContact, CMsgDialog *pDlg)
{
- HWND hwnd = nullptr;
- TContainerData *pContainer = nullptr;
-
if (hContact)
- hwnd = Srmm_FindWindow(hContact);
- else if (_hwnd)
- hwnd = _hwnd;
- else
- return 0;
-
- if (!hwnd)
+ pDlg = Srmm_FindDialog(hContact);
+ else if (!pDlg)
return 0;
- SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
+ TContainerData *pContainer = pDlg->m_pContainer;
if (pContainer) {
if (pContainer->m_flags.m_bDontReport) {
if (IsIconic(pContainer->m_hwnd))
@@ -99,7 +91,7 @@ int TSAPI MessageWindowOpened(MCONTACT hContact, HWND _hwnd)
if (pContainer->m_flags.m_bDontReportFocused)
return 0;
- return pContainer->m_hwndActive == hwnd;
+ return pContainer->m_hwndActive == pDlg->GetHwnd();
}
}
return 1;
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 83979a2368..0305e83909 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -281,7 +281,8 @@ struct TContainerData : public MZeroedObject
void InitRedraw(void);
void LoadOverrideTheme(void);
void LoadThemeDefaults(void);
- void QueryPending();
+ void OptionsDialog(void);
+ void QueryPending(void);
void ReflashContainer(void);
void Resize(bool, int newWidth);
void RestoreWindowPos(void);
@@ -610,9 +611,12 @@ public:
void NotifyDeliveryFailure(void) const;
void RemakeLog(void);
void SaveSplitter(void);
+ void SelectContainer(void);
void SetDialogToType(void);
void ShowPicture(bool showNewPic);
void SplitterMoved(int x, HWND hwnd);
+ void SwitchToContainer(const wchar_t *szNewName);
+ int Typing(int secs);
void UpdateReadChars(void) const;
void UpdateSaveAndSendButton(void);
@@ -709,7 +713,6 @@ struct TIconDescW
#define DM_SETINFOPANEL (TM_USER+13)
#define DM_OPTIONSAPPLIED (TM_USER+14)
#define DM_SPLITSENDACK (TM_USER+19)
-#define DM_TYPING (TM_USER+20)
#define DM_UPDATEWINICON (TM_USER+21)
#define DM_UPDATELASTMESSAGE (TM_USER+22)
@@ -717,14 +720,12 @@ struct TIconDescW
#define DM_CREATECONTAINER (TM_USER+26)
#define DM_QUERYLASTUNREAD (TM_USER+28)
#define DM_UPDATEPICLAYOUT (TM_USER+30)
-#define DM_QUERYCONTAINER (TM_USER+31)
#define DM_MUCFLASHWORKER (TM_USER+32)
#define DM_APPENDMCEVENT (TM_USER+34)
-#define DM_CHECKINFOTIP (TM_USER+35)
+#define DM_CHECKINFOTIP (TM_USER+35)
#define DM_SAVESIZE (TM_USER+36)
#define DM_CHECKSIZE (TM_USER+37)
#define DM_FORCEREDRAW (TM_USER+38)
-#define DM_CONTAINERSELECTED (TM_USER+39)
#define DM_QUERYHCONTACT (TM_USER+41)
#define DM_QUERYCLIENTAREA (TM_USER+45)
#define DM_ACTIVATEME (TM_USER+46)
diff --git a/plugins/TabSRMM/src/selectcontainer.cpp b/plugins/TabSRMM/src/selectcontainer.cpp
index 6174bd48a4..63cf0477fa 100644
--- a/plugins/TabSRMM/src/selectcontainer.cpp
+++ b/plugins/TabSRMM/src/selectcontainer.cpp
@@ -28,34 +28,28 @@
#include "stdafx.h"
-INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- HWND hwndMsgDlg = nullptr;
-
- hwndMsgDlg = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ auto *pDlg = (CMsgDialog *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG: {
- wchar_t szNewTitle[128];
- RECT rc, rcParent;
-
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
- hwndMsgDlg = (HWND)lParam;
TranslateDialogDefault(hwndDlg);
- if (lParam) {
- CMsgDialog *dat = (CMsgDialog*)GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
- if (dat) {
- mir_snwprintf(szNewTitle, TranslateT("Select container for %s"), dat->m_cache->getNick());
- SetWindowText(hwndDlg, szNewTitle);
- }
+ pDlg = (CMsgDialog*)(lParam);
+ if (pDlg) {
+ wchar_t szNewTitle[128];
+ mir_snwprintf(szNewTitle, TranslateT("Select container for %s"), pDlg->m_cache->getNick());
+ SetWindowText(hwndDlg, szNewTitle);
}
SendMessage(hwndDlg, DM_SC_BUILDLIST, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_NEWCONTAINERNAME, EM_LIMITTEXT, (WPARAM)CONTAINER_NAMELEN, 0);
SendDlgItemMessage(hwndDlg, IDC_NEWCONTAINER, EM_LIMITTEXT, (WPARAM)CONTAINER_NAMELEN, 0);
+ RECT rc, rcParent;
GetWindowRect(hwndDlg, &rc);
GetWindowRect(GetParent(hwndDlg), &rcParent);
SetWindowPos(hwndDlg, nullptr, (rcParent.left + rcParent.right - (rc.right - rc.left)) / 2, (rcParent.top + rcParent.bottom - (rc.bottom - rc.top)) / 2, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
@@ -64,26 +58,24 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
case WM_COMMAND:
switch (LOWORD(wParam)) {
- case IDOK: {
- wchar_t szName[CONTAINER_NAMELEN];
+ case IDOK:
+ wchar_t szName[CONTAINER_NAMELEN + 1];
LRESULT iItem;
if ((iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETCURSEL, 0, 0)) != LB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM)iItem, (LPARAM)szName);
- if (IsWindow(hwndMsgDlg))
- SendMessage(hwndMsgDlg, DM_CONTAINERSELECTED, 0, (LPARAM)szName);
+ if (IsWindow(pDlg->GetHwnd()))
+ pDlg->SwitchToContainer(szName);
}
if (IsWindow(hwndDlg))
DestroyWindow(hwndDlg);
break;
- }
+
case IDCANCEL:
DestroyWindow(hwndDlg);
break;
- case IDC_DELETECONTAINER: {
- wchar_t szName[CONTAINER_NAMELEN + 1];
- LRESULT iItem;
-
+
+ case IDC_DELETECONTAINER:
if ((iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETCURSEL, 0, 0)) != LB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM)iItem, (LPARAM)szName);
if (!wcsncmp(szName, L"default", CONTAINER_NAMELEN) || !wcsncmp(szName, TranslateT("Default container"), CONTAINER_NAMELEN))
@@ -97,18 +89,17 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
}
}
break;
- }
- case IDC_RENAMECONTAINER: {
- wchar_t szNewName[CONTAINER_NAMELEN], szName[CONTAINER_NAMELEN + 1];
- int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME));
- if (iLen) {
+
+ case IDC_RENAMECONTAINER:
+ if (int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME))) {
+ wchar_t szNewName[CONTAINER_NAMELEN];
GetDlgItemText(hwndDlg, IDC_NEWCONTAINERNAME, szNewName, _countof(szNewName));
if (!wcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN) || !wcsncmp(szNewName, TranslateT("Default container"), CONTAINER_NAMELEN)) {
MessageBox(hwndDlg, TranslateT("You cannot rename the default container"), TranslateT("Error"), MB_OK | MB_ICONERROR);
break;
}
- int iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)-1, (LPARAM)szNewName);
+ iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)-1, (LPARAM)szNewName);
if (iItem != LB_ERR) {
wchar_t szOldName[CONTAINER_NAMELEN + 1];
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM)iItem, (LPARAM)szOldName);
@@ -138,14 +129,12 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
}
}
break;
- }
- case IDC_CREATENEW: {
- wchar_t szNewName[CONTAINER_NAMELEN], szName[CONTAINER_NAMELEN + 1];
- int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINER));
- if (iLen) {
+ case IDC_CREATENEW:
+ if (int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINER))) {
+ wchar_t szNewName[CONTAINER_NAMELEN];
GetDlgItemText(hwndDlg, IDC_NEWCONTAINER, szNewName, _countof(szNewName));
- int iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)-1, (LPARAM)szNewName);
+ iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM)-1, (LPARAM)szNewName);
if (iItem != LB_ERR || !wcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN)) {
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM)iItem, (LPARAM)szName);
if (mir_wstrlen(szName) == mir_wstrlen(szNewName) || !wcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN)) {
@@ -154,14 +143,15 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
break;
}
}
- if (IsWindow(hwndMsgDlg)) {
- SendMessage(hwndMsgDlg, DM_CONTAINERSELECTED, 0, (LPARAM)szNewName);
+
+ if (IsWindow(pDlg->GetHwnd())) {
+ pDlg->SwitchToContainer(szNewName);
if (IsWindow(hwndDlg))
DestroyWindow(hwndDlg);
}
}
break;
- }
+
case IDC_CNTLIST:
if (HIWORD(wParam) == LBN_DBLCLK)
SendMessage(hwndDlg, WM_COMMAND, IDOK, 0);
@@ -185,8 +175,7 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
}
// highlight the name of the container to which the message window currently is assigned
- TContainerData *pContainer = nullptr;
- SendMessage(hwndMsgDlg, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer);
+ TContainerData *pContainer = pDlg->m_pContainer;
if (pContainer) {
LRESULT iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, -1,
(LPARAM)(!mir_wstrcmp(pContainer->m_wszName, L"default") ? TranslateT("Default container") : pContainer->m_wszName));
@@ -197,3 +186,11 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
}
return FALSE;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// chooses a new container for a window
+
+void CMsgDialog::SelectContainer()
+{
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SELECTCONTAINER), m_hwnd, SelectContainerDlgProc, (LPARAM)this);
+}