29 lines
801 B
C++
29 lines
801 B
C++
#include "qcp.h"
|
|
|
|
#define SERVICETYPE "_qcp._tcp"
|
|
|
|
namespace QCP {
|
|
Browse::Browse(QObject *parent)
|
|
: QObject(parent), m_av_browse(new Avahi::Browse(SERVICETYPE, this)) {
|
|
connect(m_av_browse, SIGNAL(found(Avahi::Service)), this, SLOT(foundService(Avahi::Service)));
|
|
connect(m_av_browse, SIGNAL(lost(Avahi::Service)), this, SLOT(lostService(Avahi::Service)));
|
|
connect(m_av_browse, SIGNAL(started()), this, SIGNAL(started()));
|
|
connect(m_av_browse, SIGNAL(stopped()), this, SIGNAL(stopped()));
|
|
}
|
|
|
|
void Browse::foundService(Avahi::Service s) {
|
|
ShareData *sd = new ShareData();
|
|
s.setData(sd);
|
|
emit found(Share(this, s));
|
|
}
|
|
|
|
void Browse::lostService(Avahi::Service s) {
|
|
emit lost(Share(this, s));
|
|
ShareData *sd = shareData(s);
|
|
if (0 != sd) {
|
|
delete sd;
|
|
}
|
|
sd->data = 0;
|
|
}
|
|
}
|