[SHELLFIND] Add CFindFolder
authorBrock Mammen <brockmammen@gmail.com>
Fri, 19 Jul 2019 20:23:20 +0000 (15:23 -0500)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 15 Sep 2019 16:46:36 +0000 (19:46 +0300)
dll/win32/browseui/browseui.cpp
dll/win32/browseui/browseui.rc
dll/win32/browseui/precomp.h
dll/win32/browseui/res/findfolder.rgs [new file with mode: 0644]
dll/win32/browseui/resource.h
dll/win32/browseui/shellfind/CFindFolder.cpp [new file with mode: 0644]
dll/win32/browseui/shellfind/CFindFolder.h [new file with mode: 0644]
dll/win32/browseui/shellfind/CMakeLists.txt
sdk/include/reactos/shlguid_undoc.h

index d7aed77..8ae993d 100644 (file)
@@ -155,6 +155,7 @@ OBJECT_ENTRY(CLSID_ExplorerBand, CExplorerBand)
 OBJECT_ENTRY(CLSID_FileSearchBand, CSearchBar)
 OBJECT_ENTRY(CLSID_ProgressDialog, CProgressDialog)
 OBJECT_ENTRY(CLSID_ISFBand, CISFBand)
+OBJECT_ENTRY(CLSID_FindFolder, CFindFolder)
 END_OBJECT_MAP()
 
 CBrowseUIModule                             gModule;
index f22d17e..6f6c28d 100644 (file)
@@ -49,6 +49,7 @@ IDR_ISFBAND REGISTRY "res/isfband.rgs"
 IDR_ACLCUSTOMMRU REGISTRY "res/custommru.rgs"
 IDR_TASKBARLIST REGISTRY "res/taskbarlist.rgs"
 IDR_FILESEARCHBAND REGISTRY "res/filesearchband.rgs"
+IDR_FINDFOLDER REGISTRY "res/findfolder.rgs"
 
 #include <reactos/manifest_dll.rc>
 
index b6c464d..f119847 100644 (file)
@@ -47,6 +47,7 @@
 #include "shellbars/CBandSite.h"
 #include "shellbars/CBandSiteMenu.h"
 #include "shellbars/CISFBand.h"
+#include "shellfind/CFindFolder.h"
 #include "shellfind/CSearchBar.h"
 #include "brandband.h"
 #include "internettoolbar.h"
diff --git a/dll/win32/browseui/res/findfolder.rgs b/dll/win32/browseui/res/findfolder.rgs
new file mode 100644 (file)
index 0000000..1cc3d29
--- /dev/null
@@ -0,0 +1,18 @@
+HKCR
+{
+       NoRemove CLSID
+       {
+               ForceRemove {E17D4FC0-5564-11D1-83F2-00A0C90DC849} = s 'Search Results Folder'
+               {
+                       DefaultIcon = e '%%SystemRoot%%\System32\shell32.dll,-134'
+                       InprocServer32 = s '%MODULE%'
+                       {
+                               val ThreadingModel = s 'Apartment'
+                       }
+                       ShellFolder
+                       {
+                               val Attributes = d '0x20180000'
+                       }
+               }
+       }
+}
index 3dbe833..bc9ad64 100644 (file)
 #define IDR_ACLCUSTOMMRU         144
 #define IDR_TASKBARLIST          145
 #define IDR_FILESEARCHBAND       146
+#define IDR_FINDFOLDER           147
 
 #define IDS_SMALLICONS           12301
 #define IDS_LARGEICONS           12302
diff --git a/dll/win32/browseui/shellfind/CFindFolder.cpp b/dll/win32/browseui/shellfind/CFindFolder.cpp
new file mode 100644 (file)
index 0000000..c196187
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * PROJECT:     ReactOS Search Shell Extension
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Search results folder
+ * COPYRIGHT:   Copyright 2019 Brock Mammen
+ */
+
+#include "CFindFolder.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(shellfind);
+
+struct FolderViewColumns
+{
+    LPCWSTR wzColumnName;
+    DWORD dwDefaultState;
+    int fmt;
+    int cxChar;
+};
+
+static FolderViewColumns g_ColumnDefs[] =
+{
+    {L"Name",      SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
+    {L"In Folder", SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
+    {L"Relevance", SHCOLSTATE_TYPE_STR,                          LVCFMT_LEFT, 0}
+};
+
+// *** IShellFolder2 methods ***
+STDMETHODIMP CFindFolder::GetDefaultSearchGUID(GUID *pguid)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::EnumSearches(IEnumExtraSearch **ppenum)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::GetDefaultColumn(DWORD, ULONG *pSort, ULONG *pDisplay)
+{
+    if (pSort)
+        *pSort = 0;
+    if (pDisplay)
+        *pDisplay = 0;
+    return S_OK;
+}
+
+STDMETHODIMP CFindFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
+{
+    if (!pcsFlags || iColumn >= _countof(g_ColumnDefs))
+        return E_INVALIDARG;
+    *pcsFlags = g_ColumnDefs[iColumn].dwDefaultState;
+    return S_OK;
+}
+
+STDMETHODIMP CFindFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *pDetails)
+{
+    if (iColumn >= _countof(g_ColumnDefs))
+        return E_FAIL;
+
+    pDetails->cxChar = g_ColumnDefs[iColumn].cxChar;
+    pDetails->fmt = g_ColumnDefs[iColumn].fmt;
+
+    if (!pidl)
+        return SHSetStrRet(&pDetails->str, g_ColumnDefs[iColumn].wzColumnName);
+
+    return GetDisplayNameOf(pidl, SHGDN_NORMAL, &pDetails->str);
+}
+
+STDMETHODIMP CFindFolder::MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+// *** IShellFolder methods ***
+STDMETHODIMP CFindFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten,
+                                           PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
+{
+    *ppEnumIDList = NULL;
+    return S_FALSE;
+}
+
+STDMETHODIMP CFindFolder::BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+STDMETHODIMP CFindFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
+{
+    if (riid == IID_IShellView)
+    {
+        SFV_CREATE sfvparams = {};
+        sfvparams.cbSize = sizeof(SFV_CREATE);
+        sfvparams.pshf = this;
+        HRESULT hr = SHCreateShellFolderView(&sfvparams, (IShellView **) ppvOut);
+        return hr;
+    }
+    return E_NOINTERFACE;
+}
+
+STDMETHODIMP CFindFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut)
+{
+    *rgfInOut = SFGAO_NONENUMERATED;
+    return S_OK;
+}
+
+STDMETHODIMP CFindFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid,
+                                        UINT *prgfInOut, LPVOID *ppvOut)
+{
+    return E_NOINTERFACE;
+}
+
+STDMETHODIMP CFindFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET pName)
+{
+    return SHSetStrRet(pName, "search result");
+}
+
+STDMETHODIMP CFindFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags,
+                                    PITEMID_CHILD *pPidlOut)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+//// *** IPersistFolder2 methods ***
+STDMETHODIMP CFindFolder::GetCurFolder(LPITEMIDLIST *pidl)
+{
+    *pidl = ILClone(m_pidl);
+    return S_OK;
+}
+
+// *** IPersistFolder methods ***
+STDMETHODIMP CFindFolder::Initialize(LPCITEMIDLIST pidl)
+{
+    m_pidl = ILClone(pidl);
+    if (!m_pidl)
+        return E_OUTOFMEMORY;
+
+    return S_OK;
+}
+
+// *** IPersist methods ***
+STDMETHODIMP CFindFolder::GetClassID(CLSID *pClassId)
+{
+    if (pClassId == NULL)
+        return E_INVALIDARG;
+    memcpy(pClassId, &CLSID_FindFolder, sizeof(CLSID));
+    return S_OK;
+}
diff --git a/dll/win32/browseui/shellfind/CFindFolder.h b/dll/win32/browseui/shellfind/CFindFolder.h
new file mode 100644 (file)
index 0000000..f7590fd
--- /dev/null
@@ -0,0 +1,83 @@
+#pragma once
+
+#include "shellfind.h"
+
+#define SWM_ADD_ITEM (WM_USER + 0)
+#define SWM_UPDATE_STATUS (WM_USER + 1)
+
+class CFindFolder :
+        public CComCoClass<CFindFolder, &CLSID_FindFolder>,
+        public CComObjectRootEx<CComMultiThreadModelNoCS>,
+        public IShellFolder2,
+        public IPersistFolder2
+{
+    // *** IShellFolder2 methods ***
+    STDMETHODIMP GetDefaultSearchGUID(GUID *pguid);
+
+    STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum);
+
+    STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay);
+
+    STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags);
+
+    STDMETHODIMP GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv);
+
+    STDMETHODIMP GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *pDetails);
+
+    STDMETHODIMP MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid);
+
+
+    // *** IShellFolder methods ***
+    STDMETHODIMP ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten,
+                                  PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes);
+
+    STDMETHODIMP EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList);
+
+    STDMETHODIMP BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut);
+
+    STDMETHODIMP BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut);
+
+    STDMETHODIMP CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2);
+
+    STDMETHODIMP CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut);
+
+    STDMETHODIMP GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut);
+
+    STDMETHODIMP GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut,
+                               LPVOID *ppvOut);
+
+    STDMETHODIMP GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET pName);
+
+    STDMETHODIMP SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags,
+                           PITEMID_CHILD *pPidlOut);
+
+private:
+    LPITEMIDLIST m_pidl;
+
+    //// *** IPersistFolder2 methods ***
+    STDMETHODIMP GetCurFolder(LPITEMIDLIST *pidl);
+
+
+    // *** IPersistFolder methods ***
+    STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
+
+
+    // *** IPersist methods ***
+    STDMETHODIMP GetClassID(CLSID *pClassId);
+
+public:
+    DECLARE_REGISTRY_RESOURCEID(IDR_FINDFOLDER)
+
+    DECLARE_NOT_AGGREGATABLE(CFindFolder)
+
+    DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+    BEGIN_COM_MAP(CFindFolder)
+        COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2)
+        COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder)
+        COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2)
+        COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder)
+        COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
+    END_COM_MAP()
+};
+
index 4f031b4..54eb15c 100644 (file)
@@ -10,6 +10,7 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 
 list(APPEND SOURCE
     CSearchBar.cpp
+    CFindFolder.cpp
     shellfind.h)
 
 add_library(shellfind ${SOURCE})
index aaca7a5..b29fc46 100644 (file)
@@ -72,6 +72,7 @@ DEFINE_GUID(CLSID_SH_SearchBand,           0x21569614, 0xB795, 0x46B1, 0x85, 0xF
 DEFINE_GUID(CLSID_FileSearchBand,          0xC4EE31F3, 0x4768, 0x11D2, 0xBE, 0x5C, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA1);
 DEFINE_GUID(CLSID_IE_SearchBand,           0x30D02401, 0x6A81, 0x11D0, 0x82, 0x74, 0x00, 0xC0, 0x4F, 0xD5, 0xAE, 0x38);
 DEFINE_GUID(CLSID_ChannelsBand,            0xEFA24E63, 0xB078, 0x11D0, 0x89, 0xE4, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E);
+DEFINE_GUID(CLSID_FindFolder,              0xE17D4FC0, 0x5564, 0x11D1, 0x83, 0xF2, 0x00, 0xA0, 0xC9, 0x0D, 0xC8, 0x49);
 // missing ResearchBand
 
 DEFINE_GUID(IID_IBandNavigate,             0x3697C30B, 0xCD88, 0x11D0, 0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E);