aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-05-10 14:09:53 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-05-10 14:09:53 +0200
commit620ed99557cf2842426a17f4bfc48c4639efbf4b (patch)
tree917946a5eac1ed5222b6f1e0eee8671b3710526f
parent9cd61f1d0361c94ee4e1bed6fd1e80151db927cd (diff)
ApplicationModel: use single afm_user_daemon_proxy instance
* Do not use org.agl.homescreenappframeworkbinder. * Use the single afm_user_proxy_instance of our main(). Change-Id: Ib7ce8d2cefe1678200f0e38148e599b4df7459cc Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r--homescreen/src/applicationmodel.cpp50
1 files changed, 23 insertions, 27 deletions
diff --git a/homescreen/src/applicationmodel.cpp b/homescreen/src/applicationmodel.cpp
index c5f0fc0..c43e1bc 100644
--- a/homescreen/src/applicationmodel.cpp
+++ b/homescreen/src/applicationmodel.cpp
@@ -23,23 +23,22 @@
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
+#include "afm_user_daemon_proxy.h"
+
+extern org::AGL::afm::user *afm_user_daemon_proxy;
+
class ApplicationModel::Private
{
public:
- Private(ApplicationModel *parent);
+ Private();
-private:
- ApplicationModel *q;
-public:
- QDBusInterface proxy;
QList<AppInfo> data;
};
namespace {
- // This is a disgrace, shouldn't we be having a defined way to know which icon (if it is not given by the getAvailableApps() reply)?
- QString get_icon_name(AppInfo const &i)
+ QString get_icon_name(QJsonObject const &i)
{
- QString icon = i.iconPath().isEmpty() ? i.id().split("@").front() : i.iconPath();
+ QString icon = i["id"].toString().split("@").front();
if (icon == "hvac" || icon == "poi") {
icon = icon.toUpper();
} else if (icon == "mediaplayer") {
@@ -51,32 +50,29 @@ namespace {
}
}
-ApplicationModel::Private::Private(ApplicationModel *parent)
- : q(parent)
- , proxy(QStringLiteral("org.agl.homescreenappframeworkbinder"), QStringLiteral("/AppFramework"), QStringLiteral("org.agl.appframework"), QDBusConnection::sessionBus())
+ApplicationModel::Private::Private()
{
- QDBusReply<QList<AppInfo>> reply = proxy.call("getAvailableApps");
- if (reply.isValid()) {
- // FIXME: Is the order from dbus the one we want to use?!
- for (auto const &i: reply.value()) {
- auto const name = i.name().split(" ").front().toUpper();
- auto const icon = get_icon_name(i);
- data.append(AppInfo(icon, name, i.id()));
- }
- } else {
- qDebug() << "getAvailableApps() reply is INVALID!";
+ QString apps = afm_user_daemon_proxy->runnables(QStringLiteral(""));
+ QJsonDocument japps = QJsonDocument::fromJson(apps.toUtf8());
+ for (auto const &app : japps.array()) {
+ QJsonObject const &jso = app.toObject();
+ auto const name = jso["name"].toString();
+ auto const id = jso["id"].toString();
+ auto const icon = get_icon_name(jso);
+ this->data.append(AppInfo(icon, name, id));
+ qDebug() << "name:" << name << "icon:" << icon << "id:" << id;
}
}
ApplicationModel::ApplicationModel(QObject *parent)
: QAbstractListModel(parent)
- , d(new Private(this))
+ , d(new Private())
{
}
ApplicationModel::~ApplicationModel()
{
- delete d;
+ delete this->d;
}
int ApplicationModel::rowCount(const QModelIndex &parent) const
@@ -84,7 +80,7 @@ int ApplicationModel::rowCount(const QModelIndex &parent) const
if (parent.isValid())
return 0;
- return d->data.count();
+ return this->d->data.count();
}
QVariant ApplicationModel::data(const QModelIndex &index, int role) const
@@ -95,13 +91,13 @@ QVariant ApplicationModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DecorationRole:
- ret = d->data[index.row()].iconPath();
+ ret = this->d->data[index.row()].iconPath();
break;
case Qt::DisplayRole:
- ret = d->data[index.row()].name();
+ ret = this->d->data[index.row()].name();
break;
case Qt::UserRole:
- ret = d->data[index.row()].id();
+ ret = this->d->data[index.row()].id();
break;
default:
break;