harbour-tooter/src/dbus.cpp
Dusko Angirevic a7670ecee2 Service test
2017-10-25 00:37:33 +02:00

52 lines
1,001 B
C++

#include "dbus.h"
static const char *PATH = "/";
static const char *SERVICE = SERVICE_NAME;
Dbus::Dbus(QObject *parent) :
QObject(parent)
{
m_dbusRegistered = false;
new TooterAdaptor(this);
registerDBus();
}
Dbus::~Dbus()
{
if (m_dbusRegistered)
{
QDBusConnection connection = QDBusConnection::sessionBus();
connection.unregisterObject(PATH);
connection.unregisterService(SERVICE);
}
}
void Dbus::registerDBus()
{
if (!m_dbusRegistered)
{
QDBusConnection connection = QDBusConnection::sessionBus();
if (!connection.registerService(SERVICE))
{
QCoreApplication::quit();
return;
}
if (!connection.registerObject(PATH, this))
{
QCoreApplication::quit();
return;
}
m_dbusRegistered = true;
}
}
void Dbus::showtoot(const QStringList &key)
{
emit viewtoot(key.at(0));
}
void Dbus::openapp()
{
emit activateapp();
}