3 Copyright (c) 2000-2012 Samsung Electronics Co., Ltd All Rights Reserved
5 This file is part of org.tizen.efl-calendar
6 Written by Taeho Kang <taeho84.kang@samsung.com>
8 PROPRIETARY/CONFIDENTIAL
10 This software is the confidential and proprietary information of
11 SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
12 disclose such Confidential Information and shall use it only in
13 accordance with the terms of the license agreement you entered
14 into with SAMSUNG ELECTRONICS.
16 SAMSUNG make no representations or warranties about the suitability
17 of the software, either express or implied, including but not limited
18 to the implied warranties of merchantability, fitness for a particular
19 purpose, or non-infringement. SAMSUNG shall not be liable for any
20 damages suffered by licensee as a result of using, modifying or
21 distributing this software or its derivatives.
26 #include <ui-gadget-module.h>
29 #include <vconf-keys.h>
32 #include "ug-settings.h"
33 #include "ug-settings-view.h"
35 extern int appcore_set_i18n(const char *, const char *);
37 static void __cal_setting_ug_back_button_callback(void *data, Evas_Object *obj, void *event_info)
39 struct ug_data *ugd = data;
40 evas_object_hide(ugd->bg);
41 ug_destroy_me(ugd->ug);
44 static void __cal_setting_ug_initialize(struct ug_data *ugd)
48 char *tz_offset = NULL;
51 ret = cal_util_get_timezone_info(&tz_path, &tz_city, &tz_offset);
52 c_warn_if(ret, "cal_util_get_timezone_info is failed");
55 ugd->city = strdup(tz_city);
57 ERR("tz_city is null");
58 ugd->city = strdup("IDS_WCL_BODY_CITYNAME_SEOUL");
59 c_warn_if(!ugd->city, "ugd->city is null");
63 ugd->time_zone = strdup(tz_offset);
65 ERR("tz_offset is null");
66 ugd->time_zone = strdup("GMT+9");
67 c_warn_if(!ugd->time_zone, "ugd->city is null");
77 ret = vconf_get_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF, &ugd->is_on);
78 c_warn_if(ret, "vconf_get_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF, &ugd->is_on) is failed");
80 if (0 != vconf_get_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT,&ugd->is_monday))
82 ret = vconf_set_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, 1);
83 c_warn_if(ret != 0,"vconf_set_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, 0) is failed(%d)", ret);
86 if (0 != vconf_get_int(CAL_VCONFKEY_FOCUS_VIEW,&ugd->is_daily))
88 ret = vconf_set_int(CAL_VCONFKEY_FOCUS_VIEW, 1);
89 c_warn_if(ret != 0,"vconf_set_int(CAL_VCONFKEY_FOCUS_VIEW, 0) is failed(%d)", ret);
93 static Evas_Object *__cal_setting_ug_create_layout(Evas_Object *parent, struct ug_data *ugd)
95 Evas_Object *bt_back = NULL;
96 Evas_Object *layout = NULL;
97 Elm_Object_Item* navi_item = NULL;
99 ugd->base = cal_util_add_layout(parent, NULL);
100 CAL_ASSERT(ugd->base);
102 ugd->bg = cal_util_add_bg(ugd->base, EINA_FALSE);
105 ugd->nv = elm_naviframe_add(ugd->base);
108 layout = cal_setting_ug_create_view(ugd->nv, ugd);
111 navi_item = elm_naviframe_item_push(ugd->nv, "Calendar", NULL, NULL, layout, NULL);
113 bt_back = elm_object_item_part_content_get(navi_item, "prev_btn");
116 bt_back = elm_button_add(ugd->nv);
117 elm_object_item_part_content_set(navi_item, "prev_btn", bt_back);
119 elm_object_style_set(bt_back, "naviframe/back_btn/default");
120 evas_object_smart_callback_add(bt_back, "clicked", __cal_setting_ug_back_button_callback, ugd);
122 elm_object_part_content_set(ugd->base, "elm.swallow.content", ugd->nv);
123 elm_object_part_content_set(ugd->base, "elm.swallow.bg", ugd->bg);
128 static void *__cal_setting_ug_create_callback(struct ui_gadget *ug, enum ug_mode mode, bundle *data, void *priv)
137 cal_util_connect_pattern_generator();
141 __cal_setting_ug_initialize(ugd);
142 if (mode != UG_MODE_FULLVIEW)
144 parent = ug_get_parent_layout(ug);
148 base = __cal_setting_ug_create_layout(parent, ugd);
149 c_retvm_if(!base, NULL, "base is null");
154 static void __cal_setting_ug_destroy_callback(struct ui_gadget *ug, bundle *data, void *priv)
163 cal_util_delete_evas_object(&ugd->base);
166 static void __cal_setting_ug_key_callback(struct ui_gadget *ug, enum ug_key_event evt,
167 bundle *data, void *priv)
172 DBG("UG: key event %d", evt);
175 case UG_KEY_EVENT_END:
183 static inline void __cal_setting_ug_bind_text_domain()
187 r = bindtextdomain(UGSETTINGS, UGLOCALE);
189 ERR("UG: bindtextdomain error");
192 API int setting_plugin_reset(bundle *data, void *priv)
198 ret = CALENDAR_SVC_CONNECT();
199 c_warn_if(ret != CAL_SUCCESS, "CALENDAR_SVC_CONNECT is failed(%d)", ret);
201 ret = vconf_set_int(CAL_VCONFKEY_FOCUS_VIEW, 0);
202 c_warn_if(ret != 0, "vconf_set_int(CAL_VCONFKEY_FOCUS_VIEW, 0) is failed(%d)", ret);
204 ret = vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF, 0);
205 c_warn_if(ret != 0, "vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_ON_OFF, 0) is failed(%d)", ret);
207 ret = vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_PATH, "Asia/Seoul");
208 c_warn_if(ret != 0, "vconf_set_int(CAL_VCONFKEY_LOCK_TIMEZONE_PATH, 'Seoul') is failed(%d)", ret);
210 ret = vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_CITY, "IDS_WCL_BODY_CITYNAME_SEOUL");
211 c_warn_if(ret != 0, "vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_CITY, tzpath) is failed");
213 ret = vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_OFFSET, "+9");
214 c_warn_if(ret != 0, "vconf_set_str(CAL_VCONFKEY_LOCK_TIMEZONE_OFFSET, tzpath) is failed");
216 ret = CALENDAR_SVC_DELETE_ALL(ALL_ACCOUNT_ID, NULL);
217 c_warn_if(ret != CAL_SUCCESS, "CALENDAR_SVC_DELETE_ALL(ALL_ACCOUNT_ID, NULL) is failed(%d)", ret);
219 ret = CALENDAR_SVC_DISCONNECT();
220 c_warn_if(ret != CAL_SUCCESS, "CALENDAR_SVC_DISCONNECT is failed(%d)", ret);
225 API int UG_MODULE_INIT(struct ug_module_ops *ops)
232 CAL_CALLOC(ugd, 1, struct ug_data);
234 ops->create = __cal_setting_ug_create_callback;
235 ops->destroy = __cal_setting_ug_destroy_callback;
236 ops->key_event = __cal_setting_ug_key_callback;
238 ops->opt = UG_OPT_INDICATOR_PORTRAIT_ONLY;
240 __cal_setting_ug_bind_text_domain();
242 appcore_set_i18n(CALENDAR_PACKAGE, LOCALEDIR);
247 API void UG_MODULE_EXIT(struct ug_module_ops *ops)
251 cal_util_disconnect_pattern_generator();