some spaces-tabs code cleanup
[TortoiseGit.git] / src / TortoiseProc / SVNProgressDlg.h
blobfc0bcb2d03e9e27c09d6daa13d254b59821f7d4a
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "StandAloneDlg.h"
23 #include "TGitPath.h"
24 #include "ProjectProperties.h"
25 #include "Git.h"
26 #include "GitStatus.h"
27 #include "Colors.h"
28 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"
29 #include "afxwin.h"
31 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
33 /**
34 * \ingroup TortoiseProc
35 * Options which can be used to configure the way the dialog box works
37 typedef enum
39 ProgOptNone = 0,
40 ProgOptRecursive = 0x01,
41 ProgOptNonRecursive = 0x00,
42 /// Don't actually do the merge - just practice it
43 ProgOptDryRun = 0x04,
44 ProgOptIgnoreExternals = 0x08,
45 ProgOptKeeplocks = 0x10,
46 /// for locking this means steal the lock, for unlocking it means breaking the lock
47 ProgOptLockForce = 0x20,
48 ProgOptSwitchAfterCopy = 0x40,
49 ProgOptIncludeIgnored = 0x80,
50 ProgOptIgnoreAncestry = 0x100,
51 ProgOptEolDefault = 0x200,
52 ProgOptEolCRLF = 0x400,
53 ProgOptEolLF = 0x800,
54 ProgOptEolCR = 0x1000,
55 ProgOptSkipConflictCheck = 0x2000,
56 ProgOptRecordOnly = 0x4000
57 } ProgressOptions;
59 typedef enum
61 CLOSE_MANUAL = 0,
62 CLOSE_NOERRORS,
63 CLOSE_NOCONFLICTS,
64 CLOSE_NOMERGES,
65 CLOSE_LOCAL
66 } ProgressCloseOptions;
68 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
70 typedef enum
72 git_wc_notify_add,
73 git_wc_notify_sendmail_start,
74 git_wc_notify_sendmail_error,
75 git_wc_notify_sendmail_retry,
76 git_wc_notify_sendmail_done,
77 git_wc_notify_resolved,
78 git_wc_notify_revert,
80 }git_wc_notify_action_t;
81 typedef enum
83 SENDMAIL_ATTACHMENT =0x1,
84 SENDMAIL_COMBINED =0x2,
85 SENDMAIL_MAPI =0x4
87 /**
88 * \ingroup TortoiseProc
89 * Handles different Subversion commands and shows the notify messages
90 * in a listbox. Since several Subversion commands have similar notify
91 * messages they are grouped together in this single class.
93 class CGitProgressDlg : public CResizableStandAloneDialog
95 public:
96 typedef enum
98 GitProgress_Add,
99 GitProgress_Checkout,
100 GitProgress_Commit,
101 GitProgress_Copy,
102 GitProgress_Export,
103 GitProgress_Import,
104 GitProgress_Lock,
105 GitProgress_Merge,
106 GitProgress_MergeReintegrate,
107 GitProgress_MergeAll,
108 GitProgress_Rename,
109 GitProgress_Resolve,
110 GitProgress_Revert,
111 GitProgress_Switch,
112 GitProgress_Unlock,
113 GitProgress_Update,
114 GitProgress_SendMail,
115 } Command;
118 DECLARE_DYNAMIC(CGitProgressDlg)
120 public:
122 CGitProgressDlg(CWnd* pParent = NULL);
123 virtual ~CGitProgressDlg();
126 void SetCommand(Command cmd) {m_Command = cmd;}
127 void SetAutoClose(DWORD ac) {m_dwCloseOnEnd = ac;}
128 void SetOptions(DWORD opts) {m_options = opts;}
129 void SetPathList(const CTGitPathList& pathList) {m_targetPathList = pathList;}
130 void SetUrl(const CString& url) {m_url.SetFromUnknown(url);}
131 void SetSecondUrl(const CString& url) {m_url2.SetFromUnknown(url);}
132 void SetCommitMessage(const CString& msg) {m_sMessage = msg;}
134 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
135 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
137 void SetDiffOptions(const CString& opts) {m_diffoptions = opts;}
138 void SetSendMailOption(CString &TO, CString &CC,CString &Subject,DWORD flags){m_SendMailTO=TO;m_SendMailSubject=Subject; m_SendMailCC=CC;this->m_SendMailFlags = flags;}
139 void SetDepth(git_depth_t depth = git_depth_unknown) {m_depth = depth;}
140 void SetPegRevision(GitRev pegrev = GitRev()) {m_pegRev = pegrev;}
141 void SetProjectProperties(ProjectProperties props) {m_ProjectProperties = props;}
142 void SetChangeList(const CString& changelist, bool keepchangelist) {m_changelist = changelist; m_keepchangelist = keepchangelist;}
143 void SetSelectedList(const CTGitPathList& selPaths);
144 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
145 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
147 * If the number of items for which the operation is done on is known
148 * beforehand, that number can be set here. It is then used to show a more
149 * accurate progress bar during the operation.
151 void SetItemCount(long count) {if(count) m_itemCountTotal = count;}
153 bool SetBackgroundImage(UINT nID);
155 bool DidErrorsOccur() {return m_bErrorsOccurred;}
157 enum { IDD = IDD_SVNPROGRESS };
159 private:
160 class NotificationData
162 public:
163 NotificationData(){} ;
164 git_wc_notify_action_t action;
165 #if 0
166 action((git_wc_notify_action_t)-1),
167 kind(git_node_none),
168 content_state(git_wc_notify_state_inapplicable),
169 prop_state(git_wc_notify_state_inapplicable),
170 rev(0),
172 color(::GetSysColor(COLOR_WINDOWTEXT)),
173 bConflictedActionItem(false),
174 bAuxItem(false)
176 // lock_state(git_wc_notify_lock_state_unchanged)
178 // merge_range.end = 0;
179 // merge_range.start = 0;
181 #endif
182 public:
183 // The text we put into the first column (the Git action for normal items, just text for aux items)
184 CString sActionColumnText;
185 CTGitPath path;
186 CTGitPath basepath;
187 CString changelistname;
189 /// git_wc_notify_action_t action;
190 // git_node_kind_t kind;
191 CString mime_type;
192 // git_wc_notify_state_t content_state;
193 // git_wc_notify_state_t prop_state;
194 // git_wc_notify_lock_state_t lock_state;
195 // git_merge_range_t merge_range;
196 git_revnum_t rev;
197 COLORREF color;
198 CString owner; ///< lock owner
199 bool bConflictedActionItem; // Is this item a conflict?
200 bool bAuxItem; // Set if this item is not a true 'Git action'
201 CString sPathColumnText;
204 protected:
206 //Need update in the future implement the virtual methods from Git base class
207 virtual BOOL Notify(const CTGitPath& path,
208 git_wc_notify_action_t action,
209 int status = 0,
210 CString *strErr =NULL
212 git_node_kind_t kind, const CString& mime_type,
213 git_wc_notify_state_t content_state,
214 git_wc_notify_state_t prop_state, LONG rev,
215 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
216 const CString& changelistname,
217 git_merge_range_t * range,
218 git_error_t * err, apr_pool_t * pool*/
221 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
222 virtual BOOL OnInitDialog();
223 virtual BOOL Cancel();
224 virtual void OnCancel();
225 virtual BOOL PreTranslateMessage(MSG* pMsg);
226 virtual void DoDataExchange(CDataExchange* pDX);
228 afx_msg void OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
229 afx_msg void OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
230 afx_msg void OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
231 afx_msg void OnBnClickedLogbutton();
232 afx_msg void OnBnClickedOk();
233 afx_msg void OnBnClickedNoninteractive();
234 afx_msg void OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
235 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
236 afx_msg void OnClose();
237 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
238 afx_msg LRESULT OnGitProgress(WPARAM wParam, LPARAM lParam);
239 afx_msg void OnTimer(UINT_PTR nIDEvent);
240 afx_msg void OnEnSetfocusInfotext();
241 afx_msg void OnLvnBegindragSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
242 afx_msg void OnSize(UINT nType, int cx, int cy);
243 LRESULT OnShowConflictResolver(WPARAM, LPARAM);
245 DECLARE_MESSAGE_MAP()
247 void Sort();
248 static bool SortCompare(const NotificationData* pElem1, const NotificationData* pElem2);
250 static BOOL m_bAscending;
251 static int m_nSortedColumn;
252 CStringList m_ExtStack;
254 private:
255 static UINT ProgressThreadEntry(LPVOID pVoid);
256 UINT ProgressThread();
257 virtual void OnOK();
258 void ReportGitError();
259 void ReportError(const CString& sError);
260 void ReportWarning(const CString& sWarning);
261 void ReportNotification(const CString& sNotification);
262 void ReportCmd(const CString& sCmd);
263 void ReportString(CString sMessage, const CString& sMsgKind, COLORREF color = ::GetSysColor(COLOR_WINDOWTEXT));
264 void AddItemToList();
265 CString BuildInfoString();
266 CString GetPathFromColumnText(const CString& sColumnText);
269 * Resizes the columns of the progress list so that the headings are visible.
271 void ResizeColumns();
273 /// Predicate function to tell us if a notification data item is auxiliary or not
274 static bool NotificationDataIsAux(const NotificationData* pData);
276 // the commands to execute
277 bool CmdAdd(CString& sWindowTitle, bool& localoperation);
278 bool CmdCheckout(CString& sWindowTitle, bool& localoperation);
279 bool CmdCommit(CString& sWindowTitle, bool& localoperation);
280 bool CmdCopy(CString& sWindowTitle, bool& localoperation);
281 bool CmdExport(CString& sWindowTitle, bool& localoperation);
282 bool CmdImport(CString& sWindowTitle, bool& localoperation);
283 bool CmdLock(CString& sWindowTitle, bool& localoperation);
284 bool CmdMerge(CString& sWindowTitle, bool& localoperation);
285 bool CmdMergeAll(CString& sWindowTitle, bool& localoperation);
286 bool CmdMergeReintegrate(CString& sWindowTitle, bool& localoperation);
287 bool CmdRename(CString& sWindowTitle, bool& localoperation);
288 bool CmdResolve(CString& sWindowTitle, bool& localoperation);
289 bool CmdRevert(CString& sWindowTitle, bool& localoperation);
290 bool CmdSwitch(CString& sWindowTitle, bool& localoperation);
291 bool CmdUnlock(CString& sWindowTitle, bool& localoperation);
292 bool CmdUpdate(CString& sWindowTitle, bool& localoperation);
293 bool CmdSendMail(CString& sWindowTitle, bool& localoperation);
295 private:
296 typedef std::map<CStringA, git_revnum_t> StringRevMap;
297 typedef std::vector<NotificationData *> NotificationDataVect;
300 CString m_mergedfile;
301 NotificationDataVect m_arData;
303 CWinThread* m_pThread;
304 volatile LONG m_bThreadRunning;
306 ProjectProperties m_ProjectProperties;
307 CListCtrl m_ProgList;
308 Command m_Command;
309 int m_options; // Use values from the ProgressOptions enum
310 git_depth_t m_depth;
311 CTGitPathList m_targetPathList;
312 CTGitPathList m_selectedPaths;
313 CTGitPath m_url;
314 CTGitPath m_url2;
315 CString m_sMessage;
316 CString m_diffoptions;
317 GitRev m_Revision;
318 GitRev m_RevisionEnd;
319 GitRev m_pegRev;
320 // GitRevRangeArray m_revisionArray;
321 CString m_changelist;
322 bool m_keepchangelist;
324 DWORD m_dwCloseOnEnd;
326 CTGitPath m_basePath;
327 StringRevMap m_UpdateStartRevMap;
328 StringRevMap m_FinishedRevMap;
330 TCHAR m_columnbuf[MAX_PATH];
332 BOOL m_bCancelled;
333 int m_nConflicts;
334 bool m_bErrorsOccurred;
335 bool m_bMergesAddsDeletesOccurred;
337 int iFirstResized;
338 BOOL bSecondResized;
339 int nEnsureVisibleCount;
341 CString m_sTotalBytesTransferred;
343 CColors m_Colors;
345 bool m_bLockWarning;
346 bool m_bLockExists;
347 bool m_bFinishedItemAdded;
348 bool m_bLastVisible;
350 int m_itemCount;
351 int m_itemCountTotal;
353 bool m_AlwaysConflicted;
355 DWORD m_SendMailFlags;
356 CString m_SendMailTO;
357 CString m_SendMailCC;
358 CString m_SendMailSubject;
360 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
362 // some strings different methods can use
363 CString sIgnoredIncluded;
364 CString sExtExcluded;
365 CString sExtIncluded;
366 CString sIgnoreAncestry;
367 CString sRespectAncestry;
368 CString sDryRun;
369 CString sRecordOnly;