summaryrefslogtreecommitdiffstats
path: root/kradio3/src/include
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 18:23:26 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 18:23:26 +0000
commitae364d9bed0589bf1a22cd5f530c563462379e3e (patch)
treee32727e2664e7ce68d0d30270afa040320ae35a1 /kradio3/src/include
downloadtderadio-ae364d9bed0589bf1a22cd5f530c563462379e3e.tar.gz
tderadio-ae364d9bed0589bf1a22cd5f530c563462379e3e.zip
Added old KDE3 version of kradio
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kradio@1094417 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kradio3/src/include')
-rw-r--r--kradio3/src/include/aboutwidget.h147
-rw-r--r--kradio3/src/include/alarm.h104
-rw-r--r--kradio3/src/include/debug-profiler.h112
-rw-r--r--kradio3/src/include/errorlog-interfaces.h64
-rw-r--r--kradio3/src/include/fileringbuffer.h71
-rw-r--r--kradio3/src/include/frequencyradiostation.h83
-rw-r--r--kradio3/src/include/frequencyseekhelper.h77
-rw-r--r--kradio3/src/include/gui_list_helper.h174
-rw-r--r--kradio3/src/include/interfaces.h714
-rw-r--r--kradio3/src/include/internetradiostation.h75
-rw-r--r--kradio3/src/include/kradioapp.h120
-rw-r--r--kradio3/src/include/kradioversion.h23
-rw-r--r--kradio3/src/include/multibuffer.h65
-rw-r--r--kradio3/src/include/plugin_configuration_dialog.h74
-rw-r--r--kradio3/src/include/pluginmanager-configuration.h60
-rw-r--r--kradio3/src/include/pluginmanager.h147
-rw-r--r--kradio3/src/include/plugins.h192
-rw-r--r--kradio3/src/include/radio_interfaces.h117
-rw-r--r--kradio3/src/include/radiodevice_interfaces.h353
-rw-r--r--kradio3/src/include/radiodevicepool_interfaces.h75
-rw-r--r--kradio3/src/include/radiostation-config.h79
-rw-r--r--kradio3/src/include/radiostation-listview.h83
-rw-r--r--kradio3/src/include/radiostation.h164
-rw-r--r--kradio3/src/include/ringbuffer.h58
-rw-r--r--kradio3/src/include/seekhelper.h83
-rw-r--r--kradio3/src/include/sound_metadata.h50
-rw-r--r--kradio3/src/include/soundformat.h75
-rw-r--r--kradio3/src/include/soundstreamclient_interfaces.h372
-rw-r--r--kradio3/src/include/soundstreamid.h63
-rw-r--r--kradio3/src/include/standardscandialog.h100
-rw-r--r--kradio3/src/include/station-drag-object.h39
-rw-r--r--kradio3/src/include/stationlist.h159
-rw-r--r--kradio3/src/include/stationlistmetadata.h55
-rw-r--r--kradio3/src/include/stationlistxmlhandler.h85
-rw-r--r--kradio3/src/include/stationselection_interfaces.h67
-rw-r--r--kradio3/src/include/stationselector.h99
-rw-r--r--kradio3/src/include/timecontrol_interfaces.h106
-rw-r--r--kradio3/src/include/utils.h47
-rw-r--r--kradio3/src/include/widgetplugins.h75
39 files changed, 4706 insertions, 0 deletions
diff --git a/kradio3/src/include/aboutwidget.h b/kradio3/src/include/aboutwidget.h
new file mode 100644
index 0000000..c2a8562
--- /dev/null
+++ b/kradio3/src/include/aboutwidget.h
@@ -0,0 +1,147 @@
+/***************************************************************************
+ aboutwidget.h - description
+ -------------------
+ begin : Sa Sep 13 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_ABOUT_WIDGET_H
+#define KRADIO_ABOUT_WIDGET_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <qwidget.h>
+
+/* Unfortunately KDE doesn't provide the class KAboutContainerBase
+ to public programming, so we have to copy most of that code into
+ an own class :(
+*/
+
+class QFrame;
+class KAboutContainer;
+class QTabWidget;
+class QVBoxLayout;
+class KAboutData;
+
+#include <qlabel.h>
+
+// copied (and renamed) from kaboutdialog_private.h
+// original: KImageTrackLabel
+
+class KRadioImageTrackLabel : public QLabel
+{
+ Q_OBJECT
+
+ public:
+ enum MouseMode
+ {
+ MousePress = 1,
+ MouseRelease,
+ MouseDoubleClick,
+ MouseMove
+ };
+
+ public:
+ KRadioImageTrackLabel( QWidget * parent, const char * name=0, WFlags f=0 );
+
+ signals:
+ void mouseTrack( int mode, const QMouseEvent *e );
+
+ protected:
+ virtual void mousePressEvent( QMouseEvent *e );
+ virtual void mouseReleaseEvent( QMouseEvent *e );
+ virtual void mouseDoubleClickEvent( QMouseEvent *e );
+ virtual void mouseMoveEvent ( QMouseEvent *e );
+};
+
+// copied (and renamed) from kaboutdialog_private.h
+// original: KAboutContainerBase
+
+class KRadioAboutWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ enum LayoutType
+ {
+ AbtPlain = 0x0001,
+ AbtTabbed = 0x0002,
+ AbtTitle = 0x0004,
+ AbtImageLeft = 0x0008,
+ AbtImageRight = 0x0010,
+ AbtImageOnly = 0x0020,
+ AbtProduct = 0x0040,
+ AbtKDEStandard = AbtTabbed|AbtTitle|AbtImageLeft,
+ AbtAppStandard = AbtTabbed|AbtTitle|AbtProduct,
+ AbtImageAndTitle = AbtPlain|AbtTitle|AbtImageOnly
+ };
+
+ public:
+ KRadioAboutWidget(const KAboutData &abtData, int layoutType, QWidget *parent = 0, char *name = 0);
+ virtual void show( void );
+ virtual QSize sizeHint( void ) const;
+
+ void setAboutData(const KAboutData &abtData);
+
+ void setTitle( const QString &title );
+ void setImage( const QString &fileName );
+ void setImageBackgroundColor( const QColor &color );
+ void setImageFrame( bool state );
+ void setProduct( const QString &appName, const QString &version,
+ const QString &author, const QString &year );
+
+ QFrame *addTextPage( const QString &title, const QString &text,
+ bool richText=false, int numLines=10 );
+ QFrame *addLicensePage( const QString &title, const QString &text,
+ int numLines=10 );
+ KAboutContainer *addContainerPage( const QString &title,
+ int childAlignment = AlignCenter, int innerAlignment = AlignCenter );
+ KAboutContainer *addScrolledContainerPage( const QString &title,
+ int childAlignment = AlignCenter, int innerAlignment = AlignCenter );
+
+ QFrame *addEmptyPage( const QString &title );
+
+ KAboutContainer *addContainer( int childAlignment, int innerAlignment );
+
+ public slots:
+ virtual void slotMouseTrack( int mode, const QMouseEvent *e );
+ virtual void slotUrlClick( const QString &url );
+ virtual void slotMailClick( const QString &name, const QString &address );
+
+ protected:
+ virtual void fontChange( const QFont &oldFont );
+
+ signals:
+ void mouseTrack( int mode, const QMouseEvent *e );
+ void urlClick( const QString &url );
+ void mailClick( const QString &name, const QString &address );
+
+ private:
+ QMemArray<QWidget*> mContainerList;
+
+ QVBoxLayout *mTopLayout;
+ KRadioImageTrackLabel *mImageLabel;
+ QLabel *mTitleLabel;
+ QLabel *mIconLabel;
+ QLabel *mVersionLabel;
+ QLabel *mAuthorLabel;
+ QFrame *mImageFrame;
+ QTabWidget *mPageTab;
+ QFrame *mPlainSpace;
+};
+
+
+#endif
diff --git a/kradio3/src/include/alarm.h b/kradio3/src/include/alarm.h
new file mode 100644
index 0000000..45cb397
--- /dev/null
+++ b/kradio3/src/include/alarm.h
@@ -0,0 +1,104 @@
+/***************************************************************************
+ alarm.h - description
+ -------------------
+ begin : Mon Feb 4 2002
+ copyright : (C) 2002 by Martin Witte / Frank Schwanz
+ email : witte@kawo1.rwth-aachen.de / schwanz@fh-brandenburg.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_ALARM_H
+#define KRADIO_ALARM_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qdatetime.h>
+#include <vector>
+
+/**
+ *@author Martin Witte
+ */
+
+class Alarm
+{
+public:
+
+ enum AlarmType { StartPlaying, StopPlaying, StartRecording, StopRecording };
+
+protected:
+ QDateTime m_time;
+
+ bool m_daily;
+ int m_weekdayMask;
+
+ bool m_enabled;
+ QString m_stationID;
+ float m_volumePreset; // < 0: disabled
+
+ AlarmType m_type;
+
+ int m_ID;
+
+ static int m_LastID;
+
+public:
+ Alarm();
+ Alarm(const QDateTime &time, bool daily, bool enabled);
+ Alarm(const Alarm &);
+ ~Alarm();
+
+ bool isEnabled() const { return m_enabled; }
+ bool isDaily() const { return m_daily; }
+ int weekdayMask() const { return m_weekdayMask; }
+ QDateTime alarmTime () const { return m_time; }
+ QDateTime nextAlarm (bool ignoreEnable = false) const;
+ const QString &stationID () const { return m_stationID; }
+ float volumePreset () const { return m_volumePreset; }
+ AlarmType alarmType() const { return m_type; }
+
+ int ID() const { return m_ID; }
+
+ void setEnabled (bool enable = true) { m_enabled = enable; }
+ void setDaily (bool d = true) { m_daily = d; }
+ void setWeekdayMask(int m = 0x7F) { m_weekdayMask = m; }
+ void setDate (const QDate &d) { m_time.setDate(d); }
+ void setTime (const QTime &d) { m_time.setTime(d); }
+ void setVolumePreset(float v) { m_volumePreset = v; }
+ void setStationID(const QString &id) { m_stationID = id;}
+ void setAlarmType(AlarmType t) { m_type = t; }
+
+
+ bool operator == (const Alarm &x) const {
+ return
+ m_time == x.m_time &&
+ m_daily == x.m_daily &&
+ m_weekdayMask == x.m_weekdayMask &&
+ m_enabled == x.m_enabled &&
+ m_stationID == x.m_stationID &&
+ m_volumePreset == x.m_volumePreset &&
+ m_type == x.m_type &&
+ m_ID == x.m_ID;
+ }
+ bool operator != (const Alarm &x) const { return ! operator == (x); }
+
+};
+
+using namespace std;
+
+typedef vector<Alarm> AlarmVector;
+typedef AlarmVector::iterator iAlarmVector;
+typedef AlarmVector::const_iterator ciAlarmVector;
+
+
+
+#endif
diff --git a/kradio3/src/include/debug-profiler.h b/kradio3/src/include/debug-profiler.h
new file mode 100644
index 0000000..969008a
--- /dev/null
+++ b/kradio3/src/include/debug-profiler.h
@@ -0,0 +1,112 @@
+/***************************************************************************
+ debug-profiler.h - description
+ -------------------
+ begin : Sat May 28 2005
+ copyright : (C) 2005 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_DEBUG_PROFILER_H
+#define KRADIO_DEBUG_PROFILER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstring.h>
+#include <qmap.h>
+
+#if (defined __i386__) || (defined __x86_64__)
+static __inline__ unsigned long long int rdtsc()
+{
+ unsigned int a, d;
+ asm volatile("rdtsc" : "=a" (a), "=d" (d));
+ return ((unsigned long long)a) | (((unsigned long long)d) << 32);
+}
+#else
+static __inline__ unsigned long long int rdtsc()
+{
+ return 0UL;
+}
+#endif
+
+class Profiler
+{
+public:
+ Profiler();
+ virtual ~Profiler();
+
+ void startProfile(const QString &descr);
+ void stopProfile (const QString &descr);
+
+ void printData();
+
+protected:
+
+ virtual long long getCounter() const = 0;
+
+ void stopInternalCounter();
+ void startInternalCounter();
+
+ long long m_internalCounter;
+ long long m_tmpStartVal;
+
+ struct profile_data
+ {
+ profile_data(long long start = 0) :
+ startCounter(start), accumulatedCounter(0), callCounter(0),
+ minCounter(0x7FFFFFFFFFFFFFFFll), maxCounter(0) {}
+ long long startCounter;
+ long long accumulatedCounter;
+ long long callCounter;
+ long long minCounter;
+ long long maxCounter;
+ };
+
+ QMap<QString, profile_data> m_ProfileData;
+};
+
+
+class TimeProfiler : public Profiler
+{
+protected:
+ long long getCounter() const { return rdtsc(); }
+};
+
+
+class MemProfiler : public Profiler
+{
+protected:
+ long long getCounter() const;
+};
+
+
+extern TimeProfiler global_time_profiler;
+extern MemProfiler global_mem_profiler;
+
+
+
+class BlockProfiler
+{
+public:
+ BlockProfiler(const QString &descr);
+ ~BlockProfiler();
+
+ void stop();
+
+protected:
+ QString m_Description;
+};
+
+
+
+#endif
diff --git a/kradio3/src/include/errorlog-interfaces.h b/kradio3/src/include/errorlog-interfaces.h
new file mode 100644
index 0000000..a480927
--- /dev/null
+++ b/kradio3/src/include/errorlog-interfaces.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ errorlog-interfaces.h - description
+ -------------------
+ begin : Sa Sep 13 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_ERRORLOG_INTERFACES_H
+#define KRADIO_ERRORLOG_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "interfaces.h"
+
+INTERFACE(IErrorLog, IErrorLogClient)
+{
+public :
+ IErrorLog();
+ virtual ~IErrorLog();
+
+RECEIVERS:
+ IF_RECEIVER( logError (const QString &) )
+ IF_RECEIVER( logWarning(const QString &) )
+ IF_RECEIVER( logInfo (const QString &) )
+ IF_RECEIVER( logDebug (const QString &) )
+};
+
+
+INTERFACE(IErrorLogClient, IErrorLog)
+{
+public :
+ IF_CON_DESTRUCTOR(IErrorLogClient, -1)
+
+public:
+ IF_SENDER ( sendLogError (const QString &) )
+ IF_SENDER ( sendLogWarning(const QString &) )
+ IF_SENDER ( sendLogInfo (const QString &) )
+ IF_SENDER ( sendLogDebug (const QString &) )
+
+ void logError (const QString &s) const { sendLogError(s); }
+ void logWarning(const QString &s) const { sendLogWarning(s); }
+ void logInfo (const QString &s) const { sendLogInfo(s); }
+ void logDebug (const QString &s) const { sendLogDebug(s); }
+
+ static void staticLogError (const QString &s);
+ static void staticLogWarning(const QString &s);
+ static void staticLogInfo (const QString &s);
+ static void staticLogDebug (const QString &s);
+};
+
+
+#endif
diff --git a/kradio3/src/include/fileringbuffer.h b/kradio3/src/include/fileringbuffer.h
new file mode 100644
index 0000000..3447277
--- /dev/null
+++ b/kradio3/src/include/fileringbuffer.h
@@ -0,0 +1,71 @@
+/***************************************************************************
+ ringbuffer.h - description
+ -------------------
+ begin : Sun March 21 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KRADIO_FILE_RING_BUFFER_H
+#define _KRADIO_FILE_RING_BUFFER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstring.h>
+#include <stdio.h>
+
+class FileRingBuffer
+{
+public:
+ FileRingBuffer(const QString &filename, Q_UINT64 max_size);
+ ~FileRingBuffer();
+
+ bool resize(const QString &filename, Q_UINT64 new_max_size);
+
+ size_t addData (const char *src, size_t size);
+ size_t takeData(char *dst, size_t size);
+ Q_UINT64 removeData(Q_UINT64 size);
+
+ const QString &getFileName () const { return m_FileName; }
+ Q_UINT64 getMaxSize() const { return m_MaxSize; }
+ Q_UINT64 getRealSize() const { return m_RealSize; }
+ Q_UINT64 getFillSize() const { return m_FillSize; }
+ Q_UINT64 getFreeSize() const { return (m_Start + m_FillSize > m_RealSize) ? m_RealSize - m_FillSize : m_MaxSize - m_FillSize; }
+
+ void clear();
+
+ bool error() const { return m_error; }
+ const QString &errorString() const { return m_errorString; }
+
+protected:
+ Q_UINT64 getFreeSpace(Q_UINT64 &size); // returns position in file + size
+ Q_UINT64 removeFreeSpace(Q_UINT64 size);
+
+ Q_UINT64 getData(Q_UINT64 &size); // returns position in file + size
+
+
+ int m_FileIdx;
+ QString m_BaseFileName;
+ QString m_FileName;
+ FILE *m_File;
+ Q_UINT64 m_Start;
+ Q_UINT64 m_MaxSize;
+ Q_UINT64 m_RealSize;
+ Q_UINT64 m_FillSize;
+
+ QString m_errorString;
+ bool m_error;
+};
+
+#endif
diff --git a/kradio3/src/include/frequencyradiostation.h b/kradio3/src/include/frequencyradiostation.h
new file mode 100644
index 0000000..87e4125
--- /dev/null
+++ b/kradio3/src/include/frequencyradiostation.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ frequencyradiostation.h - description
+ -------------------
+ begin : Sat March 29 2003
+ copyright : (C) 2003 by Klas Kalass, Ernst Martin Witte
+ email : klas@kde.org, witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_FREQUENCYRADIOSTATION_H
+#define KRADIO_FREQUENCYRADIOSTATION_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "radiostation.h"
+
+/**
+ * @author Klas Kalass, Ernst Martin Witte
+ */
+
+
+// Kopenhagener Wellenplan: 300kHz
+#define STATION_FREQ_INTERVAL_FM 0.3
+
+// Kopenhagener Wellenplan: 9kHz
+#define STATION_FREQ_INTERVAL_AM 0.009
+
+class FrequencyRadioStation : public RadioStation {
+public:
+ FrequencyRadioStation ();
+ FrequencyRadioStation (float frequency);
+ FrequencyRadioStation (const QString &name, const QString &shortName, float frequency);
+ FrequencyRadioStation (const FrequencyRadioStation &);
+ FrequencyRadioStation (RegisterStationClass, const QString &classname = QString::null);
+ ~FrequencyRadioStation();
+
+ float frequency() const { return m_frequency; }
+ void setFrequency (float frequency) { m_frequency = frequency; }
+
+ virtual QString longName() const;
+ virtual QString description() const;
+ virtual bool isValid () const;
+
+ /* = 0 : "this" is same as "s", i.e. approximately same frequency
+ > 0 : this.frequency > s.frequency
+ < 0 : this.frequency < s.frequency
+ other class than FrequencyRadioStation: compare typeid(.).name()
+ */
+ virtual int compare (const RadioStation &s) const;
+
+ /** returns an exact copy of this station */
+ virtual RadioStation *copy() const;
+ virtual RadioStation *copyNewID() const;
+
+ virtual RadioStationConfig *createEditor() const;
+
+ // for XML-Parsing/Export
+ virtual bool setProperty(const QString &property_name, const QString &val);
+ virtual QString getProperty(const QString &property_name) const;
+ virtual QStringList getPropertyNames() const;
+ virtual QString getClassName() const { return "FrequencyRadioStation"; }
+
+
+ virtual bool operator == (const RadioStation &x) const;
+
+protected:
+
+ float m_frequency;
+};
+
+
+
+#endif
diff --git a/kradio3/src/include/frequencyseekhelper.h b/kradio3/src/include/frequencyseekhelper.h
new file mode 100644
index 0000000..4dc529f
--- /dev/null
+++ b/kradio3/src/include/frequencyseekhelper.h
@@ -0,0 +1,77 @@
+/***************************************************************************
+ frequencyseekhelper.h - description
+ -------------------
+ begin : Fre Mai 9 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_FREQUENCY_SEEKHELPER_H
+#define KRADIO_FREQUENCY_SEEKHELPER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qobject.h>
+#include "radiodevice_interfaces.h"
+#include "seekhelper.h"
+
+class FrequencySeekHelper : public QObject,
+ public SeekHelper,
+ public IFrequencyRadioClient
+{
+Q_OBJECT
+public:
+
+ FrequencySeekHelper(ISeekRadio &parent);
+ virtual ~FrequencySeekHelper();
+
+// IFrequencyRadioClient
+RECEIVERS:
+ bool noticeFrequencyChanged(float /*f*/, const RadioStation */*s*/) { return false; }
+ bool noticeMinMaxFrequencyChanged(float /*min*/, float /*max*/) { return false; }
+ bool noticeDeviceMinMaxFrequencyChanged(float /*min*/, float /*max*/){ return false; }
+ bool noticeScanStepChanged(float /*s*/) { return false; }
+
+public:
+
+ virtual bool connectI (Interface *i);
+ virtual bool disconnectI(Interface *i);
+
+ virtual void start(const SoundStreamID &, direction_t dir);
+
+public slots:
+
+ virtual void step() { SeekHelper::step(); }
+
+protected:
+ virtual void abort();
+ virtual bool isGood() const;
+ virtual bool isBetter() const;
+ virtual bool isWorse() const;
+ virtual bool bestFound() const;
+ virtual void getData();
+ virtual void rememberBest();
+ virtual bool nextSeekStep();
+ virtual void applyBest();
+
+protected:
+ QTimer *m_timer;
+
+ float m_currentSignal, m_oldSignal;
+ bool m_goodSignal;
+ float m_currentFrequency, m_oldFrequency;
+ float m_bestFrequency;
+};
+
+#endif
diff --git a/kradio3/src/include/gui_list_helper.h b/kradio3/src/include/gui_list_helper.h
new file mode 100644
index 0000000..6524043
--- /dev/null
+++ b/kradio3/src/include/gui_list_helper.h
@@ -0,0 +1,174 @@
+/***************************************************************************
+ gui_list_helper.h
+ -------------------
+ begin : Son Sep 26 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KRADIO_LIBKRADIO_GUI_GUI_LIST_HELPER_H_
+#define _KRADIO_LIBKRADIO_GUI_GUI_LIST_HELPER_H_
+
+#include <qmap.h>
+#include <qvaluelist.h>
+
+
+template <class TLIST> class GUISimpleListHelper
+{
+public:
+ GUISimpleListHelper(TLIST *list) : m_List(list) {}
+ ~GUISimpleListHelper() {}
+
+ void setData(const QValueList<QString> &data);
+ QString getCurrentText() const { return m_List->currentText(); }
+ void setCurrentText(const QString &s) { m_List->setCurrentItem(m_revData.contains(s) ? m_revData[s] : 0); }
+
+ int count() const { return m_revData.count(); }
+ bool contains(const QString &id) const { return m_revData.contains(id); }
+
+protected:
+ TLIST *m_List;
+ QMap<QString, int> m_revData;
+};
+
+
+template <class TLIST>
+void GUISimpleListHelper<TLIST>::setData(const QValueList<QString> &data)
+{
+ m_List->clear();
+ m_revData.clear();
+
+ QValueListConstIterator<QString> it = data.begin();
+ QValueListConstIterator<QString> end = data.end();
+ for (int i = 0; it != end; ++it, ++i) {
+ m_revData[*it] = i;
+ m_List->insertItem(*it);
+ }
+}
+
+
+
+
+
+
+
+
+
+template <class TLIST, class TID> class GUIListHelper
+{
+public:
+ enum SORT_KEY { SORT_BY_ID, SORT_BY_DESCR };
+
+ GUIListHelper(TLIST *list, SORT_KEY skey);
+ GUIListHelper(TLIST *list, const QMap<TID, QString> &data, SORT_KEY skey);
+ ~GUIListHelper();
+
+ void setData(const QMap<TID, QString> &data);
+
+ void setCurrentItem(const TID &) const;
+ const TID &getCurrentItem() const;
+
+ int count() const { return m_Index2ID.count(); }
+
+ bool contains(const TID &id) const { return m_ID2Index.contains(id); }
+
+protected:
+ SORT_KEY m_skey;
+ TLIST *m_List;
+ QMap<int, TID> m_Index2ID;
+ QMap<TID, int> m_ID2Index;
+ QMap<TID, QString> m_ID2Description;
+
+ struct THelpData {
+ TID id;
+ QString descr;
+ SORT_KEY skey;
+
+ THelpData() : id(), descr(), skey(SORT_BY_ID) {}
+ THelpData(TID _id, const QString &_descr, SORT_KEY _skey)
+ : id(_id),
+ descr(_descr),
+ skey(_skey)
+ {}
+ bool operator > (const THelpData &d) { return (skey == SORT_BY_ID) ? id > d.id : descr > d.descr; }
+ bool operator < (const THelpData &d) { return (skey == SORT_BY_ID) ? id < d.id : descr < d.descr; }
+ };
+};
+
+
+
+template <class TLIST, class TID>
+GUIListHelper<TLIST, TID>::GUIListHelper(TLIST *list, SORT_KEY skey)
+ : m_skey(skey),
+ m_List(list)
+{
+}
+
+
+template <class TLIST, class TID>
+GUIListHelper<TLIST, TID>::GUIListHelper(TLIST *list, const QMap<TID, QString> &data, SORT_KEY skey)
+ : m_skey(skey),
+ m_List(list)
+{
+ setData(data);
+}
+
+
+template <class TLIST, class TID>
+GUIListHelper<TLIST, TID>::~GUIListHelper()
+{
+}
+
+
+template <class TLIST, class TID>
+void GUIListHelper<TLIST, TID>::setData (const QMap<TID, QString> &data)
+{
+ m_List->clear();
+
+ m_ID2Description = data;
+ QValueList<THelpData> help_list;
+ QMapConstIterator<TID, QString> end = data.end();
+ for (QMapConstIterator<TID, QString> it = data.begin(); it != end; ++it) {
+ help_list.push_back(THelpData(it.key(), *it, m_skey));
+ }
+ qHeapSort(help_list);
+
+ m_Index2ID.clear();
+ m_ID2Index.clear();
+
+ int idx = 0;
+ QValueListIterator<THelpData> end_hlp = help_list.end();
+ for (QValueListIterator<THelpData> it = help_list.begin(); it != end_hlp; ++it, ++idx) {
+ m_Index2ID.insert(idx, (*it).id);
+ m_ID2Index.insert((*it).id, idx);
+ m_List->insertItem((*it).descr);
+ }
+}
+
+
+template <class TLIST, class TID>
+void GUIListHelper<TLIST, TID>::setCurrentItem(const TID &id) const
+{
+ if (m_ID2Index.contains(id))
+ m_List->setCurrentItem(m_ID2Index[id]);
+ else
+ m_List->setCurrentItem(0);
+}
+
+template <class TLIST, class TID>
+const TID &GUIListHelper<TLIST, TID>::getCurrentItem() const
+{
+ int idx = m_List->currentItem();
+ return m_Index2ID[idx];
+}
+
+#endif
diff --git a/kradio3/src/include/interfaces.h b/kradio3/src/include/interfaces.h
new file mode 100644
index 0000000..dced1d7
--- /dev/null
+++ b/kradio3/src/include/interfaces.h
@@ -0,0 +1,714 @@
+/***************************************************************************
+ interfaces.h - description
+ -------------------
+ begin : Fre Feb 28 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_INTERFACES_H
+#define KRADIO_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qptrlist.h>
+#include <qmap.h>
+#include <kdebug.h>
+#include <typeinfo>
+
+/*
+/////////////////////////////////////////////////////////////////////////////
+
+ Interfaces - Our Concept
+
+ Without connection management an interface can be defined easily as empty
+ abstract C++-Class. But that's not what we want.
+
+ Our interfaces also provide connection management. Thus each interface has
+ exactly one matching counterpart, the complementary interface (cmplIF).
+ Therefore connecting two objects that have matching interfaces can be
+ automated.
+
+ Our interfaces have to be able to support the following "functions":
+
+ - send and receive messages (e.g. notifications, commands, ...) to
+ all connected interfaces. These functions do not need a return value,
+ but in some cases the sender might want to know if anyone has received
+ his message. Thus a boolean return value should indicate if the message
+ was handled or ignored.
+
+ - query for information on connected interfaces / answer queries. These
+ functions usually have a return value. A query is only executed on the
+ "current" or - if not selected - the first or only connection.
+
+/////////////////////////////////////////////////////////////////////////////
+
+ Why are we not using QT signal/slots?
+
+ First the idea of using qt for connecting interfaces is very nice, as the
+ signal/slot model is well known and hopefully properly implemented.
+
+ But there are some problems:
+
+ - Signals/slots do not support return values, except "call by reference".
+ To provide queries or a delivery feedback for messages, wrapper functions
+ would have been necessary.
+
+ - Qt does not support multiple inheritance of QObjects. Thus even signals
+ have to be declared abstract by the interface though the (later)
+ implementation is already known.
+
+ Those functions have to be declared as signals in the interface
+ implementation (derived from QObject) though the implementation does not
+ want to worry about these signals.
+
+ - Qt does connect functions (signals/slots) and not interfaces. These
+ functions have to be connected separately. By that it is possible to
+ forget to connect signals/slots of that interfaces.
+
+ - Aggregation of multiple interface implementations (each one is an QObject)
+ is not possible because qt does not allow multiple inheritance of QObjects
+
+/////////////////////////////////////////////////////////////////////////////
+
+ What about our own solution?
+
+ Well, it eliminates at least the qt-problems explained above. But first we
+ need a common mechanism to manage interface connections. This functionality
+ can be provided by a common base class "InterfaceBase". It stores all
+ connected interfaces in a list of InterfaceBase pointers, e.g. QPtrList.
+
+ With this approach we would have some problems:
+
+ - When calling a function of a connected interface a slow dynamic_cast
+ is necessary to upcast the stored InterfaceBase pointer to the
+ apropriate type.
+
+ - Multiple inheritance of InterfaceBase must not be virtual. Otherwise
+ interface connection management is mixed between interfaces.
+ (well, virtual inheritance is usually no real issue, but worth a hint;-)
+
+ To avoid these problems, InterfaceBase is a template with two parameters,
+ thisIF (IF = interface) and cmplIF (complementary IF). With that
+ information the base class for an interface is capable to handle
+ connections with the correct type information. Additionally some pseudo
+ types are declared (thisInterface, cmplInterface, IFList, IFIterator) to
+ make easy-to-use macros for messages and queries possible.
+
+/////////////////////////////////////////////////////////////////////////////
+
+ How do I use it ? - Declarations
+
+ First you have to declare the two matching interface-classes as unkown
+ classes, because both their names are used in the class declarations.
+ Afterwards you can declare both classes as class derived from
+ InterfaceBase.
+
+ class Interface;
+ class ComplementaryInterface;
+
+ class Interface : public InterfaceBase<Interface, ComplementaryInterface>
+ {
+ ...
+ };
+
+ class ComplementaryInterface : public InterfaceBase<ComplementaryInterface, Interface>
+ {
+ ...
+ };
+
+ With macro abbreviation:
+
+ INTERFACE(Interface, ComplementaryInterface)
+ {
+ };
+
+ INTERFACE(ComplementaryInterface, Interface)
+ {
+ };
+
+
+ In order to receive/send Messages or query/answer queries we have to declare
+ special methods:
+
+ - sending Messages
+
+ Declare a virtual constant method with return value "int" and the desired
+ parameters. The return value will indicate how many receivers have handled
+ the message:
+
+ virtual bool SendingMessages(int any_or_non_param) const;
+
+ Abbreviation by macros:
+
+ IF_SENDER( SendingMessages(int any_or_non_param) )
+
+
+ - receiving Messages
+
+ Declare an abstract Method with return value "bool", and the desired
+ paramters. The return value indicates wether the message was handled or not:
+
+ virtual bool ReceivingMessages(int any_or_non_param) = 0;
+
+ Abbreviation by macros:
+
+ IF_RECEIVER( ReceivingMessages(int any_or_non_param) )
+
+
+ The method has to be implemented by a derived class. The current item of the
+ receivers conntions list is set to the sender.
+
+
+ - querying queries
+
+ Declare a virtual constant method with the desired return value and
+ parameters:
+
+ virtual int QueryingQueries(int another_param) const;
+
+ Abbreviation by macros:
+
+ IF_QUERY( int QueryingQueries(int another_param) )
+
+
+ - answering queries
+
+ Declare an abstract Method with return value void, and the desired
+ paramters:
+
+ virtual void AnsweringQueries(int another_param) = 0;
+
+ Abbreviation by macros:
+
+ IF_ANSWER( AnsweringQueries(int another_param) )
+
+ The method has to be implemented by a derived class. The current item of the
+ receivers conntions list is set to the sender.
+
+
+ At last a note on maxConnections. This member is set on initialization by
+ the constructor and thus can be set in a derived class in it's own
+ constructor. Negative values are interpreted as "unlimited".
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+ How do I use it ? - Implementations
+
+ Because we do not have a MOC as Qt does, we have to implement our sending
+ or querying methods by hand. But this minor disadvantage should be
+ considered as less important than the fact, that this implementation is
+ done where it belongs to. Especially because there are easy to use macros
+ to do this:
+
+ int ComplementaryInterface::SendingMessages(int any_or_non_param) const
+ {
+ IF_SEND_MESSAGE( ReceivingMessages(any_or_non_param) )
+ // macro includes "return #receivers"
+ }
+
+ int ComplementaryInterface::QueryingQueries(int another_param) const
+ {
+ IF_SEND_QUERY( AnsweringQuery(another_param), (int)"default return value" )
+ }
+
+
+ Even shorter:
+
+ IF_IMPL_SENDER( ComplementaryInterface::QueryingQueries(int param),
+ AnsweringQueries(param)
+ )
+
+ IF_IMPL_QUERY( int ComplementaryInterface::SendingMessages(int param),
+ ReceivingMessages(param),
+ (int)"default return value"
+ )
+
+/////////////////////////////////////////////////////////////////////////////
+
+ How do I use it ? - Disconnect/Connect notifications
+
+
+ Usually the virtual methods notifyDisconnect(ed) or notifyConnect(ed)
+ will be called within connect/disconnect methods.
+
+ As constructors and destructors are not able to call virtual methods
+ of derived classes, there are two possible problems:
+
+ * Constructors: Calling a connect method in a constructor will not result
+ in a connect notification of any derived class. Thus do not use connect
+ calls in contructors if any derived class hast to receive all
+ connect/disconnect notifications.
+
+ * Destructors: If connections are still present if the interface destructor
+ is called, it will only call its own empty noticedisconnect method. That
+ shouldn't be a big problem as the derived class is already gone and
+ doesn't have any interest in this notification any more. But it might be
+ possible that the connected object wants to call a function of the just
+ destroyed derived class. That is not possible. Dynamic casts to the
+ derived class will return NULL. Do not try to call methods of this class
+ by use of cached pointers.
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+ Extending and Aggregating Interfaces
+
+ Our interfaces must be extended by aggregation. The reason is that
+ otherwise we would have the same problems as with a common base class
+ for connection management. Each interface extensions is an normal
+ interface on its own.
+
+ Example:
+
+ class I_AM_FM_Radio : public IRadioBase,
+ public IRadioFrequencyExtension,
+ public IRadioSeekExtension
+ {
+ ...
+ };
+
+ To guarantee, that connection management continues to work, we have to overwrite
+ the connect and disconnect methods:
+
+ virtual bool I_AM_FM_Radio::connect (Interface *i) {
+ IRadioBase::connect(i);
+ IFrequencyExtension::connect(i);
+ ISeekExtension::connect(i);
+ }
+
+ virtual bool I_AM_FM_Radio::disconnect (Interface *i) {
+ IRadioBase::disconnect(i);
+ IFrequencyExtension::disconnect(i);
+ ISeekExtension::disconnect(i);
+ }
+
+*/
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+// a polymorphic and *virtual* base class so that we can make use of
+// dynamic_casts in connect/disconnect and to be able to merge
+// connect/disconnect methods to one single function in case of multiple
+// inheritance
+
+class Interface
+{
+public:
+ Interface () {}
+ virtual ~Interface() {}
+
+ virtual bool connectI (Interface *) { return false; }
+ virtual bool disconnectI(Interface *) { return false; }
+
+ // "Interface &"-Versions for convienience, not virtual, only "Interface*"
+ // versions have to / may be overwritten in case of multiple inheritance
+ bool connectI (Interface &i) { return connectI (&i); }
+ bool disconnectI(Interface &i) { return disconnectI (&i); }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+template <class thisIF, class cmplIF>
+class InterfaceBase : virtual public Interface
+{
+private:
+ typedef InterfaceBase<thisIF, cmplIF> thisClass;
+ typedef InterfaceBase<cmplIF, thisIF> cmplClass;
+
+// friend class cmplClass; // necessary for connects (to keep number of different connect functions low)
+
+public:
+
+ typedef thisIF thisInterface;
+ typedef cmplIF cmplInterface;
+
+ typedef QPtrList<cmplIF> IFList;
+ typedef QPtrListIterator<cmplIF> IFIterator;
+
+ typedef thisClass BaseClass;
+
+public :
+ InterfaceBase (int maxIConnections = -1);
+ virtual ~InterfaceBase ();
+
+ // duplicate connects will add no more entries to connection list
+ virtual bool connectI(Interface *i);
+ virtual bool disconnectI(Interface *i);
+
+protected:
+ virtual void disconnectAllI();
+
+
+public:
+
+ // It might be compfortable to derived Interfaces to get an argument
+ // of the Interface class, but that part of the object might
+ // already be destroyed. Thus it is necessary to evaluate the additional
+ // pointer_valid argument. A null pointer is not transmitted, as the
+ // pointer value might be needed to clean up some references in derived
+ // classes
+ virtual void noticeConnectI (cmplInterface *, bool /*pointer_valid*/) {}
+ virtual void noticeConnectedI (cmplInterface *, bool /*pointer_valid*/) {}
+ virtual void noticeDisconnectI (cmplInterface *, bool /*pointer_valid*/);
+ virtual void noticeDisconnectedI(cmplInterface *, bool /*pointer_valid*/) {}
+
+ virtual bool isIConnectionFree() const;
+ virtual unsigned connectedI() const { return iConnections.count(); }
+
+ thisIF *initThisInterfacePointer();
+ thisIF *getThisInterfacePointer() const { return me; }
+ bool isThisInterfacePointerValid() const { return me_valid; }
+ bool hasConnectionTo(cmplInterface *other) const { return iConnections.containsRef(other); }
+ void appendConnectionTo(cmplInterface *other) { iConnections.append(other); }
+ void removeConnectionTo(cmplInterface *other) { iConnections.removeRef(other); }
+
+protected :
+
+ IFList iConnections;
+ int maxIConnections;
+
+ // functions for individually selectable callbacks
+protected:
+ bool addListener (const cmplInterface *i, QPtrList<cmplInterface> &list);
+ void removeListener(const cmplInterface *i, QPtrList<cmplInterface> &list);
+ void removeListener(const cmplInterface *i);
+
+ QMap<const cmplInterface *, QPtrList<QPtrList<cmplInterface> > > m_FineListeners;
+
+private:
+ thisInterface *me;
+ bool me_valid;
+};
+
+
+// macros for interface declaration
+
+#define INTERFACE(IF, cmplIF) \
+ class IF; \
+ class cmplIF; \
+ class IF : public InterfaceBase<IF, cmplIF> \
+
+#define IF_CON_DESTRUCTOR(IF, n) \
+ IF() : BaseClass((n)) {} \
+ virtual ~IF() { }
+
+// macros to make sending messages or queries easier
+
+
+// debug util
+#ifdef DEBUG
+ #include <iostream>
+ using namespace std;
+ #define IF_QUERY_DEBUG \
+ if (iConnections.count() > 1) { \
+ kdDebug() << "class " << typeid(this).name() << ": using IF_QUERY with #connections > 1\n"; \
+ }
+#else
+ #define IF_QUERY_DEBUG
+#endif
+
+
+
+// messages
+
+#define SENDERS protected
+#define RECEIVERS public
+
+#define IF_SENDER(decl) \
+ virtual int decl const;
+
+#define IF_SEND_MESSAGE(call) \
+ int ____n = 0; \
+ for (IFIterator i(iConnections); i.current(); ++i) { \
+ if (i.current()->call ) ++____n; \
+ } \
+ return ____n;
+
+#define IF_IMPL_SENDER(decl, call) \
+ int decl const \
+ { \
+ IF_SEND_MESSAGE(call) \
+ }
+
+#define IF_RECEIVER(decl) \
+ virtual bool decl = 0;
+
+#define IF_RECEIVER_EMPTY(decl) \
+ virtual bool decl { return false; }
+
+// queries
+
+#define ANSWERS public
+#define QUERIES protected
+
+#define IF_QUERY(decl) \
+ virtual decl const;
+
+#define IF_SEND_QUERY(call, default) \
+ cmplInterface *o = IFIterator(iConnections).current(); \
+ if (o) { \
+ IF_QUERY_DEBUG \
+ return o->call; \
+ } else { \
+ return default; \
+ } \
+
+#define IF_IMPL_QUERY(decl, call, default) \
+ decl const { \
+ IF_SEND_QUERY(call, default) \
+ }
+
+#define IF_ANSWER(decl) \
+ virtual decl = 0;
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// MACROS for individually selectable callbacks
+/////////////////////////////////////////////////////////////////////////////
+
+
+#define IF_SENDER_FINE(name, param) \
+protected: \
+ int name param const; \
+public: \
+ bool register4_##name (cmplInterface *); \
+ void unregister4_##name(cmplInterface *); \
+private: \
+ QPtrList<cmplInterface> m_Listeners_##name;\
+
+
+#define IF_SEND_MESSAGE_FINE(name, params, call) \
+ int ____n = 0; \
+ for (QPtrListIterator<cmplInterface> ____it(m_Listeners_##name); ____it.current(); ++____it) { \
+ if (____it.current()->call ) ++____n; \
+ } \
+ return ____n;
+
+#define IF_IMPL_SENDER_FINE(class, name, param, call) \
+ int class::name param const { \
+ IF_SEND_MESSAGE_FINE(name, param, call) \
+ } \
+ \
+ bool class::register4_##name(cmplInterface *i) { \
+ return addListener(i, m_Listeners_##name); \
+ } \
+ void class::unregister4_##name(cmplInterface *i) { \
+ m_Listeners_##name.remove(i); \
+ }
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+
+template <class thisIF, class cmplIF>
+InterfaceBase<thisIF, cmplIF>::InterfaceBase(int _maxIConnections)
+ : maxIConnections(_maxIConnections),
+ me(NULL),
+ me_valid(false)
+{
+}
+
+
+template <class thisIF, class cmplIF>
+InterfaceBase<thisIF, cmplIF>::~InterfaceBase()
+{
+ me_valid = false;
+ // In this state the derived interfaces may already be destroyed
+ // so that dereferencing cached upcasted me-pointers in noticeDisconnect(ed)
+ // will fail.
+ // Thus we must ensure that disconnectAll() is called in the (upper) thisIF
+ // destructor, not here (see macro IF_CON_DESTRUCTOR).
+ // If this has not taken place (i.e. the programmer forgot to do so)
+ // we can only warn, clear our list now and hope that nothing
+ // more bad will happen
+
+ if (iConnections.count() > 0) {
+ thisClass::disconnectAllI();
+ }
+}
+
+
+template <class thisIF, class cmplIF>
+bool InterfaceBase<thisIF, cmplIF>::isIConnectionFree () const
+{
+ int m = maxIConnections;
+ return (m < 0) || (iConnections.count() < (unsigned) m);
+}
+
+template <class thisIF, class cmplIF>
+thisIF *InterfaceBase<thisIF, cmplIF>::initThisInterfacePointer()
+{
+ if (!me) me = dynamic_cast<thisIF*>(this);
+ me_valid = me != NULL;
+ return me;
+}
+
+template <class thisIF, class cmplIF>
+bool InterfaceBase<thisIF, cmplIF>::connectI (Interface *__i)
+{
+ // cache upcasted pointer, especially important for disconnects
+ // where already destructed derived parts cannot be reached with dynamic casts
+ initThisInterfacePointer();
+
+ // same with the other interface
+ cmplClass *_i = dynamic_cast<cmplClass*>(__i);
+ if (!_i) {
+ return false;
+ }
+
+ cmplIF *i = _i->initThisInterfacePointer();
+
+ if (i && me) {
+ bool i_connected = iConnections.containsRef(i);
+ bool me_connected = i->hasConnectionTo(me);
+
+ if (i_connected || me_connected) {
+ return true;
+ } else if (isIConnectionFree() && i->isIConnectionFree()) {
+
+ noticeConnectI(i, i != NULL);
+ _i->noticeConnectI(me, me != NULL);
+
+ if (!i_connected)
+ appendConnectionTo(i);
+ if (!me_connected)
+ _i->appendConnectionTo(me);
+
+ noticeConnectedI(i, i != NULL);
+ _i->noticeConnectedI(me, me != NULL);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+}
+
+
+
+template <class thisIF, class cmplIF>
+bool InterfaceBase<thisIF, cmplIF>::disconnectI (Interface *__i)
+{
+ cmplClass *_i = dynamic_cast<cmplClass*>(__i);
+
+ // use cache to find pointer in connections list
+ cmplIF *i = _i ? _i->getThisInterfacePointer() : NULL;
+
+ // The cached me pointer might already point to an destroyed
+ // object. We must use it only for identifying the entry in
+ // connections list
+
+ if (i && _i) {
+ if (me_valid)
+ noticeDisconnectI(i, _i->isThisInterfacePointerValid());
+ }
+
+ if (me && _i) {
+ if (_i->isThisInterfacePointerValid())
+ _i->noticeDisconnectI(me, me_valid);
+ }
+
+ if (i && hasConnectionTo(i)) {
+ removeListener(i);
+ removeConnectionTo(i);
+ }
+
+ if (me && i && i->hasConnectionTo(me))
+ i->removeConnectionTo(me);
+
+ if (me_valid && i && _i)
+ noticeDisconnectedI(i, _i->isThisInterfacePointerValid());
+ if (_i && _i->isThisInterfacePointerValid() && me)
+ _i->noticeDisconnectedI(me, me_valid);
+
+ return true;
+}
+
+
+template <class thisIF, class cmplIF>
+void InterfaceBase<thisIF, cmplIF>::noticeDisconnectI(cmplInterface *i, bool /*pointer_valid*/)
+{
+ removeListener(i);
+}
+
+
+template <class thisIF, class cmplIF>
+void InterfaceBase<thisIF, cmplIF>::disconnectAllI()
+{
+ IFList tmp = iConnections;
+ for (IFIterator it(tmp); it.current(); ++it) {
+ /* Do not call virtual methods if I'm in the contstructor!
+ Actually this should be ensured by the compiler generated
+ code and virtual method tables, but unfortunately some compilers
+ seem to ignore this in some situations.
+ */
+ if (me_valid)
+ disconnectI(it.current());
+ else
+ thisClass::disconnectI(it.current());
+ }
+}
+
+
+
+
+template <class thisIF, class cmplIF>
+bool InterfaceBase<thisIF, cmplIF>::addListener(const cmplInterface *i, QPtrList<cmplInterface> &list)
+{
+ if (iConnections.containsRef(i) && !list.contains(i)) {
+ list.append(i);
+ m_FineListeners[i].append(&list);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+template <class thisIF, class cmplIF>
+void InterfaceBase<thisIF, cmplIF>::removeListener(const cmplInterface *i, QPtrList<cmplInterface> &list)
+{
+ list.remove(i);
+ if (m_FineListeners.contains(i))
+ m_FineListeners[i].remove(&list);
+}
+
+
+template <class thisIF, class cmplIF>
+void InterfaceBase<thisIF, cmplIF>::removeListener(const cmplInterface *i)
+{
+ if (m_FineListeners.contains(i)) {
+ QPtrList<QPtrList<cmplInterface> > &list = m_FineListeners[i];
+ QPtrListIterator<QPtrList<cmplInterface> > it(list);
+ for (; it.current(); ++it) {
+ (*it)->remove(i);
+ }
+ }
+ m_FineListeners.remove(i);
+}
+
+
+
+
+
+
+
+#endif
diff --git a/kradio3/src/include/internetradiostation.h b/kradio3/src/include/internetradiostation.h
new file mode 100644
index 0000000..fa25159
--- /dev/null
+++ b/kradio3/src/include/internetradiostation.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ internetradiostation.h - description
+ -------------------
+ begin : Sat March 29 2003
+ copyright : (C) 2003 by Klas Kalass, Ernst Martin Witte
+ email : klas@kde.org, witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_INTERNETRADIOSTATION_H
+#define KRADIO_INTERNETRADIOSTATION_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "radiostation.h"
+
+// KDE includes
+#include <kurl.h>
+
+/**
+ * @author Klas Kalass, Ernst Martin Witte
+ */
+
+class InternetRadioStation : public RadioStation {
+public:
+ InternetRadioStation();
+ InternetRadioStation(KURL const &url);
+ InternetRadioStation(const QString &name, const QString &shortName, KURL const &url);
+ InternetRadioStation(const InternetRadioStation &);
+ InternetRadioStation(RegisterStationClass, const QString &classname = QString::null);
+ ~InternetRadioStation();
+
+ const KURL & url() const { return m_url; }
+ void setUrl(KURL const &url) { m_url = url; }
+
+ virtual QString longName() const;
+ virtual QString description() const;
+ virtual bool isValid () const;
+
+ /* = 0 : this.url == s.url
+ > 0 : this.url > s.url
+ < 0 : this.url < s.url
+ other class than InternetRadioStation: compare typeid(.).name()
+ */
+ virtual int compare (const RadioStation &s) const;
+
+ /** returns an exact copy of this station */
+ virtual RadioStation *copy() const;
+ virtual RadioStation *copyNewID() const;
+
+ virtual RadioStationConfig *createEditor() const;
+
+ // for XML-Parsing/Export
+ virtual bool setProperty(const QString &property_name, const QString &val);
+ virtual QString getProperty(const QString &property_name) const;
+ virtual QStringList getPropertyNames() const;
+ virtual QString getClassName() const { return "InternetRadioStation"; }
+
+ virtual bool operator == (const RadioStation &x) const;
+
+protected:
+ KURL m_url;
+};
+
+#endif
diff --git a/kradio3/src/include/kradioapp.h b/kradio3/src/include/kradioapp.h
new file mode 100644
index 0000000..f5fb950
--- /dev/null
+++ b/kradio3/src/include/kradioapp.h
@@ -0,0 +1,120 @@
+/***************************************************************************
+ kradioapp.h - description
+ -------------------
+ begin : Sa Feb 9 2002
+ copyright : (C) 2002 by Klas Kalass / Martin Witte / Frank Schwanz
+ email : klas.kalass@gmx.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_KRADIOAPP_H
+#define KRADIO_KRADIOAPP_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qdict.h>
+
+#include <kapplication.h>
+#include <kaboutapplication.h>
+#include "pluginmanager.h"
+#include "plugins.h"
+
+class KLibrary;
+
+class KRadioAbout : public PluginBase
+{
+public:
+ KRadioAbout(const QString &name) : PluginBase(name, "KRadio Application") {}
+
+ virtual QString pluginClassName() const { return "KRadioAbout"; }
+
+ virtual ConfigPageInfo createConfigurationPage () { return ConfigPageInfo(); }
+ virtual AboutPageInfo createAboutPage ();
+
+ virtual void saveState (KConfig *) const {}
+ virtual void restoreState (KConfig *) {}
+};
+
+
+
+
+typedef PluginBase *(*t_kradio_plugin_init_func)(const QString & cls, const QString &obj);
+typedef void (*t_kradio_plugin_info_func)(QMap<QString, QString> &);
+typedef void (*t_kradio_plugin_libload_func)();
+typedef void (*t_kradio_plugin_libunload_func)();
+
+
+struct PluginLibraryInfo {
+ KLibrary *library;
+ QMap<QString,QString> plugins;
+ t_kradio_plugin_init_func init_func;
+ t_kradio_plugin_info_func info_func;
+ t_kradio_plugin_libload_func libload_func;
+ t_kradio_plugin_libunload_func libunload_func;
+
+ PluginLibraryInfo() : library(NULL), init_func(NULL), info_func(NULL), libload_func(NULL), libunload_func(NULL) {}
+ PluginLibraryInfo(const QString &libname);
+ bool valid() { return init_func && info_func && library && libload_func && libunload_func; }
+};
+
+
+struct PluginClassInfo {
+ QString class_name;
+ QString description;
+ t_kradio_plugin_init_func create_function;
+
+ PluginClassInfo() : create_function(NULL) {}
+ PluginClassInfo(const QString &_name, const QString &descr, t_kradio_plugin_init_func init_func)
+ : class_name(_name), description(descr), create_function(init_func) {}
+ PluginBase *CreateInstance(const QString &obj_name) { return create_function ? create_function(class_name, obj_name) : NULL; }
+};
+
+
+class KRadioApp : public KApplication
+{
+Q_OBJECT
+public:
+ KRadioApp();
+ virtual ~KRadioApp();
+
+ virtual void saveState (KConfig *c);
+ virtual void restoreState (KConfig *c);
+
+ virtual PluginManager *createNewInstance(const QString &name);
+
+ virtual KLibrary *LoadLibrary (const QString &library);
+ virtual void UnloadLibrary (const QString &library);
+ virtual PluginBase *CreatePlugin (PluginManager *manager, const QString &name, const QString &object_name);
+
+ virtual const QMap<QString, PluginLibraryInfo> &getPluginLibraries() const { return m_PluginLibraries; }
+ virtual const QMap<QString, PluginClassInfo> &getPluginClasses() const { return m_PluginInfos; }
+
+ virtual void startPlugins();
+
+protected slots:
+
+ virtual void saveState();
+ virtual void slotAboutToQuit();
+
+protected:
+
+ QDict<PluginManager> m_Instances;
+
+ QMap<QString, PluginLibraryInfo> m_PluginLibraries;
+ QMap<QString, PluginClassInfo> m_PluginInfos;
+
+ bool m_quitting;
+};
+
+
+#endif
diff --git a/kradio3/src/include/kradioversion.h b/kradio3/src/include/kradioversion.h
new file mode 100644
index 0000000..cdde36f
--- /dev/null
+++ b/kradio3/src/include/kradioversion.h
@@ -0,0 +1,23 @@
+/***************************************************************************
+ kradioversion.h - description
+ -------------------
+ begin : Su May 22 2005
+ copyright : (C) 2005 by Marcus Camen
+ email : mcamen@mcamen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_VERSION_H
+#define KRADIO_VERSION "snapshot-2006-11-12-r497"
+
+#define KRADIO_VERSION "snapshot-2006-11-12-r497"
+
+#endif
diff --git a/kradio3/src/include/multibuffer.h b/kradio3/src/include/multibuffer.h
new file mode 100644
index 0000000..e835465
--- /dev/null
+++ b/kradio3/src/include/multibuffer.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ multibuffer.h
+ -------------------
+ begin : Sat Aug 20 2005
+ copyright : (C) 2005 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_MULTIBUFFER_H
+#define KRADIO_MULTIBUFFER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qsemaphore.h>
+#include <qstring.h>
+
+class MultiBuffer
+{
+public:
+ MultiBuffer(size_t n_buffers, size_t buffersize);
+ ~MultiBuffer();
+
+ char *lockWriteBuffer (size_t &bufferSize);
+ bool unlockWriteBuffer (size_t bufferSize); // return value: complete buffer full / ready for read
+ void unlockAllWriteBuffers();
+ char *wait4ReadBuffer (size_t &buffer_fill);
+ char *getCurrentReadBuffer(size_t &buffer_fill) const;
+
+ const QString &getErrorString() const { return m_errorString; }
+ bool hasError() const { return m_error; }
+ void resetError();
+
+ size_t getWriteBufferFill() const { return (m_currentReadBuffer != m_currentWriteBuffer) ? m_buffersFill[m_currentWriteBuffer] : 0; }
+ size_t getAvailableWriteBuffer() const;
+ size_t getAvailableReadBuffers() const;
+ size_t getCurrentReadBufferIdx() const { return m_currentReadBuffer; }
+ size_t getCurrentWriteBufferIdx() const { return m_currentWriteBuffer; }
+
+protected:
+
+ size_t m_nBuffers;
+ size_t m_BufferSize;
+
+ char **m_buffers;
+ size_t *m_buffersFill;
+ size_t m_currentReadBuffer;
+ size_t m_currentWriteBuffer;
+ QSemaphore m_readLock;
+
+ QString m_errorString;
+ bool m_error;
+};
+
+#endif
diff --git a/kradio3/src/include/plugin_configuration_dialog.h b/kradio3/src/include/plugin_configuration_dialog.h
new file mode 100644
index 0000000..d315a88
--- /dev/null
+++ b/kradio3/src/include/plugin_configuration_dialog.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ plugin_configuration_dialog.h - description
+ -------------------
+ begin : Sam Jun 21 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef KRADIO_PLUGIN_CONFIGURATION_DIALOG
+#define KRADIO_PLUGIN_CONFIGURATION_DIALOG
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kdialogbase.h>
+#include "widgetplugins.h"
+
+class PluginConfigurationDialog : public KDialogBase,
+ public WidgetPluginBase
+{
+
+Q_OBJECT
+
+public:
+ PluginConfigurationDialog(
+ int dialogFace, const QString &caption,
+ int buttonMask, ButtonCode defaultButton,
+ QWidget *parent=0, const char *name=0,
+ bool modal=true, bool separator=false);
+
+ // PluginBase
+
+ virtual QString pluginClassName() const { return "PluginConfigurationDialog"; }
+
+ virtual void saveState (KConfig *) const;
+ virtual void restoreState (KConfig *);
+
+protected :
+
+ virtual ConfigPageInfo createConfigurationPage();
+ virtual AboutPageInfo createAboutPage();
+
+ // WidgetPluginBase
+
+public slots:
+ void toggleShown() { WidgetPluginBase::pToggleShown(); }
+ virtual void showOnOrgDesktop();
+ virtual void show();
+ virtual void hide();
+ virtual void cancel() { slotCancel(); }
+
+ // QWidget overrides
+
+protected:
+ virtual void showEvent(QShowEvent *);
+ virtual void hideEvent(QHideEvent *);
+
+ virtual QWidget *getWidget() { return this; }
+ virtual const QWidget *getWidget() const { return this; }
+
+ QString m_Caption;
+};
+
+
+#endif
diff --git a/kradio3/src/include/pluginmanager-configuration.h b/kradio3/src/include/pluginmanager-configuration.h
new file mode 100644
index 0000000..5cd8d5f
--- /dev/null
+++ b/kradio3/src/include/pluginmanager-configuration.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ pluginmanager-configuration.h - description
+ -------------------
+ begin : Thu Sep 30 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_PLUGINMANAGER_CONFIGURATION_H
+#define KRADIO_PLUGINMANAGER_CONFIGURATION_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pluginmanager-configuration-ui.h>
+
+class QWidget;
+class KRadioApp;
+class PluginManager;
+
+class PluginManagerConfiguration : public PluginManagerConfigurationUI
+{
+Q_OBJECT
+public :
+ PluginManagerConfiguration (QWidget *parent, KRadioApp *app, PluginManager *pm);
+ ~PluginManagerConfiguration ();
+
+ void noticePluginLibrariesChanged();
+ void noticePluginsChanged();
+
+protected slots:
+
+ void slotOK();
+ void slotCancel();
+
+ void slotAddLibrary();
+ void slotRemoveLibrary();
+ void slotNewPluginInstance();
+ void slotRemovePluginInstance();
+ void slotSetDirty();
+
+protected:
+
+ KRadioApp *m_Application;
+ PluginManager *m_PluginManager;
+ bool m_dirty;
+
+};
+
+#endif
diff --git a/kradio3/src/include/pluginmanager.h b/kradio3/src/include/pluginmanager.h
new file mode 100644
index 0000000..b52c8f2
--- /dev/null
+++ b/kradio3/src/include/pluginmanager.h
@@ -0,0 +1,147 @@
+/***************************************************************************
+ pluginmanager.h - description
+ -------------------
+ begin : Mon Apr 28 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_PLUGINMANAGER_INTERFACES_H
+#define KRADIO_PLUGINMANAGER_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstring.h>
+#include <qptrdict.h>
+
+#include "plugins.h"
+
+class PluginBase;
+class WidgetPluginBase;
+class PluginConfigurationDialog;
+class PluginManagerConfiguration;
+class QWidget;
+class KConfig;
+class QFrame;
+class KAboutDialog;
+class KDialogBase;
+
+struct ConfigPageInfo;
+class QMenuData;
+class KRadioApp;
+
+
+class PluginManager : public QObject
+{
+Q_OBJECT
+public :
+ PluginManager(const QString &name,
+ KRadioApp *app,
+ const QString &configDialogTitle,
+ const QString &aboutTitle);
+ virtual ~PluginManager();
+
+ // Library Functions
+
+ void noticeLibrariesChanged();
+ void unloadPlugins(const QString &class_name);
+
+ // managing plugins
+
+ const PluginList &plugins() const { return m_plugins; }
+ void addWidgetPluginMenuItems(QMenuData *menu, QMap<WidgetPluginBase *,int> &map) const;
+ void updateWidgetPluginMenuItem(WidgetPluginBase *p, QMenuData *menu, QMap<WidgetPluginBase *,int> &map, bool shown) const;
+
+ PluginBase *getPluginByName(const QString &name) const;
+
+ // after insert, pluginManager is responsible for deletion
+ void insertPlugin(PluginBase *);
+
+ // remove and delete plugin
+ void deletePlugin(PluginBase *);
+ void deletePluginByName(const QString &name) { deletePlugin(getPluginByName(name)); }
+
+ // remove plugin, afterwards pluginManager is no longer responsible for deletion
+ void removePlugin(PluginBase *);
+ void removePluginByName(const QString &name) { removePlugin(getPluginByName(name)); }
+
+ // operations on all plugins
+
+ virtual void saveState (KConfig *) const;
+ virtual void restoreState (KConfig *);
+ virtual void startPlugins();
+
+ // configuration dialog handling
+
+ virtual PluginConfigurationDialog *getConfigDialog();
+ virtual KDialogBase *getAboutDialog();
+ virtual bool showsProgressBar() const { return m_showProgressBar; }
+ virtual void showProgressBar(bool b) { m_showProgressBar = b; }
+
+ virtual void noticeWidgetPluginShown(WidgetPluginBase *p, bool shown);
+
+protected :
+ virtual void createConfigDialog(const QString &title = QString::null);
+ virtual void createAboutDialog (const QString &title = QString::null);
+
+ virtual void addConfigurationPage (PluginBase *forWhom,
+ const ConfigPageInfo &info);
+ virtual void addAboutPage (PluginBase *forWhom,
+ const AboutPageInfo &info);
+
+protected slots:
+
+ virtual void slotConfigOK();
+
+public slots:
+ virtual void aboutToQuit();
+
+signals:
+
+ virtual void sigConfigOK();
+
+private:
+ virtual QFrame *addConfigurationPage (const ConfigPageInfo &info);
+ ConfigPageInfo createOwnConfigurationPage();
+
+ // PluginManager's data & types ;)
+protected:
+ typedef QPtrDict<QFrame> QFrameDict;
+ typedef QPtrDictIterator<QFrame> QFrameDictIterator;
+ typedef QPtrDict<QWidget> QWidgetDict;
+ typedef QPtrDictIterator<QWidget> QWidgetDictIterator;
+
+ QString m_Name;
+ KRadioApp *m_Application;
+
+ PluginList m_plugins;
+ bool m_showProgressBar;
+
+ QFrameDict m_configPageFrames;
+ QWidgetDict m_configPages;
+
+ QFrameDict m_aboutPageFrames;
+ QWidgetDict m_aboutPages;
+
+ PluginConfigurationDialog *m_configDialog;
+ PluginManagerConfiguration*m_pluginManagerConfiguration;
+ KDialogBase *m_aboutDialog;
+ QString m_configDialogTitle;
+ QString m_aboutDialogTitle;
+};
+
+
+
+
+#endif
diff --git a/kradio3/src/include/plugins.h b/kradio3/src/include/plugins.h
new file mode 100644
index 0000000..8040437
--- /dev/null
+++ b/kradio3/src/include/plugins.h
@@ -0,0 +1,192 @@
+/***************************************************************************
+ plugins.h - description
+ -------------------
+ begin : Mon Mär 10 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef KRADIO_PLUGINS_INTERFACES_H
+#define KRADIO_PLUGINS_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kglobal.h>
+
+#include "errorlog-interfaces.h"
+#include <qstring.h>
+#include <qobject.h>
+#include <qptrlist.h>
+
+class PluginManager;
+class PluginBase;
+class QWidget;
+class KConfig;
+
+typedef QPtrList<PluginBase> PluginList;
+typedef QPtrListIterator<PluginBase> PluginIterator;
+
+/* PluginBase must be inherited from Interface so that a plugin can be used
+ in Interface::connect functions.
+
+ PluginBase must not be inherited from QObject, because derived classes may
+ be inherited e.g. from QWidget (multiple inheritance is not possible with
+ OBjects). But we must be able to receive destroy messages e.g. from
+ configuration pages. Thus we need the special callback member
+ m_destroyNotifier.
+
+ PluginBase is derived from Interface to provide connection facilities.
+ In case of multiple inheritance from interface classes, connect and disconnect
+ methods have to be reimplemented in order to call all inherited
+ connect/disconnect methods.
+
+*/
+
+
+class WidgetPluginBase;
+
+struct ConfigPageInfo
+{
+ ConfigPageInfo () : page(NULL) {}
+ ConfigPageInfo (QWidget *p,
+ const QString &in,
+ const QString &ph,
+ const QString &icon)
+ : page (p),
+ itemName(in),
+ pageHeader(ph),
+ iconName(icon)
+ {}
+
+ QWidget *page;
+ QString itemName,
+ pageHeader,
+ iconName;
+};
+
+typedef ConfigPageInfo AboutPageInfo;
+
+
+class PluginBase : public IErrorLogClient
+{
+friend class PluginManager;
+public :
+ PluginBase(const QString &name, const QString &description);
+ virtual ~PluginBase();
+
+ virtual QString pluginClassName() const = 0;
+
+ const QString &name() const { return m_name; }
+ QString &name() { return m_name; }
+
+ const QString &description() const { return m_description; }
+
+ // workaround for compiler bugs
+ bool destructorCalled() const { return m_destructorCalled; }
+
+ // interaction with pluginmanager
+protected:
+ bool setManager (PluginManager *);
+ void unsetManager ();
+ bool isManagerSet () const;
+
+public:
+
+ // these two methods will request a configuration page or
+ // plugin page from plugin manager
+ // they will be deleted automatically when this plugin
+ // is deleted, because we disconnect from pluginmanager
+ // and the plugin manager will delete all associated gui elements
+ virtual ConfigPageInfo createConfigurationPage () = 0;
+ virtual AboutPageInfo createAboutPage () = 0;
+
+ // save/restore status, window position, etc...
+
+ virtual void saveState (KConfig *) const = 0;
+ virtual void restoreState (KConfig *) = 0;
+ virtual void startPlugin();
+
+ virtual void aboutToQuit();
+
+ //
+
+ virtual void noticeWidgetPluginShown(WidgetPluginBase *, bool /*shown*/) {}
+ virtual void noticePluginsChanged(const PluginList &) {}
+
+protected :
+ QString m_name;
+ QString m_description;
+ PluginManager *m_manager;
+ bool m_destructorCalled;
+};
+
+
+#define PLUGIN_LIBRARY_FUNCTIONS(class_name, i18nName, description) \
+extern "C" void KRadioPlugin_LoadLibrary() \
+{ \
+ KGlobal::locale()->insertCatalogue(i18nName); \
+} \
+ \
+extern "C" void KRadioPlugin_UnloadLibrary() \
+{ \
+ KGlobal::locale()->removeCatalogue(i18nName); \
+} \
+ \
+extern "C" void KRadioPlugin_GetAvailablePlugins(QMap<QString, QString> &info) \
+{ \
+ info.insert(#class_name, (description)); \
+} \
+ \
+extern "C" PluginBase *KRadioPlugin_CreatePlugin(const QString &type, const QString &object_name) \
+{ \
+ if (type == #class_name) { \
+ return new class_name(object_name); \
+ } else { \
+ return NULL; \
+ } \
+}
+
+
+#define PLUGIN_LIBRARY_FUNCTIONS2(class_name1, i18nName, description1, class_name2, description2) \
+extern "C" void KRadioPlugin_LoadLibrary() \
+{ \
+ KGlobal::locale()->insertCatalogue(i18nName); \
+} \
+ \
+extern "C" void KRadioPlugin_UnloadLibrary() \
+{ \
+ KGlobal::locale()->removeCatalogue(i18nName); \
+} \
+ \
+extern "C" void KRadioPlugin_GetAvailablePlugins(QMap<QString, QString> &info) \
+{ \
+ info.insert(#class_name1, (description1)); \
+ info.insert(#class_name2, (description2)); \
+} \
+ \
+extern "C" PluginBase *KRadioPlugin_CreatePlugin(const QString &type, const QString &object_name) \
+{ \
+ if (type == #class_name1) { \
+ return new class_name1(object_name); \
+ } else if (type == #class_name2) { \
+ return new class_name2(object_name); \
+ } else { \
+ return NULL; \
+ } \
+}
+
+
+#endif
diff --git a/kradio3/src/include/radio_interfaces.h b/kradio3/src/include/radio_interfaces.h
new file mode 100644
index 0000000..12a9037
--- /dev/null
+++ b/kradio3/src/include/radio_interfaces.h
@@ -0,0 +1,117 @@
+/***************************************************************************
+ radio_interfaces.h - description
+ -------------------
+ begin : Mon Mär 10 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * Interfaces in this header: *
+ * *
+ * IRadio(Client) *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_RADIO_INTERFACES_H
+#define KRADIO_RADIO_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "interfaces.h"
+#include "soundstreamid.h"
+
+class RadioStation;
+class StationList;
+
+
+///////////////////////////////////////////////////////////////////////
+
+
+INTERFACE(IRadio, IRadioClient)
+{
+public :
+ IF_CON_DESTRUCTOR(IRadio, -1)
+
+RECEIVERS:
+ IF_RECEIVER( powerOn() )
+ IF_RECEIVER( powerOff() )
+ IF_RECEIVER( activateStation(const RadioStation &rs) )
+ IF_RECEIVER( activateStation(int index) )
+ IF_RECEIVER( setStations(const StationList &sl) )
+ IF_RECEIVER( setPresetFile(const QString &f) )
+
+SENDERS:
+ IF_SENDER ( notifyPowerChanged(bool on) )
+ IF_SENDER ( notifyStationChanged (const RadioStation &, int idx) )
+ IF_SENDER ( notifyStationsChanged(const StationList &sl) )
+ IF_SENDER ( notifyPresetFileChanged(const QString &sl) )
+ IF_SENDER ( notifyCurrentSoundStreamIDChanged(SoundStreamID id) )
+
+ANSWERS:
+ IF_ANSWER ( bool isPowerOn() const )
+ IF_ANSWER ( bool isPowerOff() const )
+ IF_ANSWER ( const RadioStation & getCurrentStation() const )
+ IF_ANSWER ( int getStationIdx(const RadioStation &rs) const )
+ IF_ANSWER ( int getCurrentStationIdx() const )
+ IF_ANSWER ( const StationList & getStations() const )
+ IF_ANSWER ( const QString & getPresetFile() const );
+
+ IF_ANSWER ( SoundStreamID getCurrentSoundStreamID() const );
+
+};
+
+
+INTERFACE(IRadioClient, IRadio)
+{
+friend class IRadio;
+
+public :
+ IF_CON_DESTRUCTOR(IRadioClient, 1)
+
+SENDERS:
+ IF_SENDER ( sendPowerOn() )
+ IF_SENDER ( sendPowerOff() )
+ IF_SENDER ( sendActivateStation(const RadioStation &rs) )
+ IF_SENDER ( sendActivateStation(int index) )
+ IF_SENDER ( sendStations(const StationList &sl) )
+ IF_SENDER ( sendPresetFile(const QString &f) )
+
+RECEIVERS:
+ IF_RECEIVER( noticePowerChanged(bool on) )
+ IF_RECEIVER( noticeStationChanged (const RadioStation &, int idx) )
+ IF_RECEIVER( noticeStationsChanged(const StationList &sl) )
+ IF_RECEIVER( noticePresetFileChanged(const QString &f) )
+ IF_RECEIVER( noticeCurrentSoundStreamIDChanged(SoundStreamID id))
+
+QUERIES:
+ IF_QUERY ( bool queryIsPowerOn() )
+ IF_QUERY ( bool queryIsPowerOff() )
+ IF_QUERY ( const RadioStation & queryCurrentStation() )
+ IF_QUERY ( int queryStationIdx(const RadioStation &rs) )
+ IF_QUERY ( int queryCurrentStationIdx() )
+ IF_QUERY ( const StationList & queryStations() )
+ IF_QUERY ( const QString & queryPresetFile() )
+
+ IF_QUERY ( SoundStreamID queryCurrentSoundStreamID() );
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool pointer_valid);
+ virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid);
+};
+
+
+
+#endif
diff --git a/kradio3/src/include/radiodevice_interfaces.h b/kradio3/src/include/radiodevice_interfaces.h
new file mode 100644
index 0000000..53b975e
--- /dev/null
+++ b/kradio3/src/include/radiodevice_interfaces.h
@@ -0,0 +1,353 @@
+/***************************************************************************
+ radiodevice_interfaces.h - description
+ -------------------
+ begin : Fre Apr 18 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * Interfaces in this header: *
+ * *
+ * IRadioDevice(Client) *
+ * IRadioSound(Client) *
+ * ISeekRadio(Client) *
+ * IFrequencyRadio(Client) *
+ * IInternetRadio(Client) *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_RADIODEVICE_INTERFACES_H
+#define KRADIO_RADIODEVICE_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "soundstreamid.h"
+#include "interfaces.h"
+
+class RadioStation;
+class KURL;
+
+INTERFACE(IRadioDevice, IRadioDeviceClient)
+{
+public:
+ IF_CON_DESTRUCTOR(IRadioDevice, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setPower(bool on) )
+ IF_RECEIVER( powerOn() )
+ IF_RECEIVER( powerOff() )
+ IF_RECEIVER( activateStation(const RadioStation &rs) )
+
+SENDERS:
+ IF_SENDER ( notifyPowerChanged(bool on) )
+ IF_SENDER ( notifyStationChanged (const RadioStation &) )
+ IF_SENDER ( notifyDescriptionChanged (const QString &) )
+ IF_SENDER ( notifyCurrentSoundStreamIDChanged(SoundStreamID id))
+
+ANSWERS:
+ IF_ANSWER ( bool isPowerOn() const );
+ IF_ANSWER ( bool isPowerOff() const );
+ IF_ANSWER ( const RadioStation & getCurrentStation() const );
+ IF_ANSWER ( const QString & getDescription() const );
+
+ IF_ANSWER ( SoundStreamID getCurrentSoundStreamID() const );
+};
+
+
+
+INTERFACE(IRadioDeviceClient, IRadioDevice)
+{
+public :
+ IF_CON_DESTRUCTOR(IRadioDeviceClient, 1);
+ IRadioDeviceClient(int _maxConnections) : IRadioDeviceClient::BaseClass(_maxConnections) {}
+
+SENDERS:
+ IF_SENDER ( sendPower(bool on) )
+ IF_SENDER ( sendPowerOn() )
+ IF_SENDER ( sendPowerOff() )
+ IF_SENDER ( sendActivateStation (const RadioStation &rs) )
+
+RECEIVERS:
+ IF_RECEIVER( noticePowerChanged (bool on, const IRadioDevice *sender = NULL) )
+ IF_RECEIVER( noticeStationChanged (const RadioStation &, const IRadioDevice *sender = NULL) )
+ IF_RECEIVER( noticeDescriptionChanged (const QString &, const IRadioDevice *sender = NULL) )
+ IF_RECEIVER( noticeCurrentSoundStreamIDChanged(SoundStreamID id, const IRadioDevice *sender = NULL))
+
+QUERIES:
+ IF_QUERY ( bool queryIsPowerOn() )
+ IF_QUERY ( bool queryIsPowerOff() )
+ IF_QUERY ( const RadioStation & queryCurrentStation() )
+ IF_QUERY ( const QString & queryDescription() )
+
+ IF_QUERY ( SoundStreamID queryCurrentSoundStreamID() )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool pointer_valid);
+ virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid);
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+// deprecated, use IRadioSoundStreamClient
+/*
+INTERFACE(IRadioSound, IRadioSoundClient)
+{
+public :
+ IF_CON_DESTRUCTOR(IRadioSound, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setVolume (float v) )
+ IF_RECEIVER( setTreble (float v) )
+ IF_RECEIVER( setBass (float v) )
+ IF_RECEIVER( setBalance (float v) )
+ IF_RECEIVER( mute (bool mute) )
+ IF_RECEIVER( unmute (bool unmute) )
+ IF_RECEIVER( setSignalMinQuality(float q) )
+ IF_RECEIVER( setStereo(bool s) )
+
+SENDERS:
+ IF_SENDER ( notifyVolumeChanged(float v) )
+ IF_SENDER ( notifyTrebleChanged(float v) )
+ IF_SENDER ( notifyBassChanged(float v) )
+ IF_SENDER ( notifyBalanceChanged(float v) )
+ IF_SENDER ( notifyMuted(bool m) )
+ IF_SENDER ( notifySignalQualityChanged(float q) )
+ IF_SENDER ( notifySignalQualityBoolChanged(bool good) )
+ IF_SENDER ( notifySignalMinQualityChanged(float q) )
+ IF_SENDER ( notifyStereoChanged(bool s) )
+
+ANSWERS:
+ IF_ANSWER ( float getVolume() const )
+ IF_ANSWER ( float getTreble() const )
+ IF_ANSWER ( float getBass () const )
+ IF_ANSWER ( float getBalance () const )
+ IF_ANSWER ( bool isMuted() const )
+ IF_ANSWER ( float getSignalQuality() const )
+ IF_ANSWER ( float getSignalMinQuality() const )
+ IF_ANSWER ( bool hasGoodQuality() const )
+ IF_ANSWER ( bool isStereo() const )
+};
+
+
+INTERFACE(IRadioSoundClient, IRadioSound)
+{
+public :
+ IF_CON_DESTRUCTOR(IRadioSoundClient, 1)
+
+SENDERS:
+ IF_SENDER ( sendVolume (float v) )
+ IF_SENDER ( sendTreble (float v) )
+ IF_SENDER ( sendBass (float v) )
+ IF_SENDER ( sendBalance (float v) )
+ IF_SENDER ( sendMute (bool mute = true) )
+ IF_SENDER ( sendUnmute (bool unmute = true) )
+ IF_SENDER ( sendSignalMinQuality (float q) )
+ IF_SENDER ( sendStereo(bool s) )
+
+RECEIVERS:
+ IF_RECEIVER( noticeVolumeChanged(float v) )
+ IF_RECEIVER( noticeTrebleChanged(float v) )
+ IF_RECEIVER( noticeBassChanged(float v) )
+ IF_RECEIVER( noticeBalanceChanged(float v) )
+ IF_RECEIVER( noticeSignalQualityChanged(float q) )
+ IF_RECEIVER( noticeSignalQualityChanged(bool good) )
+ IF_RECEIVER( noticeSignalMinQualityChanged(float q) )
+ IF_RECEIVER( noticeStereoChanged(bool s) )
+ IF_RECEIVER( noticeMuted(bool m) )
+
+QUERIES:
+ IF_QUERY ( float queryVolume() )
+ IF_QUERY ( float queryTreble() )
+ IF_QUERY ( float queryBass() )
+ IF_QUERY ( float queryBalance () )
+ IF_QUERY ( float querySignalQuality() )
+ IF_QUERY ( float querySignalMinQuality() )
+ IF_QUERY ( bool queryHasGoodQuality() )
+ IF_QUERY ( bool queryIsStereo() )
+ IF_QUERY ( bool queryIsMuted() )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool pointer_valid);
+ virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid);
+};
+*/
+
+/////////////////////////////////////////////////////////////////////////////
+INTERFACE(ISeekRadio, ISeekRadioClient)
+{
+ friend class SeekHelper;
+
+public :
+ IF_CON_DESTRUCTOR(ISeekRadio, -1)
+
+RECEIVERS:
+ IF_RECEIVER( toBeginning() )
+ IF_RECEIVER( toEnd() )
+ IF_RECEIVER( startSeek (bool up) )
+ IF_RECEIVER( startSeekUp() )
+ IF_RECEIVER( startSeekDown() )
+ IF_RECEIVER( stopSeek() )
+
+SENDERS:
+ IF_SENDER ( notifySeekStarted (bool up) )
+ IF_SENDER ( notifySeekStopped () )
+ IF_SENDER ( notifySeekFinished (const RadioStation &s, bool goodQuality) )
+ IF_SENDER ( notifyProgress (float f) )
+
+ANSWERS:
+ IF_ANSWER ( bool isSeekRunning() const )
+ IF_ANSWER ( bool isSeekUpRunning() const )
+ IF_ANSWER ( bool isSeekDownRunning() const )
+ IF_ANSWER ( float getProgress () const )
+};
+
+
+INTERFACE(ISeekRadioClient, ISeekRadio)
+{
+public :
+ IF_CON_DESTRUCTOR(ISeekRadioClient, 1)
+
+SENDERS:
+ IF_SENDER ( sendToBeginning() )
+ IF_SENDER ( sendToEnd() )
+ IF_SENDER ( sendStartSeek (bool up) )
+ IF_SENDER ( sendStartSeekUp() )
+ IF_SENDER ( sendStartSeekDown() )
+ IF_SENDER ( sendStopSeek() )
+
+RECEIVERS:
+ IF_RECEIVER( noticeSeekStarted (bool up) )
+ IF_RECEIVER( noticeSeekStopped () )
+ IF_RECEIVER( noticeSeekFinished (const RadioStation &s, bool goodQuality) )
+ IF_RECEIVER( noticeProgress (float f) )
+
+QUERIES:
+ IF_QUERY ( bool queryIsSeekRunning() )
+ IF_QUERY ( bool queryIsSeekUpRunning() )
+ IF_QUERY ( bool queryIsSeekDownRunning() )
+ IF_QUERY ( float queryProgress () )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool pointer_valid);
+ virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid);
+};
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+INTERFACE(IFrequencyRadio, IFrequencyRadioClient)
+{
+public :
+ IF_CON_DESTRUCTOR(IFrequencyRadio, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setFrequency(float f) )
+ IF_RECEIVER( setMinFrequency(float mf) )
+ IF_RECEIVER( setMaxFrequency(float mf) )
+ IF_RECEIVER( setScanStep(float s) )
+
+SENDERS:
+ IF_SENDER ( notifyFrequencyChanged(float f, const RadioStation *s) )
+ IF_SENDER ( notifyMinMaxFrequencyChanged(float min, float max) )
+ IF_SENDER ( notifyDeviceMinMaxFrequencyChanged(float min, float max) )
+ IF_SENDER ( notifyScanStepChanged(float s) )
+
+ANSWERS:
+ IF_ANSWER ( float getFrequency() const )
+ IF_ANSWER ( float getMinFrequency() const )
+ IF_ANSWER ( float getMinDeviceFrequency() const )
+ IF_ANSWER ( float getMaxFrequency() const )
+ IF_ANSWER ( float getMaxDeviceFrequency() const )
+ IF_ANSWER ( float getScanStep() const )
+};
+
+
+INTERFACE(IFrequencyRadioClient, IFrequencyRadio)
+{
+public :
+ IF_CON_DESTRUCTOR(IFrequencyRadioClient, 1)
+
+SENDERS:
+ IF_SENDER ( sendFrequency(float f) )
+ IF_SENDER ( sendMinFrequency(float mf) )
+ IF_SENDER ( sendMaxFrequency(float mf) )
+ IF_SENDER ( sendScanStep(float s) )
+
+RECEIVERS:
+ IF_RECEIVER( noticeFrequencyChanged(float f, const RadioStation *s) )
+ IF_RECEIVER( noticeMinMaxFrequencyChanged(float min, float max) )
+ IF_RECEIVER( noticeDeviceMinMaxFrequencyChanged(float min, float max) )
+ IF_RECEIVER( noticeScanStepChanged(float s) )
+
+QUERIES:
+ IF_QUERY ( float queryFrequency() )
+ IF_QUERY ( float queryMinFrequency() )
+ IF_QUERY ( float queryMinDeviceFrequency() )
+ IF_QUERY ( float queryMaxFrequency() )
+ IF_QUERY ( float queryMaxDeviceFrequency() )
+ IF_QUERY ( float queryScanStep() )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool pointer_valid);
+ virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid);
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+INTERFACE(IInternetRadio, IInternetRadioClient)
+{
+public :
+ IF_CON_DESTRUCTOR(IInternetRadio, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setURL(const KURL &url) )
+
+SENDERS:
+ IF_SENDER ( notifyURLChanged(const KURL &u) )
+
+ANSWERS:
+ IF_ANSWER ( const KURL & getURL() const )
+};
+
+
+
+
+INTERFACE(IInternetRadioClient, IInternetRadio)
+{
+public :
+ IF_CON_DESTRUCTOR(IInternetRadioClient, 1)
+
+
+SENDERS:
+ IF_SENDER ( sendURL(const KURL &url) )
+
+RECEIVERS:
+ IF_RECEIVER( noticeURLChanged(const KURL &url) )
+
+QUERIES:
+ IF_QUERY ( const KURL &queryURL() )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool pointer_valid);
+ virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid);
+};
+
+
+
+#endif
+
diff --git a/kradio3/src/include/radiodevicepool_interfaces.h b/kradio3/src/include/radiodevicepool_interfaces.h
new file mode 100644
index 0000000..6c562a8
--- /dev/null
+++ b/kradio3/src/include/radiodevicepool_interfaces.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ radiodevicepool_interface.h - description
+ -------------------
+ begin : Sam Apr 19 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_RADIODEVICEPOOL_INTERFACES_H
+#define KRADIO_RADIODEVICEPOOL_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "interfaces.h"
+
+
+class IRadioDevice;
+
+
+INTERFACE(IRadioDevicePool, IRadioDevicePoolClient)
+{
+public:
+ IF_CON_DESTRUCTOR(IRadioDevicePool, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setActiveDevice(IRadioDevice *rd, bool keepPower = true))
+
+SENDERS:
+ IF_SENDER ( notifyActiveDeviceChanged(IRadioDevice *rd) )
+ IF_SENDER ( notifyDevicesChanged(const QPtrList<IRadioDevice> &) )
+ IF_SENDER ( notifyDeviceDescriptionChanged(const QString &) )
+
+ANSWERS:
+ IF_ANSWER ( IRadioDevice * getActiveDevice() const )
+ IF_ANSWER ( const QPtrList<IRadioDevice> & getDevices() const )
+ IF_ANSWER ( const QString & getDeviceDescription() const )
+};
+
+
+INTERFACE(IRadioDevicePoolClient, IRadioDevicePool)
+{
+public:
+ IF_CON_DESTRUCTOR(IRadioDevicePoolClient, -1)
+
+SENDERS:
+ IF_SENDER ( sendActiveDevice(IRadioDevice *rd, bool keepPower = true))
+
+RECEIVERS:
+ IF_RECEIVER( noticeActiveDeviceChanged(IRadioDevice *rd) )
+ IF_RECEIVER( noticeDevicesChanged(const QPtrList<IRadioDevice> &) )
+ IF_RECEIVER( noticeDeviceDescriptionChanged(const QString &) )
+
+QUERIES:
+ IF_QUERY ( IRadioDevice *queryActiveDevice() )
+ IF_QUERY ( const QPtrList<IRadioDevice> &queryDevices() )
+ IF_QUERY ( const QString &queryDeviceDescription() )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool /*pointer_valid*/);
+ virtual void noticeDisconnectedI (cmplInterface *, bool /*pointer_valid*/);
+};
+
+
+#endif
diff --git a/kradio3/src/include/radiostation-config.h b/kradio3/src/include/radiostation-config.h
new file mode 100644
index 0000000..b0b31cf
--- /dev/null
+++ b/kradio3/src/include/radiostation-config.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ radiostation-config.h - description
+ -------------------
+ begin : Sa Aug 16 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_RADIOSTATION_CONFIG_H
+#define KRADIO_RADIOSTATION_CONFIG_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qwidget.h>
+
+class RadioStation;
+
+class RadioStationConfig : public QWidget
+{
+Q_OBJECT
+public:
+ RadioStationConfig(QWidget *parent);
+ ~RadioStationConfig();
+
+ virtual void setStationData (const RadioStation &rs) = 0;
+ virtual void storeStationData (RadioStation &rs) = 0;
+
+signals:
+ virtual void changed(RadioStationConfig *);
+};
+
+
+class UndefinedRadioStationConfig : public RadioStationConfig
+{
+Q_OBJECT
+public:
+ UndefinedRadioStationConfig (QWidget *parent);
+ ~UndefinedRadioStationConfig();
+
+ virtual void setStationData (const RadioStation &rs);
+ virtual void storeStationData (RadioStation &rs);
+};
+
+
+
+class QSpinBox;
+
+class FrequencyRadioStationConfig : public RadioStationConfig
+{
+Q_OBJECT
+public:
+ FrequencyRadioStationConfig (QWidget *parent);
+ ~FrequencyRadioStationConfig();
+
+ virtual void setStationData (const RadioStation &rs);
+ virtual void storeStationData (RadioStation &rs);
+
+protected slots:
+ virtual void slotValueChanged(int);
+
+protected:
+
+ QSpinBox *m_editFrequency;
+};
+
+
+
+#endif
diff --git a/kradio3/src/include/radiostation-listview.h b/kradio3/src/include/radiostation-listview.h
new file mode 100644
index 0000000..1f3fb6a
--- /dev/null
+++ b/kradio3/src/include/radiostation-listview.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ radiostation-listview.h - description
+ -------------------
+ begin : Mi Mar 03 2004
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef _KRADIO_RADIOSTATION_LISTVIEW_H_
+#define _KRADIO_RADIOSTATION_LISTVIEW_H_
+
+#include <klistview.h>
+
+class RadioStation;
+class StationList;
+
+class RadioStationListView : public KListView
+{
+Q_OBJECT
+public:
+ RadioStationListView(QWidget *parent=0, const char *name=0);
+ virtual ~RadioStationListView();
+
+ QListViewItem *getItemForIndex(int idx) const;
+ int getIndexForItem(QListViewItem *) const;
+
+ void setStation(int idx, const RadioStation &, int nr = -1);
+ void appendStation(const RadioStation &, int nr = -1);
+ void setStations(const StationList &);
+
+ void removeStation(int idx);
+ void takeItem(QListViewItem *item, int idx);
+ void insertItem(QListViewItem *item, const QString &stationid, int idx);
+
+ void setCurrentStation(int idx);
+ int currentStationIndex() const;
+
+ int count() const { return childCount(); }
+
+ void saveState (KConfig *) const;
+ void restoreState (KConfig *);
+
+
+protected:
+
+ QDragObject *dragObject();
+ void dragEnterEvent(QDragEnterEvent* event);
+ void dropEvent(QDropEvent* event);
+ void contentsDragEnterEvent(QDragEnterEvent* event);
+ void contentsDragMoveEvent(QDragMoveEvent* event);
+ void contentsDropEvent(QDropEvent* event);
+
+protected slots:
+
+ void slotStationActivation(QListViewItem *);
+ void slotCurrentStationChanged(QListViewItem *);
+
+signals:
+ void sigStationActivated(int idx);
+ void sigCurrentStationChanged(int idx);
+ void sigStationsReceived(const QStringList &stationIDs);
+
+protected:
+
+ QStringList m_StationIDs;
+
+};
+
+#endif
diff --git a/kradio3/src/include/radiostation.h b/kradio3/src/include/radiostation.h
new file mode 100644
index 0000000..5c63874
--- /dev/null
+++ b/kradio3/src/include/radiostation.h
@@ -0,0 +1,164 @@
+/***************************************************************************
+ radiostation.h - description
+ -------------------
+ begin : Sat Feb 2 2002
+ copyright : (C) 2003 by Martin Witte, Klas Kalass
+ email : witte@kawo1.rwth-aachen.de / klas@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_RADIOSTATION_H
+#define KRADIO_RADIOSTATION_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+//#include "utils.h"
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qdict.h>
+
+#include <klocale.h>
+
+/**
+ *@author Martin Witte, Klas Kalass
+ */
+
+/*
+
+ RadioStation
+
+ RadioStation is an abstract base class for any type of radio station,
+ e.g. AM/FM stations or internet radio stations. Thus no specific knowledge
+ about the frequency or URL is included in this class. A radio station
+ should not contain information on a matching device as well. The device has
+ to decide on its own to use or not to use a station.
+
+ There are some important abstract functions, that have to be overwritten by
+ a derived radio station:
+
+ copy create an exact copy of a station (in case we only have a RadioStation*
+ longName return a verbous station description
+ isValid is this station setup correctly ?
+ compare is this station equivalent to another station, e.g. approximately same frequency
+ getclassname classname string for station registry
+
+ Other methods "should" be overwritten, but still call inherited methods for completeness!
+
+ get/setProperty
+ getPropertyNames
+
+*/
+
+/////////////////////////////////////////////////////////////////////////////
+
+extern struct RegisterStationClass {} registerStationClass;
+
+/////////////////////////////////////////////////////////////////////////////
+
+class RadioStationConfig;
+
+class RadioStation
+{
+protected:
+ RadioStation (RegisterStationClass, const QString &classname);
+public:
+ RadioStation ();
+ RadioStation (const QString &name, const QString &shortName);
+ RadioStation (const RadioStation &);
+ virtual ~RadioStation();
+
+ const QString &stationID() const { return m_stationID; }
+
+ virtual QString longName() const = 0;
+ virtual QString description() const = 0;
+
+ const QString &name() const { return m_name; }
+ const QString &shortName() const { return m_shortName; }
+ const QString &iconName() const { return m_iconName; }
+ float initialVolume() const { return m_initialVolume; }
+
+ void setName (const QString &name) { m_name = name; }
+ void setShortName (const QString &shortName) { m_shortName = shortName; }
+ void setIconName (const QString &iconName) { m_iconName = iconName; }
+ void setInitialVolume(float initialVolume) { m_initialVolume = initialVolume; }
+
+ void copyDescriptionFrom(const RadioStation &rs);
+
+ // for XML-Parsing/Export
+ virtual bool setProperty(const QString &property_name, const QString &val);
+ virtual QString getProperty(const QString &property_name) const;
+ virtual QStringList getPropertyNames() const;
+ virtual QString getClassName() const = 0;
+
+ // get empty derived stations by classname from registry
+ static RadioStation const *getStationClass(const QString &classname);
+ RadioStation const *getStationClass() const { return getStationClass(getClassName()); }
+
+ // = 0 : "this" is same as "s", e.g. approximately same frequency, same url, ...
+ // > 0 : "this" is numerically (frequencies) or alphanumerically (urls) or ... greater than "s"
+ // < 0 : "this" is numerically (frequencies) or alphanumerically (urls) or ... smaller than "s"
+ virtual int compare(const RadioStation &s) const = 0;
+
+ // is this station setup correctly ?
+ virtual bool isValid() const = 0;
+
+ /** returns an exact copy of this station */
+ virtual RadioStation *copy() const = 0;
+ /** returns an exact copy of this station, BUT with a new station ID */
+ virtual RadioStation *copyNewID() const = 0;
+
+ void generateNewStationID();
+
+ virtual RadioStationConfig *createEditor() const = 0;
+
+ virtual bool operator == (const RadioStation &x) const;
+ virtual bool operator != (const RadioStation &x) const { return !operator==(x); }
+
+protected :
+ QString m_stationID;
+
+ QString m_name;
+ QString m_shortName;
+ float m_initialVolume; // <0: => Don't use
+ QString m_iconName;
+
+private:
+ static QDict<RadioStation> *stationClassRegistry;
+};
+
+
+
+
+
+
+
+class UndefinedRadioStation : public RadioStation
+{
+public:
+ UndefinedRadioStation (RegisterStationClass) : RadioStation (registerStationClass, getClassName()) {}
+
+ virtual QString longName() const { return i18n("unknown"); }
+ virtual QString description() const { return i18n("unknown"); }
+ virtual bool isValid() const { return false; }
+ virtual RadioStation *copy() const { return new UndefinedRadioStation(*this); }
+ virtual RadioStation *copyNewID() const { RadioStation *x = new UndefinedRadioStation(*this); x->generateNewStationID(); return x; }
+ virtual int compare(const RadioStation &s) const;
+
+ virtual QString getClassName() const { return "UndefinedRadioStation"; }
+ virtual RadioStationConfig *createEditor() const;
+};
+
+
+extern const UndefinedRadioStation undefinedRadioStation;
+
+#endif
diff --git a/kradio3/src/include/ringbuffer.h b/kradio3/src/include/ringbuffer.h
new file mode 100644
index 0000000..1f545ca
--- /dev/null
+++ b/kradio3/src/include/ringbuffer.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ ringbuffer.h - description
+ -------------------
+ begin : Sun March 21 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KRADIO_RING_BUFFER_H
+#define _KRADIO_RING_BUFFER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+
+class RingBuffer
+{
+public:
+ RingBuffer(size_t size);
+ ~RingBuffer();
+
+ bool resize(size_t new_size);
+
+ size_t addData (const char *src, size_t size);
+ size_t takeData(char *dst, size_t size);
+
+ char *getFreeSpace(size_t &size);
+ size_t removeFreeSpace(size_t size);
+
+ char *getData(size_t &size);
+ size_t removeData(size_t size);
+
+ size_t getSize() const { return m_Size; }
+ size_t getFillSize() const { return m_FillSize; }
+ size_t getFreeSize() const { return m_Size - m_FillSize; }
+
+ void clear();
+
+protected:
+
+ char *m_Buffer;
+ size_t m_Start;
+ size_t m_Size,
+ m_FillSize;
+};
+
+#endif
diff --git a/kradio3/src/include/seekhelper.h b/kradio3/src/include/seekhelper.h
new file mode 100644
index 0000000..01d8d86
--- /dev/null
+++ b/kradio3/src/include/seekhelper.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ seekhelper.h - description
+ -------------------
+ begin : Sam Mai 10 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_SEEKHELPER_H
+#define KRADIO_SEEKHELPER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "radiodevice_interfaces.h"
+#include "soundstreamclient_interfaces.h"
+
+
+class SeekHelper : public IRadioDeviceClient,
+ public ISoundStreamClient
+{
+public:
+ typedef enum { off, searchWorse, searchBest } state_t;
+ typedef enum { up, down } direction_t;
+
+ SeekHelper(ISeekRadio &parent);
+ virtual ~SeekHelper();
+
+ virtual bool connectI (Interface *i);
+ virtual bool disconnectI(Interface *i);
+
+ virtual void start(const SoundStreamID &id, direction_t dir);
+ virtual void step();
+ virtual void stop();
+
+ bool isRunning() const { return m_state != off; }
+ bool isRunningUp() const { return m_state != off && m_direction == up; }
+ bool isRunningDown() const { return m_state != off && m_direction == down; }
+
+
+// IRadioDeviceClient
+RECEIVERS:
+ bool noticePowerChanged (bool /*on*/, const IRadioDevice */*sender*/) { return false; }
+ bool noticeStationChanged (const RadioStation &, const IRadioDevice */*sender*/) { return false; }
+ bool noticeDescriptionChanged (const QString &, const IRadioDevice */*sender*/) { return false; }
+
+ bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/, const IRadioDevice */*sender*/) { return false; }
+
+protected:
+
+ virtual void finish();
+
+ virtual void abort() = 0;
+ virtual bool isGood() const = 0;
+ virtual bool isBetter() const = 0;
+ virtual bool isWorse() const = 0;
+ virtual bool bestFound() const = 0;
+ virtual void getData() = 0;
+ virtual void rememberBest() = 0;
+ virtual bool nextSeekStep() = 0;
+ virtual void applyBest() = 0;
+
+protected:
+ state_t m_state;
+ direction_t m_direction;
+ bool m_oldMute;
+
+ ISeekRadio &m_parent;
+ SoundStreamID m_SoundStreamID;
+};
+
+#endif
+
diff --git a/kradio3/src/include/sound_metadata.h b/kradio3/src/include/sound_metadata.h
new file mode 100644
index 0000000..ceecb9c
--- /dev/null
+++ b/kradio3/src/include/sound_metadata.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ sound_metadata.h - description
+ -------------------
+ begin : Sun May 15 2005
+ copyright : (C) 2005 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_SOUND_METADATA_H
+#define KRADIO_SOUND_METADATA_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <time.h>
+#include <endian.h>
+#include <qstring.h>
+#include <kconfig.h>
+#include <kurl.h>
+
+class SoundMetaData
+{
+public:
+ SoundMetaData (Q_UINT64 pos, time_t rel_ts, time_t abs_ts, const KURL &url = KURL())
+ : m_DataPosition(pos), m_relativeTimestamp(rel_ts), m_absoluteTimestamp(abs_ts), m_URL(url) {}
+
+ Q_UINT64 position() const { return m_DataPosition; }
+ KURL url() const { return m_URL; }
+ time_t relativeTimestamp() const { return m_relativeTimestamp; }
+ time_t absoluteTimestamp() const { return m_absoluteTimestamp; }
+
+protected:
+ Q_UINT64 m_DataPosition;
+ time_t m_relativeTimestamp;
+ time_t m_absoluteTimestamp;
+ KURL m_URL;
+};
+
+
+#endif
diff --git a/kradio3/src/include/soundformat.h b/kradio3/src/include/soundformat.h
new file mode 100644
index 0000000..0c7a384
--- /dev/null
+++ b/kradio3/src/include/soundformat.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ soundformat.h - description
+ -------------------
+ begin : Sun Aug 1 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_SOUNDFORMAT_H
+#define KRADIO_SOUNDFORMAT_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <endian.h>
+#include <qstring.h>
+#include <kconfig.h>
+
+struct SoundFormat {
+ unsigned m_SampleRate;
+ unsigned m_Channels;
+ unsigned m_SampleBits;
+ bool m_IsSigned;
+ unsigned m_Endianess;
+ QString m_Encoding; // "raw", "mp3", ... (no "wav", because it's only header + raw data)
+
+ SoundFormat(unsigned sample_rate, unsigned channels, unsigned sample_bits, bool is_signed, unsigned endianess, const QString &enc)
+ : m_SampleRate(sample_rate), m_Channels(channels), m_SampleBits(sample_bits), m_IsSigned(is_signed), m_Endianess(endianess), m_Encoding(enc) {}
+ SoundFormat(unsigned sample_rate, unsigned channels, unsigned sample_bits, bool is_signed, unsigned endianess)
+ : m_SampleRate(sample_rate), m_Channels(channels), m_SampleBits(sample_bits), m_IsSigned(is_signed), m_Endianess(endianess), m_Encoding("raw") {}
+ SoundFormat(unsigned sample_rate, unsigned channels, unsigned sample_bits, bool is_signed)
+ : m_SampleRate(sample_rate), m_Channels(channels), m_SampleBits(sample_bits), m_IsSigned(is_signed), m_Endianess(BYTE_ORDER), m_Encoding("raw") {}
+ SoundFormat(bool stereo)
+ : m_SampleRate(44100), m_Channels(stereo ? 2 : 1), m_SampleBits(16), m_IsSigned(true), m_Endianess(BYTE_ORDER), m_Encoding("raw") {}
+ SoundFormat()
+ : m_SampleRate(44100), m_Channels(2), m_SampleBits(16), m_IsSigned(true), m_Endianess(BYTE_ORDER), m_Encoding("raw") {}
+
+ bool operator == (const SoundFormat &o) const { return m_SampleRate == o.m_SampleRate &&
+ m_Channels == o.m_Channels &&
+ m_SampleBits == o.m_SampleBits &&
+ m_IsSigned == o.m_IsSigned &&
+ m_Endianess == o.m_Endianess &&
+ m_Encoding == o.m_Encoding
+ ;
+ }
+ bool operator != (const SoundFormat &o) const { return !operator == (o); }
+
+ int sampleSize() const; // size of a single sample
+ int frameSize() const; // sampleSize * channels
+ int minValue() const;
+ int maxValue() const;
+
+ void restoreConfig(const QString &prefix, KConfig *c);
+ void saveConfig(const QString &prefix, KConfig *c) const;
+
+ int convertSampleToInt(const char *sample, bool do_scale) const;
+ void convertIntToSample(int src, char *dst, bool is_scaled) const;
+ void convertSamplesToInts(const char *src, int *dst, size_t n, bool do_scale) const;
+ void convertIntsToSamples(const int *src, char *dst, size_t n, bool is_scaled) const;
+ void convertSamplesToFloat (const char *src, float **dst, size_t n) const;
+ void convertFloatsToSamples(const float **src, char *dst, size_t n) const;
+};
+
+
+#endif
diff --git a/kradio3/src/include/soundstreamclient_interfaces.h b/kradio3/src/include/soundstreamclient_interfaces.h
new file mode 100644
index 0000000..a3de4ca
--- /dev/null
+++ b/kradio3/src/include/soundstreamclient_interfaces.h
@@ -0,0 +1,372 @@
+/***************************************************************************
+ sounddevice_interfaces.h - description
+ -------------------
+ begin : Sun Mar 21 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * Interfaces in this header: *
+ * *
+ * ISoundDevice(Client) *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_SOUNDSTREAMCLIENT_INTERFACES_H
+#define KRADIO_SOUNDSTREAMCLIENT_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kconfig.h>
+#include <qmap.h>
+
+#include "interfaces.h"
+#include "soundformat.h"
+#include "soundstreamid.h"
+#include "sound_metadata.h"
+
+
+#define CALL_SNDSTR_SERVER(name, param, call) \
+ inline int name param const { \
+ return iConnections.count() ? iConnections.getFirst()->name call : 0; \
+ }
+
+
+#define SIZE_T_DONT_CARE ((size_t)(-1))
+
+class RadioStation;
+
+INTERFACE(ISoundStreamServer, ISoundStreamClient)
+{
+friend class ISoundStreamClient;
+public:
+ IF_CON_DESTRUCTOR(ISoundStreamServer, -1)
+
+ virtual void noticeConnectedI(cmplInterface *i, bool valid);
+ virtual void noticeDisconnectedI(cmplInterface *i, bool valid);
+
+ virtual QMap<QString, ISoundStreamClient *> getPlaybackClients() const;
+ virtual QMap<QString, QString> getPlaybackClientDescriptions() const;
+ virtual QMap<QString, ISoundStreamClient *> getCaptureClients() const;
+ virtual QMap<QString, QString> getCaptureClientDescriptions() const;
+ virtual ISoundStreamClient *getSoundStreamClientWithID(const QString &id) const;
+
+ANSWERS:
+ virtual QPtrList<ISoundStreamClient> getPlaybackMixers() const;
+ virtual QPtrList<ISoundStreamClient> getCaptureMixers() const;
+
+
+SENDERS:
+ IF_SENDER_FINE ( notifyPlaybackChannelsChanged, (const QString &/*client_id*/, const QStringList &) )
+ IF_SENDER_FINE ( notifyCaptureChannelsChanged, (const QString &/*client_id*/, const QStringList &) )
+
+ IF_SENDER_FINE ( sendPlaybackVolume, (SoundStreamID /*id*/, float /*volume*/) )
+ IF_SENDER_FINE ( sendCaptureVolume, (SoundStreamID /*id*/, float /*volume*/) )
+ IF_SENDER_FINE ( queryPlaybackVolume, (SoundStreamID /*id*/, float &/*volume*/) )
+ IF_SENDER_FINE ( queryCaptureVolume, (SoundStreamID /*id*/, float &/*volume*/) )
+ IF_SENDER_FINE ( notifyPlaybackVolumeChanged, (SoundStreamID /*id*/, float /*volume*/) )
+ IF_SENDER_FINE ( notifyCaptureVolumeChanged, (SoundStreamID /*id*/, float /*volume*/) )
+
+ IF_SENDER_FINE ( notifyTrebleChanged, (SoundStreamID /*id*/, float /*v*/) )
+ IF_SENDER_FINE ( notifyBassChanged, (SoundStreamID /*id*/, float /*v*/) )
+ IF_SENDER_FINE ( notifyBalanceChanged, (SoundStreamID /*id*/, float /*v*/) )
+ IF_SENDER_FINE ( notifyMuted, (SoundStreamID /*id*/, bool /*m*/) )
+ IF_SENDER_FINE ( notifySignalQualityChanged, (SoundStreamID /*id*/, float /*q*/) )
+ IF_SENDER_FINE ( notifySignalQualityBoolChanged, (SoundStreamID /*id*/, bool /*good*/) )
+ IF_SENDER_FINE ( notifySignalMinQualityChanged, (SoundStreamID /*id*/, float /*q*/) )
+ IF_SENDER_FINE ( notifyStereoChanged, (SoundStreamID /*id*/, bool /*s*/) )
+
+ IF_SENDER_FINE ( sendTreble, (SoundStreamID /*id*/, float /*v*/) )
+ IF_SENDER_FINE ( sendBass, (SoundStreamID /*id*/, float /*v*/) )
+ IF_SENDER_FINE ( sendBalance, (SoundStreamID /*id*/, float /*v*/) )
+ IF_SENDER_FINE ( sendMute, (SoundStreamID /*id*/, bool mute = true) )
+ IF_SENDER_FINE ( sendUnmute, (SoundStreamID /*id*/, bool unmute = true) )
+ IF_SENDER_FINE ( sendSignalMinQuality, (SoundStreamID /*id*/, float /*q*/) )
+ IF_SENDER_FINE ( sendStereo, (SoundStreamID /*id*/, bool /*s*/) )
+
+ IF_SENDER_FINE ( queryTreble, (SoundStreamID /*id*/, float &) )
+ IF_SENDER_FINE ( queryBass, (SoundStreamID /*id*/, float &) )
+ IF_SENDER_FINE ( queryBalance, (SoundStreamID /*id*/, float &) )
+ IF_SENDER_FINE ( querySignalQuality, (SoundStreamID /*id*/, float &) )
+ IF_SENDER_FINE ( querySignalMinQuality, (SoundStreamID /*id*/, float &) )
+ IF_SENDER_FINE ( queryHasGoodQuality, (SoundStreamID /*id*/, bool &) )
+ IF_SENDER_FINE ( queryIsStereo, (SoundStreamID /*id*/, bool &) )
+ IF_SENDER_FINE ( queryIsMuted, (SoundStreamID /*id*/, bool &) )
+
+
+ // sendPreparePlayback/sendPrepareCapture don't make sense for multiple receivers
+ IF_SENDER_FINE ( sendReleasePlayback, (SoundStreamID id) )
+ IF_SENDER_FINE ( sendReleaseCapture, (SoundStreamID id) )
+
+ IF_SENDER_FINE ( sendStartPlayback, (SoundStreamID id) )
+ IF_SENDER_FINE ( sendPausePlayback, (SoundStreamID id) )
+ IF_SENDER_FINE ( sendStopPlayback, (SoundStreamID id) )
+ IF_SENDER_FINE ( queryIsPlaybackRunning, (SoundStreamID id, bool &) )
+
+// IF_SENDER_FINE ( sendStartCapture, (SoundStreamID id) )
+ IF_SENDER_FINE ( sendStartCaptureWithFormat, (SoundStreamID id,
+ const SoundFormat &proposed_format,
+ SoundFormat &real_format,
+ bool force_format = false) )
+ IF_SENDER_FINE ( sendStopCapture, (SoundStreamID id) )
+ IF_SENDER_FINE ( queryIsCaptureRunning, (SoundStreamID id, bool &running, SoundFormat &sf))
+
+ // we need extra recording, in order to distinguish between plain capturing
+ // (making sound data available to kradio) and writing a stream to disk or sth similar
+ IF_SENDER_FINE ( sendStartRecording, (SoundStreamID id) )
+ IF_SENDER_FINE ( sendStartRecordingWithFormat, (SoundStreamID id,
+ const SoundFormat &proposed_format,
+ SoundFormat &real_format) )
+ IF_SENDER_FINE ( sendStopRecording, (SoundStreamID id) )
+ IF_SENDER_FINE ( queryIsRecordingRunning, (SoundStreamID id, bool &running, SoundFormat &sf))
+
+ IF_SENDER_FINE ( querySoundStreamDescription, (SoundStreamID id, QString &descr) )
+ IF_SENDER_FINE ( querySoundStreamRadioStation, (SoundStreamID id, const RadioStation *&rs))
+ IF_SENDER_FINE ( queryEnumerateSoundStreams, (QMap<QString, SoundStreamID> &) )
+
+ IF_SENDER_FINE ( notifySoundStreamCreated, (SoundStreamID id) )
+ IF_SENDER_FINE ( notifySoundStreamClosed, (SoundStreamID id) )
+ IF_SENDER_FINE ( notifySoundStreamRedirected, (SoundStreamID oldID, SoundStreamID newID) )
+
+ // e.g description or whatever changed
+ IF_SENDER_FINE ( notifySoundStreamChanged, (SoundStreamID id) )
+
+ IF_SENDER_FINE ( notifySoundStreamData, (SoundStreamID /*id*/, const SoundFormat &, const char */*data*/, size_t /*size*/, size_t &/*consumed_size*/, const SoundMetaData &/*md*/) )
+ IF_SENDER_FINE ( notifyReadyForPlaybackData, (SoundStreamID /*id*/, size_t /*size*/) )
+};
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+INTERFACE(ISoundStreamClient, ISoundStreamServer)
+{
+public:
+ ISoundStreamClient();
+ virtual ~ISoundStreamClient();
+
+ cmplInterface *getSoundStreamServer() const { return m_Server; }
+
+
+ virtual void noticeConnectedSoundClient(thisInterface *i, bool valid);
+ virtual void noticeDisconnectedSoundClient(thisInterface *i, bool valid);
+
+ virtual void noticeConnectedI(cmplInterface *i, bool valid);
+ virtual void noticeDisconnectedI(cmplInterface *i, bool valid);
+
+// some rarely implemented functions are not pure virtual for convenience
+
+// direct playback / capture device functions
+
+RECEIVERS:
+ IF_RECEIVER_EMPTY( preparePlayback(SoundStreamID /*id*/, const QString &/*channel*/, bool /*active_mode*/, bool /*start_immediately = false*/) )
+ IF_RECEIVER_EMPTY( prepareCapture(SoundStreamID /*id*/, const QString &/*channel*/) )
+ IF_RECEIVER_EMPTY( releasePlayback(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( releaseCapture(SoundStreamID /*id*/) )
+
+ANSWERS:
+ virtual bool supportsPlayback() const { return false; }
+ virtual bool supportsCapture() const { return false; }
+
+ virtual const QString &getSoundStreamClientID() const;
+ virtual QString getSoundStreamClientDescription() const { return QString::null; }
+
+ virtual QMap<QString, ISoundStreamClient *> getPlaybackClients() const;
+ virtual QMap<QString, QString> getPlaybackClientDescriptions() const;
+ virtual QMap<QString, ISoundStreamClient *> getCaptureClients() const;
+ virtual QMap<QString, QString> getCaptureClientDescriptions() const;
+ virtual ISoundStreamClient *getSoundStreamClientWithID(const QString &id) const;
+
+// device mixer functions
+
+QUERIES:
+ IF_QUERY ( QPtrList<ISoundStreamClient> queryPlaybackMixers() );
+ IF_QUERY ( QPtrList<ISoundStreamClient> queryCaptureMixers() );
+
+
+ANSWERS:
+ virtual const QStringList &getPlaybackChannels() const;
+ virtual const QStringList &getCaptureChannels() const;
+
+RECEIVERS:
+ IF_RECEIVER_EMPTY( noticePlaybackChannelsChanged(const QString & /*client_id*/, const QStringList &/*channels*/) );
+ IF_RECEIVER_EMPTY( noticeCaptureChannelsChanged (const QString & /*client_id*/, const QStringList &/*channels*/) );
+
+
+RECEIVERS:
+ IF_RECEIVER_EMPTY( setPlaybackVolume(SoundStreamID /*id*/, float /*volume*/) )
+ IF_RECEIVER_EMPTY( setCaptureVolume(SoundStreamID /*id*/, float /*volume*/) )
+ IF_RECEIVER_EMPTY( getPlaybackVolume(SoundStreamID /*id*/, float &/*volume*/) const )
+ IF_RECEIVER_EMPTY( getCaptureVolume(SoundStreamID /*id*/, float &/*volume*/) const )
+ IF_RECEIVER_EMPTY( noticePlaybackVolumeChanged(SoundStreamID /*id*/, float /*volume*/) )
+ IF_RECEIVER_EMPTY( noticeCaptureVolumeChanged(SoundStreamID /*id*/, float /*volume*/) )
+
+ IF_RECEIVER_EMPTY( setTreble (SoundStreamID /*id*/, float /*v*/) )
+ IF_RECEIVER_EMPTY( setBass (SoundStreamID /*id*/, float /*v*/) )
+ IF_RECEIVER_EMPTY( setBalance (SoundStreamID /*id*/, float /*v*/) )
+ IF_RECEIVER_EMPTY( mute (SoundStreamID /*id*/, bool /*mute*/) )
+ IF_RECEIVER_EMPTY( unmute (SoundStreamID /*id*/, bool /*unmute*/) )
+ IF_RECEIVER_EMPTY( setSignalMinQuality(SoundStreamID /*id*/, float /*q*/) )
+ IF_RECEIVER_EMPTY( setStereo(SoundStreamID /*id*/, bool /*s*/) )
+
+ IF_RECEIVER_EMPTY( noticeTrebleChanged(SoundStreamID /*id*/, float /*v*/) )
+ IF_RECEIVER_EMPTY( noticeBassChanged(SoundStreamID /*id*/, float /*v*/) )
+ IF_RECEIVER_EMPTY( noticeBalanceChanged(SoundStreamID /*id*/, float /*v*/) )
+ IF_RECEIVER_EMPTY( noticeSignalQualityChanged(SoundStreamID /*id*/, float /*q*/) )
+ IF_RECEIVER_EMPTY( noticeSignalQualityChanged(SoundStreamID /*id*/, bool /*good*/) )
+ IF_RECEIVER_EMPTY( noticeSignalMinQualityChanged(SoundStreamID /*id*/, float /*q*/) )
+ IF_RECEIVER_EMPTY( noticeStereoChanged(SoundStreamID /*id*/, bool /*s*/) )
+ IF_RECEIVER_EMPTY( noticeMuted(SoundStreamID /*id*/, bool /*m*/) )
+
+ IF_RECEIVER_EMPTY( getTreble (SoundStreamID /*id*/, float &/*v*/) const )
+ IF_RECEIVER_EMPTY( getBass (SoundStreamID /*id*/, float &/*v*/) const )
+ IF_RECEIVER_EMPTY( getBalance(SoundStreamID /*id*/, float &/*v*/) const )
+ IF_RECEIVER_EMPTY( isMuted(SoundStreamID /*id*/, bool &/*m*/) const )
+ IF_RECEIVER_EMPTY( getSignalQuality(SoundStreamID /*id*/, float &/*q*/) const )
+ IF_RECEIVER_EMPTY( getSignalMinQuality(SoundStreamID /*id*/, float &/*q*/) const )
+ IF_RECEIVER_EMPTY( hasGoodQuality(SoundStreamID /*id*/, bool &/*good*/) const )
+ IF_RECEIVER_EMPTY( isStereo(SoundStreamID /*id*/, bool &/*s*/) const )
+
+// generic stream handling (broadcasts)
+
+RECEIVERS:
+ IF_RECEIVER_EMPTY( startPlayback(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( pausePlayback(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( stopPlayback(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( isPlaybackRunning(SoundStreamID /*id*/, bool &) const )
+
+// IF_RECEIVER_EMPTY( startCapture(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( startCaptureWithFormat(SoundStreamID /*id*/,
+ const SoundFormat &/*proposed_format*/,
+ SoundFormat &/*real_format*/,
+ bool /*force_format*/ = false) )
+ IF_RECEIVER_EMPTY( stopCapture(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( isCaptureRunning(SoundStreamID /*id*/, bool &/*running*/, SoundFormat &/*sf*/) const )
+
+ IF_RECEIVER_EMPTY( startRecording(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( startRecordingWithFormat(SoundStreamID /*id*/,
+ const SoundFormat &/*proposed_format*/,
+ SoundFormat &/*real_format*/) )
+ IF_RECEIVER_EMPTY( stopRecording(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( isRecordingRunning(SoundStreamID /*id*/, bool &/*running*/, SoundFormat &/*sf*/) const )
+
+ IF_RECEIVER_EMPTY( getSoundStreamDescription(SoundStreamID /*id*/, QString &/*descr*/) const )
+ IF_RECEIVER_EMPTY( getSoundStreamRadioStation(SoundStreamID /*id*/, const RadioStation *&/*rs*/) const )
+
+ IF_RECEIVER_EMPTY( enumerateSoundStreams(QMap<QString, SoundStreamID> &/*list*/) const )
+
+ IF_RECEIVER_EMPTY( noticeSoundStreamCreated(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( noticeSoundStreamClosed(SoundStreamID /*id*/) )
+ IF_RECEIVER_EMPTY( noticeSoundStreamRedirected(SoundStreamID /*oldID*/, SoundStreamID /*newID*/) )
+
+ // e.g description or whatever changed
+ IF_RECEIVER_EMPTY( noticeSoundStreamChanged(SoundStreamID /*id*/) )
+
+ IF_RECEIVER_EMPTY( noticeSoundStreamData(SoundStreamID /*id*/, const SoundFormat &, const char */*data*/, size_t /*size*/, size_t &/*consumed_size*/, const SoundMetaData &/*md*/))
+ IF_RECEIVER_EMPTY( noticeReadyForPlaybackData(SoundStreamID /*id*/, size_t /*size*/) )
+
+SENDERS:
+ CALL_SNDSTR_SERVER ( notifyPlaybackChannelsChanged, (const QString &client_id, const QStringList &map), (client_id, map) )
+ CALL_SNDSTR_SERVER ( notifyCaptureChannelsChanged, (const QString &client_id, const QStringList &map), (client_id, map) )
+
+ CALL_SNDSTR_SERVER ( sendPlaybackVolume, (SoundStreamID id, float volume), (id, volume) )
+ CALL_SNDSTR_SERVER ( sendCaptureVolume, (SoundStreamID id, float volume), (id, volume) )
+ CALL_SNDSTR_SERVER ( queryPlaybackVolume, (SoundStreamID id, float &volume), (id, volume) )
+ CALL_SNDSTR_SERVER ( queryCaptureVolume, (SoundStreamID id, float &volume), (id, volume) )
+ CALL_SNDSTR_SERVER ( notifyPlaybackVolumeChanged, (SoundStreamID id, float volume), (id, volume) )
+ CALL_SNDSTR_SERVER ( notifyCaptureVolumeChanged, (SoundStreamID id, float volume), (id, volume) )
+
+ CALL_SNDSTR_SERVER ( notifyTrebleChanged, (SoundStreamID id, float v), (id, v) )
+ CALL_SNDSTR_SERVER ( notifyBassChanged, (SoundStreamID id, float v), (id, v) )
+ CALL_SNDSTR_SERVER ( notifyBalanceChanged, (SoundStreamID id, float v), (id, v) )
+ CALL_SNDSTR_SERVER ( notifyMuted, (SoundStreamID id, bool m), (id, m) )
+ CALL_SNDSTR_SERVER ( notifySignalQualityChanged, (SoundStreamID id, float q), (id, q) )
+ CALL_SNDSTR_SERVER ( notifySignalQualityBoolChanged, (SoundStreamID id, bool good), (id, good) )
+ CALL_SNDSTR_SERVER ( notifySignalMinQualityChanged, (SoundStreamID id, float q), (id, q) )
+ CALL_SNDSTR_SERVER ( notifyStereoChanged, (SoundStreamID id, bool s), (id, s) )
+
+ CALL_SNDSTR_SERVER ( sendTreble , (SoundStreamID id, float v), (id, v) )
+ CALL_SNDSTR_SERVER ( sendBass , (SoundStreamID id, float v), (id, v) )
+ CALL_SNDSTR_SERVER ( sendBalance , (SoundStreamID id, float v), (id, v) )
+ CALL_SNDSTR_SERVER ( sendMute , (SoundStreamID id, bool mute = true), (id, mute) )
+ CALL_SNDSTR_SERVER ( sendUnmute , (SoundStreamID id, bool unmute = true), (id, unmute) )
+ CALL_SNDSTR_SERVER ( sendSignalMinQuality , (SoundStreamID id, float q), (id, q) )
+ CALL_SNDSTR_SERVER ( sendStereo, (SoundStreamID id, bool s), (id, s) )
+
+ CALL_SNDSTR_SERVER ( queryTreble, (SoundStreamID id, float &v), (id, v) )
+ CALL_SNDSTR_SERVER ( queryBass, (SoundStreamID id, float &v), (id, v) )
+ CALL_SNDSTR_SERVER ( queryBalance, (SoundStreamID id, float &v), (id, v) )
+ CALL_SNDSTR_SERVER ( querySignalQuality, (SoundStreamID id, float &v), (id, v) )
+ CALL_SNDSTR_SERVER ( querySignalMinQuality, (SoundStreamID id, float &v), (id, v) )
+ CALL_SNDSTR_SERVER ( queryHasGoodQuality, (SoundStreamID id, bool &v), (id, v) )
+ CALL_SNDSTR_SERVER ( queryIsStereo, (SoundStreamID id, bool &v), (id, v) )
+ CALL_SNDSTR_SERVER ( queryIsMuted, (SoundStreamID id, bool &v), (id, v) )
+
+
+ // sendPreparePlayback/sendPrepareCapture don't make sense for multiple receivers
+ CALL_SNDSTR_SERVER ( sendReleasePlayback, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( sendReleaseCapture, (SoundStreamID id), (id) )
+
+ CALL_SNDSTR_SERVER ( sendStartPlayback, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( sendPausePlayback, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( sendStopPlayback, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( queryIsPlaybackRunning, (SoundStreamID id, bool &b), (id, b) )
+
+// CALL_SNDSTR_SERVER ( sendStartCapture, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( sendStartCaptureWithFormat, (SoundStreamID id,
+ const SoundFormat &proposed_format,
+ SoundFormat &real_format,
+ bool force_format = false), (id, proposed_format, real_format, force_format) )
+ CALL_SNDSTR_SERVER ( sendStopCapture, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( queryIsCaptureRunning, (SoundStreamID id, bool &b, SoundFormat &sf), (id, b, sf) )
+
+ CALL_SNDSTR_SERVER ( sendStartRecording, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( sendStartRecordingWithFormat, (SoundStreamID id,
+ const SoundFormat &proposed_format,
+ SoundFormat &real_format), (id, proposed_format, real_format) )
+ CALL_SNDSTR_SERVER ( sendStopRecording, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( queryIsRecordingRunning, (SoundStreamID id, bool &b, SoundFormat &sf), (id, b, sf) )
+
+ CALL_SNDSTR_SERVER ( querySoundStreamDescription, (SoundStreamID id, QString &descr), (id, descr) )
+ CALL_SNDSTR_SERVER ( querySoundStreamRadioStation,(SoundStreamID id, const RadioStation *&rs), (id, rs) )
+
+ CALL_SNDSTR_SERVER ( queryEnumerateSoundStreams, (QMap<QString, SoundStreamID> &list), (list) )
+
+ CALL_SNDSTR_SERVER ( notifySoundStreamCreated, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( notifySoundStreamClosed, (SoundStreamID id), (id) )
+ CALL_SNDSTR_SERVER ( notifySoundStreamRedirected, (SoundStreamID oldID, SoundStreamID newID), (oldID, newID) )
+
+ // e.g description or whatever changed
+ CALL_SNDSTR_SERVER ( notifySoundStreamChanged, (SoundStreamID id), (id) )
+
+ CALL_SNDSTR_SERVER ( notifySoundStreamData, (SoundStreamID id, const SoundFormat &f, const char *data, size_t size, size_t consumed_size, const SoundMetaData &md), (id, f, data, size, consumed_size, md) )
+ CALL_SNDSTR_SERVER ( notifyReadyForPlaybackData, (SoundStreamID id, size_t size), (id, size) )
+
+protected:
+
+ SoundStreamID createNewSoundStream(bool notify = true) const;
+ SoundStreamID createNewSoundStream(SoundStreamID old_id, bool notify = true) const;
+ void closeSoundStream(SoundStreamID id, bool notify = true);
+
+ static QString createNewSoundStreamClientID();
+ void setSoundStreamClientID(const QString &s);
+
+ QString m_SoundStreamClientID;
+
+ cmplInterface *m_Server;
+};
+
+
+#endif
diff --git a/kradio3/src/include/soundstreamid.h b/kradio3/src/include/soundstreamid.h
new file mode 100644
index 0000000..e7aa4d5
--- /dev/null
+++ b/kradio3/src/include/soundstreamid.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ soundstreamid.h - description
+ -------------------
+ begin : Sun Aug 1 2004
+ copyright : (C) 2004 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_SOUNDSTREAMID_H
+#define KRADIO_SOUNDSTREAMID_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+class SoundStreamID {
+
+ SoundStreamID(int _id, int _phys_id);
+public:
+ SoundStreamID();
+ SoundStreamID(const SoundStreamID &org);
+
+ SoundStreamID &operator = (const SoundStreamID &id);
+
+ static SoundStreamID createNewID();
+ static SoundStreamID createNewID(const SoundStreamID &oldID);
+
+ bool operator == (const SoundStreamID id) const { return m_ID == id.m_ID; }
+ bool operator != (const SoundStreamID id) const { return m_ID != id.m_ID; }
+ bool operator > (const SoundStreamID id) const { return m_ID > id.m_ID; }
+ bool operator < (const SoundStreamID id) const { return m_ID < id.m_ID; }
+ bool operator >= (const SoundStreamID id) const { return m_ID >= id.m_ID; }
+ bool operator <= (const SoundStreamID id) const { return m_ID <= id.m_ID; }
+
+ bool HasSamePhysicalID(const SoundStreamID &x) const { return m_PhysicalID == x.m_PhysicalID; }
+
+ bool isValid() const { return m_ID != 0; } // m_PhysicalID is not checked!
+ void invalidate();
+
+ static const SoundStreamID InvalidID;
+
+ int getID() const { return m_ID; }
+ int getPhysicalID() const { return m_PhysicalID; }
+
+protected:
+ unsigned m_ID;
+ unsigned m_PhysicalID;
+ static unsigned nextID;
+ static unsigned nextPhysicalID;
+};
+
+
+#endif
+
diff --git a/kradio3/src/include/standardscandialog.h b/kradio3/src/include/standardscandialog.h
new file mode 100644
index 0000000..475457b
--- /dev/null
+++ b/kradio3/src/include/standardscandialog.h
@@ -0,0 +1,100 @@
+/***************************************************************************
+ standardscandialog.h - description
+ -------------------
+ begin : Son Aug 3 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_STANDARDSCANDIALOG_H
+#define KRADIO_STANDARDSCANDIALOG_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <standardscandialog-ui.h>
+#include "radiodevice_interfaces.h"
+#include "radio_interfaces.h"
+#include "stationlist.h"
+
+#include <qtimer.h>
+#include <qdatetime.h>
+
+class StandardScanDialog : public StandardScanDialogUI,
+ public ISeekRadioClient,
+// public IRadioSoundClient,
+ public IRadioClient
+{
+Q_OBJECT
+public:
+ StandardScanDialog(QWidget *parent);
+ ~StandardScanDialog();
+
+ bool connectI (Interface *i);
+ bool disconnectI (Interface *i);
+
+ void start();
+ void stop();
+
+ const StationList &getStations() const { return m_stations; }
+
+// ISeekRadioClient
+
+RECEIVERS:
+ bool noticeSeekStarted (bool up);
+ bool noticeSeekStopped ();
+ bool noticeSeekFinished (const RadioStation &s, bool goodQuality);
+ bool noticeProgress (float f);
+
+// // ISoundRadioClient
+//
+// RECEIVERS:
+// bool noticeVolumeChanged(float /*v*/) { return false; }
+// bool noticeTrebleChanged(float /*v*/) { return false; }
+// bool noticeBassChanged(float /*v*/) { return false; }
+// bool noticeBalanceChanged(float /*v*/) { return false; }
+// bool noticeSignalQualityChanged(float /*q*/) { return false; }
+// bool noticeSignalQualityChanged(bool /*good*/) { return false; }
+// bool noticeSignalMinQualityChanged(float /*q*/) { return false; }
+// bool noticeStereoChanged(bool /*s*/) { return false; }
+// bool noticeMuted(bool /*m*/) { return false; }
+
+// IRadioClient
+
+RECEIVERS:
+ bool noticePowerChanged(bool on);
+ bool noticeStationChanged (const RadioStation &, int /*idx*/){ return false; }
+ bool noticeStationsChanged(const StationList &/*sl*/) { return false; }
+ bool noticePresetFileChanged(const QString &/*f*/) { return false; }
+
+ bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/) { return false; }
+
+protected slots:
+
+ void slotCancelDone();
+
+protected:
+
+ int m_count;
+ bool m_running;
+ bool m_oldPowerOn;
+ RadioStation *m_oldStation;
+ QDateTime m_startTime;
+
+ StationList m_stations;
+
+ bool m_ignorePower;
+};
+
+
+#endif
diff --git a/kradio3/src/include/station-drag-object.h b/kradio3/src/include/station-drag-object.h
new file mode 100644
index 0000000..d65e7a6
--- /dev/null
+++ b/kradio3/src/include/station-drag-object.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ station-drag-object.h - description
+ -------------------
+ begin : Sun Aug 28 2005
+ copyright : (C) 2005 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_STATION_DRAG_OBJECT_H
+#define KRADIO_STATION_DRAG_OBJECT_H
+
+#include <qdragobject.h>
+
+class StationDragObject : public QStoredDrag
+{
+public:
+ StationDragObject(const QStringList &stationIDs, QWidget *dragSource = NULL, const char * name = NULL);
+ StationDragObject(QWidget *dragSource = NULL, const char * name = NULL);
+ virtual ~StationDragObject();
+
+ const char *format(int i = 0) const;
+
+ void setStations(const QStringList &stationIDs);
+
+ static bool canDecode (const QMimeSource *e);
+ static bool decode (const QMimeSource *e, QStringList &stationIDs);
+};
+
+#endif
+
diff --git a/kradio3/src/include/stationlist.h b/kradio3/src/include/stationlist.h
new file mode 100644
index 0000000..70fbd32
--- /dev/null
+++ b/kradio3/src/include/stationlist.h
@@ -0,0 +1,159 @@
+/***************************************************************************
+ stationlist.h - description
+ -------------------
+ begin : Sat March 29 2003
+ copyright : (C) 2003 by Klas Kalass
+ email : klas@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef STATIONLIST_H
+#define STATIONLIST_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "stationlistmetadata.h"
+#include "errorlog-interfaces.h"
+
+#include <qptrlist.h>
+
+class RadioStation;
+class KURL;
+
+/*
+
+ Why an own Station List ?
+
+ RadioStations are used everywhere. But who is responsible for them?
+ Especially after a list merge?
+
+ A very simple solution should be a StationList with "deep copies". Though
+ this is not very efficient, we can assume, that copy operations do not
+ take place very often and thus are not critical.
+
+
+ Why don't we use QValueList then?
+
+ We are using polymorphic radio stations, thus we cannot use a template
+ using instances of a base class and copying them with a copy constructor.
+ But as each derived class has its own copy() function, we are able to create
+ exact copies from a pointer with the type of our base class "RadioStation".
+
+*/
+
+
+class RawStationList : public QPtrList<RadioStation>
+{
+public:
+
+ typedef QPtrListIterator<RadioStation> Iterator;
+ typedef QPtrList<RadioStation> BaseClass;
+
+public:
+ RawStationList ();
+ RawStationList (const RawStationList &sl);
+ ~RawStationList ();
+
+ // overwrite all insert-methods in order to change
+ // multiple insertion of same station_id into an update
+
+ bool insert (uint index, const RadioStation *item);
+ bool insert (const RadioStation *item);
+ void inSort (const RadioStation *item);
+ void prepend (const RadioStation *item);
+ void append (const RadioStation *item);
+ bool replace (uint index, const RadioStation *item);
+
+ // simplify stationIDSearch
+
+ const RadioStation & stationWithID(const QString &sid) const;
+ RadioStation & stationWithID(const QString &sid);
+
+ int idxWithID(const QString &sid) const;
+
+ bool operator == (const RawStationList &l) const;
+ bool operator != (const RawStationList &l) const { return !operator==(l); }
+
+protected:
+
+ QPtrCollection::Item newItem (QPtrCollection::Item s);
+ void deleteItem (QPtrCollection::Item s);
+
+ int compareItems (QPtrCollection::Item a, QPtrCollection::Item b);
+};
+
+
+
+
+/**
+ * Contains a list of stations, including meta data
+ * @author Klas Kalass, Ernst Martin Witte
+ */
+
+class StationList {
+public:
+ StationList();
+ StationList(const StationList &sl);
+ ~StationList();
+
+ // some usefull "proxy" functions
+
+ int count() const { return m_all.count(); }
+ const RadioStation & at(int idx) const;
+ RadioStation & at(int idx);
+
+ const RadioStation & stationWithID(const QString &sid) const;
+ RadioStation & stationWithID(const QString &sid);
+
+ // all stations, with full access
+ RawStationList & all() { return m_all; }
+ RawStationList const & all() const { return m_all; }
+
+ // the meta data for this station List, with full access
+ StationListMetaData & metaData() { return m_metaData; }
+ StationListMetaData const & metaData() const { return m_metaData; }
+
+ // we do not need a special matchingStation/find/... method because
+ // it is already implemented in RawStationList
+
+ /**
+ * merges the other list into this one. creates copies from the stations.
+ */
+ void merge(const StationList &other);
+
+ // assignment
+
+ StationList &operator = (const StationList &sl);
+
+
+ // xml in/out
+
+ bool readXML (const QString &dat, const IErrorLogClient &logger, bool enableMessageBox = true);
+ bool readXML (const KURL &url, const IErrorLogClient &logger, bool enableMessageBox = true);
+
+ QString writeXML (const IErrorLogClient &logger) const;
+ bool writeXML (const KURL &url, const IErrorLogClient &logger, bool enableMessageBox = true) const;
+
+
+ bool operator == (const StationList &x) const { return m_all == x.m_all && m_metaData == x.m_metaData; }
+ bool operator != (const StationList &x) const { return !operator ==(x); }
+
+protected:
+ RawStationList m_all;
+ StationListMetaData m_metaData;
+};
+
+
+extern const StationList emptyStationList;
+
+#endif
diff --git a/kradio3/src/include/stationlistmetadata.h b/kradio3/src/include/stationlistmetadata.h
new file mode 100644
index 0000000..36adb29
--- /dev/null
+++ b/kradio3/src/include/stationlistmetadata.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ stationlistmetadata.h - description
+ -------------------
+ begin : Sat March 29 2003
+ copyright : (C) 2003 by Klas Kalass
+ email : klas@kde.org
+ copyright : (C) 2002 by Martin Witte / Frank Schwanz
+ email : witte@kawo1.rwth-aachen.de / schwanz@fh-brandenburg.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef STATIONLISTMETADATA_H
+#define STATIONLISTMETADATA_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstring.h>
+#include <qdatetime.h>
+
+/**
+ * Meta Data about a stationlist
+ * @author Martin Witte
+ */
+
+class StationListMetaData {
+public:
+ QString maintainer;
+ QDateTime lastChange;
+ QString country;
+ QString city;
+ QString media;
+ QString comment;
+
+ bool operator != (const StationListMetaData &x) const { return !operator ==(x); }
+ bool operator == (const StationListMetaData &x) const {
+ return maintainer == x.maintainer &&
+ lastChange == x.lastChange &&
+ country == x.country &&
+ city == x.city &&
+ media == x.media &&
+ comment == x.comment;
+ }
+};
+
+#endif
diff --git a/kradio3/src/include/stationlistxmlhandler.h b/kradio3/src/include/stationlistxmlhandler.h
new file mode 100644
index 0000000..7386933
--- /dev/null
+++ b/kradio3/src/include/stationlistxmlhandler.h
@@ -0,0 +1,85 @@
+/***************************************************************************
+ radiocfgxmlhandler.h - description
+ -------------------
+ begin : Son Jan 12 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef KRADIO_RADIOCFGXMLHANDLER_H
+#define KRADIO_RADIOCFGXMLHANDLER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qxml.h>
+#include <qobject.h>
+
+#include "radiostation.h"
+#include "stationlist.h"
+
+class StationListXmlHandler : public QXmlDefaultHandler
+{
+protected:
+ QStringList m_status;
+ const IErrorLogClient&m_logger;
+
+ RawStationList m_stations;
+ StationListMetaData m_metaData;
+
+ RadioStation *m_newStation;
+
+ bool m_compatMode;
+
+public :
+ StationListXmlHandler (const IErrorLogClient &logger);
+ virtual ~StationListXmlHandler ();
+ bool startDocument ();
+ bool startElement (const QString &ns, const QString &localname,
+ const QString& qname, const QXmlAttributes &);
+ bool endElement (const QString &ns, const QString &localname,
+ const QString &qname);
+ bool characters (const QString &ch);
+
+ const RawStationList &getStations() const { return m_stations; }
+ const StationListMetaData &getMetaData() const { return m_metaData; }
+
+
+ bool wasCompatMode() const { return m_compatMode; }
+
+protected:
+
+ void clearNewStation();
+};
+
+
+
+extern const char *KRadioConfigElement;
+extern const char *StationListElement;
+
+extern const char *StationListInfo;
+extern const char *StationListInfoMaintainer;
+extern const char *StationListInfoCountry;
+extern const char *StationListInfoCity;
+extern const char *StationListInfoMedia;
+extern const char *StationListInfoComments;
+extern const char *StationListInfoChanged;
+extern const char *StationListInfoCreator;
+
+extern const char *StationQuickSelectElement;
+extern const char *StationDockingMenuElement;
+extern const char *StationListFormat;
+
+#define STATION_LIST_FORMAT "kradio-1.0"
+
+
+#endif
diff --git a/kradio3/src/include/stationselection_interfaces.h b/kradio3/src/include/stationselection_interfaces.h
new file mode 100644
index 0000000..a571147
--- /dev/null
+++ b/kradio3/src/include/stationselection_interfaces.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ stationselection_interfaces.h - description
+ -------------------
+ begin : Son Aug 3 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_STATIONSELECTION_INTERFACES_H
+#define KRADIO_STATIONSELECTION_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "interfaces.h"
+
+class QStringList;
+
+INTERFACE(IStationSelection, IStationSelectionClient)
+{
+public :
+ IF_CON_DESTRUCTOR(IStationSelection, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setStationSelection(const QStringList &sl) )
+
+SENDERS:
+ IF_SENDER ( notifyStationSelectionChanged(const QStringList &sl) )
+
+ANSWERS:
+ IF_ANSWER ( const QStringList & getStationSelection () const )
+
+};
+
+
+INTERFACE(IStationSelectionClient, IStationSelection)
+{
+public :
+ IF_CON_DESTRUCTOR(IStationSelectionClient, 1)
+
+SENDERS:
+ IF_SENDER ( sendStationSelection(const QStringList &sl) )
+
+RECEIVERS:
+ IF_RECEIVER( noticeStationSelectionChanged(const QStringList &sl) )
+
+QUERIES:
+ IF_QUERY ( const QStringList & queryStationSelection () )
+
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool /*pointer_valid*/);
+ virtual void noticeDisconnectedI (cmplInterface *, bool /*pointer_valid*/);
+};
+
+
+#endif
diff --git a/kradio3/src/include/stationselector.h b/kradio3/src/include/stationselector.h
new file mode 100644
index 0000000..6842877
--- /dev/null
+++ b/kradio3/src/include/stationselector.h
@@ -0,0 +1,99 @@
+/***************************************************************************
+ StationSelector.h - description
+ -------------------
+ begin : Son Aug 3 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_STATIONSELECTOR_H
+#define KRADIO_STATIONSELECTOR_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qstringlist.h>
+
+#include "radio_interfaces.h"
+#include "stationselection_interfaces.h"
+#include "stationlist.h"
+
+#include <stationselector-ui.h>
+#include "radiostation-listview.h"
+
+
+class RadioStationListView;
+
+class StationSelector : public StationSelectorUI,
+ public IRadioClient,
+ public IStationSelectionClient
+{
+Q_OBJECT
+public :
+ StationSelector (QWidget *parent);
+ ~StationSelector ();
+
+ bool connectI (Interface *i);
+ bool disconnectI (Interface *i);
+
+// IStationSelectionClient
+
+ bool noticeStationSelectionChanged(const QStringList &sl);
+
+// IRadioClient
+
+ bool noticePowerChanged(bool /*on*/) { return false; }
+ bool noticeStationChanged (const RadioStation &, int /*idx*/) { return false; }
+ bool noticeStationsChanged(const StationList &sl);
+ bool noticePresetFileChanged(const QString &/*f*/) { return false; }
+
+ bool noticeCurrentSoundStreamIDChanged(SoundStreamID) { return false; }
+
+ void saveState (KConfig *) const;
+ void restoreState (KConfig *);
+
+ bool isDirty () const { return m_dirty; }
+
+protected slots:
+
+ void slotButtonToLeft();
+ void slotButtonToRight();
+ void slotMoveToRight(const QStringList &list);
+ void slotMoveToLeft(const QStringList &list);
+
+ void slotOK();
+ void slotCancel();
+ void slotSetDirty();
+
+signals:
+
+ void sigDirty();
+
+protected:
+
+ void moveItem (RadioStationListView *fromListView, QStringList &fromIDList,
+ QListViewItem *item, int fromIdx,
+ RadioStationListView *toListView, QStringList &toIDList);
+
+ void updateListViews();
+
+ // station ids
+ QStringList m_stationIDsAvailable,
+ m_stationIDsSelected,
+ m_stationIDsNotDisplayed,
+ m_stationIDsAll;
+
+ bool m_dirty;
+};
+
+#endif
diff --git a/kradio3/src/include/timecontrol_interfaces.h b/kradio3/src/include/timecontrol_interfaces.h
new file mode 100644
index 0000000..ad743a4
--- /dev/null
+++ b/kradio3/src/include/timecontrol_interfaces.h
@@ -0,0 +1,106 @@
+/***************************************************************************
+ timecontrol_interfaces.h - description
+ -------------------
+ begin : Mon Mär 10 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * Interfaces in this header: *
+ * *
+ * ITimeControl(Client) *
+ * *
+ ***************************************************************************/
+
+
+#ifndef KRADIO_TIMECONTROL_INTERFACES_H
+#define KRADIO_TIMECONTROL_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "interfaces.h"
+#include "alarm.h"
+
+INTERFACE(ITimeControl, ITimeControlClient)
+{
+public :
+ IF_CON_DESTRUCTOR(ITimeControl, -1)
+
+RECEIVERS:
+ IF_RECEIVER( setAlarms(const AlarmVector &sl) )
+ IF_RECEIVER( setCountdownSeconds(int n) )
+ IF_RECEIVER( startCountdown() )
+ IF_RECEIVER( stopCountdown() )
+
+
+SENDERS:
+ IF_SENDER ( notifyAlarmsChanged(const AlarmVector &sl) )
+ IF_SENDER ( notifyAlarm(const Alarm &) )
+ IF_SENDER ( notifyNextAlarmChanged(const Alarm *) )
+ IF_SENDER ( notifyCountdownStarted(const QDateTime &end) )
+ IF_SENDER ( notifyCountdownStopped() )
+ IF_SENDER ( notifyCountdownZero() )
+ IF_SENDER ( notifyCountdownSecondsChanged(int n) )
+
+
+ANSWERS:
+ IF_ANSWER ( QDateTime getNextAlarmTime () const )
+ IF_ANSWER ( const Alarm* getNextAlarm () const )
+ IF_ANSWER ( const AlarmVector & getAlarms () const )
+ IF_ANSWER ( int getCountdownSeconds () const )
+ IF_ANSWER ( QDateTime getCountdownEnd () const )
+
+};
+
+
+INTERFACE(ITimeControlClient, ITimeControl)
+{
+public :
+ IF_CON_DESTRUCTOR(ITimeControlClient, 1)
+
+SENDERS:
+ IF_SENDER ( sendAlarms(const AlarmVector &sl) )
+ IF_SENDER ( sendCountdownSeconds(int n) )
+ IF_SENDER ( sendStartCountdown() )
+ IF_SENDER ( sendStopCountdown() )
+
+
+RECEIVERS:
+ IF_RECEIVER( noticeAlarmsChanged(const AlarmVector &sl) )
+ IF_RECEIVER( noticeAlarm(const Alarm &) )
+ IF_RECEIVER( noticeNextAlarmChanged(const Alarm *) )
+ IF_RECEIVER( noticeCountdownStarted(const QDateTime &end) )
+ IF_RECEIVER( noticeCountdownStopped() )
+ IF_RECEIVER( noticeCountdownZero() )
+ IF_RECEIVER( noticeCountdownSecondsChanged(int n) )
+
+
+QUERIES:
+ IF_QUERY ( QDateTime queryNextAlarmTime() )
+ IF_QUERY ( const Alarm* queryNextAlarm () )
+ IF_QUERY ( const AlarmVector & queryAlarms () )
+ IF_QUERY ( int queryCountdownSeconds () )
+ IF_QUERY ( QDateTime queryCountdownEnd () )
+
+RECEIVERS:
+ virtual void noticeConnectedI (cmplInterface *, bool /*pointer_valid*/);
+ virtual void noticeDisconnectedI (cmplInterface *, bool /*pointer_valid*/);
+};
+
+
+
+
+#endif
diff --git a/kradio3/src/include/utils.h b/kradio3/src/include/utils.h
new file mode 100644
index 0000000..4e93293
--- /dev/null
+++ b/kradio3/src/include/utils.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ utils.h - description
+ -------------------
+ begin : Sun Feb 3 2002
+ copyright : (C) 2002 by Martin Witte / Frank Schwanz
+ email : witte@kawo1.rwth-aachen.de / schwanz@fh-brandenburg.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_UTILS_H
+#define KRADIO_UTILS_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <kconfig.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <qstring.h>
+#define __USE_ISOC99 1
+#include <math.h>
+
+//extern const char *mixerChannelLabels[];
+//extern const char *mixerChannelNames[];
+
+extern QString XMLEscape (const QString &s);
+QString xmlOpenTag (const QString &tag, bool newline = true);
+QString xmlTag (const QString &tag, const QString &s, bool newline = true);
+QString xmlTag (const QString &tag, int i, bool newline = true);
+QString xmlTag (const QString &tag, float f, bool newline = true);
+QString xmlCloseTag (const QString &tag, bool newline = true);
+
+template<class T1, class T2> inline T1 min (T1 a, T2 b) { return a < b ? a : b; }
+template<class T1, class T2> inline T1 max (T1 a, T2 b) { return a < b ? b : a; }
+
+#endif
diff --git a/kradio3/src/include/widgetplugins.h b/kradio3/src/include/widgetplugins.h
new file mode 100644
index 0000000..c138df3
--- /dev/null
+++ b/kradio3/src/include/widgetplugins.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ widgetplugins.h - description
+ -------------------
+ begin : Mi Aug 27 2003
+ copyright : (C) 2003 by Martin Witte
+ email : witte@kawo1.rwth-aachen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_WIDGETPLUGINS_INTERFACES_H
+#define KRADIO_WIDGETPLUGINS_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "plugins.h"
+
+class QWidget;
+
+class WidgetPluginBase : public PluginBase
+{
+public :
+ WidgetPluginBase(const QString &name, const QString &description);
+
+ virtual void saveState (KConfig *) const;
+ virtual void restoreState (KConfig *);
+ virtual void restoreState (KConfig *, bool showByDefault);
+ virtual void startPlugin();
+
+ virtual QWidget *getWidget() = 0;
+ virtual const QWidget *getWidget() const = 0;
+
+ virtual bool isReallyVisible(const QWidget *w = NULL) const;
+ virtual bool isAnywhereVisible(const QWidget *w = NULL) const;
+ virtual void showOnOrgDesktop () = 0;
+
+protected:
+ virtual void pShowOnOrgDesktop ();
+ virtual void pShow ();
+ virtual void pShow (bool show);
+ virtual void pHide ();
+ virtual void pToggleShown ();
+
+ virtual void pShowEvent(QShowEvent *);
+ virtual void pHideEvent(QHideEvent *);
+
+ virtual void notifyManager(bool shown);
+
+ virtual void getKWinState(const QWidget *w = NULL) const;
+
+protected:
+ // temporary data
+ mutable bool m_geoCacheValid;
+ mutable bool m_saveMinimized;
+ mutable bool m_saveMaximized;
+ mutable bool m_saveSticky;
+ mutable int m_saveDesktop;
+ mutable QRect m_saveGeometry;
+
+ bool m_geoRestoreFlag;
+ bool m_restoreShow;
+};
+
+
+
+#endif