[SHELL32][ZIPFLDR] Implement SendTo ZIP folder (#2118)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Sun, 1 Dec 2019 17:26:34 +0000 (02:26 +0900)
committerGitHub <noreply@github.com>
Sun, 1 Dec 2019 17:26:34 +0000 (02:26 +0900)
Follow-up of #2114.
- s/Creater/Creator/
- Add an empty file in the SendTo folder.
- Trick.
CORE-16495

dll/shellext/zipfldr/CMakeLists.txt
dll/shellext/zipfldr/CSendToZip.cpp
dll/shellext/zipfldr/CSendToZip.hpp
dll/shellext/zipfldr/CZipCreator.cpp [moved from dll/shellext/zipfldr/CZipCreater.cpp with 97% similarity]
dll/shellext/zipfldr/CZipCreator.hpp [moved from dll/shellext/zipfldr/CZipCreater.hpp with 85% similarity]
dll/shellext/zipfldr/precomp.h
dll/win32/shell32/wine/shellpath.c

index a0244d6..f0339f9 100644 (file)
@@ -29,7 +29,7 @@ list(APPEND SOURCE
     CEnumZipContents.cpp
     CFolderViewCB.cpp
     CSendToZip.cpp
-    CZipCreater.cpp
+    CZipCreator.cpp
     CZipEnumerator.hpp
     CZipExtract.cpp
     CZipFolder.hpp
index 9ec9bd5..67f774c 100644 (file)
@@ -47,12 +47,10 @@ CSendToZip::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt,
                  DWORD *pdwEffect)
 {
     m_pDataObject = pDataObj;
-    *pdwEffect &= DROPEFFECT_COPY;
 
-    if (!pDataObj || !m_fCanDragDrop || !*pdwEffect)
+    if (!pDataObj || !m_fCanDragDrop)
     {
-        DPRINT1("Drop failed: %d %d %d\n",
-                !pDataObj, !m_fCanDragDrop, !*pdwEffect);
+        DPRINT1("Drop failed: %d %d\n", !pDataObj, !m_fCanDragDrop);
         *pdwEffect = 0;
         DragLeave();
         return E_FAIL;
@@ -71,19 +69,19 @@ CSendToZip::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt,
     HDROP hDrop = reinterpret_cast<HDROP>(stg.hGlobal);
     UINT cItems = ::DragQueryFileW(hDrop, -1, NULL, 0);
 
-    CZipCreator *pCreater = CZipCreator::DoCreate();
+    CZipCreator *pCreator = CZipCreator::DoCreate();
 
     for (UINT iItem = 0; iItem < cItems; ++iItem)
     {
         WCHAR szPath[MAX_PATH];
         DragQueryFileW(hDrop, iItem, szPath, _countof(szPath));
 
-        pCreater->DoAddItem(szPath);
+        pCreator->DoAddItem(szPath);
     }
 
     ::ReleaseStgMedium(&stg);
 
-    CZipCreator::runThread(pCreater);   // pCreater is deleted in runThread
+    CZipCreator::runThread(pCreator);   // pCreator is deleted in runThread
 
     DragLeave();
     return hr;
index 1f3eb24..b4e8fca 100644 (file)
@@ -46,21 +46,22 @@ public:
     }
     STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember)
     {
-        return E_FAIL;
+        return E_NOTIMPL;
     }
     STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName)
     {
-        return E_FAIL;
+        return E_NOTIMPL;
     }
     STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName)
     {
-        return E_FAIL;
+        return E_NOTIMPL;
     }
 
     // *** IPersist methods ***
     STDMETHODIMP GetClassID(CLSID *pclsid)
     {
-        return E_FAIL;
+        *pclsid = CLSID_ZipFolderSendTo;
+        return S_OK;
     }
 
 public:
