Gnash  0.8.11dev
Public Member Functions | List of all members
gnash::StreamProvider Class Reference

A StreamProvider makes IOChannels available to the core on request. More...

#include <StreamProvider.h>

Public Member Functions

 StreamProvider (URL original, URL base, std::unique_ptr< NamingPolicy > np=std::unique_ptr< NamingPolicy >(new NamingPolicy))
 Construct a StreamProvider. More...
 
virtual ~StreamProvider ()
 
virtual std::unique_ptr< IOChannelgetStream (const URL &url, bool namedCacheFile=false) const
 Returned stream ownership is transferred to caller. More...
 
virtual std::unique_ptr< IOChannelgetStream (const URL &url, const std::string &postdata, bool namedCacheFile=false) const
 Get a stream from the response of a POST operation. More...
 
virtual std::unique_ptr< IOChannelgetStream (const URL &url, const std::string &postdata, const NetworkAdapter::RequestHeaders &headers, bool namedCacheFile=false) const
 
void setNamingPolicy (std::unique_ptr< NamingPolicy > np)
 Set the NamingPolicy for cache files. More...
 
const NamingPolicynamingPolicy () const
 Return the currently selected policy for converting URL to filename. More...
 
bool allow (const URL &url) const
 Check whether access to a URL is allowed. More...
 
const URLbaseURL () const
 The base URL that should be used to resolve all relative URLs. More...
 

Detailed Description

A StreamProvider makes IOChannels available to the core on request.

The current functions of this class are:

  1. Inform users whether a connection to a certain URL is allowed.
  2. Make a connection and return an IOChannel (this performs a separate access check).

The class should in future also:

  1. Take relative URLs and resolve them against the base URL. TODO: this class should become an abstract interface.

Constructor & Destructor Documentation

§ StreamProvider()

gnash::StreamProvider::StreamProvider ( URL  original,
URL  base,
std::unique_ptr< NamingPolicy np = std::unique_ptr<NamingPolicy>(new NamingPolicy) 
)

Construct a StreamProvider.

Parameters
originalThe original URL, used to decide whether to allow connections.
baseThe base URL, used to resolve URLs.
npA policy to decide the name of cached files.

§ ~StreamProvider()

virtual gnash::StreamProvider::~StreamProvider ( )
inlinevirtual

References url.

Member Function Documentation

§ allow()

bool gnash::StreamProvider::allow ( const URL url) const

Check whether access to a URL is allowed.

This is used by the core to check whether a connection can be made before trying to make it. It's useful currently for some functions to decide what to return.

Parameters
urlThe url to check
Returns
true if allowed, false if not.

References gnash::URLAccessManager::allow().

Referenced by gnash::NetConnection_as::connect(), gnash::externalinterface_class_init(), getStream(), and gnash::NetConnection_as::validateURL().

§ baseURL()

const URL& gnash::StreamProvider::baseURL ( ) const
inline

§ getStream() [1/3]

std::unique_ptr< IOChannel > gnash::StreamProvider::getStream ( const URL url,
bool  namedCacheFile = false 
) const
virtual

§ getStream() [2/3]

std::unique_ptr< IOChannel > gnash::StreamProvider::getStream ( const URL url,
const std::string &  postdata,
bool  namedCacheFile = false 
) const
virtual

Get a stream from the response of a POST operation.

Returned stream ownership is transferred to caller.

On error NULL is returned Derive from this for a CachingStreamProvider

Parameters
urlThe url to post to.
postdataPost data in url-encoded form.

References _, allow(), gnash::log_error(), gnash::makeFileChannel(), gnash::NetworkAdapter::makeStream(), namingPolicy(), gnash::URL::path(), path, gnash::URL::protocol(), gnash::URL::str(), and url.

§ getStream() [3/3]

std::unique_ptr< IOChannel > gnash::StreamProvider::getStream ( const URL url,
const std::string &  postdata,
const NetworkAdapter::RequestHeaders headers,
bool  namedCacheFile = false 
) const
virtual

§ namingPolicy()

const NamingPolicy& gnash::StreamProvider::namingPolicy ( ) const
inline

Return the currently selected policy for converting URL to filename.

References gnash::URLAccessManager::allow().

Referenced by getStream().

§ setNamingPolicy()

void gnash::StreamProvider::setNamingPolicy ( std::unique_ptr< NamingPolicy np)
inline

Set the NamingPolicy for cache files.

This is only used when cache file naming is requested in getStream() This StreamProvider owns the NamingPolicy instance.


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