Refactored: Replace CGitLogListBase::m_From/m_To with the member variable of CFilterData
[TortoiseGit.git] / src / TortoiseShell / ShellExt.h
blob977462931ead741a242bfcf8078caec1bbee918e
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2012 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "Globals.h"
22 #include "registry.h"
23 #include "resource.h"
24 #include "ShellCache.h"
25 #include "RemoteCacheLink.h"
26 #include "GitStatus.h"
27 #include "GitFolderStatus.h"
28 #include "IconBitmapUtils.h"
29 #include "MenuInfo.h"
30 #include "CrashReport.h"
31 #include "../version.h"
33 extern volatile LONG g_cRefThisDll; // Reference count of this DLL.
34 extern HINSTANCE g_hmodThisDll; // Instance handle for this DLL
35 extern ShellCache g_ShellCache; // caching of registry entries, ...
36 extern DWORD g_langid;
37 extern DWORD g_langTimeout;
38 extern HINSTANCE g_hResInst;
39 extern stdstring g_filepath;
40 extern git_wc_status_kind g_filestatus; ///< holds the corresponding status to the file/dir above
41 extern bool g_readonlyoverlay; ///< whether to show the read only overlay or not
42 extern bool g_lockedoverlay; ///< whether to show the locked overlay or not
44 extern bool g_normalovlloaded;
45 extern bool g_modifiedovlloaded;
46 extern bool g_conflictedovlloaded;
47 extern bool g_readonlyovlloaded;
48 extern bool g_deletedovlloaded;
49 extern bool g_lockedovlloaded;
50 extern bool g_addedovlloaded;
51 extern bool g_ignoredovlloaded;
52 extern bool g_unversionedovlloaded;
53 extern LPCTSTR g_MenuIDString;
55 extern void LoadLangDll();
56 extern CComCriticalSection g_csGlobalCOMGuard;
57 typedef CComCritSecLock<CComCriticalSection> AutoLocker;
59 // The actual OLE Shell context menu handler
60 /**
61 * \ingroup TortoiseShell
62 * The main class of our COM object / Shell Extension.
63 * It contains all Interfaces we implement for the shell to use.
64 * \remark The implementations of the different interfaces are
65 * split into several *.cpp files to keep them in a reasonable size.
67 class CShellExt : public IContextMenu3,
68 IPersistFile,
69 IShellExtInit,
70 IShellIconOverlayIdentifier,
71 IShellPropSheetExt,
72 ICopyHookW
75 protected:
77 FileState m_State;
78 ULONG m_cRef;
79 //std::map<int,std::string> verbMap;
80 std::map<UINT_PTR, UINT_PTR> myIDMap;
81 std::map<UINT_PTR, UINT_PTR> mySubMenuMap;
82 std::map<stdstring, UINT_PTR> myVerbsMap;
83 std::map<UINT_PTR, stdstring> myVerbsIDMap;
84 stdstring folder_;
85 std::vector<stdstring> files_;
86 DWORD itemStates; ///< see the globals.h file for the ITEMIS_* defines
87 DWORD itemStatesFolder; ///< used for states of the folder_ (folder background and/or drop target folder)
88 stdstring uuidSource;
89 stdstring uuidTarget;
90 int space;
91 TCHAR stringtablebuffer[255];
92 stdstring ignoredprops;
93 CRegStdString regDiffLater;
95 GitFolderStatus m_CachedStatus; // status cache
96 CRemoteCacheLink m_remoteCacheLink;
97 IconBitmapUtils m_iconBitmapUtils;
99 #if ENABLE_CRASHHANLDER
100 CCrashReportTGit m_crasher;
101 #endif
103 #define MAKESTRING(ID) LoadStringEx(g_hResInst, ID, stringtablebuffer, _countof(stringtablebuffer), (WORD)CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)))
104 private:
105 void InsertGitMenu(BOOL istop, HMENU menu, UINT pos, UINT_PTR id, UINT stringid, UINT icon, UINT idCmdFirst, GitCommands com, UINT uFlags);
106 bool InsertIgnoreSubmenus(UINT &idCmd, UINT idCmdFirst, HMENU hMenu, HMENU subMenu, UINT &indexMenu, int &indexSubMenu, unsigned __int64 topmenu, bool bShowIcons, UINT uFlags);
107 stdstring WriteFileListToTempFile();
108 bool WriteClipboardPathsToTempFile(stdstring& tempfile);
109 LPCTSTR GetMenuTextFromResource(int id);
110 bool ShouldInsertItem(const MenuInfo& pair) const;
111 bool ShouldEnableMenu(const YesNoPair& pair) const;
112 void TweakMenu(HMENU menu);
113 void AddPathCommand(tstring& gitCmd, LPCTSTR command, bool bFilesAllowed);
114 void AddPathFileCommand(tstring& gitCmd, LPCTSTR command);
115 void AddPathFileDropCommand(tstring& gitCmd, LPCTSTR command);
116 STDMETHODIMP QueryDropContext(UINT uFlags, UINT idCmdFirst, HMENU hMenu, UINT &indexMenu);
117 bool IsIllegalFolder(std::wstring folder, int * cslidarray);
118 static void RunCommand(const tstring& path, const tstring& command, LPCTSTR errorMessage);
120 /** \name IContextMenu2 wrappers
121 * IContextMenu2 wrapper functions to catch exceptions and send crash reports
123 //@{
124 STDMETHODIMP QueryContextMenu_Wrap(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
125 STDMETHODIMP InvokeCommand_Wrap(LPCMINVOKECOMMANDINFO lpcmi);
126 STDMETHODIMP GetCommandString_Wrap(UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax);
127 STDMETHODIMP HandleMenuMsg_Wrap(UINT uMsg, WPARAM wParam, LPARAM lParam);
128 //@}
130 /** \name IContextMenu3 wrappers
131 * IContextMenu3 wrapper functions to catch exceptions and send crash reports
133 //@{
134 STDMETHODIMP HandleMenuMsg2_Wrap(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult);
135 //@}
137 /** \name IShellExtInit wrappers
138 * IShellExtInit wrapper functions to catch exceptions and send crash reports
140 //@{
141 STDMETHODIMP Initialize_Wrap(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID);
142 //@}
144 /** \name IShellIconOverlayIdentifier wrappers
145 * IShellIconOverlayIdentifier wrapper functions to catch exceptions and send crash reports
147 //@{
148 STDMETHODIMP GetOverlayInfo_Wrap(LPWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags);
149 STDMETHODIMP GetPriority_Wrap(int *pPriority);
150 STDMETHODIMP IsMemberOf_Wrap(LPCWSTR pwszPath, DWORD dwAttrib);
151 //@}
153 /** \name IShellPropSheetExt wrappers
154 * IShellPropSheetExt wrapper functions to catch exceptions and send crash reports
156 //@{
157 STDMETHODIMP AddPages_Wrap(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
158 //STDMETHODIMP ReplacePage_Wrap(UINT, LPFNADDPROPSHEETPAGE, LPARAM);
159 //@}
161 /** \name ICopyHook wrapper
162 * ICopyHook wrapper functions to catch exceptions and send crash reports
164 //@{
165 STDMETHODIMP_(UINT) CopyCallback_Wrap(HWND hWnd, UINT wFunc, UINT wFlags, LPCTSTR pszSrcFile, DWORD dwSrcAttribs, LPCTSTR pszDestFile, DWORD dwDestAttribs);
166 //@}
168 public:
169 CShellExt(FileState state);
170 virtual ~CShellExt();
172 /** \name IUnknown
173 * IUnknown members
175 //@{
176 STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
177 STDMETHODIMP_(ULONG) AddRef();
178 STDMETHODIMP_(ULONG) Release();
179 //@}
181 /** \name IContextMenu2
182 * IContextMenu2 members
184 //@{
185 STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
186 STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
187 STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax);
188 STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
189 //@}
191 /** \name IContextMenu3
192 * IContextMenu3 members
194 //@{
195 STDMETHODIMP HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult);
196 //@}
198 /** \name IShellExtInit
199 * IShellExtInit methods
201 //@{
202 STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID);
203 //@}
205 /** \name IPersistFile
206 * IPersistFile methods
208 //@{
209 STDMETHODIMP GetClassID(CLSID *pclsid);
210 STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode);
211 STDMETHODIMP IsDirty(void) { return S_OK; };
212 STDMETHODIMP Save(LPCOLESTR /*pszFileName*/, BOOL /*fRemember*/) { return S_OK; };
213 STDMETHODIMP SaveCompleted(LPCOLESTR /*pszFileName*/) { return S_OK; };
214 STDMETHODIMP GetCurFile(LPOLESTR * /*ppszFileName*/) { return S_OK; };
215 //@}
217 /** \name IShellIconOverlayIdentifier
218 * IShellIconOverlayIdentifier methods
220 //@{
221 STDMETHODIMP GetOverlayInfo(LPWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags);
222 STDMETHODIMP GetPriority(int *pPriority);
223 STDMETHODIMP IsMemberOf(LPCWSTR pwszPath, DWORD dwAttrib);
224 //@}
226 /** \name IShellPropSheetExt
227 * IShellPropSheetExt methods
229 //@{
230 STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);
231 STDMETHODIMP ReplacePage (UINT, LPFNADDPROPSHEETPAGE, LPARAM);
232 //@}
234 /** \name ICopyHook
235 * ICopyHook members
237 //@{
238 STDMETHODIMP_(UINT) CopyCallback(HWND hWnd, UINT wFunc, UINT wFlags, LPCTSTR pszSrcFile, DWORD dwSrcAttribs, LPCTSTR pszDestFile, DWORD dwDestAttribs);
239 //@}