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

Last change on this file since 241 was 226, checked in by rjmcnab, 25 years ago

Got browsefilter working.

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