source: trunk/gsdl/src/recpt/receptionist.h@ 649

Last change on this file since 649 was 649, checked in by sjboddie, 25 years ago
  • metadata now returns mp rather than array
  • redesigned browsing support (although it's not finished so

won't currently work ;-)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/**********************************************************************
2 *
3 * receptionist.h -- a web interface for the gsdl
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * $Id: receptionist.h 649 1999-10-10 08:14:12Z sjboddie $
25 *
26 *********************************************************************/
27
28
29#ifndef RECEPTIONIST_H
30#define RECEPTIONIST_H
31
32#include "gsdlconf.h"
33#include "text_t.h"
34#include "cgiargs.h"
35#include "display.h"
36#include "action.h"
37#include "browserclass.h"
38#include "recptproto.h"
39#include "converter.h"
40
41// the MACROPRECEDENCE macro is used as a default. override
42// it using something like:
43//
44// macroprecedence c,l
45//
46// in your configuration file
47#ifndef MACROPRECEDENCE
48#define MACROPRECEDENCE "c,l"
49#endif
50
51
52struct recptconf {
53 text_t gsdlhome;
54 text_t collection; // will equal "" in 'general' mode
55 text_t collectdir; // will equal gsdlhome in 'general' mode
56 text_t httpprefix;
57 text_t httpimg;
58 text_t gwcgi;
59 text_tarray macrofiles;
60 text_t saveconf;
61 bool usecookies; // true if we want cookies set
62 bool logcgiargs; // true if we want to log cgi arguments
63
64 text_tmap pageparams;
65 text_t macroprecedence;
66
67 void clear ();
68 recptconf () {clear();}
69};
70
71
72class receptionist {
73protected:
74 recptconf configinfo;
75
76 cgiargsinfoclass argsinfo;
77 actionmapclass actions;
78 browsermapclass browsers;
79 recptprotolistclass protocols;
80 displayclass disp;
81 convertinfoclass converters;
82 ColInfoResponse_t collectinfo;
83
84 // prepare_page sets up page parameters, sets display macros
85 // and opens the page ready for output
86 virtual void prepare_page (action *a, cgiargsclass &args, recptproto *collectproto,
87 outconvertclass &outconvert, ostream &logout);
88
89 virtual void translate_OIDs (cgiargsclass &args, recptproto *collectproto,
90 ostream &logout);
91
92 bool get_cookie (text_t &cookie);
93 bool get_cookie ();
94
95 virtual void define_general_macros (cgiargsclass &args, recptproto *collectproto,
96 outconvertclass &outconvert, ostream &logout);
97
98 bool append_logstr (const text_t &filename, const text_t &logstr,
99 ostream &logout);
100
101public:
102 receptionist ();
103 virtual ~receptionist() {}
104
105 // add_action makes another action available to the receptionist
106 // the action remains the property of the calling code and that
107 // code should destroy the action after the recptionist has been
108 // destroyed.
109 void add_action (action *theaction);
110 actionmapclass *get_actionmap_ptr () {return &actions;}
111
112 // add_browser makes another browser available to the receptionist
113 // the browser remains the property of the calling code and that
114 // code should destroy it after the recptionist has been
115 // destroyed.
116 void add_browser (browserclass *thebrowser);
117 browsermapclass *get_browsermap_ptr () {return &browsers;}
118 void setdefaultbrowser (const text_t &browsername);
119
120 // add_protocol makes another protocol available to the receptionist
121 // without any protocols, no collections will be available. The
122 // protocols remain the property of the calling code.
123 void add_protocol (recptproto *theprotocol) {protocols.addrecptproto(theprotocol);}
124 recptprotolistclass *get_recptprotolist_ptr () {return &protocols;}
125
126 // add_converter makes another converter available to the receptionist.
127 // Converters are needed to display pages using different encodings.
128 // The converters remain the property of the calling code.
129 void add_converter (const text_t &name, inconvertclass *inconverter,
130 rzwsoutconvertclass *outconverter) {
131 converters.add_converter(name, inconverter, outconverter);}
132 convertinfoclass *get_convertinfo_ptr () {return &converters;}
133
134
135 // configure should be called for each line in the
136 // configuration files to configure the receptionist and everything
137 // it contains. The configuration should take place after everything
138 // has been added but before the initialisation.
139 virtual void configure (const text_t &key, const text_tarray &cfgline);
140 virtual void configure (const text_t &key, const text_t &value);
141 const recptconf &get_configinfo () {return configinfo;}
142 cgiargsinfoclass *get_cgiargsinfo_ptr () {return &argsinfo;}
143
144
145 // init should be called after all the actions, protocols, and
146 // converters have been added to the receptionist and after everything
147 // has been configured but before any pages are created.
148 // It returns true on success and false on failure. If false is
149 // returned getpage should not be called (without producing
150 // meaningless output), instead an error page should be
151 // produced by the calling code.
152 virtual bool init (ostream &logout);
153
154 // There are two ways to produce a page. You can either call parse_cgi_args,
155 // get_cgihead_info, and produce_content or you can just call parse_cgi_args and
156 // produce_cgi_page (which will be satisfactory in most cases). You might want to call
157 // parse_cgi_args, get_cgihead_info, and produce_content when you want to
158 // interface directly with a web server for which the standard header is inappropriate.
159
160 // parse_cgi_args parses cgi arguments into an argument class.
161 // This function should be called for each page request. It returns false
162 // if there was a major problem with the cgi arguments.
163 virtual bool parse_cgi_args (const text_t &argstr, cgiargsclass &args, ostream &logout);
164
165 virtual bool log_cgi_args (cgiargsclass &args, ostream &logout);
166
167 // produce_cgi_page will call get_cgihead_info and
168 // produce_content in the appropriate way to output a cgi header and
169 // the page content (if needed). If a page could not be created it
170 // will return false
171 virtual bool produce_cgi_page (cgiargsclass &args, ostream &contentout,
172 ostream &logout);
173
174 // get_cgihead_info determines the cgi header information for
175 // a set of cgi arguments. If response contains location then
176 // response_data contains the redirect address. If reponse
177 // contains content then reponse_data contains the content-type.
178 // Note that images can now be produced by the receptionist.
179 virtual void get_cgihead_info (cgiargsclass &args, response_t &response,
180 text_t &response_data, ostream &logout);
181
182 // produce the page content
183 virtual bool produce_content (cgiargsclass &args, ostream &contentout,
184 ostream &logout);
185
186 // returns the compressed argument ("e") corresponding to the argument
187 // list. This can be used to save preferences between sessions.
188 text_t get_compressed_arg (cgiargsclass &args, ostream &logout);
189
190protected:
191 // will read in all the macro files. If one is not found an
192 // error message will be written to logout and the method will
193 // return false.
194 virtual bool read_macrofiles (ostream &logout);
195
196 // check_mainargs will check all the main arguments. If a major
197 // error is found it will return false and no cgi page should
198 // be created using the arguments.
199 virtual bool check_mainargs (cgiargsclass &args, ostream &logout);
200};
201
202
203#endif
Note: See TracBrowser for help on using the repository browser.