Removal of libhomescreen and appfw deps
[apps/homescreen.git] / homescreen / src / homescreenhandler.cpp
1 /*
2  * Copyright (c) 2017, 2018, 2019 TOYOTA MOTOR CORPORATION
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 <QGuiApplication>
18 #include <QFileInfo>
19 #include "homescreenhandler.h"
20 #include <functional>
21
22 #include <qpa/qplatformnativeinterface.h>
23
24 void* HomescreenHandler::myThis = 0;
25
26 HomescreenHandler::HomescreenHandler(Shell *_aglShell, ApplicationLauncher *launcher, QObject *parent) :
27         QObject(parent),
28         aglShell(_aglShell)
29 {
30         mp_launcher = launcher;
31 }
32
33 HomescreenHandler::~HomescreenHandler()
34 {
35 }
36
37 void HomescreenHandler::init()
38 {
39 }
40
41 static struct wl_output *
42 getWlOutput(QPlatformNativeInterface *native, QScreen *screen)
43 {
44         void *output = native->nativeResourceForScreen("output", screen);
45         return static_cast<struct ::wl_output*>(output);
46 }
47
48 void HomescreenHandler::tapShortcut(QString application_id)
49 {
50         struct agl_shell *agl_shell = aglShell->shell.get();
51         QPlatformNativeInterface *native = qApp->platformNativeInterface();
52         struct wl_output *output = getWlOutput(native, qApp->screens().first());
53
54         // start the application here, or do in the WM!
55
56         // this works (and it is redundant the first time), due to the default
57         // policy engine installed which actives the application, when starting
58         // the first time. Later calls to HomescreenHandler::tapShortcut will
59         // require calling 'agl_shell_activate_app'
60         agl_shell_activate_app(agl_shell, application_id.toStdString().c_str(), output);
61
62         // keep this for having animations working
63         if (mp_launcher) {
64                 mp_launcher->setCurrent(application_id);
65         }
66 }
67
68 void HomescreenHandler::onRep_static(struct json_object* reply_contents)
69 {
70         (void) reply_contents;
71 }
72
73 void HomescreenHandler::onEv_static(const string& event, struct json_object* event_contents)
74 {
75         (void) event;
76         (void) event_contents;
77 }
78
79 void HomescreenHandler::onRep(struct json_object* reply_contents)
80 {
81         (void) reply_contents;
82 }
83
84 void HomescreenHandler::onEv(const string& event, struct json_object* event_contents)
85 {
86         (void) event;
87         (void) event_contents;
88 }