mirror of
https://github.com/reactos/reactos.git
synced 2024-11-23 11:33:31 +08:00
[SHELLFIND] Add search command events
This commit is contained in:
parent
2f3db8d9a3
commit
41d7b3700d
@ -1,11 +1,5 @@
|
||||
/*
|
||||
* 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"
|
||||
#include <exdispid.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(shellfind);
|
||||
|
||||
@ -88,6 +82,7 @@ struct _SearchData
|
||||
HWND hwnd;
|
||||
HANDLE hStopEvent;
|
||||
SearchStart *pSearchParams;
|
||||
CFindFolder *pFindFolder;
|
||||
};
|
||||
|
||||
static LPCSTR WINAPI StrStrNA(LPCSTR lpFirst, LPCSTR lpSrch, UINT cchMax)
|
||||
@ -210,20 +205,40 @@ static VOID RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
|
||||
FindClose(hFindFile);
|
||||
}
|
||||
|
||||
static DWORD WINAPI _SearchThreadProc(LPVOID lpParameter)
|
||||
DWORD WINAPI CFindFolder::_SearchThreadProc(LPVOID lpParameter)
|
||||
{
|
||||
_SearchData *data = static_cast<_SearchData*>(lpParameter);
|
||||
|
||||
SearchStart* params = (SearchStart *) data->pSearchParams;
|
||||
|
||||
data->pFindFolder->NotifyConnections(DISPID_SEARCHSTART);
|
||||
|
||||
RecursiveFind(params->szPath, data);
|
||||
|
||||
data->pFindFolder->NotifyConnections(DISPID_SEARCHCOMPLETE);
|
||||
|
||||
SHFree(params);
|
||||
SHFree(lpParameter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CFindFolder::NotifyConnections(DISPID id)
|
||||
{
|
||||
DISPPARAMS dispatchParams = {0};
|
||||
CComDynamicUnkArray &subscribers =
|
||||
IConnectionPointImpl<CFindFolder, &DIID_DSearchCommandEvents>::m_vec;
|
||||
for (IUnknown** pSubscriber = subscribers.begin(); pSubscriber < subscribers.end(); pSubscriber++)
|
||||
{
|
||||
if (!*pSubscriber)
|
||||
continue;
|
||||
|
||||
CComPtr<IDispatch> pDispatch;
|
||||
HRESULT hResult = (*pSubscriber)->QueryInterface(IID_PPV_ARG(IDispatch, &pDispatch));
|
||||
if (!FAILED_UNEXPECTEDLY(hResult))
|
||||
pDispatch->Invoke(id, GUID_NULL, 0, DISPATCH_METHOD, &dispatchParams, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CFindFolder::StartSearch(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
||||
{
|
||||
if (!lParam)
|
||||
|
@ -12,6 +12,8 @@ class CFindFolder :
|
||||
public IShellFolder2,
|
||||
public IPersistFolder2,
|
||||
public IShellFolderViewCB,
|
||||
public IConnectionPointContainerImpl<CFindFolder>,
|
||||
public IConnectionPointImpl<CFindFolder, &DIID_DSearchCommandEvents>,
|
||||
public IContextMenuCB
|
||||
{
|
||||
// *** IShellFolder2 methods ***
|
||||
@ -68,6 +70,9 @@ private:
|
||||
CComPtr<IShellBrowser> m_shellBrowser;
|
||||
HANDLE m_hStopEvent;
|
||||
|
||||
void NotifyConnections(DISPID id);
|
||||
static DWORD WINAPI SearchThreadProc(LPVOID lpParameter);
|
||||
|
||||
//// *** IPersistFolder2 methods ***
|
||||
STDMETHODIMP GetCurFolder(LPITEMIDLIST *pidl);
|
||||
|
||||
@ -95,6 +100,10 @@ public:
|
||||
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
BEGIN_CONNECTION_POINT_MAP(CFindFolder)
|
||||
CONNECTION_POINT_ENTRY(DIID_DSearchCommandEvents)
|
||||
END_CONNECTION_POINT_MAP()
|
||||
|
||||
BEGIN_MSG_MAP(CFindFolder)
|
||||
MESSAGE_HANDLER(WM_SEARCH_START, StartSearch)
|
||||
MESSAGE_HANDLER(WM_SEARCH_ADD_RESULT, AddResult)
|
||||
@ -108,6 +117,7 @@ public:
|
||||
COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IConnectionPointContainer, IConnectionPointContainer)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IContextMenuCB, IContextMenuCB)
|
||||
END_COM_MAP()
|
||||
};
|
||||
|
@ -1043,4 +1043,16 @@ coclass SearchAssistantOC {
|
||||
[default, source] dispinterface _SearchAssistantEvents;
|
||||
}
|
||||
|
||||
[
|
||||
uuid(60890160-69f0-11d1-b758-00a0c90564fe),
|
||||
hidden
|
||||
]
|
||||
dispinterface DSearchCommandEvents {
|
||||
properties:
|
||||
methods:
|
||||
[id(DISPID_SEARCHSTART)] void SearchStart();
|
||||
[id(DISPID_SEARCHCOMPLETE)] void SearchComplete();
|
||||
[id(DISPID_SEARCHABORT)] void SearchAbort();
|
||||
}
|
||||
|
||||
} /* library */
|
||||
|
@ -169,4 +169,8 @@
|
||||
#define DISPID_EXPAND 25
|
||||
#define DISPID_UNSELECTALL 26
|
||||
|
||||
#define DISPID_SEARCHSTART 1
|
||||
#define DISPID_SEARCHCOMPLETE 2
|
||||
#define DISPID_SEARCHABORT 3
|
||||
|
||||
#endif /* EXDISPID_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user