From 73c31a3f9ac9f323d6a17a910fb6a8a32416c7bb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 26 Jul 2023 21:33:09 +0300 Subject: =?UTF-8?q?fixes=20#3585=20(=D0=9E=D1=84=D1=84=D0=BB=D0=B0=D0=B9?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B?= =?UTF-8?q?:=20=D0=B8=D1=81=D1=85=D0=BE=D0=B4=D1=8F=D1=89=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=B2=D1=8B=D0=B3=D0=BB=D1=8F=D0=B4=D0=B5=D1=82=D1=8C?= =?UTF-8?q?=20=D0=BA=D0=B0=D0=BA=20=D0=B8=20=D0=B2=D1=85=D0=BE=D0=B4=D1=8F?= =?UTF-8?q?=D1=89=D0=B8=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/JabberG/src/jabber_file.cpp | 12 ++++++------ protocols/JabberG/src/jabber_ft.cpp | 32 ++++++++++++++++++++------------ protocols/JabberG/src/jabber_opt.cpp | 1 - protocols/JabberG/src/jabber_proto.cpp | 1 - protocols/JabberG/src/jabber_proto.h | 2 +- protocols/JabberG/src/stdafx.h | 1 + 6 files changed, 28 insertions(+), 21 deletions(-) (limited to 'protocols') diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 18ca3c59b3..01f04bb01f 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -25,12 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "jabber_caps.h" -INT_PTR __cdecl CJabberProto::OnOfflineFile(WPARAM param, LPARAM) -{ - ForkThread((MyThreadFunc)&CJabberProto::OfflineFileThread, (void*)param); - return 0; -} - void __cdecl CJabberProto::OfflineFileThread(OFDTHREAD *ofd) { DB::EventInfo dbei(ofd->hDbEvent); @@ -108,6 +102,12 @@ void __cdecl CJabberProto::OfflineFileThread(OFDTHREAD *ofd) delete ofd; } +INT_PTR __cdecl CJabberProto::OnOfflineFile(WPARAM param, LPARAM) +{ + ForkThread((MyThreadFunc)&CJabberProto::OfflineFileThread, (void *)param); + return 0; +} + void CJabberProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *pHandle) { if (auto *ft = (filetransfer *)pHandle) diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 1912a5b224..7f00b81449 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -783,23 +783,31 @@ LBL_Fail: } else m << XCHILDNS("x", JABBER_FEAT_OOB2) << XCHILD("url", szMessage.c_str()); - if (m_bEmbraceUrls && ProtoGetAvatarFormat(_A2T(szMessage)) != PA_FORMAT_UNKNOWN) { - szMessage.Insert(0, "[img]"); - szMessage.Append("[/img]"); - } - int ret = SendMsgEx(ft->std.hContact, szMessage.c_str(), m); - if (ret != -1 && !isChatRoom(ft->std.hContact)) { - PROTORECVEVENT recv = {}; - recv.flags = PREF_CREATEREAD | PREF_SENT; - recv.szMessage = szMessage.GetBuffer(); - recv.timestamp = time(0); - ProtoChainRecvMsg(ft->std.hContact, &recv); - } + if (ret != -1 && !isChatRoom(ft->std.hContact)) + ft->szUrl = mir_strdup(szMessage); FtSendFinal(true, ft); } +void CJabberProto::OnSendOfflineFile(DB::EventInfo &/*dbei*/, DB::FILE_BLOB &blob, void *hTransfer) +{ + auto *ft = (filetransfer *)hTransfer; + if (!ft->szUrl) + return; + + auto *p = wcsrchr(ft->std.szCurrentFile.w, '\\'); + if (p == nullptr) + p = ft->std.szCurrentFile.w; + else + p++; + blob.setName(p); + + blob.setUrl(ft->szUrl); + blob.complete(ft->std.totalBytes); + blob.setLocalName(ft->std.szCurrentFile.w); +} + ///////////////////////////////////////////////////////////////////////////////////////// bool CJabberProto::FtTryInlineFile(filetransfer *ft) diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 27cee4ca46..c414d857f7 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -726,7 +726,6 @@ public: m_options.AddOption(LPGENW("Other"), LPGENW("Automatically accept authorization requests"), m_proto->m_bAutoAcceptAuthorization); m_options.AddOption(LPGENW("Other"), LPGENW("Fix incorrect timestamps in incoming messages"), m_proto->m_bFixIncorrectTimestamps); m_options.AddOption(LPGENW("Other"), LPGENW("Enable XMPP link processing (requires AssocMgr)"), m_proto->m_bProcessXMPPLinks); - m_options.AddOption(LPGENW("Other"), LPGENW("Embrace picture URLs with [img]"), m_proto->m_bEmbraceUrls); m_options.AddOption(LPGENW("Other"), LPGENW("Ignore server roster (groups and nick names)"), m_proto->m_bIgnoreRoster); m_options.AddOption(LPGENW("Security"), LPGENW("Allow local time and timezone requests (XEP-0202)"), m_proto->m_bAllowTimeReplies); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 61f27ddab6..d3695437fa 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -121,7 +121,6 @@ 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 4a645a894b..d08408df93 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -154,6 +154,7 @@ struct CJabberProto : public PROTO, public IJabberInterface void OnMarkRead(MCONTACT, MEVENT) override; void OnModulesLoaded() override; void OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft) override; + void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft) override; void OnShutdown() override; //====| Services |==================================================================== @@ -225,7 +226,6 @@ 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; diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index bc16368761..7123b8443e 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -445,6 +445,7 @@ struct filetransfer : public MZeroedObject HANDLE hFileEvent; unsigned __int64 *fileSize; wchar_t *szDescription; + ptrA szUrl; CJabberProto *ppro; }; -- cgit v1.2.3