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(),
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);
62 ai.setName("org.test.app1");
63 ai.setDescription("testdesc1");
64 ai.setIconPath("https://www.automotivelinux.org/sites/cpstandard/files/logo.png");
66 ai.setName("org.test.app2");
67 ai.setDescription("testdesc2");
72 HomeScreenAppFrameworkBinderAgl::~HomeScreenAppFrameworkBinderAgl()
74 delete mp_appframeworkAdaptor;
77 QList<AppInfo> HomeScreenAppFrameworkBinderAgl::getAvailableApps()
82 int HomeScreenAppFrameworkBinderAgl::launchApp(const QString &name)
86 qDebug("launchApp name: %s", name.toStdString().c_str());
87 QString jsonLaunch = "{\"id\":\"" + name + "\", \"mode\":\"local\"}";
88 qDebug("jsonLaunch %s", jsonLaunch.toStdString().c_str());
89 QString runIdString = mp_dBusAfmUserProxy->start(jsonLaunch);
90 qDebug("runIdString %s", runIdString.toStdString().c_str());
91 int runid = runIdString.toInt();
93 QString stateString = mp_dBusAfmUserProxy->state(runIdString);
94 qDebug("stateString %s", stateString.toStdString().c_str());
96 QJsonDocument jsonResponse = QJsonDocument::fromJson(stateString.toUtf8());
97 QJsonObject obj = jsonResponse.object();
98 QJsonArray pidArray = obj["pids"].toArray();
99 for (int i = 0; i < pidArray.size(); ++i)
101 qDebug("pid %d", pidArray[i].toInt());
103 if (1 == pidArray.size())
105 pid = pidArray[0].toInt();
107 if (2 == pidArray.size())
109 pid = pidArray[1].toInt();
112 qDebug("launchApp pid: %d", pid);
115 qDebug("launchApp name: %s", name.toStdString().c_str());
122 void HomeScreenAppFrameworkBinderAgl::clearAppList()
127 void HomeScreenAppFrameworkBinderAgl::appendAppName(const char* name)
130 newApp.setName(QString(name));
131 m_apps.append(newApp);*/