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 --- plugins/ExternalAPI/delphi/m_smileyadd.inc | 6 - plugins/ExternalAPI/m_smileyadd.h | 210 ++++++++++++++--------------- 2 files changed, 104 insertions(+), 112 deletions(-) (limited to 'plugins/ExternalAPI') 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" -- cgit v1.2.3