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/EmLanProto/src/mlan.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 'protocols/EmLanProto/src/mlan.cpp')
-rw-r--r-- | protocols/EmLanProto/src/mlan.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
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)
|