source: branches/corba/gsdl/src/recpt/receptionist.h@ 1074

Last change on this file since 1074 was 1067, checked in by cs025, 24 years ago

Corba first commit

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 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 1067 2000-04-04 15:02:39Z cs025 $
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#include "cfgread.h"
41#include "cnfgable.h"
42
43// the MACROPRECEDENCE macro is used as a default. override
44// it using something like:
45//
46// macroprecedence c,l
47//
48// in your configuration file
49#ifndef MACROPRECEDENCE
50#define MACROPRECEDENCE "c,l"
51#endif
52
53
54struct recptconf {
55 text_t gsdlhome;
56 text_t gdbmhome; // will equal gsdlhome if not set
57 text_t collection; // will equal "" in 'general' mode
58 text_t collectdir; // will equal gsdlhome in 'general' mode
59 colinfo_tmap collectinfo;
60 text_t httpprefix;
61 text_t httpimg;
62 text_t gwcgi;
63 text_tset macrofiles;
64 text_t saveconf;
65 bool usecookies; // true if we want cookies set
66 bool logcgiargs; // true if we want to log cgi arguments
67
68 text_tmap pageparams;
69 text_t macroprecedence;
70
71 void clear ();
72 recptconf () {clear();}
73};
74
75
76class receptionist : public configurable {
77protected:
78 recptconf configinfo;
79
80 cgiargsinfoclass argsinfo;
81 actionmapclass actions;
82 browsermapclass browsers;
83 recptprotolistclass protocols;
84 displayclass disp;
85 convertinfoclass converters;
86 ColInfoResponse_t collectinfo;
87
88 // prepare_page sets up page parameters, sets display macros
89 // and opens the page ready for output
90 virtual void prepare_page (action *a, cgiargsclass &args,
91 outconvertclass &outconvert,
92 ostream &logout);
93
94 virtual void translate_OIDs (cgiargsclass &args, recptproto *collectproto,
95 ostream &logout);
96
97 bool get_cookie (text_t &cookie, text_tmap &fcgienv);
98 bool get_cookie (text_tmap &fcgienv);
99
100 virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert,
101 ostream &logout);
102
103 bool append_logstr (const text_t &filename, const text_t &logstr,
104 ostream &logout);
105
106public:
107 receptionist ();
108 virtual ~receptionist() {}
109
110 // add_action makes another action available to the receptionist
111 // the action remains the property of the calling code and that
112 // code should destroy the action after the recptionist has been
113 // destroyed.
114 void add_action (action *theaction);
115 actionmapclass *get_actionmap_ptr () {return &actions;}
116
117 // add_browser makes another browser available to the receptionist
118 // the browser remains the property of the calling code and that
119 // code should destroy it after the recptionist has been
120 // destroyed.
121 void add_browser (browserclass *thebrowser);
122 browsermapclass *get_browsermap_ptr () {return &browsers;}
123 void setdefaultbrowser (const text_t &browsername);
124
125 // add_protocol makes another protocol available to the receptionist
126 // without any protocols, no collections will be available. The
127 // protocols remain the property of the calling code.
128 void add_protocol (recptproto *theprotocol) {protocols.addrecptproto(theprotocol);}
129 recptprotolistclass *get_recptprotolist_ptr () {return &protocols;}
130
131 // add_converter makes another converter available to the receptionist.
132 // Converters are needed to display pages using different encodings.
133 // The converters remain the property of the calling code.
134 void add_converter (const text_t &name, inconvertclass *inconverter,
135 rzwsoutconvertclass *outconverter) {
136 converters.add_converter(name, inconverter, outconverter);}
137 convertinfoclass *get_convertinfo_ptr () {return &converters;}
138
139
140 // configure should be called for each line in the
141 // configuration files to configure the receptionist and everything
142 // it contains. The configuration should take place after everything
143 // has been added but before the initialisation.
144 void configure (const text_t &key, const text_tarray &cfgline);
145 virtual void configure (const text_t &key, const text_t &value);
146 const recptconf &get_configinfo () {return configinfo;}
147 cgiargsinfoclass *get_cgiargsinfo_ptr () {return &argsinfo;}
148
149
150 // init should be called after all the actions, protocols, and
151 // converters have been added to the receptionist and after everything
152 // has been configured but before any pages are created.
153 // It returns true on success and false on failure. If false is
154 // returned getpage should not be called (without producing
155 // meaningless output), instead an error page should be
156 // produced by the calling code.
157 virtual bool init (ostream &logout);
158
159 // There are two ways to produce a page. You can either call parse_cgi_args,
160 // get_cgihead_info, and produce_content or you can just call parse_cgi_args and
161 // produce_cgi_page (which will be satisfactory in most cases). You might want to call
162 // parse_cgi_args, get_cgihead_info, and produce_content when you want to
163 // interface directly with a web server for which the standard header is inappropriate.
164
165 // parse_cgi_args parses cgi arguments into an argument class.
166 // This function should be called for each page request. It returns false
167 // if there was a major problem with the cgi arguments.
168 virtual bool parse_cgi_args (const text_t &argstr, cgiargsclass &args,
169 ostream &logout, text_tmap &fcgienv);
170
171 virtual bool log_cgi_args (cgiargsclass &args, ostream &logout, text_tmap &fcgienv);
172
173 text_t expandmacros (const text_t &astring, cgiargsclass &args,
174 ostream &logout);
175
176 // produce_cgi_page will call get_cgihead_info and
177 // produce_content in the appropriate way to output a cgi header and
178 // the page content (if needed). If a page could not be created it
179 // will return false
180 virtual bool produce_cgi_page (cgiargsclass &args, ostream &contentout,
181 ostream &logout, text_tmap &fcgienv);
182
183 // get_cgihead_info determines the cgi header information for
184 // a set of cgi arguments. If response contains location then
185 // response_data contains the redirect address. If reponse
186 // contains content then reponse_data contains the content-type.
187 // Note that images can now be produced by the receptionist.
188 virtual void get_cgihead_info (cgiargsclass &args, response_t &response,
189 text_t &response_data, ostream &logout,
190 text_tmap &fcgienv);
191
192 // produce the page content
193 virtual bool produce_content (cgiargsclass &args, ostream &contentout,
194 ostream &logout);
195
196 // returns the compressed argument ("e") corresponding to the argument
197 // list. This can be used to save preferences between sessions.
198 text_t get_compressed_arg (cgiargsclass &args, ostream &logout);
199
200protected:
201 // will read in all the macro files. If one is not found an
202 // error message will be written to logout and the method will
203 // return false.
204 virtual bool read_macrofiles (ostream &logout);
205
206 // check_mainargs will check all the main arguments. If a major
207 // error is found it will return false and no cgi page should
208 // be created using the arguments.
209 virtual bool check_mainargs (cgiargsclass &args, ostream &logout);
210};
211
212
213#endif
Note: See TracBrowser for help on using the repository browser.