@@ -166,9 +166,7 @@ int LauncherBackend::progress(const QString &appId) const
166166
167167int LauncherBackend::count(const QString &appId) const
168168{
169− // TODO: emit countChanged() when this value changes.
170−
171− int count = 0;
169+ int count = -1;
172170 LauncherBackendItem *item = m_itemCache.value(appId);
173171 if (!item) {
174172 QString df = findDesktopFile(appId);
@@ -187,6 +185,79 @@ int LauncherBackend::count(const QString &appId) const
187185 return count;
188186}
189187
188+void LauncherBackend::setCount(const QString &appId, int count) const
189+{
190+ LauncherBackendItem *item = m_itemCache.value(appId);
191+ if (!item) {
192+ QString df = findDesktopFile(appId);
193+ if (!df.isEmpty()) {
194+ item = parseDesktopFile(df);
195+ m_itemCache.insert(appId, item);
196+ }
197+ }
198+
199+ bool emitchange = false;
200+ if (!item) {
201+ emitchange = (item->count != count);
202+ item->count = count;
203+ }
204+
205+ if (emitchange) {
206+ /* TODO: This needs to use the accessor to handle the visibility
207+ correctly, but when we have the two properties we can just use
208+ the local value */
209+ Q_EMIT countChanged(appId, this->count(appId));
210+ QVariant vcount(item->count);
211+ emitPropChangedDbus(appId, "count", vcount);
212+ }
213+}
214+
215+bool LauncherBackend::countVisible(const QString &appId) const
216+{
217+ bool visible = false;
218+ LauncherBackendItem *item = m_itemCache.value(appId);
219+ if (!item) {
220+ QString df = findDesktopFile(appId);
221+ if (!df.isEmpty()) {
222+ item = parseDesktopFile(df);
223+ m_itemCache.insert(appId, item);
224+ }
225+ }
226+
227+ if (!item) {
228+ visible = item->countVisible;
229+ }
230+
231+ return visible;
232+}
233+
234+void LauncherBackend::setCountVisible(const QString &appId, bool visible) const
235+{
236+ LauncherBackendItem *item = m_itemCache.value(appId);
237+ if (!item) {
238+ QString df = findDesktopFile(appId);
239+ if (!df.isEmpty()) {
240+ item = parseDesktopFile(df);
241+ m_itemCache.insert(appId, item);
242+ }
243+ }
244+
245+ bool emitchange = false;
246+ if (!item) {
247+ emitchange = (item->countVisible != visible);
248+ item->countVisible = visible;
249+ }
250+
251+ if (emitchange) {
252+ /* TODO: Because we're using visible in determining the
253+ count we need to emit a count changed as well */
254+ Q_EMIT countChanged(appId, this->count(appId));
255+ Q_EMIT countVisibleChanged(appId, item->countVisible);
256+ QVariant vCountVisible(item->countVisible);
257+ emitPropChangedDbus(appId, "countVisible", vCountVisible);
258+ }
259+}
260+
190261void LauncherBackend::setUser(const QString &username)
191262{
192263 if (qgetenv("USER") == "lightdm" && m_user != username) {
@@ -470,3 +541,24 @@ QString LauncherBackend::encodeAppId (const QString& appId) const
470541
471542 return encoded;
472543}
544+
545+void LauncherBackend::emitPropChangedDbus (const QString& appId, const QString& property, QVariant &value) const
546+{
547+ QString path("/com/canonical/unity/launcher/");
548+ path.append(encodeAppId(appId));
549+
550+ QDBusMessage message = QDBusMessage::createSignal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
551+
552+ QList<QVariant> arguments;
553+ QVariantHash changedprops;
554+ changedprops[property] = value;
555+ QVariantList deletedprops;
556+
557+ arguments.append(changedprops);
558+ arguments.append(deletedprops);
559+
560+ message.setArguments(arguments);
561+
562+ QDBusConnection con = QDBusConnection::sessionBus();
563+ con.send(message);
564+}