From 42fee4bf18089b08790194f64687158e344e56b1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 15 Mar 2024 18:47:45 +0300 Subject: WM_DROPFILES / WM_PASTE processing unification --- plugins/TabSRMM/src/msgdlgother.cpp | 104 ------------------------------------ 1 file changed, 104 deletions(-) (limited to 'plugins/TabSRMM/src/msgdlgother.cpp') diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 4ee9fc0d87..747af1f254 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -1882,110 +1882,6 @@ void CMsgDialog::SaveSplitter() } } -///////////////////////////////////////////////////////////////////////////////////////// -// send a pasted bitmap by file transfer. - -static LIST vTempFilenames(5); - -void CMsgDialog::SendHBitmapAsFile(HBITMAP hbmp) const -{ - const wchar_t *mirandatempdir = L"Miranda"; - const wchar_t *filenametemplate = L"\\clp-%Y%m%d-%H%M%S0.jpg"; - wchar_t filename[MAX_PATH]; - size_t tempdirlen = GetTempPath(MAX_PATH, filename); - bool fSend = true; - - const char *szProto = m_cache->getActiveProto(); - int wMyStatus = Proto_GetStatus(szProto); - - uint32_t protoCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); - uint32_t typeCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0); - - // check protocol capabilities, status modes and visibility lists (privacy) - // to determine whether the file can be sent. Throw a warning if any of - // these checks fails. - if (!(protoCaps & PF1_FILESEND)) - fSend = false; - - if ((ID_STATUS_OFFLINE == wMyStatus) || (ID_STATUS_OFFLINE == m_cache->getActiveStatus() && !(typeCaps & PF4_OFFLINEFILES))) - fSend = false; - - if (!fSend) { - CWarning::show(CWarning::WARN_SENDFILE, MB_OK | MB_ICONEXCLAMATION | CWarning::CWF_NOALLOWHIDE); - return; - } - - if (tempdirlen <= 0 || tempdirlen >= MAX_PATH - mir_wstrlen(mirandatempdir) - mir_wstrlen(filenametemplate) - 2) // -2 is because %Y takes 4 symbols - filename[0] = 0; // prompt for a new name - else { - mir_wstrcpy(filename + tempdirlen, mirandatempdir); - if ((GetFileAttributes(filename) == INVALID_FILE_ATTRIBUTES || ((GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) == 0)) && CreateDirectory(filename, nullptr) == 0) - filename[0] = 0; - else { - tempdirlen = mir_wstrlen(filename); - - time_t rawtime; - time(&rawtime); - const tm *timeinfo; - timeinfo = _localtime32((__time32_t *)& rawtime); - wcsftime(filename + tempdirlen, MAX_PATH - tempdirlen, filenametemplate, timeinfo); - size_t firstnumberpos = tempdirlen + 14; - size_t lastnumberpos = tempdirlen + 20; - while (GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES) { // while it exists - for (size_t pos = lastnumberpos; pos >= firstnumberpos; pos--) - if (filename[pos]++ != '9') - break; - else - if (pos == firstnumberpos) - filename[0] = 0; // all filenames exist => prompt for a new name - else - filename[pos] = '0'; - } - } - } - - if (filename[0] == 0) { // prompting to save - wchar_t filter[MAX_PATH]; - mir_snwprintf(filter, L"%s%c*.jpg%c%c", TranslateT("JPEG-compressed images"), 0, 0, 0); - - OPENFILENAME dlg; - dlg.lStructSize = sizeof(dlg); - dlg.lpstrFilter = filter; - dlg.nFilterIndex = 1; - dlg.lpstrFile = filename; - dlg.nMaxFile = MAX_PATH; - dlg.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; - dlg.lpstrDefExt = L"jpg"; - if (!GetSaveFileName(&dlg)) - return; - } - - IMGSRVC_INFO ii; - ii.cbSize = sizeof(ii); - ii.hbm = hbmp; - ii.pwszName = filename; - ii.dwMask = IMGI_HBITMAP; - ii.fif = FIF_JPEG; - if (!Image_Save(&ii)) { - CWarning::show(CWarning::WARN_SAVEFILE, MB_OK | MB_ICONEXCLAMATION | CWarning::CWF_NOALLOWHIDE); - return; - } - - vTempFilenames.insert(mir_wstrdup(filename)); - - wchar_t *ppFiles[2] = { filename, 0 }; - File::Send(m_cache->getActiveContact(), ppFiles); -} - -// remove all temporary files created by the "send clipboard as file" feature. -void TSAPI CleanTempFiles() -{ - for (auto &it : vTempFilenames) { - DeleteFileW(it); - mir_free(it); - } -} - ///////////////////////////////////////////////////////////////////////////////////////// // Sets a status bar text for a contact -- cgit v1.2.3