diff options
author | George Hazan <george.hazan@gmail.com> | 2024-09-18 17:13:51 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-09-18 17:13:51 +0300 |
commit | 1e18ce7298c8815e89cc258d6e4a6a629a0b0bb8 (patch) | |
tree | 13a3655238609be85f44d4b91bdeaffa7a985792 /protocols | |
parent | 6984b2e7d89d3281ba045c1e81c9f641520cdd8f (diff) |
fixes #4684 (Skypeweb: сломалась автозагрузка файлов)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/files.cpp | 2 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Discord/src/utils.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_file.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_messages.cpp | 40 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 6 | ||||
-rw-r--r-- | protocols/Telegram/src/avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 2 |
10 files changed, 27 insertions, 35 deletions
diff --git a/protocols/Discord/src/files.cpp b/protocols/Discord/src/files.cpp index 163f1c7c72..b8cfa87935 100644 --- a/protocols/Discord/src/files.cpp +++ b/protocols/Discord/src/files.cpp @@ -78,7 +78,7 @@ INT_PTR CDiscordProto::SvcOfflineFile(WPARAM param, LPARAM) return 0; } -void CDiscordProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob) +void CDiscordProto::OnReceiveOfflineFile(DB::EventInfo&, DB::FILE_BLOB &blob) { if (auto *ft = (CDiscordAttachment *)blob.getUserInfo()) { blob.setUrl(ft->szUrl.GetBuffer()); diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index efee984afa..fac698111d 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -560,7 +560,7 @@ public: MWindow OnCreateAccMgrUI(MWindow) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
- void OnReceiveOfflineFile(DB::FILE_BLOB &blob);
+ void OnReceiveOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob);
void OnShutdown() override;
//////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index 3132407b03..ce5a88ae58 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -388,7 +388,7 @@ CMStringW CDiscordProto::PrepareMessageText(const JSONNode &pRoot, CDiscordUser if (dbei) {
DB::FILE_BLOB blob(dbei);
- OnReceiveOfflineFile(blob);
+ OnReceiveOfflineFile(dbei, blob);
blob.write(dbei);
db_event_edit(dbei.getEvent(), &dbei, true);
delete pFile;
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index c115e63de0..ddd2a5bdf2 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -113,7 +113,7 @@ INT_PTR __cdecl CJabberProto::OnOfflineFile(WPARAM param, LPARAM) return 0;
}
-void CJabberProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob)
+void CJabberProto::OnReceiveOfflineFile(DB::EventInfo&, DB::FILE_BLOB &blob)
{
if (auto *ft = (filetransfer *)blob.getUserInfo()) {
if (ft->type == FT_HTTP) {
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index f82cdcb850..615ab8e70b 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -154,7 +154,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface MWindow OnCreateAccMgrUI(MWindow) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
- void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override;
+ void OnReceiveOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob) override;
void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft) override;
void OnShutdown() override;
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 4fc18a5c97..e99d5fcdb1 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -210,11 +210,18 @@ void CSkypeProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent) }
}
-void CSkypeProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob)
+void CSkypeProto::OnReceiveOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob)
{
if (auto *ft = (CSkypeTransfer *)blob.getUserInfo()) {
blob.setUrl(ft->url);
blob.setSize(ft->iFileSize);
+
+ auto &json = dbei.setJson();
+ json << CHAR_PARAM("skft", ft->fileType);
+ if (ft->iHeight != -1)
+ json << INT_PARAM("h", ft->iHeight);
+ if (ft->iWidth != -1)
+ json << INT_PARAM("w", ft->iWidth);
delete ft;
}
}
@@ -229,16 +236,15 @@ void CSkypeProto::ProcessFileRecv(MCONTACT hContact, const char *szContent, DB:: if (xmlRoot == nullptr)
return;
- CMStringA szFileType;
CSkypeTransfer *ft = new CSkypeTransfer;
if (auto *str = xmlRoot->Attribute("doc_id"))
ft->docId = str;
if (auto *str = xmlRoot->Attribute("uri"))
ft->url = str;
- int iWidth = xmlRoot->IntAttribute("width", -1);
- int iHeight = xmlRoot->IntAttribute("heighr", -1);
+ ft->iWidth = xmlRoot->IntAttribute("width", -1);
+ ft->iHeight = xmlRoot->IntAttribute("heighr", -1);
if (auto *str = xmlRoot->Attribute("type"))
- szFileType = str;
+ ft->fileType = str;
if (auto *xml = xmlRoot->FirstChildElement("FileSize"))
if (auto *str = xml->Attribute("v"))
ft->iFileSize = atoi(str);
@@ -252,39 +258,25 @@ void CSkypeProto::ProcessFileRecv(MCONTACT hContact, const char *szContent, DB:: return;
}
- int idx = szFileType.Find('/');
+ int idx = ft->fileType.Find('/');
if (idx != -1)
- szFileType = szFileType.Left(idx);
+ ft->fileType = ft->fileType.Left(idx);
// ordinary file
- if (szFileType == "File.1" || szFileType == "Picture.1" || szFileType == "Video.1") {
+ if (ft->fileType == "File.1" || ft->fileType == "Picture.1" || ft->fileType == "Video.1") {
MEVENT hEvent;
dbei.flags |= DBEF_TEMPORARY | DBEF_JSON;
if (dbei) {
DB::FILE_BLOB blob(dbei);
- OnReceiveOfflineFile(blob);
+ OnReceiveOfflineFile(dbei, blob);
blob.write(dbei);
db_event_edit(dbei.getEvent(), &dbei, true);
delete ft;
hEvent = dbei.getEvent();
}
else hEvent = ProtoChainRecvFile(hContact, DB::FILE_BLOB(ft, ft->fileName), dbei);
-
- DBVARIANT dbv = { DBVT_UTF8 };
- dbv.pszVal = szFileType.GetBuffer();
- db_event_setJson(hEvent, "skft", &dbv);
-
- dbv.type = DBVT_DWORD;
- if (iWidth != -1) {
- dbv.dVal = iWidth;
- db_event_setJson(hEvent, "w", &dbv);
- }
- if (iHeight != -1) {
- dbv.dVal = iHeight;
- db_event_setJson(hEvent, "h", &dbv);
- }
}
- else debugLogA("Invalid or unsupported file type <%s> ignored", szFileType.c_str());
+ else debugLogA("Invalid or unsupported file type <%s> ignored", ft->fileType.c_str());
}
void CSkypeProto::ProcessContactRecv(MCONTACT hContact, const char *szContent, DB::EventInfo &dbei)
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index de73e6be3d..2b8b7e5e8c 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct CSkypeTransfer
{
- CMStringA docId, fileName, url;
- int iFileSize = 0;
+ CMStringA docId, fileName, fileType, url;
+ int iFileSize = 0, iWidth = -1, iHeight = -1;
};
struct CSkypeProto : public PROTO <CSkypeProto>
@@ -78,7 +78,7 @@ public: void OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
- void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override;
+ void OnReceiveOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob) override;
void OnShutdown() override;
// icons
diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index 32d2255cee..873db7663f 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -149,7 +149,7 @@ INT_PTR __cdecl CTelegramProto::SvcOfflineFile(WPARAM param, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
// Cloud file pre-creator
-void CTelegramProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob)
+void CTelegramProto::OnReceiveOfflineFile(DB::EventInfo&, DB::FILE_BLOB &blob)
{
if (auto *ft = (TG_FILE_REQUEST *)blob.getUserInfo()) {
blob.setUrl(ft->m_uniqueId.GetBuffer());
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index d19ecdfb33..f3c66d3f50 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -409,7 +409,7 @@ public: void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override; void OnMarkRead(MCONTACT, MEVENT) override; void OnModulesLoaded() override; - void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override; + void OnReceiveOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob) override; void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *hTransfer) override; void OnShutdown() override; diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index fa38d6cdc9..829677e8b3 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -454,7 +454,7 @@ bool CTelegramProto::GetMessageFile(const EmbeddedFile &F, TG_FILE_REQUEST::Type if (dbei) {
DB::FILE_BLOB blob(dbei);
- OnReceiveOfflineFile(blob);
+ OnReceiveOfflineFile(dbei, blob);
blob.write(dbei);
db_event_edit(dbei.getEvent(), &dbei, true);
delete pRequest;
|