From 7f47efb0c5973054e00fac918d2e1cdd187dd35a Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Mon, 26 Nov 2012 22:28:47 +0000
Subject: virtual protos, invisible in the Account Manager & status bar, but
 fortunately searchable

git-svn-id: http://svn.miranda-ng.org/main/trunk@2515 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 src/modules/clist/clistmenus.cpp    | 13 +++++++++----
 src/modules/findadd/findadd.cpp     |  8 ++++++--
 src/modules/protocols/protocols.cpp |  2 +-
 src/modules/protocols/protoopts.cpp | 23 +++++++++++++----------
 4 files changed, 29 insertions(+), 17 deletions(-)

(limited to 'src/modules')

diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp
index 01db784728..2ef22dbd70 100644
--- a/src/modules/clist/clistmenus.cpp
+++ b/src/modules/clist/clistmenus.cpp
@@ -795,12 +795,17 @@ static INT_PTR SetStatusMode(WPARAM wParam, LPARAM)
 	return 0;
 }
 
-int fnGetProtocolVisibility(const char* accName)
+int fnGetProtocolVisibility(const char *accName)
 {
 	if (accName) {
-		PROTOACCOUNT* pa = Proto_GetAccount(accName);
-		return pa && pa->bIsVisible && Proto_IsAccountEnabled(pa) &&
-			pa->ppro && (pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0));
+		PROTOACCOUNT *pa = Proto_GetAccount(accName);
+		if (pa && pa->bIsVisible && Proto_IsAccountEnabled(pa) && pa->ppro) {
+			PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName);
+			if (pd == NULL || pd->type != PROTOTYPE_PROTOCOL)
+				return FALSE;
+
+			return (pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0));
+		}
 	}
 
 	return FALSE;
diff --git a/src/modules/findadd/findadd.cpp b/src/modules/findadd/findadd.cpp
index 4bf76abf68..d6be80d7ca 100644
--- a/src/modules/findadd/findadd.cpp
+++ b/src/modules/findadd/findadd.cpp
@@ -349,7 +349,9 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
 
 			int i, index = 0, cbwidth = 0, netProtoCount = 0;
 			for (i=0; i < accounts.getCount(); i++) {
-				if ( !Proto_IsAccountEnabled(accounts[i])) continue;
+				if ( !Proto_IsAccountEnabled(accounts[i]))
+					continue;
+
 				DWORD caps = (DWORD)CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
 				if (caps & PF1_BASICSEARCH || caps & PF1_EXTSEARCH || caps & PF1_SEARCHBYEMAIL || caps & PF1_SEARCHBYNAME)
 					netProtoCount++;
@@ -375,7 +377,9 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
 
 			for (i=0; i < accounts.getCount(); i++) {
 				PROTOACCOUNT* pa = accounts[i];
-				if ( !Proto_IsAccountEnabled(pa)) continue;
+				if ( !Proto_IsAccountEnabled(pa))
+					continue;
+
 				DWORD caps = (DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
 				if ( !(caps&PF1_BASICSEARCH) && !(caps&PF1_EXTSEARCH) && !(caps&PF1_SEARCHBYEMAIL) && !(caps&PF1_SEARCHBYNAME))
 					continue;
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index a39e62899a..7589693e3b 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -122,7 +122,7 @@ static INT_PTR Proto_RegisterModule(WPARAM, LPARAM lParam)
 		memset(p, 0, sizeof(PROTOCOLDESCRIPTOR));
 		p->cbSize = PROTOCOLDESCRIPTOR_V3_SIZE;
 		p->type = pd->type;
-		if (p->type == PROTOTYPE_PROTOCOL) {
+		if (p->type == PROTOTYPE_PROTOCOL || p->type == PROTOTYPE_VIRTUAL) {
 			// let's create a new container
 			PROTO_INTERFACE* ppi = AddDefaultAccount(pd->szName);
 			if (ppi) {
diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp
index 9aa7436b4d..31f3302252 100644
--- a/src/modules/protocols/protoopts.cpp
+++ b/src/modules/protocols/protoopts.cpp
@@ -481,13 +481,8 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
 			EnableWindow( GetDlgItem(hwndDlg, IDC_REMOVE), FALSE);
 			EnableWindow( GetDlgItem(hwndDlg, IDC_OPTIONS), FALSE);
 			EnableWindow( GetDlgItem(hwndDlg, IDC_UPGRADE), FALSE);
-
 			{
 				LOGFONT lf;
-				HDC hdc;
-				HFONT hfnt;
-				TEXTMETRIC tm;
-
 				GetObject((HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0), sizeof(lf), &lf);
 				dat->hfntText = CreateFontIndirect(&lf);
 
@@ -495,11 +490,14 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
 				lf.lfWeight = FW_BOLD;
 				dat->hfntTitle = CreateFontIndirect(&lf);
 
-				hdc = GetDC(hwndDlg);
-				hfnt = (HFONT)SelectObject(hdc, dat->hfntTitle);
+				HDC hdc = GetDC(hwndDlg);
+				HFONT hfnt = (HFONT)SelectObject(hdc, dat->hfntTitle);
+
+				TEXTMETRIC tm;
 				GetTextMetrics(hdc, &tm);
 				dat->titleHeight = tm.tmHeight;
 				SelectObject(hdc, dat->hfntText);
+
 				GetTextMetrics(hdc, &tm);
 				dat->textHeight = tm.tmHeight;
 				SelectObject(hdc, hfnt);
@@ -660,10 +658,15 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
 			dat->iSelected = -1;
 			SendMessage(hList, LB_RESETCONTENT, 0, 0);
 			for (i=0; i < accounts.getCount(); i++) {
-				int iItem = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)accounts[i]->tszAccountName);
-				SendMessage(hList, LB_SETITEMDATA, iItem, (LPARAM)accounts[i]);
+				PROTOACCOUNT *p = accounts[i];
+				PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(p->szProtoName);
+				if (pd == NULL || pd->type != PROTOTYPE_PROTOCOL)
+					continue;
+
+				int iItem = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)p->tszAccountName);
+				SendMessage(hList, LB_SETITEMDATA, iItem, (LPARAM)p);
 
-				if (accounts[i] == acc)
+				if (p == acc)
 					ListBox_SetCurSel(hList, iItem);
 			}
 
-- 
cgit v1.2.3