#include <pages.h>
Public Member Functions | |
| action () | |
| virtual void | process () |
| This method must be overriden by the subclasses that actually process the given request. | |
| virtual zmm::Ref< IOHandler > | open (IN const char *filename, OUT struct File_Info *info, IN enum UpnpOpenFileMode mode) |
| Decodes the parameters from the filename (URL) and calls the internal open() function. | |
| virtual void | get_info (IN const char *filename, OUT struct File_Info *info) |
| Returns information about the requested content. | |
| void | retain () |
| void | release () |
| int | getRefCount () |
Static Public Member Functions | |
| static zmm::String | buildScriptPath (zmm::String filename) |
| builds full path to a script for the given relative filename | |
| static void | split_url (const char *url, char separator, zmm::String &path, zmm::String ¶meters) |
| Splits the url into a path and parameters string. Only '?' and '/' separators are allowed, otherwise an exception will be thrown. | |
| static void * | operator new (size_t size) |
| static void | operator delete (void *ptr) |
Protected Member Functions | |
| zmm::String | param (zmm::String name) |
| Little support function to access stuff from the dictionary in in an easier fashion. | |
| int | intParam (zmm::String name, int invalid=0) |
| bool | boolParam (zmm::String name) |
| void | check_request (bool checkLogin=true) |
| Checks if the incoming request is valid. | |
| zmm::String | renderXMLHeader () |
| Helper function to create a generic XML document header. | |
| zmm::Ref< IOHandler > | open (IN enum UpnpOpenFileMode mode) |
| Prepares the output buffer and calls the process function. | |
| void | addUpdateIDs (zmm::Ref< mxml::Element > root, zmm::Ref< Session > session) |
| add the ui update ids from the given session as xml tags to the given root element | |
| void | handleUpdateIDs () |
| check if ui update ids should be added to the response and add them in that case. must only be called after check_request | |
| void | appendTask (zmm::Ref< mxml::Element > el, zmm::Ref< GenericTask > task) |
| add the content manager task to the given xml element as xml elements | |
| bool | accountsEnabled () |
| check if accounts are enabled in the config | |
| zmm::String | mapAutoscanType (int type) |
| int | remapAutoscanType (zmm::String type) |
Protected Attributes | |
| bool | checkRequestCalled |
| zmm::Ref< Dictionary > | params |
| Decoded URL parameters are stored as a dictionary. | |
| zmm::String | filename |
| The original filename from url if anyone needs it. | |
| enum UpnpOpenFileMode | mode |
| We can also always see what mode was requested. | |
| zmm::Ref< zmm::StringBuffer > | out |
| This is filled during request processing and holds the output. | |
| zmm::Ref< mxml::Element > | root |
| This is the root xml element to be populated by process() method. | |
| zmm::Ref< Session > | session |
| The current session, used for this request; will be filled by check_request(). | |
| mt_atomic_t | _ref_count |
| pthread_mutex_t | mutex |
UI action button.
Definition at line 156 of file pages.h.
| bool WebRequestHandler::accountsEnabled | ( | ) | [inline, protected, inherited] |
check if accounts are enabled in the config
Definition at line 126 of file web_request_handler.h.
References CFG_SERVER_UI_ACCOUNTS_ENABLED, and Singleton< ConfigManager >::getInstance().
Referenced by web::auth::process().
| void WebRequestHandler::addUpdateIDs | ( | zmm::Ref< mxml::Element > | root, | |
| zmm::Ref< Session > | session | |||
| ) | [protected, inherited] |
add the ui update ids from the given session as xml tags to the given root element
| root | the xml element to add the elements to | |
| session | the session from which the ui update ids should be taken |
Definition at line 280 of file web_request_handler.cc.
References _, zmm::String::c_str(), log_debug, mxml::mxml_bool_type, and string_ok().
Referenced by WebRequestHandler::handleUpdateIDs().
| void WebRequestHandler::appendTask | ( | zmm::Ref< mxml::Element > | el, | |
| zmm::Ref< GenericTask > | task | |||
| ) | [protected, inherited] |
add the content manager task to the given xml element as xml elements
| el | the xml element to add the elements to | |
| task | the task to add to the given xml element |
Definition at line 292 of file web_request_handler.cc.
References _, mxml::mxml_bool_type, mxml::mxml_int_type, and nil.
Referenced by WebRequestHandler::open(), and web::tasks::process().
| bool WebRequestHandler::boolParam | ( | zmm::String | name | ) | [protected, inherited] |
Definition at line 63 of file web_request_handler.cc.
References WebRequestHandler::param(), and string_ok().
Referenced by web::autoscan::process().
| static zmm::String WebRequestHandler::buildScriptPath | ( | zmm::String | filename | ) | [static, inherited] |
builds full path to a script for the given relative filename
| void WebRequestHandler::check_request | ( | bool | checkLogin = true |
) | [protected, inherited] |
Checks if the incoming request is valid.
Each request going to the ui must at least have a valid session id, and a driver parameter. Also, there can only by a primary or a a decondary driver.
Definition at line 69 of file web_request_handler.cc.
References _, WebRequestHandler::checkRequestCalled, Singleton< SessionManager >::getInstance(), nil, WebRequestHandler::param(), WebRequestHandler::session, and sid.
Referenced by web::voidType::process(), web::autoscan::process(), web::tasks::process(), web::remove::process(), web::items::process(), web::files::process(), web::edit_save::process(), web::edit_load::process(), web::directories::process(), web::containers::process(), web::auth::process(), web::addObject::process(), web::add::process(), and process().
| void WebRequestHandler::get_info | ( | IN const char * | filename, | |
| OUT struct File_Info * | info | |||
| ) | [virtual, inherited] |
Returns information about the requested content.
| filename | Requested URL | |
| info | File_Info structure, quite similar to statbuf. |
We need to override this, because for serving UI pages (mostly generated from dynamic XML) we do not know the size of the data. This is of course different for the FileRequestHandler, where we can check the file and return all information about it.
Implements RequestHandler.
Definition at line 96 of file web_request_handler.cc.
References _, zmm::String::c_str(), DEFAULT_INTERNAL_CHARSET, ixmlCloneDOMString(), MIMETYPE_JSON, MIMETYPE_XML, NULL, WebRequestHandler::param(), and string_ok().
Referenced by WebRequestHandler::open().
| int Object::getRefCount | ( | ) | [inherited] |
Definition at line 78 of file object.cc.
References zmm::Object::_ref_count, and atomic_get().
| void WebRequestHandler::handleUpdateIDs | ( | ) | [protected, inherited] |
check if ui update ids should be added to the response and add them in that case. must only be called after check_request
Definition at line 260 of file web_request_handler.cc.
References _, WebRequestHandler::addUpdateIDs(), mxml::mxml_bool_type, WebRequestHandler::param(), WebRequestHandler::root, WebRequestHandler::session, and string_ok().
Referenced by WebRequestHandler::open().
| int WebRequestHandler::intParam | ( | zmm::String | name, | |
| int | invalid = 0 | |||
| ) | [protected, inherited] |
Definition at line 54 of file web_request_handler.cc.
References WebRequestHandler::param(), string_ok(), and zmm::String::toInt().
Referenced by web::autoscan::process(), web::tasks::process(), web::remove::process(), web::items::process(), web::containers::process(), and web::addObject::process().
| String WebRequestHandler::mapAutoscanType | ( | int | type | ) | [protected, inherited] |
Definition at line 304 of file web_request_handler.cc.
References _.
Referenced by web::items::process(), and web::containers::process().
| Ref< IOHandler > WebRequestHandler::open | ( | IN const char * | filename, | |
| OUT struct File_Info * | info, | |||
| IN enum UpnpOpenFileMode | mode | |||
| ) | [virtual, inherited] |
Decodes the parameters from the filename (URL) and calls the internal open() function.
| filename | The requested URL | |
| mode | either UPNP_READ or UPNP_WRITE |
Implements RequestHandler.
Definition at line 243 of file web_request_handler.cc.
References WebRequestHandler::get_info(), log_debug, NULL, WebRequestHandler::open(), WebRequestHandler::params, RequestHandler::split_url(), and URL_UI_PARAM_SEPARATOR.
| Ref< IOHandler > WebRequestHandler::open | ( | IN enum UpnpOpenFileMode | mode | ) | [protected, inherited] |
Prepares the output buffer and calls the process function.
Definition at line 118 of file web_request_handler.cc.
References _, WebRequestHandler::appendTask(), CFG_SERVER_UI_ENABLED, WebRequestHandler::checkRequestCalled, error_code, Singleton< ContentManager >::getInstance(), Singleton< ConfigManager >::getInstance(), zmm::Exception::getMessage(), StorageException::getUserMessage(), WebRequestHandler::handleUpdateIDs(), log_warning, mxml::mxml_bool_type, nil, WebRequestHandler::out, WebRequestHandler::param(), zmm::Exception::printStackTrace(), WebRequestHandler::process(), RefCast, WebRequestHandler::renderXMLHeader(), WebRequestHandler::root, and string_ok().
Referenced by WebRequestHandler::open().
| void Object::operator delete | ( | void * | ptr | ) | [static, inherited] |
| void * Object::operator new | ( | size_t | size | ) | [static, inherited] |
| zmm::String WebRequestHandler::param | ( | zmm::String | name | ) | [inline, protected, inherited] |
Little support function to access stuff from the dictionary in in an easier fashion.
| name | of the parameter we are looking for. |
Definition at line 87 of file web_request_handler.h.
References WebRequestHandler::params.
Referenced by web::addObject::addActiveItem(), web::addObject::addContainer(), web::addObject::addItem(), web::addObject::addUrl(), WebRequestHandler::boolParam(), WebRequestHandler::check_request(), WebRequestHandler::get_info(), WebRequestHandler::handleUpdateIDs(), WebRequestHandler::intParam(), WebRequestHandler::open(), web::autoscan::process(), web::tasks::process(), web::items::process(), web::files::process(), web::edit_save::process(), web::edit_load::process(), web::directories::process(), web::containers::process(), web::auth::process(), web::addObject::process(), web::add::process(), and process().
| void web::action::process | ( | ) | [virtual] |
This method must be overriden by the subclasses that actually process the given request.
Implements WebRequestHandler.
Definition at line 46 of file action.cc.
References _, _Exception, zmm::String::c_str(), WebRequestHandler::check_request(), Singleton< ContentManager >::getInstance(), log_debug, WebRequestHandler::param(), and string_ok().
| void Object::release | ( | ) | [inherited] |
Definition at line 66 of file object.cc.
References zmm::Object::_ref_count, atomic_dec(), and zmm::Object::mutex.
Referenced by zmm::ArrayBase::clear(), zmm::String::operator=(), DSOHash< zmm::Array< CacheObject > >::releaseData(), DSBHash< VT >::releaseData(), DSOHash< zmm::Array< CacheObject > >::remove(), zmm::ArrayBase::remove(), zmm::ArrayBase::removeUnordered(), zmm::ArrayBase::set(), zmm::ArrayBase::~ArrayBase(), DSOHash< zmm::Array< CacheObject > >::~DSOHash(), zmm::ObjectQueue< AutoscanDirectory >::~ObjectQueue(), zmm::ObjectStack< Element >::~ObjectStack(), and zmm::String::~String().
| int WebRequestHandler::remapAutoscanType | ( | zmm::String | type | ) | [protected, inherited] |
Definition at line 314 of file web_request_handler.cc.
| String WebRequestHandler::renderXMLHeader | ( | ) | [protected, inherited] |
Helper function to create a generic XML document header.
| xsl_link | If not nil, also adds header information that is required for the XSL processor. |
Definition at line 90 of file web_request_handler.cc.
References _, and DEFAULT_INTERNAL_CHARSET.
Referenced by WebRequestHandler::open().
| void Object::retain | ( | ) | [inherited] |
Definition at line 58 of file object.cc.
References zmm::Object::_ref_count, atomic_inc(), and zmm::Object::mutex.
Referenced by zmm::ArrayBase::append(), zmm::ObjectQueue< AutoscanDirectory >::enqueue(), zmm::ArrayBase::insert(), zmm::String::operator=(), zmm::ObjectStack< Element >::push(), DSOHash< zmm::Array< CacheObject > >::put(), DSBHash< VT >::put(), zmm::ArrayBase::set(), and zmm::String::String().
| void RequestHandler::split_url | ( | const char * | url, | |
| char | separator, | |||
| zmm::String & | path, | |||
| zmm::String & | parameters | |||
| ) | [static, inherited] |
Splits the url into a path and parameters string. Only '?' and '/' separators are allowed, otherwise an exception will be thrown.
| url | URL that has to be processed | |
| path | variable where the path portion will be saved | |
| parameters | variable where the parameters portion will be saved |
This function splits the url into it's path and parameter components. content/media SEPARATOR object_id=12345&transcode=wav would be transformed to: path = "content/media" parameters = "object_id=12345&transcode=wav"
Definition at line 41 of file request_handler.cc.
References _, _Exception, zmm::String::index(), zmm::String::rindex(), and zmm::String::substring().
Referenced by create_request_handler(), ServeRequestHandler::get_info(), WebRequestHandler::open(), and ServeRequestHandler::open().
mt_atomic_t zmm::Object::_ref_count [protected, inherited] |
Definition at line 54 of file object.h.
Referenced by zmm::Object::getRefCount(), zmm::Object::Object(), zmm::Object::release(), and zmm::Object::retain().
bool WebRequestHandler::checkRequestCalled [protected, inherited] |
Definition at line 59 of file web_request_handler.h.
Referenced by WebRequestHandler::check_request(), WebRequestHandler::open(), and WebRequestHandler::WebRequestHandler().
zmm::String WebRequestHandler::filename [protected, inherited] |
The original filename from url if anyone needs it.
Definition at line 65 of file web_request_handler.h.
Referenced by web::files::process(), and web::directories::process().
enum UpnpOpenFileMode WebRequestHandler::mode [protected, inherited] |
We can also always see what mode was requested.
Definition at line 68 of file web_request_handler.h.
pthread_mutex_t zmm::Object::mutex [protected, inherited] |
Reimplemented in AutoscanList, AutoscanInotify, CachedURL, Dictionary_r, DVDNavReader, IOHandlerBufferHelper, ReentrantArray< T >, SingletonManager, Singleton< T >, StorageCache, MutexAutolock, Cond, ThreadExecutor, Singleton< UpdateManager >, Singleton< Timer >, Singleton< ContentDirectoryService >, Singleton< ConfigManager >, Singleton< Server >, Singleton< Runtime >, Singleton< ContentManager >, Singleton< ConnectionManagerService >, Singleton< PlayHook >, Singleton< Storage >, and Singleton< SessionManager >.
Definition at line 56 of file object.h.
Referenced by zmm::Object::Object(), zmm::Object::release(), zmm::Object::retain(), and zmm::Object::~Object().
zmm::Ref<zmm::StringBuffer> WebRequestHandler::out [protected, inherited] |
This is filled during request processing and holds the output.
The XML or HTML that is the result of a request is put in this buffer, this is what is being served to the web browser.
Definition at line 74 of file web_request_handler.h.
Referenced by WebRequestHandler::open().
zmm::Ref<Dictionary> WebRequestHandler::params [protected, inherited] |
Decoded URL parameters are stored as a dictionary.
Definition at line 62 of file web_request_handler.h.
Referenced by WebRequestHandler::open(), WebRequestHandler::param(), web::edit_save::process(), and WebRequestHandler::WebRequestHandler().
zmm::Ref<mxml::Element> WebRequestHandler::root [protected, inherited] |
This is the root xml element to be populated by process() method.
Definition at line 77 of file web_request_handler.h.
Referenced by WebRequestHandler::handleUpdateIDs(), WebRequestHandler::open(), web::autoscan::process(), web::tasks::process(), web::items::process(), web::files::process(), web::edit_load::process(), web::directories::process(), web::containers::process(), and web::auth::process().
zmm::Ref<Session> WebRequestHandler::session [protected, inherited] |
The current session, used for this request; will be filled by check_request().
Definition at line 81 of file web_request_handler.h.
Referenced by WebRequestHandler::check_request(), WebRequestHandler::handleUpdateIDs(), and web::auth::process().
1.6.1