FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
DefaultBrowserStreamHandler.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 "precompiled_headers.h" // On windows, everything above this line in PCH
16 #include "DefaultBrowserStreamHandler.h"
17 
18 using namespace FB;
19 
20 // default stream handler
22 {
23 }
24 
26 {
27 }
28 
30 {
31  assert(Stream != NULL);
32  setStream( ptr_cast<BrowserStream>(Stream->shared_from_this()) );
33  return false;
34 }
35 
37 {
38  clearStream();
39  return false;
40 }
41 
43 {
44  FB::BrowserStreamPtr ptr(getStream());
45  return ptr && ptr->close();
46 }
47 
49 {
50  return false;
51 }
52 
54 {
55  clearStream();
56  return false;
57 }
58 
60 {
61  // process data
62  return false;
63 }
64 
66 {
67  return false;
68 }
69 
71 {
72  return false;
73 }
74 
76 {
77  return false;
78 }
79 
80 const FB::BrowserStreamPtr& DefaultBrowserStreamHandler::getStream() const
81 {
82  return stream;
83 }
84 
85 void DefaultBrowserStreamHandler::setStream(const FB::BrowserStreamPtr& Stream)
86 {
87  if ( this->stream && Stream )
88  {
89  // attempt to overwrite the stream, strange
90  assert(false);
91  }
92  this->stream = Stream;
93 }
94 
96 {
97  stream.reset();
98 }
99 
virtual bool onStreamCompleted(FB::StreamCompletedEvent *evt, FB::BrowserStream *)
Called when the stream finished downloading successfully.
This event is fired when the given stream was created.
Definition: StreamEvents.h:48
virtual bool onStreamAttached(FB::AttachedEvent *evt, FB::BrowserStream *Stream)
Called when the stream is attached to this handler (may have already been created).
virtual bool onStreamDetached(FB::DetachedEvent *evt, FB::BrowserStream *Stream)
Called when the stream is detached from this handler (may not have been destroyed).
This is the abstract base class (interface class) for a browser stream.
Definition: BrowserStream.h:41
virtual void setStream(const FB::BrowserStreamPtr &stream)
Call to set the stream associated with this handler.
virtual bool onStreamFailedOpen(FB::StreamFailedOpenEvent *evt, FB::BrowserStream *)
Called when the stream failed to open.
virtual const FB::BrowserStreamPtr & getStream() const
Call to get the stream associated with this handler. Returns empty shared_ptr if none.
virtual bool onStreamDestroyed(FB::StreamDestroyedEvent *evt, FB::BrowserStream *)
Called when the stream is destroyed.
virtual bool onStreamDataArrived(FB::StreamDataArrivedEvent *evt, FB::BrowserStream *)
Called when data arrives.
BrowserStreamPtr stream
stream instance, don't use yourself
This event is fired when a stream failed to open, e.g. the url was invalid or a seekable stream was r...
Definition: StreamEvents.h:120
virtual bool onStreamOpened(FB::StreamOpenedEvent *evt, FB::BrowserStream *)
Called when the stream was opened successfully.
Fired when a PluginEventSink is attached to a PluginEventSource (such as a PluginCore derived plugin ...
Definition: AttachedEvent.h:29
virtual bool cancel()
Cancels the stream.
virtual void clearStream()
Call to clear the stream associated with this handler.
Fired when a PluginEventSink is detached from a PluginEventSource (such as a PluginCore derived plugi...
Definition: AttachedEvent.h:39
This event is fired when a stream has completed downloading.
Definition: StreamEvents.h:148
virtual bool onStreamCreated(FB::StreamCreatedEvent *evt, FB::BrowserStream *Stream)
Called when the stream was created.