From 93b3a77b2590443e2b1e868b96196175f99180b9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 22 Mar 2020 14:20:52 +0300 Subject: File transfers: - fixes #2274 (StdMsg & Scriver cannot send files to offline contacts even if their protocol allows that to do); - all copies of AddToFileList in all plugins removed; - ProcessFileDrop() function introduced to handle all file drop operations in all SRMM plugins & contact list --- plugins/Scriver/src/msgdialog.cpp | 43 +++------------------------------------ 1 file changed, 3 insertions(+), 40 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 1d4055b22a..f119bc4458 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -91,28 +91,6 @@ static wchar_t* GetQuotedTextW(wchar_t *text) return out; } -static void AddToFileList(wchar_t ***pppFiles, int *totalCount, const wchar_t* szFilename) -{ - *pppFiles = (wchar_t**)mir_realloc(*pppFiles, (++*totalCount + 1)*sizeof(wchar_t*)); - (*pppFiles)[*totalCount] = nullptr; - (*pppFiles)[*totalCount - 1] = mir_wstrdup(szFilename); - - if (GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY) { - WIN32_FIND_DATA fd; - wchar_t szPath[MAX_PATH]; - mir_snwprintf(szPath, L"%s\\*", szFilename); - HANDLE hFind = FindFirstFile(szPath, &fd); - if (hFind != INVALID_HANDLE_VALUE) { - do { - if (!mir_wstrcmp(fd.cFileName, L".") || !mir_wstrcmp(fd.cFileName, L"..")) continue; - mir_snwprintf(szPath, L"%s\\%s", szFilename, fd.cFileName); - AddToFileList(pppFiles, totalCount, szPath); - } while (FindNextFile(hFind, &fd)); - FindClose(hFind); - } - } -} - ///////////////////////////////////////////////////////////////////////////////////////// static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) @@ -981,7 +959,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) if (OpenClipboard(m_message.GetHwnd())) { HANDLE hDrop = GetClipboardData(CF_HDROP); if (hDrop) - SendMessage(m_hwnd, WM_DROPFILES, (WPARAM)hDrop, 0); + ProcessFileDrop((HDROP)hDrop, m_hContact); CloseClipboard(); } return 0; @@ -989,7 +967,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_DROPFILES: - SendMessage(m_hwnd, WM_DROPFILES, wParam, lParam); + ProcessFileDrop((HDROP)wParam, m_hContact); return 0; case WM_CONTEXTMENU: @@ -1117,22 +1095,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_DROPFILES: - if (m_szProto == nullptr) break; - if (!(CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_FILESEND)) break; - if (m_wStatus == ID_STATUS_OFFLINE) break; - if (m_hContact != 0) { - wchar_t szFilename[MAX_PATH]; - HDROP hDrop = (HDROP)wParam; - int fileCount = DragQueryFile(hDrop, -1, nullptr, 0), totalCount = 0, i; - wchar_t** ppFiles = nullptr; - for (i = 0; i < fileCount; i++) { - DragQueryFile(hDrop, i, szFilename, _countof(szFilename)); - AddToFileList(&ppFiles, &totalCount, szFilename); - } - CallServiceSync(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles); - for (i = 0; ppFiles[i]; i++) mir_free(ppFiles[i]); - mir_free(ppFiles); - } + ProcessFileDrop((HDROP)wParam, m_hContact); break; case DM_AVATARCHANGED: -- cgit v1.2.3