Switch to unified view

a/libupnpp/device.cxx b/libupnpp/device.cxx
...
...
19
19
20
#include "upnpplib.hxx"
20
#include "upnpplib.hxx"
21
#include "device.hxx"
21
#include "device.hxx"
22
22
23
unordered_map<std::string, UpnpDevice *> UpnpDevice::o_devices;
23
unordered_map<std::string, UpnpDevice *> UpnpDevice::o_devices;
24
static string xmlquote(const string& in)
25
{
26
    string out;
27
    for (unsigned int i = 0; i < in.size(); i++) {
28
        switch(in[i]) {
29
        case '"': out += "&quot;";break;
30
        case '&': out += "&amp;";break;
31
        case '<': out += "&lt;";break;
32
        case '>': out += "&gt;";break;
33
        case '\'': out += "&apos;";break;
34
        default: out += in[i];
35
        }
36
    }
37
    return out;
38
}
24
39
25
UpnpDevice::UpnpDevice(const string& deviceId)
40
UpnpDevice::UpnpDevice(const string& deviceId)
26
    : m_deviceId(deviceId)
41
    : m_deviceId(deviceId)
27
{
42
{
28
    cerr << "UpnpDevice::UpnpDevice(" << m_deviceId << ")" << endl;
43
    cerr << "UpnpDevice::UpnpDevice(" << m_deviceId << ")" << endl;
...
...
173
        cnames.reserve(names.size());
188
        cnames.reserve(names.size());
174
        for (unsigned int i = 0; i < names.size(); i++) {
189
        for (unsigned int i = 0; i < names.size(); i++) {
175
            cnames.push_back(names[i].c_str());
190
            cnames.push_back(names[i].c_str());
176
        }
191
        }
177
192
193
        for (unsigned int i = 0; i < values.size(); i++) {
194
            values[i] = xmlquote(values[i]);
195
        }
178
        vector<const char *>cvalues;
196
        vector<const char *>cvalues;
179
        cvalues.reserve(values.size());
197
        cvalues.reserve(values.size());
180
        for (unsigned int i = 0; i < values.size(); i++) {
198
        for (unsigned int i = 0; i < values.size(); i++) {
181
            cvalues.push_back(values[i].c_str());
199
            cvalues.push_back(values[i].c_str());
182
        }
200
        }
...
...
215
    m_calls[actName] = fun;
233
    m_calls[actName] = fun;
216
}
234
}
217
235
218
void UpnpDevice::notifyEvent(const string& serviceId,
236
void UpnpDevice::notifyEvent(const string& serviceId,
219
                             const vector<string>& names, 
237
                             const vector<string>& names, 
220
                             const vector<string>& values)
238
                             const vector<string>& ivalues)
221
{
239
{
222
    cerr << "UpnpDevice::notifyEvent" << endl;
240
    cerr << "UpnpDevice::notifyEvent" << endl;
223
    vector<const char *>cnames;
241
    vector<const char *>cnames;
224
    cnames.reserve(names.size());
242
    cnames.reserve(names.size());
225
    for (unsigned int i = 0; i < names.size(); i++) {
243
    for (unsigned int i = 0; i < names.size(); i++)
226
        cnames.push_back(names[i].c_str());
244
        cnames.push_back(names[i].c_str());
227
    }
228
245
246
    vector<string> values;
247
    values.reserve(ivalues.size());
248
    for (unsigned int i = 0; i < ivalues.size(); i++) {
249
        values.push_back(xmlquote(ivalues[i]));
250
        cerr << "Pushed value: [" << values[i] << "]" << endl;
251
    }
229
    vector<const char *>cvalues;
252
    vector<const char *>cvalues;
230
    cvalues.reserve(values.size());
253
    cvalues.reserve(values.size());
231
    for (unsigned int i = 0; i < values.size(); i++) {
254
    for (unsigned int i = 0; i < values.size(); i++)
232
        cvalues.push_back(values[i].c_str());
255
        cvalues.push_back(values[i].c_str());
233
    }
234
256
235
    int ret = UpnpNotify(m_lib->getdvh(), m_deviceId.c_str(), 
257
    int ret = UpnpNotify(m_lib->getdvh(), m_deviceId.c_str(), 
236
                         serviceId.c_str(),
258
                         serviceId.c_str(),
237
                         &cnames[0], &cvalues[0],
259
                         &cnames[0], &cvalues[0],
238
                         int(cnames.size()));
260
                         int(cnames.size()));