[166] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * pingaction.cpp --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[533] | 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.
|
---|
[166] | 9 | *
|
---|
[533] | 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 | *
|
---|
[166] | 24 | * $Id: pingaction.cpp 760 1999-11-01 21:56:32Z sjboddie $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 | /*
|
---|
| 29 | $Log$
|
---|
[760] | 30 | Revision 1.5 1999/11/01 21:56:32 sjboddie
|
---|
| 31 | changes to arguments of many functions
|
---|
| 32 |
|
---|
[533] | 33 | Revision 1.4 1999/09/07 04:56:57 sjboddie
|
---|
| 34 | added GPL notice
|
---|
| 35 |
|
---|
[421] | 36 | Revision 1.3 1999/07/30 02:24:45 sjboddie
|
---|
| 37 | added collectinfo argument to some functions
|
---|
| 38 |
|
---|
[172] | 39 | Revision 1.2 1999/02/25 21:58:59 rjmcnab
|
---|
| 40 |
|
---|
| 41 | Merged sources.
|
---|
| 42 |
|
---|
[166] | 43 | Revision 1.1 1999/02/21 22:35:20 rjmcnab
|
---|
| 44 |
|
---|
| 45 | Initial revision.
|
---|
| 46 |
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | #include "pingaction.h"
|
---|
| 51 |
|
---|
| 52 | pingaction::pingaction () {
|
---|
| 53 | // this action uses cgi variable "a"
|
---|
| 54 | cgiarginfo arg_ainfo;
|
---|
| 55 | arg_ainfo.shortname = "a";
|
---|
| 56 | arg_ainfo.longname = "action";
|
---|
| 57 | arg_ainfo.multiplechar = true;
|
---|
| 58 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 59 | arg_ainfo.argdefault = "ping";
|
---|
| 60 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 61 |
|
---|
| 62 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 63 |
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[760] | 66 | void pingaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
|
---|
| 67 | response_t &response, text_t &response_data,
|
---|
| 68 | ostream &/*logout*/) {
|
---|
[166] | 69 | response = content;
|
---|
| 70 | response_data = "text/html";
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 |
|
---|
[760] | 74 | bool pingaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
|
---|
| 75 | browsermapclass * /*browsers*/, displayclass &/*disp*/,
|
---|
[421] | 76 | outconvertclass &outconvert, ostream &textout,
|
---|
| 77 | ostream &logout) {
|
---|
[166] | 78 | bool wassuccess = false;
|
---|
| 79 | comerror_t err;
|
---|
[172] | 80 |
|
---|
[760] | 81 | recptproto *collectproto = protos->getrecptproto (args["c"], logout);
|
---|
[166] | 82 | if (!args["c"].empty() && (collectproto != NULL)) {
|
---|
| 83 | collectproto->ping (args["c"], wassuccess, err, logout);
|
---|
| 84 | if (err != noError) wassuccess = false; // a communication error
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | textout << outconvert
|
---|
| 88 | << "<html>\n"
|
---|
| 89 | << "<head>\n"
|
---|
| 90 | << "<title>Ping</title>\n"
|
---|
| 91 | << "</head>\n"
|
---|
| 92 | << "<body>\n"
|
---|
| 93 | << "Ping for \"" << args["c"] << "\" ";
|
---|
| 94 |
|
---|
| 95 | if (wassuccess) {
|
---|
| 96 | textout << outconvert << " succeeded.\n";
|
---|
| 97 | } else {
|
---|
| 98 | textout << outconvert << " did not succeed.\n";
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | textout << outconvert
|
---|
| 102 | << "</body>\n"
|
---|
| 103 | << "</html>\n";
|
---|
| 104 |
|
---|
| 105 | return true;
|
---|
| 106 | };
|
---|