From 001832de6c20442ae98cdf2ab52a61556e9b0085 Mon Sep 17 00:00:00 2001
From: Sergey Bolhovskoy <elzorfox@ya.ru>
Date: Fri, 24 Apr 2015 06:47:35 +0000
Subject: =?UTF-8?q?SmileyAdd:=20change=20=E2=80=98Use=20per=20protocol=20g?=
 =?UTF-8?q?lobal=20smiley=20packs=E2=80=99=20option=20logic=20Copyright=20?=
 =?UTF-8?q?update?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

git-svn-id: http://svn.miranda-ng.org/main/trunk@13062 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/SmileyAdd/res/resource.rc  |  4 ++--
 plugins/SmileyAdd/src/options.cpp  | 17 +++++++++++++----
 plugins/SmileyAdd/src/options.h    |  3 ++-
 plugins/SmileyAdd/src/services.cpp |  6 ++++--
 plugins/SmileyAdd/src/smileys.cpp  | 13 +++++++------
 plugins/SmileyAdd/src/smileys.h    | 10 ++++++++--
 plugins/SmileyAdd/src/version.h    | 22 +++++++++++-----------
 7 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/plugins/SmileyAdd/res/resource.rc b/plugins/SmileyAdd/res/resource.rc
index 371776f18d..af9e90c9e0 100644
--- a/plugins/SmileyAdd/res/resource.rc
+++ b/plugins/SmileyAdd/res/resource.rc
@@ -45,7 +45,7 @@ BEGIN
     EDITTEXT        IDC_NEWCATEGORY,164,85,91,13,ES_AUTOHSCROLL
     PUSHBUTTON      "+",IDC_ADDCATEGORY,263,84,17,15
     PUSHBUTTON      "-",IDC_DELETECATEGORY,290,84,17,15
-	CONTROL         "Use per protocol global smiley packs",IDC_USEPHYSPROTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,92,143,11
+    CONTROL         "Use per protocol global smiley packs",IDC_USEPHYSPROTO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,92,143,11
     GROUPBOX        "Display",IDC_STATIC,6,106,310,54
     CONTROL         "Replace only smileys surrounded by spaces",IDC_SPACES,
                     "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,115,198,12,WS_EX_RTLREADING
@@ -54,7 +54,7 @@ BEGIN
     CONTROL         "Disable custom smileys",IDC_DISABLECUSTOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,138,147,10
     CONTROL         "High quality smiley scaling",IDC_HQSCALING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,148,148,10
     CONTROL         "Animate",IDC_ANIMATEDLG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,218,116,91,10
-	EDITTEXT        IDC_MAXCUSTSMSZ,165,128,30,14,ES_RIGHT | ES_NUMBER
+    EDITTEXT        IDC_MAXCUSTSMSZ,165,128,30,14,ES_RIGHT | ES_NUMBER
     CONTROL         "",IDC_MAXCUSTSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,182,129,11,12
     LTEXT           "Maximum 'Custom smiley' height",IDC_STATIC,198,132,115,8
     EDITTEXT        IDC_MINSMSZ,165,144,30,14,ES_RIGHT | ES_NUMBER
diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp
index f0c971cac2..5fb0abf771 100644
--- a/plugins/SmileyAdd/src/options.cpp
+++ b/plugins/SmileyAdd/src/options.cpp
@@ -1,5 +1,6 @@
 /*
-Miranda SmileyAdd Plugin
+Miranda NG SmileyAdd Plugin
+Copyright (C) 2012 - 2015 Miranda NG project (http://miranda-ng.org)
 Copyright (C) 2005 - 2011 Boris Krasnovskiy All Rights Reserved
 Copyright (C) 2003 - 2004 Rein-Peter de Boer
 
@@ -131,6 +132,11 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
 			break;
 
 		case IDC_USESTDPACK:
+			if (HIWORD(wParam) == BN_CLICKED) {
+				BOOL en = IsDlgButtonChecked(m_hwndDialog, IDC_USESTDPACK) == BST_CHECKED;
+				EnableWindow(GetDlgItem(m_hwndDialog, IDC_USEPHYSPROTO), en);
+			} // no break!
+		case IDC_USEPHYSPROTO:
 			if (HIWORD(wParam) == BN_CLICKED) {
 				PopulateSmPackList(); 
 				SetChanged();
@@ -159,7 +165,6 @@ BOOL OptionsDialogType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam)
 			break;
 
 		case IDC_SPACES:
-		case IDC_USEPHYSPROTO:
 		case IDC_SCALETOTEXTHEIGHT:
 		case IDC_APPENDSPACES:
 		case IDC_SMLBUT:
@@ -316,6 +321,7 @@ long OptionsDialogType::GetSelProto(HTREEITEM hItem)
 void OptionsDialogType::PopulateSmPackList(void)
 {
 	bool useOne = IsDlgButtonChecked(m_hwndDialog, IDC_USESTDPACK) == BST_UNCHECKED;
+	bool usePhysProto = IsDlgButtonChecked(m_hwndDialog, IDC_USEPHYSPROTO) == BST_CHECKED;
 
 	HWND hLstView = GetDlgItem(m_hwndDialog, IDC_CATEGORYLIST);
 
@@ -329,8 +335,10 @@ void OptionsDialogType::PopulateSmPackList(void)
 	tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_SELECTED;
 
 	SmileyCategoryListType::SmileyCategoryVectorType& smc = *tmpsmcat.GetSmileyCategoryList();
-	for (int i=0; i < smc.getCount(); i++) {
-		if (!useOne || !smc[i].IsProto()) {
+	for (int i=0; i < smc.getCount(); i++) {			
+		bool visiblecat = usePhysProto ? !smc[i].IsAcc() : !smc[i].IsPhysProto();
+		bool visible = useOne ? !smc[i].IsProto() : visiblecat;
+		if (visible) {
 			tvi.item.pszText = (TCHAR*)smc[i].GetDisplayName().c_str();
 			if (!smc[i].IsProto()) {
 				tvi.item.iImage = 0;
@@ -377,6 +385,7 @@ void OptionsDialogType::InitDialog(void)
 
 	SendDlgItemMessage(m_hwndDialog, IDC_SMLBUT, CB_SETCURSEL, opt.ButtonStatus, 0);  
 	EnableWindow(GetDlgItem(m_hwndDialog, IDC_SMLBUT), opt.PluginSupportEnabled);
+	EnableWindow(GetDlgItem(m_hwndDialog, IDC_USEPHYSPROTO), !opt.UseOneForAll);
 
 	SendDlgItemMessage(m_hwndDialog, IDC_MAXCUSTSPIN, UDM_SETRANGE32, 0, 99);
 	SendDlgItemMessage(m_hwndDialog, IDC_MAXCUSTSPIN, UDM_SETPOS, 0, opt.MaxCustomSmileySize);
diff --git a/plugins/SmileyAdd/src/options.h b/plugins/SmileyAdd/src/options.h
index fea3d97a6a..f5d10d659d 100644
--- a/plugins/SmileyAdd/src/options.h
+++ b/plugins/SmileyAdd/src/options.h
@@ -1,5 +1,6 @@
 /*
-Miranda SmileyAdd Plugin
+Miranda NG SmileyAdd Plugin
+Copyright (C) 2012 - 2015 Miranda NG project (http://miranda-ng.org)
 Copyright (C) 2005 - 2011 Boris Krasnovskiy
 Copyright (C) 2003 - 2004 Rein-Peter de Boer
 
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp
index a06f5468ba..0ada278cb0 100644
--- a/plugins/SmileyAdd/src/services.cpp
+++ b/plugins/SmileyAdd/src/services.cpp
@@ -1,5 +1,6 @@
 /*
-Miranda SmileyAdd Plugin
+Miranda NG SmileyAdd Plugin
+Copyright (C) 2012 - 2015 Miranda NG project (http://miranda-ng.org)
 Copyright (C) 2005 - 2011 Boris Krasnovskiy All Rights Reserved
 Copyright (C) 2003 - 2004 Rein-Peter de Boer
 
@@ -67,7 +68,8 @@ SmileyPackType* GetSmileyPack(const char* proto, MCONTACT hContact, SmileyPackCT
 			categoryName = A2T_SM(proto);
 			if (opt.UseOneForAll) {
 				SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName);
-				if (smc == NULL || smc->IsProto()) categoryName = _T("Standard");
+				if (smc == NULL || smc->IsProto()) 
+					categoryName = _T("Standard");
 			}
 		}
 	}
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index bd5aa658b1..8ac6d9bafe 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -1,5 +1,6 @@
 /*
-Miranda SmileyAdd Plugin
+Miranda NG SmileyAdd Plugin
+Copyright (C) 2012 - 2015 Miranda NG project (http://miranda-ng.org)
 Copyright (C) 2005 - 2011 Boris Krasnovskiy All Rights Reserved
 Copyright (C) 2003 - 2004 Rein-Peter de Boer
 
@@ -730,7 +731,7 @@ SmileyCategoryType::SmileyCategoryType(SmileyPackListType* pSPS, const CMString&
 
 void SmileyCategoryType::Load(void)
 {
-	if (!opt.UseOneForAll || type != smcProto)
+	if (!opt.UseOneForAll || !IsProto())
 		m_pSmileyPackStore->AddSmileyPack(m_Filename);
 }
 
@@ -877,7 +878,7 @@ void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMString& defau
 	displayName += TranslateT(" global smiley pack");
 	CMString tname("AllProto");
 	tname += A2T_SM(acc);
-	AddCategory(tname, displayName, smcProto, paths);
+	AddCategory(tname, displayName, smcPhysProto, paths);
 }
 
 void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc)
@@ -945,9 +946,9 @@ void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, co
 			if (_taccess(patha.c_str(), 0) != 0) 
 				paths = defaultFile;
 
-			AddCategory(displayName, displayName, smcProto, paths); 
+			AddCategory(displayName, displayName, smcTransportProto, paths); 
 		}
-		else AddCategory(displayName, displayName, smcProto, defaultFile); 
+		else AddCategory(displayName, displayName, smcTransportProto, defaultFile);
 
 		db_free(&dbv);
 	}
@@ -977,7 +978,7 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void)
 
 	PROTOACCOUNT **accList;	
 	ProtoEnumAccounts(&protoCount, &accList);
-	for (int i = 0; i < protoCount; i++) 
+	for (int i = 0; i < protoCount; i++)
 		AddAccountAsCategory(accList[i], defaultFile);
 
 	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h
index 4b04a1d756..fce65fffa2 100644
--- a/plugins/SmileyAdd/src/smileys.h
+++ b/plugins/SmileyAdd/src/smileys.h
@@ -1,5 +1,6 @@
 /*
-Miranda SmileyAdd Plugin
+Miranda NG SmileyAdd Plugin
+Copyright (C) 2012 - 2015 Miranda NG project (http://miranda-ng.org)
 Copyright (C) 2005 - 2011 Boris Krasnovskiy
 Copyright (C) 2003 - 2004 Rein-Peter de Boer
 
@@ -224,6 +225,8 @@ typedef enum
 	smcNone,
 	smcStd,
 	smcProto,
+	smcTransportProto,
+	smcPhysProto,
 	smcCustom,
 	smcExt
 } SmcType;
@@ -250,7 +253,10 @@ public:
 	const CMString& GetFilename(void) const { return m_Filename; }
 
 	bool IsCustom(void) { return type == smcCustom; }
-	bool IsProto(void)  { return type == smcProto;  }
+	bool IsProto(void)  { return type == smcProto || type == smcPhysProto || type == smcTransportProto; }
+	bool IsAcc(void)  { return type == smcProto; }
+	bool IsPhysProto(void)  { return type == smcPhysProto; }
+	bool IsTransportProto(void)  { return type == smcTransportProto; }
 	bool IsExt(void)    { return type == smcExt;  }
 
 	SmcType GetType(void) { return type; }
diff --git a/plugins/SmileyAdd/src/version.h b/plugins/SmileyAdd/src/version.h
index d4e03ce728..a8df0fc5d4 100644
--- a/plugins/SmileyAdd/src/version.h
+++ b/plugins/SmileyAdd/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION            0
-#define __MINOR_VERSION            2
-#define __RELEASE_NUM            3
-#define __BUILD_NUM               18
+#define __MAJOR_VERSION	0
+#define __MINOR_VERSION	2
+#define __RELEASE_NUM	3
+#define __BUILD_NUM		18
 
 #include <stdver.h>
 
-#define __PLUGIN_NAME            "SmileyAdd"
-#define __FILENAME               "SmileyAdd.dll"
-#define __DESCRIPTION             "Smiley support for Miranda NG."
-#define __AUTHOR               "Peacow, nightwish, bid, borkra"
-#define __AUTHOREMAIL            "borkra@miranda-im.org"
-#define __AUTHORWEB               "http://miranda-ng.org/p/SmileyAdd/"
-#define __COPYRIGHT               "� 2004 - 2012 Boris Krasnovskiy, portions by Rein-Peter de Boer"
+#define __PLUGIN_NAME	"SmileyAdd"
+#define __FILENAME		"SmileyAdd.dll"
+#define __DESCRIPTION	"Smiley support for Miranda NG."
+#define __AUTHOR		"Peacow, nightwish, bid, borkra"
+#define __AUTHOREMAIL	"borkra@miranda-im.org"
+#define __AUTHORWEB		"http://miranda-ng.org/p/SmileyAdd/"
+#define __COPYRIGHT		"� 2012 - 15 Miranda NG Team, 2004 - 12 Boris Krasnovskiy, portions by Rein-Peter de Boer"
-- 
cgit v1.2.3