00001 /*MT* 00002 00003 MediaTomb - http://www.mediatomb.cc/ 00004 00005 action_request.cc - this file is part of MediaTomb. 00006 00007 Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, 00008 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> 00009 00010 Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, 00011 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, 00012 Leonhard Wimmer <leo@mediatomb.cc> 00013 00014 MediaTomb is free software; you can redistribute it and/or modify 00015 it under the terms of the GNU General Public License version 2 00016 as published by the Free Software Foundation. 00017 00018 MediaTomb is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 version 2 along with MediaTomb; if not, write to the Free Software 00025 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 00026 00027 $Id: action_request.cc 2081 2010-03-23 20:18:00Z lww $ 00028 */ 00029 00031 00032 #ifdef HAVE_CONFIG_H 00033 #include "autoconfig.h" 00034 #endif 00035 00036 #include "action_request.h" 00037 00038 using namespace zmm; 00039 using namespace mxml; 00040 00041 ActionRequest::ActionRequest(Upnp_Action_Request *upnp_request) : Object() 00042 { 00043 this->upnp_request = upnp_request; 00044 00045 errCode = UPNP_E_SUCCESS; 00046 actionName = upnp_request->ActionName; 00047 UDN = upnp_request->DevUDN; 00048 serviceID = upnp_request->ServiceID; 00049 00050 DOMString cxml = ixmlPrintDocument(upnp_request->ActionRequest); 00051 String xml = cxml; 00052 ixmlFreeDOMString(cxml); 00053 00054 Ref<Parser> parser(new Parser()); 00055 00056 request = parser->parseString(xml)->getRoot(); 00057 } 00058 00059 String ActionRequest::getActionName() 00060 { 00061 return actionName; 00062 } 00063 String ActionRequest::getUDN() 00064 { 00065 return UDN; 00066 } 00067 String ActionRequest::getServiceID() 00068 { 00069 return serviceID; 00070 } 00071 Ref<Element> ActionRequest::getRequest() 00072 { 00073 return request; 00074 } 00075 00076 void ActionRequest::setResponse(Ref<Element> response) 00077 { 00078 this->response = response; 00079 } 00080 void ActionRequest::setErrorCode(int errCode) 00081 { 00082 this->errCode = errCode; 00083 } 00084 00085 void ActionRequest::update() 00086 { 00087 if(response != nil) 00088 { 00089 String xml = response->print(); 00090 int ret; 00091 00092 //log_debug("ActionRequest::update(): \n%s\n\n", xml.c_str()); 00093 00094 ret = ixmlParseBufferEx(xml.c_str(), &upnp_request->ActionResult); 00095 if (ret != IXML_SUCCESS) 00096 { 00097 log_error("ActionRequest::update(): could not convert to iXML\n"); 00098 log_debug("Dump:\n%s\n", xml.c_str()); 00099 upnp_request->ErrCode = UPNP_E_ACTION_FAILED; 00100 } 00101 else 00102 { 00103 // log_debug("ActionRequest::update(): converted to iXML, code %d\n", errCode); 00104 upnp_request->ErrCode = errCode; 00105 } 00106 } 00107 else 00108 { 00109 // ok, here there can be two cases 00110 // either the function below already did set an error code, 00111 // then we keep it 00112 // if it did not do so - we set an error code of our own 00113 if (errCode == UPNP_E_SUCCESS) 00114 { 00115 upnp_request->ErrCode = UPNP_E_ACTION_FAILED; 00116 } 00117 00118 log_error("ActionRequest::update(): response is nil, code %d\n", errCode); 00119 } 00120 }
1.6.1