Source code of Windows XP (NT5)
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.

214 lines
8.0 KiB

  1. #ifndef __query_h
  2. #define __query_h
  3. //
  4. // Resource IDs used for the menus
  5. //
  6. // File menu
  7. #define DSQH_FILE_CONTEXT_FIRST (CQID_MINHANDLERMENUID + 0x0000)
  8. #define DSQH_FILE_CONTEXT_LAST (CQID_MINHANDLERMENUID + 0x0fff)
  9. #define DSQH_FILE_OPENCONTAINER (CQID_MINHANDLERMENUID + 0x1001)
  10. #define DSQH_FILE_PROPERTIES (CQID_MINHANDLERMENUID + 0x1002)
  11. #define DSQH_FILE_CREATESHORTCUT (CQID_MINHANDLERMENUID + 0x1003)
  12. #define DSQH_FILE_SAVEQUERY (CQID_MINHANDLERMENUID + 0x1004)
  13. // Edit menu
  14. #define DSQH_EDIT_SELECTALL (CQID_MINHANDLERMENUID + 0x1100)
  15. #define DSQH_EDIT_INVERTSELECTION (CQID_MINHANDLERMENUID + 0x1101)
  16. // View menu
  17. #define DSQH_VIEW_FILTER (CQID_MINHANDLERMENUID + 0x1200)
  18. #define DSQH_VIEW_LARGEICONS (CQID_MINHANDLERMENUID + 0x1201)
  19. #define DSQH_VIEW_SMALLICONS (CQID_MINHANDLERMENUID + 0x1202)
  20. #define DSQH_VIEW_LIST (CQID_MINHANDLERMENUID + 0x1203)
  21. #define DSQH_VIEW_DETAILS (CQID_MINHANDLERMENUID + 0x1204)
  22. #define DSQH_VIEW_ARRANGEICONS (CQID_MINHANDLERMENUID + 0x1205)
  23. #define DSQH_VIEW_REFRESH (CQID_MINHANDLERMENUID + 0x1206)
  24. #define DSQH_VIEW_PICKCOLUMNS (CQID_MINHANDLERMENUID + 0x1207)
  25. #define DSQH_VIEW_ARRANGEFIRST (CQID_MINHANDLERMENUID + 0x1280)
  26. #define DSQH_VIEW_ARRANGELAST (CQID_MINHANDLERMENUID + 0x12FF)
  27. // Help menu
  28. #define DSQH_HELP_CONTENTS (CQID_MINHANDLERMENUID + 0x1300)
  29. #define DSQH_HELP_WHATISTHIS (CQID_MINHANDLERMENUID + 0x1301)
  30. #define DSQH_HELP_ABOUT (CQID_MINHANDLERMENUID + 0x1302)
  31. // Extra background verbs
  32. #define DSQH_BG_SELECT (CQID_MINHANDLERMENUID + 0x1400)
  33. // Filter verbs
  34. #define DSQH_CLEARFILTER (CQID_MINHANDLERMENUID + 0x1500)
  35. #define DSQH_CLEARALLFILTERS (CQID_MINHANDLERMENUID + 0x1501)
  36. //
  37. // CDsQueryHandler global information
  38. //
  39. //
  40. // The bg thread communicates with the view using the following messages
  41. //
  42. #define DSQVM_ADDRESULTS (WM_USER+0) // lParam = HDPA containing results
  43. #define DSQVM_FINISHED (WM_USER+1) // lParam = fMaxResult
  44. //
  45. // Column DSA contains these items
  46. //
  47. #define PROPERTY_ISUNDEFINED 0x00000000 // property is undefined
  48. #define PROPERTY_ISUNKNOWN 0x00000001 // only operator is exacly
  49. #define PROPERTY_ISSTRING 0x00000002 // starts with, ends with, is exactly, not equal
  50. #define PROPERTY_ISNUMBER 0x00000003 // greater, less, equal, not equal
  51. #define PROPERTY_ISBOOL 0x00000004 // equal, not equal
  52. #define DEFAULT_WIDTH 20
  53. #define DEFAULT_WIDTH_DESCRIPTION 40
  54. typedef struct
  55. {
  56. INT iPropertyType; // type of property
  57. union
  58. {
  59. LPTSTR pszText; // iPropertyType == PROPERTY_ISSTRING
  60. INT iValue; // iPropertyType == PROPERTY_ISNUMBER
  61. };
  62. } COLUMNVALUE, * LPCOLUMNVALUE;
  63. typedef struct
  64. {
  65. BOOL fHasColumnHandler:1; // column handler specified?
  66. LPWSTR pProperty; // property name
  67. LPTSTR pHeading; // column heading
  68. INT cx; // width of column (% of view)
  69. INT fmt; // formatting information
  70. INT iPropertyType; // type of property
  71. UINT idOperator; // currently selected operator
  72. COLUMNVALUE filter; // the filter applied
  73. CLSID clsidColumnHandler; // CLSID and IDsQueryColumnHandler objects
  74. IDsQueryColumnHandler* pColumnHandler;
  75. } COLUMN, * LPCOLUMN;
  76. typedef struct
  77. {
  78. LPWSTR pObjectClass; // object class (UNICODE)
  79. LPWSTR pPath; // directory object (UNICODE)
  80. INT iImage; // image / == -1 if none
  81. BOOL fIsContainer:1; // object is a container (used later)
  82. COLUMNVALUE aColumn[1]; // column data
  83. } QUERYRESULT, * LPQUERYRESULT;
  84. STDAPI CDsQuery_CreateInstance(IUnknown* punkOuter, IUnknown** ppunk, LPCOBJECTINFO poi);
  85. //
  86. // The outside world commmunicates with the thread using messages (sent via PostThreadMessage).
  87. //
  88. #define RVTM_FIRST (WM_USER)
  89. #define RVTM_LAST (WM_USER+32)
  90. #define RVTM_STOPQUERY (WM_USER) // wParam = 0, lParam =0
  91. #define RVTM_REFRESH (WM_USER+1) // wParam = 0, lParam = 0
  92. #define RVTM_SETCOLUMNTABLE (WM_USER+2) // wParam = 0, lParam = HDSA columns
  93. //
  94. // THREADINITDATA strucutre, this is passed when the query thread is being
  95. // created, it contains all the parameters required to issue the query,
  96. // and populate the view.
  97. //
  98. typedef struct
  99. {
  100. DWORD dwReference; // reference value for query
  101. LPWSTR pQuery; // base filter to be applied
  102. LPWSTR pScope; // scope to search
  103. LPWSTR pServer; // server to target
  104. LPWSTR pUserName; // user name and password to authenticate with
  105. LPWSTR pPassword;
  106. BOOL fShowHidden:1; // show hidden objects in results
  107. HWND hwndView; // handle of our result view to be filled
  108. HDSA hdsaColumns; // column table
  109. } THREADINITDATA, * LPTHREADINITDATA;
  110. //
  111. // Query thread, this is passed the THREADINITDATA structure
  112. //
  113. DWORD WINAPI QueryThread(LPVOID pThreadParams);
  114. VOID QueryThread_FreeThreadInitData(LPTHREADINITDATA* ppTID);
  115. STDAPI CQueryThreadCH_CreateInstance(IUnknown* punkOuter, IUnknown** ppunk, LPCOBJECTINFO poi);
  116. //
  117. // Scope logic
  118. //
  119. #define OBJECT_NAME_FROM_SCOPE(pDsScope)\
  120. ((LPWSTR)ByteOffset(pDsScope, pDsScope->dwOffsetADsPath))
  121. #define OBJECT_CLASS_FROM_SCOPE(pDsScope)\
  122. ((LPWSTR)(!pDsScope->dwOffsetClass ? NULL : ByteOffset(pDsScope, pDsScope->dwOffsetClass)))
  123. typedef struct
  124. {
  125. CQSCOPE cq; // all scopes must have this as a header
  126. INT iIndent; // indent
  127. DWORD dwOffsetADsPath; // offset to scope
  128. DWORD dwOffsetClass; // offset to class of scope / = 0 if none
  129. WCHAR szStrings[1]; // string data (all UNICODE)
  130. } DSQUERYSCOPE, * LPDSQUERYSCOPE;
  131. typedef struct
  132. {
  133. HWND hwndFrame; // frame window to display message boxes on
  134. LPWSTR pDefaultScope; // scope for this object
  135. LPWSTR pServer; // server to target
  136. LPWSTR pUserName; // user name and password to authenticate with
  137. LPWSTR pPassword;
  138. } SCOPETHREADDATA, * LPSCOPETHREADDATA;
  139. #define GC_OBJECTCLASS L"domainDNS" // objectClass used for GC objects
  140. HRESULT GetGlobalCatalogPath(LPCWSTR pszServer, LPWSTR pszPath, INT cchBuffer);
  141. HRESULT AddScope(HWND hwndFrame, INT index, INT iIndent, LPWSTR pPath, LPWSTR pObjectClass, BOOL fSelect);
  142. HRESULT AllocScope(LPCQSCOPE* ppScope, INT iIndent, LPWSTR pPath, LPWSTR pObjectClass);
  143. DWORD WINAPI AddScopesThread(LPVOID pThreadParams);
  144. //
  145. // helpers for all to use
  146. //
  147. VOID MergeMenu(HMENU hMenu, HMENU hMenuToInsert, INT iIndex);
  148. HRESULT BindToPath(LPWSTR pszPath, REFIID riid, LPVOID* ppObject);
  149. INT FreeQueryResultCB(LPVOID pItem, LPVOID pData);
  150. VOID FreeQueryResult(LPQUERYRESULT pResult, INT cColumns);
  151. VOID FreeColumnValue(LPCOLUMNVALUE pColumnValue);
  152. INT FreeColumnCB(LPVOID pItem, LPVOID pData);
  153. VOID FreeColumn(LPCOLUMN pColumn);
  154. DWORD PropertyIsFromAttribute(LPCWSTR pszAttributeName, IDsDisplaySpecifier *pdds);
  155. BOOL MatchPattern(LPTSTR pString, LPTSTR pPattern);
  156. HRESULT EnumClassAttributes(IDsDisplaySpecifier *pdds, LPCWSTR pszObjectClass, LPDSENUMATTRIBUTES pcbEnum, LPARAM lParam);
  157. HRESULT GetFriendlyAttributeName(IDsDisplaySpecifier *pdds, LPCWSTR pszObjectClass, LPCWSTR pszAttributeName, LPWSTR pszBuffer, UINT cch);
  158. HRESULT GetColumnHandlerFromProperty(LPCOLUMN pColumn, LPWSTR pProperty);
  159. HRESULT GetPropertyFromColumn(LPWSTR* ppProperty, LPCOLUMN pColumn);
  160. STDAPI ADsPathToIdList(LPITEMIDLIST* ppidl, LPWSTR pPath, LPWSTR pObjectClass, BOOL fRelative);
  161. #endif