[Backup&reset] Password state check 08/156508/3
authorRadek Kintop <r.kintop@samsung.com>
Wed, 18 Oct 2017 13:41:51 +0000 (15:41 +0200)
committerRadek Kintop <r.kintop@samsung.com>
Thu, 19 Oct 2017 10:17:51 +0000 (12:17 +0200)
Change-Id: I01ac6ac559352b7dd1dff09efbb90d52c191e170
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
setting-backup-and-reset/CMakeLists.txt
setting-backup-and-reset/src/setting-backup-and-reset-main-view.c

index e008df285938973f1762386219e2ace62d83489f..1c11ab47b123366b3d9c814c5bbc341bf37d0cdd 100755 (executable)
@@ -7,6 +7,7 @@ SET(SETTING_PKG_BACKUP_AND_RESET "org.tizen.setting-backup-and-reset")
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs_setting_backup_and_reset REQUIRED
+       auth-fw
        capi-appfw-application
        dlog
        efl-extension
index 0f1ceec2af1efa3e2a60d64f0e65b3d5f44cd2a1..a8cb6c317e33b5d8ce78ac422a28cffecbf9fff1 100755 (executable)
@@ -17,6 +17,7 @@
  *
  */
 
+#include <auth-passwd.h>
 #include <efl_extension.h>
 
 #include "setting-backup-and-reset-main-view.h"
@@ -366,12 +367,36 @@ static void _password_check_result_cb(app_control_h request,
 
 static void second_warning_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
-
+       unsigned int current_attempts = 0;
+       unsigned int max_attempts = 0;
+       unsigned int valid_secs = 0;
+       int ret = AUTH_PASSWD_API_SUCCESS;
        SettingBackupReset *sbr = (SettingBackupReset *)data;
        evas_object_del(get_widget_specified_type_ancestor(obj, "elm_popup"));
-       app_launcher("org.tizen.setting-password|viewtype:SETTING_PW_TYPE_PASSWORD",
-                       _password_check_result_cb, sbr);
 
+#if SECURITY_SERVER
+       ret = auth_passwd_check_passwd_state(AUTH_PWD_NORMAL, &current_attempts,
+                       &max_attempts, &valid_secs);
+       SETTING_TRACE_DEBUG(
+                       "status of password: %d (cur attempt %d, max %d, expire %d)",
+                       ret, current_attempts, max_attempts, valid_secs);
+
+       if (AUTH_PASSWD_API_SUCCESS == ret) {
+               app_launcher(
+                               "org.tizen.setting-password|viewtype:SETTING_PW_TYPE_PASSWORD",
+                               _password_check_result_cb, sbr);
+       } else {
+               if (AUTH_PASSWD_API_ERROR_NO_PASSWORD == ret) {
+                       SETTING_TRACE("No password set");
+                       create_transition_popup(sbr);
+               } else {
+                       SETTING_TRACE_ERROR("Error getting password state: %s",
+                                                               get_error_message(ret));
+               }
+       }
+#else
+       create_transition_popup(sbr);
+#endif
 }
 
 static void first_warning_reset_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)