diff options
-rw-r--r-- | plugins/Clist_modern/src/modern_cachefuncs.cpp | 5 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_smileyadd.h | 195 | ||||
-rw-r--r-- | plugins/IEView/src/TextToken.cpp | 1 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 2 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/AniSmileyObject.cpp | 2 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/dlgboxsubclass.cpp | 4 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/download.cpp | 2 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/imagecache.cpp | 2 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/main.cpp | 1 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/richcall.cpp | 4 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/services.cpp | 82 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/services.h | 4 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/smileys.h | 2 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/smltool.cpp | 4 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/version.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 3 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.cpp | 7 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 47 |
18 files changed, 182 insertions, 187 deletions
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 3c0f0fb9e3..bed00e3ffa 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -170,7 +170,7 @@ void CSmileyString::DestroySmileyList() ///////////////////////////////////////////////////////////////////////////////////////// // Parsing of text for smiley // -void CSmileyString::ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, wchar_t * szText, BOOL replace_smileys) +void CSmileyString::ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, wchar_t *szText, BOOL replace_smileys) { int last_pos = 0; iMaxSmileyHeight = 0; @@ -183,8 +183,9 @@ 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 = { 0 }; + SMADD_BATCHPARSE2 sp = {}; sp.cbSize = sizeof(sp); + sp.hContact = pdnce->hContact; if (dat->text_use_protocol_smileys) { sp.Protocolname = pdnce->szProto; diff --git a/plugins/ExternalAPI/m_smileyadd.h b/plugins/ExternalAPI/m_smileyadd.h index 80381a96e3..90ca190561 100644 --- a/plugins/ExternalAPI/m_smileyadd.h +++ b/plugins/ExternalAPI/m_smileyadd.h @@ -27,21 +27,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define SAFLRE_NOCUSTOM 8 // Do not use custom smileys
#define SAFLRE_FIREVIEW 16 // use NM_FIREVIEWCHANGE messages
-typedef struct
+struct SMADD_RICHEDIT3
{
- 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
-} SMADD_RICHEDIT3;
+ 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
+};
//Replace smileys in a rich edit control...
//wParam = (WPARAM) 0; not used
@@ -49,45 +49,17 @@ typedef struct //return: TRUE if API succeeded (all parameters were valid) , FALSE if not.
#define MS_SMILEYADD_REPLACESMILEYS "SmileyAdd/ReplaceSmileys"
-
-typedef struct
+struct SMADD_INFO2
{
- unsigned cbSize; //size of the structure
- char* Protocolname; //protocol to use... if you have defined a protocol, you can
- //use your own protocol name. Smiley add 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
- int xPosition; //Postition to place the selectwindow
- int yPosition; // "
- int Direction; //Direction (i.e. size upwards/downwards/etc) of the window 0, 1, 2, 3
-
- HWND hwndTarget; //Window, where to send the message when smiley is selected.
- UINT targetMessage; //Target message, to be sent.
- LPARAM targetWParam; //Target WParam to be sent (LParam will be char* to select smiley)
- //see the example file.
- HWND hwndParent; //Parent window for smiley dialog
-} SMADD_SHOWSEL3;
-
-//Show smiley selection window
-//wParam = (WPARAM) 0; not used
-//lParam = (LPARAM) (SMADD_SHOWSEL3*) &smre; //pointer to SMADD_SHOWSEL3
-//return: TRUE if API succeeded (all parameters were valid) , FALSE if not.
-#define MS_SMILEYADD_SHOWSELECTION "SmileyAdd/ShowSmileySelection"
-
-
-typedef struct
-{
- 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
-} SMADD_INFO2;
+ 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
+};
//get button smiley icon
//wParam = (WPARAM) 0; not used
@@ -112,43 +84,44 @@ typedef struct #define SAFL_TCHAR 0
#endif
-typedef struct
+struct SMADD_BATCHPARSE2
{
- 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
-} SMADD_BATCHPARSE2;
-
-typedef struct
+ 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
+};
+
+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
- };
-} 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
+ };
+};
//find all smileys in text, API parses the provided text and returns all smileys found
//wParam = (WPARAM) 0; not used
@@ -163,12 +136,12 @@ typedef struct //lParam = (LPARAM) (SMADD_BATCHPARSERES*) &smgp; //pointer to SMADD_BATCHPARSERES
#define MS_SMILEYADD_BATCHFREE "SmileyAdd/BatchFree"
-typedef struct
+struct SMADD_REGCAT
{
- unsigned cbSize; //size of the structure
- char* name; //smiley category name for reference
- char* dispname; //smiley category name for display
-} SMADD_REGCAT;
+ unsigned cbSize; //size of the structure
+ char *name; //smiley category name for reference
+ char *dispname; //smiley category name for display
+};
//Register smiley category
//wParam = (WPARAM) 0; not used
@@ -214,32 +187,32 @@ typedef struct #define FVCA_SKIPDRAW 5
// Extended NMHDR structure for WM_NOTIFY
-typedef struct
-{
- //NMHDR structure
- 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
- RECT rcRect; // Valid/should be in case of FVCA_DRAW
- COLORREF clrBackground; // color to fill background if fTransparent is not set
- BOOL fTransparent; // if need to fill back color (not supported)
- LPARAM lParam; // used by host window PreFire and PostFire event
-} FVCNDATA_NMHDR;
+struct FVCNDATA_NMHDR
+{
+ //NMHDR structure
+ 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
+ RECT rcRect; // Valid/should be in case of FVCA_DRAW
+ COLORREF clrBackground; // color to fill background if fTransparent is not set
+ BOOL fTransparent; // if need to fill back color (not supported)
+ LPARAM lParam; // used by host window PreFire and PostFire event
+};
// Code of WM_NOTIFY message (code)
#define NM_FIREVIEWCHANGE NM_FIRST+1;
-typedef struct
+struct SMADD_CONT
{
int type; // 0 - directory, 1 - file;
- const char *pszModule; // module name
+ const char *pszModule; // module name
const wchar_t *path; // smiley category name for reference
-} SMADD_CONT;
+};
//Loads all smileys for the contact
//wParam = (WPARAM) 0; not used
diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index 73a38878cf..76927e80a8 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -294,6 +294,7 @@ TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const wchar_t *text, bo sp.Protocolname = Proto_GetBaseAccountName(hContact);
sp.flag = SAFL_PATH | SAFL_UNICODE | (isSent ? SAFL_OUTGOING : 0);
sp.wstr = (wchar_t *)text;
+ sp.hContact = hContact;
SMADD_BATCHPARSERES *spRes = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
int last_pos = 0;
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index e62066b396..13b4b28b8b 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -463,7 +463,7 @@ int RegisterToolbarIcons(WPARAM, LPARAM) static int ModuleLoad(WPARAM, LPARAM)
{
- g_dat.smileyAddInstalled = ServiceExists(MS_SMILEYADD_SHOWSELECTION) && ServiceExists(MS_SMILEYADD_REPLACESMILEYS);
+ g_dat.smileyAddInstalled = ServiceExists(MS_SMILEYADD_REPLACESMILEYS);
return 0;
}
diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp index b5043d51c1..d18fd3ba15 100644 --- a/plugins/SmileyAdd/src/AniSmileyObject.cpp +++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp @@ -86,7 +86,7 @@ public: if (m_hwnd == nullptr)
return;
- REOBJECT reObj = { 0 };
+ REOBJECT reObj = {};
reObj.cbStruct = sizeof(reObj);
{
CComPtr<IRichEditOle> RichEditOle;
diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp index 1f11c44b48..315ea88f36 100644 --- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp +++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp @@ -33,7 +33,7 @@ struct MsgWndData : public MZeroedObject void CreateSmileyButton(void)
{
- SmileyPackType *SmileyPack = GetSmileyPack(ProtocolName);
+ SmileyPackType *SmileyPack = FindSmileyPack(ProtocolName);
bool doSmileyButton = SmileyPack != nullptr && SmileyPack->VisibleSmileyCount() != 0;
doSmileyReplace = true;
@@ -135,7 +135,7 @@ int SmileyButtonPressed(WPARAM, LPARAM lParam) return 0;
SmileyToolWindowParam *stwp = new SmileyToolWindowParam;
- stwp->pSmileyPack = GetSmileyPack(dat->ProtocolName);
+ stwp->pSmileyPack = FindSmileyPack(dat->ProtocolName, dat->hContact);
stwp->hWndParent = pcbc->hwndFrom;
stwp->hWndTarget = dat->hwndInput;
stwp->targetMessage = EM_REPLACESEL;
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp index a200d51e1f..5b51b9970b 100644 --- a/plugins/SmileyAdd/src/download.cpp +++ b/plugins/SmileyAdd/src/download.cpp @@ -43,7 +43,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HNETLIBCONN &hHttpDwn {
int result = 0xBADBAD;
char *szRedirUrl = nullptr;
- NETLIBHTTPREQUEST nlhr = { 0 };
+ NETLIBHTTPREQUEST nlhr = {};
// initialize the netlib request
nlhr.cbSize = sizeof(nlhr);
diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp index 5959f2c1a3..3aea12abc6 100644 --- a/plugins/SmileyAdd/src/imagecache.cpp +++ b/plugins/SmileyAdd/src/imagecache.cpp @@ -454,7 +454,7 @@ void ImageFType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY) GetObject(m_bmp, sizeof(bm), &bm);
if (bm.bmBitsPixel == 32) {
- BLENDFUNCTION bf = { 0 };
+ BLENDFUNCTION bf = {};
bf.SourceConstantAlpha = 255;
bf.AlphaFormat = AC_SRC_ALPHA;
GdiAlphaBlend(hdc, x, y, sizeX, sizeY, hdcImg, 0, 0, bm.bmWidth, bm.bmHeight, bf);
diff --git a/plugins/SmileyAdd/src/main.cpp b/plugins/SmileyAdd/src/main.cpp index 632dcd3b44..dd043cdf27 100644 --- a/plugins/SmileyAdd/src/main.cpp +++ b/plugins/SmileyAdd/src/main.cpp @@ -115,7 +115,6 @@ int CMPlugin::Load() // create the smiley services
CreateServiceFunction(MS_SMILEYADD_REPLACESMILEYS, ReplaceSmileysCommand);
- CreateServiceFunction(MS_SMILEYADD_SHOWSELECTION, ShowSmileySelectionCommand);
CreateServiceFunction(MS_SMILEYADD_GETINFO2, GetInfoCommand2);
CreateServiceFunction(MS_SMILEYADD_REGISTERCATEGORY, RegisterPack);
CreateServiceFunction(MS_SMILEYADD_BATCHPARSE, ParseTextBatch);
diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp index 1d9fc73d2f..ed0c886ae1 100644 --- a/plugins/SmileyAdd/src/richcall.cpp +++ b/plugins/SmileyAdd/src/richcall.cpp @@ -56,7 +56,7 @@ static void SetPosition(HWND hwnd) int objectCount = RichEditOle->GetObjectCount();
for (int i = objectCount - 1; i >= 0; i--) {
- REOBJECT reObj = { 0 };
+ REOBJECT reObj = {};
reObj.cbStruct = sizeof(REOBJECT);
HRESULT hr = RichEditOle->GetObject(i, &reObj, REO_GETOBJ_POLEOBJ);
@@ -132,7 +132,7 @@ static void ReplaceContactSmileys(RichEditData *rdt, const CHARRANGE &sel, bool {
if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace) return;
SmileyPackCType *smcp = nullptr;
- SmileyPackType *SmileyPack = GetSmileyPack(Proto_GetBaseAccountName(rdt->hContact), rdt->inputarea ? nullptr : &smcp);
+ SmileyPackType *SmileyPack = FindSmileyPack(Proto_GetBaseAccountName(rdt->hContact), rdt->hContact, rdt->inputarea ? nullptr : &smcp);
ReplaceSmileys(rdt->hwnd, SmileyPack, smcp, sel, false, ignoreLast, unFreeze);
}
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index aca7e2a8c5..e238b75ba5 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -24,7 +24,7 @@ LIST<void> menuHandleArray(5); //implementation of service functions
-SmileyPackType* GetSmileyPack(const char *proto, SmileyPackCType **smlc)
+SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact, SmileyPackCType **smlc)
{
if (smlc)
*smlc = g_SmileyPackCStore.GetSmileyPack(proto);
@@ -33,28 +33,59 @@ SmileyPackType* GetSmileyPack(const char *proto, SmileyPackCType **smlc) return nullptr;
CMStringW categoryName;
- if (proto == nullptr || proto[0] == 0)
- categoryName = L"Standard";
- else {
- categoryName = _A2T(proto);
- if (opt.UseOneForAll) {
- SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName);
- if (smc == nullptr || smc->IsProto())
- categoryName = L"Standard";
+ if (hContact != 0) {
+ opt.ReadContactCategory(hContact, categoryName);
+ if (categoryName == L"<None>") return nullptr;
+ if (!categoryName.IsEmpty() && g_SmileyCategories.GetSmileyCategory(categoryName) == nullptr) {
+ categoryName.Empty();
+ opt.WriteContactCategory(hContact, categoryName);
+ }
+
+ if (categoryName.IsEmpty() && !opt.UseOneForAll) {
+ char *protonam = Proto_GetBaseAccountName(hContact);
+ if (protonam != nullptr) {
+ DBVARIANT dbv;
+ if (db_get_ws(hContact, protonam, "Transport", &dbv) == 0) {
+ categoryName = dbv.pwszVal;
+ db_free(&dbv);
+ }
+ else if (opt.UsePhysProto && db_get_ws(0, protonam, "AM_BaseProto", &dbv) == 0) {
+ categoryName = L"AllProto";
+ categoryName += dbv.pwszVal;
+ db_free(&dbv);
+ CMStringW categoryFileName = g_SmileyCategories.GetSmileyCategory(categoryName) ? g_SmileyCategories.GetSmileyCategory(categoryName)->GetFilename() : L"";
+ if (categoryFileName.IsEmpty())
+ categoryName = _A2T(protonam);
+ }
+ else
+ categoryName = _A2T(protonam);
+ }
+ }
+ }
+
+ if (categoryName.IsEmpty()) {
+ if (proto == nullptr || proto[0] == 0)
+ categoryName = L"Standard";
+ else {
+ categoryName = _A2T(proto);
+ if (opt.UseOneForAll) {
+ SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName);
+ if (smc == nullptr || smc->IsProto())
+ categoryName = L"Standard";
+ }
}
}
return g_SmileyCategories.GetSmileyPack(categoryName);
}
-
INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam)
{
SMADD_RICHEDIT3 *smre = (SMADD_RICHEDIT3*)lParam;
if (smre == nullptr)
return FALSE;
- SMADD_RICHEDIT3 smrec = { 0 };
+ SMADD_RICHEDIT3 smrec = {};
memcpy(&smrec, smre, min(smre->cbSize, sizeof(smrec)));
static const CHARRANGE selection = { 0, LONG_MAX };
@@ -62,7 +93,7 @@ INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) else if (smrec.rangeToReplace->cpMax < 0) smrec.rangeToReplace->cpMax = LONG_MAX;
SmileyPackCType *smcp = nullptr;
- SmileyPackType *SmileyPack = GetSmileyPack(smrec.Protocolname, (smrec.flags & SAFLRE_NOCUSTOM) ? nullptr : &smcp);
+ SmileyPackType *SmileyPack = FindSmileyPack(smrec.Protocolname, smrec.hContact, (smrec.flags & SAFLRE_NOCUSTOM) ? nullptr : &smcp);
ReplaceSmileys(smre->hwndRichEditControl, SmileyPack, smcp, *smrec.rangeToReplace,
smrec.hContact == 0, false, false, (smre->flags & SAFLRE_FIREVIEW) ? true : false);
@@ -70,34 +101,11 @@ INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) return TRUE;
}
-
-INT_PTR ShowSmileySelectionCommand(WPARAM, LPARAM lParam)
-{
- SMADD_SHOWSEL3 *smaddInfo = (SMADD_SHOWSEL3*)lParam;
-
- if (smaddInfo == nullptr) return FALSE;
- HWND parent = smaddInfo->hwndParent;
-
- SmileyToolWindowParam *stwp = new SmileyToolWindowParam;
- stwp->pSmileyPack = GetSmileyPack(smaddInfo->Protocolname);
- stwp->hWndParent = parent;
- stwp->hWndTarget = smaddInfo->hwndTarget;
- stwp->targetMessage = smaddInfo->targetMessage;
- stwp->targetWParam = smaddInfo->targetWParam;
- stwp->xPosition = smaddInfo->xPosition;
- stwp->yPosition = smaddInfo->yPosition;
- stwp->direction = smaddInfo->Direction;
- mir_forkThread<SmileyToolWindowParam>(SmileyToolThread, stwp);
-
- return TRUE;
-}
-
-
static int GetInfoCommandE(SMADD_INFO2 *smre, bool retDup)
{
if (smre == nullptr) return FALSE;
- SmileyPackType *SmileyPack = GetSmileyPack(smre->Protocolname);
+ SmileyPackType *SmileyPack = FindSmileyPack(smre->Protocolname);
if (SmileyPack == nullptr || SmileyPack->SmileyCount() == 0) {
smre->ButtonIcon = nullptr;
smre->NumberOfSmileys = 0;
@@ -138,7 +146,7 @@ INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) SmileyPackCType *smcp = nullptr;
SmileysQueueType smllist;
- SmileyPackType *SmileyPack = GetSmileyPack(smre->Protocolname, (smre->flag & (SAFL_OUTGOING | SAFL_NOCUSTOM)) ? nullptr : &smcp);
+ 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);
diff --git a/plugins/SmileyAdd/src/services.h b/plugins/SmileyAdd/src/services.h index 86b1b3742b..da37065f52 100644 --- a/plugins/SmileyAdd/src/services.h +++ b/plugins/SmileyAdd/src/services.h @@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // service commands
INT_PTR ReplaceSmileysCommand(WPARAM wParam, LPARAM lParam);
-INT_PTR ShowSmileySelectionCommand(WPARAM wParam, LPARAM lParam);
INT_PTR GetInfoCommand(WPARAM wParam, LPARAM);
INT_PTR GetInfoCommand2(WPARAM wParam, LPARAM);
INT_PTR RegisterPack(WPARAM wParam, LPARAM lParam);
@@ -38,8 +37,7 @@ int AccountListChanged(WPARAM wParam, LPARAM lParam); int DbSettingChanged(WPARAM wParam, LPARAM lParam);
int ReloadColour(WPARAM, LPARAM);
-SmileyPackType* GetSmileyPack(const char* proto, SmileyPackCType** smlc = nullptr);
-
+SmileyPackType* FindSmileyPack(const char *proto, MCONTACT hContact = 0, SmileyPackCType **smlc = nullptr);
#endif // SMILEYADD_SERVICES_H_
diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h index 8071e12770..ad73daa727 100644 --- a/plugins/SmileyAdd/src/smileys.h +++ b/plugins/SmileyAdd/src/smileys.h @@ -212,7 +212,7 @@ public: bool AddSmileyPack(CMStringW &filename, CMStringW &packname);
void ClearAndFreeAll(void);
- SmileyPackType* GetSmileyPack(CMStringW& filename);
+ SmileyPackType* GetSmileyPack(CMStringW &filename);
};
diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp index 901cb07210..7a1fe4c3e8 100644 --- a/plugins/SmileyAdd/src/smltool.cpp +++ b/plugins/SmileyAdd/src/smltool.cpp @@ -296,7 +296,7 @@ void SmileyToolWindowType::MouseMove(int xposition, int yposition) if (but<0)
SendMessage(m_hToolTip, TTM_ACTIVATE, FALSE, 0);
else if (m_CurrMouseTrack != but) {
- TOOLINFO ti = { 0 };
+ TOOLINFO ti = {};
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
ti.hwnd = m_hwndDialog;
@@ -503,7 +503,7 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam) //add tooltips
m_hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"", TTS_NOPREFIX | WS_POPUP, 0, 0, 0, 0, m_hwndDialog, nullptr, g_plugin.getInst(), nullptr);
- TOOLINFO ti = { 0 };
+ TOOLINFO ti = {};
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
ti.hwnd = m_hwndDialog;
diff --git a/plugins/SmileyAdd/src/version.h b/plugins/SmileyAdd/src/version.h index fd79d40249..38e63ce7e5 100644 --- a/plugins/SmileyAdd/src/version.h +++ b/plugins/SmileyAdd/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 3
#define __RELEASE_NUM 2
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 10e8087c25..e1e80bfab6 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -186,11 +186,12 @@ ok: if (PluginConfig.g_SmileyAddAvail && (endmark > (beginmark + 1))) {
CMStringW smcode = msg.Mid(beginmark, (endmark - beginmark) + 1);
- SMADD_BATCHPARSE2 smbp = { 0 };
+ SMADD_BATCHPARSE2 smbp = {};
smbp.cbSize = sizeof(smbp);
smbp.Protocolname = m_cache->getActiveProto();
smbp.flag = SAFL_TCHAR | SAFL_PATH | (isSent ? SAFL_OUTGOING : 0);
smbp.str = (wchar_t*)smcode.c_str();
+ smbp.hContact = m_hContact;
SMADD_BATCHPARSERES *smbpr = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smbp);
if (smbpr) {
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp index d2011579de..1cf3d3156c 100644 --- a/protocols/Facebook/src/proto.cpp +++ b/protocols/Facebook/src/proto.cpp @@ -133,10 +133,15 @@ FacebookProto::~FacebookProto() void FacebookProto::OnModulesLoaded() { - CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName); + VARSW wszCache(L"%miranda_avatarcache%"); + + CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", wszCache.get(), m_szModuleName); SMADD_CONT cont = { 2, m_szModuleName, wszPath }; CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont)); + wszPath.Format(L"%s\\%S\\Stickers\\*.webp", wszCache.get(), m_szModuleName); + cont.path = wszPath; + CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont)); } void FacebookProto::OnShutdown() diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 67e0ba323e..036c8f2db4 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -96,8 +96,8 @@ FacebookUser* FacebookProto::AddContact(const CMStringW &wszId, bool bTemp) Contact_RemoveFromList(hContact); auto* ret = new FacebookUser(_wtoi64(wszId), hContact); - m_users.insert(ret); + return ret; } @@ -527,7 +527,7 @@ void FacebookProto::OnPublishPresence(FbThriftReader &rdr) rdr.readField(fieldType, fieldId); assert(fieldType == FB_THRIFT_TYPE_I64); - assert(fieldId == 1 || fieldId == 4); + assert(fieldId == 1 || fieldId == 3 || fieldId == 4); rdr.readInt64(timestamp); while (!rdr.isStop()) { @@ -710,7 +710,14 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) bool bSuccess = false; CMStringW wszFileName(FORMAT, L"%s\\STK{%S}.png", wszPath.c_str(), stickerId.c_str()); - if (GetFileAttributesW(wszFileName) == INVALID_FILE_ATTRIBUTES) { + DWORD dwAttrib = GetFileAttributesW(wszFileName); + if (dwAttrib == INVALID_FILE_ATTRIBUTES) { + wszFileName.Format(L"%s\\STK{%S}.webp", wszPath.c_str(), stickerId.c_str()); + dwAttrib = GetFileAttributesW(wszFileName); + } + + // new sticker + if (dwAttrib == INVALID_FILE_ATTRIBUTES) { auto *pReq = CreateRequestGQL(FB_API_QUERY_STICKER); pReq << CHAR_PARAM("query_params", CMStringA(FORMAT, "{\"0\":[\"%s\"]}", stickerId.c_str())); pReq->CalcSig(); @@ -718,22 +725,24 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) JsonReply reply(ExecuteRequest(pReq)); if (!reply.error()) { for (auto &sticker : reply.data()) { - for (auto &img : sticker["thread_image"]) { - CMStringA szUrl(img.as_mstring()); - - NETLIBHTTPREQUEST req = {}; - req.cbSize = sizeof(req); - req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT; - req.requestType = REQUEST_GET; - req.szUrl = szUrl.GetBuffer(); - - NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req); - if (pReply != nullptr && pReply->resultCode == 200 && pReply->pData && pReply->dataLength) { - bSuccess = true; - FILE *out = _wfopen(wszFileName, L"wb"); - fwrite(pReply->pData, 1, pReply->dataLength, out); - fclose(out); - } + std::string szUrl = sticker["animated_image"]["uri"].as_string(); + if (szUrl.empty()) + szUrl = sticker["thread_image"]["uri"].as_string(); + else + wszFileName.Format(L"%s\\STK{%S}.webp", wszPath.c_str(), stickerId.c_str()); + + NETLIBHTTPREQUEST req = {}; + req.cbSize = sizeof(req); + req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT; + req.requestType = REQUEST_GET; + req.szUrl = (char*)szUrl.c_str(); + + NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req); + if (pReply != nullptr && pReply->resultCode == 200 && pReply->pData && pReply->dataLength) { + bSuccess = true; + FILE *out = _wfopen(wszFileName, L"wb"); + fwrite(pReply->pData, 1, pReply->dataLength, out); + fclose(out); } } } |