From 1b17214fcaa3e3fa2d60969f0ea314ba4f1f26c6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 28 Jul 2020 18:24:25 +0300 Subject: Jabber: new option to embrace picture urls/filenames with BBCodes --- protocols/JabberG/src/jabber_ft.cpp | 19 +++++++++++++------ protocols/JabberG/src/jabber_opt.cpp | 1 + protocols/JabberG/src/jabber_opttree.cpp | 9 +++------ protocols/JabberG/src/jabber_proto.cpp | 1 + protocols/JabberG/src/jabber_proto.h | 1 + 5 files changed, 19 insertions(+), 12 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 9f7b49985b..4ce9ee23ac 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -708,16 +708,23 @@ LBL_Fail: Netlib_FreeHttpRequest(res); // this parameter is optional, if not specified we simply use upload URL - auto *szGetUrl = XmlGetAttr(XmlFirstChild(slotNode, "get"), "url"); - if (szGetUrl == nullptr) - szGetUrl = szUrl; + CMStringA szMessage; + if (auto *szGetUrl = XmlGetAttr(XmlFirstChild(slotNode, "get"), "url")) + szMessage = szGetUrl; + else + szMessage = szUrl; + + if (m_bEmbraceUrls && ProtoGetAvatarFormat(_A2T(szMessage)) != PA_FORMAT_UNKNOWN) { + szMessage.Insert(0, "[img]"); + szMessage.Append("[/img]"); + } if (isChatRoom(ft->std.hContact)) - GroupchatSendMsg(ft->pItem, ptrA(mir_utf8encode(szGetUrl))); - else if (ProtoChainSend(ft->std.hContact, PSS_MESSAGE, 0, (LPARAM)szGetUrl) != -1) { + GroupchatSendMsg(ft->pItem, ptrA(mir_utf8encode(szMessage))); + else if (ProtoChainSend(ft->std.hContact, PSS_MESSAGE, 0, (LPARAM)szMessage.c_str()) != -1) { PROTORECVEVENT recv = {}; recv.flags = PREF_CREATEREAD | PREF_SENT; - recv.szMessage = (char *)szGetUrl; + recv.szMessage = szMessage.GetBuffer(); recv.timestamp = time(0); ProtoChainRecvMsg(ft->std.hContact, &recv); } diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 15cba2df5b..e4edbff37e 100755 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -797,6 +797,7 @@ public: m_otvOptions.AddOption(LPGENW("Other") L"/" LPGENW("Fix incorrect timestamps in incoming messages"), m_proto->m_bFixIncorrectTimestamps); m_otvOptions.AddOption(LPGENW("Other") L"/" LPGENW("Disable frame"), m_proto->m_bDisableFrame); m_otvOptions.AddOption(LPGENW("Other") L"/" LPGENW("Enable XMPP link processing (requires AssocMgr)"), m_proto->m_bProcessXMPPLinks); + m_otvOptions.AddOption(LPGENW("Other") L"/" LPGENW("Embrace picture URLs with [img]"), m_proto->m_bEmbraceUrls); m_otvOptions.AddOption(LPGENW("Other") L"/" LPGENW("Ignore server roster (groups and nick names)"), m_proto->m_bIgnoreRoster); m_otvOptions.AddOption(LPGENW("Security") L"/" LPGENW("Allow servers to request version (XEP-0092)"), m_proto->m_bAllowVersionRequests); diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp index 46f979bc7d..10736104cd 100644 --- a/protocols/JabberG/src/jabber_opttree.cpp +++ b/protocols/JabberG/src/jabber_opttree.cpp @@ -90,13 +90,10 @@ void CCtrlTreeOpts::OnInit() { CCtrlTreeView::OnInit(); - wchar_t itemName[1024]; - HIMAGELIST hImgLst; - SelectItem(nullptr); DeleteAllItems(); - hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1); + HIMAGELIST hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1); ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_MIRANDA); ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_TICK); // check on ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_NOTICK); // check off @@ -108,12 +105,12 @@ void CCtrlTreeOpts::OnInit() /* build options tree. based on code from IcoLib */ for (auto &it : m_options) { - wchar_t *sectionName; int sectionLevel = 0; HTREEITEM hSection = nullptr; + wchar_t itemName[1024]; mir_wstrcpy(itemName, it->m_szOptionName); - sectionName = itemName; + wchar_t *sectionName = itemName; while (sectionName) { // allow multi-level tree diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index bbaeabc147..ac9e336722 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -120,6 +120,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_bManualConnect(this, "ManualConnect", false), m_bMsgAck(this, "MsgAck", true), m_bProcessXMPPLinks(this, "ProcessXMPPLinks", false), + m_bEmbraceUrls(this, "EmbraceUrls", false), m_bRcMarkMessagesAsRead(this, "RcMarkMessagesAsRead", true), m_bRosterSync(this, "RosterSync", false), m_bSavePassword(this, "SavePassword", true), diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 139a7371cd..c09b07ce34 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -213,6 +213,7 @@ struct CJabberProto : public PROTO, public IJabberInterface CMOption m_bManualConnect; CMOption m_bMsgAck; CMOption m_bProcessXMPPLinks; + CMOption m_bEmbraceUrls; CMOption m_bRcMarkMessagesAsRead; CMOption m_bRosterSync; CMOption m_bSavePassword; -- cgit v1.2.3