f060ce82a0806f4a3f6917efe9a5db8cef701b48
[apps/core/preloaded/settings.git] / setting-livebox / src / setting-livebox.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #include <setting-livebox.h>
22
23 #ifndef UG_MODULE_API
24 #define UG_MODULE_API __attribute__ ((visibility("default")))
25 #endif
26
27
28 static void setting_livebox_ug_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
29 {
30         SettingLiveboxUG *ad = (SettingLiveboxUG *) data;
31         setting_view_update(&setting_view_livebox_main, ad);
32 }
33
34 static void *setting_livebox_ug_on_create(ui_gadget_h ug,
35                                            enum ug_mode mode, service_h service,
36                                            void *priv)
37 {
38         SETTING_TRACE_BEGIN;
39         setting_retvm_if((!priv), NULL, "!priv");
40
41         SettingLiveboxUG *liveboxUG = (SettingLiveboxUG *)priv;
42         liveboxUG->ug = ug;
43         liveboxUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
44         liveboxUG->win_get = (Evas_Object *) ug_get_window();
45         evas_object_show(liveboxUG->win_main_layout);
46         liveboxUG->evas = evas_object_evas_get(liveboxUG->win_main_layout);
47
48         setting_retvm_if(liveboxUG->win_main_layout == NULL, NULL,
49                          "cannot get main window ");
50
51         /* --------------------------------------------------------- */
52         /* set launguage */
53         appcore_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
54         /* --------------------------------------------------------- */
55         int ret = setting_cfg_init();
56         if(ret != 0)
57                 SETTING_TRACE_DEBUG("cfg_init failed. %d", ret);
58
59         /*  creating a view. */
60         setting_view_create(&setting_view_livebox_main,(void *)liveboxUG);
61         evas_object_event_callback_add(liveboxUG->win_main_layout,
62                                                EVAS_CALLBACK_RESIZE,
63                                                setting_livebox_ug_cb_resize,
64                                                liveboxUG);
65         return liveboxUG->ly_main;
66 }
67
68 static void setting_livebox_ug_on_start(ui_gadget_h ug, service_h service, void *priv)
69 {
70 }
71
72 static void setting_livebox_ug_on_pause(ui_gadget_h ug, service_h service, void *priv)
73 {
74 }
75
76 static void setting_livebox_ug_on_resume(ui_gadget_h ug, service_h service, void *priv)
77 {
78 }
79
80 static void setting_livebox_ug_on_destroy(ui_gadget_h ug, service_h service, void *priv)
81 {
82         SettingLiveboxUG *liveboxUG = (SettingLiveboxUG *)priv;
83
84         evas_object_event_callback_del(liveboxUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_livebox_ug_cb_resize); /* fix flash issue for gallery */
85         liveboxUG->ug = ug;
86
87         /*  delete the allocated objects. */
88         setting_view_destroy(&setting_view_livebox_main, liveboxUG);
89         if (NULL != ug_get_layout(liveboxUG->ug)) {
90                 evas_object_hide((Evas_Object *) ug_get_layout(liveboxUG->ug));
91                 evas_object_del((Evas_Object *) ug_get_layout(liveboxUG->ug));
92         }
93 }
94
95 static void setting_livebox_ug_on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
96 {
97
98 }
99
100 static void setting_livebox_ug_on_event(ui_gadget_h ug,
101                                          enum ug_event event, service_h service,
102                                          void *priv)
103 {
104         switch (event) {
105         case UG_EVENT_LOW_MEMORY:
106                 break;
107         case UG_EVENT_LOW_BATTERY:
108                 break;
109         case UG_EVENT_LANG_CHANGE:
110                 break;
111         case UG_EVENT_ROTATE_PORTRAIT:
112                 break;
113         case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
114                 break;
115         case UG_EVENT_ROTATE_LANDSCAPE:
116                 break;
117         case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
118                 break;
119         case UG_EVENT_REGION_CHANGE:
120                 break;
121         default:
122                 break;
123         }
124 }
125
126 static void setting_livebox_ug_on_key_event(ui_gadget_h ug,
127                                              enum ug_key_event event,
128                                              service_h service, void *priv)
129 {
130         if (!ug || !priv)
131                 return;
132
133         switch (event) {
134         case UG_KEY_EVENT_END:
135                 ug_destroy_me(ug);
136                 break;
137         default:
138                 break;
139         }
140 }
141
142 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
143 {
144         SettingLiveboxUG *liveboxUG = calloc(1, sizeof(SettingLiveboxUG));
145         setting_retvm_if(!liveboxUG, -1, "Create SettingPasswordUG obj failed");
146
147         ops->create = setting_livebox_ug_on_create;
148         ops->start = setting_livebox_ug_on_start;
149         ops->pause = setting_livebox_ug_on_pause;
150         ops->resume = setting_livebox_ug_on_resume;
151         ops->destroy = setting_livebox_ug_on_destroy;
152         ops->message = setting_livebox_ug_on_message;
153         ops->event = setting_livebox_ug_on_event;
154         ops->key_event = setting_livebox_ug_on_key_event;
155         ops->priv = liveboxUG;
156         ops->opt = UG_OPT_INDICATOR_ENABLE;
157
158         return 0;
159 }
160
161 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
162 {
163         struct SettingLiveboxUG *liveboxUG;
164         setting_retm_if(!ops, "ops == NULL");
165
166         liveboxUG = ops->priv;
167         if (liveboxUG)
168                 FREE(liveboxUG);
169 }