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.

201 lines
4.9 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: TaskHost.cpp
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 11/17/1997 RaviR Created
  15. //____________________________________________________________________________
  16. //
  17. #include "stdafx.h"
  18. #include "amcdoc.h"
  19. #include "amcview.h"
  20. #include "taskhost.h"
  21. STDMETHODIMP
  22. CTaskPadHost::GetTaskEnumerator(
  23. BSTR bstrTaskGroup,
  24. IEnumTASK** ppEnumTask)
  25. {
  26. ASSERT(ppEnumTask != NULL);
  27. if (!ppEnumTask)
  28. return E_POINTER;
  29. ASSERT(m_pAMCView);
  30. if (!m_pAMCView)
  31. return E_UNEXPECTED;
  32. HNODE hNode = m_pAMCView->GetSelectedNode();
  33. ASSERT(hNode != NULL);
  34. if (!hNode)
  35. return E_UNEXPECTED;
  36. INodeCallback* pNC = _GetNodeCallback();
  37. ASSERT(pNC != NULL);
  38. if (!pNC)
  39. return E_UNEXPECTED;
  40. // do not pas NULL, pas empty string instead
  41. LPCOLESTR strTaskGroup = bstrTaskGroup ? bstrTaskGroup : L"";
  42. return pNC->GetTaskEnumerator(hNode, strTaskGroup, ppEnumTask);
  43. }
  44. STDMETHODIMP
  45. CTaskPadHost::TaskNotify(
  46. BSTR szClsid,
  47. VARIANT* pvArg,
  48. VARIANT* pvParam)
  49. {
  50. ASSERT(m_pAMCView);
  51. if (!m_pAMCView)
  52. return E_UNEXPECTED;
  53. HNODE hNode = m_pAMCView->GetSelectedNode();
  54. ASSERT(hNode != NULL);
  55. if (!hNode)
  56. return E_UNEXPECTED;
  57. INodeCallback* pNC = _GetNodeCallback();
  58. if (!pNC)
  59. return E_UNEXPECTED;
  60. VARIANT* ppv[2] = {pvArg, pvParam};
  61. pNC->Notify(hNode, NCLBK_TASKNOTIFY, reinterpret_cast<LPARAM>(szClsid),
  62. reinterpret_cast<LPARAM>(ppv));
  63. return S_OK;
  64. }
  65. STDMETHODIMP
  66. CTaskPadHost::GetPrimaryTask(
  67. IExtendTaskPad** ppExtendTaskPad)
  68. {
  69. ASSERT(ppExtendTaskPad != NULL);
  70. if (!ppExtendTaskPad)
  71. return E_POINTER;
  72. if (m_spExtendTaskPadPrimary == NULL)
  73. {
  74. HNODE hNode = m_pAMCView->GetSelectedNode();
  75. ASSERT(hNode != NULL);
  76. if (!hNode)
  77. return E_UNEXPECTED;
  78. INodeCallback* pNC = _GetNodeCallback();
  79. if (!pNC)
  80. return E_UNEXPECTED;
  81. HRESULT hr = pNC->Notify(hNode, NCLBK_GETPRIMARYTASK, NULL,
  82. reinterpret_cast<LPARAM>(&m_spExtendTaskPadPrimary));
  83. if (hr != S_OK)
  84. return hr;
  85. ASSERT (m_spExtendTaskPadPrimary != NULL);
  86. if (m_spExtendTaskPadPrimary == NULL)
  87. return E_UNEXPECTED;
  88. }
  89. *ppExtendTaskPad = m_spExtendTaskPadPrimary;
  90. (*ppExtendTaskPad)->AddRef ();
  91. return S_OK;
  92. }
  93. STDMETHODIMP
  94. CTaskPadHost::GetTitle(
  95. BSTR bstrTaskGroup,
  96. BSTR* pbstrOut)
  97. {
  98. IExtendTaskPad* pExtendTaskPad = _GetPrimaryExtendTaskPad();
  99. if (pExtendTaskPad == NULL)
  100. return E_UNEXPECTED;
  101. LPOLESTR szString = NULL;
  102. HRESULT hr = pExtendTaskPad->GetTitle (bstrTaskGroup, &szString);
  103. ASSERT ((hr == S_OK) && (szString != NULL));
  104. if ((hr == S_OK) && (szString != NULL)) {
  105. *pbstrOut = SysAllocString (szString);
  106. ASSERT (pbstrOut != NULL);
  107. CoTaskMemFree (szString);
  108. if (pbstrOut == NULL)
  109. hr = E_OUTOFMEMORY;
  110. }
  111. return hr;
  112. }
  113. STDMETHODIMP
  114. CTaskPadHost::GetDescriptiveText(
  115. BSTR bstrTaskGroup,
  116. BSTR* pbstrOut)
  117. {
  118. IExtendTaskPad* pExtendTaskPad = _GetPrimaryExtendTaskPad();
  119. if (pExtendTaskPad == NULL)
  120. return E_UNEXPECTED;
  121. LPOLESTR szString = NULL;
  122. HRESULT hr = pExtendTaskPad->GetDescriptiveText (bstrTaskGroup, &szString);
  123. // optional ASSERT ((hr == S_OK) && (szString != NULL));
  124. if ((hr == S_OK) && (szString != NULL)) {
  125. *pbstrOut = SysAllocString (szString);
  126. ASSERT (pbstrOut != NULL);
  127. CoTaskMemFree (szString);
  128. if (pbstrOut == NULL)
  129. hr = E_OUTOFMEMORY;
  130. }
  131. return hr;
  132. }
  133. STDMETHODIMP
  134. CTaskPadHost::GetBackground(
  135. BSTR bstrTaskGroup,
  136. MMC_TASK_DISPLAY_OBJECT * pTDO)
  137. {
  138. IExtendTaskPad* pExtendTaskPad = _GetPrimaryExtendTaskPad();
  139. if (pExtendTaskPad == NULL)
  140. return E_UNEXPECTED;
  141. LPOLESTR szString = NULL;
  142. HRESULT hr = pExtendTaskPad->GetBackground (bstrTaskGroup, pTDO);
  143. // optional ASSERT (hr == S_OK);
  144. return hr;
  145. }
  146. STDMETHODIMP CTaskPadHost::GetListPadInfo(BSTR szTaskGroup, MMC_ILISTPAD_INFO * pIListPadInfo)
  147. {
  148. ASSERT(pIListPadInfo != NULL);
  149. ASSERT (!IsBadWritePtr (pIListPadInfo, sizeof(MMC_ILISTPAD_INFO)));
  150. IExtendTaskPad* pExtendTaskPad = _GetPrimaryExtendTaskPad();
  151. if (pExtendTaskPad == NULL)
  152. return E_UNEXPECTED;
  153. ASSERT(m_pAMCView);
  154. if (!m_pAMCView)
  155. return E_UNEXPECTED;
  156. HNODE hNode = m_pAMCView->GetSelectedNode();
  157. ASSERT(hNode != NULL);
  158. if (!hNode)
  159. return E_UNEXPECTED;
  160. INodeCallback* pNC = _GetNodeCallback();
  161. ASSERT(pNC != NULL);
  162. if (!pNC)
  163. return E_UNEXPECTED;
  164. return pNC->GetListPadInfo (hNode, pExtendTaskPad, (LPOLESTR)szTaskGroup, pIListPadInfo);
  165. }