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