Fixed issue #1223: Workaround endless waiting when git.exe already exited
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.h
blob4330f7c0cf4505bd6bbc95e5764f655c93b6a744
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2012-2013 - 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 "afxcmn.h"
22 #include "afxwin.h"
24 #include "StandAloneDlg.h"
25 #include "HistoryCombo.h"
26 #include "MenuButton.h"
27 #include "registry.h"
28 #include "BranchCombox.h"
29 #include "GitLoglist.h"
30 #include "Win7.h"
31 #include "GitProgressList.h"
33 // CSyncDlg dialog
34 #define IDC_SYNC_TAB 0x1000000
36 #define IDC_CMD_LOG 0x1
37 #define IDC_IN_LOGLIST 0x2
38 #define IDC_IN_CHANGELIST 0x3
39 #define IDC_IN_CONFLICT 0x4
40 #define IDC_OUT_LOGLIST 0x5
41 #define IDC_OUT_CHANGELIST 0x6
42 #define IDC_CMD_GIT_PROG 0x7
44 #define IDT_INPUT 108
46 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox
48 DECLARE_DYNAMIC(CSyncDlg)
50 public:
51 CSyncDlg(CWnd* pParent = NULL); // standard constructor
52 virtual ~CSyncDlg();
54 // Dialog Data
55 enum { IDD = IDD_SYNC };
57 enum { GIT_COMMAND_PUSH,
58 GIT_COMMAND_PULL,
59 GIT_COMMAND_FETCH,
60 GIT_COMMAND_FETCHANDREBASE,
61 GIT_COMMAND_SUBMODULE,
62 GIT_COMMAND_REMOTE
64 protected:
65 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
66 BRANCH_COMBOX_EVENT_HANDLE();
68 virtual BOOL OnInitDialog();
69 afx_msg void OnBnClickedButtonManage();
70 virtual BOOL PreTranslateMessage(MSG* pMsg);
71 afx_msg void OnCbnEditchangeComboboxex();
72 afx_msg void OnBnClickedButtonPull();
73 afx_msg void OnBnClickedButtonPush();
74 afx_msg void OnBnClickedButtonApply();
75 afx_msg void OnBnClickedButtonEmail();
76 afx_msg void OnTimer(UINT_PTR nIDEvent);
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 CToolTips m_tooltips;
92 BOOL m_bInited;
94 CGitLogList m_OutLogList;
95 CGitLogList m_InLogList;
96 CGitProgressList m_GitProgressList;
98 CGitStatusListCtrl m_OutChangeFileList;
99 CGitStatusListCtrl m_InChangeFileList;
100 CGitStatusListCtrl m_ConflictFileList;
102 CRichEditCtrl m_ctrlCmdOut;
104 CTGitPathList m_arOutChangeList;
105 CTGitPathList m_arInChangeList;
107 int m_CmdOutCurrentPos;
109 CWinThread* m_pThread;
111 volatile LONG m_bBlock;
112 CGitByteArray m_Databuf;
113 int m_BufStart;
115 void ParserCmdOutput(char ch);
117 virtual void LocalBranchChange(){FetchOutList();};
118 virtual void RemoteBranchChange(){};
120 void ShowTab(int windowid)
122 this->m_ctrlTabCtrl.ShowTab(windowid-1);
123 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);
126 void FetchOutList(bool force=false);
128 bool IsURL();
130 void SetRemote(CString remote)
132 if(!remote.IsEmpty())
134 int index=this->m_ctrlURL.FindStringExact(0,remote);
135 if(index>=0)
137 m_ctrlURL.SetCurSel(index);
138 return;
140 this->m_ctrlURL.AddString(remote);
144 std::vector<CString> m_GitCmdList;
146 bool m_bAbort;
147 DWORD m_startTick;
149 int m_GitCmdStatus;
151 CStringA m_LogText;
152 CString m_OutLocalBranch;
153 CString m_OutRemoteBranch;
155 CGitHash m_oldHash;
157 void ShowProgressCtrl(bool bShow=true);
158 void ShowInputCtrl(bool bShow=true);
159 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
160 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
162 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
163 LRESULT OnProgCmdFinish(WPARAM wParam, LPARAM lParam);
164 void RunPostAction();
165 void UpdateCombox()
167 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
168 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
169 this->m_ctrlURL.GetWindowText(this->m_strURL);
170 m_strRemoteBranch=m_strRemoteBranch.Trim();
173 void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,
174 CString rev1, CString rev2)
176 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);
177 pCtrlList->m_Rev1=rev1;
178 pCtrlList->m_Rev2=rev2;
179 pCtrlList->Show(0,*pGitList);
180 pCtrlList->SetEmptyString(CString(_T("No changed file")));
181 return;
184 void PullComplete();
185 void FetchComplete();
187 DECLARE_MESSAGE_MAP()
189 public:
190 BOOL m_bAutoLoadPuttyKey;
191 BOOL m_bForce;
192 CString m_strURL;
194 protected:
195 int m_Gitverion;
197 static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };
198 UINT ProgressThread();
200 CHistoryCombo m_ctrlURL;
201 CButton m_ctrlDumyButton;
202 CMenuButton m_ctrlPull;
203 CMenuButton m_ctrlPush;
204 CStatic m_ctrlStatus;
205 CMenuButton m_ctrlSubmodule;
206 CProgressCtrl m_ctrlProgress;
207 CAnimateCtrl m_ctrlAnimate;
208 CStatic m_ctrlProgLabel;
210 void EnableControlButton(bool bEnabled=true);
211 afx_msg void OnBnClickedButtonCommit();
213 virtual void OnOK();
214 void Refresh();
216 afx_msg void OnBnClickedButtonSubmodule();
217 afx_msg void OnLvnInLogListColumnClick(NMHDR *pNMHDR, LRESULT *pResult);
218 afx_msg void OnBnClickedCheckForce();
219 afx_msg void OnBnClickedLog();