summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-07-28 18:24:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-07-28 18:24:25 +0300
commit1b17214fcaa3e3fa2d60969f0ea314ba4f1f26c6 (patch)
tree7ca076390b056ebfe409d34713e9b722a276c6af /protocols/JabberG
parent841393dcb0392491efe99f4682130757fd45dd9c (diff)
Jabber: new option to embrace picture urls/filenames with BBCodes
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp19
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp1
-rw-r--r--protocols/JabberG/src/jabber_opttree.cpp9
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp1
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h1
5 files changed, 19 insertions, 12 deletions
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<CJabberProto>, public IJabberInterface
CMOption<bool> m_bManualConnect;
CMOption<bool> m_bMsgAck;
CMOption<bool> m_bProcessXMPPLinks;
+ CMOption<bool> m_bEmbraceUrls;
CMOption<bool> m_bRcMarkMessagesAsRead;
CMOption<bool> m_bRosterSync;
CMOption<bool> m_bSavePassword;