00001 /*MT* 00002 00003 MediaTomb - http://www.mediatomb.cc/ 00004 00005 upnp_cm_actions.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: upnp_cm_actions.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 "tools.h" 00037 #include "upnp_cm.h" 00038 #include "storage.h" 00039 00040 using namespace zmm; 00041 using namespace mxml; 00042 00043 void ConnectionManagerService::upnp_action_GetCurrentConnectionIDs(Ref<ActionRequest> request) 00044 { 00045 log_debug("start\n"); 00046 00047 Ref<Element> response; 00048 response = UpnpXML_CreateResponse(request->getActionName(), serviceType); 00049 response->appendTextChild(_("ConnectionID"), _("0")); 00050 00051 request->setResponse(response); 00052 request->setErrorCode(UPNP_E_SUCCESS); 00053 00054 log_debug("end\n"); 00055 } 00056 00057 void ConnectionManagerService::upnp_action_GetCurrentConnectionInfo(Ref<ActionRequest> request) 00058 { 00059 log_debug("start\n"); 00060 00061 request->setErrorCode(UPNP_E_NOT_EXIST); 00062 00063 log_debug("upnp_action_GetCurrentConnectionInfo: end\n"); 00064 } 00065 00066 void ConnectionManagerService::upnp_action_GetProtocolInfo(Ref<ActionRequest> request) 00067 { 00068 log_debug("start\n"); 00069 00070 Ref<Element> response; 00071 response = UpnpXML_CreateResponse(request->getActionName(), serviceType); 00072 00073 Ref<Array<StringBase> > mimeTypes = Storage::getInstance()->getMimeTypes(); 00074 String CSV = mime_types_to_CSV(mimeTypes); 00075 00076 response->appendTextChild(_("Source"), CSV); 00077 response->appendTextChild(_("Sink"), _("")); 00078 00079 request->setResponse(response); 00080 request->setErrorCode(UPNP_E_SUCCESS); 00081 00082 00083 log_debug("end\n"); 00084 } 00085 00086 void ConnectionManagerService::process_action_request(Ref<ActionRequest> request) 00087 { 00088 log_debug("start\n"); 00089 00090 if (request->getActionName() == "GetCurrentConnectionIDs") 00091 { 00092 upnp_action_GetCurrentConnectionIDs(request); 00093 } 00094 else if (request->getActionName() == "GetCurrentConnectionInfo") 00095 { 00096 upnp_action_GetCurrentConnectionInfo(request); 00097 } 00098 else if (request->getActionName() == "GetProtocolInfo") 00099 { 00100 upnp_action_GetProtocolInfo(request); 00101 } 00102 else 00103 { 00104 // invalid or unsupported action 00105 log_debug("unrecognized action %s\n", request->getActionName().c_str()); 00106 request->setErrorCode(UPNP_E_INVALID_ACTION); 00107 // throw UpnpException(UPNP_E_INVALID_ACTION, _("unrecognized action")); 00108 } 00109 00110 00111 00112 log_debug("end\n"); 00113 00114 }
1.6.1