source: gsdl/trunk/src/recpt/pingaction.cpp@ 15597

Last change on this file since 15597 was 7371, checked in by mdewsnip, 20 years ago

(Human Info) Allow some actions to be easily switched off.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/**********************************************************************
2 *
3 * pingaction.cpp --
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 *********************************************************************/
25
26#include "gsdl_modules_cfg.h"
27#ifdef GSDL_USE_PING_ACTION
28
29#include "pingaction.h"
30
31pingaction::pingaction () {
32 // this action uses cgi variable "a"
33 cgiarginfo arg_ainfo;
34 arg_ainfo.shortname = "a";
35 arg_ainfo.longname = "action";
36 arg_ainfo.multiplechar = true;
37 arg_ainfo.defaultstatus = cgiarginfo::weak;
38 arg_ainfo.argdefault = "ping";
39 arg_ainfo.savedarginfo = cgiarginfo::must;
40
41 argsinfo.addarginfo (NULL, arg_ainfo);
42
43}
44
45void pingaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
46 response_t &response, text_t &response_data,
47 ostream &/*logout*/) {
48 response = content;
49 response_data = "text/html";
50}
51
52
53bool pingaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
54 browsermapclass * /*browsers*/, displayclass &/*disp*/,
55 outconvertclass &outconvert, ostream &textout,
56 ostream &logout) {
57 bool wassuccess = false;
58 comerror_t err;
59
60 recptproto *collectproto = protos->getrecptproto (args["c"], logout);
61 if (!args["c"].empty() && (collectproto != NULL)) {
62 collectproto->ping (args["c"], wassuccess, err, logout);
63 if (err != noError) wassuccess = false; // a communication error
64 }
65
66 textout << outconvert
67 << "<html>\n"
68 << "<head>\n"
69 << "<title>Ping</title>\n"
70 << "</head>\n"
71 << "<body>\n"
72 << "Ping for \"" << args["c"] << "\" ";
73
74 if (wassuccess) {
75 textout << outconvert << " succeeded.\n";
76 } else {
77 textout << outconvert << " did not succeed.\n";
78 }
79
80 textout << outconvert
81 << "</body>\n"
82 << "</html>\n";
83
84 return true;
85};
86
87#endif //GSDL_USE_PING_ACTION
Note: See TracBrowser for help on using the repository browser.