Add 2017 to copyright
[staging/HomeScreen.git] / HomeScreen / src / homescreencontrolinterface.cpp
1 /*
2  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "homescreencontrolinterface.h"
18
19 HomeScreenControlInterface::HomeScreenControlInterface(QObject *parent) :
20     QObject(parent),
21     mp_homeScreenAdaptor(0),
22     mp_dBusAppFrameworkProxy()
23 {
24     // publish dbus homescreen interface
25     mp_homeScreenAdaptor = new HomescreenAdaptor((QObject*)this);
26     QDBusConnection dbus = QDBusConnection::sessionBus();
27     dbus.registerObject("/HomeScreen", this);
28     dbus.registerService("org.agl.homescreen");
29
30     qDebug("D-Bus: connect to org.agl.homescreenappframeworkbindertizen /AppFramework");
31     mp_dBusAppFrameworkProxy = new org::agl::appframework("org.agl.homescreenappframeworkbindertizen",
32                                               "/AppFramework",
33                                               QDBusConnection::sessionBus(),
34                                               0);
35 }
36
37 HomeScreenControlInterface::~HomeScreenControlInterface()
38 {
39     delete mp_dBusAppFrameworkProxy;
40     delete mp_homeScreenAdaptor;
41 }
42
43 QList<int> HomeScreenControlInterface::getAllSurfacesOfProcess(int pid)
44 {
45     qDebug("getAllSurfacesOfProcess %d", pid);
46     return newRequestGetAllSurfacesOfProcess(pid);
47 }
48
49 int HomeScreenControlInterface::getSurfaceStatus(int surfaceId)
50 {
51     qDebug("getSurfaceStatus %d", surfaceId);
52     return newRequestGetSurfaceStatus(surfaceId);
53 }
54
55 void HomeScreenControlInterface::hardKeyPressed(int key)
56 {
57     int pid = -1;
58
59     switch (key)
60     {
61     case InputEvent::HARDKEY_NAV:
62         qDebug("hardKeyPressed NAV key pressed!");
63         pid = mp_dBusAppFrameworkProxy->launchApp("navigation@0.1");
64         qDebug("pid: %d", pid);
65         emit newRequestsToBeVisibleApp(pid);
66         break;
67     case InputEvent::HARDKEY_MEDIA:
68         qDebug("hardKeyPressed MEDIA key pressed!");
69         pid = mp_dBusAppFrameworkProxy->launchApp("media@0.1");
70         qDebug("pid: %d", pid);
71         emit newRequestsToBeVisibleApp(pid);
72         break;
73     default:
74         qDebug("hardKeyPressed %d", key);
75         break;
76     }
77 }
78
79 void HomeScreenControlInterface::renderSurfaceToArea(int surfaceId, int layoutArea)
80 {
81     qDebug("renderSurfaceToArea %d %d", surfaceId, layoutArea);
82     emit newRequestRenderSurfaceToArea(surfaceId, layoutArea);
83 }
84
85 bool HomeScreenControlInterface::renderAppToAreaAllowed(int appCategory, int layoutArea)
86 {
87     qDebug("renderAppToAreaAllowed %d %d", appCategory, layoutArea);
88     return true; //TODO: ask policy manager
89 }
90
91 void HomeScreenControlInterface::requestSurfaceIdToFullScreen(int surfaceId)
92 {
93     qDebug("requestSurfaceIdToFullScreen %d", surfaceId);
94     emit newRequestSurfaceIdToFullScreen(surfaceId);
95 }