BOOL CPeraProcessDesignerApp::InitInstance() { ZTools::InitZToolsLog(); if ( !m_CmdLine.Parse() ) { MessageBox( NULL, "解析命令行失败!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); return FALSE; } m_hMetux = CreateMutex(NULL,TRUE,"PeraProcessDesigner.exe"); if (m_hMetux) { if (ERROR_ALREADY_EXISTS== GetLastError()) { HWND hwndPeraProcessDesignerCopied = FindPeraProcessDesignerMainWindow(); //当有互斥,但是没找到窗口时,认为之前的进程还在启动中,简单处理,直接退出 if ( hwndPeraProcessDesignerCopied) { if ( !m_CmdLine.GetValue( NULL ).IsEmpty() ) { #define WS_OPENWS_SENDMSG #ifdef WS_OPENWS_SENDMSG DWORD dwProcessId = 0; GetWindowThreadProcessId(hwndPeraProcessDesignerCopied, &dwProcessId); if ( GetTopModalWindow( dwProcessId ) == NULL ) { CSharedMemory Mem; CString sMemData = g_lpszDoubleOpenWsMemStr; Mem.Init( g_lpszDoubleOpenWsMemName, sMemData.GetLength()+MAX_PATH ); SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_MAKESUREINFO, (LPVOID)NULL, 0 ); sMemData.Empty(); sMemData = (LPCTSTR)Mem.GetData(); if ( sMemData.CompareNoCase( g_lpszDoubleOpenWsMemStr ) == 0 ) { MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); } else { CString sCmdLine = ::GetCommandLine(); SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_OPENWS, (LPVOID)(LPCTSTR)sCmdLine, sCmdLine.GetLength()+1 ); } } else { MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); } #else MessageBox( hwndPeraProcessDesignerCopied, "建模环境已打开,请在建模环境中打开本文件!", g_lpszAppTitle, MB_OK | MB_TOPMOST ); #endif } if (IsIconic(hwndPeraProcessDesignerCopied)) ShowWindow(hwndPeraProcessDesignerCopied,SW_RESTORE); SetForegroundWindow(hwndPeraProcessDesignerCopied); ZTools::WriteZToolsFormatLog("将已经运行的建模窗口激活,并前端显示..."); } CloseHandle(m_hMetux); m_hMetux = NULL; ZTools::WriteZToolsFormatLog("已经存在一个建模客户端,本运行实例将退出..."); return FALSE; } } m_LoginData.m_strRealName = m_CmdLine.GetValue( "realName" ); m_LoginData.m_strUser = m_CmdLine.GetValue( "userName" ); m_LoginData.m_strTicket = m_CmdLine.GetValue( "ticket-proxy" ); WriteShareMemoryLoginInfo(); CCrashHandler ch; ch.SetProcessExceptionHandlers(); ch.SetThreadExceptionHandlers(); //如果PeraTaskService进程不存在,自动启动 StartPeraTaskService(); //_CrtSetBreakAlloc(1300); // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); //hModule = ::LoadLibrary("C:\\Users\\kunmiao-li\\Desktop\\TestBuild\\PeraLicMgr\\Release\\PeraLicMgr.dll"); //#ifndef _DEBUG if (!InitLicense("PeraWorkSpace")) return FALSE; // if(!m_FlexNetMgr.CheckOutLicense("PeraWorkSpace")) // { // return FALSE; // } // hModule = ::LoadLibrary(ZTools::FormatString("%s\\PeraLicMgr.dll", GetFlexwareBinPathMethod()).c_str()); // if( hModule != NULL ) // { // lpFnDLLfunc = (LPFNDLLFUNC) ::GetProcAddress(hModule, "CheckOutLicense"); // if(lpFnDLLfunc != NULL) // { // if(!lpFnDLLfunc("PeraProcessDesigner")) // { // return FALSE; // } // } // else // { // return FALSE; // } // } // else // { // AfxMessageBox("检测到系统安装不完整,请联系管理员重新安装!", MB_OK|MB_ICONINFORMATION); // return FALSE; // } //#endif //if(!m_FlexNetMgr.InitNewJob("PeraProcessDesigner")) //{ // return FALSE; //} CWinApp::InitInstance(); InitGDIPlus(); LoadResLibImageSet(); //LoadDefaultFont(); //CBCGPPopupMenuBar::SetPeraPaint( g_crToolbarBg ); //CXmlBase xml; //MSXML2::IXMLDOMDocument2Ptr pdoc = xml.GetXmlDocPtrByFile(GetExecDir() + "\\Manifest.xml"); //MSXML2::IXMLDOMNodeListPtr pModels; //MSXML2::IXMLDOMNodePtr pModel; //long lModelCount; //HRESULT hr = S_OK; //map<CString, CString> mapAttrs; //map<CString, CString>::iterator iterAttrs; //CString str; //pModels = xml.GetNodeListPtr("/Manifest/Component", pdoc); //if (pModels != NULL) //{ // lModelCount = pModels->Getlength(); // for (long i=0; i<lModelCount; i++) // { // hr = pModels->get_item(i, &pModel); // if (FAILED(hr) || NULL == pModel) // { // continue; // } // if (0 == xml.GetAttrsOfNode(mapAttrs, pModel)) // { // continue; // } // iterAttrs = mapAttrs.find("RobotName"); // if (iterAttrs != mapAttrs.end()) str= iterAttrs->second; // } //} //CCxArray3D a3d(DT_ARRAY3D_INT); //CString str3d = "[1,2,3,4,5,](4,3,2)" //CString str = "[1e150,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24](2,3,4)"; // CString str = "[\"\\\\\\\",,1e150\",\"2\"](2)"; //{ // CString str1; // for (int a=0;a<2;a++) // { // for (int b=0;b<3;b++) // { // for (int c=0;c<4;c++) // { // } // } // } //} // //CxArrayND nd( DT_ARRAY1D_STRING ); //nd.Parse( str ); //vector<int> vPos; //vPos.push_back(0); ////vPos.push_back(0); ////vPos.push_back(0); //LPARAM lpData = nd.GetDataPtr( vPos ); //CString * pData = reinterpret_cast< CString * > ( lpData ); //nd.Clear(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskBarInteraction(FALSE); globalData.SetDPIAware (); //globalData.bDisableAero = TRUE; //Bar挺靠后,Slider宽度,由于Splitter最小宽度为4,所以此值不应小于4,否则与Splitter不协调。 CBCGPSlider::m_nDefaultWidth = 4; // All registry read/write operations will be produced via CBCGPXMLSettings gateway: CBCGPRegistrySP::SetRuntimeClass (RUNTIME_CLASS (CBCGPXMLSettings)); // Read settings: CBCGPXMLSettings::ReadXMLFromFile (FALSE, GetExecDir() + _T("\\user.xml")); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization //SetRegistryKey(_T("PeraProcessDesigner")); //LoadStdProfileSettings(0); // Load standard INI file options (including MRU) //SetRegistryBase (_T("Settings")); RECT rectDesktop; SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rectDesktop,0); m_rcLastWindowPlacement = rectDesktop; CRect rectDesktop2 = rectDesktop; int nFlag = 0; int nShowCmd = 0; LoadWindowPlacement( m_rcLastWindowPlacement, nFlag, nShowCmd ); StoreWindowPlacement (rectDesktop2, 2, SW_SHOWMAXIMIZED); theGlobalConfig.Load(); m_bAloneVersionWs = IsPeraProcessRunnerInstalled(); CCxBCGPVisualManager2007::SetStyle (CCxBCGPVisualManager2007::VS2007_Silver); CCxBCGPVisualManager2007::SetDefaultManager (RUNTIME_CLASS (CCxBCGPVisualManager2007)); //globalData.bDisableAero = TRUE; //globalData.bIsOSAlphaBlendingSupport = TRUE; // Initialize all Managers for usage. They are automatically constructed // if not yet present InitMouseManager(); //InitContextMenuManager(); InitKeyboardManager(); // Enable user-defined tools. If you want allow more than 10 tools, // add tools entry to resources (ID_USER_TOOL11, ID_USER_TOOL12,...) EnableUserTools (ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); // TODO: Remove this if you don't want extended tooltips: InitTooltipManager(); CBCGPToolTipParams params; params.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager ()->SetTooltipParams ( BCGP_TOOLTIP_TYPE_ALL, RUNTIME_CLASS (CBCGPToolTipCtrl), ¶ms); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MAIN, RUNTIME_CLASS(CPeraProcessDesignerDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CPeraProcessDesignerView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAIN)) return FALSE; m_bCreate = TRUE; m_pMainWnd = pMainFrame; //basehtmldialog中,屏蔽快捷键 g_hwndMainWindow = pMainFrame->GetSafeHwnd(); g_pLoadingWindow = new CLoadingWindow( TIMER_LOADING_WINDOW, IDD_DIALOG_LOGIN_BK, m_pMainWnd ); g_pLoadingWindow->Create( IDD_DIALOG_LOGIN_BK, m_pMainWnd ); g_pLoadingWindow->Init( GetExecDir() + "\\Res\\DlgProgress\\DlgProgress.png" ); pMainFrame->m_wndMenuBar.LoadData(); //pMainFrame->OnMenuModuleOpenjianmo(); // call DragAcceptFiles only if there's a suffix // In an MDI app, this should occur immediately after setting m_pMainWnd // Parse command line for standard shell commands, DDE, file open //CCommandLineInfo cmdInfo; //ParseCommandLine(cmdInfo); //if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) //{ // if (!pMainFrame->LoadMDIState (GetRegSectionPath ()) || // DYNAMIC_DOWNCAST(CMDIChildWnd, pMainFrame->GetActiveFrame()) == NULL) // { // if (!ProcessShellCommand(cmdInfo)) // return FALSE; // } //} //else //{ // // Dispatch commands specified on the command line // if (!ProcessShellCommand(cmdInfo)) // return FALSE; //} // The main window has been initialized, so show and update it pMainFrame->OnMenuModuleOpenjianmo(); m_bInitMDI = TRUE; m_nCmdShow = SW_SHOWMAXIMIZED; pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); ////////////////////////////////////////////////////////////////////////// //日志输出窗口 #ifdef USE_DLGLOG m_dlgLog.Create(CDlgLog::IDD, NULL); //m_dlgLog.ShowWindow(SW_SHOW); // int x, y; // x = GetSystemMetrics(SM_CXFULLSCREEN); //屏幕宽度 // y = GetSystemMetrics(SM_CYFULLSCREEN); //屏幕高度 CRect rectFull; SystemParametersInfo(SPI_GETWORKAREA,0,&rectFull,0); CRect rect; m_dlgLog.GetWindowRect(rect); rect.MoveToXY(0, rectFull.bottom - rect.Height()); m_dlgLog.MoveWindow(rect); #endif // USE_DLGLOG ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //延长票据有效期 StartKeepTicketThread(); ////////////////////////////////////////////////////////////////////////// //在线编辑用到的共享内存初始化 m_pSharedMemoryOnlineEdit = NULL; m_pSharedMemoryOnlineEdit = new SharedMemoryOnlineEdit(); ////////////////////////////////////////////////////////////////////////// g_ReadRobotDB.Load(); pMainFrame->m_wndLoginBar.RedrawWindow(); CString sParamFile = m_CmdLine.GetValue( NULL ); if ( !sParamFile.IsEmpty() ) { ZTools::WriteZToolsFormatLog( "--------------********打开文件[%s]**********-------------", sParamFile ); theApp.m_processMgr.Open( sParamFile ); } else { ZTools::WriteZToolsLog( "--------------********未打开文件逻辑**********-------------" ); CDlgStart lgn; lgn.DoModal(); } #ifdef USE_DLGLOG m_dlgLog.ShowWindow(SW_SHOW); #endif // USE_DLGLOG ////////////////////////////////////////////////////////////////////////// WINDOWPLACEMENT wp; memset(&wp, NULL, sizeof(wp)); wp.length = sizeof (WINDOWPLACEMENT); if (pMainFrame->GetWindowPlacement (&wp)) { wp.rcNormalPosition = m_rcLastWindowPlacement; RECT rectDesktop; SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rectDesktop,0); OffsetRect(&wp.rcNormalPosition, -rectDesktop.left, -rectDesktop.top); pMainFrame->SetWindowPlacement (&wp); } return TRUE; }
bool CTrueType::RegistryLookup(LPCTSTR pszTarget, TTF_DATA_TYPE TargetType, CString& strResult, TTF_DATA_TYPE ResultType) { strResult.Empty(); CString strTarget = pszTarget; if (strTarget.IsEmpty()) return false; OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ::GetVersionEx(&osvi); bool bNT = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT); CRegKey regkey; if (regkey.Open(HKEY_LOCAL_MACHINE, (bNT ? REGKEY_NTFONT : REGKEY_FONT)) != ERROR_SUCCESS) return false; char strDisplayName[MAX_PATH]; DWORD dwDisplayNameLength = sizeof(strDisplayName)-1; char strFileName[MAX_PATH]; DWORD dwFileNameLength = sizeof(strFileName)-1; bool bFound = false; if (TargetType == TTF_DisplayName) { CString strTrueType = " (TrueType)"; if (strTarget.Find(strTrueType) < 0) strTarget += strTrueType; strcpy(strDisplayName, strTarget); bFound = (regkey.QueryStringValue(strDisplayName, strFileName, &dwFileNameLength) == ERROR_SUCCESS); } else { DWORD dwType = 0; DWORD dwIndex = 0; while (::RegEnumValue(regkey, dwIndex, strDisplayName, &dwDisplayNameLength, NULL, &dwType, (BYTE*)strFileName, &dwFileNameLength) == ERROR_SUCCESS) { dwIndex++; dwDisplayNameLength = sizeof(strDisplayName)-1; dwFileNameLength = sizeof(strFileName)-1; if (dwType != REG_SZ) continue; CString strValue; if (TargetType == TTF_FileName) strValue = strFileName; else if (TargetType == TTF_FaceName) { // Because GetFaceNameFromFileName() can be slow, assume that this is not a match // unless the first 2 characters of the target FaceName match the DisplayName if (strTarget[0] != strDisplayName[0] || strTarget[1] != strDisplayName[1]) continue; GetFaceNameFromFileName(strFileName, strValue); } bFound = (strTarget.CompareNoCase(strValue) == 0); if (bFound) break; } } if (!bFound) return false; if (ResultType == TTF_DisplayName) strResult = strDisplayName; else if (ResultType == TTF_FileName) strResult = strFileName; else if (ResultType == TTF_FaceName) GetFaceNameFromFileName(strFileName, strResult); return true; }
BSTR CMUSHclientDoc::ExportXML(short Type, LPCTSTR Name) { CString strResult; CString strName = Name; // trim spaces, force name to lower-case CheckObjectName (strName, false); char * p = NULL; try { CMemFile f; // open memory file for writing CArchive ar(&f, CArchive::store); // see if trigger exists, if not return EMPTY switch (Type) { case 0: // trigger { CTrigger * t; if (GetTriggerMap ().Lookup (strName, t)) { Save_Header_XML (ar, "triggers", false); Save_One_Trigger_XML (ar, t); Save_Footer_XML (ar, "triggers"); } // end of item existing } break; case 1: // alias { CAlias * t; if (GetAliasMap ().Lookup (strName, t)) { Save_Header_XML (ar, "aliases", false); Save_One_Alias_XML (ar, t); Save_Footer_XML (ar, "aliases"); } // end of item existing } break; case 2: // timer { CTimer * t; if (GetTimerMap ().Lookup (strName, t)) { Save_Header_XML (ar, "timers", false); Save_One_Timer_XML (ar, t); Save_Footer_XML (ar, "timers"); } // end of item existing } break; case 3: // macro { for (int i = 0; i < NUMITEMS (strMacroDescriptions); i++) { if (strMacroDescriptions [i].CompareNoCase (strName) == 0) { Save_Header_XML (ar, "macros", false); Save_One_Macro_XML (ar, i); Save_Footer_XML (ar, "macros"); } // end of item existing } // end of finding which one } break; case 4: // variable { CVariable * t; if (GetVariableMap ().Lookup (strName, t)) { Save_Header_XML (ar, "variables", false); Save_One_Variable_XML (ar, t); Save_Footer_XML (ar, "variables"); } // end of item existing } break; case 5: // keypad { for (int i = 0; i < NUMITEMS (strKeypadNames); i++) { if (strKeypadNames [i].CompareNoCase (strName) == 0) { Save_Header_XML (ar, "keypad", false); Save_One_Keypad_XML (ar, i); Save_Footer_XML (ar, "keypad"); } // end of item existing } // end of finding which one } break; } // end of switch ar.Close(); int nLength = f.GetLength (); p = (char *) f.Detach (); strResult = CString (p, nLength); free (p); // remove memory allocated in CMemFile p = NULL; } // end of try block catch (CException* e) { if (p) free (p); // remove memory allocated in CMemFile e->Delete(); strResult.Empty (); } // end of catch return strResult.AllocSysString(); } // end of CMUSHclientDoc::ExportXML
DWORD CHooks::RunScript(CString cmd, LPCTSTR currentDir, CString& error, bool bWait, bool bShow) { DWORD exitcode = 0; SECURITY_ATTRIBUTES sa; SecureZeroMemory(&sa, sizeof(sa)); sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; CAutoFile hOut ; CAutoFile hRedir; CAutoFile hErr; // clear the error string error.Empty(); // Create Temp File for redirection TCHAR szTempPath[MAX_PATH] = {0}; TCHAR szOutput[MAX_PATH] = {0}; TCHAR szErr[MAX_PATH] = {0}; GetTortoiseGitTempPath(_countof(szTempPath), szTempPath); GetTempFileName(szTempPath, _T("git"), 0, szErr); // setup redirection handles // output handle must be WRITE mode, share READ // redirect handle must be READ mode, share WRITE hErr = CreateFile(szErr, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, 0); if (!hErr) { error = CFormatMessageWrapper(); return (DWORD)-1; } hRedir = CreateFile(szErr, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); if (!hRedir) { error = CFormatMessageWrapper(); return (DWORD)-1; } GetTempFileName(szTempPath, _T("git"), 0, szOutput); hOut = CreateFile(szOutput, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, 0); if (!hOut) { error = CFormatMessageWrapper(); return (DWORD)-1; } // setup startup info, set std out/err handles // hide window STARTUPINFO si; SecureZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.hStdOutput = hOut; si.hStdError = hErr; si.wShowWindow = bShow ? SW_SHOW : SW_HIDE; PROCESS_INFORMATION pi; SecureZeroMemory(&pi, sizeof(pi)); if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, TRUE, 0, nullptr, currentDir, &si, &pi)) { const DWORD err = GetLastError(); // preserve the CreateProcess error error = CFormatMessageWrapper(err); SetLastError(err); cmd.ReleaseBuffer(); return (DWORD)-1; } cmd.ReleaseBuffer(); CloseHandle(pi.hThread); // wait for process to finish, capture redirection and // send it to the parent window/console if (bWait) { DWORD dw; char buf[256] = { 0 }; do { while (ReadFile(hRedir, &buf, sizeof(buf)-1, &dw, NULL)) { if (dw == 0) break; error += CString(CStringA(buf,dw)); } Sleep(150); } while (WaitForSingleObject(pi.hProcess, 0) != WAIT_OBJECT_0); // perform any final flushing while (ReadFile(hRedir, &buf, sizeof(buf)-1, &dw, NULL)) { if (dw == 0) break; error += CString(CStringA(buf, dw)); } WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, &exitcode); } CloseHandle(pi.hProcess); DeleteFile(szOutput); DeleteFile(szErr); return exitcode; }
void CCompareResultsDlg::WriteReportData() { CompareData::iterator cd_iter; CString buffer; if (!m_OnlyInCurrent.empty()) { buffer.Format(IDS_COMPAREENTRIES1, m_scFilename1); m_pRpt->WriteLine((LPCWSTR)buffer); for (cd_iter = m_OnlyInCurrent.begin(); cd_iter != m_OnlyInCurrent.end(); cd_iter++) { const st_CompareData &st_data = *cd_iter; buffer.Format(IDS_COMPARESTATS, st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str()); m_pRpt->WriteLine((LPCWSTR)buffer); } m_pRpt->WriteLine(); } if (!m_OnlyInComp.empty()) { buffer.Format(IDS_COMPAREENTRIES2, m_scFilename2); m_pRpt->WriteLine((LPCWSTR)buffer); for (cd_iter = m_OnlyInComp.begin(); cd_iter != m_OnlyInComp.end(); cd_iter++) { const st_CompareData &st_data = *cd_iter; buffer.Format(IDS_COMPARESTATS, st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str()); m_pRpt->WriteLine((LPCWSTR)buffer); } m_pRpt->WriteLine(); } if (!m_Conflicts.empty()) { buffer.Format(IDS_COMPAREBOTHDIFF); m_pRpt->WriteLine((LPCWSTR)buffer); const CString csx_password(MAKEINTRESOURCE(IDS_COMPPASSWORD)); const CString csx_notes(MAKEINTRESOURCE(IDS_COMPNOTES)); const CString csx_url(MAKEINTRESOURCE(IDS_COMPURL)); const CString csx_autotype(MAKEINTRESOURCE(IDS_COMPAUTOTYPE)); const CString csx_ctime(MAKEINTRESOURCE(IDS_COMPCTIME)); const CString csx_pmtime(MAKEINTRESOURCE(IDS_COMPPMTIME)); const CString csx_atime(MAKEINTRESOURCE(IDS_COMPATIME)); const CString csx_xtime(MAKEINTRESOURCE(IDS_COMPXTIME)); const CString csx_xtimeint(MAKEINTRESOURCE(IDS_COMPXTIME_INT)); const CString csx_rmtime(MAKEINTRESOURCE(IDS_COMPRMTIME)); const CString csx_pwhistory(MAKEINTRESOURCE(IDS_COMPPWHISTORY)); const CString csx_policy(MAKEINTRESOURCE(IDS_COMPPWPOLICY)); const CString csx_runcmd(MAKEINTRESOURCE(IDS_COMPRUNCOMMAND)); const CString csx_dca(MAKEINTRESOURCE(IDS_COMPDCA)); const CString csx_shiftdca(MAKEINTRESOURCE(IDS_COMPSHIFTDCA)); const CString csx_email(MAKEINTRESOURCE(IDS_COMPEMAIL)); const CString csx_protected(MAKEINTRESOURCE(IDS_COMPPROTECTED)); const CString csx_symbols(MAKEINTRESOURCE(IDS_COMPSYMBOLS)); const CString csx_policyname(MAKEINTRESOURCE(IDS_COMPPOLICYNAME)); const CString csx_kbshortcut(MAKEINTRESOURCE(IDS_KBSHORTCUT)); for (cd_iter = m_Conflicts.begin(); cd_iter != m_Conflicts.end(); cd_iter++) { const st_CompareData &st_data = *cd_iter; buffer.Format(IDS_COMPARESTATS2, st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str()); m_pRpt->WriteLine(std::wstring(buffer)); buffer.Empty(); // Non-time fields if (st_data.bsDiffs.test(CItemData::PASSWORD)) buffer += csx_password; if (st_data.bsDiffs.test(CItemData::NOTES)) buffer += csx_notes; if (st_data.bsDiffs.test(CItemData::URL)) buffer += csx_url; if (st_data.bsDiffs.test(CItemData::AUTOTYPE)) buffer += csx_autotype; if (st_data.bsDiffs.test(CItemData::PWHIST)) buffer += csx_pwhistory; if (st_data.bsDiffs.test(CItemData::POLICY)) buffer += csx_policy; if (st_data.bsDiffs.test(CItemData::RUNCMD)) buffer += csx_runcmd; if (st_data.bsDiffs.test(CItemData::DCA)) buffer += csx_dca; if (st_data.bsDiffs.test(CItemData::SHIFTDCA)) buffer += csx_shiftdca; if (st_data.bsDiffs.test(CItemData::EMAIL)) buffer += csx_email; if (st_data.bsDiffs.test(CItemData::PROTECTED)) buffer += csx_protected; if (st_data.bsDiffs.test(CItemData::SYMBOLS)) buffer += csx_symbols; if (st_data.bsDiffs.test(CItemData::POLICYNAME)) buffer += csx_policyname; if (st_data.bsDiffs.test(CItemData::KBSHORTCUT)) buffer += csx_kbshortcut; // Time fields if (st_data.bsDiffs.test(CItemData::CTIME)) buffer += csx_ctime; if (st_data.bsDiffs.test(CItemData::PMTIME)) buffer += csx_pmtime; if (st_data.bsDiffs.test(CItemData::ATIME)) buffer += csx_atime; if (st_data.bsDiffs.test(CItemData::XTIME)) buffer += csx_xtime; if (st_data.bsDiffs.test(CItemData::RMTIME)) buffer += csx_rmtime; if (st_data.bsDiffs.test(CItemData::XTIME_INT)) buffer += csx_xtimeint; m_pRpt->WriteLine((LPCWSTR)buffer); } m_pRpt->WriteLine(); } }
int GitRev::SafeGetSimpleList(CGit *git) { if(InterlockedExchange(&m_IsUpdateing,TRUE) == FALSE) { m_SimpleFileList.clear(); git->CheckAndInitDll(); GIT_COMMIT commit; GIT_COMMIT_LIST list; GIT_HASH parent; memset(&commit,0,sizeof(GIT_COMMIT)); CAutoLocker lock(g_Git.m_critGitDllSec); try { if(git_get_commit_from_hash(&commit, this->m_CommitHash.m_hash)) return -1; } catch (char *) { return -1; } int i=0; bool isRoot = this->m_ParentHash.empty(); git_get_commit_first_parent(&commit,&list); while(git_get_commit_next_parent(&list,parent) == 0 || isRoot) { GIT_FILE file=0; int count=0; try { if(isRoot) git_root_diff(git->GetGitSimpleListDiff(), commit.m_hash, &file, &count, 0); else git_diff(git->GetGitSimpleListDiff(), parent, commit.m_hash, &file, &count, 0); } catch (char *) { return -1; } isRoot = false; CTGitPath path; CString strnewname; CString stroldname; for (int j = 0; j < count; ++j) { path.Reset(); char *newname; char *oldname; strnewname.Empty(); stroldname.Empty(); int mode,IsBin,inc,dec; try { git_get_diff_file(git->GetGitSimpleListDiff(), file, j, &newname, &oldname, &mode, &IsBin, &inc, &dec); } catch (char *) { return -1; } git->StringAppend(&strnewname, (BYTE*)newname, CP_UTF8); m_SimpleFileList.push_back(strnewname); } git_diff_flush(git->GetGitSimpleListDiff()); ++i; } InterlockedExchange(&m_IsUpdateing,FALSE); InterlockedExchange(&m_IsSimpleListReady, TRUE); git_free_commit(&commit); } return 0; }
/////////////////////////////////////////////////////////////////////////////// // FormatText int CXHTMLStatic::FormatText(HDC hdc, LPCTSTR lpszText, RECT * pRect, int nInitialXOffset) { TRACE(_T("in CXHTMLStatic::FormatText: nInitialXOffset=%d <%-20.20s>\n"), nInitialXOffset, lpszText); //TRACERECT(*pRect); int xStart, /*yStart,*/ nWord, xNext, xLast, nLeftMargin; TCHAR *pText = (TCHAR *) lpszText; SIZE size; xNext = nInitialXOffset; nLeftMargin = nInitialXOffset; xLast = 0; if (pRect->top >= (pRect->bottom-1)) return 0; // set initial size TCHAR * szTest = _T("abcdefgABCDEFG"); GetTextExtentPoint32(hdc, szTest, _tcslen(szTest), &size); // prepare for next line - clear out the error term SetTextJustification(hdc, 0, 0); CString strOut = _T(""); BOOL bReturnSeen = FALSE; TEXTMETRIC tm; ::GetTextMetrics(hdc, &tm); do // for each text line { nWord = 0; // initialize number of spaces in line // skip to first non-space in line while (/**pText != _T('\0') && */*pText == _T(' ')) { if (xNext) strOut += *pText; pText++; } for(;;) // process each word { CString strWord; TCHAR *saved_pText = pText; strWord = GetNextWord(&pText, &bReturnSeen); CString strTrial; strTrial = strOut + strWord; // after each word, calculate extents nWord++; GetTextExtentPoint32(hdc, strTrial, strTrial.GetLength(), &size); BOOL bOverflow = (size.cx >= (pRect->right - xNext - 2)); // don't get too close to margin, // in case of italic text if (bOverflow) { if (strOut.IsEmpty()) { bOverflow = FALSE; strOut = strWord; } } else { strOut += strWord; } if (bReturnSeen || bOverflow || (*pText == _T('\0'))) { if (strOut.IsEmpty()) break; if (bOverflow) pText = saved_pText; nWord--; // discount last space at end of line // if end of text and no space characters, set pEnd to end GetTextExtentPoint32(hdc, strOut, strOut.GetLength(), &size); xStart = pRect->left; xStart += xNext; xNext = 0; xLast = xStart + size.cx; // display the text if ((m_yStart <= (pRect->bottom-size.cy)))// && (!IsBlank(strOut))) { TextOut(hdc, xStart, m_yStart, strOut, strOut.GetLength()); if (*pText || bReturnSeen) m_yStart += size.cy; } // prepare for next line - clear out the error term SetTextJustification(hdc, 0, 0); strOut.Empty(); } else // new word will fit { } } nWord--; // discount last space at end of line // if end of text and no space characters, set pEnd to end // prepare for next line - clear out the error term SetTextJustification(hdc, 0, 0); strOut.Empty(); } while (*pText && (m_yStart < pRect->bottom)); if (m_yStart > (pRect->bottom-size.cy)) pRect->top = pRect->bottom; else pRect->top = m_yStart; return xLast; }
bool SgmlElement::Write(CFileOutput *pOutput, int iLevel) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (pOutput == NULL) return false; CString csTabString; if (iLevel != -1) { for (int i = 0; i < iLevel; ++i) csTabString += " "; } CString csSgmlString; CString writeString; writeString.Format(_T("%s<%s"), csTabString, m_csName); for (int i = 0; i < m_aAttributes.GetSize(); ++i) { Attribute *pAttribute = m_aAttributes[i]; if (pAttribute != NULL) { writeString += _T(" "); writeString += pAttribute->GetName(); writeString += _T("=\""); StringManipulation::TransformForSgml(pAttribute->GetValue(), csSgmlString); writeString += csSgmlString; writeString += _T("\""); } } writeString += _T(">"); pOutput->Append(writeString); if (!m_csParameter.IsEmpty()) { writeString.Empty(); StringManipulation::TransformForSgml(m_csParameter.GetStringBuffer(), csSgmlString); if (m_bUseOneLine) { writeString.Format(_T("%s"), csSgmlString); csTabString.Empty(); } else { writeString.Format(_T("\n%s\n"), csSgmlString); } pOutput->Append(writeString); } if (!m_aElements.IsEmpty()) { pOutput->Append(_T("\n")); for (int i = 0; i < m_aElements.GetSize(); ++i) { SgmlElement *pElement = m_aElements[i]; if (pElement != NULL) { if (iLevel != -1) pElement->Write(pOutput, iLevel + 1); else pElement->Write(pOutput, iLevel); } } } else // use only one line csTabString.Empty(); CString csEndTag; csEndTag.Format(_T("%s</%s>\n"), csTabString, m_csName); pOutput->Append(csEndTag); return true; }
//-------------------------------------------------------------------------------- int CTextSocket::Receive(CString& sText) { // if we have something queued then just return it if(m_buffer.GetCount() > 0) { POSITION pos = m_buffer.GetHeadPosition(); if(pos == NULL) return 0; sText = m_buffer.GetAt(pos); m_buffer.RemoveAt(pos); return sText.GetLength(); } sText.Empty(); DWORD nStart = ::GetTickCount(); for(;;) { int nLen = CSmallSocket::Receive(sText.GetBuffer(1024), 1024); sText.ReleaseBuffer(nLen == -1 ? 0 : nLen); if(nLen == 0) return 0; if(nLen == SOCKET_ERROR) { DWORD nNow = ::GetTickCount(); // check for tickcount wrap around - happens every 49.7 days // of continuous running - see GetTickCount if(nNow < nStart) { nStart = ::GetTickCount(); continue; } // see if we've timed out if((nStart + GetTimeOut()) <= nNow) return 0; if(::WSAGetLastError() == WSAEWOULDBLOCK) { ::Sleep(100); continue; } else return SOCKET_ERROR; } for(int i = 0; i < sText.GetLength(); i++) { TCHAR cCur = sText[i]; switch(cCur) { case '\r': m_buffer.AddTail(m_sCurLine); m_sCurLine.Empty(); break; case '\n': break; default: m_sCurLine += cCur; break; } } sText.Empty(); return 0; } }
int GetVariableValue(int index ,CString &ret_cstring,CString &ret_unit,CString &Auto_M,int &digital_value) { CStringArray temparray; CString temp1; if(index >= BAC_VARIABLE_ITEM_COUNT) { ret_cstring.Empty(); ret_unit.Empty(); Auto_M.Empty(); return -1; } int i = index; if(m_Variable_data.at(i).auto_manual == 1) { Auto_M = _T("M"); } else { Auto_M.Empty(); } if(m_Variable_data.at(i).digital_analog == BAC_UNITS_DIGITAL) { if(m_Variable_data.at(i).range>30) { ret_cstring.Empty(); return -1; } else { if((m_Variable_data.at(i).range < 23) &&(m_Variable_data.at(i).range !=0)) temp1 = Digital_Units_Array[m_Variable_data.at(i).range]; else if((m_Variable_data.at(i).range >=23) && (m_Variable_data.at(i).range <= 30)) { if(receive_customer_unit) temp1 = temp_unit_no_index[m_Variable_data.at(i).range - 23]; } else { ret_cstring.Empty(); return -1; } SplitCStringA(temparray,temp1,_T("/")); if((temparray.GetSize()==2)) { if(m_Variable_data.at(i).control == 0) { digital_value = 0; ret_cstring = temparray.GetAt(0); return 1; } else { digital_value = 1; ret_cstring = temparray.GetAt(1); } } } } else { if(m_Variable_data.at(i).range == 20) //如果是时间; { ret_unit = Variable_Analog_Units_Array[m_Variable_data.at(i).range]; char temp_char[50]; int time_seconds = m_Variable_data.at(i).value / 1000; intervaltotext(temp_char,time_seconds,0,0); MultiByteToWideChar( CP_ACP, 0, temp_char, strlen(temp_char) + 1, ret_cstring.GetBuffer(MAX_PATH), MAX_PATH ); ret_cstring.ReleaseBuffer(); digital_value = 2; } else if((m_Variable_data.at(i).range<=sizeof(Variable_Analog_Units_Array)/sizeof(Variable_Analog_Units_Array[0])) && (m_Variable_data.at(i).range != 0)) { ret_unit = Variable_Analog_Units_Array[m_Variable_data.at(i).range]; CString cstemp_value; float temp_float_value; temp_float_value = ((float)m_Variable_data.at(i).value) / 1000; ret_cstring.Format(_T("%.3f"),temp_float_value); digital_value = 2; } else { ret_cstring.Empty(); return -1; } } return 1; }
BOOL CGIB::CreateGIBInputFile(CFile& file, CPlayer* pPlayer, CHandHoldings* pHand, CHandHoldings* pDummyHand, CString& strContents) const { // format the input CString strInput; CEasyBDoc* pDoc = pDOC; // indicate player strInput.Format("%c\n",PositionToChar(pPlayer->GetPosition())); strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // indicate hand strInput = pHand->GetInitialHand().GetGIBFormatHoldingsString(); strInput += '\n'; strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // indicate dealer strInput.Format("%c\n",PositionToChar(pDoc->GetDealer())); strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // indicate vulnerability strInput = "n\n"; // TEMP strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // indicate auction strInput.Empty(); int numBids = pDoc->GetNumBidsMade(); for(int i=0;i<numBids;i++) { strInput += BidToBriefString(pDoc->GetBidByIndex(i)); if (i < numBids) strInput += ' '; } strInput += '\n'; strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // indicate opening lead int nLeadCard = pDoc->GetPlayRecord(0); strInput.Format("%s\n",CardToShortString(nLeadCard)); strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // indicate dummy's (ORIGINAL) hand strInput = pDummyHand->GetInitialHand().GetGIBFormatHoldingsString(); strInput += '\n'; strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // and enter any plays so far strInput.Empty(); int numCardsPlayed = pDoc->GetNumCardsPlayedInGame(); for(i=1;i<numCardsPlayed;i++) { strInput += CardToShortString(pDoc->GetPlayRecord(i)); strInput += ' '; if (((i % 3) == 0) || (i == numCardsPlayed-1)) { // flush the line strInput += '\n'; file.Write((LPCTSTR)strInput, strInput.GetLength()); strInput.Empty(); } } // end the file with a # sign strInput = "#\n"; strContents += strInput; file.Write((LPCTSTR)strInput, strInput.GetLength()); // done return TRUE; }
void CEmoticonRichEditCtrl::FormatTextRange(int nStart, int nEnd) { BOOL bEmoticon = FALSE; if (nStart >= nEnd) { TRACE("\nreturn!!\n"); return; } m_bInForcedChange = TRUE; CHARRANGE crOldSel; GetSel(crOldSel); TRACE("crOldSel MIN [%d] MAX [%d] \n", crOldSel.cpMin, crOldSel.cpMax ); HideSelection(TRUE, FALSE); TCHAR *pBuffer = NULL; //char *pBuffer = NULL; try { TRACE("FormatTextRange : nStart [%d] nEnd [%d] \n", nStart, nEnd); SetSel(nStart, nEnd); pBuffer = new TCHAR[nEnd - nStart + 1]; //pBuffer = new char[nEnd - nStart + 1]; long nLen = GetSelText(pBuffer); pBuffer[nLen] = 0; TRACE("new [%d] pBuffer [%S]\n", nEnd - nStart + 1, pBuffer); //ASSERT(nLen <= nEnd - nStart); TCHAR *pStart, *pPtr, *pSymbolStart ; //char* pStart = NULL, *pPtr = NULL; //char* pSymbolStart = NULL; pStart = pPtr = pBuffer; while (*pPtr != 0) { TCHAR ch = *pPtr; //char ch = *pPtr; if ( _istalpha(ch) || ch == '_') { pSymbolStart = pPtr; do { ch = *(++pPtr); } while (_istalnum(ch) || ch == '_'); *pPtr = 0; //TRACE("pSymbolStart [%s]\n", pSymbolStart ); int nPos = IsEmoticon(pSymbolStart); if (nPos >= 0) { bEmoticon = TRUE; SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG); //TRACE("이모티콘!!! [%s]\n", pSymbolStart ); SetSel(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer ); ReplaceSel(" "); TRACE("이모티콘영역 [%d] [%d]\n", nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer ); CString strTmp(pSymbolStart); int nIndex = atoi( (LPCSTR)strTmp.Mid(2,2) ) ; HBITMAP hBitmap = GetImage( m_imgListFaces , nIndex ); if (hBitmap) { CString strOutID; strOutID.Empty(); CImageDataObject::InsertBitmap(m_pRichEditOle, hBitmap, strOutID ); // strTmp => ec01 , strOutID = 12232132321 if(m_nRole == ROLE_SEND_INPUT ) { char* pszID = new char[10+1]; char* pszVal = new char[10+1]; strncpy(pszID, (LPCSTR)strOutID, 10); strcpy(pszVal, pSymbolStart); TRACE("WM_EMOTICON_MAP : pszID [%s] pszVal [%s]\n", pszID, pszVal ); GetParent()->SendMessage( WM_EMOTICON_MAP, (WPARAM) pszID , (LPARAM) pszVal) ; } } ReplaceSel(" "); pStart = pPtr; pSymbolStart = 0; } else { pSymbolStart = NULL; } *pPtr = ch; } else { pPtr++; } } } catch(...) { //delete [] pBuffer; //pBuffer = NULL ; } delete [] pBuffer; if(m_nRole == ROLE_SEND_INPUT ) { CHARFORMAT2 cf; GetSelectionCharFormat(cf); cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE ; cf.crTextColor = CChatSession::Instance().m_ColorMe; cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR; SetSelectionCharFormat(cf); } SetSel(crOldSel); if(m_nRole == ROLE_SEND_INPUT ) { CHARFORMAT2 cf; GetSelectionCharFormat(cf); cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE ; cf.crTextColor = CChatSession::Instance().m_ColorMe; cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR; SetSelectionCharFormat(cf); } HideSelection(FALSE, FALSE); //UnlockWindowUpdate(); SetBackgroundColor( FALSE, CChatSession::Instance().m_ColorBG ); m_bInForcedChange = FALSE; }
bool CWebCDCovers::DownloadImage(CString strLetter, CString strName, CString strFilename, RESOURCEHOST* pHost, HWND hwndProgress, HWND hwndStatus, CString& strLocalFilename) { // get the html page for the image source *m_pbCancelDownload = false; WCC_GETIMAGEREQUEST* pfn_wccRequest = (WCC_GETIMAGEREQUEST*) GetProcAddress (pHost->hInst, "GetImageRequest"); WCC_GETIMAGEURL* pfn_wccImgURL = (WCC_GETIMAGEURL*) GetProcAddress (pHost->hInst, "GetImageURL"); char szUrl[300], szHeaders[300], szData[300]; int nMethod; pfn_wccRequest (strFilename.GetBuffer (0), strLetter.GetBuffer (0), "", szUrl, &nMethod, szHeaders, szData); CString strHTML = (*szUrl == 0) ? strFilename.GetBuffer (0) : CHttpRequest::DownloadBuffer (szUrl, nMethod, szHeaders, szData, m_pbCancelDownload, m_dwDownloadId, m_nError); // MCH 29/08/04 // Send version info to the DLL strcpy (szData, ((CCdCoverCreator2App*) AfxGetApp ())->GetVersion ().GetBuffer (-1)); // get the URL of the image CString strURL; if (!pfn_wccImgURL (strHTML.GetBuffer (0), strURL.GetBuffer (500), &nMethod, szHeaders, szData)) return false; strURL.ReleaseBuffer (); // generate a local temporary file name strLocalFilename = ((CCdCoverCreator2App*) AfxGetApp ())->GetImageCacheDir () + strURL.Mid (strURL.ReverseFind ('/') + 1); if (strLocalFilename.Find (".php?") >= 0) { // MCH 15/09/04 // www.darktown.to sends again JPGs, but via a PHP script. Filename provided as HTTP header which is not available here strLocalFilename = ((CCdCoverCreator2App*) AfxGetApp ())->GetImageCacheDir (); strLocalFilename.AppendFormat ("dld%d.jpg", GetTickCount ()); } // get the jpeg image *m_pbCancelDownload = false; CHttpRequest::DownloadFile (strURL, nMethod, szHeaders, szData, strLocalFilename, m_pbCancelDownload, m_dwDownloadId, m_nError, 0, hwndProgress, hwndStatus); if (m_nError) return false; // MCH 29/08/04 // if the download is a zip file, extract the image if (strLocalFilename.Right (4).MakeLower () == ".zip") { CString strPath = strLocalFilename.Left (strLocalFilename.ReverseFind ('\\')); CString strZipFile = strLocalFilename; // set up and open a zip archive, get the image files inside the zip file CZipArchive zip; zip.Open (strZipFile); CZipWordArray ar; zip.FindMatches ("*.jp*g", ar); strLocalFilename.Empty (); // extract the image files for (int i = 0; i < ar.GetSize (); i++) { // set the local file name CZipFileHeader info; zip.GetFileInfo (info, i); if (!strLocalFilename.IsEmpty ()) strLocalFilename += ";"; strLocalFilename += strPath + "\\" + info.GetFileName (); // extract the file zip.ExtractFile (ar.GetAt (i), strPath, false); } zip.Close (); // delete the zip file ::DeleteFile (strZipFile); } return true; }
void ClearUpGlobalData() { int i; option_filename.Empty(); trainset_filename.Empty(); validset_filename.Empty(); classifier_filename.Empty(); ada_log_filename.Empty(); cascade_filename.Empty(); FFS_WeakClassifiers_filename.Empty(); FFS_log_filename = "rate_FFS.txt"; FileUsage_log_filename.Empty(); Bootstrap_database_filename.Empty(); Backup_directory_name.Empty(); TestSet_filename.Empty(); sx = sy = 0; train_method = 0; linear_classifier = 0; bootstrap_level = 0; max_bootstrap_level = 0; bootstrap_resizeratio.clear(); bootstrap_increment.clear(); first_feature = 0; max_files = 0; goal_method = 0; node_det_goal = 0.0; node_fp_goal = 0.0; asym_ratio = 0.0; max_nodes = 0; nof.clear(); delete[] trainset; trainset = NULL; delete[] validset; validset = NULL; totalcount = validcount = 0; delete cascade; cascade = NULL; delete[] weights; weights = NULL; for(i=0;i<totalfeatures;i++) { delete[] table[i]; table[i] = NULL; } totalfeatures = 0; delete[] table; table = NULL; delete[] classifiers; classifiers = NULL; delete[] features; features = NULL; delete[] labels; labels = NULL; delete[] fileused; fileused = NULL; bootstrap_size = 0; delete[] bootstrap_filenames; bootstrap_filenames = NULL; }
//This method gets called by its static counterpart, and is the actual thread logic DWORD WINAPI Kinect::ProcessThread() { //numEvents is the number of events, handleEvents is an Array of all the events being handled. const int numEvents = 4; HANDLE handleEvents[numEvents] = { treadNuiProcessStop, nextColorFrameEvent, nextDepthFrameEvent, nextSkeletonEvent }; std::stringstream ss; int eventIdx, colorFrameFPS = 0, depthFrameFPS = 0; DWORD t, lastColorFPSTime, lastDepthFPSTime; CString TextFPS; // Initializes the static text fields for FPS text. CStatic * MFC_ecFPSCOLOR, * MFC_ecFPSDEPTH; //Initialize the Image vieuwer on the GUI. Because this class does not inherit anything relatied to MFC, we need CWnd::GetDlgItem instead of just GetDlgItem. // (By the way: because the main is a CWnd and 'GetDlgItem()' means the same thing as 'this->GetDlgItem()', main.cpp actually uses the same method.) MFC_ecFPSCOLOR = (CStatic *) cWnd.GetDlgItem(1013); MFC_ecFPSDEPTH = (CStatic *) cWnd.GetDlgItem(1014); lastColorFPSTime = timeGetTime( ); lastDepthFPSTime = timeGetTime( ); //blank the skeleton display when started. lastSkeletonFoundTime = 0; bool continueProcess = true; while ( continueProcess ) { // wait for any of the events eventIdx = WaitForMultipleObjects( numEvents, handleEvents, FALSE, 100); // timed out, continue if ( eventIdx == WAIT_TIMEOUT) { continue; } // stop event was signalled if ( WAIT_OBJECT_0 == eventIdx ) { continueProcess = false; break; } // Wait for each object individually with a 0 timeout to make sure to // process all signalled objects if multiple objects were signalled // this loop iteration // In situations where perfect correspondance between color/depth/skeleton // is essential, a priority queue should be used to service the item // which has been updated the longest ago Copyright Microsoft. if ( WAIT_OBJECT_0 == WaitForSingleObject( nextColorFrameEvent, 0) ) { if( gotColorAlert() ) { ++colorFrameFPS; } } if ( WAIT_OBJECT_0 == WaitForSingleObject( nextDepthFrameEvent, 0) ) { if( gotDepthAlert() ) { ++depthFrameFPS; } } if (WAIT_OBJECT_0 == WaitForSingleObject( nextSkeletonEvent, 0)) { if (gotSkeletonAlert() ) { } } // fps counter for the color stream. // compare first frametime with the current time, if more then 1000 passed, // one second passed. t = timeGetTime(); if((t - lastColorFPSTime) > 1000) { ss<<colorFrameFPS; TextFPS= ss.str().c_str(); MFC_ecFPSCOLOR->SetWindowText(TextFPS); colorFrameFPS = 0; lastColorFPSTime = timeGetTime(); // Reset both the CString text and the stringstream, so you don't get any crazy value's. TextFPS.Empty(); ss.str(""); ss<<depthFrameFPS; TextFPS = ss.str().c_str(); MFC_ecFPSDEPTH->SetWindowText(TextFPS); depthFrameFPS = 0; // Reset both the CString text and the stringstream, so you don't get any crazy value's. TextFPS.Empty(); ss.str(""); if( (t - lastSkeletonFoundTime) > 300) { if (!screenBlanked) { blankSkeletonScreen(); screenBlanked = true; } } } } return 0; }
void CClientListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for(int iCurrent = 0; iCurrent < iCount; iCurrent++){ int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if( !IsColumnHidden(iColumn) ){ cur_rec.right += GetColumnWidth(iColumn); switch(iColumn){ case 0:{ uint8 image; if (client->IsFriend()) image = 2; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) image = 4; else if (client->GetClientSoft() == SO_MLDONKEY) image = 3; else if (client->GetClientSoft() == SO_SHAREAZA) image = 5; else if (client->GetClientSoft() == SO_URL) image = 6; else if (client->GetClientSoft() == SO_AMULE) image = 7; else if (client->GetClientSoft() == SO_LPHANT) image = 8; else if (client->ExtProtocolAvailable()) image = 1; else image = 0; uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); if (client->GetUserName()==NULL) Sbuffer.Format(_T("(%s)"), GetResString(IDS_UNKNOWN)); else Sbuffer = client->GetUserName(); //EastShare Start - added by AndCycle, IP to Country CString tempStr; tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer); Sbuffer = tempStr; if(CGlobalVariable::ip2country->ShowCountryFlag()){ cur_rec.left+=20; POINT point2= {cur_rec.left,cur_rec.top+1}; CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL); } //EastShare End - added by AndCycle, IP to Country cur_rec.left +=20; dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left -=20; //EastShare Start - added by AndCycle, IP to Country if(CGlobalVariable::ip2country->ShowCountryFlag()){ cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 1:{ Sbuffer = client->GetUploadStateDisplayString(); break; } case 2:{ if(client->credits) Sbuffer = CastItoXBytes(client->credits->GetUploadedTotal(), false, false); else Sbuffer.Empty(); break; } case 3:{ Sbuffer = client->GetDownloadStateDisplayString(); break; } case 4:{ if(client->credits) Sbuffer = CastItoXBytes(client->credits->GetDownloadedTotal(), false, false); else Sbuffer.Empty(); break; } case 5:{ Sbuffer = client->GetClientSoftVer(); if (Sbuffer.IsEmpty()) Sbuffer = GetResString(IDS_UNKNOWN); break; } case 6:{ if(client->socket){ if(client->socket->IsConnected()){ Sbuffer = GetResString(IDS_YES); break; } } Sbuffer = GetResString(IDS_NO); break; } case 7: Sbuffer = md4str(client->GetUserHash()); break; } if( iColumn != 0) dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } // draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if(bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
// This method is assumed to be called with m_SharedMutex locked. int CGitHeadFileList::GetPackRef(const CString &gitdir) { CString PackRef = g_AdminDirMap.GetAdminDir(gitdir) + _T("packed-refs"); __int64 mtime; if (g_Git.GetFileModifyTime(PackRef, &mtime)) { //packed refs is not existed this->m_PackRefFile.Empty(); this->m_PackRefMap.clear(); return 0; } else if(mtime == m_LastModifyTimePackRef) { return 0; } else { this->m_PackRefFile = PackRef; this->m_LastModifyTimePackRef = mtime; } m_PackRefMap.clear(); CAutoFile hfile = CreateFile(PackRef, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (!hfile) return -1; DWORD filesize = GetFileSize(hfile, nullptr); if (filesize == 0) return -1; DWORD size = 0; std::unique_ptr<char[]> buff(new char[filesize]); ReadFile(hfile, buff.get(), filesize, &size, nullptr); if (size != filesize) return -1; CString hash; CString ref; for (DWORD i = 0; i < filesize;) { hash.Empty(); ref.Empty(); if (buff[i] == '#' || buff[i] == '^') { while (buff[i] != '\n') { ++i; if (i == filesize) break; } ++i; } if (i >= filesize) break; while (buff[i] != ' ') { hash.AppendChar(buff[i]); ++i; if (i == filesize) break; } ++i; if (i >= filesize) break; while (buff[i] != '\n') { ref.AppendChar(buff[i]); ++i; if (i == filesize) break; } if (!ref.IsEmpty()) m_PackRefMap[ref] = hash; while (buff[i] == '\n') { ++i; if (i == filesize) break; } } return 0; }
void CSearchPanel::ShowSearch(const CManagedSearch* pManaged) { if ( ! pManaged ) { OnSchemaChange(); return; } CQuerySearchPtr pSearch = pManaged->GetSearch(); if ( ! pSearch ) { OnSchemaChange(); return; } CString strURN; // The search is based on the priority from the lowest to highest if ( pSearch->m_oMD5 ) { strURN = pSearch->m_oMD5.toUrn(); } if ( pSearch->m_oBTH ) { strURN = pSearch->m_oBTH.toUrn(); } if ( pSearch->m_oTiger ) { strURN = pSearch->m_oTiger.toUrn(); } if ( pSearch->m_oED2K ) { strURN = pSearch->m_oED2K.toUrn(); } if ( pSearch->m_oSHA1 ) { strURN = pSearch->m_oSHA1.toUrn(); } if ( ! strURN.IsEmpty() ) { m_boxSearch.m_wndSearch.SetWindowText( pSearch->m_sSearch.IsEmpty() ? strURN : ( strURN + _T(" ") + pSearch->m_sSearch ) ); } else m_boxSearch.m_wndSearch.SetWindowText( pSearch->m_sSearch ); m_boxSearch.m_wndSchemas.Select( pSearch->m_pSchema ); if ( m_bAdvanced ) { m_boxAdvanced.m_wndCheckBoxG2.SetCheck( pManaged->m_bAllowG2 ? BST_CHECKED : BST_UNCHECKED); m_boxAdvanced.m_wndCheckBoxG1.SetCheck( pManaged->m_bAllowG1 ? BST_CHECKED : BST_UNCHECKED ); m_boxAdvanced.m_wndCheckBoxED2K.SetCheck( pManaged->m_bAllowED2K ? BST_CHECKED : BST_UNCHECKED ); m_boxAdvanced.m_wndCheckBoxDC.SetCheck( pManaged->m_bAllowDC ? BST_CHECKED : BST_UNCHECKED ); CString strSize; if ( pSearch->m_nMinSize > 0 && pSearch->m_nMinSize < SIZE_UNKNOWN ) strSize = Settings.SmartVolume(pSearch->m_nMinSize, Bytes, true ); else strSize.Empty(); if ( m_boxAdvanced.m_wndSizeMin.m_hWnd != NULL ) m_boxAdvanced.m_wndSizeMin.SetWindowText( strSize ); if ( pSearch->m_nMaxSize > 0 && pSearch->m_nMaxSize < SIZE_UNKNOWN ) strSize = Settings.SmartVolume( pSearch->m_nMaxSize, Bytes, true ); else strSize.Empty(); if ( m_boxAdvanced.m_wndSizeMax.m_hWnd != NULL ) m_boxAdvanced.m_wndSizeMax.SetWindowText( strSize ); } OnSchemaChange(); if ( pSearch->m_pXML != NULL ) { m_boxSchema.m_wndSchema.UpdateData( pSearch->m_pXML->GetFirstElement(), FALSE ); } }
int GitRev::SafeFetchFullInfo(CGit *git) { if(InterlockedExchange(&m_IsUpdateing,TRUE) == FALSE) { this->m_Files.Clear(); git->CheckAndInitDll(); GIT_COMMIT commit; GIT_COMMIT_LIST list; GIT_HASH parent; memset(&commit,0,sizeof(GIT_COMMIT)); CAutoLocker lock(g_Git.m_critGitDllSec); try { if (git_get_commit_from_hash(&commit, this->m_CommitHash.m_hash)) return -1; } catch (char *) { return -1; } int i=0; git_get_commit_first_parent(&commit,&list); bool isRoot = (list==NULL); while(git_get_commit_next_parent(&list,parent) == 0 || isRoot) { GIT_FILE file=0; int count=0; try { if (isRoot) git_root_diff(git->GetGitDiff(), this->m_CommitHash.m_hash, &file, &count, 1); else git_diff(git->GetGitDiff(), parent, commit.m_hash, &file, &count, 1); } catch (char *) { git_free_commit(&commit); return -1; } isRoot = false; CTGitPath path; CString strnewname; CString stroldname; for (int j = 0; j < count; ++j) { path.Reset(); char *newname; char *oldname; strnewname.Empty(); stroldname.Empty(); int mode,IsBin,inc,dec; git_get_diff_file(git->GetGitDiff(),file,j,&newname,&oldname, &mode,&IsBin,&inc,&dec); git->StringAppend(&strnewname, (BYTE*)newname, CP_UTF8); git->StringAppend(&stroldname, (BYTE*)oldname, CP_UTF8); path.SetFromGit(strnewname,&stroldname); path.ParserAction((BYTE)mode); path.m_ParentNo = i; this->m_Action|=path.m_Action; if(IsBin) { path.m_StatAdd=_T("-"); path.m_StatDel=_T("-"); } else { path.m_StatAdd.Format(_T("%d"),inc); path.m_StatDel.Format(_T("%d"),dec); } m_Files.AddPath(path); } git_diff_flush(git->GetGitDiff()); ++i; } InterlockedExchange(&m_IsUpdateing,FALSE); InterlockedExchange(&m_IsFull,TRUE); git_free_commit(&commit); } return 0; }
/** * \brief Extracts the signal data from the given Line and populates message structure. * \param[in] char *pcLine * \param[out] None * \return int * \authors Mahesh.B.S * \date 15.11.2004 */ int CSignal::Format(char *pcLine) { char *pcToken; char acTemp[defCON_MAX_TOKN_LEN],*pcTemp; pcTemp = acTemp; // get signal name pcToken = strtok(pcLine,","); // get upto colon // now get the signal name m_sName = pcToken; // copy the name to the signal's data member if(m_sName.GetLength() > defCON_MAX_MSGN_LEN) Truncate_str("Signal name",m_sName,true); // Signal length pcToken = strtok(NULL,","); m_ucLength = atoi(pcToken); // store signal length // get which byte pcToken = strtok(NULL,","); m_ucWhichByte = atoi(pcToken); // get start bit UCHAR ucStartBit; pcToken = strtok(NULL,","); m_ucStartBit = atoi(pcToken); ucStartBit = m_ucStartBit + (m_ucWhichByte - 1) * 8; //get Data type pcToken = strtok(NULL,","); m_ucType = *pcToken; // get MAX pcToken = strtok(NULL,","); // now store as double until we parse till SIG_VALTYPE_ m_MaxValue.ui64Value = _strtoui64(pcToken, NULL, 10); // get MIN value pcToken = strtok(NULL,","); //venkat - unsiged __int64 is enough to store any value m_MinValue.ui64Value = _strtoui64(pcToken, NULL, 10); // get DATA_FORMAT (intel or motorola) pcToken = strtok(NULL,","); m_ucDataFormat = *pcToken; if(m_ucDataFormat == '0') { UINT unByteIndex = m_ucWhichByte - 1; UINT nByte = (m_ucLength/8) + ((m_ucLength % 8)?1:0); UINT nStartBit = (m_ucWhichByte - nByte) * 8; UINT nBitSize = m_ucLength - (8 * (nByte - 1))+ m_ucStartBit; if(nBitSize == 0) { ucStartBit = ucStartBit + m_ucLength; } else { ucStartBit = nStartBit + nBitSize-1; } } m_ucStartBit = ucStartBit; // next token - (SCALE_FACTOR,OFFSET) pcToken = strtok(NULL,","); m_fOffset = (float)atof(pcToken); // store scale factor // Get offset pcToken = strtok(NULL,","); m_fScaleFactor = (float)atof(pcToken); // store Offset // next token -- "UNIT", "" pcTemp = acTemp; pcToken = strtok(NULL,""); //pcToken++; // copy everything, but not including the last <"> while(*pcToken && *pcToken != ',' && *pcToken != 0xa) { *pcTemp++ = *pcToken++; } *pcTemp='\0'; CString strUnit_Temp = acTemp; m_sUnit = "\""; m_sUnit = m_sUnit + acTemp; // copy UNIT to corresponding data member. m_sUnit = m_sUnit.Left(defCON_MAX_MSGN_LEN + 1); m_sUnit = m_sUnit + "\""; if(strUnit_Temp.GetLength() > defCON_MAX_MSGN_LEN + 2) { char logmsg[defCON_MAX_LINE_LEN]; sprintf(logmsg,"unit %s changed to %s\n",strUnit_Temp,m_sUnit); CConverter::fileLog.WriteString(logmsg); CConverter::bLOG_ENTERED = true; } //for multiplexing field CString strTemp = pcToken; int nIndex = strTemp.Find(','); if(nIndex != -1) { int nLength = strTemp.GetLength(); strTemp = strTemp.Right(nLength - nIndex -1); nIndex = strTemp.Find(','); if(nIndex != -1) { if(nIndex != 0) { strTemp = strTemp.Left(nIndex); } else { strTemp.Empty(); } m_sMultiplex = strTemp; } } //rx'ing nodes pcToken = strtok(pcToken,","); pcToken = strtok(NULL,","); pcToken = strtok(NULL,"\n"); if(pcToken) m_sNode = pcToken; else m_sNode = "Vector__XXX"; return 1; }
void CAllDlg::OnBnClickedEditButton() { // TODO: Add your control notification handler code here CString strArr[20]; int n_field,nCurSel; CString q; UpdateData(TRUE); switch(tab_id) { case TAB_NHAP_ID: ptr_cKmysql->select_table(NHAP_TABLE); q.Empty(); q.Format(CString("DELETE FROM nhap WHERE dot_nhap='%s' AND ms_hang='%s';"),m_vDotNhap,m_vTenHangBrif); if(!ptr_cKmysql->query(q)) goto error_del; n_field=N_NHAP_FIELD; strArr[0]=m_vTenHangBrif; strArr[1]=m_vSoLuongKgN; strArr[2]=m_vDotNhap; strArr[3]=m_vSoLuongCayN; strArr[4]=m_vDonGia; strArr[5]=m_vThueNhap; strArr[6]=m_vComment; break; case TAB_XUAT_ID: ptr_cKmysql->select_table(XUAT_TABLE); q.Empty(); q.Format(CString("DELETE FROM xuat WHERE dot_nhap='%s' AND ms_hang='%s';"),m_vDotNhap,m_vTenHangBrif); if(!ptr_cKmysql->query(q)) goto error_del; n_field=N_XUAT_FIELD; strArr[0]=m_vTenHangBrif; strArr[1]=m_vSoLuongKgX; strArr[2]=m_vDotNhap; strArr[3]=m_vSoLuongCayX; strArr[4]=m_vDonGia; strArr[5]=m_vThueNhap; strArr[6]=m_vNgayXuat; strArr[7]=m_vComment; break; case TAB_DOT_ID: n_field=4; ptr_cKmysql->select_table("dot"); q.Empty(); q.Format(CString("DELETE FROM dot WHERE dot_nhap='%s';"),m_vDotNhap); if(!ptr_cKmysql->query(q)) goto error_del; strArr[0]=m_vDotNhap; strArr[1]=m_vChungTu; strArr[2]=m_vNgayNhap; strArr[3]=m_vComment; break; case TAB_HANG_ID: // ptr_cKmysql->select_table("hang"); // n_field=4; // strArr[0]=m_vDotNhap; // strArr[1]=m_vTenHangBrif; // strArr[2]=m_vTenHangFull; // strArr[3]=m_vComment; goto exit; break; default: n_field=0; goto exit; } if(ptr_cKmysql->insert_row(strArr,n_field)) { AfxMessageBox(_T("đã sửa xong!")); nCurSel = m_cAllList.GetNextItem(-1 , LVNI_FOCUSED | LVNI_SELECTED); edit_row(nCurSel,strArr,n_field); } else { error_del: AfxMessageBox(_T("ko sửa được!")); } exit: ; }
BOOL CLoginDlg::AuthWeb() { CString csBuff; char httpBuff[1024]; CString csHash; CMD5 md5SPIP; int nBytes; unsigned char lpszBuffer[16]; // Authentication for web pages TRY { CInternetSession session; CString csIdSession, csSession; csBuff.Empty(); memset(httpBuff, 0, 1024); session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 1000); session.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 3); CFile* pf = session.OpenURL(URL_LOGIN_WEB, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD); while(nBytes = pf->Read(httpBuff, 1024)) { csBuff += httpBuff; } pf->Close(); if(csBuff.Find('/') != -1) { csSession = csBuff.Left(csBuff.Find('/')); csIdSession = csBuff.Mid(csSession.GetLength()+1); md5SPIP.SetContent(APP.m_csPassword + csSession); memset(lpszBuffer, 0, 16); md5SPIP.GetDigest(lpszBuffer); csHash = md5SPIP.ConvertToAscii(lpszBuffer); APP.m_bAuthWeb = TRUE; TRY { CHttpConnection* phttp = session.GetHttpConnection(_T(RYZOM_HOST)); CHttpFile* pfile = phttp->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/betatest/betatest_login_valid.php"); if(pfile) { CString csHeaders = _T("Content-Type: application/x-www-form-urlencoded"); CString csFormParams = _T("txtLogin="******"&digest="+csHash+"&idsession="+csIdSession); TRY { csBuff.Empty(); pfile->SendRequest(csHeaders, (LPVOID)(LPCTSTR)csFormParams, csFormParams.GetLength()); UINT nRead = pfile->Read(csBuff.GetBuffer(15000), 14999); csBuff.ReleaseBuffer(); csBuff.SetAt(nRead, 0); if(csBuff.Find("/news/") == -1) { APP.m_bAuthWeb = FALSE; } } CATCH_ALL(error) { APP.m_bAuthWeb = FALSE; } END_CATCH_ALL; delete pfile; } else { APP.m_bAuthWeb = FALSE; } } CATCH_ALL(error) { APP.m_bAuthWeb = FALSE; } END_CATCH_ALL; }
bool CHooks::Create() { if (m_pInstance == NULL) m_pInstance = new CHooks(); CRegString reghooks(_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; }
BOOL CPPageVideo::OnInitDialog() { __super::OnInitDialog(); SetHandCursor(m_hWnd, IDC_AUDRND_COMBO); SetHandCursor(m_hWnd, IDC_BUTTON1); AppSettings& s = AfxGetAppSettings(); CRenderersSettings& renderersSettings = s.m_RenderersSettings; m_iDSVideoRendererType = s.iDSVideoRendererType; m_iRMVideoRendererType = s.iRMVideoRendererType; m_iQTVideoRendererType = s.iQTVideoRendererType; m_iAPSurfaceUsage = renderersSettings.iAPSurfaceUsage; m_iDX9Resizer = renderersSettings.iDX9Resizer; m_fVMRMixerMode = renderersSettings.fVMRMixerMode; m_fVMRMixerYUV = renderersSettings.fVMRMixerYUV; m_fVMR9AlterativeVSync = renderersSettings.m_AdvRendSets.fVMR9AlterativeVSync; m_fD3DFullscreen = s.fD3DFullscreen; m_iEvrBuffers.Format(L"%d", renderersSettings.iEvrBuffers); m_fResetDevice = s.m_RenderersSettings.fResetDevice; IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION); if (pD3D) { TCHAR strGUID[50] = {0}; CString cstrGUID; CString d3ddevice_str; CStringArray adapterList; D3DADAPTER_IDENTIFIER9 adapterIdentifier; for (UINT adp = 0; adp < pD3D->GetAdapterCount(); ++adp) { if (SUCCEEDED(pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier))) { d3ddevice_str = adapterIdentifier.Description; d3ddevice_str += _T(" - "); d3ddevice_str += adapterIdentifier.DeviceName; cstrGUID.Empty(); if (::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) { cstrGUID = strGUID; } if (cstrGUID.GetLength() > 0) { boolean m_find = false; for (INT_PTR i = 0; (!m_find) && (i < m_D3D9GUIDNames.GetCount()); i++) { if (m_D3D9GUIDNames.GetAt(i) == cstrGUID) { m_find = true; } } if (!m_find) { m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str); m_D3D9GUIDNames.Add(cstrGUID); if (renderersSettings.D3D9RenderDevice == cstrGUID) { m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount() - 1; } } } } } pD3D->Release(); } CorrectComboListWidth(m_iD3D9RenderDeviceCtrl); auto addRenderer = [&](int nID) { CString sName; switch (nID) { case VIDRNDT_DS_DEFAULT: sName = ResStr(IDS_PPAGE_OUTPUT_SYS_DEF); break; case VIDRNDT_DS_OVERLAYMIXER: if (!IsWinXP()) { return; } sName = ResStr(IDS_PPAGE_OUTPUT_OVERLAYMIXER); break; case VIDRNDT_DS_VMR7WINDOWED: sName = ResStr(IDS_PPAGE_OUTPUT_VMR7WINDOWED); break; case VIDRNDT_DS_VMR9WINDOWED: sName = ResStr(IDS_PPAGE_OUTPUT_VMR9WINDOWED); break; case VIDRNDT_DS_VMR7RENDERLESS: sName = ResStr(IDS_PPAGE_OUTPUT_VMR7RENDERLESS); break; case VIDRNDT_DS_VMR9RENDERLESS: sName = ResStr(IDS_PPAGE_OUTPUT_VMR9RENDERLESS); break; case VIDRNDT_DS_DXR: sName = ResStr(IDS_PPAGE_OUTPUT_DXR); break; case VIDRNDT_DS_NULL_COMP: sName = ResStr(IDS_PPAGE_OUTPUT_NULL_COMP); break; case VIDRNDT_DS_NULL_UNCOMP: sName = ResStr(IDS_PPAGE_OUTPUT_NULL_UNCOMP); break; case VIDRNDT_DS_EVR: sName = ResStr(IDS_PPAGE_OUTPUT_EVR); break; case VIDRNDT_DS_EVR_CUSTOM: sName = ResStr(IDS_PPAGE_OUTPUT_EVR_CUSTOM); break; case VIDRNDT_DS_MADVR: sName = ResStr(IDS_PPAGE_OUTPUT_MADVR); break; case VIDRNDT_DS_SYNC: sName = ResStr(IDS_PPAGE_OUTPUT_SYNC); break; default: ASSERT(FALSE); return; } if (!IsRenderTypeAvailable(nID)) { sName.AppendFormat(L" %s", ResStr(IDS_PPAGE_OUTPUT_UNAVAILABLE)); } m_iDSVideoRendererTypeCtrl.SetItemData(m_iDSVideoRendererTypeCtrl.AddString(sName), nID); }; CComboBox& m_iDSVRTC = m_iDSVideoRendererTypeCtrl; m_iDSVRTC.SetRedraw(FALSE); addRenderer(VIDRNDT_DS_DEFAULT); addRenderer(VIDRNDT_DS_OVERLAYMIXER); addRenderer(VIDRNDT_DS_VMR7WINDOWED); addRenderer(VIDRNDT_DS_VMR9WINDOWED); addRenderer(VIDRNDT_DS_VMR7RENDERLESS); addRenderer(VIDRNDT_DS_VMR9RENDERLESS); addRenderer(VIDRNDT_DS_EVR); addRenderer(VIDRNDT_DS_EVR_CUSTOM); addRenderer(VIDRNDT_DS_SYNC); addRenderer(VIDRNDT_DS_DXR); addRenderer(VIDRNDT_DS_MADVR); addRenderer(VIDRNDT_DS_NULL_COMP); addRenderer(VIDRNDT_DS_NULL_UNCOMP); for (int i = 0; i < m_iDSVRTC.GetCount(); ++i) { if (m_iDSVideoRendererType == m_iDSVRTC.GetItemData(i)) { if (IsRenderTypeAvailable(m_iDSVideoRendererType)) { m_iDSVRTC.SetCurSel(i); m_iDSVideoRendererType_store = m_iDSVideoRendererType; } else { m_iDSVRTC.SetCurSel(0); } break; } } m_iDSVRTC.SetRedraw(TRUE); m_iDSVRTC.Invalidate(); m_iDSVRTC.UpdateWindow(); CComboBox& m_iQTVRTC = m_iQTVideoRendererTypeCtrl; m_iQTVRTC.SetItemData(m_iQTVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_SYS_DEF)), VIDRNDT_QT_DEFAULT); m_iQTVRTC.SetItemData(m_iQTVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR7RENDERLESS)), VIDRNDT_QT_DX7); m_iQTVRTC.SetItemData(m_iQTVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR9RENDERLESS)), VIDRNDT_QT_DX9); m_iQTVRTC.SetCurSel(m_iQTVideoRendererType); CorrectComboListWidth(m_iQTVRTC); CComboBox& m_iRMVRTC = m_iRMVideoRendererTypeCtrl; m_iRMVideoRendererTypeCtrl.SetItemData(m_iRMVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_SYS_DEF)), VIDRNDT_RM_DEFAULT); m_iRMVRTC.SetItemData(m_iRMVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR7RENDERLESS)), VIDRNDT_RM_DX7); m_iRMVRTC.SetItemData(m_iRMVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR9RENDERLESS)), VIDRNDT_RM_DX9); m_iRMVRTC.SetCurSel(m_iRMVideoRendererType); CorrectComboListWidth(m_iRMVRTC); UpdateData(FALSE); CreateToolTip(); m_wndToolTip.AddTool(GetDlgItem(IDC_VIDRND_COMBO), L""); m_wndToolTip.AddTool(GetDlgItem(IDC_RMRND_COMBO), L""); m_wndToolTip.AddTool(GetDlgItem(IDC_QTRND_COMBO), L""); m_wndToolTip.AddTool(GetDlgItem(IDC_DX_SURFACE), L""); OnDSRendererChange(); OnRMRendererChange(); OnQTRendererChange(); OnSurfaceChange(); CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED); GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE); switch (m_iDSVideoRendererType) { case VIDRNDT_DS_VMR9RENDERLESS: case VIDRNDT_DS_EVR_CUSTOM: if (m_iD3D9RenderDeviceCtrl.GetCount() > 1) { GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE); CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED); if (m_iD3D9RenderDevice != -1) { CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE); } } break; default: GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE); } UpdateData(TRUE); return TRUE; // return TRUE unless you set the focus to a control }
bool CUrlSrcGetFromSvrSocket::ProcessHttpResponseBody_Start(const BYTE* pucData, UINT size) { if (thePrefs.GetVerbose()) { AddDebugLogLine(false, _T("Receive UrlSources from server (http response body)")); AddDebugLogLine(false, CString((const char*) pucData, size)); } if (::IsBadReadPtr(m_pMgr, sizeof(CUrlSrcFromSvrMgr))) return true; CStringA straLine; CString strUrl; CString strRefer; LPCSTR p; LPCSTR pcNl; int iRemain; int iLineLen; int iIndexT; int iSepLen; //分隔符长度 p = (LPCSTR) pucData; pcNl = NULL; iRemain = size; while (iRemain > 0) { pcNl = (LPCSTR) memchr(p, '\n', iRemain); if (NULL == pcNl) { iSepLen = 0; iLineLen = iRemain; } else { iSepLen = 1; if (pcNl > p // 确保 (pcNl - 1) 可读 && *(pcNl - 1) == '\r') //如果分隔符是“\r\n”,则分隔符长度为 2。 iSepLen = 2; iLineLen = pcNl + 1 - p; } if (iLineLen <= 0) break; // 取出一行数据 int iCopyStrLen = iLineLen - iSepLen; char *pCopy = new char[iCopyStrLen + 1]; strncpy(pCopy, p, iCopyStrLen); pCopy[iCopyStrLen] = 0; straLine = pCopy; delete[] pCopy; pCopy = NULL; // 把指针移动到下一行 p += iLineLen; iRemain -= iLineLen; // 把一行数据解析出来,并添加到列表中。 iIndexT = straLine.Find('\t'); if (-1 == iIndexT) { strUrl = straLine; strRefer.Empty(); } else { strUrl = straLine.Left(iIndexT); strRefer = straLine.Mid(iIndexT + 1); } CStringW strUrlW; strUrlW = strUrl; if (S_OK == ::IsValidURL(NULL, strUrlW, 0)) m_pMgr->m_strlstFetchedUrlSources.AddTail(CString(straLine)); //把整行数据添加至列表,以保存Refer信息。 } if (NULL != m_pMgr->m_pAssocPartFile) m_pMgr->m_pAssocPartFile->OnUrlSrcFromSvrFetched(&m_pMgr->m_strlstFetchedUrlSources); return true; }
void CDlgLianHaoLanQiu::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); CDialog::OnShowWindow(bShow, nStatus); if(!m_IsInitData) { m_ListCtrl.DeleteAllItems(); m_ListCtrl.InsertItem(0,""); vector<sShuangSeQiu>* DataList=CDataManageCenter::GetInstance()->GetDataList(); int Sum[6]; memset(Sum,0,sizeof(int)*6); for(int Index = 1; Index < (int)DataList->size()+1; Index++) { m_ListCtrl.InsertItem(Index,""); if(Index == DataList->size()) { m_ListCtrl.SetItemText(Index,0,"预测"); } else { CString Str; Str.Format("%s ",(*DataList)[Index].m_QiShu); for(int i =0; i < 6; i++) { CString Temp; Temp.Format("%02d ",(*DataList)[Index].m_HongQiu[i]); Str+=Temp; } CString TempLan; TempLan.Format("+%02d",(*DataList)[Index].m_LanQiu); Str+=TempLan; m_ListCtrl.SetItemText(Index,0,Str); } CString JunZhi; for(int i = 0; i < 6; i++) { Sum[i]+=(*DataList)[Index-1].m_HongQiu[i]; CString Temp; Temp.Format("%02d ",Sum[i]/Index); JunZhi+=Temp; } m_ListCtrl.SetItemText(Index,1,JunZhi); CString ShaHongList; int TempData = (*DataList)[Index-1].m_HongQiu[5]-(*DataList)[Index-1].m_HongQiu[0]; CString ShaHong; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[2]-(*DataList)[Index-1].m_HongQiu[1]; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[5]-(*DataList)[Index-1].m_HongQiu[1]; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[0]*4-2; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = ((*DataList)[Index-1].m_HongQiu[0]+(*DataList)[Index-1].m_LanQiu)*3; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_LanQiu; if(TempData /2 == 0) TempData=TempData*2+2; else TempData=TempData*5+2; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[0]+9; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[1]+5; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[2]+4; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[2]+7; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[5]+4; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[4]-(*DataList)[Index-1].m_HongQiu[3]+(*DataList)[Index-1].m_LanQiu+1; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_LanQiu+(*DataList)[Index-1].m_HongQiu[0]; if(Index >= 2) { if((*DataList)[Index-1].m_LanQiu == ((*DataList)[Index-2].m_LanQiu)) TempData-=1; } if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = abs((*DataList)[Index-1].m_LanQiu-(*DataList)[Index-1].m_HongQiu[5]); if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = abs((*DataList)[Index-1].m_LanQiu*(*DataList)[Index-1].m_HongQiu[0]); if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_LanQiu+7; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_LanQiu+9; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_LanQiu*5+2; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = (*DataList)[Index-1].m_HongQiu[2]+(*DataList)[Index-1].m_HongQiu[5]/33 + 14; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); TempData = ((*DataList)[Index-1].m_HongQiu[0]+(*DataList)[Index-1].m_HongQiu[2]+(*DataList)[Index-1].m_HongQiu[4])/2; if(TempData > 33) TempData = TempData%33; if(Index < DataList->size() && CDataManageCenter::IsHongQiuInData((*DataList)[Index],TempData)) ShaHong.Format("%02dF ",TempData); else ShaHong.Format("%02dS ",TempData); ShaHongList += ShaHong; ShaHong.Empty(); m_ListCtrl.SetItemText(Index,2,ShaHongList); } } }
LRESULT CDetailDlg::OnPopupAddMoreFiles(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { // Display "Open File" dialog. CFileDialog dlg(TRUE, _T("*.*"), NULL, OFN_PATHMUSTEXIST|OFN_ALLOWMULTISELECT, _T("All Files (*.*)\0*.*\0\0"), m_hWnd); INT_PTR result = dlg.DoModal(); if(result==IDOK) { // Parse the list of files TCHAR* str = dlg.m_ofn.lpstrFile; std::vector<CString> asItems; CString sItem; int i; for(i=0; ; i++) { if(str[i]==0) { // End of item if(sItem.IsEmpty()) break; // End of multi-string asItems.push_back(sItem); sItem.Empty(); continue; } sItem += str[i]; } std::vector<ERIFileItem> aFiles; if(asItems.size()==1) { // Single file to add CString sFileName = asItems[0]; ERIFileItem fi; fi.m_bAllowDelete = true; fi.m_bMakeCopy = true; fi.m_sDestFile = Utility::GetFileName(sFileName); fi.m_sSrcFile = sFileName; aFiles.push_back(fi); } else if(asItems.size()>1) { // Several files to add unsigned j; for(j=1; j<asItems.size(); j++) { CString sFileName = asItems[0]+_T("\\")+asItems[j]; ERIFileItem fi; fi.m_bAllowDelete = true; fi.m_bMakeCopy = true; fi.m_sDestFile = Utility::GetFileName(sFileName); fi.m_sSrcFile = sFileName; aFiles.push_back(fi); } } // Add files to crash report CErrorReportSender* pSender = CErrorReportSender::GetInstance(); CCrashInfoReader* pCrashInfo = pSender->GetCrashInfo(); pCrashInfo->AddFilesToCrashReport(m_nCurReport, aFiles); // Update file items list FillFileItemList(); // Force parent to recalculate report size HWND hWndParent = GetParent(); if(::IsWindow(hWndParent)) ::SendMessage(hWndParent, WM_REPORTSIZECHANGED, m_nCurReport, 0); } return 0; }
BOOL CDlgAddTask::ApplyDocToTaskMgr(LPCTSTR lpszLocation, BOOL & bFeedAdded, BOOL bAutoDown) { // MODIFIED by VC-yavey on 2010-04-16 <begin> // 处理RSS订阅url bFeedAdded = FALSE; //CAddTaskDoc::RssUrlSet & setRssUrl = m_doc.GetRssUrlSet(); CString strCurLoc; m_cmbLocation.GetWindowText(strCurLoc); if ( !PathFileExists(strCurLoc) ) { strCurLoc.Empty(); } /*for ( CAddTaskDoc::RssUrlSet::const_iterator it = setRssUrl.begin(); it != setRssUrl.end(); ++it ) { TRACE(TEXT("\nRssUrlSet str %s\n"), *it); }*/ set<CRssFeed*>& setLastRssFeed = m_editLinks.GetLastRssFeedSet(); for (set<CRssFeed*>::iterator it = setLastRssFeed.begin(); it != setLastRssFeed.end(); ++it ) { //TRACE(TEXT("m_editLinks.m_setLastRssfee str %s\n"), (*it)->m_strFeedUrl); CGlobalVariable::s_wndRssCtrl->AddFeed(*it, strCurLoc, bAutoDown); bFeedAdded = TRUE; } // MODIFIED by VC-yavey on 2010-04-16 <end> // ed2k tasks <begin> const map<CFileHashKey, CAddTaskDoc::SItem> *pMap; map<CFileHashKey, CAddTaskDoc::SItem>::const_iterator it; CArray<SSpDownLink*, SSpDownLink*> arrSpDownLinks; //special download links CArray<SSpDownLink*, SSpDownLink*> arrDowningLinks; //downloading links CArray<SSpDownLink*, SSpDownLink*> arrReDownLinks; //ask whether redownload links CArray<SSpDownLink*, SSpDownLink*> arrTooBigDownLinks; int iState; CString strFileName; pMap = m_doc.GetData(); for (it = pMap->begin(); it != pMap->end(); it++) { if (it->second.bCheck) { CED2KFileLink *pLink = NULL; // MODIFIED by VC-yavey on 2010-04-16 : 安全地创建filelink pLink = CreateFileLinkFromUrl(it->second.strLinkText); if( pLink && pLink->GetSize()> OLD_MAX_EMULE_FILE_SIZE && !thePrefs.CanFSHandleLargeFiles(lpszLocation)) { strFileName = CGlobalVariable::filemgr.GetFileName(it->second.strLinkText); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 0; psdl->strLink = it->second.strLinkText; psdl->iCat = it->second.iCategory; psdl->strName = strFileName; arrTooBigDownLinks.Add(psdl); continue; } SAFE_DELETE(pLink); iState = CGlobalVariable::filemgr.GetFileState(it->second.strLinkText); switch (iState) { case FILESTATE_DOWNLOADING: { strFileName = CGlobalVariable::filemgr.GetFileName(it->second.strLinkText); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 0; psdl->strLink = it->second.strLinkText; psdl->iCat = it->second.iCategory; psdl->iState = iState; psdl->strName = strFileName; arrDowningLinks.Add(psdl); } break; case FILESTATE_COMPLETED: case FILESTATE_HASH: case FILESTATE_DOWNLOADED_SHARE: case FILESTATE_LOCAL_SHARE: case FILESTATE_SHARE_TASK_DELED: { strFileName = CGlobalVariable::filemgr.GetFileName(it->second.strLinkText); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 0; psdl->strLink = it->second.strLinkText; psdl->iCat = it->second.iCategory; psdl->iState = iState; psdl->strName = strFileName; arrSpDownLinks.Add(psdl); } break; case FILESTATE_DELETED: { strFileName = CGlobalVariable::filemgr.GetFileName(it->second.strLinkText); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 0; psdl->strLink = it->second.strLinkText; psdl->iCat = it->second.iCategory; psdl->iState = iState; psdl->strName = strFileName; arrReDownLinks.Add(psdl); } break; default: CGlobalVariable::filemgr.NewDownloadFile(it->second.strLinkText, lpszLocation, it->second.iCategory); break; } } } // ed2k tasks <end> // Url tasks <begin> CString strUrl; BOOL bCheck; const CMapStringToPtr* pUrlData = m_doc.GetUrlData(); POSITION pos = pUrlData->GetStartPosition(); while (NULL != pos) { pUrlData->GetNextAssoc(pos, strUrl, (void*&)bCheck); strUrl.Trim(); if( _tcsrchr((LPCTSTR)strUrl+7,_T('/'))==NULL ) strUrl += _T('/'); /* int len=strUrl.GetLength(); bool state=false; int index = strUrl.Find(_T("//"),0); for(int i = index + 2;i < len;i++) { if(strUrl[i] == _T('/')) { state = true; break; } } if(state ==false) strUrl+='/';*/ if (bCheck) { iState = CGlobalVariable::filemgr.GetUrlTaskState(strUrl); //< 统一转换后再判断,避免实际是重复的Url switch (iState) { case FILESTATE_DOWNLOADING: { strFileName = CGlobalVariable::filemgr.GetUrlFileName(strUrl); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 1; psdl->strLink = strUrl; psdl->iCat = 0; psdl->iState = iState; psdl->strName = strFileName; arrDowningLinks.Add(psdl); } break; case FILESTATE_COMPLETED: case FILESTATE_HASH: case FILESTATE_LOCAL_SHARE: { strFileName = CGlobalVariable::filemgr.GetUrlFileName(strUrl); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 1; psdl->strLink = strUrl; psdl->iCat = 0; psdl->iState = iState; psdl->strName = strFileName; arrSpDownLinks.Add(psdl); } break; case FILESTATE_DOWNLOADED_SHARE: case FILESTATE_SHARE_TASK_DELED: case FILESTATE_DELETED: case FILESTATE_ZEROSIZE_DOWNLOADED: { strFileName = CGlobalVariable::filemgr.GetUrlFileName(strUrl); SSpDownLink* psdl = new SSpDownLink; psdl->iLinkType = 1; psdl->strLink = strUrl; psdl->iCat = 0; psdl->iState = iState; psdl->strName = strFileName; arrReDownLinks.Add(psdl); } break; default: CmdFuncs::ActualllyAddUrlDownload(strUrl,lpszLocation); break; } } } // URL tasks <end> int i; CString strPrompt; if (!arrSpDownLinks.IsEmpty()) { strPrompt = GetResString(IDS_ALREADY_DOWNLOAD); for (i = 0; i < arrSpDownLinks.GetCount(); i++) { if(arrSpDownLinks[i]->iLinkType==1) strPrompt += arrSpDownLinks[i]->strLink; else strPrompt += arrSpDownLinks[i]->strName; strPrompt += _T("\n"); } for (i = 0; i < arrSpDownLinks.GetCount(); i++) delete arrSpDownLinks[i]; arrSpDownLinks.RemoveAll(); } UINT iTooBigDownLinks = 0; if (!arrTooBigDownLinks.IsEmpty()) { iTooBigDownLinks =arrTooBigDownLinks.GetCount(); if (!strPrompt.IsEmpty()) strPrompt += _T("\n\n"); strPrompt = GetResString(IDS_ERR_FSCANTHANDLEFILE); strPrompt += _T("\n"); for (i = 0; i < arrTooBigDownLinks.GetCount(); i++) { if(arrTooBigDownLinks[i]->iLinkType==1) strPrompt += arrTooBigDownLinks[i]->strLink; else strPrompt += arrTooBigDownLinks[i]->strName; strPrompt += _T("\n"); } for (i = 0; i < arrTooBigDownLinks.GetCount(); i++) delete arrTooBigDownLinks[i]; arrTooBigDownLinks.RemoveAll(); } if (!arrDowningLinks.IsEmpty()) { if (!strPrompt.IsEmpty()) strPrompt += _T("\n\n"); strPrompt += GetResString(IDS_TASK_IN_DOWNLOADING); for (i = 0; i < arrDowningLinks.GetCount(); i++) { if(arrDowningLinks[i]->iLinkType==1) strPrompt += arrDowningLinks[i]->strLink; else strPrompt += arrDowningLinks[i]->strName; strPrompt += _T("\n"); } for (i = 0; i < arrDowningLinks.GetCount(); i++) delete arrDowningLinks[i]; arrDowningLinks.RemoveAll(); } if (!strPrompt.IsEmpty()) MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_OK|MB_ICONWARNING); //if (IDYES == ::AfxMessageBox(strPrompt, MB_YESNO)) //{ // for (i = 0; i < arrDledLink.GetCount(); i++) // CGlobalVariable::filemgr.NewDownloadFile(arrDledLink[i], lpszLocation, arrDledLinkCat[i]); // for (i = 0; i < arrDledUrl.GetCount(); i++) // ActualllyAddUrlDownload(arrDledUrl[i], lpszLocation); //} if (!arrReDownLinks.IsEmpty()) { strPrompt = GetResString(IDS_DOWN_DELED_LINKS); for (i = 0; i < arrReDownLinks.GetCount(); i++) { if(arrReDownLinks[i]->iLinkType==1) strPrompt += arrReDownLinks[i]->strLink; else strPrompt += arrReDownLinks[i]->strName; strPrompt += _T("\n"); } if(IDYES == MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_YESNO|MB_ICONWARNING)) { for (i = 0; i < arrReDownLinks.GetCount(); i++) { switch (arrReDownLinks[i]->iLinkType) { case 0: CGlobalVariable::filemgr.NewDownloadFile(arrReDownLinks[i]->strLink, lpszLocation, arrReDownLinks[i]->iCat); break; case 1: //ActualllyAddUrlDownload(arrReDownLinks[i]->strLink, lpszLocation); CmdFuncs::ActualllyAddUrlDownload(arrReDownLinks[i]->strLink,lpszLocation); break; default: break; } } } for (i = 0; i < arrReDownLinks.GetCount(); i++) delete arrReDownLinks[i]; arrReDownLinks.RemoveAll(); } if (!pMap->size() && !iTooBigDownLinks) return TRUE; return iTooBigDownLinks != pMap->size(); }
UINT CLiteHTMLReader::parseDocument(void) { ASSERT(m_lpszBuffer != NULL); bool bAbort = false; // continue parsing or abort? bool bIsClosingTag = false; // tag parsed is a closing tag? bool bIsOpeningTag = false; // tag parsed is an opening tag? CString strCharacters; // character data CString strComment; // comment data CString strT; // temporary storage DWORD dwCharDataStart = 0L; // starting position of character data DWORD dwCharDataLen = 0L; // length of character data LONG lTemp = 0L; // temporary storage TCHAR ch = 0; // character at current buffer position CLiteHTMLTag oTag; // tag information if ( (!m_lpszBuffer) || (!m_dwBufLen) ) return (0U); // reset seek pointer to beginning ResetSeekPointer(); // notify event handler about parsing startup if (getEventNotify(notifyStartStop)) { bAbort = false; m_pEventHandler->BeginParse(m_dwAppData, bAbort); if (bAbort) goto LEndParse; } // skip leading white-space characters while (isWhiteSpace(ReadChar())) ; ch = UngetChar(); while ((ch = ReadChar()) != NULL) { switch (ch) { // tag starting delimeter? case _T('<'): { UngetChar(); strComment.Empty(); if (!parseComment(strComment)) { bIsOpeningTag = false; bIsClosingTag = false; if (!parseTag(oTag, bIsOpeningTag, bIsClosingTag)) { ++dwCharDataLen; // manually advance buffer position // because the last call to UngetChar() // moved it back one character ch = ReadChar(); break; } } // clear pending notifications if ( (dwCharDataLen) || (strCharacters.GetLength()) ) { strCharacters += CString(&m_lpszBuffer[dwCharDataStart], dwCharDataLen); NormalizeCharacters(strCharacters); if ( (strCharacters.GetLength()) && (getEventNotify(notifyCharacters)) ) { bAbort = false; m_pEventHandler->Characters(strCharacters, m_dwAppData, bAbort); if (bAbort) goto LEndParse; } strCharacters.Empty(); } dwCharDataLen = 0L; dwCharDataStart = m_dwBufPos; if (strComment.GetLength()) { if (getEventNotify(notifyComment)) { bAbort = false; m_pEventHandler->Comment(strComment, m_dwAppData, bAbort); if (bAbort) goto LEndParse; } } else { if ( (bIsOpeningTag) && (getEventNotify(notifyTagStart)) ) { bAbort = false; m_pEventHandler->StartTag(&oTag, m_dwAppData, bAbort); if (bAbort) goto LEndParse; } if ( (bIsClosingTag) && (getEventNotify(notifyTagEnd)) ) { bAbort = false; m_pEventHandler->EndTag(&oTag, m_dwAppData, bAbort); if (bAbort) goto LEndParse; } } break; } // entity reference beginning delimeter? case _T('&'): { UngetChar(); lTemp = 0; if (m_bResolveEntities) lTemp = CLiteHTMLEntityResolver::resolveEntity(&m_lpszBuffer[m_dwBufPos], ch); if (lTemp) { strCharacters += CString(&m_lpszBuffer[dwCharDataStart], dwCharDataLen) + ch; m_dwBufPos += lTemp; dwCharDataStart = m_dwBufPos; dwCharDataLen = 0L; } else { ch = ReadChar(); ++dwCharDataLen; } break; } // any other character default: { ++dwCharDataLen; break; } } } // clear pending notifications if ( (dwCharDataLen) || (strCharacters.GetLength()) ) { strCharacters += CString(&m_lpszBuffer[dwCharDataStart], dwCharDataLen) + ch; NormalizeCharacters(strCharacters); strCharacters.TrimRight(); // explicit trailing white-space removal if ( (strCharacters.GetLength()) && (getEventNotify(notifyCharacters)) ) { bAbort = false; m_pEventHandler->Characters(strCharacters, m_dwAppData, bAbort); if (bAbort) goto LEndParse; } } LEndParse: // notify event handler about parsing completion if (getEventNotify(notifyStartStop)) m_pEventHandler->EndParse(m_dwAppData, bAbort); m_lpszBuffer = NULL; m_dwBufLen = 0L; return (m_dwBufPos); }
bool DropCopyAddCommand::Execute() { bool bRet = false; CString droppath = parser.GetVal(_T("droptarget")); if (CTGitPath(droppath).IsAdminDir()) return FALSE; if(!CTGitPath(droppath).HasAdminDir(&g_Git.m_CurrentDir)) return FALSE; int worktreePathLen = g_Git.m_CurrentDir.GetLength(); orgPathList.RemoveAdminPaths(); CTGitPathList copiedFiles; for(int nPath = 0; nPath < orgPathList.GetCount(); ++nPath) { if (orgPathList[nPath].IsEquivalentTo(CTGitPath(droppath))) continue; //copy the file to the new location CString name = orgPathList[nPath].GetFileOrDirectoryName(); if (::PathFileExists(droppath + _T("\\") + name)) { if (::PathIsDirectory(droppath + _T("\\") + name)) { if (orgPathList[nPath].IsDirectory()) continue; } CString strMessage; strMessage.Format(IDS_PROC_OVERWRITE_CONFIRM, (LPCTSTR)(droppath + _T("\\") + name)); CString sBtn1(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_OVERWRITE)); CString sBtn2(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_KEEP)); CString sBtn3(MAKEINTRESOURCE(IDS_PROC_OVERWRITEEXPORT_CANCEL)); UINT ret = CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), 2, IDI_QUESTION, sBtn1, sBtn2, sBtn3); if (ret == 3) return FALSE; //cancel the whole operation if (ret == 1) { if (!::CopyFile(orgPathList[nPath].GetWinPath(), droppath + _T("\\") + name, FALSE)) { //the copy operation failed! Get out of here! ShowErrorMessage(); return FALSE; } } } else { if (orgPathList[nPath].IsDirectory()) { CString fromPath = orgPathList[nPath].GetWinPathString() + L"||"; CString toPath = droppath + L"\\" + name + L"||"; std::unique_ptr<TCHAR[]> fromBuf(new TCHAR[fromPath.GetLength() + 2]); std::unique_ptr<TCHAR[]> toBuf(new TCHAR[toPath.GetLength() + 2]); wcscpy_s(fromBuf.get(), fromPath.GetLength() + 2, fromPath); wcscpy_s(toBuf.get(), toPath.GetLength() + 2, toPath); CStringUtils::PipesToNulls(fromBuf.get(), fromPath.GetLength() + 2); CStringUtils::PipesToNulls(toBuf.get(), toPath.GetLength() + 2); SHFILEOPSTRUCT fileop = {0}; fileop.wFunc = FO_COPY; fileop.pFrom = fromBuf.get(); fileop.pTo = toBuf.get(); fileop.fFlags = FOF_NO_CONNECTED_ELEMENTS | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS | FOF_SILENT; if (!SHFileOperation(&fileop)) { // add all copied files WITH special handling for repos/submodules (folders which include a .git entry) CDirFileEnum finder(droppath + L"\\" + name); bool isDir = true; CString filepath; CString lastRepo; bool isRepo = false; while (finder.NextFile(filepath, &isDir, !isRepo)) // don't recurse into .git directories { if (!lastRepo.IsEmpty()) { if (filepath.Find(lastRepo) == 0) continue; else lastRepo.Empty(); } int pos = -1; if ((pos = filepath.Find(L"\\" + GitAdminDir::GetAdminDirName())) >= 0) isRepo = (pos == filepath.GetLength() - GitAdminDir::GetAdminDirName().GetLength() - 1); else isRepo = false; if (isRepo) { lastRepo = filepath.Mid(0, filepath.GetLength() - GitAdminDir::GetAdminDirName().GetLength()); CString msg; if (!isDir) msg.Format(IDS_PROC_COPY_SUBMODULE, lastRepo); else msg.Format(IDS_PROC_COPY_REPOSITORY, lastRepo); int ret = CMessageBox::Show(hwndExplorer, msg, _T("TortoiseGit"), 1, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_IGNOREBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))); if (ret == 3) return FALSE; if (ret == 1) { CTGitPath(filepath).Delete(false, true); lastRepo.Empty(); } continue; } if (!isDir) copiedFiles.AddPath(CTGitPath(filepath.Mid(worktreePathLen + 1))); //add the new filepath } } continue; // do not add a directory to copiedFiles } else if (!CopyFile(orgPathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE)) { //the copy operation failed! Get out of here! ShowErrorMessage(); return FALSE; } } CString destPath(droppath + _T("\\") + name); copiedFiles.AddPath(CTGitPath(destPath.Mid(worktreePathLen + 1))); //add the new filepath } //now add all the newly copied files to the working copy CGitProgressDlg progDlg; theApp.m_pMainWnd = &progDlg; AddProgressCommand addCommand; progDlg.SetCommand(&addCommand); addCommand.SetPathList(copiedFiles); progDlg.DoModal(); bRet = !progDlg.DidErrorsOccur(); return bRet; }