4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@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.
23 *@defgroup setting-datetime
24 *UG creation code for setting-datetime
28 * - Date and time (elm_datefield)
29 * - Time format (12H/24H)
32 #include <setting-time.h>
34 #define UG_MODULE_API __attribute__ ((visibility("default")))
38 * @callback handler for EVAS_CALLBACK_RESIZE
40 * @param data user data (SettingTimeUG *)
42 static void setting_time_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
45 SettingTimeUG *ad = (SettingTimeUG *) data;
46 setting_view_update(&setting_view_time_main, ad);
50 * @callback function called first while loading setting-time UG.
52 * @param ug ug object itself.
54 * @param data bundle (key, value pair) data as arguments into UG.
55 * @param priv SettingTimeUG context
59 static void *setting_time_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
60 service_h service, void *priv)
63 setting_retvm_if((!priv), NULL, "!priv");
65 SettingTimeUG *timeUG = priv;
67 timeUG->bundle_data = service;
68 timeUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
69 timeUG->win_get = (Evas_Object *) ug_get_window();
70 evas_object_show(timeUG->win_main_layout);
71 timeUG->evas = evas_object_evas_get(timeUG->win_main_layout);
73 timeUG->pop_progress = NULL;
74 /* Initialize Caller value */
75 timeUG->caller = NULL;
77 setting_retvm_if(timeUG->win_main_layout == NULL, NULL, "cannot get main window ");
79 /* --------------------------------------------------------- */
80 char *pa_path = NULL;;
82 pa_path = vconf_get_str(VCONFKEY_LANGSET);
84 SETTING_TRACE ("%s*** language setting has no proper value (nil) ***%s", SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
89 appcore_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
91 /* register view node table */
92 setting_view_node_table_intialize();
93 setting_view_node_table_register(&setting_view_time_main, NULL);
95 setting_create_Gendial_itc("dialogue/2text.3", &(timeUG->itc_2text_2));
96 setting_create_Gendial_itc("dialogue/1text.1icon",
97 &(timeUG->itc_1text_1icon));
99 setting_create_Gendial_itc("dialogue/1text.1icon.5", &(timeUG->itc_layout));
101 setting_create_Gendial_itc("dialogue/2text.3/expandable",
102 &(timeUG->itc_2text_3_parent));
103 setting_create_Gendial_itc("dialogue/1text.1icon/expandable2",
104 &(timeUG->itc_1icon_1text_sub));
106 timeUG->itc_seperator.item_style = "dialogue/separator/21/with_line";
107 timeUG->itc_seperator.func.text_get = NULL;
108 timeUG->itc_seperator.func.content_get = NULL;
109 timeUG->itc_seperator.func.state_get = NULL;
110 timeUG->itc_seperator.func.del = NULL;
112 /* creating a view. */
113 setting_view_node_set_cur_view(&setting_view_time_main);
114 setting_view_create(&setting_view_time_main, (void *)timeUG);
115 evas_object_event_callback_add(timeUG->win_main_layout,
116 EVAS_CALLBACK_RESIZE,
117 setting_time_ug_cb_resize, timeUG);
118 return timeUG->ly_main;
121 static void setting_time_ug_on_start(ui_gadget_h ug, service_h service,
128 static void setting_time_ug_on_pause(ui_gadget_h ug, service_h service,
135 static void setting_time_ug_on_resume(ui_gadget_h ug, service_h service,
141 static void setting_time_ug_on_destroy(ui_gadget_h ug, service_h service,
145 setting_retm_if((!priv), "!priv");
146 SettingTimeUG *timeUG = priv;
148 evas_object_event_callback_del(timeUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_time_ug_cb_resize); /* fix flash issue for gallery */
151 /* delete the allocated objects. */
152 setting_view_destroy(&setting_view_time_main, timeUG);
154 if (NULL != ug_get_layout(timeUG->ug)) {
155 evas_object_hide((Evas_Object *) ug_get_layout(timeUG->ug));
156 evas_object_del((Evas_Object *) ug_get_layout(timeUG->ug));
162 static void setting_time_ug_on_message(ui_gadget_h ug, service_h msg,
163 service_h service, void *priv)
168 static void setting_time_ug_on_event(ui_gadget_h ug, enum ug_event event,
169 service_h service, void *priv)
173 case UG_EVENT_LOW_MEMORY:
175 case UG_EVENT_LOW_BATTERY:
177 case UG_EVENT_LANG_CHANGE:
179 case UG_EVENT_ROTATE_PORTRAIT:
181 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
183 case UG_EVENT_ROTATE_LANDSCAPE:
185 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
187 case UG_EVENT_REGION_CHANGE:
195 * @brief key event handler for UG
197 static void setting_time_ug_on_key_event(ui_gadget_h ug,
198 enum ug_key_event event, service_h service,
202 SettingTimeUG *ad = (SettingTimeUG *) priv;
205 case UG_KEY_EVENT_END:
207 if (0 == safeStrCmp(ad->caller, "pwlock")) {
208 /* Create Bundle and send message */
211 if (service_create(&svc))
214 service_add_extra_data(svc, "result", "lbutton_click");
215 ug_send_result(ad->ug, svc);
217 service_destroy(svc);
220 if (elm_naviframe_top_item_get(ad->navi_bar) ==
221 elm_naviframe_bottom_item_get(ad->navi_bar)) {
224 /* elm_naviframe_item_pop(ad->navi_bar); */
225 setting_view_cb_at_endKey(ad);
235 * @brief UG entry point - create the SettingTimeUG context
238 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
241 SettingTimeUG *timeUG = calloc(1, sizeof(SettingTimeUG));
242 setting_retvm_if(!timeUG, -1, "Create SettingTimeUG obj failed");
244 ops->create = setting_time_ug_on_create;
245 ops->start = setting_time_ug_on_start;
246 ops->pause = setting_time_ug_on_pause;
247 ops->resume = setting_time_ug_on_resume;
248 ops->destroy = setting_time_ug_on_destroy;
249 ops->message = setting_time_ug_on_message;
250 ops->event = setting_time_ug_on_event;
251 ops->key_event = setting_time_ug_on_key_event;
253 ops->opt = UG_OPT_INDICATOR_ENABLE;
259 * @brief UG finalizer - destroy the SettingTimeUG context
261 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
264 struct SettingTimeUG *timeUG;
265 setting_retm_if(!ops, "ops == NULL");
273 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
275 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
279 #if SUPPORT_RUN_SYSTEM_COMMAND
280 ret += excuteCmd(SETTING_POSTINST_FILE, 1, "timeAndData");
282 ret += vconf_set_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, TRUE);
284 ret += vconf_set_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12);
285 ret += vconf_set_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, SETTING_DATE_FORMAT_DD_MM_YYYY);
286 ret += vconf_set_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, SETTING_WEEKOFDAY_FORMAT_SUNDAY);
288 ret += vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, "+9");
289 ret += vconf_set_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT, "IDS_WCL_BODY_CITYNAME_SEOUL");
291 /** @todo replace with vconf ID */
292 ret += vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, "Asia/Seoul");