diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-16 20:01:14 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-16 20:01:14 +0300 |
commit | 39390b02dbd5aa7eb21a83773fa561b39f8828bc (patch) | |
tree | 7982eda1257f7466b5663c2865fdb7804c397257 /plugins/Sessions/Src | |
parent | 5046973a41e412afd06d6a78a3b9bce226e3cf50 (diff) |
always hated these long expressions: contact_iter makes them much shorter
Diffstat (limited to 'plugins/Sessions/Src')
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 12 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index 303fcf3fd5..6ee67026ad 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -204,7 +204,7 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l GetDlgItemText(hdlg, IDC_LIST, szUserSessionName, _countof(szUserSessionName));
szUserSessionName[length + 1] = '\0';
if (IsDlgButtonChecked(hdlg, IDC_SELCONTACTS) && bSC) {
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
BYTE res = (BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, hContact, 0), 0);
if (res) {
user_session_list[i] = hContact;
@@ -408,7 +408,7 @@ int SaveSessionHandles(WPARAM, LPARAM lparam) return 1;
int k = 0;
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
if ((k = CheckForDuplicate(session_list, hContact)) != -1 && !(g_bExclHidden && !CheckContactVisibility(hContact))) {
AddSessionMark(hContact, lparam, '1');
AddInSessionOrder(hContact, lparam, k, 1);
@@ -528,7 +528,7 @@ int LoadSession(WPARAM, LPARAM lparam) if (session_list_recovered[0] && lparam == 256 && mode == 0)
memcpy(session_list_t, session_list_recovered, sizeof(session_list_t));
else
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
if (LoadContactsFromMask(hContact, mode, lparam)) {
int i = GetInSessionOrder(hContact, mode, lparam);
session_list_t[i] = hContact;
@@ -577,7 +577,7 @@ int LoadSession(WPARAM, LPARAM lparam) int DelUserDefSession(int ses_count)
{
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
RemoveSessionMark(hContact, 1, ses_count);
SetInSessionOrder(hContact, 1, ses_count, 0);
}
@@ -613,7 +613,7 @@ int DelUserDefSession(int ses_count) int DeleteAutoSession(int ses_count)
{
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
RemoveSessionMark(hContact, 0, ses_count);
SetInSessionOrder(hContact, 0, ses_count, 0);
}
@@ -841,7 +841,7 @@ extern "C" __declspec(dllexport) int Load(void) int i = 0;
memset(session_list_recovered, 0, sizeof(session_list_recovered));
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
if (db_get_b(hContact, MODNAME, "wasInLastSession", 0))
session_list_recovered[i++] = hContact;
}
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index cfc378ff6e..f19d90c1e1 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -46,7 +46,7 @@ int OpLoadSessionContacts(WPARAM, LPARAM lparam) {
memset(session_list_t, 0, sizeof(session_list_t));
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
if (LoadContactsFromMask(hContact, 1, lparam)) {
int i = GetInSessionOrder(hContact, 1, lparam);
session_list_t[i] = hContact;
@@ -314,7 +314,7 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l if (!hOpClistControl)
EnableWindow(GetDlgItem(hdlg, IDC_DEL), TRUE);
else {
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
for (int i = 0; session_list_t[i] > 0; i++) {
@@ -361,7 +361,7 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l case IDC_SAVE:
{
int i = 0;
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
BYTE res = (BYTE)SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_GETCHECKMARK,
SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, hContact, 0), 0);
if (res) {
|