similarity index 97%
rename from dll/shellext/zipfldr/CZipCreater.cpp
rename to dll/shellext/zipfldr/CZipCreator.cpp
index 694128b..c0ba8da 100644 (file)
@@ -182,15 +182,15 @@ CZipCreator::~CZipCreator()
 static unsigned __stdcall
 create_zip_function(void *arg)
 {
-    CZipCreator *pCreater = reinterpret_cast<CZipCreator *>(arg);
-    return pCreater->m_pimpl->JustDoIt();
+    CZipCreator *pCreator = reinterpret_cast<CZipCreator *>(arg);
+    return pCreator->m_pimpl->JustDoIt();
 }
 
-BOOL CZipCreator::runThread(CZipCreator *pCreater)
+BOOL CZipCreator::runThread(CZipCreator *pCreator)
 {
     unsigned tid = 0;
     HANDLE hThread = reinterpret_cast<HANDLE>(
-        _beginthreadex(NULL, 0, create_zip_function, pCreater, 0, &tid));
+        _beginthreadex(NULL, 0, create_zip_function, pCreator, 0, &tid));
 
     if (hThread)
     {
@@ -204,7 +204,7 @@ BOOL CZipCreator::runThread(CZipCreator *pCreater)
     CStringW strText(MAKEINTRESOURCEW(IDS_CANTSTARTTHREAD));
     MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
 
-    delete pCreater;
+    delete pCreator;
     return FALSE;
 }
 
similarity index 85%
rename from dll/shellext/zipfldr/CZipCreater.hpp
rename to dll/shellext/zipfldr/CZipCreator.hpp
index 52fb14f..1a77451 100644 (file)
@@ -5,8 +5,8 @@
  * COPYRIGHT:   Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
  *              Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
  */
-#ifndef CZIPCREATER_HPP_
-#define CZIPCREATER_HPP_
+#ifndef CZIPCREATOR_HPP_
+#define CZIPCREATOR_HPP_
 
 struct CZipCreatorImpl;
 
@@ -23,7 +23,7 @@ public:
     }
 
     virtual void DoAddItem(LPCWSTR pszFile);
-    static BOOL runThread(CZipCreator* pCreater);
+    static BOOL runThread(CZipCreator* pCreator);
 
 protected:
     CZipCreator();
index ed61dc7..b228624 100644 (file)
@@ -78,7 +78,7 @@ eZipConfirmResponse _CZipAskReplace(HWND hDlg, const char* FullPath);
 
 #include "CZipEnumerator.hpp"
 #include "CZipFolder.hpp"
-#include "CZipCreater.hpp"
+#include "CZipCreator.hpp"
 #include "CSendToZip.hpp"
 
 #endif /* ZIPFLDR_PRECOMP_H */
index 3c19063..984116f 100644 (file)
@@ -2224,6 +2224,7 @@ HRESULT DoCreateSendToFiles(LPCWSTR pszSendTo)
     WCHAR szShell32[MAX_PATH];
     HRESULT hr;
     HANDLE hFile;
+    HINSTANCE hZipFldr;
 
     /* create my documents */
     SHGetSpecialFolderPathW(NULL, szTarget, CSIDL_MYDOCUMENTS, TRUE);
@@ -2248,7 +2249,24 @@ HRESULT DoCreateSendToFiles(LPCWSTR pszSendTo)
                         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
     CloseHandle(hFile);
 
-    return hr;
+    /* create zipped compressed folder */
+    hZipFldr = LoadLibraryW(L"zipfldr.dll");
+    if (hZipFldr)
+    {
+#define IDS_FRIENDLYNAME 10195
+        LoadStringW(hZipFldr, IDS_FRIENDLYNAME, szTarget, _countof(szTarget));
+#undef IDS_FRIENDLYNAME
+        FreeLibrary(hZipFldr);
+
+        StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
+        PathAppendW(szSendToFile, szTarget);
+        StringCbCatW(szSendToFile, sizeof(szSendToFile), L".ZFSendToTarget");
+        hFile = CreateFileW(szSendToFile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+        CloseHandle(hFile);
+    }
+
+    return S_OK;
 }
 
 /*************************************************************************