diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-09 19:32:32 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-09 19:32:39 +0300 |
commit | df6b0c988eb26339d4c7e4a1d0fe3b9717703c28 (patch) | |
tree | 5b4960edd6c9186e1fbc14f83f7f08a6a842f0a7 | |
parent | 303dd9297732fc943ed3e20ab37587f0c009dfe5 (diff) |
more loop-related code cleaning
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 3 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 11 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/services.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sidebar.cpp | 53 | ||||
-rw-r--r-- | plugins/TopToolBar/src/toolbar.cpp | 6 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/Flags/svc_flags.cpp | 9 | ||||
-rw-r--r-- | plugins/YAPP/src/services.cpp | 15 | ||||
-rw-r--r-- | protocols/IRCG/src/output.cpp | 38 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_opttree.cpp | 12 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_search.cpp | 24 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_userinfo.cpp | 13 | ||||
-rw-r--r-- | protocols/MSN/src/msn_chat.cpp | 6 | ||||
-rw-r--r-- | protocols/MSN/src/msn_lists.cpp | 16 | ||||
-rw-r--r-- | protocols/MSN/src/msn_skypeab.cpp | 30 | ||||
-rw-r--r-- | protocols/MSN/src/msn_srv.cpp | 13 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 13 | ||||
-rw-r--r-- | src/core/stdmsg/src/cmdlist.cpp | 9 | ||||
-rw-r--r-- | src/mir_core/src/threads.cpp | 30 | ||||
-rw-r--r-- | src/mir_core/src/windowlist.cpp | 8 |
19 files changed, 117 insertions, 196 deletions
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index fa521bbcfc..81f40481b7 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -27,9 +27,8 @@ static void SelectAll(HWND hDlg, bool bEnable) OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);
- for (int i = 0; i < todo.getCount(); i++) {
+ for (int i = 0; i < todo.getCount(); i++)
ListView_SetCheckState(hwndList, i, todo[i].bEnabled = bEnable);
- }
}
static void ApplyDownloads(void *param)
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 91f6358b2d..467e7e44ce 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -315,8 +315,8 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM // Toggle the Download button
bool enableOk = false;
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- for (int i=0; i < todo.getCount(); ++i) {
- if (todo[i].bEnabled) {
+ for (auto &it : todo) {
+ if (it->bEnabled) {
enableOk = true;
break;
}
@@ -423,11 +423,10 @@ static void DlgUpdateSilent(void *param) HNETLIBCONN nlc = nullptr;
// Count all updates that have been enabled
int count = 0;
- for (int i = 0; i < UpdateFiles.getCount(); i++) {
- if (UpdateFiles[i].bEnabled && !UpdateFiles[i].bDeleteOnly) {
+ for (auto &it : UpdateFiles) {
+ if (it->bEnabled && !it->bDeleteOnly) {
// download update
- FILEURL *pFileUrl = &UpdateFiles[i].File;
- if (!DownloadFile(pFileUrl, nlc)) {
+ if (!DownloadFile(&it->File, nlc)) {
// interrupt update as we require all components to be updated
Netlib_CloseHandle(nlc);
Skin_PlaySound("updatefailed");
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 9cfacbd516..adc15d008e 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -279,8 +279,8 @@ int RebuildContactMenu(WPARAM wParam, LPARAM) Menu_ShowItem(hContactMenuItem, haveMenu);
- for (int i = 0; i < menuHandleArray.getCount(); i++)
- Menu_RemoveItem((HGENMENU)menuHandleArray[i]);
+ for (auto &it : menuHandleArray)
+ Menu_RemoveItem((HGENMENU)it);
menuHandleArray.destroy();
if (haveMenu) {
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp index e205025321..9dd8649657 100644 --- a/plugins/TabSRMM/src/sidebar.cpp +++ b/plugins/TabSRMM/src/sidebar.cpp @@ -592,8 +592,8 @@ HRESULT CSideBar::removeSession(CTabBaseDlg *dat) */
void CSideBar::scrollIntoView(const CSideBarButton *item)
{
- LONG spaceUsed = 0, itemHeight = 0;
- bool fNeedLayout = false;
+ LONG spaceUsed = 0, itemHeight = 0;
+ bool fNeedLayout = false, bFound = false;
if (!m_isActive)
return;
@@ -601,45 +601,36 @@ void CSideBar::scrollIntoView(const CSideBarButton *item) if (item == nullptr)
item = m_activeItem;
- int i;
- for (i = 0; i < m_buttonlist.getCount(); i++) {
- CSideBarButton &p = m_buttonlist[i];
- itemHeight = p.getHeight();
- spaceUsed += (itemHeight + 1);
- if (&p == item)
+ for (auto &it : m_buttonlist) {
+ itemHeight = it->getHeight();
+ spaceUsed += itemHeight;
+ if (it == item) {
+ bFound = true;
break;
+ }
}
RECT rc;
GetClientRect(m_hwndScrollWnd, &rc);
-
- if (m_topHeight <= rc.bottom) {
+ if (m_topHeight <= rc.bottom)
m_firstVisibleOffset = 0;
- Layout();
- return;
- }
- if (i == m_buttonlist.getCount() || (i == 0 && m_firstVisibleOffset == 0)) {
- Layout();
- return; // do nothing for the first item and .end() should not really happen
- }
+ else if (!bFound || (item == &m_buttonlist[0] && m_firstVisibleOffset == 0))
+ ; // do nothing for the first item and .end() should not really happen
- if (spaceUsed <= rc.bottom && spaceUsed - (itemHeight + 1) >= m_firstVisibleOffset) {
- Layout();
- return; // item fully visible, do nothing
- }
+ else if (spaceUsed <= rc.bottom && spaceUsed - (itemHeight +1) >= m_firstVisibleOffset)
+ ; // item fully visible, do nothing
- /*
- * button partially or not at all visible at the top
- */
- if (spaceUsed < m_firstVisibleOffset || spaceUsed - (itemHeight + 1) < m_firstVisibleOffset) {
- m_firstVisibleOffset = spaceUsed - (itemHeight + 1);
- fNeedLayout = true;
- }
- else {
- if (spaceUsed > rc.bottom) { // partially or not at all visible at the bottom
+ else { // button partially or not at all visible at the top
+ if (spaceUsed < m_firstVisibleOffset || spaceUsed - (itemHeight + 1) < m_firstVisibleOffset) {
+ m_firstVisibleOffset = spaceUsed - (itemHeight + 1);
fNeedLayout = true;
- m_firstVisibleOffset = spaceUsed - rc.bottom;
+ }
+ else {
+ if (spaceUsed > rc.bottom) { // partially or not at all visible at the bottom
+ fNeedLayout = true;
+ m_firstVisibleOffset = spaceUsed - rc.bottom;
+ }
}
}
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index 413ac69fb5..de6755c5d8 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -273,12 +273,12 @@ int ArrangeButtons() nextX = 0;
if (g_ctrl->bSingleLine)
break;
- } while (iFirstButtonId < Buttons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top)));
+ }
+ while (iFirstButtonId < Buttons.getCount() && y >= 0 && (g_ctrl->bAutoSize || (y + g_ctrl->nButtonHeight <= rcClient.bottom - rcClient.top)));
- for (i = iLastButtonId; i < Buttons.getCount(); i++) {
+ for (i = iLastButtonId; i < Buttons.getCount(); i++)
if (nullptr != Buttons[i]->hwnd) /* Wine fix. */
hdwp = DeferWindowPos(hdwp, Buttons[i]->hwnd, nullptr, nextX, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW);
- }
if (hdwp)
EndDeferWindowPos(hdwp);
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index a5352033ab..dcbf1af0c5 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -255,12 +255,9 @@ void SvcFlagsOnModulesLoaded() void SvcFlagsUnloadModule()
{
- //Uninit message winsow
- for (int i = 0; i < gMsgWndList.getCount(); i++) {
- //this should not happen
- delete gMsgWndList[i];
- gMsgWndList.remove(i);
- }
+ // Uninit message window
+ for (auto &it : gMsgWndList)
+ delete it;
gMsgWndList.destroy();
// Uninit misc
diff --git a/plugins/YAPP/src/services.cpp b/plugins/YAPP/src/services.cpp index 87ef273df9..d9143ab624 100644 --- a/plugins/YAPP/src/services.cpp +++ b/plugins/YAPP/src/services.cpp @@ -323,7 +323,7 @@ INT_PTR Popup_ShowHistory(WPARAM, LPARAM) return 0;
}
-LIST<POPUPCLASS> arClasses(3);
+LIST<POPUPCLASS> arClasses(3, PtrKeySortT);
static INT_PTR RegisterPopupClass(WPARAM, LPARAM lParam)
{
@@ -361,15 +361,12 @@ static INT_PTR UnregisterPopupClass(WPARAM, LPARAM lParam) POPUPCLASS *pc = (POPUPCLASS*)lParam;
if (pc == nullptr)
return 1;
+ if (arClasses.find(pc) == nullptr)
+ return 1;
- for (int i=0; i < arClasses.getCount(); i++)
- if (arClasses[i] == pc) {
- arClasses.remove(i);
- FreePopupClass(pc);
- return 0;
- }
-
- return 1;
+ arClasses.remove(pc);
+ FreePopupClass(pc);
+ return 0;
}
static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/IRCG/src/output.cpp b/protocols/IRCG/src/output.cpp index fe0c8b97f4..0e8bc3ff0b 100644 --- a/protocols/IRCG/src/output.cpp +++ b/protocols/IRCG/src/output.cpp @@ -21,39 +21,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-static CMStringW FormatOutput(const CIrcMessage* pmsg)
+static CMStringW FormatOutput(const CIrcMessage *pmsg)
{
CMStringW sMessage;
if (pmsg->m_bIncoming) { // Is it an incoming message?
if (pmsg->sCommand == L"WALLOPS" && pmsg->parameters.getCount() > 0) {
sMessage.Format(TranslateT("WallOps from %s: "), pmsg->prefix.sNick.c_str());
- for (int i = 0; i < pmsg->parameters.getCount(); i++) {
- sMessage += pmsg->parameters[i];
- if (i != pmsg->parameters.getCount() - 1)
- sMessage += L" ";
- }
+ for (auto &it : pmsg->parameters)
+ sMessage += *it + L" ";
goto THE_END;
}
if (pmsg->sCommand == L"INVITE" && pmsg->parameters.getCount() > 1) {
sMessage.Format(TranslateT("%s invites you to %s"), pmsg->prefix.sNick.c_str(), pmsg->parameters[1].c_str());
- for (int i = 2; i < pmsg->parameters.getCount(); i++) {
- sMessage += L": " + pmsg->parameters[i];
- if (i != pmsg->parameters.getCount() - 1)
- sMessage += L" ";
- }
+ for (int i = 2; i < pmsg->parameters.getCount(); i++)
+ sMessage += L": " + pmsg->parameters[i] + L" ";
goto THE_END;
}
int index = _wtoi(pmsg->sCommand.c_str());
if (index == 301 && pmsg->parameters.getCount() > 0) {
sMessage.Format(TranslateT("%s is away"), pmsg->parameters[1].c_str());
- for (int i = 2; i < pmsg->parameters.getCount(); i++) {
- sMessage += L": " + pmsg->parameters[i];
- if (i != pmsg->parameters.getCount() - 1)
- sMessage += L" ";
- }
+ for (int i = 2; i < pmsg->parameters.getCount(); i++)
+ sMessage += L": " + pmsg->parameters[i] + L" ";
goto THE_END;
}
@@ -62,11 +53,8 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) if (index == 303) { // ISON command
sMessage = TranslateT("These are online: ");
- for (int i = 1; i < pmsg->parameters.getCount(); i++) {
- sMessage += pmsg->parameters[i];
- if (i != pmsg->parameters.getCount() - 1)
- sMessage += L", ";
- }
+ for (int i = 1; i < pmsg->parameters.getCount(); i++)
+ sMessage += pmsg->parameters[i] + L", ";
goto THE_END;
}
@@ -88,11 +76,8 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) }
else {
sMessage.Format(TranslateT("Notice to %s: "), pmsg->parameters[0].c_str());
- for (int i = 1; i < pmsg->parameters.getCount(); i++) {
- sMessage += pmsg->parameters[i];
- if (i != pmsg->parameters.getCount() - 1)
- sMessage += L" ";
- }
+ for (int i = 1; i < pmsg->parameters.getCount(); i++)
+ sMessage += pmsg->parameters[i] + L" ";
}
goto THE_END;
}
@@ -116,6 +101,7 @@ static CMStringW FormatOutput(const CIrcMessage* pmsg) }
THE_END:
+ sMessage.TrimRight();
return sMessage;
}
diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp index 047decb2be..c9ad4ba465 100644 --- a/protocols/JabberG/src/jabber_opttree.cpp +++ b/protocols/JabberG/src/jabber_opttree.cpp @@ -175,10 +175,10 @@ void CCtrlTreeOpts::OnApply() {
CCtrlTreeView::OnApply();
- for (int i = 0; i < m_options.getCount(); i++) {
+ for (auto &it : m_options) {
TVITEMEX tvi;
- GetItem(m_options[i]->m_hItem, &tvi);
- *m_options[i]->m_option = ((tvi.iImage == IMG_CHECK) || (tvi.iImage == IMG_RCHECK)) ? 1 : 0;
+ GetItem(it->m_hItem, &tvi);
+ *it->m_option = ((tvi.iImage == IMG_CHECK) || (tvi.iImage == IMG_RCHECK)) ? 1 : 0;
}
}
@@ -208,11 +208,11 @@ void CCtrlTreeOpts::ProcessItemClick(HTREEITEM hti) break;
case IMG_NORCHECK:
- for (int i = 0; i < m_options.getCount(); i++) {
- if (m_options[i]->m_groupId == m_options[tvi.lParam]->m_groupId) {
+ for (auto &it : m_options) {
+ if (it->m_groupId == m_options[tvi.lParam]->m_groupId) {
TVITEMEX tvi_tmp;
tvi_tmp.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi_tmp.hItem = m_options[i]->m_hItem;
+ tvi_tmp.hItem = it->m_hItem;
tvi_tmp.iImage = tvi_tmp.iSelectedImage = IMG_NORCHECK;
SetItem(&tvi_tmp);
}
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index e325fad9fe..d0dfcfcbe3 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -209,12 +209,10 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M { LIST<wchar_t> ListOfNonEmptyFields(20, (LIST<wchar_t>::FTSortFunc)TCharKeyCmp); LIST<wchar_t> ListOfFields(20); - LIST<void>* plUsersInfo = (LIST<void>*)pvUsersInfo; - int i, nUsersFound = plUsersInfo->getCount(); + LIST<U_TCHAR_MAP> *plUsersInfo = (LIST<U_TCHAR_MAP>*)pvUsersInfo; // lets fill the ListOfNonEmptyFields but in users order - for (i = 0; i < nUsersFound; i++) { - U_TCHAR_MAP* pmUserData = (U_TCHAR_MAP*)plUsersInfo->operator [](i); + for (auto &pmUserData : *plUsersInfo) { int nUserFields = pmUserData->getCount(); for (int j = 0; j < nUserFields; j++) { wchar_t *var = pmUserData->getKeyName(j); @@ -225,7 +223,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M // now fill the ListOfFields but order is from pmAllFields int nAllCount = pmAllFields->getCount(); - for (i = 0; i < nAllCount; i++) { + for (int i = 0; i < nAllCount; i++) { wchar_t *var = pmAllFields->getUnOrderedKeyName(i); if (var && ListOfNonEmptyFields.getIndex(var) < 0) continue; @@ -241,7 +239,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M Results.nFieldCount = nFieldCount; /* Sending Columns Titles */ - for (i = 0; i < nFieldCount; i++) { + for (int i = 0; i < nFieldCount; i++) { wchar_t *var = ListOfFields[i]; if (var) Results.pszFields[i] = pmAllFields->operator [](var); @@ -253,10 +251,9 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M /* Sending Users Data */ Results.psr.cbSize = sizeof(Results.psr); // sending user data - for (i = 0; i < nUsersFound; i++) { + for (auto &pmUserData : *plUsersInfo) { wchar_t buff[200]; buff[0] = 0; - U_TCHAR_MAP *pmUserData = (U_TCHAR_MAP *)plUsersInfo->operator [](i); for (int j = 0; j < nFieldCount; j++) { wchar_t *var = ListOfFields[j]; wchar_t *value = pmUserData->operator [](var); @@ -554,14 +551,11 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR SetDlgItemTextA(hwndDlg, IDC_SERVER, szServerName); SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szServerName); //TO DO: Add Transports here - int i, transpCount = dat->ppro->m_lstTransports.getCount(); - for (i = 0; i < transpCount; i++) { - wchar_t *szTransp = dat->ppro->m_lstTransports[i]; - if (szTransp) - JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp); - } + for (auto &it : dat->ppro->m_lstTransports) + if (it != nullptr) + JabberSearchAddUrlToRecentCombo(hwndDlg, it); - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { char key[30]; mir_snprintf(key, "RecentlySearched_%d", i); ptrW szValue(dat->ppro->getWStringA(key)); diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 610cab6a87..203c1022e2 100755 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -292,15 +292,16 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i)); } - for (int j = 0; j < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); j++, i++) - if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[j]->jcbCap) { + for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic) { + if (jcb & it->jcbCap) { wchar_t szDescription[1024]; - if (ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription) - mir_snwprintf(szDescription, L"%s (%s)", TranslateW(ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature); + if (it->szDescription) + mir_snwprintf(szDescription, L"%s (%s)", TranslateW(it->szDescription), it->szFeature); else - wcsncpy_s(szDescription, ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature, _TRUNCATE); - sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i)); + wcsncpy_s(szDescription, it->szFeature, _TRUNCATE); + sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i++)); } + } } // Software info diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index 2ed9979947..fe9b611941 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -152,9 +152,9 @@ void CMsnProto::MSN_Promoteuser(GCHOOK *gch, const char *pszRole) const wchar_t *CMsnProto::MSN_GCGetRole(GCThreadData* thread, const char *pszWLID)
{
if (thread)
- for (int j = 0; j < thread->mJoinedContacts.getCount(); j++)
- if (!mir_strcmp(thread->mJoinedContacts[j]->WLID, pszWLID))
- return thread->mJoinedContacts[j]->role;
+ for (auto &it : thread->mJoinedContacts)
+ if (!mir_strcmp(it->WLID, pszWLID))
+ return it->role;
return nullptr;
}
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index 0953685dde..c103be86f3 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -297,21 +297,9 @@ void CMsnProto::MSN_CreateContList(void) cxml.AppendFormat("<c n=\"%s\" t=\"%d\"><s l=\"%d\" n=\"PE\"/><s l=\"%d\" n=\"IM\"/><s l=\"%d\" n=\"SKP\"/><s l=\"%d\" n=\"PUB\"/></c>", C.email, C.netId, list, list, list, list);
used[j] = true;
}
- /* Seems to be unused in Skype and causing errors
- else if (dom != NULL && lastds != NULL && _stricmp(lastds, dom) == 0) {
- if (newdom) {
- cxml.AppendFormat("<d n=\"%s\">", lastds + 1);
- newdom = false;
- }
-
- *(char*)dom = 0;
- cxml.AppendFormat("<c n=\"%s\" t=\"%d\"><s n=\"IM\" l=\"%d\"/></c>", C.email, C.netId, C.list & ~(LIST_RL | LIST_LL));
- *(char*)dom = '@';
- used[j] = true;
- }
- */
}
- if (!newdom) cxml.Append(lastds ? "</d>" : "</skp>");
+ if (!newdom)
+ cxml.Append(lastds ? "</d>" : "</skp>");
}
}
diff --git a/protocols/MSN/src/msn_skypeab.cpp b/protocols/MSN/src/msn_skypeab.cpp index c551866a78..571dcf63b3 100644 --- a/protocols/MSN/src/msn_skypeab.cpp +++ b/protocols/MSN/src/msn_skypeab.cpp @@ -405,33 +405,3 @@ bool CMsnProto::MSN_SKYABSearch(const char *keyWord, HANDLE hSearch) else hHttpsConnection = nullptr;
return bRet;
}
-
-/*
-class GetContactsInfoRequest : public HttpRequest
-{
-public:
- GetContactsInfoRequest(const char *token, const LIST<char> &skypenames, const char *skypename = "self") :
- HttpRequest(REQUEST_POST, FORMAT, "api.skype.com/users/%s/contacts/profiles", skypename)
- {
- Headers
- << CHAR_VALUE("X-Skypetoken", token)
- << CHAR_VALUE("Accept", "application/json");
-
- for (int i = 0; i < skypenames.getCount(); i++)
- Body << CHAR_VALUE("contacts[]", skypenames[i]);
- }
-};
-
-class GetContactStatusRequest : public HttpRequest
-{
-public:
- GetContactStatusRequest(const char *regToken, const char *skypename, const char *server = SKYPE_ENDPOINTS_HOST) :
- HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/contacts/8:%s/presenceDocs/messagingService", server, skypename)
- {
- Headers
- << CHAR_VALUE("Accept", "application/json, text/javascript")
- << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
- }
-};
-
-*/
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp index a3e5181f73..cc9ff30f2b 100644 --- a/protocols/MSN/src/msn_srv.cpp +++ b/protocols/MSN/src/msn_srv.cpp @@ -177,19 +177,22 @@ void CMsnProto::MSN_RemoveEmptyGroups(void) int count = -1;
for (;;) {
MsnContact *msc = Lists_GetNext(count);
- if (msc == nullptr) break;
+ if (msc == nullptr)
+ break;
char szGroupID[100];
if (!db_get_static(msc->hContact, m_szModuleName, "GroupID", szGroupID, sizeof(szGroupID))) {
const char *pId = szGroupID;
int i = m_arGroups.getIndex((ServerGroupItem*)&pId);
- if (i > -1) ++cCount[i];
+ if (i > -1)
+ ++cCount[i];
}
}
- for (int i = m_arGroups.getCount(); i--;) {
- if (cCount[i] == 0) MSN_DeleteServerGroup(m_arGroups[i]->id);
- }
+ for (int i = m_arGroups.getCount(); i--;)
+ if (cCount[i] == 0)
+ MSN_DeleteServerGroup(m_arGroups[i]->id);
+
mir_free(cCount);
}
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index c8479c6911..551ac57da7 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -519,14 +519,15 @@ void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr) }
if (!szCookieName.IsEmpty() && !szDomain.IsEmpty()) {
- int k;
- for (k = 0; k < m_cookies.getCount(); k++) {
- if (m_cookies[k].m_name == szCookieName) {
- m_cookies[k].m_value = szCookieVal;
+ bool bFound = false;
+ for (auto &it : m_cookies)
+ if (it->m_name == szCookieName) {
+ bFound = true;
+ it->m_value = szCookieVal;
break;
}
- }
- if (k == m_cookies.getCount())
+
+ if (!bFound)
m_cookies.insert(new CVkCookie(szCookieName, szCookieVal, szDomain));
}
}
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 32e6049de4..3b44e921c9 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -65,17 +65,16 @@ TMsgQueue* msgQueue_find(MCONTACT hContact, int id) MCONTACT hMeta = db_mc_getMeta(hContact);
mir_cslockfull lck(csMsgQueue);
- for (int i = 0; i < msgQueue.getCount(); i++) {
- TMsgQueue *item = msgQueue[i];
- if ((item->hContact == hContact || item->hContact == hMeta) && item->id == id) {
- msgQueue.remove(i);
+ for (auto &it : msgQueue) {
+ if ((it->hContact == hContact || it->hContact == hMeta) && it->id == id) {
+ msgQueue.remove(it);
if (!msgQueue.getCount() && timerId) {
KillTimer(nullptr, timerId);
timerId = 0;
}
- return item;
+ return it;
}
}
return nullptr;
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp index 9d293c2e5e..120cdeff1e 100644 --- a/src/mir_core/src/threads.cpp +++ b/src/mir_core/src/threads.cpp @@ -218,11 +218,9 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner) {
mir_cslock lck(csThreads);
- for (int j = threads.getCount(); j--;) {
- THREAD_WAIT_ENTRY *p = threads[j];
- if (p->pObject == owner)
- threadPool[threadCount++] = p->hThread;
- }
+ for (auto &it : threads)
+ if (it->pObject == owner)
+ threadPool[threadCount++] = it->hThread;
}
// is there anything to kill?
@@ -250,20 +248,18 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner) static void CALLBACK KillAllThreads(HWND, UINT, UINT_PTR, DWORD)
{
- {
- mir_cslock lck(csThreads);
- for (auto &p : threads) {
- char szModuleName[MAX_PATH];
- GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(nullptr, "Killing thread %s:%p (%p)", szModuleName, p->dwThreadId, p->pEntryPoint);
- TerminateThread(p->hThread, 9999);
- CloseHandle(p->hThread);
- mir_free(p);
- }
-
- threads.destroy();
+ mir_cslock lck(csThreads);
+ for (auto &p : threads) {
+ char szModuleName[MAX_PATH];
+ GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
+ Netlib_Logf(nullptr, "Killing thread %s:%p (%p)", szModuleName, p->dwThreadId, p->pEntryPoint);
+ TerminateThread(p->hThread, 9999);
+ CloseHandle(p->hThread);
+ mir_free(p);
}
+ threads.destroy();
+
SetEvent(hThreadQueueEmpty);
}
diff --git a/src/mir_core/src/windowlist.cpp b/src/mir_core/src/windowlist.cpp index 13b339b8f6..a785472cbb 100644 --- a/src/mir_core/src/windowlist.cpp +++ b/src/mir_core/src/windowlist.cpp @@ -66,12 +66,12 @@ MIR_CORE_DLL(int) WindowList_Remove(MWindowList hList, HWND hwnd) {
if (hList == nullptr) return 1;
- for (int i = 0; i < hList->getCount(); i++) {
- if ((*hList)[i].hWnd == hwnd) {
- hList->remove(i);
+ for (auto &it : *hList)
+ if (it->hWnd == hwnd) {
+ hList->remove(it);
return 0;
}
- }
+
return 1;
}
|