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.

138 lines
5.4 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Add/Remove Programs Data Source Object
  4. //
  5. //------------------------------------------------------------------------
  6. #ifndef _DATASRC_H_
  7. #define _DATASRC_H_
  8. #include <simpdata.h> // for OLEDBSimpleProvider
  9. #include "mtxarray.h" // for CMtxArray
  10. #include "worker.h"
  11. #include "iface.h" // for IARPSimpleProvider
  12. // The load state progression can be as follows:
  13. //
  14. // LS_NOTSTARTED --> LS_LOADING_SLOWINFO --> LS_DONE
  15. //
  16. // or
  17. //
  18. // LS_NOTSTARTED --> LS_DONE
  19. //
  20. enum LOAD_STATE
  21. {
  22. LS_NOTSTARTED, // OSP is not initialized
  23. LS_LOADING_SLOWINFO, // loading slow info (worker thread)
  24. LS_DONE, // completely finished
  25. };
  26. // Do not build this file if on Win9X or NT4
  27. #ifndef DOWNLEVEL_PLATFORM
  28. //------------------------------------------------------------------------
  29. //
  30. // CDataSrc (ARP Data Source Object)
  31. //
  32. // This is the OSP (OLEDB Simple Provider). It organizes
  33. // the data in matrix form and disseminates the data to the data
  34. // consumer via the OLEDBSimpleProvider interface.
  35. //
  36. //------------------------------------------------------------------------
  37. class CDataSrc : public CWorkerThread,
  38. public OLEDBSimpleProvider,
  39. public IWorkerEvent,
  40. public IARPSimpleProvider,
  41. public ISequentialStream
  42. {
  43. public:
  44. // *** IUnknown ***
  45. virtual STDMETHODIMP_(ULONG) AddRef (void) {return CWorkerThread::AddRef();};
  46. virtual STDMETHODIMP_(ULONG) Release (void) {return CWorkerThread::Release();};
  47. virtual STDMETHODIMP QueryInterface (REFIID riid, LPVOID * ppvObj);
  48. // *** ISequentialStream ***
  49. STDMETHOD(Read) (void * pvData, ULONG cbData, ULONG * pcbRead);
  50. STDMETHOD(Write) (void const * pvData, ULONG cbData, ULONG * pcbWritten);
  51. // *** OLEDBSimpleProvider ***
  52. STDMETHOD(getRowCount) (DBROWCOUNT *pcRows);
  53. STDMETHOD(getColumnCount) (DB_LORDINAL *pcCols);
  54. STDMETHOD(getRWStatus) (DBROWCOUNT iRow, DB_LORDINAL iCol, OSPRW *prwStatus);
  55. STDMETHOD(getVariant) (DBROWCOUNT iRow, DB_LORDINAL iCol, OSPFORMAT format, VARIANT *pVar);
  56. STDMETHOD(setVariant) (DBROWCOUNT iRow, DB_LORDINAL iCol, OSPFORMAT format, VARIANT Var);
  57. STDMETHOD(getLocale) (BSTR *pbstrLocale);
  58. STDMETHOD(deleteRows) (DBROWCOUNT iRow, DBROWCOUNT cRows, DBROWCOUNT *pcRowsDeleted);
  59. STDMETHOD(insertRows) (DBROWCOUNT iRow, DBROWCOUNT cRows, DBROWCOUNT *pcRowsInserted);
  60. STDMETHOD(find) (DBROWCOUNT iRowStart, DB_LORDINAL iCol, VARIANT val,
  61. OSPFIND findFlags, OSPCOMP compType, DBROWCOUNT *piRowFound);
  62. STDMETHOD(addOLEDBSimpleProviderListener)(OLEDBSimpleProviderListener *pospIListener);
  63. STDMETHOD(removeOLEDBSimpleProviderListener)(OLEDBSimpleProviderListener *pospIListener);
  64. STDMETHOD(getEstimatedRows) (DBROWCOUNT *pcRows);
  65. STDMETHOD(isAsync) (BOOL *pbAsync);
  66. STDMETHOD(stopTransfer) (void);
  67. // *** IWorkerEvent methods ***
  68. STDMETHOD(FireOnDataReady) (DBROWCOUNT iRow);
  69. STDMETHOD(FireOnFinished) (void);
  70. STDMETHOD(FireOnDatasetChanged) (void);
  71. // *** IARPSimpleProvider methods ***
  72. STDMETHOD(Initialize) (IShellAppManager * psam, IARPEvent *, DWORD dwEnum);
  73. STDMETHOD(EnumerateItemsAsync) (void);
  74. STDMETHOD(Recalculate) (void);
  75. STDMETHOD(SetSortCriteria) (BSTR bstrSortExpr);
  76. STDMETHOD(SetFilter) (BSTR bstrFilter);
  77. STDMETHOD(Sort) (void);
  78. STDMETHOD(DoCommand) (HWND hwndParent, APPCMD appcmd, DBROWCOUNT iRow);
  79. STDMETHOD(TransferData) (IARPSimpleProvider * parposp);
  80. CDataSrc();
  81. // *** IARPWorker *** (overide)
  82. STDMETHOD(KillWT) (void);
  83. private:
  84. virtual ~CDataSrc();
  85. inline BOOL _IsValidDataRow(DBROWCOUNT iRow);
  86. inline BOOL _IsValidRow(DBROWCOUNT iRow);
  87. inline BOOL _IsValidCol(DB_LORDINAL iCol);
  88. inline BOOL _IsValidCell(DBROWCOUNT iRow, DB_LORDINAL iCol);
  89. DBROWCOUNT _CalcRows(void);
  90. DB_LORDINAL _CalcCols(void);
  91. HRESULT _ApplySortCriteria(BOOL bFireDataSetChanged);
  92. IAppData * _GetAppData(DBROWCOUNT iRow);
  93. // NOTE: this is not used to kill the apps enumeration thread!!
  94. // kills only the thread that get slow appinfo.
  95. HRESULT _KillMtxWorkerThread(void);
  96. HRESULT _EnumAppItems(DWORD dwEnum, LPCWSTR pszCategory);
  97. DWORD _ThreadStartProc();
  98. ULONG _cRef; // interface reference count
  99. LOAD_STATE _loadstate;
  100. DB_LORDINAL _cCols; // count of columns
  101. DBROWCOUNT _cRows; // count of rows
  102. DWORD _dwEnum; // items to enumerate (ENUM_*)
  103. BITBOOL _fSortDirty: 1; // TRUE: the sort criteria is dirty
  104. BITBOOL _fFilterDirty: 1; // TRUE: the sort criteria is dirty
  105. BITBOOL _fAppsEnumed : 1; // TRUE if we have already finished enumerating apps
  106. BITBOOL _fInEnumOp : 1; // TRUE if we are in a enumeraion opertion
  107. IShellAppManager * _psam;
  108. IARPEvent * _parpevt;
  109. IMtxArray * _pmtxarray; // data is stored here
  110. CComBSTR _cbstrSort; // sort string. contains name of column to sort.
  111. CComBSTR _cbstrCategory; // category. used only for published apps.
  112. };
  113. HRESULT CDataSrc_CreateInstance(REFIID riid, LPVOID * ppvObj);
  114. #endif //DOWNLEVEL_PLATFORM
  115. #endif // _DATASRC_H_