3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include <setting-menuscreen-password.h>
20 #define SETTING_PW_UG_NORMAL_PASSWORD_MIN_LENGTH 4
21 #define SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH 16
22 #define SETTING_PW_UG_PRIVACY_PASSWORD_MIN_LENGTH 4
23 #define SETTING_PW_UG_PRIVACY_PASSWORD_MAX_LENGTH 16
27 static int setting_menuscreen_password_create(void *cb);
28 static int setting_menuscreen_password_destroy(void *cb);
29 static int setting_menuscreen_password_update(void *cb);
30 static int setting_menuscreen_password_cleanup(void *cb);
33 setting_view setting_view_menuscreen_password = {
34 .create = setting_menuscreen_password_create,
35 .destroy = setting_menuscreen_password_destroy,
36 .update = setting_menuscreen_password_update,
37 .cleanup = setting_menuscreen_password_cleanup,
39 static Eina_Bool __focus_on_idler(void *data)
43 retv_if(data == NULL, FALSE);
45 SettingMenuscreenUG *ad = (SettingMenuscreenUG *) data;
46 retv_if(ad->data_pwd == NULL, EINA_FALSE);
47 if (ad->data_pwd->isFocusFlag || (ad->data_pwd->eo_check != NULL))
49 //no matter how many edifileds, it only need focus on 1st editfiled
50 elm_object_focus_set(ad->data_pwd->eo_check, EINA_TRUE);
54 return ECORE_CALLBACK_CANCEL;
58 static int setting_menuscreen_password_create(void *cb)
61 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
63 SettingMenuscreenUG *ad = (SettingMenuscreenUG *) cb;
64 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
65 elm_object_style_set(scroller, "dialogue");
67 return SETTING_RETURN_FAIL;
69 elm_genlist_clear(scroller); /* first to clear list */
70 elm_genlist_homogeneous_set(scroller, EINA_TRUE);
72 ad->navi_it = setting_create_navi_bar_top_buttons(_("IDS_COM_BODY_AUTH_PASSWORD"),
73 _("IDS_COM_SK_CANCEL"),
74 _("IDS_COM_SK_DONE"), NULL,
75 setting_menuscreen_password_click_softkey_back_cb,
76 setting_menuscreen_password_click_softkey_done_cb,
77 NULL, ad, scroller, ad->navi_bar);
78 retv_if(!ad->navi_it, SETTING_RETURN_FAIL);
79 Evas_Object *done_btn = elm_object_item_part_content_get(ad->navi_it, "title_right_btn");
80 setting_disable_evas_object(done_btn);
81 setting_dim_evas_object(done_btn, TRUE);
83 Elm_Object_Item *item = NULL;;
84 item =elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
85 ELM_GENLIST_ITEM_NONE, NULL, NULL);
86 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
88 //---------------------------------------------------------------------
89 // draw password UG code
90 //---------------------------------------------------------------------
92 setting_create_Gendial_field_entry(scroller,
95 SWALLOW_Type_LAYOUT_ENTRY,
97 "IDS_COM_BODY_PASSWORD",
99 setting_menuscreen_password_entry_change_cb,
100 ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
102 SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH,
104 elm_object_focus_set(ad->data_pwd->eo_check, EINA_TRUE);
105 ecore_idler_add(__focus_on_idler, ad);
107 setting_view_menuscreen_password.is_create = 1;
108 return SETTING_RETURN_SUCCESS;
111 static int setting_menuscreen_password_destroy(void *cb)
115 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
117 SettingMenuscreenUG *ad = (SettingMenuscreenUG *) cb;
118 elm_naviframe_item_pop(ad->navi_bar);
120 setting_view_menuscreen_password.is_create = 0;
121 return SETTING_RETURN_SUCCESS;
125 static int setting_menuscreen_password_update(void *cb)
127 return SETTING_RETURN_SUCCESS;
130 static int setting_menuscreen_password_cleanup(void *cb)
134 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
135 return setting_menuscreen_password_destroy(cb);
138 /* ***************************************************
142 ***************************************************/
144 setting_menuscreen_password_click_softkey_back_cb(void *data, Evas_Object *obj,
149 setting_retm_if(data == NULL,
150 "[Setting > Menuscreen] Data parameter is NULL");
152 SettingMenuscreenUG *ad = (SettingMenuscreenUG *) data;
154 /* Send destroy request */
155 setting_view_change(&setting_view_menuscreen_password, &setting_view_menuscreen_main, ad);
161 setting_menuscreen_password_click_softkey_done_cb(void *data, Evas_Object *obj,
166 retm_if(data == NULL, "[Setting > Password] Data parameter is NULL");
168 SettingMenuscreenUG *ad = (SettingMenuscreenUG *) data;
169 const char *entry_str = ad->data_pwd->sub_desc;
170 if (0 == safeStrCmp(entry_str, SETTING_PW_STR))
172 // choose the value from radio button state.
173 vconf_set_str( VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, ad->selected_theme);
174 ug_destroy_me(ad->ug);
178 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_INCORRECT_PASSWORD"),NULL, 2, FALSE, FALSE);
179 ad->data_pwd->sub_desc = NULL;
180 elm_entry_entry_set(obj, ad->data_pwd->sub_desc);
181 elm_entry_cursor_end_set(obj);
182 elm_object_focus_set(ad->data_pwd->eo_check, EINA_TRUE);
187 static void setting_menuscreen_password_entry_change_cb (void *data, Evas_Object *obj, void *event_info)
189 retm_if(data == NULL, "[Setting > Password] Data parameter is NULL");
190 Setting_GenGroupItem_Data *list_item =
191 (Setting_GenGroupItem_Data *) data;
192 SettingMenuscreenUG *ad = (SettingMenuscreenUG *) list_item->userdata;
193 const char *entry_str = elm_entry_entry_get(obj);
194 /* SETTING_TRACE("entry_str:%s", entry_str); */
195 list_item->sub_desc = (char *)g_strdup(entry_str);
197 /* Evas_Object *eo_entry = NULL; */
198 bool isFoundEmptyEntry = FALSE;
202 entry_str = ad->data_pwd->sub_desc;
203 if (NULL == entry_str || '\0' == entry_str[0]) {
204 isFoundEmptyEntry = TRUE;
211 bool disableFlag = isFoundEmptyEntry;
213 Evas_Object *done_btn = elm_object_item_part_content_get(ad->navi_it, "title_right_btn");
215 if (!evas_object_pass_events_get(done_btn)) {//it had not yet been disabled
216 setting_disable_evas_object(done_btn);
217 setting_dim_evas_object(done_btn, TRUE);
218 }//else already disabled
220 setting_enable_evas_object(done_btn);
221 setting_undo_dim_evas_object(done_btn, TRUE);