Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
14 KiB

  1. #ifndef _INC_DOCFIND
  2. #define _INC_DOCFIND
  3. // for the OLEDB query stuff
  4. #define OLEDBVER 0x0250 // enable ICommandTree interface
  5. #include <oledberr.h>
  6. #include <oledb.h>
  7. #include <cmdtree.h>
  8. #include <oledbdep.h>
  9. #include <query.h>
  10. #include <stgprop.h>
  11. #include <ntquery.h>
  12. #include <idhidden.h>
  13. // reg location where we store bad paths that ci should not have indexed
  14. #define CI_SPECIAL_FOLDERS TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Search\\SpecialFolders")
  15. // Define some options that are used between filter and search code
  16. #define DFOO_INCLUDESUBDIRS 0x0001 // Include sub directories.
  17. #define DFOO_SHOWALLOBJECTS 0x1000 // Show all files
  18. #define DFOO_CASESEN 0x0008 // Do case sensitive search
  19. #define DFOO_SEARCHSYSTEMDIRS 0x0010 // Search into system directories
  20. // Some error happended on the get next file...
  21. #define GNF_ERROR -1
  22. #define GNF_DONE 0
  23. #define GNF_MATCH 1
  24. #define GNF_NOMATCH 2
  25. #define GNF_ASYNC 3
  26. // Define a FACILITY That we can check errors for...
  27. #define FACILITY_SEARCHCOMMAND 99
  28. #undef INTERFACE
  29. #define INTERFACE IFindEnum
  30. DECLARE_INTERFACE_(IFindEnum, IUnknown)
  31. {
  32. // IUnknown
  33. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void ** ppv) PURE;
  34. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  35. STDMETHOD_(ULONG,Release) (THIS) PURE;
  36. // IFindEnum
  37. STDMETHOD(Next)(THIS_ LPITEMIDLIST *ppidl, int *pcObjectSearched, int *pcFoldersSearched, BOOL *pfContinue, int *pState) PURE;
  38. STDMETHOD (Skip)(THIS_ int celt) PURE;
  39. STDMETHOD (Reset)(THIS) PURE;
  40. STDMETHOD (StopSearch)(THIS) PURE;
  41. STDMETHOD_(BOOL,FQueryIsAsync)(THIS) PURE;
  42. STDMETHOD (GetAsyncCount)(THIS_ DBCOUNTITEM *pdwTotalAsync, int *pnPercentComplete, BOOL *pfQueryDone) PURE;
  43. STDMETHOD (GetItemIDList)(THIS_ UINT iItem, LPITEMIDLIST *ppidl) PURE;
  44. STDMETHOD (GetItemID)(THIS_ UINT iItem, DWORD *puWorkID) PURE;
  45. STDMETHOD (SortOnColumn)(THIS_ UINT iCol, BOOL fAscending) PURE;
  46. };
  47. // We overloaded Async case when we are in mixed (some async some sync mode)
  48. #define DF_QUERYISMIXED ((BOOL)42)
  49. typedef interface IFindFolder IFindFolder;
  50. #undef INTERFACE
  51. #define INTERFACE IFindFilter
  52. DECLARE_INTERFACE_(IFindFilter, IUnknown)
  53. {
  54. // IUnknown
  55. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void ** ppv) PURE;
  56. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  57. STDMETHOD_(ULONG,Release) (THIS) PURE;
  58. // IFindFilter
  59. STDMETHOD(GetStatusMessageIndex)(THIS_ UINT uContext, UINT *puMsgIndex) PURE;
  60. STDMETHOD(GetFolderMergeMenuIndex)(THIS_ UINT *puBGMainMergeMenu, UINT *puBGPopupMergeMenu) PURE;
  61. STDMETHOD(FFilterChanged)(THIS) PURE;
  62. STDMETHOD(GenerateTitle)(THIS_ LPTSTR *ppszTile, BOOL fFileName) PURE;
  63. STDMETHOD(PrepareToEnumObjects)(THIS_ HWND hwnd, DWORD *pdwFlags) PURE;
  64. STDMETHOD(ClearSearchCriteria)(THIS) PURE;
  65. STDMETHOD(EnumObjects)(THIS_ IShellFolder *psf, LPCITEMIDLIST pidlStart,
  66. DWORD grfFlags, int iColSort, LPTSTR pszProgressText, IRowsetWatchNotify *prwn,
  67. IFindEnum **ppdfenum) PURE;
  68. STDMETHOD(GetColumnsFolder)(THIS_ IShellFolder2 **ppsf) PURE;
  69. STDMETHOD_(BOOL,MatchFilter)(THIS_ IShellFolder *psf, LPCITEMIDLIST pidl) PURE;
  70. STDMETHOD(SaveCriteria)(THIS_ IStream * pstm, WORD fCharType) PURE;
  71. STDMETHOD(RestoreCriteria)(THIS_ IStream * pstm, int cCriteria, WORD fCharType) PURE;
  72. STDMETHOD(DeclareFSNotifyInterest)(THIS_ HWND hwndDlg, UINT uMsg) PURE;
  73. STDMETHOD(GetColSaveStream)(THIS_ WPARAM wParam, IStream **ppstm) PURE;
  74. STDMETHOD(GenerateQueryRestrictions)(THIS_ LPWSTR *ppwszQuery, DWORD *pdwGQRFlags) PURE;
  75. STDMETHOD(ReleaseQuery)(THIS) PURE;
  76. STDMETHOD(UpdateField)(THIS_ LPCWSTR pszField, VARIANT vValue) PURE;
  77. STDMETHOD(ResetFieldsToDefaults)(THIS) PURE;
  78. STDMETHOD(GetItemContextMenu)(THIS_ HWND hwndOwner, IFindFolder* pdfFolder, IContextMenu** ppcm) PURE;
  79. STDMETHOD(GetDefaultSearchGUID)(THIS_ IShellFolder2 *psf2, LPGUID lpGuid) PURE;
  80. STDMETHOD(EnumSearches)(THIS_ IShellFolder2 *psf2, LPENUMEXTRASEARCH *ppenum) PURE;
  81. STDMETHOD(GetSearchFolderClassId)(THIS_ LPGUID lpGuid) PURE;
  82. STDMETHOD(GetNextConstraint)(THIS_ VARIANT_BOOL fReset, BSTR *pName, VARIANT *pValue, VARIANT_BOOL *pfFound) PURE;
  83. STDMETHOD(GetQueryLanguageDialect)(THIS_ ULONG * pulDialect);
  84. STDMETHOD(GetWarningFlags)(THIS_ DWORD *pdwWarningFlags);
  85. };
  86. // Define the flags that GenerateQueryRestrictions may return
  87. typedef enum {
  88. GQR_MAKES_USE_OF_CI = 0x0001, // some constraint makes resonable use of Content index
  89. GQR_REQUIRES_CI = 0x0002, // The query requires the CI to work
  90. GQR_BYBASS_CI = 0x0004, // The query should bybass CI.
  91. } GQR_FLAGS;
  92. // Docfind UI warning bits.
  93. #define DFW_DEFAULT 0x00000000
  94. #define DFW_IGNORE_CISCOPEMISMATCH 0x00000001 // CI query requested search scopes beyond indexed scopes
  95. #define DFW_IGNORE_INDEXNOTCOMPLETE 0x00000002 // ci not done indexing
  96. #define ESFITEM_ICONOVERLAYSET 0x00000001
  97. typedef struct
  98. {
  99. DWORD dwMask;
  100. DWORD dwState; // State of the item;
  101. int iIcon;
  102. ITEMIDLIST idl; // find pidl bits (with hidden stuff embedded), variable length
  103. } FIND_ITEM;
  104. // Currently the state above is LVIS_SELECTED and LVIS_FOCUSED (low two bits)
  105. // Add a bit to use in the processing of updatedir
  106. #define CDFITEM_STATE_MAYBEDELETE 0x80000000L
  107. #define CDFITEM_STATE_MASK (LVIS_SELECTED) // Which states we will hav LV have us track
  108. // Definition of the data items that we cache per directory.
  109. typedef struct
  110. {
  111. IShellFolder * psf; // Cache of MRU items
  112. BOOL fUpdateDir:1; // Was this node touched by an updatedir...
  113. BOOL fDeleteDir:1; // Was this directory removed from the list?
  114. // Allocate the pidl at end as variable length
  115. ITEMIDLIST idl; // the pidl
  116. } FIND_FOLDER_ITEM;
  117. #pragma pack(1)
  118. typedef struct
  119. {
  120. HIDDENITEMID hid;
  121. WORD iFolder; // index to the folder DPA
  122. WORD wFlags;
  123. UINT uRow; // Which row in the CI;
  124. DWORD dwItemID; // Only used for Async support...
  125. ULONG ulRank; // The rank returned by CI...
  126. ITEMIDLIST idlParent; // the pidl of the folder this thing came from (fully qualified!)
  127. } HIDDENDOCFINDDATA;
  128. #pragma pack()
  129. #define DFDF_NONE 0x0000
  130. #define DFDF_EXTRADATA 0x0001
  131. typedef UNALIGNED HIDDENDOCFINDDATA * PHIDDENDOCFINDDATA;
  132. typedef const UNALIGNED HIDDENDOCFINDDATA * PCHIDDENDOCFINDDATA;
  133. //
  134. // Define structure that will be saved out to disk.
  135. //
  136. #define DOCFIND_SIG (TEXT('D') | (TEXT('F') << 8))
  137. typedef struct
  138. {
  139. WORD wSig; // Signature
  140. WORD wVer; // Version
  141. DWORD dwFlags; // Flags that controls the sort
  142. WORD wSortOrder; // Current sort order
  143. WORD wcbItem; // Size of the fixed portion of each item.
  144. DWORD oCriteria; // Offset to criterias in list
  145. long cCriteria; // Count of Criteria
  146. DWORD oResults; // Starting location of results in file
  147. long cResults; // Count of items that have been saved to file
  148. UINT ViewMode; // The view mode of the file...
  149. } DFHEADER_WIN95;
  150. typedef struct
  151. {
  152. WORD wSig; // Signature
  153. WORD wVer; // Version
  154. DWORD dwFlags; // Flags that controls the sort
  155. WORD wSortOrder; // Current sort order
  156. WORD wcbItem; // Size of the fixed portion of each item.
  157. DWORD oCriteria; // Offset to criterias in list
  158. long cCriteria; // Count of Criteria
  159. DWORD oResults; // Starting location of results in file
  160. long cResults; // Count of items that have been saved to file
  161. UINT ViewMode; // The view mode of the file...
  162. DWORD oHistory; // IPersistHistory::Save offset
  163. } DFHEADER;
  164. // The check in Win95/NT4 would fail to read the DFHEADER structure if
  165. // the wVer field was > 3, which is unfortunate since the DFHEADER struct is
  166. // backwards compiatible (that's why it uses offsets). So we either
  167. // go through the pain of revving the stream format in a backwards
  168. // compatible way (not impossible, just a pain in the brain), or simply
  169. // rev the version and add our new fields and call the Win95/NT4 problem
  170. // a bug and punt. I'm leaning towards "bug" as this is a rarely used feature.
  171. #define DF_CURFILEVER_WIN95 3
  172. #define DF_CURFILEVER 4
  173. // define the format of the column information.
  174. typedef struct
  175. {
  176. WORD wNum; // Criteria number (cooresponds to dlg item id)
  177. WORD cbText; // size of text including null char (DavePl: code using this now assumes byte count)
  178. } DFCRITERIA;
  179. // Formats for saving find criteria.
  180. #define DFC_FMT_UNICODE 1
  181. #define DFC_FMT_ANSI 2
  182. // This is a subset of fileinfo structure
  183. typedef struct
  184. {
  185. WORD flags; // FIF_ bits
  186. WORD timeLastWrite;
  187. WORD dateLastWrite;
  188. WORD dummy; // 16/32 bit compat.
  189. //the compiler adds this padding
  190. // remove and use if needed
  191. DWORD dwSize; // size of the file
  192. WORD cbPath; // size of the text (0 implies use previous files)
  193. WORD cbName; // Size of name including NULL.
  194. } DFITEM;
  195. STDAPI CreateNameSpaceFindFilter(IFindFilter **ppff);
  196. STDAPI_(BOOL) SetupWildCardingOnFileSpec(LPTSTR pszSpecIn, LPTSTR * pszSpecOut);
  197. STDAPI CreateDefaultComputerFindFilter(IFindFilter **ppff);
  198. STDAPI CreateOleDBEnum(
  199. IFindFilter * pdfff,
  200. IShellFolder *psf,
  201. LPWSTR *apwszPaths,
  202. UINT *pcPaths,
  203. DWORD grfFlags,
  204. int iColSort,
  205. LPTSTR pszProgressText,
  206. IRowsetWatchNotify *prwn,
  207. IFindEnum **ppdfenum);
  208. #undef INTERFACE
  209. #define INTERFACE IFindControllerNotify
  210. // This interface is used to let the callback class talk to the class that is actually controlling
  211. // the queries and the like.
  212. DECLARE_INTERFACE_(IFindControllerNotify, IUnknown)
  213. {
  214. // IUnknown
  215. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void ** ppv) PURE;
  216. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  217. STDMETHOD_(ULONG,Release) (THIS) PURE;
  218. // *** IFindControllerNotify methods ***
  219. STDMETHOD(DoSortOnColumn)(THIS_ UINT iCol, BOOL fSameCol) PURE;
  220. STDMETHOD(SaveSearch)(THIS) PURE;
  221. STDMETHOD(RestoreSearch)(THIS) PURE;
  222. STDMETHOD(StopSearch)(THIS) PURE;
  223. STDMETHOD(GetItemCount)(THIS_ UINT *pcItems) PURE;
  224. STDMETHOD(SetItemCount)(THIS_ UINT cItems) PURE;
  225. STDMETHOD(ViewDestroyed)(THIS) PURE;
  226. };
  227. typedef struct {
  228. LPITEMIDLIST pidlSaveFile; // [in, out] most recent pidl saved to
  229. DWORD dwFlags; // [in, out] current flag state
  230. int SortMode; // [in] current sort mode
  231. } DFBSAVEINFO;
  232. #undef INTERFACE
  233. #define INTERFACE IFindFolder
  234. DECLARE_INTERFACE_(IFindFolder, IUnknown)
  235. {
  236. // IUnknown
  237. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void ** ppv) PURE;
  238. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  239. STDMETHOD_(ULONG,Release) (THIS) PURE;
  240. // IFindFolder
  241. STDMETHOD(GetFindFilter)(THIS_ IFindFilter **pdfff) PURE;
  242. STDMETHOD(AddPidl)(THIS_ int i, LPCITEMIDLIST pidl, DWORD dwItemID, FIND_ITEM **ppItem) PURE;
  243. STDMETHOD(GetItem)(THIS_ int iItem, FIND_ITEM **ppItem) PURE;
  244. STDMETHOD(DeleteItem)(THIS_ int iItem) PURE;
  245. STDMETHOD(GetItemCount)(THIS_ INT *pcItems) PURE;
  246. STDMETHOD(ValidateItems)(THIS_ IUnknown *punk, int iItemFirst, int cItems, BOOL bSearchComplete) PURE;
  247. STDMETHOD(GetFolderListItemCount)(THIS_ INT *pcCount) PURE;
  248. STDMETHOD(GetFolderListItem)(THIS_ int iItem, FIND_FOLDER_ITEM **ppItem) PURE;
  249. STDMETHOD(GetFolder)(THIS_ int iFolder, REFIID riid, void **ppv) PURE;
  250. STDMETHOD_(UINT,GetFolderIndex)(THIS_ LPCITEMIDLIST pidl) PURE;
  251. STDMETHOD(SetItemsChangedSinceSort)(THIS) PURE;
  252. STDMETHOD(ClearItemList)(THIS) PURE;
  253. STDMETHOD(ClearFolderList)(THIS) PURE;
  254. STDMETHOD(AddFolder)(THIS_ LPITEMIDLIST pidl, BOOL fCheckForDup, int *piFolder) PURE;
  255. STDMETHOD(SetAsyncEnum)(THIS_ IFindEnum *pdfEnumAsync) PURE;
  256. STDMETHOD(GetAsyncEnum)(THIS_ IFindEnum **ppdfEnumAsync) PURE;
  257. STDMETHOD(SetAsyncCount)(THIS_ DBCOUNTITEM cCount) PURE;
  258. STDMETHOD(CacheAllAsyncItems)(THIS) PURE;
  259. STDMETHOD_(BOOL,AllAsyncItemsCached)(THIS) PURE;
  260. STDMETHOD(ClearSaveStateList)(THIS) PURE;
  261. STDMETHOD(GetStateFromSaveStateList)(THIS_ DWORD dwItemID, DWORD *pdwState) PURE;
  262. STDMETHOD(MapToSearchIDList)(LPCITEMIDLIST pidl, BOOL fMapToReal, LPITEMIDLIST *ppidl) PURE;
  263. STDMETHOD(GetParentsPIDL)(LPCITEMIDLIST pidl, LPITEMIDLIST *ppidlParent) PURE;
  264. STDMETHOD(RememberSelectedItems)(THIS) PURE;
  265. STDMETHOD(SetControllerNotifyObject)(IFindControllerNotify *pdfcn) PURE;
  266. STDMETHOD(GetControllerNotifyObject)(IFindControllerNotify **ppdfcn) PURE;
  267. STDMETHOD(SaveFolderList)(THIS_ IStream *pstm) PURE;
  268. STDMETHOD(RestoreFolderList)(THIS_ IStream *pstm) PURE;
  269. STDMETHOD(SaveItemList)(THIS_ IStream *pstm) PURE;
  270. STDMETHOD(RestoreItemList)(THIS_ IStream *pstm, int *pcItems) PURE;
  271. STDMETHOD(RestoreSearchFromSaveFile)(LPCITEMIDLIST pidlSaveFile, IShellFolderView *psfv) PURE;
  272. STDMETHOD_(BOOL,HandleUpdateDir)(LPCITEMIDLIST pidl, BOOL fCheckSubDirs) PURE;
  273. STDMETHOD_(void,HandleRMDir)(IShellFolderView *psfv, LPCITEMIDLIST pidl) PURE;
  274. STDMETHOD_(void,UpdateOrMaybeAddPidl)(IShellFolderView *psfv, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlOld) PURE;
  275. STDMETHOD_(void,Save)(IFindFilter* pdfff, HWND hwnd, DFBSAVEINFO * pSaveInfo, IShellView* psv, IUnknown * pObject) PURE;
  276. STDMETHOD(OpenContainingFolder)(IUnknown *punkSite) PURE;
  277. STDMETHOD(AddDataToIDList)(LPCITEMIDLIST pidl, int iFolder, LPCITEMIDLIST pidlFolder, UINT uFlags, UINT uRow, DWORD dwItemID, ULONG ulRank, LPITEMIDLIST *ppidl) PURE;
  278. };
  279. STDAPI CFindItem_Create(HWND hwnd, IFindFolder *pdfFolder, IContextMenu **ppcm);
  280. EXTERN_C const GUID IID_IFindFolder;
  281. EXTERN_C const GUID IID_IFindFilter;
  282. EXTERN_C const GUID IID_IFindControllerNotify;
  283. #endif // !_INC_DOCFIND