void CCmd_Password::OnPrompt( const StrPtr &msg, StrBuf &rsp, int noEcho, Error *e ) { CString message = CharToCString(msg.Text()); CString *csp; csp = (message.Find(_T("old")) != -1) ? &m_OldPwd : &m_NewPwd; rsp.Set(CharFromCString(*csp)); }
void CForceSyncDlg::OnDeleteSelected() { CString filename; POSITION pos; POSITION oldPos; for(int i=m_List.GetCount()-1; i>=0; i--) { if(m_List.GetSel(i)) { m_List.GetText(i, filename); if (filename.FindOneOf(_T("@#%")) != -1) { StrBuf b; StrBuf f; f << CharFromCString(filename); StrPtr *p = &f; StrOps::WildToStr(*p, b); filename = CharToCString(b.Value()); } for(pos = m_lpCstrListC->GetHeadPosition(); pos != NULL; ) { oldPos = pos; if (filename == m_lpCstrListC->GetNext(pos)) { m_lpCstrListC->RemoveAt(oldPos); m_List.DeleteString(i); continue; } } for(pos = m_lpCstrListD->GetHeadPosition(); pos != NULL; ) { oldPos = pos; if (filename == m_lpCstrListD->GetNext(pos)) { m_lpCstrListD->RemoveAt(oldPos); m_List.DeleteString(i); break; } } } } m_Delete.EnableWindow(FALSE); }
int CJsonData::ReadClassfiyJson(string s_path,myListClassify &m_list) { Json::Reader reader; Json::Value root; std::ifstream is; is.open(s_path, std::ios::binary); int ss=reader.parse(is,root); if (ss) { int dataList_size = root["data"].size(); if (dataList_size == 0) { LOGA("json data is null ,请查看class.json 是否正确 "); return -1; } for(int i = 0; i < dataList_size; ++i) { CLASSIFY m_classify; m_classify.strname = CharToCString(root["data"][i]["name"].asCString()); m_classify.classifyid = root["data"][i]["id"].asInt(); /* 2级 留空 Json::Value val_info = root["dataList"][i]["info"]; int info_size = val_info.size(); for(int j = 0; j < info_size; ++j) { val_info[j]["type_id"].asInt(); CharToCString(val_info[j]["type_name"].asCString()); } */ m_list.push_back(m_classify); } } else { LOGA("json 解析错误 ss 为0 ") return -1; } return 0; }
// Create from an fstat result set. BOOL CP4FileStats::Create(StrDict *client) { int i; StrPtr *str; Error err; // Get the depot name str= client->GetVar( "depotFile", &err); // name in depot ASSERT(str || err.Test()); if(err.Test()) goto badFile; m_DepotPath = CharToCString(str->Value()); // If the client path exists, note that file is in client view str= client->GetVar( "clientFile" ); if(str) { m_ClientPath = CharToCString(str->Value()); m_ClientPath.Replace(_T('/'), _T('\\')); } else { // need to determine if the client path doesn't exist or doesn't translate // we can't handle the no translation case. CString txt = FormatError(&err); if(txt.Find(_T("No Translation")) == 0) goto badFile; // there is no client path m_ClientPath=_T(""); } // Concatenate a list of all other users with the file open { char varName[] = "otherOpen "; char varNam2[] = "otherAction "; for(m_OtherOpens=m_OtherOpenAction=0; m_OtherOpens < 100; m_OtherOpens++) { _itoa(m_OtherOpens, varName+9, 10); if( (str=client->GetVar( varName )) == 0 ) break; else { if(m_OtherOpens==0) m_OtherUsers = CharToCString(str->Value()); else { m_OtherUsers+=_T("/"); m_OtherUsers+=CharToCString(str->Value()); } if (m_OtherOpenAction != F_DELETE) { _itoa(m_OtherOpens, varNam2+11, 10); if ( (str=client->GetVar( varNam2 )) != 0) { m_OtherOpenAction = actionByName(CharToCString(str->Value())); } } } } } if( (str= client->GetVar( "headRev" )) != NULL) m_HeadRev=atol(str->Value()); if( (str= client->GetVar( "haveRev" )) != NULL) m_HaveRev=atol(str->Value()); if( (str= client->GetVar( "change" )) != NULL) m_OpenChangeNum=atol(str->Value()); if( (str= client->GetVar( "headChange" )) != NULL) m_HeadChangeNum=atol(str->Value()); if( (str= client->GetVar( "headTime" )) != NULL) m_HeadTime=atol(str->Value()); if( (str= client->GetVar( "ourLock" )) != NULL) m_MyLock=TRUE; if( (str= client->GetVar( "otherLock" )) != NULL) m_OtherLock=TRUE; if( (str= client->GetVar( "type" )) != NULL) m_Type= CharToCString(str->Value()); if( (str= client->GetVar( "headType" )) != NULL) m_HeadType= CharToCString(str->Value()); if( (str= client->GetVar( "headAction" )) != NULL) { m_HeadAction = actionByName(CharToCString(str->Value())); } ASSERT(client->GetVar("headAction")==NULL || m_HeadAction); if( (str= client->GetVar( "action" )) != NULL) { m_MyOpenAction = actionByName(CharToCString(str->Value())); } ASSERT(client->GetVar("action")==NULL || m_MyOpenAction); if (!m_HaveRev && !m_HeadRev && (m_MyOpenAction == F_ADD || m_MyOpenAction == F_BRANCH)) m_HaveRev = 1; if( (str= client->GetVar( "unresolved" )) != NULL) m_Unresolved=TRUE; str= client->GetVar( "actionOwner" ); if(str) { m_ActionOwner = CharToCString(str->Value()); if (Compare( m_ActionOwner, GET_P4REGPTR()->GetP4User() ) !=0) { m_OtherUserMyClient = TRUE; m_OtherUsers = m_ActionOwner + _T('@') + GET_P4REGPTR()->GetP4Client(); } } str= client->GetVar( "digest" ); if(str) m_Digest = CharToCString(str->Value()); if( (str= client->GetVar( "fileSize" )) != NULL) m_FileSize=atol(str->Value()); // In release builds, these values may be zero for an unrecognized // file type or action, which maps to F_UNKNOWNFILETYPE or F_UNKNOWNACTION // ASSERT(client->GetVar("headType")== NULL || m_HeadType); // commented out as useless and irritating in debug version - leighb 99/11/30 ASSERT(client->GetVar("headAction")==NULL || m_HeadAction); ASSERT(client->GetVar("action")==NULL || m_MyOpenAction); return TRUE; badFile: // most likely a translation failure. Nothing to do but ignore this file. return FALSE; }
BOOL CForceSyncDlg::OnInitDialog() { CDialog::OnInitDialog(); GetWindowRect(&m_InitRect); m_LastRect = m_InitRect; CString filename; CString filenmok; POSITION pos; BOOL bWeird = FALSE; CStringList strlist; for(pos = m_lpCstrListC->GetHeadPosition(); pos != NULL; ) { filename = m_lpCstrListC->GetNext(pos); if (filename.FindOneOf(_T("@#%")) != -1) { StrBuf b; StrBuf f; f << CharFromCString(filename); StrPtr *p = &f; StrOps::WildToStr(*p, b); filenmok = CharToCString(b.Value()); bWeird = TRUE; } m_List.AddString(filename); strlist.AddTail(filenmok); } if (bWeird) { m_lpCstrListC->RemoveAll(); for(pos = strlist.GetHeadPosition(); pos != NULL; ) m_lpCstrListC->AddTail(strlist.GetNext(pos)); } bWeird = FALSE; strlist.RemoveAll(); for(pos = m_lpCstrListD->GetHeadPosition(); pos != NULL; ) { filename = m_lpCstrListD->GetNext(pos); if (filename.FindOneOf(_T("@#%")) != -1) { StrBuf b; StrBuf f; f << CharFromCString(filename); StrPtr *p = &f; StrOps::WildToStr(*p, b); filenmok = CharToCString(b.Value()); bWeird = TRUE; } m_List.AddString(filename); strlist.AddTail(filenmok); } if (bWeird) { m_lpCstrListD->RemoveAll(); for(pos = strlist.GetHeadPosition(); pos != NULL; ) m_lpCstrListD->AddTail(strlist.GetNext(pos)); } ///////////////////////////// // Fill in the change list, if present, and select the suggested // change number if(!m_pChangeList.IsEmpty()) { ASSERT(m_pChangeList.GetCount() > 0); for(pos=m_pChangeList.GetHeadPosition(); pos != NULL; ) { m_ChangeCombo.AddString(m_pChangeList.GetNext(pos)); } } int index; ASSERT(!m_SelChange.IsEmpty()); if( (index=m_ChangeCombo.FindStringExact(-1, m_SelChange))==CB_ERR) { ASSERT(0); //Why wasnt default value in list? index=0; } m_ChangeCombo.SetCurSel(index); m_Delete.ShowWindow(SW_SHOWNOACTIVATE); m_Delete.EnableWindow(FALSE); m_OK.EnableWindow(FALSE); m_ChangeCombo.EnableWindow(FALSE); hWndThis = m_hWnd; RECT rect; m_List.GetWindowRect(&rect); adjX = rect.left; adjY = rect.top; adjX -= m_InitRect.left; adjY -= m_InitRect.top; m_List.SetRightClkCallback((PTRFUNC)OnRightClickList); // Restore window position m_InitDialogDone = TRUE; m_WinPos.RestoreWindowPosition(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CForceSyncDlg::OnDiffFile(BOOL bHave) { CString filename; m_StringList.RemoveAll(); for(int i=m_List.GetCount()-1; i>=0; i--) { if(!m_List.GetSel(i)) continue; m_List.GetText(i, filename); if (filename.FindOneOf(_T("@#%")) != -1) { StrBuf b; StrBuf f; f << CharFromCString(filename); StrPtr *p = &f; StrOps::WildToStr(*p, b); filename = CharToCString(b.Value()); } BOOL b = TRUE; for(POSITION pos = m_lpCstrListD->GetHeadPosition(); pos != NULL; ) { if (filename == m_lpCstrListD->GetNext(pos)) { CString txt; txt.FormatMessage(IDS_s_IS_MISSING, filename); AddToStatus(txt, SV_MSG); b = FALSE; break; } } if (b) m_StringList.AddTail(filename); } if (!m_StringList.GetCount()) { if (m_List.GetSelCount() > 1) AddToStatus(LoadStringResource(IDS_ALLSELFILESAREMISSING_NODIFFRUN), SV_COMPLETION); return; } if (bHave) { int cnt = m_StringList.GetCount(); CCmd_Fstat *pCmd2= new CCmd_Fstat; pCmd2->Init(NULL, RUN_SYNC); if( pCmd2->Run( FALSE, &m_StringList, TRUE, 0 ) && !pCmd2->GetError() ) { m_StringList.RemoveAll(); CObList *coblist2 = pCmd2->GetFileList( ); ASSERT_KINDOF( CObList, coblist2 ); ASSERT( coblist2->GetCount() == cnt ); for (POSITION pos = coblist2->GetHeadPosition( ); pos != NULL; ) { CP4FileStats *stats = ( CP4FileStats * )coblist2->GetNext( pos ); ASSERT_KINDOF( CP4FileStats, stats ); long headRev = stats->GetHeadRev(); long haveRev = stats->GetHaveRev(); CString filename = stats->GetFullDepotPath(); if (headRev != haveRev) { CString revnbr; revnbr.Format(_T("#%ld"), haveRev); filename += revnbr; } m_StringList.AddTail(filename); delete stats; } } delete pCmd2; } CCmd_Diff *pCmd= new CCmd_Diff; pCmd->Init( m_hWnd, RUN_ASYNC); if( pCmd->Run( &m_StringList, _T("-f") ) ) MainFrame()->UpdateStatus( LoadStringResource(IDS_DIFFING_FILE) ); else delete pCmd; }