|
a/upqo/ohradio_qo.h |
|
b/upqo/ohradio_qo.h |
|
... |
|
... |
20 |
#include <string>
|
20 |
#include <string>
|
21 |
|
21 |
|
22 |
#include <QObject>
|
22 |
#include <QObject>
|
23 |
#include <QThread>
|
23 |
#include <QThread>
|
24 |
#include <QDebug>
|
24 |
#include <QDebug>
|
|
|
25 |
#include <QTimer>
|
25 |
|
26 |
|
26 |
#include "libupnpp/control/ohradio.hxx"
|
27 |
#include "libupnpp/control/ohradio.hxx"
|
27 |
#include "ohpool.h"
|
28 |
#include "ohpool.h"
|
28 |
|
29 |
|
29 |
class OHRadioQO : public QObject, public UPnPClient::VarEventReporter {
|
30 |
class OHRadioQO : public QObject, public UPnPClient::VarEventReporter {
|
30 |
Q_OBJECT
|
31 |
Q_OBJECT
|
31 |
|
32 |
|
32 |
public:
|
33 |
public:
|
33 |
OHRadioQO(UPnPClient::OHRDH ohp, QObject *parent = 0)
|
34 |
OHRadioQO(UPnPClient::OHRDH ohp, QObject *parent = 0)
|
34 |
: QObject(parent), m_curid(-1), m_srv(ohp) {
|
35 |
: QObject(parent), m_curid(-1), m_srv(ohp), m_timer(0), m_errcnt(0) {
|
|
|
36 |
m_timer = new QTimer(this);
|
|
|
37 |
connect(m_timer, SIGNAL(timeout()), this, SLOT(testconn()));
|
|
|
38 |
m_timer->start(2000);
|
35 |
m_srv->installReporter(this);
|
39 |
m_srv->installReporter(this);
|
36 |
}
|
40 |
}
|
37 |
|
41 |
|
38 |
virtual ~OHRadioQO() {
|
42 |
virtual ~OHRadioQO() {
|
39 |
m_srv->installReporter(0);
|
43 |
m_srv->installReporter(0);
|
|
... |
|
... |
62 |
Q_UNUSED(value);
|
66 |
Q_UNUSED(value);
|
63 |
//qDebug() << "OHRadioQO: changed: " << nm << " (char*): " << value;
|
67 |
//qDebug() << "OHRadioQO: changed: " << nm << " (char*): " << value;
|
64 |
}
|
68 |
}
|
65 |
|
69 |
|
66 |
public slots:
|
70 |
public slots:
|
|
|
71 |
|
|
|
72 |
// Ping renderer to check it's still there.
|
|
|
73 |
virtual void testconn() {
|
|
|
74 |
int val;
|
|
|
75 |
if (m_srv->id(&val) != 0) {
|
|
|
76 |
if (m_errcnt++ > 2) {
|
|
|
77 |
emit connectionLost();
|
|
|
78 |
}
|
|
|
79 |
return;
|
|
|
80 |
}
|
|
|
81 |
m_errcnt = 0;
|
|
|
82 |
}
|
67 |
|
83 |
|
68 |
// Read state from the remote. Used when starting up, to avoid
|
84 |
// Read state from the remote. Used when starting up, to avoid
|
69 |
// having to wait for events.
|
85 |
// having to wait for events.
|
70 |
virtual void fetchState() {
|
86 |
virtual void fetchState() {
|
71 |
//qDebug() << "OHRadioQO::fetchState()";
|
87 |
//qDebug() << "OHRadioQO::fetchState()";
|
|
... |
|
... |
131 |
|
147 |
|
132 |
signals:
|
148 |
signals:
|
133 |
void currentTrackId(int);
|
149 |
void currentTrackId(int);
|
134 |
void trackArrayChanged();
|
150 |
void trackArrayChanged();
|
135 |
void tpStateChanged(int);
|
151 |
void tpStateChanged(int);
|
136 |
|
152 |
void connectionLost();
|
|
|
153 |
|
137 |
// This is an internal signal. Use trackArrayChanged()
|
154 |
// This is an internal signal. Use trackArrayChanged()
|
138 |
void __idArrayChanged(std::vector<int>);
|
155 |
void __idArrayChanged(std::vector<int>);
|
139 |
|
156 |
|
140 |
private slots:
|
157 |
private slots:
|
141 |
|
158 |
|
|
... |
|
... |
158 |
|
175 |
|
159 |
private:
|
176 |
private:
|
160 |
virtual bool idArray(std::vector<int> *ids, int *tokp) {
|
177 |
virtual bool idArray(std::vector<int> *ids, int *tokp) {
|
161 |
return m_srv->idArray(ids, tokp) == 0;
|
178 |
return m_srv->idArray(ids, tokp) == 0;
|
162 |
}
|
179 |
}
|
|
|
180 |
|
163 |
UPnPClient::OHRDH m_srv;
|
181 |
UPnPClient::OHRDH m_srv;
|
|
|
182 |
QTimer *m_timer;
|
|
|
183 |
int m_errcnt;
|
164 |
};
|
184 |
};
|
165 |
|
185 |
|
166 |
#endif // _OHRADIO_QO_INCLUDED
|
186 |
#endif // _OHRADIO_QO_INCLUDED
|