// // Copyright 1999 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wMultiUserPane: the user preferences edit pane #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wSpecPane.h" #include "p4wMultiUserPane.h" p4wMultiUserPane::p4wMultiUserPane( p4wView & ParentView, p4wRequest & Request ) : p4wSpecPane( ParentView, Request, 1 ), fGotClient(0), fOK2End(0) { } p4wMultiUserPane::~p4wMultiUserPane() { } void p4wMultiUserPane::Render( StrDict * varList ) { if (fRequest.fHadPasswordError) return; // // If varlist given, save off the client name if (varList) { const StrPtr *client = varList->GetVar( "client" ); const StrPtr *host = varList->GetVar( "Host" ); const StrPtr *owner = varList->GetVar( "Owner "); const StrPtr *root = varList->GetVar( "Root" ); //if (client->Length() < 70) //return; // see if this host is allowed if (!fRequest.isLocalRequest() && !SEC_ALLOW_NOHOST_CLIENTS && (!host || !*(host->Text()))) return; if (host && *(host->Text()) && strcmp(host->Text(), fRequest.GetHost().Text())) return; // see if this client belongs to this user const StrPtr *server = fRequest.GetProtocol( "server2" ); if ( !server || server->Atoi() < 22 ) { if (!owner || strcmp(owner->Text(), fRequest.GetUser().Text())) return; } // see if this client's root is acceptible int lgthMaster; if (!fRequest.isLocalRequest() && (lgthMaster = fRequest.GetMasterRoot()->Length()) > 0) { #ifdef OS_NT if (!root || strnicmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgthMaster)) #else if (!root || strncmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgthMaster)) #endif return; } if (!fGotClient) { StrBuf onchange; onchange << "document.enterForm.Client.value = document.enterForm.cliList.options[document.enterForm.cliList.selectedIndex].value;"; if (fRequest.GetJavascriptMode() == 1) // make Mozilla more keybrd friendly onchange << "document.enterForm.Client.focus();"; StrBuf onfocus; onfocus << "if (document.enterForm.Client.value == '') document.enterForm.Client.value = document.enterForm.cliList.options[document.enterForm.cliList.selectedIndex].value;"; fDDhtm.beginSelect("cliList", 0, 0, onchange.Text(), onfocus.Text()); } fDDhtm.selectOpt( !fGotClient, client->Text() ); fDDhtm.text( client->Text() ); fGotClient = 1; return; } // // Draw the Multiuser page p4wHtml htm(1); StrBuf clearIcon; p4wURL urlMaker; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); StrBuf actionURL; fRequest.ConstructSafeURL( actionURL, NULL, AC_MULTIUSERPROCESSOR, NULL ); htm.endForm(); htm.beginTRow(); htm.beginCol(); htm.beginDList(); if (fRequest.isLocalRequest() || !SEC_DISALLOW_CHG_CLIENTS) { if (fErrorMsg.Length()) { char *p = fErrorMsg.Text(); if (!strncmp(p, "<p>", 3)) { strcpy(p, p+3); fErrorMsg.SetLength(); } htm.text(fErrorMsg.Text(), 0, 0, "#FF0000"); } else { StrBuf buf; char sw; const StrPtr *err = fRequest.GetDynArg("err"); sw = err ? *(err->Text()) : '0'; switch(sw) { case '1': buf << "Client '"; buf << p4wStrBuf().EscapeHTML( fRequest.GetClient(), Unicode() ).Text(); buf << "' does not exist"; htm.text(buf.Text(), 0, 0, "#FF0000"); break; case '2': buf << "Only clients owned by '"; buf << p4wStrBuf().EscapeHTML( fRequest.GetUser(), Unicode() ).Text(); buf << "' can be used."; htm.text(buf.Text(), 0, 0, "#FF0000"); break; case '3': htm.text("Clients whose host field is not specified can not be used.", 0, 0, "#FF0000"); break; case '4': htm.text("Invalid client", 0, 0, "#FF0000"); break; case '5': buf << "Client '"; buf << p4wStrBuf().EscapeHTML( fRequest.GetClient(), Unicode() ).Text(); buf << "' can not be used on '"; buf << fRequest.GetHost().Text(); buf << "'"; htm.text(buf.Text(), 0, 0, "#FF0000"); break; case '6': buf << "You are only allowed to use a client whose root begins with "; buf << p4wStrBuf().EscapeHTML( StrRef(fRequest.GetMasterRoot()->Text()), Unicode() ); htm.text(buf.Text(), 0, 0, "#FF0000"); break; case'0': default: htm.text("You have successfully logged in as user \""); htm << p4wStrBuf().EscapeHTML( fRequest.GetUser(), Unicode() ).Text(); htm.text( "\". Before proceeding you need to choose a client." ); break; } } htm << "<p><ul>"; htm.text( "<li><b>Select an existing client:</b>" ); htm.linebreak(); htm.beginTable(); htm.beginForm(actionURL.Text(), "enterForm"); htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,1); if (fGotClient) { htm << "<script language=javascript>"; htm << "document.write(\"Client name: \")"; htm << "</script>"; htm << "<noscript>"; htm << "Enter client name:"; htm << "</noscript>"; } else htm.text( "Enter client name: " ); htm.endCol(); htm.beginCol(0,0,0,0,0, "100%", 0, 1); const StrPtr *cl = fRequest.GetStateArg( "cl" ); htm.textField( "Client", "", 32, "client" ); htm << "<script language=\"JavaScript\" type=\"text/javascript\">if(document.getElementById) document.getElementById('client').focus();</script>"; htm.button( "save", "Select" ); htm.endCol(); htm.endTRow(); if (fGotClient) { fDDhtm.selectOpt(); int i; for (i=64; --i; ) fDDhtm << " "; fDDhtm.endSelect(); htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,1); htm << "<script language=javascript>"; htm << "</script>"; htm << "<noscript>"; htm << "Or choose client from list:"; htm << "</noscript>"; htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); fRequest << htm << fDDhtm; htm.Clear(); htm << "<script language=javascript>"; htm << "</script>"; htm << "<noscript>"; htm.button( "cliListBtn", "Select"); htm << "</noscript>"; htm.endCol(); htm.beginCol(0,0,0,0,0, "100%"); htm << " "; htm.endCol(); htm.endTRow(); } htm.endForm(); if (!fRequest.isLocalRequest() && !SEC_ALLOW_NOHOST_CLIENTS && !SEC_ALLOW_ALL_CLIENTS) { htm.beginTRow(); htm.beginCol(0,0, "100%",0,0,0,0,0, "remote"); htm << "Note: only clients that are associated with host machine '"; htm << fRequest.GetHost(); htm << "'can be used.<br>"; StrBuf url; url << fRequest.GetFullURL() << "#remote"; htm.beginLink(url.Text(), NULL, "remote"); htm << "See notes below on working remotely."; htm.endLink(); htm.endCol(); htm.endTRow(); } htm.endTable(); if (fRequest.isLocalRequest() || SEC_ALLOW_CREATE_CLIENTS) { htm << "<p><li><b>Create a new client:</b>"; htm.linebreak(); htm.beginTable(); htm.beginForm(actionURL.Text(), "create"); htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,1); htm << "New client name:"; htm.endCol(); htm.beginCol(0,0,0,0,0, "100%", 0, 1); htm.textField( "newClient", "", 32 ); htm.button( "create", "Create"); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.endCol(); htm.beginCol(); htm << "(name must not contain spaces)"; htm.endCol(); htm.endTRow(); htm.endForm(); htm.endTable(); } StrPtr *s; Options *opts = fRequest.GetOpts(); if( s = (*opts)[ 'M' ] ) { StrBuf newPath; StrBuf clientURL; fRequest.ReplaceBase( "md", "d" ); fRequest.UseNewBase(newPath, NULL, "path", NULL); fRequest.UseNewBase(newPath, newPath.Text(), "cl", NULL); fRequest.UseNewBase(newPath, newPath.Text(), "bo", "1"); urlMaker.ConstructURL( clientURL, newPath.Text(), AC_PATHBROWSER, NULL, fRequest.GetUnicode() ); htm.text("<p><li><b>Skip client selection, I only want to browse the depot:</b>"); htm.linebreak(); htm.beginTable(); htm.beginCol(0,0,"100%"); htm.beginForm( clientURL.Text() ); htm << "A client is not needed if you are not making changes to the depot"; htm.linebreak(); htm.button( "Browse Depot", "Browse Depot" ); htm.endForm(); htm.endCol(); htm.endTRow(); htm.endTable(); } htm.text( "</ul>" ); } htm.endCol(); htm.endTRow(); fRequest << htm; fOK2End = 1; End(); } // // Overrides for spec config panes // void p4wMultiUserPane::GetAction( StrBuf & actionURL ) { // // Constructs url used for the form ACTION value ConstructAction( AC_MULTIUSERPROCESSOR, NULL, 1, actionURL ); } void p4wMultiUserPane::End() { if (!fOK2End) return; // // End the pane. char multiusermsg1[] = "<b>Working remotely:</b><p>" "All workspace files are stored on the computer " "that is running the P4Web application ('"; char multiusermsg2[] = "') and not on your local machine.<p>" "To edit files:<ul>" "<li>Open the file for edit (a writable copy of the file will now exist " "on the computer running P4Web)" "<li>Download the file from the P4Web computer to your local machine" "<li>Edit file on your computer</ul><p>" "To submit edits made to file:<ul>" "<li>Upload file back to workspace on the computer running P4Web" "<li>Submit file</ul><p>" "To add files:<ul>" "<li>Upload file to workspace on the computer running P4Web" "<li>Open the file for add" "<li>Submit file</ul>"; p4wHtml htm; htm.endTable(); htm.endCol(); htm.endTRow(); if (!fRequest.isLocalRequest()) { htm.beginTRow(); htm.beginCol(0,0,"100%"); htm.beginTable(0, "100%", "1", "0", "#D1D5DA"); htm.beginTRow(); htm.beginCol(); htm.beginTable(0, "100%", "15", 0, "#F1F5FA"); htm.beginTRow(); htm.beginCol(); htm << "<a name=\"remote\">"; htm << multiusermsg1; htm << fRequest.GetHost().Text(); htm << multiusermsg2 << "</a>"; htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); } htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.comment( "END MULTIUSER 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/p4wMultiUserPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |