/********************************************************************** * * statusaction.cpp -- * Copyright (C) 1999 The New Zealand Digital Library Project * * PUT COPYRIGHT NOTICE HERE * * $Id: statusaction.cpp 197 1999-03-09 21:00:48Z rjmcnab $ * *********************************************************************/ /* $Log$ Revision 1.7 1999/03/09 21:00:47 rjmcnab Reorganised the statusaction, added more functions to comtypes. Revision 1.6 1999/02/25 21:59:02 rjmcnab Merged sources. Revision 1.5 1999/02/21 22:33:58 rjmcnab Lots of stuff :-) Revision 1.4 1999/02/12 02:40:18 sjboddie Added page action Revision 1.3 1999/02/11 23:07:00 sjboddie extended the status action Revision 1.2 1999/02/11 01:24:06 rjmcnab Fixed a few compiler warnings. Revision 1.1 1999/02/11 01:01:27 rjmcnab Initial revision. */ #include "statusaction.h" #include void statusaction::output_generalinfo (cgiargsclass &/*args*/, displayclass &/*disp*/, outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) { const recptconf &rcinfo = recpt->get_configinfo (); textout << outconvert << "\n"; textout << outconvert << "\n"; textout << outconvert << "\n"; textout << outconvert << "\n"; textout << outconvert << "\n"; textout << outconvert << "\n"; // macrofiles textout << outconvert << "\n"; // saveconf textout << outconvert << "\n"; // arguments cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr (); if (rcargsinfo != NULL) { textout << outconvert << "\n"; } // actions actionmapclass *actions = recpt->get_actionmap_ptr(); if (actions != NULL) { textout << outconvert << "\n"; } // protocols recptprotolistclass *protocols = recpt->get_recptprotolist_ptr (); if (protocols != NULL) { textout << outconvert << "\n"; } // converters convertinfoclass *converters = recpt->get_convertinfo_ptr (); if (converters != NULL) { textout << outconvert << "\n"; } textout << outconvert << "
gsdlhome\"" << rcinfo.gsdlhome << "\"
collection\"" << rcinfo.collection << "\"
collectdir\"" << rcinfo.collectdir << "\"
httpimg\"" << rcinfo.httpimg << "\"
gwcgi\"" << rcinfo.gwcgi << "\"
macrofiles"; text_tarray::const_iterator macrohere = rcinfo.macrofiles.begin (); text_tarray::const_iterator macroend = rcinfo.macrofiles.end (); bool macrofirst = true; while (macrohere != macroend) { if (!macrofirst) textout << outconvert << ", "; macrofirst = false; textout << outconvert << "\"" << *macrohere << "\""; macrohere++; } textout << outconvert << "
saveconf\"" << rcinfo.saveconf << "\"
arguments"; cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin (); cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end (); bool argsinfofirst = true; while (argsinfohere != argsinfoend) { if (!argsinfofirst) textout << outconvert << ", "; argsinfofirst = false; textout << outconvert << "\"" << (*argsinfohere).second.shortname << "\""; argsinfohere++; } textout << outconvert << "
actions"; actionptrmap::iterator actionshere = actions->begin (); actionptrmap::iterator actionsend = actions->end (); bool actionsfirst = true; while (actionshere != actionsend) { if (!actionsfirst) textout << outconvert << ", "; actionsfirst = false; assert ((*actionshere).second.a != NULL); if ((*actionshere).second.a != NULL) { textout << outconvert << "\"" << (*actionshere).second.a->get_action_name() << "\""; } actionshere++; } textout << outconvert << "
protocols"; recptprotolistclass::iterator protohere = protocols->begin (); recptprotolistclass::iterator protoend = protocols->end (); bool protofirst = true; while (protohere != protoend) { if (!protofirst) textout << outconvert << ", "; protofirst = false; if ((*protohere).p != NULL) { textout << outconvert << "\"" << (*protohere).p->get_protocol_name() << "\""; } protohere++; } textout << outconvert << "
converters"; convertinfoclass::iterator converthere = converters->begin (); convertinfoclass::iterator convertend = converters->end (); bool convertfirst = true; while (converthere != convertend) { if (!convertfirst) textout << outconvert << ", "; convertfirst = false; textout << outconvert << "\"" << (*converthere).second.name << "\""; converthere++; } textout << outconvert << "
\n"; } void statusaction::output_argumentinfo (cgiargsclass &args, displayclass &/*disp*/, outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) { cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr (); textout << outconvert << "

Argument information

\n" << ""; // argument information textout << outconvert << "" << "" << "" << "\n"; cgiargsclass::const_iterator argshere = args.begin(); cgiargsclass::const_iterator argsend = args.end(); cgiarginfo *ainfo; while (argshere != argsend) { const text_t &aname = (*argshere).first; textout << outconvert << "\n"; if ((rcargsinfo != NULL) && ((ainfo=rcargsinfo->getarginfo(aname)) != NULL)) { textout << outconvert << "\n"; if (ainfo->multiplechar) textout << outconvert << "\n"; else textout << outconvert << "\n"; textout << outconvert << "\n"; switch (ainfo->defaultstatus) { case cgiarginfo::none: textout << outconvert << "\n"; break; case cgiarginfo::weak: textout << outconvert << "\n"; break; case cgiarginfo::good: textout << outconvert << "\n"; break; case cgiarginfo::config: textout << outconvert << "\n"; break; case cgiarginfo::imperative: textout << outconvert << "\n"; break; } switch (ainfo->savedarginfo) { case cgiarginfo::mustnot: textout << outconvert << "\n"; break; case cgiarginfo::can: textout << outconvert << "\n"; break; case cgiarginfo::must: textout << outconvert << "\n"; break; } } else { textout << outconvert << "\n"; } textout << outconvert << "\n"; argshere ++; } textout << outconvert << "
short namelong namemultiple char?defaultdefault statussaved argscurrent value
" << aname << "" << ainfo->longname << "yesno" << ainfo->argdefault << "noneweakgoodconfigimperativemustnotcanmust\"" << (*argshere).second << "\"
\n"; } void statusaction::output_actioninfo (cgiargsclass &/*args*/, displayclass &/*disp*/, outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) { actionmapclass *actions = recpt->get_actionmap_ptr(); textout << outconvert << "

