From 1e18ce7298c8815e89cc258d6e4a6a629a0b0bb8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Sep 2024 17:13:51 +0300 Subject: =?UTF-8?q?fixes=20#4684=20(Skypeweb:=20=D1=81=D0=BB=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BB=D0=B0=D1=81=D1=8C=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/SkypeWeb/src/skype_messages.cpp | 40 +++++++++++++------------------ protocols/SkypeWeb/src/skype_proto.h | 6 ++--- 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'protocols/SkypeWeb/src') 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 . 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 @@ -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 -- cgit v1.2.3