tizen_policy: change version of tizen_policy from 1 to 7.
[platform/core/uifw/pepper-dali.git] / pepper-dali / internal / extensions / tizen-policy.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
18 #include "tizen-policy.h"
19
20 #include <dali/integration-api/debug.h>
21 #include <tizen-extension-server-protocol.h>
22
23 namespace Dali
24 {
25
26 namespace Pepper
27 {
28
29 namespace Internal
30 {
31
32 namespace Extension
33 {
34
35 namespace
36 {
37
38 #if defined(DEBUG_ENABLED)
39 Integration::Log::Filter* gPepperTizenPolicyLogging  = Integration::Log::Filter::New( Debug::Verbose, false, "LOG_PEPPER_TIZEN_POLICY" );
40 #endif
41
42 } // unnamed namespace
43
44 /* tizen policy data for pepper_surface_t */
45 typedef struct
46 {
47    pepper_surface_t *psurf;
48    pepper_event_listener_t *psurf_destroy_listener;
49    struct wl_list resource_list;
50    VisibilityState visibility;
51    int references;
52 } tzpol_surface_t;
53
54 const static char       *tsurf_data_key = "tzpol-surf";
55 static struct wl_global *_tzpol_global = NULL;
56 static struct wl_list    _tzpol_res_list;
57
58 static void
59 _tzpol_surface_del(tzpol_surface_t *tsurf)
60 {
61    free(tsurf);
62 }
63
64 static void
65 _tzpol_surface_unref(tzpol_surface_t *tsurf, struct wl_resource *unref)
66 {
67    int res;
68
69    res = wl_list_empty(&tsurf->resource_list);
70    if (res)
71      {
72         DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "Couldn't unreference, list is empty" );
73         return;
74      }
75
76    wl_list_remove(wl_resource_get_link(unref));
77    wl_resource_set_user_data(unref, NULL);
78
79    res = wl_list_empty(&tsurf->resource_list);
80    if (res)
81      {
82         pepper_event_listener_remove(tsurf->psurf_destroy_listener);
83         pepper_object_set_user_data((pepper_object_t *)tsurf->psurf,
84                                     (const void *)tsurf_data_key, NULL, NULL);
85         _tzpol_surface_del(tsurf);
86      }
87 }
88
89 static void
90 _tzpol_surface_ref(tzpol_surface_t *tsurf, struct wl_resource *ref)
91 {
92    wl_list_insert(&tsurf->resource_list, wl_resource_get_link(ref));
93    wl_resource_set_user_data(ref, tsurf);
94 }
95
96 static void
97 _tzpol_surface_pepper_surf_cb_destroy(pepper_event_listener_t *listener, pepper_object_t *object, uint32_t id, void *info, void *data)
98 {
99    tzpol_surface_t *tsurf;
100    struct wl_resource *res, *tmp;
101
102    tsurf = (tzpol_surface_t*)data;
103
104    wl_resource_for_each_safe(res, tmp, &tsurf->resource_list)
105         _tzpol_surface_unref(tsurf, res);
106 }
107
108 static tzpol_surface_t *
109 _tzpol_surface_get(pepper_surface_t *psurf)
110 {
111    tzpol_surface_t *tsurf;
112
113    tsurf = (tzpol_surface_t*)pepper_object_get_user_data((pepper_object_t *)psurf,
114                                        (const void *)tsurf_data_key);
115    if (!tsurf)
116      {
117         tsurf = (tzpol_surface_t*)calloc(1, sizeof(*tsurf));
118         if (!tsurf)
119           return NULL;
120
121         tsurf->psurf = psurf;
122
123         wl_list_init(&tsurf->resource_list);
124
125         tsurf->psurf_destroy_listener =
126            pepper_object_add_event_listener((pepper_object_t *)psurf,
127                                             PEPPER_EVENT_OBJECT_DESTROY, 0,
128                                             _tzpol_surface_pepper_surf_cb_destroy, tsurf);
129         pepper_object_set_user_data((pepper_object_t *)psurf,
130                                     (const void *)tsurf_data_key, tsurf, NULL);
131      }
132
133    tsurf->references++;
134
135    return tsurf;
136 }
137
138 // --------------------------------------------------------
139 // visibility
140 // --------------------------------------------------------
141 static void
142 _tzvis_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzvis)
143 {
144    wl_resource_destroy(res_tzvis);
145 }
146
147 static const struct tizen_visibility_interface _tzvis_iface =
148 {
149    _tzvis_iface_cb_destroy
150 };
151
152 static void
153 _tzvis_res_cb_destroy(struct wl_resource *res_tzvis)
154 {
155    tzpol_surface_t *tsurf;
156
157    tsurf = (tzpol_surface_t*)wl_resource_get_user_data(res_tzvis);
158    if (!tsurf)
159      return;
160
161    _tzpol_surface_unref(tsurf, res_tzvis);
162 }
163
164 static void
165 _tzpol_iface_cb_vis_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
166 {
167    tzpol_surface_t *tsurf;
168    pepper_surface_t *psurf;
169    struct wl_resource *new_res;
170    int ver;
171
172    if (!surf)
173      {
174         wl_resource_post_error(res_tzpol, WL_DISPLAY_ERROR_INVALID_OBJECT,
175                                "tizen_policy::visibility_get requires surface");
176         return;
177      }
178
179    psurf = (pepper_surface_t*)wl_resource_get_user_data(surf);
180    if (!psurf)
181      {
182         DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "failed to get pepper_surface from wl_resource" );
183         wl_resource_post_error(res_tzpol, WL_DISPLAY_ERROR_INVALID_OBJECT,
184                                "tizen_policy::visibility_get invalid surface resource");
185         return;
186      }
187
188    DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "tizen_policy::visibility_get" );
189    tsurf = _tzpol_surface_get(psurf);
190    if (!tsurf)
191      {
192         wl_resource_post_no_memory(res_tzpol);
193         return;
194      }
195
196    ver = wl_resource_get_version(res_tzpol);
197    new_res = wl_resource_create(client, &tizen_visibility_interface, ver, id);
198    if (!new_res)
199      {
200         wl_resource_post_no_memory(res_tzpol);
201         return;
202      }
203
204    wl_resource_set_implementation(new_res, &_tzvis_iface, tsurf, _tzvis_res_cb_destroy);
205    _tzpol_surface_ref(tsurf, new_res);
206 }
207
208 // --------------------------------------------------------
209 // position
210 // --------------------------------------------------------
211 static void
212 _tzpos_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzpos)
213 {
214    wl_resource_destroy(res_tzpos);
215 }
216
217 static void
218 _tzpos_iface_cb_set(struct wl_client *client, struct wl_resource *res_tzpos, int32_t x, int32_t y)
219 {
220    (void)client;
221    (void)res_tzpos;
222    (void)x;
223    (void)y;
224 }
225
226 static const struct tizen_position_interface _tzpos_iface =
227 {
228    _tzpos_iface_cb_destroy,
229    _tzpos_iface_cb_set,
230 };
231
232 static void
233 _tzpos_res_cb_destroy(struct wl_resource *res_tzpos)
234 {
235    tzpol_surface_t *tsurf;
236
237    tsurf = (tzpol_surface_t*)wl_resource_get_user_data(res_tzpos);
238    if (!tsurf)
239      return;
240
241    _tzpol_surface_unref(tsurf, res_tzpos);
242 }
243
244 static void
245 _tzpol_iface_cb_pos_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surf)
246 {
247    tzpol_surface_t *tsurf;
248    pepper_surface_t *psurf;
249    struct wl_resource *new_res;
250    int ver;
251
252    if (!surf)
253      {
254         wl_resource_post_error(res_tzpol, WL_DISPLAY_ERROR_INVALID_OBJECT,
255                                "tizen_policy::visibility_get requires surface");
256         return;
257      }
258
259    psurf = (pepper_surface_t*)wl_resource_get_user_data(surf);
260    if (!psurf)
261      {
262         DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "failed to get pepper_surface from wl_resource" );
263         wl_resource_post_error(res_tzpol, WL_DISPLAY_ERROR_INVALID_OBJECT,
264                                "tizen_policy::visibility_get invalid surface resource");
265         return;
266      }
267
268    DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "tizen_policy::visibility_get" );
269    tsurf = _tzpol_surface_get(psurf);
270    if (!tsurf)
271      {
272         wl_resource_post_no_memory(res_tzpol);
273         return;
274      }
275
276    ver = wl_resource_get_version(res_tzpol);
277    new_res = wl_resource_create(client, &tizen_position_interface, ver, id);
278    if (!new_res)
279      {
280         wl_resource_post_no_memory(res_tzpol);
281         return;
282      }
283
284    wl_resource_set_implementation(new_res, &_tzpos_iface, tsurf, _tzpos_res_cb_destroy);
285    _tzpol_surface_ref(tsurf, new_res);
286 }
287
288 // --------------------------------------------------------
289 // stack: activate, raise, lower
290 // --------------------------------------------------------
291 static void
292 _tzpol_iface_cb_activate(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
293 {
294    (void)client;
295    (void)res_tzpol;
296    (void)surf;
297 }
298
299 static void
300 _tzpol_iface_cb_activate_below_by_res_id(struct wl_client *client, struct wl_resource *res_tzpol,  uint32_t res_id, uint32_t below_res_id)
301 {
302    (void)client;
303    (void)res_tzpol;
304    (void)res_id;
305    (void)below_res_id;
306 }
307
308 static void
309 _tzpol_iface_cb_activate_above_by_res_id(struct wl_client *client, struct wl_resource *res_tzpol,  uint32_t res_id, uint32_t above_res_id)
310 {
311    (void)client;
312    (void)res_tzpol;
313    (void)res_id;
314    (void)above_res_id;
315 }
316
317 static void
318 _tzpol_iface_cb_raise(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
319 {
320    (void)client;
321    (void)res_tzpol;
322    (void)surf;
323 }
324
325 static void
326 _tzpol_iface_cb_lower(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
327 {
328    (void)client;
329    (void)res_tzpol;
330    (void)surf;
331 }
332
333 static void
334 _tzpol_iface_cb_lower_by_res_id(struct wl_client *client, struct wl_resource *res_tzpol,  uint32_t res_id)
335 {
336    (void)client;
337    (void)res_tzpol;
338    (void)res_id;
339 }
340
341 // --------------------------------------------------------
342 // focus
343 // --------------------------------------------------------
344 static void
345 _tzpol_iface_cb_focus_skip_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
346 {
347    (void)client;
348    (void)res_tzpol;
349    (void)surf;
350 }
351
352 static void
353 _tzpol_iface_cb_focus_skip_unset(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
354 {
355    (void)client;
356    (void)res_tzpol;
357    (void)surf;
358 }
359
360 // --------------------------------------------------------
361 // role
362 // --------------------------------------------------------
363 static void
364 _tzpol_iface_cb_role_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, const char *role)
365 {
366    (void)client;
367    (void)res_tzpol;
368    (void)surf;
369    (void)role;
370 }
371
372 static void
373 _tzpol_iface_cb_type_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t type)
374 {
375    (void)client;
376    (void)res_tzpol;
377    (void)surf;
378    (void)type;
379 }
380
381 // --------------------------------------------------------
382 // conformant
383 // --------------------------------------------------------
384 static void
385 _tzpol_iface_cb_conformant_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
386 {
387    (void)client;
388    (void)res_tzpol;
389    (void)surf;
390 }
391
392 static void
393 _tzpol_iface_cb_conformant_unset(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
394 {
395    (void)client;
396    (void)res_tzpol;
397    (void)surf;
398 }
399
400 static void
401 _tzpol_iface_cb_conformant_get(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
402 {
403    (void)client;
404    (void)res_tzpol;
405    (void)surf;
406 }
407
408 // --------------------------------------------------------
409 // notification level
410 // --------------------------------------------------------
411 static void
412 _tzpol_iface_cb_notilv_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t lv)
413 {
414    (void)client;
415    (void)res_tzpol;
416    (void)surf;
417    (void)lv;
418 }
419
420 // --------------------------------------------------------
421 // transient for
422 // --------------------------------------------------------
423 static void
424 _tzpol_iface_cb_transient_for_set(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t child_id, uint32_t parent_id)
425 {
426    (void)client;
427    (void)res_tzpol;
428    (void)child_id;
429    (void)parent_id;
430 }
431
432 static void
433 _tzpol_iface_cb_transient_for_unset(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t child_id)
434 {
435    (void)client;
436    (void)res_tzpol;
437    (void)child_id;
438 }
439
440 // --------------------------------------------------------
441 // window screen mode
442 // --------------------------------------------------------
443 static void
444 _tzpol_iface_cb_win_scrmode_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
445 {
446    (void)client;
447    (void)res_tzpol;
448    (void)surf;
449    (void)mode;
450 }
451
452 // --------------------------------------------------------
453 // subsurface
454 // --------------------------------------------------------
455 static void
456 _tzpol_iface_cb_subsurf_place_below_parent(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *subsurf)
457 {
458    (void)client;
459    (void)res_tzpol;
460    (void)subsurf;
461 }
462
463 static void
464 _tzpol_iface_cb_subsurf_stand_alone_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *subsurf)
465 {
466    (void)client;
467    (void)res_tzpol;
468    (void)subsurf;
469 }
470
471 static void
472 _tzpol_iface_cb_subsurface_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surface, uint32_t parent_id)
473 {
474    (void)client;
475    (void)res_tzpol;
476    (void)id;
477    (void)surface;
478    (void)parent_id;
479 }
480
481 static void
482 _tzpol_iface_cb_opaque_state_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, int32_t state)
483 {
484    (void)client;
485    (void)res_tzpol;
486    (void)surface;
487    (void)state;
488 }
489
490 // --------------------------------------------------------
491 // iconify
492 // --------------------------------------------------------
493 static void
494 _tzpol_iface_cb_iconify(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
495 {
496    (void)client;
497    (void)res_tzpol;
498    (void)surf;
499 }
500
501 static void
502 _tzpol_iface_cb_uniconify(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
503 {
504    (void)client;
505    (void)res_tzpol;
506    (void)surf;
507 }
508
509 static void
510 _tzpol_iface_cb_aux_hint_add(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id, const char *name, const char *value)
511 {
512    (void)client;
513    (void)res_tzpol;
514    (void)surf;
515    (void)id;
516    (void)name;
517    (void)value;
518 }
519
520 static void
521 _tzpol_iface_cb_aux_hint_change(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id, const char *value)
522 {
523    (void)client;
524    (void)res_tzpol;
525    (void)surf;
526    (void)id;
527    (void)value;
528 }
529
530 static void
531 _tzpol_iface_cb_aux_hint_del(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, int32_t id)
532 {
533    (void)client;
534    (void)res_tzpol;
535    (void)surf;
536    (void)id;
537 }
538
539 static void
540 _tzpol_iface_cb_supported_aux_hints_get(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
541 {
542    (void)client;
543    (void)res_tzpol;
544    (void)surf;
545 }
546
547 static void
548 _tzpol_iface_cb_background_state_set(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t pid)
549 {
550    (void)client;
551    (void)res_tzpol;
552    (void)pid;
553 }
554
555 static void
556 _tzpol_iface_cb_background_state_unset(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t pid)
557 {
558    (void)client;
559    (void)res_tzpol;
560    (void)pid;
561 }
562
563 static void
564 _tzpol_iface_cb_floating_mode_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
565 {
566    (void)client;
567    (void)res_tzpol;
568    (void)surf;
569 }
570
571 static void
572 _tzpol_iface_cb_floating_mode_unset(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf)
573 {
574    (void)client;
575    (void)res_tzpol;
576    (void)surf;
577 }
578
579 static void
580 _tzpol_iface_cb_stack_mode_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surf, uint32_t mode)
581 {
582    (void)client;
583    (void)res_tzpol;
584    (void)surf;
585    (void)mode;
586 }
587
588 static void
589 _tzpol_iface_cb_subsurf_watcher_get(struct wl_client *client, struct wl_resource *res_tzpol, uint32_t id, struct wl_resource *surface)
590 {
591    (void)client;
592    (void)res_tzpol;
593    (void)id;
594    (void)surface;
595 }
596
597 static void
598 _tzpol_iface_cb_parent_set(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *child, struct wl_resource *parent)
599 {
600    (void)client;
601    (void)res_tzpol;
602    (void)child;
603    (void)parent;
604 }
605
606 static void
607 _tzpol_iface_cb_ack_conformant_region(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t serial)
608 {
609    (void)client;
610    (void)res_tzpol;
611    (void)surface;
612    (void)serial;
613 }
614
615 static void
616 _tzpol_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzpol)
617 {
618    wl_resource_destroy(res_tzpol);
619 }
620
621 static void
622 _tzpol_iface_cb_has_video(struct wl_client *client, struct wl_resource *res_tzpol, struct wl_resource *surface, uint32_t has)
623 {
624    (void)client;
625    (void)res_tzpol;
626    (void)surface;
627    (void)has;
628 }
629
630 static const struct tizen_policy_interface _tzpol_iface =
631 {
632    _tzpol_iface_cb_vis_get,
633    _tzpol_iface_cb_pos_get,
634    _tzpol_iface_cb_activate,
635    _tzpol_iface_cb_activate_below_by_res_id,
636    _tzpol_iface_cb_raise,
637    _tzpol_iface_cb_lower,
638    _tzpol_iface_cb_lower_by_res_id,
639    _tzpol_iface_cb_focus_skip_set,
640    _tzpol_iface_cb_focus_skip_unset,
641    _tzpol_iface_cb_role_set,
642    _tzpol_iface_cb_type_set,
643    _tzpol_iface_cb_conformant_set,
644    _tzpol_iface_cb_conformant_unset,
645    _tzpol_iface_cb_conformant_get,
646    _tzpol_iface_cb_notilv_set,
647    _tzpol_iface_cb_transient_for_set,
648    _tzpol_iface_cb_transient_for_unset,
649    _tzpol_iface_cb_win_scrmode_set,
650    _tzpol_iface_cb_subsurf_place_below_parent,
651    _tzpol_iface_cb_subsurf_stand_alone_set,
652    _tzpol_iface_cb_subsurface_get,
653    _tzpol_iface_cb_opaque_state_set,
654    _tzpol_iface_cb_iconify,
655    _tzpol_iface_cb_uniconify,
656    _tzpol_iface_cb_aux_hint_add,
657    _tzpol_iface_cb_aux_hint_change,
658    _tzpol_iface_cb_aux_hint_del,
659    _tzpol_iface_cb_supported_aux_hints_get,
660    _tzpol_iface_cb_background_state_set,
661    _tzpol_iface_cb_background_state_unset,
662    _tzpol_iface_cb_floating_mode_set,
663    _tzpol_iface_cb_floating_mode_unset,
664    _tzpol_iface_cb_stack_mode_set,
665    _tzpol_iface_cb_activate_above_by_res_id,
666    _tzpol_iface_cb_subsurf_watcher_get,
667    _tzpol_iface_cb_parent_set,
668    _tzpol_iface_cb_ack_conformant_region,
669    _tzpol_iface_cb_destroy,
670    _tzpol_iface_cb_has_video,
671 };
672
673 static void
674 _tzpol_cb_bind(struct wl_client *client, void *data, uint32_t ver, uint32_t id)
675 {
676    struct wl_resource *resource;
677
678    DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "tizen_policy::bind" );
679
680    resource = wl_resource_create(client, &tizen_policy_interface, ver, id);
681    if (!resource)
682      {
683         DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "failed to create resource for tizen_policy" );
684         wl_client_post_no_memory(client);
685         return;
686      }
687
688    wl_resource_set_implementation(resource, &_tzpol_iface, NULL, NULL);
689
690    wl_list_insert(&_tzpol_res_list, wl_resource_get_link(resource));
691 }
692
693 bool
694 TizenPolicyInit(pepper_compositor_t *comp)
695 {
696    struct wl_display *wl_disp;
697
698    DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "tizen_policy::init" );
699
700    if (_tzpol_global)
701      goto end;
702
703    wl_list_init(&_tzpol_res_list);
704
705    wl_disp = pepper_compositor_get_display(comp);
706    _tzpol_global = wl_global_create(wl_disp, &tizen_policy_interface, 7, NULL, _tzpol_cb_bind);
707    if (!_tzpol_global)
708      {
709         DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "failed to create global for tizen policy" );
710         return false;
711      }
712 end:
713    return true;
714 }
715
716 void
717 TizenPolicyShutdown(void)
718 {
719    struct wl_resource *res, *tmp;
720
721    DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "tizen_policy::shutdown" );
722
723    wl_resource_for_each_safe(res, tmp, &_tzpol_res_list)
724      {
725         wl_list_remove(wl_resource_get_link(res));
726         wl_resource_destroy(res);
727      }
728
729    wl_global_destroy(_tzpol_global);
730    _tzpol_global = NULL;
731 }
732
733 bool
734 TizenPolicySetVisibility( pepper_surface_t* psurf, VisibilityState state )
735 {
736    tzpol_surface_t *tsurf;
737    struct wl_resource *resource;
738    int res;
739
740    tsurf = (tzpol_surface_t*)pepper_object_get_user_data((pepper_object_t *)psurf, (const void *)tsurf_data_key);
741    if (!tsurf)
742      {
743         DALI_LOG_INFO( gPepperTizenPolicyLogging, Debug::General, "there is no data for 'tzpol_surface_t' in 'pepper_surface_t'" );
744         return false;
745      }
746
747    if (tsurf->visibility == state)
748      return true;
749
750    tsurf->visibility = state;
751    wl_resource_for_each(resource, &tsurf->resource_list)
752      {
753         res = wl_resource_instance_of(resource, &tizen_visibility_interface, &_tzvis_iface);
754         if (!res)
755           continue;
756         tizen_visibility_send_notify(resource, state);
757      }
758
759    return true;
760 }
761
762 } // namespace Extension
763
764 } // namespace Internal
765
766 } // namespace Pepper
767
768 } // namespace Dali