X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fsrc%2Fapplicationlauncher.cpp;fp=homescreen%2Fsrc%2Fapplicationlauncher.cpp;h=7b825bb6fc4a41c66d87f0685dc034fd01663fab;hb=0592a405aa68f3baf6773795efa5522e4ee16779;hp=0000000000000000000000000000000000000000;hpb=6fcde5166305cd40b5816c4495290984ca925ab6;p=apps%2Fhomescreen.git diff --git a/homescreen/src/applicationlauncher.cpp b/homescreen/src/applicationlauncher.cpp new file mode 100644 index 0000000..7b825bb --- /dev/null +++ b/homescreen/src/applicationlauncher.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "applicationlauncher.h" + +#include + +ApplicationLauncher::ApplicationLauncher(QObject *parent) + : QObject(parent), + mp_dBusAppFrameworkProxy() +{ + qDebug("D-Bus: connect to org.agl.homescreenappframeworkbinder /AppFramework"); + mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbinder", + "/AppFramework", + QDBusConnection::sessionBus(), + 0); +} + +ApplicationLauncher::~ApplicationLauncher() +{ + delete mp_dBusAppFrameworkProxy; +} + +int ApplicationLauncher::launch(const QString &application) +{ + int result = -1; + qDebug() << "launch" << application; + + result = mp_dBusAppFrameworkProxy->launchApp(application); + qDebug() << "pid:" << result; + + if (result > 1) { + setCurrent(application); + } + return result; +} + +QString ApplicationLauncher::current() const +{ + return m_current; +} + +void ApplicationLauncher::setCurrent(const QString ¤t) +{ + if (m_current == current) return; + m_current = current; + emit currentChanged(current); +}