MainApplication m;
QObject::connect(&m, SIGNAL(quitRequested()), &a, SLOT(quit()));
QObject::connect(&a, SIGNAL(aboutToQuit()), &m, SLOT(aboutToQuit()));
- m.start();
- return a.exec();
+ if(m.start()) {
+ return a.exec();
+ } else {
+ return EXIT_FAILURE;
+ }
}
#include "mainapplication.h"
#include <QDebug>
+#include <QCoreApplication>
MainApplication::MainApplication(QObject *parent) :
QObject(parent)
dnssdService = new DnssdService(0);
trayIconMenu = new QMenu(0);
- // Initialize the service
- raopService->init(10, &m_callbacks);
- dnssdService->init();
-
quitAction = new QAction(tr("&Quit"), trayIconMenu);
connect(quitAction, SIGNAL(triggered()), this, SIGNAL(quitRequested()));
trayIconMenu->addAction(quitAction);
delete raopService;
}
-void MainApplication::start()
+bool MainApplication::start()
{
+ // Initialize the service
+ bool initSuccess = false;
+ initSuccess = raopService->init(10, &m_callbacks);
+ if(!initSuccess) {
+ qDebug() << "Error initializing raop service";
+ return false;
+ }
+ initSuccess &= dnssdService->init();
+ if(!initSuccess) {
+ qDebug() << "Error initializing dnssd service";
+ return false;
+ }
+
char chwaddr[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB };
QByteArray hwaddr(chwaddr, sizeof(chwaddr));
raopService->start(5000, hwaddr);
dnssdService->registerRaop("Shairplay", 5000, hwaddr);
trayIcon->show();
+ return true;
}
void MainApplication::stop()