Gnash  0.8.11dev
StreamProvider.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_STREAMPROVIDER_H
20 #define GNASH_STREAMPROVIDER_H
21 
22 #include "NetworkAdapter.h"
23 #include "dsodefs.h" // for DSOEXPORT
24 #include "NamingPolicy.h"
25 
26 #include <string>
27 #include <memory>
28 
29 // Forward declarations
30 namespace gnash {
31  class URL;
32  class IOChannel;
33 }
34 
35 
36 namespace gnash {
37 
39 //
47 //
50 {
51 public:
52 
54  //
59  StreamProvider(URL original, URL base,
60  std::unique_ptr<NamingPolicy> np =
61  std::unique_ptr<NamingPolicy>(new NamingPolicy));
62 
63  virtual ~StreamProvider() {}
64 
66  //
69  virtual std::unique_ptr<IOChannel> getStream(const URL& url,
70  bool namedCacheFile = false) const;
71 
73  //
81  virtual std::unique_ptr<IOChannel> getStream(const URL& url,
82  const std::string& postdata, bool namedCacheFile = false) const;
83 
84  virtual std::unique_ptr<IOChannel> getStream(const URL& url,
85  const std::string& postdata,
86  const NetworkAdapter::RequestHeaders& headers,
87  bool namedCacheFile = false) const;
88 
90  //
93  void setNamingPolicy(std::unique_ptr<NamingPolicy> np) {
94  _namingPolicy = std::move(np);
95  }
96 
98  const NamingPolicy& namingPolicy() const {
99  assert(_namingPolicy.get());
100  return *_namingPolicy;
101  }
102 
104  //
108  //
111  bool allow(const URL& url) const;
112 
114  //
117  const URL& baseURL() const {
118  return _base;
119  }
120 
121 private:
122 
124  std::unique_ptr<NamingPolicy> _namingPolicy;
125 
126  const URL _base;
127 
128  const URL _original;
129 
130 };
131 
132 } // namespace gnash
133 
134 #endif
135 
136 
137 // Local Variables:
138 // mode: C++
139 // indent-tabs-mode: t
140 // End:
void setNamingPolicy(std::unique_ptr< NamingPolicy > np)
Set the NamingPolicy for cache files.
Definition: StreamProvider.h:93
const NamingPolicy & namingPolicy() const
Return the currently selected policy for converting URL to filename.
Definition: StreamProvider.h:98
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
virtual ~StreamProvider()
Definition: StreamProvider.h:63
bool allow(const URL &url, const URL &baseurl)
Return true if access to given url is allowed, false otherwise.
Definition: URLAccessManager.cpp:273
#define DSOEXPORT
Definition: dsodefs.h:55
const URL & baseURL() const
The base URL that should be used to resolve all relative URLs.
Definition: StreamProvider.h:117
std::map< std::string, std::string, StringNoCaseLessThan > RequestHeaders
Definition: NetworkAdapter.h:43
std::string url
Definition: gnash.cpp:59
A StreamProvider makes IOChannels available to the core on request.
Definition: StreamProvider.h:49
Definition: NamingPolicy.h:31
Uniform Resource Locator.
Definition: URL.h:34