BOOL CClientListCtrl::ClientSpecSwitch(CString switchTo, BOOL bAlways /*=FALSE*/, BOOL portWasChanged /*= FALSE*/) { CCmd_Describe *pCmd = new CCmd_Describe; pCmd->Init( NULL, RUN_SYNC ); BOOL cmdStarted= pCmd->Run( P4CLIENT_SPEC, switchTo ); if(cmdStarted && !pCmd->GetError()) { CString options= TheApp()->GetClientSpecField( _T("Options"), pCmd->GetDescription() ); if (( options.Find(_T("unlocked")) == -1 ) && ( options.Find(_T("locked")) != -1 )) { CString lockedby= TheApp()->GetClientSpecField( _T("Owner"), pCmd->GetDescription() ); if ( lockedby.Compare( GET_P4REGPTR()->GetP4User() ) != 0 ) { CString errmsg; errmsg.FormatMessage(IDS_CLIENT_s_IS_LOCKED_BY_USER_s_AND_CANT_BE_USED_BY_s, switchTo, lockedby, GET_P4REGPTR()->GetP4User()); AddToStatus( errmsg, SV_WARNING ); AfxMessageBox( errmsg, MB_ICONEXCLAMATION ); delete pCmd; return FALSE; } } } delete pCmd; m_Active = switchTo; if ( SetP4Client( bAlways ) ) MainFrame()->OnPerforceOptions( FALSE, portWasChanged ) ; return TRUE; }
static BOOL IsLFonly(LPCTSTR desc) { CString lineend= TheApp()->GetClientSpecField( _T("LineEnd"), desc ); if (!lineend.IsEmpty()) return lineend == _T("unix"); CString options= TheApp()->GetClientSpecField( _T("Options"), desc ); return ( options.Find(_T("nocrlf")) != -1 ) ? TRUE : FALSE; }
BOOL WINAPI SkylarkApp::CtrlCHandlerRoutine(__in DWORD dwCtrlType) { LOG("Ctrl+C handler"); TheApp().quit = true; Cout() << "Ctrl + C\n"; TcpSocket h; h.Connect("127.0.0.1", TheApp().port); h.Put("quit"); return TRUE; }
void SkylarkApp::Signal(int signal) { #ifdef PLATFORM_POSIX switch(signal) { case SIGTERM: case SIGHUP: quit = true; Broadcast(signal); break; case SIGINT: Broadcast(signal); exit(0); break; case SIGUSR1: Broadcast(signal); SigUsr1(); break; case SIGALRM: if(getpid() != TheApp().main_pid) { // "Timeout - session stoped" exit(0); } break; } #endif }
BOOL CCmd_Fstat::HandledCmdSpecificError(LPCTSTR errBuf, LPCTSTR errMsg) { if ((StrStr(errBuf, _T(" - file(s) not in client view"))) || (StrStr(errBuf, _T(" - protected namespace - access denied"))) || (m_bWorking && StrStr(errBuf, _T(" - file(s) not opened on this client")))) { return TRUE; } else if ((GET_P4REGPTR( )->ShowEntireDepot( ) > SDF_DEPOT) && (StrStr(errBuf, _T(" - no mappings in client view")))) { m_ErrorList.AddHead(errBuf); return TRUE; } else if ( StrStr(errBuf, _T("no such file") ) ) { TheApp()->StatusAdd( LoadStringResource(IDS_NO_FILES_UNDER_FOLDER), SV_DEBUG ); return TRUE ; } else if ( StrStr(errBuf, _T(" database access failed.") ) ) { m_FatalError = TRUE; return FALSE; } return StrStr(errBuf, _T("up-to-date.") ) != 0; }
void CCmd_Password::OnOutputInfo(char level, LPCTSTR data, LPCTSTR msg) { if(StrStr(data, _T("Password updated"))) TheApp()->StatusAdd( msg, SV_COMPLETION ); else { m_ErrorTxt = StrCmp(data, _T("Password not changed.")) ? msg : data; CP4Command::OnOutputInfo(level, data, msg); } }
void CTempDirPage::OnBrowseDir() { UpdateData(); CString newfolder = TheApp()->BrowseForFolder(m_hWnd, m_TempPath, LoadStringResource(IDS_CHOOSE_TEMP_DIR), BIF_NEWDIALOGSTYLE); if (!newfolder.IsEmpty()) { m_TempPath = newfolder; UpdateData(FALSE); } }
BOOL CCmd_Password::HandledCmdSpecificError(LPCTSTR errBuf, LPCTSTR errMsg) { BOOL handledError= FALSE; if(StrStr(errBuf, _T("Password invalid")) || StrStr(errBuf, _T("Password should be "))) { m_ErrorTxt= errMsg; TheApp()->StatusAdd( errMsg, SV_WARNING ); handledError= TRUE; } return handledError; }
LRESULT CClientListCtrl::OnP4Sync(WPARAM wParam, LPARAM lParam) { CCmd_Get *pCmd= (CCmd_Get *) wParam; if (TheApp()->m_RunClientWizOnly) { if (pCmd->GetWarningsCount() == 0) { pCmd->ReleaseServerLock(); ::PostMessage(MainFrame()->m_hWnd, WM_COMMAND, ID_APP_EXIT, 0); } else { TheApp()->m_RunClientWizOnly = FALSE; ::ShowWindow(MainFrame()->m_hWnd, SW_RESTORE); MainFrame()->UpdateDepotandChangeViews(REDRILL, pCmd->GetServerKey()); } } else MainFrame()->UpdateDepotandChangeViews(REDRILL, pCmd->GetServerKey()); delete pCmd; return 0; }
BOOL CCmd_Describe::HandledCmdSpecificError(LPCTSTR errBuf, LPCTSTR errMsg) { BOOL handledError=TRUE; #ifndef UNICODE if (!StrNCmp(errBuf, NOTRANS, sizeof(NOTRANS)-1)) { CString utf8; TCHAR *p = (TCHAR *)errBuf + sizeof(NOTRANS)-1; while (*p && *p != '\'') { TCHAR c1 = *p++; TCHAR c2 = *p++; if (_istdigit(c1)) c1 &= 0x0F; else c1 = (c1 & 0x0F) + 9; if (_istdigit(c2)) c2 &= 0x0F; else c2 = (c2 & 0x0F) + 9; TCHAR c3 = (c1 << 4) + c2; utf8.Insert(0x7FFFFFFF, c3); } // allocate widechar buffer and convert into it int lenw = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, 0, 0); LPWSTR utf16 = (LPWSTR)::VirtualAlloc(NULL, lenw*sizeof(WCHAR), MEM_COMMIT, PAGE_READWRITE); MultiByteToWideChar(CP_UTF8, 0, utf8, -1, utf16, lenw); // allocate char buffer and convert back into it, using '?' for // unmappable characters int len = WideCharToMultiByte(CP_ACP, 0, utf16, -1, 0, 0, NULL, NULL); LPSTR buf = (LPSTR)::VirtualAlloc(NULL, len*sizeof(TCHAR), MEM_COMMIT, PAGE_READWRITE); WideCharToMultiByte(CP_ACP, 0, utf16, -1, buf, len, NULL, NULL); // append to description m_Description += buf; m_Description += g_CRLF; ::VirtualFree(buf, 0, MEM_RELEASE); ::VirtualFree(utf16, 0, MEM_RELEASE); handledError = FALSE; } else #endif { m_FatalError = TRUE; TheApp()->StatusAdd( errMsg, SV_WARNING, true ); } return handledError; }
void CCmd_Delete::OnOutputInfo(char level, LPCTSTR data, LPCTSTR msg) { if(StrStr(data, _T("can't be deleted"))) { if(StrStr(data, _T("User")) && StrStr(data, _T("open on"))) TheApp()->StatusAdd( LoadStringResource(IDS_USER_HAS_OPEN_FILES_CANT_DELETE), SV_ERROR); else TheApp()->StatusAdd(msg, SV_WARNING); m_FatalError=TRUE; } else if(StrStr(data, _T("Can't delete branch"))) { if(StrStr(data, _T("owned by"))) TheApp()->StatusAdd( LoadStringResource(IDS_CANT_DELETE_UNOWNED_BRANCH), SV_ERROR); else TheApp()->StatusAdd(msg, SV_WARNING); m_FatalError=TRUE; } else { m_CompletionData= data; m_CompletionMsg = msg; } }
BOOL CCmd_Depots::HandledCmdSpecificError( LPCTSTR errBuf, LPCTSTR errMsg ) { if ( StrStr(errBuf, _T("no such file") ) ) { TheApp()->StatusAdd( LoadStringResource(IDS_NO_SUBDIR_UNDER_FOLDER), SV_DEBUG ); return TRUE ; } BOOL b = (StrStr(errBuf, _T("up-to-date.") ) != 0); if (!b && !m_GotDepot) m_FatalError = TRUE; // have to set this in case error comes from the broker // else we hang. return ( b ); }
BOOL CCmd_SendSpec::HandledCmdSpecificError(LPCTSTR errBuf, LPCTSTR errMsg) { m_ErrorTxt.Empty(); // Omit message about line number, if present CString omit= _T("\nError detected at line"); LPCTSTR pStartOmit= StrStr(errMsg, omit); if( pStartOmit ) { LPCTSTR pEndOmit = StrChr(pStartOmit+1, _T('\n')); if( pEndOmit ) m_ErrorTxt = CString(errMsg).Left(pStartOmit - errMsg) + pEndOmit; } else m_ErrorTxt = errMsg; if (StrStr(errBuf, _T("You cannot use the default branch view;"))) m_ErrorTxt += LoadStringResource(IDS_YOUMUSTCHANGETHEVIEW); // replace message about submit failure, if present int startSubmit = m_ErrorTxt.Find(_T("Submit failed")); if(startSubmit > -1) { m_ErrorTxt = m_ErrorTxt.Left(startSubmit) + LoadStringResource(IDS_SUBMIT_FAILED_CORRECT_AND_RESUBMIT); } else if ((errBuf != errMsg) && StrStr(errBuf, _T("Submit failed"))) { m_ErrorTxt.TrimRight(); startSubmit = m_ErrorTxt.ReverseFind(_T('\n')); if(startSubmit > -1) { m_ErrorTxt = m_ErrorTxt.Left(startSubmit+1) + LoadStringResource(IDS_SUBMIT_FAILED_CORRECT_AND_RESUBMIT); } m_ErrorTxt += _T("\n"); } // Put the error into the status bar. Let the UI thread pop the // error dialog so there isnt a window on-topness problem TheApp()->StatusAdd( m_ErrorTxt, SV_WARNING ); m_FatalError= TRUE; return TRUE; }
void CCmd_Labels::OnOutputInfo(char level, LPCTSTR data, LPCTSTR msg) { // Parse into a CP4Label and send that back CP4Label *label= new CP4Label; if( label->Create(data) ) m_Labels.Add(label); else { #ifdef _DEBUG CString errMsg; errMsg.Format(_T("Label parse failed:\n%s"), data); TheApp()->StatusAdd(errMsg, SV_DEBUG); #endif delete label; } }
BOOL CCmd_Delete::HandledCmdSpecificError(LPCTSTR errBuf, LPCTSTR errMsg) { m_FatalError = TRUE; if( StrStr(errBuf, _T("use -f to force delete"))) { CString m; m.FormatMessage(IDS_CANT_DELETE_PRIVELEGE_s, CString(errBuf, StrStr(errBuf, _T("; use -f")) - errBuf )); TheApp()->StatusAdd( m, SV_ERROR); return m_FatalError; } if(StrStr(errBuf, _T("Can't delete client")) && StrStr(errBuf, _T("owned by"))) { TheApp()->StatusAdd(LoadStringResource(IDS_CANT_DELETE_UNOWNED_CLIENT), SV_ERROR); return m_FatalError; } if(StrStr(errBuf, _T("Can't delete label"))) { if(StrStr(errBuf, _T("owned by"))) TheApp()->StatusAdd( LoadStringResource(IDS_CANT_DELETE_UNOWNED_LABEL), SV_ERROR); else TheApp()->StatusAdd(errMsg, SV_ERROR ); return m_FatalError; } if(StrStr(errBuf, _T("Can't delete branch"))) { if(StrStr(errBuf, _T("owned by"))) TheApp()->StatusAdd( LoadStringResource(IDS_CANT_DELETE_UNOWNED_BRANCH), SV_ERROR); else TheApp()->StatusAdd(errMsg, SV_ERROR); return m_FatalError; } if (( StrStr(errBuf, _T("don't have permission"))) || ( StrStr(errBuf, _T("is locked and can't be deleted")))) { TheApp()->StatusAdd( errMsg, SV_ERROR ); return m_FatalError; } m_FatalError = FALSE; return m_FatalError; }
void CCmd_Depots::PostProcess() { // The 'p4 depots' command may produce no output, in which case // GET_SERVERLEVEL() will come up dry. So the first order of // business is to run ANY command that is guaranteed to produce // output. I selected 'p4 client' cuz we already have the header // included and unlike commands like 'p4 info', it wont take a year // and a day on a slow network BOOL hasPlusMapping = FALSE; CCmd_Describe cmd(m_pClient); cmd.Init( NULL, RUN_SYNC ); BOOL cmdStarted= cmd.Run( P4CLIENT_SPEC, GET_P4REGPTR()->GetP4Client() ); if(cmdStarted && !cmd.GetError()) { // get client spec, and set NOCRLF flag and Client root in app TheApp()->m_bNoCRLF = IsLFonly(cmd.GetDescription()); TheApp()->Set_m_ClientRoot(TheApp()->GetClientSpecField( _T("Root"), cmd.GetDescription())); if (GET_SERVERLEVEL() >= 22) TheApp()->Set_m_ClientSubOpts(TheApp()->GetClientSpecField( _T("SubmitOptions"), cmd.GetDescription())); } else { TheApp()->m_ClientRoot.Empty(); m_ErrorTxt= LoadStringResource(IDS_UNABLE_TO_GET_CLIENT_DESCRIPTION); m_FatalError=TRUE; return; } int depotCount= m_LocalDepotList.GetCount() + m_RemoteDepotList.GetCount(); if (GET_P4REGPTR()->ShowEntireDepot() > SDF_DEPOT) { m_LocalDepotList.RemoveAll(); m_LocalDepotList.AddHead(TheApp()->m_ClientRoot); hasPlusMapping = DoesClientViewHavePlusMapping(cmd.GetDescription()); } // If more than one depot returned and in client-view-only mode, // get the client spec and remove any depots that are outside the clientview // else if( depotCount > 1 && !(GET_P4REGPTR()->ShowEntireDepot() == SDF_DEPOT) ) { if(!m_FatalError) { CString depot; CString view; hasPlusMapping = GetViewDepots( cmd.GetDescription(), view ); if(IS_NOCASE()) view.MakeLower(); POSITION pos1, pos2; for( pos1= m_LocalDepotList.GetHeadPosition(); (pos2=pos1) != NULL; ) { depot.Format(_T("%s/"), m_LocalDepotList.GetNext(pos1)); if(IS_NOCASE()) depot.MakeLower(); if( view.Find( depot ) == -1 ) { XTRACE(_T("Removed local depot %s because it is outside client view"), depot ); m_LocalDepotList.RemoveAt( pos2 ); } } for( pos1= m_RemoteDepotList.GetHeadPosition(); (pos2=pos1) != NULL; ) { depot.Format(_T("%s/"), m_RemoteDepotList.GetNext(pos1)); if(IS_NOCASE()) depot.MakeLower(); if( view.Find( depot ) == -1 ) { XTRACE(_T("Removed remote depot %s because it is outside client view"), depot ); m_RemoteDepotList.RemoveAt( pos2 ); } } } } // Else if no depots returned, just add the single remote depot 'depot' // since there is ALWAYS a default depot called 'depot' when no depots have // been defined // else { hasPlusMapping = DoesClientViewHavePlusMapping(cmd.GetDescription()); if ( depotCount == 0 ) m_LocalDepotList.AddHead( _T("//depot") ); } TheApp()->m_HasPlusMapping = hasPlusMapping; }
void SkylarkApp::SignalHandler(int signal) { TheApp().Signal(signal); }
BOOL CP4ListBrowse::OnInitDialog() { CDialog::OnInitDialog(); // Record the initial window size, then see if there is a registry preference GetWindowRect(&m_InitRect); m_LastRect = m_InitRect; if (!m_Wiz) m_WinPos.RestoreWindowPosition(); CString str; SetWindowText(m_caption); SetFont(m_Font); // Modify the list control style so that the entire selected row is highlighted DWORD dwStyle = ::SendMessage(m_P4ListCtrl.m_hWnd,LVM_GETEXTENDEDLISTVIEWSTYLE,0,0); dwStyle |= LVS_EX_FULLROWSELECT; ::SendMessage(m_P4ListCtrl.m_hWnd,LVM_SETEXTENDEDLISTVIEWSTYLE,0,dwStyle); // Make sure list control shows selection when not the focused control m_P4ListCtrl.ModifyStyle(0, LVS_SHOWSELALWAYS, 0); // Set the imagelist m_P4ListCtrl.SetImageList(TheApp()->GetImageList(), LVSIL_SMALL); if (m_Wiz) { GetDlgItem(IDC_BACK)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BACK)->EnableWindow(TRUE); GetDlgItem(IDOK)->SetWindowText(LoadStringResource(IDS_FINISH)); m_Hostname = GET_P4REGPTR()->GetHostname(); m_FilterByHost = TRUE; if (!m_IsFiltered) { GetDlgItem(IDC_REFRESH)->EnableWindow(FALSE); GetDlgItem(IDC_REFRESH)->ShowWindow(SW_HIDE); } } else if (m_BranchInteg) { GetDlgItem(IDC_BACK)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BACK)->EnableWindow(FALSE); GetDlgItem(IDOK)->SetWindowText(LoadStringResource(IDS_NEXT)); } if (m_IsFiltered) GetDlgItem(IDC_REFRESH)->SetWindowText(LoadStringResource(IDS_CLEARFILTERR)); // Get original size of control CRect rect; m_P4ListCtrl.GetWindowRect(&rect); int colwidth[MAX_P4OBJECTS_COLUMNS]= {90,90,90,90,90,90,90,90,90,90}; // make sure OnSize gets called to reposition controls // if restored position is default, this won't happen unless // we force it GetClientRect(&rect); SendMessage(WM_SIZE, 0, MAKELONG(rect.Width(), rect.Height())); // Get new size of control after resized as specified in the registry m_P4ListCtrl.GetWindowRect(&rect); // Get any saved column widths from registry RestoreSavedWidths(colwidth, MAX_P4OBJECTS_COLUMNS); // Make sure no column completely disappeared (because you can't get it back then) for (int i=-1; ++i < MAX_P4OBJECTS_COLUMNS; ) { if (colwidth[i] < 5) colwidth[i] = 5; } // Use the same font as the calling window m_P4ListCtrl.SetFont(m_Font); // Insert the columns int maxcols = m_ColNames->GetSize(); int width=GetSystemMetrics(SM_CXVSCROLL);; int retval; LV_COLUMN lvCol; for(int subItem=0; subItem < maxcols; subItem++) { lvCol.mask= LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT |LVCF_WIDTH; lvCol.fmt=LVCFMT_LEFT; lvCol.pszText=( LPTSTR )( LPCTSTR ) m_ColNames->GetAt( subItem ); lvCol.iSubItem=subItem; if(subItem < maxcols-1) { lvCol.cx=colwidth[subItem]; width+=lvCol.cx; } else lvCol.cx=max(colwidth[subItem], rect.Width() - width - 4); // expand last column to fill window retval=m_P4ListCtrl.InsertColumn(subItem, &lvCol); } AddTheListData(); EnumChildWindows(AfxGetMainWnd()->m_hWnd, ChildSetRedraw, TRUE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CCmd_ListOpStat::PreProcess(BOOL& done) { int i; POSITION pos; CCmd_ListOp cmd1(m_pClient); // Set up and run ListOp synchronously cmd1.Init(NULL, RUN_SYNC); cmd1.SetChkForSyncs(m_ChkForSyncs); cmd1.SetWarnIfLocked(m_WarnIfLocked); if(cmd1.Run(m_pFileSpecs, m_Command, m_ChangeNumber, m_NewType)) { m_FatalError= cmd1.GetError(); done=TRUE; if (m_ChkForSyncs) { CStringList * pSyncList = cmd1.GetSyncList(); if (!pSyncList->IsEmpty()) { for( pos= pSyncList->GetHeadPosition(); pos!= NULL; ) m_Unsynced.AddHead( pSyncList->GetNext(pos) ); CStringList * pEditList = cmd1.GetList(); for( pos= pEditList->GetHeadPosition(); pos!= NULL; ) { CString txt = pEditList->GetNext(pos); if ((i = txt.Find(_T('#'))) != -1) txt = txt.Left(i); m_RevertIfCancel.AddHead( txt ); } } else m_ChkForSyncs = FALSE; } } else { m_ErrorTxt= _T("Unable to Run ListOp"); m_FatalError=TRUE; } // Extract the CStringList from ListOp, which has filtered // results for the command. Note that Errors, warnings and // gee-whiz info have been thrown to the status window and // are not in the list CStringList *strList= cmd1.GetList(); // Check for huge file sets, where incremental screen update can take // a very looong time to complete. We are more tolerant for repoens, // because they involve updates in only one pane if(!m_FatalError && m_Command== P4REOPEN && strList->GetCount() > (3 * MAX_FILESEEKS)) { m_HitMaxFileSeeks= TRUE; TheApp()->StatusAdd(_T("CCmd_ListOpStat/P4REOPEN hit MAX_FILESEEKS - blowing off incremental update"), SV_DEBUG); } else if(!m_FatalError && m_Command!= P4REOPEN && strList->GetCount() > MAX_FILESEEKS) { m_HitMaxFileSeeks= TRUE; TheApp()->StatusAdd(_T("CCmd_ListOpStat hit MAX_FILESEEKS - blowing off incremental update"), SV_DEBUG); } // In the usual case of zero to a few hundred files, gather ostat-like info // for each file so that screen updates can be completed else if(!m_FatalError && strList->GetCount() > 0) { // Save a copy of the stringlist. for( pos= strList->GetHeadPosition(); pos!= NULL; ) m_StrListOut.AddHead( strList->GetNext(pos) ); // See if we need to run Ostat if(m_Command==P4EDIT || m_Command==P4DELETE) { // Set up and run ostat synchronously CCmd_Ostat cmd2(m_pClient); cmd2.Init(NULL, RUN_SYNC); if(cmd2.Run(FALSE, m_ChangeNumber)) m_FatalError= cmd2.GetError(); else { m_ErrorTxt= _T("Unable to Run Ostat"); m_FatalError=TRUE; } CObArray const *array= cmd2.GetArray(); if(!m_FatalError && array->GetSize() > 0) { // Save a copy of the oblist. for( int i=0; i < array->GetSize(); i++ ) m_StatList.AddHead( array->GetAt(i) ); } } else PrepareStatInfo(); } // Post the completion message if(!m_FatalError) { CString message; int already = 0; int reopened = 0; switch(m_Command) { case P4EDIT: for( pos= strList->GetHeadPosition(); pos!= NULL; ) { CString str = strList->GetNext(pos); if (str.Find(_T(" - currently opened ")) != -1) already++; else if (str.Find(_T(" - reopened ")) != -1) reopened++; } message.FormatMessage(IDS_OPENED_n_FILES_FOR_EDIT, strList->GetCount() - already - reopened); if (reopened) message.FormatMessage(IDS_s_n_FILES_REOPENED, message, reopened); if (already) message.FormatMessage(IDS_s_n_FILES_ALREADY_OPENED, message, already); break; case P4REOPEN: message.FormatMessage(IDS_REOPENED_n_FILES, strList->GetCount()); break; case P4REVERT: case P4VIRTREVERT: m_OutputError = cmd1.GetOutputErrFlag(); message.FormatMessage(m_OutputError ? IDS_ERROR_REVERTING_n_FILES : IDS_REVERTED_n_FILES, strList->GetCount()); break; case P4REVERTUNCHG: m_OutputError = cmd1.GetOutputErrFlag(); if (m_OutputError) message.FormatMessage(IDS_ERROR_REVERTING_n_FILES, strList->GetCount()); else if (m_NbrChgedFilesReverted) message.FormatMessage(IDS_REVERTED_n_FILES_n_CHG_n_UNCHG, m_NbrChgedFilesReverted + strList->GetCount(), m_NbrChgedFilesReverted, strList->GetCount()); else message.FormatMessage(IDS_REVERTED_n_FILES, strList->GetCount()); break; case P4LOCK: message.FormatMessage(IDS_LOCKED_n_FILES, strList->GetCount()); break; case P4UNLOCK: message.FormatMessage(IDS_UNLOCKED_n_FILES, strList->GetCount()); break; case P4DELETE: for( pos= strList->GetHeadPosition(); pos!= NULL; ) { CString str = strList->GetNext(pos); if (str.Find(_T(" - currently opened ")) != -1) already++; else if (str.Find(_T(" - reopened ")) != -1) reopened++; } message.FormatMessage(IDS_OPENED_n_FILES_FOR_DELETE, strList->GetCount() - already - reopened); if (reopened) message.FormatMessage(IDS_s_n_FILES_REOPENED, message, reopened); if (already) message.FormatMessage(IDS_s_n_FILES_ALREADY_OPENED, message, already); break; case P4ADD: message.FormatMessage(IDS_OPENED_n_FILES_FOR_ADD, strList->GetCount()); break; default: ASSERT(0); } if(!message.IsEmpty()) TheApp()->StatusAdd( message, SV_COMPLETION ); } done=TRUE; }
BOOL CJobListDlg::OnInitDialog() { CDialog::OnInitDialog(); CP4Job *job; CString str; SetFont(m_Font); // Modify the list control style so that the entire selected row is highlighted DWORD dwStyle = ::SendMessage(m_JobListCtrl.m_hWnd,LVM_GETEXTENDEDLISTVIEWSTYLE,0,0); dwStyle |= LVS_EX_FULLROWSELECT; ::SendMessage(m_JobListCtrl.m_hWnd,LVM_SETEXTENDEDLISTVIEWSTYLE,0,dwStyle); // Make sure list control shows selection when not the focused control m_JobListCtrl.ModifyStyle(0, LVS_SHOWSELALWAYS, 0); // Set the imagelist m_JobListCtrl.SetImageList(TheApp()->GetImageList(), LVSIL_SMALL); // Get original size of control CRect rect; m_JobListCtrl.GetWindowRect(&rect); int colwidth[MAX_JOBS_COLUMNS]={90,80,60,90,200}; // Record the initial window size, and then see if there is a registry preference GetWindowRect(&m_InitRect); m_WinPos.RestoreWindowPosition(); // make sure OnSize gets called to reposition controls // if restored position is default, this won't happen unless // we force it GetClientRect(&rect); SendMessage(WM_SIZE, 0, MAKELONG(rect.Width(), rect.Height())); // Get new size of control after resized as specified in the registry m_JobListCtrl.GetWindowRect(&rect); // Get any saved column widths from registry RestoreSavedWidths(colwidth, MAX_JOBS_COLUMNS); // Make sure no column completely disappeared (because you can't get it back then) for (int i=-1; ++i < MAX_JOBS_COLUMNS; ) { if (colwidth[i] < 5) colwidth[i] = 5; } // Show the current job filter CString txt; m_sFilter = PersistentJobFilter(KEY_READ); if(m_sFilter.GetLength() > 0) { txt.FormatMessage(IDS_JOBFILTERSTR, m_sFilter); } else { txt = LoadStringResource(IDS_ALLJOBS); GetDlgItem(ID_CLEARFILTER)->EnableWindow(FALSE); } GetDlgItem(IDC_FILTER_TEXT)->SetWindowText(txt); // Use the same font as the calling window m_JobListCtrl.SetFont(m_Font); // Insert the columns int maxcols = m_ColNames->GetSize(); int width=GetSystemMetrics(SM_CXVSCROLL);; int retval; LV_COLUMN lvCol; int subItem; for(subItem=0; subItem < maxcols; subItem++) { lvCol.mask= LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT |LVCF_WIDTH; lvCol.fmt=LVCFMT_LEFT; lvCol.pszText=( LPTSTR )( LPCTSTR ) m_ColNames->GetAt( subItem ); lvCol.iSubItem=subItem; if(subItem < maxcols-1) { lvCol.cx=colwidth[subItem]; width+=lvCol.cx; } else lvCol.cx=rect.Width() - width - 4; // expand last column to fill window retval=m_JobListCtrl.InsertColumn(subItem, &lvCol); } // Add the data LV_ITEM lvItem; int iActualItem = -1; POSITION pos= m_pJobList->GetHeadPosition(); int iItem; for(iItem=0; iItem < m_pJobList->GetCount(); iItem++) { job= (CP4Job *) m_pJobList->GetNext(pos); for(subItem=0; subItem < maxcols; subItem++) { lvItem.mask=LVIF_TEXT | ((subItem==0) ? LVIF_IMAGE : 0) | ((subItem==0) ? LVIF_PARAM : 0); lvItem.iItem= (subItem==0) ? iItem : iActualItem; ASSERT(lvItem.iItem != -1); lvItem.iSubItem= subItem; lvItem.iImage = CP4ViewImageList::VI_JOB; lvItem.lParam=(LPARAM) job; txt=PadCRs(job->GetJobField(subItem)); lvItem.pszText = const_cast<LPTSTR>( (LPCTSTR ) txt); if(subItem==0) iActualItem=m_JobListCtrl.InsertItem(&lvItem); else m_JobListCtrl.SetItem(&lvItem); } } if(m_pJobList->GetCount()) { // Sort the jobs list the same way the JobView is sorted m_JobListCtrl.SortItems( JobListDlgSort, m_LastSortColumn ); // Find the job currently selected in the jobs pane iItem=0; if (!m_CurrJob->IsEmpty()) { TCHAR cur[ LISTVIEWNAMEBUFSIZE + 1 ]; TCHAR str[ LISTVIEWNAMEBUFSIZE + 1 ]; lstrcpy(cur, m_CurrJob->GetBuffer(m_CurrJob->GetLength()+1)); m_CurrJob->ReleaseBuffer(-1); for( ; iItem < ListView_GetItemCount( m_JobListCtrl.m_hWnd ); iItem++ ) { ListView_GetItemText( m_JobListCtrl.m_hWnd, iItem, 0, str, LISTVIEWNAMEBUFSIZE ); if( !Compare(cur, str) ) break; } if (iItem >= ListView_GetItemCount( m_JobListCtrl.m_hWnd )) iItem = 0; } // Make sure the same job is selected and visible m_JobListCtrl.SetItemState(iItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); m_JobListCtrl.EnsureVisible( iItem, FALSE ); // Set change description to match selected item in list job= (CP4Job *) m_JobListCtrl.GetItemData(iItem); str= job->GetDescription(); str.Replace(_T("\n"), _T("\r\n")); m_JobDesc.SetWindowText(str); } else if( m_sFilter.IsEmpty() ) { AfxMessageBox(IDS_NO_JOBS_AVAILABLE_FOR_FIXING, MB_ICONEXCLAMATION); EndDialog(IDCANCEL); } else AddToStatus(LoadStringResource(IDS_USEJOBFILTERBUTTON), SV_MSG); if (!LoadJobStatusComboBox()) { GetDlgItem(IDC_JOBSTATUSPROMPT)->ShowWindow( SW_HIDE ); GetDlgItem(IDC_JOBSTATUS)->ShowWindow( SW_HIDE ); } // And finally, set focus to the list control so that the first 'down' // keystroke can be used to scroll down m_JobListCtrl.SetFocus(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
CMsgBox::CMsgBox(CString text, UINT nType /*=1*/, int cancelButton /*=0*/, CWnd* pParent /*=NULL*/, BOOL *lpBdontShow /*= NULL*/, BOOL bShowVscroll /*= FALSE*/) : CDialog(CMsgBox::IDD, pParent), m_cancelButton(cancelButton) { //{{AFX_DATA_INIT(CMsgBox) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_InitRect = CRect(0,0,0,0); // the string provided should be delimited by tabs, with button labels // first, followed by the prompt string. First, extract the button labels m_numButtons = 0; m_DontShowAgain = 0; m_ShowVscroll = bShowVscroll; m_lpDontShowAgain = lpBdontShow; for(int nextTab = text.Find(_T('\t')); nextTab != -1; nextTab = text.Find(_T('\t'))) { switch(m_numButtons) { case 0: m_Button1 = text.Left(nextTab); m_numButtons++; break; case 1: m_Button2 = text.Left(nextTab); m_numButtons++; break; case 2: m_Button3 = text.Left(nextTab); m_numButtons++; break; default: ASSERT(0); // too many buttons specified - ignore them } text = text.Mid(nextTab+1); } // what's left in string 'labels' now is just the prompt string if (text.GetLength() < 150) text = "\n" + text; m_Text = text; switch(nType & MB_DEFMASK) { case MB_DEFBUTTON2: m_DefButton = IDC_BUTTON2; break; case MB_DEFBUTTON3: m_DefButton = IDC_BUTTON3; break; default: m_DefButton = m_numButtons == 1 ? IDC_BUTTON2 : IDC_BUTTON1; } int nIDCaption = 0; switch(nType & MB_ICONMASK) { case MB_ICONHAND: m_Icon = IDI_HAND; nIDCaption = IDS_ERROR; break; case MB_ICONQUESTION: m_Icon = IDI_QUESTION; break; case MB_ICONEXCLAMATION: m_Icon = IDI_EXCLAMATION; nIDCaption = IDS_WARNING; break; case MB_ICONASTERISK: m_Icon = IDI_ASTERISK; break; default: m_Icon = 0; } m_Caption = TheApp()->m_pszAppName; if(nIDCaption) m_Caption += _T(" ") + LoadStringResource(nIDCaption); }
LRESULT CClientListCtrl::OnP4EndSpecEdit( WPARAM wParam, LPARAM lParam ) { CCmd_EditSpec *pCmd= (CCmd_EditSpec *) wParam; BOOL chainedCommand = FALSE; BOOL need2Refresh = FALSE; if (lParam != IDCANCEL && lParam != IDABORT) { // Get the Sync flag int syncAfter = SYNC_DONT; BOOL bHasChgs = TRUE; if (m_PrevNbrCli < 1) { int key= pCmd->HaveServerLock() ? pCmd->GetServerKey() : 0; CCmd_Changes *pCmd2= new CCmd_Changes; pCmd2->Init( m_hWnd, RUN_SYNC, key ? HOLD_LOCK : LOSE_LOCK, key); if( pCmd2->Run(SUBMITTED_CHANGES, FALSE, NULL, 1) ) { if (!pCmd2->GetChanges()->GetCount()) bHasChgs = FALSE; } delete pCmd2; } if (m_isNew && !GET_P4REGPTR()->DontShowYouHaveCr8NewClient() && bHasChgs) { BOOL b; switch(MsgBox(IDS_YOU_HAVE_CREATED_NEW_CLIENT, MB_ICONEXCLAMATION | MB_DEFBUTTON1, 0, this, &b)) { case IDC_BUTTON1: syncAfter = SYNC_HEAD; break; case IDC_BUTTON2: syncAfter = SYNC_DONT; break; } GET_P4REGPTR()->SetDontShowYouHaveCr8NewClient(b); } else if ((pCmd->IsSyncAfter() || pCmd->IsAutoUpdateSpec()) && !GET_P4REGPTR()->DontShowYouHaveChgClientView() && bHasChgs) { BOOL b; switch(MsgBox(pCmd->IsAutoUpdateSpec() ? IDS_DOYOUWANTOTSYNCYOURNEWCLIENT : IDS_YOU_HAVE_CHANGED_CLIENTS_VIEW, MB_ICONQUESTION | MB_DEFBUTTON1, 0, this, pCmd->IsAutoUpdateSpec() ? NULL : &b)) { case IDC_BUTTON1: syncAfter = SYNC_HEAD; break; case IDC_BUTTON2: syncAfter = pCmd->IsAutoUpdateSpec() ? SYNC_DONT : SYNC_HAVE; break; case IDC_BUTTON3: syncAfter = SYNC_DONT; break; } if (!pCmd->IsAutoUpdateSpec()) GET_P4REGPTR()->SetDontShowYouHaveChgClientView(b); } BOOL bDeld = FALSE; if (m_UpdateState == LIST_UPDATED) { // we have to set 'index' again in case client's name got changed int index= FindInList(m_pNewSpec->GetClientName()); int ixAll= FindInListAll(m_pNewSpec->GetClientName()); if (ixAll == -1) // not in either list { ASSERT(index == -1); CString curclient = GET_P4REGPTR()->GetP4Client(); CString defclient = GET_P4REGPTR()->GetP4Client(TRUE); InsertClient(m_pNewSpec, GetItemCount(), &curclient, &defclient); } else if (index > -1) // in both lists { ASSERT(ixAll > -1); if (MainFrame()->IsClientFilteredOut(m_pNewSpec)) // should it no longer be shown? { need2Refresh = TRUE; delete m_pNewSpec; } else { UpdateClient(m_pNewSpec, index); UpdateClientAll(m_pNewSpec, ixAll); } } else // not in visible list; is in list of all { if (MainFrame()->IsClientFilteredOut(m_pNewSpec)) // should it now be shown? need2Refresh = TRUE; else UpdateClientAll(m_pNewSpec, ixAll); if (pCmd->IsAutoUpdateSpec()) m_OldClient = m_pNewSpec->GetClientName(); delete m_pNewSpec; bDeld = TRUE; } ReSort(); if (pCmd->IsAutoUpdateSpec() || pCmd->IsSpecForceSwitch()) { if (bDeld) need2Refresh = TRUE; else { int i = FindInList(m_OldClient = m_pNewSpec->GetClientName()); if (i < 0) i = 0; SetItemState(i, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); EnsureVisible(i, FALSE); } m_Active = _T("@"); // force switch to new client } } else if ( m_pNewSpec ) delete m_pNewSpec; int key= pCmd->HaveServerLock() ? pCmd->GetServerKey() : 0; if( m_Active == m_saveclientnew ) // active-client == saved new client name m_OldClient = m_saveclientnew; // means they decided to edit the current client if( m_Active != m_OldClient ) // If current client is not now the client when this { // all started, switch to the new current client if (GET_P4REGPTR()->GetExpandFlag() == 1) GET_P4REGPTR()->AddMRUPcuPath(MainFrame()->GetCurrentItemPath()); m_Active = m_OldClient; GET_P4REGPTR()->SetP4Client( m_Active, TRUE, FALSE, FALSE); MainFrame()->UpdateCaption( ); if (syncAfter) chainedCommand = SyncAfter(key, syncAfter); } else if( syncAfter || GET_P4REGPTR()->GetClearAndReload() || AfxMessageBox(IDS_YOU_HAVE_UPDATED_YOUR_CLIENT_WORKSPACE__CLEAR_AND_RELOAD, MB_YESNO |MB_ICONQUESTION ) == IDYES ) { if (syncAfter) chainedCommand = SyncAfter(key, syncAfter); else { int key= pCmd->HaveServerLock() ? pCmd->GetServerKey() : 0; MainFrame()->UpdateDepotandChangeViews(REDRILL, key); chainedCommand=TRUE; } } if (GET_SERVERLEVEL() >= 22) TheApp()->Set_m_ClientSubOpts(TheApp()->GetClientSpecField( _T("SubmitOptions"), pCmd->GetSpecOut())); } else { if ( m_pNewSpec ) delete m_pNewSpec; if (lParam == IDCANCEL && pCmd->GetIsRequestingNew()) { m_Active = pCmd->GetOldClient(); // switch back to the previous client GET_P4REGPTR()->SetP4Client( m_Active, TRUE, FALSE, FALSE); MainFrame()->UpdateCaption( ); } } if (lParam != IDABORT) { MainFrame()->ClearStatus(); if (!chainedCommand && pCmd->HaveServerLock()) pCmd->ReleaseServerLock(); CDialog *dlg = (CDialog *)pCmd->GetSpecSheet(); dlg->DestroyWindow(); } delete pCmd; m_EditInProgress = FALSE; if (need2Refresh && !chainedCommand) OnViewUpdate(); if (TheApp()->m_RunClientWizOnly && !chainedCommand) ::PostMessage(MainFrame()->m_hWnd, WM_COMMAND, ID_APP_EXIT, 0); return 0; }
void CCmd_ListOpStat::PrepareStatInfo() { POSITION pos; CString listRow, fname, fRev; int separator; int pound = -1; int lastSlash; int rev = -1; BOOL rowError; for(pos=m_StrListOut.GetHeadPosition(); pos !=NULL; ) { listRow=fname=m_StrListOut.GetNext(pos); rowError=FALSE; ////////////// // Separate the filename from the action description // For all operations but lock and unlock, this amounts to a // quick search for '#'. In the case of the lock commands, // there is no revision number, so search for the action text itself switch(m_Command) { case P4LOCK: // For Lock and Unlock, server doesnt send rev number separator= listRow.Find(_T(" - locking")); if(separator == -1) rowError=TRUE; break; case P4UNLOCK: // For Lock and Unlock, server doesnt send rev number separator= listRow.Find(_T(" - unlocking")); if(separator == -1) rowError=TRUE; break; default: pound= listRow.Find(_T('#')); if(pound == -1) { separator = -1; // this is just to make the compiler shut up rowError=TRUE; break; } separator= pound+1; int len= listRow.GetLength(); for( ; separator < len ; separator++) { if(listRow[separator]==_T(' ') && listRow[separator+1]==_T('-') && listRow[separator+2]==_T(' ')) break; } if(separator==len) rowError=TRUE; } if(rowError) { // doesnt look like a valid row, report it and skip it ASSERT(0); listRow= _T("Invalid listRow: ") + listRow; TheApp()->StatusAdd(listRow, SV_WARNING); continue; } fname=fname.Left(separator); lastSlash=fname.ReverseFind(_T('/')); // For Lock and Unlock, server doesnt send rev number if(m_Command != P4LOCK && m_Command != P4UNLOCK) { fRev=fname.Mid(pound+1); rev=_ttol(fRev); fname=fname.Left(pound); // full name without revision } CP4FileStats *fs= new CP4FileStats; fs->SetDepotPath(fname); switch(m_Command) { case P4EDIT: fs->SetOpenAction(F_EDIT, FALSE); fs->SetHaveRev(rev); fs->SetOpenChangeNum(m_ChangeNumber); break; case P4DELETE: fs->SetOpenAction(F_DELETE, FALSE); fs->SetHaveRev(rev); fs->SetOpenChangeNum(m_ChangeNumber); break; case P4LOCK: fs->SetLocked(TRUE, FALSE); break; case P4UNLOCK: fs->SetLocked(FALSE, FALSE); break; case P4REOPEN: case P4REVERT: case P4VIRTREVERT: case P4REVERTUNCHG: break; case P4ADD: fs->SetOpenAction(F_ADD, FALSE); fs->SetHaveRev(rev); fs->SetOpenChangeNum(m_ChangeNumber); break; default: ASSERT(0); } m_StatList.AddHead(fs); } // for each }
void CFirstTimeDlg::OnGetAdobe() { GotoDlgCtrl(GetDlgItem(IDOK)); ShellExecute( m_hWnd, _T("open"), LoadStringResource(IDS_WWW_ADOBE), NULL, NULL, SW_SHOWNORMAL); TheApp()->StatusAdd(LoadStringResource(IDS_WAIT4ADOBE), SV_MSG); }
void MvcController::UponUpdateUI(wxUpdateUIEvent& event) { event.Skip(); unit_test_idle_processing_completed_ = false; // Explicitly disregard any wxUpdateUIEvent received while this // application is not active: see // http://lists.gnu.org/archive/html/lmi/2006-03/msg00006.html // for a discussion. if(!TheApp().IsActive()) { return; } // A disabled window might have focus: // http://lists.nongnu.org/archive/html/lmi/2005-11/msg00040.html // so make sure focus is valid now. EnsureOptimalFocus(); // Exit immediately if nothing changed. The library calls this // function continually in idle time, and it's pointless to fret // over inputs that didn't change on this update because they've // already been handled. Complex processing of many inputs has // been observed to consume excessive CPU time when a malloc // debugger is running, so this optimization is significant. // // The early-exit condition cannot succeed until Assimilate() has // been called: therefore, Assimilate() is guaranteed to be called // here by the time the user can interact with the GUI. TransferDataFromWindow(); if(cached_transfer_data_ == transfer_data_) { unit_test_idle_processing_completed_ = true; return; } cached_transfer_data_ = transfer_data_; DiagnosticsWindow().SetLabel(""); std::vector<std::string> control_changes; std::string const name_to_ignore = NameOfControlToDeferEvaluating(); typedef std::map<std::string,std::string>::const_iterator smci; for(smci i = transfer_data_.begin(); i != transfer_data_.end(); ++i) { std::string const& name = i->first; std::string const& view_value = i->second; std::string const& model_value = model_.Entity(name).str(); if(name == name_to_ignore || ModelAndViewValuesEquivalent(name)) { continue; } try { std::string change = name + ":\n" + " model: '" + model_value + "'\n" + " view: '" + view_value + "'\n" ; control_changes.push_back(change); model_.Entity(name) = view_value; } catch(std::exception const& e) { DiagnosticsWindow().SetLabel(name + ": " + e.what()); } } // wxEVT_UPDATE_UI events should occur frequently enough that two // control changes cannot be simultaneous. if(1 < control_changes.size()) { warning() << "Contents of more than one control changed.\n"; typedef std::vector<std::string>::const_iterator svci; for(svci i = control_changes.begin(); i != control_changes.end(); ++i) { warning() << *i; } warning() << LMI_FLUSH; } Assimilate(name_to_ignore); }
void CCmd_SendSpec::OnOutputInfo(char level, LPCTSTR data, LPCTSTR msg) { //i18n: completion message in data BOOL processedMessage=FALSE; switch(m_SpecType) { case P4BRANCH_SPEC: if(StrNCmp(data, _T("Branch "), 7) == 0) { TheApp()->StatusAdd(msg, SV_COMPLETION); processedMessage=TRUE; } break; case P4CLIENT_SPEC: if(StrNCmp(data, _T("Client "), 7) == 0) { TheApp()->StatusAdd(msg, SV_COMPLETION); processedMessage=TRUE; } break; case P4JOB_SPEC: if(StrNCmp(data, _T("Job "), 4) == 0) { // Extract the new job name LPCTSTR pRest = StrChr(data+4, _T(' ')); if(pRest && (!StrCmp(pRest+1, _T("saved.")) || !StrCmp(pRest+1, _T("not changed.")))) { CString temp(data + 4); temp=temp.Left(temp.Find(_T(' '))); m_NewJobName= temp; } TheApp()->StatusAdd(msg, SV_COMPLETION); processedMessage=TRUE; } break; case P4LABEL_SPEC: if(StrNCmp(data, _T("Label "), 6) == 0) { TheApp()->StatusAdd(msg, SV_COMPLETION); processedMessage=TRUE; } break; case P4USER_SPEC: if(StrNCmp(data, _T("User "), 5) == 0) { TheApp()->StatusAdd(msg, SV_COMPLETION); processedMessage=TRUE; } break; case P4CHANGE_SPEC: if(!m_Submit) { if(StrNCmp(data, _T("Change"), 6) ==0 ) { m_NewChangeNum= _ttol(data+7); ASSERT(m_NewChangeNum); processedMessage=TRUE; } break; } else { // Typically many lines are returned - The only thing we need is the new // change number static TCHAR rc[] = _T("renamed change "); static TCHAR sc[] = _T("Submitting change "); if(!StrNCmp(data, _T("Change"), 6) && !StrStr(data, _T("updated"))) { // Its either 'Change n1 renamed change n2 and submitted' // or 'Change n1 submitted' m_NewChangeNum = _ttol(data+7); LPCTSTR pRenamed = StrStr(data+7, rc); if(pRenamed) m_NewChangeNum = _ttol(pRenamed + StrLen(rc)); ASSERT(m_NewChangeNum); } else if(!StrNCmp(data, sc, StrLen(sc))) { // It's 'Submitting change n1' m_NewChangeNum = _ttol(data+StrLen(sc)); ASSERT(m_NewChangeNum); } else if(StrStr(data, _T(" - must get")) || StrStr(data, _T(" - must resolve"))) TheApp()->StatusAdd(msg, SV_WARNING); else if(StrCmp(data, _T("Specification not corrected -- giving up.")) == 0) TheApp()->StatusAdd(msg, SV_WARNING); else TheApp()->StatusAdd(msg); processedMessage=TRUE; break; } default: ASSERT(0); } if(!processedMessage) CP4Command::OnOutputInfo( level, data, msg); }