tizen 2.3.1 release
[apps/home/settings.git] / setting-security / src / setting-security-locktype.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #include <setting-common-data-type.h>
22 #include <setting-common-data-slp-setting.h>
23 #include <setting-common-draw-widget.h>
24 #include <setting-common-view.h>
25
26 #include <setting-security-locktype.h>
27 #include <setting-security.h>
28 #include <setting-debug.h>
29 #include <security-server.h>
30 #include <ail.h>
31 #include <efl_assist.h>
32 #include <ode.h>
33
34 #define TBD 0
35
36 static int setting_security_locktype_create(void *cb);
37 static int setting_security_locktype_destroy(void *cb);
38 static int setting_security_locktype_update(void *cb);
39 static int setting_security_locktype_cleanup(void *cb);
40 static void __record_btn_click_cb(void *data, Evas_Object *obj, void *event_info);
41 setting_view setting_view_security_locktype = {
42         .create = setting_security_locktype_create,
43         .destroy = setting_security_locktype_destroy,
44         .update = setting_security_locktype_update,
45         .cleanup = setting_security_locktype_cleanup,
46 };
47
48 openlock_appdata *lockapp_data = NULL;
49
50 /* ***************************************************
51  **
52  **basic func
53  **
54  ****************************************************/
55
56 static int __get_lockapp_index_from_pkgname(char *pkg_name)
57 {
58         SETTING_TRACE_BEGIN;
59         if (pkg_name == NULL)
60                 return SETTING_RETURN_FAIL;
61
62         openlock_appdata *item = lockapp_data;
63         for (; item != NULL; item = item->next) {
64                 if (safeStrCmp(item->pkg_name, pkg_name) == 0)
65                         return item->index;
66         }
67         return SETTING_RETURN_FAIL;
68 }
69 static int __get_lockapp_index_from_appname(char *app_name)
70 {
71         SETTING_TRACE_BEGIN;
72         if (app_name == NULL)
73                 return SETTING_RETURN_FAIL;
74
75         openlock_appdata *item = lockapp_data;
76         for (; item != NULL; item = item->next) {
77                 if (safeStrCmp(item->app_name, app_name) == 0)
78                         return item->index;
79         }
80         return SETTING_RETURN_FAIL;
81 }
82 static char *__get_lockapp_pkgname_from_appname(char *app_name)
83 {
84         SETTING_TRACE_BEGIN;
85         if (app_name == NULL)
86                 return NULL;
87
88         openlock_appdata *item = lockapp_data;
89         for (; item != NULL; item = item->next) {
90                 if (safeStrCmp(item->app_name, app_name) == 0)
91                         return item->app_name;
92         }
93         return NULL;
94 }
95
96 ail_cb_ret_e __get_appinfo_cb(const ail_appinfo_h appinfo, void *user_data)
97 {
98         SETTING_TRACE_BEGIN;
99
100         openlock_appdata *item = lockapp_data;
101         openlock_appdata *new_item = NULL;
102         char *pkg_name = NULL;
103         char *app_name = NULL;
104
105         ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &pkg_name);
106         ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &app_name);
107
108         while (item->next != NULL)
109                 item = item->next;
110
111         if (item->index == 0 && item->pkg_name == NULL) {
112                 /* first app */
113                 item->pkg_name = strdup(pkg_name);
114                 item->app_name = strdup(app_name);
115
116                 SETTING_TRACE_DEBUG("app info %d %s %s", item->index, item->pkg_name, item->app_name);
117         } else {
118                 /* create new */
119                 new_item = (openlock_appdata *)malloc(sizeof(openlock_appdata));
120                 if (new_item != NULL) {
121                         memset(new_item, 0x00, sizeof(openlock_appdata));
122                         new_item->pkg_name = strdup(pkg_name);
123                         new_item->app_name = strdup(app_name);
124                         new_item->index = item->index + 1;
125                         new_item->prev = item;
126                         item->next = new_item;
127
128                         SETTING_TRACE_DEBUG("app info %d %s %s", new_item->index, new_item->pkg_name, new_item->app_name);
129                 } else {
130                         SETTING_TRACE_DEBUG("malloc() failed");
131                 }
132         }
133         return AIL_CB_RET_CONTINUE;
134 }
135
136 static void __add_3rd_party_lock(void *data)
137 {
138         SETTING_TRACE_BEGIN;
139         ret_if(data == NULL);
140
141         SettingSecurityUG *ad = (SettingSecurityUG *) data;
142
143         /* Get info from AIL */
144         ail_filter_h filter;
145         ail_error_e ret;
146         int count = 0;
147
148         ret = ail_filter_new(&filter);
149         if (ret != AIL_ERROR_OK) {
150                 SETTING_TRACE_DEBUG("ail_filter_new() failed");
151                 return;
152         }
153         ret = ail_filter_add_str(filter, AIL_PROP_CATEGORIES_STR, "lockscreen");
154         ret = ail_filter_count_appinfo(filter, &count);
155         SETTING_TRACE_DEBUG("There is/are %d 3rd lock app(s)", count);
156         if (count <= 0) {
157                 SETTING_TRACE_DEBUG("No 3rd lock app");
158                 ail_filter_destroy(filter);
159                 return;
160
161         }
162
163         lockapp_data = (openlock_appdata *)malloc(sizeof(openlock_appdata));
164         if (lockapp_data == NULL) {
165                 SETTING_TRACE_DEBUG("malloc() failed");
166                 return;
167         }
168         memset(lockapp_data, 0x00, sizeof(openlock_appdata));
169         lockapp_data->prev = NULL;
170         lockapp_data->next = NULL;
171         lockapp_data->pkg_name = NULL;
172         lockapp_data->app_name = NULL;
173         lockapp_data->index = 0;
174
175         ail_filter_list_appinfo_foreach(filter, __get_appinfo_cb, ad);
176         ail_filter_destroy(filter);
177
178         /* Add to genlist */
179         openlock_appdata *list = lockapp_data;
180         int index = 0;
181         for (index = 0; index < count; index++) {
182                 ad->data_locktype_3rd[index] = setting_create_Gendial_field_1radio(ad->sl_scroller,
183                                                                                    &(itc_1text_1icon_3),
184                                                                                    setting_security_locktype_mouse_up_Gendial_list_cb,  /*add to sel_cb */
185                                                                                    ad,  /* sel data */
186                                                                                    SWALLOW_Type_1RADIO,
187                                                                                    ad->lock_type_rd, SETTING_SCREEN_LOCK_TYPE_OTHER + index,
188                                                                                    list->app_name,
189                                                                                    NULL);
190                 if (ad->data_locktype_3rd[index]) {
191                         ad->data_locktype_3rd[index]->userdata = ad;
192                 } else {
193                         SETTING_TRACE_ERROR("item_data is NULL");
194                 }
195                 list = list->next;
196         }
197         SETTING_TRACE_END;
198 }
199
200 bool __voice_recorder_destroy(recorder_h handle)
201 {
202         SETTING_TRACE_BEGIN;
203         if (handle == 0) {
204                 SETTING_TRACE("Camcorder is already destroyed");
205                 return TRUE;
206         }
207
208         /*recorder_unset_recording_limit_reached_cb(handle); */
209         /*recorder_unset_recording_status_cb(handle); */
210         /*recorder_unset_state_changed_cb(handle); */
211
212         recorder_state_e rec_state = RECORDER_STATE_NONE;
213         recorder_get_state(handle, &rec_state);
214         if (rec_state == RECORDER_STATE_PAUSED || rec_state == RECORDER_STATE_RECORDING)
215                 recorder_cancel(handle);
216
217         recorder_get_state(handle, &rec_state);
218         if (rec_state == RECORDER_STATE_READY)
219                 recorder_unprepare(handle);
220
221         recorder_get_state(handle, &rec_state);
222         if (rec_state == RECORDER_STATE_CREATED)
223                 recorder_destroy(handle);
224
225         return TRUE;
226 }
227
228 recorder_h  __voice_recorder_create()
229 {
230         SETTING_TRACE_BEGIN;
231         recorder_h handle = NULL;
232
233         int mmf_ret = recorder_create_audiorecorder(&handle);
234         if (mmf_ret != RECORDER_ERROR_NONE) {
235                 SETTING_TRACE_ERROR("recorder_create_audiorecorder Error : %x", mmf_ret);
236                 return NULL;
237         }
238
239
240         SETTING_TRACE("Set attribut of recorder");
241         /*recorder_set_state_changed_cb(handle, cbs->state_changed_cb, cb_data); */
242         /*recorder_set_recording_status_cb(handle, cbs->recording_status_cb, cb_data); */
243         /*recorder_set_recording_limit_reached_cb(handle, cbs->limit_reached_cb, cb_data); */
244         /*recorder_set_error_cb(handle, cbs->error_cb, cb_data); */
245         recorder_audio_codec_e encoder = RECORDER_AUDIO_CODEC_AAC;
246         recorder_file_format_e file_format = RECORDER_FILE_FORMAT_MP4;
247
248         int sample_rate = 44100;
249         int bitrate = 64000;/* 288000 */
250
251
252         mmf_ret = recorder_attr_set_audio_device(handle, RECORDER_AUDIO_DEVICE_MIC);
253         if (mmf_ret != RECORDER_ERROR_NONE) {
254                 SETTING_TRACE_ERROR("recorder_attr_set_audio_device().. [%x]", mmf_ret);
255                 goto READY_FAIL;
256         }
257
258         mmf_ret = recorder_set_audio_encoder(handle, encoder);
259         if (mmf_ret != RECORDER_ERROR_NONE) {
260                 SETTING_TRACE_ERROR("recorder_set_audio_encoder().. [%x]", mmf_ret);
261                 goto READY_FAIL;
262         }
263
264         mmf_ret = recorder_set_file_format(handle, file_format);
265         if (mmf_ret != RECORDER_ERROR_NONE) {
266                 SETTING_TRACE_ERROR("recorder_set_file_format().. [%x]", mmf_ret);
267                 goto READY_FAIL;
268         }
269
270         mmf_ret = recorder_attr_set_audio_samplerate(handle, sample_rate);
271         if (mmf_ret != RECORDER_ERROR_NONE) {
272                 SETTING_TRACE_ERROR("recorder_attr_set_audio_samplerate().. [%x]", mmf_ret);
273                 goto READY_FAIL;
274         }
275
276         mmf_ret = recorder_attr_set_audio_encoder_bitrate(handle, bitrate);
277         if (mmf_ret != RECORDER_ERROR_NONE) {
278                 SETTING_TRACE_ERROR("recorder_attr_set_audio_encoder_bitrate().. [%x]", mmf_ret);
279                 goto READY_FAIL;
280         }
281
282         /*mmf_ret = recorder_set_filename(handle, target_filename);
283         if (mmf_ret != RECORDER_ERROR_NONE) {
284                 SETTING_TRACE_ERROR("recorder_set_filename().. [%x]", mmf_ret);
285                 goto READY_FAIL;
286         }
287         mmf_ret = recorder_attr_set_size_limit(handle, max_size);
288         if (mmf_ret != RECORDER_ERROR_NONE) {
289                 SETTING_TRACE_ERROR("recorder_attr_set_size_limit().. [%x]", mmf_ret);
290                 goto READY_FAIL;
291         }
292         */
293
294         /*
295         SETTING_TRACE("recorder_prepare");
296         mmf_ret = recorder_prepare(handle);
297         if (mmf_ret == RECORDER_ERROR_NONE) {
298                 SETTING_TRACE("recorder_prepare success");
299         } else {
300                 SETTING_TRACE_ERROR("recorder_prepare Error : %x\n", mmf_ret);
301                 goto READY_FAIL;
302         }*/
303
304         /*mmf_ret = recorder_start(handle);
305         if (mmf_ret == RECORDER_ERROR_NONE)
306                 SETTING_TRACE("recorder_start success");
307         else {
308                 SETTING_TRACE_ERROR("recorder_start Error : %x", mmf_ret);
309                 goto READY_FAIL;
310         }
311
312         }*/
313
314         return handle;
315
316 READY_FAIL:
317         recorder_destroy(handle);
318         handle = NULL;
319         return handle;
320 }
321
322 static void __change_simple_password_cb(void *data, Evas_Object *obj, void *event_info)
323 {
324         retm_if(data == NULL, "Data parameter is NULL");
325         Setting_GenGroupItem_Data *list_item =
326             (Setting_GenGroupItem_Data *) data;
327         /*  for update */
328
329         SettingSecurityUG *ad = (SettingSecurityUG *)list_item->userdata;
330         if (ad == NULL)
331                 return;
332
333         ad->pw_type = SETTING_SEC_PW_CHANGE_SIMPLE_PASSWD;
334         setting_security_create_password_sg(ad);
335 }
336
337 static void __change_password_cb(void *data, Evas_Object *obj, void *event_info)
338 {
339         retm_if(data == NULL, "Data parameter is NULL");
340         Setting_GenGroupItem_Data *list_item =
341             (Setting_GenGroupItem_Data *) data;
342         /*  for update */
343
344         SettingSecurityUG *ad = (SettingSecurityUG *)list_item->userdata;
345         if (ad == NULL)
346                 return;
347
348         ad->pw_type = SETTING_SEC_PW_CHANGE_PASSWD;
349         setting_security_create_password_sg(ad);
350 }
351
352 static Eina_Bool __update_locktype_items_status(void *data)
353 {
354         SETTING_TRACE_BEGIN;
355         retv_if(data == NULL, FALSE);
356
357         SettingSecurityUG *ad = (SettingSecurityUG *) data;
358
359         int enc_ode = 0;
360         int enc_sde = 0;
361
362         char *encryption_state = NULL;
363         encryption_state = vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
364         if (encryption_state != NULL) {
365                 if (safeStrCmp(encryption_state, "mounted") == 0
366                     || safeStrCmp(encryption_state, "encrypted") == 0) {
367                         enc_ode = TRUE;
368                 }
369         }
370         FREE(encryption_state);
371
372         vconf_get_bool(VCONFKEY_SETAPPL_MMC_ENCRYPTION_STATUS_BOOL, &enc_sde);
373         if (enc_ode || enc_sde)
374                 ad->cur_enc_mode = TRUE;
375         else
376                 ad->cur_enc_mode = FALSE;
377
378         if (ad->cur_enc_mode == TRUE) {
379                 setting_disable_genlist_item(ad->data_locktype_none->item);
380                 setting_disable_genlist_item(ad->data_locktype_swipe->item);
381                 setting_disable_genlist_item(ad->data_locktype_motion->item);
382                 /*setting_disable_genlist_item(ad->data_locktype_face); */
383                 setting_disable_genlist_item(ad->data_locktype_simple->item);
384
385                 int index = 0;
386                 while (ad->data_locktype_3rd[index] && ad->data_locktype_3rd[index]->item) {
387                         setting_disable_genlist_item(ad->data_locktype_3rd[index]->item);
388                         index++;
389                 }
390
391                 if (enc_ode) {
392                         ADD_GL_LABLE(ad->sl_scroller, "IDS_ST_BODY_SCREEN_LOCK_TYPE_CANNOT_BE_CHANGED_WHILE_ENCRYPTING_THE_DEVICE");
393                 } else if (enc_sde) {
394                         ADD_GL_LABLE(ad->sl_scroller, "IDS_ST_BODY_SCREEN_LOCK_TYPE_CANNOT_BE_CHANGED_WHILE_ENCRYPTING_THE_SD_CARD");
395                 }
396         }
397
398         /*ecore_timer_del(ad->update_locktype_timer); */
399         ad->update_locktype_timer = NULL;
400
401         return ECORE_CALLBACK_CANCEL;
402 }
403
404 void __add_locktype_items(void *data)
405 {
406         SETTING_TRACE_BEGIN;
407         ret_if(data == NULL);
408
409         SettingSecurityUG *ad = (SettingSecurityUG *) data;
410
411         Elm_Object_Item *item = NULL;
412         Evas_Object *radio;
413
414         int index = -1;
415         int locktype = 0;
416         vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
417
418         char *encryption_state = NULL;
419         encryption_state = vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
420         if ((encryption_state != NULL) && (safeStrCmp(encryption_state, "mounted") == 0)) {
421                 ad->cur_enc_mode = 1;
422         }
423         if (ode_init() == 0) {
424                 int sde_status = sde_checkencrypt();
425                 if (sde_status == 0)
426                         ad->cur_enc_mode = 1;
427                 ode_deinit();
428         }
429         FREE(encryption_state);
430
431         radio = elm_radio_add(ad->sl_scroller);
432         elm_radio_state_value_set(radio, -1);
433         ad->lock_type_rd = radio;
434
435         /* separator */
436         item = elm_genlist_item_append(ad->sl_scroller, &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
437         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
438
439         evas_object_smart_callback_add(ad->sl_scroller, "realized", __gl_realized_cb, NULL);
440
441         /* to do : radio menu */
442         /* 0) None */
443         ad->data_locktype_none =
444             setting_create_Gendial_field_1radio(ad->sl_scroller,
445                                                 &(itc_1text_1icon_3),
446                                                 setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
447                                                 ad,     /* sel data */
448                                                 SWALLOW_Type_1RADIO,
449                                                 radio, SETTING_SCREEN_LOCK_TYPE_NONE,
450                                                 "IDS_ST_BODY_NONE",
451                                                 setting_security_locktype_click_radio_cb);
452         if (ad->data_locktype_none) {
453                 ad->data_locktype_none->userdata = ad;
454                 ad->data_locktype_none->group_style = SETTING_GROUP_STYLE_TOP;
455
456         } else {
457                 SETTING_TRACE_ERROR("item_data is NULL");
458         }
459
460         /* 1) swipe */
461         ad->data_locktype_swipe =
462             setting_create_Gendial_field_1radio(ad->sl_scroller,
463                                                 &(itc_1text_1icon_3),
464                                                 setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
465                                                 ad,     /* sel data */
466                                                 SWALLOW_Type_1RADIO,
467                                                 radio, SETTING_SCREEN_LOCK_TYPE_SWIPE,
468                                                 Keystr_Swipe,
469                                                 setting_security_locktype_click_radio_cb);
470         if (ad->data_locktype_swipe) {
471                 ad->data_locktype_swipe->userdata = ad;
472                 ad->data_locktype_swipe->group_style = SETTING_GROUP_STYLE_CENTER;
473         } else {
474                 SETTING_TRACE_ERROR("item_data is NULL");
475         }
476
477         /* 2) Motion */
478         ad->data_locktype_motion =
479             setting_create_Gendial_field_1radio(ad->sl_scroller,
480                                                 &(itc_1text_1icon_3),
481                                                 setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
482                                                 ad,     /* sel data */
483                                                 SWALLOW_Type_1RADIO,
484                                                 radio, SETTING_SCREEN_LOCK_TYPE_MOTION,
485                                                 "IDS_ST_BODY_MOTION",
486                                                 setting_security_locktype_click_radio_cb);
487         if (ad->data_locktype_motion) {
488                 ad->data_locktype_motion->userdata = ad;
489                 ad->data_locktype_motion->group_style = SETTING_GROUP_STYLE_CENTER;
490         } else {
491                 SETTING_TRACE_ERROR("item_data is NULL");
492         }
493 #if TBD
494         /* 3) Face and voice */
495         ad->data_locktype_face =
496             setting_create_Gendial_field_1radio(ad->sl_scroller,
497                                                 &(itc_1text_1icon_3),
498                                                 setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
499                                                 ad,     /* sel data */
500                                                 SWALLOW_Type_1RADIO,
501                                                 radio, SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE,
502                                                 Keystr_FaceAndVoice,
503                                                 setting_security_locktype_click_radio_cb);
504         if (ad->data_locktype_face) {
505                 ad->data_locktype_face->userdata = ad;
506                 ad->data_locktype_face->group_style = SETTING_GROUP_STYLE_CENTER;
507         } else {
508                 SETTING_TRACE_ERROR("item_data is NULL");
509         }
510 #endif
511         /* 4) simple password */
512         if (locktype == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
513                 ad->data_locktype_simple =
514                     setting_create_Gendial_field_1radio_1button(ad->sl_scroller,
515                                                                 &(itc_1text_2icon_2),
516                                                                 setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
517                                                                 ad,     /* sel data */
518                                                                 SWALLOW_Type_1RADIO_1BTN,
519                                                                 "reveal", /* button style */
520                                                                 radio, SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD,
521                                                                 "IDS_ST_BODY_SIMPLE_PASSWORD",
522                                                                 setting_security_locktype_click_radio_cb,       /* radio callback */
523                                                                 __change_simple_password_cb);   /* button callback */
524         } else {
525                 ad->data_locktype_simple =
526                     setting_create_Gendial_field_1radio(ad->sl_scroller,
527                                                         &(itc_1text_1icon_3),
528                                                         setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
529                                                         ad,     /* sel data */
530                                                         SWALLOW_Type_1RADIO_1BTN,
531                                                         radio, SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD,
532                                                         "IDS_ST_BODY_SIMPLE_PASSWORD",
533                                                         setting_security_locktype_click_radio_cb);
534
535         }
536         if (ad->data_locktype_simple) {
537                 ad->data_locktype_simple->userdata = ad;
538                 ad->data_locktype_simple->group_style = SETTING_GROUP_STYLE_CENTER;
539         } else {
540                 SETTING_TRACE_ERROR("item_data is NULL");
541         }
542
543         /* 5) password */
544         if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
545                 ad->data_locktype_password =
546                     setting_create_Gendial_field_1radio_1button(ad->sl_scroller,
547                                                                 &(itc_1text_2icon_2),
548                                                                 setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
549                                                                 ad,     /* sel data */
550                                                                 SWALLOW_Type_1RADIO_1BTN,
551                                                                 "reveal", /* button style */
552                                                                 radio, SETTING_SCREEN_LOCK_TYPE_PASSWORD,
553                                                                 "IDS_ST_BODY_PASSWORD",
554                                                                 setting_security_locktype_click_radio_cb,       /* radio callback */
555                                                                 __change_password_cb);  /* button callback */
556         } else {
557                 ad->data_locktype_password =
558                     setting_create_Gendial_field_1radio(ad->sl_scroller,
559                                                         &(itc_1text_1icon_3),
560                                                         setting_security_locktype_mouse_up_Gendial_list_cb,     /*add to sel_cb */
561                                                         ad,     /* sel data */
562                                                         SWALLOW_Type_1RADIO,
563                                                         radio, SETTING_SCREEN_LOCK_TYPE_PASSWORD,
564                                                         "IDS_ST_BODY_PASSWORD",
565                                                         setting_security_locktype_click_radio_cb);
566         }
567         if (ad->data_locktype_password) {
568                 ad->data_locktype_password->userdata = ad;
569                 ad->data_locktype_password->group_style = SETTING_GROUP_STYLE_BOTTOM;
570         } else {
571                 SETTING_TRACE_ERROR("item_data is NULL");
572         }
573
574         /* Add 3rd party lock apps in list. */
575         __add_3rd_party_lock(ad);
576
577         /* update info */
578         /* To do : If type is OTHER, should calculate something.*/
579         if (locktype == SETTING_SCREEN_LOCK_TYPE_OTHER) {
580                 char *open_lock_name = NULL;
581                 open_lock_name = vconf_get_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR);
582                 index = __get_index_of_lockapp(open_lock_name);
583
584                 if (open_lock_name)
585                         FREE(open_lock_name);
586         }
587         /* End */
588         if (index < 0)
589                 elm_radio_value_set(radio, locktype);
590         else
591                 elm_radio_value_set(radio, locktype + index);
592
593         ad->update_locktype_timer = ecore_timer_add(0.5, __update_locktype_items_status, ad);
594         /*__update_locktype_items_status(ad); */
595 }
596
597
598 static void __lock_type_key_changed_cb(keynode_t *key, void *data)
599 {
600         ret_if(data == NULL);
601
602         SettingSecurityUG *ad = data;
603         int status = 0;
604         char *vconf_name = vconf_keynode_get_name(key);
605
606         if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT)) {
607                 /*status = vconf_keynode_get_int(key); */
608
609                 if (ad->sl_scroller) {
610                         elm_genlist_clear(ad->sl_scroller);
611                         __add_locktype_items(ad);
612                 }
613         }
614         ug_destroy_me(ad->ug);
615 }
616
617
618 static int setting_security_locktype_create(void *cb)
619 {
620         SETTING_TRACE_BEGIN;
621         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
622
623         SettingSecurityUG *ad = (SettingSecurityUG *) cb;
624
625         /* add basic layout */
626
627         Evas_Object *scroller = NULL;
628         if (&setting_view_security_locktype == ad->view_to_load) {
629                 ad->ly_main =
630                     setting_create_layout_navi_bar_genlist(ad->win_main_layout,
631                                                            ad->win_get,
632                                                            "IDS_ST_BODY_SCREEN_LOCK_TYPE",
633                                                            _("IDS_COM_BODY_BACK"),
634                                                            NULL,
635                                                            setting_security_locktype_click_softkey_back_cb,
636                                                            NULL, ad, &scroller,
637                                                            &(ad->navi_bar));
638                 ad->screen_lock_main_item = elm_naviframe_top_item_get(ad->navi_bar);
639         } else {
640                 ad->screen_lock_main_item = setting_push_layout_navi_bar_genlist(ad->win_main_layout,
641                                                                                  ad->win_get,
642                                                                                  "IDS_ST_BODY_SCREEN_LOCK_TYPE",
643                                                                                  _("IDS_COM_BODY_BACK"), NULL,
644                                                                                  setting_security_locktype_click_softkey_back_cb,
645                                                                                  NULL, ad, &scroller, ad->navi_bar);
646         }
647
648         ad->sl_scroller = scroller;
649
650         __add_locktype_items(ad);
651
652         vconf_notify_key_changed(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, __lock_type_key_changed_cb, ad);
653
654         setting_view_security_locktype.is_create = 1;
655 #if TBD
656         ad->recorder_handle = __voice_recorder_create();
657 #endif
658         return SETTING_RETURN_SUCCESS;
659 }
660
661 static int setting_security_locktype_destroy(void *cb)
662 {
663         SETTING_TRACE_BEGIN;
664         /* error check */
665         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
666
667         SettingSecurityUG *ad = (SettingSecurityUG *) cb;
668
669         (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT,
670                                        __lock_type_key_changed_cb);
671 #if TBD
672         if (ad->recorder_handle) {
673                 __voice_recorder_destroy(ad->recorder_handle);
674                 ad->recorder_handle = NULL;
675         }
676 #endif
677         if (ad->update_locktype_timer) {
678                 ecore_timer_del(ad->update_locktype_timer);
679                 ad->update_locktype_timer = NULL;
680         }
681         if (ad->notify) {
682                 evas_object_del(ad->notify);
683                 ad->notify = NULL;
684         }
685         ad->screen_lock_main_item = NULL;
686         if (&setting_view_security_locktype == ad->view_to_load) {
687                 evas_object_del(ad->ly_main);
688         } else
689                 elm_naviframe_item_pop(ad->navi_bar);
690
691         setting_view_security_locktype.is_create = 0;
692
693         return SETTING_RETURN_SUCCESS;
694 }
695
696 static int setting_security_locktype_update(void *cb)
697 {
698         SETTING_TRACE_BEGIN;
699         /* error check */
700         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
701
702         __update_locktype_items_status(cb);
703
704         return SETTING_RETURN_SUCCESS;
705 }
706
707 static int setting_security_locktype_cleanup(void *cb)
708 {
709         SETTING_TRACE_BEGIN;
710         /* error check */
711         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
712
713         SettingSecurityUG *ad = (SettingSecurityUG *) cb;
714
715         if (&setting_view_security_locktype == ad->view_to_load) {
716                 return SETTING_RETURN_SUCCESS;
717         }
718         return setting_security_locktype_destroy(ad);
719 }
720
721 /* ***************************************************
722  **
723  **call back func
724  **
725  ****************************************************/
726 const char *record_img[] = {
727         SETTING_ICON_PATH_CFG "motions/direct call/B15_direct_call_01.png",
728         /*SETTING_ICON_PATH_CFG "motions/direct call/B15_direct_call_02.png", */
729         /*SETTING_ICON_PATH_CFG "motions/direct call/B15_direct_call_03.png", */
730         NULL
731 };
732 const char *motion_img[] = {
733         SETTING_ICON_PATH_CFG "motions/unlock_illust_01.png",
734         SETTING_ICON_PATH_CFG "motions/unlock_illust_02.png",
735         NULL
736 };
737
738 static void
739 __motion_set_cb(void *data, Evas_Object *obj, void *event_info)
740 {
741         SETTING_TRACE_BEGIN;
742         SETTING_TRACE("[HYEJIN] __motion_guild_ly_cb() start. ");
743         /* error check */
744         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
745         SettingSecurityUG *ad = (SettingSecurityUG *) data;
746
747         if (vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_MOTION) == 0) {
748                 elm_radio_value_set(ad->lock_type_rd, SETTING_SCREEN_LOCK_TYPE_MOTION);
749                 if (ad->old_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
750                     || ad->old_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
751                         SETTING_TRACE_DEBUG("set_pwd result : %d", security_server_set_pwd(ad->input_pwd, "0000", 0, 0));
752                 uid_t user = 5000;
753                 int ckmc_ret = CKMC_ERROR_NONE;
754                 ckmc_ret = ckmc_change_user_password(user, ad->input_pwd, NULL);
755                 SETTING_TRACE("ckmc_change_user_password() returns %d", ckmc_ret);
756         }
757
758         elm_naviframe_item_pop(ad->navi_bar);
759         ug_destroy_me(ad->ug);
760 }
761
762 static void
763 __motion_cancel_cb(void *data, Evas_Object *obj, void *event_info)
764 {
765         SETTING_TRACE_BEGIN;
766         SETTING_TRACE("[HYEJIN] __motion_guild_ly_cb() start. ");
767         /* error check */
768         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
769         SettingSecurityUG *ad = (SettingSecurityUG *) data;
770
771         elm_naviframe_item_pop(ad->navi_bar);
772         ug_destroy_me(ad->ug);
773 }
774 static void
775 ___camera_ug_kayout_cb(ui_gadget_h ug, enum ug_mode mode,
776                        void *priv)
777 {
778         SETTING_TRACE_BEGIN;
779         SettingSecurityUG *ad = (SettingSecurityUG *) priv;
780         Evas_Object *base;
781
782         if (!priv)
783                 return;
784
785         base = (Evas_Object *) ug_get_layout(ug);
786         if (!base)
787                 return;
788
789         switch (mode) {
790                 case UG_MODE_FULLVIEW:
791                         evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
792                                                          EVAS_HINT_EXPAND);
793                         /*elm_win_resize_object_add(ad->win_get, base); */
794                         evas_object_show(base);
795                         break;
796                 case UG_MODE_FRAMEVIEW:
797                         elm_layout_content_set(ad->video_ly, "elm.swallow.content", base);
798                 default:
799                         break;
800         }
801         SETTING_TRACE_END;
802 }
803 static void ___camera_ug_destory_cb(ui_gadget_h ug,
804                                     void *priv)
805 {
806         SETTING_TRACE_BEGIN;
807         ret_if(!priv);
808         /*SettingSecurityUG *ad = (SettingSecurityUG *) priv;
809         if (ug) {
810                 ug_destroy(ug);
811                 ad->ug_loading = NULL;
812         }*/
813 }
814
815 void __load_camera_ug(SettingSecurityUG *ad)
816 {
817         app_control_h svc;
818         if (app_control_create(&svc)) {
819                 return;
820         }
821
822         /*service_add_extra_data(svc, "launch-type", "select-one"); */
823         /*service_add_extra_data(svc, "file-type", "image"); */
824         /*service_set_window(service, win_id); */
825         app_control_set_operation(svc, "Normal");
826         /*service_set_mime(service, "image/jpg"); */
827
828         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
829         if (!cbs) {
830                 app_control_destroy(svc);
831                 return;
832         }
833
834         cbs->layout_cb = ___camera_ug_kayout_cb;
835         cbs->result_cb = NULL;
836         cbs->destroy_cb = ___camera_ug_destory_cb;
837         cbs->priv = (void *)ad;
838
839         elm_object_tree_focus_allow_set(ad->ly_main, EINA_FALSE);
840         ad->ug_loading = setting_ug_create(ad->ug, "camera-efl", UG_MODE_FRAMEVIEW, svc, cbs);
841         SETTING_TRACE("ad->ug_loading = %p", ad->ug_loading);
842
843         if (NULL == ad->ug_loading) {   /* error handling */
844                 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));
845         }
846
847         app_control_destroy(svc);
848         FREE(cbs);
849 }
850
851
852 static void
853 __voice_record_back_cb(void *data, Evas_Object *obj, void *event_info)
854 {
855         /* error check */
856         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
857         SettingSecurityUG *ad = (SettingSecurityUG *) data;
858         elm_naviframe_item_pop(ad->navi_bar);
859         if (ad->video_ly_show_face_btn) elm_object_text_set(ad->video_ly_show_face_btn, _(Show_Face_Str));
860         __load_camera_ug(ad);
861 }
862
863 static void ___record_popup_cb(void *data, Evas_Object *obj,
864                                void *event_info)
865 {
866         setting_retm_if(NULL == data, "NULL == data");
867         SettingSecurityUG *ad = (SettingSecurityUG *) data;
868         const char *btn_str = elm_object_text_get(obj);
869         /*int response_type = btn_type(obj); */
870         if (0 == safeStrCmp(btn_str, _("IDS_COM_SK_DONE"))) {
871                 /*__load_password_ug(ad); */
872                 ad->pw_type = SETTING_SEC_PW_SIMPLE_PASSWD;
873                 if (elm_radio_value_get(ad->lock_type_rd) != SETTING_SCREEN_LOCK_TYPE_PASSWORD)
874                         ad->input_pwd = (char *)strdup("0000");
875                 setting_security_create_password_sg(ad);
876
877         } else if (0 == safeStrCmp(btn_str, _(ADAPT_VOICE_STR))) {
878                 if (ad->record_genlist) {
879                         Evas_Object *scroller = ad->record_genlist;
880                         elm_genlist_clear(scroller);    /* first to clear list */
881                         elm_genlist_mode_set(scroller, ELM_LIST_COMPRESS);
882
883                         ADD_GL_LABLE(scroller, _(Voice_Unlock_Guildtext));
884                         ADD_GL_GIF(scroller, record_img)
885                         ADD_GL_LABLE(scroller, _(Voice_Unlock_Guildtext2));
886                         ADD_GL_BUTTON(scroller, _(Voice_Record_BtnStr), __record_btn_click_cb, ad)
887                 }
888         }
889         if (ad->notify) {
890                 evas_object_del(ad->notify);
891                 ad->notify = NULL;
892         }
893 }
894 static Eina_Bool __record_timer_cb(void *data)
895 {
896         SETTING_TRACE_BEGIN;
897         retv_if(data == NULL, TRUE);
898         SettingSecurityUG *ad = (SettingSecurityUG *) data;
899         SETTING_TRACE("ad->processed_img_num:%d", ad->processed_img_num);
900         if (ad->processed_img_num < MAX_VOICE_TIME) {
901                 /*record old file */
902                 recorder_state_e rec_state = RECORDER_STATE_NONE;
903                 recorder_get_state(ad->recorder_handle, &rec_state);
904                 if (rec_state == RECORDER_STATE_PAUSED || rec_state == RECORDER_STATE_RECORDING) {
905                         if (recorder_commit(ad->recorder_handle) != RECORDER_ERROR_NONE)
906                                 SETTING_TRACE_ERROR("recorder_commit Error");
907
908                         recorder_get_state(ad->recorder_handle, &rec_state);
909                         if (rec_state == RECORDER_STATE_READY
910                             && recorder_unprepare(ad->recorder_handle) == RECORDER_ERROR_NONE)
911                                 SETTING_TRACE("recorder_unprepare success");
912                 }
913
914                 /*vr_mm_camcorder_unrealize(model->handle); */
915                 if (ad->processed_img_num != MAX_VOICE_TIME - 1) {
916                         /*set new file */
917                         char file_path[MAX_COMMON_BUFFER_LEN + 1] = {0, };
918                         snprintf(file_path, MAX_COMMON_BUFFER_LEN, "/opt/usr/data/setting/voiceRecord%d.mp4", ad->processed_img_num + 1);
919                         if (recorder_set_filename(ad->recorder_handle, file_path) == RECORDER_ERROR_NONE) {
920                                 SETTING_TRACE("recorder_set_filename sucess");
921                                 if (recorder_prepare(ad->recorder_handle) == RECORDER_ERROR_NONE)
922                                         SETTING_TRACE("recorder_prepare success");
923
924                                 if (recorder_start(ad->recorder_handle) == RECORDER_ERROR_NONE)
925                                         SETTING_TRACE("recorder_start success");
926                         }
927                 }
928
929
930
931                 elm_image_file_set(ad->image[ad->processed_img_num], SETTING_ICON_PATH_CFG"00_circle_button_press.png", NULL);
932                 if (ad->record_genlist) {
933                         Elm_Object_Item *first_item = elm_genlist_first_item_get(ad->record_genlist);
934                         Setting_GenGroupItem_Data *item_data = elm_object_item_data_get(first_item);
935                         if (item_data) {
936                                 G_FREE(item_data->keyStr);
937                                 char src[MAX_COMMON_BUFFER_LEN + 1] = {0, };
938                                 snprintf(src, sizeof(src), "%s (%d/4)", _(Speak_Now_Str), ad->processed_img_num + 1);
939                                 char dst[MAX_COMMON_BUFFER_LEN + 1] = {0, };
940                                 memset(dst, ' ', MAX_COMMON_BUFFER_LEN);
941                                 memcpy(dst, src, safeStrLen(src));
942
943                                 item_data->keyStr = (char *)g_strdup(dst);
944                                 elm_genlist_item_fields_update(item_data->item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
945                                 \
946                         }
947
948                 }
949         }
950         if (ad->processed_img_num == MAX_VOICE_TIME - 1) {
951                 Evas_Object *btn = setting_create_button(ad->notify, _(ADAPT_VOICE_STR), NULL, ___record_popup_cb, data);
952                 elm_object_style_set(btn, "popup");
953                 elm_object_part_content_set(ad->notify, "button1", btn);
954                 evas_object_show(btn);
955
956                 btn = setting_create_button(ad->notify, _("IDS_COM_SK_DONE"), NULL, ___record_popup_cb, data);
957                 elm_object_style_set(btn, "popup");
958                 elm_object_part_content_set(ad->notify, "button2", btn);
959                 evas_object_show(btn);
960                 evas_object_show(ad->notify);
961
962                 if (ad->update_timer) {
963                         /*ecore_timer_del(ad->update_timer); */
964                         ad->update_timer = NULL;
965                 }
966                 if (ad->record_genlist) {
967 #if 1
968                         Evas_Object *scroller = ad->record_genlist;
969                         elm_genlist_clear(scroller);    /* first to clear list */
970                         elm_genlist_mode_set(scroller, ELM_LIST_COMPRESS);
971                         /*ADD_GL_LABLE(scroller, _(Voice_Recognized_text)); */
972                         char dst[MAX_COMMON_BUFFER_LEN + 1] = {0, };
973                         memset(dst, ' ', MAX_COMMON_BUFFER_LEN);
974                         char *src = _(Voice_Recognized_text);
975                         memcpy(dst, src, safeStrLen(src));
976                         SETTING_TRACE("dst: %s", dst);
977                         ADD_GL_LABLE(scroller, dst);
978                         setting_create_Gendial_field_def(scroller, &(itc_1icon_with_no_line),
979                                                          NULL, NULL, SWALLOW_Type_LOAD_LAYOUT,
980                                                          NULL, NULL, 140, NULL, NULL,
981                                                          NULL);
982
983                         ADD_GL_BUTTON(scroller, _(Voice_Record_BtnStr), __record_btn_click_cb, ad);
984 #else
985
986                         Elm_Object_Item *first_item = elm_genlist_first_item_get(ad->record_genlist);
987                         Setting_GenGroupItem_Data *item_data = elm_object_item_data_get(first_item);
988                         if (item_data) {
989                                 G_FREE(item_data->keyStr);
990                                 char *src[MAX_COMMON_BUFFER_LEN + 1] = {0, };
991                                 snprintf(src, sizeof(src), "%s", _(Voice_Recognized_text));
992                                 char *dst[MAX_COMMON_BUFFER_LEN + 1] = {0, };
993                                 memset(dst, ' ', MAX_COMMON_BUFFER_LEN);
994                                 memcpy(dst, src, safeStrLen(src));
995
996                                 item_data->keyStr = g_strdup(dst);
997                                 elm_genlist_item_fields_update(item_data->item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
998                                 \
999                         }
1000 #endif
1001
1002                 }
1003                 return FALSE;
1004         }
1005         ad->processed_img_num++;
1006
1007         return TRUE;
1008 }
1009
1010 Evas_Object *___customize_voice_record_popup(SettingSecurityUG *ad)
1011 {
1012         SETTING_TRACE_BEGIN;
1013         Evas_Object *popup = elm_popup_add(ad->win_get);
1014         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb_2, NULL);
1015         setting_add_hardkey_features(popup, ad);
1016         evas_object_size_hint_weight_set(ad->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1017
1018         /*content */
1019         Evas_Object *content_box = elm_box_add(popup);
1020
1021         Evas_Object *image = setting_create_image(popup, SETTING_ICON_PATH_CFG "RB06-1_VoiceRecoder_icon_voice.png");
1022
1023         int w = 0;
1024         int h = 0;
1025         elm_image_object_size_get(image, &w, &h);
1026         setting_resize_object(image, 1.5 * w, 1.5 * h);
1027
1028         elm_box_pack_end(content_box, image);
1029
1030         Evas_Object *layout = elm_layout_add(popup);
1031         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1032         elm_layout_theme_set(layout, "layout", "application", "default");
1033         elm_object_part_content_set(layout, "elm.swallow.bg", setting_create_blank_rect_customize(popup, 680, 100));
1034         Evas_Object *icon_box = elm_box_add(popup);
1035         elm_box_horizontal_set(icon_box, 1);
1036
1037         int i = 0;
1038         for (; i < MAX_VOICE_TIME; i++) {
1039                 ad->image[i] = setting_create_image(popup, SETTING_ICON_PATH_CFG"00_circle_button_dim.png");
1040                 elm_box_pack_end(icon_box, ad->image[i]);
1041         }
1042         ad->processed_img_num = 0;
1043         elm_object_part_content_set(layout, "elm.swallow.content", icon_box);
1044         evas_object_show(icon_box);
1045         evas_object_show(layout);
1046         elm_box_pack_end(content_box, layout);
1047
1048         elm_object_content_set(popup, content_box);
1049         /*evas_object_smart_callback_add(popup, "block,clicked", ___record_popup_cb, ad); */
1050         evas_object_show(popup);
1051         return popup;
1052 }
1053
1054
1055 static void
1056 __record_btn_click_cb(void *data, Evas_Object *obj, void *event_info)
1057 {
1058         SETTING_TRACE_BEGIN;
1059         /* error check */
1060         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
1061         Setting_GenGroupItem_Data *item_data = data;
1062         SettingSecurityUG *ad = item_data->userdata;
1063         retm_if(ad == NULL, "ad is NULL");
1064
1065         if (ad->record_genlist) {
1066                 /*refresh the genlist */
1067                 Evas_Object *scroller = ad->record_genlist;
1068                 elm_genlist_clear(scroller);    /* first to clear list */
1069                 elm_genlist_mode_set(scroller, ELM_LIST_COMPRESS);
1070
1071                 char src[MAX_COMMON_BUFFER_LEN + 1] = {0, };
1072                 snprintf(src, sizeof(src), "%s (%d/4)", _(Speak_Now_Str), 0);
1073                 char dst[MAX_COMMON_BUFFER_LEN + 1] = {0, };
1074                 memset(dst, ' ', MAX_COMMON_BUFFER_LEN);
1075                 memcpy(dst, src, safeStrLen(src));
1076                 SETTING_TRACE("dst: %s", dst);
1077                 ADD_GL_LABLE(scroller, dst);
1078
1079                 setting_create_Gendial_field_def(scroller, &(itc_1icon_with_no_line),
1080                                                  NULL, NULL, SWALLOW_Type_LOAD_LAYOUT,
1081                                                  NULL, NULL, 180, NULL, NULL,
1082                                                  NULL);
1083
1084                 ADD_GL_BUTTON(scroller, _(Voice_Record_BtnStr), __record_btn_click_cb, ad);
1085
1086                 /*create the popup */
1087                 ad->notify = ___customize_voice_record_popup(ad);
1088                 if (recorder_set_filename(ad->recorder_handle, "/opt/usr/data/setting/voiceRecord0.mp4") == RECORDER_ERROR_NONE) {
1089                         SETTING_TRACE("recorder_set_filename sucess");
1090                         if (recorder_prepare(ad->recorder_handle) == RECORDER_ERROR_NONE)
1091                                 SETTING_TRACE("recorder_prepare success");
1092
1093                         if (recorder_start(ad->recorder_handle) == RECORDER_ERROR_NONE)
1094                                 SETTING_TRACE("recorder_start success");
1095                 }
1096
1097                 if (ad->update_timer) {
1098                         ecore_timer_del(ad->update_timer);
1099                         ad->update_timer = NULL;
1100                 }
1101                 ad->update_timer =
1102                     ecore_timer_add(2.0, (Ecore_Task_Cb) __record_timer_cb, ad);
1103         } else {
1104                 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));
1105         }
1106
1107         /*elm_object_item_text_set(navi_it, _(RESET_SETTINGS_STR)); */
1108 }
1109
1110 static void
1111 __face_setup_cb(void *data, Evas_Object *obj, void *event_info)
1112 {
1113         SETTING_TRACE_BEGIN;
1114         /* error check */
1115         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
1116         SettingSecurityUG *ad = (SettingSecurityUG *) data;
1117         const char *btn_str = elm_object_text_get(obj);
1118
1119         if (ad->ug_loading) {
1120                 setting_ug_destroy(ad->ug_loading);
1121                 ad->ug_loading = NULL;
1122         }
1123
1124         if (!safeStrCmp(btn_str, _("IDS_COM_SK_CANCEL"))) {
1125                 elm_naviframe_item_pop(ad->navi_bar);
1126         } else if (!safeStrCmp(btn_str, _(CONTINUE_STR))) {
1127                 Elm_Object_Item *navi_it = setting_create_guild_layout(ad->navi_bar, NULL,
1128                                                                        _("IDS_COM_BODY_BACK"), NULL, NULL,
1129                                                                        __voice_record_back_cb, NULL, NULL,
1130                                                                        _(Voice_Unlock_Guildtext),
1131                                                                        record_img, _(Voice_Unlock_Guildtext2), _(Voice_Record_BtnStr), __record_btn_click_cb, ad);
1132
1133                 if (navi_it) {
1134                         ad->record_genlist = elm_object_item_content_get(navi_it);
1135                         if (0 != safeStrCmp(elm_object_widget_type_get(ad->record_genlist), "genlist")
1136                             && 0 != safeStrCmp(elm_object_widget_type_get(ad->record_genlist), "elm_genlist")) {
1137                                 ad->record_genlist = NULL;/*only save the genlist content */
1138                         }
1139                 }
1140         }
1141 }
1142
1143 static void
1144 __show_face_btn_click_cb(void *data, Evas_Object *obj, void *event_info)
1145 {
1146         SETTING_TRACE_BEGIN;
1147         /* error check */
1148         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
1149         /*Setting_GenGroupItem_Data *item_data = data; */
1150         SettingSecurityUG *ad = data;
1151         retm_if(ad == NULL, "ad is NULL");
1152         const char *btn_str = elm_object_text_get(obj);
1153         SETTING_TRACE("btn_str:%s", btn_str);
1154
1155         ad->video_ly_show_face_btn = obj;
1156         if (!safeStrCmp(btn_str, _(Show_Face_Str))) {
1157                 elm_object_text_set(obj, _("Record your face"));
1158
1159 #if 0
1160                 ad->video_ly_content_camera = elm_layout_content_unset(ad->video_ly, "elm.swallow.content");
1161                 if (ad->video_ly_content_camera)
1162                         evas_object_hide(ad->video_ly_content_camera);
1163                 if (ad->ug_loading) ug_pause(ad->ug_loading);
1164 #else
1165                 if (ad->ug_loading) {
1166                         setting_ug_destroy(ad->ug_loading);
1167                         ad->ug_loading = NULL;
1168                 }
1169                 /*elm_layout_content_unset(ad->video_ly, "elm.swallow.content"); */
1170 #endif
1171
1172                 /*if (!ad->video_ly_content_face) */
1173                 ad->video_ly_content_face = setting_create_image(ad->video_ly, SETTING_ICON_PATH_CFG "demo-face.png");
1174
1175                 elm_layout_content_set(ad->video_ly, "elm.swallow.content", ad->video_ly_content_face);
1176
1177         } else if (!safeStrCmp(btn_str, _("Record your face"))) {
1178                 elm_object_text_set(obj, _(Show_Face_Str));
1179
1180                 ad->video_ly_content_face = elm_layout_content_unset(ad->video_ly, "elm.swallow.content");
1181                 if (ad->video_ly_content_face)
1182                         evas_object_del(ad->video_ly_content_face);
1183
1184                 __load_camera_ug(ad);
1185         }
1186 }
1187
1188
1189 static void
1190 __face_warring3_cb(void *data, Evas_Object *obj, void *event_info)
1191 {
1192         SETTING_TRACE_BEGIN;
1193         /* error check */
1194         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
1195         SettingSecurityUG *ad = (SettingSecurityUG *) data;
1196         const char *btn_str = elm_object_text_get(obj);
1197         if (!safeStrCmp(btn_str, _("IDS_COM_SK_CANCEL"))) {
1198                 elm_naviframe_item_pop(ad->navi_bar);
1199         } else if (!safeStrCmp(btn_str, _(CONTINUE_STR))) {
1200                 setting_create_guild_layout2(ad->navi_bar,
1201                                              _(Setup_Face_Unlock_Str),
1202                                              _(CONTINUE_STR), _("IDS_COM_SK_CANCEL"), NULL,
1203                                              __face_setup_cb, __face_setup_cb, NULL,
1204                                              _(Put_Face_Str),
1205                                              &(ad->video_ly), NULL, _(Show_Face_Str),
1206                                              __show_face_btn_click_cb, ad);
1207                 ad->video_ly_show_face_btn = NULL;/*reset */
1208                 __load_camera_ug(ad);
1209         }
1210
1211 }
1212
1213 static void
1214 __face_warring2_cb(void *data, Evas_Object *obj, void *event_info)
1215 {
1216         SETTING_TRACE_BEGIN;
1217         /* error check */
1218         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
1219         SettingSecurityUG *ad = (SettingSecurityUG *) data;
1220         const char *btn_str = elm_object_text_get(obj);
1221         if (!safeStrCmp(btn_str, _("IDS_COM_SK_CANCEL"))) {
1222                 elm_naviframe_item_pop(ad->navi_bar);
1223         } else if (!safeStrCmp(btn_str, _(SET_UP_STR))) {
1224                 setting_create_guild_layout(ad->navi_bar,
1225                                             _(Setup_Face_Unlock_Str),
1226                                             _(CONTINUE_STR), _("IDS_COM_SK_CANCEL"), NULL,
1227                                             __face_warring3_cb, __face_warring3_cb, NULL,
1228                                             _(Face_Unlock_Warring3),
1229                                             NULL, NULL, NULL, NULL, ad);
1230         }
1231
1232 }
1233
1234 static void
1235 __face_warring_cb(void *data, Evas_Object *obj, void *event_info)
1236 {
1237         SETTING_TRACE_BEGIN;
1238         /* error check */
1239         retm_if(data == NULL, "[Setting > Security] Data parameter is NULL");
1240         SettingSecurityUG *ad = (SettingSecurityUG *) data;
1241         const char *btn_str = elm_object_text_get(obj);
1242         if (!safeStrCmp(btn_str, _("IDS_COM_SK_CANCEL"))) {
1243                 elm_naviframe_item_pop(ad->navi_bar);
1244         } else if (!safeStrCmp(btn_str, _(CONTINUE_STR))) {
1245                 setting_create_guild_layout(ad->navi_bar,
1246                                             _(About_Face_Unlock_Str),
1247                                             _(SET_UP_STR), _("IDS_COM_SK_CANCEL"), NULL,
1248                                             __face_warring2_cb, __face_warring2_cb, NULL,
1249                                             _(Face_Unlock_Warring2),
1250                                             NULL, NULL, NULL, NULL, ad);
1251         }
1252
1253 }
1254
1255 static void
1256 setting_security_locktype_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
1257                                                    void *event_info)
1258 {
1259         SETTING_TRACE_BEGIN;
1260         /* error check */
1261         setting_retm_if(data == NULL, "Data parameter is NULL");
1262
1263         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1264         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1265         elm_genlist_item_selected_set(item, 0);
1266         Setting_GenGroupItem_Data *list_item =
1267             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1268         SettingSecurityUG *ad = (SettingSecurityUG *) data;
1269         int lock_type = list_item->chk_status;
1270         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
1271         int old_type = elm_radio_value_get(list_item->eo_check);
1272
1273         ad->selected_lock_type = list_item->keyStr;
1274
1275         /* If lock_type is same with old_lock_type, return. */
1276         if (lock_type == old_type) {
1277                 SETTING_TRACE_DEBUG("[Screen Lock Type] Selected same type");
1278                 return;
1279         }
1280
1281         int index = -1;
1282         char *pkg_name = NULL;
1283
1284         switch (lock_type) {
1285                 case SETTING_SCREEN_LOCK_TYPE_NONE:
1286                 case SETTING_SCREEN_LOCK_TYPE_SWIPE:
1287                         /* To do : Call security-server API. pw : 0000 */
1288                         if (old_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
1289                             || old_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
1290                                 int result = security_server_set_pwd(ad->input_pwd, "0000", 0, 0);
1291                                 SETTING_TRACE_DEBUG("set_pwd result : %d", result);
1292                                 uid_t user = 5000;
1293                                 int ckmc_ret = CKMC_ERROR_NONE;
1294                                 ckmc_ret = ckmc_change_user_password(user, ad->input_pwd, NULL);
1295                                 SETTING_TRACE("ckmc_change_user_password() returns %d", ckmc_ret);
1296                         }
1297                         if (vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, lock_type) == 0) {
1298                                 /* set radio */
1299                                 elm_radio_value_set(list_item->eo_check, lock_type);
1300                         }
1301                         /*SETTING_TRACE_DEBUG("PASS #1"); */
1302                         ug_destroy_me(ad->ug);
1303                         break;
1304                 case SETTING_SCREEN_LOCK_TYPE_MOTION:
1305                         /* To do : Call security-server API. pw : 0000 */
1306                         /*if(old_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD */
1307                         /*      || old_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) */
1308                         /*      SETTING_TRACE_DEBUG("set_pwd result : %d", security_server_set_pwd(ad->input_pwd, "0000", 0, 30)); */
1309                         ad->old_type = old_type;
1310
1311                         /* motion unlock guide text */
1312                         char motion_unlock_desc[MAX_COMMON_BUFFER_LEN] = {0,};
1313                         snprintf(motion_unlock_desc, sizeof(motion_unlock_desc), "%s<br><br>%s<br>%s", _(Motion_Unlock_Guildtext1), _(Motion_Unlock_Guildtext2), _(Motion_Unlock_Guildtext3));
1314                         setting_create_guild_layout(ad->navi_bar,
1315                                                     _(About_Motion_Unlock_Str),
1316                                                     _("IDS_COM_SK_CANCEL"), _(SET_AS_LOCK_STR), NULL,
1317                                                     __motion_cancel_cb, __motion_set_cb, NULL,
1318                                                     motion_unlock_desc,
1319                                                     motion_img,
1320                                                     NULL, NULL, NULL, ad);
1321                         break;
1322                 case SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE:
1323                         /* To do : Call security-server API. pw : 0000 */
1324                         /*if(old_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD */
1325                         /*      || old_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) */
1326                         /*      SETTING_TRACE_DEBUG("set_pwd result : %d", security_server_set_pwd(ad->input_pwd, "0000", 0, 30)); */
1327                         ad->old_type = old_type;
1328                         /*setting_create_simple_popup(NULL, ad->win_get, NULL, "NOT SUPPORT YET"); */
1329                         /*if(vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, lock_type) == 0) */
1330                         /*{ */
1331                         /* set radio */
1332                         /*      elm_radio_value_set(list_item->eo_check, lock_type); */
1333                         /*} */
1334                         setting_create_guild_layout(ad->navi_bar,
1335                                                     _(About_Face_Unlock_Str),
1336                                                     _(CONTINUE_STR), _("IDS_COM_SK_CANCEL"), NULL,
1337                                                     __face_warring_cb, __face_warring_cb, NULL,
1338                                                     _(Face_Unlock_Warring),
1339                                                     NULL, NULL, NULL, NULL, ad);
1340
1341                         break;
1342                 case SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD:
1343                         ad->pw_type = SETTING_SEC_PW_SIMPLE_PASSWD;
1344                         if (old_type != SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1345                                 ad->input_pwd = (char *)strdup("0000");
1346                         setting_security_create_password_sg(ad);
1347                         break;
1348                 case SETTING_SCREEN_LOCK_TYPE_PASSWORD:
1349                         ad->pw_type = SETTING_SEC_PW_PASSWORD;
1350                         if (old_type != SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
1351                                 ad->input_pwd = (char *)strdup("0000");
1352                         setting_security_create_password_sg(ad);
1353                         break;
1354                 case SETTING_SCREEN_LOCK_TYPE_OTHER:
1355                         SETTING_TRACE_DEBUG("set_pwd result : %d", security_server_set_pwd(ad->input_pwd, "0000", 0, 0));
1356                         uid_t user = 5000;
1357                         int ckmc_ret = CKMC_ERROR_NONE;
1358                         ckmc_ret = ckmc_change_user_password(user, ad->input_pwd, NULL);
1359                         SETTING_TRACE("ckmc_change_user_password() returns %d", ckmc_ret);
1360                         index = __get_lockapp_index_from_appname(list_item->keyStr);
1361                         pkg_name = __get_lockapp_pkgname_from_appname(list_item->keyStr);
1362                         SETTING_TRACE_DEBUG("3rd lock selected. index[%d] pkg_name[%s]", index, pkg_name);
1363                         vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, pkg_name);
1364                         vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, lock_type);
1365                         /* set radio */
1366                         elm_radio_value_set(list_item->eo_check, lock_type + index);
1367                         break;
1368                 default:
1369                         break;
1370         }
1371 }
1372
1373 static void
1374 setting_security_locktype_click_radio_cb(void *data, Evas_Object *obj, void *event_info)
1375 {
1376         SETTING_TRACE_BEGIN;
1377         setting_retm_if(data == NULL, "Data parameter is NULL");
1378         Setting_GenGroupItem_Data *list_item =
1379             (Setting_GenGroupItem_Data *) data;
1380         SettingSecurityUG *ad = list_item->userdata;
1381
1382         int lock_type = elm_radio_value_get(obj);
1383         int old_type = 0;
1384
1385         vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &old_type);
1386
1387         if (old_type == lock_type)
1388                 return;
1389
1390         switch (lock_type) {
1391                 case SETTING_SCREEN_LOCK_TYPE_NONE:
1392                 case SETTING_SCREEN_LOCK_TYPE_SWIPE:
1393                         /* To do : Call security-server API. pw : 0000 */
1394                         if (old_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
1395                             || old_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
1396                                 int result = security_server_set_pwd(ad->input_pwd, "0000", 0, 30);
1397                                 SETTING_TRACE_DEBUG("set_pwd result : %d", result);
1398                                 uid_t user = 5000;
1399                                 int ckmc_ret = CKMC_ERROR_NONE;
1400                                 ckmc_ret = ckmc_change_user_password(user, ad->input_pwd, NULL);
1401                                 SETTING_TRACE("ckmc_change_user_password() returns %d", ckmc_ret);
1402                         }
1403                         vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, lock_type);
1404                         ug_destroy_me(ad->ug);
1405                         break;
1406                 case SETTING_SCREEN_LOCK_TYPE_MOTION:
1407                         ad->old_type = old_type;
1408
1409                         elm_radio_value_set(ad->lock_type_rd, old_type);
1410
1411                         /* motion unlock guide text */
1412                         char motion_unlock_desc[MAX_COMMON_BUFFER_LEN] = {0,};
1413                         snprintf(motion_unlock_desc, sizeof(motion_unlock_desc), "%s<br><br>%s<br>%s", _(Motion_Unlock_Guildtext1), _(Motion_Unlock_Guildtext2), _(Motion_Unlock_Guildtext3));
1414                         setting_create_guild_layout(ad->navi_bar,
1415                                                     _(About_Motion_Unlock_Str),
1416                                                     _("IDS_COM_SK_CANCEL"), _(SET_AS_LOCK_STR), NULL,
1417                                                     __motion_cancel_cb, __motion_set_cb, NULL,
1418                                                     motion_unlock_desc,
1419                                                     motion_img,
1420                                                     NULL, NULL, NULL, ad);
1421                         break;
1422                 case SETTING_SCREEN_LOCK_TYPE_FACE_AND_VOICE:
1423                         ad->old_type = old_type;
1424                         elm_radio_value_set(ad->lock_type_rd, old_type);
1425                         setting_create_guild_layout(ad->navi_bar,
1426                                                     _(About_Face_Unlock_Str),
1427                                                     _(CONTINUE_STR), _("IDS_COM_SK_CANCEL"), NULL,
1428                                                     __face_warring_cb, __face_warring_cb, NULL,
1429                                                     _(Face_Unlock_Warring),
1430                                                     NULL, NULL, NULL, NULL, ad);
1431
1432                         break;
1433                 case SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD:
1434                         elm_radio_value_set(ad->lock_type_rd, old_type);
1435                         ad->pw_type = SETTING_SEC_PW_SIMPLE_PASSWD;
1436                         if (old_type != SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1437                                 ad->input_pwd = (char *)strdup("0000");
1438                         setting_security_create_password_sg(ad);
1439                         break;
1440                 case SETTING_SCREEN_LOCK_TYPE_PASSWORD:
1441                         elm_radio_value_set(ad->lock_type_rd, old_type);
1442                         ad->pw_type = SETTING_SEC_PW_PASSWORD;
1443                         if (old_type != SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
1444                                 ad->input_pwd = (char *)strdup("0000");
1445                         setting_security_create_password_sg(ad);
1446                         break;
1447                 case SETTING_SCREEN_LOCK_TYPE_OTHER:
1448 #if TEMP
1449                         int index = -1;
1450                         char *pkg_name = NULL;
1451                         SETTING_TRACE_DEBUG("set_pwd result : %d", security_server_set_pwd(ad->input_pwd, "0000", 0, 30));
1452                         uid_t user = 5000;
1453                         int ckmc_ret = CKMC_ERROR_NONE;
1454                         ckmc_ret = ckmc_change_user_password(user, ad->input_pwd, NULL);
1455                         SETTING_TRACE("ckmc_change_user_password() returns %d", ckmc_ret);
1456                         index = __get_lockapp_index_from_appname(list_item->keyStr);
1457                         pkg_name = __get_lockapp_pkgname_from_appname(list_item->keyStr);
1458                         SETTING_TRACE_DEBUG("3rd lock selected. index[%d] pkg_name[%s]", index, pkg_name);
1459                         vconf_set_str(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, pkg_name);
1460                         vconf_set_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, lock_type);
1461                         /* set radio */
1462                         elm_radio_value_set(list_item->eo_check, lock_type + index);
1463 #endif
1464                         break;
1465                 default:
1466                         break;
1467         }
1468 }
1469
1470 Eina_Bool setting_security_locktype_click_softkey_back_cb(void *data, Elm_Object_Item *it)
1471 {
1472         SETTING_TRACE_BEGIN;
1473         /* error check */
1474         retvm_if(data == NULL, EINA_FALSE, "[Setting > Security] Data parameter is NULL");
1475
1476         SettingSecurityUG *ad = (SettingSecurityUG *) data;
1477         if (ad->ug_passwd) {
1478                 return EINA_FALSE;
1479         }
1480
1481         if (&setting_view_security_locktype == ad->view_to_load) {
1482                 /* Send destroy request */
1483                 ug_destroy_me(ad->ug);
1484         } else {
1485                 setting_view_change(&setting_view_security_locktype, &setting_view_security_main, ad);
1486         }
1487         SETTING_TRACE_END;
1488         return EINA_TRUE;
1489 }