22
22
#include "launchermenu.h"
25
#include <dashclient.h>
25
26
#include <debug_p.h>
27
28
#include <QDBusMetaType>
30
#include <QDBusServiceWatcher>
31
#include <QDBusConnectionInterface>
34
32
// Marshall the RendererInfoStruct data into a D-Bus argument
35
33
QDBusArgument &operator<<(QDBusArgument &argument, const RendererInfoStruct &r)
146
144
static const char* UNITY_PLACE_ENTRY_INTERFACE = "com.canonical.Unity.PlaceEntry";
147
145
static const char* SECTION_PROPERTY = "section";
149
static const char* DASH_DBUS_SERVICE = "com.canonical.Unity2d.Dash";
150
static const char* DASH_DBUS_PATH = "/Dash";
151
static const char* DASH_DBUS_INTERFACE = "com.canonical.Unity2d.Dash";
153
147
PlaceEntry::PlaceEntry(QObject* parent) :
154
148
LauncherItem(parent),
163
157
m_entryResultsModel(NULL),
164
158
m_globalGroupsModel(NULL),
165
159
m_globalResultsModel(NULL),
167
m_dashDbusIface(NULL),
170
162
qDBusRegisterMetaType<RendererInfoStruct>();
171
163
qDBusRegisterMetaType<PlaceEntryInfoStruct>();
172
164
qDBusRegisterMetaType<QList<PlaceEntryInfoStruct> >();
173
165
qDBusRegisterMetaType<QHash<QString, QString>>();
175
/* Check if the dash is already up and running by asking the bus instead of
176
trying to create an instance of the interface. Creating an instance would
177
cause D-Bus to activate the dash and we don’t want this to happen, the
178
dash should be started on demand only. */
179
QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
180
QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(DASH_DBUS_SERVICE);
181
if (reply.isValid() && reply.value()) {
184
/* The dash is not running: monitor its registration on the bus so we
185
can connect to it when it comes up. */
186
QDBusServiceWatcher* watcher = new QDBusServiceWatcher(DASH_DBUS_SERVICE,
187
QDBusConnection::sessionBus(),
188
QDBusServiceWatcher::WatchForRegistration,
190
connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));
167
connect(DashClient::instance(), SIGNAL(activePageChanged(const QString&)),
168
SLOT(slotActivePageChanged(const QString&)));
194
171
PlaceEntry::PlaceEntry(const PlaceEntry& other) :
752
729
Q_EMIT globalRendererHintsChanged();
756
PlaceEntry::connectToDash()
758
if (m_dashDbusIface != NULL) {
762
m_dashDbusIface = new QDBusInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE,
763
QDBusConnection::sessionBus(), this);
764
connect(m_dashDbusIface, SIGNAL(activeChanged(bool)),
765
SLOT(slotDashActiveChanged(bool)));
766
connect(m_dashDbusIface, SIGNAL(activePlaceEntryChanged(const QString&)),
767
SLOT(slotDashActivePlaceEntryChanged(const QString&)));
769
QVariant value = m_dashDbusIface->property("active");
770
if (value.isValid()) {
771
m_dashActive = value.toBool();
773
UQ_WARNING << "Fetching Dash.active property failed";
775
value = m_dashDbusIface->property("activePlaceEntry");
776
if (value.isValid()) {
777
m_dashActivePlaceEntry = value.toString();
779
UQ_WARNING << "Fetching Dash.activePlaceEntry property failed";
786
PlaceEntry::slotDashActiveChanged(bool value)
788
if (m_dashActive != value) {
789
m_dashActive = value;
795
PlaceEntry::slotDashActivePlaceEntryChanged(const QString& entry)
797
if (m_dashActivePlaceEntry != entry) {
798
m_dashActivePlaceEntry = entry;
804
PlaceEntry::updateActiveState()
734
PlaceEntry::slotActivePageChanged(const QString& page)
806
736
bool active = false;
807
if (m_dashActive && !m_dbusObjectPath.isEmpty() && (m_dashActivePlaceEntry == m_dbusObjectPath)) {
737
if (!m_dbusObjectPath.isEmpty() && page == m_dbusObjectPath) {
827
757
startRemotePlaceOnDemand();
830
QDBusInterface iface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE);
831
iface.asyncCall(QLatin1String("activatePlaceEntry"), m_fileName, m_groupName, section);
761
DashClient::instance()->setActivePage(QString());
763
/* FIXME: DashClient::setActivePage has changed but PlaceEntry is deprecated anyway */
764
//DashClient::instance()->setActivePage(m_dbusObjectPath, m_fileName, m_groupName, section);