From 3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Apr 2013 21:40:22 +0000 Subject: - the kernel filters out contacts by proto names much faster than a plugin; - database cycles simplified git-svn-id: http://svn.miranda-ng.org/main/trunk@4404 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/EmLanProto/src/mlan.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'protocols/EmLanProto') diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp index b17b7ef7c9..653557e160 100644 --- a/protocols/EmLanProto/src/mlan.cpp +++ b/protocols/EmLanProto/src/mlan.cpp @@ -127,12 +127,9 @@ void CMLan::SetMirandaStatus(u_int status) void CMLan::SetAllOffline() { - 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"); - } + for (HANDLE hContact = db_find_first(PROTONAME); hContact; hContact = db_find_next(hContact, PROTONAME)) { + db_set_w(hContact, PROTONAME, "Status", ID_STATUS_OFFLINE); + db_unset(hContact, PROTONAME, "IP"); } DeleteCache(); } @@ -241,18 +238,15 @@ 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) { - 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); - if (caddr==addr.S_un.S_addr) { - if (make_permanent) - db_unset(res,"CList","NotOnList"); - if (make_visible) - db_unset(res,"CList","Hidden"); - return res; - } - } + for (HANDLE res = db_find_first(PROTONAME); res; res = db_find_next(res, PROTONAME)) { + u_long caddr = db_get_dw(res, PROTONAME, "ipaddr", -1); + if (caddr==addr.S_un.S_addr) { + if (make_permanent) + db_unset(res,"CList","NotOnList"); + if (make_visible) + db_unset(res,"CList","Hidden"); + return res; + } } if (add_to_list) { -- cgit v1.2.3