Changeset b2bbf1aee6bb…
Parent 273b179a0014…
by
Changes to 11 files · Browse files at b2bbf1aee6bb Showing diff from parent 273b179a0014 Diff from another changeset...
@@ -50,3 +50,7 @@ // Keyboard shortcut data
extern const CKeyShortcut KeyShortcutList[];
extern const int KeyShortcutListCount;
+
+// Warning messages displayed by the copy hook
+extern const LPCTSTR DeleteHgMessage;
+extern const LPCTSTR DeleteHgTitle;
|
@@ -24,6 +24,7 @@ #include "TortoiseHgDropHandler.h"
#include "TortoiseHgOverlay.h"
#include "TortoiseHgKeyboard.h"
+#include "TortoiseHgCopyHook.h"
CComModule _Module;
@@ -35,6 +36,7 @@ OBJECT_ENTRY(CLSID_TortoiseHgModified, CTortoiseHgModified)
OBJECT_ENTRY(CLSID_TortoiseHgUnversioned, CTortoiseHgUnversioned)
OBJECT_ENTRY(CLSID_TortoiseHgKeyboard, CTortoiseHgKeyboard)
+ OBJECT_ENTRY(CLSID_TortoiseHgCopyHook, CTortoiseHgCopyHook)
END_OBJECT_MAP()
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
@@ -63,4 +63,10 @@ {
[default] interface IObjectWithSite;
}
+
+ [uuid(61047697-7E8B-46FE-9CF8-2CE603EB3017)]
+ coclass TortoiseHgCopyHook
+ {
+ [default] interface IUnknown;
+ }
}
|
@@ -30,6 +30,7 @@ IDR_MODIFIED REGISTRY "TortoiseHgModified.rgs"
IDR_UNVERSIONED REGISTRY "TortoiseHgUnversioned.rgs"
IDR_KEYBOARD REGISTRY "TortoiseHgKeyboard.rgs"
+IDR_COPYHOOK REGISTRY "TortoiseHgCopyHook.rgs"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
|
@@ -232,6 +232,7 @@ <ClCompile Include="THgStatus.cpp" />
<ClCompile Include="THgVersion.cpp" />
<ClCompile Include="TortoiseHgCmenu.cpp" />
+ <ClCompile Include="TortoiseHgCopyHook.cpp" />
<ClCompile Include="TortoiseHgDropHandler.cpp" />
<ClCompile Include="TortoiseHgKeyboard.cpp" />
<ClCompile Include="TortoiseHgOverlay.cpp" />
@@ -260,6 +261,7 @@ <ClInclude Include="THgVersion.h" />
<ClInclude Include="TlsPtr.h" />
<ClInclude Include="TortoiseHgCmenu.h" />
+ <ClInclude Include="TortoiseHgCopyHook.h" />
<ClInclude Include="TortoiseHgDropHandler.h" />
<ClInclude Include="TortoiseHgKeyboard.h" />
<ClInclude Include="TortoiseHgOverlay.h" />
@@ -272,6 +274,7 @@ <None Include="THgShell.rc2" />
<None Include="TortoiseHgAdded.rgs" />
<None Include="TortoiseHgCmenu.rgs" />
+ <None Include="TortoiseHgCopyHook.rgs" />
<None Include="TortoiseHgDropHandler.rgs" />
<None Include="TortoiseHgKeyboard.rgs" />
<None Include="TortoiseHgModified.rgs" />
|
@@ -90,6 +90,9 @@ <ClCompile Include="GlobalData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="TortoiseHgCopyHook.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Directory.h">
@@ -170,6 +173,9 @@ <ClInclude Include="TlsPtr.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="TortoiseHgCopyHook.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="THgShell.def">
@@ -199,6 +205,9 @@ <None Include="TortoiseHgKeyboard.rgs">
<Filter>Resource Files</Filter>
</None>
+ <None Include="TortoiseHgCopyHook.rgs">
+ <Filter>Resource Files</Filter>
+ </None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="THgShell.rc">
|
|
@@ -0,0 +1,51 @@ + // Copyright (C) 2011 Fog Creek Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "stdafx.h"
+#include "THgShell_h.h"
+
+#include "TortoiseHgCopyHook.h"
+#include "RegistryConfig.h"
+#include "GlobalData.h"
+
+CTortoiseHgCopyHook::CTortoiseHgCopyHook()
+{
+}
+
+STDMETHODIMP_(UINT) CTortoiseHgCopyHook::CopyCallback(HWND hWnd, UINT wFunc, UINT wFlags,
+ LPCTSTR pszSrcFile, DWORD dwSrcAttribs, LPCTSTR pszDestFile, DWORD dwDestAttribs)
+{
+ if (wFunc != FO_DELETE || !(dwSrcAttribs & FILE_ATTRIBUTE_DIRECTORY)) return IDYES;
+
+ CString strDirName = pszSrcFile;
+ if (strDirName.Right(4) != "\\.hg") return IDYES;
+
+ CStringW strMenuText = DeleteHgTitle;
+ CStringW strHelpText = DeleteHgMessage;
+
+ // Attempt to load localized message and title strings if they exist.
+ CString strLang;
+ GetRegistryConfig("CMenuLang", strLang);
+ if (!strLang.IsEmpty())
+ {
+ CStringW strMenuText2;
+ CStringW strHelpText2;
+ GetCMenuTranslation(strLang, "hgwarning", strMenuText, strHelpText);
+ if (!strMenuText2.IsEmpty()) strMenuText = strMenuText2;
+ if (!strHelpText2.IsEmpty()) strHelpText = strHelpText2;
+ }
+ return ::MessageBoxW(hWnd, strHelpText, strMenuText,
+ MB_YESNOCANCEL | MB_ICONWARNING);
+}
|
|
@@ -0,0 +1,36 @@ + // Copyright (C) 2011 Fog Creek Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+
+class CTortoiseHgCopyHook :
+ public CComObjectRootEx<CComMultiThreadModel>,
+ public CComCoClass<CTortoiseHgCopyHook, &CLSID_TortoiseHgCopyHook>,
+ public ICopyHook
+{
+public:
+ CTortoiseHgCopyHook();
+
+ BEGIN_COM_MAP(CTortoiseHgCopyHook)
+ COM_INTERFACE_ENTRY(ICopyHook)
+ END_COM_MAP()
+
+ DECLARE_REGISTRY_RESOURCEID(IDR_COPYHOOK)
+
+ // ICopyHook
+ STDMETHOD_(UINT, CopyCallback)(HWND hWnd, UINT wFunc, UINT wFlags,
+ LPCTSTR pszSrcFile, DWORD dwSrcAttribs, LPCTSTR pszDestFile,
+ DWORD dwDestAttribs);
+};
|
|
@@ -0,0 +1,45 @@ + HKCR
+{
+ NoRemove 'CLSID'
+ {
+ ForceRemove '{61047697-7E8B-46FE-9CF8-2CE603EB3017}' = s 'TortoiseHg'
+ {
+ 'InprocServer32' = s '%MODULE%'
+ {
+ val 'ThreadingModel' = s 'Apartment'
+ }
+ }
+ }
+ 'Directory'
+ {
+ 'shellex'
+ {
+ 'CopyHookHandlers'
+ {
+ 'TortoiseCopyHook' = s '{61047697-7E8B-46FE-9CF8-2CE603EB3017}'
+ }
+ }
+ }
+}
+HKLM
+{
+ NoRemove 'Software'
+ {
+ NoRemove 'Microsoft'
+ {
+ NoRemove 'Windows'
+ {
+ NoRemove 'CurrentVersion'
+ {
+ NoRemove 'Shell Extensions'
+ {
+ NoRemove 'Approved'
+ {
+ val '{61047697-7E8B-46FE-9CF8-2CE603EB3017}' = s 'TortoiseHg'
+ }
+ }
+ }
+ }
+ }
+ }
+}
|
@@ -10,6 +10,7 @@ #define IDR_UNVERSIONED 106
#define IDR_KEYBOARD 107
#define IDD_KEYBOARDHELP 108
+#define IDR_COPYHOOK 109
#define IDC_KEYLIST 1000
#define IDC_TOPTEXT 1001
@@ -17,7 +18,7 @@//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 109
+#define _APS_NEXT_RESOURCE_VALUE 110
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
|
Loading...