@@ -27,25 +27,13 @@
27#include <QDebug>
27#include <QDebug>
29DBusInterface::DBusInterface(LauncherModel *parent):
29DBusInterface::DBusInterface(LauncherModel *parent):
30− QDBusVirtualObject(parent),
30+ UnityDBusVirtualObject("/com/canonical/Unity/Launcher", "com.canonical.Unity.Launcher", true, parent),
31 m_launcherModel(parent)
31 m_launcherModel(parent)
33− /* Set up ourselves on DBus */
34− QDBusConnection con = QDBusConnection::sessionBus();
35− if (!con.registerService("com.canonical.Unity.Launcher")) {
36− qWarning() << "Unable to register launcher name";
38− if (!con.registerVirtualObject("/com/canonical/Unity/Launcher", this, QDBusConnection::VirtualObjectRegisterOption::SubPath)) {
39− qWarning() << "Unable to register launcher object";
43DBusInterface::~DBusInterface()
35DBusInterface::~DBusInterface()
45− /* Remove oursevles from DBus */
46− QDBusConnection con = QDBusConnection::sessionBus();
47− con.unregisterService("com.canonical.Unity.Launcher");
48− con.unregisterObject("/com/canonical/Unity/Launcher");
51QString DBusInterface::introspect(const QString &path) const
39QString DBusInterface::introspect(const QString &path) const
@@ -186,13 +174,13 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
186 int newCount = message.arguments()[2].toInt();
174 int newCount = message.arguments()[2].toInt();
187 if (!item || newCount != item->count()) {
175 if (!item || newCount != item->count()) {
188 Q_EMIT countChanged(appid, newCount);
176 Q_EMIT countChanged(appid, newCount);
189− emitPropChangedDbus(appid, "count", QVariant(newCount));
177+ notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "count", QVariant(newCount));
191 } else if (message.arguments()[1].toString() == "countVisible") {
179 } else if (message.arguments()[1].toString() == "countVisible") {
192 bool newVisible = message.arguments()[2].toBool();
180 bool newVisible = message.arguments()[2].toBool();
193 if (!item || newVisible != item->countVisible()) {
181 if (!item || newVisible != item->countVisible()) {
194 Q_EMIT countVisibleChanged(appid, newVisible);
182 Q_EMIT countVisibleChanged(appid, newVisible);
195− emitPropChangedDbus(appid, "countVisible", newVisible);
183+ notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "countVisible", newVisible);
198 } else if (message.member() == "GetAll") {
186 } else if (message.member() == "GetAll") {
@@ -209,24 +197,3 @@ bool DBusInterface::handleMessage(const QDBusMessage& message, const QDBusConnec
209 QDBusMessage reply = message.createReply(retval);
197 QDBusMessage reply = message.createReply(retval);
210 return connection.send(reply);
198 return connection.send(reply);
213−void DBusInterface::emitPropChangedDbus(const QString& appId, const QString& property, const QVariant &value)
215− QString path("/com/canonical/Unity/Launcher/");
216− path.append(encodeAppId(appId));
218− QDBusMessage message = QDBusMessage::createSignal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
220− QList<QVariant> arguments;
221− QVariantHash changedprops;
222− changedprops[property] = QVariant::fromValue(QDBusVariant(value));
223− QVariantList deletedprops;
225− arguments.append(changedprops);
226− arguments.append(deletedprops);
228− message.setArguments(arguments);
230− QDBusConnection con = QDBusConnection::sessionBus();