source: trunk/gsdl/src/recpt/statusaction.cpp@ 357

Last change on this file since 357 was 261, checked in by sjboddie, 25 years ago

added argsinfo to the call to check_cgiargs to make it easy to set
args to their default if they're found to be screwed up

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 25.1 KB
Line 
1/**********************************************************************
2 *
3 * statusaction.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: statusaction.cpp 261 1999-06-08 04:29:42Z sjboddie $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.13 1999/06/08 04:29:39 sjboddie
15 added argsinfo to the call to check_cgiargs to make it easy to set
16 args to their default if they're found to be screwed up
17
18 Revision 1.12 1999/04/06 22:20:35 rjmcnab
19 Got browsefilter working.
20
21 Revision 1.11 1999/03/31 23:44:49 rjmcnab
22 Altered the protocol so that the metadata is part of the filter.
23
24 Revision 1.10 1999/03/16 04:47:03 rjmcnab
25 Changed the list of arguments on the argument page to be the info list
26 not the current args list (there are some arguments which don't have
27 a default so they never make it onto the args list).
28
29 Revision 1.9 1999/03/11 01:26:02 rjmcnab
30 Fixed a few small formatting things.
31
32 Revision 1.8 1999/03/11 00:12:30 rjmcnab
33 Started using status.dm to handle the bulky text. Made the status
34 action use frames and added some more information.
35
36 Revision 1.7 1999/03/09 21:00:47 rjmcnab
37 Reorganised the statusaction, added more functions to comtypes.
38
39 Revision 1.6 1999/02/25 21:59:02 rjmcnab
40
41 Merged sources.
42
43 Revision 1.5 1999/02/21 22:33:58 rjmcnab
44
45 Lots of stuff :-)
46
47 Revision 1.4 1999/02/12 02:40:18 sjboddie
48
49 Added page action
50
51 Revision 1.3 1999/02/11 23:07:00 sjboddie
52
53 extended the status action
54
55 Revision 1.2 1999/02/11 01:24:06 rjmcnab
56
57 Fixed a few compiler warnings.
58
59 Revision 1.1 1999/02/11 01:01:27 rjmcnab
60
61 Initial revision.
62
63 */
64
65
66#include "statusaction.h"
67#include <assert.h>
68
69
70void statusaction::output_frameset (cgiargsclass &/*args*/, displayclass &disp,
71 outconvertclass &outconvert,
72 ostream &textout, ostream &/*logout*/) {
73 textout << outconvert << disp << "_status:frameset_\n";
74}
75
76void statusaction::output_select (cgiargsclass &/*args*/, displayclass &disp,
77 outconvertclass &outconvert,
78 ostream &textout, ostream &/*logout*/) {
79 textout << outconvert << disp << "_status:header_(selector)\n"
80 "_status:select_\n"
81 "_status:footer_\n";
82}
83
84void statusaction::output_generalinfo (cgiargsclass &/*args*/, displayclass &disp,
85 outconvertclass &outconvert,
86 ostream &textout, ostream &/*logout*/) {
87 if (recpt == NULL) return;
88 const recptconf &rcinfo = recpt->get_configinfo ();
89
90 textout << outconvert << disp << "_status:header_(General Information)\n";
91 textout << outconvert
92 << "<h2>General information</h2>\n"
93 << "<table>\n"
94 << "<tr valign=top><th>gsdlhome</th><td>\"" << rcinfo.gsdlhome
95 << "\"</td></tr>\n"
96 << "<tr valign=top><th>collection</th><td>\"" << rcinfo.collection
97 << "\"</td></tr>\n"
98 << "<tr valign=top><th>collectdir</th><td>\"" << rcinfo.collectdir
99 << "\"</td></tr>\n"
100 << "<tr valign=top><th>httpimg</th><td>\"" << rcinfo.httpimg
101 << "\"</td></tr>\n"
102 << "<tr valign=top><th>gwcgi</th><td>\"" << rcinfo.gwcgi
103 << "\"</td></tr>\n";
104
105 // macrofiles
106 textout << outconvert << "<tr valign=top><th>macrofiles</th><td>";
107 text_tarray::const_iterator macrohere = rcinfo.macrofiles.begin ();
108 text_tarray::const_iterator macroend = rcinfo.macrofiles.end ();
109 bool macrofirst = true;
110 while (macrohere != macroend) {
111 if (!macrofirst) textout << outconvert << ", ";
112 macrofirst = false;
113 textout << outconvert << "\"" << *macrohere << "\"";
114 macrohere++;
115 }
116 textout << outconvert << "</td></tr>\n";
117
118 // saveconf
119 textout << outconvert << "<tr valign=top><th>saveconf</th><td>\"" << rcinfo.saveconf
120 << "\"</td></tr>\n";
121
122 // arguments
123 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
124 if (rcargsinfo != NULL) {
125 textout << outconvert << "<tr valign=top><th>arguments</th><td>";
126
127 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin ();
128 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end ();
129 bool argsinfofirst = true;
130 while (argsinfohere != argsinfoend) {
131 if (!argsinfofirst) textout << outconvert << ", ";
132 argsinfofirst = false;
133 textout << outconvert << "\"" << (*argsinfohere).second.shortname << "\"";
134 argsinfohere++;
135 }
136
137 textout << outconvert << "</td></tr>\n";
138 }
139
140 // actions
141 actionmapclass *actions = recpt->get_actionmap_ptr();
142 if (actions != NULL) {
143 textout << outconvert << "<tr valign=top><th>actions</th><td>";
144
145 actionptrmap::iterator actionshere = actions->begin ();
146 actionptrmap::iterator actionsend = actions->end ();
147 bool actionsfirst = true;
148 while (actionshere != actionsend) {
149 if (!actionsfirst) textout << outconvert << ", ";
150 actionsfirst = false;
151 assert ((*actionshere).second.a != NULL);
152 if ((*actionshere).second.a != NULL) {
153 textout << outconvert << "\"" << (*actionshere).second.a->get_action_name() << "\"";
154 }
155 actionshere++;
156 }
157
158 textout << outconvert << "</td></tr>\n";
159 }
160
161 // protocols
162 recptprotolistclass *protocols = recpt->get_recptprotolist_ptr ();
163 if (protocols != NULL) {
164 textout << outconvert << "<tr valign=top><th>protocols</th><td>";
165
166 recptprotolistclass::iterator protohere = protocols->begin ();
167 recptprotolistclass::iterator protoend = protocols->end ();
168 bool protofirst = true;
169 while (protohere != protoend) {
170 if (!protofirst) textout << outconvert << ", ";
171 protofirst = false;
172 if ((*protohere).p != NULL) {
173 textout << outconvert << "\"" << (*protohere).p->get_protocol_name() << "\"";
174 }
175 protohere++;
176 }
177
178 textout << outconvert << "</td></tr>\n";
179 }
180
181 // converters
182 convertinfoclass *converters = recpt->get_convertinfo_ptr ();
183 if (converters != NULL) {
184 textout << outconvert << "<tr valign=top><th>converters</th><td>";
185
186 convertinfoclass::iterator converthere = converters->begin ();
187 convertinfoclass::iterator convertend = converters->end ();
188 bool convertfirst = true;
189 while (converthere != convertend) {
190 if (!convertfirst) textout << outconvert << ", ";
191 convertfirst = false;
192 textout << outconvert << "\"" << (*converthere).second.name << "\"";
193 converthere++;
194 }
195
196 textout << outconvert << "</td></tr>\n";
197 }
198
199 textout << outconvert << disp << "</table>\n_status:footer_\n";
200}
201
202void statusaction::output_argumentinfo (cgiargsclass &args, displayclass &disp,
203 outconvertclass &outconvert,
204 ostream &textout, ostream &/*logout*/) {
205 if (recpt == NULL) return;
206 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr ();
207 if (rcargsinfo == NULL) return;
208
209 textout << outconvert << disp << "_status:header_(Argument Information)\n";
210 textout << outconvert
211 << "<h2>Argument information</h2>\n"
212 << "<table>";
213
214 // argument information
215 textout << outconvert << "<tr valign=top><th>short name</th><th>long name</th>"
216 << "<th>multiple char?</th>"
217 << "<th>default</th><th>default status</th><th>saved args</th>"
218 << "<th>current value</th></tr>\n";
219
220
221 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin();
222 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end();
223 text_t *arg_value;
224 while (argsinfohere != argsinfoend) {
225 const cgiarginfo &ainfo = (*argsinfohere).second;
226 textout << outconvert
227 << "<tr valign=top><td>" << ainfo.shortname << "</td>\n";
228
229 textout << outconvert << "<td>" << ainfo.longname << "</td>\n";
230 if (ainfo.multiplechar) textout << outconvert << "<td>yes</td>\n";
231 else textout << outconvert << "<td>no</td>\n";
232 textout << outconvert << "<td>" << ainfo.argdefault << "</td>\n";
233 switch (ainfo.defaultstatus) {
234 case cgiarginfo::none: textout << outconvert << "<td>none</td>\n"; break;
235 case cgiarginfo::weak: textout << outconvert << "<td>weak</td>\n"; break;
236 case cgiarginfo::good: textout << outconvert << "<td>good</td>\n"; break;
237 case cgiarginfo::config: textout << outconvert << "<td>config</td>\n"; break;
238 case cgiarginfo::imperative: textout << outconvert << "<td>imperative</td>\n"; break;
239 }
240 switch (ainfo.savedarginfo) {
241 case cgiarginfo::mustnot: textout << outconvert << "<td>mustnot</td>\n"; break;
242 case cgiarginfo::can: textout << outconvert << "<td>can</td>\n"; break;
243 case cgiarginfo::must: textout << outconvert << "<td>must</td>\n"; break;
244 }
245
246 arg_value = args.getarg (ainfo.shortname);
247 if (arg_value == NULL) textout << outconvert << "<td></td></tr>\n";
248 else textout << outconvert << "<td>\"" << *arg_value << "\"</td></tr>\n";
249
250 argsinfohere ++;
251 }
252
253 textout << outconvert << disp << "</table>\n_status:footer_\n";
254}
255
256void statusaction::output_actioninfo (cgiargsclass &/*args*/, displayclass &disp,
257 outconvertclass &outconvert,
258 ostream &textout, ostream &/*logout*/) {
259 if (recpt == NULL) return;
260 actionmapclass *actions = recpt->get_actionmap_ptr();
261
262 textout << outconvert << disp << "_status:header_(Action Information)\n";
263 textout << outconvert
264 << "<h2>Action information</h2>\n"
265 << "<table>";
266
267 // action information
268 if (actions != NULL) {
269 textout << outconvert
270 << "<tr><th>action name</th><th>cgi arguments</th></tr>\n";
271
272 actionptrmap::iterator actionshere = actions->begin ();
273 actionptrmap::iterator actionsend = actions->end ();
274 while (actionshere != actionsend) {
275 assert ((*actionshere).second.a != NULL);
276 if ((*actionshere).second.a != NULL) {
277 textout << outconvert
278 << "<tr><td>" << (*actionshere).second.a->get_action_name()
279 << "</td><td>";
280
281 cgiargsinfoclass argsinfo = (*actionshere).second.a->getargsinfo();
282 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin ();
283 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end ();
284 bool aifirst = true;
285 while (argsinfohere != argsinfoend) {
286 if (!aifirst) textout << outconvert << ", ";
287 aifirst = false;
288 textout << outconvert << (*argsinfohere).second.shortname;
289 argsinfohere++;
290 }
291
292 textout << outconvert << "</td></tr>\n";
293 }
294 actionshere++;
295 }
296 }
297
298 textout << outconvert << disp << "</table>\n_status:footer_\n";
299}
300
301void statusaction::output_protocolinfo (cgiargsclass &/*args*/, displayclass &disp,
302 outconvertclass &outconvert,
303 ostream &textout, ostream &logout) {
304 if (recpt == NULL) return;
305 const recptconf &rcinfo = recpt->get_configinfo ();
306 bool colspecific = !rcinfo.collection.empty();
307 bool unreachablecol = false;
308
309 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
310 if (rprotolist == NULL) return;
311
312 textout << outconvert << disp << "_status:header_(Protocol Information)\n";
313 textout << outconvert
314 << "<h2>Protocol information</h2>\n"
315 << "<table>\n"
316 << "<tr><th>protocol</th><th>collections</th></tr>\n";
317
318 text_t protoname;
319 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
320 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
321 while (rprotolist_here != rprotolist_end) {
322 if ((*rprotolist_here).p != NULL) {
323 protoname = (*rprotolist_here).p->get_protocol_name();
324 textout << outconvert
325 << "<tr><td>"
326 << protoname
327 << "</td><td>";
328
329 text_tarray collist;
330 comerror_t err;
331 (*rprotolist_here).p->get_collection_list (collist, err, logout);
332 if (err == noError) {
333 text_tarray::iterator collist_here = collist.begin();
334 text_tarray::iterator collist_end = collist.end();
335 bool first = true;
336 while (collist_here != collist_end) {
337 if (!first) textout << outconvert << ", ";
338 first = false;
339
340 if (colspecific && *collist_here != rcinfo.collection) {
341 unreachablecol = true;
342 textout << outconvert << "\"" << *collist_here << "\"";
343 } else {
344 textout << outconvert << disp
345 << "\"<a href=\"_gwcgi_?a=status&sp=collectioninfo&pr="
346 << protoname
347 << "&c="
348 << *collist_here
349 << "\">"
350 << *collist_here
351 << "</a>\"";
352 }
353
354 collist_here++;
355 }
356
357 } else {
358 textout << outconvert << "Error (" << get_comerror_string (err)
359 << ") while getting collect list\n";
360 }
361
362 textout << outconvert
363 << "</td></tr>\n";
364 }
365
366 rprotolist_here++;
367 }
368
369 textout << outconvert << "</table>\n";
370 if (unreachablecol) {
371 textout << outconvert
372 << "<b>Warning:</b> the receptionist is running in collection specific\n"
373 << "mode making some of the collections unreachable.\n";
374 }
375 textout << outconvert << disp << "_status:footer_\n";
376}
377
378void statusaction::output_collectioninfo (cgiargsclass &args, displayclass &disp,
379 outconvertclass &outconvert,
380 ostream &textout, ostream &logout) {
381 if (recpt == NULL) return;
382
383 textout << outconvert << disp << "_status:header_(Collection info)\n";
384 textout << outconvert << "<h2>Collection info</h2>\n";
385
386 // get the list of protocols
387 recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
388 if (rprotolist == NULL) return;
389
390 // look for the desired protocol
391 text_t &arg_pr = args["pr"];
392 text_t &arg_c = args["c"];
393 recptproto *rproto;
394 recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
395 recptprotolistclass::iterator rprotolist_end = rprotolist->end();
396 while (rprotolist_here != rprotolist_end) {
397 rproto = (*rprotolist_here).p;
398 if (rproto != NULL && rproto->get_protocol_name() == arg_pr) {
399 // see if the protocol has the collection
400 bool hascollection;
401 comerror_t err;
402 rproto->has_collection (arg_c, hascollection, err, logout);
403 if (err == noError && hascollection) break;
404 }
405 rprotolist_here++;
406 }
407
408 if (rprotolist_here == rprotolist_end) {
409 textout << outconvert << "Protocol \"" << arg_pr << "\" with collection \""
410 << arg_c << "\" was not found\n";
411
412 } else {
413 ColInfoResponse_t collectinfo;
414 comerror_t err;
415
416 rproto->get_collectinfo (arg_c, collectinfo, err, logout);
417 if (err == noError) {
418 textout << outconvert << "<table>\n"
419 << "<tr><th>collection name</th><td>\""
420 << collectinfo.shortInfo.name
421 << "\"</td></tr>\n"
422
423 << "<tr><th>host</th><td>\""
424 << collectinfo.shortInfo.host
425 << "\"</td></tr>\n"
426
427 << "<tr><th>port</th><td>\""
428 << collectinfo.shortInfo.port
429 << "\"</td></tr>\n"
430
431 << "<tr><th>is public?</th><td>";
432 if (collectinfo.isPublic) textout << outconvert << "true";
433 else textout << outconvert << "false";
434 textout << outconvert
435 << "</td></tr>\n"
436
437 << "<tr><th>is beta?</th><td>";
438 if (collectinfo.isBeta) textout << outconvert << "true";
439 else textout << outconvert << "false";
440 textout << outconvert
441 << "</td></tr>\n"
442
443 << "<tr><th>build date</th><td>\""
444 << collectinfo.buildDate
445 << "\"</td></tr>\n"
446
447 << "<tr><th>interface languages</th><td>";
448 text_tarray::iterator languages_here = collectinfo.languages.begin();
449 text_tarray::iterator languages_end = collectinfo.languages.end();
450 bool languages_first = true;
451 while (languages_here != languages_end) {
452 if (!languages_first) textout << outconvert << ", ";
453 languages_first = false;
454 textout << outconvert << "\"" << *languages_here << "\"";
455 languages_here++;
456 }
457 textout << outconvert
458 << "</td></tr>\n"
459
460 << "<tr><th>number of documents</th><td>\""
461 << collectinfo.numDocs
462 << "\"</td></tr>\n"
463
464 << "<tr><th>number of words</th><td>\""
465 << collectinfo.numWords
466 << "\"</td></tr>\n"
467
468 << "<tr><th>number of bytes</th><td>\""
469 << collectinfo.numBytes
470 << "\"</td></tr>\n"
471
472 << "</table>";
473
474 } else {
475 textout << outconvert << "Error (" << get_comerror_string (err)
476 << ") while getting collect information\n";
477 }
478
479
480 InfoFiltersResponse_t filterinfo;
481 InfoFilterOptionsRequest_t filteroptions_request;
482 InfoFilterOptionsResponse_t filteroptions;
483 rproto->get_filterinfo (arg_c, filterinfo, err, logout);
484 if (err == noError) {
485 text_tset::iterator filternames_here = filterinfo.filterNames.begin();
486 text_tset::iterator filternames_end = filterinfo.filterNames.end();
487 while (filternames_here != filternames_end) {
488 textout << outconvert
489 << "<hr>\n"
490 << "<h3>Filter options for \"" << (*filternames_here) << "\"</h3>\n"
491 << "<table>\n"
492 << "<tr><th>option name</th><th>type</th><th>repeatable</th>"
493 << "<th>default value</th><th>valid values</th></tr>\n";
494
495 filteroptions_request.clear();
496 filteroptions_request.filterName = *filternames_here;
497 rproto->get_filteroptions (arg_c, filteroptions_request,
498 filteroptions, err, logout);
499 if (err == noError) {
500 FilterOption_tmap::iterator filteropt_here =
501 filteroptions.filterOptions.begin();
502 FilterOption_tmap::iterator filteropt_end =
503 filteroptions.filterOptions.end();
504 while (filteropt_here != filteropt_end) {
505 textout << outconvert
506 << "<tr><td>\""
507 << (*filteropt_here).second.name
508 << "\"</td>\n"
509
510 << "<td>";
511 text_t type_string;
512 switch ((*filteropt_here).second.type) {
513 case FilterOption_t::booleant: type_string = "boolean"; break;
514 case FilterOption_t::integert: type_string = "integer"; break;
515 case FilterOption_t::enumeratedt: type_string = "enumerated"; break;
516 case FilterOption_t::stringt: type_string = "string"; break;
517 }
518 textout << outconvert
519 << type_string
520 << "</td>\n"
521
522 << "<td>";
523 text_t repeat_string;
524 switch ((*filteropt_here).second.repeatable) {
525 case FilterOption_t::onePerQuery: repeat_string = "one per query"; break;
526 case FilterOption_t::onePerTerm: repeat_string = "one per term"; break;
527 case FilterOption_t::nPerTerm: repeat_string = "n per term"; break;
528 }
529 textout << outconvert
530 << repeat_string
531 << "</td>\n"
532
533 << "<td>\""
534 << (*filteropt_here).second.defaultValue
535 << "\"</td>\n"
536
537 << "<td>";
538
539 text_tarray::iterator valid_here =
540 (*filteropt_here).second.validValues.begin();
541 text_tarray::iterator valid_end =
542 (*filteropt_here).second.validValues.end();
543 bool valid_first = true;
544 while (valid_here != valid_end) {
545 if (!valid_first) textout << outconvert << ", ";
546 valid_first = false;
547 textout << outconvert << "\"" << *valid_here << "\"";
548 valid_here++;
549 }
550 textout << outconvert
551 << "</td></tr>\n";
552
553 filteropt_here++;
554 }
555
556 textout << outconvert
557 << "</table>\n";
558
559 } else {
560 textout << outconvert << "Error (" << get_comerror_string (err)
561 << ") while getting filter option information\n";
562 }
563
564 filternames_here++;
565 }
566
567 } else {
568 textout << outconvert << "Error (" << get_comerror_string (err)
569 << ") while getting filter information\n";
570 }
571 }
572
573 textout << outconvert << disp << "_status:footer_\n";
574}
575
576void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &disp,
577 outconvertclass &outconvert,
578 ostream &textout, ostream &/*logout*/) {
579 textout << outconvert << disp << "_status:header_(Init log)\n";
580 textout << outconvert << "<h2>Init log</h2>\n";
581
582 ifstream initin (GSDL_GSDLHOME "/etc/initout.txt");
583 if (initin) {
584 textout << outconvert << "<p>The initialisation error log, "
585 GSDL_GSDLHOME "/etc/initout.txt, contains the\n";
586 textout << outconvert << "following information:\n\n";
587 text_t errorpage = "<p><pre>\n";
588
589 char c;
590 initin.get(c);
591 while (!initin.eof ()) {
592 errorpage.push_back(c);
593 initin.get(c);
594 }
595
596 errorpage += "</pre>\n";
597 initin.close();
598 textout << outconvert << errorpage;
599
600 } else {
601 textout << outconvert << "Couldn't read initialisation error log, " GSDL_GSDLHOME "/etc/initout.txt.\n";
602 }
603
604 textout << outconvert << disp << "_status:footer_\n";
605}
606
607void statusaction::output_errorlog (cgiargsclass &/*args*/, displayclass &disp,
608 outconvertclass &outconvert,
609 ostream &textout, ostream &logout) {
610 textout << outconvert << disp << "_status:header_(Error log)\n";
611 textout << outconvert << "<h2>Error log</h2>\n";
612 logout << flush;
613
614 ifstream errin (GSDL_GSDLHOME "/etc/errout.txt");
615 if (errin) {
616 textout << outconvert << "<p>The error log, " GSDL_GSDLHOME "/etc/errout.txt, contains the\n";
617 textout << outconvert << "following information:\n\n";
618 text_t errorpage = "<p><pre>\n";
619
620 char c;
621 errin.get(c);
622 while (!errin.eof ()) {
623 errorpage.push_back(c);
624 errin.get(c);
625 }
626
627 errorpage += "</pre>\n";
628 errin.close();
629 textout << outconvert << errorpage;
630
631 } else {
632 textout << outconvert << "Couldn't read error log, " GSDL_GSDLHOME "/etc/errout.txt.\n";
633 }
634
635 textout << outconvert << disp << "_status:footer_\n";
636}
637
638void statusaction::output_errorpage (outconvertclass &outconvert,
639 ostream &textout, ostream &/*logout*/,
640 text_t message) {
641 textout << outconvert
642 << "<html>\n"
643 << "<head>\n"
644 << "<title>Error</title>\n"
645 << "</head>\n"
646 << "<body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#006666\" "
647 << "alink=\"#cc9900\" vlink=\"#666633\">\n"
648 << "<h2>Oops!</h2>\n"
649 << message
650 << "\n</body>\n"
651 << "</html>\n";
652 return;
653}
654
655
656
657statusaction::statusaction () {
658 disabled = true;
659 recpt = NULL;
660
661 // this action uses cgi variable "a"
662 cgiarginfo arg_ainfo;
663 arg_ainfo.shortname = "a";
664 arg_ainfo.longname = "action";
665 arg_ainfo.multiplechar = true;
666 arg_ainfo.defaultstatus = cgiarginfo::weak;
667 arg_ainfo.argdefault = "status";
668 arg_ainfo.savedarginfo = cgiarginfo::must;
669 argsinfo.addarginfo (NULL, arg_ainfo);
670
671 // "sp" -- status page
672 arg_ainfo.shortname = "sp";
673 arg_ainfo.longname = "status page";
674 arg_ainfo.multiplechar = true;
675 arg_ainfo.defaultstatus = cgiarginfo::good;
676 arg_ainfo.argdefault = "frameset";
677 arg_ainfo.savedarginfo = cgiarginfo::can;
678 argsinfo.addarginfo (NULL, arg_ainfo);
679
680 // "pr" -- protocol
681 arg_ainfo.shortname = "pr";
682 arg_ainfo.longname = "protocol";
683 arg_ainfo.multiplechar = true;
684 arg_ainfo.defaultstatus = cgiarginfo::none;
685 arg_ainfo.argdefault = "";
686 arg_ainfo.savedarginfo = cgiarginfo::can;
687 argsinfo.addarginfo (NULL, arg_ainfo);
688}
689
690statusaction::~statusaction () {
691}
692
693bool statusaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
694 ostream &/*logout*/) {
695 // don't want to check anything yet.
696 return true;
697}
698
699void statusaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
700 text_t &response_data, ostream &/*logout*/) {
701 response = content;
702 response_data = "text/html";
703}
704
705bool statusaction::do_action (cgiargsclass &args, recptproto */*collectproto*/,
706 displayclass &disp, outconvertclass &outconvert,
707 ostream &textout, ostream &logout) {
708 // make sure the status function is enabled
709 if (disabled) {
710 output_errorpage (outconvert, textout, logout,
711 "The status action is disabled. "
712 "See the documentation (what documentation!) on how "
713 "to enable it.");
714 return true;
715 }
716
717 // make sure we know about a receptionist
718 if (recpt == NULL) {
719 output_errorpage (outconvert, textout, logout,
720 "The status action does not contain information\n"
721 "about any receptionists. The method set_receptionist\n"
722 "was probably not called from the module which instantiated\n"
723 "this status action.\n");
724 return true;
725 }
726
727 // check to make sure status.dm was read in
728 const recptconf &rcinfo = recpt->get_configinfo ();
729 text_tarray::const_iterator macrohere = rcinfo.macrofiles.begin ();
730 text_tarray::const_iterator macroend = rcinfo.macrofiles.end ();
731 while (macrohere != macroend) {
732 if (*macrohere == "status.dm") break;
733 macrohere++;
734 }
735 if (macrohere == macroend) {
736 output_errorpage (outconvert, textout, logout,
737 "The status.dm file was not read in. This macro file is\n"
738 "needed to display configuration and status information.\n");
739 return true;
740 }
741
742 // output the required status page
743 text_t &arg_sp = args["sp"];
744 if (arg_sp == "frameset") output_frameset (args, disp, outconvert, textout, logout);
745 else if (arg_sp == "select") output_select (args, disp, outconvert, textout, logout);
746 else if (arg_sp == "generalinfo") output_generalinfo (args, disp, outconvert, textout, logout);
747 else if (arg_sp == "argumentinfo") output_argumentinfo (args, disp, outconvert, textout, logout);
748 else if (arg_sp == "actioninfo") output_actioninfo (args, disp, outconvert, textout, logout);
749 else if (arg_sp == "protocolinfo") output_protocolinfo (args, disp, outconvert, textout, logout);
750 else if (arg_sp == "collectioninfo") output_collectioninfo (args, disp, outconvert, textout, logout);
751 else if (arg_sp == "initlog") output_initlog (args, disp, outconvert, textout, logout);
752 else if (arg_sp == "errorlog") output_errorlog (args, disp, outconvert, textout, logout);
753 else {
754 output_errorpage (outconvert, textout, logout,
755 "Unknown page \"" + arg_sp + "\".\n");
756 }
757
758 return true;
759}
760
761void statusaction::configure (const text_t &key, const text_tarray &cfgline) {
762 if ((key == "status") && (cfgline.size() == 1) &&
763 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
764 disabled = false;
765 } else {
766 // call the parent class to deal with the things which
767 // are not dealt with here
768 action::configure (key, cfgline);
769 }
770}
771
Note: See TracBrowser for help on using the repository browser.