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 stateString = mp_dBusAfmUserProxy->once(jsonLaunch);
89 qDebug("stateString %s", stateString.toStdString().c_str());
91 QJsonDocument jsonResponse = QJsonDocument::fromJson(stateString.toUtf8());
92 QJsonObject obj = jsonResponse.object();
93 QJsonArray pidArray = obj["pids"].toArray();
94 for (int i = 0; i < pidArray.size(); ++i)
96 qDebug("pid %d", pidArray[i].toInt());
98 if (1 == pidArray.size())
100 pid = pidArray[0].toInt();
102 if (2 == pidArray.size())
104 pid = pidArray[1].toInt();
107 qDebug("launchApp pid: %d", pid);
109 qDebug("launchApp name: %s", name.toStdString().c_str());
116 void HomeScreenAppFrameworkBinderAgl::clearAppList()
121 void HomeScreenAppFrameworkBinderAgl::appendAppName(const char* name)
124 newApp.setName(QString(name));
125 m_apps.append(newApp);*/