/********************************************************************** * * receptionist.h -- a web interface for the gsdl * Copyright (C) 1999 The New Zealand Digital Library Project * * PUT COPYRIGHT NOTICE HERE * * $Id: receptionist.h 159 1999-02-11 23:07:00Z sjboddie $ * *********************************************************************/ #ifndef RECEPTIONIST_H #define RECEPTIONIST_H #include "gsdlconf.h" #include "text_t.h" #include "cgiargs.h" #include "display.h" #include "action.h" #ifndef MACROPRECEDENCE #define MACROPRECEDENCE "style,collection,queryversion,version,language" #endif class receptionist { public: receptionist () {} virtual ~receptionist() {} // this version of set_gsdlhome should be used if the receptionist // is being run for multiple collections ("general" mode). void set_gsdlhome (const text_t &thegsdlhome); text_t get_gsdlhome () {return gsdlhome;} // this version of set_gsdlhome should be used if the receptionist // is being run for a single collection ("collection specific" mode). void set_gsdlhome (const text_t &thegsdlhome, const text_t &thecollection); text_t get_collection () {return collection;} // sets the http address of the images directory. This is used to // speed up the access to the images which are a part of the general // interface. If this is not set the interface will have to get the // images via gwcgi which will be a lot slower (especially if the // browser does not cache the images). void set_httpimg (const text_t &thehttpimg) {httpimg=thehttpimg;} text_t get_httpimg () {return httpimg;} // sets the http address of the gateway cgi program (ie. the program // that contains this receptionist). void set_gwcgi (const text_t &thegwcgi) {gwcgi=thegwcgi;} text_t get_gwcgi () {return gwcgi;} // set_macrofiles defines the macro files which will be read when // the init function is called. void set_macrofiles (const text_tarray &themacrofiles) {macrofiles=themacrofiles;} text_tarray get_macrofiles () {return macrofiles;} // set_saveconf defines what should be included in the compressed // arguments. This string should consist of cgi argument names // seperated by "-". void set_saveconf (const text_t &thesaveconf) {saveconf=thesaveconf;} text_t get_saveconf () {return saveconf;} // add_action makes another action available to the receptionist // the action becomes the property of the receptionist void add_action (action *theaction) {actions.addaction(theaction);} // configure_actions should be called for each line in the // configuration files to configure the actions. The configuration // should take place after all the actions have been added. void configure_actions (const text_t &key, const text_tarray &cfgline); // init should be called after setgsdhome has been called. // It returns true on success and false on failure. If false is // returned getpage should not be called (without producing // meaningless output), instead an error page should be // produced by the calling code. bool init (ostream &logout); // There are two ways to produce a page. You can either call parse_cgi_args, // get_cgihead_info, and produce_content or you can just call parse_cgi_args and // produce_cgi_page (which will be satisfactory in most cases). You might want to call // parse_cgi_args, get_cgihead_info, and produce_content when you want to // interface directly with a web server for which the standard header is inappropriate. // parse_cgi_args parses cgi arguments into an argument class. // This function should be called for each page request. It returns false // if there was a major problem with the cgi arguments. bool parse_cgi_args (const text_t &argstr, cgiargsclass &args, ostream &logout); // produce_cgi_page will call get_cgihead_info and // produce_content in the appropriate way to output a cgi header and // the page content (if needed). If a page could not be created it // will return false bool produce_cgi_page (cgiargsclass &args, ostream &contentout, ostream &logout); // get_cgihead_info determines the cgi header information for // a set of cgi arguments. If response contains location then // response_data contains the redirect address. If reponse // contains content then reponse_data contains the content-type. // Note that images can now be produced by the receptionist. void get_cgihead_info (cgiargsclass &args, response_t &response, text_t &response_data, ostream &logout); // produce the page content bool produce_content (cgiargsclass &args, ostream &contentout, ostream &logout); // returns the compressed argument ("e") corresponding to the argument // list. This can be used to save preferences between sessions. text_t get_compressed_arg (const cgiargsclass &args); // returns a pointer to the action list actionmapclass *get_actionmap_ptr () {return &actions;} protected: text_t gsdlhome; text_t collectdir; // will equal gsdlhome in 'general' mode text_t collection; // will equal "" in 'general' mode text_t httpimg; text_t gwcgi; displayclass disp; text_tarray macrofiles; text_t saveconf; cgiargsinfoclass argsinfo; actionmapclass actions; // will read in all the macro files. If one is not found an // error message will be written to logout and the method will // return false. bool read_macrofiles (ostream &logout); // Will define the main general arguments used by the receptionist. // If an error occurs a message will be written to logout and the // method will return false. virtual bool define_mainargs (ostream &logout); // check_mainargs will check all the main arguments. If a major // error is found it will return false and no cgi page should // be created using the arguments. virtual bool check_mainargs (cgiargsclass &args, ostream &logout); }; #endif