|
a/src/ohproduct.cxx |
|
b/src/ohproduct.cxx |
|
... |
|
... |
38 |
using namespace std::placeholders;
|
38 |
using namespace std::placeholders;
|
39 |
|
39 |
|
40 |
static const string sTpProduct("urn:av-openhome-org:service:Product:1");
|
40 |
static const string sTpProduct("urn:av-openhome-org:service:Product:1");
|
41 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Product");
|
41 |
static const string sIdProduct("urn:av-openhome-org:serviceId:Product");
|
42 |
|
42 |
|
43 |
static string csxml(
|
43 |
static string csxml("<SourceList>\n");
|
44 |
"<SourceList>"
|
44 |
static vector<string> o_sources;
|
45 |
" <Source>"
|
|
|
46 |
" <Name>PlayList</Name>"
|
|
|
47 |
" <Type>Playlist</Type>"
|
|
|
48 |
" <Visible>true</Visible>"
|
|
|
49 |
" </Source>"
|
|
|
50 |
" <Source>"
|
|
|
51 |
" <Name>UpnpAv</Name>"
|
|
|
52 |
" <Type>UpnpAv</Type>"
|
|
|
53 |
" <Visible>true</Visible>"
|
|
|
54 |
" </Source>"
|
|
|
55 |
);
|
|
|
56 |
|
45 |
|
57 |
OHProduct::OHProduct(UpMpd *dev, const string& friendlyname, bool hasRcv)
|
46 |
OHProduct::OHProduct(UpMpd *dev, const string& friendlyname, bool hasRcv)
|
58 |
: UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev),
|
47 |
: UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev),
|
59 |
m_roomOrName(friendlyname)
|
48 |
m_roomOrName(friendlyname), m_sourceIndex(0)
|
60 |
{
|
49 |
{
|
|
|
50 |
o_sources.push_back("Playlist");
|
|
|
51 |
o_sources.push_back("UpnpAv");
|
61 |
if (hasRcv) {
|
52 |
if (hasRcv)
|
|
|
53 |
o_sources.push_back("Receiver");
|
|
|
54 |
|
|
|
55 |
for (auto it = o_sources.begin(); it != o_sources.end(); it++) {
|
62 |
csxml += string(" <Source>"
|
56 |
csxml += string(" <Source>\n") +
|
63 |
" <Name>Receiver</Name>"
|
57 |
" <Name>" + *it + "</Name>\n" +
|
64 |
" <Type>Receiver</Type>"
|
58 |
" <Type>" + *it + "</Type>\n" +
|
65 |
" <Visible>true</Visible>"
|
59 |
" <Visible>true</Visible>\n" +
|
66 |
" </Source>");
|
60 |
" </Source>\n";
|
67 |
}
|
61 |
}
|
68 |
csxml += string("</SourceList>");
|
62 |
csxml += string("</SourceList>\n");
|
|
|
63 |
LOGDEB("OHProduct::OHProduct: sources: " << csxml << endl);
|
69 |
|
64 |
|
70 |
dev->addActionMapping(this, "Manufacturer",
|
65 |
dev->addActionMapping(this, "Manufacturer",
|
71 |
bind(&OHProduct::manufacturer, this, _1, _2));
|
66 |
bind(&OHProduct::manufacturer, this, _1, _2));
|
72 |
dev->addActionMapping(this, "Model", bind(&OHProduct::model, this, _1, _2));
|
67 |
dev->addActionMapping(this, "Model", bind(&OHProduct::model, this, _1, _2));
|
73 |
dev->addActionMapping(this, "Product",
|
68 |
dev->addActionMapping(this, "Product",
|
|
... |
|
... |
122 |
names.push_back("ProductRoom"); values.push_back(m_roomOrName);
|
117 |
names.push_back("ProductRoom"); values.push_back(m_roomOrName);
|
123 |
names.push_back("ProductName"); values.push_back(csprodname);
|
118 |
names.push_back("ProductName"); values.push_back(csprodname);
|
124 |
names.push_back("ProductInfo"); values.push_back(csversion);
|
119 |
names.push_back("ProductInfo"); values.push_back(csversion);
|
125 |
names.push_back("ProductUrl"); values.push_back("");
|
120 |
names.push_back("ProductUrl"); values.push_back("");
|
126 |
names.push_back("ProductImageUri"); values.push_back("");
|
121 |
names.push_back("ProductImageUri"); values.push_back("");
|
127 |
names.push_back("Standby"); values.push_back("0");
|
122 |
names.push_back("Standby"); values.push_back(m_standby?"1":"0");
|
128 |
names.push_back("SourceCount"); values.push_back("1");
|
123 |
names.push_back("SourceCount");
|
|
|
124 |
values.push_back(SoapHelp::i2s(o_sources.size()));
|
129 |
names.push_back("SourceXml"); values.push_back(csxml);
|
125 |
names.push_back("SourceXml"); values.push_back(csxml);
|
130 |
names.push_back("SourceIndex"); values.push_back("0");
|
126 |
names.push_back("SourceIndex");
|
|
|
127 |
values.push_back(SoapHelp::i2s(m_sourceIndex));
|
131 |
names.push_back("Attributes");values.push_back(csattrs);
|
128 |
names.push_back("Attributes");values.push_back(csattrs);
|
132 |
}
|
129 |
}
|
133 |
return true;
|
130 |
return true;
|
134 |
}
|
131 |
}
|
135 |
|
132 |
|
|
... |
|
... |
172 |
}
|
169 |
}
|
173 |
|
170 |
|
174 |
int OHProduct::setStandby(const SoapArgs& sc, SoapData& data)
|
171 |
int OHProduct::setStandby(const SoapArgs& sc, SoapData& data)
|
175 |
{
|
172 |
{
|
176 |
LOGDEB("OHProduct::setStandby" << endl);
|
173 |
LOGDEB("OHProduct::setStandby" << endl);
|
177 |
bool standby;
|
|
|
178 |
if (!sc.getBool("Value", &standby)) {
|
174 |
if (!sc.getBool("Value", &m_standby)) {
|
179 |
return UPNP_E_INVALID_PARAM;
|
175 |
return UPNP_E_INVALID_PARAM;
|
180 |
}
|
176 |
}
|
|
|
177 |
m_dev->loopWakeup();
|
181 |
return UPNP_E_SUCCESS;
|
178 |
return UPNP_E_SUCCESS;
|
182 |
}
|
179 |
}
|
183 |
|
180 |
|
184 |
int OHProduct::sourceCount(const SoapArgs& sc, SoapData& data)
|
181 |
int OHProduct::sourceCount(const SoapArgs& sc, SoapData& data)
|
185 |
{
|
182 |
{
|
186 |
LOGDEB("OHProduct::sourceCount" << endl);
|
183 |
LOGDEB("OHProduct::sourceCount" << endl);
|
187 |
data.addarg("Value", "1");
|
184 |
data.addarg("Value", SoapHelp::i2s(o_sources.size()));
|
188 |
return UPNP_E_SUCCESS;
|
185 |
return UPNP_E_SUCCESS;
|
189 |
}
|
186 |
}
|
190 |
|
187 |
|
191 |
int OHProduct::sourceXML(const SoapArgs& sc, SoapData& data)
|
188 |
int OHProduct::sourceXML(const SoapArgs& sc, SoapData& data)
|
192 |
{
|
189 |
{
|
|
... |
|
... |
196 |
}
|
193 |
}
|
197 |
|
194 |
|
198 |
int OHProduct::sourceIndex(const SoapArgs& sc, SoapData& data)
|
195 |
int OHProduct::sourceIndex(const SoapArgs& sc, SoapData& data)
|
199 |
{
|
196 |
{
|
200 |
LOGDEB("OHProduct::sourceIndex" << endl);
|
197 |
LOGDEB("OHProduct::sourceIndex" << endl);
|
201 |
data.addarg("Value", "0");
|
198 |
data.addarg("Value", SoapHelp::i2s(m_sourceIndex));
|
202 |
return UPNP_E_SUCCESS;
|
199 |
return UPNP_E_SUCCESS;
|
203 |
}
|
200 |
}
|
204 |
|
201 |
|
205 |
int OHProduct::setSourceIndex(const SoapArgs& sc, SoapData& data)
|
202 |
int OHProduct::setSourceIndex(const SoapArgs& sc, SoapData& data)
|
206 |
{
|
203 |
{
|
|
... |
|
... |
208 |
int sindex;
|
205 |
int sindex;
|
209 |
if (!sc.getInt("Value", &sindex)) {
|
206 |
if (!sc.getInt("Value", &sindex)) {
|
210 |
return UPNP_E_INVALID_PARAM;
|
207 |
return UPNP_E_INVALID_PARAM;
|
211 |
}
|
208 |
}
|
212 |
LOGDEB("OHProduct::setSourceIndex: " << sindex << endl);
|
209 |
LOGDEB("OHProduct::setSourceIndex: " << sindex << endl);
|
|
|
210 |
if (sindex < 0 || sindex >= int(o_sources.size())) {
|
|
|
211 |
LOGERR("OHProduct::setSourceIndex: bad index: " << sindex << endl);
|
|
|
212 |
return UPNP_E_INVALID_PARAM;
|
|
|
213 |
}
|
|
|
214 |
m_sourceIndex = sindex;
|
|
|
215 |
m_dev->loopWakeup();
|
213 |
return UPNP_E_SUCCESS;
|
216 |
return UPNP_E_SUCCESS;
|
214 |
}
|
217 |
}
|
215 |
|
218 |
|
216 |
int OHProduct::setSourceIndexByName(const SoapArgs& sc, SoapData& data)
|
219 |
int OHProduct::setSourceIndexByName(const SoapArgs& sc, SoapData& data)
|
217 |
{
|
220 |
{
|
218 |
LOGDEB("OHProduct::setSourceIndexByName" << endl);
|
221 |
LOGDEB("OHProduct::setSourceIndexByName" << endl);
|
219 |
map<string, string>::const_iterator it;
|
|
|
220 |
|
222 |
|
221 |
it = sc.args.find("Value");
|
223 |
string name;
|
222 |
if (it == sc.args.end() || it->second.empty()) {
|
224 |
if (!sc.getString("Value", &name)) {
|
|
|
225 |
return UPNP_E_INVALID_PARAM;
|
|
|
226 |
}
|
|
|
227 |
for (unsigned int i = 0; i < o_sources.size(); i++) {
|
|
|
228 |
if (o_sources[i] == name) {
|
|
|
229 |
m_sourceIndex = i;
|
|
|
230 |
m_dev->loopWakeup();
|
|
|
231 |
return UPNP_E_SUCCESS;
|
|
|
232 |
}
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
LOGERR("OHProduct::setSoaurceIndexByName: no such name: " << name << endl);
|
223 |
return UPNP_E_INVALID_PARAM;
|
236 |
return UPNP_E_INVALID_PARAM;
|
224 |
}
|
|
|
225 |
LOGDEB("OHProduct::setSourceIndexByName: " << it->second << endl);
|
|
|
226 |
m_dev->loopWakeup();
|
|
|
227 |
return UPNP_E_SUCCESS;
|
|
|
228 |
}
|
237 |
}
|
229 |
|
238 |
|
230 |
int OHProduct::source(const SoapArgs& sc, SoapData& data)
|
239 |
int OHProduct::source(const SoapArgs& sc, SoapData& data)
|
231 |
{
|
240 |
{
|
232 |
LOGDEB("OHProduct::source" << endl);
|
241 |
LOGDEB("OHProduct::source" << endl);
|
233 |
int sindex;
|
242 |
int sindex;
|
234 |
if (!sc.getInt("Index", &sindex)) {
|
243 |
if (!sc.getInt("Index", &sindex)) {
|
235 |
return UPNP_E_INVALID_PARAM;
|
244 |
return UPNP_E_INVALID_PARAM;
|
236 |
}
|
245 |
}
|
237 |
LOGDEB("OHProduct::source: " << sindex << endl);
|
246 |
LOGDEB("OHProduct::source: " << sindex << endl);
|
238 |
if (sindex != 0) {
|
247 |
if (sindex < 0 || sindex >= int(o_sources.size())) {
|
|
|
248 |
LOGERR("OHProduct::source: bad index: " << sindex << endl);
|
239 |
return UPNP_E_INVALID_PARAM;
|
249 |
return UPNP_E_INVALID_PARAM;
|
240 |
}
|
250 |
}
|
241 |
data.addarg("SystemName", m_roomOrName);
|
251 |
data.addarg("SystemName", m_roomOrName);
|
242 |
data.addarg("Type", "Playlist");
|
252 |
data.addarg("Type", o_sources[sindex]);
|
243 |
data.addarg("Name", "PlayList");
|
253 |
data.addarg("Name", o_sources[sindex]);
|
244 |
data.addarg("Visible", "1");
|
254 |
data.addarg("Visible", "1");
|
245 |
return UPNP_E_SUCCESS;
|
255 |
return UPNP_E_SUCCESS;
|
246 |
}
|
256 |
}
|
247 |
|
257 |
|
248 |
int OHProduct::attributes(const SoapArgs& sc, SoapData& data)
|
258 |
int OHProduct::attributes(const SoapArgs& sc, SoapData& data)
|