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.
21 #include <setting-common-data-type.h>
22 #include <setting-common-data-slp-setting.h>
23 #include <setting-common-draw-widget.h>
25 #include <setting-personalpage-unlock.h>
26 #include <setting-debug.h>
29 static int setting_personalpage_unlock_create(void *cb);
30 static int setting_personalpage_unlock_destroy(void *cb);
31 static int setting_personalpage_unlock_update(void *cb);
32 static int setting_personalpage_unlock_cleanup(void *cb);
34 setting_view setting_view_personalpage_unlock = {
35 .create = setting_personalpage_unlock_create,
36 .destroy = setting_personalpage_unlock_destroy,
37 .update = setting_personalpage_unlock_update,
38 .cleanup = setting_personalpage_unlock_cleanup,
41 /* ***************************************************
45 ****************************************************/
47 static void setting_personalpage_unlock_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
51 setting_retm_if(data == NULL, "Data parameter is NULL");
53 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
54 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
55 elm_genlist_item_selected_set(item, 0);
56 Setting_GenGroupItem_Data *list_item =
57 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
59 SettingPersonalpageUG *ad = (SettingPersonalpageUG *) data;
61 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
63 if (!safeStrCmp("IDS_ST_BODY_SIMPLE_PASSWORD", list_item->keyStr))
65 // launch password ug for setting key.
66 setting_personalpage_create_password_sg(ad, SETTING_PERSONAL_PW_CALLER_UNLOCK_PIN);
68 else if (!safeStrCmp("IDS_COM_BODY_AUTH_PASSWORD", list_item->keyStr))
70 // launch password ug for setting key.
71 setting_personalpage_create_password_sg(ad, SETTING_PERSONAL_PW_CALLER_UNLOCK_PASSWORD);
75 static void setting_personalpage_unlock_click_radio_cb(void *data, Evas_Object *obj, void *event_info)
79 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
80 SettingPersonalpageUG *ad = (SettingPersonalpageUG *) list_item->userdata;
82 int selected = elm_radio_value_get(obj);
86 setting_personalpage_create_password_sg(ad, SETTING_PERSONAL_PW_CALLER_UNLOCK_PIN);
88 else if(selected == 2)
90 setting_personalpage_create_password_sg(ad, SETTING_PERSONAL_PW_CALLER_UNLOCK_PASSWORD);
95 vconf_get_int(VCONFKEY_SETAPPL_PERSONAL_MODE_UNLOCK_METHOD_INT, ¤t);
96 elm_radio_value_set(obj, current);
99 void __init_popup_resp_cb(void *data, Evas_Object *obj, void *event_info)
104 SettingPersonalpageUG *ad = (SettingPersonalpageUG *)data;
106 int response_type = btn_type(obj);
108 if(response_type == POPUP_RESPONSE_CANCEL)
110 SETTING_TRACE("CANCEL");
111 // if cancel, ug_destroy me
112 ug_destroy_me(ad->ug);
114 else if(response_type == POPUP_RESPONSE_OK)
122 evas_object_del(ad->init_popup);
123 ad->init_popup = NULL;
127 static int setting_personalpage_unlock_create(void *cb)
130 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
132 SettingPersonalpageUG *ad = (SettingPersonalpageUG *) cb;
134 Elm_Object_Item *item = NULL;
135 Evas_Object *genlist = NULL;
137 /* add basic layout */
138 char setBtnStr[MAX_DISPLAY_NAME_LEN_ON_UI];
139 snprintf(setBtnStr, sizeof(setBtnStr), "%s",
140 (char *)dgettext("sys_string", "IDS_COM_BODY_BACK"));
142 if(ad->viewtype == PERSONAL_VIEW_UNLOCK_METHOD)
144 ad->ly_main = setting_create_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get, "IDS_ST_MBODY_UNLOCK_METHOD",
146 (setting_call_back_func)setting_personalpage_unlock_click_softkey_back_cb,
154 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get, "IDS_ST_MBODY_UNLOCK_METHOD",
156 (setting_call_back_func)setting_personalpage_unlock_click_softkey_back_cb,
163 item = elm_genlist_item_append(genlist,
164 &itc_seperator, NULL, NULL,
165 ELM_GENLIST_ITEM_NONE, NULL, NULL);
166 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
168 Evas_Object *radio = elm_radio_add(genlist);
169 elm_radio_state_value_set(radio, -1);
170 ad->rd_option = radio;
173 ad->data_unlock_pin = setting_create_Gendial_field_1radio(genlist,
174 &(itc_1text_1icon_3),
175 setting_personalpage_unlock_mouse_up_Gendial_list_cb, /*add to sel_cb */
177 SWALLOW_Type_1RADIO_1BTN,
179 "IDS_ST_BODY_SIMPLE_PASSWORD",
180 setting_personalpage_unlock_click_radio_cb);
181 if(ad->data_unlock_pin)
183 ad->data_unlock_pin->userdata = ad;
184 ad->data_unlock_pin->group_style = SETTING_GROUP_STYLE_TOP;
187 ad->data_unlock_password = setting_create_Gendial_field_1radio(genlist,
188 &(itc_1text_1icon_3),
189 setting_personalpage_unlock_mouse_up_Gendial_list_cb, /*add to sel_cb */
191 SWALLOW_Type_1RADIO_1BTN,
193 "IDS_COM_BODY_AUTH_PASSWORD",
194 setting_personalpage_unlock_click_radio_cb);
195 if(ad->data_unlock_password)
197 ad->data_unlock_password->userdata = ad;
198 ad->data_unlock_password->group_style = SETTING_GROUP_STYLE_BOTTOM;
201 int unlock_method = -1;
202 vconf_get_int(VCONFKEY_SETAPPL_PERSONAL_MODE_UNLOCK_METHOD_INT, &unlock_method);
203 if(unlock_method > 0)
205 elm_radio_value_set(radio, unlock_method);
207 else if(ad->viewtype == PERSONAL_VIEW_UNLOCK_METHOD)
210 ad->init_popup = setting_create_popup_with_btn(ad, ad->navi_bar,
211 _("IDS_ST_HEADER_PERSONAL_MODE"),
212 _("IDS_ST_POP_TO_USE_PERSONAL_MODE_YOU_MUST_REGISTER_AN_UNLOCK_METHOD"),
213 __init_popup_resp_cb, 0,
215 "IDS_COM_SK_OK", "IDS_COM_SK_CANCEL");
219 setting_view_personalpage_unlock.is_create = 1;
221 return SETTING_RETURN_SUCCESS;
225 static int setting_personalpage_unlock_destroy(void *cb)
229 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
231 SettingPersonalpageUG *ad = (SettingPersonalpageUG *) cb;
233 if(ad->viewtype == PERSONAL_VIEW_UNLOCK_METHOD)
237 evas_object_del(ad->init_popup);
238 ad->init_popup = NULL;
241 if (ad->ly_main != NULL)
243 evas_object_del(ad->ly_main);
249 elm_naviframe_item_pop(ad->navi_bar);
251 setting_view_personalpage_unlock.is_create = 0;
253 return SETTING_RETURN_SUCCESS;
256 static int setting_personalpage_unlock_update(void *cb)
261 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
262 //SettingPersonalpageUG *ad = (SettingPersonalpageUG *) cb;
264 return SETTING_RETURN_SUCCESS;
267 static int setting_personalpage_unlock_cleanup(void *cb)
271 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
272 SettingPersonalpageUG *ad = (SettingPersonalpageUG *) cb;
274 if (ad->viewtype == PERSONAL_VIEW_UNLOCK_METHOD)
276 return SETTING_RETURN_SUCCESS;
280 return setting_personalpage_unlock_destroy(ad);
284 /* ***************************************************
288 ****************************************************/
291 setting_personalpage_unlock_click_softkey_back_cb(void *data, Elm_Object_Item *it)
294 retvm_if(data == NULL, EINA_TRUE, "[Setting > Security] Data parameter is NULL");
296 SettingPersonalpageUG *ad = (SettingPersonalpageUG *) data;
299 if (ad->viewtype == PERSONAL_VIEW_UNLOCK_METHOD)
301 ug_destroy_me(ad->ug);
306 setting_view_change(&setting_view_personalpage_unlock, &setting_view_personalpage_main, ad);