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.
22 #include <sys/socket.h>
26 #include <setting-password.h>
27 #include <setting-password-forgot-password.h>
29 static int setting_password_forgot_password_create(void *cb);
30 static int setting_password_forgot_password_destroy(void *cb);
31 static int setting_password_forgot_password_update(void *cb);
32 static int setting_password_forgot_password_cleanup(void *cb);
34 setting_view setting_view_password_forgot_password = {
35 .create = setting_password_forgot_password_create,
36 .destroy = setting_password_forgot_password_destroy,
37 .update = setting_password_forgot_password_update,
38 .cleanup = setting_password_forgot_password_cleanup,
41 void __reset_personal_popup_resp_cb(void *data, Evas_Object *obj, void *event_info)
46 SettingPasswordUG *ad = (SettingPasswordUG *)data;
48 char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
49 if (!safeStrCmp(btn_str, _(PW_ST_RESET))) {
52 if (ode_init() == 0) {
54 SETTING_TRACE("pse_restore() returns %d", ret);
56 /* initialize vconf */
57 vconf_set_int(VCONFKEY_SETAPPL_PERSONAL_MODE_UNLOCK_METHOD_INT, -1);
58 vconf_set_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, 0);
61 /* send resunt to personal mode ug */
63 if (!app_control_create(&svc)) {
64 app_control_add_extra_data(svc, "result", "Restore");
65 ug_send_result(ad->ug, svc);
66 app_control_destroy(svc);
68 ug_destroy_me(ad->ug);
72 if (ad->reset_personal_popup) {
73 evas_object_del(ad->reset_personal_popup);
74 ad->reset_personal_popup = NULL;
78 static void __launch_lockscreen(void)
81 struct sockaddr_un saddr;
85 fd = socket(AF_UNIX, SOCK_STREAM, 0);
87 fd = socket(AF_UNIX, SOCK_STREAM, 0);
89 SETTING_TRACE("socket() failed");
93 bzero(&saddr, sizeof(saddr));
94 saddr.sun_family = AF_UNIX;
95 strncpy(saddr.sun_path, "/tmp/phlock", strlen("/tmp/phlock"));
96 saddr.sun_path[strlen("/tmp/phlock")] = 0;
98 SETTING_TRACE("saddr.sun_path = %s", saddr.sun_path);
100 if (connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
107 SETTING_TRACE("connect() failed");
110 char *cmd = "launch_phone_lock";
111 int len = strlen(cmd);
112 send(fd, cmd, len, 0);
115 static void setting_password_forgot_password_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
119 setting_retm_if(data == NULL, "Data parameter is NULL");
120 SettingPasswordUG *ad = (SettingPasswordUG *)data;
122 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
123 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
124 elm_genlist_item_selected_set(item, 0);
125 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
127 SETTING_TRACE("%s clicked", list_item->keyStr);
128 if (!safeStrCmp(list_item->keyStr, PW_ST_RESET_PERSONAL_MODE)) {
129 /* if lock type is simple password or password, call lockscreen. */
130 int screen_lock_type = 0;
131 vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &screen_lock_type);
132 if (screen_lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD
133 || screen_lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
134 /* call lockscreen app */
135 __launch_lockscreen();
137 /*ret = aul_launch_app("org.tizen.lockscreen", NULL); */
138 /*SETTING_TRACE("aul_launch_app() returns %d", ret); */
142 ad->reset_personal_popup = setting_create_popup(ad, ad->win_get,
143 PW_ST_RESET_PERSONAL_MODE,
144 PW_ST_RESET_PERSONAL_MODE_POPUP_Q,
145 __reset_personal_popup_resp_cb, 0, FALSE, FALSE,
146 2, PW_ST_RESET, PW_ST_CANCEL);
150 static Eina_Bool __forgot_password_pop_cb(void *data, Elm_Object_Item *it)
154 setting_view_change(&setting_view_password_forgot_password, &setting_view_password_main, data);
159 static int setting_password_forgot_password_create(void *cb)
163 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
165 SettingPasswordUG *ad = (SettingPasswordUG *) cb;
167 Evas_Object *genlist = NULL;
168 Elm_Object_Item *navi_it = NULL;
170 navi_it = setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
171 PW_ST_FORGOT_PASSWORD,
172 NULL, NULL, NULL, NULL, NULL,
173 &genlist, ad->navi_bar);
175 elm_naviframe_item_pop_cb_set(navi_it, (Elm_Naviframe_Item_Pop_Cb)__forgot_password_pop_cb, ad);
178 Elm_Object_Item *item = elm_genlist_item_append(genlist,
179 &itc_seperator, NULL, NULL,
180 ELM_GENLIST_ITEM_NONE, NULL, NULL);
182 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
185 setting_create_Gendial_field_def(genlist, &(itc_1text),
186 setting_password_forgot_password_mouse_up_Gendial_list_cb, ad,
187 SWALLOW_Type_INVALID,
189 0, PW_ST_RESET_PERSONAL_MODE, NULL, NULL);
192 ADD_GL_HELP(genlist, PW_ST_RESET_PERSONAL_MODE_HELP);
196 setting_view_password_forgot_password.is_create = 1;
199 return SETTING_RETURN_SUCCESS;
202 static int setting_password_forgot_password_destroy(void *cb)
206 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
208 setting_view_password_forgot_password.is_create = 0;
211 return SETTING_RETURN_SUCCESS;
214 static int setting_password_forgot_password_update(void *cb)
218 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
220 SettingPasswordUG *ad = (SettingPasswordUG *) cb;
222 if (ad->ly_main != NULL) {
223 evas_object_show(ad->ly_main);
226 return SETTING_RETURN_SUCCESS;
229 static int setting_password_forgot_password_cleanup(void *cb)
232 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
234 return setting_password_forgot_password_destroy(cb);
237 /* ***************************************************
241 ***************************************************/