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.

145 lines
4.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: P I D L U T I L . C P P
  7. //
  8. // Contents: PIDL utility routines. This stuff is mainly copied from the
  9. // existing Namespace extension samples and real code, since
  10. // everyone and their gramma uses this stuff.
  11. //
  12. // Notes:
  13. //
  14. // Author: jeffspr 1 Oct 1997
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "pch.h"
  18. #pragma hdrstop
  19. #include "foldinc.h" // Standard shell\folder includes
  20. #include "connlist.h" // Connection list code
  21. //+---------------------------------------------------------------------------
  22. //
  23. // Function: HrCloneRgIDL
  24. //
  25. // Purpose: Clone a pidl array
  26. //
  27. // Arguments:
  28. // rgpidl [in] PIDL array to clone
  29. // cidl [in] Count of the pidl array
  30. // fUseCache [in] If TRUE, generate the returned IDL from the cache
  31. // fAllowNonCacheItems [in] Use old version of pidl if cached version non available
  32. // pppidl [out] Return pointer for pidl array
  33. //
  34. // Returns:
  35. //
  36. // Author: jeffspr 22 Oct 1997
  37. //
  38. // Notes:
  39. //
  40. HRESULT HrCloneRgIDL(
  41. const PCONFOLDPIDLVEC& rgpidl,
  42. BOOL fUseCache,
  43. BOOL fAllowNonCacheItems,
  44. PCONFOLDPIDLVEC& pppidl)
  45. {
  46. HRESULT hr = NOERROR;
  47. NETCFG_TRY
  48. PCONFOLDPIDLVEC rgpidlReturn;
  49. PCONFOLDPIDLVEC::const_iterator irg;
  50. if (rgpidl.empty())
  51. {
  52. hr = E_INVALIDARG;
  53. goto Exit;
  54. }
  55. else
  56. {
  57. // Clone all elements within the passed in PIDL array
  58. //
  59. for (irg = rgpidl.begin(); irg != rgpidl.end(); irg++)
  60. {
  61. if (fUseCache)
  62. {
  63. ConnListEntry cle;
  64. PCONFOLDPIDL pcfp = *irg;
  65. hr = g_ccl.HrFindConnectionByGuid(&(pcfp->guidId), cle);
  66. if (hr == S_OK)
  67. {
  68. Assert(!cle.empty());
  69. Assert(!cle.ccfe.empty());
  70. // Copy to the return pidl array.
  71. PCONFOLDPIDL newPidl;
  72. hr = cle.ccfe.ConvertToPidl(newPidl);
  73. if (SUCCEEDED(hr))
  74. {
  75. rgpidlReturn.push_back(newPidl);
  76. }
  77. else
  78. {
  79. goto Exit;
  80. }
  81. }
  82. else
  83. {
  84. TraceTag(ttidShellFolder, "HrCloneRgIDL: Connection find returned: 0x%08x", hr);
  85. if (hr == S_FALSE)
  86. {
  87. if (fAllowNonCacheItems)
  88. {
  89. TraceTag(ttidShellFolder, "HrCloneRgIDL: Connection not found in cache, "
  90. "using non-cache item");
  91. PCONFOLDPIDL newPidl;
  92. newPidl = *irg;
  93. rgpidlReturn.push_back(newPidl);
  94. }
  95. else
  96. {
  97. TraceTag(ttidShellFolder, "HrCloneRgIDL: Connection not found in cache. "
  98. "Dropping item from array");
  99. }
  100. }
  101. else
  102. {
  103. AssertSz(FALSE, "HrCloneRgIDL: Connection find HR_FAILED");
  104. }
  105. }
  106. }
  107. else
  108. {
  109. PCONFOLDPIDL newPidl;
  110. newPidl = *irg;
  111. rgpidlReturn.push_back(newPidl);
  112. }
  113. }
  114. }
  115. Exit:
  116. if (FAILED(hr))
  117. {
  118. rgpidlReturn.clear();
  119. }
  120. else
  121. {
  122. // Fill in the return var.
  123. //
  124. pppidl = rgpidlReturn;
  125. }
  126. NETCFG_CATCH(hr)
  127. TraceHr(ttidError, FAL, hr, FALSE, "HrCloneRgIDL");
  128. return hr;
  129. } // HrCloneRgIDL