1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include "foo.h"
#include <qxtdiscoverableservice.h>
#include <qxtservicebrowser.h>
#include <QxtSignalWaiter>
#include <QCoreApplication>
#include <QtDebug>
int main(int argc, char** argv) {
QCoreApplication app(argc, argv);
QxtDiscoverableService svc("daap");
svc.setPort(9123);
Foo foo;
QObject::connect(&svc, SIGNAL(registered()), &foo, SLOT(ok()));
QObject::connect(&svc, SIGNAL(registrationError(int)), &foo, SLOT(err(int)));
qDebug() << "registering...";
svc.registerService(true);
qDebug() << "registerService invoked";
QxtServiceBrowser browser("daap");
foo.browser = &browser;
QObject::connect(&browser, SIGNAL(browsingFailed(int)), &foo, SLOT(err(int)));
QObject::connect(&browser, SIGNAL(serviceAdded(QString,QString)), &foo, SLOT(add(QString,QString)));
QObject::connect(&browser, SIGNAL(serviceRemoved(QString,QString)), &foo, SLOT(remove(QString)));
browser.browse();
app.exec();
}
|