From 477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 21 Feb 2018 18:40:03 +0300 Subject: all another C++'11 iterators --- plugins/GmailNotifier/src/check.cpp | 9 ++++----- plugins/GmailNotifier/src/main.cpp | 8 ++++---- plugins/GmailNotifier/src/options.cpp | 8 ++++---- plugins/GmailNotifier/src/utility.cpp | 15 +++++++-------- 4 files changed, 19 insertions(+), 21 deletions(-) (limited to 'plugins/GmailNotifier/src') diff --git a/plugins/GmailNotifier/src/check.cpp b/plugins/GmailNotifier/src/check.cpp index 0d642a8a42..88cafca600 100644 --- a/plugins/GmailNotifier/src/check.cpp +++ b/plugins/GmailNotifier/src/check.cpp @@ -141,11 +141,10 @@ void __cdecl Check_ThreadFunc(void *lpParam) NotifyUser((Account *)lpParam); } else { - for (int i = 0; i < g_accs.getCount(); i++) { - Account &acc = g_accs[i]; - if (GetContactProto(acc.hContact)) { - CheckMailInbox(&acc); - NotifyUser(&acc); + for (auto &it : g_accs) { + if (GetContactProto(it->hContact)) { + CheckMailInbox(it); + NotifyUser(it); } } } diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp index 3fc69d130d..3a715ca048 100644 --- a/plugins/GmailNotifier/src/main.cpp +++ b/plugins/GmailNotifier/src/main.cpp @@ -133,8 +133,8 @@ extern "C" int __declspec(dllexport) Load() BuildList(); ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; - for (int i = 0; i < g_accs.getCount(); i++) - db_set_dw(g_accs[i].hContact, MODULE_NAME, "Status", ID_STATUS_NONEW); + for (auto &it : g_accs) + db_set_dw(it->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW); hTimer = SetTimer(nullptr, 0, opt.circleTime * 60000, TimerProc); hMirandaStarted = HookEvent(ME_SYSTEM_MODULESLOADED, OnMirandaStart); @@ -162,8 +162,8 @@ extern "C" int __declspec(dllexport) Unload(void) if (hTimer) KillTimer(nullptr, hTimer); - for (int i = 0; i < g_accs.getCount(); i++) - DeleteResults(g_accs[i].results.next); + for (auto &it : g_accs) + DeleteResults(it->results.next); g_accs.destroy(); Netlib_CloseHandle(hNetlibUser); diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp index a3f781c8b1..cc2bd0ffa9 100644 --- a/plugins/GmailNotifier/src/options.cpp +++ b/plugins/GmailNotifier/src/options.cpp @@ -46,8 +46,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA optionWindowIsOpen = TRUE; BuildList(); - for (int i = 0; i < g_accs.getCount(); i++) - SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LONG_PTR)g_accs[i].name); + for (auto &it : g_accs) + SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LONG_PTR)it->name); SendMessage(hwndCombo, CB_SETCURSEL, curIndex, 0); if (curIndex < g_accs.getCount()) SetDlgItemTextA(hwndDlg, IDC_PASS, g_accs[curIndex].pass); @@ -256,8 +256,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA db_set_dw(NULL, MODULE_NAME, "LogThreads", opt.LogThreads); ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; - for (int i = 0; i < g_accs.getCount(); i++) - db_set_w(g_accs[i].hContact, MODULE_NAME, "Status", ID_STATUS_NONEW); + for (auto &it : g_accs) + db_set_w(it->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW); } return TRUE; diff --git a/plugins/GmailNotifier/src/utility.cpp b/plugins/GmailNotifier/src/utility.cpp index cadc6820db..840ff28a3c 100644 --- a/plugins/GmailNotifier/src/utility.cpp +++ b/plugins/GmailNotifier/src/utility.cpp @@ -19,12 +19,11 @@ void BuildList(void) } } - for (int i = 0; i < g_accs.getCount(); i++) { - Account &acc = g_accs[i]; - char *tail = strchr(acc.name, '@'); + for (auto &acc : g_accs) { + char *tail = strchr(acc->name, '@'); if (tail && mir_strcmp(tail + 1, "gmail.com") != 0) - mir_strcpy(acc.hosted, tail + 1); - acc.IsChecking = false; + mir_strcpy(acc->hosted, tail + 1); + acc->IsChecking = false; } } @@ -70,9 +69,9 @@ BOOL GetBrowser(char *str) Account* GetAccountByContact(MCONTACT hContact) { - for (int i = 0; i < g_accs.getCount(); i++) - if (g_accs[i].hContact == hContact) - return &g_accs[i]; + for (auto &it : g_accs) + if (it->hContact == hContact) + return it; return nullptr; } -- cgit v1.2.3