summaryrefslogtreecommitdiff
path: root/plugins/WebView/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-16 20:01:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-16 20:01:14 +0300
commit39390b02dbd5aa7eb21a83773fa561b39f8828bc (patch)
tree7982eda1257f7466b5663c2865fdb7804c397257 /plugins/WebView/src
parent5046973a41e412afd06d6a78a3b9bce226e3cf50 (diff)
always hated these long expressions: contact_iter makes them much shorter
Diffstat (limited to 'plugins/WebView/src')
-rw-r--r--plugins/WebView/src/main.cpp2
-rw-r--r--plugins/WebView/src/webview.cpp8
-rw-r--r--plugins/WebView/src/webview_datawnd.cpp2
-rw-r--r--plugins/WebView/src/webview_services.cpp11
4 files changed, 11 insertions, 12 deletions
diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp
index 3ba57dd526..3053895860 100644
--- a/plugins/WebView/src/main.cpp
+++ b/plugins/WebView/src/main.cpp
@@ -70,7 +70,7 @@ void ChangeContactStatus(int con_stat)
if (con_stat == 3)
status_code = ID_STATUS_NA;
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ for (auto &hContact : contact_iter(MODULENAME))
db_set_w(hContact, MODULENAME, "Status", status_code);
}
diff --git a/plugins/WebView/src/webview.cpp b/plugins/WebView/src/webview.cpp
index 9c77b5e6af..f15977bb1d 100644
--- a/plugins/WebView/src/webview.cpp
+++ b/plugins/WebView/src/webview.cpp
@@ -94,7 +94,7 @@ void FillFontListThread(void *param)
/*****************************************************************************/
void TxtclrLoop()
{
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ for (auto &hContact : contact_iter(MODULENAME)) {
HWND hwndDlg = WindowList_Find(hWindowList, hContact);
SetDlgItemText(hwndDlg, IDC_DATA, L"");
InvalidateRect(hwndDlg, nullptr, 1);
@@ -104,7 +104,7 @@ void TxtclrLoop()
/*****************************************************************************/
void BGclrLoop()
{
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ for (auto &hContact : contact_iter(MODULENAME)) {
HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
SetDlgItemText(hwndDlg, IDC_DATA, L"");
SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, BackgoundClr);
@@ -118,7 +118,7 @@ void StartUpdate(void*)
StartUpDelay = 1;
Sleep(((db_get_dw(NULL, MODULENAME, START_DELAY_KEY, 0)) * SECOND));
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ for (auto &hContact : contact_iter(MODULENAME))
GetData((void*)hContact);
StartUpDelay = 0;
@@ -128,7 +128,7 @@ void StartUpdate(void*)
void ContactLoop(void*)
{
if (StartUpDelay == 0) {
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ for (auto &hContact : contact_iter(MODULENAME)) {
GetData((void*)hContact);
Sleep(10); // avoid 100% CPU
}
diff --git a/plugins/WebView/src/webview_datawnd.cpp b/plugins/WebView/src/webview_datawnd.cpp
index bbbed64265..b467e396f1 100644
--- a/plugins/WebView/src/webview_datawnd.cpp
+++ b/plugins/WebView/src/webview_datawnd.cpp
@@ -128,7 +128,7 @@ static MCONTACT FindContactByUrl(HWND hwndDlg)
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, _countof(urltext));
GetWindowText(hwndDlg, titlebartxt, _countof(titlebartxt));
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ for (auto &hContact : contact_iter(MODULENAME)) {
ptrW db1( db_get_wsa(hContact, MODULENAME, URL_KEY));
ptrW db2( db_get_wsa(hContact, MODULENAME, PRESERVE_NAME_KEY));
diff --git a/plugins/WebView/src/webview_services.cpp b/plugins/WebView/src/webview_services.cpp
index 83c6fde0ae..585b85fe77 100644
--- a/plugins/WebView/src/webview_services.cpp
+++ b/plugins/WebView/src/webview_services.cpp
@@ -250,7 +250,7 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM)
// Make sure no contact has offline status for any reason on first time run
if ( db_get_b(NULL, MODULENAME, "FirstTime", 100) == 100) {
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ for (auto &hContact : contact_iter(MODULENAME))
db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
db_set_b(NULL, MODULENAME, "FirstTime", 1);
@@ -332,7 +332,6 @@ INT_PTR AddToList(WPARAM, LPARAM lParam)
{
PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *) lParam;
DBVARIANT dbv;
- MCONTACT hContact;
int sameurl = 0;
int samename = 0;
@@ -346,7 +345,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam)
if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
return NULL;
// search for existing contact
- for (hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ for (auto &hContact : contact_iter(MODULENAME)) {
// check ID to see if the contact already exist in the database
if (db_get_ws(hContact, MODULENAME, "URL", &dbv))
continue;
@@ -363,7 +362,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam)
db_free(&dbv);
}
- hContact = db_add_contact();
+ MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, MODULENAME);
/////////write to db
@@ -399,7 +398,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam)
wchar_t *Nend = wcschr(Newnick, '.');
if (Nend) *Nend = '\0';
- for (MCONTACT hContact2 = db_find_first(MODULENAME); hContact2 != NULL; hContact2 = db_find_next(hContact2, MODULENAME)) {
+ for (auto &hContact2 : contact_iter(MODULENAME)) {
if (!db_get_ws(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
if (!mir_wstrcmpi(Newnick, dbv.ptszVal)) {
// remove the flag for not on list and hidden, thus make the
@@ -457,6 +456,6 @@ INT_PTR GetInfo(WPARAM, LPARAM)
/*****************************************************************************/
void AckFunc(void*)
{
- for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ for (auto &hContact : contact_iter(MODULENAME))
ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}