summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:35:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit429c0d0524e7197a593209468fef530344f5ee05 (patch)
tree71df95fdf71c52a956de69b6f31f3a6528053442 /plugins/TabSRMM
parent5b6db3290cb9c9817cba126bd7aea798a610c31d (diff)
tabsrmm: C++'11 iterators
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/chat_log.cpp10
-rw-r--r--plugins/TabSRMM/src/chat_manager.cpp22
-rw-r--r--plugins/TabSRMM/src/contactcache.cpp17
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp4
-rw-r--r--plugins/TabSRMM/src/globals.cpp9
-rw-r--r--plugins/TabSRMM/src/modplus.cpp4
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp7
-rw-r--r--plugins/TabSRMM/src/msglog.cpp6
-rw-r--r--plugins/TabSRMM/src/sendlater.cpp24
-rw-r--r--plugins/TabSRMM/src/sidebar.cpp29
10 files changed, 53 insertions, 79 deletions
diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp
index 582c72f297..f737795772 100644
--- a/plugins/TabSRMM/src/chat_log.cpp
+++ b/plugins/TabSRMM/src/chat_log.cpp
@@ -651,13 +651,11 @@ char* Log_CreateRtfHeader(void)
// colour table
str.Append("}{\\colortbl ;");
- for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
- str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color));
+ for (auto &it : pci->aFonts)
+ str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(it.color), GetGValue(it.color), GetBValue(it.color));
- for (int i = 0; i < Utils::rtf_clrs.getCount(); i++) {
- COLORREF clr = Utils::rtf_clrs[i].clr;
- str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(clr), GetGValue(clr), GetBValue(clr));
- }
+ for (auto &it : Utils::rtf_clrs)
+ str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(it->clr), GetGValue(it->clr), GetBValue(it->clr));
for (int i = 0; i < STATUSICONCOUNT; i++)
str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(g_Settings.nickColors[i]), GetGValue(g_Settings.nickColors[i]), GetBValue(g_Settings.nickColors[i]));
diff --git a/plugins/TabSRMM/src/chat_manager.cpp b/plugins/TabSRMM/src/chat_manager.cpp
index aa325e6026..4b582ee06e 100644
--- a/plugins/TabSRMM/src/chat_manager.cpp
+++ b/plugins/TabSRMM/src/chat_manager.cpp
@@ -77,30 +77,26 @@ int UM_CompareItem(USERINFO *u1, const wchar_t* pszNick, WORD wStatus)
BOOL SM_ReconfigureFilters()
{
- for (int i = 0; i < pci->arSessions.getCount(); i++)
- Chat_SetFilters(pci->arSessions[i]);
+ for (auto &si : pci->arSessions)
+ Chat_SetFilters(si);
return TRUE;
}
SESSION_INFO* SM_FindSessionByHWND(HWND hWnd)
{
- for (int i = 0; i < pci->arSessions.getCount(); i++) {
- SESSION_INFO *si = pci->arSessions[i];
+ for (auto &si : pci->arSessions)
if (si->pDlg && si->pDlg->GetHwnd() == hWnd)
return si;
- }
return nullptr;
}
SESSION_INFO* SM_FindSessionByHCONTACT(MCONTACT h)
{
- for (int i = 0; i < pci->arSessions.getCount(); i++) {
- SESSION_INFO *si = pci->arSessions[i];
+ for (auto &si : pci->arSessions)
if (si->hContact == h)
return si;
- }
return nullptr;
}
@@ -115,17 +111,13 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* cu
pszCurrent = pszOriginal;
SESSION_INFO *pResult = nullptr;
- for (int i = 0; i < pci->arSessions.getCount(); i++) {
- SESSION_INFO *si = pci->arSessions[i];
- if (si != currSession && !mir_strcmpi(pszModule, si->pszModule)) {
- if (my_strstri(si->ptszName, pszOriginal) == si->ptszName) {
+ for (auto &si : pci->arSessions)
+ if (si != currSession && !mir_strcmpi(pszModule, si->pszModule))
+ if (my_strstri(si->ptszName, pszOriginal) == si->ptszName)
if (prevSession != si && mir_wstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || mir_wstrcmpi(si->ptszName, pszName) < 0)) {
pResult = si;
pszName = si->ptszName;
}
- }
- }
- }
return pResult;
}
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp
index d1e60c8eb0..86e2066837 100644
--- a/plugins/TabSRMM/src/contactcache.cpp
+++ b/plugins/TabSRMM/src/contactcache.cpp
@@ -467,20 +467,19 @@ CContactCache* CContactCache::getContactCache(MCONTACT hContact)
int CContactCache::cacheUpdateMetaChanged(WPARAM bMetaEnabled, LPARAM)
{
- for (int i = 0; i < arContacts.getCount(); i++) {
- CContactCache &c = arContacts[i];
- if (c.isMeta() && !bMetaEnabled) {
- c.closeWindow();
- c.resetMeta();
+ for (auto &c : arContacts) {
+ if (c->isMeta() && !bMetaEnabled) {
+ c->closeWindow();
+ c->resetMeta();
}
// meta contacts are enabled, but current contact is a subcontact - > close window
- if (bMetaEnabled && c.isSubContact())
- c.closeWindow();
+ if (bMetaEnabled && c->isSubContact())
+ c->closeWindow();
// reset meta contact information, if metacontacts protocol became avail
- if (bMetaEnabled && !c.cc->IsMeta())
- c.resetMeta();
+ if (bMetaEnabled && !c->cc->IsMeta())
+ c->resetMeta();
}
return 0;
}
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 785260ee4d..e9c5a0cf6c 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -557,8 +557,8 @@ void CTabBaseDlg::DM_InitRichEdit()
LOGFONTA lf = m_pContainer->theme.logFonts[MSGFONTID_MESSAGEAREA];
inputcharcolor = m_pContainer->theme.fontColors[MSGFONTID_MESSAGEAREA];
- for (int i = 0; i < Utils::rtf_clrs.getCount(); i++)
- if (Utils::rtf_clrs[i].clr == inputcharcolor)
+ for (auto &it : Utils::rtf_clrs)
+ if (it->clr == inputcharcolor)
inputcharcolor = RGB(GetRValue(inputcharcolor), GetGValue(inputcharcolor), GetBValue(inputcharcolor) == 0 ? GetBValue(inputcharcolor) + 1 : GetBValue(inputcharcolor) - 1);
cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index 69e3799fd9..7da147b615 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -527,11 +527,10 @@ void CGlobals::RestoreUnreadMessageAlerts(void)
cle.flags = CLEF_UNICODE;
cle.szTooltip.w = toolTip;
- for (int i = 0; i < arEvents.getCount(); i++) {
- MSavedEvent &e = arEvents[i];
- mir_snwprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e.hContact, 0));
- cle.hContact = e.hContact;
- cle.hDbEvent = e.hEvent;
+ for (auto &e : arEvents) {
+ mir_snwprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e->hContact, 0));
+ cle.hContact = e->hContact;
+ cle.hDbEvent = e->hEvent;
pcli->pfnAddEvent(&cle);
}
}
diff --git a/plugins/TabSRMM/src/modplus.cpp b/plugins/TabSRMM/src/modplus.cpp
index 084ffc39e6..35341a6d60 100644
--- a/plugins/TabSRMM/src/modplus.cpp
+++ b/plugins/TabSRMM/src/modplus.cpp
@@ -102,8 +102,8 @@ static int CustomButtonPressed(WPARAM wParam, LPARAM lParam)
pwszFormatedText.Format(arMenuLines[res-1], pszText);
}
- for (int i = 0; i < arMenuLines.getCount(); i++)
- mir_free(arMenuLines[i]);
+ for (auto &it : arMenuLines)
+ mir_free(it);
}
}
else if (textlenght) {
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 8635b41daf..fae16eb748 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -1834,9 +1834,8 @@ void CTabBaseDlg::SendHBitmapAsFile(HBITMAP hbmp) const
// remove all temporary files created by the "send clipboard as file" feature.
void TSAPI CleanTempFiles()
{
- for (int i = 0; i < vTempFilenames.getCount(); i++) {
- wchar_t* _t = vTempFilenames[i];
- DeleteFileW(_t);
- mir_free(_t);
+ for (auto &it : vTempFilenames) {
+ DeleteFileW(it);
+ mir_free(it);
}
}
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 312913a269..ceff02c1b5 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -351,10 +351,8 @@ static void Build_RTF_Header(CMStringA &str, CTabBaseDlg *dat)
}
// bbcode colors...
- for (i = 0; i < Utils::rtf_clrs.getCount(); i++) {
- auto &p = Utils::rtf_clrs[i];
- str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(p.clr), GetGValue(p.clr), GetBValue(p.clr));
- }
+ for (auto &p : Utils::rtf_clrs)
+ str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(p->clr), GetGValue(p->clr), GetBValue(p->clr));
// paragraph header
str.AppendFormat("}");
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp
index 2f7ad775b9..eb80099210 100644
--- a/plugins/TabSRMM/src/sendlater.cpp
+++ b/plugins/TabSRMM/src/sendlater.cpp
@@ -178,8 +178,7 @@ CSendLater::~CSendLater()
if (m_sendLaterJobList.getCount() == 0)
return;
- for (int i = 0; i < m_sendLaterJobList.getCount(); i++) {
- CSendLaterJob *p = m_sendLaterJobList[i];
+ for (auto &p : m_sendLaterJobList) {
mir_free(p->sendBuffer);
mir_free(p->pBuf);
p->fSuccess = false; // avoid clearing jobs from the database
@@ -255,9 +254,9 @@ void CSendLater::processSingleContact(const MCONTACT hContact)
// and process them
void CSendLater::processContacts()
{
- if (m_fAvail && m_sendLaterContactList.getCount() != 0) {
- for (int i = 0; i < m_sendLaterContactList.getCount(); i++)
- processSingleContact((UINT_PTR)m_sendLaterContactList[i]);
+ if (m_fAvail) {
+ for (auto &it : m_sendLaterContactList)
+ processSingleContact((UINT_PTR)it);
m_sendLaterContactList.destroy();
}
@@ -285,11 +284,9 @@ int CSendLater::addJob(const char *szSetting, void *lParam)
return 0;
// check for possible dupes
- for (int i = 0; i < m_sendLaterJobList.getCount(); i++) {
- CSendLaterJob *p = m_sendLaterJobList[i];
+ for (auto &p : m_sendLaterJobList)
if (p->hContact == hContact && !mir_strcmp(p->szId, szSetting))
return 0;
- }
if (szSetting[0] == 'S') {
if (0 == db_get_s(hContact, "SendLater", szSetting, &dbv))
@@ -436,8 +433,7 @@ HANDLE CSendLater::processAck(const ACKDATA *ack)
if (m_sendLaterJobList.getCount() == 0 || !m_fAvail)
return nullptr;
- for (int i = 0; i < m_sendLaterJobList.getCount(); i++) {
- CSendLaterJob *p = m_sendLaterJobList[i];
+ for (auto &p : m_sendLaterJobList)
if (p->hProcess == ack->hProcess && p->hTargetContact == ack->hContact && !(p->fSuccess || p->fFailed)) {
if (!p->fSuccess) {
DBEVENTINFO dbei = {};
@@ -458,7 +454,7 @@ HANDLE CSendLater::processAck(const ACKDATA *ack)
qMgrUpdate();
return nullptr;
}
- }
+
return nullptr;
}
@@ -504,8 +500,7 @@ void CSendLater::qMgrFillList(bool fClear)
BYTE bCode = '-';
unsigned uIndex = 0;
- for (int i = 0; i < m_sendLaterJobList.getCount(); i++) {
- CSendLaterJob *p = m_sendLaterJobList[i];
+ for (auto &p : m_sendLaterJobList) {
CContactCache *c = CContactCache::getContactCache(p->hContact);
const wchar_t *tszNick = c->getNick();
@@ -713,8 +708,7 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
m_fIsInteractive = true;
int selection = ::TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwndDlg, nullptr);
if (selection == ID_QUEUEMANAGER_CANCELALLMULTISENDJOBS) {
- for (int i = 0; i < m_sendLaterJobList.getCount(); i++) {
- CSendLaterJob *p = m_sendLaterJobList[i];
+ for (auto &p : m_sendLaterJobList) {
if (p->szId[0] == 'M') {
p->fFailed = true;
p->bCode = CSendLaterJob::JOB_REMOVABLE;
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp
index f736e20e98..e205025321 100644
--- a/plugins/TabSRMM/src/sidebar.cpp
+++ b/plugins/TabSRMM/src/sidebar.cpp
@@ -732,12 +732,11 @@ void CSideBar::Layout(const RECT *rc, bool fOnlyCalc)
LONG height = m_elementHeight;
- for (int i = 0; i < m_buttonlist.getCount(); i++) {
- CSideBarButton &p = m_buttonlist[i];
- hwnd = p.getHwnd();
+ for (auto &p : m_buttonlist) {
+ hwnd = p->getHwnd();
if (m_dwFlags & SIDEBARLAYOUT_DYNHEIGHT)
- height = p.getHeight();
+ height = p->getHeight();
if (spaceUsed > iSpaceAvail || m_totalItemHeight + height < m_firstVisibleOffset) {
::ShowWindow(hwnd, SW_HIDE);
@@ -745,7 +744,7 @@ void CSideBar::Layout(const RECT *rc, bool fOnlyCalc)
continue;
}
- if (p.isTopAligned()) {
+ if (p->isTopAligned()) {
if (m_totalItemHeight <= m_firstVisibleOffset) { // partially visible
if (!fOnlyCalc && nullptr != hwnd) /* Wine fix. */
hdwp = ::DeferWindowPos(hdwp, hwnd, nullptr, 2, -(m_firstVisibleOffset - m_totalItemHeight),
@@ -793,8 +792,8 @@ void CSideBar::showAll(int showCmd)
::ShowWindow(m_up->getHwnd(), showCmd);
::ShowWindow(m_down->getHwnd(), showCmd);
- for (int i = 0; i < m_buttonlist.getCount(); i++)
- ::ShowWindow(m_buttonlist[i].getHwnd(), showCmd);
+ for (auto &it : m_buttonlist)
+ ::ShowWindow(it->getHwnd(), showCmd);
}
/**
@@ -811,11 +810,9 @@ CSideBarButton* CSideBar::findSession(const CTabBaseDlg *dat)
if (dat == nullptr)
return nullptr;
- for (int i = 0; i < m_buttonlist.getCount(); i++) {
- CSideBarButton &p = m_buttonlist[i];
- if (p.getDat() == dat)
- return &p;
- }
+ for (auto &it : m_buttonlist)
+ if (it->getDat() == dat)
+ return it;
return nullptr;
}
@@ -834,11 +831,9 @@ CSideBarButton* CSideBar::findSession(const MCONTACT hContact)
if (hContact == 0)
return nullptr;
- for (int i = 0; i < m_buttonlist.getCount(); i++) {
- CSideBarButton &p = m_buttonlist[i];
- if (p.getContactHandle() == hContact)
- return &p;
- }
+ for (auto &it : m_buttonlist)
+ if (it->getContactHandle() == hContact)
+ return it;
return nullptr;
}