tizen 2.4 release
[apps/home/quickpanel.git] / daemon / modules.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 #include <Elementary.h>
19 #include <tzsh.h>
20 #include <tzsh_quickpanel_service.h>
21
22 #include "common.h"
23 #include "quickpanel-ui.h"
24 #include "modules.h"
25
26 /*******************************************************************
27  *
28  * MODULES
29  *
30  *****************************************************************/
31
32 #ifdef QP_SETTING_ENABLE
33 /* setting */
34 extern QP_Module settings;
35 extern QP_Module settings_view_featured;
36 extern QP_Module settings_view_all;
37 #endif /* QP_SETTING_ENABLE */
38
39 #ifdef QP_MINICTRL_ENABLE
40 extern QP_Module minictrl;
41 #endif /* QP_MINICTRL_ENABLE */
42
43 #ifdef QP_BRIGHTNESS_ENABLE
44 /* brightness */
45 extern QP_Module brightness_ctrl;
46 #endif /* QP_BRIGHTNESS_ENABLE */
47
48 #ifdef QP_ANIMATED_IMAGE_ENABLE
49 extern QP_Module animated_image;
50 #endif
51
52 extern QP_Module vi_manager;
53 extern QP_Module pager;
54
55 /* notification */
56 extern QP_Module noti;
57 extern QP_Module activenoti;
58 extern QP_Module qp_datetime_controller;
59 extern QP_Module qp_datetime_view;
60
61 /* voice control */
62 #ifdef QP_VOICE_CONTROL_ENABLE
63 extern QP_Module voice_control;
64 #endif
65
66 /* do not change the order of modules, result may be changed up to order */
67 static QP_Module *modules[] = {
68         &vi_manager,
69         &pager,
70         &qp_datetime_controller,
71         &qp_datetime_view,
72 #ifdef QP_SETTING_ENABLE
73         &settings,
74         &settings_view_featured,
75         &settings_view_all,
76 #endif /* QP_SETTING_ENABLE */
77 #ifdef QP_MINICTRL_ENABLE
78         &minictrl,
79 #endif /* QP_MINICTRL_ENABLE */
80 #ifdef QP_BRIGHTNESS_ENABLE
81         &brightness_ctrl,
82 #endif /* QP_BRIGHTNESS_ENABLE */
83         &noti,
84         &activenoti,
85 #ifdef QP_ANIMATED_IMAGE_ENABLE
86         &animated_image,
87 #endif
88 #ifdef QP_VOICE_CONTROL_ENABLE
89         &voice_control,
90 #endif
91 };
92
93 HAPI int quickpanel_modules_init(void *data)
94 {
95         int i;
96
97         retif(data == NULL, QP_FAIL, "Invalid parameter!");
98
99         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
100                 if (modules[i]->init) {
101                         modules[i]->init(data);
102                 }
103
104                 if (modules[i]->init_job_cb) {
105                         ecore_job_add(modules[i]->init_job_cb, data);
106                 }
107         }
108
109         return QP_OK;
110 }
111
112 HAPI int quickpanel_modules_fini(void *data)
113 {
114         int i;
115
116         retif(data == NULL, QP_FAIL, "Invalid parameter!");
117
118         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
119                 if (modules[i]->fini) {
120                         modules[i]->fini(data);
121                 }
122         }
123
124         return QP_OK;
125 }
126
127 HAPI int quickpanel_modules_suspend(void *data)
128 {
129         int i;
130
131         retif(data == NULL, QP_FAIL, "Invalid parameter!");
132
133         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
134                 if (modules[i]->suspend) {
135                         modules[i]->suspend(data);
136                 }
137         }
138
139         return QP_OK;
140 }
141
142 HAPI int quickpanel_modules_resume(void *data)
143 {
144         int i;
145
146         retif(data == NULL, QP_FAIL, "Invalid parameter!");
147
148         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
149                 if (modules[i]->resume) {
150                         modules[i]->resume(data);
151                 }
152         }
153
154         return QP_OK;
155 }
156
157 HAPI int quickpanel_modules_hib_enter(void *data)
158 {
159         int i;
160
161         retif(data == NULL, QP_FAIL, "Invalid parameter!");
162
163         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
164                 if (modules[i]->hib_enter) {
165                         modules[i]->hib_enter(data);
166                 }
167         }
168
169         return QP_OK;
170 }
171
172 HAPI int quickpanel_modules_hib_leave(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]->hib_leave) {
180                         modules[i]->hib_leave(data);
181                 }
182         }
183
184         return QP_OK;
185 }
186
187 /******************************************************************
188  *
189  * LANGUAGE
190  *
191  ****************************************************************/
192
193 HAPI void quickpanel_modules_lang_change(void *data)
194 {
195         int i;
196         retif(data == NULL, , "Invalid parameter!");
197
198         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
199                 if (modules[i]->lang_changed) {
200                         modules[i]->lang_changed(data);
201                 }
202         }
203 }
204
205 HAPI void quickpanel_modules_refresh(void *data)
206 {
207         int i;
208         retif(data == NULL, , "Invalid parameter!");
209
210         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
211                 if (modules[i]->refresh) {
212                         modules[i]->refresh(data);
213                 }
214         }
215 }
216
217 /******************************************************************
218  *
219  * Quickpanel open/close Events
220  *
221  ****************************************************************/
222 HAPI int quickpanel_modules_opened(void *data)
223 {
224         int i;
225
226         retif(data == NULL, QP_FAIL, "Invalid parameter!");
227
228         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
229                 if (modules[i]->qp_opened) {
230                         modules[i]->qp_opened(data);
231                 }
232         }
233
234         return QP_OK;
235 }
236
237 HAPI int quickpanel_modules_closed(void *data)
238 {
239         int i;
240
241         retif(data == NULL, QP_FAIL, "Invalid parameter!");
242
243         for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) {
244                 if (modules[i]->qp_closed) {
245                         modules[i]->qp_closed(data);
246                 }
247         }
248
249         return QP_OK;
250 }