// // Copyright 2007 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wUploadLocalPane: // Upload to the client file on local workspace #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wUploadLocalPane.h" p4wUploadLocalPane::p4wUploadLocalPane( p4wView & ParentView, p4wRequest & Request ) : p4wPane( ParentView, Request ), fSeenData(0) { } p4wUploadLocalPane::~p4wUploadLocalPane() { } // ------------------------------------- // Render functions. // void p4wUploadLocalPane::Begin() { // // Begin the pane. p4wHtml htm; htm.comment( "BEGIN UPLOAD LOCAL PANE" ); fRequest << htm; } void p4wUploadLocalPane::Render( StrDict * varList ) { Error e; StrBuf buf; CharSetCvt *cvt; CharSetCvt::CharSet cs; if( varList->GetVar( "clientFile" ) == NULL ) return; #if 0 StrBuf md5; FileSys *f; f = FileSys::Create( FST_BINARY ); f->Set( *varList->GetVar( "clientFile" ) ); if (!fRequest.isLocalRequest() && (f->Stat() & FSF_SYMLINK) && !SEC_ALLOW_CR8CHG_SYMLINKS) { delete f; fRequest << "A Symlink may not be uploaded by a remote browser."; return; } f->Digest(&md5, &e); delete f; #endif if( e.Test() ) return; if( !fSeenData ) { fSeenData = 1; p4wHtml htm; StrBuf clearIcon; htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "15", "0", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.beginTable( "0", "100%", "8", "1", "#FFFFFF" ); // 7F7F7F for border htm.beginTRow( NULL, NULL, "#FFFFFF" ); htm.beginCol(); // htm << "<center>"; htm.beginTable( "0", NULL, "2", "0", "#FFFFFF" ); htm.beginTRow(); htm.beginCol(); // htm << "<center>"; if (fRequest.GetCmd() == AC_UPLOADTOLOCALPROCESSOR) { char time_buffer[255 + 1]; time_buffer[0] = '\0'; time_t iTime = time( NULL ); StrBuf time_format; time_format.Append( "%a, %d %b %Y %H:%M:%S %Z" ); strftime( time_buffer, sizeof( time_buffer ), time_format.Text(), localtime( &iTime ) ); htm << "File saved at " << time_buffer << crlf; htm << "</center>"; htm.paragraph(); htm << "You still need to submit this file's changelist "; StrPtr *change = varList->GetVar( "change" ); fRequest << htm; htm.Clear(); if (change) { p4wHtml htm(1); htm << "("; StrBuf newBase; fRequest.UseNewBase( newBase, NULL, "path", NULL ); p4wURL urlMaker; StrBuf changeURL; StrBufDict cmdArgs; cmdArgs.SetVar( "arg", change ); urlMaker.ConstructURL( changeURL, newBase.Text(), AC_CHANGEPENDINGEDIT, strcmp(change->Text(), "default") ? &cmdArgs : NULL, fRequest.GetUnicode() ); htm.beginLink( changeURL.Text() ); if (strcmp(change->Text(), "default")) htm << p4wStrBuf().EscapeHTML( *change, Unicode() ).Text(); else htm << "Default"; htm.endLink(); htm << ") "; fRequest << htm; } htm << "to update the head revision of the file in the depot."; fRequest << htm; return; } fRequest << htm; } if( PageLimitExceeded() ) return; p4wHtml htm; StrBuf newBase; StrBuf actionURL; StrBuf clientFile; clientFile << varList->GetVar( "clientFile" ); if (fRequest.GetViewMode() == VM_WORKSPACE) fRequest.UseNewBase( newBase, NULL, "path", clientFile.Text() ); else fRequest.UseNewBase( newBase, NULL, "path", varList->GetVar( "depotFile" )->Text() ); fRequest.ConstructSafeURL( actionURL, newBase.Text(), AC_UPLOADTOLOCALPROCESSOR, NULL ); htm << "<p>" << crlf; htm << "<FORM METHOD=POST ENCTYPE=\"multipart/form-data\" ACTION=\""; htm << actionURL.Text() << "\">" << crlf; htm << "Enter the full path to the file to upload: "; htm.linebreak(); htm << "<INPUT TYPE=FILE SIZE=\"50\" NAME=\"upfile\"><p>" << crlf; htm.button( "submitfile", "Upload" ); htm.endForm(); fRequest << htm; } void p4wUploadLocalPane::End() { // // End the pane. p4wHtml htm; if( fSeenData ) { // htm << "</center>"; htm.endCol(); htm.endTRow(); htm.endTable(); // htm << "</center>"; htm.endCol(); htm.endTRow(); htm.endTable(); } else { htm.beginTRow(); htm.beginCol(); htm.text( "File not found, or file is empty." ); htm.endCol(); htm.endTRow(); } htm.comment( "END UPLOAD LOCAL PANE" ); 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/p4wUploadLocalPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |