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 /protocols/IRCG/src | |
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 'protocols/IRCG/src')
-rw-r--r-- | protocols/IRCG/src/clist.cpp | 23 | ||||
-rw-r--r-- | protocols/IRCG/src/commandmonitor.cpp | 14 |
2 files changed, 14 insertions, 23 deletions
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 );
|