summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-04-24 13:41:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-04-24 13:41:41 +0300
commit7a11ce58becfc750e5b4a9bb07102f8d334bbcf6 (patch)
treed8d28c73c4f3c5b5953b7785e374e38e89de7580
parentcce43e30dca000d713131a87ddd78265d71eb763 (diff)
Telegram: silent file transfers don't require f/t manager, but simply create offline events
-rw-r--r--include/m_protosvc.h6
-rw-r--r--protocols/Telegram/src/proto.cpp32
-rw-r--r--protocols/Telegram/src/proto.h4
-rw-r--r--protocols/Telegram/src/utils.cpp2
-rw-r--r--src/core/stdfile/src/file.cpp19
5 files changed, 16 insertions, 47 deletions
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index 76ed0eb260..c9e6aacfc2 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -768,8 +768,10 @@ EXTERN_C MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, PROTORECVEV
// wParam = 0
// lParam = (LPARAM)(PROTORECVFILE*)&prf
-#define PRFF_UNICODE 1
-#define PRFF_UTF 2
+#define PRFF_UNICODE 0x0001 // in all MAllCStrings .w is valid
+#define PRFF_UTF 0x0002 // in all MAllCStrings .a contains text in UTF8
+#define PRFF_SILENT 0x0004 // do not show file send/receive dialog
+
struct PROTORECVFILE
{
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 11bed96d85..172b299ebc 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -278,38 +278,6 @@ INT_PTR CTelegramProto::GetCaps(int type, MCONTACT)
}
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-HANDLE CTelegramProto::FileAllow(MCONTACT, HANDLE hTransfer, const wchar_t *pwszSavePath)
-{
- auto *ft = (TG_FILE_REQUEST *)hTransfer;
- if (ft == nullptr)
- return nullptr;
-
- ft->m_destPath = pwszSavePath;
- ft->pfts.szCurrentFile.w = ft->m_fileName.GetBuffer();
- ft->pfts.szWorkingDir.w = ft->m_destPath.GetBuffer();
- SendQuery(new TD::downloadFile(ft->m_fileId, 5, 0, 0, false));
- return ft;
-}
-
-int CTelegramProto::FileCancel(MCONTACT, HANDLE hTransfer)
-{
- auto *ft = (TG_FILE_REQUEST *)hTransfer;
- delete ft;
- return 1;
-}
-
-int CTelegramProto::FileResume(HANDLE hTransfer, int, const wchar_t *pwszFilename)
-{
- auto *ft = (TG_FILE_REQUEST *)hTransfer;
- if (ft == nullptr)
- return 1;
-
- ft->m_destPath = pwszFilename;
- return 0;
-}
-
////////////////////////////////////////////////////////////////////////////////////////
// RecvFile - writes down an incoming file transfer to db
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 25c4bd9af3..95c98a0739 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -286,10 +286,6 @@ public:
MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr);
- HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath) override;
- int FileCancel(MCONTACT hContact, HANDLE hTransfer) override;
- int FileResume(HANDLE hTransfer, int action, const wchar_t *szFilename) override;
-
INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE *pre) override;
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index 28b3204cf7..99887aa661 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -270,7 +270,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
auto *pszFileName = pDoc->document_->file_name_.c_str();
PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UTF;
+ pre.dwFlags = PRFF_UTF | PRFF_SILENT;
pre.fileCount = 1;
pre.timestamp = time(0);
pre.files.a = &pszFileName;
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp
index 159a421fe6..b1f8f3670f 100644
--- a/src/core/stdfile/src/file.cpp
+++ b/src/core/stdfile/src/file.cpp
@@ -358,6 +358,7 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
blob.write(dbei);
}
+ bool bShow = (pre->dwFlags & PRFF_SILENT) == 0;
MEVENT hdbe = db_event_add(ccs->hContact, &dbei);
CLISTEVENT cle = {};
@@ -365,19 +366,21 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
cle.hDbEvent = hdbe;
cle.lParam = pre->lParam;
- if (g_plugin.bAutoAccept && Contact::OnList(ccs->hContact))
+ if (bShow && g_plugin.bAutoAccept && Contact::OnList(ccs->hContact))
LaunchRecvDialog(&cle);
else {
Skin_PlaySound("RecvFile");
- wchar_t szTooltip[256];
- mir_snwprintf(szTooltip, TranslateT("File from %s"), Clist_GetContactDisplayName(ccs->hContact));
- cle.szTooltip.w = szTooltip;
+ if (bShow) {
+ wchar_t szTooltip[256];
+ mir_snwprintf(szTooltip, TranslateT("File from %s"), Clist_GetContactDisplayName(ccs->hContact));
+ cle.szTooltip.w = szTooltip;
- cle.flags |= CLEF_UNICODE;
- cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_FILE);
- cle.pszService = "SRFile/RecvFile";
- g_clistApi.pfnAddEvent(&cle);
+ cle.flags |= CLEF_UNICODE;
+ cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_FILE);
+ cle.pszService = "SRFile/RecvFile";
+ g_clistApi.pfnAddEvent(&cle);
+ }
}
return hdbe;