From dd13e3c81400c3607a4f63a501b53b46052035ab Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Thu, 23 Apr 2015 11:36:27 +0000 Subject: SmileyAdd: add per protocol global smiley packs support version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@13056 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SmileyAdd/res/resource.rc | 8 ++++---- plugins/SmileyAdd/src/options.cpp | 5 +++++ plugins/SmileyAdd/src/options.h | 1 + plugins/SmileyAdd/src/resource.h | 1 + plugins/SmileyAdd/src/services.cpp | 8 +++++++- plugins/SmileyAdd/src/smileys.cpp | 38 ++++++++++++++++++++++++++++++++++++-- plugins/SmileyAdd/src/smileys.h | 1 + plugins/SmileyAdd/src/version.h | 2 +- 8 files changed, 56 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/SmileyAdd/res/resource.rc b/plugins/SmileyAdd/res/resource.rc index 3477b97f1f..371776f18d 100644 --- a/plugins/SmileyAdd/res/resource.rc +++ b/plugins/SmileyAdd/res/resource.rc @@ -30,7 +30,7 @@ EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Smiley categories",IDC_STATIC,6,3,310,102 - CONTROL "",IDC_CATEGORYLIST,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_CHECKBOXES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,14,13,104,83 + CONTROL "",IDC_CATEGORYLIST,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_CHECKBOXES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,14,13,104,76 CONTROL "Specify smiley pack for each category",IDC_USESTDPACK, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,124,11,165,11 EDITTEXT IDC_FILENAME,124,25,185,12,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES @@ -42,9 +42,10 @@ BEGIN LTEXT "Version:",IDC_STATIC,125,70,34,8 LTEXT "",IDC_LIBVERSION,163,70,100,11,SS_SUNKEN | SS_PATHELLIPSIS PUSHBUTTON "Preview",IDC_SMLOPTBUTTON,270,55,37,25 - EDITTEXT IDC_NEWCATEGORY,126,85,129,13,ES_AUTOHSCROLL + 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 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 @@ -53,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 @@ -105,7 +106,6 @@ END // remains consistent on all systems. IDI_SMILINGICON ICON "smiley.ICO" - #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp index d4147c36f2..f0c971cac2 100644 --- a/plugins/SmileyAdd/src/options.cpp +++ b/plugins/SmileyAdd/src/options.cpp @@ -159,6 +159,7 @@ 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: @@ -357,6 +358,7 @@ void OptionsDialogType::InitDialog(void) CheckDlgButton(m_hwndDialog, IDC_SPACES, opt.EnforceSpaces ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwndDialog, IDC_SCALETOTEXTHEIGHT, opt.ScaleToTextheight ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwndDialog, IDC_USESTDPACK, opt.UseOneForAll ? BST_UNCHECKED : BST_CHECKED); + CheckDlgButton(m_hwndDialog, IDC_USEPHYSPROTO, opt.UsePhysProto ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwndDialog, IDC_APPENDSPACES, opt.SurroundSmileyWithSpaces ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwndDialog, IDC_SCALEALLSMILEYS, opt.ScaleAllSmileys ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwndDialog, IDC_IEVIEWSTYLE, opt.IEViewStyle ? BST_CHECKED : BST_UNCHECKED); @@ -431,6 +433,7 @@ void OptionsDialogType::ApplyChanges(void) opt.EnforceSpaces = IsDlgButtonChecked(m_hwndDialog, IDC_SPACES) == BST_CHECKED; opt.ScaleToTextheight = IsDlgButtonChecked(m_hwndDialog, IDC_SCALETOTEXTHEIGHT) == BST_CHECKED; opt.UseOneForAll = IsDlgButtonChecked(m_hwndDialog, IDC_USESTDPACK) == BST_UNCHECKED; + opt.UsePhysProto = IsDlgButtonChecked(m_hwndDialog, IDC_USEPHYSPROTO) == BST_CHECKED; opt.SurroundSmileyWithSpaces = IsDlgButtonChecked(m_hwndDialog, IDC_APPENDSPACES) == BST_CHECKED; opt.ScaleAllSmileys = IsDlgButtonChecked(m_hwndDialog, IDC_SCALEALLSMILEYS) == BST_CHECKED; opt.IEViewStyle = IsDlgButtonChecked(m_hwndDialog, IDC_IEVIEWSTYLE) == BST_CHECKED; @@ -555,6 +558,7 @@ void OptionsType::Save(void) db_set_b(NULL, "SmileyAdd", "EnforceSpaces", EnforceSpaces); db_set_b(NULL, "SmileyAdd", "ScaleToTextheight", ScaleToTextheight); db_set_b(NULL, "SmileyAdd", "UseOneForAll", UseOneForAll); + db_set_b(NULL, "SmileyAdd", "UsePhysProto", UsePhysProto); db_set_b(NULL, "SmileyAdd", "SurroundSmileyWithSpaces", SurroundSmileyWithSpaces); db_set_b(NULL, "SmileyAdd", "ScaleAllSmileys", ScaleAllSmileys); db_set_b(NULL, "SmileyAdd", "IEViewStyle", IEViewStyle); @@ -576,6 +580,7 @@ void OptionsType::Load(void) EnforceSpaces = db_get_b(NULL, "SmileyAdd", "EnforceSpaces", FALSE) != 0; ScaleToTextheight = db_get_b(NULL, "SmileyAdd", "ScaleToTextheight", FALSE) != 0; UseOneForAll = db_get_b(NULL, "SmileyAdd", "UseOneForAll", TRUE) != 0; + UsePhysProto = db_get_b(NULL, "SmileyAdd", "UsePhysProto", FALSE) != 0; SurroundSmileyWithSpaces = db_get_b(NULL, "SmileyAdd", "SurroundSmileyWithSpaces", FALSE) != 0; ScaleAllSmileys = db_get_b(NULL, "SmileyAdd", "ScaleAllSmileys", FALSE) != 0; diff --git a/plugins/SmileyAdd/src/options.h b/plugins/SmileyAdd/src/options.h index c7fcb9ebd2..fea3d97a6a 100644 --- a/plugins/SmileyAdd/src/options.h +++ b/plugins/SmileyAdd/src/options.h @@ -29,6 +29,7 @@ public: bool EnforceSpaces; bool ScaleToTextheight; bool UseOneForAll; + bool UsePhysProto; bool SurroundSmileyWithSpaces; bool ScaleAllSmileys; bool IEViewStyle; diff --git a/plugins/SmileyAdd/src/resource.h b/plugins/SmileyAdd/src/resource.h index bdf799fe2c..dcc3d859e7 100644 --- a/plugins/SmileyAdd/src/resource.h +++ b/plugins/SmileyAdd/src/resource.h @@ -19,6 +19,7 @@ #define IDC_IEVIEWSTYLE 1047 #define IDC_ANIMATESEL 1048 #define IDC_USESTDPACK 1049 +#define IDC_USEPHYSPROTO 1050 #define IDC_ANIMATEDLG 1051 #define IDC_DISABLECUSTOM 1052 #define IDC_DISABLECUSTOM2 1053 diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 904da99971..a06f5468ba 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -49,7 +49,13 @@ SmileyPackType* GetSmileyPack(const char* proto, MCONTACT hContact, SmileyPackCT categoryName = dbv.ptszVal; db_free(&dbv); } - else categoryName = A2T_SM(protonam); + else if (opt.UsePhysProto && db_get_ts(NULL, protonam, "AM_BaseProto", &dbv) == 0){ + categoryName = _T("AllProto"); + categoryName += dbv.ptszVal; + db_free(&dbv); + } + else + categoryName = A2T_SM(protonam); } } } diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index dc6a0e215f..bd5aa658b1 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -854,6 +854,32 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr } } +void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMString& defaultFile) +{ + if (acc == NULL) + return; + + const char* packnam = acc; + if (strcmp(packnam, "JABBER") == 0) + packnam = "JGMail"; + else if (strstr(packnam, "SIP") != NULL) + packnam = "MSN"; + + char path[MAX_PATH]; + mir_snprintf(path, SIZEOF(path), "Smileys\\nova\\%s.msl", packnam); + + CMString paths = A2T_SM(path), patha; + pathToAbsolute(paths, patha); + + if (_taccess(patha.c_str(), 0) != 0) + paths = defaultFile; + CMString displayName(acc); + displayName += TranslateT(" global smiley pack"); + CMString tname("AllProto"); + tname += A2T_SM(acc); + AddCategory(tname, displayName, smcProto, paths); +} + void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) { CMString tname(A2T_SM(acc->szModuleName)); @@ -939,9 +965,17 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) unsigned lpcp = (unsigned)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); if (lpcp == CALLSERVICE_NOTFOUND) lpcp = CP_ACP; + PROTOCOLDESCRIPTOR **proto; + int protoCount = 0; + CallService(MS_PROTO_ENUMPROTOS, (WPARAM)&protoCount, (LPARAM)&proto); + + for (int i = 0; i < protoCount; i++){ + PROTOCOLDESCRIPTOR* pd = proto[i]; + if (pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof(*pd)) + AddProtoAsCategory(pd->szName, defaultFile); + } - PROTOACCOUNT **accList; - int protoCount; + PROTOACCOUNT **accList; ProtoEnumAccounts(&protoCount, &accList); for (int i = 0; i < protoCount; i++) AddAccountAsCategory(accList[i], defaultFile); diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h index d0ed2756c9..4b04a1d756 100644 --- a/plugins/SmileyAdd/src/smileys.h +++ b/plugins/SmileyAdd/src/smileys.h @@ -291,6 +291,7 @@ public: void AddAndLoad(const CMString& name, const CMString& displayName); void AddAllProtocolsAsCategory(void); void AddAccountAsCategory(PROTOACCOUNT *acc, const CMString& defaultFile); + void AddProtoAsCategory(char *acc, const CMString& defaultFile); void AddContactTransportAsCategory(MCONTACT hContact, const CMString& defaultFile); void ClearAndLoadAll(void); diff --git a/plugins/SmileyAdd/src/version.h b/plugins/SmileyAdd/src/version.h index 82ac720df0..d4e03ce728 100644 --- a/plugins/SmileyAdd/src/version.h +++ b/plugins/SmileyAdd/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 3 -#define __BUILD_NUM 17 +#define __BUILD_NUM 18 #include -- cgit v1.2.3