homescreenhandler: Include homescreen handler
[apps/hvac.git] / app / homescreenhandler.cpp
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  * Copyright (c) 2018,2019 TOYOTA MOTOR CORPORATION
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <QDBusMessage>
19 #include <QDBusConnection>
20 #include "homescreenhandler.h"
21
22 #define APPLAUNCH_DBUS_IFACE     "org.automotivelinux.AppLaunch"
23 #define APPLAUNCH_DBUS_OBJECT    "/org/automotivelinux/AppLaunch"
24
25 HomescreenHandler::HomescreenHandler(QObject *parent) : QObject(parent)
26 {
27     applaunch_iface = new org::automotivelinux::AppLaunch(APPLAUNCH_DBUS_IFACE, APPLAUNCH_DBUS_OBJECT, QDBusConnection::sessionBus(), this);
28 }
29
30 HomescreenHandler::~HomescreenHandler()
31 {
32 }
33
34 void HomescreenHandler::setOrientation(QString application_id, uint32_t orientation)
35 {
36     QDBusPendingReply<> reply = applaunch_iface->split(application_id, orientation);
37     reply.waitForFinished();
38     if (reply.isError()) {
39         fprintf(stderr, "HVAC: Unable to split application '%s': %s",
40                   application_id.toStdString().c_str(),
41                   reply.error().message().toStdString().c_str());
42     }
43
44     fprintf(stderr, "hvac done calling set split for appid %s, orientation %d\n",
45                     application_id.toStdString().c_str(), orientation);
46 }