92c50afca171b84ce5065822a46dbbf713ec8dcf
[apps/home/quickpanel.git] / daemon / minictrl / minictrl.c
1 /*
2  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
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
19 #include <glib.h>
20 #include <Ecore_X.h>
21 #include <minicontrol-viewer.h>
22 #include <minicontrol-monitor.h>
23 #include <string.h>
24 #include "common.h"
25 #include "quickpanel-ui.h"
26 #include "quickpanel_def.h"
27 #include "list_util.h"
28 #include "quickpanel_debug_util.h"
29 #ifdef QP_SCREENREADER_ENABLE
30 #include "accessibility.h"
31 #endif
32 #include "minictrl.h"
33 #include "vi_manager.h"
34
35 #define MINICONTROL_TYPE_STR_VIEWER "::[viewer="
36 #define MINICONTROL_TYPE_STR_QUICKPANEL "QUICKPANEL"
37 #define MINICONTROL_TYPE_STR_LOCKSCREEN "LOCKSCREEN"
38 #define MINICONTROL_TYPE_STR_ONGOING "_ongoing]"
39
40 static Eina_Bool _anim_init_cb(void *data);
41 static Eina_Bool _anim_job_cb(void *data);
42 static Eina_Bool _anim_done_cb(void *data);
43 static int quickpanel_minictrl_init(void *data);
44 static int quickpanel_minictrl_fini(void *data);
45 static int quickpanel_minictrl_suspend(void *data);
46 static int quickpanel_minictrl_resume(void *data);
47
48 QP_Module minictrl = {
49         .name = "minictrl",
50         .init = quickpanel_minictrl_init,
51         .fini = quickpanel_minictrl_fini,
52         .suspend = quickpanel_minictrl_suspend,
53         .resume = quickpanel_minictrl_resume,
54         .hib_enter = NULL,
55         .hib_leave = NULL,
56         .lang_changed = NULL,
57         .refresh = NULL,
58         .get_height = NULL,
59 };
60
61 struct _viewer_item {
62         char *name;
63         unsigned int width;
64         unsigned int height;
65         minicontrol_priority_e priority;
66         Evas_Object *viewer;
67         void *data;
68 };
69
70 static void _minictrl_resize_vi(Evas_Object *list,
71                                         struct _viewer_item *item, int to_w, int to_h);
72
73 GHashTable *g_prov_table;
74
75 static int _viewer_check(const char *name)
76 {
77         char *pos_start = NULL;
78         retif(!name, 0, "name is NULL");
79
80         if ((pos_start = strstr(name, MINICONTROL_TYPE_STR_VIEWER)) != NULL) {
81                 if (strstr(pos_start, MINICONTROL_TYPE_STR_QUICKPANEL) != NULL) {
82                         return 1;
83                 } else {
84                         return 0;
85                 }
86         } else if (strstr(name, MINICONTROL_TYPE_STR_LOCKSCREEN) != NULL) {
87                 return 0;
88         }
89
90         return 1;
91 }
92
93 static void _viewer_freeze(Evas_Object *viewer)
94 {
95         int freezed_count = 0;
96         retif(viewer == NULL, , "Invalid parameter!");
97
98         freezed_count = elm_object_scroll_freeze_get(viewer);
99
100         if (freezed_count <= 0) {
101                 elm_object_scroll_freeze_push(viewer);
102         }
103 }
104
105 static void _viewer_unfreeze(Evas_Object *viewer)
106 {
107         int i = 0, freezed_count = 0;
108         retif(viewer == NULL, , "Invalid parameter!");
109
110         freezed_count = elm_object_scroll_freeze_get(viewer);
111
112         for (i = 0 ; i < freezed_count; i++) {
113                 elm_object_scroll_freeze_pop(viewer);
114         }
115 }
116
117 static Evas_Object *_get_minictrl_obj(Evas_Object *layout) {
118         retif(layout == NULL, NULL, "Invalid parameter!");
119
120         return elm_object_part_content_get(layout, "elm.icon");
121 }
122
123 static void _viewer_set_size(Evas_Object *layout, void *data, int width, int height)
124 {
125         Evas_Object *viewer = NULL;
126         retif(layout == NULL, , "Invalid parameter!");
127         retif(data == NULL, , "Invalid parameter!");
128         retif(width < 0, , "Invalid parameter!");
129         retif(height < 0, , "Invalid parameter!");
130         struct appdata *ad = data;
131         int max_width = 0;
132         int resized_width = 0;
133         int is_landscape = 0;
134
135         viewer = _get_minictrl_obj(layout);
136         retif(viewer == NULL, , "Invalid parameter!");
137
138         is_landscape = (width > ad->win_width) ? 1 : 0;
139
140         if (is_landscape) {
141                 max_width = (ad->scale * ad->win_height);
142         } else {
143                 max_width = (ad->scale * ad->win_width);
144         }
145         resized_width = (width > max_width) ? max_width : width;
146
147         SERR("minicontroller view is resized to w:%d(%d) h:%d Landscape[%d]", resized_width, width, height, is_landscape);
148
149         evas_object_size_hint_min_set(viewer, resized_width, height);
150         evas_object_size_hint_max_set(viewer, resized_width, height);
151 }
152
153 static void _viewer_item_free(struct _viewer_item *item)
154 {
155         struct appdata *ad = quickpanel_get_app_data();
156         retif(ad == NULL, , "Invalid parameter!");
157         retif(ad->list == NULL, , "Invalid parameter!");
158         retif(item == NULL, , "Invalid parameter!");
159
160         if (item->name)
161                 free(item->name);
162
163         if (item->viewer) {
164                 quickpanel_list_util_item_unpack_by_object(ad->list, item->viewer, 0, 0);
165                 quickpanel_list_util_item_del_tag(item->viewer);
166                 if (item->viewer != NULL) {
167                         evas_object_del(item->viewer);
168                         item->viewer = NULL;
169                 }
170         }
171
172         free(item);
173 }
174
175 static Evas_Object *_minictrl_create_view(struct appdata *ad, const char *name)
176 {
177         retif(ad == NULL, NULL, "Invalid parameter!");
178         retif(ad->list == NULL, NULL, "Invalid parameter!");
179         retif(name == NULL, NULL, "Invalid parameter!");
180
181         Evas_Object *layout = NULL;
182
183         layout = elm_layout_add(ad->list);
184
185         elm_layout_file_set(layout, DEFAULT_EDJ,
186                         "quickpanel/minictrl/default");
187
188         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
189         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
190         evas_object_show(layout);
191
192         Evas_Object *viewer = minicontrol_viewer_add(layout, name);
193         if (!viewer)
194         {
195                 ERR("fail to add viewer - %s", name);
196                 if (layout)
197                 {
198                         evas_object_del(layout);
199                 }
200                 return NULL;
201         }
202         elm_object_focus_allow_set(viewer, EINA_TRUE);
203         elm_object_part_content_set(layout, "elm.icon", viewer);
204
205         Evas_Object *focus = quickpanel_ui_get_focus_object(layout);
206         elm_object_part_content_set(layout, "focus", focus);
207
208 #ifdef QP_SCREENREADER_ENABLE
209         Evas_Object *ao = quickpanel_screen_reader_object_get(layout,
210                         SCREEN_READER_OBJ_TYPE_ELM_OBJECT, "focus", layout);
211
212         if (ao != NULL) {
213                 elm_access_info_cb_set(ao, ELM_ACCESS_TYPE, quickpanel_access_info_cb,
214                                 _NOT_LOCALIZED("Mini controller"));
215         }
216 #endif
217
218         return layout;
219 }
220
221 static int _minictrl_is_ongoing(const char *str)
222 {
223         if (str == NULL) return 0;
224
225         if (strstr(str, MINICONTROL_TYPE_STR_ONGOING) != NULL) {
226                 return 1;
227         } else {
228                 return 0;
229         }
230 }
231
232 static qp_item_type_e _minictrl_priority_to_type(minicontrol_priority_e priority)
233 {
234         qp_item_type_e type;
235
236         switch (priority) {
237         case MINICONTROL_PRIORITY_TOP:
238                 type = QP_ITEM_TYPE_MINICTRL_TOP;
239                 break;
240         case MINICONTROL_PRIORITY_MIDDLE:
241                 type = QP_ITEM_TYPE_MINICTRL_MIDDLE;
242                 break;
243         case MINICONTROL_PRIORITY_LOW:
244         default:
245                 type = QP_ITEM_TYPE_MINICTRL_LOW;
246                 break;
247         }
248
249         return type;
250 }
251
252 static void _minictrl_release_cb(void *data, Evas *e,
253                 Evas_Object *obj, void *event_info) {
254         struct appdata *ad;
255         retif(!data, , "data is NULL");
256         ad = data;
257
258         _viewer_unfreeze(ad->scroller);
259 }
260
261 static void _minictrl_add(const char *name, unsigned int width,
262                                 unsigned int height,
263                                 minicontrol_priority_e priority,
264                                 void *data)
265 {
266         qp_item_data *qid = NULL;
267         struct _viewer_item *vit = NULL;
268         qp_item_type_e type;
269         struct appdata *ad;
270         Evas_Object *viewer = NULL;
271
272         retif(!name, , "name is NULL");
273         retif(!data, , "data is NULL");
274
275         ad = data;
276         retif(!ad->list, , "list is NULL");
277
278         if (g_prov_table) {
279                 struct _viewer_item *found = NULL;
280                 found = g_hash_table_lookup(g_prov_table, name);
281
282                 if (found) {
283                         ERR("already have it : %s", name);
284                         return;
285                 }
286         } else {
287                 ERR("g_prov_table is NULL");
288                 return;
289         }
290
291         /* elm_plug receives 'server_del' event,
292          * if it repeats connect and disconnect frequently.
293          *
294          */
295         viewer = _minictrl_create_view(ad, name);
296         if (!viewer)
297         {
298                 ERR("Failed to create view[%s]", name);
299                 return;
300         }
301         _viewer_set_size(viewer, ad, width, height);
302         quickpanel_initial_resize(viewer,
303                         (height > QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT)
304                         ? height : QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT);
305
306         evas_object_event_callback_add(_get_minictrl_obj(viewer), EVAS_CALLBACK_MOUSE_UP,
307                         _minictrl_release_cb, ad);
308
309         vit = malloc(sizeof(struct _viewer_item));
310         if (!vit) {
311                 ERR("fail to alloc vit");
312                 if (viewer != NULL) {
313                         evas_object_del(viewer);
314                         viewer = NULL;
315                 }
316                 return;
317         }
318
319         if (_minictrl_is_ongoing(name) == 1) {
320                 type = QP_ITEM_TYPE_MINICTRL_ONGOING;
321         } else {
322                 type = _minictrl_priority_to_type(priority);
323         }
324         qid = quickpanel_list_util_item_new(type, vit);
325         if (!qid) {
326                 ERR("fail to alloc vit");
327                 if (viewer != NULL) {
328                         evas_object_del(viewer);
329                         viewer = NULL;
330                 }
331                 free(vit);
332                 return;
333         }
334         vit->name = strdup(name);
335         vit->width = width;
336         vit->height = height;
337         vit->priority = priority;
338         vit->viewer = viewer;
339         vit->data = data;
340         quickpanel_list_util_item_set_tag(vit->viewer, qid);
341         quickpanel_list_util_sort_insert(ad->list, vit->viewer);
342
343         g_hash_table_insert(g_prov_table, g_strdup(name), vit);
344
345         DBG("success to add minicontrol %s", name);
346         quickpanel_minictrl_rotation_report(ad->angle);
347 }
348
349 static void _minictrl_remove(const char *name, void *data)
350 {
351         if (g_prov_table) {
352                 if (g_hash_table_remove(g_prov_table, name))
353                 {
354                         DBG("success to remove %s", name);
355
356                         retif(data == NULL, , "data is NULL");
357                 }
358                 else
359                         WARN("unknown provider name : %s", name);
360         }
361 }
362
363 static void _minictrl_update(const char *name, unsigned int width,
364                                 unsigned int height, void *data)
365 {
366         int old_h = 0;
367         struct appdata *ad = data;
368         struct _viewer_item *found = NULL;
369
370         retif(!g_prov_table, , "data is NULL");
371         retif(!ad, , "data is NULL");
372
373         found = g_hash_table_lookup(g_prov_table, name);
374
375         if (!found) {
376                 WARN("unknown provider name : %s", name);
377                 return;
378         }
379
380         old_h = found->height;
381
382         if (found->viewer) {
383                 if (old_h != height) {
384                         _minictrl_resize_vi(ad->list,
385                                 found, width, height);
386                 } else {
387                         _viewer_set_size(found->viewer, ad, width, height);
388                         quickpanel_initial_resize(found->viewer,
389                                         (height > QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT)
390                                         ? height : QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT);
391                 }
392         }
393 }
394
395 static void _minictrl_request(const char *name, int action, int value, void *data)
396 {
397         struct appdata *ad = data;
398         retif(!name, , "name is NULL");
399         retif(!ad, , "data is NULL");
400
401         SDBG("%s %d %d", name, action, value);
402
403         if (action == MINICONTROL_REQ_HIDE_VIEWER) {
404                 quickpanel_close_quickpanel(true, 0);
405         } else if (action == MINICONTROL_REQ_FREEZE_SCROLL_VIEWER) {
406                 if (ad->list != NULL) {
407                         ERR("freezed by %s", name);
408                         _viewer_freeze(ad->scroller);
409                 }
410         } else if (action == MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER) {
411                 if (ad->list != NULL) {
412                         ERR("unfreezed by %s", name);
413                         _viewer_unfreeze(ad->scroller);
414                 }
415         } else if (action == MINICONTROL_REQ_REPORT_VIEWER_ANGLE) {
416                 if (ad->list != NULL) {
417                         SERR("need to broadcasting angle by %s %d", name, action);
418                         quickpanel_minictrl_rotation_report(ad->angle);
419                 }
420         }
421 }
422
423 static void _mctrl_monitor_cb(minicontrol_action_e action,
424                                 const char *name, unsigned int width,
425                                 unsigned int height,
426                                 minicontrol_priority_e priority,
427                                 void *data)
428 {
429         retif(!data, , "data is NULL");
430         retif(!name, , "name is NULL");
431
432         if (_viewer_check(name) == 0) {
433                 ERR("%s: ignored", name);
434                 return ;
435         }
436
437         switch (action) {
438         case MINICONTROL_ACTION_START:
439                 _minictrl_add(name, width, height, priority, data);
440                 break;
441         case MINICONTROL_ACTION_RESIZE:
442                 _minictrl_update(name, width, height, data);
443                 break;
444         case MINICONTROL_ACTION_STOP:
445                 _minictrl_remove(name, data);
446                 break;
447         case MINICONTROL_ACTION_REQUEST:
448                 _minictrl_request(name, width, height, data);
449                 break;
450         default:
451                 break;
452         }
453 }
454
455 static void _minictrl_resize_vi(Evas_Object *list,
456                                         struct _viewer_item *item, int to_w, int to_h)
457 {
458         QP_VI *vi = NULL;
459         retif(list == NULL, , "invalid parameter");
460         retif(item == NULL, , "invalid parameter");
461
462         vi = quickpanel_vi_new_with_data(
463                         VI_OP_RESIZE,
464                         QP_ITEM_TYPE_MINICTRL_MIDDLE,
465                         list,
466                         item->viewer,
467                         _anim_init_cb,
468                         _anim_job_cb,
469                         _anim_done_cb,
470                         _anim_done_cb,
471                         vi,
472                         item,
473                         to_w,
474                         to_h);
475         quickpanel_vi_start(vi);
476 }
477
478 static void _anim_init_resize(void *data) {
479         QP_VI *vi = data;
480         retif(vi == NULL, , "invalid parameter");
481         retif(vi->target == NULL, , "invalid parameter");
482
483         Evas_Object *item = vi->target;
484         evas_object_color_set(item, 0, 0, 0, 0);
485 }
486
487 void _reorder_transit_del_cb(void *data, Elm_Transit *transit) {
488         QP_VI *vi = data;
489         int to_w = 0, to_h = 0;
490         Evas_Object *item = NULL;
491         retif(vi == NULL, , "data is NULL");
492         retif(vi->target == NULL, , "invalid parameter");
493
494         item = vi->target;
495         to_w = vi->extra_flag_1;
496         to_h = vi->extra_flag_2;
497
498         struct appdata *ad = quickpanel_get_app_data();
499         retif(ad == NULL, , "Invalid parameter!");
500
501         _viewer_set_size(item, ad, to_w, to_h);
502         quickpanel_initial_resize(item,
503                         (to_h > QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT)
504                         ? to_h : QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT);
505 }
506
507 static void _anim_job_resize(void *data) {
508         QP_VI *vi = data;
509         int to_w = 0, to_h = 0;
510         Elm_Transit *transit_layout_parent = NULL;
511         Elm_Transit *transit_fadein = NULL;
512         Evas_Object *item = NULL;
513         struct _viewer_item *viewer_item = NULL;
514
515         struct appdata *ad = quickpanel_get_app_data();
516         retif(ad == NULL, , "Invalid parameter!");
517         retif(vi == NULL, , "invalid parameter");
518         retif(vi->target == NULL, , "invalid parameter");
519         retif(vi->extra_data_2 == NULL, , "invalid parameter");
520
521         item = vi->target;
522         to_w = vi->extra_flag_1;
523         to_h = vi->extra_flag_2;
524         viewer_item = vi->extra_data_2;
525
526         transit_layout_parent = quickpanel_list_get_reorder_transit(viewer_item->viewer, NULL, to_h - viewer_item->height);
527         if (transit_layout_parent != NULL) {
528                 elm_transit_del_cb_set(transit_layout_parent, _reorder_transit_del_cb, vi);
529         } else {
530                 _viewer_set_size(item, ad, to_w, to_h);
531                 quickpanel_initial_resize(item,
532                                 (to_h > QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT)
533                                 ? to_h : QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT);
534         }
535
536         transit_fadein = elm_transit_add();
537         if (transit_fadein != NULL) {
538                 elm_transit_object_add(transit_fadein, item);
539                 elm_transit_effect_color_add(transit_fadein, 0, 0, 0, 0, 255, 255, 255, 255);
540                 elm_transit_duration_set(transit_fadein, 0.35);
541                 elm_transit_tween_mode_set(transit_fadein,
542                                 quickpanel_vim_get_tweenmode(VI_OP_INSERT));
543                 elm_transit_del_cb_set(transit_fadein, quickpanel_vi_done_cb_for_transit, vi);
544                 elm_transit_objects_final_state_keep_set(transit_fadein, EINA_TRUE);
545
546                 if (transit_layout_parent != NULL) {
547                         elm_transit_chain_transit_add(transit_layout_parent, transit_fadein);
548                         elm_transit_go(transit_layout_parent);
549                 } else {
550                         elm_transit_go(transit_fadein);
551                 }
552         } else {
553                 ERR("Failed to create all the transit");
554                 quickpanel_vi_done(vi);
555         }
556 }
557
558 static void _anim_done_resize(void *data) {
559         QP_VI *vi = data;
560         struct _viewer_item *viewer_item = NULL;
561         struct appdata *ad = quickpanel_get_app_data();
562         retif(ad == NULL, , "Invalid parameter!");
563         retif(vi == NULL, , "invalid parameter");
564         retif(vi->target == NULL, , "invalid parameter");
565
566         Evas_Object *item = vi->target;
567         viewer_item = vi->extra_data_2;
568
569         viewer_item->width = vi->extra_flag_1;
570         viewer_item->height = vi->extra_flag_2;
571
572         _viewer_set_size(item, ad, viewer_item->width, viewer_item->height);
573         quickpanel_initial_resize(item,
574                         (viewer_item->height > QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT)
575                         ? viewer_item->height : QP_THEME_LIST_ITEM_MINICONTRL_HEIGHT + QP_THEME_LIST_ITEM_SEPERATOR_HEIGHT);
576         evas_object_color_set(item, 255, 255, 255, 255);
577 }
578
579 static Eina_Bool _anim_init_cb(void *data) {
580         QP_VI *vi = data;
581         retif(vi == NULL, EINA_FALSE, "invalid parameter");
582
583         static qp_vi_op_table anim_init_table[] = {
584                 {
585                         .op_type = VI_OP_RESIZE,
586                         .handler = _anim_init_resize,
587                 },
588                 {
589                         .op_type = VI_OP_NONE,
590                         .handler = NULL,
591                 },
592         };
593
594         int i = 0;
595         for (i = 0; anim_init_table[i].op_type != VI_OP_NONE; i++) {
596                 if (anim_init_table[i].op_type != vi->op_type)
597                         continue;
598
599                 anim_init_table[i].handler(vi);
600                 break;
601         }
602
603         return EINA_TRUE;
604 }
605
606 static Eina_Bool _anim_job_cb(void *data) {
607         QP_VI *vi = data;
608         retif(vi == NULL, EINA_FALSE, "invalid parameter");
609
610         static qp_vi_op_table anim_job_table[] = {
611                 {
612                         .op_type = VI_OP_RESIZE,
613                         .handler = _anim_job_resize,
614                 },
615                 {
616                         .op_type = VI_OP_NONE,
617                         .handler = NULL,
618                 },
619         };
620
621         int i = 0;
622         for (i = 0; anim_job_table[i].op_type != VI_OP_NONE; i++) {
623                 if (anim_job_table[i].op_type != vi->op_type)
624                         continue;
625
626                 anim_job_table[i].handler(vi);
627                 break;
628         }
629
630         return EINA_TRUE;
631 }
632
633 static Eina_Bool _anim_done_cb(void *data) {
634         QP_VI *vi = data;
635         retif(vi == NULL, EINA_FALSE, "invalid parameter");
636
637         static qp_vi_op_table anim_done_table[] = {
638                 {
639                         .op_type = VI_OP_RESIZE,
640                         .handler = _anim_done_resize,
641                 },
642                 {
643                         .op_type = VI_OP_NONE,
644                         .handler = NULL,
645                 },
646         };
647
648         int i = 0;
649         for (i = 0; anim_done_table[i].op_type != VI_OP_NONE; i++) {
650                 if (anim_done_table[i].op_type != vi->op_type)
651                         continue;
652
653                 anim_done_table[i].handler(vi);
654                 break;
655         }
656
657         return EINA_TRUE;
658 }
659
660 static int quickpanel_minictrl_init(void *data)
661 {
662         minicontrol_error_e ret;
663
664         retif(!data, QP_FAIL, "Invalid parameter!");
665
666         g_prov_table = g_hash_table_new_full(g_str_hash, g_str_equal,
667                                         (GDestroyNotify)g_free,
668                                         (GDestroyNotify)_viewer_item_free);
669
670         ret = minicontrol_monitor_start(_mctrl_monitor_cb, data);
671         if (ret != MINICONTROL_ERROR_NONE) {
672                 ERR("fail to minicontrol_monitor_start()- %d", ret);
673                 return QP_FAIL;
674         }
675
676         return QP_OK;
677 }
678
679 static int quickpanel_minictrl_fini(void *data)
680 {
681         minicontrol_error_e ret;
682         ret = minicontrol_monitor_stop();
683         if (ret != MINICONTROL_ERROR_NONE)
684                 ERR("fail to minicontrol_monitor_stop()- %d", ret);
685
686         if (g_prov_table) {
687                 g_hash_table_remove_all(g_prov_table);
688                 g_prov_table = NULL;
689         }
690
691         return QP_OK;
692 }
693
694 static int quickpanel_minictrl_suspend(void *data)
695 {
696         struct appdata *ad = data;
697         retif(ad == NULL, QP_FAIL, "Invalid parameter!");
698
699         if (ad->list != NULL) {
700                 _viewer_unfreeze(ad->scroller);
701         }
702
703         return QP_OK;
704 }
705
706 static int quickpanel_minictrl_resume(void *data)
707 {
708         struct appdata *ad = data;
709         retif(ad == NULL, QP_FAIL, "Invalid parameter!");
710
711         if (ad->list != NULL) {
712                 _viewer_unfreeze(ad->scroller);
713         }
714
715         return QP_OK;
716 }
717
718 void quickpanel_minictrl_rotation_report(int angle)
719 {
720         if (g_prov_table != NULL) {
721                 if (g_hash_table_size(g_prov_table) > 0) {
722                         SINFO("minicontrol rotation:%d", angle);
723                         minicontrol_viewer_request(QP_PKG_QUICKPANEL,
724                                         MINICONTROL_REQ_ROTATE_PROVIDER, angle);
725                 }
726         }
727 }