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.

150 lines
3.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: copyhook.cxx
  7. //
  8. // Contents: CShareCopyHook implementation
  9. //
  10. // History: 21-Apr-95 BruceFo Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include "headers.hxx"
  14. #pragma hdrstop
  15. #include "copyhook.hxx"
  16. #include "cache.hxx"
  17. #include "shrinfo.hxx"
  18. #include "util.hxx"
  19. //+-------------------------------------------------------------------------
  20. //
  21. // Member: CShareCopyHook::CShareCopyHook
  22. //
  23. // Synopsis: Constructor
  24. //
  25. // History: 21-Apr-95 BruceFo Created
  26. //
  27. //--------------------------------------------------------------------------
  28. CShareCopyHook::CShareCopyHook(
  29. VOID
  30. )
  31. :
  32. _uRefs(0)
  33. {
  34. INIT_SIG(CShareCopyHook);
  35. AddRef(); // give it the correct initial reference count. add to the DLL reference count
  36. }
  37. //+-------------------------------------------------------------------------
  38. //
  39. // Member: CShareCopyHook::~CShareCopyHook
  40. //
  41. // Synopsis: Destructor
  42. //
  43. // History: 21-Apr-95 BruceFo Created
  44. //
  45. //--------------------------------------------------------------------------
  46. CShareCopyHook::~CShareCopyHook()
  47. {
  48. CHECK_SIG(CShareCopyHook);
  49. }
  50. //+-------------------------------------------------------------------------
  51. //
  52. // Member: CShareCopyHook::CopyCallback
  53. //
  54. // Derivation: ICopyHook
  55. //
  56. // Synopsis: Called when the shell is copying an object
  57. //
  58. // History: 21-Apr-95 BruceFo Created
  59. //
  60. // FEATURE: instead of deleting a share on a directory move, how about
  61. // moving the share?
  62. //
  63. //--------------------------------------------------------------------------
  64. STDMETHODIMP_(UINT)
  65. CShareCopyHook::CopyCallback(
  66. HWND hwnd,
  67. UINT wFunc,
  68. UINT fFlags,
  69. LPCWSTR pszSrcFile,
  70. DWORD dwSrcAttribs,
  71. LPCWSTR pszDestFile,
  72. DWORD dwDestAttribs
  73. )
  74. {
  75. appDebugOut((DEB_TRACE,
  76. "CShareCopyHook::CopyCallback. %ws -> %ws\n",
  77. pszSrcFile, pszDestFile));
  78. UINT idMsg;
  79. if (!(dwSrcAttribs & FILE_ATTRIBUTE_DIRECTORY))
  80. {
  81. return IDYES; //We're only worried about directories
  82. }
  83. if (!g_fSharingEnabled)
  84. {
  85. return IDYES;
  86. }
  87. switch (wFunc)
  88. {
  89. case FO_DELETE:
  90. idMsg = MSG_RMDIRCONFIRM;
  91. break;
  92. case FO_RENAME:
  93. case FO_MOVE:
  94. idMsg = MSG_MVDIRCONFIRM;
  95. break;
  96. default:
  97. return IDYES;
  98. }
  99. BOOL fChange = FALSE;
  100. UINT wnErr = IDYES; /* by default, shell should go ahead and do it */
  101. CShareInfo* pWarnList = NULL;
  102. HRESULT hr = g_ShareCache.ConstructParentWarnList(pszSrcFile, &pWarnList);
  103. if (SUCCEEDED(hr))
  104. {
  105. if (NULL != pWarnList)
  106. {
  107. for (CShareInfo* p = (CShareInfo*) pWarnList->Next();
  108. p != pWarnList;
  109. p = (CShareInfo*) p->Next())
  110. {
  111. wnErr = WarnDelShare(hwnd, idMsg, p->GetNetname(), p->GetPath());
  112. if (wnErr != IDYES)
  113. {
  114. // IDYES: obviously, continue
  115. break;
  116. }
  117. fChange = TRUE;
  118. }
  119. // get rid of the temporary list
  120. DeleteShareInfoList(pWarnList, TRUE);
  121. if (fChange)
  122. {
  123. g_ShareCache.Refresh();
  124. }
  125. }
  126. }
  127. return wnErr;
  128. }