diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-09 20:03:46 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-09 20:03:46 +0000 |
commit | bcb27264ba737778e5d3edad36088bacf74f0236 (patch) | |
tree | fd1f57744dd380b7babe312a0ab5dc60b48854f2 | |
parent | 940231dc5a484b03a278900e1880aa083472b601 (diff) |
- short function names allows to write database loops in one string;
- 'continue' operator can be used then;
- multiple bugs fixed in clists;
- code becomes much more compact;
git-svn-id: http://svn.miranda-ng.org/main/trunk@4403 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
156 files changed, 1025 insertions, 2099 deletions
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 46908870fa..4cd2748660 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -423,31 +423,24 @@ INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case 0:
switch (((LPNMHDR) lParam)->code) {
case PSN_APPLY:
- {
- for (int i = 0; i < ListView_GetItemCount(hwndList); i++) {
- char *szProto = GetProtoFromList(hwndDlg, i);
+ for (int i = 0; i < ListView_GetItemCount(hwndList); i++) {
+ char *szProto = GetProtoFromList(hwndDlg, i);
- BOOL oldVal = db_get_b(NULL, AVS_MODULE, szProto, 1);
- BOOL newVal = ListView_GetCheckState(hwndList, i);
+ BOOL oldVal = db_get_b(NULL, AVS_MODULE, szProto, 1);
+ BOOL newVal = ListView_GetCheckState(hwndList, i);
- if (oldVal && !newVal)
- {
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- char* szContactProto = GetContactProto(hContact);
- if (szContactProto != NULL && !strcmp(szContactProto, szProto))
- DeleteAvatarFromCache(hContact, TRUE);
-
- hContact = db_find_next(hContact);
- }
+ if (oldVal && !newVal) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szContactProto = GetContactProto(hContact);
+ if (szContactProto != NULL && !strcmp(szContactProto, szProto))
+ DeleteAvatarFromCache(hContact, TRUE);
}
-
- if (newVal)
- db_set_b(NULL, AVS_MODULE, szProto, 1);
- else
- db_set_b(NULL, AVS_MODULE, szProto, 0);
}
+
+ if (newVal)
+ db_set_b(NULL, AVS_MODULE, szProto, 1);
+ else
+ db_set_b(NULL, AVS_MODULE, szProto, 0);
}
}
}
diff --git a/plugins/AuthState/src/main.cpp b/plugins/AuthState/src/main.cpp index 14e3159a1d..74226b8b43 100644 --- a/plugins/AuthState/src/main.cpp +++ b/plugins/AuthState/src/main.cpp @@ -169,11 +169,8 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) hExtraIcon = ExtraIcon_Register("authstate", LPGEN("Auth State"), "authgrant_icon");
// Set initial value for all contacts
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
onExtraImageApplying((WPARAM)hContact, 1);
- hContact = db_find_next(hContact);
- }
hOptInitialise = HookEvent(ME_OPT_INITIALISE, onOptInitialise);
if (bContactMenuItem)
diff --git a/plugins/AuthState/src/options.cpp b/plugins/AuthState/src/options.cpp index 43f6118658..e7d3961b60 100644 --- a/plugins/AuthState/src/options.cpp +++ b/plugins/AuthState/src/options.cpp @@ -54,13 +54,9 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP bUseGrantIcon = IsDlgButtonChecked(hwndDlg, IDC_GRANTICON);
bContactMenuItem = IsDlgButtonChecked(hwndDlg, IDC_ENABLEMENUITEM);
bIconsForRecentContacts = IsDlgButtonChecked(hwndDlg, IDC_ICONSFORRECENT);
- {
- HANDLE hContact = db_find_first();
- while (hContact) {
- onExtraImageApplying((WPARAM)hContact,0);
- hContact = db_find_next(hContact);
- }
- }
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ onExtraImageApplying((WPARAM)hContact,0);
//Store options values to DB
db_set_b(NULL, MODULENAME, "EnableAuthIcon", bUseAuthIcon);
diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index acbd8c31ad..a9d3ebb6d8 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -179,10 +179,9 @@ static BOOL CheckAllContactsOffline(void) {
BOOL fSmartCheck,fAllOffline=TRUE; /* tentatively */
fSmartCheck=db_get_b(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT);
- HANDLE hContact = db_find_first();
- while(hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *pszProto = GetContactProto(hContact);
- if(pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)!=ID_STATUS_OFFLINE)
+ if(pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)!=ID_STATUS_OFFLINE) {
if(db_get_b(hContact,pszProto,"ChatRoom",0)) continue;
if(db_get_w(hContact,pszProto,"Status",0)!=ID_STATUS_OFFLINE) {
if(fSmartCheck) {
@@ -192,7 +191,7 @@ static BOOL CheckAllContactsOffline(void) fAllOffline=FALSE;
break;
}
- hContact=db_find_next(hContact);
+ }
}
return fAllOffline;
}
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index e5cd9c7384..5902dc3de8 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -1773,27 +1773,19 @@ void HistoryWindow::ReloadContacts() }
}
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- if(EventList::GetContactMessageNumber(_hContact) && (metaContactProto == NULL || db_get_b(_hContact, metaContactProto, "IsSubcontact", 0) == 0))
+ HANDLE hContact;
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if(EventList::GetContactMessageNumber(hContact) && (metaContactProto == NULL || db_get_b(hContact, metaContactProto, "IsSubcontact", 0) == 0))
{
- HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
+ HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem == NULL)
- {
- SendMessage(contactList, CLM_ADDCONTACT, (WPARAM)_hContact, 0);
- }
+ SendMessage(contactList, CLM_ADDCONTACT, (WPARAM)hContact, 0);
}
- else
- {
- HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
+ else {
+ HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem != NULL)
- {
- SendMessage(contactList, CLM_DELETEITEM, (WPARAM)_hContact, 0);
- }
+ SendMessage(contactList, CLM_DELETEITEM, (WPARAM)hContact, 0);
}
-
- _hContact = db_find_next(_hContact);
}
if(hContact != NULL)
@@ -1944,17 +1936,14 @@ void HistoryWindow::SavePos(bool all) HANDLE contactToSave = hContact;
if(all)
{
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- db_unset(_hContact, MODULE, "history_x");
- db_unset(_hContact, MODULE, "history_y");
- db_unset(_hContact, MODULE, "history_width");
- db_unset(_hContact, MODULE, "history_height");
- db_unset(_hContact, MODULE, "history_ismax");
- db_unset(_hContact, MODULE, "history_splitterv");
- db_unset(_hContact, MODULE, "history_splitter");
- _hContact = db_find_next(_hContact);
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ db_unset(hContact, MODULE, "history_x");
+ db_unset(hContact, MODULE, "history_y");
+ db_unset(hContact, MODULE, "history_width");
+ db_unset(hContact, MODULE, "history_height");
+ db_unset(hContact, MODULE, "history_ismax");
+ db_unset(hContact, MODULE, "history_splitterv");
+ db_unset(hContact, MODULE, "history_splitter");
}
contactToSave = NULL;
@@ -2170,12 +2159,9 @@ void HistoryWindow::DoImport(IImport::ImportType type) std::vector<IImport::ExternalMessage> messages;
std::wstring err;
std::vector<HANDLE> contacts;
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- contacts.push_back(_hContact);
- _hContact = db_find_next(_hContact);
- }
+
+ for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ contacts.push_back(hContact);
bool changeContact = false;
HANDLE lastContact = hContact;
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp index 3e9283df10..8e3d159289 100644 --- a/plugins/BasicHistory/src/Options.cpp +++ b/plugins/BasicHistory/src/Options.cpp @@ -598,18 +598,12 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) sprintf_s(buf, "Task_zipPassword_%d", i);
db_set_s(0, MODULE, buf, it->zipPassword.c_str());
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- db_unset(_hContact, MODULE, buf);
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_unset(hContact, MODULE, buf);
for(size_t j = 0; j < it->contacts.size(); ++j)
- {
db_set_b(it->contacts[j], MODULE, buf, 1);
- }
it->orderNr = i++;
taskOptions.push_back(*it);
@@ -660,13 +654,9 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) sprintf_s(buf, "Task_taskName_%d", i);
db_unset(NULL, MODULE, buf);
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- db_unset(_hContact, MODULE, buf);
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_unset(hContact, MODULE, buf);
}
LeaveCriticalSection(&criticalSection);
@@ -758,17 +748,10 @@ void Options::LoadTasks() db_free(&var);
}
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- if(db_get_b(_hContact, MODULE, buf, 0) == 1)
- {
- to.contacts.push_back(_hContact);
- }
-
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if(db_get_b(hContact, MODULE, buf, 0) == 1)
+ to.contacts.push_back(hContact);
to.orderNr = i;
taskOptions.push_back(to);
@@ -1765,19 +1748,15 @@ void RebuildList(HWND hwnd, HANDLE hSystem, TaskOptions* to) void SaveList(HWND hwnd, HANDLE hSystem, TaskOptions* to)
{
- HANDLE hContact, hItem;
-
to->contacts.clear();
if (hSystem)
to->isSystem = SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM) hSystem, 0) != 0;
- hContact = db_find_first();
- do
- {
- hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) hContact, 0);
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) hContact, 0);
if (hItem && SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM) hItem, 0))
to->contacts.push_back(hContact);
}
- while (hContact = db_find_next(hContact));
}
bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top = NULL, std::wstring* err = NULL, std::wstring* errDescr = NULL);
diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index 54864b2e89..8ea3387b04 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -565,11 +565,8 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
- HANDLE hContact = db_find_first();
- char *proto;
- while (hContact != 0)
- {
- proto = GetContactProto(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *proto = GetContactProto(hContact);
if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULE_NAME, "StillAbsentNotified", 0) == 0))
{
db_set_b(hContact, MODULE_NAME, "StillAbsentNotified", 1);
@@ -596,8 +593,6 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) GoneNotify(hContact, message);
}
-
- hContact = db_find_next(hContact);
}
}
/**
@@ -712,15 +707,13 @@ extern "C" int __declspec(dllexport) Load(void) // ensure all contacts are timestamped
DBVARIANT dbv;
- HANDLE hContact = db_find_first();
DWORD current_time = (DWORD)time(0);
- while (hContact != 0) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if ( !db_get(hContact, MODULE_NAME, "CreationTime", &dbv))
db_free(&dbv);
else
db_set_dw(hContact, MODULE_NAME, "CreationTime", current_time);
-
- hContact = db_find_next(hContact);
}
return 0;
diff --git a/plugins/BuddyExpectator/src/options.cpp b/plugins/BuddyExpectator/src/options.cpp index 3cd321b1d7..18fe4fb056 100644 --- a/plugins/BuddyExpectator/src/options.cpp +++ b/plugins/BuddyExpectator/src/options.cpp @@ -247,14 +247,10 @@ static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, SaveOptions();
// clear all notified settings
- HANDLE hContact = db_find_first();
- while (hContact != 0) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if(db_get_b(hContact, MODULE_NAME, "StillAbsentNotified", 0))
db_set_b(hContact, MODULE_NAME, "StillAbsentNotified", 0);
- hContact = db_find_next(hContact);
- }
-
// restart timer & run check
KillTimer(0, timer_id);
timer_id = SetTimer(0, 0, 1000 * 60 * 60 * 4, TimerProc); // check every 4 hours
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 753a8f0682..3aa6b7e313 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -372,8 +372,7 @@ void cliRebuildEntireList(HWND hwnd,ClcData *dat) }
}
- hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *cacheEntry = NULL;
cont = NULL;
cacheEntry = pcli->pfnGetCacheEntry(hContact);
@@ -408,7 +407,6 @@ void cliRebuildEntireList(HWND hwnd,ClcData *dat) if (cont->proto && g_szMetaModuleName && dat->IsMetaContactsEnabled && strcmp(cont->proto,g_szMetaModuleName) == 0)
AddSubcontacts(dat,cont,CLCItems_IsShowOfflineGroup(group));
}
- hContact = db_find_next(hContact);
}
if (style & CLS_HIDEEMPTYGROUPS) {
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 592320f7c9..79f399a174 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -185,23 +185,19 @@ static void UpdateStickies() {
DWORD localMask;
int i;
- HANDLE hItem;
- HANDLE hContact = db_find_first();
- while(hContact)
- {
- hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, (BYTE)db_get_dw(hContact, CLVM_MODULE, g_szModename, 0) ? 1 : 0);
localMask = HIWORD(db_get_dw(hContact, CLVM_MODULE, g_szModename, 0));
UpdateClistItem(hItem, (localMask == 0 || localMask == stickyStatusMask) ? stickyStatusMask : localMask);
- hContact = db_find_next(hContact);
}
for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hInfoItem, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & stickyStatusMask ? i - ID_STATUS_OFFLINE : ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1));
- hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETNEXTITEM,CLGN_ROOT,0);
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETNEXTITEM,CLGN_ROOT,0);
hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP, (LPARAM)hItem);
while(hItem) {
for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
@@ -476,9 +472,7 @@ void SaveState() }
dwGlobalMask = GetMaskForItem(hInfoItem);
- hContact = db_find_first();
- while(hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
{
@@ -494,8 +488,8 @@ void SaveState() db_set_dw(hContact, CLVM_MODULE, szModeName, 0);
}
}
- hContact = db_find_next(hContact);
}
+
operators |= ((SendDlgItemMessage(clvmHwnd, IDC_PROTOGROUPOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_PROTOGROUP_OP : 0) |
(SendDlgItemMessage(clvmHwnd, IDC_GROUPSTATUSOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_GROUPSTATUS_OP : 0) |
(IsDlgButtonChecked(clvmHwnd, IDC_AUTOCLEAR) ? CLVM_AUTOCLEAR : 0) |
@@ -687,13 +681,10 @@ void DeleteViewMode( char * szName ) pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
SetWindowText(hwndSelector, TranslateT("All contacts"));
}
- HANDLE hContact = db_find_first();
- while(hContact)
- {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (db_get_dw(hContact, CLVM_MODULE, szName, -1) != -1)
db_set_dw(hContact, CLVM_MODULE, szName, 0);
- hContact = db_find_next(hContact);
- }
}
INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -879,12 +870,10 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
case IDC_CLEARALL:
{
- HANDLE hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 0);
- hContact = db_find_next(hContact);
}
}
case IDOK:
diff --git a/plugins/Clist_mw/src/clcitems.cpp b/plugins/Clist_mw/src/clcitems.cpp index 245afe3048..af48a8fd0f 100644 --- a/plugins/Clist_mw/src/clcitems.cpp +++ b/plugins/Clist_mw/src/clcitems.cpp @@ -323,7 +323,6 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) {
// char *szProto;
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
- HANDLE hContact;
struct ClcContact * cont;
ClcGroup *group;
//DBVARIANT dbv;
@@ -352,9 +351,7 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) }
}
- hContact = db_find_first();
- while(hContact) {
-
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *cacheEntry;
cont = NULL;
cacheEntry = GetContactFullCacheEntry(hContact);
@@ -389,7 +386,6 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) if (strcmp(cont->proto,"MetaContacts") == 0)
AddSubcontacts(cont);
}
- hContact = db_find_next(hContact);
}
if (style&CLS_HIDEEMPTYGROUPS) {
diff --git a/plugins/Clist_mw/src/clistmod.cpp b/plugins/Clist_mw/src/clistmod.cpp index 41a73e0041..b6879662c7 100644 --- a/plugins/Clist_mw/src/clistmod.cpp +++ b/plugins/Clist_mw/src/clistmod.cpp @@ -129,11 +129,8 @@ static int ContactListShutdownProc(WPARAM wParam,LPARAM lParam) int LoadContactListModule(void)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
db_set_s(hContact, "CList", "StatusMsg", "");
- hContact = db_find_next(hContact);
- }
hCListImages = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
DefaultImageListColorDepth = db_get_dw(NULL,"CList","DefaultImageListColorDepth",ILC_COLOR32);
diff --git a/plugins/Clist_mw/src/clistsettings.cpp b/plugins/Clist_mw/src/clistsettings.cpp index 28b69254ca..1bd75f0956 100644 --- a/plugins/Clist_mw/src/clistsettings.cpp +++ b/plugins/Clist_mw/src/clistsettings.cpp @@ -46,16 +46,13 @@ void InitDisplayNameCache(SortedList *list) list->sortFunc = (FSortFunc)handleCompare;
list->increment = CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;
- hContact = db_find_first();
i = 0;
- while (hContact != 0)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *pdnce = (ClcCacheEntry *)mir_calloc(sizeof(ClcCacheEntry));
pdnce->hContact = hContact;
InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
List_GetIndex(list,pdnce,&idx);
List_Insert(list,pdnce,idx);
- hContact = db_find_next(hContact);
i++;
} }
diff --git a/plugins/Clist_mw/src/contact.cpp b/plugins/Clist_mw/src/contact.cpp index bd2ad97052..589b11bbbc 100644 --- a/plugins/Clist_mw/src/contact.cpp +++ b/plugins/Clist_mw/src/contact.cpp @@ -82,9 +82,8 @@ void LoadContactTree(void) CallService(MS_CLUI_GROUPADDED, i, 0);
int hideOffline = db_get_b(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
- HANDLE hContact = db_find_first();
- while(hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *cacheEntry = GetContactFullCacheEntry(hContact);
if (cacheEntry == NULL) {
MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!",0);
@@ -93,7 +92,6 @@ void LoadContactTree(void) int status = cacheEntry->status;
if ((!hideOffline || status != ID_STATUS_OFFLINE) && !cacheEntry->bIsHidden)
ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact,(char*)cacheEntry->szProto,status),1);
- hContact = db_find_next(hContact);
}
sortByStatus = db_get_b(NULL,"CList","SortByStatus",SETTING_SORTBYSTATUS_DEFAULT);
sortByProto = db_get_b(NULL,"CList","SortByProto",SETTING_SORTBYPROTO_DEFAULT);
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 6f49e7c97c..ebb3a8c3d8 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -171,8 +171,7 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat) }
}
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (style & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(hContact, NULL, dat)) {
ZeroMemory((void *)&dbv, sizeof(dbv));
if (cfg::getTString(hContact, "CList", "Group", &dbv))
@@ -196,7 +195,6 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat) else AddContactToGroup(dat, group, hContact);
}
}
- hContact = db_find_next(hContact);
}
if (style & CLS_HIDEEMPTYGROUPS) {
diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index b96be53a52..4c572e4a31 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -111,20 +111,17 @@ extern TCHAR g_ptszEventName[]; void MF_UpdateThread(LPVOID)
{
- HANDLE hContact;
HANDLE hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, g_ptszEventName);
WaitForSingleObject(hEvent, 20000);
ResetEvent(hEvent);
while(mf_updatethread_running) {
- hContact = db_find_first();
- while (hContact != NULL && mf_updatethread_running) {
+ for (HANDLE hContact = db_find_first(); hContact && mf_updatethread_running; hContact = db_find_next(hContact)) {
MF_CalcFrequency(hContact, 50, 1);
if (mf_updatethread_running)
WaitForSingleObject(hEvent, 5000);
ResetEvent(hEvent);
- hContact = db_find_next(hContact);
}
if (mf_updatethread_running)
WaitForSingleObject(hEvent, 1000000);
@@ -137,7 +134,6 @@ static BOOL mc_hgh_removed = FALSE; void LoadContactTree(void)
{
- HANDLE hContact;
int i, status, hideOffline;
BOOL mc_disablehgh = ServiceExists(MS_MC_DISABLEHIDDENGROUP);
DBVARIANT dbv = {0};
@@ -151,8 +147,8 @@ void LoadContactTree(void) }
hideOffline = cfg::getByte("CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
status = GetContactStatus(hContact);
if ((!hideOffline || status != ID_STATUS_OFFLINE) && !CLVM_GetContactHiddenStatus(hContact, NULL, NULL))
pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(GetContactProto(hContact), status, hContact, NULL), 1);
@@ -168,8 +164,6 @@ void LoadContactTree(void) // build initial data for message frequency
if ( !bMsgFrequency)
MF_CalcFrequency(hContact, 100, 0);
-
- hContact = db_find_next(hContact);
}
cfg::writeByte("CList", "fhistdata", 1);
mc_hgh_removed = TRUE;
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index a41f0f5ff6..7e4f351407 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -1226,14 +1226,12 @@ void LoadPerContactSkins(TCHAR *tszFileName) char *p, *szProto, *uid, szItem[100];
char *szSections = reinterpret_cast<char *>(malloc(3002));
StatusItems_t *items = NULL, *this_item;
- HANDLE hContact;
int i = 1;
char file[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, tszFileName, MAX_PATH, file, MAX_PATH, 0, 0);
file[MAX_PATH - 1] = 0;
-
ReadItem(&default_item, "%Default", file);
ZeroMemory(szSections, 3000);
p = szSections;
@@ -1262,8 +1260,7 @@ void LoadPerContactSkins(TCHAR *tszFileName) }
if (items) {
- hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char UIN[40];
int j;
@@ -1318,7 +1315,6 @@ void LoadPerContactSkins(TCHAR *tszFileName) }
}
}
- hContact = db_find_next(hContact);
}
}
free(szSections);
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index d574c00e11..e40564d3ee 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -144,17 +144,15 @@ static DWORD GetMaskForItem(HANDLE hItem) static void UpdateStickies()
{
- HANDLE hContact = db_find_first();
HANDLE hItem;
int i;
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, cfg::getByte(hContact, "CLVM", g_szModename, 0) ? 1 : 0);
DWORD localMask = HIWORD(cfg::getDword(hContact, "CLVM", g_szModename, 0));
UpdateClistItem(hItem, (localMask == 0 || localMask == stickyStatusMask) ? stickyStatusMask : localMask);
- hContact = db_find_next(hContact);
}
for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
@@ -348,7 +346,7 @@ void SaveState() HWND hwndList;
char *szModeName = NULL;
DWORD statusMask = 0;
- HANDLE hContact, hItem;
+ HANDLE hItem;
DWORD operators = 0;
if (clvm_curItem == -1)
@@ -395,10 +393,10 @@ void SaveState() }
}
hwndList = GetDlgItem(clvmHwnd, IDC_STATUSMODES);
- for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
if (ListView_GetCheckState(hwndList, i - ID_STATUS_OFFLINE))
statusMask |= (1 << (i - ID_STATUS_OFFLINE));
- }
+
iLen = SendMessageA(GetDlgItem(clvmHwnd, IDC_VIEWMODES), LB_GETTEXTLEN, clvm_curItem, 0);
if (iLen) {
unsigned int stickies = 0;
@@ -408,16 +406,10 @@ void SaveState() szModeName = ( char* )malloc(iLen + 1);
if (szModeName) {
DWORD options, lmdat;
- //char *vastring = NULL;
- //int len = GetWindowTextLengthA(GetDlgItem(clvmHwnd, IDC_VARIABLES)) + 1;
-
- //vastring = (char *)malloc(len);
- //if (vastring)
- // GetDlgItemTextA(clvmHwnd, IDC_VARIABLES, vastring, len);
SendDlgItemMessageA(clvmHwnd, IDC_VIEWMODES, LB_GETTEXT, clvm_curItem, (LPARAM)szModeName);
dwGlobalMask = GetMaskForItem(hInfoItem);
- hContact = db_find_first();
- while(hContact) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem) {
if (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
@@ -425,13 +417,11 @@ void SaveState() cfg::writeDword(hContact, "CLVM", szModeName, MAKELONG(1, (unsigned short)dwLocalMask));
stickies++;
}
- else {
- if (cfg::getDword(hContact, "CLVM", szModeName, 0))
- cfg::writeDword(hContact, "CLVM", szModeName, 0);
- }
+ else if (cfg::getDword(hContact, "CLVM", szModeName, 0))
+ cfg::writeDword(hContact, "CLVM", szModeName, 0);
}
- hContact = db_find_next(hContact);
}
+
operators |= ((SendDlgItemMessage(clvmHwnd, IDC_PROTOGROUPOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_PROTOGROUP_OP : 0) |
(SendDlgItemMessage(clvmHwnd, IDC_GROUPSTATUSOP, CB_GETCURSEL, 0, 0) == 1 ? CLVM_GROUPSTATUS_OP : 0) |
(IsDlgButtonChecked(clvmHwnd, IDC_AUTOCLEAR) ? CLVM_AUTOCLEAR : 0) |
@@ -700,12 +690,10 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
SetWindowTextA(hwndSelector, Translate("No view mode"));
}
- hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (cfg::getDword(hContact, "CLVM", szBuf, -1) != -1)
cfg::writeDword(hContact, "CLVM", szBuf, 0);
- hContact = db_find_next(hContact);
- }
+
SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0);
if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) {
clvm_curItem = 0;
@@ -748,14 +736,10 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
case IDC_CLEARALL:
{
- HANDLE hItem;
- HANDLE hContact = db_find_first();
-
- while(hContact) {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 0);
- hContact = db_find_next(hContact);
}
}
case IDOK:
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 12d3dc78b7..18c39570e7 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1829,17 +1829,13 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r {
if (_stricmp(argv[2], "list") == 0)
{
- HANDLE hContact = NULL;
char buffer[1024];
char protocol[128];
-
- hContact = db_find_first();
+
int count = 0;
reply->code = MIMRES_SUCCESS;
- while (hContact)
- {
-
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
GetContactProto(hContact, protocol, sizeof(protocol));
char *contact = GetContactName(hContact, protocol);
@@ -1869,8 +1865,6 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r free(contact);
free(id);
-
- hContact = db_find_next(hContact);
}
}
else{
@@ -1878,14 +1872,11 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r {
if (argc > 3)
{
- HANDLE hContact = NULL;
char protocol[128];
- hContact = db_find_first();
reply->code = MIMRES_SUCCESS;
*reply->message = 0;
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
GetContactProto(hContact, protocol, sizeof(protocol));
char *contact = GetContactName(hContact, protocol);
@@ -1898,42 +1889,26 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r free(contact);
free(id);
-
- hContact = db_find_next(hContact);
}
}
- else{
- if (argc == 3)
- {
- HANDLE hContact = NULL;
- hContact = db_find_first();
-
- reply->code = MIMRES_SUCCESS;
- *reply->message = 0;
-
- while (hContact) {
- HANDLE hUnreadEvent = db_event_firstUnread(hContact);
- if (hUnreadEvent != NULL) {
- DWORD threadID;
- HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, hContact, NULL, &threadID);
- }
+ else if (argc == 3) {
+ reply->code = MIMRES_SUCCESS;
+ *reply->message = 0;
- hContact = db_find_next(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hUnreadEvent = db_event_firstUnread(hContact);
+ if (hUnreadEvent != NULL) {
+ DWORD threadID;
+ HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, hContact, NULL, &threadID);
}
}
- else {
- HandleWrongParametersCount(command, reply);
- }
}
+ else HandleWrongParametersCount(command, reply);
}
- else{
- HandleUnknownParameter(command, argv[2], reply);
- }
+ else HandleUnknownParameter(command, argv[2], reply);
}
}
- else{
- HandleWrongParametersCount(command, reply);
- }
+ else HandleWrongParametersCount(command, reply);
}
void AddHistoryEvent(DBEVENTINFO *dbEvent, char *contact, PReply reply)
@@ -1996,8 +1971,7 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re reply->code = MIMRES_SUCCESS;
mir_snprintf(reply->message, reply->cMessage, Translate("No unread messages found."));
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hEvent = db_event_firstUnread(hContact);
if (hEvent != NULL) {
count = 0;
@@ -2024,18 +1998,13 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re free(contact);
}
-
- hContact = db_find_next(hContact);
}
}
- else{
+ else {
if (_stricmp(cmd, "show") == 0)
- {
HandleWrongParametersCount(command, reply);
- }
- else{
+ else
HandleUnknownParameter(command, cmd, reply);
- }
}
break;
diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp index 626141e68f..1dddb04310 100644 --- a/plugins/CmdLine/src/utils.cpp +++ b/plugins/CmdLine/src/utils.cpp @@ -337,32 +337,27 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) #pragma warning (disable: 4312)
HANDLE GetContactFromID(TCHAR *szID, char *szProto)
{
- HANDLE hContact = db_find_first();
- TCHAR *szHandle;
TCHAR dispName[1024];
char cProtocol[256];
char *tmp;
int found = 0;
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
GetContactProto(hContact, cProtocol, sizeof(cProtocol));
- szHandle = GetContactID(hContact, cProtocol);
+ TCHAR *szHandle = GetContactID(hContact, cProtocol);
tmp = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0);
STRNCPY(dispName, tmp, sizeof(dispName));
if ((szHandle) && ((_tcsicmp(szHandle, szID) == 0) || (_tcsicmp(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0)))
- {
found = 1;
- }
- if (szHandle) { free(szHandle); }
+
+ if (szHandle) free(szHandle);
- if (found) { break; }
- hContact = db_find_next(hContact);
+ if (found) return hContact;
}
- return hContact;
+ return NULL;
}
#pragma warning (default: 4312)
diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp index 2406d660e6..5ec4620b46 100644 --- a/plugins/ContactsPlus/src/main.cpp +++ b/plugins/ContactsPlus/src/main.cpp @@ -94,8 +94,7 @@ static int HookDBEventAdded(WPARAM wParam, LPARAM lParam) static void ProcessUnreadEvents(void)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
DBEVENTINFO dbei = { sizeof(dbei) };
@@ -106,7 +105,6 @@ static void ProcessUnreadEvents(void) }
hDbEvent = db_event_next(hDbEvent);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp index ab109230ce..99a737cfd5 100644 --- a/plugins/CountryFlags/src/extraimg.cpp +++ b/plugins/CountryFlags/src/extraimg.cpp @@ -64,21 +64,15 @@ static void CALLBACK SetExtraImage(HANDLE hContact) // always call in context of main thread
static void RemoveExtraImages(void)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
ExtraIcon_Clear(hExtraIcon, hContact);
- hContact = db_find_next(hContact);
- }
}
// always call in context of main thread
static void EnsureExtraImages(void)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
SetExtraImage(hContact);
- hContact = db_find_next(hContact);
- }
}
static void CALLBACK UpdateExtraImages(LPARAM lParam)
diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp index fe3ec781d6..9a9772edb4 100644 --- a/plugins/DbEditorPP/src/copymodule.cpp +++ b/plugins/DbEditorPP/src/copymodule.cpp @@ -45,10 +45,7 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara {
int index, loaded;
char szProto[256];
- HANDLE hContact = db_find_first();
-
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto)))
loaded = IsProtocolLoaded(szProto);
else
@@ -56,10 +53,7 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara // filter
if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED))
- {
- hContact = db_find_next(hContact);
continue;
- }
// contacts name
DBVARIANT dbv ={0};
@@ -78,8 +72,7 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara else
mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)");
}
- else
- wcscpy(nick, nick_unknownW);
+ else wcscpy(nick, nick_unknownW);
}
else {
if (Order)
@@ -90,8 +83,6 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick);
SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact);
-
- hContact = db_find_next(hContact);
}
index = (int)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_INSERTSTRING, 0, (LPARAM)(char*)Translate("Settings"));
@@ -101,46 +92,33 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam);
TranslateDialogDefault(hwnd);
}
- else
- if (msg == WM_COMMAND)
+ else if (msg == WM_COMMAND)
{
- switch(LOWORD(wParam))
- {
- case CHK_COPY2ALL:
- EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),!IsDlgButtonChecked(hwnd,CHK_COPY2ALL));
+ switch(LOWORD(wParam)) {
+ case CHK_COPY2ALL:
+ EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),!IsDlgButtonChecked(hwnd,CHK_COPY2ALL));
break;
- case IDOK:
- {
- HANDLE hContact;
- if (!IsDlgButtonChecked(hwnd,CHK_COPY2ALL))
- {
- hContact = (HANDLE)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL, 0, 0), 0);
+ case IDOK:
+ if (!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)) {
+ HANDLE hContact = (HANDLE)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL, 0, 0), 0);
+ copyModule(mac->module, mac->hContact, hContact);
+ }
+ else {
+ SetCursor(LoadCursor(NULL,IDC_WAIT));
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
copyModule(mac->module, mac->hContact, hContact);
- }
- else
- {
- SetCursor(LoadCursor(NULL,IDC_WAIT));
- hContact = db_find_first();
-
- while (hContact)
- {
- copyModule(mac->module, mac->hContact, hContact);
- hContact = db_find_next(hContact);
- }
- SetCursor(LoadCursor(NULL,IDC_ARROW));
- }
- mir_free(mac);
- refreshTree(1);
- DestroyWindow(hwnd);
+ SetCursor(LoadCursor(NULL,IDC_ARROW));
}
+ mir_free(mac);
+ refreshTree(1);
+ DestroyWindow(hwnd);
break;
- case IDCANCEL:
- {
- mir_free(mac);
- DestroyWindow(hwnd);
- }
+
+ case IDCANCEL:
+ mir_free(mac);
+ DestroyWindow(hwnd);
break;
}
}
diff --git a/plugins/DbEditorPP/src/deletemodule.cpp b/plugins/DbEditorPP/src/deletemodule.cpp index 15998e74ad..5ceab04a3f 100644 --- a/plugins/DbEditorPP/src/deletemodule.cpp +++ b/plugins/DbEditorPP/src/deletemodule.cpp @@ -35,25 +35,20 @@ void __cdecl PopulateModuleDropListThreadFunc(LPVOID di) HWND hwnd = (HWND)di;
ModuleSettingLL msll;
struct ModSetLinkLinkItem *module;
- HANDLE hContact;
int moduleEmpty;
if (!EnumModules(&msll)) DestroyWindow(hwnd);
module = msll.first;
- while (module && working)
- {
+ while (module && working) {
moduleEmpty = 1;
// check the null
- if (!IsModuleEmpty(NULL,module->name))
- {
+ if (!IsModuleEmpty(NULL,module->name)) {
SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name);
moduleEmpty = 0;
module = (struct ModSetLinkLinkItem *)module->next;
continue;
}
- for (hContact = db_find_first();moduleEmpty && hContact;hContact = db_find_next(hContact))
- {
- if (!IsModuleEmpty(hContact,module->name))
- {
+ for (HANDLE hContact = db_find_first();moduleEmpty && hContact;hContact = db_find_next(hContact)) {
+ if (!IsModuleEmpty(hContact,module->name)) {
SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name);
moduleEmpty = 0;
break;
@@ -78,64 +73,52 @@ void __cdecl PopulateModuleDropListThreadFunc(LPVOID di) INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
- case WM_INITDIALOG:
- {
- SetWindowText(hwnd,Translate("Delete module from Database... Loading"));
- EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),0);
- EnableWindow(GetDlgItem(hwnd,IDOK),0);
- SetDlgItemText(hwnd,IDC_INFOTEXT,"Delete module from Database");
- SetDlgItemText(hwnd,CHK_COPY2ALL,"Delete module from all contacts (Includes Setting)");
- EnableWindow(GetDlgItem(hwnd,CHK_COPY2ALL),0);
- CheckDlgButton(hwnd,CHK_COPY2ALL,1);
- TranslateDialogDefault(hwnd);
- working = 1;
- forkthread(PopulateModuleDropListThreadFunc,0,hwnd);
- }
+ switch(msg) {
+ case WM_INITDIALOG:
+ SetWindowText(hwnd,Translate("Delete module from Database... Loading"));
+ EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),0);
+ EnableWindow(GetDlgItem(hwnd,IDOK),0);
+ SetDlgItemText(hwnd,IDC_INFOTEXT,"Delete module from Database");
+ SetDlgItemText(hwnd,CHK_COPY2ALL,"Delete module from all contacts (Includes Setting)");
+ EnableWindow(GetDlgItem(hwnd,CHK_COPY2ALL),0);
+ CheckDlgButton(hwnd,CHK_COPY2ALL,1);
+ TranslateDialogDefault(hwnd);
+ working = 1;
+ forkthread(PopulateModuleDropListThreadFunc,0,hwnd);
return TRUE;
- case WM_COMMAND:
- switch(LOWORD(wParam))
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDOK:
{
- case IDOK:
- {
- char text[128];
- HANDLE hContact = db_find_first();
- GetDlgItemText(hwnd,IDC_CONTACTS,text,128);
- SetCursor(LoadCursor(NULL,IDC_WAIT));
- while (hContact)
- {
- deleteModule(text,hContact,1);
- hContact = db_find_next(hContact);
- }
- // do the null
- deleteModule(text,NULL,1);
- SetCursor(LoadCursor(NULL,IDC_ARROW));
- refreshTree(1);
- }
- // fall through
- case IDCANCEL:
- {
- if (working == 1)
- {
- working = 0;
- EnableWindow(GetDlgItem(hwnd,IDCANCEL),0);
- }
- else
- DestroyWindow(hwnd);
- }
- break;
+ char text[128];
+ GetDlgItemText(hwnd,IDC_CONTACTS,text,128);
+ SetCursor(LoadCursor(NULL,IDC_WAIT));
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ deleteModule(text,hContact,1);
+
+ // do the null
+ deleteModule(text,NULL,1);
+ SetCursor(LoadCursor(NULL,IDC_ARROW));
+ refreshTree(1);
+ }
+ // fall through
+ case IDCANCEL:
+ if (working == 1) {
+ working = 0;
+ EnableWindow(GetDlgItem(hwnd,IDCANCEL),0);
}
+ else DestroyWindow(hwnd);
+ }
break;
- case WM_DESTROY:
- hwnd2Delete = NULL;
+
+ case WM_DESTROY:
+ hwnd2Delete = NULL;
break;
}
return 0;
}
-
-
void deleteModuleGui()
{
if (!hwnd2Delete)
diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index ed7aa6b371..f1e24cfc7c 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -329,32 +329,14 @@ void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. HANDLE CheckNewContact(char *myProto, char *uid, char *myName)
{
char szProto[256], szName[256];
- HANDLE resultHandle = INVALID_HANDLE_VALUE;
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, 256))
- {
if (!mir_strcmp(szProto, myProto))
- {
- if (GetValue(hContact, szProto, uid, szName, SIZEOF(szName)) &&
- !mir_strcmp(szName, myName))
- {
- //char msg[1024];
- //_snprintf(msg, 1024, Translate("Do you want to overwrite it \"%s\"?"), szName);
- //if (MessageBox(0,msg, Translate("Contact already exists"), MB_YESNO|MB_ICONEXCLAMATION) == IDYES)
- resultHandle = hContact;
- break;
- }
- }
- }
-
- hContact = db_find_next(hContact);
- }
-
- return resultHandle;
+ if (GetValue(hContact, szProto, uid, szName, SIZEOF(szName)) && !mir_strcmp(szName, myName))
+ return hContact;
+ return INVALID_HANDLE_VALUE;
}
HANDLE Clist_GroupExists(WCHAR *tszGroup)
diff --git a/plugins/DbEditorPP/src/modules.cpp b/plugins/DbEditorPP/src/modules.cpp index 898f581db3..aa4b77b6e5 100644 --- a/plugins/DbEditorPP/src/modules.cpp +++ b/plugins/DbEditorPP/src/modules.cpp @@ -61,21 +61,14 @@ INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam {
char modulename[256];
GetDlgItemText(hwnd, IDC_MODNAME, modulename, 256);
- if (IsDlgButtonChecked(hwnd,CHK_ADD2ALL))
- {
- HANDLE hContact = db_find_first();
+ if (IsDlgButtonChecked(hwnd,CHK_ADD2ALL)) {
// null contact
db_set_b(NULL, modulename, "(Default)", 0);
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
db_set_b(hContact, modulename, "(Default)", 0);
- hContact = db_find_next(hContact);
- }
- }
- else
- {
- db_set_b((HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA), modulename, "(Default)", 0);
}
+ else db_set_b((HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA), modulename, "(Default)", 0);
+
refreshTree(1);
}
}
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index f1e4f348c7..6e3f8f35fd 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -9,7 +9,6 @@ static ModuleTreeInfoStruct settings_mtis = {CONTACT, 0}; int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, HANDLE hSelectedContact, char *SelectedModule, char *SelectedSetting)
{
TVINSERTSTRUCT tvi;
- HANDLE hContact;
HTREEITEM contact;
ModuleTreeInfoStruct *lParam;
struct ModSetLinkLinkItem *module;
@@ -21,12 +20,10 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H SetWindowText(hwnd2mainWindow, Translate("Loading contacts..."));
- hContact = db_find_first();
-
tvi.hInsertAfter = TVI_SORT;
tvi.item.cChildren = 1;
- while (hContact && hwnd2mainWindow) { // break after null contact
+ for (HANDLE hContact = db_find_first(); hContact && hwnd2mainWindow; hContact = db_find_next(hContact)) {
char szProto[100];
if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) {
icon = GetProtoIcon(szProto);
@@ -40,10 +37,8 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H i++;
// filter
- if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) {
- hContact = db_find_next(hContact);
+ if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED))
continue;
- }
// add the contact
lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
@@ -122,8 +117,6 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule);
}
-
- hContact = db_find_next(hContact);
}
if (hItem != -1) {
diff --git a/plugins/Dbx_mmap_SA/src/security.cpp b/plugins/Dbx_mmap_SA/src/security.cpp index 8b075a37a0..04d7c82b49 100644 --- a/plugins/Dbx_mmap_SA/src/security.cpp +++ b/plugins/Dbx_mmap_SA/src/security.cpp @@ -186,15 +186,9 @@ int SelectEncoder() void CDbxMmapSA::EncodeAll()
{
- HANDLE hContact;
-
- hContact = db_find_first();
- if (hContact){
- do {
- EncodeContactEvents(hContact);
- EncodeContactSettings(hContact);
- }
- while(hContact = FindNextContact(hContact));
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ EncodeContactEvents(hContact);
+ EncodeContactSettings(hContact);
}
EncodeContactEvents(NULL);
@@ -203,14 +197,9 @@ void CDbxMmapSA::EncodeAll() void CDbxMmapSA::DecodeAll()
{
- HANDLE hContact;
-
- hContact = db_find_first();
- if (hContact){
- do{
- DecodeContactEvents(hContact);
- DecodeContactSettings(hContact);
- }while(hContact = db_find_next(hContact));
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ DecodeContactEvents(hContact);
+ DecodeContactSettings(hContact);
}
DecodeContactEvents(NULL);
DecodeContactSettings(NULL);
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index 1167d98f0d..0cfc3b4757 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -81,16 +81,12 @@ void CContactCache::Rebuild() unsigned long timestamp = time(NULL);
m_lastUpdate = time(NULL);
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
TContactInfo *info = new TContactInfo;
info->hContact = hContact;
info->rate = 0;
- HANDLE hEvent = db_event_last(hContact);
- while (hEvent)
- {
+ for (HANDLE hEvent = db_event_last(hContact); hEvent; hEvent = db_event_prev(hEvent)) {
DBEVENTINFO dbei = { sizeof(dbei) };
if (!db_event_get(hEvent, &dbei)) {
if (float weight = GetEventWeight(timestamp - dbei.timestamp))
@@ -100,11 +96,9 @@ void CContactCache::Rebuild() }
else break;
}
- hEvent = db_event_prev(hEvent);
}
m_cache.insert(info);
- hContact = db_find_next(hContact);
}
}
diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h index 40f44b6e6d..a9db3fb3dd 100644 --- a/plugins/FavContacts/src/favlist.h +++ b/plugins/FavContacts/src/favlist.h @@ -99,12 +99,10 @@ public: void build()
{
TCHAR *prevGroup = NULL;
- int i;
-
+
nGroups = 1;
- HANDLE hContact = db_find_first();
- for ( ; hContact; hContact = db_find_next(hContact))
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (db_get_b(hContact, "FavContacts", "IsFavourite", 0))
{
TCHAR *group = addContact(hContact, true)->getGroup();
@@ -114,9 +112,8 @@ public: }
int nRecent = 0;
- for (i = 0; nRecent < g_Options.wMaxRecent; ++i)
- {
- hContact = g_contactCache->get(i);
+ for (int i = 0; nRecent < g_Options.wMaxRecent; ++i) {
+ HANDLE hContact = g_contactCache->get(i);
if (!hContact) break;
if (!db_get_b(hContact, "FavContacts", "IsFavourite", 0))
{
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index fdef5aeb9b..3abcf07a58 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -231,8 +231,7 @@ int ProcessModulesLoaded(WPARAM wParam, LPARAM lParam) Hotkey_Register(&hotkey);
if (ServiceExists(MS_AV_GETAVATARBITMAP)) {
- HANDLE hContact = db_find_first();
- for ( ; hContact; hContact = db_find_next(hContact))
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (db_get_b(hContact, "FavContacts", "IsFavourite", 0))
CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
}
@@ -1097,50 +1096,43 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA static bool bInitialized = false;
static HANDLE hSelectedContact = 0;
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ bInitialized = false;
+
+ TranslateDialogDefault(hwnd);
+
+ CheckDlgButton(hwnd, IDC_CHK_GROUPS, g_Options.bUseGroups ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_GROUPCOLUMS, g_Options.bUseColumns ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_SECONDLINE, g_Options.bSecondLine ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_AVATARS, g_Options.bAvatars ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_AVATARBORDER, g_Options.bAvatarBorder ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_NOTRANSPARENTBORDER, g_Options.bNoTransparentBorder ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_SYSCOLORS, g_Options.bSysColors ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_CENTERHOTKEY, g_Options.bCenterHotkey ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_RIGHTAVATARS, g_Options.bRightAvatars ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHK_DIMIDLE, g_Options.bDimIdle ? BST_CHECKED : BST_UNCHECKED);
+ SetDlgItemInt(hwnd, IDC_TXT_RADIUS, g_Options.wAvatarRadius, FALSE);
+ SetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, g_Options.wMaxRecent, FALSE);
+
+ SetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE,
+ GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES);
+ SendMessage(GetDlgItem(hwnd, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0);
+ sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));
+
+ hSelectedContact = db_find_first();
{
- bInitialized = false;
-
- TranslateDialogDefault(hwnd);
-
- CheckDlgButton(hwnd, IDC_CHK_GROUPS, g_Options.bUseGroups ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_GROUPCOLUMS, g_Options.bUseColumns ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_SECONDLINE, g_Options.bSecondLine ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_AVATARS, g_Options.bAvatars ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_AVATARBORDER, g_Options.bAvatarBorder ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_NOTRANSPARENTBORDER, g_Options.bNoTransparentBorder ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_SYSCOLORS, g_Options.bSysColors ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_CENTERHOTKEY, g_Options.bCenterHotkey ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_RIGHTAVATARS, g_Options.bRightAvatars ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHK_DIMIDLE, g_Options.bDimIdle ? BST_CHECKED : BST_UNCHECKED);
- SetDlgItemInt(hwnd, IDC_TXT_RADIUS, g_Options.wAvatarRadius, FALSE);
- SetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, g_Options.wMaxRecent, FALSE);
-
- SetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE,
- GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES);
- SendMessage(GetDlgItem(hwnd, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0);
- sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));
-
- hSelectedContact = db_find_first();
-
- HANDLE hContact = db_find_first();
- for ( ; hContact; hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK,
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0),
- db_get_b(hContact, "FavContacts", "IsFavourite", 0));
- }
-
- bInitialized = true;
-
- PostMessage(hwnd, WM_APP, 0, 0);
-
- return TRUE;
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0),
+ db_get_b(hContact, "FavContacts", "IsFavourite", 0));
}
- case WM_APP:
+ bInitialized = true;
+ PostMessage(hwnd, WM_APP, 0, 0);
+ return TRUE;
+
+ case WM_APP:
{
BOOL bGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
EnableWindow(GetDlgItem(hwnd, IDC_CHK_GROUPCOLUMS), bGroups);
@@ -1151,20 +1143,18 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwnd, IDC_CHK_RIGHTAVATARS), bAvatars);
EnableWindow(GetDlgItem(hwnd, IDC_CHK_NOTRANSPARENTBORDER), bAvatars && bBorders);
EnableWindow(GetDlgItem(hwnd, IDC_TXT_RADIUS), bAvatars && bBorders);
- return TRUE;
}
+ return TRUE;
- case WM_DRAWITEM:
+ case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlID == IDC_CANVAS)
- {
+ if (lpdis->CtlID == IDC_CANVAS) {
MEASUREITEMSTRUCT mis = {0};
DRAWITEMSTRUCT dis = *lpdis;
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_BTNFACE));
- if (hSelectedContact)
- {
+ if (hSelectedContact) {
Options options;
options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
@@ -1192,128 +1182,107 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA rc.bottom = rc.top + mis.itemHeight;
FrameRect(lpdis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
}
-
return TRUE;
}
- return FALSE;
}
+ return FALSE;
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_CHK_SECONDLINE:
- case IDC_CHK_AVATARS:
- case IDC_CHK_AVATARBORDER:
- case IDC_CHK_NOTRANSPARENTBORDER:
- case IDC_CHK_SYSCOLORS:
- case IDC_CHK_CENTERHOTKEY:
- case IDC_CHK_GROUPS:
- case IDC_CHK_GROUPCOLUMS:
- case IDC_CHK_RIGHTAVATARS:
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
- PostMessage(hwnd, WM_APP, 0, 0);
- break;
-
- case IDC_BTN_FONTS:
- {
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(ood);
- ood.pszGroup = "Customize";
- ood.pszPage = "Fonts & Colors";
- ood.pszTab = NULL;
- Options_Open(&ood);
- }
- break;
-
- case IDC_TXT_RADIUS:
- if ((HIWORD(wParam) == EN_CHANGE) && bInitialized)
- {
- RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_CHK_SECONDLINE:
+ case IDC_CHK_AVATARS:
+ case IDC_CHK_AVATARBORDER:
+ case IDC_CHK_NOTRANSPARENTBORDER:
+ case IDC_CHK_SYSCOLORS:
+ case IDC_CHK_CENTERHOTKEY:
+ case IDC_CHK_GROUPS:
+ case IDC_CHK_GROUPCOLUMS:
+ case IDC_CHK_RIGHTAVATARS:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
+ PostMessage(hwnd, WM_APP, 0, 0);
+ break;
- case IDC_TXT_MAXRECENT:
- if ((HIWORD(wParam) == EN_CHANGE) && bInitialized)
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
+ case IDC_BTN_FONTS:
+ {
+ OPENOPTIONSDIALOG ood = { sizeof(ood) };
+ ood.pszGroup = "Customize";
+ ood.pszPage = "Fonts & Colors";
+ ood.pszTab = NULL;
+ Options_Open(&ood);
}
break;
- }
- case WM_NOTIFY:
- {
- if ((((LPNMHDR)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY))
- {
- g_Options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
- g_Options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
- g_Options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
- g_Options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER);
- g_Options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS);
- g_Options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
- g_Options.bUseGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
- g_Options.bUseColumns = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPCOLUMS);
- g_Options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
- g_Options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
- g_Options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE);
- g_Options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE);
-
- sttSaveOptions();
-
- HANDLE hContact = db_find_first();
- for ( ; hContact; hContact = db_find_next(hContact))
- {
- BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK,
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
- if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0))
- db_set_b(hContact, "FavContacts", "IsFavourite", fav);
- if (fav) CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
- }
- } else
- if (((LPNMHDR)lParam)->idFrom == IDC_CLIST)
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case CLN_OPTIONSCHANGED:
- {
- sttResetListOptions(GetDlgItem(hwnd,IDC_CLIST));
- break;
- }
+ case IDC_TXT_RADIUS:
+ if ((HIWORD(wParam) == EN_CHANGE) && bInitialized) {
+ RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
- case CLN_NEWCONTACT:
- {
- int iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
- HANDLE hContact = db_find_first();
- for ( ; hContact; hContact = db_find_next(hContact))
- if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection)
- {
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection,
- db_get_b(hContact, "FavContacts", "IsFavourite", 0));
- break;
- }
+ case IDC_TXT_MAXRECENT:
+ if ((HIWORD(wParam) == EN_CHANGE) && bInitialized)
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ if ((((LPNMHDR)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY)) {
+ g_Options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
+ g_Options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
+ g_Options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
+ g_Options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER);
+ g_Options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS);
+ g_Options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
+ g_Options.bUseGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
+ g_Options.bUseColumns = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPCOLUMS);
+ g_Options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
+ g_Options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
+ g_Options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE);
+ g_Options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE);
+
+ sttSaveOptions();
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK,
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
+ if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0))
+ db_set_b(hContact, "FavContacts", "IsFavourite", fav);
+ if (fav) CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
+ }
+ }
+ else if (((LPNMHDR)lParam)->idFrom == IDC_CLIST) {
+ int iSelection;
+
+ switch (((LPNMHDR)lParam)->code) {
+ case CLN_OPTIONSCHANGED:
+ sttResetListOptions(GetDlgItem(hwnd,IDC_CLIST));
+ break;
+
+ case CLN_NEWCONTACT:
+ iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection) {
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection,
+ db_get_b(hContact, "FavContacts", "IsFavourite", 0));
break;
}
+ }
+ break;
- case CLN_CHECKCHANGED:
- {
- int iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
- HANDLE hContact = db_find_first();
- for ( ; hContact; hContact = db_find_next(hContact))
- if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection)
- break;
- if (hContact)
- {
- hSelectedContact = hContact;
- RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
- }
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ case CLN_CHECKCHANGED:
+ iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection) {
+ hSelectedContact = hContact;
+ RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
}
}
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
- break;
}
+ break;
}
return FALSE;
diff --git a/plugins/FloatingContacts/src/main.cpp b/plugins/FloatingContacts/src/main.cpp index 4bf2de12d2..abc8cc508e 100644 --- a/plugins/FloatingContacts/src/main.cpp +++ b/plugins/FloatingContacts/src/main.cpp @@ -779,11 +779,8 @@ void SaveContactsPos() static void LoadContacts()
{
- HANDLE hContact = db_find_first() ;
- while( hContact != NULL ) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
LoadContact( hContact );
- hContact = db_find_next(hContact);
- }
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 70be70347b..2adbec5872 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -209,19 +209,13 @@ void SweepHistoryFromContact(HANDLE hContact, CriteriaStruct Criteria, BOOL keep void ShutdownAction(void)
{
CriteriaStruct Criteria;
- HANDLE hContact = db_find_first();
-
Criteria.keep = KeepCriteria(db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0));
Criteria.time = BuildCriteria(db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0));
SweepHistoryFromContact(NULL, Criteria, FALSE); // sweep system history, keepunread==0
- while ( hContact != NULL )
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
SweepHistoryFromContact(hContact, Criteria, TRUE); // sweep contact history, keepunread==1
-
- hContact = db_find_next(hContact); // go to next contact
- }
}
int OnWindowEvent(WPARAM wParam, LPARAM lParam)
diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp index 3508a6b8dc..0e96e3ad6f 100644 --- a/plugins/HistorySweeperLight/src/main.cpp +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -77,7 +77,6 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
StatusIconData sid = {0};
int i, sweep = db_get_b(NULL, ModuleName, "SweepHistory", 0);
- HANDLE hContact = db_find_first();
sid.cbSize = sizeof(sid);
sid.szModule = ModuleName;
@@ -119,8 +118,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
// for new contacts
- while ( hContact != NULL )
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ZeroMemory(&sid,sizeof(sid));
sweep = db_get_b(hContact, ModuleName, "SweepHistory", 0);
@@ -128,14 +126,11 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) sid.cbSize = sizeof(sid);
sid.szModule = ModuleName;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
sid.dwId = i;
sid.flags = (sweep == i) ? 0 : MBF_HIDDEN;
CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
}
-
- hContact = db_find_next(hContact);
}
hHooks[2] = HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp index d77d4946f9..06686fe2d6 100644 --- a/plugins/HistorySweeperLight/src/options.cpp +++ b/plugins/HistorySweeperLight/src/options.cpp @@ -102,17 +102,13 @@ void ResetListOptions(HWND hwndList) static void ShowAllContactIcons(HWND hwndList)
{
- HANDLE hContact, hItem;
-
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hAllContacts,
MAKELPARAM(0, db_get_b(NULL, ModuleName, "SweepHistory", 0)));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hSystemHistory,
MAKELPARAM(0, db_get_b(NULL, ModuleName, "SweepSHistory", 0)));
- for (hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem,
MAKELPARAM(0, db_get_b(hContact, ModuleName, "SweepHistory", 0)));
}
@@ -161,7 +157,8 @@ void LoadSettings(HWND hwndDlg) void SaveSettings(HWND hwndDlg)
{
- int st, i; StatusIconData sid = {0}; HANDLE hContact, hItem; HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+ int st, i; StatusIconData sid = {0};
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
db_set_b(NULL, ModuleName, "StartupShutdownOlder", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_GETCURSEL, 0, 0));
db_set_b(NULL, ModuleName, "StartupShutdownKeep", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_GETCURSEL, 0, 0));
@@ -177,10 +174,8 @@ void SaveSettings(HWND hwndDlg) db_set_b(NULL, ModuleName, "SweepSHistory",
(BYTE)SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hSystemHistory, 0));
- for (hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
st = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0);
if ( st != 0 ) db_set_b(hContact, ModuleName, "SweepHistory", (BYTE)st);
diff --git a/plugins/IgnoreState/src/main.cpp b/plugins/IgnoreState/src/main.cpp index 15deb3e489..bff3520324 100644 --- a/plugins/IgnoreState/src/main.cpp +++ b/plugins/IgnoreState/src/main.cpp @@ -141,11 +141,8 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) hExtraIcon = ExtraIcon_Register("ignore", LPGEN("Ignore State"), "ignore_full");
// Set initial value for all contacts
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
applyExtraImage(hContact);
- hContact = db_find_next(hContact);
- }
return 0;
}
diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp index ac83735f01..074b1236b9 100644 --- a/plugins/KeyboardNotify/src/ignore.cpp +++ b/plugins/KeyboardNotify/src/ignore.cpp @@ -188,22 +188,19 @@ static void SaveItemMask(HWND hwndList, HANDLE hContact, HANDLE hItem, const cha static void SetAllContactIcons(HWND hwndList)
{
- HANDLE hContact,hItem;
DWORD protoCaps;
- char *szProto;
- hContact=db_find_first();
- do {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 0)) == EMPTY_EXTRA_ICON) {
- szProto = GetContactProto(hContact);
+ char *szProto = GetContactProto(hContact);
if(szProto == NULL)
protoCaps = 0;
else
protoCaps = CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_1, 0);
InitialiseItem(hwndList, hContact, hItem, protoCaps);
}
- } while(hContact = db_find_next(hContact));
+ }
}
INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -316,14 +313,12 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA switch (((LPNMHDR)lParam)->code)
{
case PSN_APPLY:
- { HANDLE hContact, hItem;
-
- hContact = db_find_first();
- do {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem)
SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), hContact, hItem, "Mask1");
- } while(hContact = db_find_next(hContact));
+ }
SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemAll, "Default1");
SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemUnknown, "Mask1");
return TRUE;
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 62ecd7c48e..2f9933ca82 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -300,8 +300,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // Extra icon support
hExtraIcon = ExtraIcon_Register(MODULE_NAME, LPGEN("Listening to music"), "listening_to_icon");
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if (proto != NULL) {
DBVARIANT dbv;
@@ -312,8 +311,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) db_free(&dbv);
}
}
-
- hContact = db_find_next(hContact);
}
// Add main menu item
diff --git a/plugins/ListeningTo/src/players/mradio.cpp b/plugins/ListeningTo/src/players/mradio.cpp index d9f81fecb8..d8e23508a3 100644 --- a/plugins/ListeningTo/src/players/mradio.cpp +++ b/plugins/ListeningTo/src/players/mradio.cpp @@ -34,30 +34,13 @@ void MRadio::EnableDisable() int MRadio::GetData()
{
- HANDLE hContact;
+ for (HANDLE hContact = db_find_first("mRadio"); hContact; hContact = db_find_next(hContact, "mRadio")) {
+ WORD status = db_get_w(hContact, "mRadio", "Status", ID_STATUS_OFFLINE);
+ if (status != ID_STATUS_ONLINE)
+ continue;
- hContact = db_find_first();
- while (hContact != NULL)
- {
- char *proto = GetContactProto(hContact);
- if (proto)
- {
- if (strcmp("mRadio", proto) == 0)
- {
- WORD status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
- if (status == ID_STATUS_ONLINE)
- break;
- }
- }
-
- hContact = db_find_next(hContact);
- }
-
- if (hContact)
- {
- DBVARIANT dbv = {0};
- if (!db_get_s(hContact, "mRadio", "Nick", &dbv))
- {
+ DBVARIANT dbv;
+ if (!db_get_s(hContact, "mRadio", "Nick", &dbv)) {
listening_info.cbSize = sizeof(listening_info);
listening_info.dwFlags = LTI_TCHAR;
listening_info.ptszArtist = mir_tstrdup(_T("Radio"));
diff --git a/plugins/MetaContacts/src/meta_main.cpp b/plugins/MetaContacts/src/meta_main.cpp index 4b102b16d6..3361bdc475 100644 --- a/plugins/MetaContacts/src/meta_main.cpp +++ b/plugins/MetaContacts/src/meta_main.cpp @@ -151,8 +151,7 @@ extern "C" __declspec(dllexport) int Load(void) CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/WindowOpen"));
//set all contacts to 'offline', and initialize subcontact counter for db consistency check
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if (proto && !lstrcmpA( META_PROTO, proto)) {
db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE);
@@ -165,8 +164,6 @@ extern "C" __declspec(dllexport) int Load(void) db_set_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1);
}
}
-
- hContact = db_find_next(hContact);
}
Meta_ReadOptions(&options);
diff --git a/plugins/MetaContacts/src/meta_menu.cpp b/plugins/MetaContacts/src/meta_menu.cpp index 556eb5fe2d..815d4d4a0f 100644 --- a/plugins/MetaContacts/src/meta_menu.cpp +++ b/plugins/MetaContacts/src/meta_menu.cpp @@ -239,8 +239,7 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) return 0;
}
- HANDLE hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// This contact is assigned to the MetaContact that will be deleted, clear the "MetaContacts" information
if ( db_get_dw(hContact, META_PROTO, META_LINK,(DWORD)-1) == metaID) {
db_unset(hContact, META_PROTO, "IsSubcontact");
@@ -256,7 +255,6 @@ INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) if (options.suppress_status)
CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE);
}
- hContact = db_find_next(hContact);
}
NotifyEventHooks(hSubcontactsChanged, (WPARAM)wParam, 0);
diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp index 9403c24675..70ed20c633 100755 --- a/plugins/MetaContacts/src/meta_services.cpp +++ b/plugins/MetaContacts/src/meta_services.cpp @@ -611,15 +611,11 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) {
// import process has just been run...call startup routines...
Meta_SetHandles();
- {
- HANDLE hContact = db_find_first();
- while ( hContact != NULL ) {
- int meta_id;
- if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID,(DWORD)-1)) != (DWORD)-1)
- Meta_CopyData(hContact);
- hContact = db_find_next(hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ int meta_id;
+ if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID,(DWORD)-1)) != (DWORD)-1)
+ Meta_CopyData(hContact);
}
Meta_HideLinkedContacts();
@@ -1087,14 +1083,10 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) // loop and copy data from subcontacts
if (options.copydata) {
- HANDLE hContact = db_find_first();
int meta_id;
- while ( hContact != NULL ) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if ((meta_id = db_get_dw(hContact, META_PROTO, META_ID,(DWORD)-1))!=(DWORD)-1)
Meta_CopyData(hContact);
-
- hContact = db_find_next(hContact);
- }
}
Meta_HideLinkedContacts();
diff --git a/plugins/MetaContacts/src/meta_utils.cpp b/plugins/MetaContacts/src/meta_utils.cpp index 1587346323..365df63864 100644 --- a/plugins/MetaContacts/src/meta_utils.cpp +++ b/plugins/MetaContacts/src/meta_utils.cpp @@ -104,7 +104,6 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) {
char *field;
DBVARIANT dbv;
- HANDLE hUser;
DWORD i,res = 1;
// Get the field identifying the contact in the database.
char str[MAXMODULELABELLENGTH];
@@ -114,10 +113,10 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) return NULL;
field = (char *)CallProtoService(protocol,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
- hUser = db_find_first();
- while(hUser) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// Scan the database and retrieve the field for each contact
- if ( !db_get(hUser,protocol,field,&dbv)) {
+ if ( !db_get(hContact, protocol, field, &dbv)) {
if (dbv.type == id->type) {
// If the id parameter and the value returned by the db_get
// are the same, this is the correct HANDLE, return it.
@@ -126,21 +125,21 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) break;
case DBVT_BYTE:
if (dbv.bVal == id->bVal)
- return hUser;
+ return hContact;
break;
case DBVT_WORD:
if (dbv.wVal == id->wVal)
- return hUser;
+ return hContact;
break;
case DBVT_DWORD:
if (dbv.dVal == id->dVal)
- return hUser;
+ return hContact;
break;
case DBVT_ASCIIZ:
case DBVT_UTF8:
if ( !strcmp(dbv.pszVal,id->pszVal)) {
db_free(&dbv);
- return hUser;
+ return hContact;
}
db_free(&dbv);
break;
@@ -148,7 +147,7 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) case DBVT_WCHAR:
if ( !wcscmp(dbv.pwszVal,id->pwszVal)) {
db_free(&dbv);
- return hUser;
+ return hContact;
}
db_free(&dbv);
break;
@@ -159,7 +158,7 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) res = (dbv.pbVal[i] == id->pbVal[i]);
if (res) {
db_free(&dbv);
- return hUser;
+ return hContact;
}
}
db_free(&dbv);
@@ -168,8 +167,6 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) }
else db_free(&dbv);
}
- // This contact wasn't the good one, go to the next.
- hUser = db_find_next(hUser);
}
return NULL;
}
@@ -1004,17 +1001,14 @@ int Meta_HideLinkedContacts(void) { /** Unhide all contacts linked to any meta contact
*
*/
-int Meta_UnhideLinkedContacts(void) {
- HANDLE hContact = db_find_first();
-
- while ( hContact != NULL ) {
+int Meta_UnhideLinkedContacts(void)
+{
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_dw(hContact, META_PROTO, META_LINK,(DWORD)-1)!=(DWORD)-1) {
// has a link - unhide it
// restore old group
Meta_RestoreGroup(hContact);
}
-
- hContact = db_find_next(hContact);
}
if ( !CallService(MS_SYSTEM_TERMINATED, 0, 0))
@@ -1022,32 +1016,27 @@ int Meta_UnhideLinkedContacts(void) { return 0;
}
-int Meta_HideMetaContacts(int hide) {
- HANDLE hContact = db_find_first();
-
+int Meta_HideMetaContacts(int hide)
+{
// set status suppression
if (hide) Meta_SuppressStatus(FALSE);
else Meta_SuppressStatus(options.suppress_status);
- while ( hContact != NULL ) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_dw(hContact, META_PROTO, META_ID,(DWORD)-1)!=(DWORD)-1) {
// is a meta contact
-
if (hide)
db_set_b(hContact, "CList", "Hidden", 1);
else
db_unset(hContact, "CList", "Hidden");
-
- } else if (db_get_dw(hContact, META_PROTO, META_LINK,(DWORD)-1)!=(DWORD)-1) {
+ }
+ else if (db_get_dw(hContact, META_PROTO, META_LINK,(DWORD)-1)!=(DWORD)-1) {
// when metacontacts are hidden, show subcontacts, and vice versa
- if (hide) {
+ if (hide)
Meta_RestoreGroup(hContact);
- } else {
+ else
Meta_SetGroup(hContact);
- }
}
-
- hContact = db_find_next(hContact);
}
if ( !CallService(MS_SYSTEM_TERMINATED, 0, 0))
@@ -1201,10 +1190,9 @@ void Meta_GetStatusString(int status, TCHAR *buf, size_t size) }
}
-int Meta_SuppressStatus(BOOL suppress) {
- HANDLE hContact = db_find_first();
-
- while ( hContact != NULL ) {
+int Meta_SuppressStatus(BOOL suppress)
+{
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_dw(hContact, META_PROTO, META_LINK,(DWORD)-1)!=(DWORD)-1) {
// is a subcontact
if (suppress)
@@ -1212,8 +1200,6 @@ int Meta_SuppressStatus(BOOL suppress) { else
CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE);
}
-
- hContact = db_find_next(hContact);
}
return 0;
@@ -1258,17 +1244,14 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { int Meta_SetAllNicks()
{
- HANDLE hContact = db_find_first(), most_online;
-
- while ( hContact != NULL ) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_dw(hContact, META_PROTO, META_ID,(DWORD)-1)!=(DWORD)-1) {
- most_online = Meta_GetMostOnline(hContact);
+ HANDLE most_online = Meta_GetMostOnline(hContact);
Meta_CopyContactNick(hContact, most_online);
Meta_FixStatus(hContact);
Meta_CopyData(hContact);
}
-
- hContact = db_find_next(hContact);
+
}
return 0;
}
diff --git a/plugins/MirOTR/MirOTR/src/dllmain.cpp b/plugins/MirOTR/MirOTR/src/dllmain.cpp index 9d788fac89..84499c11c6 100644 --- a/plugins/MirOTR/MirOTR/src/dllmain.cpp +++ b/plugins/MirOTR/MirOTR/src/dllmain.cpp @@ -102,11 +102,8 @@ extern "C" __declspec(dllexport) int Load(void) // remove us as a filter to all contacts - fix filter type problem
if(db_get_b(0, MODULENAME, "FilterOrderFix", 0) != 2) {
- HANDLE hContact = db_find_first();
- while ( hContact != NULL ) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME);
- hContact = db_find_next(hContact);
- }
db_set_b(0, MODULENAME, "FilterOrderFix", 2);
}
diff --git a/plugins/MirOTR/MirOTR/src/options.cpp b/plugins/MirOTR/MirOTR/src/options.cpp index 27de2987ea..41ea5f8209 100644 --- a/plugins/MirOTR/MirOTR/src/options.cpp +++ b/plugins/MirOTR/MirOTR/src/options.cpp @@ -560,9 +560,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM const char *proto;
TCHAR *proto_t;
- HANDLE hContact = db_find_first();
- while ( hContact != NULL )
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
proto = contact_get_proto(hContact);
if(proto && db_get_b(hContact, proto, "ChatRoom", 0) == 0 && CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME) // ignore chatrooms
&& (g_metaproto == 0 || strcmp(proto, g_metaproto) != 0)) // and MetaContacts
@@ -580,13 +578,11 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM ListView_SetItemText(lv, lvI.iItem, 2, (TCHAR*)policy_to_string((OtrlPolicy)db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY)) );
ListView_SetItemText(lv, lvI.iItem, 3, (db_get_b(hContact, MODULENAME, "HTMLConv", 0))?TranslateT(LANG_YES):TranslateT(LANG_NO) );
}
-
-
- hContact = db_find_next(hContact);
}
}
return TRUE;
break;
+
case WM_COMMAND:
switch ( HIWORD( wParam )) {
case CBN_SELCHANGE:
diff --git a/plugins/MirOTR/MirOTR/src/utils.cpp b/plugins/MirOTR/MirOTR/src/utils.cpp index 148934b9cc..859d3b7be5 100644 --- a/plugins/MirOTR/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/MirOTR/src/utils.cpp @@ -18,9 +18,7 @@ void lib_cs_unlock() { }
HANDLE find_contact(const char* userid, const char* protocol) {
- HANDLE hContact = db_find_first();
- while ( hContact != NULL )
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
const char *proto = contact_get_proto(hContact);
if(proto && strcmp(proto, protocol) == 0) {
char *name = contact_get_id(hContact);
@@ -30,7 +28,6 @@ HANDLE find_contact(const char* userid, const char* protocol) { }
mir_free(name);
}
- hContact = db_find_next(hContact);
}
return 0;
diff --git a/plugins/MobileState/src/main.cpp b/plugins/MobileState/src/main.cpp index 66d41b83d6..ed72e1247f 100644 --- a/plugins/MobileState/src/main.cpp +++ b/plugins/MobileState/src/main.cpp @@ -100,11 +100,8 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) hExtraIcon = ExtraIcon_Register("mobilestate", LPGEN("Mobile State"), "mobile_icon");
// Set initial value for all contacts
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
ExtraIconsApply((WPARAM)hContact, 1);
- hContact = db_find_next(hContact);
- }
return 0;
}
diff --git a/plugins/ModernOpt/src/mopt_ignore.cpp b/plugins/ModernOpt/src/mopt_ignore.cpp index 97805ff4db..249ad5ae61 100644 --- a/plugins/ModernOpt/src/mopt_ignore.cpp +++ b/plugins/ModernOpt/src/mopt_ignore.cpp @@ -48,13 +48,11 @@ static void ResetListOptions(HWND hwndList) static void SetAllContactIcons(HWND hwndList, int count)
{
- HANDLE hContact=db_find_first();
- do {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DWORD hItem = SendMessage(hwndList,CLM_FINDCONTACT,(WPARAM)hContact,0);
for (int i = 0; i < count; ++i)
SendMessage(hwndList,CLM_SETEXTRAIMAGE,hItem,MAKELPARAM(i, i+1));
if (!db_get_b(hContact,"CList","Hidden",0))
SendMessage(hwndList,CLM_SETCHECKMARK,hItem,1);
}
- while(hContact=db_find_next(hContact));
}
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index b525503d2a..97888172ce 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -899,18 +899,11 @@ void UpdateFileToColWidth() {
clFileTo1ColWidth.clear();
- HANDLE hContact = db_find_first();
- for(;;)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
tstring sNick = NickFromHandle( hContact );
string::size_type &rnValue = clFileTo1ColWidth[ GetFilePathFromUser( hContact) ];
if (rnValue < sNick.size())
rnValue = sNick.size();
-
- if ( !hContact )
- break;
-
- hContact = db_find_next(hContact);
}
}
@@ -1602,16 +1595,10 @@ int nContactDeleted(WPARAM wparam,LPARAM /*lparam*/) tstring sFilePath = GetFilePathFromUser( hContact );
- { // Test if there is another user using this file
- for(HANDLE hOtherContact = db_find_first();hOtherContact;hOtherContact = db_find_next(hOtherContact))
- {
- if (hContact != hOtherContact && sFilePath == GetFilePathFromUser( hOtherContact))
- {
- return 0; // we found another contact abort mission :-)
- }
- }
- }
-
+ // Test if there is another user using this file
+ for(HANDLE hOtherContact = db_find_first();hOtherContact;hOtherContact = db_find_next(hOtherContact))
+ if (hContact != hOtherContact && sFilePath == GetFilePathFromUser( hOtherContact))
+ return 0; // we found another contact abort mission :-)
// Test to see if there is a file to delete
HANDLE hPrevFile = CreateFile( sFilePath.c_str(),
diff --git a/plugins/NewXstatusNotify/src/indsnd.cpp b/plugins/NewXstatusNotify/src/indsnd.cpp index 52f2456d10..6e7976a788 100644 --- a/plugins/NewXstatusNotify/src/indsnd.cpp +++ b/plugins/NewXstatusNotify/src/indsnd.cpp @@ -364,22 +364,18 @@ __inline void SetExtraImage(HWND hwndList, HANDLE hItem, int column, int imageID void SetAllContactsIcons(HWND hwndList)
{
BYTE EnableSounds, EnablePopups, EnableXStatus, EnableLogging;
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- {
+ if (hItem) {
char *szProto = GetContactProto(hContact);
- if (szProto)
- {
+ if (szProto) {
EnableSounds = db_get_b(hContact, MODULE, "EnableSounds", 1);
EnablePopups = db_get_b(hContact, MODULE, "EnablePopups", 1);
EnableXStatus = db_get_b(hContact, MODULE, "EnableXStatusNotify", 1);
EnableLogging = db_get_b(hContact, MODULE, "EnableLogging", 1);
}
- else
- EnableSounds = EnablePopups = EnableXStatus = EnableLogging = 0;
+ else EnableSounds = EnablePopups = EnableXStatus = EnableLogging = 0;
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_SOUND, EnableSounds ? EXTRA_IMAGE_SOUND : EXTRA_IMAGE_DOT);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_POPUP, EnablePopups? EXTRA_IMAGE_POPUP : EXTRA_IMAGE_DOT);
@@ -388,8 +384,6 @@ void SetAllContactsIcons(HWND hwndList) SetExtraImage(hwndList, hItem, EXTRA_IMAGE_DISABLEALL, EXTRA_IMAGE_DISABLEALL);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_ENABLEALL, EXTRA_IMAGE_ENABLEALL);
}
-
- hContact = db_find_next(hContact);
}
}
@@ -487,9 +481,8 @@ void SetAllChildrenIcons(HWND hwndList, HANDLE hFirstItem, int column, int image INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HANDLE hItemAll;
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
@@ -524,30 +517,27 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return TRUE;
}
- case WM_SETFOCUS:
- {
- SetFocus(GetDlgItem(hwndDlg, IDC_INDSNDLIST));
- break;
- }
- case WM_NOTIFY:
+ case WM_SETFOCUS:
+ SetFocus(GetDlgItem(hwndDlg, IDC_INDSNDLIST));
+ break;
+
+ case WM_NOTIFY:
{
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case IDC_INDSNDLIST:
- switch (((LPNMHDR)lParam)->code)
- {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- SetAllContactsIcons(hList);
- //fall through
- case CLN_CONTACTMOVED:
- SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
- break;
- case CLN_OPTIONSCHANGED:
- ResetListOptions(hList);
- break;
- case NM_CLICK:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case IDC_INDSNDLIST:
+ switch (((LPNMHDR)lParam)->code) {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ SetAllContactsIcons(hList);
+ //fall through
+ case CLN_CONTACTMOVED:
+ SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
+ break;
+ case CLN_OPTIONSCHANGED:
+ ResetListOptions(hList);
+ break;
+ case NM_CLICK:
{
NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
DWORD hitFlags;
@@ -582,18 +572,13 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM for (int i = 0; i < 4; i++)
SetExtraImage(hList, hItem, i, i);
}
- else
- {
- SetExtraImage(hList, hItem, nm->iColumn, image);
- }
+ else SetExtraImage(hList, hItem, nm->iColumn, image);
}
- else if (itemType == CLCIT_INFO || itemType == CLCIT_GROUP)
- {
+ else if (itemType == CLCIT_INFO || itemType == CLCIT_GROUP) {
if (itemType == CLCIT_GROUP)
hItem = (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
- if (hItem)
- {
+ if (hItem) {
if (image == EXTRA_IMAGE_DISABLEALL)
{
for (int i = 0; i < 4; i++)
@@ -604,10 +589,7 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM for (int i = 0; i < 4; i++)
SetAllChildrenIcons(hList, hItem, i, i);
}
- else
- {
- SetAllChildrenIcons(hList, hItem, nm->iColumn, image);
- }
+ else SetAllChildrenIcons(hList, hItem, nm->iColumn, image);
}
}
@@ -619,56 +601,45 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM }
}
break;
- case 0:
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HANDLE hContact = db_find_first();
- do
- {
- HANDLE hItem = (HANDLE)SendMessage(hList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- {
- if (GetExtraImage(hList, hItem, EXTRA_IMAGE_SOUND) == EXTRA_IMAGE_SOUND)
- db_unset(hContact, MODULE, "EnableSounds");
- else
- db_set_b(hContact, MODULE, "EnableSounds", 0);
-
- if (GetExtraImage(hList, hItem, EXTRA_IMAGE_POPUP) == EXTRA_IMAGE_POPUP)
- db_unset(hContact, MODULE, "EnablePopups");
- else
- db_set_b(hContact, MODULE, "EnablePopups", 0);
-
- if (GetExtraImage(hList, hItem, EXTRA_IMAGE_XSTATUS) == EXTRA_IMAGE_XSTATUS)
- db_unset(hContact, MODULE, "EnableXStatusNotify");
- else
- db_set_b(hContact, MODULE, "EnableXStatusNotify", 0);
-
- if (GetExtraImage(hList, hItem, EXTRA_IMAGE_LOGGING) == EXTRA_IMAGE_LOGGING)
- db_unset(hContact, MODULE, "EnableLogging");
- else
- db_set_b(hContact, MODULE, "EnableLogging", 0);
-
- }
- } while(hContact = db_find_next(hContact));
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem) {
+ if (GetExtraImage(hList, hItem, EXTRA_IMAGE_SOUND) == EXTRA_IMAGE_SOUND)
+ db_unset(hContact, MODULE, "EnableSounds");
+ else
+ db_set_b(hContact, MODULE, "EnableSounds", 0);
+
+ if (GetExtraImage(hList, hItem, EXTRA_IMAGE_POPUP) == EXTRA_IMAGE_POPUP)
+ db_unset(hContact, MODULE, "EnablePopups");
+ else
+ db_set_b(hContact, MODULE, "EnablePopups", 0);
+
+ if (GetExtraImage(hList, hItem, EXTRA_IMAGE_XSTATUS) == EXTRA_IMAGE_XSTATUS)
+ db_unset(hContact, MODULE, "EnableXStatusNotify");
+ else
+ db_set_b(hContact, MODULE, "EnableXStatusNotify", 0);
- return TRUE;
+ if (GetExtraImage(hList, hItem, EXTRA_IMAGE_LOGGING) == EXTRA_IMAGE_LOGGING)
+ db_unset(hContact, MODULE, "EnableLogging");
+ else
+ db_set_b(hContact, MODULE, "EnableLogging", 0);
+ }
}
+ return TRUE;
}
- break;
}
- break;
- }
- case WM_DESTROY:
- {
- HIMAGELIST hImageList = (HIMAGELIST)SendMessage(GetDlgItem(hwndDlg, IDC_INDSNDLIST), CLM_GETEXTRAIMAGELIST, 0, 0);
- for (int i = 0; i < ImageList_GetImageCount(hImageList); i++)
- DestroyIcon(ImageList_GetIcon(hImageList, i, ILD_NORMAL));
- ImageList_Destroy(hImageList);
- break;
}
+ break;
+
+ case WM_DESTROY:
+ HIMAGELIST hImageList = (HIMAGELIST)SendMessage(GetDlgItem(hwndDlg, IDC_INDSNDLIST), CLM_GETEXTRAIMAGELIST, 0, 0);
+ for (int i = 0; i < ImageList_GetImageCount(hImageList); i++)
+ DestroyIcon(ImageList_GetIcon(hImageList, i, ILD_NORMAL));
+ ImageList_Destroy(hImageList);
+ break;
}
return FALSE;
}
-
diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp index 4d16183422..ef236d16b4 100755 --- a/plugins/New_GPG/src/icons.cpp +++ b/plugins/New_GPG/src/icons.cpp @@ -95,11 +95,9 @@ void setSrmmIcon(HANDLE h) void RefreshContactListIcons()
{
CallService(MS_CLUI_LISTBEGINREBUILD,0,0);
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
setClistIcon(hContact);
- hContact = db_find_next(hContact);
- }
+
CallService(MS_CLUI_LISTENDREBUILD,0,0);
}
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 2c9f05b3e8..46a0aaa475 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -243,8 +243,6 @@ extern "C" int __declspec(dllexport) Load() extern list<wstring> transfers;
extern "C" int __declspec(dllexport) Unload(void)
{
-// for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
-// db_unset(hContact, szGPGModuleName, "KeyID_Prescense");
if(!transfers.empty())
{
for(list<wstring>::iterator p = transfers.begin(); p != transfers.end(); p++)
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index 26c7fd010e..eb65fc8184 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -145,10 +145,8 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT); int i = 1, iRow = 0; bool isContactHaveKey(HANDLE); - for(HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) - { - if(isContactHaveKey(hContact)) - { + for(HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { + if(isContactHaveKey(hContact)) { TCHAR *name = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); item.mask = LVIF_TEXT; item.iItem = i; @@ -241,13 +239,10 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP ismetacontact = true; } tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); - for(HANDLE hcnttmp = db_find_first(); hcnttmp != NULL; hcnttmp = db_find_next(hcnttmp)) - { - if(hcnttmp != hContact) - { + for(HANDLE hcnttmp = db_find_first(); hcnttmp != NULL; hcnttmp = db_find_next(hcnttmp)) { + if(hcnttmp != hContact) { char *tmp2 = UniGetContactSettingUtf(hcnttmp, szGPGModuleName, "KeyID", ""); - if(!strcmp(tmp, tmp2)) - { + if(!strcmp(tmp, tmp2)) { mir_free(tmp2); keep = true; break; diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 51f9bb8312..aa43bb7a50 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -1392,10 +1392,8 @@ void ExportGpGKeysFunc(int type) int exported_keys = 0;
if(!file.is_open())
return; //TODO: handle error
- if(!type || type == 2)
- {
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- {
+ if(!type || type == 2) {
+ for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *k = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", "");
if(!k[0])
{
@@ -1693,8 +1691,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) if(acc.length())
{
const char * uid = (const char*)CallProtoService(acc.c_str(), PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0);
- for(HANDLE hContact = db_find_first(acc.c_str()); hContact; hContact = db_find_next(hContact, acc.c_str()))
- {
+ for(HANDLE hContact = db_find_first(acc.c_str()); hContact; hContact = db_find_next(hContact, acc.c_str())) {
DBVARIANT dbv = {0};
DBCONTACTGETSETTING dbcgs = {0};
dbcgs.pValue = &dbv;
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index eb894a776b..44a3a4a5a7 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -153,8 +153,8 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0);
SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ HANDLE hContact;
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
DBVARIANT dbNick = {0};
if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
@@ -197,7 +197,6 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
db_free(&dbNick);
}
- hContact = db_find_next(hContact);
}
WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact);
Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg");
@@ -493,8 +492,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ListView_GetItemText(hwndList, sel, 0, nick, MAX_PATH);
ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH);
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(IsMyContact(hContact)) {
DBVARIANT dbNick = {0};
if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
@@ -514,7 +512,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA }
db_free(&dbNick);
}
- hContact = db_find_next(hContact);
}
}
return FALSE;
@@ -716,8 +713,8 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA HXML header = xi.addChild(hXml, _T("head"), NULL);
HXML title = xi.addChild(header, _T("title"), _T("Miranda NG NewsAggregator plugin export"));
header = xi.addChild(hXml, _T("body"), NULL);
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL;
DBVARIANT dbv = {0};
@@ -768,7 +765,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA mir_free(siteurl);
mir_free(group);
}
- hContact = db_find_next(hContact);
}
xi.toFile(hXml, FileName, 1);
xi.destroyNode(hXml);
@@ -789,12 +785,9 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case PSN_APPLY:
{
db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE));
- HANDLE hContact = db_find_first();
int i = 0;
- while (hContact != NULL)
- {
- if(IsMyContact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if(IsMyContact(hContact)) {
db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
if (!ListView_GetCheckState(hwndList, i))
db_set_b(hContact, "CList", "Hidden", 1);
@@ -802,7 +795,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA db_unset(hContact,"CList","Hidden");
i += 1;
}
- hContact = db_find_next(hContact);
}
break;
}
diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index 238e7f1145..da1c899b86 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -32,13 +32,10 @@ void SetContactStatus(HANDLE hContact, int nNewStatus) static void __cdecl WorkingThread(void* param)
{
int nStatus = (int)param;
- HANDLE hContact= db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if(IsMyContact(hContact))
SetContactStatus(hContact, nStatus);
-
- hContact = db_find_next(hContact);
- }
}
int OnFoldersChanged(WPARAM, LPARAM)
@@ -55,15 +52,14 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam) else
lstrcpyn(tszRoot, VARST( _T("%miranda_userdata%\\Avatars\\"_T(DEFAULT_AVATARS_FOLDER))), SIZEOF(tszRoot));
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(IsMyContact(hContact)) {
if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1))
db_set_dw(hContact, MODULE, "LastCheck", time(NULL));
SetContactStatus(hContact, ID_STATUS_ONLINE);
}
- hContact = db_find_next(hContact);
}
+
NetlibInit();
InitIcons();
InitMenu();
@@ -158,13 +154,11 @@ INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam) INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact) && lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(hContact);
else if (IsMyContact(hContact) && !lParam)
UpdateListAdd(hContact);
- hContact = db_find_next(hContact);
}
if (!ThreadRunning)
mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp index 1846b7271a..7acc0373cc 100644 --- a/plugins/NewsAggregator/Src/Update.cpp +++ b/plugins/NewsAggregator/Src/Update.cpp @@ -30,8 +30,7 @@ VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) // only run if it is not current updating and the auto update option is enabled
if (!ThreadRunning && !Miranda_Terminated()) {
BOOL HaveUpdates = FALSE;
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(IsMyContact(hContact)) {
if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) {
double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
@@ -41,7 +40,6 @@ VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) }
}
}
- hContact = db_find_next(hContact);
}
if (!ThreadRunning && HaveUpdates)
mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index d7efc461b6..745869e27d 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -239,9 +239,8 @@ VOID UpdateList(HWND hwndList) // Some code to create the list-view control.
// Initialize LVITEM members that are common to all
// items.
- HANDLE hContact = db_find_first();
int i = 0;
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
UpdateListFlag = TRUE;
lvI.mask = LVIF_TEXT;
@@ -263,7 +262,6 @@ VOID UpdateList(HWND hwndList) db_free(&dbNick);
}
}
- hContact = db_find_next(hContact);
}
UpdateListFlag = FALSE;
}
diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp index 5f9c256492..8dae1fe190 100644 --- a/plugins/NoHistory/src/options.cpp +++ b/plugins/NoHistory/src/options.cpp @@ -84,8 +84,7 @@ static void ResetListOptions(HWND hwndList) static void SetAllContactIcons(HWND hwndList)
{
- HANDLE hContact = db_find_first();
- do {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
@@ -97,7 +96,6 @@ static void SetAllContactIcons(HWND hwndList) }
}
}
- while(hContact = db_find_next(hContact));
}
static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -200,8 +198,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- HANDLE hContact = db_find_first();
- do {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
@@ -213,8 +210,6 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }
}
}
- while(hContact = db_find_next(hContact));
-
return TRUE;
}
}
diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp index 811bead19a..c8cca233be 100644 --- a/plugins/Popup/src/config.cpp +++ b/plugins/Popup/src/config.cpp @@ -103,18 +103,6 @@ void PopUpPreview() ppd.cbSize = sizeof(ppd);
ppd.flags = PU2_TCHAR;
-#if defined(_DEBUG)
- // test per-contact popups
- for (HANDLE hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
- if (db_get_dw(hContact, "ICQ", "UIN", 0) == 256771455)
- {
- ppd.lchContact = hContact;
- break;
- }
- }
-#endif
ppd.lptzTitle = lptzTitle1Eng;
ppd.lptzText = lptzText1Eng;
ppd.lchIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
@@ -128,30 +116,7 @@ void PopUpPreview() ppd.lptzText = lptzText2;
ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
ppd.hbmAvatar = hbmNoAvatar;
-#if defined(_DEBUG)
-//remove testactions
- POPUPACTION actions[3];
- actions[0].cbSize = sizeof(POPUPACTION);
- actions[0].flags = PAF_ENABLED;
- lstrcpyA(actions[0].lpzTitle, "Popup Plus/Test action");
- actions[0].lchIcon = IcoLib_GetIcon(ICO_POPUP_ON,0);
- actions[0].wParam = actions[0].lParam = -1;
-
- actions[1].cbSize = sizeof(POPUPACTION);
- actions[1].flags = PAF_ENABLED;
- lstrcpyA(actions[1].lpzTitle, "Popup Plus/Second test action");
- actions[1].lchIcon = IcoLib_GetIcon(ICO_ACT_CLOSE,0);
- actions[1].wParam = actions[1].lParam = -1;
-
- actions[2].cbSize = sizeof(POPUPACTION);
- actions[2].flags = PAF_ENABLED;
- lstrcpyA(actions[2].lpzTitle, "Popup Plus/One more action");
- actions[2].lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- actions[2].wParam = actions[2].lParam = -1;
-
- ppd.lpActions = actions;
- ppd.actionCount = SIZEOF(actions);
-#endif
+
CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY);
if (PopUpOptions.UseAnimations || PopUpOptions.UseEffect) Sleep((ANIM_TIME*2)/3); //Pause
diff --git a/plugins/Popup/src/opt_contacts.cpp b/plugins/Popup/src/opt_contacts.cpp index 84e528ea03..b19ee39359 100644 --- a/plugins/Popup/src/opt_contacts.cpp +++ b/plugins/Popup/src/opt_contacts.cpp @@ -28,9 +28,8 @@ static void sttSetAllContactIcons(HWND hwndList); INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
{
TranslateDialogDefault(hwnd);
@@ -40,7 +39,7 @@ INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l SendMessage(GetDlgItem(hwnd, IDC_ICO_BLOCK), STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_OPT_BLOCK,0), 0);
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),
- (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK,5,5);
+ (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK,5,5);
ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT));
ImageList_AddIcon(hIml, IcoLib_GetIcon(ICO_OPT_DEF,0));
ImageList_AddIcon(hIml, IcoLib_GetIcon(ICO_OPT_FAV,0));
@@ -54,75 +53,59 @@ INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l break;
}
- case WM_NOTIFY:
- {
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case IDC_LIST:
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case IDC_LIST:
+ switch (((LPNMHDR)lParam)->code) {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ sttSetAllContactIcons(GetDlgItem(hwnd,IDC_LIST));
+ break;
+ case CLN_OPTIONSCHANGED:
+ sttResetListOptions(GetDlgItem(hwnd,IDC_LIST));
+ break;
+ case NM_CLICK:
{
- switch (((LPNMHDR)lParam)->code)
- {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- sttSetAllContactIcons(GetDlgItem(hwnd,IDC_LIST));
- break;
- case CLN_OPTIONSCHANGED:
- sttResetListOptions(GetDlgItem(hwnd,IDC_LIST));
- break;
- case NM_CLICK:
- {
- HANDLE hItem;
- NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
- DWORD hitFlags;
- int iImage;
-
- if (nm->iColumn==-1) break;
- hItem=(HANDLE)SendDlgItemMessage(hwnd,IDC_LIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
- if (hItem==NULL) break;
- if (!(hitFlags&CLCHT_ONITEMEXTRA)) break;
-
- iImage = SendDlgItemMessage(hwnd,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0));
- if (iImage != EMPTY_EXTRA_ICON) {
- for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
- //hIml element [0] = SKINICON_OTHER_SMALLDOT
- //hIml element [1..5] = IcoLib_GetIcon(....) ~ old sttIcons
+ HANDLE hItem;
+ NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
+ DWORD hitFlags;
+ int iImage;
+
+ if (nm->iColumn==-1) break;
+ hItem=(HANDLE)SendDlgItemMessage(hwnd,IDC_LIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
+ if (hItem==NULL) break;
+ if (!(hitFlags&CLCHT_ONITEMEXTRA)) break;
+
+ iImage = SendDlgItemMessage(hwnd,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0));
+ if (iImage != EMPTY_EXTRA_ICON) {
+ for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
+ //hIml element [0] = SKINICON_OTHER_SMALLDOT
+ //hIml element [1..5] = IcoLib_GetIcon(....) ~ old sttIcons
SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, (i==nm->iColumn)?i+1:0));
- }
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- }
}
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
}
+ }
+ break;
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HWND hwndList = GetDlgItem(hwnd, IDC_LIST);
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
- HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
- {
- if (SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0)))
- {
- db_set_b(hContact, MODULNAME, "ShowMode", i);
- break;
- }
- }
- }
- return TRUE;
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ HWND hwndList = GetDlgItem(hwnd, IDC_LIST);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i) {
+ if (SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0))) {
+ db_set_b(hContact, MODULNAME, "ShowMode", i);
+ break;
}
}
- break;
}
+ return TRUE;
}
- break;
}
+ break;
}
return FALSE;
@@ -142,9 +125,7 @@ static void sttResetListOptions(HWND hwndList) static void sttSetAllContactIcons(HWND hwndList)
{
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
DWORD dwMode = db_get_b(hContact, MODULNAME, "ShowMode", 0);
for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp index c11f9c91af..1a978df72b 100644 --- a/plugins/QuickContacts/src/quickcontacts.cpp +++ b/plugins/QuickContacts/src/quickcontacts.cpp @@ -358,10 +358,8 @@ void LoadContacts(HWND hwndDlg, BOOL show_all) // enumerate all contacts and write them to the array
// item data of listbox-strings is the array position
FreeContacts();
- for(HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact))
- {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *pszProto = GetContactProto(hContact);
if(pszProto != NULL)
{
@@ -441,12 +439,9 @@ void LoadContacts(HWND hwndDlg, BOOL show_all) PROTOACCOUNT *acc = ProtoGetAccount(pszProto);
if (acc != NULL)
- {
lstrcpyn(contact->proto, acc->tszAccountName, SIZEOF(contact->proto));
- }
contact->hcontact = hContact;
-
contacts.insert(contact);
}
}
diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index edcd5806ab..c8b7d9afbf 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -298,7 +298,7 @@ INT_PTR Quotes_Export(WPARAM wp,LPARAM lp) }
else
{
- for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
{
CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact);
if(pProvider)
diff --git a/plugins/Rate/src/main.cpp b/plugins/Rate/src/main.cpp index f3d0c8c21d..4088de559d 100644 --- a/plugins/Rate/src/main.cpp +++ b/plugins/Rate/src/main.cpp @@ -106,11 +106,8 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) hExtraIcon = ExtraIcon_Register("contact_rate", LPGEN("Contact rate"), "rate_high");
// Set initial value for all contacts
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
setExtraIcon(hContact, -1, FALSE);
- hContact = db_find_next(hContact);
- }
return 0;
}
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp index 14df262de2..49cda03964 100644 --- a/plugins/SMS/src/SMS_svc.cpp +++ b/plugins/SMS/src/SMS_svc.cpp @@ -77,11 +77,12 @@ int SendSMSMenuCommand(WPARAM wParam,LPARAM lParam) EnableWindow(GetDlgItem(hwndSendSms,IDC_NAME),TRUE);
EnableWindow(GetDlgItem(hwndSendSms,IDC_SAVENUMBER),FALSE);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (GetContactPhonesCount(hContact)) {
SEND_DLG_ITEM_MESSAGEW(hwndSendSms,IDC_NAME,CB_ADDSTRING,0,(LPARAM)GetContactNameW(hContact));
SendSMSWindowSMSContactAdd(hwndSendSms,hContact);
}
+ }
}
return 0;
}
@@ -135,7 +136,7 @@ void RestoreUnreadMessageAlerts(void) for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
for (HANDLE hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
- dbei.cbBlob=0;
+ dbei.cbBlob = 0;
if (db_event_get(hDbEvent, &dbei) == 0)
if ((dbei.flags & (DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
@@ -143,7 +144,7 @@ void RestoreUnreadMessageAlerts(void) }
for (HANDLE hDbEvent = db_event_firstUnread(NULL); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
- dbei.cbBlob=0;
+ dbei.cbBlob = 0;
if (db_event_get(hDbEvent, &dbei) == 0)
if ((dbei.flags & (DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN)
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 6d6be46791..d65a512194 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -804,44 +804,44 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG if (dat->buffer == NULL) {
dat->bufferOffset = 0;
switch (dat->stage) {
- case STREAMSTAGE_HEADER:
- dat->buffer = CreateRTFHeader(dat->dlgDat, dat->gdat);
- dat->stage = STREAMSTAGE_EVENTS;
- break;
- case STREAMSTAGE_EVENTS:
- if (dat->events != NULL) {
- EventData *event = dat->events;
- dat->buffer = NULL;
- dat->buffer = CreateRTFFromEvent(dat->dlgDat, event, dat->gdat, dat);
- dat->events = event->next;
- freeEvent(event);
- } else if (dat->eventsToInsert) {
- do {
- EventData *event = getEventFromDB(dat->dlgDat, dat->hContact, dat->hDbEvent);
- dat->buffer = NULL;
- if (event != NULL) {
- dat->buffer = CreateRTFFromEvent(dat->dlgDat, event, dat->gdat, dat);
- freeEvent(event);
- }
- if (dat->buffer)
- dat->hDbEventLast = dat->hDbEvent;
- dat->hDbEvent = db_event_next(dat->hDbEvent);
- if (--dat->eventsToInsert == 0)
- break;
- } while (dat->buffer == NULL && dat->hDbEvent);
- }
- if (dat->buffer) {
- break;
- }
- dat->stage = STREAMSTAGE_TAIL;
- //fall through
- case STREAMSTAGE_TAIL:
- dat->buffer = CreateRTFTail();
- dat->stage = STREAMSTAGE_STOP;
+ case STREAMSTAGE_HEADER:
+ dat->buffer = CreateRTFHeader(dat->dlgDat, dat->gdat);
+ dat->stage = STREAMSTAGE_EVENTS;
+ break;
+ case STREAMSTAGE_EVENTS:
+ if (dat->events != NULL) {
+ EventData *event = dat->events;
+ dat->buffer = NULL;
+ dat->buffer = CreateRTFFromEvent(dat->dlgDat, event, dat->gdat, dat);
+ dat->events = event->next;
+ freeEvent(event);
+ } else if (dat->eventsToInsert) {
+ do {
+ EventData *event = getEventFromDB(dat->dlgDat, dat->hContact, dat->hDbEvent);
+ dat->buffer = NULL;
+ if (event != NULL) {
+ dat->buffer = CreateRTFFromEvent(dat->dlgDat, event, dat->gdat, dat);
+ freeEvent(event);
+ }
+ if (dat->buffer)
+ dat->hDbEventLast = dat->hDbEvent;
+ dat->hDbEvent = db_event_next(dat->hDbEvent);
+ if (--dat->eventsToInsert == 0)
+ break;
+ } while (dat->buffer == NULL && dat->hDbEvent);
+ }
+ if (dat->buffer) {
break;
- case STREAMSTAGE_STOP:
- *pcb = 0;
- return 0;
+ }
+ dat->stage = STREAMSTAGE_TAIL;
+ //fall through
+ case STREAMSTAGE_TAIL:
+ dat->buffer = CreateRTFTail();
+ dat->stage = STREAMSTAGE_STOP;
+ break;
+ case STREAMSTAGE_STOP:
+ *pcb = 0;
+ return 0;
}
dat->bufferLen = lstrlenA(dat->buffer);
}
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 4997af2a44..b39e6ef330 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -949,41 +949,33 @@ static void ResetCList(HWND hwndDlg) static void RebuildList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
BYTE defType = db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW);
-
- if (hItemNew && defType) {
+ if (hItemNew && defType)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItemNew, 1);
- }
- if (hItemUnknown && db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN)) {
+
+ if (hItemUnknown && db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItemUnknown, 1);
- }
- hContact = db_find_first();
- do {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
- if (hItem && db_get_b(hContact, SRMMMOD, SRMSGSET_TYPING, defType)) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem && db_get_b(hContact, SRMMMOD, SRMSGSET_TYPING, defType))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItem, 1);
- }
- } while ((hContact = db_find_next(hContact)));
+ }
}
static void SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
-
- if (hItemNew) {
+ if (hItemNew)
db_set_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItemNew, 0) ? 1 : 0));
- }
- if (hItemUnknown) {
+
+ if (hItemUnknown)
db_set_b(NULL, SRMMMOD, SRMSGSET_TYPINGUNKNOWN, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItemUnknown, 0) ? 1 : 0));
- }
- hContact = db_find_first();
- do {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
- if (hItem) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
+ if (hItem)
db_set_b(hContact, SRMMMOD, SRMSGSET_TYPING, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItem, 0) ? 1 : 0));
- }
- } while ((hContact = db_find_next(hContact)));
+ }
}
static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 6bda0dfb90..0eaf5158c8 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -276,8 +276,7 @@ static void RestoreUnreadMessageAlerts(void) cle.flags = CLEF_TCHAR;
cle.ptszTooltip = toolTip;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
dbei.cbBlob = 0;
@@ -303,7 +302,6 @@ static void RestoreUnreadMessageAlerts(void) }
hDbEvent = db_event_next(hDbEvent);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp index d5eacbd51b..5907fb5b62 100644 --- a/plugins/SecureIM/src/crypt_icons.cpp +++ b/plugins/SecureIM/src/crypt_icons.cpp @@ -107,12 +107,9 @@ void RefreshContactListIcons(void) for (int i=0; i < arIcoList.getCount(); i++)
arIcoList[i].hCLIcon = 0;
- HANDLE hContact = db_find_first();
- while (hContact) { // и снова зажигаем иконку
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (isSecureProtocol(hContact))
ShowStatusIcon(hContact);
- hContact = db_find_next(hContact);
- }
}
// EOF
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 784cb2378d..47d53a7878 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -118,11 +118,8 @@ void loadContactList() freeContactList();
loadSupportedProtocols();
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
addContact(hContact);
- hContact = db_find_next(hContact);
- }
}
// free list of secureIM users
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index 386fc023bf..795e88b14c 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -985,10 +985,9 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) LVITEM lvi; memset(&lvi,0,sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
- HANDLE hContact = db_find_first();
char tmp[NAMSIZE];
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
pUinKey ptr = getUinKey(hContact);
if (ptr && isSecureProtocol(hContact) && !isChatRoom(hContact)) {
if (iInit) {
@@ -1013,7 +1012,6 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) else setListViewPUB(hLV, itemNum, hasKey(ptr));
setListViewIcon(hLV, itemNum, ptr);
}
- hContact = db_find_next(hContact);
}
ListView_Sort(hLV,0);
}
@@ -1073,10 +1071,9 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) LVITEM lvi; memset(&lvi,0,sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
- HANDLE hContact = db_find_first();
char tmp[NAMSIZE];
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
pUinKey ptr = getUinKey(hContact);
if (ptr && ptr->mode == MODE_PGP && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) {
LPSTR szKeyID = db_get_sa(hContact,MODULENAME,"pgp_abbr");
@@ -1095,7 +1092,6 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221));
SAFE_FREE(szKeyID);
}
- hContact = db_find_next(hContact);
}
ListView_Sort(hLV,(LPARAM)0x10);
}
@@ -1135,10 +1131,9 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) LVITEM lvi; memset(&lvi,0,sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
- HANDLE hContact = db_find_first();
char tmp[NAMSIZE];
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
pUinKey ptr = getUinKey(hContact);
if (ptr && ptr->mode == MODE_GPG && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) {
if (iInit )
@@ -1161,7 +1156,6 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) LV_SetItemTextA(hLV, itemNum, 3, (ptr->tgpgMode)?Translate(sim228):Translate(sim229));
SAFE_FREE(szKeyID);
}
- hContact = db_find_next(hContact);
}
ListView_Sort(hLV,(LPARAM)0x20);
}
diff --git a/plugins/SeenPlugin/src/missed.cpp b/plugins/SeenPlugin/src/missed.cpp index 9098d3d0e1..4b7d4bcf44 100644 --- a/plugins/SeenPlugin/src/missed.cpp +++ b/plugins/SeenPlugin/src/missed.cpp @@ -42,11 +42,8 @@ int RemoveUser(int pos) int ResetMissed(void)
{
- HANDLE hcontact = db_find_first();
- while (hcontact != NULL) {
- db_set_b(hcontact, S_MOD, "Missed", 0);
- hcontact = db_find_next(hcontact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_set_b(hContact, S_MOD, "Missed", 0);
ZeroMemory(&mcs,sizeof(mcs));
return 0;
@@ -54,13 +51,9 @@ int ResetMissed(void) int CheckIfOnline(void)
{
- HANDLE hcontact = db_find_first();
- while (hcontact != NULL) {
- if ( CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hcontact, 0) != ICON_OFFLINE)
- db_set_b(hcontact, S_MOD, "Missed", 2);
-
- hcontact = db_find_next(hcontact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if ( CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hContact, 0) != ICON_OFFLINE)
+ db_set_b(hContact, S_MOD, "Missed", 2);
return 0;
}
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index a7948c6baa..41c4271955 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -656,22 +656,22 @@ static void cleanThread(void *param) // I hope in 10 secons all logged-in contacts will be listed
if ( WaitForSingleObject(g_hShutdownEvent, 10000) == WAIT_TIMEOUT) {
- HANDLE hcontact = db_find_first();
- while(hcontact != NULL) {
- char *contactProto = GetContactProto(hcontact);
- if (contactProto) {
- if ( !strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH)) {
- WORD oldStatus = db_get_w(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000;
- if (oldStatus > ID_STATUS_OFFLINE) {
- if (db_get_w(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){
- db_set_w(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000));
- if (includeIdle)db_set_b(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1));
- db_set_w(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
- }
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *contactProto = GetContactProto(hContact);
+ if (!contactProto)
+ continue;
+
+ if ( strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH))
+ continue;
+
+ WORD oldStatus = db_get_w(hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000;
+ if (oldStatus > ID_STATUS_OFFLINE) {
+ if (db_get_w(hContact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){
+ db_set_w(hContact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000));
+ if (includeIdle)db_set_b(hContact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1));
+ db_set_w(hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
}
}
- hcontact = db_find_next(hcontact);
}
char *str = (char *)malloc(MAXMODULELABELLENGTH+9);
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index f422608a58..3ead9ab314 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -219,19 +219,15 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar case IDOK:
{
DWORD session_list_temp[255]={0};
- int lenght,i;
+ int lenght,i = 0;
TCHAR szUserSessionName[MAX_PATH];
lenght = GetWindowTextLength(GetDlgItem(hdlg, IDC_LIST));
SavePosition(hdlg, "SaveDlg");
- if (lenght>0)
- {
+ if (lenght>0) {
GetWindowText(GetDlgItem(hdlg, IDC_LIST), szUserSessionName, SIZEOF(szUserSessionName));
szUserSessionName[lenght+1]='\0';
- if (IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)&&bSC)
- {
- HANDLE hContact = db_find_first();
- for (i=0; hContact; hContact = db_find_next(hContact))
- {
+ if (IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)&&bSC) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
BYTE res =(BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
if (res) {
user_session_list[i] = hContact;
@@ -722,9 +718,7 @@ int DeleteAutoSession(int ses_count) TCHAR *szSessionNameBuf=NULL;
- for (hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
RemoveSessionMark(hContact,0,ses_count);
SetInSessionOrder(hContact,0,ses_count,0);
}
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index 926d641226..fe8a8a2e59 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -319,16 +319,12 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) if (!hOpClistControl)
EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE);
else {
- int i;
- HANDLE hContact = db_find_first();
-
- for ( ; hContact; hContact = db_find_next(hContact))
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact,0);
- for (i=0 ; session_list_t[i]>0; i++)
- {
- hContact=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
- //hItem=session_list[i];
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact,1);
+
+ for (int i=0 ; session_list_t[i] > 0; i++) {
+ HANDLE hContact = (HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact, 1);
}
EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
}
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 29925dbb9d..e3150943da 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1813,20 +1813,16 @@ static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam) if (db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", 1))
return 0;
- HANDLE hContact;
char *szProto;
BOOL bContactFound = FALSE;
+ HANDLE hContact;
- hContact = db_find_first();
- while (hContact)
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, (char *)lMirParam) && db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam)
- {
+ if (szProto != NULL && !strcmp(szProto, (char *)lMirParam) && db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam) {
bContactFound = TRUE;
break;
}
- hContact = db_find_next(hContact);
}
if (!bContactFound)
return 0;
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index 6b18c9cd57..b63cbf4223 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -958,12 +958,8 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) for (int i = 0; i < protoCount; i++)
AddAccountAsCategory(accList[i], defaultFile);
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
AddContactTransportAsCategory(hContact, defaultFile);
- hContact = db_find_next(hContact);
- }
bkstring cats;
opt.ReadCustomCategories(cats);
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index 44ad773675..4e31ebfbb3 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -100,92 +100,6 @@ void DeleteCListGroupsByName(TCHAR* szGroupName) db_set_b(NULL, "CList", "ConfirmDelete", ConfirmDelete); } -/* -void RemoveExcludedUsers() -{ - HANDLE hContact; - hContact_entry *first, *plist, *tmp; - hContact = db_find_first(); - first = new hContact_entry; - plist = first; - plist->hContact = INVALID_HANDLE_VALUE; - if(hContact) - { - do{ - if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0)) - { - plist->hContact = hContact; - plist->next = new hContact_entry; - plist = plist->next; - plist->hContact = INVALID_HANDLE_VALUE; - } - }while(hContact = db_find_next(hContact)); - - plist = first; - while(plist->hContact != INVALID_HANDLE_VALUE) - { - std::string proto=DBGetContactSettingStringPAN_A(plist->hContact,"Protocol","p",""); - UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0); - - if(status>= ID_STATUS_CONNECTING && status <= ID_STATUS_OFFLINE){ - LogSpamToFile(plist->hContact, _T("Mark for delete")); - db_set_b(plist->hContact,"CList","Delete", 1); - }else{ - LogSpamToFile(plist->hContact, _T("Deleted")); - CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); - }; - tmp = plist; - plist = plist->next; - delete tmp; - } - delete plist; - } -} - -void RemoveTemporaryUsers() -{ - HANDLE hContact; - hContact_entry *first, *plist, *tmp; - hContact = db_find_first(); - first = new hContact_entry; - plist = first; - plist->hContact = INVALID_HANDLE_VALUE; - if(hContact) - { - do{ - if(db_get_b(hContact, "CList", "NotOnList", 0)|| - (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))) - ) - { - plist->hContact = hContact; - plist->next = new hContact_entry; - plist = plist->next; - plist->hContact = INVALID_HANDLE_VALUE; - } - }while(hContact = db_find_next(hContact)); - - plist = first; - while(plist->hContact != INVALID_HANDLE_VALUE) - { - std::string proto=DBGetContactSettingStringPAN_A(plist->hContact,"Protocol","p",""); - UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0); - - if(status>= ID_STATUS_CONNECTING && status <= ID_STATUS_OFFLINE){ - LogSpamToFile(plist->hContact, _T("Mark for delete")); - db_set_b(plist->hContact,"CList","Delete", 1); - }else{ - LogSpamToFile(plist->hContact, _T("Deleted")); - CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); - }; - - tmp = plist; - plist = plist->next; - delete tmp; - } - delete plist; - }; - DeleteCListGroupsByName(_T("Not In List")); -}*/ int RemoveTmp(WPARAM,LPARAM) { void CleanThread(); @@ -394,9 +308,9 @@ void CleanProtocolTmpThread(std::string proto) break; boost::this_thread::sleep(boost::posix_time::seconds(2)); } + std::list<HANDLE> contacts; - for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) - { + for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *proto_tmp = GetContactProto(hContact); if(proto_tmp) if(!strcmp(proto.c_str(), proto_tmp)) @@ -424,6 +338,7 @@ void CleanProtocolExclThread(std::string proto) break; boost::this_thread::sleep(boost::posix_time::seconds(2)); } + std::list<HANDLE> contacts; for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index fd0f232573..483603b24d 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -115,12 +115,8 @@ BOOL CList_SetOffline(HANDLE hContact, BOOL bHide) BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
{
- HANDLE hContact;
- char* szProto;
-
- hContact = db_find_first();
- while (hContact) {
- szProto = GetContactProto(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if (MM_FindModule(szProto)) {
if (!pszModule || (pszModule && !strcmp(pszModule, szProto))) {
int i = M->GetByte(hContact, szProto, "ChatRoom", 0);
@@ -130,8 +126,6 @@ BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule) }
}
}
-
- hContact = db_find_next(hContact);
}
return TRUE;
}
@@ -297,9 +291,8 @@ BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, const T HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
- char* szProto = GetContactProto(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if (szProto && !lstrcmpiA(szProto, pszModule)) {
if (M->GetByte(hContact, szProto, "ChatRoom", 0) != 0) {
DBVARIANT dbv;
@@ -312,8 +305,6 @@ HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom) }
}
}
-
- hContact = db_find_next(hContact);
}
return 0;
}
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index e5e98c9a44..c37642d345 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -2389,25 +2389,21 @@ void TSAPI DeleteContainer(int iIndex) char *szKey = "TAB_ContainersW";
char *szSettingP = "CNTW_";
char *szSubKey = "containerW";
- HANDLE hhContact;
_snprintf(szIndex, 8, "%d", iIndex);
-
if (!M->GetTString(NULL, szKey, szIndex, &dbv)) {
if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR) {
TCHAR *wszContainerName = dbv.ptszVal;
M->WriteTString(NULL, szKey, szIndex, _T("**free**"));
- hhContact = db_find_first();
- while (hhContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv_c;
- if (!M->GetTString(hhContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
+ if (!M->GetTString(hContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
TCHAR *wszString = dbv_c.ptszVal;
if (_tcscmp(wszString, wszContainerName) && lstrlen(wszString) == lstrlen(wszContainerName))
- db_unset(hhContact, SRMSGMOD_T, "containerW");
+ db_unset(hContact, SRMSGMOD_T, "containerW");
db_free(&dbv_c);
}
- hhContact = db_find_next(hhContact);
}
_snprintf(szSetting, CONTAINER_NAMELEN + 15, "%s%d_Flags", szSettingP, iIndex);
db_unset(NULL, SRMSGMOD_T, szSetting);
@@ -2433,27 +2429,24 @@ void TSAPI RenameContainer(int iIndex, const TCHAR *szNew) char *szSettingP = "CNTW_";
char *szSubKey = "containerW";
char szIndex[10];
- HANDLE hhContact;
_snprintf(szIndex, 8, "%d", iIndex);
if (!M->GetTString(NULL, szKey, szIndex, &dbv)) {
- if (szNew != NULL) {
+ if (szNew != NULL)
if (lstrlen(szNew) != 0)
M->WriteTString(NULL, szKey, szIndex, szNew);
- }
- hhContact = db_find_first();
- while (hhContact) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv_c;
- if (!M->GetTString(hhContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
+ if (!M->GetTString(hContact, SRMSGMOD_T, szSubKey, &dbv_c)) {
if (!_tcscmp(dbv.ptszVal, dbv_c.ptszVal) && lstrlen(dbv_c.ptszVal) == lstrlen(dbv.ptszVal)) {
if (szNew != NULL) {
if (lstrlen(szNew) != 0)
- M->WriteTString(hhContact, SRMSGMOD_T, szSubKey, szNew);
+ M->WriteTString(hContact, SRMSGMOD_T, szSubKey, szNew);
}
}
db_free(&dbv_c);
}
- hhContact = db_find_next(hhContact);
}
db_free(&dbv);
}
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 67c4333121..76f44eefe7 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -562,7 +562,6 @@ int CGlobals::MetaContactEvent(WPARAM wParam, LPARAM lParam) int CGlobals::PreshutdownSendRecv(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact;
int i;
#if defined(__USE_EX_HANDLERS)
@@ -579,11 +578,8 @@ int CGlobals::PreshutdownSendRecv(WPARAM wParam, LPARAM lParam) ::SendMessage(pFirstContainer->hwnd, WM_CLOSE, 0, 1);
}
- hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
M->WriteDword(hContact, SRMSGMOD_T, "messagecount", 0);
- hContact = db_find_next(hContact);
- }
for (i=0; i < SERVICE_LAST; i++) {
if (PluginConfig.hSvc[i])
@@ -651,8 +647,7 @@ void CGlobals::RestoreUnreadMessageAlerts(void) cle.pszService = "SRMsg/ReadMessage";
cle.flags = CLEF_TCHAR;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (M->GetDword(hContact, "SendLater", "count", 0))
sendLater->addContact(hContact);
@@ -675,7 +670,6 @@ void CGlobals::RestoreUnreadMessageAlerts(void) }
hDbEvent = db_event_next(hDbEvent);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 419863cb75..868e59513b 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -853,41 +853,33 @@ static void ResetCList(HWND hwndDlg) static void RebuildList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
BYTE defType = M->GetByte(SRMSGMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW);
-
- if (hItemNew && defType) {
+ if (hItemNew && defType)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItemNew, 1);
- }
- if (hItemUnknown && M->GetByte(SRMSGMOD, SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN)) {
+
+ if (hItemUnknown && M->GetByte(SRMSGMOD, SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItemUnknown, 1);
- }
- hContact = db_find_first();
- do {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem && M->GetByte(hContact, SRMSGMOD, SRMSGSET_TYPING, defType)) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem && M->GetByte(hContact, SRMSGMOD, SRMSGSET_TYPING, defType))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
- }
- } while (hContact = db_find_next(hContact));
+ }
}
static void SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
-
- if (hItemNew) {
+ if (hItemNew)
M->WriteByte(SRMSGMOD, SRMSGSET_TYPINGNEW, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItemNew, 0) ? 1 : 0));
- }
- if (hItemUnknown) {
+
+ if (hItemUnknown)
M->WriteByte(SRMSGMOD, SRMSGSET_TYPINGUNKNOWN, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItemUnknown, 0) ? 1 : 0));
- }
- hContact = db_find_first();
- do {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem)
db_set_b(hContact, SRMSGMOD, SRMSGSET_TYPING, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0) ? 1 : 0));
- }
- } while (hContact = db_find_next(hContact));
+ }
}
static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index fdfda626b7..3f78cf8c32 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -375,45 +375,39 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) HWND hwndDlg = dat->hwnd;
if (dat->sendMode & SMODE_MULTIPLE) {
- HANDLE hContact, hItem;
- int iJobs = 0;
- int iMinLength = 0;
- CContactCache* c = 0;
-
- hContact = db_find_first();
+ int iJobs = 0;
+ int iMinLength = 0;
m_jobs[iEntry].hOwner = dat->hContact;
m_jobs[iEntry].iStatus = SQ_INPROGRESS;
m_jobs[iEntry].hwndOwner = hwndDlg;
- int iSendLength = getSendLength(iEntry, dat->sendMode);
+ int iSendLength = getSendLength(iEntry, dat->sendMode);
- do {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem && SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
- c = CContactCache::getContactCache(hContact);
+ CContactCache *c = CContactCache::getContactCache(hContact);
if (c)
iMinLength = (iMinLength == 0 ? c->getMaxMessageLength() : min(c->getMaxMessageLength(), iMinLength));
}
- } while (hContact = db_find_next(hContact));
+ }
if (iSendLength >= iMinLength) {
TCHAR tszError[256];
-
mir_sntprintf(tszError, 256, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), iMinLength);
::SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, reinterpret_cast<LPARAM>(tszError));
sendQueue->clearJob(iEntry);
return 0;
}
- hContact = db_find_first();
- do {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem && SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
doSendLater(iEntry, 0, hContact, false);
iJobs++;
}
- } while (hContact = db_find_next(hContact));
+ }
sendQueue->clearJob(iEntry);
if (iJobs)
diff --git a/plugins/TabSRMM/src/trayicon.cpp b/plugins/TabSRMM/src/trayicon.cpp index 212ba2d8b4..5739275cbb 100644 --- a/plugins/TabSRMM/src/trayicon.cpp +++ b/plugins/TabSRMM/src/trayicon.cpp @@ -330,39 +330,39 @@ typedef struct _recentEntry { void TSAPI LoadFavoritesAndRecent()
{
- RCENTRY *recentEntries, rceTemp;
DWORD dwRecent;
- int iIndex = 0, i, j;
- HANDLE hContact = db_find_first();
- recentEntries = new RCENTRY[nen_options.wMaxRecent + 1];
- if (recentEntries != NULL) {
- while (hContact != 0) {
- if (M->GetByte(hContact, SRMSGMOD_T, "isFavorite", 0))
- AddContactToFavorites(hContact, NULL, NULL, NULL, 0, 0, 1, PluginConfig.g_hMenuFavorites);
- if ((dwRecent = M->GetDword(hContact, "isRecent", 0)) != 0 && iIndex < nen_options.wMaxRecent) {
- recentEntries[iIndex].dwTimestamp = dwRecent;
- recentEntries[iIndex++].hContact = hContact;
- }
- hContact = db_find_next(hContact);
- }
- if (iIndex == 0) {
- free(recentEntries);
- return;
+ int iIndex = 0, i, j;
+
+ RCENTRY *recentEntries = new RCENTRY[nen_options.wMaxRecent + 1];
+ if (recentEntries == NULL)
+ return;
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (M->GetByte(hContact, SRMSGMOD_T, "isFavorite", 0))
+ AddContactToFavorites(hContact, NULL, NULL, NULL, 0, 0, 1, PluginConfig.g_hMenuFavorites);
+ if ((dwRecent = M->GetDword(hContact, "isRecent", 0)) != 0 && iIndex < nen_options.wMaxRecent) {
+ recentEntries[iIndex].dwTimestamp = dwRecent;
+ recentEntries[iIndex++].hContact = hContact;
}
+ }
- for (i=0; i < iIndex - 1; i++) {
- for (j = 0; j < iIndex - 1; j++) {
- if (recentEntries[j].dwTimestamp > recentEntries[j+1].dwTimestamp) {
- rceTemp = recentEntries[j];
- recentEntries[j] = recentEntries[j+1];
- recentEntries[j+1] = rceTemp;
- }
+ if (iIndex == 0) {
+ free(recentEntries);
+ return;
+ }
+
+ for (i=0; i < iIndex - 1; i++) {
+ for (j = 0; j < iIndex - 1; j++) {
+ if (recentEntries[j].dwTimestamp > recentEntries[j+1].dwTimestamp) {
+ RCENTRY rceTemp = recentEntries[j];
+ recentEntries[j] = recentEntries[j+1];
+ recentEntries[j+1] = rceTemp;
}
}
- for (i=0; i < iIndex; i++)
- AddContactToFavorites(recentEntries[i].hContact, NULL, NULL, NULL, 0, 0, 1, PluginConfig.g_hMenuRecent);
-
- delete[] recentEntries;
}
+ for (i=0; i < iIndex; i++)
+ AddContactToFavorites(recentEntries[i].hContact, NULL, NULL, NULL, 0, 0, 1, PluginConfig.g_hMenuRecent);
+
+ delete[] recentEntries;
}
diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp index 15a52ef814..3bef236dce 100644 --- a/plugins/TabSRMM/src/typingnotify.cpp +++ b/plugins/TabSRMM/src/typingnotify.cpp @@ -303,12 +303,10 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_PREVIEW:
if (PluginConfig.g_PopupAvail) {
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL)
break;
- hContact = db_find_next(hContact);
}
POPUPDATAT ppd = { 0 };
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp index 8436b5f632..84ad4272c8 100644 --- a/plugins/TipperYM/src/options.cpp +++ b/plugins/TipperYM/src/options.cpp @@ -2087,15 +2087,10 @@ INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam, SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0);
- HANDLE hContact, hItem;
- hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem && db_get_b(hContact, MODULE, "FavouriteContact", 0))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
-
- hContact = db_find_next(hContact);
}
CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE);
@@ -2109,22 +2104,17 @@ INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam, {
case IDC_BTN_OK:
{
- HANDLE hContact, hItem;
BYTE isChecked;
int count = 0;
- hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
{
isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
db_set_b(hContact, MODULE, "FavouriteContact", isChecked);
if (isChecked) count++;
}
-
- hContact = db_find_next(hContact);
}
db_set_dw(0, MODULE, "FavouriteContactsCount", count);
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 155990697d..290c1fcdd6 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -1551,15 +1551,13 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if (dwItems & TRAYTIP_NUMCONTACTS) {
int iCount = 0, iCountOnline = 0;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if (proto && !strcmp(proto, pa->szModuleName)) {
if (db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
iCountOnline++;
iCount++;
}
- hContact = db_find_next(hContact);
}
mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount);
}
@@ -1678,8 +1676,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa bool bTitlePainted = false;
int iCount = 0, iCountOnline = 0;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_b(hContact, MODULE, "FavouriteContact", 0)) {
char *proto = GetContactProto(hContact);
if (proto) {
@@ -1710,7 +1707,6 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa }
}
}
- hContact = db_find_next(hContact);
}
int index = pwd->iRowCount - 1;
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index 779fe76bf8..9740dbd1d2 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -885,8 +885,7 @@ TCHAR *GetProtoExtraStatusMessage(char *szProto) swzText = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
- if (ServiceExists(MS_VARS_FORMATSTRING))
- {
+ if (ServiceExists(MS_VARS_FORMATSTRING)) {
HANDLE hContact = db_find_first();
char *proto = GetContactProto(hContact);
while(!proto)
diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp index abcbe146d5..7265d3a6c7 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.cpp +++ b/plugins/TooltipNotify/src/TooltipNotify.cpp @@ -807,48 +807,33 @@ void CTooltipNotify::ResetCList(HWND hwndDlg) void CTooltipNotify::LoadList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
if (hItemNew && !m_sOptions.bIgnoreNew)
- {
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItemNew, 1);
- }
+
if (hItemUnknown && !m_sOptions.bIgnoreUnknown)
- {
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItemUnknown, 1);
- }
- HANDLE hContact = db_find_first();
- do
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
if (hItem && !db_get_b(hContact, s_szModuleName, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
- {
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItem, 1);
- }
}
- while (hContact = db_find_next(hContact));
}
void CTooltipNotify::SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
if (hItemNew)
- {
m_sOptions.bIgnoreNew = (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItemNew, 0) ? 0 : 1);
- }
+
if (hItemUnknown)
- {
m_sOptions.bIgnoreUnknown = (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItemUnknown, 0) ? 0 : 1);
- }
- HANDLE hContact = db_find_first();
- do
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
- if (hItem)
- {
+ if (hItem) {
BYTE bChecked = (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItem, 0));
db_set_b(hContact, s_szModuleName, CONTACT_IGNORE_TTNOTIFY, bChecked ? 0 : 1);
}
}
- while (hContact = db_find_next(hContact));
}
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index c281d02ed3..faec6a8f42 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -271,22 +271,18 @@ int getContactFromString( CONTACTSINFO* ci ) LeaveCriticalSection(&csContactCache);
/* contact was not in cache, do a search */
- hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szFind = NULL;
bMatch = FALSE;
ZeroMemory(&dbv, sizeof(DBVARIANT));
szProto = GetContactProto(hContact);
- if (szProto == NULL) {
- hContact = db_find_next(hContact);
+ if (szProto == NULL)
continue;
- }
+
// <proto:id> (exact)
- if (ci->flags&CI_PROTOID)
- {
+ if (ci->flags & CI_PROTOID) {
cInfo = getContactInfoT(CNF_UNIQUEID, hContact);
- if (cInfo == NULL)
- {
+ if (cInfo == NULL) {
// <HANDLE:hContact>
cInfo = (TCHAR*)mir_alloc(32);
_stprintf(cInfo, _T("%p"), hContact);
@@ -295,22 +291,17 @@ int getContactFromString( CONTACTSINFO* ci ) {
wsprintf(szFind, _T("<%s:%s>"), _T(PROTOID_HANDLE), cInfo);
if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
- {
bMatch = TRUE;
- }
+
mir_free(cInfo);
mir_free(szFind);
}
}
- else
- {
+ else {
szFind = (TCHAR*)mir_alloc((_tcslen(cInfo) + strlen(szProto) + 4)*sizeof(TCHAR));
- if (szFind != NULL)
- {
+ if (szFind != NULL) {
tszProto = mir_a2t(szProto);
-
- if ((tszProto != NULL) && (szFind != NULL))
- {
+ if ((tszProto != NULL) && (szFind != NULL)) {
wsprintf(szFind, _T("<%s:%s>"), tszProto, cInfo);
mir_free(cInfo);
mir_free(tszProto);
@@ -401,7 +392,6 @@ int getContactFromString( CONTACTSINFO* ci ) ci->hContacts[count] = hContact;
count += 1;
}
- hContact=db_find_next(hContact);
}
if (count == 1) { /* cache the found result */
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index 6d14bf7cb3..c686037325 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -546,14 +546,13 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) hDbEvent = db_event_prev(hDbEvent);
}
else {
- HANDLE hMatchEvent, hSearchEvent, hSearchContact;
+ HANDLE hMatchEvent, hSearchEvent;
DWORD matchTimestamp, priorTimestamp;
- hMatchEvent = hSearchEvent = hSearchContact = NULL;
+ hMatchEvent = hSearchEvent = NULL;
matchTimestamp = priorTimestamp = 0;
if (flags & DBE_FIRST) {
- hSearchContact = db_find_first();
- do {
+ for (HANDLE hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) {
hSearchEvent = findDbEvent(hSearchContact, NULL, flags);
dbe.cbBlob = 0;
if (!db_event_get(hSearchEvent, &dbe)) {
@@ -562,13 +561,11 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) matchTimestamp = dbe.timestamp;
}
}
- hSearchContact = db_find_next(hSearchContact);
- } while (hSearchContact);
+ }
hDbEvent = hMatchEvent;
}
- else if (flags&DBE_LAST) {
- hSearchContact = db_find_first();
- do {
+ else if (flags & DBE_LAST) {
+ for (HANDLE hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) {
hSearchEvent = findDbEvent(hSearchContact, NULL, flags);
dbe.cbBlob = 0;
if (!db_event_get(hSearchEvent, &dbe)) {
@@ -577,16 +574,14 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) matchTimestamp = dbe.timestamp;
}
}
- hSearchContact = db_find_next(hSearchContact);
- } while (hSearchContact);
+ }
hDbEvent = hMatchEvent;
}
- else if (flags&DBE_NEXT) {
+ else if (flags & DBE_NEXT) {
dbe.cbBlob = 0;
if (!db_event_get(hDbEvent, &dbe)) {
priorTimestamp = dbe.timestamp;
- hSearchContact = db_find_first();
- do {
+ for (HANDLE hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) {
hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags);
dbe.cbBlob = 0;
if (!db_event_get(hSearchEvent, &dbe)) {
@@ -595,16 +590,14 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) matchTimestamp = dbe.timestamp;
}
}
- hSearchContact = db_find_next(hSearchContact);
- } while (hSearchContact);
+ }
hDbEvent = hMatchEvent;
}
}
- else if (flags&DBE_PREV) {
+ else if (flags & DBE_PREV) {
if (!db_event_get(hDbEvent, &dbe)) {
priorTimestamp = dbe.timestamp;
- hSearchContact = db_find_first();
- do {
+ for (HANDLE hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) {
hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags);
dbe.cbBlob = 0;
if (!db_event_get(hSearchEvent, &dbe)) {
@@ -613,8 +606,7 @@ static HANDLE findDbEvent(HANDLE hContact, HANDLE hDbEvent, int flags) matchTimestamp = dbe.timestamp;
}
}
- hSearchContact = db_find_next(hSearchContact);
- } while (hSearchContact);
+ }
hDbEvent = hMatchEvent;
}
}
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index fe315a8ad5..08ee90d862 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -40,8 +40,7 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) return 0;
// search for existing contact
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// check if it is a weather contact
if ( IsMyContact(hContact)) {
DBVARIANT dbv;
@@ -61,12 +60,11 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
// if contact with the same ID was not found, add it
if (psr->cbSize < sizeof(PROTOSEARCHRESULT)) return 0;
- hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)WEATHERPROTONAME);
// suppress online notification for the new contact
CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index c43f3332d4..a52727f002 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -448,8 +448,7 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam) // now the default station is deleted, try to get a new one
// start looking for other weather stations
- HANDLE hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
// if the station is not a default station, set it as the new default station
@@ -470,7 +469,6 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam) db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
// got here if no more weather station left
opt.Default[0] = 0; // no default station
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index cc7a4e93b9..3f6ce3b0f2 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -124,8 +124,7 @@ void EraseAllInfo() HANDLE LastContact = NULL;
DBVARIANT dbv;
// loop through all contacts
- HANDLE hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// see if the contact is a weather contact
if ( IsMyContact(hContact)) {
db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
@@ -173,7 +172,6 @@ void EraseAllInfo() ContactCount++; // increment counter
LastContact = hContact;
}
- hContact = db_find_next(hContact);
}
// if weather contact exists, set the status to online so it is ready for update
diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp index b748173aeb..7f70b659d0 100644 --- a/plugins/Weather/src/weather_mwin.cpp +++ b/plugins/Weather/src/weather_mwin.cpp @@ -384,33 +384,25 @@ void InitMwin(void) FontRegisterT(&fontid);
}
- HANDLE hContact = db_find_first();
- while(hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// see if the contact is a weather contact
- if (IsMyContact(hContact))
- {
+ if (IsMyContact(hContact)) {
if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0))
addWindow(hContact);
}
- hContact = db_find_next(hContact);
}
hFontHook = HookEvent(ME_FONT_RELOAD, RedrawFrame);
}
void DestroyMwin(void)
{
- HANDLE hContact = db_find_first();
- while(hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// see if the contact is a weather contact
- if (IsMyContact(hContact))
- {
+ if (IsMyContact(hContact)) {
DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0);
if (frameId)
CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
}
- hContact = db_find_next(hContact);
}
UnregisterClass( _T("WeatherFrame"), hInst);
UnhookEvent(hFontHook);
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index da46dc8709..4c7f819b1f 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -282,18 +282,13 @@ void DestroyUpdateList(void) void UpdateAll(BOOL AutoUpdate, BOOL RemoveData)
{
// add all weather contact to the update queue list
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if (IsMyContact(hContact))
- {
- if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (IsMyContact(hContact)) {
+ if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) {
if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0);
UpdateListAdd(hContact);
}
}
- hContact = db_find_next(hContact);
}
// if it is not updating, then start the update thread process
diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp index 790d766863..c13d4cc428 100644 --- a/plugins/WhenWasIt/src/dlg_handlers.cpp +++ b/plugins/WhenWasIt/src/dlg_handlers.cpp @@ -691,11 +691,9 @@ int LoadBirthdays(HWND hWnd, int bShowAll) ListView_DeleteAllItems(hList);
int count = 0;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
count = UpdateBirthdayEntry(hList, hContact, count, bShowAll, commonData.cShowAgeMode, 1);
- hContact = db_find_next(hContact);
- }
+
SetBirthdaysCount(hWnd);
return 0;
}
diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp index 15736f1951..4d02d6ff0e 100644 --- a/plugins/WhenWasIt/src/notifiers.cpp +++ b/plugins/WhenWasIt/src/notifiers.cpp @@ -221,13 +221,11 @@ int SoundNotifyBirthday(int dtb) //called with oldClistIcon != -1 from dlg_handlers whtn the extra icon slot changes.
int RefreshAllContactListIcons(int oldClistIcon)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (oldClistIcon != -1)
ExtraIcon_Clear(hWWIExtraIcons, hContact);
RefreshContactListIcons(hContact); //will change bBirthdayFound if needed
- hContact = db_find_next(hContact);
}
return 0;
}
diff --git a/plugins/WhenWasIt/src/services.cpp b/plugins/WhenWasIt/src/services.cpp index b7ee590882..dd61f51c49 100644 --- a/plugins/WhenWasIt/src/services.cpp +++ b/plugins/WhenWasIt/src/services.cpp @@ -334,8 +334,7 @@ int DoExport(TCHAR *fileName) _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), TranslateT("Warning! Please do not mix Unicode and Ansi exported birthday files. You should use the same version (Ansi/Unicode) of WhenWasIt that was used to export the info.\n"));
_ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), TranslateT("This file was exported with a Unicode version of WhenWasIt. Please only use a Unicode version of the plugin to import the birthdays.\n"));
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
int year, month, day;
GetContactDOB(hContact, year, month, day);
if ( IsDOBValid(year, month, day)) {
@@ -348,8 +347,6 @@ int DoExport(TCHAR *fileName) if (szHandle)
free(szHandle);
}
-
- hContact = db_find_next(hContact);
}
fclose(fout);
diff --git a/plugins/WhenWasIt/src/utils.cpp b/plugins/WhenWasIt/src/utils.cpp index 724b4331a4..323e63d979 100644 --- a/plugins/WhenWasIt/src/utils.cpp +++ b/plugins/WhenWasIt/src/utils.cpp @@ -219,20 +219,15 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) HANDLE GetContactFromID(TCHAR *szID, char *szProto)
{
- HANDLE hContact = db_find_first();
-
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *m_szProto = GetContactProto(hContact);
TCHAR *szHandle = GetContactID(hContact, szProto);
- if (szHandle)
- {
+ if (szHandle) {
bool found = (!_tcsicmp(szHandle, szID) && !_stricmp(szProto, m_szProto));
free(szHandle);
if (found)
return hContact;
}
-
- hContact = db_find_next(hContact);
}
return NULL;
}
diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 56ff14b74c..ce1ace8ab9 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -105,8 +105,8 @@ INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_RESETCONTENT, 0, 0);
int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_GETCURSEL, 0, 0);
PROTOACCOUNT *pa = (PROTOACCOUNT *)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_GETITEMDATA, cursel, 0);
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char* szUniqueId = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if ((INT_PTR) szUniqueId != CALLSERVICE_NOTFOUND && szUniqueId != NULL) {
DBVARIANT dbvuid = {0};
@@ -134,9 +134,7 @@ INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) db_free(&dbvuid);
}
}
- hContact = db_find_next(hContact);
}
-
}
return 0;
diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index d973548e74..dcb2d55b59 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -272,16 +272,13 @@ int RegisterPOP3Plugin(WPARAM,LPARAM) //HookEvent(ME_OPT_INITIALISE,POP3OptInit);
HACCOUNT Finder;
- HANDLE hContact;
DBVARIANT dbv;
char *szProto;
for (Finder=POP3Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next)
{
Finder->hContact = NULL;
- hContact = db_find_first();
- while(hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
if (szProto != NULL && strcmp(szProto, YAMN_DBMODULE)==0)
{
@@ -299,7 +296,6 @@ int RegisterPOP3Plugin(WPARAM,LPARAM) db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
if (Finder->hContact == NULL && (Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) {
diff --git a/plugins/YAPP/src/options.cpp b/plugins/YAPP/src/options.cpp index c47ea27311..c8cc3955f0 100644 --- a/plugins/YAPP/src/options.cpp +++ b/plugins/YAPP/src/options.cpp @@ -98,8 +98,7 @@ void ShowExamplePopups() { pd.ptzText = TranslateT("Thequickbrownfoxjumpedoverthelazydog.");
ShowPopup(pd);
- HANDLE hContact = db_find_first();
- while(hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) {
AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
if (ace && (ace->dwFlags & AVS_BITMAP_VALID)) {
@@ -109,8 +108,6 @@ void ShowExamplePopups() { break;
}
}
-
- hContact = db_find_next(hContact);
}
}
diff --git a/plugins/YAPP/src/yapp_history_dlg.cpp b/plugins/YAPP/src/yapp_history_dlg.cpp index 71457acc41..9de3e8eda5 100644 --- a/plugins/YAPP/src/yapp_history_dlg.cpp +++ b/plugins/YAPP/src/yapp_history_dlg.cpp @@ -354,7 +354,7 @@ void AddEventsCustomControl(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESF ieEvent.hwnd = pwData->hIEView;
ieEvent.codepage = CP_ACP;
ieEvent.iType = IEE_LOG_MEM_EVENTS;
- ieEvent.hContact = NULL;//db_find_first(); IEVIEW needs a contact handle !!
+ ieEvent.hContact = NULL;
IEVIEWEVENTDATA *eventData = NULL;
IEVIEWEVENTDATA *cED = NULL;
diff --git a/plugins/YahooGroups/src/services.cpp b/plugins/YahooGroups/src/services.cpp index 5334e7f4a2..e5c1175db4 100644 --- a/plugins/YahooGroups/src/services.cpp +++ b/plugins/YahooGroups/src/services.cpp @@ -161,12 +161,8 @@ void CreateGroup(char *group) void ProcessContacts(void (*callback)(HANDLE, char *), char *protocol)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
callback(hContact, protocol);
- hContact = db_find_next(hContact);
- }
}
void YahooMoveCallback(HANDLE hContact, char *unused)
diff --git a/plugins/YahooGroups/src/utils.cpp b/plugins/YahooGroups/src/utils.cpp index 652c19f716..fce73b4936 100644 --- a/plugins/YahooGroups/src/utils.cpp +++ b/plugins/YahooGroups/src/utils.cpp @@ -316,15 +316,13 @@ TCHAR *GetContactID(HANDLE hContact, char *szProto) HANDLE GetContactFromID(TCHAR *szID, char *szProto)
{
- HANDLE hContact = db_find_first();
TCHAR *szHandle;
TCHAR dispName[1024];
char cProtocol[256];
TCHAR *tmp;
int found = 0;
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
GetContactProtocol(hContact, cProtocol, sizeof(cProtocol));
szHandle = GetContactID(hContact, cProtocol);
@@ -337,11 +335,10 @@ HANDLE GetContactFromID(TCHAR *szID, char *szProto) }
if (szHandle) { free(szHandle); }
- if (found) { break; }
- hContact = db_find_next(hContact);
+ if (found) return hContact;
}
- return hContact;
+ return NULL;
}
#pragma warning (default: 4312)
diff --git a/protocols/AimOscar/src/theme.cpp b/protocols/AimOscar/src/theme.cpp index b5c0ae20a7..3dc5dce55f 100644 --- a/protocols/AimOscar/src/theme.cpp +++ b/protocols/AimOscar/src/theme.cpp @@ -144,46 +144,30 @@ void set_contact_icon(CAimProto* ppro, HANDLE hContact) void remove_AT_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0))
ExtraIcon_Clear(hExtraAT, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void remove_ES_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0))
ExtraIcon_Clear(hExtraES, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void add_AT_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact))
set_AT_icon(ppro, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void add_ES_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact))
set_ES_icon(ppro, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void InitExtraIcons(void)
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp index cabadfffb0..4fbc7a03c5 100644 --- a/protocols/AimOscar/src/utility.cpp +++ b/protocols/AimOscar/src/utility.cpp @@ -168,69 +168,50 @@ bool CAimProto::is_my_contact(HANDLE hContact) HANDLE CAimProto::find_chat_contact(const char* room)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
DBVARIANT dbv;
- if (!getString(hContact, "ChatRoomID", &dbv))
- {
+ if (!getString(hContact, "ChatRoomID", &dbv)) {
bool found = !strcmp(room, dbv.pszVal);
db_free(&dbv);
if (found) return hContact;
}
}
- hContact = db_find_next(hContact);
}
return NULL;
}
HANDLE CAimProto::contact_from_sn(const char* sn, bool addIfNeeded, bool temporary)
{
- char* norm_sn = normalize_name(sn);
+ mir_ptr<char> norm_sn( normalize_name(sn));
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
DBVARIANT dbv;
- if (!getString(hContact, AIM_KEY_SN, &dbv))
- {
+ if (!getString(hContact, AIM_KEY_SN, &dbv)) {
bool found = !strcmp(norm_sn, dbv.pszVal);
db_free(&dbv);
if (found)
- {
- mir_free(norm_sn);
return hContact;
- }
}
}
- hContact = db_find_next(hContact);
}
- if (addIfNeeded)
- {
- hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (hContact)
- {
- if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) m_szModuleName) == 0)
- {
+ if (addIfNeeded) {
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ if (hContact) {
+ if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) m_szModuleName) == 0) {
setString(hContact, AIM_KEY_SN, norm_sn);
setString(hContact, AIM_KEY_NK, sn);
LOG("Adding contact %s to client side list.",norm_sn);
if (temporary)
db_set_b(hContact, "CList", "NotOnList", 1);
- mir_free(norm_sn);
return hContact;
}
- else
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
}
- mir_free(norm_sn);
return NULL;
}
@@ -340,13 +321,10 @@ void CAimProto::offline_contact(HANDLE hContact, bool remove_settings) void CAimProto::offline_contacts(void)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (is_my_contact(hContact))
offline_contact(hContact,true);
- hContact = db_find_next(hContact);
- }
+
allow_list.destroy();
block_list.destroy();
group_list.destroy();
@@ -409,20 +387,15 @@ unsigned short CAimProto::search_for_free_item_id(HANDLE hbuddy)//returns a free retry:
id = get_random();
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
- for(int i=1; ;++i)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
+ for(int i=1; ;++i) {
unsigned short item_id = getBuddyId(hContact, i);
if (item_id == 0) break;
if (item_id == id) goto retry; //found one no need to look through anymore
}
}
- hContact = db_find_next(hContact);
}
setBuddyId(hbuddy, 1, id);
@@ -435,44 +408,34 @@ unsigned short* CAimProto::get_members_of_group(unsigned short group_id, unsigne unsigned short* list = NULL;
size = 0;
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
- for(int i=1; ;++i)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
+ for(int i=1; ;++i) {
unsigned short user_group_id = getGroupId(hContact, i);
- if (user_group_id == 0) break;
+ if (user_group_id == 0)
+ break;
- if (group_id == user_group_id)
- {
+ if (group_id == user_group_id) {
unsigned short buddy_id = getBuddyId(hContact, i);
- if (buddy_id)
- {
+ if (buddy_id) {
list = (unsigned short*)mir_realloc(list, ++size*sizeof(list[0]));
list[size-1] = _htons(buddy_id);
}
}
}
}
- hContact = db_find_next(hContact);
}
return list;
}
void CAimProto::upload_nicks(void)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv;
- if (is_my_contact(hContact) && !db_get_utf(hContact, MOD_KEY_CL, "MyHandle", &dbv))
- {
+ if (is_my_contact(hContact) && !db_get_utf(hContact, MOD_KEY_CL, "MyHandle", &dbv)) {
set_local_nick(hContact, dbv.pszVal, NULL);
db_free(&dbv);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp index 165a18afa6..b17b7ef7c9 100644 --- a/protocols/EmLanProto/src/mlan.cpp +++ b/protocols/EmLanProto/src/mlan.cpp @@ -127,14 +127,12 @@ void CMLan::SetMirandaStatus(u_int status) void CMLan::SetAllOffline()
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *svc = GetContactProto(hContact);
if (svc != NULL && lstrcmp(PROTONAME,svc) == 0) {
db_set_w(hContact,PROTONAME,"Status",ID_STATUS_OFFLINE);
db_unset(hContact, PROTONAME, "IP");
}
- hContact = db_find_next(hContact);
}
DeleteCache();
}
@@ -243,8 +241,7 @@ void CMLan::SendPacketExt(TPacket& pak, u_long addr) HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, bool make_permanent, bool make_visible, u_int status)
{
- HANDLE res = db_find_first();
- while (res != NULL) {
+ for (HANDLE res = db_find_first(); res; res = db_find_next(res)) {
char *szProto = GetContactProto(res);
if (szProto!=NULL && !lstrcmp(PROTONAME, szProto)) {
u_long caddr = db_get_dw(res, PROTONAME, "ipaddr", -1);
@@ -256,11 +253,10 @@ HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, boo return res;
}
}
- res = db_find_next(res);
}
if (add_to_list) {
- res=(HANDLE)CallService(MS_DB_CONTACT_ADD,0,0);
+ HANDLE res=(HANDLE)CallService(MS_DB_CONTACT_ADD,0,0);
CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)res,(LPARAM)PROTONAME);
db_set_dw(res,PROTONAME, "ipaddr", addr.S_un.S_addr);
db_set_s(res,PROTONAME, "Nick", nick);
@@ -271,10 +267,10 @@ HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, boo db_set_b(res,"CList","Hidden",1);
db_set_w(res,PROTONAME, "Status", status);
+ return res;
}
- else res = NULL;
- return res;
+ return NULL;
}
void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from)
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index abea7b8f49..392b95df82 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -38,10 +38,7 @@ bool FacebookProto::IsMyContact(HANDLE hContact, bool include_chat) HANDLE FacebookProto::ChatIDToHContact(std::string chat_id)
{
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(!IsMyContact(hContact, true))
continue;
@@ -63,10 +60,7 @@ HANDLE FacebookProto::ChatIDToHContact(std::string chat_id) HANDLE FacebookProto::ContactIDToHContact(std::string user_id)
{
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(!IsMyContact(hContact))
continue;
@@ -140,10 +134,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_ void FacebookProto::SetAllContactStatuses(int status, bool reset_client)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (!IsMyContact(hContact))
continue;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index d095118045..e3f1a014ba 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -160,10 +160,7 @@ void FacebookProto::ProcessFriendList( void* data ) // Check and update old contacts
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (!IsMyContact(hContact))
continue;
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 6d3b91fe28..393157275d 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -1446,12 +1446,10 @@ void GGPROTO::setalloffline() {
netlog("setalloffline(): started. Setting buddies offline");
db_set_w(NULL, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName))
- {
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
db_set_w(hContact, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
// Clear IP and port settings
db_unset(hContact, m_szModuleName, GG_KEY_CLIENTIP);
@@ -1459,7 +1457,6 @@ void GGPROTO::setalloffline() // Delete status descr
db_unset(hContact, "CList", GG_KEY_STATUSDESCR);
}
- hContact = db_find_next(hContact);
}
#ifdef DEBUGMODE
netlog("setalloffline(): End.");
@@ -1519,20 +1516,17 @@ void GGPROTO::notifyall() netlog("notifyall(): Subscribing notification to all users");
// Readup count
- hContact = db_find_first();
- while (hContact)
- {
+
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName)) count ++;
- hContact = db_find_next(hContact);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName))
+ count ++;
}
// Readup list
/* FIXME: If we have nothing on the list but we omit gg_notify_ex we have problem with receiving any contacts */
- if (count == 0)
- {
- if (isonline())
- {
+ if (count == 0) {
+ if (isonline()) {
gg_EnterCriticalSection(&sess_mutex, "notifyall", 29, "sess_mutex", 1);
gg_notify_ex(sess, NULL, NULL, 0);
gg_LeaveCriticalSection(&sess_mutex, "notifyall", 29, 1, "sess_mutex", 1);
@@ -1542,12 +1536,9 @@ void GGPROTO::notifyall() uins = (uin_t*)calloc(sizeof(uin_t), count);
types = (char*)calloc(sizeof(char), count);
- hContact = db_find_first();
- while (hContact && cc < count)
- {
+ for (hContact = db_find_first(); hContact && cc < count; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName) && (uins[cc] = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)))
- {
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName) && (uins[cc] = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0))) {
if ((db_get_w(hContact, m_szModuleName, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
db_get_b(hContact, "CList", "NotOnList", 0))
types[cc] = GG_USER_OFFLINE;
@@ -1557,7 +1548,6 @@ void GGPROTO::notifyall() types[cc] = GG_USER_NORMAL;
cc ++;
}
- hContact = db_find_next(hContact);
}
if (cc < count) count = cc;
@@ -1582,8 +1572,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) netlog("getcontact(): uin=%d create=%d inlist=%d", uin, create, inlist);
#endif
// Look for contact in DB
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
if ((uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0) == uin
@@ -1596,11 +1585,10 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) return hContact;
}
}
- hContact = db_find_next(hContact);
}
if (!create) return NULL;
- hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
if (!hContact) {
netlog("getcontact(): Failed to create Gadu-Gadu contact %S", szNick);
return NULL;
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 1f19e0c25c..1fd94d1fd1 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -137,23 +137,19 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) // Window terminated (Miranda exit)
if (gch->pDest->iType == SESSION_TERMINATE)
{
- HANDLE hContact = NULL;
netlog("gc_event(): Terminating chat %x, id %S from chat window...", chat, gch->pDest->ptszID);
// Destroy chat entry
free(chat->recipients);
list_remove(&chats, chat, 1);
+
// Remove contact from contact list (duh!) should be done by chat.dll !!
- hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR))
- {
+ if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR)) {
if (dbv.ptszVal && !_tcscmp(gch->pDest->ptszID, dbv.ptszVal))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
db_free(&dbv);
}
- hContact = db_find_next(hContact);
}
return 1;
}
@@ -440,13 +436,10 @@ static void gg_gc_resetclistopts(HWND hwndList) static int gg_gc_countcheckmarks(HWND hwndList)
{
int count = 0;
- HANDLE hItem, hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
count++;
- hContact = db_find_next(hContact);
}
return count;
}
@@ -494,17 +487,13 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa // Create new participiants table
TCHAR* chat;
uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t));
- HANDLE hItem, hContact = db_find_first();
gg->netlog("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count);
- while (hContact && i < count)
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- {
+ for (HANDLE hContact = db_find_first(); hContact && i < count; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
HANDLE hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
participants[i++] = db_get_dw(hMetaContact ? hMetaContact : hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
}
- hContact = db_find_next(hContact);
}
if (count > i) i = count;
chat = gg->gc_getchat(0, participants, count);
@@ -545,8 +534,6 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa case CLN_CONTACTMOVED:
case CLN_LISTREBUILT:
{
- HANDLE hContact;
- HANDLE hItem;
char* szProto;
uin_t uin;
GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER);
@@ -554,20 +541,15 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa if (!gg) break;
// Delete non-gg contacts
- hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem) {
HANDLE hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
- if (hMetaContact)
- {
+ if (hMetaContact) {
szProto = gg->m_szModuleName;
uin = (uin_t)db_get_dw(hMetaContact, gg->m_szModuleName, GG_KEY_UIN, 0);
}
- else
- {
+ else {
szProto = GetContactProto(hContact);
uin = (uin_t)db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
}
@@ -575,7 +557,6 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa if (szProto == NULL || lstrcmpA(szProto, gg->m_szModuleName) || !uin || uin == db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
- hContact = db_find_next(hContact);
}
}
break;
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index abaa9799f6..0492ecb32b 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -101,12 +101,9 @@ char *gg_makecontacts(GGPROTO *gg, int cr) char *contacts;
// Readup contacts
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, gg->m_szModuleName) && !db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0))
- {
+ if (szProto != NULL && !strcmp(szProto, gg->m_szModuleName) && !db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0)) {
DBVARIANT dbv;
// Readup FirstName
@@ -139,9 +136,9 @@ char *gg_makecontacts(GGPROTO *gg, int cr) string_append(s, pszValA);
mir_free(pszValA);
db_free(&dbv2);
- } else {
- string_append(s, dbvA);
}
+ else string_append(s, dbvA);
+
string_append_c(s, ';');
string_append(s, dbvA);
mir_free(dbvA);
@@ -183,7 +180,6 @@ char *gg_makecontacts(GGPROTO *gg, int cr) else
string_append(s, ";0;;0;\n");
}
- hContact = db_find_next(hContact);
}
contacts = string_free(s, 0);
diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp index d3f4aed5de..a60353a8e5 100644 --- a/protocols/IRCG/src/clist.cpp +++ b/protocols/IRCG/src/clist.cpp @@ -144,9 +144,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo) DisconnectAllDCCSessions(false);
- HANDLE hContact = db_find_first();
- while ( hContact ) {
- char* szProto = GetContactProto(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if (szProto != NULL && !lstrcmpiA( szProto, m_szModuleName)) {
if ( getByte( hContact, "ChatRoom", 0 ) == 0 ) {
if ( getByte(hContact, "DCC", 0 ) != 0 ) {
@@ -161,9 +160,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo) db_unset( hContact, m_szModuleName, "IP" );
setString( hContact, "User", "" );
setString( hContact, "Host", "" );
- } }
-
- hContact = db_find_next(hContact);
+ }
+ }
}
return true;
}
@@ -176,15 +174,14 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user) TCHAR* lowercasename = mir_tstrdup( user->name );
CharLower(lowercasename);
- char *szProto;
DBVARIANT dbv1;
DBVARIANT dbv2;
DBVARIANT dbv3;
DBVARIANT dbv4;
DBVARIANT dbv5;
- HANDLE hContact = db_find_first();
- while (hContact) {
- szProto = GetContactProto(hContact);
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, m_szModuleName )) {
if ( getByte( hContact, "ChatRoom", 0) == 0) {
HANDLE hContact_temp = NULL;
@@ -238,9 +235,9 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user) if ( hContact_temp != (HANDLE)-1 )
return hContact_temp;
return 0;
- } } }
-
- hContact = db_find_next(hContact);
+ }
+ }
+ }
}
mir_free(lowercasename);
return 0;
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index a38c11fe2a..e91473722a 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -139,12 +139,9 @@ VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD ) if ( name.IsEmpty() && name2.IsEmpty()) {
DBVARIANT dbv;
- char* szProto;
-
- HANDLE hContact = db_find_first();
- while ( hContact ) {
- szProto = GetContactProto(hContact);
- if ( szProto != NULL && !lstrcmpiA( szProto, ppro->m_szModuleName )) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
+ if (szProto != NULL && !lstrcmpiA( szProto, ppro->m_szModuleName)) {
BYTE bRoom = ppro->getByte(hContact, "ChatRoom", 0);
if ( bRoom == 0 ) {
BYTE bDCC = ppro->getByte(hContact, "DCC", 0);
@@ -177,10 +174,7 @@ VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD ) if ( DBNick ) db_free(&dbv);
if ( DBWildcard ) db_free(&dbv2);
- } } } } }
-
- hContact = db_find_next(hContact);
- } }
+ } } } } } } }
if ( ppro->m_namesToWho.IsEmpty() && ppro->m_namesToUserhost.IsEmpty()) {
ppro->SetChatTimer( ppro->OnlineNotifTimer, 60*1000, OnlineNotifTimerProc );
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index 20285b193f..0b37e6ad22 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -112,19 +112,11 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll) static void DeleteOtherContactsFromControl(HWND hCtrl, CIcqProto* ppro)
{
- HANDLE hContact;
- HANDLE hItem;
-
- hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE)SendMessage(hCtrl, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hCtrl, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
- {
if (!ppro->IsICQContact(hContact))
SendMessage(hCtrl, CLM_DELETEITEM, (WPARAM)hItem, 0);
- }
- hContact = db_find_next(hContact);
}
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 36a4dbcf40..6a8adbc714 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -701,15 +701,13 @@ class CGroupchatInviteDlg : public CJabberDlgBase void FilterList(CCtrlClc *)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if (lstrcmpA(proto, m_proto->m_szModuleName) || db_get_b(hContact, proto, "ChatRoom", 0))
if (HANDLE hItem = m_clc.FindContact(hContact))
m_clc.DeleteItem(hItem);
- } }
+ }
+ }
void ResetListOptions(CCtrlClc *)
{
@@ -819,10 +817,7 @@ public: HWND hwndList = GetDlgItem(m_hwnd, IDC_CLIST);
// invite users from roster
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if ( !lstrcmpA(proto, m_proto->m_szModuleName) && !db_get_b(hContact, proto, "ChatRoom", 0))
{
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index f727d0ee1f..ea7203bd5d 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -462,18 +462,14 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact void CJabberProto::CheckAllContactsAreTransported()
{
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( !lstrcmpA(m_szModuleName, szProto)) {
DBVARIANT dbv;
if ( !JGetStringT(hContact, "jid", &dbv)) {
DBCheckIsTransportedContact(dbv.ptszVal, hContact);
db_free(&dbv);
- } }
-
- hContact = db_find_next(hContact);
-} }
+} } } }
/////////////////////////////////////////////////////////////////////////////////////////
// Cross-instance shared icons
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 9d3bb562cf..eced1ebbd9 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -535,8 +535,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo) if (m_options.RosterSync == TRUE) {
int listSize = 0, listAllocSize = 0;
HANDLE* list = NULL;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char* str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, m_szModuleName)) {
DBVARIANT dbv;
@@ -553,9 +552,8 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo) list[listSize++] = hContact;
}
db_free(&dbv);
- } }
-
- hContact = db_find_next(hContact);
+ }
+ }
}
for (i=0; i < listSize; i++) {
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 4ed270192e..10d23186a4 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -154,6 +154,7 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick) HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource)
{
+ HANDLE hContact;
TCHAR* s, *p, *q;
size_t len;
char *szProto;
@@ -173,8 +174,7 @@ HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL t len = _tcslen(s);
// We can't use JabberHContactFromJID() here because of the stripResource option
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
if (szProto!=NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
@@ -185,8 +185,8 @@ HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL t break;
}
db_free(&dbv);
- } }
- hContact = db_find_next(hContact);
+ }
+ }
}
if (hContact == NULL) {
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 614baef47f..dbe3ca3d1f 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1055,47 +1055,41 @@ void CJabberProto::_RosterHandleGetRequest(HXML node) group = xmlGetText(groupNode);
_RosterInsertListItem(hList, jid, name, group, subscription, TRUE);
}
+
// now it is require to process whole contact list to add not in roster contacts
- {
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL)
- {
- char* str = GetContactProto(hContact);
- if (str != NULL && !strcmp(str, m_szModuleName))
- {
- DBVARIANT dbv;
- if ( !JGetStringT(hContact, "jid", &dbv))
- {
- LVFINDINFO lvfi={0};
- lvfi.flags = LVFI_STRING;
- lvfi.psz = dbv.ptszVal;
- TCHAR *p = _tcschr(dbv.ptszVal,_T('@'));
- if (p) {
- p = _tcschr(dbv.ptszVal, _T('/'));
- if (p) *p = _T('\0');
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char* str = GetContactProto(hContact);
+ if (str != NULL && !strcmp(str, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ LVFINDINFO lvfi={0};
+ lvfi.flags = LVFI_STRING;
+ lvfi.psz = dbv.ptszVal;
+ TCHAR *p = _tcschr(dbv.ptszVal,_T('@'));
+ if (p) {
+ p = _tcschr(dbv.ptszVal, _T('/'));
+ if (p) *p = _T('\0');
+ }
+ if (ListView_FindItem(hList, -1, &lvfi) == -1) {
+ TCHAR *jid = mir_tstrdup(dbv.ptszVal);
+ TCHAR *name = NULL;
+ TCHAR *group = NULL;
+ DBVARIANT dbvtemp;
+ if ( !db_get_ts(hContact, "CList", "MyHandle", &dbvtemp)) {
+ name = mir_tstrdup(dbvtemp.ptszVal);
+ db_free(&dbvtemp);
}
- if (ListView_FindItem(hList, -1, &lvfi) == -1) {
- TCHAR *jid = mir_tstrdup(dbv.ptszVal);
- TCHAR *name = NULL;
- TCHAR *group = NULL;
- DBVARIANT dbvtemp;
- if ( !db_get_ts(hContact, "CList", "MyHandle", &dbvtemp)) {
- name = mir_tstrdup(dbvtemp.ptszVal);
- db_free(&dbvtemp);
- }
- if ( !db_get_ts(hContact, "CList", "Group", &dbvtemp)) {
- group = mir_tstrdup(dbvtemp.ptszVal);
- db_free(&dbvtemp);
- }
- _RosterInsertListItem(hList, jid, name, group, NULL, FALSE);
- if (jid) mir_free(jid);
- if (name) mir_free(name);
- if (group) mir_free(group);
+ if ( !db_get_ts(hContact, "CList", "Group", &dbvtemp)) {
+ group = mir_tstrdup(dbvtemp.ptszVal);
+ db_free(&dbvtemp);
}
- db_free(&dbv);
+ _RosterInsertListItem(hList, jid, name, group, NULL, FALSE);
+ if (jid) mir_free(jid);
+ if (name) mir_free(name);
+ if (group) mir_free(group);
}
+ db_free(&dbv);
}
- hContact = db_find_next(hContact);
}
}
rrud.bReadyToDownload = FALSE;
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index e0c5f041f2..39da2ae3f1 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -424,8 +424,7 @@ public: return;
LRESULT nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
- switch (nItemData)
- {
+ switch (nItemData) {
case Jid:
{
ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
@@ -433,20 +432,15 @@ public: SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_proto->m_szModuleName))
- {
+ if (szProto != NULL && !strcmp(szProto, m_proto->m_szModuleName)) {
DBVARIANT dbv;
- if ( !m_proto->JGetStringT(hContact, "jid", &dbv))
- {
+ if ( !m_proto->JGetStringT(hContact, "jid", &dbv)) {
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
// append known chatroom jids from bookmarks
@@ -1365,10 +1359,7 @@ void CJabberDlgPrivacyLists::CListResetOptions(HWND) void CJabberDlgPrivacyLists::CListFilter(HWND)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if ( !proto || lstrcmpA(proto, m_proto->m_szModuleName))
if (HANDLE hItem = m_clcClist.FindContact(hContact))
@@ -1468,12 +1459,10 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) CListResetIcons(hwndList, hItem, bHideIcons);
}
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = m_clcClist.FindContact(hContact);
- if ( !hItem) continue;
- CListResetIcons(hwndList, hItem, bHideIcons);
+ if (hItem)
+ CListResetIcons(hwndList, hItem, bHideIcons);
}
for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid)
@@ -1569,8 +1558,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) pList->RemoveAllRules();
- for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid)
- {
+ for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid) {
hItem = clc_info.newJids[iJid]->hItem;
szJid = clc_info.newJids[iJid]->jid;
@@ -1580,16 +1568,13 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
}
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = m_clcClist.FindContact(hContact);
DBVARIANT dbv = {0};
- if (m_proto->JGetStringT(hContact, "jid", &dbv)) {
+ if (m_proto->JGetStringT(hContact, "jid", &dbv))
if (m_proto->JGetStringT(hContact, "ChatRoomID", &dbv))
continue;
- }
szJid = dbv.ptszVal;
@@ -1602,8 +1587,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) }
// group handles start with 1 (0 is "root")
- for (int iGroup = 1; ; ++iGroup)
- {
+ for (int iGroup = 1; ; ++iGroup) {
char idstr[33];
_itoa(iGroup-1, idstr, 10);
DBVARIANT dbv = {0};
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index fc296d7c18..25e9da3411 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -307,13 +307,9 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) JHookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
JHookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName))
- MenuHideSrmmIcon(hContact);
- hContact = db_find_next(hContact);
- } }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ MenuHideSrmmIcon(hContact);
+ }
DBEVENTTYPEDESCR dbEventType = {0};
dbEventType.cbSize = sizeof(DBEVENTTYPEDESCR);
@@ -332,8 +328,7 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) CheckAllContactsAreTransported();
// Set all contacts to offline
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
SetContactOfflineStatus(hContact);
@@ -347,10 +342,7 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) *resourcepos = '\0';
m_lstTransports.insert(mir_tstrdup(domain));
db_free(&dbv);
- } } }
-
- hContact = db_find_next(hContact);
- }
+ } } } }
CleanLastResourceMap();
return 0;
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index 23800fc307..0081409290 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -477,8 +477,7 @@ int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe int CJabberProto::RcGetUnreadEventsCount()
{
int nEventsSent = 0;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
@@ -504,7 +503,6 @@ int CJabberProto::RcGetUnreadEventsCount() db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
return nEventsSent;
}
@@ -573,8 +571,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe m_options.RcMarkMessagesAsRead = bRemoveCListEvents ? 1 : 0;
int nEventsSent = 0;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
@@ -631,7 +628,6 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%d message(s) forwarded"), nEventsSent);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 3660fbce04..85cc395218 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -595,15 +595,11 @@ recvRest: JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
// Set all contacts to offline
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
- if ( !lstrcmpA(GetContactProto(hContact), m_szModuleName))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if ( !lstrcmpA(GetContactProto(hContact), m_szModuleName)) {
SetContactOfflineStatus(hContact);
MenuHideSrmmIcon(hContact);
}
-
- hContact = db_find_next(hContact);
}
mir_free(m_szJabberJID);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 2a365c562e..2f5a02f792 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -75,8 +75,7 @@ HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid) return (HANDLE)NULL;
HANDLE hContactMatched = NULL;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
@@ -91,10 +90,7 @@ HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid) if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0) {
hContactMatched = hContact;
break;
- } } }
-
- hContact = db_find_next(hContact);
- }
+ } } } }
return hContactMatched;
}
@@ -110,8 +106,8 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource) JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, jid);
HANDLE hContactMatched = NULL;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
@@ -144,10 +140,7 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource) if ( !result) {
hContactMatched = hContact;
break;
- } } }
-
- hContact = db_find_next(hContact);
- }
+ } } } }
return hContactMatched;
}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 9cdc9a4758..04fcac2504 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -571,8 +571,7 @@ HANDLE CMraProto::MraHContactFromEmail(LPSTR lpszEMail, size_t dwEMailSize, BOOL if (dwEMailSize == -1) dwEMailSize = lstrlenA(lpszEMail);
//check not already on list
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsContactMra(hContact))
if (mraGetStaticStringA(hContact, "e-mail", szEMailLocal, SIZEOF(szEMailLocal), &dwEMailLocalSize))
if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL)
@@ -598,15 +597,12 @@ HANDLE CMraProto::MraHContactFromEmail(LPSTR lpszEMail, size_t dwEMailSize, BOOL gcw.dwFlags = GC_UNICODE;
MultiByteToWideChar(MRA_CODE_PAGE, 0, lpszEMail, dwEMailSize, wszEMail, SIZEOF(wszEMail));
- if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0)
- {
+ if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0) {
BOOL bChatAdded = FALSE;
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) {
if (IsContactMra(hContact))
if (mraGetStaticStringA(hContact, "ChatRoomID", szEMailLocal, SIZEOF(szEMailLocal), &dwEMailLocalSize))
- if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL)
- {
+ if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL) {
bChatAdded = TRUE;
break;
}
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index e927d2dd0f..82dbb828d4 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -1516,7 +1516,7 @@ DWORD CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader, DWORD *pd dwAuthMessageSize = lstrlenW(wszAuthMessage);
}
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (GetContactBasicInfoW(hContact, &dwID, NULL, NULL, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, NULL, 0, NULL, NULL, 0, NULL) == NO_ERROR)
if (dwID == -1) {
if (IsEMailChatAgent(szEMail, dwEMailSize)) {// чат: ещё раз запросим авторизацию, пометим как видимый в списке, постоянный
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 600331cff5..5e42aa4222 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -220,9 +220,7 @@ INT_PTR CMraProto::MraWebSearch(WPARAM wParam, LPARAM lParam) INT_PTR CMraProto::MraUpdateAllUsersInfo(WPARAM wParam, LPARAM lParam)
{
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_UPD_ALL_USERS_INFO_STR), MB_YESNO | MB_ICONQUESTION) == IDYES ) {
- for (HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
size_t dwEMailSize;
CHAR szEMail[MAX_EMAIL_LEN];
if ( IsContactMra(hContact))
@@ -236,9 +234,7 @@ INT_PTR CMraProto::MraUpdateAllUsersInfo(WPARAM wParam, LPARAM lParam) INT_PTR CMraProto::MraCheckUpdatesUsersAvt(WPARAM wParam, LPARAM lParam)
{
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_CHK_USERS_AVATARS_STR), MB_YESNO | MB_ICONQUESTION) == IDYES) {
- for (HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
size_t dwEMailSize;
CHAR szEMail[MAX_EMAIL_LEN];
@@ -254,9 +250,7 @@ INT_PTR CMraProto::MraCheckUpdatesUsersAvt(WPARAM wParam, LPARAM lParam) INT_PTR CMraProto::MraRequestAuthForAll(WPARAM wParam, LPARAM lParam)
{
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_REQ_AUTH_FOR_ALL_STR), MB_YESNO | MB_ICONQUESTION) == IDYES) {
- for (HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DWORD dwContactSeverFlags;
if (GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL) == NO_ERROR)
if (dwContactSeverFlags&CONTACT_INTFLAG_NOT_AUTHORIZED && dwContactSeverFlags != -1)
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index bf23f84ce2..74961195f7 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -256,8 +256,7 @@ void CMsnProto::Lists_Populate(void) else
Lists_Add(0, NETID_UNKNOWN, szEmail, hContact);
}
- else
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
hContact = hContactN;
}
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index bdf55a975f..a9da564cf3 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -92,17 +92,13 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : LoadOptions();
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if (MSN_IsMyContact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (MSN_IsMyContact(hContact)) {
deleteSetting(hContact, "Status");
deleteSetting(hContact, "IdleTS");
deleteSetting(hContact, "p2pMsgId");
deleteSetting(hContact, "AccList");
}
- hContact = db_find_next(hContact);
}
deleteSetting(NULL, "MobileEnabled");
deleteSetting(NULL, "MobileAllowed");
@@ -112,8 +108,7 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : strcmp(path, MSN_DEFAULT_GATEWAY) == 0))
deleteSetting(NULL, "LoginServer");
- if (MyOptions.SlowSend)
- {
+ if (MyOptions.SlowSend) {
if (db_get_dw(NULL, "SRMsg", "MessageTimeout", 10000) < 60000)
db_set_dw(NULL, "SRMsg", "MessageTimeout", 60000);
if (db_get_dw(NULL, "SRMM", "MessageTimeout", 10000) < 60000)
diff --git a/protocols/Tlen/src/jabber_iqid.cpp b/protocols/Tlen/src/jabber_iqid.cpp index a94630b628..b77a367170 100644 --- a/protocols/Tlen/src/jabber_iqid.cpp +++ b/protocols/Tlen/src/jabber_iqid.cpp @@ -145,7 +145,6 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) XmlNode *itemNode, *groupNode;
JABBER_SUBSCRIPTION sub;
JABBER_LIST_ITEM *item;
- HANDLE hContact;
char *jid, *name, *nick;
int i, oldStatus;
@@ -166,6 +165,7 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) nick = JabberLocalNickFromJID(jid);
}
if (nick != NULL) {
+ HANDLE hContact;
item = JabberListAdd(proto, LIST_ROSTER, jid);
if (item->nick) mir_free(item->nick);
item->nick = nick;
@@ -211,8 +211,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) listSize = listAllocSize = 0;
list = NULL;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, proto->m_szModuleName)) {
if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
@@ -230,8 +230,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
+
for (i=0; i<listSize; i++) {
JabberLog(proto, "Syncing roster: deleting 0x%x", list[i]);
CallService(MS_DB_CONTACT_DELETE, (WPARAM) list[i], 0);
diff --git a/protocols/Tlen/src/jabber_misc.cpp b/protocols/Tlen/src/jabber_misc.cpp index 30ec49b67d..c20cc63c06 100644 --- a/protocols/Tlen/src/jabber_misc.cpp +++ b/protocols/Tlen/src/jabber_misc.cpp @@ -85,32 +85,27 @@ char *JabberJIDFromHContact(TlenProtocol *proto, HANDLE hContact) HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid)
{
- HANDLE hContact, hContactMatched;
DBVARIANT dbv;
char *szProto;
char *p;
- if (jid == NULL) return (HANDLE) NULL;
- hContactMatched = NULL;
- hContact = db_find_first();
- while (hContact != NULL) {
+ if (jid == NULL)
+ return NULL;
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(proto->m_szModuleName, szProto)) {
if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
if ((p=dbv.pszVal) != NULL) {
if (!stricmp(p, jid)) { // exact match (node@domain/resource)
- hContactMatched = hContact;
db_free(&dbv);
- break;
+ return hContact;
}
}
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
- }
- if (hContactMatched != NULL) {
- return hContactMatched;
}
+
return NULL;
}
diff --git a/protocols/Tlen/src/jabber_thread.cpp b/protocols/Tlen/src/jabber_thread.cpp index ce4a95f539..896bf29016 100644 --- a/protocols/Tlen/src/jabber_thread.cpp +++ b/protocols/Tlen/src/jabber_thread.cpp @@ -107,7 +107,6 @@ void __cdecl JabberServerThread(ThreadData *info) char *buffer;
int datalen;
XmlState xmlState;
- HANDLE hContact;
int jabberNetworkBufferSize;
int oldStatus = ID_STATUS_OFFLINE;
int reconnectMaxTime;
@@ -363,15 +362,13 @@ void __cdecl JabberServerThread(ThreadData *info) ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
// Set all contacts to offline
- hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, info->proto->m_szModuleName)) {
if (db_get_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
db_set_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
}
- hContact = db_find_next(hContact);
}
JabberListWipeSpecial(info->proto);
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index 34e03d3071..8c76e78b42 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -252,20 +252,19 @@ INT_PTR TlenMenuHandleInbox(void *ptr, LPARAM wParam, LPARAM lParam) int TlenOnModulesLoaded(void *ptr, WPARAM wParam, LPARAM lParam)
{
-
char str[128];
TlenProtocol *proto = (TlenProtocol *)ptr;
/* Set all contacts to offline */
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, proto->m_szModuleName)) {
if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
}
- hContact = db_find_next(hContact);
}
+
TlenMUCInit(proto);
sprintf(str, "%s", LPGEN("Incoming mail"));
SkinAddNewSoundEx("TlenMailNotify", proto->m_szModuleName, str);
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp index c43ee11edd..bf18a4a5ce 100644 --- a/protocols/Tlen/src/tlen_muc.cpp +++ b/protocols/Tlen/src/tlen_muc.cpp @@ -948,7 +948,6 @@ typedef struct { static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
{
- HANDLE hContact;
MUCCQUERYRESULT queryResult;
DBVARIANT dbv;
MUCSENDQUERYTHREADDATA* threadData = (MUCSENDQUERYTHREADDATA*)ptr;
@@ -957,8 +956,8 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr) queryResult.pszModule = threadData->proto->m_szModuleName;
queryResult.pszParent = threadData->roomId;
queryResult.iItemsNum = 0;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, threadData->proto->m_szModuleName)) {
if (!db_get_b(hContact, threadData->proto->m_szModuleName, "bChat", FALSE)) {
@@ -970,13 +969,12 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr) }
}
}
- hContact = db_find_next(hContact);
}
queryResult.pItems = (MUCCQUERYITEM*)mir_alloc(sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
memset(queryResult.pItems, 0, sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
queryResult.iItemsNum = 0;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *baseProto = GetContactProto(hContact);
if (baseProto != NULL && !strcmp(baseProto, threadData->proto->m_szModuleName)) {
if (!db_get_b(hContact, threadData->proto->m_szModuleName, "bChat", FALSE)) {
@@ -990,7 +988,6 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr) }
}
}
- hContact = db_find_next(hContact);
}
CallService(MS_MUCC_QUERY_RESULT, 0, (LPARAM) &queryResult);
TlenMUCFreeQueryResult(&queryResult);
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index 577dfd3be6..8bb15b85e9 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -197,8 +197,7 @@ void TwitterProto::SetChatStatus(int status) if(status == ID_STATUS_ONLINE)
{
// Add all friends to contact list
- for(HANDLE hContact = db_find_first();hContact;hContact = db_find_next(hContact))
- {
+ for(HANDLE hContact = db_find_first();hContact;hContact = db_find_next(hContact)) {
if(!IsMyContact(hContact))
continue;
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index 320b2cd4c3..d0024ef48f 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -1802,14 +1802,12 @@ BOOL IsXFireContact(HANDLE hContact) HANDLE CList_FindContact (int uid)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
if ( db_get_dw(hContact, protocolname, "UserId",-1)==uid)
return hContact;
}
- hContact = db_find_next(hContact);
}
return 0;
}
@@ -1817,8 +1815,7 @@ HANDLE CList_FindContact (int uid) void CList_MakeAllOffline()
{
vector<HANDLE> fhandles;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
//freunde von freunden in eine seperate liste setzen
@@ -1878,7 +1875,6 @@ void CList_MakeAllOffline() }
db_set_w(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
}
- hContact = db_find_next(hContact);
}
//alle gefundenen handles lsцchen
diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp index c375f29330..b7db4b3c8d 100644 --- a/protocols/Yahoo/src/services.cpp +++ b/protocols/Yahoo/src/services.cpp @@ -31,9 +31,7 @@ void CYahooProto::logoff_buddies()
{
//set all contacts to 'offline'
- HANDLE hContact = db_find_first();
- while ( hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
SetWord( hContact, "Status", ID_STATUS_OFFLINE );
SetDword(hContact, "IdleTS", 0);
@@ -44,8 +42,6 @@ void CYahooProto::logoff_buddies() db_unset(hContact, m_szModuleName, "YGMsg");
//db_unset(hContact, m_szModuleName, "MirVer");
}
-
- hContact = db_find_next(hContact);
}
}
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index f7cce7d094..0f16a241e3 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -284,24 +284,16 @@ void CYahooProto::AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg) HANDLE CYahooProto::getbuddyH(const char *yahoo_id)
{
- HANDLE hContact;
-
- for ( hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact))
- {
- if (IsMyContact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (IsMyContact(hContact)) {
DBVARIANT dbv;
if (GetString(hContact, YAHOO_LOGINID, &dbv))
continue;
- {
- int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id );
- db_free( &dbv );
- if ( tCompareResult )
- continue;
- }
+ int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id );
+ db_free( &dbv );
+ if ( tCompareResult )
+ continue;
return hContact;
}
@@ -606,17 +598,13 @@ void CYahooProto::ext_got_stealth(char *stealthlist) char **s;
int found = 0;
char **stealth = NULL;
- HANDLE hContact;
LOG(("[ext_got_stealth] list: %s", stealthlist));
if (stealthlist)
stealth = y_strsplit(stealthlist, ",", -1);
- for ( hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
DBVARIANT dbv;
if (GetString( hContact, YAHOO_LOGINID, &dbv))
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp index 31e47b1f6a..63a4a5687a 100644 --- a/src/core/stdchat/src/clist.cpp +++ b/src/core/stdchat/src/clist.cpp @@ -99,21 +99,16 @@ BOOL CList_SetOffline(HANDLE hContact, BOOL bHide) BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule)
{
- HANDLE hContact;
- char* szProto;
-
- hContact = db_find_first();
- while ( hContact ) {
- szProto = GetContactProto(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if ( MM_FindModule( szProto )) {
if ( !pszModule || ( pszModule && !strcmp( pszModule, szProto ))) {
int i = db_get_b(hContact, szProto, "ChatRoom", 0);
if ( i != 0 ) {
db_set_w(hContact, szProto,"ApparentMode",(LPARAM)(WORD) 0);
db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- } } }
- hContact = db_find_next(hContact);
- }
+ } } } }
+
return TRUE;
}
@@ -288,8 +283,7 @@ BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( szProto && !lstrcmpiA( szProto, pszModule )) {
if ( db_get_b( hContact, szProto, "ChatRoom", 0) != 0 ) {
@@ -300,10 +294,8 @@ HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom) return hContact;
}
db_free(&dbv);
- } } }
+ } } } }
- hContact = db_find_next(hContact);
- }
return 0;
}
diff --git a/src/core/stdfile/file.cpp b/src/core/stdfile/file.cpp index 292eb13873..cd558e443c 100644 --- a/src/core/stdfile/file.cpp +++ b/src/core/stdfile/file.cpp @@ -287,8 +287,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS static void RemoveUnreadFileEvents(void)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
DBEVENTINFO dbei = { sizeof(dbei) };
@@ -297,7 +296,6 @@ static void RemoveUnreadFileEvents(void) db_event_markRead(hContact, hDbEvent);
hDbEvent = db_event_next(hDbEvent);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index fc74d0ec0d..ff139165e6 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -446,41 +446,33 @@ static void ResetCList(HWND hwndDlg) static void RebuildList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
BYTE defType = db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW);
-
- if (hItemNew && defType) {
+ if (hItemNew && defType)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItemNew, 1);
- }
- if (hItemUnknown && db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN)) {
+
+ if (hItemUnknown && db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGUNKNOWN, SRMSGDEFSET_TYPINGUNKNOWN))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItemUnknown, 1);
- }
- hContact = db_find_first();
- do {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
- if (hItem && db_get_b(hContact, SRMMMOD, SRMSGSET_TYPING, defType)) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
+ if (hItem && db_get_b(hContact, SRMMMOD, SRMSGSET_TYPING, defType))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItem, 1);
- }
- } while (hContact = db_find_next(hContact));
+ }
}
static void SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
-
- if (hItemNew) {
+ if (hItemNew)
db_set_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItemNew, 0) ? 1 : 0));
- }
- if (hItemUnknown) {
+
+ if (hItemUnknown)
db_set_b(NULL, SRMMMOD, SRMSGSET_TYPINGUNKNOWN, (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItemUnknown, 0) ? 1 : 0));
- }
- hContact = db_find_first();
- do {
- hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
- if (hItem) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem)
db_set_b(hContact, SRMMMOD, SRMSGSET_TYPING, (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItem, 0) ? 1 : 0));
- }
- } while (hContact = db_find_next(hContact));
+ }
}
static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index ba8063ea65..26047b065c 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -251,8 +251,7 @@ static void RestoreUnreadMessageAlerts(void) DBEVENTINFO dbei = { sizeof(dbei) };
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
autoPopup = 0;
@@ -282,7 +281,6 @@ static void RestoreUnreadMessageAlerts(void) }
hDbEvent = db_event_next(hDbEvent);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp index ff4d8ec72a..44a41e65f6 100644 --- a/src/core/stdurl/url.cpp +++ b/src/core/stdurl/url.cpp @@ -74,8 +74,7 @@ static void RestoreUnreadUrlAlerts(void) cle.pszService = "SRUrl/ReadUrl";
cle.flags = CLEF_TCHAR;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hDbEvent = db_event_firstUnread(hContact);
while (hDbEvent) {
DBEVENTINFO dbei = { sizeof(dbei) };
@@ -91,7 +90,6 @@ static void RestoreUnreadUrlAlerts(void) }
hDbEvent = db_event_next(hDbEvent);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/src/modules/clist/clcitems.cpp b/src/modules/clist/clcitems.cpp index f2e6dac894..139c7e6e70 100644 --- a/src/modules/clist/clcitems.cpp +++ b/src/modules/clist/clcitems.cpp @@ -107,17 +107,15 @@ ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD group->totalMembers = 0;
if (flags != (DWORD) - 1 && pNextField == NULL && calcTotalMembers) {
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
- HANDLE hContact = db_find_first();
- while (hContact) {
- ClcCacheEntry* cache = cli.pfnGetCacheEntry(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ ClcCacheEntry *cache = cli.pfnGetCacheEntry(hContact);
if ( !lstrcmp(cache->tszGroup, szName) && (style & CLS_SHOWHIDDEN || !cache->bIsHidden))
group->totalMembers++;
-
- hContact = db_find_next(hContact);
}
}
}
- } while (pNextField);
+ }
+ while (pNextField);
return group;
}
@@ -348,32 +346,25 @@ void fnDeleteItemFromTree(HWND hwnd, HANDLE hItem) void fnRebuildEntireList(HWND hwnd, struct ClcData *dat)
{
- char *szProto;
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
- HANDLE hContact;
ClcGroup *group;
- DBVARIANT dbv;
dat->list.expanded = 1;
dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && style&CLS_USEGROUPS;
dat->list.cl.count = dat->list.cl.limit = 0;
dat->selection = -1;
- {
- int i;
- TCHAR *szGroupName;
- DWORD groupFlags;
- for (i = 1;; i++) {
- szGroupName = cli.pfnGetGroupName(i, &groupFlags);
- if (szGroupName == NULL)
- break;
- cli.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
- }
+ for (int i = 1;; i++) {
+ DWORD groupFlags;
+ TCHAR *szGroupName = cli.pfnGetGroupName(i, &groupFlags);
+ if (szGroupName == NULL)
+ break;
+ cli.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
}
- hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (style & CLS_SHOWHIDDEN || !db_get_b(hContact, "CList", "Hidden", 0)) {
+ DBVARIANT dbv;
if (db_get_ts(hContact, "CList", "Group", &dbv))
group = &dat->list;
else {
@@ -392,8 +383,9 @@ void fnRebuildEntireList(HWND hwnd, struct ClcData *dat) if (_tcsstr(lowered_name, lowered_search))
cli.pfnAddContactToGroup(dat, group, hContact);
- } else if ( !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
- szProto = GetContactProto(hContact);
+ }
+ else if ( !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
+ char *szProto = GetContactProto(hContact);
if (szProto == NULL) {
if ( !cli.pfnIsHiddenMode(dat, ID_STATUS_OFFLINE))
cli.pfnAddContactToGroup(dat, group, hContact);
@@ -404,7 +396,6 @@ void fnRebuildEntireList(HWND hwnd, struct ClcData *dat) else cli.pfnAddContactToGroup(dat, group, hContact);
}
}
- hContact = db_find_next(hContact);
}
if (style & CLS_HIDEEMPTYGROUPS) {
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp index 65b1b7eebf..3b3797a90e 100644 --- a/src/modules/clist/clistmod.cpp +++ b/src/modules/clist/clistmod.cpp @@ -144,13 +144,11 @@ static int ProtocolAck(WPARAM, LPARAM lParam) if ((int)ack->hProcess < ID_STATUS_ONLINE && ack->lParam >= ID_STATUS_ONLINE) {
DWORD caps = (DWORD)CallProtoServiceInt(NULL,ack->szModule, PS_GETCAPS, PFLAGNUM_1, 0);
if (caps & PF1_SERVERCLIST) {
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, ack->szModule))
if (db_get_b(hContact, "CList", "Delete", 0))
CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
- hContact = db_find_next(hContact);
}
}
}
diff --git a/src/modules/clist/contact.cpp b/src/modules/clist/contact.cpp index 209f8fc052..7671cd2b11 100644 --- a/src/modules/clist/contact.cpp +++ b/src/modules/clist/contact.cpp @@ -69,23 +69,18 @@ int GetStatusModeOrdering(int statusMode) void fnLoadContactTree(void)
{
- HANDLE hContact;
- int i, status, hideOffline;
-
CallService(MS_CLUI_LISTBEGINREBUILD, 0, 0);
- for (i = 1;; i++) {
+ for (int i = 1;; i++) {
if (cli.pfnGetGroupName(i, NULL) == NULL)
break;
CallService(MS_CLUI_GROUPADDED, i, 0);
}
- hideOffline = db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
- hContact = db_find_first();
- while (hContact != NULL) {
- status = GetContactStatus(hContact);
+ int hideOffline = db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ int status = GetContactStatus(hContact);
if (( !hideOffline || status != ID_STATUS_OFFLINE) && !db_get_b(hContact, "CList", "Hidden", 0))
cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(GetContactProto(hContact), status, hContact), 1);
- hContact = db_find_next(hContact);
}
sortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT);
sortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT);
diff --git a/src/modules/clist/groups.cpp b/src/modules/clist/groups.cpp index eb221ae5c7..c2ac366c54 100644 --- a/src/modules/clist/groups.cpp +++ b/src/modules/clist/groups.cpp @@ -184,10 +184,7 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, NULL };
- for (hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_ts(hContact, "CList", "Group", &dbv))
continue;
@@ -256,7 +253,6 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) char idstr[33];
TCHAR str[256], oldName[256];
DBVARIANT dbv;
- HANDLE hContact;
if (GroupNameExists(szName, groupId)) {
MessageBox(NULL, TranslateT("You already have a group with that name. Please enter a unique name for the group."), TranslateT("Rename Group"), MB_OK);
@@ -274,16 +270,15 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) db_set_ts(NULL, "CListGroups", idstr, str);
//must rename setting in all child contacts too
- hContact = db_find_first();
- do {
- ClcCacheEntry* cache = cli.pfnGetCacheEntry(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ ClcCacheEntry *cache = cli.pfnGetCacheEntry(hContact);
if ( !lstrcmp(cache->tszGroup, oldName)) {
db_set_ts(hContact, "CList", "Group", szName);
mir_free(cache->tszGroup);
cache->tszGroup = 0;
cli.pfnCheckCacheItem(cache);
}
- } while ((hContact = db_find_next(hContact)) != NULL);
+ }
//rename subgroups
{
diff --git a/src/modules/extraicons/DefaultExtraIcons.cpp b/src/modules/extraicons/DefaultExtraIcons.cpp index 590d21c715..3287a72d1d 100644 --- a/src/modules/extraicons/DefaultExtraIcons.cpp +++ b/src/modules/extraicons/DefaultExtraIcons.cpp @@ -342,13 +342,10 @@ void DefaultExtraIcons_Load() p.hExtraIcon = ExtraIcon_Register(p.name, p.desc, LoadSkinnedIconName(p.iSkinIcon));
}
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
SetExtraIcons(hContact);
SetVisibility(hContact, -1, false);
SetGender(hContact, -1, false);
-
- hContact = db_find_next(hContact);
}
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged);
diff --git a/src/modules/extraicons/ExtraIcon.cpp b/src/modules/extraicons/ExtraIcon.cpp index f59a7310fa..379265e9ba 100644 --- a/src/modules/extraicons/ExtraIcon.cpp +++ b/src/modules/extraicons/ExtraIcon.cpp @@ -67,15 +67,10 @@ void ExtraIcon::applyIcons() if (!isEnabled())
return;
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// Clear to assert that it will be cleared
Clist_SetExtraIcon(hContact, slot, INVALID_HANDLE_VALUE);
-
applyIcon(hContact);
-
- hContact = db_find_next(hContact);
}
}
diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp index 24cec55b7f..79922167c4 100644 --- a/src/modules/extraicons/extraicons.cpp +++ b/src/modules/extraicons/extraicons.cpp @@ -330,12 +330,8 @@ void fnSetAllExtraIcons(HWND hwndList, HANDLE hContact) if (hContact == NULL)
hContact = db_find_first();
- do {
- HANDLE hItem = hContact;
- if (hItem == 0)
- continue;
-
- ClcCacheEntry* pdnce = (ClcCacheEntry*)cli.pfnGetCacheEntry(hItem);
+ for (; hContact; hContact = db_find_next(hContact)) {
+ ClcCacheEntry* pdnce = (ClcCacheEntry*)cli.pfnGetCacheEntry(hContact);
if (pdnce == NULL)
continue;
@@ -343,7 +339,6 @@ void fnSetAllExtraIcons(HWND hwndList, HANDLE hContact) if (hcontgiven) break;
Sleep(0);
}
- while(hContact = db_find_next(hContact));
g_mutex_bSetAllExtraIconsCycle = 0;
cli.pfnInvalidateRect(hwndList, NULL, FALSE);
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp index 99d5f8c91d..48a763dc83 100644 --- a/src/modules/extraicons/options_ei.cpp +++ b/src/modules/extraicons/options_ei.cpp @@ -56,11 +56,8 @@ BOOL ScreenToClient(HWND hWnd, LPRECT lpRect) static void RemoveExtraIcons(int slot)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
Clist_SetExtraIcon(hContact, slot, INVALID_HANDLE_VALUE);
- hContact = db_find_next(hContact);
- }
}
#ifndef TVIS_FOCUSED
diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp index e77f0e6321..d719ca67a8 100644 --- a/src/modules/ignore/ignore.cpp +++ b/src/modules/ignore/ignore.cpp @@ -168,8 +168,7 @@ static void SaveItemMask(HWND hwndList, HANDLE hContact, HANDLE hItem, const cha static void SetAllContactIcons(HWND hwndList)
{
- HANDLE hContact = db_find_first();
- do {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 0)) == EMPTY_EXTRA_ICON) {
DWORD proto1Caps, proto4Caps;
@@ -184,7 +183,6 @@ static void SetAllContactIcons(HWND hwndList) SendMessage(hwndList, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
}
}
- while (hContact = db_find_next(hContact));
}
static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
@@ -291,41 +289,33 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM SetListGroupIcons( GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- break;
}
break;
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- {
- HANDLE hContact = db_find_first();
- do {
- HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem) SaveItemMask( GetDlgItem(hwndDlg, IDC_LIST), hContact, hItem, "Mask1");
- if (SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- db_unset(hContact, "CList", "Hidden");
- else
- db_set_b(hContact, "CList", "Hidden", 1);
- }
- while (hContact = db_find_next(hContact));
- SaveItemMask( GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemAll, "Default1");
- SaveItemMask( GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemUnknown, "Mask1");
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem) SaveItemMask( GetDlgItem(hwndDlg, IDC_LIST), hContact, hItem, "Mask1");
+ if (SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
+ db_unset(hContact, "CList", "Hidden");
+ else
+ db_set_b(hContact, "CList", "Hidden", 1);
}
- return TRUE;
+ SaveItemMask( GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemAll, "Default1");
+ SaveItemMask( GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemUnknown, "Mask1");
+ return TRUE;
}
- break;
}
break;
case WM_DESTROY:
- {
- for (int i=0; i < SIZEOF(hIcons); i++)
- DestroyIcon(hIcons[i]);
- HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
- ImageList_Destroy(hIml);
- }
+ for (int i=0; i < SIZEOF(hIcons); i++)
+ DestroyIcon(hIcons[i]);
+ HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
+ ImageList_Destroy(hIml);
break;
}
return FALSE;
diff --git a/src/modules/visibility/visibility.cpp b/src/modules/visibility/visibility.cpp index b8b21b2838..5204a0a622 100644 --- a/src/modules/visibility/visibility.cpp +++ b/src/modules/visibility/visibility.cpp @@ -106,8 +106,7 @@ static void ResetListOptions(HWND hwndList) static void SetAllContactIcons(HWND hwndList)
{
- HANDLE hContact = db_find_first();
- do {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem) {
DWORD flags;
@@ -131,7 +130,6 @@ static void SetAllContactIcons(HWND hwndList) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, status == ID_STATUS_OFFLINE ? 2 : 0));
}
}
- while (hContact = db_find_next(hContact));
}
static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
@@ -244,8 +242,7 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP case 0:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- HANDLE hContact = db_find_first();
- do {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem) {
int set = 0;
@@ -261,7 +258,6 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0);
}
}
- while (hContact = db_find_next(hContact));
return TRUE;
}
}
|