Exemple #1
0
LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
{
    if(wParam == MSG_PROGRESSDLG_START)
    {
        m_ctrlAnimate.Play(0, UINT_MAX, UINT_MAX);
        this->m_ctrlProgress.SetPos(0);
        if (m_pTaskbarList)
        {
            m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
            m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
        }
    }

    if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
    {
        DWORD tickSpent = GetTickCount() - m_startTick;
        CString strEndTime = CLoglistUtils::FormatDateAndTime(CTime::GetCurrentTime(), DATE_SHORTDATE, true, false);
        //m_bDone = true;
        m_ctrlAnimate.Stop();
        m_ctrlProgress.SetPos(100);
        //this->DialogEnableWindow(IDOK,TRUE);

        DWORD exitCode = (DWORD)lParam;
        if (exitCode)
        {
            if (m_pTaskbarList)
            {
                m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
                m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
            }
            CString log;
            log.Format(IDS_PROC_PROGRESS_GITUNCLEANEXIT, exitCode);
            CString err;
            err.Format(_T("\r\n\r\n%s (%d ms @ %s)\r\n"), log, tickSpent, strEndTime);
            CProgressDlg::InsertColorText(this->m_ctrlCmdOut, err, RGB(255,0,0));
        }
        else
        {
            if (m_pTaskbarList)
                m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
            CString temp;
            temp.LoadString(IDS_SUCCESS);
            CString log;
            log.Format(_T("\r\n%s (%d ms @ %s)\r\n"), temp, tickSpent, strEndTime);
            CProgressDlg::InsertColorText(this->m_ctrlCmdOut, log, RGB(0,0,255));
        }

        //if(wParam == MSG_PROGRESSDLG_END)
        RunPostAction();
    }

    if(lParam != 0)
        ParserCmdOutput((char)lParam);

    return 0;
}
Exemple #2
0
void CProgressDlg::ParserCmdOutput(char ch)
{
	ParserCmdOutput(this->m_Log,this->m_Progress,this->m_hWnd,this->m_pTaskbarList,this->m_LogTextA,ch,&this->m_CurrentWork);
}
Exemple #3
0
LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
{
	if(wParam == MSG_PROGRESSDLG_START)
	{
		m_BufStart = 0 ;
		m_Animate.Play(0,-1,-1);
		this->DialogEnableWindow(IDOK,FALSE);
		if (m_pTaskbarList)
		{
			m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
			m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
		}
	}
	if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
	{
		if(m_bBufferAll)
		{
			m_Databuf.m_critSec.Lock();
			m_Databuf.push_back(0);
			m_Databuf.m_critSec.Unlock();
			InsertCRLF();
			m_Databuf.m_critSec.Lock();
			m_Log.SetWindowText(Convert2UnionCode((char*)&m_Databuf[0]));
			m_Databuf.m_critSec.Unlock();
			m_Log.LineScroll(m_Log.GetLineCount() - m_Log.GetFirstVisibleLine() - 4);
		}
		m_BufStart=0;
		m_Databuf.m_critSec.Lock();
		this->m_Databuf.clear();
		m_Databuf.m_critSec.Unlock();

		m_bDone = true;
		m_Animate.Stop();
		m_Progress.SetPos(100);
		this->DialogEnableWindow(IDOK,TRUE);

		CString err;
		err.Format(_T("\r\nFailed 0x%x (git returned a wrong return code at some time)\r\n"),m_GitStatus);
		if(this->m_GitStatus)
		{
			if (m_pTaskbarList)
			{
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
				m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
			}
			//InsertColorText(this->m_Log,err,RGB(255,0,0));
		}
		else {
			if (m_pTaskbarList)
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
			InsertColorText(this->m_Log,_T("\r\nSuccess\r\n"),RGB(0,0,255));
			this->DialogEnableWindow(IDCANCEL,FALSE);
		}

		if(wParam == MSG_PROGRESSDLG_END && m_GitStatus == 0)
		{
			if(m_bAutoCloseOnSuccess)
				EndDialog(IDOK);

			if(m_PostCmdList.GetCount() > 0)
			{
				//GetDlgItem(IDC_PROGRESS_BUTTON1)->SetWindowText(m_changeAbortButtonOnSuccessTo);
				GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
				//GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
				//Set default button is "close" rather than "push"
				this->SendMessage(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDOK)->m_hWnd, TRUE);
			}
		}
	}

	if(!m_bBufferAll)
	{
		if(lParam == 0)
		{
			m_Databuf.m_critSec.Lock();
			for(int i=this->m_BufStart;i<this->m_Databuf.size();i++)
			{
				char c = this->m_Databuf[m_BufStart];
				m_BufStart++;
				m_Databuf.m_critSec.Unlock();
				ParserCmdOutput(c);

				m_Databuf.m_critSec.Lock();
			}

			if(m_BufStart>1000)
			{
				m_Databuf.erase(m_Databuf.begin(), m_Databuf.begin()+m_BufStart);
				m_BufStart =0;
			}
			m_Databuf.m_critSec.Unlock();

		}
		else
			ParserCmdOutput((char)lParam);
	}
	return 0;
}
Exemple #4
0
LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
{
	if(wParam == MSG_PROGRESSDLG_START)
	{
		m_BufStart = 0 ;
		m_Animate.Play(0, INT_MAX, INT_MAX);
		this->DialogEnableWindow(IDOK,FALSE);
		if (m_pTaskbarList)
		{
			m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
			m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
		}
	}
	if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
	{
		CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": got message: %d\n"), wParam);
		DWORD tickSpent = GetTickCount() - m_startTick;
		CString strEndTime = CLoglistUtils::FormatDateAndTime(CTime::GetCurrentTime(), DATE_SHORTDATE, true, false);

		if(m_bBufferAll)
		{
			m_Databuf.m_critSec.Lock();
			m_Databuf.push_back(0);
			m_Log.SetWindowText(Convert2UnionCode((char*)&m_Databuf[0]));
			m_Databuf.m_critSec.Unlock();
			m_Log.LineScroll(m_Log.GetLineCount() - m_Log.GetFirstVisibleLine() - 4);
		}
		m_BufStart=0;
		m_Databuf.m_critSec.Lock();
		this->m_Databuf.clear();
		m_Databuf.m_critSec.Unlock();

		m_bDone = true;
		m_Animate.Stop();
		m_Progress.SetPos(100);
		this->DialogEnableWindow(IDOK,TRUE);

		m_GitStatus = (DWORD)lParam;

		// detect crashes of perl when performing git svn actions
		if (m_GitStatus == 0 && m_GitCmd.Find(_T(" svn ")) > 1)
		{
			CString log;
			m_Log.GetWindowText(log);
			if (log.GetLength() > 18 && log.Mid(log.GetLength() - 18) == _T("perl.exe.stackdump"))
				m_GitStatus = (DWORD)-1;
		}

		if(this->m_GitStatus)
		{
			if (m_pTaskbarList)
			{
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
				m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
			}
			CString log;
			log.Format(IDS_PROC_PROGRESS_GITUNCLEANEXIT, m_GitStatus);
			CString err;
			err.Format(_T("\r\n\r\n%s (%lu ms @ %s)\r\n"), log, tickSpent, strEndTime);
			InsertColorText(this->m_Log, err, RGB(255,0,0));
			CSoundUtils::PlayTGitError();
		}
		else {
			if (m_pTaskbarList)
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
			CString temp;
			temp.LoadString(IDS_SUCCESS);
			CString log;
			log.Format(_T("\r\n%s (%lu ms @ %s)\r\n"), temp, tickSpent, strEndTime);
			InsertColorText(this->m_Log, log, RGB(0,0,255));
			this->DialogEnableWindow(IDCANCEL,FALSE);
		}

		if (wParam == MSG_PROGRESSDLG_END)
		{
			if (m_PostCmdCallback)	// new handling method using callback
			{
				m_PostCmdCallback(this, m_caller, m_GitStatus);

				if (m_PostCmdList.GetCount() > 0)
				{
					m_ctrlPostCmd.AddEntries(m_PostCmdList);
					GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
				}
			}
			else if (m_GitStatus == 0)	// default old behaviour on success
			{
				if (m_PostCmdList.GetCount() > 0)
				{
					m_ctrlPostCmd.AddEntries(m_PostCmdList);
					GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
				}
			}
			else	// simple method to show buttons on failed
			{
				if (m_PostFailCmdList.GetCount() > 0)
				{
					m_ctrlPostCmd.AddEntries(m_PostFailCmdList);
					GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
				}
			}
		}

		if(wParam == MSG_PROGRESSDLG_END && m_GitStatus == 0)
		{
			if(m_bAutoCloseOnSuccess)
			{
				m_Log.GetWindowText(this->m_LogText);
				EndDialog(IDOK);
			}
		}
	}

	if(!m_bBufferAll)
	{
		if(lParam == 0)
		{
			m_Databuf.m_critSec.Lock();
			for (size_t i = this->m_BufStart; i < this->m_Databuf.size(); ++i)
			{
				char c = this->m_Databuf[m_BufStart];
				++m_BufStart;
				m_Databuf.m_critSec.Unlock();
				ParserCmdOutput(c);

				m_Databuf.m_critSec.Lock();
			}

			if(m_BufStart>1000)
			{
				m_Databuf.erase(m_Databuf.begin(), m_Databuf.begin()+m_BufStart);
				m_BufStart =0;
			}
			m_Databuf.m_critSec.Unlock();

		}
		else
			ParserCmdOutput((char)lParam);
	}
	return 0;
}
Exemple #5
0
LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
{
	if(wParam == MSG_PROGRESSDLG_START)
	{
		m_BufStart = 0 ;
		m_Animate.Play(0,-1,-1);
		this->DialogEnableWindow(IDOK,FALSE);
		if (m_pTaskbarList)
		{
			m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
			m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
		}
	}
	if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
	{
		if(m_bBufferAll)
		{
			m_Databuf.m_critSec.Lock();
			m_Databuf.push_back(0);
			m_Databuf.m_critSec.Unlock();
			InsertCRLF();
			m_Databuf.m_critSec.Lock();
			m_Log.SetWindowText(Convert2UnionCode((char*)&m_Databuf[0]));
			m_Databuf.m_critSec.Unlock();
			m_Log.LineScroll(m_Log.GetLineCount() - m_Log.GetFirstVisibleLine() - 4);
		}
		m_BufStart=0;
		m_Databuf.m_critSec.Lock();
		this->m_Databuf.clear();
		m_Databuf.m_critSec.Unlock();

		m_bDone = true;
		m_Animate.Stop();
		m_Progress.SetPos(100);
		this->DialogEnableWindow(IDOK,TRUE);

		m_GitStatus = lParam;

		// detect crashes of perl when performing git svn actions
		if (m_GitStatus == 0 && m_GitCmd.Find(_T(" svn ")) > 1)
		{
			CString log;
			m_Log.GetWindowText(log);
			if (log.GetLength() > 18 && log.Mid(log.GetLength() - 18) == _T("perl.exe.stackdump"))
				m_GitStatus = -1;
		}

		if(this->m_GitStatus)
		{
			if (m_pTaskbarList)
			{
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
				m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
			}
			CString log;
			log.Format(IDS_PROC_PROGRESS_GITUNCLEANEXIT, m_GitStatus);
			CString err;
			err.Format(_T("\r\n\r\n%s\r\n"), log);
			InsertColorText(this->m_Log, err, RGB(255,0,0));
		}
		else {
			if (m_pTaskbarList)
				m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
			CString temp;
			temp.LoadString(IDS_SUCCESS);
			CString log;
			log.Format(_T("\r\n%s\r\n"), temp);
			InsertColorText(this->m_Log, log, RGB(0,0,255));
			this->DialogEnableWindow(IDCANCEL,FALSE);
		}

		if(wParam == MSG_PROGRESSDLG_END && m_GitStatus == 0)
		{
			if(m_bAutoCloseOnSuccess)
			{
				m_Log.GetWindowText(this->m_LogText);
				EndDialog(IDOK);
			}

			if(m_PostCmdList.GetCount() > 0)
				GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
		}
	}

	if(!m_bBufferAll)
	{
		if(lParam == 0)
		{
			m_Databuf.m_critSec.Lock();
			for(int i=this->m_BufStart;i<this->m_Databuf.size();i++)
			{
				char c = this->m_Databuf[m_BufStart];
				m_BufStart++;
				m_Databuf.m_critSec.Unlock();
				ParserCmdOutput(c);

				m_Databuf.m_critSec.Lock();
			}

			if(m_BufStart>1000)
			{
				m_Databuf.erase(m_Databuf.begin(), m_Databuf.begin()+m_BufStart);
				m_BufStart =0;
			}
			m_Databuf.m_critSec.Unlock();

		}
		else
			ParserCmdOutput((char)lParam);
	}
	return 0;
}
Exemple #6
0
LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
{
	if(wParam == MSG_PROGRESSDLG_START)
	{
		m_ctrlAnimate.Play(0,-1,-1);
		this->m_ctrlProgress.SetPos(0);
		if (m_pTaskbarList)
		{
			m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
			m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
		}
	}

	if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
	{
		//m_bDone = true;
		m_ctrlAnimate.Stop();
		m_ctrlProgress.SetPos(100);
		//this->DialogEnableWindow(IDOK,TRUE);
		if (m_pTaskbarList)
			m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);

		//if(wParam == MSG_PROGRESSDLG_END)
		if(this->m_CurrentCmd == GIT_COMMAND_PUSH )
		{
			if(!m_GitCmdStatus)
			{
				CTGitPathList list;
				list.AddPath(CTGitPath(g_Git.m_CurrentDir));
				DWORD exitcode;
				CString error;
				if (CHooks::Instance().PostPush(list,exitcode, error))
				{
					if (exitcode)
					{
						CString temp;
						temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
						//ReportError(temp);
						CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
						return false;
					}
				}

			}
			EnableControlButton(true);
			SwitchToInput();
			this->FetchOutList(true);
		}
		if(this->m_CurrentCmd == GIT_COMMAND_PULL )
		{
			PullComplete();
		}
		if(this->m_CurrentCmd == GIT_COMMAND_FETCH || this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
		{
			FetchComplete();
		}
		if(this->m_CurrentCmd == GIT_COMMAND_SUBMODULE)
		{
			//this->m_ctrlCmdOut.SetSel(-1,-1);
			//this->m_ctrlCmdOut.ReplaceSel(_T("Done\r\n"));
			//this->m_ctrlCmdOut.SetSel(-1,-1);
			EnableControlButton(true);
			SwitchToInput();
		}
		if(this->m_CurrentCmd == GIT_COMMAND_REMOTE)
		{
			this->FetchOutList(true);
			EnableControlButton(true);
			SwitchToInput();
		}
	}

	if(lParam != 0)
		ParserCmdOutput((char)lParam);

	return 0;
}