From c6f59d75142b7568dd89f5cff691b0b58030aafd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Sep 2023 13:41:55 +0300 Subject: SmileyAdd: fix for the obsolete quirks in SmaileyAdd API --- libs/mTextControl/src/services.cpp | 3 +- plugins/BasicHistory/src/HistoryWindow.cpp | 3 +- plugins/BasicHistory/src/RichHtmlExport.cpp | 7 +- plugins/Clist_modern/src/modern_cachefuncs.cpp | 7 +- plugins/Clist_modern/src/modern_clc.cpp | 2 - plugins/ExternalAPI/delphi/m_smileyadd.inc | 6 - plugins/ExternalAPI/m_smileyadd.h | 210 ++++++++++++------------- plugins/HistoryPlusPlus/hpp_itemprocess.pas | 1 - plugins/IEView/src/TextToken.cpp | 5 +- plugins/Scriver/src/msglog.cpp | 5 +- plugins/SmileyAdd/src/AniSmileyObject.cpp | 1 - plugins/SmileyAdd/src/services.cpp | 20 +-- plugins/TabSRMM/src/infopanel.cpp | 2 +- plugins/TabSRMM/src/msgdlgother.cpp | 7 +- plugins/TabSRMM/src/msglog.cpp | 4 +- plugins/TipperYM/src/mir_smileys.cpp | 10 +- plugins/TranslitSwitcher/src/Layoutproc.cpp | 17 +- src/core/stdmsg/src/msglog.cpp | 6 +- utils/mir_smileys.cpp | 21 +-- 19 files changed, 152 insertions(+), 185 deletions(-) diff --git a/libs/mTextControl/src/services.cpp b/libs/mTextControl/src/services.cpp index 310c2863dd..4eebeeab22 100644 --- a/libs/mTextControl/src/services.cpp +++ b/libs/mTextControl/src/services.cpp @@ -52,8 +52,7 @@ void MText_InitFormatting1(TextObject *text) // smilies HWND hwnd = CreateProxyWindow(text->ftd->getTextService()); - SMADD_RICHEDIT3 sm = {}; - sm.cbSize = sizeof(sm); + SMADD_RICHEDIT sm = {}; sm.hwndRichEditControl = hwnd; sm.rangeToReplace = nullptr; sm.Protocolname = text->szProto; diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 813fc57860..ec120dadc9 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -1189,8 +1189,7 @@ void HistoryWindow::ReplaceIcons(HWND hwndDlg, int selStart, BOOL isSent) sel.cpMin = selStart; sel.cpMax = -1; - SMADD_RICHEDIT3 smadd = { 0 }; - smadd.cbSize = sizeof(smadd); + SMADD_RICHEDIT smadd = { 0 }; smadd.hwndRichEditControl = hwndDlg; smadd.Protocolname = Proto_GetBaseAccountName(m_hContact); smadd.hContact = m_hContact; diff --git a/plugins/BasicHistory/src/RichHtmlExport.cpp b/plugins/BasicHistory/src/RichHtmlExport.cpp index 682b7240f1..0a10a71db0 100644 --- a/plugins/BasicHistory/src/RichHtmlExport.cpp +++ b/plugins/BasicHistory/src/RichHtmlExport.cpp @@ -379,12 +379,11 @@ std::wstring RichHtmlExport::ReplaceSmileys(bool isMe, const std::wstring &msg, wchar_t* msgbuf = new wchar_t[msg.length() + 1]; memcpy_s(msgbuf, (msg.length() + 1) * sizeof(wchar_t), msg.c_str(), (msg.length() + 1) * sizeof(wchar_t)); - SMADD_BATCHPARSE2 sp = { 0 }; + SMADD_BATCHPARSE sp = { 0 }; SMADD_BATCHPARSERES *spr; - sp.cbSize = sizeof(sp); sp.Protocolname = baseProto.length() == 0 ? nullptr : baseProto.c_str(); - sp.str = msgbuf; - sp.flag = SAFL_TCHAR | SAFL_PATH | (isMe ? SAFL_OUTGOING : 0); + sp.str.w = msgbuf; + sp.flag = SAFL_UNICODE | SAFL_PATH | (isMe ? SAFL_OUTGOING : 0); spr = (SMADD_BATCHPARSERES*)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); delete[] msgbuf; diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 1fff523f92..a6bfa12a9d 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -183,8 +183,7 @@ void CSmileyString::ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, wchar_t * int text_size = (int)mir_wstrlen(szText); // Call service for the first time to see if needs to be used... - SMADD_BATCHPARSE2 sp = {}; - sp.cbSize = sizeof(sp); + SMADD_BATCHPARSE sp = {}; sp.hContact = pdnce->hContact; if (dat->text_use_protocol_smileys) { @@ -198,8 +197,8 @@ void CSmileyString::ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, wchar_t * } else sp.Protocolname = "clist"; - sp.str = szText; - sp.flag = SAFL_TCHAR; + sp.str.w = szText; + sp.flag = SAFL_UNICODE; SMADD_BATCHPARSERES *spr = (SMADD_BATCHPARSERES*)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index fecf90b3c5..2e9646681d 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1604,10 +1604,8 @@ static int clcHookModulesLoaded(WPARAM, LPARAM) // Register smiley category if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) { SMADD_REGCAT rc; - rc.cbSize = sizeof(rc); rc.name = "clist"; rc.dispname = Translate("Contact list smileys"); - CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc); HookEvent(ME_SMILEYADD_OPTIONSCHANGED, clcHookSmileyAddOptionsChanged); diff --git a/plugins/ExternalAPI/delphi/m_smileyadd.inc b/plugins/ExternalAPI/delphi/m_smileyadd.inc index 186b9446ea..346c03c9e1 100644 --- a/plugins/ExternalAPI/delphi/m_smileyadd.inc +++ b/plugins/ExternalAPI/delphi/m_smileyadd.inc @@ -30,7 +30,6 @@ const type PSMADD_RICHEDIT3 = ^TSMADD_RICHEDIT3; TSMADD_RICHEDIT3 = record - cbSize :uint; // size of the structure hwndRichEditControl:HWND; // handle to the rich edit control rangeToReplace :PCHARRANGE; // same meaning as for normal Richedit use (NULL = replaceall) Protocolname :PAnsiChar; // protocol to use... if you have defined a @@ -61,7 +60,6 @@ const type PSMADD_INFO2 = ^TSMADD_INFO2; TSMADD_INFO2 = record - cbSize : int; // size of the structure Protocolname : PAnsiChar; ButtonIcon : HICON; // RETURN VALUE: this is filled with the // icon handle of the smiley that can be used on the button @@ -86,7 +84,6 @@ const type PSMADD_BATCHPARSE2 = ^TSMADD_BATCHPARSE2; TSMADD_BATCHPARSE2 = record - cbSize :uint; // size of the structure Protocolname:PAnsiChar; // protocol to use... if you have defined a protocol, u can // use your own protocol name. Smiley add wil automatically // select the smileypack that is defined for your protocol. @@ -132,7 +129,6 @@ const type PSMADD_REGCAT = ^TSMADD_REGCAT; TSMADD_REGCAT = record - cbSize :uint; // size of the structure name :PAnsiChar; // smiley category name for reference dispname:PAnsiChar; // smiley category name for display end; @@ -190,7 +186,6 @@ type idFrom :uint_ptr; // ignored code :uint; // NM_FIREVIEWCHANGE - cbSize :size_t; bEvent :byte; // FVCN_ value - pre- or post- painting bAction :byte; // FVCA_ keys hDC :HDC; // Canvas to draw on @@ -206,7 +201,6 @@ const type TSMADD_CONT = record - cbSize :uint; hContact:TMCONTACT; _type :int; // 0 - directory, 1 - file; path :TChar; // smiley category name for reference diff --git a/plugins/ExternalAPI/m_smileyadd.h b/plugins/ExternalAPI/m_smileyadd.h index 90ca190561..636dda0bcd 100644 --- a/plugins/ExternalAPI/m_smileyadd.h +++ b/plugins/ExternalAPI/m_smileyadd.h @@ -21,136 +21,135 @@ along with this program. If not, see . #include -#define SAFLRE_INSERTEMF 2 // insert smiley as EMF into RichEdit, otherwise bitmap inserted - // this flag allows "true" transparency -#define SAFLRE_OUTGOING 4 // Parsing outgoing message -#define SAFLRE_NOCUSTOM 8 // Do not use custom smileys -#define SAFLRE_FIREVIEW 16 // use NM_FIREVIEWCHANGE messages - -struct SMADD_RICHEDIT3 +///////////////////////////////////////////////////////////////////////////////////////// +// Replace smileys in a rich edit control... +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_RICHEDIT3*) &smre; //pointer to SMADD_RICHEDIT3 +// return: TRUE if API succeeded (all parameters were valid) , FALSE if not. + +#define SAFLRE_INSERTEMF 2 // insert smiley as EMF into RichEdit, otherwise bitmap inserted + // this flag allows "true" transparency +#define SAFLRE_OUTGOING 4 // Parsing outgoing message +#define SAFLRE_NOCUSTOM 8 // Do not use custom smileys +#define SAFLRE_FIREVIEW 16 // use NM_FIREVIEWCHANGE messages + +struct SMADD_RICHEDIT { - unsigned cbSize; //size of the structure - HWND hwndRichEditControl; //handle to the rich edit control - CHARRANGE *rangeToReplace; //same meaning as for normal Richedit use (NULL = replaceall) - const char *Protocolname; //protocol to use... if you have defined a protocol, u can - //use your own protocol name. SmileyAdd will automatically - //select the smileypack that is defined for your protocol. - //Or, use "Standard" for standard smiley set. Or "ICQ" - //if you prefer those icons. - //If not found or NULL, "Standard" will be used - unsigned flags; //Flags (SAFLRE_*) that define the behaivior - BOOL disableRedraw; //Parameter have been depricated, have no effect on operation - MCONTACT hContact; //Contact handle + HWND hwndRichEditControl; // handle to the rich edit control + CHARRANGE *rangeToReplace; // same meaning as for normal Richedit use (NULL = replaceall) + const char *Protocolname; // protocol to use... if you have defined a protocol, u can + // use your own protocol name. SmileyAdd will automatically + // select the smileypack that is defined for your protocol. + // Or, use "Standard" for standard smiley set. Or "ICQ" + // if you prefer those icons. + // If not found or NULL, "Standard" will be used + unsigned flags; // Flags (SAFLRE_*) that define the behaivior + BOOL disableRedraw; // Parameter have been depricated, have no effect on operation + MCONTACT hContact; // Contact handle }; -//Replace smileys in a rich edit control... -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) (SMADD_RICHEDIT3*) &smre; //pointer to SMADD_RICHEDIT3 -//return: TRUE if API succeeded (all parameters were valid) , FALSE if not. #define MS_SMILEYADD_REPLACESMILEYS "SmileyAdd/ReplaceSmileys" -struct SMADD_INFO2 +///////////////////////////////////////////////////////////////////////////////////////// +// gets button smiley icon +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_INFO2*) &smgi; //pointer to SMADD_INFO2 +// return: TRUE if API succeeded (all parameters were valid) , FALSE if not. + +struct SMADD_INFO { - unsigned cbSize; //size of the structure - char *Protocolname; // " " - HICON ButtonIcon; //RETURN VALUE: this is filled with the icon handle - //of the smiley that can be used on the button - //if used with GETINFO2 handle must be destroyed by user! - //NULL if the buttonicon is not defined... - int NumberOfVisibleSmileys; //Number of visible smileys defined. - int NumberOfSmileys; //Number of total smileys defined + char *Protocolname; + HICON ButtonIcon; // RETURN VALUE: this is filled with the icon handle + // of the smiley that can be used on the button + // if used with GETINFO2 handle must be destroyed by user! + // NULL if the buttonicon is not defined... + int NumberOfVisibleSmileys; // Number of visible smileys defined. + int NumberOfSmileys; // Number of total smileys defined }; -//get button smiley icon -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) (SMADD_INFO2*) &smgi; //pointer to SMADD_INFO2 -//return: TRUE if API succeeded (all parameters were valid) , FALSE if not. #define MS_SMILEYADD_GETINFO2 "SmileyAdd/GetInfo2" +///////////////////////////////////////////////////////////////////////////////////////// // Event notifies that SmileyAdd options have changed // Message dialogs usually need to redraw it's content on reception of this event -//wParam = Contact handle which options have changed, NULL if global options changed -//lParam = (LPARAM) 0; not used +// wParam = Contact handle which options have changed, NULL if global options changed +// lParam = (LPARAM) 0; not used + #define ME_SMILEYADD_OPTIONSCHANGED "SmileyAdd/OptionsChanged" -#define SAFL_PATH 1 // provide smiley file path, icon otherwise -#define SAFL_UNICODE 2 // string fields in OPTIONSDIALOGPAGE are WCHAR* -#define SAFL_OUTGOING 4 // Parsing outgoing message -#define SAFL_NOCUSTOM 8 // Do not use custom smileys +///////////////////////////////////////////////////////////////////////////////////////// +// finds all smileys in text, API parses the provided text and returns all smileys found +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_BATCHPARSE2*) &smgp; //pointer to SMADD_BATCHPARSE2 +// function returns pointer to array SMADD_BATCHPARSERES records for each smiley found +// if no smileys found NULL is returned +// if non NULL value returned pointer must be freed with MS_SMILEYADD_BATCHFREE API -#if defined _UNICODE || defined UNICODE - #define SAFL_TCHAR SAFL_UNICODE -#else - #define SAFL_TCHAR 0 -#endif +#define SAFL_PATH 1 // provide smiley file path, icon otherwise +#define SAFL_UNICODE 2 // string fields in OPTIONSDIALOGPAGE are WCHAR* +#define SAFL_OUTGOING 4 // Parsing outgoing message +#define SAFL_NOCUSTOM 8 // Do not use custom smileys -struct SMADD_BATCHPARSE2 +struct SMADD_BATCHPARSE { - unsigned cbSize; //size of the structure - const char *Protocolname; //protocol to use... if you have defined a protocol, u can - //use your own protocol name. Smiley add wil automatically - //select the smileypack that is defined for your protocol. - //Or, use "Standard" for standard smiley set. Or "ICQ" - //if you prefer those icons. - //If not found or NULL: "Standard" will be used - union { - TCHAR *str; //String to parse - char *astr; - wchar_t *wstr; - }; - unsigned flag; //One of the SAFL_ flags specifies parsing requirements - //This parameter should be filled by the user - - unsigned numSmileys; //Number of Smileys found, this parameter filled by SmileyAdd - unsigned oflag; //One of the SAFL_ flags specifies content of the parse results - //this parameter filled by SmileyAdd - MCONTACT hContact; //Contact handle + const char *Protocolname; // protocol to use... if you have defined a protocol, u can + // use your own protocol name. Smiley add wil automatically + // select the smileypack that is defined for your protocol. + // Or, use "Standard" for standard smiley set. Or "ICQ" + // if you prefer those icons. + // If not found or NULL: "Standard" will be used + + MAllCStrings str; // A text to parse + unsigned flag; // One of the SAFL_ flags specifies parsing requirements + // This parameter should be filled by the user + unsigned numSmileys; // Number of Smileys found, this parameter filled by SmileyAdd + unsigned oflag; // One of the SAFL_ flags specifies content of the parse results + // this parameter filled by SmileyAdd + MCONTACT hContact; // Contact handle }; struct SMADD_BATCHPARSERES { - unsigned startChar; //Starting smiley character - //Because of iterative nature of the API caller should set this - //parameter to correct value - unsigned size; //Number of characters in smiley (0 if not found) - //Because of iterative nature of the API caller should set this - //parameter to correct value - union { - const TCHAR *filepath; - const char *afilepath; - const wchar_t *wfilepath; - HICON hIcon; //User responsible for destroying icon handle + unsigned startChar; // Starting smiley character + // Because of iterative nature of the API caller should set this + // parameter to correct value + unsigned size; // Number of characters in smiley (0 if not found) + // Because of iterative nature of the API caller should set this + // parameter to correct value + union + { + const wchar_t *filepath; + HICON hIcon; // User is responsible for destroying icon handle }; }; -//find all smileys in text, API parses the provided text and returns all smileys found -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) (SMADD_BATCHPARSE2*) &smgp; //pointer to SMADD_BATCHPARSE2 -//function returns pointer to array SMADD_BATCHPARSERES records for each smiley found -//if no smileys found NULL is returned -//if non NULL value returned pointer must be freed with MS_SMILEYADD_BATCHFREE API #define MS_SMILEYADD_BATCHPARSE "SmileyAdd/BatchParse" -//Free memory allocated by MS_SMILEYADD_BATCHPARSE -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) (SMADD_BATCHPARSERES*) &smgp; //pointer to SMADD_BATCHPARSERES +///////////////////////////////////////////////////////////////////////////////////////// +// Frees memory allocated by MS_SMILEYADD_BATCHPARSE +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_BATCHPARSERES*) &smgp; //pointer to SMADD_BATCHPARSERES + #define MS_SMILEYADD_BATCHFREE "SmileyAdd/BatchFree" +///////////////////////////////////////////////////////////////////////////////////////// +// Register smiley category +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_REGCAT*) &smgp; pointer to SMADD_REGCAT + struct SMADD_REGCAT { - unsigned cbSize; //size of the structure - char *name; //smiley category name for reference - char *dispname; //smiley category name for display + char *name; // smiley category name for reference + char *dispname; // smiley category name for display }; -//Register smiley category -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) (SMADD_REGCAT*) &smgp; pointer to SMADD_REGCAT #define MS_SMILEYADD_REGISTERCATEGORY "SmileyAdd/RegisterCategory" -//Register smiley category -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) Pointer to protocol name or NULL for all; +///////////////////////////////////////////////////////////////////////////////////////// +// Reloads smiley category +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) Pointer to protocol name or NULL for all; + #define MS_SMILEYADD_RELOAD "SmileyAdd/Reload" /** @@ -182,19 +181,16 @@ struct SMADD_REGCAT #define FVCA_NONE 0 #define FVCA_DRAW 1 // do not modify hdc in case of _DRAW, Use _CUSTOMDRAW #define FVCA_CUSTOMDRAW 2 -//#define FVCA_INVALIDATE 3 (not supported) -//#define FVCA_SENDVIEWCHANGE 4 (not supported) -#define FVCA_SKIPDRAW 5 +#define FVCA_SKIPDRAW 5 // Extended NMHDR structure for WM_NOTIFY struct FVCNDATA_NMHDR { //NMHDR structure - HWND hwndFrom; // Window of smiley host - UINT_PTR idFrom; // ignored - UINT code; // NM_FIREVIEWCHANGE + HWND hwndFrom; // Window of smiley host + UINT_PTR idFrom; // ignored + UINT code; // NM_FIREVIEWCHANGE - size_t cbSize; BYTE bEvent; // FVCN_ value - pre- or post- painting BYTE bAction; // FVCA_ keys HDC hDC; // Canvas to draw on @@ -207,6 +203,11 @@ struct FVCNDATA_NMHDR // Code of WM_NOTIFY message (code) #define NM_FIREVIEWCHANGE NM_FIRST+1; +///////////////////////////////////////////////////////////////////////////////////////// +// Loads all smileys for the contact +// wParam = (WPARAM) 0; not used +// lParam = (LPARAM) (SMADD_CONT*) &dir; // pointer to directory to load smiley from + struct SMADD_CONT { int type; // 0 - directory, 1 - file; @@ -214,7 +215,4 @@ struct SMADD_CONT const wchar_t *path; // smiley category name for reference }; -//Loads all smileys for the contact -//wParam = (WPARAM) 0; not used -//lParam = (LPARAM) (SMADD_CONT*) &dir; // pointer to directory to load smiley from #define MS_SMILEYADD_LOADCONTACTSMILEYS "SmileyAdd/LoadContactSmileys" diff --git a/plugins/HistoryPlusPlus/hpp_itemprocess.pas b/plugins/HistoryPlusPlus/hpp_itemprocess.pas index d3afe770b1..f1aeb35bcc 100644 --- a/plugins/HistoryPlusPlus/hpp_itemprocess.pas +++ b/plugins/HistoryPlusPlus/hpp_itemprocess.pas @@ -442,7 +442,6 @@ var ird: PItemRenderDetails; begin ird := Pointer(alParam); - sare.cbSize := SizeOf(sare); sare.hwndRichEditControl := awParam; sare.rangeToReplace := nil; sare.ProtocolName := ird^.pProto; diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index a1bb18be63..c1aef39cd1 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -289,11 +289,10 @@ TextToken *TextToken::tokenizeSmileys(MCONTACT hContact, const wchar_t *text, bo if (!Options::bHasSmileyAdd) return new TextToken(TEXT, text, l); - SMADD_BATCHPARSE2 sp; - sp.cbSize = sizeof(sp); + SMADD_BATCHPARSE sp; sp.Protocolname = Proto_GetBaseAccountName(hContact); sp.flag = SAFL_PATH | SAFL_UNICODE | (isSent ? SAFL_OUTGOING : 0); - sp.wstr = (wchar_t *)text; + sp.str.w = text; sp.hContact = hContact; SMADD_BATCHPARSERES *spRes = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index d747909527..e61802a471 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -630,8 +630,7 @@ public: } if (g_dat.smileyAddInstalled) { - SMADD_RICHEDIT3 smre; - smre.cbSize = sizeof(SMADD_RICHEDIT3); + SMADD_RICHEDIT smre; smre.hwndRichEditControl = m_rtf.GetHwnd(); MCONTACT hContact = db_mc_getSrmmSub(m_pDlg.m_hContact); @@ -714,7 +713,7 @@ public: if (newsel.cpMin < 0) newsel.cpMin = 0; - SMADD_RICHEDIT3 sm = { sizeof(sm) }; + SMADD_RICHEDIT sm = {}; sm.hwndRichEditControl = m_rtf.GetHwnd(); sm.Protocolname = si->pszModule; sm.rangeToReplace = bRedraw ? nullptr : &newsel; diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp index d18fd3ba15..56540023f8 100644 --- a/plugins/SmileyAdd/src/AniSmileyObject.cpp +++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp @@ -189,7 +189,6 @@ public: nmh.code = NM_FIREVIEWCHANGE; nmh.hwndFrom = m_hwnd; - nmh.cbSize = sizeof(nmh); nmh.bEvent = FVCN_PREFIRE; nmh.bAction = FVCA_DRAW; nmh.rcRect = m_orect; diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index eb9210e2eb..4a89feff26 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -85,12 +85,12 @@ SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact, SmileyPackC INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) { - SMADD_RICHEDIT3 *smre = (SMADD_RICHEDIT3*)lParam; + SMADD_RICHEDIT *smre = (SMADD_RICHEDIT*)lParam; if (smre == nullptr) return FALSE; - SMADD_RICHEDIT3 smrec = {}; - memcpy(&smrec, smre, min(smre->cbSize, sizeof(smrec))); + SMADD_RICHEDIT smrec = {}; + memcpy(&smrec, smre, sizeof(smrec)); static const CHARRANGE selection = { 0, LONG_MAX }; if (smre->rangeToReplace == nullptr) @@ -109,7 +109,7 @@ INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -static int GetInfoCommandE(SMADD_INFO2 *smre, bool retDup) +static int GetInfoCommandE(SMADD_INFO *smre, bool retDup) { if (smre == nullptr) return FALSE; @@ -137,19 +137,19 @@ static int GetInfoCommandE(SMADD_INFO2 *smre, bool retDup) INT_PTR GetInfoCommand(WPARAM, LPARAM lParam) { - return GetInfoCommandE((SMADD_INFO2*)lParam, false); + return GetInfoCommandE((SMADD_INFO*)lParam, false); } INT_PTR GetInfoCommand2(WPARAM, LPARAM lParam) { - return GetInfoCommandE((SMADD_INFO2*)lParam, true); + return GetInfoCommandE((SMADD_INFO*)lParam, true); } ///////////////////////////////////////////////////////////////////////////////////////// INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) { - SMADD_BATCHPARSE2 *smre = (SMADD_BATCHPARSE2*)lParam; + SMADD_BATCHPARSE *smre = (SMADD_BATCHPARSE*)lParam; if (smre == nullptr) return FALSE; @@ -158,9 +158,9 @@ INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) SmileyPackType *SmileyPack = FindSmileyPack(smre->Protocolname, smre->hContact, (smre->flag & (SAFL_OUTGOING | SAFL_NOCUSTOM)) ? nullptr : &smcp); if (smre->flag & SAFL_UNICODE) - LookupAllSmileys(SmileyPack, smcp, smre->wstr, smllist, false); + LookupAllSmileys(SmileyPack, smcp, smre->str.w, smllist, false); else - LookupAllSmileys(SmileyPack, smcp, _A2T(smre->astr), smllist, false); + LookupAllSmileys(SmileyPack, smcp, _A2T(smre->str.a), smllist, false); if (smllist.getCount() == 0) return 0; @@ -206,7 +206,7 @@ INT_PTR FreeTextBatch(WPARAM, LPARAM lParam) INT_PTR RegisterPack(WPARAM, LPARAM lParam) { SMADD_REGCAT *smre = (SMADD_REGCAT*)lParam; - if (smre == nullptr || smre->cbSize < sizeof(SMADD_REGCAT)) + if (smre == nullptr) return FALSE; if (IsBadStringPtrA(smre->name, 50) || IsBadStringPtrA(smre->dispname, 50)) diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index 5cf4751391..ee62c0b288 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -1350,7 +1350,7 @@ void CTip::show(const RECT& rc, POINT& pt, const HICON hIcon, const wchar_t *szT CContactCache *c = CContactCache::getContactCache(m_hContact); ::SendMessage(m_hRich, EM_SETBKGNDCOLOR, 0, (LPARAM)PluginConfig.m_ipBackgroundGradientHigh); - SMADD_RICHEDIT3 smadd = { sizeof(smadd) }; + SMADD_RICHEDIT smadd = {}; smadd.hwndRichEditControl = m_hRich; smadd.Protocolname = const_cast(c->getActiveProto()); smadd.hContact = c->getActiveContact(); diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 7816293863..ce2a2d32e6 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -931,11 +931,10 @@ ok: if (PluginConfig.g_SmileyAddAvail && (endmark > (beginmark + 1))) { CMStringW smcode = msg.Mid(beginmark, (endmark - beginmark) + 1); - SMADD_BATCHPARSE2 smbp = {}; - smbp.cbSize = sizeof(smbp); + SMADD_BATCHPARSE smbp = {}; smbp.Protocolname = m_cache->getActiveProto(); - smbp.flag = SAFL_TCHAR | SAFL_PATH | (isSent ? SAFL_OUTGOING : 0); - smbp.str = (wchar_t*)smcode.c_str(); + smbp.flag = SAFL_UNICODE | SAFL_PATH | (isSent ? SAFL_OUTGOING : 0); + smbp.str.w = smcode.c_str(); smbp.hContact = m_hContact; SMADD_BATCHPARSERES *smbpr = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smbp); diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index ffbb75e694..352063b2dd 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -1326,7 +1326,7 @@ void CLogWindow::LogChatEvents(const LOGINFO *lin) if (newsel.cpMin < 0) newsel.cpMin = 0; - SMADD_RICHEDIT3 sm = { sizeof(sm) }; + SMADD_RICHEDIT sm = {}; sm.hwndRichEditControl = m_rtf.GetHwnd(); sm.Protocolname = si->pszModule; sm.rangeToReplace = bRedraw ? nullptr : &newsel; @@ -1467,7 +1467,7 @@ void CLogWindow::ReplaceIcons(LONG startAt, int fAppend, BOOL isSent) sel.cpMin = startAt; sel.cpMax = -1; - SMADD_RICHEDIT3 smadd = { sizeof(smadd) }; + SMADD_RICHEDIT smadd = {}; smadd.hwndRichEditControl = m_rtf.GetHwnd(); smadd.Protocolname = const_cast(m_pDlg.m_cache->getActiveProto()); smadd.hContact = m_pDlg.m_cache->getActiveContact(); diff --git a/plugins/TipperYM/src/mir_smileys.cpp b/plugins/TipperYM/src/mir_smileys.cpp index 1d7544eeda..72c6369148 100644 --- a/plugins/TipperYM/src/mir_smileys.cpp +++ b/plugins/TipperYM/src/mir_smileys.cpp @@ -27,7 +27,6 @@ int InitTipperSmileys() // Register smiley category if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) { SMADD_REGCAT rc; - rc.cbSize = sizeof(rc); rc.name = "tipper"; rc.dispname = Translate("Tipper smileys"); CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc); @@ -322,13 +321,12 @@ SortedList *ReplaceSmileys(const wchar_t *text, int text_size, const char *proto strncpy(smileyProto, protocol, sizeof(smileyProto) - 1); // Parse it! - SMADD_BATCHPARSE2 sp = { 0 }; - sp.cbSize = sizeof(sp); - sp.str = (wchar_t *)text; - sp.flag = SAFL_TCHAR; + SMADD_BATCHPARSE sp = {}; + sp.str.w = text; + sp.flag = SAFL_UNICODE; sp.Protocolname = (opt.iSmileyAddFlags & SMILEYADD_USEPROTO) ? smileyProto : "tipper"; - SMADD_BATCHPARSERES *spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); + SMADD_BATCHPARSERES *spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); if (!spres) // Did not find a smiley return nullptr; diff --git a/plugins/TranslitSwitcher/src/Layoutproc.cpp b/plugins/TranslitSwitcher/src/Layoutproc.cpp index 5ac0ba1115..33183d9615 100644 --- a/plugins/TranslitSwitcher/src/Layoutproc.cpp +++ b/plugins/TranslitSwitcher/src/Layoutproc.cpp @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. #include "stdafx.h" -SMADD_BATCHPARSE2 smgp; +SMADD_BATCHPARSE smgp; SMADD_BATCHPARSERES *smileyPrs = nullptr; bool isItSmiley(unsigned int position) @@ -399,9 +399,8 @@ void SwitchLayout(bool lastword) if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) { memset(&smgp, 0, sizeof(smgp)); - smgp.cbSize = sizeof(smgp); - smgp.str = buf; - smgp.flag = SAFL_TCHAR; + smgp.str.w = buf; + smgp.flag = SAFL_UNICODE; smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); } @@ -449,9 +448,8 @@ void SwitchLayout(bool lastword) if (slen != 0) { if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) { memset(&smgp, 0, sizeof(smgp)); - smgp.cbSize = sizeof(smgp); - smgp.str = sel; - smgp.flag = SAFL_TCHAR; + smgp.str.w = sel; + smgp.flag = SAFL_UNICODE; smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); } @@ -672,9 +670,8 @@ int OnButtonPressed(WPARAM, LPARAM lParam) HKL hkl = GetKeyboardLayout(dwThreadID); memset(&smgp, 0, sizeof(smgp)); - smgp.cbSize = sizeof(smgp); - smgp.str = sel; - smgp.flag = SAFL_TCHAR; + smgp.str.w = sel; + smgp.flag = SAFL_UNICODE; if (ServiceExists(MS_SMILEYADD_BATCHPARSE)) smileyPrs = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smgp); diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index c0a83c5259..55cac4d02f 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -461,8 +461,7 @@ public: } if (g_plugin.bSmileyInstalled) { - SMADD_RICHEDIT3 smre; - smre.cbSize = sizeof(SMADD_RICHEDIT3); + SMADD_RICHEDIT smre; smre.hwndRichEditControl = m_rtf.GetHwnd(); MCONTACT hContact = db_mc_getSrmmSub(m_pDlg.m_hContact); @@ -546,8 +545,7 @@ public: if (newsel.cpMin < 0) newsel.cpMin = 0; - SMADD_RICHEDIT3 sm = {}; - sm.cbSize = sizeof(sm); + SMADD_RICHEDIT sm = {}; sm.hwndRichEditControl = m_rtf.GetHwnd(); sm.Protocolname = si->pszModule; sm.rangeToReplace = bRedraw ? nullptr : &newsel; diff --git a/utils/mir_smileys.cpp b/utils/mir_smileys.cpp index a723cdffcf..a27f16cba8 100644 --- a/utils/mir_smileys.cpp +++ b/utils/mir_smileys.cpp @@ -64,17 +64,10 @@ SIZE GetTextSize(HDC hdcMem, const wchar_t *szText, SortedList *plText, UINT uTe int InitContactListSmileys() { // Register smiley category - if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) - { - SMADD_REGCAT rc; - - rc.cbSize = sizeof(rc); - rc.name = "clist"; - rc.dispname = TranslateA_LP("Contact List smileys"); - - CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc); - } - + SMADD_REGCAT rc; + rc.name = "clist"; + rc.dispname = TranslateA_LP("Contact List smileys"); + CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc); return 0; } @@ -397,10 +390,10 @@ SortedList * ReplaceSmileys(const wchar_t *text, int text_size, const char *prot return nullptr; // Parse it! - SMADD_BATCHPARSE2 sp = { sizeof(sp) }; + SMADD_BATCHPARSE sp = {}; sp.Protocolname = protocol; - sp.str = (wchar_t*)text; - sp.flag = SAFL_TCHAR; + sp.str.w = text; + sp.flag = SAFL_UNICODE; SMADD_BATCHPARSERES *spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); if (spres == nullptr) // Did not find a simley -- cgit v1.2.3