// // Copyright 2001 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wClientPane: // Display the result of the p4 client clientname command or // else display a form to edit the client #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wClientPane.h" char *option[] = { "allwrite", "locked", "compress", "rmdir", "modtime", "clobber", "nocrlf" }; char *optText[] = { "Unopened files writable on client <I>(allwrite)</I>", "Client spec write-protected <I>(locked)</I>", "Compression between client/server <I>(compress)</I>", "Sync deletes empty client directories <I>(rmdir)</I>", "Mod time set to depot submit time <I>(modtime)</I>", "Sync overwrites writable unopened files <I>(clobber)</I>", "No CR/LF translation on client <I>(nocrlf)</I>", }; p4wClientPane::p4wClientPane( p4wView & ParentView, p4wRequest & Request, int isForm ) : p4wSpecPane( ParentView, Request, isForm ) { fOverrideCmd = AC_NONE; } p4wClientPane::~p4wClientPane() { } // ------------------------------------- // Overrides for spec panes. // int p4wClientPane::IgnoreField( const char * field ) { // // No fields are ignored return 0; } int p4wClientPane::MakeFieldReadOnly( const char * field ) { // // Make Owner, Root and AltRoot readonly if not local if( !fRequest.isLocalRequest() && !SEC_ALLOW_EDIT_CLIENTROOT ) { if (!strcmp("Owner", field) || !strcmp("Root", field) || !strcmp("AltRoots", field)) return 1; } return 0; } int p4wClientPane::CustomField( const char * field, StrDict * varList, int len, SpecElem *se ) { // // Process our custom fields. int retVal; if( fIsForm ) retVal = doCustomForm( field, varList, len ); else retVal = doCustomNotForm( field, varList ); return retVal; } void p4wClientPane::End() { // // Client edit form uses the default specPane's End() method. // So does Client View if we are viewing the current client. StrBuf newBase; StrBuf switchURL; p4wURL urlMaker; if( fIsForm || ( fRequest.GetCmd() == AC_CLIENTVIEW && ( !fRequest.GetURL().Length() || fRequest.GetURL() == fRequest.GetClient() ) ) ) { p4wSpecPane::End(); return; } // // Optionally generate a link to switch to this client if this was the // result of a client view command. If this was the result of switching // to a client, generate a "switched to client" message. p4wHtml htm; if( fRequest.GetCmd() == AC_CLIENTSWITCHRES ) { StrBuf txt; txt << "Switched to client " << p4wStrBuf().EscapeHTML( fRequest.GetClient(), Unicode() ).Text() << "."; htm.beginTRow(); htm.beginCol( NULL, NULL, "2" ); htm.text( txt.Text() ); htm.endCol(); htm.endTRow(); // // Generate a link to switch to this client if we are not // already using this client. } else if( fRequest.GetURL().Length() && ( fRequest.GetURL() != fRequest.GetClient() ) && ( fRequest.isLocalRequest() || !SEC_DISALLOW_CHG_CLIENTS ) ) { htm.beginTRow(); htm.beginCol( NULL, NULL, "2" ); htm.text( "Switch to client " ); fRequest.UseNewBase( newBase, NULL, "path", NULL ); newBase << fRequest.GetURL(); urlMaker.ConstructURL( switchURL, newBase.Text(), AC_CLIENTSWITCH, NULL, fRequest.GetUnicode() ); htm.beginLink( switchURL.Text() ); htm.text( p4wStrBuf().EscapeHTML(fRequest.GetURL(), Unicode()).Text() ); htm.endLink(); htm.endCol(); htm.endTRow(); } // // End the pane. htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.comment( "END SPEC PANE" ); fRequest << htm; } void p4wClientPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( fOverrideCmd != AC_NONE ? fOverrideCmd : AC_CLIENTCMD, NULL, 0, actionURL ); } int p4wClientPane::doCustomNotForm( const char * field, StrDict * varList ) { // // Provide nicer output for the Options field p4wHtml htm; if( strcmp(field, "Options") == 0 ) { StrBuf tag; char * val = varList->GetVar( StrRef(field) )->Text(); tag << field << ":"; htm.beginTRow(); htm.beginCol( "top" ); htm.text( tag.Text(), "b" ); htm.endCol(); htm.beginCol(); char *selectVal = strtok( val, " " ); while( selectVal != NULL ) { if( strcmp( selectVal, "allwrite" ) == 0 ) { htm.text( "Unopened files writable on client" ); htm.linebreak(); } else if( strcmp( selectVal, "clobber" ) == 0 ) { htm.text( "Sync overwrites writable unopened files" ); htm.linebreak(); } else if( strcmp( selectVal, "compress" ) == 0 ) { htm.text( "Data compression between client/server" ); htm.linebreak(); } else if( strcmp( selectVal, "nocrlf" ) == 0 ) { htm.text( "No CR/LF translation between depot/client" ); htm.linebreak(); } else if( strcmp( selectVal, "locked" ) == 0 ) { htm.text( "Client spec write-protected" ); htm.linebreak(); } else if( strcmp( selectVal, "modtime" ) == 0 ) { htm.text( "Mod time set to depot submission time" ); htm.linebreak(); } else if( strcmp( selectVal, "rmdir" ) == 0 ) { htm.text( "Sync deletes empty client directories" ); htm.linebreak(); } selectVal = strtok( NULL, " " ); } htm.endCol(); htm.endTRow(); fRequest << htm; // // We're done with this custom field. return 1; } else if( strcmp(field, "Description") == 0 ) { char *dval = varList->GetVar( StrRef(field) )->Text(); htm.beginTRow(); htm.beginCol( "top" ); htm.text( "Description", "b" ); htm.endCol(); htm.beginCol(); htm.beginUnformatted( "normal" ); htm.text( p4wStrBuf().EscapeHTML( StrRef(dval), Unicode() ).Text() ); htm.endUnformatted(); htm.endCol(); htm.endTRow(); fRequest << htm; return 1; } else { // // Not a custom field return 0; } } int p4wClientPane::doCustomForm( const char * field, StrDict * varList, int maxFieldLen ) { // // Process our custom fields. p4wHtml htm; StrBuf tagOut; if( strcmp( field, "Options" ) == 0 ) { StrBuf currValue; int crlfOpt = 0; currValue.Set( varList->GetVar( StrRef( field ) ) ); tagOut << field << ":"; if( !fIsOpen ) htm.beginTRow(); FormatFields( htm, tagOut.Text(), "top" ); htm.beginTable( "0", "100%" ); htm.beginTRow(); char *optVect[7]; int wc = StrOps::Words( currValue, field, optVect, 7 ); // // Determine whether Options has crlf/nocrlf for( int c = 0; c < wc; c++ ) { if( strstr( optVect[c], "crlf" ) ) { crlfOpt++; break; } } //Parse options line to get checked checklist items int i; int ck; for( int opt = 0; opt < 7; opt++ ) { // // If the crlf/nocrlf option wasn't found, leave this // checkbox out if( !crlfOpt && opt == 6 ) break; htm.beginCol( "top" ); ck = 0; for( i = 0; i < wc; i++ ) { if( strcmp( optVect[i], option[opt] ) == 0 ) { ck = 1; break; } } char optstr[8]; sprintf(optstr, "%d", opt); htm.checkbox( "Options", option[opt], ck, 0, optstr ); htm.label( optText[opt], optstr ); htm.endCol(); if( opt % 2 ) { htm.endTRow(); htm.beginTRow(); } } htm.endTRow(); htm.endTable(); htm.endCol(); if( !fLeaveOpen ) htm.endTRow(); fRequest << htm; // We're done with this custom field. return 1; } else if( strcmp( field, "View" ) == 0 ) { const StrPtr * p; tagOut << field << ":"; if( !fIsOpen ) htm.beginTRow(); FormatFields( htm, tagOut.Text(), "top" ); htm.beginTextbox( field, 6, fTextALen ); for( int d = 0; ( p = varList->GetVar( StrRef( field ), d ) ) != NULL; d++ ) htm.text( p4wStrBuf().EscapeHTML( *p, Unicode() ).Text() ); htm.endTextbox(); htm.endCol(); if( !fLeaveOpen ) htm.endTRow(); fRequest << htm; return 1; } else if( strcmp( field, "Root" ) == 0 && fRequest.GetCr8NewClient() && fRequest.GetMasterRoot()->Length() ) { const StrPtr * p; tagOut << field << ":"; if( !fIsOpen ) htm.beginTRow(); FormatFields( htm, tagOut.Text(), "top" ); StrBuf root; root.Set(fRequest.GetMasterRoot()->Text()); char slash = strchr(root.Text(), '/') ? '/' : '\\'; if (slash != *(root.Text() + root.Length() - 1)) root << (slash == '/' ? "/" : "\\"); root << fRequest.GetClient().Text(); if (SEC_ALLOW_EDIT_CLIENTROOT) htm.textField( field, root.Text(), fTextALen ); else { htm << root; htm.hiddenField( field, root.Text() ); } htm.endCol(); if( !fLeaveOpen ) htm.endTRow(); fRequest << htm; return 1; } else { // // No custom fields. return 0; } } void p4wClientPane::RenderInfo( char *data, char level ) { if (!fRequest.bQuiet()) printf("%s\n", data); } void p4wClientPane::RenderExistsNotNew( StrDict * varList ) { p4wHtml htm(1); htm.linebreak(); const StrPtr *client = varList->GetVar( "Client" ); if (client) { StrBuf newBase; p4wURL urlMaker; p4wStrBuf clientURL; fRequest.UseNewBase( newBase, NULL, "path", NULL ); newBase << client; urlMaker.ConstructURL( clientURL, newBase.Text(), AC_CLIENTVIEW, NULL, fRequest.GetUnicode() ); htm.beginLink( clientURL.Text() ); htm.text( p4wStrBuf().EscapeHTML( *client, Unicode() ).Text() ); htm.endLink(); htm.text( " is the name of an existing client."); } else htm << "You have entered the name of an existing client."; htm.linebreak(); htm << "Do you want to switch to this client?"; htm.linebreak(); htm.linebreak(); htm.button("editexistingyes", "Yes"); htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "document.write(\"<input type=button name='editexistingno' value='No' onClick='history.go(-1)'>\")" << crlf; htm << "</script>" << crlf; htm << "<noscript>" << crlf; htm.button("editexistingno", "No"); htm << "</noscript>" << crlf; fRequest << htm; }
# | 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/Panes/p4wClientPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |