summaryrefslogtreecommitdiff
path: root/sowatchd/main.cpp
blob: 29eee28104e647630b5e51abb9a2d88385809ef8 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtDBus/QDBusConnection>

#include <sowatch.h>
#include "global.h"
#include "allscanner.h"
#include "daemonadaptor.h"
#include "scanneradaptor.h"

namespace sowatch
{
	Daemon* daemon;
}

using namespace sowatch;

int main(int argc, char *argv[])
{
	// Some plugins might require a user interface, so use QApplication instead
	// of QCoreApplication
	QApplication a(argc, argv);
	QApplication::setOrganizationDomain("com.javispedro.sowatch");
	QApplication::setOrganizationName("sowatch");
	QApplication::setApplicationName("sowatchd");

	sowatch::daemon = new Daemon(&a);
	new DaemonAdaptor(sowatch::daemon);
	AllScanner *scanner = new AllScanner(&a);
	new ScannerAdaptor(scanner);

	QDBusConnection connection = QDBusConnection::sessionBus();
	if (!connection.registerService("com.javispedro.sowatchd")) {
		qCritical("Could not register D-Bus service");
	}

	if (!connection.registerObject("/com/javispedro/sowatch/allscanner", scanner)) {
		qCritical("Could not register scanner object");
	}
	if (!connection.registerObject("/com/javispedro/sowatch/daemon", sowatch::daemon)) {
		qCritical("Could not register daemon object");
	}

	return a.exec();
}