4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include "ug-module.h"
29 #include "ug-manager.h"
33 #define UG_API __attribute__ ((visibility("default")))
37 ui_gadget_h ug_root_create(void)
41 ug = calloc(1, sizeof(struct ui_gadget_s));
43 _ERR("ug root create failed: Memory allocation failed");
47 ug->mode = UG_MODE_FULLVIEW;
48 ug->state = UG_STATE_RUNNING;
56 int ug_free(ui_gadget_h ug)
59 _ERR("ug free failed: Invalid ug");
65 ug_module_unload(ug->module);
67 free((void *)ug->name);
70 if (ug->app_control) {
71 app_control_destroy(ug->app_control);
72 ug->app_control = NULL;
80 UG_API ui_gadget_h ug_create(ui_gadget_h parent,
83 app_control_h app_control, struct ug_cbs *cbs)
86 _ERR("ug_create() failed: Invalid name");
91 if (mode < UG_MODE_FULLVIEW || mode >= UG_MODE_INVALID) {
92 _ERR("ug_create() failed: Invalid mode");
97 return ugman_ug_load(parent, name, mode, app_control, cbs);
101 UG_API int ug_init(void *disp, unsigned long xid, void *win, enum ug_option opt)
103 if (!win || !xid || !disp) {
104 _ERR("ug_init() failed: Invalid arguments");
108 if (opt < UG_OPT_INDICATOR_ENABLE || opt >= UG_OPT_MAX) {
109 _ERR("ug_init() failed: Invalid option");
113 return ugman_init((Display *)disp, (Window)xid, win, opt);
117 /* LCOV_EXCL_START */
118 UG_API int ug_init(void *disp, unsigned long xid, void *win, enum ug_option opt)
120 if (opt < UG_OPT_INDICATOR_ENABLE || opt >= UG_OPT_MAX) {
121 _ERR("ug_init() failed: Invalid option");
125 return ugman_init(win, opt);
130 /* LCOV_EXCL_START */
131 UG_API int UG_INIT_EFL(void *win, enum ug_option opt)
133 return ug_init_efl((Evas_Object *)win, opt);
137 UG_API int ug_init_efl(Evas_Object *win, enum ug_option opt)
140 _ERR("ug_init_efl() failed: Invalid arguments");
144 if (opt < UG_OPT_INDICATOR_ENABLE || opt >= UG_OPT_MAX) {
145 _ERR("ug_init_efl() failed: Invalid option");
149 return ugman_init_efl(win, opt);
152 UG_API int ug_pause(void)
154 return ugman_pause();
157 UG_API int ug_pause_ug(ui_gadget_h ug)
159 if (!ug || !ugman_ug_exist(ug)) {
160 _ERR("ug_pause_ug() failed: Invalid ug");
165 return ugman_pause_ug(ug);
168 UG_API int ug_resume(void)
170 return ugman_resume();
173 UG_API int ug_resume_ug(ui_gadget_h ug)
175 if (!ug || !ugman_ug_exist(ug)) {
176 _ERR("ug_resume_ug() failed: Invalid ug");
181 return ugman_resume_ug(ug);
184 UG_API int ug_destroy(ui_gadget_h ug)
186 return ugman_ug_del(ug);
189 UG_API int ug_destroy_all(void)
191 return ugman_ug_del_all();
194 UG_API int ug_destroy_me(ui_gadget_h ug)
196 if (!ug || !ugman_ug_exist(ug)) {
197 _ERR("ug_destroy_me() failed: Invalid ug");
202 if (ug->state == UG_STATE_DESTROYING) {
203 _ERR("ug_destory_me() failed:ug(%p) is already on destroying", ug);
207 if (!ug->cbs.destroy_cb) {
208 _ERR("ug_destroy_me() failed: destroy callback does not "
213 ug->cbs.destroy_cb(ug, ug->cbs.priv);
217 UG_API void *ug_get_layout(ui_gadget_h ug)
219 if (!ug || !ugman_ug_exist(ug)) {
220 _ERR("ug_get_layout() failed: Invalid ug");
227 UG_API void *ug_get_parent_layout(ui_gadget_h ug)
230 if (!ug || !ugman_ug_exist(ug)) {
231 _ERR("ug_get_parent_layout() failed: Invalid ug");
239 return parent->layout;
243 UG_API enum ug_mode ug_get_mode(ui_gadget_h ug)
245 if (!ug || !ugman_ug_exist(ug)) {
246 _ERR("ug_get_mode() failed: Invalid ug");
248 return UG_MODE_INVALID;
254 UG_API void *ug_get_window(void)
256 return ugman_get_window();
259 UG_API void *ug_get_conformant(void)
261 return ugman_get_conformant();
264 UG_API int ug_send_event(enum ug_event event)
266 if (event <= UG_EVENT_NONE || event >= UG_EVENT_MAX) {
267 _ERR("ug_send_event() failed: Invalid event");
271 return ugman_send_event(event);
274 UG_API int ug_send_key_event(enum ug_key_event event)
276 if (event <= UG_KEY_EVENT_NONE || event >= UG_KEY_EVENT_MAX) {
277 _ERR("ug_send_key_event() failed: Invalid event");
281 return ugman_send_key_event(event);
284 UG_API int ug_send_result(ui_gadget_h ug, app_control_h send)
286 app_control_h send_dup = NULL;
288 if (!ug || !ugman_ug_exist(ug)) {
289 _ERR("ug_send_result() failed: Invalid ug");
294 if (!ug->cbs.result_cb) {
295 _ERR("ug_send_result() failed: result callback does not exist");
300 app_control_clone(&send_dup, send);
302 _ERR("ug_send_result() failed: app_control_destroy failed");
307 ug->cbs.result_cb(ug, send_dup, ug->cbs.priv);
310 app_control_destroy(send_dup);
315 UG_API int ug_send_result_full(ui_gadget_h ug, app_control_h send, app_control_result_e result)
317 app_control_h send_dup = NULL;
318 char tmp_result[4] = {0,};
320 if (!ug || !ugman_ug_exist(ug)) {
321 _ERR("ug_send_result() failed: Invalid ug");
326 if (!ug->cbs.result_cb) {
327 _ERR("ug_send_result() failed: result callback does not exist");
332 app_control_clone(&send_dup, send);
334 _ERR("ug_send_result() failed: app_control_destroy failed");
339 snprintf(tmp_result, 4, "%d", result);
341 app_control_add_extra_data(send_dup, UG_APP_CONTROL_DATA_RESULT, (const char*)tmp_result);
343 ug->cbs.result_cb(ug, send_dup, ug->cbs.priv);
346 app_control_destroy(send_dup);
351 UG_API int ug_send_message(ui_gadget_h ug, app_control_h msg)
355 app_control_h msg_dup = NULL;
357 app_control_clone(&msg_dup, msg);
359 _ERR("ug_send_message() failed: app_control_destroy failed");
364 r = ugman_send_message(ug, msg_dup);
367 app_control_destroy(msg_dup);
372 UG_API int ug_disable_effect(ui_gadget_h ug)
375 _ERR("ug input param is null");
378 if (ug->layout_state != UG_LAYOUT_INIT) {
379 _ERR("ug_disable_effect() failed: ug has already been shown");
382 ug->layout_state = UG_LAYOUT_NOEFFECT;
387 UG_API int ug_is_installed(const char *name)
390 char *ug_file_path = NULL;
393 _ERR("name is null");
397 if (ug_module_get_file_path(name, &ug_file_path) < 0)
406 #ifdef ENABLE_UG_CREATE_CB
407 UG_API int ug_create_cb(void (*create_cb)(char *, char *, char *, void *), void *user_data)
411 ret = ugman_create_cb(create_cb, user_data);
413 _ERR("trace cb register fail");