summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_thread.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-13 18:22:12 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-13 18:22:12 +0300
commit51ccfb874ece51a0bdd08226d190ddf86a6013fd (patch)
treeef843f6760cb8c75a0ce4183dcf741c35da44233 /protocols/JabberG/src/jabber_thread.cpp
parentfcf2f92e1b3e06c696260f14167a42d54c17c028 (diff)
Jabber: ability to autoload files passed via HTTP Upload instead of writing messages with URLs
Diffstat (limited to 'protocols/JabberG/src/jabber_thread.cpp')
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 0ad67e79dd..a088f16c12 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1330,32 +1330,33 @@ void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info)
szMessage += tempstring;
}
}
- else if (!mir_strcmp(pszXmlns, JABBER_FEAT_OOB2)) {
+ else if (!mir_strcmp(pszXmlns, JABBER_FEAT_OOB2) && m_bAutoLoadOOB) {
if (auto *url = XmlGetChildText(xNode, "url")) {
- DBEVENTINFO dbei = {};
- dbei.szModule = Proto_GetBaseAccountName(hContact);
- dbei.timestamp = msgTime;
- dbei.eventType = EVENTTYPE_FILE;
- dbei.flags = DBEF_UTF;
- //if (pre->dwFlags & PREF_CREATEREAD)
- dbei.flags |= DBEF_READ;
-
+ // create incoming file transfer instead of writing message
CMStringA szName;
const char *b = strrchr(url, '/') + 1;
while (*b != 0 && *b != '#' && *b != '?')
szName.AppendChar(*b++);
-
- auto *szDescr = XmlGetChildText(xNode, "desc");
-
- CMStringA szBlob(FORMAT, "%c%c%c%c", 0, 0, 0, 0);
- szBlob.AppendFormat("%s%c", szName.c_str(), 0);
- szBlob.AppendFormat("%s%c", szDescr ? szDescr : "", 0);
- szBlob.AppendFormat("%s%c", url, 0);
-
- dbei.cbBlob = szBlob.GetLength();
- dbei.pBlob = (uint8_t*)szBlob.GetBuffer();
- db_event_add(hContact, &dbei);
+ auto *pszName = szName.c_str();
+
+ filetransfer *ft = new filetransfer(this, 0);
+ ft->jid = mir_strdup(from);
+ ft->std.hContact = hContact;
+ ft->type = FT_HTTP;
+ ft->httpPath = mir_strdup(url);
+ ft->std.totalFiles = 1;
+ ft->std.szCurrentFile.w = mir_utf8decodeW(szName);
+
+ PROTORECVFILE pre = {};
+ pre.fileCount = 1;
+ pre.timestamp = time(0);
+ pre.files.a = &pszName;
+ pre.lParam = (LPARAM)ft;
+ pre.descr.a = XmlGetChildText(xNode, "desc");
+ ProtoChainRecvFile(ft->std.hContact, &pre);
+ return;
}
+ else debugLogA("No URL in OOB file transfer, ignoring");
}
else if (!mir_strcmp(pszXmlns, JABBER_FEAT_MUC_USER)) {
auto *inviteNode = XmlFirstChild(xNode, "invite");