cooldown : add remove_other_cooldown_popup
[platform/core/system/system-popup.git] / src / cooldown / cooldown-mobile.c
1 /*
2  *  system-popup
3  *
4  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18 */
19
20 #include "popup-common.h"
21
22 static const struct popup_ops cooldown_poweroff_ops;
23 static const struct popup_ops cooldown_ops;
24 static const struct popup_ops cooled_down_ops;
25 static const struct popup_ops cooldown_remove_ops;
26
27 static int remove_cooldown_popups(bundle *b, const struct popup_ops *ops)
28 {
29         unload_simple_popup(&cooldown_poweroff_ops);
30         unload_simple_popup(&cooldown_ops);
31         unload_simple_popup(&cooled_down_ops);
32         terminate_if_no_popup();
33
34         return 0;
35 }
36
37 static int remove_other_cooldown_popups(bundle *b, const struct popup_ops *ops)
38 {
39         if (!ops) {
40                 _E("Invalid removal request for cooldown");
41                 return 0;
42         }
43
44         if (ops != &cooldown_poweroff_ops)
45                 unload_simple_popup(&cooldown_poweroff_ops);
46
47         if (ops != &cooldown_ops)
48                 unload_simple_popup(&cooldown_ops);
49
50         if (ops != &cooled_down_ops)
51                 unload_simple_popup(&cooled_down_ops);
52
53         return 0;
54 }
55
56 static const struct popup_ops cooldown_poweroff_ops = {
57         .name           = "cooldown_poweroff",
58         .pattern        = FEEDBACK_PATTERN_LOWBATT,
59         .show           = load_simple_popup,
60         .title          = "IDS_ST_HEADER_POWER_OFF_ABB",
61         .content        = "IDS_QP_POP_YOUR_DEVICE_IS_OVERHEATING_IT_WILL_NOW_POWER_OFF_TO_COOL_DOWN",
62         .left_text      = "IDS_QP_BUTTON_DO_NOT_POWER_OFF_ABB",
63         .pre            = remove_other_cooldown_popups,
64 };
65
66 static const struct popup_ops cooldown_ops = {
67         .name           = "cooldown",
68         .pattern        = FEEDBACK_PATTERN_LOWBATT,
69         .show           = load_simple_popup,
70         .title          = "IDS_IDLE_HEADER_PHONE_COOLING_DOWN_ABB",
71         .content        = "IDS_IDLE_POP_YOUR_PHONE_IS_OVERHEATING_STEPS_WILL_BE_TAKEN_TO_COOL_IT_DOWN_N_NYOU_CAN_STILL_USE_YOUR_PHONE_MSG",
72         .left_text      = "IDS_COM_SK_OK",
73         .pre            = remove_other_cooldown_popups,
74 };
75
76 static const struct popup_ops cooled_down_ops = {
77         .name           = "cooled_down",
78         .pattern        = FEEDBACK_PATTERN_LOWBATT,
79         .show           = load_simple_popup,
80         .title          = "IDS_IDLE_HEADER_PHONE_COOLED_DOWN",
81         .content        = "IDS_IDLE_POP_YOUR_PHONE_IS_NOW_READY_TO_USE",
82         .left_text      = "IDS_COM_SK_OK",
83         .pre            = remove_other_cooldown_popups,
84 };
85
86 static const struct popup_ops cooldown_remove_ops = {
87         .name           = "remove_cooldown_popups",
88         .show           = remove_cooldown_popups,
89 };
90
91 /* Constructor to register cooldown button */
92 static __attribute__ ((constructor)) void cooldown_register_popup(void)
93 {
94         register_popup(&cooldown_poweroff_ops);
95         register_popup(&cooldown_ops);
96         register_popup(&cooled_down_ops);
97         register_popup(&cooldown_remove_ops);
98 }