streamdirectoryservice.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2008-2009  Tim Fechtner < urwald at users dot sourceforge dot net >
00003 
00004     This program is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU General Public License as
00006     published by the Free Software Foundation; either version 2 of
00007     the License or (at your option) version 3 or any later version
00008     accepted by the membership of KDE e.V. (or its successor approved
00009     by the membership of KDE e.V.), which shall act as a proxy
00010     defined in Section 14 of version 3 of the license.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include "streamdirectoryservice.h"
00022 
00023 #include "stationdirectorytree.h"
00024 
00025 streamDirectoryService::streamDirectoryService(QObject *parent) : QObject(parent)
00026 {
00027   internal_enabled = true;
00028   fetchIsRunning = false;
00029 }
00030 
00031 streamDirectoryService::~streamDirectoryService()
00032 {
00033   helper_stop();
00034 }
00035 
00036 void streamDirectoryService::addStreamToWidget(const QString & genre,
00037                                                const QString & streamName,
00038                                                const quint64 bitrate,
00039                                                const QString & currentlyPlaying)
00040 {
00041   if (widget) {
00042     widget->addStreamToWidget(this, genre, streamName, bitrate, currentlyPlaying);
00043   };
00044 }
00045 
00046 bool streamDirectoryService::isEnabled() const
00047 {
00048   return internal_enabled;
00049 }
00050 
00051 void streamDirectoryService::setEnabled(const bool value)
00052 {
00053   if (internal_enabled != value) {
00054     internal_enabled = value;
00055     if (widget) {
00056       if (value) {
00057         helper_start();
00058       } else {
00059         helper_stop();
00060       };
00061     };
00062   };
00063 }
00064 
00065 void streamDirectoryService::setWidget(stationDirectoryTree *newWidget)
00066 {
00067   if (widget != newWidget) {
00068     helper_stop();
00069     widget = newWidget;
00070     if (isEnabled() && widget) {
00071       helper_start();
00072     };
00073   };
00074 }
00075 
00076 void streamDirectoryService::helper_start()
00077 {
00078   if (!fetchIsRunning) {
00079     fetchIsRunning = true;
00080     kickOffStreamFetch();
00081   };
00082 }
00083 
00084 void streamDirectoryService::helper_stop()
00085 {
00086   if (fetchIsRunning) {
00087     fetchIsRunning = false;
00088     stopStreamFetch();
00089     if (widget) {
00090       widget->removeAllStreamsOfThisService(this);
00091     };
00092   };
00093 }

Generated on Sat May 2 10:43:44 2009 for kradioripper by  doxygen 1.5.6