~sil2100/unity-2d/precise-security

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
46
47
48
49
50
51
#include "qdbusconnectionqml.h"

QDBusConnectionQML::QDBusConnectionQML(QObject *parent) : QObject(parent), m_interface(NULL)
{
    QObject::connect(this, SIGNAL(objectPathChanged(QString)), this, SLOT(connectToDBus()));
    QObject::connect(this, SIGNAL(serviceChanged(QString)), this, SLOT(connectToDBus()));
}

QDBusConnectionQML::~QDBusConnectionQML()
{
    if (m_interface != NULL)
        delete m_interface;
}

QString
QDBusConnectionQML::objectPath() const
{
    return m_objectPath;
}

QString
QDBusConnectionQML::service() const
{
    return m_service;
}

void
QDBusConnectionQML::setObjectPath(QString objectPath)
{
    m_objectPath = objectPath;
    emit objectPathChanged(m_objectPath);
}

void
QDBusConnectionQML::setService(QString service)
{
    m_service = service;
    emit serviceChanged(m_service);
}

void
QDBusConnectionQML::connectToDBus()
{
    if (m_interface != NULL)
        delete m_interface;

    if (m_service.isEmpty() || m_objectPath.isEmpty())
        return;

    m_interface = new QDBusInterface(m_service, m_objectPath);
}