sync with master branch
[apps/core/preloaded/quickpanel.git] / daemon / modules.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 "common.h"
18 #include "modules.h"
19
20 /*******************************************************************
21   *
22   * MODULES
23   *
24   *****************************************************************/
25 /* searchbar */
26 /* extern QP_Module searchbar; */
27 #ifdef QP_MINICTRL_ENABLE
28 extern QP_Module minictrl;
29 #endif /* QP_MINICTRL_ENABLE */
30
31 #ifdef QP_BRIGHTNESS_ENABLE
32 /* brightness */
33 extern QP_Module brightness_ctrl;
34 #endif /* QP_BRIGHTNESS_ENABLE */
35 /* notification */
36 extern QP_Module noti;
37 extern QP_Module ticker;
38 extern QP_Module ticker_status;
39 /* idle test */
40 extern QP_Module idletxt;
41
42 static QP_Module *modules[] = {
43 #ifdef QP_MINICTRL_ENABLE
44         &minictrl,
45 #endif /* QP_MINICTRL_ENABLE */
46 #ifdef QP_BRIGHTNESS_ENABLE
47         &brightness_ctrl,
48 #endif /* QP_BRIGHTNESS_ENABLE */
49         &noti,
50         &ticker,
51         &ticker_status,
52         &idletxt
53 };
54
55 int init_modules(void *data)
56 {
57         int i;
58
59         retif(data == NULL, QP_FAIL, "Invalid parameter!");
60
61         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
62                 if (modules[i]->init)
63                         modules[i]->init(data);
64         }
65
66         return QP_OK;
67 }
68
69 int fini_modules(void *data)
70 {
71         int i;
72
73         retif(data == NULL, QP_FAIL, "Invalid parameter!");
74
75         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
76                 if (modules[i]->fini)
77                         modules[i]->fini(data);
78         }
79
80         return QP_OK;
81 }
82
83 int suspend_modules(void *data)
84 {
85         int i;
86
87         retif(data == NULL, QP_FAIL, "Invalid parameter!");
88
89         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
90                 if (modules[i]->suspend)
91                         modules[i]->suspend(data);
92         }
93
94         return QP_OK;
95 }
96
97 int resume_modules(void *data)
98 {
99         int i;
100
101         retif(data == NULL, QP_FAIL, "Invalid parameter!");
102
103         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
104                 if (modules[i]->resume)
105                         modules[i]->resume(data);
106         }
107
108         return QP_OK;
109 }
110
111 int hib_enter_modules(void *data)
112 {
113         int i;
114
115         retif(data == NULL, QP_FAIL, "Invalid parameter!");
116
117         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
118                 if (modules[i]->hib_enter)
119                         modules[i]->hib_enter(data);
120         }
121
122         return QP_OK;
123 }
124
125 int hib_leave_modules(void *data)
126 {
127         int i;
128
129         retif(data == NULL, QP_FAIL, "Invalid parameter!");
130
131         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
132                 if (modules[i]->hib_leave)
133                         modules[i]->hib_leave(data);
134         }
135
136         return QP_OK;
137 }
138
139 /******************************************************************
140   *
141   * LANGUAGE
142   *
143   ****************************************************************/
144
145 void lang_change_modules(void *data)
146 {
147         int i;
148         retif(data == NULL, , "Invalid parameter!");
149
150         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
151                 if (modules[i]->lang_changed)
152                         modules[i]->lang_changed(data);
153         }
154 }
155
156 void refresh_modules(void *data)
157 {
158         int i;
159         retif(data == NULL, , "Invalid parameter!");
160
161         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
162                 if (modules[i]->refresh)
163                         modules[i]->refresh(data);
164         }
165 }
166
167 /******************************************************************
168   *
169   * Quickpanel open/close Events
170   *
171   ****************************************************************/
172 int qp_opened_modules(void *data)
173 {
174         int i;
175
176         retif(data == NULL, QP_FAIL, "Invalid parameter!");
177
178         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
179                 if (modules[i]->qp_opened)
180                         modules[i]->qp_opened(data);
181         }
182
183         return QP_OK;
184 }
185
186 int qp_closed_modules(void *data)
187 {
188         int i;
189
190         retif(data == NULL, QP_FAIL, "Invalid parameter!");
191
192         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
193                 if (modules[i]->qp_closed)
194                         modules[i]->qp_closed(data);
195         }
196
197         return QP_OK;
198 }