dbus.cpp 808 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#include "dbus.h"
#include "source_correlate.h"
#include "../viewer.h"

#include <QDBusConnection>
#include <QApplication>

#include <iostream>

using namespace std;

Philipp Erhardt's avatar
Philipp Erhardt committed
12
void dbus_init(Viewer *viewer) {
13
14
15
16
17
18
19
20
	/* Add dbus interfaces to the viewer object.
	 *
	 * These are automatically destroyed, if the parent object is.
	 *
	 * At present, there is only the SourceCorrelate interface.
	 */
	new SourceCorrelate(viewer);

Philipp Erhardt's avatar
Philipp Erhardt committed
21
	QString bus_name = QString("katarakt.pid%1").arg(QApplication::applicationPid());
22
23
24
25
26
27
28
29
30
31
32
33
34

	if (!QDBusConnection::sessionBus().registerService(bus_name)) {
#ifdef DEBUG
		cerr << "Failed to register DBus service" << endl;
#endif	
	} else {
		if (!QDBusConnection::sessionBus().registerObject("/", viewer)) {
#ifdef DEBUG
			cerr << "Failed to register viewer object on DBus" << endl;
#endif
		}
	}
}