00001 /*MT* 00002 00003 MediaTomb - http://www.mediatomb.cc/ 00004 00005 web_request_handler.h - 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: web_request_handler.h 2081 2010-03-23 20:18:00Z lww $ 00028 */ 00029 00032 #ifndef __WEB_REQUEST_HANDLER_H__ 00033 #define __WEB_REQUEST_HANDLER_H__ 00034 00035 #include "common.h" 00036 #include "mxml/mxml.h" 00037 #include "request_handler.h" 00038 #include "dictionary.h" 00039 #include "session_manager.h" 00040 #include "config_manager.h" 00041 #include "content_manager.h" 00042 00043 class SessionException : public zmm::Exception 00044 { 00045 public: 00046 SessionException(zmm::String message) : zmm::Exception(message) {} 00047 }; 00048 00049 class LoginException : public zmm::Exception 00050 { 00051 public: 00052 LoginException(zmm::String message) : zmm::Exception(message) {} 00053 }; 00054 00056 class WebRequestHandler : public RequestHandler 00057 { 00058 protected: 00059 bool checkRequestCalled; 00060 00062 zmm::Ref<Dictionary> params; 00063 00065 zmm::String filename; 00066 00068 enum UpnpOpenFileMode mode; 00069 00074 zmm::Ref<zmm::StringBuffer> out; 00075 00077 zmm::Ref<mxml::Element> root; 00078 00081 zmm::Ref<Session> session; 00082 00087 inline zmm::String param(zmm::String name) { return params->get(name); } 00088 00089 int intParam(zmm::String name, int invalid = 0); 00090 bool boolParam(zmm::String name); 00091 00097 void check_request(bool checkLogin = true); 00098 00102 zmm::String renderXMLHeader(); 00103 00107 zmm::Ref<IOHandler> open(IN enum UpnpOpenFileMode mode); 00108 00112 void addUpdateIDs(zmm::Ref<mxml::Element> root, zmm::Ref<Session> session); 00113 00117 void handleUpdateIDs(); 00118 00122 void appendTask(zmm::Ref<mxml::Element> el, zmm::Ref<GenericTask> task); 00123 00126 bool accountsEnabled() { return (ConfigManager::getInstance()->getBoolOption(CFG_SERVER_UI_ACCOUNTS_ENABLED)); } 00127 00128 zmm::String mapAutoscanType(int type); 00129 int remapAutoscanType(zmm::String type); 00130 00131 public: 00133 WebRequestHandler(); 00142 virtual void get_info(IN const char *filename, OUT struct File_Info *info); 00143 00148 virtual zmm::Ref<IOHandler> open(IN const char *filename, OUT struct File_Info *info, IN enum UpnpOpenFileMode mode); 00149 00151 virtual void process() = 0; 00152 00154 static zmm::String buildScriptPath(zmm::String filename); 00155 00156 }; 00157 00158 00159 #endif // __WEB_REQUEST_HANDLER_H__
1.6.1