|
a/src/ohradio.cxx |
|
b/src/ohradio.cxx |
|
... |
|
... |
32 |
#include "libupnpp/base64.hxx"
|
32 |
#include "libupnpp/base64.hxx"
|
33 |
#include "libupnpp/log.hxx"
|
33 |
#include "libupnpp/log.hxx"
|
34 |
#include "libupnpp/soaphelp.hxx"
|
34 |
#include "libupnpp/soaphelp.hxx"
|
35 |
#include "libupnpp/upnpavutils.hxx"
|
35 |
#include "libupnpp/upnpavutils.hxx"
|
36 |
|
36 |
|
|
|
37 |
#include "main.hxx"
|
37 |
#include "mpdcli.hxx"
|
38 |
#include "mpdcli.hxx"
|
38 |
#include "upmpd.hxx"
|
39 |
#include "upmpd.hxx"
|
39 |
#include "smallut.h"
|
40 |
#include "smallut.h"
|
40 |
#include "pathut.h"
|
41 |
#include "pathut.h"
|
41 |
#include "upmpdutils.hxx"
|
42 |
#include "upmpdutils.hxx"
|
|
... |
|
... |
48 |
using namespace std;
|
49 |
using namespace std;
|
49 |
using namespace std::placeholders;
|
50 |
using namespace std::placeholders;
|
50 |
|
51 |
|
51 |
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
|
52 |
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
|
52 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Radio");
|
53 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Radio");
|
|
|
54 |
|
|
|
55 |
static const string cstr_sturlkey("ohradio.url");
|
53 |
|
56 |
|
54 |
static string find_script(const string& icmd)
|
57 |
static string find_script(const string& icmd)
|
55 |
{
|
58 |
{
|
56 |
if (path_isabsolute(icmd))
|
59 |
if (path_isabsolute(icmd))
|
57 |
return icmd;
|
60 |
return icmd;
|
|
... |
|
... |
121 |
}
|
124 |
}
|
122 |
if (!readRadios()) {
|
125 |
if (!readRadios()) {
|
123 |
LOGINF("OHRadio: readRadios() failed, radio service will not work\n");
|
126 |
LOGINF("OHRadio: readRadios() failed, radio service will not work\n");
|
124 |
return;
|
127 |
return;
|
125 |
}
|
128 |
}
|
|
|
129 |
|
|
|
130 |
// Try to restore the current preset channel if this was memorized.
|
|
|
131 |
string refstr;
|
|
|
132 |
if (g_state && g_state->get(cstr_sturlkey, refstr)) {
|
|
|
133 |
for (unsigned int i = 0; i < o_radios.size(); i++) {
|
|
|
134 |
string sms = stringsToString(o_radios[i].metaScript);
|
|
|
135 |
const string& uri = o_radios[i].uri;
|
|
|
136 |
if ((!uri.empty() && !uri.compare(refstr)) ||
|
|
|
137 |
(uri.empty() && !sms.compare(refstr))) {
|
|
|
138 |
m_id = i;
|
|
|
139 |
break;
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
|
126 |
m_ok = true;
|
144 |
m_ok = true;
|
127 |
|
145 |
|
128 |
dev->addActionMapping(this, "Channel",
|
146 |
dev->addActionMapping(this, "Channel",
|
129 |
bind(&OHRadio::channel, this, _1, _2));
|
147 |
bind(&OHRadio::channel, this, _1, _2));
|
130 |
dev->addActionMapping(this, "ChannelsMax",
|
148 |
dev->addActionMapping(this, "ChannelsMax",
|
|
... |
|
... |
544 |
LOGDEB("OHRadio::setId: bad value " << id << endl);
|
562 |
LOGDEB("OHRadio::setId: bad value " << id << endl);
|
545 |
return UPNP_E_INTERNAL_ERROR;
|
563 |
return UPNP_E_INTERNAL_ERROR;
|
546 |
}
|
564 |
}
|
547 |
iStop();
|
565 |
iStop();
|
548 |
m_id = id;
|
566 |
m_id = id;
|
|
|
567 |
|
|
|
568 |
// Memorize the current radio (for restart). We use either the
|
|
|
569 |
// static uri or the metaScript to identify the radio
|
|
|
570 |
if (g_state) {
|
|
|
571 |
string refstr = o_radios[m_id].uri.empty() ?
|
|
|
572 |
stringsToString(o_radios[m_id].metaScript) : o_radios[m_id].uri;
|
|
|
573 |
g_state->set(cstr_sturlkey, refstr);
|
|
|
574 |
}
|
|
|
575 |
|
549 |
maybeWakeUp(true);
|
576 |
maybeWakeUp(true);
|
550 |
return UPNP_E_SUCCESS;
|
577 |
return UPNP_E_SUCCESS;
|
551 |
}
|
578 |
}
|
552 |
|
579 |
|
553 |
// Return current channel Id.
|
580 |
// Return current channel Id.
|