// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wThumbnailView: // Renders output of print command using mime type determined by file suffix. // ------------------------------------- // Includes // #include <stdio.h> #include <string.h> #include <p4wp4.h> #include "p4wThumbnailView.h" #include "p4wThumbnailPane.h" #include "p4wErrorView.h" #include "base64.h" p4wThumbnailView::p4wThumbnailView(p4wRequest & Request) : p4wView(Request) { } p4wThumbnailView::~p4wThumbnailView() { } // ------------------------------------- // Render this view. // void p4wThumbnailView::Render() { // we will need a p4wThumbnailPane no matter how we hanfle this p4wThumbnailPane printPane( *this, fRequest ); // // handle AC_ECHOURLAsDATA if (fRequest.GetCmd() == AC_ECHOURLAsDATA) { int l; StrBuf bindata; StrBuf b64data; b64data << fRequest.GetFullURL(); char *src = b64data.Text(); if (*src == '/') strcpy(src, src+1); if (*src == '?' && !strcmp(src, "?ac=171")) return; // bad url! char * dest = bindata.Alloc(l = strlen(src)); int lgth = b64_decode(src, l, dest, l); printPane.RenderHeaderIfMapped( 0 ); fRequest.Write( dest, lgth ); return; // got it, wrote it, done } // // Request file text at head rev unless we have revision argument. const StrPtr *rev1 = fRequest.GetStateArg( "rev1" ); const StrPtr *rev1Dyn = fRequest.GetDynArg( "rev1" ); const StrPtr *srev = fRequest.GetDynArg( "sr" ); const StrPtr *srevState = fRequest.GetStateArg( "sr" ); // // If both dynamic & state parameters for sr are set, dynamic // wins...set srev to winner if( !srev && srevState ) srev = srevState; if( rev1Dyn ) rev1 = rev1Dyn; // get the path StrBuf path; path.Set( fRequest.GetPath() ); char *p = path.Text(); if (*p == '\\') // is the path trashed? { do // replace all \ with / { *p++ = '/'; p = strchr(p, '\\'); } while (p); p = path.Text(); if (*(p+1) != '/') // only one / at beginning? { StrBuf temp; temp.Set( path ); path.Clear(); path << "/" << temp; } } // run p4 fstat -Oae -A thumb on this file#rev or file@chgnbr if( rev1 && strcmp("0", rev1->Text()) ) { path << "#" << rev1; } else if( srev ) { path << "@" << srev; } char *cmd; StrBuf errorMsg; Error e; fRequest.p4Arg( "-Oae" ); fRequest.p4Arg( "-A" ); fRequest.p4Arg( "thumb" ); fRequest.p4Arg( path.Text() ); fRequest.p4( "fstat", 0, 0, &printPane ); if( p4debug.GetLevel( DT_NET ) >= 2 ) printf("Re-getting thumbnail: p4 fstat -Oae -A thumb %s\n", path.Text()); 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/p4wThumbnailView.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |