Commit | Line | Data |
---|---|---|
2340bcd3 JVH |
1 | #include "mainapplication.h" |
2 | ||
3 | #include <QDebug> | |
4 | ||
5 | MainApplication::MainApplication(QObject *parent) : | |
6 | QObject(parent) | |
7 | { | |
8 | raopService = new RaopService(0); | |
9434b30c | 9 | dnssdService = new DnssdService(0); |
2340bcd3 JVH |
10 | trayIconMenu = new QMenu(0); |
11 | ||
12 | // Initialize the service | |
9434b30c JVH |
13 | raopService->init(10, &m_callbacks); |
14 | dnssdService->init(); | |
2340bcd3 JVH |
15 | |
16 | quitAction = new QAction(tr("&Quit"), trayIconMenu); | |
17 | connect(quitAction, SIGNAL(triggered()), this, SIGNAL(quitRequested())); | |
18 | trayIconMenu->addAction(quitAction); | |
19 | ||
20 | // Construct the actual system tray icon | |
21 | trayIcon = new QSystemTrayIcon(this); | |
22 | trayIcon->setContextMenu(trayIconMenu); | |
23 | trayIcon->setIcon(QIcon(":icons/airtv.svg")); | |
24 | } | |
25 | ||
26 | MainApplication::~MainApplication() | |
27 | { | |
28 | trayIcon->setContextMenu(0); | |
29 | delete trayIconMenu; | |
30 | delete raopService; | |
31 | } | |
32 | ||
33 | void MainApplication::start() | |
34 | { | |
9434b30c JVH |
35 | char chwaddr[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB }; |
36 | QByteArray hwaddr(chwaddr, sizeof(chwaddr)); | |
37 | ||
38 | raopService->start(5000, hwaddr); | |
39 | dnssdService->registerRaop("Shairplay", 5000, hwaddr); | |
2340bcd3 JVH |
40 | trayIcon->show(); |
41 | } | |
42 | ||
43 | void MainApplication::stop() | |
44 | { | |
9434b30c | 45 | dnssdService->unregisterRaop(); |
2340bcd3 JVH |
46 | raopService->stop(); |
47 | trayIcon->hide(); | |
48 | } | |
49 | ||
50 | void MainApplication::aboutToQuit() | |
51 | { | |
52 | this->stop(); | |
53 | } |