summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_system_cpp.h1
-rw-r--r--plugins/Clist_modern/src/modern_clistevents.cpp14
-rw-r--r--plugins/Clist_nicer/src/clistevents.cpp14
-rw-r--r--plugins/CloudFile/src/srmm.cpp6
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp28
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp26
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp14
-rw-r--r--plugins/SmileyAdd/src/SmileyBase.cpp6
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp6
-rw-r--r--plugins/SpellChecker/src/spellchecker.cpp5
-rw-r--r--plugins/SpellChecker/src/utils.cpp27
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_options.cpp35
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp4
-rw-r--r--plugins/TopToolBar/src/toolbar.cpp8
-rw-r--r--plugins/Weather/src/weather_data.cpp53
-rw-r--r--protocols/JabberG/src/jabber_frame.cpp32
-rw-r--r--protocols/JabberG/src/jabber_list.cpp6
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp5
-rw-r--r--protocols/JabberG/src/jabber_opttree.cpp12
-rw-r--r--protocols/JabberG/src/jabber_treelist.cpp7
-rw-r--r--protocols/MSN/src/msn_lists.cpp39
-rw-r--r--protocols/VKontakte/src/misc.cpp6
-rw-r--r--src/mir_app/src/FontOptions.cpp68
-rw-r--r--src/mir_app/src/chat_manager.cpp7
-rw-r--r--src/mir_app/src/clistevents.cpp10
-rw-r--r--src/mir_app/src/clisttray.cpp6
-rw-r--r--src/mir_app/src/db_ini.cpp7
-rw-r--r--src/mir_app/src/iconheader.cpp2
-rw-r--r--src/mir_app/src/menu_clist.cpp6
-rw-r--r--src/mir_app/src/netlib.cpp4
-rw-r--r--src/mir_app/src/netliblog.cpp8
-rw-r--r--src/mir_app/src/netlibopts.cpp27
-rw-r--r--src/mir_app/src/options.cpp20
-rw-r--r--src/mir_app/src/proto_chains.cpp6
-rw-r--r--src/mir_app/src/proto_order.cpp22
-rw-r--r--src/mir_app/src/skin2opts.cpp5
-rw-r--r--src/mir_core/src/timezones.cpp23
37 files changed, 281 insertions, 294 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h
index b262254dfb..b0f15305de 100644
--- a/include/m_system_cpp.h
+++ b/include/m_system_cpp.h
@@ -233,6 +233,7 @@ template<class T> struct LIST
__inline int insert(T *p) { return List_InsertPtr((SortedList*)this, p); }
__inline int remove(T *p) { return List_RemovePtr((SortedList*)this, p); }
+ __inline int indexOf(T **p) const { return int(p - items); }
__inline T* removeItem(T **p)
{
T *savePtr = *p;
diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp
index 0caf90b0d7..a336f326f9 100644
--- a/plugins/Clist_modern/src/modern_clistevents.cpp
+++ b/plugins/Clist_modern/src/modern_clistevents.cpp
@@ -158,19 +158,19 @@ CListEvent* cli_AddEvent(CLISTEVENT *cle)
int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent)
{
// Find the event that should be removed
- int i;
- for (i = 0; i < pcli->events->getCount(); i++) {
- CListEvent &e = (*pcli->events)[i];
- if (e.hContact == hContact && e.hDbEvent == hDbEvent)
+ CListEvent *pEvent = nullptr;
+ for (auto &it : *pcli->events)
+ if (it->hContact == hContact && it->hDbEvent == hDbEvent) {
+ pEvent = it;
break;
- }
+ }
// Event was not found
- if (i == pcli->events->getCount())
+ if (pEvent == nullptr)
return 1;
// remove event from the notify menu
- int iMenuId = (*pcli->events)[i].menuId;
+ int iMenuId = pEvent->menuId;
if (iMenuId > 0) {
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp
index 288d55cdcc..d9856cec30 100644
--- a/plugins/Clist_nicer/src/clistevents.cpp
+++ b/plugins/Clist_nicer/src/clistevents.cpp
@@ -315,19 +315,19 @@ CListEvent* AddEvent(CLISTEVENT *cle)
int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent)
{
// Find the event that should be removed
- int i;
- for (i = 0; i < pcli->events->getCount(); i++) {
- CListEvent &e = (*pcli->events)[i];
- if (e.hContact == hContact && e.hDbEvent == hDbEvent)
+ CListEvent *e = nullptr;
+ for (auto &it : *pcli->events)
+ if (it->hContact == hContact && it->hDbEvent == hDbEvent) {
+ e = it;
break;
- }
+ }
// Event was not found
- if (i == pcli->events->getCount())
+ if (e == nullptr)
return 1;
// remove event from the notify menu
- int iMenuId = (*pcli->events)[i].menuId;
+ int iMenuId = e->menuId;
if (iMenuId > 0) {
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
diff --git a/plugins/CloudFile/src/srmm.cpp b/plugins/CloudFile/src/srmm.cpp
index 68c2cca0cb..8e400bbdbf 100644
--- a/plugins/CloudFile/src/srmm.cpp
+++ b/plugins/CloudFile/src/srmm.cpp
@@ -54,10 +54,8 @@ int OnSrmmButtonPressed(WPARAM, LPARAM lParam)
}
HMENU hMenu = CreatePopupMenu();
- for (int i = 0; i < Services.getCount(); i++) {
- CCloudService *service = Services[i];
- AppendMenu(hMenu, MF_STRING, i + 1, TranslateW(service->GetUserName()));
- }
+ for (auto &it : Services)
+ AppendMenu(hMenu, MF_STRING, Services.indexOf(&it) + 1, TranslateW(it->GetUserName()));
int pos = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbc->pt.x, cbc->pt.y, 0, cbc->hwndFrom, nullptr);
DestroyMenu(hMenu);
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index 81f40481b7..7151781255 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -224,24 +224,22 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
///
bool enableOk = false;
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam;
- for (int i = 0; i < todo.getCount(); i++) {
- auto &p = todo[i];
-
+ for (auto &p : todo) {
LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM | LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE;
int groupId = 4;
- if (wcschr(p.tszOldName, L'\\') != nullptr)
- groupId = (wcsstr(p.tszOldName, L"Plugins") != nullptr) ? 1 : ((wcsstr(p.tszOldName, L"Languages") != nullptr) ? 3 : 2);
+ if (wcschr(p->tszOldName, L'\\') != nullptr)
+ groupId = (wcsstr(p->tszOldName, L"Plugins") != nullptr) ? 1 : ((wcsstr(p->tszOldName, L"Languages") != nullptr) ? 3 : 2);
- lvi.iItem = i;
- lvi.lParam = (LPARAM)&todo[i];
+ lvi.iItem = todo.indexOf(&p);
+ lvi.lParam = (LPARAM)p;
lvi.iGroupId = groupId;
lvi.iImage = ((groupId == 1) ? 0 : -1);
- lvi.pszText = p.tszOldName;
+ lvi.pszText = p->tszOldName;
ListView_InsertItem(hwndList, &lvi);
- if (p.bEnabled) {
+ if (p->bEnabled) {
enableOk = true;
ListView_SetCheckState(hwndList, lvi.iItem, 1);
}
@@ -273,8 +271,8 @@ INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
p->bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);
bool enableOk = false;
- for (int i = 0; i < todo.getCount(); ++i) {
- if (p->bEnabled) {
+ for (auto &it : todo) {
+ if (it->bEnabled) {
enableOk = true;
break;
}
@@ -396,14 +394,12 @@ static void GetList(void *)
FILELIST *UpdateFiles = new FILELIST(20);
VARSW dirname(L"%miranda_path%");
- for (int i = 0; i < hashes.getCount(); i++) {
- ServListEntry &hash = hashes[i];
-
+ for (auto &it : hashes) {
wchar_t tszPath[MAX_PATH];
- mir_snwprintf(tszPath, L"%s\\%s", dirname, hash.m_name);
+ mir_snwprintf(tszPath, L"%s\\%s", dirname, it->m_name);
if (GetFileAttributes(tszPath) == INVALID_FILE_ATTRIBUTES) {
- FILEINFO *FileInfo = ServerEntryToFileInfo(hash, baseUrl, tszPath);
+ FILEINFO *FileInfo = ServerEntryToFileInfo(*it, baseUrl, tszPath);
UpdateFiles->insert(FileInfo);
}
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 467e7e44ce..f5058c63a0 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -30,9 +30,9 @@ 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++) {
- ListView_SetCheckState(hwndList, i, bEnable);
- db_set_b(NULL, DB_MODULE_FILES, StrToLower(_T2A(todo[i].tszOldName)), todo[i].bEnabled = bEnable);
+ for (auto &it : todo) {
+ ListView_SetCheckState(hwndList, todo.indexOf(&it), bEnable);
+ db_set_b(NULL, DB_MODULE_FILES, StrToLower(_T2A(it->tszOldName)), it->bEnabled = bEnable);
}
}
@@ -266,23 +266,23 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM
bool enableOk = false;
OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam;
- for (int i = 0; i < todo.getCount(); ++i) {
+ for (auto &it : todo) {
LVITEM lvI = {0};
lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_GROUPID | LVIF_NORECOMPUTE;
- lvI.iGroupId = (wcsstr(todo[i].tszOldName, L"Plugins") != nullptr) ? 1 :
- ((wcsstr(todo[i].tszOldName, L"Languages") != nullptr) ? 3 :
- ((wcsstr(todo[i].tszOldName, L"Icons") != nullptr) ? 4 : 2));
+ lvI.iGroupId = (wcsstr(it->tszOldName, L"Plugins") != nullptr) ? 1 :
+ ((wcsstr(it->tszOldName, L"Languages") != nullptr) ? 3 :
+ ((wcsstr(it->tszOldName, L"Icons") != nullptr) ? 4 : 2));
lvI.iSubItem = 0;
- lvI.lParam = (LPARAM)&todo[i];
- lvI.pszText = todo[i].tszOldName;
- lvI.iItem = i;
+ lvI.lParam = (LPARAM)it;
+ lvI.pszText = it->tszOldName;
+ lvI.iItem = todo.indexOf(&it);
ListView_InsertItem(hwndList, &lvI);
- ListView_SetCheckState(hwndList, lvI.iItem, todo[i].bEnabled);
- if (todo[i].bEnabled)
+ ListView_SetCheckState(hwndList, lvI.iItem, it->bEnabled);
+ if (it->bEnabled)
enableOk = true;
- SetStringText(hwndList,i,todo[i].bDeleteOnly ? TranslateT("Deprecated!") : TranslateT("Update found!"));
+ SetStringText(hwndList, lvI.iItem, it->bDeleteOnly ? TranslateT("Deprecated!") : TranslateT("Update found!"));
}
if(enableOk)
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index d0c720b2e7..9f864e2bc7 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -404,12 +404,8 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
SortArray();
SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_RESETCONTENT, 0, 0);
- for (int loop = 0; loop < contacts.getCount(); loop++) {
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETITEMDATA,
- (WPARAM)SendDlgItemMessage(hwndDlg, IDC_USERNAME,
- CB_ADDSTRING, 0, (LPARAM)GetListName(contacts[loop])),
- (LPARAM)loop);
- }
+ for (int loop = 0; loop < contacts.getCount(); loop++)
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_ADDSTRING, 0, (LPARAM)GetListName(contacts[loop])), loop);
}
@@ -511,9 +507,9 @@ MCONTACT GetSelectedContact(HWND hwndDlg)
// get array position from handle
int GetItemPos(MCONTACT hcontact)
{
- for (int loop = 0; loop < contacts.getCount(); loop++)
- if (hcontact == contacts[loop]->hcontact)
- return loop;
+ for (auto &it : contacts)
+ if (hcontact == it->hcontact)
+ return contacts.indexOf(&it);
return -1;
}
diff --git a/plugins/SmileyAdd/src/SmileyBase.cpp b/plugins/SmileyAdd/src/SmileyBase.cpp
index e9ef6722d8..6394a9ba6a 100644
--- a/plugins/SmileyAdd/src/SmileyBase.cpp
+++ b/plugins/SmileyAdd/src/SmileyBase.cpp
@@ -376,9 +376,9 @@ void CloseSmileys(void)
int CheckForTip(int x, int y, HWND hwnd, wchar_t **smltxt)
{
- for (int i = 0; i < regSmileys.getCount(); i++)
- if (regSmileys[i]->QueryHitPointSpecial(x, y, hwnd, smltxt))
- return i;
+ for (auto &it : regSmileys)
+ if (it->QueryHitPointSpecial(x, y, hwnd, smltxt))
+ return regSmileys.indexOf(&it);
return -1;
}
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 98178f0a23..0bb88d0482 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -836,9 +836,11 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, wchar_t *path, w
// Check if dict is new
bool exists = false;
- for (int i = 0; i < dicts.getCount() && !exists; i++)
- if (mir_wstrcmp(dicts[i]->language, lang) == 0)
+ for (auto &it : dicts)
+ if (mir_wstrcmp(it->language, lang) == 0) {
exists = true;
+ break;
+ }
if (!exists) {
found = TRUE;
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp
index 4b495303c1..9770861c9c 100644
--- a/plugins/SpellChecker/src/spellchecker.cpp
+++ b/plugins/SpellChecker/src/spellchecker.cpp
@@ -144,12 +144,11 @@ static int ModulesLoaded(WPARAM, LPARAM)
sid.section.w = LPGENW("Spell Checker") L"/" LPGENW("Flags");
// Get language flags
- for (int i = 0; i < languages.getCount(); i++) {
- auto *p = languages[i];
+ for (auto &p : languages) {
sid.description.w = p->full_name;
char lang[32];
- mir_snprintf(lang, "spell_lang_%d", i);
+ mir_snprintf(lang, "spell_lang_%d", languages.indexOf(&p));
sid.pszName = lang;
HICON hFlag = nullptr, hFlagIcoLib = nullptr;
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp
index 7dfcd12884..4fd399f44f 100644
--- a/plugins/SpellChecker/src/utils.cpp
+++ b/plugins/SpellChecker/src/utils.cpp
@@ -668,39 +668,38 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int GetClosestLanguage(wchar_t *lang_name)
{
- int i;
-
// Search the language by name
- for (i = 0; i < languages.getCount(); i++)
- if (mir_wstrcmpi(languages[i]->language, lang_name) == 0)
- return i;
+ for (auto &it : languages)
+ if (mir_wstrcmpi(it->language, lang_name) == 0)
+ return languages.indexOf(&it);
// Try searching by the prefix only
wchar_t lang[128];
mir_wstrncpy(lang, lang_name, _countof(lang));
{
wchar_t *p = wcschr(lang, '_');
- if (p != nullptr) *p = '\0';
+ if (p != nullptr)
+ *p = '\0';
}
// First check if there is a language that is only the prefix
- for (i = 0; i < languages.getCount(); i++)
- if (mir_wstrcmpi(languages[i]->language, lang) == 0)
- return i;
+ for (auto &it : languages)
+ if (mir_wstrcmpi(it->language, lang) == 0)
+ return languages.indexOf(&it);
// Now try any suffix
size_t len = mir_wstrlen(lang);
- for (i = 0; i < languages.getCount(); i++) {
- wchar_t *p = wcschr(languages[i]->language, '_');
+ for (auto &it : languages) {
+ wchar_t *p = wcschr(it->language, '_');
if (p == nullptr)
continue;
- size_t prefix_len = p - languages[i]->language;
+ size_t prefix_len = p - it->language;
if (prefix_len != len)
continue;
- if (wcsnicmp(languages[i]->language, lang_name, len) == 0)
- return i;
+ if (wcsnicmp(it->language, lang_name, len) == 0)
+ return languages.indexOf(&it);
}
return -1;
diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
index af4e8f79c9..1b401cdca7 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
@@ -502,8 +502,8 @@ class CSSAdvancedOptDlg : public CDlgBase
{
// creates profile combo box according to 'dat'
cmbProfile.ResetContent();
- for (int i = 0; i < arProfiles.getCount(); i++)
- cmbProfile.AddString(arProfiles[i].tszName, i);
+ for (auto &it : arProfiles)
+ cmbProfile.AddString(it->tszName, arProfiles.indexOf(&it));
cmbProfile.SetCurSel(0);
SetProfile();
@@ -695,24 +695,23 @@ public:
}
}
- for (int i = 0; i < arProfiles.getCount(); i++) {
- PROFILEOPTIONS& po = arProfiles[i];
- db_set_b(0, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), po.showDialog);
- db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), po.createTtb);
- db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), po.createMmi);
- db_set_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), po.inSubMenu);
- db_set_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), po.regHotkey);
- db_set_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), po.hotKey);
- db_set_ws(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME), po.tszName);
-
- TProtoSettings &ar = po.ps;
- for (int j = 0; j < ar.getCount(); j++) {
- if (ar[j].m_szMsg != nullptr) {
+ for (auto &it : arProfiles) {
+ int i = arProfiles.indexOf(&it);
+ db_set_b(0, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), it->showDialog);
+ db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), it->createTtb);
+ db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), it->createMmi);
+ db_set_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), it->inSubMenu);
+ db_set_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), it->regHotkey);
+ db_set_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), it->hotKey);
+ db_set_ws(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME), it->tszName);
+
+ for (auto jt : it->ps) {
+ if (jt->m_szMsg != nullptr) {
char setting[128];
- mir_snprintf(setting, "%s_%s", ar[j].m_szName, SETTING_PROFILE_STSMSG);
- db_set_ws(0, SSMODULENAME, OptName(i, setting), ar[j].m_szMsg);
+ mir_snprintf(setting, "%s_%s", jt->m_szName, SETTING_PROFILE_STSMSG);
+ db_set_ws(0, SSMODULENAME, OptName(i, setting), jt->m_szMsg);
}
- db_set_w(0, SSMODULENAME, OptName(i, ar[j].m_szName), ar[j].m_status);
+ db_set_w(0, SSMODULENAME, OptName(i, jt->m_szName), jt->m_status);
}
}
db_set_w(0, SSMODULENAME, SETTING_PROFILECOUNT, (WORD)arProfiles.getCount());
diff --git a/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp
index 628f4f192c..63e914b60a 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp
@@ -33,8 +33,8 @@ static IconItem iconList[] =
void RemoveTopToolbarButtons()
{
- for (int i = ttbButtons.getCount() - 1; i >= 0; i--)
- CallService(MS_TTB_REMOVEBUTTON, (WPARAM)ttbButtons[i], 0);
+ for (auto &it : ttbButtons.rev_iter())
+ CallService(MS_TTB_REMOVEBUTTON, (WPARAM)it, 0);
ttbButtons.destroy();
}
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp
index 380daf02dd..a0a77b8536 100644
--- a/plugins/TopToolBar/src/toolbar.cpp
+++ b/plugins/TopToolBar/src/toolbar.cpp
@@ -25,11 +25,11 @@ LIST<TopButtonInt> Buttons(8, sortfunc);
TopButtonInt *idtopos(int id, int *pPos)
{
- for (int i = 0; i < Buttons.getCount(); i++)
- if (Buttons[i]->id == id) {
+ for (auto &it : Buttons)
+ if (it->id == id) {
if (pPos)
- *pPos = i;
- return Buttons[i];
+ *pPos = Buttons.indexOf(&it);
+ return it;
}
if (pPos)
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp
index dfcfc642d2..28fa9a622d 100644
--- a/plugins/Weather/src/weather_data.cpp
+++ b/plugins/Weather/src/weather_data.cpp
@@ -408,33 +408,32 @@ void DBDataManage(MCONTACT hContact, WORD Mode, WPARAM wParam, LPARAM)
db_enum_settings(hContact, GetWeatherDataFromDB, WEATHERCONDITION, &arSettings);
// begin deleting settings
- for (int i = arSettings.getCount() - 1; i >= 0; i--) {
- char *szSetting = arSettings[i];
-
- DBVARIANT dbv;
- if (!db_get_ws(hContact, WEATHERCONDITION, szSetting, &dbv)) {
- switch (Mode) {
- case WDBM_REMOVE:
- db_unset(hContact, WEATHERCONDITION, szSetting);
- break;
-
- case WDBM_DETAILDISPLAY:
- // skip the "WeatherInfo" variable
- if (!mir_strcmp(szSetting, "WeatherInfo") || !mir_strcmp(szSetting, "Ignore") || szSetting[0] == '#')
- continue;
-
- HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST);
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.lParam = i;
- lvi.pszText = TranslateW(_A2T(szSetting));
- lvi.iItem = ListView_InsertItem(hList, &lvi);
- lvi.pszText = dbv.ptszVal;
- ListView_SetItemText(hList, lvi.iItem, 1, dbv.ptszVal);
- break;
- }
- db_free(&dbv);
+ auto T = arSettings.rev_iter();
+ for (auto &str : T) {
+ ptrW wszText(db_get_wsa(hContact, WEATHERCONDITION, str));
+ if (wszText == nullptr)
+ continue;
+
+ switch (Mode) {
+ case WDBM_REMOVE:
+ db_unset(hContact, WEATHERCONDITION, str);
+ break;
+
+ case WDBM_DETAILDISPLAY:
+ // skip the "WeatherInfo" variable
+ if (!mir_strcmp(str, "WeatherInfo") || !mir_strcmp(str, "Ignore") || str[0] == '#')
+ continue;
+
+ HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST);
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = T.indexOf(&str);
+ lvi.pszText = TranslateW(_A2T(str));
+ lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.pszText = wszText;
+ ListView_SetItemText(hList, lvi.iItem, 1, wszText);
+ break;
}
- mir_free(szSetting);
+ mir_free(str);
}
}
diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp
index 9253442816..6f15bf4780 100644
--- a/protocols/JabberG/src/jabber_frame.cpp
+++ b/protocols/JabberG/src/jabber_frame.cpp
@@ -190,9 +190,9 @@ LRESULT CJabberInfoFrame::WndProc(UINT msg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONDOWN:
{
POINT pt = { LOWORD(lParam), HIWORD(lParam) };
- for (int i=0; i < m_pItems.getCount(); i++)
- if (m_pItems[i].m_onEvent && PtInRect(&m_pItems[i].m_rcItem, pt)) {
- m_clickedItem = i;
+ for (auto &it : m_pItems)
+ if (it->m_onEvent && PtInRect(&it->m_rcItem, pt)) {
+ m_clickedItem = m_pItems.indexOf(&it);
return 0;
}
}
@@ -339,19 +339,17 @@ void CJabberInfoFrame::PaintCompact(HDC hdc)
int cy_icon = GetSystemMetrics(SM_CYSMICON);
int cx = rc.right - cx_icon - SZ_FRAMEPADDING;
- for (int i = m_pItems.getCount(); i--;) {
- CJabberInfoFrameItem &item = m_pItems[i];
-
- SetRect(&item.m_rcItem, 0, 0, 0, 0);
- if (!item.m_bShow) continue;
- if (!item.m_bCompact) continue;
+ for (auto &it : m_pItems.rev_iter()) {
+ SetRect(&it->m_rcItem, 0, 0, 0, 0);
+ if (!it->m_bShow) continue;
+ if (!it->m_bCompact) continue;
int depth = 0;
- for (char *p = item.m_pszName; p = strchr(p+1, '/'); ++depth) ;
+ for (char *p = it->m_pszName; p = strchr(p+1, '/'); ++depth) ;
if (depth == 0) {
- if (item.m_hIcolibIcon) {
- HICON hIcon = IcoLib_GetIconByHandle(item.m_hIcolibIcon);
+ if (it->m_hIcolibIcon) {
+ HICON hIcon = IcoLib_GetIconByHandle(it->m_hIcolibIcon);
if (hIcon) {
DrawIconEx(hdc, SZ_FRAMEPADDING, (rc.bottom-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, nullptr, DI_NORMAL);
IcoLib_ReleaseIcon(hIcon);
@@ -359,19 +357,19 @@ void CJabberInfoFrame::PaintCompact(HDC hdc)
}
RECT rcText; SetRect(&rcText, cx_icon + SZ_FRAMEPADDING + SZ_ICONSPACING, 0, rc.right - SZ_FRAMEPADDING, rc.bottom);
- DrawText(hdc, item.m_pszText, -1, &rcText, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);
+ DrawText(hdc, it->m_pszText, -1, &rcText, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);
}
else {
- if (item.m_hIcolibIcon) {
- HICON hIcon = IcoLib_GetIconByHandle(item.m_hIcolibIcon);
+ if (it->m_hIcolibIcon) {
+ HICON hIcon = IcoLib_GetIconByHandle(it->m_hIcolibIcon);
if (hIcon) {
- SetRect(&item.m_rcItem, cx, (rc.bottom-cy_icon)/2, cx+cx_icon, (rc.bottom-cy_icon)/2+cy_icon);
+ SetRect(&it->m_rcItem, cx, (rc.bottom-cy_icon)/2, cx+cx_icon, (rc.bottom-cy_icon)/2+cy_icon);
DrawIconEx(hdc, cx, (rc.bottom-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, nullptr, DI_NORMAL);
cx -= cx_icon;
IcoLib_ReleaseIcon(hIcon);
- SetToolTip(item.m_tooltipId, &item.m_rcItem, item.m_pszText);
+ SetToolTip(it->m_tooltipId, &it->m_rcItem, it->m_pszText);
}
}
}
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index 0d102bf196..8a4b817965 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -362,13 +362,11 @@ pResourceStatus JABBER_LIST_ITEM::getBestResource() const
return m_pManualResource;
int nBestPos = -1, nBestPri = -200;
- for (int i = 0; i < arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *r = arResources[i];
+ for (auto &r : arResources)
if (r->m_iPriority > nBestPri) {
nBestPri = r->m_iPriority;
- nBestPos = i;
+ nBestPos = arResources.indexOf(&r);
}
- }
return (nBestPos != -1) ? arResources[nBestPos] : nullptr;
}
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 02fc077c4f..9e0c556ba1 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -1067,11 +1067,10 @@ CJabberProto* JabberChooseInstance(bool bIsLink)
return it;
int nItems = 0, lastItemId = 0;
- for (int i = 0; i < g_Instances.getCount(); i++) {
- CJabberProto *ppro = g_Instances[i];
+ for (auto &ppro : g_Instances) {
if (ppro->m_iStatus != ID_STATUS_OFFLINE && ppro->m_iStatus != ID_STATUS_CONNECTING) {
++nItems;
- lastItemId = i + 1;
+ lastItemId = g_Instances.indexOf(&ppro) + 1;
Menu_ModifyItem(ppro->m_hChooseMenuItem, nullptr, Skin_LoadProtoIcon(ppro->m_szModuleName, ppro->m_iStatus));
}
else Menu_ShowItem(ppro->m_hChooseMenuItem, false);
diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp
index c9ad4ba465..d4b0bfca13 100644
--- a/protocols/JabberG/src/jabber_opttree.cpp
+++ b/protocols/JabberG/src/jabber_opttree.cpp
@@ -107,12 +107,12 @@ void CCtrlTreeOpts::OnInit()
SetImageList(hImgLst, TVSIL_NORMAL);
/* build options tree. based on code from IcoLib */
- for (int i = 0; i < m_options.getCount(); i++) {
+ for (auto &it : m_options) {
wchar_t *sectionName;
int sectionLevel = 0;
HTREEITEM hSection = nullptr;
- mir_wstrcpy(itemName, m_options[i]->m_szOptionName);
+ mir_wstrcpy(itemName, it->m_szOptionName);
sectionName = itemName;
while (sectionName) {
@@ -142,18 +142,18 @@ void CCtrlTreeOpts::OnInit()
tvis.item.iImage = tvis.item.iSelectedImage = IMG_GRPOPEN;
}
else {
- tvis.item.lParam = i;
+ tvis.item.lParam = m_options.indexOf(&it);
- BYTE val = *m_options[i]->m_option;
+ BYTE val = *it->m_option;
- if (m_options[i]->m_groupId == OPTTREE_CHECK)
+ if (it->m_groupId == OPTTREE_CHECK)
tvis.item.iImage = tvis.item.iSelectedImage = val ? IMG_CHECK : IMG_NOCHECK;
else
tvis.item.iImage = tvis.item.iSelectedImage = val ? IMG_RCHECK : IMG_NORCHECK;
}
hItem = InsertItem(&tvis);
if (!sectionName)
- m_options[i]->m_hItem = hItem;
+ it->m_hItem = hItem;
}
}
sectionLevel++;
diff --git a/protocols/JabberG/src/jabber_treelist.cpp b/protocols/JabberG/src/jabber_treelist.cpp
index 7a960fedd4..e701c79f60 100644
--- a/protocols/JabberG/src/jabber_treelist.cpp
+++ b/protocols/JabberG/src/jabber_treelist.cpp
@@ -320,8 +320,9 @@ void TreeList_Update(HWND hwnd)
if (data->mode == TLM_TREE)
TreeList_RecursiveApply(hItem, sttTreeList_CreateItems, (LPARAM)hwnd);
else {
- for (int i = data->hItemSelected->subItems.getCount(); i--;)
- sttTreeList_CreateItems_List(data->hItemSelected->subItems[i], (LPARAM)hwnd);
+ for (auto &it : data->hItemSelected->subItems)
+ sttTreeList_CreateItems_List(it, (LPARAM)hwnd);
+
for (HTREELISTITEM p = data->hItemSelected; !(p->flags & TLIF_ROOT); p = p->parent)
sttTreeList_CreateItems_List(p, (LPARAM)hwnd);
}
@@ -504,7 +505,7 @@ static void sttTreeList_ResetIndex(HTREELISTITEM hItem, LPARAM data)
static void sttTreeList_FilterItems(HTREELISTITEM hItem, LPARAM data)
{
- int i = 0;
+ int i;
for (i=0; i < hItem->text.getCount(); i++)
if (JabberStrIStr(hItem->text[i], (wchar_t *)data))
break;
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp
index c103be86f3..393e1d085d 100644
--- a/protocols/MSN/src/msn_lists.cpp
+++ b/protocols/MSN/src/msn_lists.cpp
@@ -209,23 +209,22 @@ void CMsnProto::Lists_Populate(void)
void CMsnProto::MSN_CleanupLists(void)
{
- for (int i = m_arContacts.getCount(); i--;) {
- MsnContact& p = m_arContacts[i];
- if (p.list & LIST_FL)
- MSN_SetContactDb(p.hContact, p.email);
-
- if (p.list & LIST_PL) {
- if (p.list & (LIST_AL | LIST_BL))
- MSN_AddUser(NULL, p.email, p.netId, LIST_PL + LIST_REMOVE);
+ for (auto &it : m_arContacts.rev_iter()) {
+ if (it->list & LIST_FL)
+ MSN_SetContactDb(it->hContact, it->email);
+
+ if (it->list & LIST_PL) {
+ if (it->list & (LIST_AL | LIST_BL))
+ MSN_AddUser(NULL, it->email, it->netId, LIST_PL + LIST_REMOVE);
else
- MSN_AddAuthRequest(p.email, p.nick, p.invite);
+ MSN_AddAuthRequest(it->email, it->nick, it->invite);
}
- if (p.hContact && !(p.list & (LIST_LL | LIST_FL | LIST_PL)) && p.list != LIST_RL) {
- int count = db_event_count(p.hContact);
+ if (it->hContact && !(it->list & (LIST_LL | LIST_FL | LIST_PL)) && it->list != LIST_RL) {
+ int count = db_event_count(it->hContact);
if (count) {
wchar_t text[256];
- wchar_t *sze = mir_a2u(p.email);
+ wchar_t *sze = mir_a2u(it->email);
mir_snwprintf(text, TranslateT("Contact %s has been removed from the server.\nWould you like to keep it as \"Local Only\" contact to preserve history?"), sze);
mir_free(sze);
@@ -233,25 +232,25 @@ void CMsnProto::MSN_CleanupLists(void)
mir_snwprintf(title, TranslateT("%s protocol"), m_tszUserName);
if (MessageBox(nullptr, text, title, MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND) == IDYES) {
- MSN_AddUser(p.hContact, p.email, 0, LIST_LL);
- setByte(p.hContact, "LocalList", 1);
+ MSN_AddUser(it->hContact, it->email, 0, LIST_LL);
+ setByte(it->hContact, "LocalList", 1);
continue;
}
}
- if (!(p.list & (LIST_LL | LIST_FL))) {
- db_delete_contact(p.hContact);
- p.hContact = NULL;
+ if (!(it->list & (LIST_LL | LIST_FL))) {
+ db_delete_contact(it->hContact);
+ it->hContact = NULL;
}
}
- if (p.list & (LIST_LL | LIST_FL) && p.hContact) {
+ if (it->list & (LIST_LL | LIST_FL) && it->hContact) {
wchar_t path[MAX_PATH];
- MSN_GetCustomSmileyFileName(p.hContact, path, _countof(path), "", 0);
+ MSN_GetCustomSmileyFileName(it->hContact, path, _countof(path), "", 0);
if (path[0]) {
SMADD_CONT cont;
cont.cbSize = sizeof(SMADD_CONT);
- cont.hContact = p.hContact;
+ cont.hContact = it->hContact;
cont.type = 0;
cont.path = path;
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 551ac57da7..07bf5cd0b5 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -229,9 +229,9 @@ bool CVkProto::IsGroupUser(MCONTACT hContact)
bool CVkProto::CheckMid(LIST<void> &lList, int guid)
{
- for (int i = lList.getCount() - 1; i >= 0; i--)
- if ((INT_PTR)lList[i] == guid) {
- lList.remove(i);
+ for (auto &it : lList)
+ if ((INT_PTR)it == guid) {
+ lList.remove(lList.indexOf(&it));
return true;
}
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp
index bce42d268c..9d42904807 100644
--- a/src/mir_app/src/FontOptions.cpp
+++ b/src/mir_app/src/FontOptions.cpp
@@ -599,16 +599,16 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
SendDlgItemMessage(hwndDlg, IDC_FONTLIST, WM_SETREDRAW, FALSE, 0);
- for (int fontId = 0; fontId < font_id_list_w2.getCount(); fontId++) {
- FontInternal &F = font_id_list_w2[fontId];
- if (!wcsncmp(F.group, group_buff, 64)) {
- FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
- itemData->colour_id = -1;
- itemData->effect_id = -1;
- itemData->font_id = fontId;
- SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
- need_restart |= (F.flags & FIDF_NEEDRESTART);
- }
+ for (auto &it : font_id_list_w2) {
+ if (wcsncmp(it->group, group_buff, 64))
+ continue;
+
+ FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
+ itemData->colour_id = -1;
+ itemData->effect_id = -1;
+ itemData->font_id = font_id_list_w2.indexOf(&it);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
+ need_restart |= (it->flags & FIDF_NEEDRESTART);
}
if (hBkgColourBrush) {
@@ -616,37 +616,39 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
hBkgColourBrush = nullptr;
}
- for (int colourId = 0; colourId < colour_id_list_w2.getCount(); colourId++) {
- ColourInternal &C = colour_id_list_w2[colourId];
- if (!wcsncmp(C.group, group_buff, 64)) {
- if (!sttFsuiBindColourIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), C.name, C.group, C.name, colourId)) {
- FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
- itemData->colour_id = colourId;
- itemData->font_id = -1;
- itemData->effect_id = -1;
+ for (auto &it : colour_id_list_w2) {
+ if (wcsncmp(it->group, group_buff, 64))
+ continue;
- SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
- }
+ int colourId = colour_id_list_w2.indexOf(&it);
+ if (!sttFsuiBindColourIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), it->name, it->group, it->name, colourId)) {
+ FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
+ itemData->colour_id = colourId;
+ itemData->font_id = -1;
+ itemData->effect_id = -1;
- if (mir_wstrcmp(C.name, L"Background") == 0)
- hBkgColourBrush = CreateSolidBrush(C.value);
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
}
+
+ if (mir_wstrcmp(it->name, L"Background") == 0)
+ hBkgColourBrush = CreateSolidBrush(it->value);
}
if (!hBkgColourBrush)
hBkgColourBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
- for (int effectId = 0; effectId < effect_id_list_w2.getCount(); effectId++) {
- EffectInternal& E = effect_id_list_w2[effectId];
- if (!wcsncmp(E.group, group_buff, 64)) {
- if (!sttFsuiBindEffectIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), E.name, effectId)) {
- FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
- itemData->effect_id = effectId;
- itemData->font_id = -1;
- itemData->colour_id = -1;
-
- SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
- }
+ for (auto &it : effect_id_list_w2) {
+ if (wcsncmp(it->group, group_buff, 64))
+ continue;
+
+ int effectId = effect_id_list_w2.indexOf(&it);
+ if (!sttFsuiBindEffectIdToFonts(GetDlgItem(hwndDlg, IDC_FONTLIST), it->name, effectId)) {
+ FSUIListItemData *itemData = (FSUIListItemData*)mir_alloc(sizeof(FSUIListItemData));
+ itemData->effect_id = effectId;
+ itemData->font_id = -1;
+ itemData->colour_id = -1;
+
+ SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)itemData);
}
}
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 0feb9f65b7..55c42c9d42 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -385,10 +385,9 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce)
void SM_RemoveAll(void)
{
- while (g_arSessions.getCount()) {
- SM_FreeSession(g_arSessions[0], false);
- g_arSessions.remove(0);
- }
+ for (auto &it : g_arSessions)
+ SM_FreeSession(it, false);
+ g_arSessions.destroy();
}
static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand)
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp
index f9a7130108..c000f1462f 100644
--- a/src/mir_app/src/clistevents.cpp
+++ b/src/mir_app/src/clistevents.cpp
@@ -99,7 +99,9 @@ static void ShowOneEventInTray(int idx)
static void ShowEventsInTray()
{
int nTrayCnt = cli.trayIconCount;
- if (!g_cliEvents.getCount() || !nTrayCnt) return;
+ if (!g_cliEvents.getCount() || !nTrayCnt)
+ return;
+
if (g_cliEvents.getCount() == 1 || nTrayCnt == 1) {
ShowOneEventInTray(0); //for only one icon in tray show topmost event
return;
@@ -133,7 +135,7 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
{
ShowEventsInTray();
- for (int i=0; i < g_cliEvents.getCount(); i++) {
+ for (int i = 0; i < g_cliEvents.getCount(); i++) {
auto &e = g_cliEvents[i];
int j;
for (j = 0; j < i; j++)
@@ -141,7 +143,7 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
break;
if (j >= i)
cli.pfnChangeContactIcon(e.hContact, iconsOn || disableIconFlash ? e.imlIconIndex : 0);
-
+
// decrease eflashes in any case - no need to collect all events
if (e.flags & CLEF_ONLYAFEW)
if (0 >= --e.flashesDone)
@@ -257,7 +259,7 @@ CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx)
if (it->hContact == hContact)
if (idx-- == 0)
return it;
-
+
return nullptr;
}
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp
index 8ef2039e5f..6fb2866dc1 100644
--- a/src/mir_app/src/clisttray.cpp
+++ b/src/mir_app/src/clisttray.cpp
@@ -470,9 +470,9 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
cli.cycleTimerId = 0;
}
- for (int i = 0; i < accounts.getCount(); i++)
- if (!mir_strcmp(szChangedProto, accounts[i]->szModuleName))
- cli.cycleStep = i;
+ for (auto &it : accounts)
+ if (!mir_strcmp(szChangedProto, it->szModuleName))
+ cli.cycleStep = accounts.indexOf(&it);
int changed = cli.pfnTrayCalcChanged(szChangedProto, averageMode, netProtoCount);
if (changed != -1 && cli.trayIcon[changed].isBase)
diff --git a/src/mir_app/src/db_ini.cpp b/src/mir_app/src/db_ini.cpp
index 34acedeb5c..d37a374e85 100644
--- a/src/mir_app/src/db_ini.cpp
+++ b/src/mir_app/src/db_ini.cpp
@@ -426,10 +426,9 @@ LBL_NewLine:
ESFDParam param = { &arSettings, szName };
db_enum_settings(0, EnumSettingsForDeletion, szSection, &param);
- while (arSettings.getCount()) {
- db_unset(0, szSection, arSettings[0]);
- mir_free(arSettings[0]);
- arSettings.remove(0);
+ for (auto &it : arSettings) {
+ db_unset(0, szSection, it);
+ mir_free(it);
}
}
db_unset(0, szSection, szName);
diff --git a/src/mir_app/src/iconheader.cpp b/src/mir_app/src/iconheader.cpp
index 4a00cbfd48..beb7c9fbcb 100644
--- a/src/mir_app/src/iconheader.cpp
+++ b/src/mir_app/src/iconheader.cpp
@@ -415,7 +415,7 @@ static LRESULT CALLBACK MIcoTabWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
newIdx--;
break;
}
- if ((newIdx >= 0) && (newIdx < itc->pList.getCount()) && (newIdx != itc->nSelectedIdx)) {
+ if (newIdx >= 0 && newIdx < itc->pList.getCount() && newIdx != itc->nSelectedIdx) {
itc->nSelectedIdx = newIdx;
SetWindowText(hwndDlg, itc->pList[itc->nSelectedIdx]->tcsName);
RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE);
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp
index 6b4a3a1e1f..a7d1718498 100644
--- a/src/mir_app/src/menu_clist.cpp
+++ b/src/mir_app/src/menu_clist.cpp
@@ -766,9 +766,9 @@ int fnGetProtoIndexByPos(PROTOCOLDESCRIPTOR **proto, int protoCnt, int Pos)
int fnGetAccountIndexByPos(int Pos)
{
- for (int i = 0; i < accounts.getCount(); i++)
- if (accounts[i]->iOrder == Pos)
- return i;
+ for (auto &it : accounts)
+ if (it->iOrder == Pos)
+ return accounts.indexOf(&it);
return -1;
}
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index 9f22ad933b..64f76962bb 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -393,8 +393,8 @@ void UnloadNetlibModule(void)
DestroyHookableEvent(hRecvEvent); hRecvEvent = nullptr;
DestroyHookableEvent(hSendEvent); hSendEvent = nullptr;
- for (int i = netlibUser.getCount(); i > 0; i--)
- Netlib_CloseHandle(netlibUser[i-1]);
+ for (auto &it : netlibUser.rev_iter())
+ Netlib_CloseHandle(it);
CloseHandle(hConnectionHeaderMutex);
if (hConnectionOpenMutex)
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp
index 6bb9fc32a3..391fb5e38f 100644
--- a/src/mir_app/src/netliblog.cpp
+++ b/src/mir_app/src/netliblog.cpp
@@ -127,10 +127,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE;
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- for (int i = 0; i < netlibUser.getCount(); i++) {
- tvis.item.pszText = netlibUser[i]->user.szDescriptiveName.w;
- tvis.item.lParam = i;
- tvis.item.state = INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1);
+ for (auto &it : netlibUser) {
+ tvis.item.pszText = it->user.szDescriptiveName.w;
+ tvis.item.lParam = netlibUser.indexOf(&it);
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(it->toLog ? 2 : 1);
TreeView_InsertItem(hwndFilter, &tvis);
}
tvis.item.lParam = -1;
diff --git a/src/mir_app/src/netlibopts.cpp b/src/mir_app/src/netlibopts.cpp
index a9aef9ae86..2672778a9b 100644
--- a/src/mir_app/src/netlibopts.cpp
+++ b/src/mir_app/src/netlibopts.cpp
@@ -262,20 +262,19 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
int iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)TranslateT("<All connections>"));
SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, (LPARAM)-1);
SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETCURSEL, iItem, 0);
- {
- mir_cslock lck(csNetlibUser);
- for (int i = 0; i < netlibUser.getCount(); ++i) {
- NetlibTempSettings *thisSettings = (NetlibTempSettings*)mir_calloc(sizeof(NetlibTempSettings));
- thisSettings->flags = netlibUser[i]->user.flags;
- thisSettings->szSettingsModule = mir_strdup(netlibUser[i]->user.szSettingsModule);
- CopySettingsStruct(&thisSettings->settings, &netlibUser[i]->settings);
- tempSettings.insert(thisSettings);
-
- if (netlibUser[i]->user.flags & NUF_NOOPTIONS)
- continue;
- iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)netlibUser[i]->user.szDescriptiveName.w);
- SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, i);
- }
+
+ mir_cslock lck(csNetlibUser);
+ for (auto &it : netlibUser) {
+ NetlibTempSettings *thisSettings = (NetlibTempSettings*)mir_calloc(sizeof(NetlibTempSettings));
+ thisSettings->flags = it->user.flags;
+ thisSettings->szSettingsModule = mir_strdup(it->user.szSettingsModule);
+ CopySettingsStruct(&thisSettings->settings, &it->settings);
+ tempSettings.insert(thisSettings);
+
+ if (it->user.flags & NUF_NOOPTIONS)
+ continue;
+ iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)it->user.szDescriptiveName.w);
+ SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, netlibUser.indexOf(&it));
}
}
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp
index ad7876ecca..9280d29cd6 100644
--- a/src/mir_app/src/options.cpp
+++ b/src/mir_app/src/options.cpp
@@ -582,7 +582,9 @@ class COptionsDlg : public CDlgBase
else {
tvi.hItem = FindNamedTreeItem(nullptr, useTitle);
if (tvi.hItem != nullptr) {
- if (i == m_currentPage) m_hCurrentPage = tvi.hItem;
+ if (i == m_currentPage)
+ m_hCurrentPage = tvi.hItem;
+
tvi.mask = TVIF_PARAM;
m_pageTree.GetItem(&tvi);
if (tvi.lParam == -1) {
@@ -754,17 +756,16 @@ public:
else
lastTab = mir_wstrdup(m_szTab);
- for (int i = 0; i < m_pages.getCount(); i++) {
- const OPTIONSDIALOGPAGE &odp = m_pages[i];
- OptionsPageData *opd = new OptionsPageData(odp);
+ for (auto &it : m_pages) {
+ OptionsPageData *opd = new OptionsPageData(*it);
if (opd->pDialog == nullptr) // smth went wrong
delete opd;
else
m_arOpd.insert(opd);
- if (!mir_wstrcmp(lastPage, odp.szTitle.w) && !mir_wstrcmp(lastGroup, odp.szGroup.w))
- if ((m_szTab == nullptr && m_currentPage == -1) || !mir_wstrcmp(lastTab, odp.szTab.w))
- m_currentPage = i;
+ if (!mir_wstrcmp(lastPage, it->szTitle.w) && !mir_wstrcmp(lastGroup, it->szGroup.w))
+ if ((m_szTab == nullptr && m_currentPage == -1) || !mir_wstrcmp(lastTab, it->szTab.w))
+ m_currentPage = m_pages.indexOf(&it);
}
GetWindowRect(GetDlgItem(m_hwnd, IDC_STNOPAGE), &m_rcDisplay);
@@ -839,8 +840,7 @@ public:
PSHNOTIFY pshn = {};
pshn.hdr.code = PSN_APPLY;
- for (int i = 0; i < m_arOpd.getCount(); i++) {
- OptionsPageData *p = m_arOpd[i];
+ for (auto &p : m_arOpd) {
if (p->getHwnd() == nullptr || !p->changed)
continue;
@@ -852,7 +852,7 @@ public:
m_pageTree.SelectItem(m_hCurrentPage);
if (opd)
opd->pDialog->Hide();
- m_currentPage = i;
+ m_currentPage = m_arOpd.indexOf(&p);
if (opd)
opd->pDialog->Show();
return;
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp
index 0855cdc8e3..6bfb1df0a9 100644
--- a/src/mir_app/src/proto_chains.cpp
+++ b/src/mir_app/src/proto_chains.cpp
@@ -170,9 +170,9 @@ MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char *szProto)
if (!_stricmp(szProto, szContactProto))
return -1;
- for (int i = 0; i < filters.getCount(); i++)
- if (!mir_strcmp(szProto, filters[i]->szName))
- return i + 1;
+ for (auto &it : filters)
+ if (!mir_strcmp(szProto, it->szName))
+ return filters.indexOf(&it) + 1;
return 0;
}
diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp
index b35c115385..020f5e9d4c 100644
--- a/src/mir_app/src/proto_order.cpp
+++ b/src/mir_app/src/proto_order.cpp
@@ -42,26 +42,30 @@ int isProtoSuitable(PROTO_INTERFACE* ppi)
bool CheckProtocolOrder(void)
{
bool changed = false;
- int i, id = 0;
+ int id = 0;
for (;;) {
// Find account with this id
- for (i = 0; i < accounts.getCount(); i++)
- if (accounts[i]->iOrder == id)
+ bool bFound = false;
+ for (auto &pa : accounts)
+ if (pa->iOrder == id) {
+ bFound = true;
break;
+ }
// Account with id not found
- if (i == accounts.getCount()) {
+ if (!bFound) {
// Check if this is skipped id, if it is decrement all other ids
- bool found = false;
for (auto &pa : accounts) {
if (pa->iOrder < 1000000 && pa->iOrder > id) {
--pa->iOrder;
- found = true;
+ bFound = true;
}
}
- if (found) changed = true;
- else break;
+ if (!bFound)
+ break;
+
+ changed = true;
}
else id++;
}
@@ -77,7 +81,7 @@ bool CheckProtocolOrder(void)
if (id < accounts.getCount()) {
// Remove duplicate ids
- for (i = 0; i < accounts.getCount(); i++) {
+ for (int i = 0; i < accounts.getCount(); i++) {
bool found = false;
for (int j = 0; j < accounts.getCount(); j++) {
if (accounts[j]->iOrder == i) {
diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp
index a3c9b06e19..b1401cc07f 100644
--- a/src/mir_app/src/skin2opts.cpp
+++ b/src/mir_app/src/skin2opts.cpp
@@ -783,15 +783,14 @@ public:
{
mir_cslock lck(csIconList);
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IcolibItem *item = iconList[indx];
+ for (auto &item : iconList) {
if (item->section == sectionActive) {
lvi.pszText = item->getDescr();
HICON hIcon = item->temp_icon;
if (!hIcon)
hIcon = IconItem_GetIcon_Preview(item);
lvi.iImage = ImageList_AddIcon(hIml, hIcon);
- lvi.lParam = indx;
+ lvi.lParam = iconList.indexOf(&item);
m_preview.InsertItem(&lvi);
if (hIcon != item->temp_icon)
SafeDestroyIcon(hIcon);
diff --git a/src/mir_core/src/timezones.cpp b/src/mir_core/src/timezones.cpp
index a4e74b1eb0..a6b972ae38 100644
--- a/src/mir_core/src/timezones.cpp
+++ b/src/mir_core/src/timezones.cpp
@@ -400,15 +400,16 @@ MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HW
if (lstMsg == nullptr)
return -1;
- if (szModule == nullptr) szModule = "UserInfo";
+ if (szModule == nullptr)
+ szModule = "UserInfo";
int iSelection = 0;
ptrW tszName(db_get_wsa(hContact, szModule, "TzName"));
if (tszName != NULL) {
unsigned hash = mir_hashstrT(tszName);
- for (int i = 0; i < g_timezonesBias.getCount(); i++) {
- if (hash == g_timezonesBias[i]->hash) {
- iSelection = i + 1;
+ for (auto &it : g_timezonesBias) {
+ if (hash == it->hash) {
+ iSelection = g_timezonesBias.indexOf(&it) + 1;
break;
}
}
@@ -417,9 +418,9 @@ MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HW
signed char cBias = db_get_b(hContact, szModule, "Timezone", -100);
if (cBias != -100) {
int iBias = cBias * 30;
- for (int i = 0; i < g_timezonesBias.getCount(); i++) {
- if (iBias == g_timezonesBias[i]->tzi.Bias) {
- iSelection = i + 1;
+ for (auto &it : g_timezonesBias) {
+ if (iBias == it->tzi.Bias) {
+ iSelection = g_timezonesBias.indexOf(&it) + 1;
break;
}
}
@@ -438,11 +439,9 @@ MIR_CORE_DLL(int) TimeZone_PrepareList(MCONTACT hContact, LPCSTR szModule, HWND
SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)TranslateT("<unspecified>"));
- for (int i = 0; i < g_timezonesBias.getCount(); i++) {
- MIM_TIMEZONE *tz = g_timezonesBias[i];
-
- SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)tz->szDisplay);
- SendMessage(hWnd, lstMsg->setData, i + 1, (LPARAM)tz);
+ for (auto &it : g_timezonesBias) {
+ SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)it->szDisplay);
+ SendMessage(hWnd, lstMsg->setData, g_timezonesBias.indexOf(&it) + 1, (LPARAM)it);
}
return TimeZone_SelectListItem(hContact, szModule, hWnd, dwFlags);