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.

162 lines
6.3 KiB

  1. #ifndef _DVTASKS_H
  2. #define _DVTASKS_H
  3. #include <runtask.h>
  4. class CDefView;
  5. class CGetIconTask;
  6. class CStatusBarAndInfoTipTask;
  7. class CDUIInfotipTask;
  8. class CTestCacheTask;
  9. class CBackgroundInfoTip; // Used for the background processing of InfoTips
  10. STDAPI CCategoryTask_Create(CDefView *pView, LPCITEMIDLIST pidl, UINT uId, IRunnableTask **ppTask);
  11. STDAPI CBkgrndEnumTask_CreateInstance(CDefView *pdsv, IEnumIDList * peunk, HDPA hdpaNew, BOOL fRefresh, IRunnableTask **ppTask);
  12. STDAPI CIconOverlayTask_CreateInstance(CDefView *pdsv, LPCITEMIDLIST pdl, int iList, IRunnableTask **ppTask);
  13. STDAPI CExtendedColumnTask_CreateInstance(CDefView *pdsv, LPCITEMIDLIST pidl, UINT uId, int fmt, UINT uiColumn, IRunnableTask **ppTask);
  14. STDAPI CFileTypePropertiesTask_CreateInstance(CDefView *pdsv, LPCITEMIDLIST pidl, UINT uMaxPropertiesToShow, UINT uId, IRunnableTask **ppTask);
  15. STDAPI CStatusBarAndInfoTipTask_CreateInstance(LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidl, UINT uMsg, int nMsgParam, CBackgroundInfoTip *pbit, HWND hwnd, IShellTaskScheduler2* pScheduler, CStatusBarAndInfoTipTask ** ppTask);
  16. STDAPI CDUIInfotipTask_CreateInstance(CDefView *pDefView, HWND hwndContaining, UINT uToolID, LPCITEMIDLIST pidl, CDUIInfotipTask **ppTask);
  17. STDAPI CTestCacheTask_Create(DWORD dwTaskID, CDefView *pView,
  18. IExtractImage * pExtract, LPCWSTR pszPath, FILETIME ftDateStamp,
  19. LPCITEMIDLIST pidl, int iItem, DWORD dwFlags, DWORD dwPriority,
  20. BOOL fAsync, BOOL fBackground, BOOL fForce, CTestCacheTask **ppTask);
  21. HRESULT CDiskCacheTask_Create(DWORD dwTaskID, CDefView *pView,
  22. DWORD dwPriority, int iItem, LPCITEMIDLIST pidl, LPCWSTR pszPath,
  23. FILETIME ftDateStamp, IExtractImage *pExtract, DWORD dwFlags, IRunnableTask **ppTask);
  24. HRESULT CExtractImageTask_Create(DWORD dwTaskID, CDefView* pView,
  25. IExtractImage *pExtract, LPCWSTR pszPath, LPCITEMIDLIST pidl,
  26. FILETIME fNewTimeStamp, int iItem,
  27. DWORD dwFlags, DWORD dwPriority, IRunnableTask **ppTask);
  28. HRESULT CWriteCacheTask_Create(DWORD dwTaskID, CDefView *pView,
  29. LPCWSTR pszFullPath, FILETIME ftTimeStamp, HBITMAP hImage, IRunnableTask **ppTask);
  30. HRESULT CReadAheadTask_Create(CDefView *pView, IRunnableTask **ppTask);
  31. HRESULT CGetCommandStateTask_Create(CDefView *pView, IUICommand *puiCommand,IShellItemArray *psiItemArray, IRunnableTask **ppTask);
  32. class CTestCacheTask : public CRunnableTask
  33. {
  34. public:
  35. CTestCacheTask(DWORD dwTaskID, CDefView *pView, IExtractImage *pExtract, LPCWSTR pszPath,
  36. FILETIME ftDateStamp, int iItem, DWORD dwFlags, DWORD dwPriority,
  37. BOOL fAsync, BOOL fBackground, BOOL fForce);
  38. STDMETHOD (RunInitRT)();
  39. HRESULT Init(LPCITEMIDLIST pidl);
  40. protected:
  41. ~CTestCacheTask();
  42. CDefView *_pView;
  43. IExtractImage * _pExtract;
  44. WCHAR _szPath[MAX_PATH];
  45. FILETIME _ftDateStamp;
  46. LPITEMIDLIST _pidl;
  47. int _iItem;
  48. DWORD _dwFlags;
  49. DWORD _dwPriority;
  50. BOOL _fAsync;
  51. BOOL _fBackground;
  52. BOOL _fForce;
  53. DWORD _dwTaskID;
  54. };
  55. // task used to perform the background status bar update
  56. class CStatusBarAndInfoTipTask : public CRunnableTask
  57. {
  58. public:
  59. CStatusBarAndInfoTipTask(HRESULT *phr, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidl, UINT uMsg, int nMsgParam, CBackgroundInfoTip *pbit, HWND hwnd, IShellTaskScheduler2* pScheduler);
  60. STDMETHODIMP RunInitRT(void);
  61. protected:
  62. ~CStatusBarAndInfoTipTask();
  63. LPITEMIDLIST _pidl;
  64. LPITEMIDLIST _pidlFolder;
  65. UINT _uMsg;
  66. int _nMsgParam;
  67. CBackgroundInfoTip *_pbit;
  68. HWND _hwnd;
  69. IShellTaskScheduler2* _pScheduler;
  70. };
  71. class CBackgroundInfoTip : IUnknown
  72. {
  73. public:
  74. CBackgroundInfoTip(HRESULT *phr, NMLVGETINFOTIP *plvGetInfoTip)
  75. {
  76. _lvSetInfoTip.cbSize = sizeof(_lvSetInfoTip);
  77. _lvSetInfoTip.iItem = plvGetInfoTip->iItem;
  78. _lvSetInfoTip.iSubItem = plvGetInfoTip->iSubItem;
  79. *phr = SHStrDup(plvGetInfoTip->pszText, &_lvSetInfoTip.pszText);
  80. if (SUCCEEDED(*phr))
  81. {
  82. // Do not repeat the text if the item is not folded
  83. if (plvGetInfoTip->dwFlags & LVGIT_UNFOLDED)
  84. _lvSetInfoTip.pszText[0] = 0;
  85. }
  86. _cRef = 1;
  87. }
  88. // IUnknown
  89. virtual STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj) { return E_NOINTERFACE; }
  90. virtual STDMETHODIMP_(ULONG) AddRef(void)
  91. {
  92. return InterlockedIncrement(&_cRef);
  93. }
  94. virtual STDMETHODIMP_(ULONG) Release(void)
  95. {
  96. ASSERT( 0 != _cRef );
  97. ULONG cRef = InterlockedDecrement(&_cRef);
  98. if ( 0 == cRef )
  99. {
  100. delete this;
  101. }
  102. return cRef;
  103. }
  104. LVSETINFOTIP _lvSetInfoTip;
  105. BOOL _fReady; // This ensures that we will not try to use the object before it's ready
  106. // CONSIDER: the memory can be released and then re-used by the same object
  107. // CONSIDER: which would have us believe that the InfoTip should be shown.
  108. // CONSIDER: But if another InfoTip had been requested and the memory re-used for the new CBackgroundInfoTip
  109. // CONSIDER: we would handle the message WM_AEB_ASYNCNAVIGATION with an
  110. // CONSIDER: unprocessed CBackgroundInfoTip object. (See the handler for WM_AEB_ASYNCNAVIGATION).
  111. private:
  112. LONG _cRef;
  113. ~CBackgroundInfoTip()
  114. {
  115. CoTaskMemFree(_lvSetInfoTip.pszText); // NULL ok
  116. }
  117. };
  118. class CDUIInfotipTask : public CRunnableTask
  119. {
  120. public:
  121. CDUIInfotipTask() : CRunnableTask(RTF_DEFAULT) {}
  122. // Local
  123. HRESULT Initialize(CDefView *pDefView, HWND hwndContaining, UINT uToolID, LPCITEMIDLIST pidl);
  124. // IRunnableTask
  125. STDMETHOD(RunInitRT)(void);
  126. protected:
  127. virtual ~CDUIInfotipTask();
  128. CDefView * _pDefView;
  129. HWND _hwndContaining; // hwnd containing tool
  130. UINT _uToolID; // tool id (unique among tools in containing hwnd)
  131. LPITEMIDLIST _pidl;
  132. };
  133. #endif