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.

144 lines
4.5 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 vector to clone
  29. // fUseCache [in] If TRUE, generate the returned IDL from the cache
  30. // fAllowNonCacheItems [in] Use old version of pidl if cached version non available
  31. // pppidl [out] Return pointer for pidl array
  32. //
  33. // Returns:
  34. //
  35. // Author: jeffspr 22 Oct 1997
  36. //
  37. // Notes:
  38. //
  39. HRESULT HrCloneRgIDL(
  40. IN const PCONFOLDPIDLVEC& rgpidl,
  41. IN BOOL fUseCache,
  42. IN BOOL fAllowNonCacheItems,
  43. OUT PCONFOLDPIDLVEC& pppidl)
  44. {
  45. HRESULT hr = NOERROR;
  46. NETCFG_TRY
  47. PCONFOLDPIDLVEC rgpidlReturn;
  48. PCONFOLDPIDLVEC::const_iterator irg;
  49. if (rgpidl.empty())
  50. {
  51. hr = E_INVALIDARG;
  52. goto Exit;
  53. }
  54. else
  55. {
  56. // Clone all elements within the passed in PIDL array
  57. //
  58. for (irg = rgpidl.begin(); irg != rgpidl.end(); irg++)
  59. {
  60. if (fUseCache)
  61. {
  62. ConnListEntry cle;
  63. PCONFOLDPIDL pcfp = *irg;
  64. hr = g_ccl.HrFindConnectionByGuid(&(pcfp->guidId), cle);
  65. if (hr == S_OK)
  66. {
  67. Assert(!cle.empty());
  68. Assert(!cle.ccfe.empty());
  69. // Copy to the return pidl array.
  70. PCONFOLDPIDL newPidl;
  71. hr = cle.ccfe.ConvertToPidl(newPidl);
  72. if (SUCCEEDED(hr))
  73. {
  74. rgpidlReturn.push_back(newPidl);
  75. }
  76. else
  77. {
  78. goto Exit;
  79. }
  80. }
  81. else
  82. {
  83. TraceTag(ttidShellFolder, "HrCloneRgIDL: Connection find returned: 0x%08x", hr);
  84. if (hr == S_FALSE)
  85. {
  86. if (fAllowNonCacheItems)
  87. {
  88. TraceTag(ttidShellFolder, "HrCloneRgIDL: Connection not found in cache, "
  89. "using non-cache item");
  90. PCONFOLDPIDL newPidl;
  91. newPidl = *irg;
  92. rgpidlReturn.push_back(newPidl);
  93. }
  94. else
  95. {
  96. TraceTag(ttidShellFolder, "HrCloneRgIDL: Connection not found in cache. "
  97. "Dropping item from array");
  98. }
  99. }
  100. else
  101. {
  102. AssertSz(FALSE, "HrCloneRgIDL: Connection find HR_FAILED");
  103. }
  104. }
  105. }
  106. else
  107. {
  108. PCONFOLDPIDL newPidl;
  109. newPidl = *irg;
  110. rgpidlReturn.push_back(newPidl);
  111. }
  112. }
  113. }
  114. Exit:
  115. if (FAILED(hr))
  116. {
  117. rgpidlReturn.clear();
  118. }
  119. else
  120. {
  121. // Fill in the return var.
  122. //
  123. pppidl = rgpidlReturn;
  124. }
  125. NETCFG_CATCH(hr)
  126. TraceHr(ttidError, FAL, hr, FALSE, "HrCloneRgIDL");
  127. return hr;
  128. } // HrCloneRgIDL