~ci-train-bot/history-service/history-service-ubuntu-yakkety-landing-052

« back to all changes in this revision

Viewing changes to src/manager.cpp

Request contact information for all known participants on history-daemon initialization, and use this cached information on the models.
Approved by: Tiago Salem Herrmann, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "threadview.h"
30
30
#include "voiceevent.h"
31
31
#include <QDebug>
 
32
#include <QDBusConnection>
 
33
#include <QDBusConnectionInterface>
 
34
#include <QDBusReply>
32
35
 
33
36
namespace History
34
37
{
36
39
// ------------- ManagerPrivate ------------------------------------------------
37
40
 
38
41
ManagerPrivate::ManagerPrivate()
39
 
    : dbus(new ManagerDBus())
 
42
    : dbus(new ManagerDBus()), serviceWatcher(DBusService, QDBusConnection::sessionBus())
40
43
{
41
44
}
42
45
 
70
73
    connect(d->dbus.data(),
71
74
            SIGNAL(eventsRemoved(History::Events)),
72
75
            SIGNAL(eventsRemoved(History::Events)));
 
76
 
 
77
    // watch for the service going up and down
 
78
    connect(&d->serviceWatcher, &QDBusServiceWatcher::serviceRegistered, [&](const QString &serviceName) {
 
79
        qDebug() << "HistoryService: service registered:" << serviceName;
 
80
        this->d_ptr->serviceRunning = true;
 
81
        Q_EMIT this->serviceRunningChanged();
 
82
    });
 
83
    connect(&d->serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, [&](const QString &serviceName) {
 
84
        qDebug() << "HistoryService: service unregistered:" << serviceName;
 
85
        this->d_ptr->serviceRunning = false;
 
86
        Q_EMIT this->serviceRunningChanged();
 
87
    });
 
88
 
 
89
    // and fetch the current status
 
90
    d->serviceRunning = false;
 
91
    QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(DBusService);
 
92
    if (reply.isValid()) {
 
93
        d->serviceRunning = reply.value();
 
94
    }
73
95
}
74
96
 
75
97
Manager::~Manager()
142
164
    return d->dbus->removeEvents(events);
143
165
}
144
166
 
 
167
bool Manager::isServiceRunning() const
 
168
{
 
169
    Q_D(const Manager);
 
170
    return d->serviceRunning;
 
171
}
 
172
 
145
173
}
146
174