// // Copyright 2002 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wRequest: // Manages a single browser request from determining the appropriate // request, through generating the p4 requests to get the data #ifndef p4wRequest_H #define p4wRequest_H # include <vararray.h> #include "p4wAllCommands.h" #include "p4wURL.h" #define crlf "\n" enum HTMLEncoding { HE_None, HE_Page, HE_URL }; enum ShowHideMasks { SH_P4CMDS = 256, SH_FILES = 128, SH_PENDING = 64, SH_SUBMITTED= 32, SH_BRANCHES = 16, SH_LABELS = 8, SH_CLIENTS = 4, SH_USERS = 2, SH_JOBS = 1 }; enum ScreenChunkMasks { SCRN_LOGO = 256, SCRN_HEADER = 128, SCRN_PATH = 64, SCRN_TABS = 32, SCRN_TOOLBAR = 16, SCRN_TITLE = 8, SCRN_FILTER = 4, SCRN_BODY = 2, SCRN_COPYRIGHT = 1 }; class Web822; class p4wPane; // // Allow user to cancel server requests class P4KeepAlive : public KeepAlive { public: int IsAlive(); } ; struct ThumbNailItem { int rev; StrBuf thumbnail; }; /* * ThumbNailTable -- array of available ThumbNails */ class ThumbNailTable : public VarArray { public: ~ThumbNailTable(); ThumbNailItem * GetItem( int rev ); void AddItem( int rev, const StrRef base64thumb ); }; class p4wRequest { public: p4wRequest( ClientApi &client, Web822 *web822, int isBrowseOnly, int javascript, const char *jsvname, const char *jsvpath, int noAuth, int authBrowseOnly, const char *hostPort, const char *progName, const char *group, const char *tabs, int isNTService=0, int isHTTPS=0, ErrorLog *reportLog=0, int securityFlags=0, Options * opts=0); virtual ~p4wRequest(); // // URL, form and body processing functions. void ProcessURL(); int ProcessForm( Spec &spec, StrBufDict *useDict = NULL ); char *GetPostData() { return fPostData; } int GetPostLgth() { return fPostLgth; } SpecDataTable &GetPostArgs() { return fPostArgs; } // // Gets/sets state as retrieved from url int GetViewMode() { return fViewMode; } AllCommands GetCmd() { return fCommand; } void SetCmd(AllCommands ac) { fCommand = ac; } AllCommands GetLastReturnType(); const StrPtr &GetBITBRev() { return fBITBRev; } const StrPtr &GetURL() { return fURL; } const StrPtr &GetDynURL() { return fDynURL; } const StrPtr &GetReturnURL( AllCommands ac ) { return ac == AC_PATHBROWSER ? fReturnURL : fReturnFileURL; } const StrPtr &GetFullURL() { return fFullURL; } const StrPtr &GetPath() { return GetDepotPath(); } const StrPtr &GetDepotPath() { return fDepotPath; } void SetDepotPath( StrPtr *path ) { fDepotPath.Set(path); } const StrPtr &GetBase() { return fBase; } void SetBase( char *str ) { fBase.Set(str); } const StrPtr *GetCmdArg() { return fDynParms.GetVar( "arg" ); } const StrPtr *GetCmdFlag() { return fDynParms.GetVar( "fl" ); } void SetCmdFlag( char * flag ) { fDynParms.SetVar( "fl", flag ); } const StrPtr *GetDynArg( const char *var, HTMLEncoding encoding = HE_None ) { return argEncoding(var, fDynParms.GetVar( var ), encoding); } const StrPtr *GetDynArg( const char *var, int index, HTMLEncoding encoding = HE_None ) { return argEncoding(var,fDynParms.GetVar( StrRef( var ), index ), encoding ); } const StrPtr *GetStateArg( const char *var, HTMLEncoding encoding = HE_None ) { return argEncoding(var, fStateParms.GetVar( var ), encoding); } int GetStateArgX( int x, StrRef &var, StrRef &val ) { return fStateParms.VGetVarX( x, var, val ); } // Be careful! StrBufDict * GetDynArgs() { return &fDynParms; } const StrPtr &GetHTTPPort() { return fHTTPPort; } int HideDeletedFiles() { return fHideDeleted; }; int HideCurrentDir() { return fHideCurrentDir; }; int HideRecentChanges() { return fHideRecentChanges; }; int HideRawP4Cmds() { return fHideRawP4Cmds; }; int HideGoTo() { return fHideGoTo; }; int HideThumbnails() { return fHideThumbnails; }; int HideDetails() { return fHideDetails; }; int HideOpenedFiles() { return fHideOpened; }; int isLocalRequest(); int URLHasNoStateInfo(); StrPtr *GetAddress( int raf_flags ); void SetDiffType( int t ) { fDiffType = t; }; int GetDiffType() { return fDiffType; }; void SetSaveDefaults( int t ) { fSaveDefaults = t; }; void SetSaveJobsDefs( int t ) { fSaveJobsDefs = t; }; void SetSaveChgsDefs( int t ) { fSaveChgsDefs = t; }; void SetSaveFilterDefs( int t ) { fSaveFilterDefs = t; }; void SetSaveUserPswd( int t ) { fSaveUserPswd = t; }; void SetDefaults( char *str ) { fDefaults.Set(str); } StrPtr &GetDefaults( ) { return fDefaults; } void SetShowHide( char *str ) { fShowHide.Set(str); } const StrPtr &GetShowHide( ) { return fShowHide; } int GetScreenChunks() { return fScreenChunks; } void SetScreenChunks(int screenChunks) { fScreenChunks = screenChunks; } int GetXSS( ) { return fXSS; } void SetMultiUser( int b ) { fMultiUser = b; }; int GetMultiUser() { return fMultiUser; }; void SetGroup( StrPtr *g ) { fGroup << g; }; const StrPtr &GetGroup() { return fGroup; } ; void SetTabs( StrPtr *t ) { fTabs << t; }; const StrPtr &GetTabs() { return fTabs; } ; int GetIsTagged() { return fIsTagged; }; int IsMac() { return fIsMac; }; const StrPtr &GetClientRoot() { return fClientRoot; } void SetClientRoot( StrPtr *path) { fClientRoot.Set(path); } void SetAuthBrowseOnly() { fMultiUser = 0; fBrowseOnly = fAuthBrowseOnly = 1; } // // Gets/sets unicode mode as detected by p4wThread.cpp int GetUnicode() { return fIsUnicode; }; void SetUnicode( int mode ) { fIsUnicode = mode; }; // // Gets/Sets for dealing with thumbnails int GetHeaderProcessed() { return fHeaderProcessed; }; void SetHeaderProcessed( int flag ) { fHeaderProcessed = flag; }; int GetHeadRev() { return fHeadRev; } void SetHeadRev( int rev ) { fHeadRev = rev; } int GetHaveRev() { return fHaveRev; } void SetHaveRev( int rev ) { fHaveRev = rev; } int GetHasThumbs() { return fHasThumbs; }; void SetHasThumbs( int flag ) { fHasThumbs = flag; }; int GetThumbnailColsDefault() { return fThumbColsDefault; }; int GetThumbnailCols() { return fThumbCols; }; void SetThumbnailCols( int flag ) { fThumbCols = flag; }; void AddThumbNail( int rev, const StrPtr * base16thumb ); ThumbNailItem * GetThumbNail( int rev ); void SetViewMode( ViewMode vMode ); void SetCdPath( const char *var, const char *val, int normalize, int isPathBrowser, StrBuf &cdPath ); void SetPath( const char *path, int normalize ); void SetWRPath(); void UseNewBase( StrBuf & newBase, const char *oldBaseStr, const char *var, const char *val ); void UseNewBaseDoCache( StrBuf & newBase, const char *oldBaseStr, const char *var, const char *val ); void ReplaceBase( const char *var, const char *val ); int GetOutputInfoOK() { return fOutputInfoOK; }; void SetOutputInfoOK( int b ) { fOutputInfoOK = b; }; // // Page content limit methods int PageLimitExceeded() { return ( fNBytesSent > fByteLimit ); } int PageContentLimit() { return fKBytes; }; int PageContentDefault() { return fKByteDefault; }; // // Use Javascript for Links methods int UseJSforLinks() { return fJSlinks; } // // Redirection methods void DoLocation( const char *newLocation ); void RedirectToURLWithReferrerState(); int RmvDynArgBeginWith(StrPtr & dynbuf, char x); // x must be one of 'b', 'l', 'c', 'u' // // Returns state of this p4web session int GetBrowseMode() { return fBrowseOnly; } int GetJavascriptMode() { return fJavascript; } const StrPtr &GetJavaScriptViewName() { return fJavaScriptViewName; } const StrPtr &GetJavaScriptViewPath() { return fJavaScriptViewPath;} float GetBrowserVersion() { return fBrowserVersion; } const StrPtr &GetUserAgent() { return fUserAgent; } const StrPtr &GetHTTPVersion() { return fHTTPVersion; } const StrPtr *GetSvcName() { return &fProgName; } int BypassAuth() { return fNoAuth; }; int BrowseWithAuth() { return fAuthBrowseOnly; }; int IsNTService() { return fIsNTService; }; int IsHTTPS() { return fIsHTTPS; }; int GetSecurityFlags() { return fSecurityFlags; }; int bQuiet() { return fQuiet; } Options *GetOpts() { return fOpts; } const StrPtr *GetFileFilter() { return &fFileFilter; } const StrPtr *GetMasterRoot() { return &fMasterRoot; } const StrPtr *GetCustBackground() { return &fcustBackground; } const StrPtr *GetCustLabel() { return &fcustLabel; } const StrPtr *GetCustText() { return &fcustText; } const StrPtr *GetCustTitle() { return &fcustTitle; } const StrPtr *GetCustHeader() { return &fcustHeader; } const StrPtr *GetCustSubheader() { return &fcustSubheader; } const StrPtr *GetCustFooter() { return &fcustFooter; } const StrPtr *GetCustGraphic(){ return &fcustGraphic; } const StrPtr *GetReferer() { return fWeb822->GetVar( "referer" ); } const StrPtr *GetCookies() { return fWeb822->GetVar( "cookie" ); } int GetCr8NewClient() { return fCr8NewClient; } void SetCr8NewClient(int b) { fCr8NewClient = b; } // // Gets/sets state of the current clientApi & p4 request ClientApi &GetClientApi() { return fClient; }; const StrPtr &GetCwd() { return fClient.GetCwd(); } const StrPtr &GetClient() { return fClient.GetClient(); } const StrPtr &GetOs() { return fClient.GetOs(); } const StrPtr &GetPassword() { return fClient.GetPassword(); } const StrPtr &GetPort() { return fClient.GetPort(); } const StrPtr &GetUser() { return fClient.GetUser(); } const StrPtr &GetHost() { return fClient.GetHost(); } const StrPtr &GetCharset() { return fClient.GetCharset(); } StrPtr *GetProtocol( char *arg ) { return fClient.GetProtocol( arg ); } int GetP4Init() { return fP4InitSet; }; void SetP4Init( int p4Init ) { fP4InitSet = p4Init; }; void SetUser( const StrPtr *user ) { fClient.SetUser( user ); } void SetPassword( const StrPtr *passwd ) { fClient.SetPassword( passwd ); } // // Wrapper to p4wURL::ConstructURL which will construct a // "safe" url by constructing an absolute path instead of a relative // path when the url contains unsafe characters void ConstructSafeURL( StrBuf & url, const char *path, AllCommands cmd, StrBufDict *cmdArgs ); // // p4 request functions. void p4( const char *cmd, int argc, const char **argv, ClientUser *pane); void p4Arg( const StrRef &arg ); void p4Arg( const char *arg ) { fShowP4Args << " " << arg; p4Arg( StrRef( (char *)arg ) ); } void p4Wait(); void p4Init( Error *e ); void p4Final( Error *e ); int didP4Init() { return fDidP4Init; } StrBuf *GetShowP4Cmds() { return &fShowP4Cmds; } // // iostream-style write functions. p4wRequest& operator <<( int val ); p4wRequest& operator <<( const char *s ) { if (fSave4Later) fLater << s; else Write( s, strlen( s ) ); return *this; } p4wRequest& operator <<( const StrPtr *s ) { if (fSave4Later) fLater << s; else Write( s->Text(), s->Length() ); return *this; } p4wRequest& operator <<( const StrPtr &s ) { if (fSave4Later) fLater << s; else Write( s.Text(), s.Length() ); return *this; } p4wRequest& operator <<( const char c ) { if (fSave4Later) fLater << c; else Write( &c, 1 ); return *this; } // // WriteX(StrBuf) clear StrBuf void Write( StrBuf & str ); void Write( const char *buf, int len ); void WriteLine(); void WriteLine( StrBuf & str ); // // Process a customization file void ProcessCustomization(); void WriteCustHTML(char *filename, int indent=0); // // Generates a javascript show/hide block void doShowHideBlock(int showHideState, char *alt, char* title, char* msg=0, int ctr=0); // // Hash/Unhash pswd with user and szInitTime void doHashPswd(char *userpswd, int lgth); void unHashPswd(char *userpswd, int lgth); protected: // // The keep alive instance for supporting server request cancel P4KeepAlive cancel; private: const StrPtr *argEncoding( const char *var, StrPtr *arg, HTMLEncoding encoding ); // // Detect browser type from userAgent string sent from browser int DetectBrowser(); // // Create base string optionally setting variable to prevent // page caching void doUseNewBase( StrBuf & newBase, const char *oldBaseStr, const char *var, const char *val, int noCache ); // // The Perforce client handle and Web822 object. ClientApi &fClient; Web822 *fWeb822; // // Internal request state. StrBuf fURL; StrBuf fFullURL; StrBuf fDynURL; StrBufDict fStateParms; StrBufDict fDynParms; StrBufDict fEscStateParms; StrBuf fReturnURL; StrBuf fReturnFileURL; ViewMode fViewMode; StrBuf fDepotRootPath; StrBuf fDepotPath; StrBuf fClientRoot; AllCommands fCommand; StrBuf fFlags; StrBuf fArgs; StrBuf fBase; StrBuf fHTTPPort; StrBuf fUserAgent; StrBuf fHTTPVersion; StrBuf fGroup; StrBuf fTabs; int fHideDeleted; int fHideCurrentDir; int fHideRecentChanges; int fHideRawP4Cmds; int fHideGoTo; int fHideThumbnails; int fHideDetails; int fHideOpened; int fMultiUser; int fIsTagged; int fIsMac; // // Page content limit in bytes, the current // number of bytes sent so far, the current limit // in K Bytes, and the default K Byte limit int fByteLimit; int fNBytesSent; int fKBytes; int fKByteDefault; // // Use Javascript for Workspace links in the Revision History pane int fJSlinks; // // Post data char * fPostData; int fPostLgth; SpecDataTable fPostArgs; // // Browse-only mode? int fBrowseOnly; // // Javascript mode int fJavascript; float fBrowserVersion; StrBuf fJavaScriptViewName; StrBuf fJavaScriptViewPath; // // no authorization required int fNoAuth; // // Browse ony and authorization required int fAuthBrowseOnly; // // was p4 init called? int fP4InitSet; // // Back In Tme Browsing StrBuf fBITBRev; // // Name of program or service StrBuf fProgName; // // Does this need to be redirected to a new URL that includes // state info? int fURLHasNoState; // // Is this process an NT service? int fIsNTService; // // Are to generate https? int fIsHTTPS; // // Security flags for remote users int fSecurityFlags; // // Run in quiet-mode (for inetd) int fQuiet; // // Startup options Options * fOpts; // // Default file filter StrBuf fFileFilter; // // All clients' roots must be at or under this path StrBuf fMasterRoot; // // Creating new client int fCr8NewClient; // // Customization strings StrBuf fcustBackground; StrBuf fcustLabel; StrBuf fcustText; StrBuf fcustTitle; StrBuf fcustHeader; StrBuf fcustSubheader; StrBuf fcustFooter; StrBuf fcustGraphic; // // Are we operating in unicode mode int fIsUnicode; // // Are we operating in unicode mode int fOutputInfoOK; // Have we gotten the fstat header int fHeaderProcessed; // The head rev if we processed the fstat header int fHeadRev; // The have rev if we processed the fstat header int fHaveRev; // Diff type int fDiffType; // Save settings as default int fSaveDefaults; // Save job settings as default int fSaveJobsDefs; // Save submitted changelists settings as default int fSaveChgsDefs; // Save chgs, branches, labels, clients, users filter settings int fSaveFilterDefs; // Save user:passwordticket int fSaveUserPswd; // Saved default settings StrBuf fDefaults; // Saved show/hide settings StrBuf fShowHide; // Which pieces of the screen to show - see ScreenChunkMasks for details int fScreenChunks; // p4Init call for this request int fDidP4Init; // XSS attack detected int fXSS; // Does this request have thumbnails int fHasThumbs; // Number of thumbnail columns int fThumbCols; // Default number of thumbnail columns int fThumbColsDefault; // Thumbnail Table ThumbNailTable * fThumbNailTab; // Report Log ErrorLog *fReportLog; StrBuf fReportBuf; public: // Save output from running p4 groups int fGroupsRun; int fClientRun; int fHadClientError; int fHadGroupError; int fHadPasswordError; int fHadLoginError; int fHadUnicodeError; int fHadSSLError; int fHadMiscError; int fHadAnyError; StrBuf fErrorText; // Save output from running p4 info int fUnknownClient; // Save output that is to be displayed at a later time int fSave4Later; StrBuf fLater; // Save P4 commands StrBuf fShowP4Cmds; StrBuf fShowP4Args; private: }; #endif // p4wRequest_H
# | 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/Main/p4wRequest.h | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |