2 * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "homescreenappframeworkbinderagl.h"
20 HomeScreenAppFrameworkBinderAgl::HomeScreenAppFrameworkBinderAgl(QObject *parent) :
22 mp_appframeworkAdaptor(0),
24 mp_dBusAfmUserProxy(0)
26 qDebug("D-Bus: register as org.agl.homescreenappframeworkbinder");
30 // publish app framework interface
31 mp_appframeworkAdaptor = new AppframeworkAdaptor((QObject*)this);
32 QDBusConnection dbus = QDBusConnection::sessionBus();
33 dbus.registerObject("/AppFramework", this);
34 dbus.registerService("org.agl.homescreenappframeworkbinder");
36 qDebug("D-Bus: connect to org.AGL.afm.user /org/AGL/afm/user");
37 mp_dBusAfmUserProxy = new org::AGL::afm::user("org.AGL.afm.user",
39 QDBusConnection::sessionBus(),
42 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
43 QString runnables = mp_dBusAfmUserProxy->runnables("{\"dummy\": \"entry\"}");
44 qDebug("runnables: %s", runnables.toStdString().c_str());
46 QJsonDocument jsonResponse = QJsonDocument::fromJson(runnables.toUtf8());
47 QJsonArray appsArray = jsonResponse.array();
48 for (int i = 0; i < appsArray.size(); ++i)
50 qDebug("new app %d", i);
51 QJsonObject appObject = appsArray[i].toObject();
53 appInfo.read(appObject);
54 qDebug("name %s", appInfo.name().toStdString().c_str());
55 m_apps.append(appInfo);
61 ai.setName("org.test.app1");
62 ai.setDescription("testdesc1");
63 ai.setIconPath("https://www.automotivelinux.org/sites/cpstandard/files/logo.png");
65 ai.setName("org.test.app2");
66 ai.setDescription("testdesc2");
71 HomeScreenAppFrameworkBinderAgl::~HomeScreenAppFrameworkBinderAgl()
73 delete mp_appframeworkAdaptor;
76 QList<AppInfo> HomeScreenAppFrameworkBinderAgl::getAvailableApps()
81 int HomeScreenAppFrameworkBinderAgl::launchApp(const QString &name)
84 #ifdef HAVE_IVI_LAYERMANAGEMENT_API
85 qDebug("launchApp name: %s", name.toStdString().c_str());
86 QString jsonLaunch = "{\"id\":\"" + name + "\", \"mode\":\"local\"}";
87 qDebug("jsonLaunch %s", jsonLaunch.toStdString().c_str());
88 QString runIdString = mp_dBusAfmUserProxy->start(jsonLaunch);
89 qDebug("runIdString %s", runIdString.toStdString().c_str());
90 int runid = runIdString.toInt();
92 QString stateString = mp_dBusAfmUserProxy->state(runIdString);
93 qDebug("stateString %s", stateString.toStdString().c_str());
95 QJsonDocument jsonResponse = QJsonDocument::fromJson(stateString.toUtf8());
96 QJsonObject obj = jsonResponse.object();
97 QJsonArray pidArray = obj["pids"].toArray();
98 for (int i = 0; i < pidArray.size(); ++i)
100 qDebug("pid %d", pidArray[i].toInt());
102 if (1 == pidArray.size())
104 pid = pidArray[0].toInt();
106 if (2 == pidArray.size())
108 pid = pidArray[1].toInt();
111 qDebug("launchApp pid: %d", pid);
113 qDebug("launchApp name: %s", name.toStdString().c_str());
120 void HomeScreenAppFrameworkBinderAgl::clearAppList()
125 void HomeScreenAppFrameworkBinderAgl::appendAppName(const char* name)
128 newApp.setName(QString(name));
129 m_apps.append(newApp);*/