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

Last change on this file since 3036 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

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