summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-11-04 14:48:16 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-11-04 14:48:16 +0300
commit6f05a8f4e5c9f075193a68615ad06a19d003cfaf (patch)
tree9d3d5974c93ddaac417d8b8a503f4e94aa076a87 /plugins
parentd1a660dcebdaeca43201d695a7d22454b620521e (diff)
warning fixes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/TabSRMM/src/container.cpp378
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.h2
-rw-r--r--plugins/TabSRMM/src/utils.cpp12
3 files changed, 204 insertions, 188 deletions
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp
index bbe52c6647..989946c157 100644
--- a/plugins/TabSRMM/src/container.cpp
+++ b/plugins/TabSRMM/src/container.cpp
@@ -33,24 +33,59 @@
#define CONTAINER_SUBKEY "containerW"
#define CONTAINER_PREFIX "CNTW_"
+static bool fForceOverlayIcons = false;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// functions for handling the linked list of struct ContainerWindowData *foo
+
TContainerData *pFirstContainer = nullptr; // the linked list of struct ContainerWindowData
TContainerData *pLastActiveContainer = nullptr;
-static TContainerData* TSAPI AppendToContainerList(TContainerData*);
-static TContainerData* TSAPI RemoveContainerFromList(TContainerData*);
+static TContainerData *AppendToContainerList(TContainerData *pContainer)
+{
+ if (!pFirstContainer) {
+ pFirstContainer = pContainer;
+ pFirstContainer->pNext = nullptr;
+ return pFirstContainer;
+ }
-static bool fForceOverlayIcons = false;
+ TContainerData *p = pFirstContainer;
+ while (p->pNext != nullptr)
+ p = p->pNext;
+ p->pNext = pContainer;
+ pContainer->pNext = nullptr;
+ return p;
+}
-HWND TSAPI GetTabWindow(HWND hwndTab, int i)
+static TContainerData *RemoveContainerFromList(TContainerData *pContainer)
{
- if (i < 0)
- return nullptr;
+ if (pContainer == pFirstContainer) {
+ if (pContainer->pNext != nullptr)
+ pFirstContainer = pContainer->pNext;
+ else
+ pFirstContainer = nullptr;
+
+ if (pLastActiveContainer == pContainer) // make sure, we don't reference this container anymore
+ pLastActiveContainer = pFirstContainer;
+
+ return pFirstContainer;
+ }
+
+ for (TContainerData *p = pFirstContainer; p; p = p->pNext) {
+ if (p->pNext == pContainer) {
+ p->pNext = p->pNext->pNext;
- TCITEM tci;
- tci.mask = TCIF_PARAM;
- return (TabCtrl_GetItem(hwndTab, i, &tci)) ? (HWND)tci.lParam: nullptr;
+ if (pLastActiveContainer == pContainer) // make sure, we don't reference this container anymore
+ pLastActiveContainer = pFirstContainer;
+
+ return nullptr;
+ }
+ }
+ return nullptr;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
TContainerData::~TContainerData()
{
delete m_pMenuBar;
@@ -224,6 +259,36 @@ void TContainerData::Configure()
BroadCastContainer(DM_CONFIGURETOOLBAR, 0, 1);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// flashes the container
+// iMode != 0: turn on flashing
+// iMode == 0: turn off flashing
+
+void TContainerData::FlashContainer(int iMode, int iCount)
+{
+ if (m_flags.m_bNoFlash) // container should never flash
+ return;
+
+ FLASHWINFO fwi;
+ fwi.cbSize = sizeof(fwi);
+ fwi.uCount = 0;
+
+ if (iMode) {
+ fwi.dwFlags = FLASHW_ALL;
+ if (m_flags.m_bFlashAlways)
+ fwi.dwFlags |= FLASHW_TIMER;
+ else
+ fwi.uCount = (iCount == 0) ? M.GetByte("nrflash", 4) : iCount;
+ fwi.dwTimeout = M.GetDword("flashinterval", 1000);
+
+ }
+ else fwi.dwFlags = FLASHW_STOP;
+
+ fwi.hwnd = m_hwnd;
+ m_dwFlashingStarted = GetTickCount();
+ FlashWindowEx(&fwi);
+}
+
void TContainerData::InitDialog(HWND hwndDlg)
{
m_hwnd = hwndDlg;
@@ -1256,7 +1321,7 @@ panel_found:
itoa(iSelection - IDM_CONTAINERMENU, szIndex, 10);
if (iSelection - IDM_CONTAINERMENU >= 0) {
ptrW tszName(db_get_wsa(0, CONTAINER_KEY, szIndex));
- if (tszName != nullptr)
+ if (hDlg && tszName != nullptr)
SendMessage(hDlg, DM_CONTAINERSELECTED, 0, tszName);
}
return 1;
@@ -2093,29 +2158,7 @@ TContainerData* TSAPI CreateContainer(const wchar_t *name, int iTemp, MCONTACT h
return pContainer;
}
-// search the list of tabs and return the tab (by index) which "belongs" to the given
-// hwnd. The hwnd is the handle of a message dialog childwindow. At creation,
-// the dialog handle is stored in the TCITEM.lParam field, because we need
-// to know the owner of the tab.
-//
-// hwndTab: handle of the tab control itself.
-// hwnd: handle of a message dialog.
-//
-// returns the tab index (zero based), -1 if no tab is found (which SHOULD not
-// really happen, but who knows... ;))
-
-int TSAPI GetTabIndexFromHWND(HWND hwndTab, HWND hwnd)
-{
- int iItems = TabCtrl_GetItemCount(hwndTab);
-
- for (int i = 0; i < iItems; i++) {
- HWND pDlg = GetTabWindow(hwndTab, i);
- if (pDlg == hwnd)
- return i;
- }
- return -1;
-}
-
+/////////////////////////////////////////////////////////////////////////////////////////
// activates the tab belonging to the given client HWND (handle of the actual
// message window.
@@ -2133,7 +2176,61 @@ int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd)
return -1;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+HMENU TSAPI BuildContainerMenu()
+{
+ if (PluginConfig.g_hMenuContainer != nullptr) {
+ HMENU submenu = GetSubMenu(PluginConfig.g_hMenuContext, 0);
+ RemoveMenu(submenu, 6, MF_BYPOSITION);
+ DestroyMenu(PluginConfig.g_hMenuContainer);
+ PluginConfig.g_hMenuContainer = nullptr;
+ }
+
+ // no container attach menu, if we are using the "clist group mode"
+ if (M.GetByte("useclistgroups", 0) || M.GetByte("singlewinmode", 0))
+ return nullptr;
+
+ HMENU hMenu = CreateMenu();
+ int i = 0;
+ while (true) {
+ char szCounter[10];
+ itoa(i, szCounter, 10);
+ ptrW tszName(db_get_wsa(0, CONTAINER_KEY, szCounter));
+ if (tszName == nullptr)
+ break;
+
+ if (wcsncmp(tszName, L"**free**", CONTAINER_NAMELEN))
+ AppendMenu(hMenu, MF_STRING, IDM_CONTAINERMENU + i, !mir_wstrcmp(tszName, L"default") ? TranslateT("Default container") : tszName);
+ i++;
+ }
+
+ InsertMenu(PluginConfig.g_hMenuContext, ID_TABMENU_ATTACHTOCONTAINER, MF_BYCOMMAND | MF_POPUP, (UINT_PTR)hMenu, TranslateT("Attach to"));
+ PluginConfig.g_hMenuContainer = hMenu;
+ return hMenu;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void TSAPI CloseAllContainers()
+{
+ bool fOldHideSetting = PluginConfig.m_bHideOnClose;
+
+ while (pFirstContainer != nullptr) {
+ if (!IsWindow(pFirstContainer->m_hwnd))
+ pFirstContainer = pFirstContainer->pNext;
+ else {
+ PluginConfig.m_bHideOnClose = false;
+ ::SendMessage(pFirstContainer->m_hwnd, WM_CLOSE, 0, 1);
+ }
+ }
+
+ PluginConfig.m_bHideOnClose = fOldHideSetting;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// enumerates tabs and closes all of them, but the one in dat
+
void TSAPI CloseOtherTabs(HWND hwndTab, CMsgDialog &dat)
{
for (int idxt = 0; idxt < dat.m_pContainer->m_iChilds;) {
@@ -2153,7 +2250,7 @@ void TSAPI CloseOtherTabs(HWND hwndTab, CMsgDialog &dat)
//
// size = max length of target string
-int TSAPI CutContactName(const wchar_t *oldname, wchar_t *newname, size_t size)
+void TSAPI CutContactName(const wchar_t *oldname, wchar_t *newname, size_t size)
{
if ((int)mir_wstrlen(oldname) <= PluginConfig.m_iTabNameLimit)
wcsncpy_s(newname, size, oldname, _TRUNCATE);
@@ -2162,89 +2259,9 @@ int TSAPI CutContactName(const wchar_t *oldname, wchar_t *newname, size_t size)
mir_snwprintf(fmt, L"%%%d.%ds...", PluginConfig.m_iTabNameLimit, PluginConfig.m_iTabNameLimit);
mir_snwprintf(newname, size, fmt, oldname);
}
- return 0;
-}
-
-// functions for handling the linked list of struct ContainerWindowData *foo
-
-static TContainerData* TSAPI AppendToContainerList(TContainerData *pContainer)
-{
- if (!pFirstContainer) {
- pFirstContainer = pContainer;
- pFirstContainer->pNext = nullptr;
- return pFirstContainer;
- }
-
- TContainerData *p = pFirstContainer;
- while (p->pNext != nullptr)
- p = p->pNext;
- p->pNext = pContainer;
- pContainer->pNext = nullptr;
- return p;
-}
-
-TContainerData* TSAPI FindContainerByName(const wchar_t *name)
-{
- if (name == nullptr || mir_wstrlen(name) == 0)
- return nullptr;
-
- if (M.GetByte("singlewinmode", 0)) // single window mode - always return 0 and force a new container
- return nullptr;
-
- for (TContainerData *p = pFirstContainer; p; p = p->pNext)
- if (!wcsncmp(p->m_wszName, name, CONTAINER_NAMELEN))
- return p;
-
- // error, didn't find it.
- return nullptr;
-}
-
-static TContainerData* TSAPI RemoveContainerFromList(TContainerData *pContainer)
-{
- if (pContainer == pFirstContainer) {
- if (pContainer->pNext != nullptr)
- pFirstContainer = pContainer->pNext;
- else
- pFirstContainer = nullptr;
-
- if (pLastActiveContainer == pContainer) // make sure, we don't reference this container anymore
- pLastActiveContainer = pFirstContainer;
-
- return pFirstContainer;
- }
-
- for (TContainerData *p = pFirstContainer; p; p = p->pNext) {
- if (p->pNext == pContainer) {
- p->pNext = p->pNext->pNext;
-
- if (pLastActiveContainer == pContainer) // make sure, we don't reference this container anymore
- pLastActiveContainer = pFirstContainer;
-
- return nullptr;
- }
- }
- return nullptr;
}
-// retrieve the container name for the given contact handle.
-// if none is assigned, return the name of the default container
-
-void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen)
-{
- // single window mode using cloned (temporary) containers
- if (M.GetByte("singlewinmode", 0)) {
- wcsncpy_s(szName, iNameLen, L"Message Session", _TRUNCATE);
- return;
- }
-
- // use clist group names for containers...
- if (M.GetByte("useclistgroups", 0)) {
- wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, "CList", "Group", L"default")), _TRUNCATE);
- return;
- }
-
- wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY, L"default")), _TRUNCATE);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
void TSAPI DeleteContainer(int iIndex)
{
@@ -2277,100 +2294,87 @@ void TSAPI DeleteContainer(int iIndex)
db_unset(0, SRMSGMOD_T, szSetting);
}
-void TSAPI RenameContainer(int iIndex, const wchar_t *szNew)
+/////////////////////////////////////////////////////////////////////////////////////////
+// retrieve the container name for the given contact handle.
+// if none is assigned, return the name of the default container
+
+void TSAPI GetContainerNameForContact(MCONTACT hContact, wchar_t *szName, int iNameLen)
{
- if (mir_wstrlen(szNew) == 0)
+ // single window mode using cloned (temporary) containers
+ if (M.GetByte("singlewinmode", 0)) {
+ wcsncpy_s(szName, iNameLen, L"Message Session", _TRUNCATE);
return;
+ }
- char szIndex[10];
- itoa(iIndex, szIndex, 10);
- ptrW tszContainerName(db_get_wsa(0, CONTAINER_KEY, szIndex));
- if (tszContainerName == nullptr)
+ // use clist group names for containers...
+ if (M.GetByte("useclistgroups", 0)) {
+ wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, "CList", "Group", L"default")), _TRUNCATE);
return;
-
- db_set_ws(0, CONTAINER_KEY, szIndex, szNew);
-
- for (auto &hContact : Contacts()) {
- ptrW tszValue(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY));
- if (!mir_wstrcmp(tszValue, tszContainerName))
- db_set_ws(hContact, SRMSGMOD_T, CONTAINER_SUBKEY, szNew);
}
+
+ wcsncpy_s(szName, iNameLen, ptrW(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY, L"default")), _TRUNCATE);
}
-HMENU TSAPI BuildContainerMenu()
+/////////////////////////////////////////////////////////////////////////////////////////
+// search the list of tabs and return the tab (by index) which "belongs" to the given
+// hwnd. The hwnd is the handle of a message dialog childwindow. At creation,
+// the dialog handle is stored in the TCITEM.lParam field, because we need
+// to know the owner of the tab.
+//
+// hwndTab: handle of the tab control itself.
+// hwnd: handle of a message dialog.
+//
+// returns the tab index (zero based), -1 if no tab is found (which SHOULD not
+// really happen, but who knows... ;))
+
+int TSAPI GetTabIndexFromHWND(HWND hwndTab, HWND hwnd)
{
- if (PluginConfig.g_hMenuContainer != nullptr) {
- HMENU submenu = GetSubMenu(PluginConfig.g_hMenuContext, 0);
- RemoveMenu(submenu, 6, MF_BYPOSITION);
- DestroyMenu(PluginConfig.g_hMenuContainer);
- PluginConfig.g_hMenuContainer = nullptr;
+ int iItems = TabCtrl_GetItemCount(hwndTab);
+
+ for (int i = 0; i < iItems; i++) {
+ HWND pDlg = GetTabWindow(hwndTab, i);
+ if (pDlg == hwnd)
+ return i;
}
+ return -1;
+}
- // no container attach menu, if we are using the "clist group mode"
- if (M.GetByte("useclistgroups", 0) || M.GetByte("singlewinmode", 0))
+/////////////////////////////////////////////////////////////////////////////////////////
+
+TContainerData* TSAPI FindContainerByName(const wchar_t *name)
+{
+ if (name == nullptr || mir_wstrlen(name) == 0)
return nullptr;
- HMENU hMenu = CreateMenu();
- int i = 0;
- while (true) {
- char szCounter[10];
- itoa(i, szCounter, 10);
- ptrW tszName(db_get_wsa(0, CONTAINER_KEY, szCounter));
- if (tszName == nullptr)
- break;
+ if (M.GetByte("singlewinmode", 0)) // single window mode - always return 0 and force a new container
+ return nullptr;
- if (wcsncmp(tszName, L"**free**", CONTAINER_NAMELEN))
- AppendMenu(hMenu, MF_STRING, IDM_CONTAINERMENU + i, !mir_wstrcmp(tszName, L"default") ? TranslateT("Default container") : tszName);
- i++;
- }
+ for (TContainerData *p = pFirstContainer; p; p = p->pNext)
+ if (!wcsncmp(p->m_wszName, name, CONTAINER_NAMELEN))
+ return p;
- InsertMenu(PluginConfig.g_hMenuContext, ID_TABMENU_ATTACHTOCONTAINER, MF_BYCOMMAND | MF_POPUP, (UINT_PTR)hMenu, TranslateT("Attach to"));
- PluginConfig.g_hMenuContainer = hMenu;
- return hMenu;
+ // error, didn't find it.
+ return nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
-// flashes the container
-// iMode != 0: turn on flashing
-// iMode == 0: turn off flashing
-void TContainerData::FlashContainer(int iMode, int iCount)
+void TSAPI RenameContainer(int iIndex, const wchar_t *szNew)
{
- if (m_flags.m_bNoFlash) // container should never flash
+ if (mir_wstrlen(szNew) == 0)
return;
- FLASHWINFO fwi;
- fwi.cbSize = sizeof(fwi);
- fwi.uCount = 0;
-
- if (iMode) {
- fwi.dwFlags = FLASHW_ALL;
- if (m_flags.m_bFlashAlways)
- fwi.dwFlags |= FLASHW_TIMER;
- else
- fwi.uCount = (iCount == 0) ? M.GetByte("nrflash", 4) : iCount;
- fwi.dwTimeout = M.GetDword("flashinterval", 1000);
-
- }
- else fwi.dwFlags = FLASHW_STOP;
-
- fwi.hwnd = m_hwnd;
- m_dwFlashingStarted = GetTickCount();
- FlashWindowEx(&fwi);
-}
+ char szIndex[10];
+ itoa(iIndex, szIndex, 10);
+ ptrW tszContainerName(db_get_wsa(0, CONTAINER_KEY, szIndex));
+ if (tszContainerName == nullptr)
+ return;
-void TSAPI CloseAllContainers()
-{
- bool fOldHideSetting = PluginConfig.m_bHideOnClose;
+ db_set_ws(0, CONTAINER_KEY, szIndex, szNew);
- while (pFirstContainer != nullptr) {
- if (!IsWindow(pFirstContainer->m_hwnd))
- pFirstContainer = pFirstContainer->pNext;
- else {
- PluginConfig.m_bHideOnClose = false;
- ::SendMessage(pFirstContainer->m_hwnd, WM_CLOSE, 0, 1);
- }
+ for (auto &hContact : Contacts()) {
+ ptrW tszValue(db_get_wsa(hContact, SRMSGMOD_T, CONTAINER_SUBKEY));
+ if (!mir_wstrcmp(tszValue, tszContainerName))
+ db_set_ws(hContact, SRMSGMOD_T, CONTAINER_SUBKEY, szNew);
}
-
- PluginConfig.m_bHideOnClose = fOldHideSetting;
}
diff --git a/plugins/TabSRMM/src/msgdlgutils.h b/plugins/TabSRMM/src/msgdlgutils.h
index d434ee48ad..b43075ccf1 100644
--- a/plugins/TabSRMM/src/msgdlgutils.h
+++ b/plugins/TabSRMM/src/msgdlgutils.h
@@ -34,7 +34,7 @@ void TSAPI ProcessAvatarChange(HWND hwnd, LPARAM lParam);
BOOL TSAPI CheckCustomLink(HWND hwndRich, POINT *ptClient, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bUrlNeeded);
int TSAPI CheckValidSmileyPack(const char *szProto, MCONTACT hContact);
wchar_t* TSAPI QuoteText(const wchar_t *text);
-int TSAPI CutContactName(const wchar_t *szold, wchar_t *sznew, size_t size);
+void TSAPI CutContactName(const wchar_t *szold, wchar_t *sznew, size_t size);
LRESULT TSAPI GetSendButtonState(HWND hwnd);
void TSAPI RearrangeTab(HWND hwndDlg, const CMsgDialog *dat, int iMode, BOOL bSavePos);
bool TSAPI IsStatusEvent(int eventType);
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index aa6e723da9..53e9d18bf3 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -935,6 +935,18 @@ size_t Utils::CopyToClipBoard(const wchar_t *str, const HWND hwndOwner)
}
/////////////////////////////////////////////////////////////////////////////////////////
+
+HWND TSAPI GetTabWindow(HWND hwndTab, int i)
+{
+ if (i < 0)
+ return nullptr;
+
+ TCITEM tci;
+ tci.mask = TCIF_PARAM;
+ return (TabCtrl_GetItem(hwndTab, i, &tci)) ? (HWND)tci.lParam : nullptr;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// file list handler
void Utils::AddToFileList(wchar_t ***pppFiles, int *totalCount, LPCTSTR szFilename)