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.

262 lines
5.8 KiB

  1. /*
  2. * inetps.cpp - Property sheet implementation for Internet class.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.hpp"
  7. #pragma hdrstop
  8. #include "clsfact.h"
  9. #include "inetcpl.h"
  10. #include "inetps.hpp"
  11. /***************************** Private Functions *****************************/
  12. PRIVATE_CODE HRESULT AddInternetPS(LPFNADDPROPSHEETPAGE pfnAddPage,
  13. LPARAM lparam)
  14. {
  15. // lparam may be any value.
  16. ASSERT(IS_VALID_CODE_PTR(pfnAddPage, LPFNADDPROPSHEETPAGE));
  17. return(AddInternetPropertySheets(pfnAddPage, lparam, NULL, NULL));
  18. }
  19. /****************************** Public Functions *****************************/
  20. #ifdef DEBUG
  21. PUBLIC_CODE BOOL IsValidPCInternet(PCInternet pcinet)
  22. {
  23. return(IS_VALID_READ_PTR(pcinet, CInternet) &&
  24. IS_VALID_STRUCT_PTR((PCRefCount)pcinet, CRefCount) &&
  25. IS_VALID_INTERFACE_PTR((PCIShellExtInit)pcinet, IShellExtInit) &&
  26. IS_VALID_INTERFACE_PTR((PCIShellPropSheetExt)pcinet, IShellPropSheetExt));
  27. }
  28. #endif
  29. /********************************** Methods **********************************/
  30. #pragma warning(disable:4705) /* "statement has no effect" warning - cl bug, see KB Q98989 */
  31. Internet::Internet()
  32. {
  33. DebugEntry(Internet::Internet);
  34. // Don't validate this until after construction.
  35. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  36. DebugExitVOID(Internet::Internet);
  37. return;
  38. }
  39. #pragma warning(default:4705) /* "statement has no effect" warning - cl bug, see KB Q98989 */
  40. Internet::~Internet(void)
  41. {
  42. DebugEntry(Internet::~Internet);
  43. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  44. DebugExitVOID(Internet::~Internet);
  45. return;
  46. }
  47. ULONG STDMETHODCALLTYPE Internet::AddRef(void)
  48. {
  49. ULONG ulcRef;
  50. DebugEntry(Internet::AddRef);
  51. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  52. ulcRef = RefCount::AddRef();
  53. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  54. DebugExitULONG(Internet::AddRef, ulcRef);
  55. return(ulcRef);
  56. }
  57. ULONG STDMETHODCALLTYPE Internet::Release(void)
  58. {
  59. ULONG ulcRef;
  60. DebugEntry(Internet::Release);
  61. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  62. ulcRef = RefCount::Release();
  63. DebugExitULONG(Internet::Release, ulcRef);
  64. return(ulcRef);
  65. }
  66. HRESULT STDMETHODCALLTYPE Internet::QueryInterface(REFIID riid,
  67. PVOID *ppvObject)
  68. {
  69. HRESULT hr = S_OK;
  70. DebugEntry(Internet::QueryInterface);
  71. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  72. ASSERT(IsValidREFIID(riid));
  73. ASSERT(IS_VALID_WRITE_PTR(ppvObject, PVOID));
  74. if (riid == IID_IShellExtInit)
  75. {
  76. *ppvObject = (PIShellExtInit)this;
  77. TRACE_OUT(("Internet::QueryInterface(): Returning IShellExtInit."));
  78. }
  79. else if (riid == IID_IShellPropSheetExt)
  80. {
  81. *ppvObject = (PIShellPropSheetExt)this;
  82. TRACE_OUT(("Internet::QueryInterface(): Returning IShellPropSheetExt."));
  83. }
  84. else if (riid == IID_IUnknown)
  85. {
  86. *ppvObject = (PIUnknown)(PIShellPropSheetExt)this;
  87. TRACE_OUT(("Internet::QueryInterface(): Returning IUnknown."));
  88. }
  89. else
  90. {
  91. TRACE_OUT(("Internet::QueryInterface(): Called on unknown interface."));
  92. *ppvObject = NULL;
  93. hr = E_NOINTERFACE;
  94. }
  95. if (hr == S_OK)
  96. AddRef();
  97. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  98. DebugExitHRESULT(Internet::QueryInterface, hr);
  99. return(hr);
  100. }
  101. #pragma warning(disable:4100) /* "unreferenced formal parameter" warning */
  102. HRESULT STDMETHODCALLTYPE Internet::Initialize(PCITEMIDLIST pcidlFolder,
  103. PIDataObject pido,
  104. HKEY hkeyProgID)
  105. {
  106. HRESULT hr;
  107. DebugEntry(Internet::Initialize);
  108. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  109. ASSERT(! pcidlFolder ||
  110. IS_VALID_STRUCT_PTR(pcidlFolder, CITEMIDLIST));
  111. ASSERT(IS_VALID_INTERFACE_PTR(pido, IDataObject));
  112. ASSERT(IS_VALID_HANDLE(hkeyProgID, KEY));
  113. // An Internet doesn't care where it lives in the name space.
  114. hr = S_OK;
  115. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  116. DebugExitHRESULT(Internet::Initialize, hr);
  117. return(hr);
  118. }
  119. #pragma warning(default:4100) /* "unreferenced formal parameter" warning */
  120. HRESULT STDMETHODCALLTYPE Internet::AddPages(LPFNADDPROPSHEETPAGE pfnAddPage,
  121. LPARAM lparam)
  122. {
  123. HRESULT hr;
  124. DebugEntry(Internet::AddPages);
  125. // lparam may be any value.
  126. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  127. ASSERT(IS_VALID_CODE_PTR(pfnAddPage, LPFNADDPROPSHEETPAGE));
  128. hr = AddInternetPS(pfnAddPage, lparam);
  129. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  130. DebugExitHRESULT(Internet::AddPages, hr);
  131. return(hr);
  132. }
  133. #pragma warning(disable:4100) /* "unreferenced formal parameter" warning */
  134. HRESULT STDMETHODCALLTYPE Internet::ReplacePage(
  135. UINT uPageID,
  136. LPFNADDPROPSHEETPAGE pfnReplaceWith,
  137. LPARAM lparam)
  138. {
  139. HRESULT hr;
  140. DebugEntry(Internet::ReplacePage);
  141. // lparam may be any value.
  142. // uPageID may be any value.
  143. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  144. ASSERT(IS_VALID_CODE_PTR(pfnReplaceWith, LPFNADDPROPSHEETPAGE));
  145. // No pages to replace.
  146. hr = E_NOTIMPL;
  147. ASSERT(IS_VALID_STRUCT_PTR(this, CInternet));
  148. DebugExitHRESULT(Internet::ReplacePage, hr);
  149. return(hr);
  150. }
  151. #pragma warning(default:4100) /* "unreferenced formal parameter" warning */
  152. extern "C"
  153. STDAPI CreateInstance_Internet(IUnknown *punkOuter, REFIID riid, void **ppvOut)
  154. {
  155. HRESULT hres;
  156. *ppvOut = NULL;
  157. if (punkOuter)
  158. return CLASS_E_NOAGGREGATION;
  159. Internet *pinet = new(Internet);
  160. if (pinet)
  161. {
  162. hres = pinet->QueryInterface(riid, ppvOut);
  163. pinet->Release();
  164. }
  165. else
  166. hres = E_OUTOFMEMORY;
  167. return hres;
  168. }