FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
StreamEvents.h
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 Richard Bateman, Firebreath development team
13 \**********************************************************/
14 
15 #pragma once
16 #ifndef H_FB_PLUGINEVENTS_STREAMEVENTS
17 #define H_FB_PLUGINEVENTS_STREAMEVENTS
18 
19 #include "../PluginEvent.h"
20 
21 namespace FB {
22  class BrowserStream;
23 
31  class StreamEvent : public PluginEvent
32  {
33  public:
34  StreamEvent(BrowserStream* Stream) : stream(Stream)
35  {}
36 
37  public:
38  BrowserStream* stream;
39  };
40 
49  {
50  public:
52  {}
53  };
54 
62  class StreamDestroyedEvent : public StreamEvent
63  {
64  public:
65  StreamDestroyedEvent(BrowserStream* stream) : StreamEvent(stream)
66  {}
67  };
68 
76  class StreamDataArrivedEvent : public StreamEvent
77  {
78  public:
79  StreamDataArrivedEvent( BrowserStream* stream, const void* Data, const size_t Length, const size_t DataPosition, const float Progress ) : StreamEvent(stream), data(Data), length(Length), dataPosition(DataPosition), progress(Progress)
80  {}
81 
83  const void* getData() const
84  {
85  return data;
86  }
87 
89  const size_t getLength() const
90  {
91  return length;
92  }
93 
95  const size_t getDataPosition() const
96  {
97  return dataPosition;
98  }
99 
101  const float getProgress() const
102  {
103  return progress;
104  }
105  protected:
106  const void* data; // the data
107  const size_t length; // length of the data in bytes
108  const size_t dataPosition; // the position in the stream where the data starts (e.g. 0 if the data starts at the beginning)
109  const float progress; // the current progress in percent (0-100). 0 if progress is unknown (stream length not known in advance).
110  };
111 
121  {
122  public:
124  {}
125  };
126 
134  class StreamOpenedEvent : public StreamEvent
135  {
136  public:
137  StreamOpenedEvent(BrowserStream* stream) : StreamEvent(stream)
138  {}
139  };
140 
149  {
150  public:
151  StreamCompletedEvent(BrowserStream* stream, bool Success) : StreamEvent(stream), success(Success)
152  {}
153 
154  public:
155  bool success;
156  };
157 };
158 
159 #endif // H_FB_PLUGINEVENTS_STREAMEVENTS
160 
This event is fired when the given stream was created.
Definition: StreamEvents.h:48
This is the abstract base class (interface class) for a browser stream.
Definition: BrowserStream.h:41
Base class for all stream events.
Definition: StreamEvents.h:31
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
Plugin event base class.
Definition: PluginEvent.h:36
This event is fired when a stream has completed downloading.
Definition: StreamEvents.h:148