// // Copyright 2001 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wJobCmdView: // Posts the job edit form data back to p4 via job -i ONLY // if the job will not overwrite an existing job. #include <stdlib.h> #include <string.h> #include <p4wp4.h> #include "p4wMenuPane.h" #include "p4wJobCmdView.h" #include "p4wJobCmdPane.h" p4wJobCmdView::p4wJobCmdView( p4wRequest & Request ) : p4wView( Request ) { // // Set the short and the long versions of the title fShortTitle.Set( "Job Result" ); if( fRequest.GetURL().Length() ) fFullTitle << "Job " << fRequest.GetURL() << " Result"; else fFullTitle.Set( "Job Result" ); } p4wJobCmdView::~p4wJobCmdView() { } void p4wJobCmdView::RenderContent() { // // Post the edited job form back to p4 for processing // unless the user replaced the jobname with an existing // job name. Spec s; StrBufDict st; StrPtr *job; int cUnique = 0; int isEdit = fRequest.GetURL().Length(); StrPtr *noCase = fRequest.GetProtocol( "nocase" ); // // If this is not a form, or the job field is missing, // generate the invalid url error message. s.Add( "Job" ); if( !fRequest.GetPostData() || !fRequest.ProcessForm( s, &st ) || !( job = st.GetVar( StrRef( "Job" ) ) ) ) { RenderError( "Requested URL is invalid in this context." ); return; } // // If the job name is "new" or it matches the url, we // don't have to check for an existing job by this name. // If we must check, issue jobs -e <jobname> and check // result. p4wJobCmdPane jobPane( *this, fRequest, job->Text() ); if( *job == "new" || ( isEdit && ( noCase && !job->CCompare( fRequest.GetURL() ) || !noCase && !job->XCompare( fRequest.GetURL() ) ) ) ) { jobPane.Begin(); jobPane.End(); } else { ++cUnique; fRequest.p4Arg( "-e" ); fRequest.p4Arg( job->Text() ); fRequest.p4( "jobs", 0, 0, &jobPane ); fRequest.p4Wait(); if( jobPane.FatalError() ) return; } // Post an error if the job name has been edited // and the job already exists. if( cUnique && jobPane.JobExists() ) { StrBuf err; err << "Error: Job " << job << " already exists."; jobPane.RenderError( err.Text(), 1 ); return; } // // All is well...post the form back to p4 fRequest.p4Arg( "-i" ); fRequest.p4( "job", 0, 0, &jobPane ); fRequest.p4Wait(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
//guest/perforce_software/p4web/Views/p4wJobCmdView.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |