Wait and terminate background thread before destructing the window
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.h
bloba11ebb744271d02eaab9301736026ad4a9045ea0
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2012-2016 - TortoiseGit
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.
20 #pragma once
21 #include "StandAloneDlg.h"
22 #include "HistoryCombo.h"
23 #include "MenuButton.h"
24 #include "registry.h"
25 #include "BranchCombox.h"
26 #include "GitLoglist.h"
27 #include "GitProgressList.h"
28 #include "GitRefCompareList.h"
30 // CSyncDlg dialog
31 #define IDC_SYNC_TAB 0x1000000
33 #define IDC_CMD_LOG 0x1
34 #define IDC_IN_LOGLIST 0x2
35 #define IDC_IN_CHANGELIST 0x3
36 #define IDC_IN_CONFLICT 0x4
37 #define IDC_OUT_LOGLIST 0x5
38 #define IDC_OUT_CHANGELIST 0x6
39 #define IDC_CMD_GIT_PROG 0x7
40 #define IDC_REFLIST 0x8
42 #define IDT_INPUT 108
44 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox
46 DECLARE_DYNAMIC(CSyncDlg)
48 public:
49 CSyncDlg(CWnd* pParent = NULL); // standard constructor
50 virtual ~CSyncDlg();
52 // Dialog Data
53 enum { IDD = IDD_SYNC };
55 enum { GIT_COMMAND_PUSH,
56 GIT_COMMAND_PULL,
57 GIT_COMMAND_FETCH,
58 GIT_COMMAND_FETCHANDREBASE,
59 GIT_COMMAND_SUBMODULE,
60 GIT_COMMAND_REMOTE,
61 GIT_COMMAND_STASH
63 protected:
64 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
65 BRANCH_COMBOX_EVENT_HANDLE();
67 virtual BOOL OnInitDialog();
68 afx_msg void OnBnClickedButtonManage();
69 virtual BOOL PreTranslateMessage(MSG* pMsg);
70 afx_msg void OnCbnEditchangeComboboxex();
71 afx_msg void OnBnClickedButtonPull();
72 afx_msg void OnBnClickedButtonPush();
73 afx_msg void OnBnClickedButtonApply();
74 afx_msg void OnBnClickedButtonEmail();
75 afx_msg void OnTimer(UINT_PTR nIDEvent);
76 afx_msg void OnDestroy();
78 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
79 CComPtr<ITaskbarList3> m_pTaskbarList;
81 int m_CurrentCmd;
83 CRegDWORD m_regPullButton;
84 CRegDWORD m_regPushButton;
85 CRegDWORD m_regSubmoduleButton;
86 CRegDWORD m_regAutoLoadPutty;
88 CMFCTabCtrl m_ctrlTabCtrl;
90 BOOL m_bInited;
92 CGitLogList m_OutLogList;
93 CGitLogList m_InLogList;
94 CGitProgressList m_GitProgressList;
96 CGitStatusListCtrl m_OutChangeFileList;
97 CGitStatusListCtrl m_InChangeFileList;
98 CGitStatusListCtrl m_ConflictFileList;
100 CRichEditCtrl m_ctrlCmdOut;
101 CGitRefCompareList m_refList;
103 CTGitPathList m_arOutChangeList;
104 CTGitPathList m_arInChangeList;
106 int m_CmdOutCurrentPos;
108 CWinThread* m_pThread;
110 volatile LONG m_bBlock;
111 CGitGuardedByteArray m_Databuf;
112 int m_BufStart;
114 void ParserCmdOutput(char ch);
116 virtual void LocalBranchChange(){FetchOutList();};
117 virtual void RemoteBranchChange(){};
119 void ShowTab(int windowid)
121 this->m_ctrlTabCtrl.ShowTab(windowid-1);
122 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);
125 void FetchOutList(bool force=false);
127 bool IsURL();
129 void SetRemote(CString remote)
131 if(!remote.IsEmpty())
133 int index=this->m_ctrlURL.FindStringExact(0,remote);
134 if(index>=0)
136 m_ctrlURL.SetCurSel(index);
137 return;
139 this->m_ctrlURL.AddString(remote);
143 std::vector<CString> m_GitCmdList;
145 volatile bool m_bAbort;
146 bool m_bDone;
147 ULONGLONG m_startTick;
148 bool m_bWantToExit;
150 int m_GitCmdStatus;
152 CStringA m_LogText;
153 CString m_OutLocalBranch;
154 CString m_OutRemoteBranch;
156 CGitHash m_oldHash;
157 CGitHash m_oldRemoteHash;
158 MAP_HASH_NAME m_oldHashMap;
159 MAP_HASH_NAME m_newHashMap;
161 void ShowProgressCtrl(bool bShow=true);
162 void ShowInputCtrl(bool bShow=true);
163 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
164 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
166 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
167 LRESULT OnProgCmdFinish(WPARAM wParam, LPARAM lParam);
168 void FillNewRefMap();
169 void RunPostAction();
170 void UpdateCombox()
172 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
173 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
174 this->m_ctrlURL.GetWindowText(this->m_strURL);
175 m_strRemoteBranch=m_strRemoteBranch.Trim();
178 void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,
179 CString rev1, CString rev2)
181 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);
182 pCtrlList->m_Rev1=rev1;
183 pCtrlList->m_Rev2=rev2;
184 pCtrlList->Show(0,*pGitList);
185 pCtrlList->SetEmptyString(CString(MAKEINTRESOURCE(IDS_COMPAREREV_NODIFF)));
186 return;
189 void PullComplete();
190 void FetchComplete();
191 void StashComplete();
193 DECLARE_MESSAGE_MAP()
195 public:
196 BOOL m_bAutoLoadPuttyKey;
197 BOOL m_bForce;
198 CString m_strURL;
199 int m_seq;
201 protected:
202 static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };
203 UINT ProgressThread();
205 CHistoryCombo m_ctrlURL;
206 CButton m_ctrlDumyButton;
207 CMenuButton m_ctrlPull;
208 CMenuButton m_ctrlPush;
209 CStatic m_ctrlStatus;
210 CMenuButton m_ctrlSubmodule;
211 CMenuButton m_ctrlStash;
212 CProgressCtrl m_ctrlProgress;
213 CAnimateCtrl m_ctrlAnimate;
214 CStatic m_ctrlProgLabel;
215 int m_iPullRebase;
217 void EnableControlButton(bool bEnabled=true);
218 afx_msg void OnBnClickedButtonCommit();
220 virtual void OnOK();
221 void OnCancel();
222 void Refresh();
224 afx_msg void OnBnClickedButtonSubmodule();
225 afx_msg void OnBnClickedButtonStash();
226 afx_msg void OnLvnInLogListColumnClick(NMHDR *pNMHDR, LRESULT *pResult);
227 afx_msg void OnBnClickedCheckForce();
228 afx_msg void OnBnClickedLog();