|
a/libupnpp/device/device.cxx |
|
b/libupnpp/device/device.cxx |
|
... |
|
... |
422 |
|
422 |
|
423 |
int ret = UpnpNotify(dvh, deviceId.c_str(),
|
423 |
int ret = UpnpNotify(dvh, deviceId.c_str(),
|
424 |
serviceId.c_str(), &cnames[0], &cvalues[0],
|
424 |
serviceId.c_str(), &cnames[0], &cvalues[0],
|
425 |
int(cnames.size()));
|
425 |
int(cnames.size()));
|
426 |
if (ret != UPNP_E_SUCCESS) {
|
426 |
if (ret != UPNP_E_SUCCESS) {
|
427 |
LOGERR(lib->errAsString("UpnpDevice::notifyEvent", ret) << endl);
|
427 |
LOGERR(lib->errAsString("UpnpDevice::notifyEvent: id", ret) <<
|
|
|
428 |
" for " << serviceId << endl);
|
428 |
}
|
429 |
}
|
429 |
}
|
430 |
}
|
430 |
|
431 |
|
431 |
int timespec_diffms(const struct timespec& old, const struct timespec& recent)
|
432 |
int timespec_diffms(const struct timespec& old, const struct timespec& recent)
|
432 |
{
|
433 |
{
|
|
... |
|
... |
512 |
// last call the main program will make after adding the
|
513 |
// last call the main program will make after adding the
|
513 |
// services, so locking does not seem necessary
|
514 |
// services, so locking does not seem necessary
|
514 |
for (vector<string>::iterator it = m->serviceids.begin();
|
515 |
for (vector<string>::iterator it = m->serviceids.begin();
|
515 |
it != m->serviceids.end(); it++) {
|
516 |
it != m->serviceids.end(); it++) {
|
516 |
vector<string> names, values;
|
517 |
vector<string> names, values;
|
|
|
518 |
UpnpService* serv = m->servicemap[*it];
|
517 |
{
|
519 |
{
|
518 |
PTMutexLocker lock(m->devlock);
|
520 |
PTMutexLocker lock(m->devlock);
|
519 |
UpnpService* serv = m->servicemap[*it];
|
|
|
520 |
if (!serv->getEventData(all, names, values) || names.empty()) {
|
521 |
if (!serv->getEventData(all, names, values) || names.empty()) {
|
521 |
continue;
|
522 |
continue;
|
522 |
}
|
523 |
}
|
523 |
}
|
524 |
}
|
|
|
525 |
if (!serv->noevents())
|
524 |
m->notifyEvent(*it, names, values);
|
526 |
m->notifyEvent(*it, names, values);
|
525 |
}
|
527 |
}
|
526 |
}
|
528 |
}
|
527 |
}
|
529 |
}
|
528 |
|
530 |
|
529 |
// Can't take the loop lock here. We're called from the service and
|
531 |
// Can't take the loop lock here. We're called from the service and
|
|
... |
|
... |
544 |
m->needExit = true;
|
546 |
m->needExit = true;
|
545 |
pthread_cond_broadcast(&m->evloopcond);
|
547 |
pthread_cond_broadcast(&m->evloopcond);
|
546 |
}
|
548 |
}
|
547 |
|
549 |
|
548 |
|
550 |
|
|
|
551 |
struct UpnpService::Internal {
|
|
|
552 |
Internal(bool noevs)
|
|
|
553 |
: noevents(noevs) {
|
|
|
554 |
}
|
|
|
555 |
bool noevents;
|
|
|
556 |
};
|
549 |
|
557 |
|
550 |
UpnpService::UpnpService(const std::string& stp,
|
558 |
UpnpService::UpnpService(const std::string& stp,
|
551 |
const std::string& sid, UpnpDevice *dev)
|
559 |
const std::string& sid, UpnpDevice *dev)
|
552 |
: m_serviceType(stp), m_serviceId(sid), m(0)
|
560 |
: m_serviceType(stp), m_serviceId(sid), m(0)
|
553 |
{
|
561 |
{
|
554 |
dev->addService(this, sid);
|
562 |
dev->addService(this, sid);
|
555 |
}
|
563 |
}
|
556 |
|
564 |
|
|
|
565 |
UpnpService::UpnpService(const std::string& stp,
|
|
|
566 |
const std::string& sid, UpnpDevice *dev, bool noevs)
|
|
|
567 |
: m_serviceType(stp), m_serviceId(sid), m(new Internal(noevs))
|
|
|
568 |
{
|
|
|
569 |
dev->addService(this, sid);
|
|
|
570 |
}
|
|
|
571 |
|
557 |
UpnpService::~UpnpService()
|
572 |
UpnpService::~UpnpService()
|
558 |
{
|
573 |
{
|
|
|
574 |
if (m) {
|
|
|
575 |
delete m;
|
|
|
576 |
m = 0;
|
|
|
577 |
}
|
|
|
578 |
}
|
|
|
579 |
|
|
|
580 |
bool UpnpService::noevents()
|
|
|
581 |
{
|
|
|
582 |
return m && m->noevents;
|
559 |
}
|
583 |
}
|
560 |
|
584 |
|
561 |
bool UpnpService::getEventData(bool all, std::vector<std::string>& names,
|
585 |
bool UpnpService::getEventData(bool all, std::vector<std::string>& names,
|
562 |
std::vector<std::string>& values)
|
586 |
std::vector<std::string>& values)
|
563 |
{
|
587 |
{
|