summaryrefslogtreecommitdiffstats
path: root/launcher/src
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/src')
-rw-r--r--launcher/src/applicationmodel.cpp19
-rw-r--r--launcher/src/homescreenhandler.cpp67
-rw-r--r--launcher/src/homescreenhandler.h7
3 files changed, 71 insertions, 22 deletions
diff --git a/launcher/src/applicationmodel.cpp b/launcher/src/applicationmodel.cpp
index 42982d5..1af4366 100644
--- a/launcher/src/applicationmodel.cpp
+++ b/launcher/src/applicationmodel.cpp
@@ -40,13 +40,10 @@ public:
namespace {
QString get_icon_name(QJsonObject const &i)
{
- QString icon = i["name"].toString().toLower();
-
- if ( !QFile::exists(QString(":/images/%1_active.svg").arg(icon)) ||
- !QFile::exists(QString(":/images/%1_inactive.svg").arg(icon)) )
- {
+ QString icon = i["icon"].toString();
+ fprintf(stderr, "Looking for icon %s\n", icon.toLocal8Bit().data());
+ if ( !QFile::exists(icon) )
icon = "blank";
- }
return icon;
}
}
@@ -63,9 +60,13 @@ void ApplicationModel::Private::addApp(QString icon, QString name, QString id)
return;
}
- QString _icon = name.toLower();
- if ( !QFile::exists(QString(":/images/%1_active.svg").arg(_icon)) ||
- !QFile::exists(QString(":/images/%1_inactive.svg").arg(_icon)) )
+ QString _icon;
+ if ( QFile::exists(icon) )
+ {
+ _icon = QString("file:%1").arg(icon);
+ fprintf(stderr, "using icon '%s'\n", _icon.toLocal8Bit().data());
+ }
+ else
{
_icon = "blank";
}
diff --git a/launcher/src/homescreenhandler.cpp b/launcher/src/homescreenhandler.cpp
index 811daa0..9cf7e61 100644
--- a/launcher/src/homescreenhandler.cpp
+++ b/launcher/src/homescreenhandler.cpp
@@ -15,33 +15,76 @@
* limitations under the License.
*/
+#include <QDBusMessage>
+#include <QDBusConnection>
#include "homescreenhandler.h"
#include "hmi-debug.h"
+#include <json.h>
+
+#define APPLAUNCH_DBUS_IFACE "org.automotivelinux.AppLaunch"
+#define APPLAUNCH_DBUS_OBJECT "/org/automotivelinux/AppLaunch"
+
HomescreenHandler::HomescreenHandler(QObject *parent) : QObject(parent)
{
+ applaunch_iface = new org::automotivelinux::AppLaunch(APPLAUNCH_DBUS_IFACE, APPLAUNCH_DBUS_OBJECT, QDBusConnection::sessionBus(), this);
}
HomescreenHandler::~HomescreenHandler()
{
}
-void HomescreenHandler::tapShortcut(QString application_id, QString output_name)
+void HomescreenHandler::tapShortcut(QString application_id)
{
- HMI_DEBUG("Launcher","tapShortcut %s", application_id.toStdString().c_str());
-}
+ HMI_DEBUG("Launcher","tapShortcut %s", application_id.toStdString().c_str());
-void HomescreenHandler::onRep(struct json_object* reply_contents)
-{
- if (reply_contents) {
- QString data = json_object_to_json_string(reply_contents);
- HMI_DEBUG("Launcher", "doing an emit initAppList()");
- emit initAppList(data);
- } else {
- HMI_DEBUG("Launcher", "reply contents is invalid!");
- }
+ QDBusPendingReply<> reply = applaunch_iface->start(application_id);
+ reply.waitForFinished();
+ if (reply.isError()) {
+ HMI_ERROR("Launcher","Unable to start application '%s': %s",
+ application_id.toStdString().c_str(),
+ reply.error().message().toStdString().c_str());
+ }
}
void HomescreenHandler::getRunnables(void)
{
+ struct json_object *json_applist;
+ QString applist;
+ QStringList apps;
+
+ QDBusPendingReply<QVariantList> reply = applaunch_iface->listApplications(true);
+ reply.waitForFinished();
+ if (reply.isError()) {
+ HMI_ERROR("Launcher","Unable to retrieve application list: %s",
+ reply.error().message().toStdString().c_str());
+ return;
+ } else {
+ QVariantList applist_variant = reply.value();
+ for (auto &v: applist_variant) {
+ QString app_id;
+ QString name;
+ QString icon_path;
+ const QDBusArgument &dbus_arg = v.value<QDBusArgument>();
+
+ dbus_arg.beginStructure();
+ dbus_arg >> app_id >> name >> icon_path;
+
+ apps << QString("{ \"name\":\"%1\", \"id\":\"%2\", \"icon\":\"%3\" }")
+ .arg(name)
+ .arg(app_id)
+ .arg(icon_path);
+ dbus_arg.endStructure();
+ }
+ }
+
+ applist = QString("[ %1 ]").arg(apps.join(", "));
+ json_applist = json_tokener_parse(applist.toLocal8Bit().data());
+ if (json_applist) {
+ QString data = json_object_to_json_string(json_applist);
+ HMI_DEBUG("Launcher", "doing an emit initAppList()");
+ emit initAppList(data);
+ } else {
+ HMI_DEBUG("Launcher", "app list is invalid!");
+ }
}
diff --git a/launcher/src/homescreenhandler.h b/launcher/src/homescreenhandler.h
index c5d46b4..616f816 100644
--- a/launcher/src/homescreenhandler.h
+++ b/launcher/src/homescreenhandler.h
@@ -25,6 +25,8 @@
#include <json.h>
+#include "applaunch_interface.h"
+
using namespace std;
class HomescreenHandler : public QObject
@@ -34,7 +36,7 @@ public:
explicit HomescreenHandler(QObject *parent = 0);
~HomescreenHandler();
- Q_INVOKABLE void tapShortcut(QString application_id, QString output_name);
+ Q_INVOKABLE void tapShortcut(QString application_id);
Q_INVOKABLE void getRunnables(void);
void onRep(struct json_object* reply_contents);
@@ -42,6 +44,9 @@ public:
signals:
void initAppList(QString data);
void appListUpdate(QStringList info);
+
+private:
+ org::automotivelinux::AppLaunch *applaunch_iface;
};
#endif // HOMESCREENHANDLER_H