From: Asbjorn M. <ste...@us...> - 2002-03-08 11:45:38
|
Update of /cvsroot/epp-rtk/epp-rtk/c++/src In directory usw-pr-cvs1:/tmp/cvs-serv30223 Modified Files: Makefile.am Added Files: epp_Status.h epp_Status.cc main_status.cc Log Message: -Added <status> command -Changes in ifdef's used for testing --- NEW FILE: epp_Status.h --- /************************************************************************ * EPP RTK C++ * Copyright (C) 2001, 2002 The Global Name Registry, Limited * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: ep...@gn... * * EPP RTK * The Global Name Registry, Limited * 125 High Holborn * London WC1V 6QA * United Kingdom ************************************************************************/ #ifndef __EPP_STATUS_H #define __EPP_STATUS_H #include "data/epp_StatusReq.h" #include "data/epp_StatusRsp.h" #include "epp_Action.h" namespace eppobject { namespace epp { class epp_Status : public epp_Action { private: epp_StatusReq_ref m_request; epp_StatusRsp_ref m_response; public: epp_Status() {}; virtual ~epp_Status() {}; void setRequestData(const epp_StatusReq & data); epp_StatusRsp_ref getResponseData(); virtual eppobject::epp::epp_string toXML(); virtual void fromXML(const eppobject::epp::epp_string & xml); }; typedef refcnt_ptr<epp_Status> epp_Status_ref; }} #endif --- NEW FILE: epp_Status.cc --- /************************************************************************ * EPP RTK C++ * Copyright (C) 2001, 2002 The Global Name Registry, Limited * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: ep...@gn... * * EPP RTK * The Global Name Registry, Limited * 125 High Holborn * London WC1V 6QA * United Kingdom ************************************************************************/ #include "config.h" #include "epp_Status.h" #include <domtools/dom_output.h> #include <domtools/dom_wrapper.h> #include "data/epp_eppXMLbase.h" #include "data/epp_XMLException.h" using namespace domtools; using namespace eppobject::epp; void epp_Status::setRequestData(const epp_StatusReq & data) { m_request.ref(new epp_StatusReq(data)); } epp_StatusRsp_ref epp_Status::getResponseData() { return m_response; } epp_string epp_Status::toXML() { if(m_request == NULL || m_request->m_cmd == NULL || m_request->m_client_trid == NULL) { throw epp_XMLException(__FILE__, __LINE__, "Missing data in request"); } EPP_output xml_request; xml_request.setWhitespace(Whitespace); createStandardXMLHeader(xml_request); xml_request.beginTag("command"); xml_request.beginTag("status"); if(m_request->m_command != NULL) { xml_request.putAttribute("command", returnStatusCommandType(*m_request->m_command)); } xml_request.beginTag("clTRID"); xml_request.putCDATA(*m_request->m_client_trid); xml_request.endTag("clTRID"); xml_request.endTag("status"); addExtensionElement(xml_request, m_request->m_cmd->m_ext); if(m_request->m_cmd->m_client_trid != NULL) { xml_request.putTag("clTRID",*m_request->m_cmd->m_client_trid); } // if "m_cmd->m_client_trid" xml_request.endTag("command"); createStandardXMLFooter(xml_request); return xml_request.getString(); } void epp_Status::fromXML(const eppobject::epp::epp_string & xml) { dom_ptr doc = createDOMDocument(xml); dom_ptr responseNode = dom_ptr(doc->getTag("response")); if(responseNode->isNull()) { throw epp_XMLException(__FILE__, __LINE__, "Unable to find response-element"); } epp_Response_ref res = createGenericResponse(responseNode); m_response.ref(new epp_StatusRsp(res)); } --- NEW FILE: main_status.cc --- /************************************************************************ * EPP RTK C++ * Copyright (C) 2001, 2002 The Global Name Registry, Limited * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: ep...@gn... * * EPP RTK * The Global Name Registry, Limited * 125 High Holborn * London WC1V 6QA * United Kingdom ************************************************************************/ #include <string> #include <vector> #include <iostream.h> #include "data/epp_StatusReq.h" #include "data/epp_StatusRsp.h" #include "data/epp_XMLException.h" #include "data/epp_Exception.h" #include "epp_Action.h" #include "epp_Status.h" #include "epp_Session.h" #include "testTools.h" using namespace eppobject::epp; void printRsp(const epp_StatusRsp_ref req) { cout << "Printing Response:\n_______________________________\n"; if(req != NULL) printResponsePart(req->m_rsp); cout << "_______________________________\n"; } // printRsp int main(int argc, char * argv[]) { epp_Session test; string username, password; if(!handleArgs(test, argc, argv, username, password)) return 1; testLogIn(test, username, password); try { epp_StatusReq_ref l_req(new epp_StatusReq()); epp_Command_ref cmd(new epp_Command()); cmd->m_client_trid.ref(new epp_trid("ABC-12346")); l_req->m_cmd = cmd; l_req->m_client_trid.ref(new epp_trid("ABC-12345")); l_req->m_command.ref(new epp_StatusCommandType(CREATE)); epp_Status_ref l_obj(new epp_Status()); l_obj->setRequestData(*l_req); test.processAction(l_obj); epp_StatusRsp_ref l_rsp = l_obj->getResponseData(); #ifndef TEST_IO_REQUEST2CERR printRsp(l_rsp); #endif return 0; } catch(epp_XMLException ex) { cout << "Exception: " << ex.getString() << endl; } catch(epp_Exception ex) { cout << "Exception: " << endl; #ifndef TEST_IO_REQUEST2CERR cerr << "<response>" << endl; printResultsSeq(ex.m_details); printTransID(ex.m_trans_id); cerr << "</response>" << endl; #endif } catch(...) { cout << "Something else went wrong...\n"; } } Index: Makefile.am =================================================================== RCS file: /cvsroot/epp-rtk/epp-rtk/c++/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 8 Feb 2002 18:21:52 -0000 1.5 --- Makefile.am 8 Mar 2002 11:45:35 -0000 1.6 *************** *** 10,14 **** domaininfo domainrenew domaintransfer domainupdate \ hostcheck hostcreate hostdelete hostinfo hostupdate \ ! loginunspec noinst_LIBRARIES = libepprtk.a --- 10,14 ---- domaininfo domainrenew domaintransfer domainupdate \ hostcheck hostcreate hostdelete hostinfo hostupdate \ ! loginunspec status noinst_LIBRARIES = libepprtk.a *************** *** 34,37 **** --- 34,38 ---- epp_Logout.cc \ epp_Poll.cc \ + epp_Status.cc \ epp_ContactCheck.cc \ epp_ContactCreate.cc \ *************** *** 64,67 **** --- 65,71 ---- poll_SOURCES = \ main_poll.cc $(common) + + status_SOURCES = \ + main_status.cc $(common) contactcheck_SOURCES = \ |