Switch to unified view

a/src/ohproduct.cxx b/src/ohproduct.cxx
...
...
31
#include "libupnpp/device/device.hxx"   // for UpnpService
31
#include "libupnpp/device/device.hxx"   // for UpnpService
32
#include "libupnpp/log.hxx"             // for LOGDEB
32
#include "libupnpp/log.hxx"             // for LOGDEB
33
#include "libupnpp/soaphelp.hxx"        // for SoapOutgoing, SoapIncoming
33
#include "libupnpp/soaphelp.hxx"        // for SoapOutgoing, SoapIncoming
34
34
35
#include "upmpd.hxx"                    // for UpMpd
35
#include "upmpd.hxx"                    // for UpMpd
36
#include "upmpdutils.hxx"                    // for UpMpd
36
#include "ohplaylist.hxx"
37
#include "ohplaylist.hxx"
37
#include "ohreceiver.hxx"
38
#include "ohreceiver.hxx"
38
#include "ohsndrcv.hxx"
39
#include "ohsndrcv.hxx"
39
40
40
using namespace std;
41
using namespace std;
...
...
48
// (Type, Name) list
49
// (Type, Name) list
49
static vector<pair<string, string> > o_sources;
50
static vector<pair<string, string> > o_sources;
50
51
51
OHProduct::OHProduct(UpMpd *dev, const string& friendlyname)
52
OHProduct::OHProduct(UpMpd *dev, const string& friendlyname)
52
    : UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev),
53
    : UpnpService(sTpProduct, sIdProduct, dev), m_dev(dev),
53
      m_roomOrName(friendlyname), m_sourceIndex(0)
54
      m_roomOrName(friendlyname), m_sourceIndex(0), m_standby(false)
54
{
55
{
55
    // Playlist must stay first.
56
    // Playlist must stay first.
56
    o_sources.push_back(pair<string,string>("Playlist","Playlist"));
57
    o_sources.push_back(pair<string,string>("Playlist","Playlist"));
57
    //o_sources.push_back("UpnpAv");
58
    //o_sources.push_back("UpnpAv");
58
    if (m_dev->m_ohrcv) {
59
    if (m_dev->m_ohrcv) {
...
...
118
static const string csmanurl("http://www.lesbonscomptes.com/upmpdcli");
119
static const string csmanurl("http://www.lesbonscomptes.com/upmpdcli");
119
static const string csmodname("UpMPDCli UPnP-MPD gateway");
120
static const string csmodname("UpMPDCli UPnP-MPD gateway");
120
static const string csmodurl("http://www.lesbonscomptes.com/upmpdcli");
121
static const string csmodurl("http://www.lesbonscomptes.com/upmpdcli");
121
static const string csprodname("Upmpdcli");
122
static const string csprodname("Upmpdcli");
122
123
124
bool OHProduct::makestate(unordered_map<string, string> &st)
125
{
126
    st.clear();
127
128
    st["ManufacturerName"] = csmanname;
129
    st["ManufacturerInfo"] = csmaninfo;
130
    st["ManufacturerUrl"] = csmanurl;
131
    st["ManufacturerImageUri"] = "";
132
    st["ModelName"] = csmodname;
133
    st["ModelInfo"] = csversion;
134
    st["ModelUrl"] = csmodurl;
135
    st["ModelImageUri"] = "";
136
    st["ProductRoom"] = m_roomOrName;
137
    st["ProductName"] = csprodname;
138
    st["ProductInfo"] = csversion;
139
    st["ProductUrl"] = "";
140
    st["ProductImageUri"] = "";
141
    st["Standby"] = m_standby ? "1" : "0";
142
    st["SourceCount"] = SoapHelp::i2s(o_sources.size());
143
    st["SourceXml"] = csxml;
144
    st["SourceIndex"] = SoapHelp::i2s(m_sourceIndex);
145
    st["Attributes"] = csattrs;
146
147
    return true;
148
}
149
123
bool OHProduct::getEventData(bool all, std::vector<std::string>& names, 
150
bool OHProduct::getEventData(bool all, std::vector<std::string>& names, 
124
                             std::vector<std::string>& values)
151
                             std::vector<std::string>& values)
125
{
152
{
126
    //LOGDEB("OHProduct::getEventData" << endl);
153
    //LOGDEB("OHProduct::getEventData" << endl);
127
    // Our data never changes, so if this is not an unconditional
154
128
    // request, we return nothing.
155
    unordered_map<string, string> state;
156
    makestate(state);
157
158
    unordered_map<string, string> changed;
129
    if (all) {
159
    if (all) {
130
        names.push_back("ManufacturerName"); values.push_back(csmanname);
160
        changed = state;
131
        names.push_back("ManufacturerInfo"); values.push_back(csmaninfo);
161
    } else {
132
        names.push_back("ManufacturerUrl");  values.push_back(csmanurl);
162
        changed = diffmaps(m_state, state);
133
        names.push_back("ManufacturerImageUri"); values.push_back("");
163
    }
134
        names.push_back("ModelName"); values.push_back(csmodname);
164
    m_state = state;
135
        names.push_back("ModelInfo"); values.push_back(csversion);
165
136
        names.push_back("ModelUrl");  values.push_back(csmodurl);
166
    for (auto it = changed.begin(); it != changed.end(); it++) {
137
        names.push_back("ModelImageUri"); values.push_back("");
138
        names.push_back("ProductRoom"); values.push_back(m_roomOrName);
139
        names.push_back("ProductName"); values.push_back(csprodname);
140
        names.push_back("ProductInfo"); values.push_back(csversion);
141
        names.push_back("ProductUrl"); values.push_back("");
142
        names.push_back("ProductImageUri"); values.push_back("");
143
        names.push_back("Standby"); values.push_back(m_standby?"1":"0");
144
        names.push_back("SourceCount"); 
167
        names.push_back(it->first);
145
        values.push_back(SoapHelp::i2s(o_sources.size()));
168
        values.push_back(it->second);
146
        names.push_back("SourceXml"); values.push_back(csxml);
147
        names.push_back("SourceIndex"); 
148
        values.push_back(SoapHelp::i2s(m_sourceIndex));
149
        names.push_back("Attributes");values.push_back(csattrs);
150
    }
169
    }
170
151
    return true;
171
    return true;
152
}
172
}
153
173
154
int OHProduct::manufacturer(const SoapIncoming& sc, SoapOutgoing& data)
174
int OHProduct::manufacturer(const SoapIncoming& sc, SoapOutgoing& data)
155
{
175
{