summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
commit3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c (patch)
treeefee912ee654baafeb98efcd117921db6b7489bc /src
parentbcb27264ba737778e5d3edad36088bacf74f0236 (diff)
- 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
Diffstat (limited to 'src')
-rw-r--r--src/core/stdchat/src/clist.cpp27
-rw-r--r--src/modules/clist/clistmod.cpp12
-rw-r--r--src/modules/visibility/visibility.cpp62
3 files changed, 50 insertions, 51 deletions
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp
index 63a4a5687a..fb147bf717 100644
--- a/src/core/stdchat/src/clist.cpp
+++ b/src/core/stdchat/src/clist.cpp
@@ -281,20 +281,21 @@ BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR
return TRUE;
}
-HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom)
+HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom)
{
- 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 ) {
- DBVARIANT dbv;
- if ( !db_get_ts( hContact, szProto, "ChatRoomID", &dbv )) {
- if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free( &dbv );
- return hContact;
- }
- db_free(&dbv);
- } } } }
+ for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
+ if ( !db_get_b(hContact, pszModule, "ChatRoom", 0))
+ continue;
+
+ DBVARIANT dbv;
+ if ( !db_get_ts( hContact, pszModule, "ChatRoomID", &dbv )) {
+ if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
+ db_free(&dbv);
+ return hContact;
+ }
+ db_free(&dbv);
+ }
+ }
return 0;
}
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp
index 3b3797a90e..9ab769b65a 100644
--- a/src/modules/clist/clistmod.cpp
+++ b/src/modules/clist/clistmod.cpp
@@ -143,14 +143,10 @@ 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) {
- 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);
- }
- }
+ if (caps & PF1_SERVERCLIST)
+ for (HANDLE hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, ack->szModule))
+ if (db_get_b(hContact, "CList", "Delete", 0))
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
cli.pfnTrayIconUpdateBase(ack->szModule);
diff --git a/src/modules/visibility/visibility.cpp b/src/modules/visibility/visibility.cpp
index 5204a0a622..7f805e2b99 100644
--- a/src/modules/visibility/visibility.cpp
+++ b/src/modules/visibility/visibility.cpp
@@ -108,27 +108,28 @@ static void SetAllContactIcons(HWND hwndList)
{
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;
- WORD status;
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL) {
- flags = 0;
- status = 0;
- }
- else {
- flags = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- status = db_get_w(hContact, szProto, "ApparentMode", 0);
- }
+ if (hItem == NULL)
+ continue;
+
+ DWORD flags;
+ WORD status;
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL) {
+ flags = 0;
+ status = 0;
+ }
+ else {
+ flags = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ status = db_get_w(hContact, szProto, "ApparentMode", 0);
+ }
- if (flags & PF1_INVISLIST)
- if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, 0)) == EMPTY_EXTRA_ICON)
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, status == ID_STATUS_ONLINE ? 1 : 0));
+ if (flags & PF1_INVISLIST)
+ if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, 0)) == EMPTY_EXTRA_ICON)
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, status == ID_STATUS_ONLINE ? 1 : 0));
- if (flags & PF1_VISLIST)
- if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, 0)) == EMPTY_EXTRA_ICON)
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, status == ID_STATUS_OFFLINE ? 2 : 0));
- }
+ if (flags & PF1_VISLIST)
+ if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, 0)) == EMPTY_EXTRA_ICON)
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, status == ID_STATUS_OFFLINE ? 2 : 0));
}
}
@@ -244,19 +245,20 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
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;
- for (int i=0; i < 2; i++) {
- int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
- if (iImage == i+1) {
- CallContactService(hContact, PSS_SETAPPARENTMODE, iImage == 1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE, 0);
- set = 1;
- break;
- }
+ if (hItem == NULL)
+ continue;
+
+ int set = 0;
+ for (int i=0; i < 2; i++) {
+ int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
+ if (iImage == i+1) {
+ CallContactService(hContact, PSS_SETAPPARENTMODE, iImage == 1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE, 0);
+ set = 1;
+ break;
}
- if ( !set)
- CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0);
}
+ if ( !set)
+ CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0);
}
return TRUE;
}