summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/IcqOscarJ/src')
-rw-r--r--protocols/IcqOscarJ/src/icq_infoupdate.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_server.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.cpp17
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp14
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp37
6 files changed, 17 insertions, 57 deletions
diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
index 8ebdcbd7bf..b4f443aa2c 100644
--- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp
+++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
@@ -126,7 +126,7 @@ void CIcqProto::icq_RescanInfoUpdate()
bInfoUpdateEnabled = 0; // freeze thread
// Queue all outdated users
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ for (auto &hContact : acc_contact_iter())
if (IsMetaInfoChanged(hContact)) // Queue user
if (!icq_QueueUser(hContact)) { // The queue is full, pause queuing contacts
bInfoPendingUsers = 1;
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp
index 25ba07ecd5..21b99bdd01 100644
--- a/protocols/IcqOscarJ/src/icq_proto.cpp
+++ b/protocols/IcqOscarJ/src/icq_proto.cpp
@@ -259,7 +259,7 @@ int CIcqProto::OnModulesLoaded(WPARAM, LPARAM)
ModuleLoad(0, 0);
InitXStatusItems(FALSE);
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ for (auto &hContact : acc_contact_iter()) {
DWORD bXStatus = getContactXStatus(hContact);
if (bXStatus > 0)
setContactExtraIcon(hContact, bXStatus);
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp
index 00c7f46806..b71737b5c6 100644
--- a/protocols/IcqOscarJ/src/icq_server.cpp
+++ b/protocols/IcqOscarJ/src/icq_server.cpp
@@ -178,7 +178,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam)
StopAvatarThread();
// Offline all contacts
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ for (auto &hContact : acc_contact_iter()) {
if (getContactStatus(hContact) == ID_STATUS_OFFLINE)
continue;
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp
index 54602dd8f5..b61fee4701 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.cpp
+++ b/protocols/IcqOscarJ/src/icq_servlist.cpp
@@ -858,9 +858,7 @@ void CIcqProto::LoadServerIDs()
nGroups = nServerIDListCount - nStart;
- MCONTACT hContact = db_find_first(m_szModuleName);
-
- while (hContact) { // search all our contacts, reserve their server IDs
+ for (auto &hContact : acc_contact_iter()) {
if (wSrvID = getWord(hContact, DBSETTING_SERVLIST_ID, 0)) {
ReserveServerID(wSrvID, SSIT_ITEM, 0);
nContacts++;
@@ -877,8 +875,6 @@ void CIcqProto::LoadServerIDs()
ReserveServerID(wSrvID, SSIT_ITEM, 0);
nIgnores++;
}
-
- hContact = db_find_next(hContact, m_szModuleName);
}
l.unlock();
@@ -1201,9 +1197,7 @@ void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count)
MCONTACT hContact;
WORD wItemID;
- hContact = db_find_first(m_szModuleName);
-
- while (hContact) { // search all contacts
+ for (auto &hContact : acc_contact_iter()) {
if (wGroupID == getWord(hContact, DBSETTING_SERVLIST_GROUP, 0)) { // add only buddys from specified group
wItemID = getWord(hContact, DBSETTING_SERVLIST_ID, 0);
@@ -1214,8 +1208,6 @@ void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count)
if (!count) break;
}
}
-
- hContact = db_find_next(hContact, m_szModuleName);
}
if (count)
@@ -1231,8 +1223,7 @@ void* CIcqProto::collectGroups(int *count)
int i;
WORD wGroupID;
- MCONTACT hContact = db_find_first(m_szModuleName);
- while (hContact) { // search all contacts
+ for (auto &hContact : acc_contact_iter()) {
if (wGroupID = getWord(hContact, DBSETTING_SERVLIST_GROUP, 0)) { // add only valid IDs
for (i = 0; i < cnt; i++) // check for already added ids
if (buf[i] == wGroupID)
@@ -1244,8 +1235,6 @@ void* CIcqProto::collectGroups(int *count)
buf[i] = wGroupID;
}
}
-
- hContact = db_find_next(hContact, m_szModuleName);
}
*count = cnt << 1;
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp
index b841f1eade..5991d7cfcc 100644
--- a/protocols/IcqOscarJ/src/icq_uploadui.cpp
+++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp
@@ -52,8 +52,7 @@ static void UpdateAllContactsCheckmark(HWND hwndList, CIcqProto* ppro, HANDLE ph
{
int check = 1;
- MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact) {
+ for (auto &hContact : ppro->acc_contact_iter()) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
if (!SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { // if any of our contacts is unchecked, uncheck all contacts as well
@@ -61,7 +60,6 @@ static void UpdateAllContactsCheckmark(HWND hwndList, CIcqProto* ppro, HANDLE ph
break;
}
}
- hContact = db_find_next(hContact, ppro->m_szModuleName);
}
SendMessage(hwndList, CLM_SETCHECKMARK, (WPARAM)phItemAll, check);
@@ -74,8 +72,7 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
int bAll = 1;
bListInit = 1; // lock CLC events
- MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact) {
+ for (auto &hContact : ppro->acc_contact_iter()) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
if (ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0))
@@ -83,7 +80,6 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
else
bAll = 0;
}
- hContact = db_find_next(hContact, ppro->m_szModuleName);
}
// Update the "All contacts" checkmark
@@ -97,7 +93,7 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
static void DeleteOtherContactsFromControl(HWND hCtrl, CIcqProto* ppro)
{
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
HANDLE hItem = (HANDLE)SendMessage(hCtrl, CLM_FINDCONTACT, hContact, 0);
if (hItem)
if (!ppro->IsICQContact(hContact))
@@ -835,12 +831,10 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
if (nm->flags&CLNF_ISINFO) {
int check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
- hContact = db_find_first(ppro->m_szModuleName);
- while (hContact) {
+ for (auto &hContact : ppro->acc_contact_iter()) {
HANDLE hItem = (HANDLE)SendMessage(hClist, CLM_FINDCONTACT, hContact, 0);
if (hItem)
SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItem, check);
- hContact = db_find_next(hContact, ppro->m_szModuleName);
}
}
else UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index e7af9c8a33..ceaa122129 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -355,15 +355,11 @@ void CIcqProto::InitContactsCache()
// build cache
mir_cslock l(contactsCacheMutex);
- MCONTACT hContact = db_find_first(m_szModuleName);
-
- while (hContact) {
+ for (auto &hContact : acc_contact_iter()) {
DWORD dwUin;
uid_str szUid;
if (!getContactUid(hContact, &dwUin, &szUid))
AddToContactsCache(hContact, dwUin, szUid);
-
- hContact = db_find_next(hContact, m_szModuleName);
}
}
@@ -421,17 +417,12 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added)
if (hContact)
return hContact;
- hContact = db_find_first(m_szModuleName);
- while (hContact) {
- DWORD dwContactUin;
-
- dwContactUin = getContactUin(hContact);
+ for (auto &hContact : acc_contact_iter()) {
+ DWORD dwContactUin = getContactUin(hContact);
if (dwContactUin == dwUin) {
AddToContactsCache(hContact, dwUin, nullptr);
return hContact;
}
-
- hContact = db_find_next(hContact, m_szModuleName);
}
// not present: add
@@ -489,8 +480,7 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added)
if (hContact)
return hContact;
- hContact = db_find_first(m_szModuleName);
- while (hContact) {
+ for (auto &hContact : acc_contact_iter()) {
DWORD dwContactUin;
uid_str szContactUid;
if (!getContactUid(hContact, &dwContactUin, &szContactUid)) {
@@ -501,7 +491,6 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added)
return hContact;
}
}
- hContact = db_find_next(hContact, m_szModuleName);
}
//not present: add
@@ -811,9 +800,7 @@ void CIcqProto::ResetSettingsOnListReload()
setWord("SrvRecordCount", 0);
delSetting(DBSETTING_SERVLIST_UNHANDLED);
- MCONTACT hContact = db_find_first(m_szModuleName);
-
- while (hContact) {
+ for (auto &hContact : acc_contact_iter()) {
// All these values will be restored during the serv-list receive
setWord(hContact, DBSETTING_SERVLIST_ID, 0);
setWord(hContact, DBSETTING_SERVLIST_GROUP, 0);
@@ -822,8 +809,6 @@ void CIcqProto::ResetSettingsOnListReload()
delSetting(hContact, DBSETTING_SERVLIST_IGNORE);
setByte(hContact, "Auth", 0);
delSetting(hContact, DBSETTING_SERVLIST_DATA);
-
- hContact = db_find_next(hContact, m_szModuleName);
}
FlushSrvGroupsCache();
@@ -835,9 +820,7 @@ void CIcqProto::ResetSettingsOnConnect()
setByte("SrvVisibility", 0);
setDword("IdleTS", 0);
- MCONTACT hContact = db_find_first(m_szModuleName);
-
- while (hContact) {
+ for (auto &hContact : acc_contact_iter()) {
setDword(hContact, "LogonTS", 0);
setDword(hContact, "IdleTS", 0);
setDword(hContact, "TickTS", 0);
@@ -846,8 +829,6 @@ void CIcqProto::ResetSettingsOnConnect()
// All these values will be restored during the login
if (getContactStatus(hContact) != ID_STATUS_OFFLINE)
setWord(hContact, "Status", ID_STATUS_OFFLINE);
-
- hContact = db_find_next(hContact, m_szModuleName);
}
}
@@ -856,9 +837,7 @@ void CIcqProto::ResetSettingsOnLoad()
setDword("IdleTS", 0);
setDword("LogonTS", 0);
- MCONTACT hContact = db_find_first(m_szModuleName);
-
- while (hContact) {
+ for (auto &hContact : acc_contact_iter()) {
setDword(hContact, "LogonTS", 0);
setDword(hContact, "IdleTS", 0);
setDword(hContact, "TickTS", 0);
@@ -870,8 +849,6 @@ void CIcqProto::ResetSettingsOnLoad()
delSetting(hContact, DBSETTING_XSTATUS_MSG);
}
setByte(hContact, "DCStatus", 0);
-
- hContact = db_find_next(hContact, m_szModuleName);
}
}