// Copyright 1999 (c) by Perforce Software, Inc. All rights reserved. // // p4wClientsPane: // The clients pane. // ------------------------------------- // Includes // #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wClientsPane.h" // ------------------------------------- // Constructors and destructor. // p4wClientsPane::p4wClientsPane(p4wView & ParentView, p4wRequest & Request) : p4wPane(ParentView, Request), fRowCtr(0), fClientCtr(0), fCfl('\0') { } p4wClientsPane::~p4wClientsPane() { } // ------------------------------------- // Render functions. // void p4wClientsPane::Begin() { // // Begin the pane. p4wHtml htm; p4wURL urlMaker; StrBuf clearIcon; StrBuf grayIcon; // // Construct whitespace spacer & line underneathe title urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); htm.comment( "BEGIN CLIENTS PANE" ); if (fRequest.GetScreenChunks() & SCRN_TITLE) { // Output the title htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << "Clients:"; htm.endSpan(); htm.endCol(); htm.endTRow(); // // Generate line underneath the title htm.beginTRow(); htm.beginCol( "top" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); } fRequest << htm; htm.Clear(); // // Generate the labels filter form if (fRequest.GetScreenChunks() & SCRN_FILTER) doForm(); // // Start the table htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "6", "1", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.beginTable( "0", "100%", "0", "1", "#7F7F7F" ); htm.beginTRow( NULL, NULL, "#FFFFFF" ); htm.beginCol(); htm.beginTable( "0", "100%", "0", "0", "#FFFFFF" ); // // Generate table headings. Generate spacers between columns // just in case the Description field is so large that it // crowds the other fields. htm.beginTRow( NULL, NULL, "#EEEEEE" ); htm.beginColHead(); htm.icon( clearIcon.Text(), "18", "5", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Client"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm << "<script language=javascript>" << crlf; htm << "document.write(\"<img src='/clearpixelIcon?ac=20' height='0' width='2' border='0' alt='' title=''>\")" << crlf; htm << "</script>" << crlf; htm << "<noscript>" << crlf; htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm << "</noscript>" << crlf; htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Owner"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Host"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Updated"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Accessed"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Root"; htm.endColHead(); htm.beginColHead( NULL, NULL, NULL, NULL, "#EEEEEE" ); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Description"; htm.endColHead(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top", NULL, "14", NULL, NULL, NULL, "5" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); fRequest << htm; const StrPtr *cfl = fRequest.GetDynArg( "cfl", HE_None ); if (cfl) { fCfl = *(cfl->Text()); if ((fCfl & 0x02) && !fRequest.isLocalRequest() && !SEC_ALLOW_ALL_CLIENTS) fCfl |= 0x01; } const StrPtr *cnm = fRequest.GetDynArg( "cnm", HE_None ); if (cnm) fCnm << cnm->Text(); const StrPtr *cow = fRequest.GetDynArg( "cow", HE_None ); if (cow) fCow << cow->Text(); const StrPtr *cdu = fRequest.GetDynArg( "cdu", HE_None ); if (cdu) fCdu << cdu->Text(); const StrPtr *cda = fRequest.GetDynArg( "cda", HE_None ); if (cda) fCda << cda->Text(); const StrPtr *cho = fRequest.GetDynArg( "cho", HE_None ); if (cho) { if (*cho == "NULL" || *cho == "\"\"") fCho << "NULL"; else fCho << cho->Text(); } } void p4wClientsPane::Render(StrDict * varList) { // // Build the client URL StrPtr * client = varList->GetVar("client"); StrPtr * owner = varList->GetVar("Owner"); StrPtr * host = varList->GetVar("Host"); if (fCfl) { if (fCfl & 0x01) { if (!owner || strcmp(owner->Text(), fRequest.GetUser().Text())) return; } if (fCfl & 0x02) { if (!fRequest.isLocalRequest() && !SEC_ALLOW_ALL_CLIENTS && !SEC_ALLOW_NOHOST_CLIENTS) { if (!host || strcmp(fRequest.GetHost().Text(), host->Text())) return; } if (host && host->Length() && strcmp(fRequest.GetHost().Text(), host->Text())) return; int lgth; if (!fRequest.isLocalRequest() && (lgth = fRequest.GetMasterRoot()->Length())) { StrPtr * root = varList->GetVar("Root"); #ifdef OS_NT if (!root || strnicmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgth)) #else if (!root || strncmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgth)) #endif return; } } } if (fCnm.Length()) { if (!client || !strstr(client->Text(), fCnm.Text())) return; } if (fCow.Length()) { if (!owner || strcmp(owner->Text(), fCow.Text())) return; } if (fCdu.Length()) { char *p; StrBuf date; date << p4wStrBuf().Expand(StrRef("%Update@*Y/*m/*d%"), *varList, Unicode() ); switch(*(p = fCdu.Text())) { case '_': if (strncmp(date.Text(), p+1, strlen(p+1)) != 0) return; break; case '-': if (fCdu.Length() == 11 ) { if (strcmp(date.Text(), p+1) >= 0) { return; } } else if (strcmp(date.Text(), p+1) > 0) { return; } break; default: if (fCdu.Length() == 10 ) { if (strcmp(date.Text(), p) < 0) { return; } } else if (strncmp(date.Text(), p, strlen(p)) < 0) { return; } break; } } if (fCda.Length()) { char *p; StrBuf date; date << p4wStrBuf().Expand(StrRef("%Access@*Y/*m/*d%"), *varList, Unicode() ); switch(*(p = fCda.Text())) { case '_': if (strncmp(date.Text(), p+1, strlen(p+1)) != 0) return; break; case '-': if (fCda.Length() == 11 ) { if (strcmp(date.Text(), p+1) >= 0) { return; } } else if (strcmp(date.Text(), p+1) > 0) { return; } break; default: if (fCda.Length() == 10 ) { if (strcmp(date.Text(), p) < 0) { return; } } else if (strncmp(date.Text(), p, strlen(p)) < 0) { return; } break; } } if (fCho.Length()) { if (fCho == "NULL") { if (host && host->Length()) return; } else { if (!host || strcmp(host->Text(), fCho.Text())) return; } } // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; StrBuf clientURL; StrBuf ownerURL; StrBuf newBase; // // Output this client. p4wHtml htm(1); p4wURL urlMaker; StrBuf clearIcon; // // Construct the vertical spacing icon urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Build the client url fRequest.UseNewBase( newBase, NULL, "path", NULL ); if( strcmp( client->Text(), fRequest.GetClient().Text() ) != 0 ) { newBase << client; } urlMaker.ConstructURL( clientURL, newBase.Text(), AC_CLIENTVIEW, NULL, fRequest.GetUnicode() ); // // Build the owner url fRequest.UseNewBase( newBase, NULL, "path", NULL ); newBase << owner; urlMaker.ConstructURL( ownerURL, newBase.Text(), AC_USERVIEW, NULL, fRequest.GetUnicode() ); htm.beginTRow( "top", 0, 0, (fRowCtr & 0x01) ? "list_row alt_row" : "list_row" ); htm.beginCol(); htm.endCol(); // // Client name htm.beginCol(0,0,0,0,0,0,0,1); htm.beginLink( clientURL.Text() ); htm.text( p4wStrBuf().EscapeHTML(*client, Unicode()).Text() ); htm.endLink(); int show = 0; if ( !strcmp(client->Text(), fRequest.GetClient().Text()) ) // current client? { show = -1; } else if ( fRequest.isLocalRequest() || SEC_ALLOW_ALL_CLIENTS ) // local or allow all clients? { show = 1 + (1<<2) + (1<<3) + (1<<4); } else if ( owner && !strcmp(owner->Text(), fRequest.GetUser().Text()) ) // current user's client? { if ( host && !strcmp(host->Text(), fRequest.GetHost().Text()) ) // same host? show = 1 + (1<<2) + (1<<3) + (1<<4); else if ( !host || !host->Length() && SEC_ALLOW_NOHOST_CLIENTS ) // empty host allowed? show = 1 + (1<<2) + (1<<3) + (1<<4); if (show) { int lgth = fRequest.GetMasterRoot()->Length(); if (lgth) { StrPtr * root = varList->GetVar("Root"); #ifdef OS_NT if (!root || strnicmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgth)) #else if (!root || strncmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgth)) #endif show = 0; } } } if (show) { htm << crlf; htm << "<script language=javascript>" << crlf; htm << "document.write(\"<span class='muaro'><a href='javascript:showMenu(\\\""; htm << p4wStrBuf().EscapeHTML(*client, Unicode()).Text(); htm << "\\\",\\\"m"; htm << fClientCtr; htm << "\\\",\\\"client\\\","; htm << show; htm << ",\\\"\\\")' id='id_m"; htm << fClientCtr++; htm << "' title ='Menu'>"; htm << " "; htm << "</a></span>"; htm << "\")" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.beginCol(); htm.endCol(); // // Owner htm.beginCol(); htm.beginLink( ownerURL.Text() ); htm.text( p4wStrBuf().EscapeHTML(*owner, Unicode()).Text() ); htm.endLink(); htm.endCol(); htm.beginCol(); htm.endCol(); // // Host htm.beginCol(0,0,0,0,0,0,0,1); htm.text( p4wStrBuf().Expand(StrRef("%Host% "), *varList, Unicode() ).Text() ); htm.endCol(); htm.beginCol(); htm.endCol(); // // Update date htm.beginCol(); htm.text( p4wStrBuf().Expand(StrRef("%Update@*Y/*m/*d% "), *varList, Unicode() ).Text() ); htm.endCol(); htm.beginCol(); htm.endCol(); // // Access date htm.beginCol(); StrPtr *access = varList->GetVar("Access"); if (access && *(access->Text()) != '0') { htm.text( p4wStrBuf().Expand(StrRef("%Access@*Y/*m/*d% "), *varList, Unicode() ).Text() ); } htm.endCol(); htm.beginCol(); htm.endCol(); // // Root htm.beginCol(); htm.text( p4wStrBuf().Expand(StrRef("%Root% "), *varList, Unicode() ).Text() ); htm.endCol(); htm.beginCol(); htm.endCol(); // // Description htm.beginCol(); htm.text( p4wStrBuf().Expand(StrRef("%Description% "), *varList, Unicode() ).Text() ); htm.endCol(); htm.endTRow(); // // Vertical space between rows htm.beginTRow( 0, 0, 0, (fRowCtr++ & 0x01) ? "alt_row b" : "b" ); htm.beginCol( 0, 0, "100%" ); htm.icon( clearIcon.Text(), "3", "1", "", 1 ); htm.endCol(); htm.endTRow(); fRequest << htm; } void p4wClientsPane::End() { // // End the "Clients" list. p4wHtml htm; if( !fRowCtr ) { p4wURL urlMaker; StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); htm.beginTRow(); htm.beginCol(); htm.endCol(); htm.beginCol( NULL, NULL, "4" ); htm.text( "No clients found." ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "5", "0", "", 1 ); htm.endCol(); htm.endTRow(); } // // End the pane. htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.comment( "END CLIENTS PANE" ); fRequest << htm; } void p4wClientsPane::doForm() { // // Generate the clients filter form p4wHtml htm; p4wURL urlMaker; StrBuf actionURL; StrBuf path; StrBuf clearIcon; char *p; const StrPtr *cfl = fRequest.GetDynArg( "cfl", HE_Page ); const StrPtr *cnm = fRequest.GetDynArg( "cnm", HE_Page ); const StrPtr *cow = fRequest.GetDynArg( "cow", HE_Page ); const StrPtr *cdu = fRequest.GetDynArg( "cdu", HE_Page ); const StrPtr *cda = fRequest.GetDynArg( "cda", HE_Page ); const StrPtr *cho = fRequest.GetDynArg( "cho", HE_Page ); // // Used to generate some whitespace urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Some browsers will truncate the path from the BASE // if the path does not end in a forward slash. So if // we're in workspace mode, use the full path as a precaution. if( fRequest.GetViewMode() == VM_WORKSPACE ) fRequest.UseNewBase( path, NULL, "path", fRequest.GetPath().Text() ); else path << fRequest.GetURL(); fRequest.ConstructSafeURL( actionURL, path.Text(), AC_CLIENTSPROCESSOR, NULL ); htm.beginTRow(); htm.beginCol(); fRequest << htm; htm.Clear(); StrBuf filtermsg; doFilterMessage(&filtermsg); fRequest.doShowHideBlock(SH_CLIENTS, "client filter", "Client Filter", filtermsg.Text()); htm.endCol(); htm.endTRow(); // // Start a DIV for showing/hiding the filter htm.beginTRow(); htm.beginCol(); htm << "<script language=javascript>" << crlf; htm << "document.write(\"<div id='showhideBlock'>\")" << crlf; htm << "</script>" << crlf; htm.beginTable(0, "100%", "0", "0"); // // Start the tables with the form htm.beginTRow(); htm.beginCol(); if( fRequest.GetJavascriptMode() != 2) htm.icon( clearIcon.Text(), "5", "1", "", 1 ); htm.beginForm( actionURL.Text() ); htm.beginTable( "0", "100%", "2", "0", "#FFFFFF" ); // // Top row of filter htm.beginTRow(); htm.beginCol(0,0,0,"100%"); htm.icon( clearIcon.Text(), "1", "14", "", 1 ); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.label("Client name contains:", "cnm"); htm.endCol(); htm.beginCol(); htm.textField("cnm", cnm && cnm->Length() ? cnm->Text() : 0, 0, "cnm"); htm.endCol(); htm.beginCol(); htm.icon( clearIcon.Text(), "1", "50", "", 1 ); htm.endCol(); htm.beginCol(); htm.text("Updated:"); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.radio("Updated", "on", cdu && *(cdu->Text()) == '_', 0, "uon"); htm.label("on ", "uon"); htm.radio("Updated", "before", cdu && *(cdu->Text()) == '-', 0, "ub4"); htm.label("before ", "ub4"); htm.radio("Updated", "after", !cdu || (*(cdu->Text()) != '_' && *(cdu->Text()) != '-'), 0, "uaf"); htm.label("after ", "uaf"); htm.endCol(); htm.beginCol(); if (cdu && cdu->Length()) { p = cdu->Text(); if (*p == '-' || *p == '_') p++; } else p = NULL; htm.textField("cdu", p ? p : 0, 0, "cdu", 0, "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')"); if (!p) { htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('cdu');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.beginCol(0,0,0,0,0,"100%"); htm.endCol(); htm.endTRow(); // // 2nd row of filter htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,1); htm.label("Owner:", "cow"); htm.endCol(); htm.beginCol(); if (cfl && (cfl->Atoi() & 1)) htm.textField("cow", p4wStrBuf().EscapeHTML(fRequest.GetUser(), Unicode()).Text(), 0, "cow"); else htm.textField("cow", cow && cow->Length() ? cow->Text() : 0, 0, "cow"); htm.endCol(); htm.beginCol(); htm.endCol(); htm.beginCol(); htm.text("Accessed:"); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.radio("Accessed", "on", cda && *(cda->Text()) == '_', 0, "aon"); htm.label("on ", "aon"); htm.radio("Accessed", "before", cda && *(cda->Text()) == '-', 0, "ab4"); htm.label("before ", "ab4"); htm.radio("Accessed", "after", !cda || (*(cda->Text()) != '_' && *(cda->Text()) != '-'), 0, "aft"); htm.label("after ", "aft"); htm.endCol(); htm.beginCol(); if (cda && cda->Length()) { p = cda->Text(); if (*p == '-' || *p == '_') p++; } else p = NULL; htm.textField("cda", p ? p : 0, 0, "cda", 0, "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')"); if (!p) { htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('cda');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.endTRow(); // // Host field htm.beginTRow(); htm.beginCol(0,0,0,0,0,0,0,1); htm.label( "Host:", "cho" ); htm.endCol(); htm.beginCol(); htm.textField("cho", cho && cho->Length() ? cho->Text() : 0, 0, "cho"); htm.endCol(); htm.beginCol(); htm.endCol(); // // Show mine checkbox htm.beginCol(0,0,"100%",0,0,0,0,1); if( cfl && (cfl->Atoi() & 2) ) htm.checkbox( "canuse", "checked", 1 ); else htm.checkbox( "canuse", "checked" ); htm.label( "Exclude clients not available for use", "canuse" ); htm.endCol(); htm.endTRow(); // // Filter button htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "5", "1", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0,0,"100%",0,0,0,0,1); htm.button( "Show", "Filter" ); // // Clear button htm.button( "Clear", "Reset Defaults" ); htm.endCol(); htm.endTRow(); htm.endTable(); StrBuf grayIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); htm.icon( clearIcon.Text(), "10", "100%", "", 1, "0", "0" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); htm.endCol(); htm.endTRow(); htm.endTable(); htm << "<script language=javascript>" << crlf; htm << "document.write(\"</div>\")" << crlf; htm << "</script>" << crlf; fRequest << htm; } void p4wClientsPane::doFilterMessage(StrBuf *msg) { const StrPtr *cfl = fRequest.GetDynArg( "cfl", HE_Page ); const StrPtr *cnm = fRequest.GetDynArg( "cnm", HE_Page ); const StrPtr *cow = fRequest.GetDynArg( "cow", HE_Page ); const StrPtr *cdu = fRequest.GetDynArg( "cdu", HE_Page ); const StrPtr *cda = fRequest.GetDynArg( "cda", HE_Page ); const StrPtr *cho = fRequest.GetDynArg( "cho", HE_Page ); if (cnm) *msg << "(Name contains: "" << cnm->Text() << """; char *p = NULL; if (cfl && (cfl->Atoi() & 1)) p = p4wStrBuf().EscapeHTML( fRequest.GetUser(), Unicode() ).Text(); else if (cow) p = cow->Text(); if (p) { if (*(msg->Text())) *msg << "; Owner: "; else *msg << "(Owner: "; *msg << """ << p << """; } if (cho) { if (*(msg->Text())) *msg << "; Host: "; else *msg << "(Host: "; *msg << """ << cho->Text() << """; } if (cdu) { if (*(msg->Text())) *msg << "; Updated "; else *msg << "(Updated "; switch(*(cdu->Text())) { case '-': if (cdu->Length() < 11) *msg << "on or"; *msg << " before"; p = cdu->Text()+1; break; case '_': if (cdu->Length() < 11) *msg << "in"; else *msg << "on"; p = cdu->Text()+1; break; default: if (cdu->Length() < 10) *msg << "in or"; *msg << " after"; p = cdu->Text(); break; } *msg << ": " << p; } if (cda) { if (*(msg->Text())) *msg << "; Accessed "; else *msg << "(Accessed "; switch(*(cda->Text())) { case '-': if (cda->Length() < 11) *msg << "on or"; *msg << " before"; p = cda->Text()+1; break; case '_': if (cda->Length() < 11) *msg << "in"; else *msg << "on"; p = cda->Text()+1; break; default: if (cda->Length() < 10) *msg << "in or"; *msg << " after"; p = cda->Text(); break; } *msg << ": " << p; } if (cfl && (cfl->Atoi() & 2)) { if (*(msg->Text())) *msg << "; "; else *msg << "("; *msg << "Exclude unavailable clients"; } if (*(msg->Text())) *msg << ")"; }
# | 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/p4wClientsPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |