summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-22 14:20:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-22 14:20:52 +0300
commit93b3a77b2590443e2b1e868b96196175f99180b9 (patch)
tree70601e77b9f6f7256721967eed0be10b598ad2e4 /src/core
parentbb0498bf6aa0accd22bbc19091a12d54602a52be (diff)
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
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp52
-rw-r--r--src/core/stdmsg/src/msgs.h1
2 files changed, 3 insertions, 50 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 8d57bab10d..8e5aa0a79d 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -37,30 +37,6 @@ LIST<CMsgDialog> g_arDialogs(10, PtrKeySortT);
/////////////////////////////////////////////////////////////////////////////////////////
-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);
- }
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, MCONTACT hContact) :
CSuper(g_plugin, IDD_MSG),
m_btnOk(this, IDOK),
@@ -573,7 +549,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case WM_DROPFILES: // Mod from tabsrmm
- ProcessFileDrop((HDROP)wParam);
+ ProcessFileDrop((HDROP)wParam, m_hContact);
return TRUE;
case HM_AVATARACK:
@@ -987,7 +963,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_DROPFILES:
- ProcessFileDrop((HDROP)wParam);
+ ProcessFileDrop((HDROP)wParam, m_hContact);
break;
case WM_LBUTTONDOWN:
@@ -1107,7 +1083,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
if (OpenClipboard(m_message.GetHwnd())) {
HANDLE hDrop = GetClipboardData(CF_HDROP);
if (hDrop)
- ProcessFileDrop((HDROP)hDrop);
+ ProcessFileDrop((HDROP)hDrop, m_hContact);
CloseClipboard();
}
}
@@ -1501,28 +1477,6 @@ void CMsgDialog::RemakeLog()
m_pLog->LogEvents(m_hDbEventFirst, -1, 0);
}
-void CMsgDialog::ProcessFileDrop(HDROP hDrop)
-{
- if (m_szProto == nullptr) return;
- if (!(CallProtoService(m_szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_FILESEND)) return;
- if (m_wStatus == ID_STATUS_OFFLINE) return;
- if (m_hContact != 0) {
- wchar_t szFilename[MAX_PATH];
- int fileCount = DragQueryFile(hDrop, -1, nullptr, 0), totalCount = 0;
- wchar_t **ppFiles = nullptr;
- for (int i = 0; i < fileCount; i++) {
- DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
- AddToFileList(&ppFiles, totalCount, szFilename);
- }
- CallServiceSync(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles);
- if (ppFiles) {
- for (int i = 0; ppFiles[i]; i++)
- mir_free(ppFiles[i]);
- mir_free(ppFiles);
- }
- }
-}
-
void CMsgDialog::ShowAvatar()
{
if (g_dat.bShowAvatar) {
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 3f045dc17a..7b77bae289 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -58,7 +58,6 @@ class CMsgDialog : public CSrmmBaseDialog
void Init(void);
void NotifyTyping(int mode);
- void ProcessFileDrop(HDROP hDrop);
void ShowAvatar(void);
void ShowTime(bool bForce);
void SetupStatusBar(void);