-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpong.cpp
44 lines (35 loc) · 976 Bytes
/
pong.cpp
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
#include <stdio.h>
#include <stdlib.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QTimer>
#include <QtDBus/QtDBus>
#include "pong.h"
Pong::Pong()
{
if (!QDBusConnection::sessionBus().isConnected()) {
fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
"To start it, run:\n"
"\teval `dbus-launch --auto-syntax`\n");
}
if (!QDBusConnection::sessionBus().registerService("org.cinpla.focus")) {
fprintf(stderr, "%s\n",
qPrintable(QDBusConnection::sessionBus().lastError().message()));
}
QDBusConnection::sessionBus().registerObject("/", this, QDBusConnection::ExportAllSlots);
}
QString Pong::response() const
{
return m_response;
}
QString Pong::ping(const QString &message)
{
emit pinged(message);
return response();
}
void Pong::setResponse(QString arg)
{
if (m_response == arg)
return;
m_response = arg;
emit responseChanged(arg);
}