Code sync
[apps/native/starter.git] / lock-setting / lockapp-setting / src / openlock-setting.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://www.tizenopensource.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
18
19 #ifndef UG_MODULE_API
20 #define UG_MODULE_API __attribute__ ((visibility("default")))
21 #endif
22
23 #include <Elementary.h>
24 #include <ui-gadget-module.h>
25
26 #include "openlock-setting.h"
27 #include "openlock-setting-util.h"
28 #include "openlock-setting-main.h"
29
30 static Evas_Object *create_bg(Evas_Object * parent)
31 {
32         Evas_Object *bg = elm_bg_add(parent);
33
34         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
35                                          EVAS_HINT_EXPAND);
36         elm_object_style_set(bg, "group_list");
37
38         elm_object_part_content_set(parent, "elm.swallow.bg", bg);
39         evas_object_show(bg);
40
41         return bg;
42 }
43
44 static Evas_Object *create_fullview(Evas_Object * parent,
45                                     openlock_ug_data * openlock_data)
46 {
47         Evas_Object *base = NULL;
48         Evas_Object *navi_bar = NULL;
49         Evas_Object *bg = NULL;
50
51         base = openlock_setting_util_create_layout(parent);
52
53         elm_layout_theme_set(base, "layout", "application", "default");
54         elm_win_resize_object_add(parent, base);
55         elm_win_indicator_mode_set(parent, ELM_WIN_INDICATOR_SHOW);
56
57         bg = create_bg(base);
58
59         navi_bar = openlock_setting_util_create_navigation(base);
60         openlock_data->navi_bar = navi_bar;
61
62         openlock_setting_main_create_view(openlock_data);
63
64         return base;
65 }
66
67 static Evas_Object *create_frameview(Evas_Object * parent,
68                                      openlock_ug_data * openlock_data)
69 {
70         Evas_Object *base = NULL;
71
72         /* Create Frame view */
73
74         return base;
75 }
76
77 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service,
78                        void *priv)
79 {
80         Evas_Object *parent = NULL;
81         Evas_Object *win_main = NULL;
82         openlock_ug_data *openlock_data = NULL;
83
84         if (!ug || !priv)
85                 return NULL;
86
87         bindtextdomain("openlock-setting", "/opt/ug/res/locale");
88
89         openlock_data = priv;
90         openlock_data->ug = ug;
91
92         parent = ug_get_parent_layout(ug);
93         if (!parent)
94                 return NULL;
95
96         win_main = ug_get_window();
97         if (!win_main) {
98                 return NULL;
99         }
100
101         openlock_data->win_main = win_main;
102
103         if (mode == UG_MODE_FULLVIEW)
104                 openlock_data->base = create_fullview(parent, openlock_data);
105         else
106                 openlock_data->base = create_frameview(parent, openlock_data);
107
108         /* Add del callback for base layout */
109
110         return openlock_data->base;
111 }
112
113 static void on_start(ui_gadget_h ug, service_h service, void *priv)
114 {
115 }
116
117 static void on_pause(ui_gadget_h ug, service_h service, void *priv)
118 {
119
120 }
121
122 static void on_resume(ui_gadget_h ug, service_h service, void *priv)
123 {
124
125 }
126
127 static void on_destroy(ui_gadget_h ug, service_h service, void *priv)
128 {
129         openlock_ug_data *openlock_data;
130
131         if (!ug || !priv)
132                 return;
133
134         openlock_data = priv;
135         evas_object_del(openlock_data->base);
136         openlock_data->base = NULL;
137 }
138
139 static void on_message(ui_gadget_h ug, service_h msg, service_h service,
140                        void *priv)
141 {
142 }
143
144 static void on_event(ui_gadget_h ug, enum ug_event event, service_h service,
145                      void *priv)
146 {
147         switch (event) {
148         case UG_EVENT_LOW_MEMORY:
149                 break;
150         case UG_EVENT_LOW_BATTERY:
151                 break;
152         case UG_EVENT_LANG_CHANGE:
153                 break;
154         case UG_EVENT_ROTATE_PORTRAIT:
155                 break;
156         case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
157                 break;
158         case UG_EVENT_ROTATE_LANDSCAPE:
159                 break;
160         case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
161                 break;
162         default:
163                 break;
164         }
165 }
166
167 static void on_key_event(ui_gadget_h ug, enum ug_key_event event,
168                          service_h service, void *priv)
169 {
170         if (!ug)
171                 return;
172
173         switch (event) {
174         case UG_KEY_EVENT_END:
175                 ug_destroy_me(ug);
176                 break;
177         default:
178                 break;
179         }
180 }
181
182 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
183 {
184         openlock_ug_data *openlock_data;
185
186         if (!ops)
187                 return -1;
188
189         openlock_data = calloc(1, sizeof(openlock_ug_data));
190         if (!openlock_data)
191                 return -1;
192
193         ops->create = on_create;
194         ops->start = on_start;
195         ops->pause = on_pause;
196         ops->resume = on_resume;
197         ops->destroy = on_destroy;
198         ops->message = on_message;
199         ops->event = on_event;
200         ops->key_event = on_key_event;
201         ops->priv = openlock_data;
202         ops->opt = UG_OPT_INDICATOR_ENABLE;
203
204         return 0;
205 }
206
207 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
208 {
209         openlock_ug_data *openlock_data;
210
211         if (!ops)
212                 return;
213
214         openlock_data = ops->priv;
215         if (openlock_data)
216                 free(openlock_data);
217 }