Esempio n. 1
0
BOOL AFX_GLOBAL_DATA::ExcludeTag(CString& strBuffer, LPCTSTR lpszTag, CString& strTag, BOOL bIsCharsList /* = FALSE*/)
{
	const int iBufLen = strBuffer.GetLength();

	CString strTagStart = _T("<");
	strTagStart += lpszTag;
	strTagStart += _T(">");

	const int iTagStartLen = strTagStart.GetLength();

	int iStart = -1;

	int iIndexStart = strBuffer.Find(strTagStart);
	if (iIndexStart < 0)
	{
		return FALSE;
	}

	iStart = iIndexStart + iTagStartLen;

	CString strTagEnd = _T("</");
	strTagEnd += lpszTag;
	strTagEnd += _T('>');

	const int iTagEndLen = strTagEnd.GetLength();

	int iIndexEnd =  -1;
	int nBalanse = 1;
	for (int i = iStart; i < iBufLen - iTagEndLen + 1; i ++)
	{
		if (strBuffer [i] != '<')
		{
			continue;
		}

		if (i < iBufLen - iTagStartLen && _tcsncmp(strBuffer.Mid(i), strTagStart, iTagStartLen) == 0)
		{
			i += iTagStartLen - 1;
			nBalanse ++;
			continue;
		}

		if (_tcsncmp(strBuffer.Mid(i), strTagEnd, iTagEndLen) == 0)
		{
			nBalanse --;
			if (nBalanse == 0)
			{
				iIndexEnd = i;
				break;
			}

			i += iTagEndLen - 1;
		}
	}

	if (iIndexEnd == -1 || iStart > iIndexEnd)
	{
		return FALSE;
	}

	strTag = strBuffer.Mid(iStart, iIndexEnd - iStart);
	strTag.TrimLeft();
	strTag.TrimRight();

	strBuffer.Delete(iIndexStart, iIndexEnd + iTagEndLen - iIndexStart);

	if (bIsCharsList)
	{
		if (strTag.GetLength() > 1 && strTag [0] == _T('\"'))
		{
			strTag = strTag.Mid(1, strTag.GetLength() - 2);
		}

		strTag.Replace(_T("\\t"), _T("\t"));
		strTag.Replace(_T("\\n"), _T("\n"));
		strTag.Replace(_T("\\r"), _T("\r"));
		strTag.Replace(_T("\\b"), _T("\b"));
		strTag.Replace(_T("LT"), _T("<"));
		strTag.Replace(_T("GT"), _T(">"));
		strTag.Replace(_T("AMP"), _T("&"));
	}

	return TRUE;
}
Esempio n. 2
0
bool CSubtitleDlDlg::Parse()
{
    // Parse raw list
    isdb_movie m;
    isdb_subtitle sub;

    CAtlList<CStringA> sl;
    Explode(m_pTA->raw_list, sl, '\n');
    CString str;

    POSITION pos = sl.GetHeadPosition();
    while (pos) {
        str = sl.GetNext(pos);

        CStringA param = str.Left(max(0, str.Find('=')));
        CStringA value = str.Mid(str.Find('=') + 1);

        if (param == "ticket") {
            m_pTA->ticket = value;
        } else if (param == "movie") {
            m.reset();
            Explode(value, m.titles, '|');
        } else if (param == "subtitle") {
            sub.reset();
            sub.id = atoi(value);
        } else if (param == "name") {
            sub.name = value;
        } else if (param == "discs") {
            sub.discs = atoi(value);
        } else if (param == "disc_no") {
            sub.disc_no = atoi(value);
        } else if (param == "format") {
            sub.format = value;
        } else if (param == "iso639_2") {
            sub.iso639_2 = value;
        } else if (param == "language") {
            sub.language = value;
        } else if (param == "nick") {
            sub.nick = value;
        } else if (param == "email") {
            sub.email = value;
        } else if (param == "" && value == "endsubtitle") {
            m.subs.AddTail(sub);
        } else if (param == "" && value == "endmovie") {
            m_pTA->raw_movies.AddTail(m);
        } else if (param == "" && value == "end") {
            break;
        }
    }

    // Parse movies
    pos = m_pTA->raw_movies.GetHeadPosition();
    while (pos) {
        isdb_movie& raw_movie = m_pTA->raw_movies.GetNext(pos);
        isdb_movie_parsed p;

        CStringA titlesA = Implode(raw_movie.titles, '|');
        titlesA.Replace("|", ", ");
        p.titles = UTF8To16(titlesA);
        p.checked = false;

        POSITION pos2 = raw_movie.subs.GetHeadPosition();
        while (pos2) {
            const isdb_subtitle& s = raw_movie.subs.GetNext(pos2);
            p.name = UTF8To16(s.name);
            p.language = s.language;
            p.format = s.format;
            p.disc.Format(_T("%d/%d"), s.disc_no, s.discs);
            p.ptr = reinterpret_cast<DWORD_PTR>(&s);

            m_parsed_movies.Add(p);
        }
    }

    bool ret = true;
    if (m_parsed_movies.GetCount() == 0) {
        ret = false;
    }

    return ret;
}
Esempio n. 3
0
bool CHexFileList::ReadFile()
{
	CStdioFile ff;                      // Text file we are reading from
	CFileException fe;                  // Stores file exception info
	CString strLine;                    // One line read in from the file

	// Open the file
	if (!ff.Open(filename_, CFile::modeRead|CFile::shareDenyWrite|CFile::typeText, &fe))
		return false;

	// Read all the recent file names (and associated data) from the file
	ver_ = -1;
	for (int line_no = 0; ff.ReadString(strLine); ++line_no)
	{
		// Ignore comment lines
		if (strLine[0] == ';')
		{
			// Get file version from 1st comment line
			if (line_no == 0 && _strnicmp(strLine, "; version ", 10) == 0)
				ver_ = atoi((const char *)strLine + 10);
			if (ver_ > 4)
				return false;   // Can't handle new fileformat in this old program
			continue;
		}

		CString ss;

		// Get the file's name
		AfxExtractSubString(ss, strLine, 0, '|');
		if (ss.IsEmpty()) continue;
		name_.push_back(ss);
		ss.MakeUpper();
		hash_.push_back(str_hash(ss));

		// Get the last opened date
		AfxExtractSubString(ss, strLine, 1, '|');
		time_t tt = strtol(ss, NULL, 10);
		opened_.push_back(tt);

		if (ver_ > 3)
		{
			AfxExtractSubString(ss, strLine, 2, '|');
			open_count_.push_back(strtol(ss, NULL, 10));
		}
		else
			open_count_.push_back(1);   // it must have been opened at least once before

		// Get the data string
		int curr;                           // Where in the input string the extra data is stored

		ss.Empty();                         // Default data
		if (ver_ > 3)
		{
			// Skip 1st three vertical bars (|)
			if ((curr = strLine.Find('|')) != -1  && (curr = strLine.Find('|', curr+1)) != -1 && (curr = strLine.Find('|', curr+1)) != -1)
				ss = strLine.Mid(curr+1);
		}
		else
		{
			// Skip 1st two vertical bars (|)
			if ((curr = strLine.Find('|')) != -1  && (curr = strLine.Find('|', curr+1)) != -1)
				ss = strLine.Mid(curr+1);
		}


		data_.push_back(ss);
	}

	ff.Close();

	int max_keep = 20000;

	if (name_.size() > max_keep)
	{
		CString ss;
		ss.Format("Truncated recent file list to most recent %d files", max_keep);
		name_.erase(name_.begin(), name_.begin() + (name_.size() - max_keep));
		hash_.erase(hash_.begin(), hash_.begin() + (hash_.size() - max_keep));
		opened_.erase(opened_.begin(), opened_.begin() + (opened_.size() - max_keep));
		open_count_.erase(open_count_.begin(), open_count_.begin() + (open_count_.size() - max_keep));
		data_.erase(data_.begin(), data_.begin() + (data_.size() - max_keep));
	}

	ASSERT(hash_.size() == name_.size());
	ASSERT(opened_.size() == name_.size());
	ASSERT(open_count_.size() == name_.size());
	ASSERT(data_.size() == name_.size());

	return true;
}
Esempio n. 4
0
void CMuleToolbarCtrl::Init(void)
{
	m_astrToolbarPaths.RemoveAll();

	// Win98: Explicitly set to Unicode to receive Unicode notifications.
	SendMessage(CCM_SETUNICODEFORMAT, TRUE);

	ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_ALTDRAG | CCS_ADJUSTABLE | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | CCS_NODIVIDER);
	if (thePrefs.GetUseReBarToolbar())
	{
		ModifyStyle(0, CCS_NORESIZE);
		SetExtendedStyle(GetExtendedStyle() | TBSTYLE_EX_HIDECLIPPEDBUTTONS);
	}

	ChangeToolbarBitmap(thePrefs.GetToolbarBitmapSettings(), false);

	// add button-text:
	TCHAR cButtonStrings[2000];
	int lLen, lLen2;
	m_buttoncount = 0;
	
	_tcscpy(cButtonStrings, GetResString(IDS_MAIN_BTN_CONNECT));
	lLen = _tcslen(GetResString(IDS_MAIN_BTN_CONNECT)) + 1;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_KADEMLIA)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_KADEMLIA), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_SERVER)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SERVER), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_TRANS)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_TRANS), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_SEARCH)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SEARCH), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_FILES)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_FILES), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_MESSAGES)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_MESSAGES), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_IRC)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_IRC), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_STATISTIC)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_STATISTIC), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_PREFS)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_PREFS), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_TOOLS)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_TOOLS), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_HELP)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_HELP), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	// terminate
	memcpy(cButtonStrings+lLen, _T("\0"), sizeof(TCHAR));

	AddStrings(cButtonStrings);

	// initialize buttons:	
	for(int i = 0; i < m_buttoncount; i++)
	{		
		TBButtons[i].fsState	= TBSTATE_ENABLED;
		TBButtons[i].fsStyle	= TBSTYLE_CHECKGROUP;
		TBButtons[i].idCommand	= IDC_TOOLBARBUTTON + i;
		TBButtons[i].iString	= i;

		switch (TBButtons[i].idCommand)
		{
			case TBBTN_CONNECT:
			case TBBTN_OPTIONS:
			case TBBTN_TOOLS:
			case TBBTN_HELP:
				TBButtons[i].fsStyle = TBSTYLE_BUTTON;
				break;
		}
	}

	// set button image indices
	int iBitmap = 0;
	for (int i = 0; i < m_buttoncount; i++)
	{		
		TBButtons[i].iBitmap = iBitmap;
		if (TBButtons[i].idCommand == TBBTN_CONNECT) // 'Connect' button has 3 states
			iBitmap += 3;
		else
			iBitmap += 1;
	}
	
	TBBUTTON sepButton = {0};
	sepButton.idCommand = 0;
	sepButton.fsStyle = TBSTYLE_SEP;
	sepButton.fsState = TBSTATE_ENABLED;
	sepButton.iString = -1;
	sepButton.iBitmap = -1;
	
	CString config = thePrefs.GetToolbarSettings();
	for (int i = 0; i < config.GetLength(); i += 2)
	{
		int index = _tstoi(config.Mid(i, 2));
		if (index == 99)
		{
			AddButtons(1, &sepButton);
			continue;
		}
		AddButtons(1, &TBButtons[index]);
	}

	// recalc toolbar-size
	SetAllButtonsStrings();
	ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true);
	SetAllButtonsWidth();	// then calc and set the button width
	AutoSize();				// and finally call the original (but maybe obsolete) function
	SaveCurHeight();
}
Esempio n. 5
0
void CDlgAutoRegister::OnBnClickedOk()
{
	if (!SaveConfig())
		return;

	FILE *fp;
	if ((fp=fopen(CT2A(m_strFilePath), "r"))==NULL) {
		CString strErr;
		strErr.Format(_T("启动失败, 无法打开文件%s"), m_strFilePath);
		AfxMessageBox(strErr);
		return;
	}

	m_btnStart.EnableWindow(FALSE);

	// 读取文件,证件信息
	while(1) {
		char buf[200] = {0};

		if (!fgets(buf, 200, fp))
		{
			break;
		}

		CString str = CA2T(buf);
		str.Trim();
		int nSpace = str.Find(_T(' '));
		if (nSpace < 0) continue;
		int nSpace2 = str.ReverseFind(_T(' '));
		if (nSpace2 < 0) continue;

		IDInfo info;
		ZeroMemory(&info, sizeof(info));
		_tcscpy(info.idNumber, str.Mid(0, nSpace));
		_tcscpy(info.name, str.Mid(nSpace2 + 1));
		if (_tcslen(info.idNumber) != 18)
		{
			continue;
		}
		info.sex = (BYTE)(info.idNumber[16] - _T('0')) % 2;

		GXX_TRACE(_T("%s %s"), info.idNumber, info.name);

		m_arrayIDs.push_back(info);
	}

	COleDateTime begTime;
	COleDateTime curTime = COleDateTime::GetCurrentTime();
	if(m_config.m_startTime < curTime)
	{
		begTime = curTime;
	}
	else
	{
		begTime = m_config.m_startTime;
	}
	
	COleDateTime timeTodayEnd;
	// 结束时间不是今天
	if(m_config.m_startTime.GetDay() != m_config.m_endTime.GetDay())
	{
		timeTodayEnd.SetDateTime(begTime.GetYear(), begTime.GetMonth(), begTime.GetDay(), 23,59,59);
	}
	else
	{
		timeTodayEnd = m_config.m_endTime;
	}

	int dBeginDaySeconds = GetSeconds(timeTodayEnd, begTime);

	double dBeginDayInterval = (double)dBeginDaySeconds / (double)m_config.m_array24Amount[0];		// 第一天单位间隔开户时间
	if(0 == m_config.m_array24Amount.size())
		return ;

	m_arrayTasks.clear();
	int iIdIndex = 0;
	// 获取第一天的开户数组
	std::vector<int> vecRegMoneyBeginDay;
	GetRegisterMoneyArr(m_config.m_array24Amount[0], vecRegMoneyBeginDay);
	for(size_t i = 1; i < vecRegMoneyBeginDay.size(); i++)
	{
		TaskNode tn;
		tn.idInfo = m_arrayIDs[iIdIndex];
		tn.nDeltaSeconds = vecRegMoneyBeginDay[i] * dBeginDayInterval;
		tn.nAmount = vecRegMoneyBeginDay[i] * 100;

		m_arrayTasks.push_back(tn);
		iIdIndex++;
		if(iIdIndex >= m_arrayIDs.size())
		{
			iIdIndex = 0;
		}
	}

	if(2 <= m_config.m_array24Amount.size())
	{
		// 获取最后一天的开户数组
		COleDateTime timeEndDayEnd;
		timeEndDayEnd.SetDateTime(m_config.m_endTime.GetYear(), m_config.m_endTime.GetMonth(), m_config.m_endTime.GetDay(), 23,59,59);
		int dEndDaySeconds = GetSeconds(timeEndDayEnd, m_config.m_endTime);

		double dEndInterval = (double)dEndDaySeconds / (double)m_config.m_array24Amount[m_config.m_array24Amount.size() - 1];		// 最后一天单位间隔开户时间

		std::vector<int> vecRegMoneyEndDay;
		GetRegisterMoneyArr(m_config.m_array24Amount[m_config.m_array24Amount.size() - 1], vecRegMoneyEndDay);
		for(size_t i = 1; i < vecRegMoneyEndDay.size(); i++)
		{
			TaskNode tn;
			tn.idInfo = m_arrayIDs[iIdIndex];
			tn.nDeltaSeconds = vecRegMoneyEndDay[i] * dEndInterval;
			tn.nAmount = vecRegMoneyEndDay[i] * 100;

			m_arrayTasks.push_back(tn);
			iIdIndex++;
			if(iIdIndex >= m_arrayIDs.size())
			{
				iIdIndex = 0;
			}
		}

		// 获取中间天数
		int i = m_arrayTasks.size();
		std::vector<int> vecRegMoney24;
		for(size_t i = 1; i < m_config.m_array24Amount.size() - 1; i++)
		{
			GetRegisterMoneyArr(m_config.m_array24Amount[i], vecRegMoney24);
			double d24Interval = (double)(24 * 60 * 60) / (double)m_config.m_array24Amount[i];
			for(size_t i = 1; i < vecRegMoney24.size(); i++)
			{
				TaskNode tn;
				tn.idInfo = m_arrayIDs[iIdIndex];
				tn.nDeltaSeconds = vecRegMoney24[i] * d24Interval;
				tn.nAmount = vecRegMoney24[i] * 100;

				m_arrayTasks.push_back(tn);
				iIdIndex++;
				if(iIdIndex >= m_arrayIDs.size())
				{
					iIdIndex = 0;
				}
			}
			int i = m_arrayTasks.size();
			vecRegMoney24.clear();
		}

	}

	m_theThread1.SetCallBack(this, CDlgAutoRegister::Run);
	m_theThread1.Start();

	m_theThread2.SetCallBack(this, CDlgAutoRegister::Run2);
	m_theThread2.Start();

	m_theThread3.SetCallBack(this, CDlgAutoRegister::Run3);
	m_theThread3.Start();
}
Esempio n. 6
0
void CuDlgSqlQueryPageXML::OnButtonSave() 
{
	CWaitCursor doWaitCursor;
	CString strFullName;
	CFileDialog dlg(
	    FALSE,
	    NULL,
	    NULL,
	    OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
	    _T("XML Files (*.xml)|*.xml||"));

	ASSERT(m_pQueryRowParam);
	if (!m_pQueryRowParam)
		return;
	if (dlg.DoModal() != IDOK)
		return; 
	strFullName = dlg.GetPathName ();
	int nDot = strFullName.ReverseFind(_T('.'));
	if (nDot==-1)
	{
		strFullName += _T(".xml");
	}
	else
	{
		CString strExt = strFullName.Mid(nDot+1);
		if (strExt.IsEmpty())
			strFullName += _T("xml");
		else
		if (strExt.CompareNoCase (_T("xml")) != 0)
			strFullName += _T(".xml");
	}
	if (strFullName.IsEmpty())
		return;

	if (m_bXMLSource || m_pQueryRowParam->IsAlreadyGeneratedXML())
	{
		CopyFile (m_pQueryRowParam->GetFileXML(), strFullName, FALSE);
	}
	else
	{
		const int nSize = 2048;
		TCHAR tchszBuffer[nSize + 1];
		CFile rf(m_pQueryRowParam->GetFileXSL(), CFile::modeRead);
		CFile wf(strFullName, CFile::modeCreate|CFile::modeWrite);

		//
		// Construct XML file from from the translated XMLXSL file:
		DWORD dw = rf.Read(tchszBuffer, nSize);
		tchszBuffer[dw] = _T('\0');
		BOOL bFoundStylesheet = FALSE;
		CString strLine = _T("");
		while (dw > 0)
		{
			strLine += tchszBuffer;

			if (!bFoundStylesheet)
			{
				int nPos0x0d = strLine.Find((TCHAR)0x0d);
				while (nPos0x0d != -1)
				{
					CString strHeaderLine = strLine.Left(nPos0x0d);
					strHeaderLine.MakeLower();
					if (strHeaderLine.Find(_T("<?xml-stylesheet type")) == 0)
					{
						bFoundStylesheet = TRUE;
					}
					else
					{
						strHeaderLine = strLine.Left(nPos0x0d);
						wf.Write ((const void*)(LPCTSTR)strHeaderLine, strHeaderLine.GetLength());
						wf.Write ((const void*)consttchszReturn, _tcslen(consttchszReturn));
					}

					if (strLine.GetAt(nPos0x0d+1) == 0x0a)
						strLine = strLine.Mid(nPos0x0d+2);
					else
						strLine = strLine.Mid(nPos0x0d+1);
					if (strLine.IsEmpty())
					{
						dw = rf.Read(tchszBuffer, nSize);
						tchszBuffer[dw] = _T('\0');

						break;
					}

					if (bFoundStylesheet)
						break;
					nPos0x0d = strLine.Find((TCHAR)0x0d);
				}
				dw = rf.Read(tchszBuffer, nSize);
				tchszBuffer[dw] = _T('\0');
			}
			else
			{
				wf.Write((const void*)(LPCTSTR)strLine, strLine.GetLength());
				strLine = _T("");

				dw = rf.Read(tchszBuffer, nSize);
				tchszBuffer[dw] = _T('\0');
			}
		}

		wf.Flush();
	}
}
Esempio n. 7
0
// 서버접속처리
void CConnectDlg::OnButtonConnect() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CString ip;

	if(m_nClient == 0){	// 클라이언트
		if(m_strServerName == ""){
			MessageBox("서버이름을 확인하세요!");
			GetDlgItem(IDC_EDIT_SERVERNAME)->SetFocus();
			return;
		}

		m_ipAddressServerIP.GetWindowText(ip);
		if(ip == "0.0.0.0"){
			MessageBox("서버IP 를 확인하세요!");
			GetDlgItem(IDC_IPADDRESS_SERVERIP)->SetFocus();
			return;
		}
	}

	// 서버라도 이부분을 체크
	if(m_strUserID == ""){
		MessageBox("사용자 아이디를 확인하세요!");
		GetDlgItem(IDC_EDIT_USERID)->SetFocus();
		return;
	}

	// 소켓연결(접속처리)
	((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_strUserID = m_strUserID;
	((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_bIsClient = m_nClient;	// 클라이언트인지 서버인지
	((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_strSevrIP = ip;

	((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_bViewFolder = m_bViewFolder;
	((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.InitSock();
	if(((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_nErrorCode != 0){	// 접속실패시
		AfxMessageBox("접속에 실패했습니다\n다시 접속하십시요!");
		return;
	}

	// 접속할때 환경설정값을 넣어준다
	CMainFrame *pMain = (CMainFrame *)AfxGetMainWnd();
	pMain->m_cPreferencesValue.DirectoryLoadFile(&(pMain->m_cPreferencesValue.m_strFolderTemp), &(pMain->m_cPreferencesValue.m_strFolderInComing), 
		&(pMain->m_cPreferencesValue.m_strFolderShare));
	pMain->m_cPreferencesValue.DirectoryLoadFile(&(pMain->m_cPreferencesValue.m_strFolderTemp), &(pMain->m_cPreferencesValue.m_strFolderInComing), 
		&(pMain->m_cPreferencesValue.m_strFolderShare));
	pMain->m_cPreferencesValue.DisplayLoadFile(&(pMain->m_cPreferencesValue.m_bDeleteComplete), &(pMain->m_cPreferencesValue.m_nPopupTime), 
		&(pMain->m_cPreferencesValue.m_bPopupConnect), &(pMain->m_cPreferencesValue.m_bPopupDisconnect), &(pMain->m_cPreferencesValue.m_bPopupCompleteDownload));
	
	// 쓰레드에서 이폴더값을 접근을 못해서 여기서 값을넣어준다
	pMain->m_myIOCPSocket.m_strFolderInComing = pMain->m_cPreferencesValue.m_strFolderInComing;
	pMain->m_myIOCPSocket.m_strFolderTemp = pMain->m_cPreferencesValue.m_strFolderTemp;
	pMain->m_myIOCPSocket.m_strFolderShare = pMain->m_cPreferencesValue.m_strFolderShare;

	// 하드의 용량을 알아내서 status 바에 넣는다	
	CString strUNC;
	pMain->m_cPreferencesValue.DirectoryLoadFile(&pMain->m_cPreferencesValue.m_strFolderTemp, &pMain->m_cPreferencesValue.m_strFolderInComing, &pMain->m_cPreferencesValue.m_strFolderShare);
	strUNC.Format(pMain->m_cPreferencesValue.m_strFolderInComing.Left(1));
	strUNC = strUNC + ":\\";
	ULARGE_INTEGER ulAvailable, ulTotal, ulFree;
	GetDiskFreeSpaceEx((LPCTSTR)strUNC, &ulAvailable, &ulTotal, &ulFree);
	double nFree, nTotal;
	if(ulAvailable.QuadPart){	
		nFree = ulAvailable.LowPart+(double)ulAvailable.HighPart*(double)4294967296;
		nTotal = ulTotal.LowPart+(double)ulTotal.HighPart*(double)4294967296;
	}
	CString strFree;
	strFree.Format("%f", nFree);
 	int cnt = strFree.Find(".", 0);
	strFree = strFree.Mid(0, cnt - 7);	// 8은 기가바이트로 나타낼경우 소수점이상의 수치에서 9자리가 기가바이트(12.34 GB)
	strFree.Format("(%s:)%s.%s GB Free", strUNC.Left(1), strFree.Left(strFree.GetLength() - 2), strFree.Right(2));
	pMain->m_wndStatusBar.SetPaneText(1, strFree);

	// status 바, upload, download
	CString strStatus;
	pMain->m_cPreferencesValue.ConnectLoadFile(&pMain->m_cPreferencesValue.m_nDownloadSpeed, &pMain->m_cPreferencesValue.m_nUploadSpeed);
	strStatus.Format("%d개 - %d kB/s", 0, pMain->m_cPreferencesValue.m_nUploadSpeed);
	pMain->m_wndStatusBar.SetPaneText(2, strStatus);
	strStatus.Format("%d개 - %d kB/s", 0, pMain->m_cPreferencesValue.m_nDownloadSpeed);
	pMain->m_wndStatusBar.SetPaneText(3, strStatus);


	EndDialog(IDYES);
}
Esempio n. 8
0
CGnuDownloadShell* CGnuTransfers::LoadDownloadHosts(CString FilePath)
{
	// Check if file already loaded
	for(int i = 0; i < m_DownloadList.size(); i++)
		if( m_DownloadList[i]->m_BackupPath.CompareNoCase(FilePath) == 0 )
			return NULL;


	CStdioFile BackupFile;

	CString NextLine;
	CString Backup;
	
	if (BackupFile.Open(FilePath, CFile::modeRead))
	{
		while (BackupFile.ReadString(NextLine))
			Backup += NextLine + "\n";

		BackupFile.Abort();
	}

	if(Backup.IsEmpty() || Backup.Find("[Download]") == -1)
		return NULL;

	int CurrentPos = Backup.Find("[Download]");

	CGnuDownloadShell* Download = new CGnuDownloadShell(this);
	
	Download->m_ShellStatus		= (CGnuDownloadShell::Status) atoi(GetBackupString("Status", CurrentPos, Backup));
	Download->m_Name			= GetBackupString("Name", CurrentPos, Backup);
	Download->m_FileLength		= _atoi64(GetBackupString("FileLength", CurrentPos, Backup));
	Download->m_PartSize		= atoi(GetBackupString("PartSize", CurrentPos, Backup));
	Download->m_OverrideName	= GetBackupString("OverrideName", CurrentPos, Backup);
	Download->m_OverridePath	= GetBackupString("OverridePath", CurrentPos, Backup);
	Download->m_PartialPath		= GetBackupString("PartialPath", CurrentPos, Backup);
	Download->m_BackupPath  	= FilePath;
	Download->m_Sha1Hash		= GetBackupString("Sha1Hash", CurrentPos, Backup);
	Download->m_Search			= GetBackupString("Search", CurrentPos, Backup);
	Download->m_AvgSpeed		= atoi(GetBackupString("AvgSpeed", CurrentPos, Backup));
	Download->m_HashComputed	= atoi(GetBackupString("HashComputed", CurrentPos, Backup));
	Download->m_HashVerified	= atoi(GetBackupString("HashVerified", CurrentPos, Backup));
	Download->m_FileMoved		= atoi(GetBackupString("FileMoved", CurrentPos, Backup));
	Download->m_ReasonDead		= GetBackupString("ReasonDead", CurrentPos, Backup);
	Download->m_MetaXml         = GetBackupString("Meta", CurrentPos, Backup);

	Download->m_UseProxy		= atoi(GetBackupString("UseProxy", CurrentPos, Backup));
	Download->m_DefaultProxy	= GetBackupString("DefaultProxy", CurrentPos, Backup);

	Download->m_TigerHash		= GetBackupString("TigerHash", CurrentPos, Backup);
	Download->m_TreeSize		= atoi(GetBackupString("TreeSize", CurrentPos, Backup));
	Download->m_TreeRes			= atoi(GetBackupString("TreeRes", CurrentPos, Backup));

	if(Download->m_TreeSize)
	{
		Download->m_TigerTree = new byte[Download->m_TreeSize];
		memset(Download->m_TigerTree, 0, Download->m_TreeSize);
	}

	if(Download->m_TigerTree)
	{
		CString Value = GetBackupString("TigerTree", CurrentPos, Backup);

		int buffPos = 0;
		int dotPos  = Value.Find(".");

		while(dotPos != -1 && buffPos < Download->m_TreeSize)
		{
			DecodeBase32( Value.Mid(dotPos - 39, 39), 39, Download->m_TigerTree + buffPos, Download->m_TreeSize - buffPos );

			buffPos += 24;
			dotPos = Value.Find(".", dotPos + 1);
		}
	}


	Download->Init(Download->m_Name, Download->m_FileLength, HASH_SHA1, Download->m_Sha1Hash);

	
	// Load Host info
	if( !Download->m_FileMoved )
		for(int i = 0; ; i++)
		{
			CurrentPos = Backup.Find("[Host " + NumtoStr(i) + "]");

			if(CurrentPos == -1)
				break;

			CurrentPos += 5; // Host in header and value conflict

			FileSource nResult;
			nResult.Name = GetBackupString("Name", CurrentPos, Backup);
			nResult.NameLower = nResult.Name;
			nResult.NameLower.MakeLower();

			nResult.Sha1Hash	 = GetBackupString("Sha1Hash", CurrentPos, Backup);
			//nResult.BitprintHash = GetBackupString("BitprintHash", CurrentPos, Backup);

			nResult.FileIndex	= atoi(GetBackupString("FileIndex", CurrentPos, Backup));
			nResult.Size		= _atoi64(GetBackupString("Size", CurrentPos, Backup));

			nResult.Address.Host = StrtoIP(GetBackupString("Host", CurrentPos, Backup));
			nResult.Address.Port = atoi(GetBackupString("Port", CurrentPos, Backup));
			nResult.Network      = atoi(GetBackupString("Network", CurrentPos, Backup));
			nResult.HostStr		 = GetBackupString("HostStr", CurrentPos, Backup);
			nResult.Path		 = GetBackupString("Path", CurrentPos, Backup);
			nResult.Speed		 = atoi(GetBackupString("Speed", CurrentPos, Backup));
			nResult.Vendor		 = GetBackupString("Vendor", CurrentPos, Backup);

			nResult.Firewall	= atoi(GetBackupString("Firewall", CurrentPos, Backup)) != 0;
			nResult.OpenSlots	= atoi(GetBackupString("OpenSlots", CurrentPos, Backup)) != 0;
			nResult.Busy		= atoi(GetBackupString("Busy", CurrentPos, Backup)) != 0;
			nResult.Stable		= atoi(GetBackupString("Stable", CurrentPos, Backup)) != 0;
			nResult.ActualSpeed = atoi(GetBackupString("ActualSpeed", CurrentPos, Backup)) != 0;
			nResult.SupportF2F  = atoi(GetBackupString("SupportF2F", CurrentPos, Backup)) != 0;
			DecodeBase16(GetBackupString("PushID", CurrentPos, Backup), 32, (byte*) &nResult.PushID, 16);

			CString Nodes = GetBackupString("Direct", CurrentPos, Backup);
			while(!Nodes.IsEmpty())
				nResult.DirectHubs.push_back( StrtoIPv4(ParseString(Nodes, ',')) );

			nResult.GnuRouteID = 0;
			nResult.Distance = 7;
			//nResult.Icon     = m_pCore->GetIconIndex(nResult.Name);

			Download->AddHost(nResult);
		}

	//Download->m_DoReQuery = true;


	// Add Download to list
	m_DownloadAccess.Lock();
	m_DownloadList.push_back(Download);
	m_DownloadAccess.Unlock();

	TransferLoadMeta();

	if(Download->m_ShellStatus == CGnuDownloadShell::eActive)
		Download->Start();

	return Download;
}
Esempio n. 9
0
void CBrowseRefsDlg::Refresh(CString selectRef)
{
//	m_RefMap.clear();
//	g_Git.GetMapHashToFriendName(m_RefMap);

	if(!selectRef.IsEmpty())
	{
		if(selectRef == "HEAD")
		{
			selectRef = g_Git.GetSymbolicRef(selectRef, false);
		}
	}
	else
	{
		selectRef = GetSelectedRef(false, true);
	}

	m_RefTreeCtrl.DeleteAllItems();
	m_ListRefLeafs.DeleteAllItems();
	m_TreeRoot.m_ShadowTree.clear();
	m_TreeRoot.m_csRefName = "refs";
	m_TreeRoot.m_hTree=m_RefTreeCtrl.InsertItem(L"Refs",NULL,NULL);
	m_RefTreeCtrl.SetItemData(m_TreeRoot.m_hTree,(DWORD_PTR)&m_TreeRoot);

	CString allRefs, error;
	if (g_Git.Run(L"git for-each-ref --format="
			  L"%(refname)%04"
			  L"%(objectname)%04"
			  L"%(authordate:relative)%04"
			  L"%(subject)%04"
			  L"%(authorname)%04"
			  L"%(authordate:iso8601)%03",
			  &allRefs, &error, CP_UTF8))
	{
		CMessageBox::Show(NULL, CString(_T("Get refs failed\n")) + error, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
	}

	int linePos=0;
	CString singleRef;

	MAP_STRING_STRING refMap;

	//First sort on ref name
	while(!(singleRef=allRefs.Tokenize(L"\03",linePos)).IsEmpty())
	{
		singleRef.TrimLeft(L"\r\n");
		int valuePos=0;
		CString refName=singleRef.Tokenize(L"\04",valuePos);
		if(refName.IsEmpty())
			continue;
		CString refRest=singleRef.Mid(valuePos);


		//Use ref based on m_pickRef_Kind
		if(wcsncmp(refName,L"refs/heads",10)==0 && !(m_pickRef_Kind & gPickRef_Head) )
			continue; //Skip
		if(wcsncmp(refName,L"refs/tags",9)==0 && !(m_pickRef_Kind & gPickRef_Tag) )
			continue; //Skip
		if(wcsncmp(refName,L"refs/remotes",12)==0 && !(m_pickRef_Kind & gPickRef_Remote) )
			continue; //Skip

		refMap[refName] = refRest; //Use
	}

	MAP_STRING_STRING descriptions = GetBranchDescriptions();

	//Populate ref tree
	for(MAP_STRING_STRING::iterator iterRefMap=refMap.begin();iterRefMap!=refMap.end();++iterRefMap)
	{
		CShadowTree& treeLeaf=GetTreeNode(iterRefMap->first,NULL,true);
		CString values=iterRefMap->second;
		values.Replace(L"\04" L"\04",L"\04 \04");//Workaround Tokenize problem (treating 2 tokens as one)

		int valuePos=0;
		treeLeaf.m_csRefHash=		values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
		treeLeaf.m_csDate=			values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
		treeLeaf.m_csSubject=		values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
		treeLeaf.m_csAuthor=		values.Tokenize(L"\04",valuePos); if(valuePos < 0) continue;
		treeLeaf.m_csDate_Iso8601=	values.Tokenize(L"\04",valuePos);

		if (wcsncmp(iterRefMap->first, L"refs/heads", 10) == 0)
			treeLeaf.m_csDescription = descriptions[treeLeaf.m_csRefName];
	}

	// try exact match first
	if(selectRef.IsEmpty() || !(SelectRef(selectRef, true) || SelectRef(selectRef, false)))
		//Probably not on a branch. Select root node.
		m_RefTreeCtrl.Expand(m_TreeRoot.m_hTree,TVE_EXPAND);

}
Esempio n. 10
0
bool CBrowseRefsDlg::DoDeleteRef(CString completeRefName, bool bForce)
{
	bool bIsRemoteBranch = false;
	bool bIsBranch = false;
	if		(wcsncmp(completeRefName, L"refs/remotes",12)==0)	{bIsBranch = true; bIsRemoteBranch = true;}
	else if	(wcsncmp(completeRefName, L"refs/heads",10)==0)		{bIsBranch = true;}

	if(bIsBranch)
	{
		CString branchToDelete = completeRefName.Mid(bIsRemoteBranch ? 13 : 11);
		CString cmd;
		if(bIsRemoteBranch)
		{
			CString remoteName, remoteBranchToDelete;
			if (SplitRemoteBranchName(branchToDelete, remoteName, remoteBranchToDelete))
				return false;

			if(CAppUtils::IsSSHPutty())
			{
				CAppUtils::LaunchPAgent(NULL, &remoteName);
			}

			cmd.Format(L"git.exe push \"%s\" :refs/heads/%s", remoteName, remoteBranchToDelete);
		}
		else
			cmd.Format(L"git.exe branch -%c -- %s",bForce?L'D':L'd',branchToDelete);
		CSysProgressDlg sysProgressDlg;
		if (bIsRemoteBranch)
		{
			sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME)));
			sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS)));
			sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));
			sysProgressDlg.SetShowProgressBar(false);
			sysProgressDlg.ShowModal(this, true);
		}
		CString errorMsg;
		if(g_Git.Run(cmd,&errorMsg,CP_UTF8)!=0)
		{
			CMessageBox::Show(m_hWnd, errorMsg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
			if (bIsRemoteBranch)
				sysProgressDlg.Stop();
			BringWindowToTop();
			return false;
		}
		if (bIsRemoteBranch)
			sysProgressDlg.Stop();
		BringWindowToTop();
	}
	else if(wcsncmp(completeRefName,L"refs/tags",9)==0)
	{
		CString tagToDelete = completeRefName.Mid(10);
		CString cmd;
		cmd.Format(L"git.exe tag -d -- %s",tagToDelete);
		CString errorMsg;
		if(g_Git.Run(cmd,&errorMsg,CP_UTF8)!=0)
		{
			CMessageBox::Show(m_hWnd, errorMsg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
			return false;
		}
	}
	return true;
}
Esempio n. 11
0
bool DropMoveCommand::Execute()
{
	CString droppath = parser.GetVal(_T("droptarget"));
	CString ProjectTop;
	if (!CTGitPath(droppath).HasAdminDir(&ProjectTop))
		return FALSE;

	if (ProjectTop != g_Git.m_CurrentDir )
	{
		CMessageBox::Show(NULL,_T("Target and source must be the same git repository"),_T("TortoiseGit"),MB_OK);
		return FALSE;
	}

	if (ProjectTop.GetLength() == 3 && ProjectTop.Mid(1, 2) == _T(":\\")) // working tree root is directly on a drive
		droppath = droppath.Right(droppath.GetLength() - ProjectTop.GetLength());
	else
		droppath = droppath.Right(droppath.GetLength() - ProjectTop.GetLength() - 1);
	if (!droppath.IsEmpty())
		droppath += L"\\";

	unsigned long count = 0;
	pathList.RemoveAdminPaths();
	CString sNewName;

	if ((parser.HasKey(_T("rename")))&&(pathList.GetCount()==1))
	{
		// ask for a new name of the source item
		do
		{
			CRenameDlg renDlg;
			renDlg.m_windowtitle.LoadString(IDS_PROC_MOVERENAME);
			renDlg.m_name = pathList[0].GetFileOrDirectoryName();
			if (renDlg.DoModal() != IDOK)
			{
				return FALSE;
			}
			sNewName = renDlg.m_name;
		} while(sNewName.IsEmpty() || PathFileExists(droppath + sNewName));
	}
	CSysProgressDlg progress;
	if (progress.IsValid())
	{
		progress.SetTitle(IDS_PROC_MOVING);
		progress.SetAnimation(IDR_MOVEANI);
		progress.SetTime(true);
		progress.ShowModeless(CWnd::FromHandle(hwndExplorer));
	}
	for (int nPath = 0; nPath < pathList.GetCount(); ++nPath)
	{
		CTGitPath destPath;
		if (sNewName.IsEmpty())
			destPath = CTGitPath(droppath + pathList[nPath].GetFileOrDirectoryName());
		else
			destPath = CTGitPath(droppath + sNewName);
		if (destPath.Exists())
		{
			CString name = pathList[nPath].GetFileOrDirectoryName();
			if (!sNewName.IsEmpty())
				name = sNewName;
			progress.Stop();
			CRenameDlg dlg;
			dlg.m_name = name;
			dlg.m_windowtitle.Format(IDS_PROC_NEWNAMEMOVE, (LPCTSTR)name);
			if (dlg.DoModal() != IDOK)
			{
				return FALSE;
			}
			destPath.SetFromWin(droppath + dlg.m_name);
		}
		CString cmd,out;

		cmd.Format(_T("git.exe mv -- \"%s\" \"%s\""),pathList[nPath].GetGitPathString(),destPath.GetGitPathString());
		if (g_Git.Run(cmd, &out, CP_UTF8))
		{
			if (CMessageBox::Show(hwndExplorer, out, _T("TortoiseGit"), 2, IDI_EXCLAMATION, CString(MAKEINTRESOURCE(IDS_IGNOREBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1)
			{
#if 0
					if (!svn.Move(CTSVNPathList(pathList[nPath]), destPath, TRUE))
					{
						CMessageBox::Show(hwndExplorer, svn.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);
						return FALSE;		//get out of here
					}
					CShellUpdater::Instance().AddPathForUpdate(destPath);
#endif
			}
			else
			{
				CMessageBox::Show(hwndExplorer, IDS_git_USERCANCELLED, IDS_APPNAME, MB_ICONERROR);
				return FALSE;		//get out of here
			}
		}
		else
			CShellUpdater::Instance().AddPathForUpdate(destPath);
		++count;
		if (progress.IsValid())
		{
			progress.FormatPathLine(1, IDS_PROC_MOVINGPROG, pathList[nPath].GetWinPath());
			progress.FormatPathLine(2, IDS_PROC_CPYMVPROG2, destPath.GetWinPath());
			progress.SetProgress(count, pathList.GetCount());
		}
		if ((progress.IsValid())&&(progress.HasUserCancelled()))
		{
			CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION);
			return FALSE;
		}
	}
	return true;
}
Esempio n. 12
0
/////////////////////////////////////////////////////////////////////////////
// CDocSelector message handlers
BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon, LPCTSTR lpszImage )
{
	CRect rect;
	GetClientRect(&rect);

	// Yogesh Jagota
	CDocument* pDoc = ((CView *) wnd)->GetDocument();

	CString sPath = pDoc->GetPathName();
	CString sFileName;
	
	if ( sPath.IsEmpty() )
		sPath = pDoc->GetTitle();

	// Can be only the filename, like Noname01
	if ( sPath.Find( _T('\\') ) != -1 )
		sFileName = sPath.Mid( sPath.ReverseFind( _T('\\') ) + 1 );
	else
		sFileName = sPath;

	// If there is no space left to display extra buttons...
	int nNewSize = ( ( rect.Width() - DS_MENU_BUTTON_WIDTH ) 
		/ ( m_Buttons.GetSize() + 1 ) ) - DS_SEPERATER_MARGIN;

	bool bShowButton = true;
	if ( nNewSize <= MINWIDTH )
	{
		// Check if the menu button is displayed, if not, display it...
		m_btnMenuButton.ShowWindow( SW_SHOW );

		// Don't show the button...
		bShowButton = false;
	}
	else
		m_nDisplayedButtons++;

	// End Yogesh Jagota

	CSwitcherButton* newbutton = new CSwitcherButton();

	 // Yogesh Jagota
	newbutton->m_AttachedView = wnd;

	// I am saving the frame to make life easier in case
	// of activation in selection process...
	CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
	CWnd * pWnd = pFrame->GetWindow( GW_CHILD );
	ASSERT (pWnd);
	pWnd = pWnd->GetWindow( GW_CHILD );
	while (pWnd)
	{
		if ( ((CFrameWnd *)pWnd)->GetActiveView() == (CView*)wnd )
			newbutton->m_FrameWnd = (CFrameWnd *)pWnd;

		pWnd = pWnd->GetWindow( GW_HWNDNEXT );
	}

	// Load the icon....
	if ( wIcon != 0 ){

		newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(), 
			MAKEINTRESOURCE( wIcon ) );
	}
	
	else if(lpszImage  != 0){

		HBITMAP hTmp = (HBITMAP)::LoadImage(NULL, lpszImage, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_DEFAULTCOLOR);
		if(hTmp){

			newbutton->m_hBmp = CEmoticonManager::ReplaceColor(hTmp, RGB(255, 0, 255), ::GetSysColor(COLOR_3DFACE), 0);
			DeleteObject(hTmp);
		}
		else{

			newbutton->m_hBmp = NULL;
		}
	}
	// End Yogesh Jagota

	newbutton->m_iID = m_Buttons.GetSize();
	if (!newbutton->DoCreate(this, m_iNextButtonStart, 
		rect.top + 3, m_iButtonWidth, DS_HEIGHT - 2, 
		sFileName, sPath )) // Yogesh Jagota
	{
		return FALSE;
	}

	if ( !bShowButton )
		newbutton->ShowWindow( SW_HIDE );

	m_Buttons.Add((void*)newbutton);
	m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN;

	if (m_iNextButtonStart - DS_SEPERATER_MARGIN > rect.Width())
	{
		// this loop makes a neat little animation
		int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) 
			/ (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN;

//		Yogesh Jagota. Removed animation because did'nt liked it.
//		Remove if you want animated addition or removal of buttons.
//
		register int y;
		for (y = m_iButtonWidth; y >= newsize; y-=3)
		{
			ResizeButtons(y);
			Sleep(15);
		}

		if (y != newsize)
//			/* ResizeButtons(newsize); */ <- this is the next line...
//		End Yogesh Jagota

		ResizeButtons(newsize);

		if (m_iButtonWidth < MINWIDTH)
		{
			// the smallest allowable button size has been reached...
			// in this version, we can't handle this
			ASSERT(0);
			return FALSE;
		}
	}
	else
		m_btnMenuButton.ShowWindow( SW_HIDE );

	// Yogesh Jagota
	if ( m_iSelectedButton != -1 )
		((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Unselect();

	m_iSelectedButton = newbutton->m_iID;
	((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Select();
	// End Yogesh Jagota

	return TRUE;
}
Esempio n. 13
0
CString GetSelectedFunction (CString & strWindowContents, int & nStartChar, int & nEndChar)
  {

  CString strWord;

  if (!strWindowContents.IsEmpty ())
    {
    // if no selection try to get word under cursor


    if (nStartChar == nEndChar)
      {
      nStartChar--;   // go back one so we are not at end of string

      // scan backwards from cursor
      while (nStartChar >= 0 && 
             strWord.GetLength () < 30 &&
             (isalnum (strWindowContents [nStartChar]) || 
              strWindowContents [nStartChar] == '.' || 
              strWindowContents [nStartChar] == '-' || 
              strWindowContents [nStartChar] == '_')
             )
        {
        strWord = strWindowContents.Mid (nStartChar, 1) + strWord;
        nStartChar--;
        }

      nStartChar++;

      // scan forwards from cursor
      while (nEndChar < strWindowContents.GetLength () && 
             strWord.GetLength () < 30 &&
             (isalnum (strWindowContents [nEndChar]) || 
              strWindowContents [nEndChar] == '.' || 
              strWindowContents [nEndChar] == '-' || 
              strWindowContents [nEndChar] == '_')
             )
        {
        strWord = strWord + strWindowContents.Mid (nEndChar, 1);
        nEndChar++;
        }

      strWord.MakeLower ();
      strWord.Replace ("world.", "");  // if they said world.note, just take note    

      } // end of no selection
    else
      {
      if (nEndChar > nStartChar &&
          (nEndChar - nStartChar) < 30)
        {

        // skip spaces, changing the selection while we do it (for replacement purposes)
        while (isspace (strWindowContents [nStartChar]) &&
               nEndChar > nStartChar)
          nStartChar++;

        // ditto for trailing spaces
        while (isspace (strWindowContents [nEndChar - 1]) &&
               (nEndChar - 1) > nStartChar)
          nEndChar--;

        strWindowContents = strWindowContents.Mid (nStartChar, nEndChar - nStartChar);
        strWindowContents.MakeLower ();
        strWindowContents.Replace ("@world.", ""); // ditto for @world.Note  (Ruby)
        strWindowContents.Replace ("world.", "");  // if they said world.note, just take note    
        strWindowContents.Replace ("$world->", ""); // ditto for $world->note  (Perl)
        bool bFunction = true;
        for (int i = 0; i < strWindowContents.GetLength (); i++)
          if (!isalnum (strWindowContents [i]))
            bFunction = false;
        if (bFunction)
          strWord = strWindowContents;
        }

      } // we have a selection

     }   // end of some selection supplied

  return strWord;

  } // end of GetSelectedFunction
Esempio n. 14
0
void CTimerDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);

    if(!pDX->m_bSaveAndValidate)
    {
        if (m_current_timer && m_current_timer->bIncluded)
            m_strIncluded = "(included)";
        else
            m_strIncluded.Empty ();
    }

    //{{AFX_DATA_MAP(CTimerDlg)
    DDX_Control(pDX, IDC_SEND_TO, m_ctlSendTo);
    DDX_Control(pDX, IDC_SCRIPT_NAME, m_ctlProcedure);
    DDX_Control(pDX, IDC_TIMER_CONTENTS, m_ctlContents);
    DDX_Control(pDX, IDC_BUTTON_AT, m_ctlButtonAt);
    DDX_Check(pDX, IDC_ENABLED, m_bEnabled);
    DDX_Text(pDX, IDC_TIMER_LABEL, m_strLabel);
    DDX_Text(pDX, IDC_AT_HOUR, m_iAtHour);
    DDV_MinMaxInt(pDX, m_iAtHour, 0, 23);
    DDX_Text(pDX, IDC_AT_MINUTE, m_iAtMinute);
    DDV_MinMaxInt(pDX, m_iAtMinute, 0, 59);
    DDX_Text(pDX, IDC_INTERVAL_HOUR, m_iEveryHour);
    DDV_MinMaxInt(pDX, m_iEveryHour, 0, 23);
    DDX_Text(pDX, IDC_INTERVAL_MINUTE, m_iEveryMinute);
    DDV_MinMaxInt(pDX, m_iEveryMinute, 0, 59);
    DDX_Text(pDX, IDC_OFFSET_HOUR, m_iOffsetHour);
    DDV_MinMaxInt(pDX, m_iOffsetHour, 0, 23);
    DDX_Text(pDX, IDC_OFFSET_MINUTE, m_iOffsetMinute);
    DDV_MinMaxInt(pDX, m_iOffsetMinute, 0, 59);
    DDX_MinMaxString(pDX, IDC_TIMER_CONTENTS, m_strContents);
    DDV_MinMaxString(pDX, m_strContents, 0, 32000);
    DDX_Radio(pDX, IDC_BUTTON_EVERY, m_iType);
    DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure);
    DDX_Check(pDX, IDC_ONE_SHOT_TIMER, m_bOneShot);
    DDX_Check(pDX, IDC_TEMPORARY, m_bTemporary);
    DDX_Check(pDX, IDC_ACTIVE_WHEN_CLOSED, m_bActiveWhenClosed);
    DDX_Text(pDX, IDC_GROUP, m_strGroup);
    DDX_CBIndex(pDX, IDC_SEND_TO, m_iSendTo);
    DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
    DDX_Text(pDX, IDC_INCLUDED, m_strIncluded);
    DDX_Check(pDX, IDC_OMIT_FROM_OUTPUT, m_bOmitFromOutput);
    DDX_Check(pDX, IDC_OMIT_FROM_LOG, m_bOmitFromLog);
    DDX_Text(pDX, IDC_AT_SECOND, m_fAtSecond);
    DDV_MinMaxDouble(pDX, m_fAtSecond, 0., 59.99999);
    DDX_Text(pDX, IDC_INTERVAL_SECOND, m_fEverySecond);
    DDV_MinMaxDouble(pDX, m_fEverySecond, 0., 59.99999);
    DDX_Text(pDX, IDC_OFFSET_SECOND, m_fOffsetSecond);
    DDV_MinMaxDouble(pDX, m_fOffsetSecond, 0., 59.99999);
    //}}AFX_DATA_MAP

    if(pDX->m_bSaveAndValidate)
    {


        m_strLabel.TrimLeft ();
        m_strLabel.TrimRight ();

        m_strProcedure.TrimLeft ();
        m_strProcedure.TrimRight ();

        m_strGroup.TrimLeft ();
        m_strGroup.TrimRight ();

        if (m_iType == CTimer::eInterval)
        {
            CmcDateTimeSpan ts1 (0, m_iEveryHour, m_iEveryMinute, m_fEverySecond);
            CmcDateTimeSpan ts2 (0, m_iOffsetHour, m_iOffsetMinute, m_fOffsetSecond);

            if (ts1 <= CmcDateTimeSpan (0, 0, 0, 0))
            {
                ::TMessageBox("The timer interval must be greater than zero.");
                DDX_Text(pDX, IDC_INTERVAL_HOUR, m_iEveryHour);
                pDX->Fail();
            }     // end of interval <= 0

            if(ts2 >= ts1)
            {
                ::TMessageBox("The timer offset must be less than the timer period.");
                DDX_Text(pDX, IDC_OFFSET_HOUR, m_iOffsetHour);
                pDX->Fail();
            }     // end of offset >= period
        }   // end of doing a periodical timer


        CString strTimerName;
        CTimer * timer_item;
        POSITION pos;

        for (pos = m_pTimerMap->GetStartPosition (); pos; )
        {
            m_pTimerMap->GetNextAssoc (pos, strTimerName, timer_item);

// don't compare against itself

            if (timer_item == m_current_timer)
                continue;

// now check the label for duplicates

            if (!m_strLabel.IsEmpty ())    // we can have duplicate blank names
                if (m_strLabel.CompareNoCase (timer_item->strLabel) == 0)
                {
                    CString strMsg;
                    strMsg = TFormat ("The timer label \"%s\" is already in the list of timers.",
                                      (LPCTSTR) m_strLabel);
                    ::UMessageBox(strMsg);
                    DDX_Text(pDX, IDC_TIMER_LABEL, m_strLabel);
                    pDX->Fail();
                }

        }   // end of checking each Timer

        if (!m_strLabel.IsEmpty ())    // we can have blank labels
        {

// check label is valid

            if (CheckLabel (m_strLabel))
            {
                ::TMessageBox ("The label must start with a letter and consist of letters"
                               ", numbers or the underscore character.");
                DDX_Text(pDX, IDC_TIMER_LABEL, m_strLabel);
                pDX->Fail();
            }

        }   // end of having non-blank label


        if (m_strVariable.IsEmpty ())    // we can have blank variables
        {
            if (m_iSendTo == eSendToVariable)
            {
                ::TMessageBox("When sending to a variable you must specify a variable name. ",
                              MB_ICONSTOP);
                DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
                pDX->Fail();
            }
        }
        else
        {

// check variable name is valid

            if (CheckLabel (m_strVariable))
            {
                ::TMessageBox("The variable name must start with a letter and consist of letters"
                              ", numbers or the underscore character.");
                DDX_Text(pDX, IDC_VARIABLE, m_strVariable);
                pDX->Fail();
            }

        }   // end of having non-blank variable


        // check for speed walking OK, unless they are substituting

        if (m_iSendTo == eSendToSpeedwalk)
        {

            CString strResult = m_pDoc->DoEvaluateSpeedwalk (m_strContents);

            if (!strResult.IsEmpty ())
            {
                if (strResult [0] == '*')    // error in speedwalk string?
                {
                    ::UMessageBox (strResult.Mid (1));  // already translated, I think
                    DDX_Text(pDX, IDC_TIMER_CONTENTS, m_strContents);
                    pDX->Fail();
                }   // end of error message
            } // end of non-empty speedwalk
        }   // end of speed walking wanted

        if(m_strContents.IsEmpty () && m_strProcedure.IsEmpty ())
        {
            ::TMessageBox("The timer contents cannot be blank unless you specify a script subroutine.");
            DDX_Text(pDX, IDC_TIMER_CONTENTS, m_strContents);
            pDX->Fail();
        }     // end of contents being blank


        if (!m_strProcedure.IsEmpty ())    // blank procedure is OK
        {

// check procedure is valid

            if (CheckLabel (m_strProcedure, true))
            {
                ::TMessageBox("The script subroutine name must start with a letter and consist of letters"
                              ", numbers or the underscore character.");
                DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure);
                pDX->Fail();
            }

        }   // end of having non-blank procedure

    }   // end of saving and validating
    else
    {
        if (App.m_bFixedFontForEditing)
        {
            FixFont(m_font, m_ctlContents, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET);
        }
    }

}
Esempio n. 15
0
void CCloneDlg::OnCbnEditchangeUrlcombo()
{
	// do not update member variables from UI while saving
	if (m_bSaving || m_bExactPath)
		return;

	this->UpdateData();
	CString url;
	m_URLCombo.GetWindowText(url);
	url.Trim();

	if(m_OldURL == url )
		return;

	m_OldURL=url;

	//if(url.IsEmpty())
	//	return;

	CString old;
	old=m_ModuleName;

	url.Replace(L'\\', L'/');

	// add compatibility for Google Code git urls
	url.TrimRight(L"/");

	int start = url.ReverseFind(L'/');
	if(start<0)
	{
		start = url.ReverseFind(L':');
		if(start <0)
			start = url.ReverseFind(L'@');

		if(start<0)
			start = 0;
	}
	CString temp;
	temp=url.Mid(start+1);

	temp=temp.MakeLower();

	// we've to check whether the URL ends with .git (instead of using the first .git)
	int end = CStringUtils::EndsWith(temp, L".git") ? (temp.GetLength() - 4) : temp.GetLength();

	//CString modulename;
	m_ModuleName=url.Mid(start+1,end);

	start = m_Directory.ReverseFind(L'\\');
	if(start <0 )
		start = m_Directory.ReverseFind(L'/');
	if(start <0 )
		start =0;

	int dirstart=m_Directory.Find(old,start);
	if(dirstart>=0 && (dirstart+old.GetLength() == m_Directory.GetLength()) )
		m_Directory=m_Directory.Left(dirstart);

	m_Directory.TrimRight(L"\\/");
	m_Directory += L'\\';
	m_Directory += m_ModuleName;

	// check if URL starts with http://, https:// or git:// in those cases loading putty keys is only
	// asking for passwords for keys that are never used
	if (url.Find(L"http://", 0) >= 0 || url.Find(L"https://", 0) >= 0 || url.Find(L"git://", 0) >= 0)
		m_bAutoloadPuttyKeyFile = false;
	else
		m_bAutoloadPuttyKeyFile = m_regUseSSHKey && CAppUtils::IsSSHPutty();

	this->UpdateData(FALSE);
}
Esempio n. 16
0
//////////////////////////////////////////////////////////////////////////
//简要描述 : 设置扩展属性配置文件
//输入参数 :
//返 回 值 :
//
//
//修改日志 :
//////////////////////////////////////////////////////////////////////////
STDMETHODIMP CDwgWriter::put_XDataXMLConfigFile(BSTR sXMLFile)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    if (sXMLFile == NULL) return S_OK;

    CString sXml = sXMLFile;
    if (sXml.IsEmpty()) return S_OK;

    m_XDataCfgs.RemoveAll();

    try
    {
        CXMLFile xmlfile;
        xmlfile.load(sXml);
        MSXML2::IXMLDOMNodePtr pNode;
        MSXML2::IXMLDOMNodePtr pExtAttrNode = NULL;
        xmlfile.GetNode("LAYERS", pNode);
        if (pNode == NULL)
        {
            //AfxMessageBox("XML配置文件不正确,请检查。");
            m_dwgWriter.WriteLog("XML配置文件不正确,请检查。");
            return S_FALSE;
        }
        pNode = pNode->GetfirstChild();
        if (pNode == NULL)
        {
            //AfxMessageBox("XML配置文件不正确,请检查。");
            m_dwgWriter.WriteLog("XML配置文件不正确,请检查。");
            return S_FALSE;
        }
        CComBSTR bsNodeName;
        CComBSTR bsExtAttrs;
        CString sLayerName;
        CString sRegAppName;
        CString sExtAttrs;
        while (pNode != NULL)
        {
            //得到图层名
            pNode->get_nodeName(&bsNodeName);
            sLayerName = bsNodeName;

            //去掉前面的_前缀,解决数字开头的节点问题
            CString sSign = "";
            sSign = sLayerName.Mid(0, 1);
            if (sSign.CompareNoCase("_") == 0)
            {
                sLayerName = sLayerName.Mid(1);
            }

            XDataAttrLists* pExtAttrs = new XDataAttrLists();
            //得到图层下的注册应用名
            if (pNode->hasChildNodes())
            {
                pExtAttrNode = pNode->GetfirstChild();
                while (pExtAttrNode != NULL)
                {
                    pExtAttrNode->get_nodeName(&bsNodeName);
                    sRegAppName = bsNodeName;

                    //去掉前面的_前缀,解决数字开头的节点问题
                    sSign = sRegAppName.Mid(0, 1);
                    if (sSign.CompareNoCase("_") == 0)
                    {
                        sRegAppName = sRegAppName.Mid(1);
                    }

                    pExtAttrNode->get_text(&bsExtAttrs);
                    sExtAttrs = bsExtAttrs;
                    CStringList* pAttrLst = new CStringList();
                    //解析注册应用名下的属性字段名称
                    CString sAttr;
                    int iPos  = sExtAttrs.Find(',');
                    while (iPos > 0)
                    {
                        sAttr = sExtAttrs.Mid(0, iPos);
                        sExtAttrs = sExtAttrs.Mid(iPos + 1);
                        if (!sAttr.IsEmpty())
                        {
                            pAttrLst->AddTail(sAttr);
                        }
                        iPos  = sExtAttrs.Find(',');
                    }
                    if (iPos == -1)
                    {
                        if (!sExtAttrs.IsEmpty())
                        {
                            pAttrLst->AddTail(sExtAttrs);
                        }
                    }
                    pExtAttrs->SetAt(sRegAppName, pAttrLst);
                    //得到下一个注册应用名的配置
                    pExtAttrNode = pExtAttrNode->GetnextSibling();
                }
            }

            m_XDataCfgs.SetAt(sLayerName, pExtAttrs);
            //得到下一个图层的扩展属性的配置
            pNode = pNode->GetnextSibling();
        }
    }
    catch (...)
    {
		m_dwgWriter.WriteLog("解析XML文件出错,请检查。");
        return S_FALSE;
    }

    return S_OK;
}
Esempio n. 17
0
bool CHooks::Create()
{
	if (m_pInstance == NULL)
		m_pInstance = new CHooks();
	CRegString reghooks = CRegString(_T("Software\\TortoiseGit\\hooks"));
	CString strhooks = reghooks;
	// now fill the map with all the hooks defined in the string
	// the string consists of multiple lines, where one hook script is defined
	// as four lines:
	// line 1: the hook type
	// line 2: path to working copy where to apply the hook script
	// line 3: command line to execute
	// line 4: 'true' or 'false' for waiting for the script to finish
	// line 5: 'show' or 'hide' on how to start the hook script
	hookkey key;
	int pos = 0;
	hookcmd cmd;
	while ((pos = strhooks.Find('\n')) >= 0)
	{
		// line 1
		key.htype = GetHookType(strhooks.Mid(0, pos));
		if (pos+1 < strhooks.GetLength())
			strhooks = strhooks.Mid(pos+1);
		else
			strhooks.Empty();
		bool bComplete = false;
		if ((pos = strhooks.Find('\n')) >= 0)
		{
			// line 2
			key.path = CTGitPath(strhooks.Mid(0, pos));
			if (pos+1 < strhooks.GetLength())
				strhooks = strhooks.Mid(pos+1);
			else
				strhooks.Empty();
			if ((pos = strhooks.Find('\n')) >= 0)
			{
				// line 3
				cmd.commandline = strhooks.Mid(0, pos);
				if (pos+1 < strhooks.GetLength())
					strhooks = strhooks.Mid(pos+1);
				else
					strhooks.Empty();
				if ((pos = strhooks.Find('\n')) >= 0)
				{
					// line 4
					cmd.bWait = (strhooks.Mid(0, pos).CompareNoCase(_T("true"))==0);
					if (pos+1 < strhooks.GetLength())
						strhooks = strhooks.Mid(pos+1);
					else
						strhooks.Empty();
					if ((pos = strhooks.Find('\n')) >= 0)
					{
						// line 5
						cmd.bShow = (strhooks.Mid(0, pos).CompareNoCase(_T("show"))==0);
						if (pos+1 < strhooks.GetLength())
							strhooks = strhooks.Mid(pos+1);
						else
							strhooks.Empty();
						bComplete = true;
					}
				}
			}
		}
		if (bComplete)
		{
			m_pInstance->insert(std::pair<hookkey, hookcmd>(key, cmd));
		}
	}
	return true;
}