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 /plugins/Clist_nicer/src/contact.cpp | |
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
Diffstat (limited to 'plugins/Clist_nicer/src/contact.cpp')
-rw-r--r-- | plugins/Clist_nicer/src/contact.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
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;
|