#include <streamdirectoryservice.h>
Public Member Functions | |
streamDirectoryService (QObject *parent=0) | |
virtual | ~streamDirectoryService () |
bool | isEnabled () const |
void | setEnabled (const bool value) |
Protected Member Functions | |
void | addStreamToWidget (const QString &genre, const QString &streamName, const quint64 bitrate, const QString ¤tlyPlaying=QString()) |
virtual void | kickOffStreamFetch ()=0 |
virtual void | stopStreamFetch ()=0 |
Properties | |
bool | enabled |
Private Member Functions | |
void | helper_start () |
void | helper_stop () |
void | setWidget (stationDirectoryTree *newWidget) |
Private Attributes | |
bool | fetchIsRunning |
bool | internal_enabled |
QPointer< stationDirectoryTree > | widget |
Friends | |
class | stationDirectoryTree |
This is the abstract base class for service plugins for the stationDirectoryTree widget. Each plugin makes a streams from a specific service (for example http://shoutcast.com) available for a stationDirectoryTree widget. With the property enabled, you can enable or disable the plugin.
To register plugins in stationDirectoryTree, please see the documentation of stationDirectoryTree.
To implement plugins, you have to implement asynchroniously the processing. Reimplement virtual void kickOffStreamFetch() = 0;
in a way that it just kicks off the fetching of the stream - and returns imediatly. (You can do this with the KIO library of maybe also with threads). Once the data has arrived, process it and use addStreamToWidget() to make the streams available. Furthermore, you have to implement virtual void stopStreamFetch() = 0;
, which stopps all fetching and processing of data. You don't have to worry about removing existing items from the widget - this is done automatically.
Definition at line 45 of file streamdirectoryservice.h.
streamDirectoryService::streamDirectoryService | ( | QObject * | parent = 0 |
) | [explicit] |
Constructor of the class.
parent | Sets the parent widget of this object. It is not necessary to use the stationDirectoryTree object as parent, but it is possible. |
Definition at line 25 of file streamdirectoryservice.cpp.
References fetchIsRunning, and internal_enabled.
streamDirectoryService::~streamDirectoryService | ( | ) | [virtual] |
The desctructor.
Definition at line 31 of file streamdirectoryservice.cpp.
References helper_stop().
bool streamDirectoryService::isEnabled | ( | ) | const |
See property enabled.
Definition at line 46 of file streamdirectoryservice.cpp.
References internal_enabled.
Referenced by setWidget().
void streamDirectoryService::setEnabled | ( | const bool | value | ) |
See property enabled.
Definition at line 51 of file streamdirectoryservice.cpp.
References helper_start(), helper_stop(), internal_enabled, and widget.
void streamDirectoryService::addStreamToWidget | ( | const QString & | genre, | |
const QString & | streamName, | |||
const quint64 | bitrate, | |||
const QString & | currentlyPlaying = QString() | |||
) | [protected] |
Adds a stream entry with the specified values to the stationDirectoryTree widget where this object is used as plugin.
Use this function in your implementation of kickOffStreamFetch(). TODO Parameter dokumentieren
Definition at line 36 of file streamdirectoryservice.cpp.
References widget.
virtual void streamDirectoryService::kickOffStreamFetch | ( | ) | [protected, pure virtual] |
This function kicks of the fetching of the stream list.
The fetching of the stream list must be asynchronious. This function only kicks of the necessary processes, but it expected to return itself imediatly.
Once the information that you have requested from the internet is available, process it and use addStreamToWidget() to make it available.
Referenced by helper_start().
virtual void streamDirectoryService::stopStreamFetch | ( | ) | [protected, pure virtual] |
This function stopps all running file transfers from the internet and stopps all processing of data. It is expected, that after calling this function, there will be no call of addStreamToWidget() anymore (until kickOffStreamFetch() is called the next time).
You don't have to worry about removing existing items from the widget - this is done automatically.
Referenced by helper_stop().
void streamDirectoryService::helper_start | ( | ) | [private] |
Helper function to start the fetching of the stream list.
Definition at line 76 of file streamdirectoryservice.cpp.
References fetchIsRunning, and kickOffStreamFetch().
Referenced by setEnabled(), and setWidget().
void streamDirectoryService::helper_stop | ( | ) | [private] |
Helper function to stop the fetching of the stream list and to remove all stream of this plugin from widget.
Definition at line 84 of file streamdirectoryservice.cpp.
References fetchIsRunning, stopStreamFetch(), and widget.
Referenced by setEnabled(), setWidget(), and ~streamDirectoryService().
void streamDirectoryService::setWidget | ( | stationDirectoryTree * | newWidget | ) | [private] |
Registers this object as plugin of the specified stationDirectoryTree widget.
Although this function is private, it is acessible from stationDirectoryTree because of a friend declaration.
newWidget | A pointer to the widget where this object is registered as plugin. Can also be set to 0 to unregister the object. |
Definition at line 65 of file streamdirectoryservice.cpp.
References helper_start(), helper_stop(), isEnabled(), and widget.
Referenced by stationDirectoryTree::registerPlugin().
friend class stationDirectoryTree [friend] |
Definition at line 50 of file streamdirectoryservice.h.
bool streamDirectoryService::fetchIsRunning [private] |
Used to remember if the object is fetching the stream directory data. This is only possible if the widget is enabled and registered as plugin.
It is used and managed by helper_start() and helper_stop().
Definition at line 105 of file streamdirectoryservice.h.
Referenced by helper_start(), helper_stop(), and streamDirectoryService().
bool streamDirectoryService::internal_enabled [private] |
Used internally to store the property enabled.
Definition at line 112 of file streamdirectoryservice.h.
Referenced by isEnabled(), setEnabled(), and streamDirectoryService().
QPointer<stationDirectoryTree> streamDirectoryService::widget [private] |
A pointer to the stationDirectoryTree where this object is used as plugin. If you want to register this object as plugin, don't set this directly, but use setWidget()!
Definition at line 115 of file streamdirectoryservice.h.
Referenced by addStreamToWidget(), helper_stop(), setEnabled(), and setWidget().
bool streamDirectoryService::enabled [read, write] |
This property holds whether the plugin is enabled.
If the plugin is disabled, it's streams will not be shown in stationDirectoryTree.
bool isEnabled() const
void setEnabled(const bool value)
bool internal_enabled
Definition at line 60 of file streamdirectoryservice.h.