diff options
Diffstat (limited to 'src')
48 files changed, 508 insertions, 666 deletions
diff --git a/src/mir_app/src/ExtraIconGroup.cpp b/src/mir_app/src/ExtraIconGroup.cpp index c9e39e35ef..7911a50797 100644 --- a/src/mir_app/src/ExtraIconGroup.cpp +++ b/src/mir_app/src/ExtraIconGroup.cpp @@ -39,10 +39,10 @@ void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra) m_items.insert(extra);
CMStringW description;
- for (int i = 0; i < m_items.getCount(); i++) {
- if (i > 0)
- description += L" / ";
- description += m_items[i]->getDescription();
+ for (auto &p : m_items) {
+ if (!description.IsEmpty())
+ description.Append(L" / ");
+ description += p->getDescription();
}
m_tszDescription = mir_wstrdup(description);
@@ -50,8 +50,8 @@ void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra) void ExtraIconGroup::rebuildIcons()
{
- for (int i = 0; i < m_items.getCount(); i++)
- m_items[i]->rebuildIcons();
+ for (auto &p : m_items)
+ p->rebuildIcons();
}
void ExtraIconGroup::applyIcon(MCONTACT hContact)
@@ -77,8 +77,8 @@ void ExtraIconGroup::applyIcon(MCONTACT hContact) int ExtraIconGroup::getPosition() const
{
int pos = INT_MAX;
- for (int i = 0; i < m_items.getCount(); i++)
- pos = min(pos, m_items[i]->getPosition());
+ for (auto &p : m_items)
+ pos = min(pos, p->getPosition());
return pos;
}
@@ -86,8 +86,8 @@ void ExtraIconGroup::setSlot(int slot) {
ExtraIcon::setSlot(slot);
- for (int i = 0; i < m_items.getCount(); i++)
- m_items[i]->setSlot(slot);
+ for (auto &p : m_items)
+ p->setSlot(slot);
}
ExtraIcon * ExtraIconGroup::getCurrentItem(MCONTACT hContact) const
@@ -96,9 +96,9 @@ ExtraIcon * ExtraIconGroup::getCurrentItem(MCONTACT hContact) const if (id < 1)
return nullptr;
- for (int i = 0; i < m_items.getCount(); i++)
- if (id == m_items[i]->getID())
- return m_items[i];
+ for (auto &p : m_items)
+ if (id == p->getID())
+ return p;
return nullptr;
}
@@ -123,11 +123,11 @@ int ExtraIconGroup::setIconByName(int id, MCONTACT hContact, const char *value) int ExtraIconGroup::internalSetIcon(int id, MCONTACT hContact, void *value, bool bByName)
{
if (m_insideApply) {
- for (int i = 0; i < m_items.getCount(); i++)
- if (m_items[i]->getID() == id) {
+ for (auto &p : m_items)
+ if (p->getID() == id) {
if (bByName)
- return m_items[i]->setIconByName(id, hContact, (const char*)value);
- return m_items[i]->setIcon(id, hContact, (HANDLE)value);
+ return p->setIconByName(id, hContact, (const char*)value);
+ return p->setIcon(id, hContact, (HANDLE)value);
}
return -1;
@@ -195,9 +195,9 @@ const wchar_t* ExtraIconGroup::getDescription() const const char *ExtraIconGroup::getDescIcon() const
{
- for (int i = 0; i < m_items.getCount(); i++)
- if (!IsEmpty(m_items[i]->getDescIcon()))
- return m_items[i]->getDescIcon();
+ for (auto &p : m_items)
+ if (!IsEmpty(p->getDescIcon()))
+ return p->getDescIcon();
return "";
}
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp index c39ee22ab6..bce42d268c 100644 --- a/src/mir_app/src/FontOptions.cpp +++ b/src/mir_app/src/FontOptions.cpp @@ -144,22 +144,20 @@ static BOOL ExportSettings(HWND hwndDlg, const wchar_t *filename, OBJLIST<FontIn fputs("SETTINGS:\n\n", out);
- for (int i = 0; i < flist.getCount(); i++) {
- FontInternal& F = flist[i];
-
- mir_snprintf(buff, "\n[%s]", F.dbSettingsGroup);
+ for (auto &F : flist) {
+ mir_snprintf(buff, "\n[%s]", F->dbSettingsGroup);
if (mir_strcmp(buff, header) != 0) {
strncpy(header, buff, _countof(header));
WriteLine(out, buff);
}
- fprintf(out, (F.flags & FIDF_APPENDNAME) ? "%sName=s%S\n" : "%s=s%S\n", F.prefix, F.value.szFace);
+ fprintf(out, (F->flags & FIDF_APPENDNAME) ? "%sName=s%S\n" : "%s=s%S\n", F->prefix, F->value.szFace);
int iFontSize;
- if (F.flags & FIDF_SAVEACTUALHEIGHT) {
+ if (F->flags & FIDF_SAVEACTUALHEIGHT) {
SIZE size;
LOGFONT lf;
- CreateFromFontSettings(&F.value, &lf);
+ CreateFromFontSettings(&F->value, &lf);
HFONT hFont = CreateFontIndirect(&lf);
HDC hdc = GetDC(hwndDlg);
@@ -171,48 +169,44 @@ static BOOL ExportSettings(HWND hwndDlg, const wchar_t *filename, OBJLIST<FontIn iFontSize = size.cy;
}
- else if (F.flags & FIDF_SAVEPOINTSIZE) {
+ else if (F->flags & FIDF_SAVEPOINTSIZE) {
HDC hdc = GetDC(hwndDlg);
- iFontSize = (BYTE)-MulDiv(F.value.size, 72, GetDeviceCaps(hdc, LOGPIXELSY));
+ iFontSize = (BYTE)-MulDiv(F->value.size, 72, GetDeviceCaps(hdc, LOGPIXELSY));
ReleaseDC(hwndDlg, hdc);
}
- else iFontSize = F.value.size;
- fprintf(out, "%sSize=b%d\n", F.prefix, iFontSize);
+ else iFontSize = F->value.size;
+ fprintf(out, "%sSize=b%d\n", F->prefix, iFontSize);
- fprintf(out, "%sSty=b%d\n", F.prefix, F.value.style);
- fprintf(out, "%sSet=b%d\n", F.prefix, F.value.charset);
- fprintf(out, "%sCol=d%d\n", F.prefix, F.value.colour);
+ fprintf(out, "%sSty=b%d\n", F->prefix, F->value.style);
+ fprintf(out, "%sSet=b%d\n", F->prefix, F->value.charset);
+ fprintf(out, "%sCol=d%d\n", F->prefix, F->value.colour);
- if (F.flags & FIDF_NOAS)
- fprintf(out, "%sAs=w%d\n", F.prefix, 0x00FF);
+ if (F->flags & FIDF_NOAS)
+ fprintf(out, "%sAs=w%d\n", F->prefix, 0x00FF);
- fprintf(out, "%sFlags=w%d\n", F.prefix, F.flags);
+ fprintf(out, "%sFlags=w%d\n", F->prefix, F->flags);
}
header[0] = 0;
- for (int i = 0; i < clist.getCount(); i++) {
- ColourInternal& C = clist[i];
-
- mir_snprintf(buff, "\n[%s]", C.dbSettingsGroup);
+ for (auto &C : clist) {
+ mir_snprintf(buff, "\n[%s]", C->dbSettingsGroup);
if (mir_strcmp(buff, header) != 0) {
strncpy_s(header, buff, _TRUNCATE);
WriteLine(out, buff);
}
- fprintf(out, "%s=d%d\n", C.setting, (DWORD)C.value);
+ fprintf(out, "%s=d%d\n", C->setting, (DWORD)C->value);
}
header[0] = 0;
- for (int i = 0; i < elist.getCount(); i++) {
- EffectInternal& E = elist[i];
-
- mir_snprintf(buff, "\n[%s]", E.dbSettingsGroup);
+ for (auto &E : elist) {
+ mir_snprintf(buff, "\n[%s]", E->dbSettingsGroup);
if (mir_strcmp(buff, header) != 0) {
strncpy_s(header, buff, _TRUNCATE);
WriteLine(out, buff);
}
- fprintf(out, "%sEffect=b%d\n", E.setting, E.value.effectIndex);
- fprintf(out, "%sEffectCol1=d%d\n", E.setting, E.value.baseColour);
- fprintf(out, "%sEffectCol2=d%d\n", E.setting, E.value.secondaryColour);
+ fprintf(out, "%sEffect=b%d\n", E->setting, E->value.effectIndex);
+ fprintf(out, "%sEffectCol1=d%d\n", E->setting, E->value.baseColour);
+ fprintf(out, "%sEffectCol2=d%d\n", E->setting, E->value.secondaryColour);
}
fclose(out);
@@ -566,27 +560,22 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, effect_id_list_w2 = effect_id_list;
effect_id_list_w3 = effect_id_list;
- for (int i = 0; i < font_id_list_w2.getCount(); i++) {
- FontInternal& F = font_id_list_w2[i];
+ for (auto &F : font_id_list_w2) {
// sync settings with database
- UpdateFontSettings(&F, &F.value);
- sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), F.group, F.hLangpack);
+ UpdateFontSettings(F, &F->value);
+ sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), F->group, F->hLangpack);
}
- for (int i = 0; i < colour_id_list_w2.getCount(); i++) {
- ColourInternal& C = colour_id_list_w2[i];
-
+ for (auto &C : colour_id_list_w2) {
// sync settings with database
- UpdateColourSettings(&C, &C.value);
- sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), C.group, C.hLangpack);
+ UpdateColourSettings(C, &C->value);
+ sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), C->group, C->hLangpack);
}
- for (int i = 0; i < effect_id_list_w2.getCount(); i++) {
- EffectInternal& E = effect_id_list_w2[i];
-
+ for (auto &E : effect_id_list_w2) {
// sync settings with database
- UpdateEffectSettings(&E, &E.value);
- sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), E.group, E.hLangpack);
+ UpdateEffectSettings(E, &E->value);
+ sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), E->group, E->hLangpack);
}
SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETDEFAULTCOLOUR, 0, (LPARAM)GetSysColor(COLOR_WINDOW));
@@ -1121,29 +1110,21 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, colour_id_list = colour_id_list_w2;
effect_id_list = effect_id_list_w2;
- for (int i = 0; i < font_id_list_w2.getCount(); i++) {
- FontInternal& F = font_id_list_w2[i];
- sttSaveFontData(hwndDlg, F);
- }
-
- for (int i = 0; i < colour_id_list_w2.getCount(); i++) {
- ColourInternal& C = colour_id_list_w2[i];
+ for (auto &F : font_id_list_w2)
+ sttSaveFontData(hwndDlg, *F);
- strncpy_s(str, C.setting, _TRUNCATE);
- db_set_dw(0, C.dbSettingsGroup, str, C.value);
- }
+ for (auto &C : colour_id_list_w2)
+ db_set_dw(0, C->dbSettingsGroup, C->setting, C->value);
- for (int i = 0; i < effect_id_list_w2.getCount(); i++) {
- EffectInternal& E = effect_id_list_w2[i];
+ for (auto &E : effect_id_list_w2) {
+ mir_snprintf(str, "%sEffect", E->setting);
+ db_set_b(0, E->dbSettingsGroup, str, E->value.effectIndex);
- mir_snprintf(str, "%sEffect", E.setting);
- db_set_b(0, E.dbSettingsGroup, str, E.value.effectIndex);
+ mir_snprintf(str, "%sEffectCol1", E->setting);
+ db_set_dw(0, E->dbSettingsGroup, str, E->value.baseColour);
- mir_snprintf(str, "%sEffectCol1", E.setting);
- db_set_dw(0, E.dbSettingsGroup, str, E.value.baseColour);
-
- mir_snprintf(str, "%sEffectCol2", E.setting);
- db_set_dw(0, E.dbSettingsGroup, str, E.value.secondaryColour);
+ mir_snprintf(str, "%sEffectCol2", E->setting);
+ db_set_dw(0, E->dbSettingsGroup, str, E->value.secondaryColour);
}
OptionsChanged();
@@ -1202,11 +1183,9 @@ int OptInit(WPARAM wParam, LPARAM) static FontInternal* sttFindFont(OBJLIST<FontInternal> &fonts, char *module, char *prefix)
{
- for (int i = 0; i < fonts.getCount(); i++) {
- FontInternal& F = fonts[i];
- if (!mir_strcmp(F.dbSettingsGroup, module) && !mir_strcmp(F.prefix, prefix))
- return &F;
- }
+ for (auto &F : fonts)
+ if (!mir_strcmp(F->dbSettingsGroup, module) && !mir_strcmp(F->prefix, prefix))
+ return F;
return nullptr;
}
diff --git a/src/mir_app/src/FontService.cpp b/src/mir_app/src/FontService.cpp index 525be5e4a7..b30cfa7344 100644 --- a/src/mir_app/src/FontService.cpp +++ b/src/mir_app/src/FontService.cpp @@ -243,11 +243,9 @@ static int sttRegisterFontWorker(FontIDW *font_id, int _hLang) if (font_id->cbSize != sizeof(FontIDW))
return -1;
- for (int i = 0; i < font_id_list.getCount(); i++) {
- FontInternal& F = font_id_list[i];
- if (!mir_wstrcmp(F.group, font_id->group) && !mir_wstrcmp(F.name, font_id->name) && !(F.flags & FIDF_ALLOWREREGISTER))
+ for (auto &F : font_id_list)
+ if (!mir_wstrcmp(F->group, font_id->group) && !mir_wstrcmp(F->name, font_id->name) && !(F->flags & FIDF_ALLOWREREGISTER))
return 1;
- }
char idstr[256];
mir_snprintf(idstr, "%sFlags", font_id->prefix);
@@ -290,12 +288,11 @@ static COLORREF sttGetFontWorker(const wchar_t *wszGroup, const wchar_t *wszName {
COLORREF colour;
- for (int i = 0; i < font_id_list.getCount(); i++) {
- FontInternal& F = font_id_list[i];
- if (!wcsncmp(F.name, wszName, _countof(F.name)) && !wcsncmp(F.group, wszGroup, _countof(F.group))) {
- if (GetFontSettingFromDB(F.dbSettingsGroup, F.prefix, lf, &colour, F.flags) && (F.flags & FIDF_DEFAULTVALID)) {
- CreateFromFontSettings(&F.deffontsettings, lf);
- colour = F.deffontsettings.colour;
+ for (auto &F : font_id_list) {
+ if (!wcsncmp(F->name, wszName, _countof(F->name)) && !wcsncmp(F->group, wszGroup, _countof(F->group))) {
+ if (GetFontSettingFromDB(F->dbSettingsGroup, F->prefix, lf, &colour, F->flags) && (F->flags & FIDF_DEFAULTVALID)) {
+ CreateFromFontSettings(&F->deffontsettings, lf);
+ colour = F->deffontsettings.colour;
}
return colour;
@@ -347,11 +344,9 @@ static INT_PTR sttRegisterColourWorker(ColourIDW *colour_id, int _hLang) if (colour_id->cbSize != sizeof(ColourIDW))
return -1;
- for (int i = 0; i < colour_id_list.getCount(); i++) {
- ColourInternal& C = colour_id_list[i];
- if (!mir_wstrcmp(C.group, colour_id->group) && !mir_wstrcmp(C.name, colour_id->name))
+ for (auto &C : colour_id_list)
+ if (!mir_wstrcmp(C->group, colour_id->group) && !mir_wstrcmp(C->name, colour_id->name))
return 1;
- }
ColourInternal* newItem = new ColourInternal;
memset(newItem, 0, sizeof(ColourInternal));
@@ -379,11 +374,9 @@ MIR_APP_DLL(int) Colour_Register(ColourID *pFont, int _hLang) static INT_PTR sttGetColourWorker(const wchar_t *wszGroup, const wchar_t *wszName)
{
- for (int i = 0; i < colour_id_list.getCount(); i++) {
- ColourInternal& C = colour_id_list[i];
- if (!mir_wstrcmp(C.group, wszGroup) && !mir_wstrcmp(C.name, wszName))
- return db_get_dw(0, C.dbSettingsGroup, C.setting, C.defcolour);
- }
+ for (auto &C : colour_id_list)
+ if (!mir_wstrcmp(C->group, wszGroup) && !mir_wstrcmp(C->name, wszName))
+ return db_get_dw(0, C->dbSettingsGroup, C->setting, C->defcolour);
return -1;
}
@@ -437,11 +430,9 @@ static int sttRegisterEffectWorker(EffectIDW *effect_id, int _hLang) if (effect_id->cbSize != sizeof(EffectIDW))
return -1;
- for (int i = 0; i < effect_id_list.getCount(); i++) {
- EffectInternal& E = effect_id_list[i];
- if (!mir_wstrcmp(E.group, effect_id->group) && !mir_wstrcmp(E.name, effect_id->name))
+ for (auto &E : effect_id_list)
+ if (!mir_wstrcmp(E->group, effect_id->group) && !mir_wstrcmp(E->name, effect_id->name))
return 1;
- }
EffectInternal* newItem = new EffectInternal;
memset(newItem, 0, sizeof(EffectInternal));
@@ -469,10 +460,9 @@ MIR_APP_DLL(int) Effect_Register(EffectID *pFont, int _hLang) static INT_PTR sttGetEffectWorker(const wchar_t *wszGroup, const wchar_t *wszName, FONTEFFECT *effect)
{
- for (int i = 0; i < effect_id_list.getCount(); i++) {
- EffectInternal& E = effect_id_list[i];
- if (!wcsncmp(E.name, wszName, _countof(E.name)) && !wcsncmp(E.group, wszGroup, _countof(E.group))) {
- UpdateEffectSettings(&E, effect);
+ for (auto &E : effect_id_list) {
+ if (!wcsncmp(E->name, wszName, _countof(E->name)) && !wcsncmp(E->group, wszGroup, _countof(E->group))) {
+ UpdateEffectSettings(E, effect);
return TRUE;
}
}
diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp index 61b32afc13..bfab4d2793 100644 --- a/src/mir_app/src/MDatabaseCommon.cpp +++ b/src/mir_app/src/MDatabaseCommon.cpp @@ -287,8 +287,8 @@ STDMETHODIMP_(BOOL) MDatabaseCommon::FreeVariant(DBVARIANT *dbv) STDMETHODIMP_(BOOL) MDatabaseCommon::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam) { - for (int i = 0; i < m_lResidentSettings.getCount(); i++) { - int ret = pFunc(m_lResidentSettings[i], pParam); + for (auto &it : m_lResidentSettings) { + int ret = pFunc(it, pParam); if (ret) return ret; } diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index dc004cdc25..64e206bcc6 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -165,10 +165,9 @@ BOOL SM_SetOffline(const char *pszModule, SESSION_INFO *si) if (pszModule == nullptr)
return FALSE;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- si = g_arSessions[i];
- if (!_strcmpi(si->pszModule, pszModule))
- SM_SetOffline(pszModule, si);
+ for (auto &p : g_arSessions) {
+ if (!_strcmpi(p->pszModule, pszModule))
+ SM_SetOffline(pszModule, p);
}
return TRUE;
}
@@ -244,8 +243,7 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (!pszModule || !pszUID)
return FALSE;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
continue;
@@ -323,8 +321,7 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
{
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if (pszModule && _strcmpi(si->pszModule, pszModule))
continue;
@@ -344,10 +341,9 @@ BOOL SM_SetStatus(const char *pszModule, SESSION_INFO *si, int wStatus) if (pszModule == nullptr)
return FALSE;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- si = g_arSessions[i];
- if (!_strcmpi(si->pszModule, pszModule))
- SM_SetStatus(pszModule, si, wStatus);
+ for (auto &p : g_arSessions) {
+ if (!_strcmpi(p->pszModule, pszModule))
+ SM_SetStatus(pszModule, p, wStatus);
}
return TRUE;
}
@@ -371,8 +367,7 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce) if (!pszModule)
return FALSE;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if ((!pszID || !mir_wstrcmpi(si->ptszID, pszID)) && !mir_strcmpi(si->pszModule, pszModule)) {
USERINFO *ui = chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
if (ui) {
@@ -473,11 +468,9 @@ static int SM_GetCount(const char *pszModule) {
int count = 0;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions)
if (!mir_strcmpi(pszModule, si->pszModule))
count++;
- }
return count;
}
@@ -485,8 +478,7 @@ static int SM_GetCount(const char *pszModule) static SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem)
{
int count = 0;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if (!mir_strcmpi(pszModule, si->pszModule)) {
if (iItem == count)
return si;
@@ -504,8 +496,7 @@ char* SM_GetUsers(SESSION_INFO *si) return nullptr;
USERINFO *utemp = nullptr;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *p = g_arSessions[i];
+ for (auto &p : g_arSessions) {
if (si == p) {
if ((utemp = p->pUsers) == nullptr)
return nullptr;
@@ -533,10 +524,8 @@ char* SM_GetUsers(SESSION_INFO *si) static void SM_InvalidateLogDirectories()
{
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions)
si->pszLogFileName[0] = si->pszLogFileName[1] = 0;
- }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -564,19 +553,15 @@ static void MM_IconsChanged() {
LoadChatIcons();
- for (int i = 0; i < g_arModules.getCount(); i++) {
- MODULEINFO *mi = g_arModules[i];
+ for (auto &mi : g_arModules)
if (chatApi.OnCreateModule) // recreate icons
chatApi.OnCreateModule(mi);
- }
}
static void MM_FontsChanged()
{
- for (int i = 0; i < g_arModules.getCount(); i++) {
- MODULEINFO *mi = g_arModules[i];
+ for (auto &mi : g_arModules)
mi->pszHeader = chatApi.Log_CreateRtfHeader();
- }
}
static MODULEINFO* MM_FindModule(const char *pszModule)
@@ -589,8 +574,7 @@ static MODULEINFO* MM_FindModule(const char *pszModule) static BOOL MM_RemoveAll(void)
{
- for (int i = 0; i < g_arModules.getCount(); i++) {
- MODULEINFO *mi = g_arModules[i];
+ for (auto &mi : g_arModules) {
if (chatApi.OnDestroyModule)
chatApi.OnDestroyModule(mi);
@@ -1003,12 +987,11 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ if (g_cbSession) { // reallocate old sessions
mir_cslock lck(csChat);
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *p = g_arSessions[i];
+ for (auto &p : g_arSessions) {
SESSION_INFO *p1 = (SESSION_INFO*)mir_realloc(p, pInit->cbSession);
memset(PBYTE(p1) + sizeof(GCSessionInfoBase), 0, pInit->cbSession - sizeof(GCSessionInfoBase));
if (p1 != p) { // realloc could change a pointer, reinsert a structure
- g_arSessions.remove(i);
+ g_arSessions.remove(p);
g_arSessions.insert(p1);
}
}
@@ -1016,13 +999,12 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ if (g_cbModuleInfo) { // reallocate old modules
mir_cslock lck(csChat);
- for (int i = 0; i < g_arModules.getCount(); i++) {
- MODULEINFO *mi = g_arModules[i];
+ for (auto &mi : g_arModules) {
MODULEINFO *p1 = (MODULEINFO*)mir_realloc(mi, pInit->cbModuleInfo);
memset(PBYTE(p1) + sizeof(GCModuleInfoBase), 0, pInit->cbModuleInfo - sizeof(GCModuleInfoBase));
if (p1 != mi) { // realloc could change a pointer, reinsert a structure
- g_arModules.remove(i);
- g_arModules.insert(p1, i);
+ g_arModules.remove(mi);
+ g_arModules.insert(p1);
}
}
}
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index b2b1e9d7fb..7b70998612 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -116,11 +116,10 @@ static int PreShutdown(WPARAM, LPARAM) static int SmileyOptionsChanged(WPARAM, LPARAM)
{
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions)
if (si->pDlg)
si->pDlg->RedrawLog();
- }
+
return 0;
}
@@ -397,8 +396,7 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) {
int bManyFix = 0;
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if (!si->bInitDone || mir_strcmpi(si->pszModule, gce->pszModule))
continue;
@@ -632,8 +630,7 @@ MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, c return GC_EVENT_ERROR;
mir_cslock lck(csChat);
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
@@ -660,8 +657,7 @@ MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId return GC_EVENT_ERROR;
mir_cslock lck(csChat);
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
@@ -699,8 +695,7 @@ MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, in return GC_EVENT_ERROR;
mir_cslock lck(csChat);
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions) {
if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
@@ -725,11 +720,9 @@ MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, vo EXTERN_C MIR_APP_DLL(void) Chat_UpdateOptions()
{
- for (int i = 0; i < g_arSessions.getCount(); i++) {
- SESSION_INFO *si = g_arSessions[i];
+ for (auto &si : g_arSessions)
if (si->pDlg)
si->pDlg->UpdateOptions();
- }
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 32f040edfb..3af1660df8 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -126,18 +126,19 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam) static int ClcAccountsChanged(WPARAM, LPARAM)
{
- int i, cnt;
- for (i = 0, cnt = 0; i < accounts.getCount(); i++)
- if (Proto_IsAccountEnabled(accounts[i]))
+ int cnt = 0;
+ for (auto &pa : accounts)
+ if (Proto_IsAccountEnabled(pa))
cnt++;
cli.hClcProtoCount = cnt;
cli.clcProto = (ClcProtoStatus *)mir_realloc(cli.clcProto, sizeof(ClcProtoStatus) * cli.hClcProtoCount);
- for (i = 0, cnt = 0; i < accounts.getCount(); i++) {
- if (Proto_IsAccountEnabled(accounts[i])) {
- cli.clcProto[cnt].szProto = accounts[i]->szModuleName;
- cli.clcProto[cnt].dwStatus = CallProtoServiceInt(0, accounts[i]->szModuleName, PS_GETSTATUS, 0, 0);
+ cnt = 0;
+ for (auto &pa : accounts) {
+ if (Proto_IsAccountEnabled(pa)) {
+ cli.clcProto[cnt].szProto = pa->szModuleName;
+ cli.clcProto[cnt].dwStatus = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0);
++cnt;
}
}
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 8cceb62922..268135e832 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -129,9 +129,9 @@ void fnFreeGroup(ClcGroup *group) if (!group) return; - for (int i = 0; i < group->cl.getCount(); i++) { - cli.pfnFreeContact(group->cl[i]); - mir_free(group->cl[i]); + for (auto &it : group->cl) { + cli.pfnFreeContact(it); + mir_free(it); } group->cl.destroy(); } @@ -291,9 +291,9 @@ ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, group->cl.remove(iContact); if ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) && group->cl.getCount() == 0 && group->parent != nullptr) - for (int i = 0; i < group->parent->cl.getCount(); i++) - if (group->parent->cl[i]->type == CLCIT_GROUP && group->parent->cl[i]->groupId == group->groupId) - return cli.pfnRemoveItemFromGroup(hwnd, group->parent, group->parent->cl[i], 0); + for (auto &cc : group->parent->cl) + if (cc->type == CLCIT_GROUP && cc->groupId == group->groupId) + return cli.pfnRemoveItemFromGroup(hwnd, group->parent, cc, 0); return group; } @@ -697,18 +697,18 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) group->scanIndex++; } - for (int i = 0; i < saveInfo.getCount(); i++) { - if (saveInfo[i].parentId == -1) + for (auto &it : saveInfo) { + if (it->parentId == -1) group = &dat->list; else { ClcContact *contact; - if (!Clist_FindItem(hwnd, dat, saveInfo[i].parentId | HCONTACT_ISGROUP, &contact, nullptr, nullptr)) + if (!Clist_FindItem(hwnd, dat, it->parentId | HCONTACT_ISGROUP, &contact, nullptr, nullptr)) continue; group = contact->group; } - ClcContact *cc = cli.pfnAddInfoItemToGroup(group, saveInfo[i].contact.flags, L""); - *cc = saveInfo[i].contact; + ClcContact *cc = cli.pfnAddInfoItemToGroup(group, it->contact.flags, L""); + *cc = it->contact; } dat->bLockScrollbar = false; diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp index 37518f4f41..cb5c5d863f 100644 --- a/src/mir_app/src/clcutils.cpp +++ b/src/mir_app/src/clcutils.cpp @@ -837,8 +837,7 @@ void fnSetContactCheckboxes(ClcContact *cc, int checked) void fnSetGroupChildCheckboxes(ClcGroup *group, int checked)
{
- for (int i = 0; i < group->cl.getCount(); i++) {
- ClcContact *cc = group->cl[i];
+ for (auto &cc : group->cl) {
if (cc->type == CLCIT_GROUP) {
cli.pfnSetGroupChildCheckboxes(cc->group, checked);
cli.pfnSetContactCheckboxes(cc, checked);
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index b28f020bfd..ecb73ea2eb 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -197,11 +197,11 @@ int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent) // count same protocoled events
int nSameProto = 0;
char *szEventProto;
- for (i = 0; i < g_cliEvents.getCount(); i++) {
- if (g_cliEvents[i].hContact)
- szEventProto = GetContactProto((g_cliEvents[i].hContact));
- else if (g_cliEvents[i].flags & CLEF_PROTOCOLGLOBAL)
- szEventProto = (char*)g_cliEvents[i].lpszProtocol;
+ for (auto &it : g_cliEvents) {
+ if (it->hContact)
+ szEventProto = GetContactProto((it->hContact));
+ else if (it->flags & CLEF_PROTOCOLGLOBAL)
+ szEventProto = (char*)it->lpszProtocol;
else
szEventProto = nullptr;
if (szEventProto && szProto && !mir_strcmp(szEventProto, szProto))
@@ -232,19 +232,20 @@ CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx) return &g_cliEvents[idx];
}
- for (int i=0; i < g_cliEvents.getCount(); i++)
- if (g_cliEvents[i].hContact == hContact)
+ for (auto &it : g_cliEvents)
+ if (it->hContact == hContact)
if (idx-- == 0)
- return &g_cliEvents[i];
+ return it;
+
return nullptr;
}
int fnEventsProcessContactDoubleClick(MCONTACT hContact)
{
- for (int i = 0; i < g_cliEvents.getCount(); i++) {
- if (g_cliEvents[i].hContact == hContact) {
- MEVENT hDbEvent = g_cliEvents[i].hDbEvent;
- CallService(g_cliEvents[i].pszService, 0, (LPARAM)&g_cliEvents[i]);
+ for (auto &it : g_cliEvents) {
+ if (it->hContact == hContact) {
+ MEVENT hDbEvent = it->hDbEvent;
+ CallService(it->pszService, 0, (LPARAM)it);
cli.pfnRemoveEvent(hContact, hDbEvent);
return 0;
}
@@ -274,12 +275,12 @@ int fnEventsProcessTrayDoubleClick(int index) }
}
if (szProto) {
- for (i = 0; i < g_cliEvents.getCount(); i++) {
+ for (auto &it : g_cliEvents) {
char *eventProto = nullptr;
- if (g_cliEvents[i].hContact)
- eventProto = GetContactProto(g_cliEvents[i].hContact);
+ if (it->hContact)
+ eventProto = GetContactProto(it->hContact);
if (!eventProto)
- eventProto = g_cliEvents[i].lpszProtocol;
+ eventProto = it->lpszProtocol;
if (!eventProto || !_strcmpi(eventProto, szProto)) {
eventIndex = i;
@@ -290,12 +291,12 @@ int fnEventsProcessTrayDoubleClick(int index) // let's process backward try to find first event without desired proto in tray
if (i == g_cliEvents.getCount()) {
if (click_in_first_icon) {
- for (i = 0; i < g_cliEvents.getCount(); i++) {
+ for (auto &it : g_cliEvents) {
char *eventProto = nullptr;
- if (g_cliEvents[i].hContact)
- eventProto = GetContactProto(g_cliEvents[i].hContact);
+ if (it->hContact)
+ eventProto = GetContactProto(it->hContact);
if (!eventProto)
- eventProto = g_cliEvents[i].lpszProtocol;
+ eventProto = it->lpszProtocol;
if (!eventProto)
continue;
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp index 5ac69335b3..9dac871611 100644 --- a/src/mir_app/src/clistgroups.cpp +++ b/src/mir_app/src/clistgroups.cpp @@ -531,8 +531,8 @@ int InitGroupServices(void) void UninitGroupServices(void)
{
- for (int i = 0; i < arByIds.getCount(); i++)
- delete arByIds[i];
+ for (auto &p : arByIds)
+ delete p;
arByIds.destroy();
arByName.destroy();
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index 95a9745aed..8362bf71f9 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -142,8 +142,7 @@ HICON fnGetIconFromStatusMode(MCONTACT hContact, const char *szProto, int status int fnIconFromStatusMode(const char *szProto, int status, MCONTACT)
{
- int index, i;
-
+ int index;
for (index = 0; index < _countof(statusModeList); index++)
if (status == statusModeList[index])
break;
@@ -152,10 +151,11 @@ int fnIconFromStatusMode(const char *szProto, int status, MCONTACT) index = 0;
if (szProto == nullptr)
return index + 1;
- for (i = 0; i < protoIconIndex.getCount(); i++) {
- if (mir_strcmp(szProto, protoIconIndex[i].szProto) == 0)
- return protoIconIndex[i].iIconBase + index;
- }
+
+ for (auto &it : protoIconIndex)
+ if (mir_strcmp(szProto, it->szProto) == 0)
+ return it->iIconBase + index;
+
return 1;
}
@@ -192,8 +192,8 @@ static int ContactListModulesLoaded(WPARAM, LPARAM) ScheduleMenuUpdate();
RebuildMenuOrder();
- for (int i = 0; i < accounts.getCount(); i++)
- AddProtoIconIndex(accounts[i]);
+ for (auto &it : accounts)
+ AddProtoIconIndex(it);
cli.pfnLoadContactTree();
@@ -254,9 +254,9 @@ static int CListIconsChanged(WPARAM, LPARAM) ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, Skin_LoadIcon(skinIconStatusList[i]));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT));
- for (int i = 0; i < protoIconIndex.getCount(); i++)
+ for (auto &it : protoIconIndex)
for (int j = 0; j < _countof(statusModeList); j++)
- ImageList_ReplaceIcon_IconLibLoaded(hCListImages, protoIconIndex[i].iIconBase + j, Skin_LoadProtoIcon(protoIconIndex[i].szProto, statusModeList[j]));
+ ImageList_ReplaceIcon_IconLibLoaded(hCListImages, it->iIconBase + j, Skin_LoadProtoIcon(it->szProto, statusModeList[j]));
cli.pfnTrayIconIconsChanged();
cli.pfnInvalidateRect(cli.hwndContactList, nullptr, TRUE);
return 0;
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 3413fdc5f0..975321c410 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -29,9 +29,9 @@ static LIST<ClcCacheEntry> clistCache(50, NumericKeySortT); void FreeDisplayNameCache(void)
{
- for (int i = 0; i < clistCache.getCount(); i++) {
- cli.pfnFreeCacheItem(clistCache[i]);
- mir_free(clistCache[i]);
+ for (auto &it : clistCache) {
+ cli.pfnFreeCacheItem(it);
+ mir_free(it);
}
clistCache.destroy();
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 8300725baa..8ef2039e5f 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -310,8 +310,9 @@ static VOID CALLBACK RefreshTimerProc(HWND, UINT, UINT_PTR, DWORD) KillTimer(nullptr, RefreshTimerId);
RefreshTimerId = 0;
}
- for (int i = 0; i < accounts.getCount(); i++)
- cli.pfnTrayIconUpdateBase(accounts[i]->szModuleName);
+
+ for (auto &it : accounts)
+ cli.pfnTrayIconUpdateBase(it->szModuleName);
}
int fnTrayIconUpdate(HICON hNewIcon, const wchar_t *szNewTip, const char *szPreferredProto, int isBase)
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 503f8b22e8..9e12baa282 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -75,8 +75,8 @@ static int CluiModulesLoaded(WPARAM, LPARAM) // Happens on shutdown and standby.
static void DisconnectAll()
{
- for (int i = 0; i < accounts.getCount(); i++)
- CallProtoServiceInt(0, accounts[i]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
+ for (auto &it : accounts)
+ CallProtoServiceInt(0, it->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
}
static int CluiIconsChanged(WPARAM, LPARAM)
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 056226d1a3..ad96bd3245 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -423,9 +423,7 @@ static int tryCreateDatabase(const wchar_t *ptszProfile) wchar_t *tszProfile = NEWWSTR_ALLOCA(ptszProfile);
CreatePathToFileW(tszProfile);
- for (int i = 0; i < arDbPlugins.getCount(); i++) {
- DATABASELINK* p = arDbPlugins[i];
-
+ for (auto &p : arDbPlugins) {
int err = p->makeDatabase(tszProfile);
if (err == ERROR_SUCCESS) {
g_bDbCreated = true;
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index b0c27fa80b..e0bc764e6e 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -38,8 +38,7 @@ static LIST<DBEVENTTYPEDESCR> eventTypes(10, CompareEventTypes); void UnloadEventsModule()
{
- for (int i = 0; i < eventTypes.getCount(); i++) {
- DBEVENTTYPEDESCR *p = eventTypes[i];
+ for (auto &p : eventTypes) {
mir_free(p->module);
mir_free(p->descr);
mir_free(p->textService);
diff --git a/src/mir_app/src/encrypt.cpp b/src/mir_app/src/encrypt.cpp index 2089902ac7..48464f8258 100644 --- a/src/mir_app/src/encrypt.cpp +++ b/src/mir_app/src/encrypt.cpp @@ -79,8 +79,7 @@ int InitCrypt(void) void UninitCrypt(void)
{
- for (int i = 0; i < arProviders.getCount(); i++) {
- CRYPTO_PROVIDER *p = arProviders[i];
+ for (auto &p : arProviders) {
mir_free(p->pszName);
mir_free(p->pszDescr);
delete p;
diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp index b5793e1756..90cac83a2b 100644 --- a/src/mir_app/src/extraicons.cpp +++ b/src/mir_app/src/extraicons.cpp @@ -103,21 +103,19 @@ ExtraIcon* GetExtraIcon(HANDLE id) ExtraIcon* GetExtraIconBySlot(int slot)
{
- for (int i = 0; i < extraIconsBySlot.getCount(); i++) {
- ExtraIcon *extra = extraIconsBySlot[i];
+ for (auto &extra : extraIconsBySlot)
if (extra->getSlot() == slot)
return extra;
- }
+
return nullptr;
}
BaseExtraIcon* GetExtraIconByName(const char *name)
{
- for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
- BaseExtraIcon *extra = registeredExtraIcons[i];
+ for (auto &extra : registeredExtraIcons)
if (mir_strcmp(name, extra->getName()) == 0)
return extra;
- }
+
return nullptr;
}
@@ -160,13 +158,11 @@ static void LoadGroups(LIST<ExtraIconGroup> &groups) static ExtraIconGroup* IsInGroup(LIST<ExtraIconGroup> &groups, BaseExtraIcon *extra)
{
- for (int i = 0; i < groups.getCount(); i++) {
- ExtraIconGroup *group = groups[i];
- for (int j = 0; j < group->m_items.getCount(); j++) {
+ for (auto &group : groups)
+ for (int j = 0; j < group->m_items.getCount(); j++)
if (extra == group->m_items[j])
return group;
- }
- }
+
return nullptr;
}
@@ -174,30 +170,24 @@ void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups) {
extraIconsByHandle.destroy();
- for (int i = 0; i < registeredExtraIcons.getCount(); i++)
- extraIconsByHandle.insert(registeredExtraIcons[i]);
+ for (auto &it : registeredExtraIcons)
+ extraIconsByHandle.insert(it);
- for (int k = 0; k < extraIconsBySlot.getCount(); k++) {
- ExtraIcon *extra = extraIconsBySlot[k];
+ for (auto &extra : extraIconsBySlot)
if (extra->getType() == EXTRAICON_TYPE_GROUP)
delete extra;
- }
extraIconsBySlot.destroy();
- for (int i = 0; i < groups.getCount(); i++) {
- ExtraIconGroup *group = groups[i];
-
+ for (auto &group : groups) {
for (int j = 0; j < group->m_items.getCount(); j++)
extraIconsByHandle.put(group->m_items[j]->getID() - 1, group);
extraIconsBySlot.insert(group);
}
- for (int k = 0; k < extraIconsByHandle.getCount(); k++) {
- ExtraIcon *extra = extraIconsByHandle[k];
+ for (auto &extra : extraIconsByHandle)
if (extra->getType() != EXTRAICON_TYPE_GROUP)
extraIconsBySlot.insert(extra);
- }
}
///////////////////////////////////////////////////////////////////////////////
@@ -221,8 +211,8 @@ MIR_APP_DLL(void) KillModuleExtraIcons(int _hLang) LoadGroups(groups);
RebuildListsBasedOnGroups(groups);
- for (int k = 0; k < arDeleted.getCount(); k++)
- delete arDeleted[k];
+ for (auto &it : arDeleted)
+ delete it;
}
///////////////////////////////////////////////////////////////////////////////
@@ -233,8 +223,8 @@ int ClistExtraListRebuild(WPARAM, LPARAM) ResetIcons();
- for (int i = 0; i < extraIconsBySlot.getCount(); i++)
- extraIconsBySlot[i]->rebuildIcons();
+ for (auto &it : extraIconsBySlot)
+ it->rebuildIcons();
return 0;
}
@@ -246,8 +236,8 @@ int ClistExtraImageApply(WPARAM hContact, LPARAM) clistApplyAlreadyCalled = TRUE;
- for (int i = 0; i < extraIconsBySlot.getCount(); i++)
- extraIconsBySlot[i]->applyIcon(hContact);
+ for (auto &it : extraIconsBySlot)
+ it->applyIcon(hContact);
return 0;
}
@@ -259,8 +249,7 @@ int ClistExtraClick(WPARAM hContact, LPARAM lParam) int clistSlot = (int)lParam;
- for (int i = 0; i < extraIconsBySlot.getCount(); i++) {
- ExtraIcon *extra = extraIconsBySlot[i];
+ for (auto &extra : extraIconsBySlot) {
if (ConvertToClistSlot(extra->getSlot()) == clistSlot) {
extra->onClick(hContact);
break;
@@ -361,8 +350,8 @@ static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int flags, int if (group != nullptr)
RebuildListsBasedOnGroups(groups);
else {
- for (int i = 0; i < groups.getCount(); i++)
- delete groups[i];
+ for (auto &it : groups)
+ delete it;
extraIconsBySlot.insert(extra);
}
@@ -372,8 +361,7 @@ static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int flags, int extra->rebuildIcons();
slot = 0;
- for (int i = 0; i < extraIconsBySlot.getCount(); i++) {
- ExtraIcon *ex = extraIconsBySlot[i];
+ for (auto &ex : extraIconsBySlot) {
if (ex->getSlot() < 0)
continue;
@@ -523,12 +511,10 @@ void LoadExtraIconsModule() void UnloadExtraIconsModule(void)
{
- for (int k = 0; k < extraIconsBySlot.getCount(); k++) {
- ExtraIcon *extra = extraIconsBySlot[k];
+ for (auto &extra : extraIconsBySlot)
if (extra->getType() == EXTRAICON_TYPE_GROUP)
delete extra;
- }
- for (int i = 0; i < registeredExtraIcons.getCount(); i++)
- delete registeredExtraIcons[i];
+ for (auto &it : registeredExtraIcons)
+ delete it;
}
diff --git a/src/mir_app/src/filter.h b/src/mir_app/src/filter.h index ed160d54f2..8586838ddb 100644 --- a/src/mir_app/src/filter.h +++ b/src/mir_app/src/filter.h @@ -51,8 +51,8 @@ public: CPageKeywords(PageHash pageHashKey) : _pageHashKey(pageHashKey), _pageKeyWords(1, _KeyWordsSortFunc) {};
~CPageKeywords()
{
- for (int j = 0; j < _pageKeyWords.getCount(); j++)
- mir_free(_pageKeyWords[j]);
+ for (auto &it : _pageKeyWords)
+ mir_free(it);
};
void AddKeyWord(wchar_t *ptKeyWord)
@@ -66,8 +66,8 @@ public: BOOL ContainsString(wchar_t *data)
{
- for (int i=0; i < _pageKeyWords.getCount(); i++)
- if (wcsstr(_pageKeyWords[i], data))
+ for (auto &it : _pageKeyWords)
+ if (wcsstr(it, data))
return TRUE;
return FALSE;
}
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index bc1e252a0c..5ec97ddbb6 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -368,12 +368,12 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (tszLast) szProto = NEWWSTR_ALLOCA(tszLast); - int i, index = 0, cbwidth = 0, netProtoCount = 0; - for (i = 0; i < accounts.getCount(); i++) { - if (!Proto_IsAccountEnabled(accounts[i])) + int index = 0, cbwidth = 0, netProtoCount = 0; + for (auto &pa : accounts) { + if (!Proto_IsAccountEnabled(pa)) continue; - DWORD caps = (DWORD)CallProtoServiceInt(0, accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + DWORD caps = (DWORD)CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (caps & PF1_ANYSEARCH) netProtoCount++; } @@ -396,8 +396,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP cbei.iItem++; } - for (i = 0; i < accounts.getCount(); i++) { - PROTOACCOUNT *pa = accounts[i]; + for (auto &pa : accounts) { if (!Proto_IsAccountEnabled(pa)) continue; @@ -473,8 +472,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (szProto == (char *)CB_ERR) break; if (szProto == nullptr) { - for (int i = 0; i < accounts.getCount(); i++) { - PROTOACCOUNT *pa = accounts[i]; + for (auto &pa : accounts) { if (Proto_IsAccountEnabled(pa)) { DWORD protoCaps = (DWORD)CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (protoCaps & PF1_SEARCHBYEMAIL) dat->showEmail = 1; @@ -981,8 +979,7 @@ static INT_PTR FindAddCommand(WPARAM, LPARAM) // One alternative would be to only create the service if we have network // protocols loaded but that would delay the creation until MODULE_LOADED and // that is not good either... - for (int i = 0; i < accounts.getCount(); i++) { - PROTOACCOUNT *pa = accounts[i]; + for (auto &pa : accounts) { if (!Proto_IsAccountEnabled(pa)) continue; @@ -1027,8 +1024,7 @@ static int OnSystemModulesLoaded(WPARAM, LPARAM) int netProtoCount = 0; // Make sure we have some networks to search on. - for (int i = 0; i < accounts.getCount(); i++) { - PROTOACCOUNT *pa = accounts[i]; + for (auto &pa : accounts) { int protoCaps = CallProtoServiceInt(0, pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (protoCaps & PF1_ANYSEARCH) netProtoCount++; diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp index 526e48dc59..1de4e22f38 100644 --- a/src/mir_app/src/hotkey_opts.cpp +++ b/src/mir_app/src/hotkey_opts.cpp @@ -346,7 +346,6 @@ static void sttOptionsSetChanged(THotkeyItem *item) static void sttOptionsSaveItem(THotkeyItem *item) { - int i; char buf[MAXMODULELABELLENGTH]; if (item->rootHotkey) return; @@ -362,16 +361,15 @@ static void sttOptionsSaveItem(THotkeyItem *item) db_set_b(0, DBMODULENAME "Types", item->pszName, (BYTE)item->type); item->nSubHotkeys = 0; - for (i = 0; i < hotkeys.getCount(); i++) { - THotkeyItem *subItem = hotkeys[i]; - if (subItem->rootHotkey == item) { - subItem->Hotkey = subItem->OptHotkey; - subItem->type = subItem->OptType; + for (auto &it : hotkeys) { + if (it->rootHotkey == item) { + it->Hotkey = it->OptHotkey; + it->type = it->OptType; mir_snprintf(buf, "%s$%d", item->pszName, item->nSubHotkeys); - db_set_w(0, DBMODULENAME, buf, subItem->Hotkey); - if (subItem->type != HKT_MANUAL) - db_set_b(0, DBMODULENAME "Types", buf, (BYTE)subItem->type); + db_set_w(0, DBMODULENAME, buf, it->Hotkey); + if (it->type != HKT_MANUAL) + db_set_b(0, DBMODULENAME "Types", buf, (BYTE)it->type); ++item->nSubHotkeys; } @@ -502,14 +500,12 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvc.cx = g_iIconSX; ListView_InsertColumn(hwndHotkey, COL_ADDREMOVE, &lvc); - for (int i = 0; i < hotkeys.getCount(); i++) { - THotkeyItem *item = hotkeys[i]; - - item->OptChanged = FALSE; - item->OptDeleted = item->OptNew = FALSE; - item->OptEnabled = item->Enabled; - item->OptHotkey = item->Hotkey; - item->OptType = item->type; + for (auto &it : hotkeys) { + it->OptChanged = FALSE; + it->OptDeleted = it->OptNew = FALSE; + it->OptEnabled = it->Enabled; + it->OptHotkey = it->Hotkey; + it->OptType = it->type; } currentLanguage = LOWORD(GetKeyboardLayout(0)); @@ -753,43 +749,33 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPNMHDR lpnmhdr = (LPNMHDR)lParam; switch (lpnmhdr->idFrom) { case 0: - { - int i; - - if ((lpnmhdr->code != PSN_APPLY) && (lpnmhdr->code != PSN_RESET)) - break; + if ((lpnmhdr->code != PSN_APPLY) && (lpnmhdr->code != PSN_RESET)) + break; - UnregisterHotkeys(); + UnregisterHotkeys(); - for (i = 0; i < hotkeys.getCount(); i++) { - THotkeyItem *item = hotkeys[i]; - if (item->OptNew && item->OptDeleted || - item->rootHotkey && !item->OptHotkey || - (lpnmhdr->code == PSN_APPLY) && item->OptDeleted || - (lpnmhdr->code == PSN_RESET) && item->OptNew) { - FreeHotkey(item); - hotkeys.remove(i--); - } - } + for (auto &it : hotkeys) + if (it->OptNew && it->OptDeleted || it->rootHotkey && !it->OptHotkey || (lpnmhdr->code == PSN_APPLY) && it->OptDeleted || (lpnmhdr->code == PSN_RESET) && it->OptNew) + FreeHotkey(it); + hotkeys.destroy(); - if (lpnmhdr->code == PSN_APPLY) { - LVITEM lvi = { 0 }; - int count = ListView_GetItemCount(hwndHotkey); + if (lpnmhdr->code == PSN_APPLY) { + LVITEM lvi = { 0 }; + int count = ListView_GetItemCount(hwndHotkey); - for (i = 0; i < hotkeys.getCount(); i++) - sttOptionsSaveItem(hotkeys[i]); + for (auto &it : hotkeys) + sttOptionsSaveItem(it); - lvi.mask = LVIF_IMAGE; - lvi.iSubItem = COL_RESET; - lvi.iImage = -1; - for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) - ListView_SetItem(hwndHotkey, &lvi); - } + lvi.mask = LVIF_IMAGE; + lvi.iSubItem = COL_RESET; + lvi.iImage = -1; + for (lvi.iItem = 0; lvi.iItem < count; ++lvi.iItem) + ListView_SetItem(hwndHotkey, &lvi); + } - RegisterHotkeys(); + RegisterHotkeys(); - NotifyEventHooks(hEvChanged, 0, 0); - } + NotifyEventHooks(hEvChanged, 0, 0); break; case IDC_LV_HOTKEYS: @@ -917,18 +903,17 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, else if (param->uNewState >> 12 == 2) { int nItems = ListView_GetItemCount(lpnmhdr->hwndFrom); initialized = FALSE; - for (int i = 0; i < hotkeys.getCount(); i++) { + for (auto &it : hotkeys) { LVITEM lvi2 = { 0 }; - item = hotkeys[i]; - if (item->OptDeleted || mir_wstrcmp(buf, item->getSection())) + if (it->OptDeleted || mir_wstrcmp(buf, it->getSection())) continue; lvi2.mask = LVIF_PARAM | LVIF_INDENT; lvi2.iIndent = 1; lvi2.iItem = nItems++; - lvi2.lParam = (LPARAM)item; + lvi2.lParam = (LPARAM)it; ListView_InsertItem(lpnmhdr->hwndFrom, &lvi2); - sttOptionsSetupItem(lpnmhdr->hwndFrom, nItems - 1, item); + sttOptionsSetupItem(lpnmhdr->hwndFrom, nItems - 1, it); } ListView_SortItemsEx(lpnmhdr->hwndFrom, sttOptionsSortList, (LPARAM)lpnmhdr->hwndFrom); initialized = TRUE; diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp index 160c426d75..6443955168 100644 --- a/src/mir_app/src/hotkeys.cpp +++ b/src/mir_app/src/hotkeys.cpp @@ -50,9 +50,9 @@ static HHOOK hhkKeyboard = nullptr; WORD GetHotkeyValue(INT_PTR idHotkey)
{
- for (int i = 0; i < hotkeys.getCount(); i++)
- if (hotkeys[i]->idHotkey == idHotkey)
- return hotkeys[i]->Enabled ? hotkeys[i]->Hotkey : 0;
+ for (auto &it : hotkeys)
+ if (it->idHotkey == idHotkey)
+ return it->Enabled ? it->Hotkey : 0;
return 0;
}
@@ -70,8 +70,7 @@ static void sttWordToModAndVk(WORD w, BYTE *mod, BYTE *vk) static LRESULT CALLBACK sttHotkeyHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_HOTKEY) {
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *p = hotkeys[i];
+ for (auto &p : hotkeys) {
if (p->type != HKT_GLOBAL || !p->Enabled)
continue;
@@ -98,8 +97,7 @@ static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam) if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT;
if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN;
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *p = hotkeys[i];
+ for (auto &p : hotkeys) {
if (p->type != HKT_LOCAL || !p->Enabled)
continue;
@@ -209,12 +207,12 @@ MIR_APP_DLL(int) Hotkey_Unregister(const char *pszName) mir_snprintf(pszNamePrefix, "%s$", pszName);
cbNamePrefix = mir_strlen(pszNamePrefix);
- for (int i = 0; i < hotkeys.getCount(); i++) {
- char *pszCurrentName = hotkeys[i]->getName();
+ for (auto &it : hotkeys) {
+ char *pszCurrentName = it->getName();
if (!pszCurrentName)
continue;
- hotkeys[i]->UnregisterHotkey =
+ it->UnregisterHotkey =
!mir_strcmp(pszCurrentName, pszName) ||
!strncmp(pszCurrentName, pszNamePrefix, cbNamePrefix);
}
@@ -244,8 +242,7 @@ MIR_APP_DLL(int) Hotkey_Check(MSG *msg, const char *szSection) if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN;
ptrW pszSection(mir_a2u(szSection));
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *p = hotkeys[i];
+ for (auto &p : hotkeys) {
if ((p->type != HKT_MANUAL) || mir_wstrcmp(pszSection, p->pwszSection))
continue;
@@ -276,8 +273,7 @@ void FreeHotkey(THotkeyItem *p) void RegisterHotkeys()
{
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *p = hotkeys[i];
+ for (auto &p : hotkeys) {
UnregisterHotKey(g_hwndHotkeyHost, p->idHotkey);
if (p->type != HKT_GLOBAL) continue;
if (p->Enabled) {
@@ -302,11 +298,9 @@ MIR_APP_DLL(void) KillModuleHotkeys(int _hLang) void UnregisterHotkeys()
{
- for (int i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *p = hotkeys[i];
+ for (auto &p : hotkeys)
if (p->type == HKT_GLOBAL && p->Enabled)
UnregisterHotKey(g_hwndHotkeyHost, p->idHotkey);
- }
}
static int sttModulesLoaded(WPARAM, LPARAM)
@@ -379,8 +373,8 @@ void UnloadSkinHotkeys(void) DestroyHookableEvent(hEvChanged);
UnhookWindowsHookEx(hhkKeyboard);
- for (int i = 0; i < hotkeys.getCount(); i++)
- FreeHotkey(hotkeys[i]);
+ for (auto &p : hotkeys)
+ FreeHotkey(p);
DestroyWindow(g_hwndHotkeyHost);
}
diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp index bf7f430214..b3e212f3f3 100644 --- a/src/mir_app/src/icolib.cpp +++ b/src/mir_app/src/icolib.cpp @@ -423,8 +423,7 @@ IcolibItem* IcoLib_FindHIcon(HICON hIcon, bool &big) if (hIcon == nullptr)
return nullptr;
- for (int i = 0; i < iconList.getCount(); i++) {
- IcolibItem *p = iconList[i];
+ for (auto &p : iconList) {
if ((void*)p == hIcon) {
big = (p->source_small == nullptr);
return p;
@@ -808,8 +807,8 @@ void UnloadIcoLibModule(void) while (iconList.getCount() > 0)
IcoLib_RemoveIcon_Internal(0);
- for (int i = 0; i < iconSourceList.getCount(); i++)
- delete iconSourceList[i];
+ for (auto &p : iconSourceList)
+ delete p;
iconSourceList.destroy();
while (iconSourceFileList.getCount() > 0) {
@@ -818,8 +817,8 @@ void UnloadIcoLibModule(void) mir_free(p);
}
- for (int i = 0; i < sectionList.getCount(); i++)
- delete sectionList[i];
+ for (auto &p : sectionList)
+ delete p;
SafeDestroyIcon(hIconBlank);
bModuleInitialized = false;
diff --git a/src/mir_app/src/iconheader.cpp b/src/mir_app/src/iconheader.cpp index debb3db098..4a00cbfd48 100644 --- a/src/mir_app/src/iconheader.cpp +++ b/src/mir_app/src/iconheader.cpp @@ -90,7 +90,8 @@ static void MITListDestructor(void * adr) void li_ListDestruct(LIST<MIcoTab> &pList, ItemDestuctor pItemDestructor)
{
- for (int i = 0; i < pList.getCount(); i++) pItemDestructor(pList[i]);
+ for (auto &p : pList)
+ pItemDestructor(p);
pList.destroy();
}
@@ -280,10 +281,8 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit) HFONT hOldFont = (HFONT)SelectObject(tempDC, hFont);
SetBkMode(tempDC, TRANSPARENT);
- for (int i = 0; i < mit->pList.getCount(); i++) {
- MIcoTab *tab = (MIcoTab *)mit->pList[i];
- MIcoTab_DrawItem(hwndDlg, tempDC, mit, tab, i);
- }
+ for (int i = 0; i < mit->pList.getCount(); i++)
+ MIcoTab_DrawItem(hwndDlg, tempDC, mit, mit->pList[i], i);
//Copy to output
BitBlt(hdc, mit->rc.left, mit->rc.top, mit->width, mit->height, tempDC, 0, 0, SRCCOPY);
diff --git a/src/mir_app/src/mdatabasecache.cpp b/src/mir_app/src/mdatabasecache.cpp index a3fa6faa35..83ab81790d 100644 --- a/src/mir_app/src/mdatabasecache.cpp +++ b/src/mir_app/src/mdatabasecache.cpp @@ -49,8 +49,8 @@ MDatabaseCache::MDatabaseCache(size_t _size) : MDatabaseCache::~MDatabaseCache()
{
- for (int i = 0; i < m_lContacts.getCount(); i++)
- mir_free(m_lContacts[i]->pSubs);
+ for (auto &it : m_lContacts)
+ mir_free(it->pSubs);
HeapDestroy(m_hCacheHeap);
}
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index 70fbf68454..6b4a3a1e1f 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -117,8 +117,7 @@ int fnGetAverageMode(int *pNetProtoCount) {
int netProtoCount = 0, averageMode = 0;
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (cli.pfnGetProtocolVisibility(pa->szModuleName) == 0 || Proto_IsAccountLocked(pa))
continue;
@@ -610,14 +609,13 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) int MenusProtoCount = 0;
- for (int i = 0; i < accounts.getCount(); i++)
- if (cli.pfnGetProtocolVisibility(accounts[i]->szModuleName))
+ for (auto &pa : accounts)
+ if (cli.pfnGetProtocolVisibility(pa->szModuleName))
MenusProtoCount++;
cli.currentDesiredStatusMode = smep->status;
- for (int j = 0; j < accounts.getCount(); j++) {
- PROTOACCOUNT *pa = accounts[j];
+ for (auto &pa : accounts) {
if (!Proto_IsAccountEnabled(pa))
continue;
if (MenusProtoCount > 1 && Proto_IsAccountLocked(pa))
@@ -904,8 +902,7 @@ void RebuildMenuOrder(void) // add to root menu
for (int j = 0; j < _countof(statusModeList); j++) {
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName))
continue;
diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index 93e4422902..51d1716f64 100644 --- a/src/mir_app/src/menu_options.cpp +++ b/src/mir_app/src/menu_options.cpp @@ -186,13 +186,12 @@ class CGenMenuOptionsPage : public CDlgBase tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_PARAM | TVIF_CHILDREN | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - for (int i = 0; i < arItems.getCount(); i++) { - MenuItemOptData *PD = arItems[i]; - if (i > 0 && PD->pos - lastpos >= SEPARATORPOSITIONINTERVAL) { + for (auto &it : arItems) { + if (it != arItems[0] && it->pos - lastpos >= SEPARATORPOSITIONINTERVAL) { MenuItemOptData *sep = new MenuItemOptData(); sep->id = -1; sep->name = mir_wstrdup(STR_SEPARATOR); - sep->pos = PD->pos - 1; + sep->pos = it->pos - 1; tvis.item.lParam = (LPARAM)sep; tvis.item.pszText = sep->name; @@ -201,10 +200,10 @@ class CGenMenuOptionsPage : public CDlgBase m_menuItems.InsertItem(&tvis); } - tvis.item.lParam = (LPARAM)PD; - tvis.item.pszText = PD->name; - tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow; - tvis.item.cChildren = PD->pimi->submenu.first != nullptr; + tvis.item.lParam = (LPARAM)it; + tvis.item.pszText = it->name; + tvis.item.iImage = tvis.item.iSelectedImage = it->bShow; + tvis.item.cChildren = it->pimi->submenu.first != nullptr; HTREEITEM hti = m_menuItems.InsertItem(&tvis); if (bIsFirst) { @@ -213,12 +212,12 @@ class CGenMenuOptionsPage : public CDlgBase bIsFirst = false; } - if (PD->pimi->submenu.first != nullptr) { - BuildTreeInternal(pszModule, bReread, PD->pimi->submenu.first, hti); + if (it->pimi->submenu.first != nullptr) { + BuildTreeInternal(pszModule, bReread, it->pimi->submenu.first, hti); m_menuItems.Expand(hti, TVE_EXPAND); } - lastpos = PD->pos; + lastpos = it->pos; } } @@ -315,11 +314,9 @@ public: m_enableIcons.SetState(!bIconsDisabled); //---- init menu object list -------------------------------------- - for (int i = 0; i < g_menus.getCount(); i++) { - TIntMenuObject *p = g_menus[i]; + for (auto &p : g_menus) if (p->id != (int)hStatusMenuObject && p->m_bUseUserDefinedItems) m_menuObjects.AddString(TranslateW(p->ptszDisplayName), p->id); - } m_menuObjects.SetCurSel(0); RebuildCurrent(); diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp index 6fd467fdfd..dc9e92bcef 100644 --- a/src/mir_app/src/menu_utils.cpp +++ b/src/mir_app/src/menu_utils.cpp @@ -183,8 +183,8 @@ MIR_APP_DLL(BOOL) Menu_DrawItem(LPARAM lParam) int MO_RemoveAllObjects()
{
- for (int i = 0; i < g_menus.getCount(); i++)
- delete g_menus[i];
+ for (auto &p : g_menus)
+ delete p;
g_menus.destroy();
return 0;
}
@@ -447,8 +447,8 @@ MIR_APP_DLL(BOOL) Menu_ProcessCommandById(int command, LPARAM lParam) return false;
mir_cslock lck(csMenuHook);
- for (int i = 0; i < g_menus.getCount(); i++)
- if (TMO_IntMenuItem *pimi = MO_RecursiveWalkMenu(g_menus[i]->m_items.first, FindMenuByCommand, &command))
+ for (auto &p : g_menus)
+ if (TMO_IntMenuItem *pimi = MO_RecursiveWalkMenu(p->m_items.first, FindMenuByCommand, &command))
return Menu_ProcessCommand(pimi, lParam);
return false;
@@ -634,11 +634,11 @@ MIR_APP_DLL(void) KillModuleMenus(int _hLang) KillMenuItemsParam param(_hLang);
mir_cslock lck(csMenuHook);
- for (int i = 0; i < g_menus.getCount(); i++)
- MO_RecursiveWalkMenu(g_menus[i]->m_items.first, (pfnWalkFunc)KillMenuItems, ¶m);
+ for (auto &p : g_menus)
+ MO_RecursiveWalkMenu(p->m_items.first, (pfnWalkFunc)KillMenuItems, ¶m);
- for (int k = 0; k < param.arItems.getCount(); k++)
- Menu_RemoveItem(param.arItems[k]);
+ for (auto &p : param.arItems)
+ Menu_RemoveItem(p);
}
///////////////////////////////////////////////////////////////////////////////
@@ -655,8 +655,8 @@ static int GetNextObjectMenuItemId() // if menu commands are exausted, pack the menu array
if (NextObjectMenuItemId >= CLISTMENUIDMAX) {
NextObjectMenuItemId = CLISTMENUIDMIN;
- for (int i = 0; i < g_menus.getCount(); i++)
- MO_RecursiveWalkMenu(g_menus[i]->m_items.first, PackMenuItems, nullptr);
+ for (auto &p : g_menus)
+ MO_RecursiveWalkMenu(p->m_items.first, PackMenuItems, nullptr);
}
return NextObjectMenuItemId++;
@@ -918,8 +918,7 @@ static int sttDumpItem(TMO_IntMenuItem *pmi, void *szModule) static void CALLBACK sttUpdateMenuService()
{
- for (int i = 0; i < g_menus.getCount(); i++) {
- TIntMenuObject *pmo = g_menus[i];
+ for (auto &pmo : g_menus) {
if (!pmo->m_bUseUserDefinedItems)
continue;
@@ -1195,9 +1194,9 @@ int OnIconLibChanges(WPARAM, LPARAM) {
{
mir_cslock lck(csMenuHook);
- for (int mo = 0; mo < g_menus.getCount(); mo++)
- if (hStatusMenuObject != g_menus[mo]->id) //skip status menu
- MO_RecursiveWalkMenu(g_menus[mo]->m_items.first, MO_ReloadIcon, nullptr);
+ for (auto &p : g_menus)
+ if (hStatusMenuObject != p->id) //skip status menu
+ MO_RecursiveWalkMenu(p->m_items.first, MO_ReloadIcon, nullptr);
}
cli.pfnReloadProtoMenus();
@@ -1255,11 +1254,11 @@ static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*) int RegisterAllIconsInIconLib()
{
// register all icons
- for (int mo = 0; mo < g_menus.getCount(); mo++) {
- if (hStatusMenuObject == g_menus[mo]->id) //skip status menu
+ for (auto &p : g_menus) {
+ if (hStatusMenuObject == p->id) //skip status menu
continue;
- MO_RecursiveWalkMenu(g_menus[mo]->m_items.first, MO_RegisterIcon, nullptr);
+ MO_RecursiveWalkMenu(p->m_items.first, MO_RegisterIcon, nullptr);
}
return 0;
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index 28a7ecc50d..79d91aacb5 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -555,9 +555,9 @@ static int Meta_MessageWindowEvent(WPARAM, LPARAM lParam) }
}
else if (mwed->uType == MSG_WINDOW_EVT_CLOSING) {
- for (int i = 0; i < arMetaWindows.getCount(); i++)
- if (arMetaWindows[i].m_hWnd == mwed->hwndWindow)
- arMetaWindows.remove(i);
+ for (auto &p : arMetaWindows)
+ if (p->m_hWnd == mwed->hwndWindow)
+ arMetaWindows.remove(p);
}
return 0;
}
diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp index c50aed9b84..28e1207d99 100644 --- a/src/mir_app/src/meta_utils.cpp +++ b/src/mir_app/src/meta_utils.cpp @@ -401,8 +401,8 @@ int Meta_HideMetaContacts(bool bHide) }
if (bHide) {
- for (int i = 0; i < arMetaWindows.getCount(); i++)
- SendMessage(arMetaWindows[i].m_hWnd, WM_CLOSE, 0, 0);
+ for (auto &p : arMetaWindows)
+ SendMessage(p->m_hWnd, WM_CLOSE, 0, 0);
arMetaWindows.destroy();
}
diff --git a/src/mir_app/src/movetogroup.cpp b/src/mir_app/src/movetogroup.cpp index 23bbab8518..3a66641c4c 100644 --- a/src/mir_app/src/movetogroup.cpp +++ b/src/mir_app/src/movetogroup.cpp @@ -88,8 +88,8 @@ static void AddGroupItem(HGENMENU hRoot, wchar_t* name, int pos, WPARAM param, b static int OnContactMenuBuild(WPARAM wParam, LPARAM)
{
OBJLIST<GroupItemSort> groups(10, GroupItemSort::compare);
- for (int i = 0; i < lphGroupsItems.getCount(); i++)
- Menu_RemoveItem((HGENMENU)lphGroupsItems[i]);
+ for (auto &p : lphGroupsItems)
+ Menu_RemoveItem((HGENMENU)p);
lphGroupsItems.destroy();
ptrW szContactGroup(db_get_wsa(wParam, "CList", "Group"));
@@ -114,9 +114,9 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM) mir_free(dbv.ptszVal);
}
- for (int i = 0; i < groups.getCount(); i++) {
- bool checked = szContactGroup && !mir_wstrcmp(szContactGroup, groups[i].name);
- AddGroupItem(hMoveToGroupItem, groups[i].name, ++pos, groups[i].position, checked);
+ for (auto &p : groups) {
+ bool checked = szContactGroup && !mir_wstrcmp(szContactGroup, p->name);
+ AddGroupItem(hMoveToGroupItem, p->name, ++pos, p->position, checked);
}
return 0;
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp index f5e587078c..04b70cabbf 100644 --- a/src/mir_app/src/netlibautoproxy.cpp +++ b/src/mir_app/src/netlibautoproxy.cpp @@ -221,22 +221,24 @@ static void NetlibIeProxyThread(void *arg) char* NetlibGetIeProxy(char *szUrl)
{
- char *res = nullptr;
- char* p = strstr(szUrl, "://");
- if (p) p += 3; else p = szUrl;
-
- char *szHost = NEWSTR_ALLOCA(p);
- p = strchr(szHost, '/'); if (p) *p = 0;
- p = strchr(szHost, ':'); if (p) *p = 0;
- _strlwr(szHost);
+ char *res = nullptr, *szHost;
+ {
+ char* p = strstr(szUrl, "://");
+ if (p) p += 3; else p = szUrl;
+
+ szHost = NEWSTR_ALLOCA(p);
+ p = strchr(szHost, '/'); if (p) *p = 0;
+ p = strchr(szHost, ':'); if (p) *p = 0;
+ _strlwr(szHost);
+ }
if (bEnabled) {
- for (int i = 0; i < proxyBypass.getCount(); i++) {
- if (mir_strcmp(proxyBypass[i], "<local>") == 0) {
+ for (auto &p : proxyBypass) {
+ if (mir_strcmp(p, "<local>") == 0) {
if (strchr(szHost, '.') == nullptr)
return nullptr;
}
- else if (wildcmp(szHost, proxyBypass[i]))
+ else if (wildcmp(szHost, p))
return nullptr;
}
@@ -353,12 +355,11 @@ void NetlibLoadIeProxy(void) void NetlibUnloadIeProxy(void)
{
- int i;
- for (i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
mir_free(szProxyHost[i]);
- for (i = 0; i < proxyBypass.getCount(); i++)
- mir_free(proxyBypass[i]);
+ for (auto &p : proxyBypass)
+ mir_free(p);
mir_free(abuf.lpszScriptBuffer);
diff --git a/src/mir_app/src/netlibopts.cpp b/src/mir_app/src/netlibopts.cpp index 1ba6678d75..a9aef9ae86 100644 --- a/src/mir_app/src/netlibopts.cpp +++ b/src/mir_app/src/netlibopts.cpp @@ -165,11 +165,9 @@ static void ChangeSettingIntByCheckbox(HWND hwndDlg, UINT ctrlId, int iUser, int int newValue = IsDlgButtonChecked(hwndDlg, ctrlId) != BST_CHECKED;
CheckDlgButton(hwndDlg, ctrlId, newValue ? BST_CHECKED : BST_UNCHECKED);
if (iUser == -1) {
- for (int i = 0; i < tempSettings.getCount(); i++) {
- NetlibTempSettings *p = tempSettings[i];
+ for (auto &p : tempSettings)
if (!(p->flags & NUF_NOOPTIONS))
*(int*)(((PBYTE)&p->settings) + memberOffset) = newValue;
- }
}
else *(int*)(((PBYTE)&tempSettings[iUser]->settings) + memberOffset) = newValue;
SendMessage(hwndDlg, M_REFRESHENABLING, 0, 0);
@@ -181,8 +179,7 @@ static void ChangeSettingStringByEdit(HWND hwndDlg, UINT ctrlId, int iUser, int char *szNewValue = (char*)mir_alloc(newValueLen+1);
GetDlgItemTextA(hwndDlg, ctrlId, szNewValue, newValueLen+1);
if (iUser == -1) {
- for (int i = 0; i < tempSettings.getCount(); i++) {
- NetlibTempSettings *p = tempSettings[i];
+ for (auto &p : tempSettings) {
if (!(p->flags & NUF_NOOPTIONS)) {
char **ppszNew = (char**)(((PBYTE)&p->settings) + memberOffset);
mir_free(*ppszNew);
@@ -238,10 +235,10 @@ void NetlibSaveUserSettingsStruct(const char *szSettingsModule, const NETLIBUSER combinedSettings.cbSize = sizeof(combinedSettings);
DWORD flags = 0;
- for (int i = 0; i < netlibUser.getCount(); i++) {
- if (thisUser->user.flags & NUF_NOOPTIONS)
+ for (auto &p : netlibUser) {
+ if (p->user.flags & NUF_NOOPTIONS)
continue;
- CombineSettingsStructs(&combinedSettings, &flags, &thisUser->settings, thisUser->user.flags);
+ CombineSettingsStructs(&combinedSettings, &flags, &p->settings, p->user.flags);
}
if (combinedSettings.validateSSL == 2) combinedSettings.validateSSL = 0;
if (combinedSettings.useProxy == 2) combinedSettings.useProxy = 0;
@@ -293,11 +290,9 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (iUser == -1) {
settings.cbSize = sizeof(settings);
- for (int i = 0; i < tempSettings.getCount(); i++) {
- NetlibTempSettings *p = tempSettings[i];
+ for (auto &p : tempSettings)
if (!(p->flags & NUF_NOOPTIONS))
CombineSettingsStructs(&settings, &flags, &p->settings, p->flags);
- }
}
else {
NetlibFreeUserSettingsStruct(&settings);
@@ -347,10 +342,8 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, int enableAuth = 0, enableUser = 0, enablePass = 0, enableServer = 1;
EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), TRUE);
if (selectedProxyType == 0) {
- for (int i = 0; i < tempSettings.getCount(); i++) {
- NetlibTempSettings *p = tempSettings[i];
- if (!p->settings.useProxy ||
- p->flags & NUF_NOOPTIONS || !(p->flags & NUF_OUTGOING))
+ for (auto &p : tempSettings) {
+ if (!p->settings.useProxy || p->flags & NUF_NOOPTIONS || !(p->flags & NUF_OUTGOING))
continue;
if (p->settings.proxyType == PROXYTYPE_SOCKS4) enableUser = 1;
@@ -402,8 +395,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (newValue == 0)
return 0;
- for (int i=0; i < tempSettings.getCount(); i++) {
- NetlibTempSettings *p = tempSettings[i];
+ for (auto &p : tempSettings) {
if (p->flags & NUF_NOOPTIONS)
continue;
if (newValue == PROXYTYPE_HTTP && !(p->flags & NUF_HTTPCONNS))
@@ -450,11 +442,9 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, {
int newValue = GetDlgItemInt(hwndDlg, LOWORD(wParam), nullptr, FALSE);
if (iUser == -1) {
- for (int i = 0; i < tempSettings.getCount(); i++) {
- NetlibTempSettings *p = tempSettings[i];
+ for (auto &p : tempSettings)
if (!(p->flags & NUF_NOOPTIONS))
p->settings.wProxyPort = newValue;
- }
}
else tempSettings[iUser]->settings.wProxyPort = newValue;
}
@@ -485,9 +475,8 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- for (iUser = 0; iUser < tempSettings.getCount(); iUser++)
- NetlibSaveUserSettingsStruct(tempSettings[iUser]->szSettingsModule,
- &tempSettings[iUser]->settings);
+ for (auto &p : tempSettings)
+ NetlibSaveUserSettingsStruct(p->szSettingsModule, &p->settings);
return TRUE;
}
break;
@@ -495,11 +484,10 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, break;
case WM_DESTROY:
- for (int i = 0; i < tempSettings.getCount(); ++i) {
- NetlibTempSettings *p = tempSettings[i];
+ for (auto &p : tempSettings) {
mir_free(p->szSettingsModule);
NetlibFreeUserSettingsStruct(&p->settings);
- mir_free(tempSettings[i]);
+ mir_free(p);
}
tempSettings.destroy();
break;
@@ -512,8 +500,8 @@ int NetlibOptInitialise(WPARAM wParam, LPARAM) int optionsCount = 0;
{
mir_cslock lck(csNetlibUser);
- for (int i=0; i < netlibUser.getCount(); i++)
- if (!(netlibUser[i]->user.flags & NUF_NOOPTIONS))
+ for (auto &p : netlibUser)
+ if (!(p->user.flags & NUF_NOOPTIONS))
++optionsCount;
}
diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp index 8dfcbd36a8..cdc0668fdf 100644 --- a/src/mir_app/src/netlibupnp.cpp +++ b/src/mir_app/src/netlibupnp.cpp @@ -736,8 +736,8 @@ void NetlibUPnPCleanup(void*) {
int incoming = 0;
mir_cslock lck(csNetlibUser);
- for (int i = 0; i < netlibUser.getCount(); i++)
- if (netlibUser[i]->user.flags & NUF_INCOMING) {
+ for (auto &p : netlibUser)
+ if (p->user.flags & NUF_INCOMING) {
incoming = 1;
break;
}
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index f16ba12347..87cd7e0254 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -178,11 +178,10 @@ char* GetPluginNameByLangpack(int _hLang) if (pluginList.getCount() == 0)
return "";
- for (int i = 0; i < pluginList.getCount(); i++) {
- pluginEntry *p = pluginList[i];
+ for (auto &p : pluginList)
if (p->hLangpack == _hLang)
return p->bpi.pluginInfo->shortName;
- }
+
return "";
}
@@ -191,11 +190,10 @@ char* GetPluginNameByInstance(HINSTANCE hInstance) if (pluginList.getCount() == 0)
return nullptr;
- for (int i = 0; i < pluginList.getCount(); i++) {
- pluginEntry *p = pluginList[i];
+ for (auto &p : pluginList)
if (p->bpi.pluginInfo && p->bpi.hInst == hInstance)
return p->bpi.pluginInfo->shortName;
- }
+
return nullptr;
}
@@ -204,11 +202,10 @@ MIR_APP_DLL(int) GetPluginLangByInstance(HINSTANCE hInstance) if (pluginList.getCount() == 0)
return 0;
- for (int i = 0; i < pluginList.getCount(); i++) {
- pluginEntry *p = pluginList[i];
+ for (auto &p : pluginList)
if (p->bpi.pluginInfo && p->bpi.hInst == hInstance)
return p->hLangpack;
- }
+
return 0;
}
@@ -217,8 +214,7 @@ MIR_APP_DLL(int) GetPluginLangId(const MUUID &uuid, int _hLang) if (uuid == miid_last)
return --sttFakeID;
- for (int i = 0; i < pluginList.getCount(); i++) {
- pluginEntry *p = pluginList[i];
+ for (auto &p : pluginList) {
if (!p->bpi.hInst)
continue;
@@ -231,8 +227,7 @@ MIR_APP_DLL(int) GetPluginLangId(const MUUID &uuid, int _hLang) MIR_APP_DLL(int) IsPluginLoaded(const MUUID &uuid)
{
- for (int i = 0; i < pluginList.getCount(); i++) {
- pluginEntry *p = pluginList[i];
+ for (auto &p : pluginList) {
if (!p->bpi.hInst)
continue;
@@ -636,8 +631,7 @@ static pluginEntry* getCListModule(wchar_t *exe) {
wchar_t tszFullPath[MAX_PATH];
- for (int i = 0; i < clistPlugins.getCount(); i++) {
- pluginEntry *p = clistPlugins[i];
+ for (auto &p : clistPlugins) {
if (!isPluginOnWhiteList(p->pluginname))
continue;
@@ -646,7 +640,7 @@ static pluginEntry* getCListModule(wchar_t *exe) return p;
}
- MuuidReplacement& stdClist = pluginDefault[0];
+ MuuidReplacement &stdClist = pluginDefault[0];
if (LoadCorePlugin(stdClist)) {
mir_snwprintf(tszFullPath, L"%s\\Core\\%s.dll", exe, stdClist.stdplugname);
if (loadClistModule(tszFullPath, stdClist.pImpl))
@@ -705,8 +699,7 @@ int LoadDefaultServiceModePlugin() return SERVICE_CONTINUE;
size_t cbLen = mir_wstrlen(param);
- for (int i = 0; i < servicePlugins.getCount(); i++) {
- pluginEntry *p = servicePlugins[i];
+ for (auto &p : servicePlugins) {
if (!wcsnicmp(p->pluginname, param, cbLen)) {
int res = LaunchServicePlugin(p);
if (res == SERVICE_ONLYDB) // load it later
@@ -725,8 +718,7 @@ int LoadServiceModePlugin() void EnsureCheckerLoaded(bool bEnable)
{
- for (int i = 0; i < pluginList.getCount(); i++) {
- pluginEntry *p = pluginList[i];
+ for (auto &p : pluginList) {
if (mir_wstrcmpi(p->pluginname, L"dbchecker.dll"))
continue;
@@ -829,8 +821,8 @@ int LoadNewPluginsModule(void) }
/* enable and disable as needed */
- for (int i = 0; i < clistPlugins.getCount(); i++)
- SetPluginOnWhiteList(clistPlugins[i]->pluginname, clist != clistPlugins[i] ? 0 : 1);
+ for (auto &p : clistPlugins)
+ SetPluginOnWhiteList(p->pluginname, clist != p ? 0 : 1);
/* now loop thru and load all the other plugins, do this in one pass */
for (int i = 0; i < pluginList.getCount(); i++) {
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp index 261841f39b..62a549b9bc 100644 --- a/src/mir_app/src/options.cpp +++ b/src/mir_app/src/options.cpp @@ -429,8 +429,7 @@ class COptionsDlg : public CDlgBase m_keywordFilter.AddString(ALL_MODULES_FILTER, 0);
m_keywordFilter.AddString(CORE_MODULES_FILTER, (LPARAM)g_hInst);
- for (int i = 0; i < m_arOpd.getCount(); i++) {
- OptionsPageData *opd = m_arOpd[i];
+ for (auto &opd : m_arOpd) {
opd->FindFilterStrings(false, 0, m_hwnd); // only modules name (fast enougth)
HINSTANCE inst = opd->getInst();
@@ -755,7 +754,7 @@ public: 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 = (int)i;
+ m_currentPage = i;
}
GetWindowRect(GetDlgItem(m_hwnd, IDC_STNOPAGE), &m_rcDisplay);
@@ -804,8 +803,8 @@ public: Utils_SaveWindowPosition(m_hwnd, 0, "Options", "");
- for (int i = 0; i < m_arOpd.getCount(); i++)
- delete m_arOpd[i];
+ for (auto &p : m_arOpd)
+ delete p;
DeleteObject(m_hBoldFont);
pOptionsDlg = nullptr;
@@ -867,8 +866,7 @@ public: pshn.hdr.idFrom = 0;
pshn.lParam = 0;
pshn.hdr.code = PSN_RESET;
- 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;
pshn.hdr.hwndFrom = p->getHwnd();
diff --git a/src/mir_app/src/options_ei.cpp b/src/mir_app/src/options_ei.cpp index e26a83e2f3..9ac0e0bad4 100644 --- a/src/mir_app/src/options_ei.cpp +++ b/src/mir_app/src/options_ei.cpp @@ -173,9 +173,9 @@ class CExtraIconOptsDlg : public CDlgBase HTREEITEM hNew = Tree_AddExtraIconGroup(ids, selected, hPlace);
// Remove old
- for (int i = 0; i < toRemove.getCount(); i++) {
- delete Tree_GetIDs(toRemove[i]);
- m_tree.DeleteItem(toRemove[i]);
+ for (auto &p : toRemove) {
+ delete Tree_GetIDs(p);
+ m_tree.DeleteItem(p);
}
// Select
@@ -264,9 +264,7 @@ public: HICON hBlankIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, cx, cx, 0);
ImageList_AddIcon(hImageList, hBlankIcon);
- for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
- ExtraIcon *extra = registeredExtraIcons[i];
-
+ for (auto &extra : registeredExtraIcons) {
HICON hIcon = IcoLib_GetIcon(extra->getDescIcon());
if (hIcon == nullptr)
ImageList_AddIcon(hImageList, hBlankIcon);
@@ -278,14 +276,12 @@ public: m_tree.SetImageList(hImageList, TVSIL_NORMAL);
DestroyIcon(hBlankIcon);
- for (int k = 0; k < extraIconsBySlot.getCount(); k++) {
- ExtraIcon *extra = extraIconsBySlot[k];
-
+ for (auto &extra : extraIconsBySlot) {
if (extra->getType() == EXTRAICON_TYPE_GROUP) {
ExtraIconGroup *group = (ExtraIconGroup *)extra;
intlist ids;
- for (int j = 0; j < group->m_items.getCount(); j++)
- ids.add(group->m_items[j]->getID());
+ for (auto &p : group->m_items)
+ ids.add(p->getID());
Tree_AddExtraIconGroup(ids, extra->isEnabled());
}
else Tree_AddExtraIcon((BaseExtraIcon *)extra, extra->isEnabled());
@@ -361,9 +357,7 @@ public: }
// Store data
- for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
- BaseExtraIcon *extra = registeredExtraIcons[i];
-
+ for (auto &extra : registeredExtraIcons) {
char setting[512];
mir_snprintf(setting, "Position_%s", extra->getName());
db_set_w(0, MODULE_NAME, setting, extra->getPosition());
@@ -395,8 +389,7 @@ public: // Apply icons to new slots
RebuildListsBasedOnGroups(groups);
- for (int n = 0; n < extraIconsBySlot.getCount(); n++) {
- ExtraIcon *extra = extraIconsBySlot[n];
+ for (auto &extra : extraIconsBySlot) {
if (extra->getType() != EXTRAICON_TYPE_GROUP)
if (oldSlots[((BaseExtraIcon *)extra)->getID() - 1] == extra->getSlot())
continue;
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index 9e451e4589..0637704491 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -232,8 +232,7 @@ static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LP else {
szFilter.AppendChar(wParam);
- for (int i = 0; i < arPluginList.getCount(); i++) {
- PluginListItemData *p = arPluginList[i];
+ for (auto &p : arPluginList) {
if (!wcsnicmp(szFilter, p->fileName, szFilter.GetLength())) {
LVFINDINFO lvfi;
lvfi.flags = LVFI_PARAM;
diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index c2ac658263..9da0261e13 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -152,10 +152,8 @@ public: ShowWindow(m_warning.GetHwnd(), TRUE); } else { - for (int i = 0; i < arDbPlugins.getCount(); i++) { - DATABASELINK *p = arDbPlugins[i]; + for (auto &p : arDbPlugins) m_driverList.AddString(TranslateW(p->szFullName), (LPARAM)p); - } } // default item diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 269027909d..3a701e1188 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -207,8 +207,7 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) {
int count = 0;
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (!pa->ppro || !Proto_IsAccountEnabled(pa))
continue;
@@ -234,18 +233,16 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) static int UninitializeStaticAccounts(WPARAM, LPARAM)
{
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ // request permission to exit first
+ for (auto &pa : accounts)
if (pa->ppro && Proto_IsAccountEnabled(pa))
if (pa->ppro->OnEvent(EV_PROTO_ONREADYTOEXIT, 0, 0) != TRUE)
return 1;
- }
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ // okay, all protocols are ready, exiting
+ for (auto &pa : accounts)
if (pa->ppro && Proto_IsAccountEnabled(pa))
pa->ppro->OnEvent(EV_PROTO_ONEXIT, 0, 0);
- }
return 0;
}
@@ -254,8 +251,7 @@ int LoadAccountsModule(void) {
bModuleInitialized = TRUE;
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
pa->bDynDisabled = !Proto_IsProtocolLoaded(pa->szProtoName);
if (pa->ppro)
continue;
@@ -421,8 +417,7 @@ void UnloadAccountsModule() void BuildProtoMenus()
{
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (cli.pfnGetProtocolVisibility(pa->szModuleName) == 0)
continue;
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index d7090a080f..c28a042e9e 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -99,8 +99,8 @@ static bool FindAccountByName(const char *szModuleName) if (!mir_strlen(szModuleName))
return false;
- for (int i = 0; i < accounts.getCount(); i++)
- if (_stricmp(szModuleName, accounts[i]->szModuleName) == 0)
+ for (auto &pa : accounts)
+ if (_stricmp(szModuleName, pa->szModuleName) == 0)
return true;
return false;
@@ -427,8 +427,7 @@ public: PSHNOTIFY pshn;
pshn.hdr.idFrom = 0;
pshn.hdr.code = PSN_APPLY;
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (pa->hwndAccMgrUI && pa->bAccMgrUIChanged) {
pshn.hdr.hwndFrom = pa->hwndAccMgrUI;
SendMessage(pa->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn);
@@ -442,8 +441,7 @@ public: PSHNOTIFY pshn;
pshn.hdr.idFrom = 0;
pshn.hdr.code = PSN_RESET;
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (pa->hwndAccMgrUI && pa->bAccMgrUIChanged) {
pshn.hdr.hwndFrom = pa->hwndAccMgrUI;
SendMessage(pa->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn);
@@ -454,8 +452,7 @@ public: virtual void OnDestroy() override
{
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
pa->bAccMgrUIChanged = FALSE;
if (pa->hwndAccMgrUI) {
::DestroyWindow(pa->hwndAccMgrUI);
@@ -682,8 +679,7 @@ public: PROTOACCOUNT *acc = (i == LB_ERR) ? nullptr : (PROTOACCOUNT *)m_accList.GetItemData(i);
m_accList.ResetContent();
- for (i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *p = accounts[i];
+ for (auto &p : accounts) {
PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(p->szProtoName);
if (pd != nullptr && pd->type != PROTOTYPE_PROTOCOL)
continue;
diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index c1b971b185..7456218447 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -53,9 +53,9 @@ bool CheckProtocolOrder(void) if (i == accounts.getCount()) {
// Check if this is skipped id, if it is decrement all other ids
bool found = false;
- for (i = 0; i < accounts.getCount(); i++) {
- if (accounts[i]->iOrder < 1000000 && accounts[i]->iOrder > id) {
- --accounts[i]->iOrder;
+ for (auto &pa : accounts) {
+ if (pa->iOrder < 1000000 && pa->iOrder > id) {
+ --pa->iOrder;
found = true;
}
}
@@ -67,9 +67,9 @@ bool CheckProtocolOrder(void) if (id < accounts.getCount()) {
// Remove huge ids
- for (i = 0; i < accounts.getCount(); i++)
- if (accounts[i]->iOrder >= 1000000)
- accounts[i]->iOrder = id++;
+ for (auto &pa : accounts)
+ if (pa->iOrder >= 1000000)
+ pa->iOrder = id++;
changed = true;
}
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 8e2896414d..dd74d726a6 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -440,9 +440,9 @@ void UnloadProtocolsModule() {
if (!bModuleInitialized) return;
- for (int i = 0; i < protos.getCount(); i++) {
- mir_free(protos[i]->szName);
- mir_free(protos[i]);
+ for (auto &p : protos) {
+ mir_free(p->szName);
+ mir_free(p);
}
protos.destroy();
diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp index 76ba6342ab..658efdaa78 100644 --- a/src/mir_app/src/searchresults.cpp +++ b/src/mir_app/src/searchresults.cpp @@ -199,8 +199,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha int failures = 0;
dat->searchCount = 0;
dat->search = (struct ProtoSearchInfo*)mir_calloc(sizeof(struct ProtoSearchInfo) * accounts.getCount());
- for (int i = 0; i < accounts.getCount(); i++) {
- PROTOACCOUNT *pa = accounts[i];
+ for (auto &pa : accounts) {
if (!Proto_IsAccountEnabled(pa))
continue;
diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp index 20902cf76f..a3c9b06e19 100644 --- a/src/mir_app/src/skin2opts.cpp +++ b/src/mir_app/src/skin2opts.cpp @@ -302,21 +302,19 @@ static void LoadSectionIcons(wchar_t *filename, SectionItem* sectionActive) mir_cslock lck(csIconList);
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IcolibItem *item = iconList[indx];
-
- if (item->default_file && item->section == sectionActive) {
- _itow(item->default_indx, path + suffIndx, 10);
- HICON hIcon = ExtractIconFromPath(path, item->cx, item->cy);
+ for (auto &it : iconList) {
+ if (it->default_file && it->section == sectionActive) {
+ _itow(it->default_indx, path + suffIndx, 10);
+ HICON hIcon = ExtractIconFromPath(path, it->cx, it->cy);
if (!hIcon)
continue;
- replaceStrW(item->temp_file, nullptr);
- SafeDestroyIcon(item->temp_icon);
+ replaceStrW(it->temp_file, nullptr);
+ SafeDestroyIcon(it->temp_icon);
- item->temp_file = mir_wstrdup(path);
- item->temp_icon = hIcon;
- item->temp_reset = FALSE;
+ it->temp_file = mir_wstrdup(path);
+ it->temp_icon = hIcon;
+ it->temp_reset = FALSE;
}
}
}
@@ -500,15 +498,14 @@ class CIcoLibOptsDlg : public CDlgBase iconEventActive = 0;
mir_cslock lck(csIconList); // Destroy unused icons
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IcolibItem *item = iconList[indx];
- if (item->source_small && !item->source_small->icon_ref_count) {
- item->source_small->icon_ref_count++;
- item->source_small->releaseIcon();
+ for (auto &it : iconList) {
+ if (it->source_small && !it->source_small->icon_ref_count) {
+ it->source_small->icon_ref_count++;
+ it->source_small->releaseIcon();
}
- if (item->source_big && !item->source_big->icon_ref_count) {
- item->source_big->icon_ref_count++;
- item->source_big->releaseIcon();
+ if (it->source_big && !it->source_big->icon_ref_count) {
+ it->source_big->icon_ref_count++;
+ it->source_big->releaseIcon();
}
}
}
@@ -582,10 +579,10 @@ public: {
mir_cslock lck(csIconList);
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- iconList[indx]->temp_file = nullptr;
- iconList[indx]->temp_icon = nullptr;
- iconList[indx]->temp_reset = false;
+ for (auto &it : iconList) {
+ it->temp_file = nullptr;
+ it->temp_icon = nullptr;
+ it->temp_reset = false;
}
bNeedRebuild = false;
}
@@ -646,20 +643,19 @@ public: {
mir_cslock lck(csIconList);
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IcolibItem *item = iconList[indx];
- if (item->temp_reset) {
- db_unset(0, "SkinIcons", item->name);
- if (item->source_small != item->default_icon) {
- item->source_small->release();
- item->source_small = nullptr;
+ for (auto &it : iconList) {
+ if (it->temp_reset) {
+ db_unset(0, "SkinIcons", it->name);
+ if (it->source_small != it->default_icon) {
+ it->source_small->release();
+ it->source_small = nullptr;
}
}
- else if (item->temp_file) {
- db_set_ws(0, "SkinIcons", item->name, item->temp_file);
- item->source_small->release();
- item->source_small = nullptr;
- SafeDestroyIcon(item->temp_icon);
+ else if (it->temp_file) {
+ db_set_ws(0, "SkinIcons", it->name, it->temp_file);
+ it->source_small->release();
+ it->source_small = nullptr;
+ SafeDestroyIcon(it->temp_icon);
}
}
}
@@ -704,10 +700,9 @@ public: m_pDialog->Close();
mir_cslock lck(csIconList);
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IcolibItem *item = iconList[indx];
- replaceStrW(item->temp_file, nullptr);
- SafeDestroyIcon(item->temp_icon);
+ for (auto &it : iconList) {
+ replaceStrW(it->temp_file, nullptr);
+ SafeDestroyIcon(it->temp_icon);
}
}
diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp index 3aa05c0f02..11d66ef688 100644 --- a/src/mir_app/src/sounds.cpp +++ b/src/mir_app/src/sounds.cpp @@ -57,7 +57,7 @@ static OBJLIST<SoundItem> arSounds(10, CompareSounds); MIR_APP_DLL(void) KillModuleSounds(int _hLang)
{
- for (int i = arSounds.getCount()-1; i >= 0; i--) {
+ for (int i = arSounds.getCount() - 1; i >= 0; i--) {
SoundItem &p = arSounds[i];
if (p.hLangpack == _hLang) {
p.clear();
@@ -95,7 +95,7 @@ MIR_APP_DLL(int) Skin_AddSound(const char *pszName, const wchar_t *pwszSection, static int Skin_PlaySoundDefault(WPARAM wParam, LPARAM lParam)
{
- wchar_t *pszFile = (wchar_t*) lParam;
+ wchar_t *pszFile = (wchar_t*)lParam;
if (pszFile && (db_get_b(0, "Skin", "UseSound", 0) || (int)wParam == 1))
PlaySound(pszFile, nullptr, SND_ASYNC | SND_FILENAME | SND_NOSTOP);
@@ -164,7 +164,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
hwndTree = GetDlgItem(hwndDlg, IDC_SOUNDTREE);
- SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
+ SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
SendMessage(hwndDlg, DM_REBUILD_STREE, 0, 0);
TreeView_SetItemState(hwndTree, 0, TVIS_SELECTED, TVIS_SELECTED);
@@ -182,24 +182,25 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM tvis.hInsertAfter = TVI_SORT;
tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
- for (int i=0; i < arSounds.getCount(); i++) {
+ for (auto &p : arSounds) {
tvis.item.stateMask = TVIS_EXPANDED;
tvis.item.state = TVIS_EXPANDED;
- tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, arSounds[i].getSection());
+ tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, p->getSection());
if (tvis.hParent == nullptr) {
tvis.item.lParam = -1;
- tvis.item.pszText = arSounds[i].getSection();
+ tvis.item.pszText = p->getSection();
tvis.hParent = tvis.item.hItem = TreeView_InsertItem(hwndTree, &tvis);
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
tvis.item.state = INDEXTOSTATEIMAGEMASK(0);
TreeView_SetItem(hwndTree, &tvis.item);
}
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK(!db_get_b(0, "SkinSoundsOff", arSounds[i].name, 0)?2:1);
- tvis.item.lParam = i;
- tvis.item.pszText = arSounds[i].getDescr();
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(!db_get_b(0, "SkinSoundsOff", p->name, 0) ? 2 : 1);
+ tvis.item.lParam = (LPARAM)p;
+ tvis.item.pszText = p->getDescr();
TreeView_InsertItem(hwndTree, &tvis);
- } }
+ }
+ }
{
TVITEM tvi;
tvi.hItem = TreeView_GetRoot(hwndTree);
@@ -210,35 +211,36 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK);
tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- } }
+ }
+ }
ShowWindow(hwndTree, SW_SHOW);
break;
case DM_HIDEPANE:
- ShowWindow( GetDlgItem(hwndDlg, IDC_SGROUP), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAME), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAMEVAL), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_SLOC), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_LOCATION), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_CHANGE), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_PREVIEW), SW_HIDE);
- ShowWindow( GetDlgItem(hwndDlg, IDC_GETMORE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SGROUP), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_NAME), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_NAMEVAL), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SLOC), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_LOCATION), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_CHANGE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GETMORE), SW_HIDE);
break;
case DM_SHOWPANE:
- ShowWindow( GetDlgItem(hwndDlg, IDC_SGROUP), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAME), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_NAMEVAL), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_SLOC), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_LOCATION), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_CHANGE), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_PREVIEW), SW_SHOW);
- ShowWindow( GetDlgItem(hwndDlg, IDC_GETMORE), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SGROUP), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_NAME), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_NAMEVAL), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SLOC), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_LOCATION), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_CHANGE), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GETMORE), SW_SHOW);
break;
case DM_CHECKENABLED:
- EnableWindow( GetDlgItem(hwndDlg, IDC_SOUNDTREE), IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SOUNDTREE), IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS))
SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
else if (TreeView_GetSelection(hwndTree) && TreeView_GetParent(hwndTree, TreeView_GetSelection(hwndTree)))
@@ -262,11 +264,12 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (tvi.lParam == -1)
break;
- if (arSounds[tvi.lParam].ptszTempFile)
- NotifyEventHooks(hPlayEvent, 1, (LPARAM)arSounds[tvi.lParam].ptszTempFile);
+ SoundItem *p = (SoundItem *)tvi.lParam;
+ if (p->ptszTempFile)
+ NotifyEventHooks(hPlayEvent, 1, (LPARAM)p->ptszTempFile);
else {
DBVARIANT dbv;
- if (!db_get_ws(0, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
+ if (!db_get_ws(0, "SkinSounds", p->name, &dbv)) {
wchar_t szPathFull[MAX_PATH];
PathToAbsoluteW(dbv.ptszVal, szPathFull);
NotifyEventHooks(hPlayEvent, 1, (LPARAM)szPathFull);
@@ -282,7 +285,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break;
TVITEM tvi = { 0 };
- tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM|TVIF_TEXT;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT;
tvi.hItem = hti;
if (TreeView_GetItem(hwndTree, &tvi) == FALSE)
break;
@@ -300,7 +303,9 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (db_get_ws(0, "SkinSounds", snd.name, &dbv) == 0) {
PathToAbsoluteW(dbv.ptszVal, strdir);
db_free(&dbv);
- } } }
+ }
+ }
+ }
wcsncpy_s(strFull, (snd.ptszTempFile ? snd.ptszTempFile : L""), _TRUNCATE);
PathToAbsoluteW(strFull, strdir);
@@ -324,7 +329,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM str[0] = 0;
ofn.lpstrFile = str;
- ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_LONGNAMES|OFN_NOCHANGEDIR;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_LONGNAMES | OFN_NOCHANGEDIR;
ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = L"wav";
@@ -351,9 +356,9 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (((LPNMHDR)lParam)->code == PSN_APPLY) {
db_set_b(0, "Skin", "UseSound", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
- for (int i = 0; i < arSounds.getCount(); i++)
- if (arSounds[i].ptszTempFile)
- db_set_ws(0, "SkinSounds", arSounds[i].name, arSounds[i].ptszTempFile);
+ for (auto &p : arSounds)
+ if (p->ptszTempFile)
+ db_set_ws(0, "SkinSounds", p->name, p->ptszTempFile);
TVITEM tvi, tvic;
tvi.hItem = TreeView_GetRoot(hwndTree);
@@ -389,14 +394,16 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (tvi.lParam == -1)
SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
else {
+ SoundItem *p = (SoundItem *)tvi.lParam;
+
wchar_t buf[256];
- mir_snwprintf(buf, L"%s: %s", arSounds[tvi.lParam].getSection(), arSounds[tvi.lParam].getDescr());
+ mir_snwprintf(buf, L"%s: %s", p->getSection(), p->getDescr());
SetDlgItemText(hwndDlg, IDC_NAMEVAL, buf);
- if (arSounds[tvi.lParam].ptszTempFile)
- SetDlgItemText(hwndDlg, IDC_LOCATION, arSounds[tvi.lParam].ptszTempFile);
+ if (p->ptszTempFile)
+ SetDlgItemText(hwndDlg, IDC_LOCATION, p->ptszTempFile);
else {
DBVARIANT dbv;
- if (!db_get_ws(0, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
+ if (!db_get_ws(0, "SkinSounds", p->name, &dbv)) {
SetDlgItemText(hwndDlg, IDC_LOCATION, dbv.ptszVal);
db_free(&dbv);
}
@@ -465,6 +472,6 @@ int LoadSkinSounds(void) void UnloadSkinSounds(void)
{
- for (int i = 0; i < arSounds.getCount(); i++)
- arSounds[i].clear();
+ for (auto &p : arSounds)
+ p->clear();
}
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index 5451637512..8069a1c42c 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -120,9 +120,9 @@ MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang) cbd->m_dwOrigFlags.bit4 = cbd->m_bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0; if (bbdi->pszHotkey) { - for (int i = 0; i < hotkeys.getCount(); i++) { - if (!mir_strcmp(hotkeys[i]->getName(), bbdi->pszHotkey)) { - cbd->m_hotkey = hotkeys[i]; + for (auto &p : hotkeys) { + if (!mir_strcmp(p->getName(), bbdi->pszHotkey)) { + cbd->m_hotkey = p; break; } } @@ -168,13 +168,12 @@ MIR_APP_DLL(int) Srmm_GetButtonState(HWND hwndDlg, BBButton *bbdi) DWORD tempCID = 0; bbdi->bbbFlags = 0; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonID == bbdi->dwButtonID)) { tempCID = cbd->m_dwButtonCID; break; } - } + if (!tempCID) return 1; @@ -189,13 +188,12 @@ MIR_APP_DLL(int) Srmm_SetButtonState(MCONTACT hContact, BBButton *bbdi) return 1; DWORD tempCID = 0; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonID == bbdi->dwButtonID)) { tempCID = cbd->m_dwButtonCID; break; } - } + if (!tempCID) return 1; @@ -251,20 +249,17 @@ MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi) if (!bbdi) return 1; - bool bFound = false; CustomButtonData *cbd = nullptr; { mir_cslock lck(csToolBar); - for (int i = 0; i < arButtonsList.getCount(); i++) { - cbd = arButtonsList[i]; - if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && (cbd->m_dwButtonID == bbdi->dwButtonID)) { - bFound = true; + for (auto &p : arButtonsList) + if (!mir_strcmp(p->m_pszModuleName, bbdi->pszModuleName) && (p->m_dwButtonID == bbdi->dwButtonID)) { + cbd = p; break; } - } - if (bFound) { + if (cbd != nullptr) { if (bbdi->pwszTooltip) cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip); if (bbdi->hIcon) @@ -280,7 +275,7 @@ MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi) } } - if (bFound) + if (cbd != nullptr) WindowList_Broadcast(g_hWindowList, WM_CBD_UPDATED, 0, (LPARAM)cbd); return 0; } @@ -292,8 +287,7 @@ MIR_APP_DLL(void) Srmm_ClickToolbarIcon(MCONTACT hContact, int idFrom, HWND hwnd CustomButtonClickData cbcd = {}; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) { if (cbd->m_dwButtonCID == idFrom) { cbcd.pszModule = cbd->m_pszModuleName; cbcd.dwButtonId = cbd->m_dwButtonID; @@ -328,8 +322,7 @@ void Srmm_ProcessToolbarHotkey(MCONTACT hContact, INT_PTR iButtonFrom, HWND hwnd CustomButtonClickData cbcd = {}; - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) { if (cbd->m_hotkey == nullptr || cbd->m_bDisabled) continue; @@ -358,8 +351,7 @@ void Srmm_ProcessToolbarHotkey(MCONTACT hContact, INT_PTR iButtonFrom, HWND hwnd MIR_APP_DLL(void) Srmm_ResetToolbar() { - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) { cbd->m_dwPosition = cbd->m_dwOrigPosition; cbd->m_bRSided = cbd->m_dwOrigFlags.bit1; cbd->m_bIMButton = cbd->m_dwOrigFlags.bit2; @@ -374,8 +366,7 @@ void Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) CDlgBase *pDlg = CDlgBase::Find(hwndDlg); - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) { if (cbd->m_bSeparator) continue; @@ -418,8 +409,7 @@ void Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) MIR_APP_DLL(void) Srmm_UpdateToolbarIcons(HWND hwndDlg) { - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) { if (cbd->m_bSeparator || cbd->m_hIcon == nullptr) continue; @@ -431,8 +421,7 @@ MIR_APP_DLL(void) Srmm_UpdateToolbarIcons(HWND hwndDlg) MIR_APP_DLL(void) Srmm_RedrawToolbarIcons(HWND hwndDlg) { - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; + for (auto &cbd : arButtonsList) { HWND hwnd = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); if (hwnd) InvalidateRect(hwnd, nullptr, TRUE); @@ -582,9 +571,7 @@ class CSrmmToolbarOptions : public CDlgBase tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE; mir_cslock lck(csToolBar); - for (int i = 0; i < arButtonsList.getCount(); i++) { - CustomButtonData *cbd = arButtonsList[i]; - + for (auto &cbd : arButtonsList) { if (bPrevSide != cbd->m_bRSided) { bPrevSide = true; |