Action information

\n" << ""; // action information if (actions != NULL) { textout << outconvert << "\n"; actionptrmap::iterator actionshere = actions->begin (); actionptrmap::iterator actionsend = actions->end (); while (actionshere != actionsend) { assert ((*actionshere).second.a != NULL); if ((*actionshere).second.a != NULL) { textout << outconvert << "\n"; } actionshere++; } } textout << outconvert << "
action namecgi arguments
" << (*actionshere).second.a->get_action_name() << ""; cgiargsinfoclass argsinfo = (*actionshere).second.a->getargsinfo(); cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin (); cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end (); bool aifirst = true; while (argsinfohere != argsinfoend) { if (!aifirst) textout << outconvert << ", "; aifirst = false; textout << outconvert << (*argsinfohere).second.shortname; argsinfohere++; } textout << outconvert << "
\n"; } void statusaction::output_protocolinfo (cgiargsclass &/*args*/, displayclass &/*disp*/, outconvertclass &/*outconvert*/, ostream &/*textout*/, ostream &/*logout*/) { } void statusaction::output_collectioninfo (cgiargsclass &/*args*/, displayclass &/*disp*/, outconvertclass &/*outconvert*/, ostream &/*textout*/, ostream &/*logout*/) { } void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &/*disp*/, outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) { ifstream initin (GSDL_GSDLHOME "/etc/initout.txt"); if (initin) { textout << outconvert << "

The initialisation error log, " GSDL_GSDLHOME "/etc/initout.txt, contains the\n"; textout << outconvert << "following information:\n\n"; text_t errorpage = "

\n";
    
    char c;
    initin.get(c);
    while (!initin.eof ()) {
      errorpage.push_back(c);
      initin.get(c);
    }
    
    errorpage += "
\n"; initin.close(); textout << outconvert << errorpage; } else { textout << outconvert << "Couldn't read initialisation error log, " GSDL_GSDLHOME "/etc/initout.txt.\n"; } } void statusaction::output_errorlog (cgiargsclass &/*args*/, displayclass &/*disp*/, outconvertclass &outconvert, ostream &textout, ostream &/*logout*/) { ifstream errin (GSDL_GSDLHOME "/etc/errout.txt"); if (errin) { textout << outconvert << "

The error log, " GSDL_GSDLHOME "/etc/errout.txt, contains the\n"; textout << outconvert << "following information:\n\n"; text_t errorpage = "

\n";

    char c;
    errin.get(c);
    while (!errin.eof ()) {
      errorpage.push_back(c);
      errin.get(c);
    }
    
    errorpage += "
\n"; errin.close(); textout << outconvert << errorpage; } else { textout << outconvert << "Couldn't read error log, " GSDL_GSDLHOME "/etc/errout.txt.\n"; } } statusaction::statusaction () { disabled = true; recpt = NULL; // this action uses cgi variable "a" cgiarginfo arg_ainfo; arg_ainfo.shortname = "a"; arg_ainfo.longname = "action"; arg_ainfo.multiplechar = true; arg_ainfo.defaultstatus = cgiarginfo::weak; arg_ainfo.argdefault = "status"; arg_ainfo.savedarginfo = cgiarginfo::must; argsinfo.addarginfo (NULL, arg_ainfo); } statusaction::~statusaction () { } bool statusaction::check_cgiargs (cgiargsclass &/*args*/, ostream &/*logout*/) { // don't want to check anything yet. return true; } void statusaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response, text_t &response_data, ostream &/*logout*/) { response = content; response_data = "text/html"; } bool statusaction::do_action (cgiargsclass &args, recptproto */*collectproto*/, displayclass &disp, outconvertclass &outconvert, ostream &textout, ostream &logout) { textout << outconvert << "\n"; textout << outconvert << "\n"; textout << outconvert << "Status\n"; textout << outconvert << "\n"; textout << outconvert << "\n"; textout << outconvert << disp << "
\n"; if (disabled) textout << outconvert << "

Status disabled

\n"; else { textout << outconvert << "

General information

\n"; if (recpt == NULL) { textout << outconvert << "The status action does not contain information\n"; textout << outconvert << "about any receptionists. The method set_receptionist\n"; textout << outconvert << "was probably not called from the module which instantiated\n"; textout << outconvert << "this action.\n"; } else { output_generalinfo (args, disp, outconvert, textout, logout); textout << outconvert << "
\n"; output_argumentinfo (args, disp, outconvert, textout, logout); textout << outconvert << "
\n"; output_actioninfo (args, disp, outconvert, textout, logout); textout << outconvert << "
\n"; output_initlog (args, disp, outconvert, textout, logout); textout << outconvert << "
\n"; output_errorlog (args, disp, outconvert, textout, logout); textout << outconvert << "
\n"; } } textout << outconvert << "\n"; textout << outconvert << "\n"; return true; } void statusaction::configure (const text_t &key, const text_tarray &cfgline) { if ((key == "status") && (cfgline.size() == 1) && (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) { disabled = false; } else { // call the parent class to deal with the things which // are not dealt with here action::configure (key, cfgline); } }