Move global variable to PolicyManager member
[apps/agl-service-windowmanager.git] / src / main.cpp
1 /*
2  * Copyright (c) 2017 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 <unistd.h>
18 #include <algorithm>
19 #include <mutex>
20 #include <json.h>
21 #include <json.hpp>
22 #include "app.hpp"
23 #include "result.hpp"
24 #include "json_helper.hpp"
25 #include "util.hpp"
26 #include "wayland_ivi_wm.hpp"
27 #include "low_can_client.hpp"
28
29 extern "C" {
30 #include <afb/afb-binding.h>
31 #include <systemd/sd-event.h>
32 }
33
34 typedef struct wmClientCtxt{
35     std::string name;
36     wmClientCtxt(const char* appName){
37         name = appName;
38     }
39 } wmClientCtxt;
40
41 struct afb_instance {
42    std::unique_ptr<wl::display> display;
43    wm::LowCanClient lcc;
44    wm::App app;
45
46    afb_instance() : display{new wl::display}, lcc{}, app{this->display.get()} {}
47
48    int init();
49 };
50
51 struct afb_instance *g_afb_instance;
52 std::mutex binding_m;
53
54 int afb_instance::init() {
55    // Initialize LowCanClient class
56    this->lcc.initialize();
57
58    // Initialize App class
59    return this->app.init();
60 }
61
62 int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events,
63                            void * /*data*/) {
64    ST();
65
66    if ((events & EPOLLHUP) != 0) {
67       HMI_ERROR("wm", "The compositor hung up, dying now.");
68       delete g_afb_instance;
69       g_afb_instance = nullptr;
70       goto error;
71    }
72
73    if ((events & EPOLLIN) != 0u) {
74       {
75          STN(display_read_events);
76          g_afb_instance->app.display->read_events();
77          g_afb_instance->app.set_pending_events();
78       }
79       {
80          // We want do dispatch pending wayland events from within
81          // the API context
82          STN(winman_ping_api_call);
83          afb_service_call("windowmanager", "ping", json_object_new_object(),
84                           [](void *c, int st, json_object *j) {
85                              STN(winman_ping_api_call_return);
86                           },
87                           nullptr);
88       }
89    }
90
91    return 0;
92
93 error:
94    sd_event_source_unref(evs);
95    if (getenv("WINMAN_EXIT_ON_HANGUP") != nullptr) {
96    exit(1);
97 }
98    return -1;
99 }
100
101 int _binding_init() {
102    HMI_NOTICE("wm", "WinMan ver. %s", WINMAN_VERSION_STRING);
103
104    if (g_afb_instance != nullptr) {
105       HMI_ERROR("wm", "Wayland context already initialized?");
106       return 0;
107    }
108
109    if (getenv("XDG_RUNTIME_DIR") == nullptr) {
110       HMI_ERROR("wm", "Environment variable XDG_RUNTIME_DIR not set");
111       goto error;
112    }
113
114    {
115       // wait until wayland compositor starts up.
116       int cnt = 0;
117       g_afb_instance = new afb_instance;
118       while (!g_afb_instance->display->ok()) {
119          cnt++;
120          if (20 <= cnt) {
121             HMI_ERROR("wm", "Could not connect to compositor");
122             goto error;
123          }
124          HMI_ERROR("wm", "Wait to start weston ...");
125          sleep(1);
126          delete g_afb_instance;
127          g_afb_instance = new afb_instance;
128       }
129    }
130
131    if (g_afb_instance->init() == -1) {
132       HMI_ERROR("wm", "Could not connect to compositor");
133       goto error;
134    }
135
136    {
137       int ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
138                                 g_afb_instance->display->get_fd(), EPOLLIN,
139                                 display_event_callback, g_afb_instance);
140       if (ret < 0) {
141          HMI_ERROR("wm", "Could not initialize afb_instance event handler: %d", -ret);
142          goto error;
143       }
144    }
145
146    atexit([] { delete g_afb_instance; });
147
148    return 0;
149
150 error:
151    delete g_afb_instance;
152    g_afb_instance = nullptr;
153    return -1;
154 }
155
156 int binding_init() noexcept {
157    try {
158       return _binding_init();
159    } catch (std::exception &e) {
160       HMI_ERROR("wm", "Uncaught exception in binding_init(): %s", e.what());
161    }
162    return -1;
163 }
164
165 static bool checkFirstReq(afb_req req){
166     wmClientCtxt* ctxt = (wmClientCtxt*)afb_req_context_get(req);
167     return (ctxt) ? false : true;
168 }
169
170 static void cbRemoveClientCtxt(void* data){
171     wmClientCtxt* ctxt = (wmClientCtxt*)data;
172     if(ctxt == nullptr){
173         return;
174     }
175     HMI_DEBUG("wm","remove app %s", ctxt->name.c_str());
176     // Lookup surfaceID and remove it because App is dead.
177     auto pSid = g_afb_instance->app.id_alloc.lookup(ctxt->name.c_str());
178     if(pSid){
179         auto sid = *pSid;
180         g_afb_instance->app.id_alloc.remove_id(sid);
181         g_afb_instance->app.layers.remove_surface(sid);
182         g_afb_instance->app.controller->sprops.erase(sid);
183         g_afb_instance->app.controller->surfaces.erase(sid);
184         HMI_DEBUG("wm", "delete surfaceID %d", sid);
185     }
186     delete ctxt;
187 }
188
189 void windowmanager_requestsurface(afb_req req) noexcept {
190    std::lock_guard<std::mutex> guard(binding_m);
191    #ifdef ST
192    ST();
193    #endif
194    if (g_afb_instance == nullptr) {
195       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
196       return;
197    }
198
199    try {
200    const char* a_drawing_name = afb_req_value(req, "drawing_name");
201    if(!a_drawing_name){
202        afb_req_fail(req, "failed", "Need char const* argument drawing_name");
203        return;
204    }
205
206    /* Create Security Context */
207    bool isFirstReq = checkFirstReq(req);
208    if(!isFirstReq){
209        wmClientCtxt* ctxt = (wmClientCtxt*)afb_req_context_get(req);
210        HMI_DEBUG("wm", "You're %s.", ctxt->name.c_str());
211        if(ctxt->name != std::string(a_drawing_name)){
212            afb_req_fail_f(req, "failed", "Dont request with other name: %s for now", a_drawing_name);
213            HMI_DEBUG("wm", "Don't request with other name: %s for now", a_drawing_name);
214            return;
215        }
216    }
217
218    auto ret = g_afb_instance->app.api_request_surface(a_drawing_name);
219
220    if(isFirstReq){
221        wmClientCtxt* ctxt = new wmClientCtxt(a_drawing_name);
222        HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
223        afb_req_session_set_LOA(req, 1);
224        afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
225    }
226    else{
227        HMI_DEBUG("wm", "session already created for %s", a_drawing_name);
228    }
229
230    if (ret.is_err()) {
231       afb_req_fail(req, "failed", ret.unwrap_err());
232       return;
233    }
234
235    afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
236
237    } catch (std::exception &e) {
238       afb_req_fail_f(req, "failed", "Uncaught exception while calling requestsurface: %s", e.what());
239       return;
240    }
241
242 }
243
244 void windowmanager_requestsurfacexdg(afb_req req) noexcept {
245    std::lock_guard<std::mutex> guard(binding_m);
246    #ifdef ST
247    ST();
248    #endif
249    if (g_afb_instance == nullptr) {
250       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
251       return;
252    }
253
254    try {
255    json_object *jreq = afb_req_json(req);
256
257    json_object *j_drawing_name = nullptr;
258    if (! json_object_object_get_ex(jreq, "drawing_name", &j_drawing_name)) {
259       afb_req_fail(req, "failed", "Need char const* argument drawing_name");
260       return;
261    }
262    char const* a_drawing_name = json_object_get_string(j_drawing_name);
263
264    json_object *j_ivi_id = nullptr;
265    if (! json_object_object_get_ex(jreq, "ivi_id", &j_ivi_id)) {
266       afb_req_fail(req, "failed", "Need char const* argument ivi_id");
267       return;
268    }
269    char const* a_ivi_id = json_object_get_string(j_ivi_id);
270
271    auto ret = g_afb_instance->app.api_request_surface(a_drawing_name, a_ivi_id);
272    if (ret != nullptr) {
273       afb_req_fail(req, "failed", ret);
274       return;
275    }
276
277    afb_req_success(req, NULL, "success");
278    } catch (std::exception &e) {
279       afb_req_fail_f(req, "failed", "Uncaught exception while calling requestsurfacexdg: %s", e.what());
280       return;
281    }
282 }
283
284 void windowmanager_activatesurface(afb_req req) noexcept {
285    std::lock_guard<std::mutex> guard(binding_m);
286    #ifdef ST
287    ST();
288    #endif
289    if (g_afb_instance == nullptr) {
290       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
291       return;
292    }
293
294    try {
295    const char* a_drawing_name = afb_req_value(req, "drawing_name");
296    if(!a_drawing_name){
297        afb_req_fail(req, "failed", "Need char const* argument drawing_name");
298        return;
299    }
300
301    const char* a_drawing_area = afb_req_value(req, "drawing_area");
302    if(!a_drawing_area){
303        afb_req_fail(req, "failed", "Need char const* argument drawing_area");
304        return;
305    }
306
307    g_afb_instance->app.allocateWindowResource("activate",
308                                               a_drawing_name, a_drawing_area,
309                                               [&req](const char* errmsg){
310       if (errmsg != nullptr) {
311          HMI_ERROR("wm", errmsg);
312          afb_req_fail(req, "failed", errmsg);
313          return;
314       }
315       afb_req_success(req, NULL, "success");
316    });
317
318    } catch (std::exception &e) {
319       HMI_WARNING("wm", "failed", "Uncaught exception while calling activatesurface: %s", e.what());
320       return;
321    }
322
323 }
324
325 void windowmanager_deactivatesurface(afb_req req) noexcept {
326    std::lock_guard<std::mutex> guard(binding_m);
327    #ifdef ST
328    ST();
329    #endif
330    if (g_afb_instance == nullptr) {
331       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
332       return;
333    }
334
335    try {
336    const char* a_drawing_name = afb_req_value(req, "drawing_name");
337    if(!a_drawing_name){
338        afb_req_fail(req, "failed", "Need char const* argument drawing_name");
339        return;
340    }
341
342    g_afb_instance->app.allocateWindowResource("deactivate",
343                                               a_drawing_name, nullptr,
344                                               [&req](const char* errmsg){
345       if (errmsg != nullptr) {
346          HMI_ERROR("wm", errmsg);
347          afb_req_fail(req, "failed", errmsg);
348          return;
349       }
350       afb_req_success(req, NULL, "success");
351    });
352
353    } catch (std::exception &e) {
354       HMI_WARNING("wm", "Uncaught exception while calling deactivatesurface: %s", e.what());
355       return;
356    }
357 }
358
359 void windowmanager_enddraw(afb_req req) noexcept {
360    std::lock_guard<std::mutex> guard(binding_m);
361    #ifdef ST
362    ST();
363    #endif
364    if (g_afb_instance == nullptr) {
365       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
366       return;
367    }
368
369    try {
370    const char* a_drawing_name = afb_req_value(req, "drawing_name");
371    if(!a_drawing_name){
372        afb_req_fail(req, "failed", "Need char const* argument drawing_name");
373        return;
374    }
375    afb_req_success(req, NULL, "success");
376
377    g_afb_instance->app.api_enddraw(a_drawing_name);
378
379    } catch (std::exception &e) {
380       HMI_WARNING("wm", "failed", "Uncaught exception while calling enddraw: %s", e.what());
381       return;
382    }
383
384 }
385
386 void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept {
387    std::lock_guard<std::mutex> guard(binding_m);
388    #ifdef ST
389    ST();
390    #endif
391    if (g_afb_instance == nullptr) {
392       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
393       return;
394    }
395
396    try {
397    auto ret = g_afb_instance->app.api_get_display_info();
398    if (ret.is_err()) {
399       afb_req_fail(req, "failed", ret.unwrap_err());
400       return;
401    }
402
403    afb_req_success(req, ret.unwrap(), "success");
404    } catch (std::exception &e) {
405       afb_req_fail_f(req, "failed", "Uncaught exception while calling getdisplayinfo: %s", e.what());
406       return;
407    }
408
409 }
410
411 void windowmanager_getareainfo_thunk(afb_req req) noexcept {
412    std::lock_guard<std::mutex> guard(binding_m);
413    #ifdef ST
414    ST();
415    #endif
416    if (g_afb_instance == nullptr) {
417       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
418       return;
419    }
420
421    try {
422    json_object *jreq = afb_req_json(req);
423
424    json_object *j_drawing_name = nullptr;
425    if (! json_object_object_get_ex(jreq, "drawing_name", &j_drawing_name)) {
426       afb_req_fail(req, "failed", "Need char const* argument drawing_name");
427       return;
428    }
429    char const* a_drawing_name = json_object_get_string(j_drawing_name);
430
431    auto ret = g_afb_instance->app.api_get_area_info(a_drawing_name);
432    if (ret.is_err()) {
433       afb_req_fail(req, "failed", ret.unwrap_err());
434       return;
435    }
436
437    afb_req_success(req, ret.unwrap(), "success");
438    } catch (std::exception &e) {
439       afb_req_fail_f(req, "failed", "Uncaught exception while calling getareainfo: %s", e.what());
440       return;
441    }
442
443 }
444
445 void windowmanager_wm_subscribe(afb_req req) noexcept {
446    std::lock_guard<std::mutex> guard(binding_m);
447    #ifdef ST
448    ST();
449    #endif
450    if (g_afb_instance == nullptr) {
451       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
452       return;
453    }
454
455    try {
456    json_object *jreq = afb_req_json(req);
457    json_object *j = nullptr;
458    if (! json_object_object_get_ex(jreq, "event", &j)) {
459       afb_req_fail(req, "failed", "Need char const* argument event");
460       return;
461    }
462    int event_type = json_object_get_int(j);
463    if ((wm::App::Event_Val_Min > event_type)
464        || (wm::App::Event_Val_Max < event_type)) {
465       afb_req_fail(req, "failed", "Invalid EventType");
466       return;
467    }
468
469    const char *event_name = g_afb_instance->app.kListEventName[event_type];
470    struct afb_event event = g_afb_instance->app.map_afb_event[event_name];
471    int ret = afb_req_subscribe(req, event);
472    if (ret) {
473       afb_req_fail(req, "failed", "Error: afb_req_subscribe()");
474       return;
475    }
476    afb_req_success(req, NULL, "success");
477
478    } catch (std::exception &e) {
479       afb_req_fail_f(req, "failed", "Uncaught exception while calling wm_subscribe: %s", e.what());
480       return;
481    }
482
483 }
484
485 void windowmanager_list_drawing_names(afb_req req) noexcept {
486    std::lock_guard<std::mutex> guard(binding_m);
487    #ifdef ST
488    ST();
489    #endif
490    if (g_afb_instance == nullptr) {
491       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
492       return;
493    }
494
495    try {
496
497    nlohmann::json j = g_afb_instance->app.id_alloc.name2id;
498    auto ret = wm::Ok(json_tokener_parse(j.dump().c_str()));
499    if (ret.is_err()) {
500       afb_req_fail(req, "failed", ret.unwrap_err());
501       return;
502    }
503
504    afb_req_success(req, ret.unwrap(), "success");
505
506    } catch (std::exception &e) {
507       afb_req_fail_f(req, "failed", "Uncaught exception while calling list_drawing_names: %s", e.what());
508       return;
509    }
510
511 }
512
513 void windowmanager_ping(afb_req req) noexcept {
514    std::lock_guard<std::mutex> guard(binding_m);
515    #ifdef ST
516    ST();
517    #endif
518    if (g_afb_instance == nullptr) {
519       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
520       return;
521    }
522
523    try {
524
525    g_afb_instance->app.api_ping();
526
527    afb_req_success(req, NULL, "success");
528
529    } catch (std::exception &e) {
530       afb_req_fail_f(req, "failed", "Uncaught exception while calling ping: %s", e.what());
531       return;
532    }
533 }
534
535 void windowmanager_debug_status(afb_req req) noexcept {
536    std::lock_guard<std::mutex> guard(binding_m);
537    #ifdef ST
538    ST();
539    #endif
540    if (g_afb_instance == nullptr) {
541       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
542       return;
543    }
544
545    try {
546
547    json_object *jr = json_object_new_object();
548    json_object_object_add(jr, "surfaces",
549                           to_json(g_afb_instance->app.controller->sprops));
550    json_object_object_add(jr, "layers", to_json(g_afb_instance->app.controller->lprops));
551
552    afb_req_success(req, jr, "success");
553
554    } catch (std::exception &e) {
555       afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_status: %s", e.what());
556       return;
557    }
558 }
559
560 void windowmanager_debug_layers(afb_req req) noexcept {
561    std::lock_guard<std::mutex> guard(binding_m);
562    #ifdef ST
563    ST();
564    #endif
565    if (g_afb_instance == nullptr) {
566       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
567       return;
568    }
569
570    try {
571    auto ret = wm::Ok(json_tokener_parse(g_afb_instance->app.layers.to_json().dump().c_str()));
572
573    afb_req_success(req, ret, "success");
574
575    } catch (std::exception &e) {
576       afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_layers: %s", e.what());
577       return;
578    }
579 }
580
581 void windowmanager_debug_surfaces(afb_req req) noexcept {
582    std::lock_guard<std::mutex> guard(binding_m);
583    #ifdef ST
584    ST();
585    #endif
586    if (g_afb_instance == nullptr) {
587       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
588       return;
589    }
590
591    try {
592
593    auto ret = wm::Ok(to_json(g_afb_instance->app.controller->sprops));
594    if (ret.is_err()) {
595       afb_req_fail(req, "failed", ret.unwrap_err());
596       return;
597    }
598
599    afb_req_success(req, ret.unwrap(), "success");
600
601    } catch (std::exception &e) {
602       afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_surfaces: %s", e.what());
603       return;
604    }
605
606 }
607
608 void windowmanager_debug_terminate(afb_req req) noexcept {
609    std::lock_guard<std::mutex> guard(binding_m);
610    #ifdef ST
611    ST();
612    #endif
613    if (g_afb_instance == nullptr) {
614       afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
615       return;
616    }
617
618    try {
619
620    if (getenv("WINMAN_DEBUG_TERMINATE") != nullptr) {
621       raise(SIGKILL);  // afb-daemon kills it's pgroup using TERM, which
622                        // doesn't play well with perf
623    }
624
625    afb_req_success(req, NULL, "success");
626
627    } catch (std::exception &e) {
628       afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_terminate: %s", e.what());
629       return;
630    }
631
632 }
633
634 const struct afb_verb_v2 windowmanager_verbs[] = {
635    { "requestsurface", windowmanager_requestsurface, nullptr, nullptr, AFB_SESSION_NONE },
636    { "requestsurfacexdg", windowmanager_requestsurfacexdg, nullptr, nullptr, AFB_SESSION_NONE },
637    { "activatesurface", windowmanager_activatesurface, nullptr, nullptr, AFB_SESSION_NONE },
638    { "deactivatesurface", windowmanager_deactivatesurface, nullptr, nullptr, AFB_SESSION_NONE },
639    { "enddraw", windowmanager_enddraw, nullptr, nullptr, AFB_SESSION_NONE },
640    { "getdisplayinfo", windowmanager_getdisplayinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE },
641    { "getareainfo", windowmanager_getareainfo_thunk, nullptr, nullptr, AFB_SESSION_NONE },
642    { "wm_subscribe", windowmanager_wm_subscribe, nullptr, nullptr, AFB_SESSION_NONE },
643    { "list_drawing_names", windowmanager_list_drawing_names, nullptr, nullptr, AFB_SESSION_NONE },
644    { "ping", windowmanager_ping, nullptr, nullptr, AFB_SESSION_NONE },
645    { "debug_status", windowmanager_debug_status, nullptr, nullptr, AFB_SESSION_NONE },
646    { "debug_layers", windowmanager_debug_layers, nullptr, nullptr, AFB_SESSION_NONE },
647    { "debug_surfaces", windowmanager_debug_surfaces, nullptr, nullptr, AFB_SESSION_NONE },
648    { "debug_terminate", windowmanager_debug_terminate, nullptr, nullptr, AFB_SESSION_NONE },
649    {}
650 };
651
652 void on_event(const char *event, struct json_object *object){
653     HMI_DEBUG("wm", "event:%s", event);
654
655     // If receive low can signal
656     if (strstr(event, "low-can")) {
657         wm::LowCanClient *lcc = &(g_afb_instance->lcc);
658         wm::App *app = &(g_afb_instance->app);
659
660         // Analyze low can signal
661         const char* signal_name = lcc->analyzeCanSignal(object);
662
663         // If car info is updated, set event name
664         const char *can_event = nullptr;
665         if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoParkingBrake])) {
666             HMI_DEBUG("wm", "Parking Brake state is changed");
667
668             // Set event
669             if (lcc->getCurrentParkingBrakeState()) {
670                 can_event = "parking_brake_on";
671             }
672             else {
673                 can_event = "parking_brake_off";
674             }
675         }
676         else if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoAccelPedalPos])) {
677             // Update accel pedal position
678             app->setAccelPedalPos(lcc->getCurrentAccelPedalPosition());
679
680             if (lcc->isChangedAccelPedalState()) {
681                 HMI_DEBUG("wm", "Accelerator Pedal state is changed");
682
683                 // Set event
684                 if (lcc->getCurrentAccelPedalState()) {
685                     can_event = "accel_pedal_on";
686                 }
687                 else {
688                     can_event = "accel_pedal_off";
689                 }
690             }
691         }
692         else if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoHeadlame])) {
693             HMI_DEBUG("wm", "Headlamp state is changed");
694
695             // Set event
696             if (lcc->getCurrentHeadlampState()) {
697                 can_event = "headlamp_on";
698             }
699             else {
700                 can_event = "headlamp_off";
701             }
702         }
703         else if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoLightstatusBrake])) {
704             HMI_DEBUG("wm", "Lightstatus Brake state is changed");
705
706             // Set event
707             if (lcc->getCurrentLightstatusBrakeState()) {
708                 can_event = "lightstatus_brake_on";
709             }
710             else {
711                 can_event = "lightstatus_brake_off";
712             }
713         }
714
715         // Allocate window resource
716         if (nullptr != can_event) {
717             g_afb_instance->app.allocateWindowResource(can_event,
718                                                        nullptr, nullptr,
719                                                        [](const char* errmsg){
720                 if (errmsg != nullptr) {
721                     HMI_ERROR("wm", errmsg);
722                 }
723             });
724         }
725     }
726 }
727
728 extern "C" const struct afb_binding_v2 afbBindingV2 = {
729    "windowmanager", nullptr, nullptr, windowmanager_verbs, nullptr, binding_init, on_event, 0};