web::add Class Reference

Browser add item. More...

#include <pages.h>

Inheritance diagram for web::add:
WebRequestHandler RequestHandler zmm::Object

Public Member Functions

 add ()
virtual void process ()
 This method must be overriden by the subclasses that actually process the given request.
virtual zmm::Ref< IOHandleropen (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 &parameters)
 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< IOHandleropen (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< Dictionaryparams
 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::StringBufferout
 This is filled during request processing and holds the output.
zmm::Ref< mxml::Elementroot
 This is the root xml element to be populated by process() method.
zmm::Ref< Sessionsession
 The current session, used for this request; will be filled by check_request().
mt_atomic_t _ref_count
pthread_mutex_t mutex

Detailed Description

Browser add item.

Definition at line 87 of file pages.h.


Constructor & Destructor Documentation

web::add::add (  ) 

Definition at line 47 of file add.cc.


Member Function Documentation

bool WebRequestHandler::accountsEnabled (  )  [inline, protected, inherited]

check if accounts are enabled in the config

Returns:
true if accounts are enabled, false if not

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

Parameters:
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

Parameters:
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]
void WebRequestHandler::get_info ( IN const char *  filename,
OUT struct File_Info info 
) [virtual, inherited]

Returns information about the requested content.

Parameters:
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]
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.

Parameters:
filename The requested URL
mode either UPNP_READ or UPNP_WRITE
Returns:
the appropriate IOHandler for the request.

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]
void Object::operator delete ( void *  ptr  )  [static, inherited]

Definition at line 87 of file object.cc.

References FREE.

void * Object::operator new ( size_t  size  )  [static, inherited]

Definition at line 83 of file object.cc.

References MALLOC.

zmm::String WebRequestHandler::param ( zmm::String  name  )  [inline, protected, inherited]
void web::add::process (  )  [virtual]

This method must be overriden by the subclasses that actually process the given request.

Implements WebRequestHandler.

Definition at line 51 of file add.cc.

References _, _Exception, WebRequestHandler::check_request(), FS_ROOT_DIRECTORY, Singleton< ContentManager >::getInstance(), hex_decode_string(), log_debug, nil, WebRequestHandler::param(), and string_ok().

void Object::release (  )  [inherited]
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.

Parameters:
xsl_link If not nil, also adds header information that is required for the XSL processor.
Returns:
The header as a string... because our parser does not yet understand <? ?> stuff :)

Definition at line 90 of file web_request_handler.cc.

References _, and DEFAULT_INTERNAL_CHARSET.

Referenced by WebRequestHandler::open().

void Object::retain (  )  [inherited]
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.

Parameters:
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().


Field Documentation

mt_atomic_t zmm::Object::_ref_count [protected, inherited]
bool WebRequestHandler::checkRequestCalled [protected, inherited]
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]

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().

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<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().


The documentation for this class was generated from the following files:

Generated on Fri Mar 26 20:16:58 2010 for MediaTomb by  doxygen 1.6.1