FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
BrowserStream.cpp
1 /**********************************************************\
2 Original Author: Matthias (nitrogenycs)
3 
4 Created: Feb 28, 2010
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2010 PacketPass, Inc and the Firebreath development team
13 \**********************************************************/
14 
15 #include "BrowserStream.h"
16 #include "precompiled_headers.h" // On windows, everything above this line in PCH
17 
18 using namespace FB;
19 
20 // browser stream
21 BrowserStream::BrowserStream(const std::string& Url, bool Cache, bool SeekableRequested, size_t InternalBufferSize)
22  : url(Url)
23  , seekableRequested(SeekableRequested)
24  , seekableByServer(false)
25  , cached(Cache)
26  , internalBufferSize(InternalBufferSize)
27  , length(0)
28  , completed(false)
29  , opened(false)
30 {
31 }
32 
34 {
35  StreamDestroyedEvent ev(this);
36  SendEvent( &ev );
37 }
38 
39 bool BrowserStream::readRange( size_t start, size_t end )
40 {
41  return readRanges( std::vector<Range>( 1, Range(start, end) ) );
42 }
43 
44 std::string BrowserStream::getUrl() const
45 {
46  return url;
47 }
48 
50 {
51  return seekableRequested;
52 }
53 
55 {
56  return seekableByServer;
57 }
58 
60 {
62 }
63 
65 {
66  return cached;
67 }
68 
70 {
71  return opened;
72 }
73 
75 {
76  return completed;
77 }
78 
79 std::string BrowserStream::getMimeType() const
80 {
81  return mimeType;
82 }
83 
84 std::wstring BrowserStream::getCacheFilename() const
85 {
86  return cacheFilename;
87 }
88 
89 std::string BrowserStream::getHeaders() const
90 {
91  return headers;
92 }
93 
95 {
96  return length;
97 }
98 
100 {
101  return internalBufferSize;
102 }
103 
104 
105 
106 void BrowserStream::setSeekableByServer(bool SeekableByServer)
107 {
108  seekableByServer = SeekableByServer;
109 }
110 
111 void BrowserStream::setCached(bool Cached)
112 {
113  cached = Cached;
114 }
115 
116 void BrowserStream::setOpen(bool Opened)
117 {
118  opened = Opened;
119 }
120 
121 void BrowserStream::setCompleted(bool Completed)
122 {
123  completed = Completed;
124 }
125 
126 void BrowserStream::setUrl(const std::string& Url)
127 {
128  url = Url;
129 }
130 
131 void BrowserStream::setHeaders(const std::string& Headers)
132 {
133  headers = Headers;
134 }
135 
136 void BrowserStream::setMimeType(const std::string& MimeType)
137 {
138  mimeType = MimeType;
139 }
140 
141 void BrowserStream::setCacheFilename(const std::wstring& CacheFilename)
142 {
143  cacheFilename = CacheFilename;
144 }
145 
146 void BrowserStream::setLength(size_t Length)
147 {
148  length = Length;
149 }
150 
151 void BrowserStream::setInternalBufferSize(size_t InternalBufferSize)
152 {
153  internalBufferSize = InternalBufferSize;
154 }
155 
156 // range
157 
158 BrowserStream::Range::Range(size_t Start, size_t End) : start(Start), end(End)
159 {
160 }
161 
virtual bool isSeekableRequested() const
Returns true if a stream was requested to be seekable. Not all servers support this.
virtual std::string getMimeType() const
Returns the mime type of this stream, e.g. "text/plain".
Specifies the range for a read range request (start to end) in bytes.
Definition: BrowserStream.h:51
virtual bool isCached() const
Returns true if the content of this stream should be cached (i.e. a physical file must be created)...
virtual bool isOpen() const
Returns true if the stream is open.
virtual bool readRanges(const std::vector< Range > &ranges)=0
Same functionality as BrowserStream::readRange( size_t start, size_t end ), except multiple ranges ca...
BrowserStream(const std::string &url, bool cache, bool requestSeekable, size_t internalBufferSize)
Default constructor. Dont't use directly, use BrowserHost::createStream instead.
virtual ~BrowserStream()
Destructor.
virtual size_t getLength() const
Returns the length of the stream in bytes (if server gives info like content-length).
virtual std::wstring getCacheFilename() const
If this is a cached stream, returns the physical filename of the file in the browser's cache...
virtual std::string getHeaders() const
Returns the http headers.
virtual bool isSeekable() const
Returns true if a stream was requested to be seekable and the server supports it. ...
virtual size_t getInternalBufferSize() const
Returns the size of the internal buffer used by this stream.
virtual bool isCompleted() const
Returns true if download of this stream is completed (e.g. due to error or download finished)...
virtual std::string getUrl() const
Returns the url associated with this stream. This is the url supplied to.
virtual bool SendEvent(PluginEvent *evt)
Sends an event to all attached sinks.
virtual bool readRange(size_t start, size_t end)
Performs a read range request, returns the bytes in the range [start, end).
virtual bool isSeekableByServer() const
Returns true if the stream is actually seekable (server says so).