summaryrefslogtreecommitdiff
path: root/plugins/StatusManager/src/StartupStatus
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:35:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit5b6db3290cb9c9817cba126bd7aea798a610c31d (patch)
treef5b51474c51988ac60c20d33d3d6837070e055ce /plugins/StatusManager/src/StartupStatus
parente4e088d37070bab69b1457621706d65472874243 (diff)
SM: C++'11 iterators
Diffstat (limited to 'plugins/StatusManager/src/StartupStatus')
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_options.cpp27
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_profiles.cpp13
-rw-r--r--plugins/StatusManager/src/StartupStatus/startupstatus.cpp30
3 files changed, 33 insertions, 37 deletions
diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
index c0253b26e1..c3400120bd 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
@@ -109,23 +109,21 @@ static wchar_t* GetLinkDescription(TProtoSettings& protoSettings)
return nullptr;
CMStringW result(SHORTCUT_DESC);
- for (int i = 0; i < protoSettings.getCount(); i++) {
- SMProto &p = protoSettings[i];
-
+ for (auto &p : protoSettings) {
wchar_t *status;
- if (p.m_status == ID_STATUS_LAST)
+ if (p->m_status == ID_STATUS_LAST)
status = TranslateT("<last>");
- else if (p.m_status == ID_STATUS_CURRENT)
+ else if (p->m_status == ID_STATUS_CURRENT)
status = TranslateT("<current>");
- else if (p.m_status >= MIN_STATUS && p.m_status <= MAX_STATUS)
- status = pcli->pfnGetStatusModeDescription(p.m_status, 0);
+ else if (p->m_status >= MIN_STATUS && p->m_status <= MAX_STATUS)
+ status = pcli->pfnGetStatusModeDescription(p->m_status, 0);
else
status = nullptr;
if (status == nullptr)
status = TranslateT("<unknown>");
result.AppendChar('\r');
- result.Append(p.m_tszAccName);
+ result.Append(p->m_tszAccName);
result.AppendChar(':');
result.AppendChar(' ');
result.Append(status);
@@ -525,9 +523,8 @@ class CSSAdvancedOptDlg : public CDlgBase
// fill proto list
lstAccount.ResetContent();
- TProtoSettings &ar = arProfiles[sel].ps;
- for (int i = 0; i < ar.getCount(); i++)
- lstAccount.AddString(ar[i].m_tszAccName, (LPARAM)&ar[i]);
+ for (auto &it : arProfiles[sel].ps)
+ lstAccount.AddString(it->m_tszAccName, (LPARAM)it);
lstAccount.SetCurSel(0);
SetProtocol();
@@ -684,10 +681,10 @@ public:
char setting[128];
int len = mir_snprintf(setting, "%d_", i);
- for (int k = 0; k < arSettings.getCount(); k++) {
- if (!strncmp(setting, arSettings[k], len))
- db_unset(0, SSMODULENAME, arSettings[k]);
- mir_free(arSettings[k]);
+ for (auto &it : arSettings) {
+ if (!strncmp(setting, it, len))
+ db_unset(0, SSMODULENAME, it);
+ mir_free(it);
}
}
diff --git a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
index 872139fc83..608cface96 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
@@ -133,11 +133,10 @@ wchar_t* GetStatusMessage(int profile, const char *szProto)
char dbSetting[80];
mir_snprintf(dbSetting, "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG);
- for (int i = 0; i < arProfiles.getCount(); i++) {
- auto &p = arProfiles[i];
- if (p.profile == profile && !mir_strcmp(p.szProto, szProto)) {
- p.msg = db_get_wsa(0, SSMODULENAME, dbSetting);
- return p.msg;
+ for (auto &p : arProfiles) {
+ if (p->profile == profile && !mir_strcmp(p->szProto, szProto)) {
+ p->msg = db_get_wsa(0, SSMODULENAME, dbSetting);
+ return p->msg;
}
}
@@ -181,8 +180,8 @@ int GetProfile(int profile, TProtoSettings &arSettings)
if (profile >= count && count > 0)
return -1;
- for (int i = 0; i < arSettings.getCount(); i++)
- FillStatus(arSettings[i], profile);
+ for (auto &it : arSettings)
+ FillStatus(*it, profile);
return (arSettings.getCount() == 0) ? -1 : 0;
}
diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
index f4d6df4150..0c44c09a9c 100644
--- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
+++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
@@ -37,9 +37,9 @@ static BYTE showDialogOnStartup = 0;
static PROTOCOLSETTINGEX* IsValidProtocol(TProtoSettings &protoSettings, const char *protoName)
{
- for (int i = 0; i < protoSettings.getCount(); i++)
- if (!strncmp(protoSettings[i].m_szName, protoName, mir_strlen(protoSettings[i].m_szName)))
- return &protoSettings[i];
+ for (auto &it : protoSettings)
+ if (!strncmp(it->m_szName, protoName, mir_strlen(it->m_szName)))
+ return it;
return nullptr;
}
@@ -117,13 +117,13 @@ static void ProcessCommandLineOptions(TProtoSettings& protoSettings)
static void SetLastStatusMessages(TProtoSettings &ps)
{
- for (int i = 0; i < ps.getCount(); i++) {
- if (ps[i].m_status != ID_STATUS_LAST)
+ for (auto &it : ps) {
+ if (it->m_status != ID_STATUS_LAST)
continue;
char dbSetting[128];
- mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, ps[i].m_szName);
- ps[i].m_szMsg = db_get_wsa(0, SSMODULENAME, dbSetting);
+ mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, it->m_szName);
+ it->m_szMsg = db_get_wsa(0, SSMODULENAME, dbSetting);
}
}
@@ -141,9 +141,9 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0)
return 0;
- for (int i = 0; i < protoList.getCount(); i++) {
- if (!mir_strcmp(ack->szModule, protoList[i].m_szName)) {
- protoList[i].m_szName = "";
+ for (auto &it : protoList) {
+ if (!mir_strcmp(ack->szModule, it->m_szName)) {
+ it->m_szName = "";
log_debugA("StartupStatus: %s overridden by ME_PROTO_ACK, status will not be set", ack->szModule);
}
}
@@ -159,15 +159,15 @@ static int StatusChange(WPARAM, LPARAM lParam)
char *szProto = (char *)lParam;
if (szProto == nullptr) { // global status change
- for (int i = 0; i < protoList.getCount(); i++) {
- protoList[i].m_szName = "";
+ for (auto &it : protoList) {
+ it->m_szName = "";
log_debugA("StartupStatus: all protos overridden by ME_CLIST_STATUSMODECHANGE, status will not be set");
}
}
else {
- for (int i = 0; i < protoList.getCount(); i++) {
- if (!mir_strcmp(protoList[i].m_szName, szProto)) {
- protoList[i].m_szName = "";
+ for (auto &it : protoList) {
+ if (!mir_strcmp(it->m_szName, szProto)) {
+ it->m_szName = "";
log_debugA("StartupStatus: %s overridden by ME_CLIST_STATUSMODECHANGE, status will not be set", szProto);
}
}