From 51ccfb874ece51a0bdd08226d190ddf86a6013fd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 13 Jan 2023 18:22:12 +0300 Subject: Jabber: ability to autoload files passed via HTTP Upload instead of writing messages with URLs --- protocols/JabberG/src/jabber_thread.cpp | 41 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'protocols/JabberG/src/jabber_thread.cpp') 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"); -- cgit v1.2.3