Initial buildable version of FIDO Lock UI 94/119594/5 accepted/tizen_common accepted/tizen_mobile accepted/tizen_wearable accepted/tizen/common/20170330.151844 accepted/tizen/mobile/20170330.224746 accepted/tizen/unified/20170330.224830 accepted/tizen/wearable/20170330.224811 submit/tizen/20170324.100006 submit/tizen/20170330.074029
authorManasij Sur Roy <manasij.r@samsung.com>
Fri, 17 Mar 2017 12:11:05 +0000 (17:41 +0530)
committerManasij Sur Roy <manasij.r@samsung.com>
Tue, 21 Mar 2017 09:03:45 +0000 (14:33 +0530)
Change-Id: I0d373c9e945215403993fdf02c5581f578737ea8
Signed-off-by: Manasij Sur Roy <manasij.r@samsung.com>
22 files changed:
.gitignore [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
edc_resource/fido-syspopup.edc [new file with mode: 0644]
inc/key_storage_handler.h [new file with mode: 0644]
inc/main.h [new file with mode: 0644]
inc/password_handler.h [new file with mode: 0644]
inc/util.h [new file with mode: 0644]
org.tizen.fido-syspopup.manifest [new file with mode: 0644]
org.tizen.fido-syspopup.png [new file with mode: 0644]
org.tizen.fido-syspopup.xml [new file with mode: 0755]
packaging/fido-syspopup.spec [new file with mode: 0644]
po/CMakeLists.txt [new file with mode: 0644]
po/en_US.po [new file with mode: 0644]
res/fido-syspopup.edc [new file with mode: 0644]
res/images/popup_btn_cancel.png [new file with mode: 0644]
res/images/popup_btn_check.png [new file with mode: 0644]
src/asm_ui.c [new file with mode: 0644]
src/key_storage_handler.c [new file with mode: 0644]
src/lockscreen.c [new file with mode: 0644]
src/main.c [new file with mode: 0644]
src/password_handler.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..080e5b2
--- /dev/null
@@ -0,0 +1,5 @@
+*.config
+*.creator
+*.user
+*.files
+*.includes
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..67a6e3b
--- /dev/null
@@ -0,0 +1,101 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(fido-syspopup C)
+
+SET(PACKAGE org.tizen.fido-syspopup)
+
+FILE(GLOB SRCS
+       src/main.c
+       src/lockscreen.c
+       src/asm_ui.c
+       src/password_handler.c
+       src/key_storage_handler.c
+)
+
+# Mobile profile
+IF("${PROFILE}" STREQUAL "mobile")
+       ADD_DEFINITIONS("-D_MOBILE_")
+ENDIF("${PROFILE}" STREQUAL "mobile")
+
+# Wearable profile
+IF("${PROFILE}" STREQUAL "wearable")
+       ADD_DEFINITIONS("-D_WEARABLE_")
+ENDIF("${PROFILE}" STREQUAL "wearable")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/inc)
+
+FIND_LIBRARY(LIB_M m)
+
+SET(PKG_LDFLAGS "-pthread ${LIB_M} -pie")
+SET(PKG_CFLAGS "-g -Wall -fPIE -funroll-loops")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(BASE_PKG REQUIRED elementary efl-extension)
+FOREACH(flag ${BASE_PKG_CFLAGS})
+       SET(PKG_CFLAGS "${PKG_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+FOREACH(flag ${BASE_PKG_LDFLAGS})
+       SET(PKG_LDFLAGS "${PKG_LDFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+pkg_check_modules(TIZEN_PKG REQUIRED
+       dlog
+       bundle
+       gio-2.0
+       json-glib-1.0
+       appcore-efl
+       capi-appfw-application
+       capi-system-system-settings
+       capi-system-device
+       capi-appfw-app-manager
+       syspopup
+       auth-fw
+       buxton2
+)
+
+FOREACH(flag ${TIZEN_PKG_CFLAGS})
+       SET(PKG_CFLAGS "${PKG_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+FOREACH(flag ${TIZEN_PKG_LDFLAGS})
+       SET(PKG_LDFLAGS "${PKG_LDFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PKG_CFLAGS}")
+
+# install desktop file & icon
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(SHDIR "${PREFIX}/shared")
+SET(RESDIR "${PREFIX}/res")
+SET(LOCALEDIR "${RESDIR}/locale")
+SET(IMGDIR "${RESDIR}/images")
+
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DLOCALE_DIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DICON_DIR=\"${IMGDIR}\"")
+ADD_DEFINITIONS("-DEDJ_FILE=\"${RESDIR}/${PROJECT_NAME}.edj\"")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKG_LDFLAGS})
+
+ADD_CUSTOM_TARGET(${PROJECT_NAME}.edj
+       COMMAND edje_cc -no-save -id ${CMAKE_CURRENT_SOURCE_DIR}/edje/images -id ${CMAKE_CURRENT_SOURCE_DIR}/res/images
+       ${CMAKE_SOURCE_DIR}/res/${PROJECT_NAME}.edc ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.edj
+       DEPENDS ${CMAKE_SOURCE_DIR}/res/${PROJECT_NAME}.edc
+)
+
+ADD_DEPENDENCIES(${PROJECT_NAME} ${PROJECT_NAME}.edj)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+# for workaround taskmanager behaviour
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PACKAGE}.png DESTINATION ${SHDIR}/res/)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.edj DESTINATION ${RESDIR})
+
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/images/ DESTINATION ${IMGDIR} FILES_MATCHING PATTERN "*.png")
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/${PACKAGE}.xml ${CMAKE_SOURCE_DIR}/${PACKAGE}.xml @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PACKAGE}.xml DESTINATION ${PKG_MANIFEST_PATH})
+
+# i18n
+ADD_SUBDIRECTORY(po)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..4544429
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,178 @@
+Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
diff --git a/edc_resource/fido-syspopup.edc b/edc_resource/fido-syspopup.edc
new file mode 100644 (file)
index 0000000..90537f5
--- /dev/null
@@ -0,0 +1,52 @@
+collections {
+   group { name: "main";
+      parts {
+         part { name: "txt_title";
+            type: TEXT;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               text { text: "Enter 4 digit PIN"; font: "Tizen:style=regular"; size: 40; min: 1 1; align: 0 0.717; ellipsis: -1; }
+               color: 0 0 0 255;
+            }
+         }
+         swallow { "";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.00 0.50;
+               rel2.relative: 1.00 1.00;
+            }
+         }
+         swallow { "swallow_entry";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.00 0.50;
+               rel2.relative: 1.00 1.00;
+
+            }
+         }
+
+         swallow { "swallow_button";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.6767 0.5000;
+               rel2.relative: 0.9467 0.6100;
+            }
+         }
+         swallow { "swallow_popup";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.00 0.54;
+               rel2.relative: 1.00 0.60;
+            }
+         }
+      }
+   }
+}
diff --git a/inc/key_storage_handler.h b/inc/key_storage_handler.h
new file mode 100644 (file)
index 0000000..4201420
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef KEY_STORAGE_HANDLER_H
+#define KEY_STORAGE_HANDLER_H
+
+int ks_notify(const char *ts, bool data);
+
+#endif // KEY_STORAGE_HANDLER_H
diff --git a/inc/main.h b/inc/main.h
new file mode 100644 (file)
index 0000000..a53314e
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __main_H__
+#define __main_H__
+
+#include <app.h>
+#include <app_control.h>
+#include <app_control_internal.h>
+#include <device/haptic.h>
+#include <bundle.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+#include <syspopup.h>
+#include <dlog.h>
+#include <glib.h>
+#include <app.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+
+#include <dlog.h>
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "FIDO-SYSPOPUP"
+
+#ifdef PKG_NAME
+#undef PKG_NAME
+#endif
+#define PKG_NAME "org.tizen.fido-syspopup"
+
+#ifdef EDJ_FILE
+#undef EDJ_FILE
+#endif
+#define EDJ_FILE "fido-syspopup.edj"
+
+#ifdef ICON_DIR
+#undef ICON_DIR
+#endif
+#define ICON_DIR "/usr/apps/org.tizen.fido-syspopup/res/images"
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "pin"
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.example.pin"
+#endif
+//#define EDJ_FILE "edje/pin.edj"
+#define PIN_LIMIT 3
+#define GRP_MAIN "main"
+
+typedef struct appdata{
+       Evas_Object* win;
+       Evas_Object* layout;
+       Evas_Object* conform;
+       Evas_Object* label;
+       Evas_Object* entry;
+       Evas_Object* entry_confirm;
+       Evas_Object* layout_confirm;
+       Evas_Object* Button;
+       Evas_Object* Naviframe;
+       Evas_Object* popup;
+       const char *pin_buffer;
+       const char *confirm_buffer;
+       char *ts_Caller;
+       int attempt;
+} appdata_s;
+
+#endif /* __main_H__ */
diff --git a/inc/password_handler.h b/inc/password_handler.h
new file mode 100644 (file)
index 0000000..b9cab1f
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef PASSWORD_HANDLER_H
+#define PASSWORD_HANDLER_H
+
+/*Pwd update not allowed*/
+int password_handler_set_password(const char *pwd);
+
+bool password_handler_is_password_set(void);
+
+bool password_handler_verify_password(const char *pwd);
+
+#endif // PASSWORD_HANDLER_H
diff --git a/inc/util.h b/inc/util.h
new file mode 100644 (file)
index 0000000..bcd864e
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef UTIL_H
+#define UTIL_H
+#include <tizen.h>
+#include <dlog.h>
+
+#define RET_IF_FAIL_VOID(cond) do {\
+               if (!(cond)){\
+                       return;\
+               }\
+} while(0)
+
+#define RET_IF_FAIL(cond, err) do {\
+               if (!(cond)){\
+                       return err;\
+               }\
+} while(0)
+
+#define CATCH_IF_FAIL(cond) do {\
+               if (!(cond)){\
+                       goto CATCH;\
+               }\
+} while(0)
+
+#define CATCH_IF_FAIL_X(cond, expr) do {\
+               if (!(cond)){\
+                       expr;\
+                       goto CATCH;\
+               }\
+} while(0)
+
+#define GOTO_IF_FAIL(cond, catch_block) do {\
+               if (!(cond)){\
+                       goto catch_block;\
+               }\
+} while(0)
+
+#define SAFE_DELETE(x) do {\
+       if (x != NULL) {\
+               free(x);    \
+               x = NULL;\
+       }\
+} while(0)
+
+#define _SAFE_DUP(x) ((x) ? strdup(x) : NULL)
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "org.tizen.fido-syspopup"
+
+#ifndef _ERR
+#define _ERR(fmt, args...) LOGE("[%s:%d] " fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) LOGD("[%s:%d] " fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) LOGI("[%s:%d] " fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _BEGIN
+#define _BEGIN LOGI("[%s:%d] START \n", __func__, __LINE__)
+#endif
+
+#ifndef _END
+#define _END LOGI("[%s:%d] END \n", __func__, __LINE__)
+#endif
+
+#define ALLOC(type) (type *)calloc(1, sizeof(type))
+#define NALLOC(num, type) (type *)calloc(num, sizeof(type))
+
+#endif // UTIL_H
diff --git a/org.tizen.fido-syspopup.manifest b/org.tizen.fido-syspopup.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/org.tizen.fido-syspopup.png b/org.tizen.fido-syspopup.png
new file mode 100644 (file)
index 0000000..9765b1b
Binary files /dev/null and b/org.tizen.fido-syspopup.png differ
diff --git a/org.tizen.fido-syspopup.xml b/org.tizen.fido-syspopup.xml
new file mode 100755 (executable)
index 0000000..9c3ed38
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="@PACKAGE@" api-version="3.0" version="@PKG_VERSION@" install-location="internal-only">
+
+    <label>fido-syspopup</label>
+    <description>Tizen FIDO Convergence system popup</description>
+
+    <ui-application appid="@PACKAGE@" exec="@BINDIR@/@PROJECT_NAME@" nodisplay="true" multiple="false" type="capp" taskmanage="true">
+        <label>fido-syspopup</label>
+        <label xml:lang="en-us">fido-syspopup</label>
+    </ui-application>
+
+       <privileges>
+        <privilege>http://tizen.org/privilege/mediastorage</privilege>
+        <privilege>http://tizen.org/privilege/externalstorage</privilege>
+        <privilege>http://tizen.org/privilege/content.write</privilege>
+    </privileges>
+
+</manifest>
diff --git a/packaging/fido-syspopup.spec b/packaging/fido-syspopup.spec
new file mode 100644 (file)
index 0000000..283b35d
--- /dev/null
@@ -0,0 +1,71 @@
+Name: org.tizen.fido-syspopup
+Version:    1.0
+Release:    1
+Summary: Tizen FIDO system popup
+Source: %{name}-%{version}.tar.gz
+License: Apache-2.0
+Group: Applications/Core Applications
+
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(json-glib-1.0)
+BuildRequires:  pkgconfig(edje)
+BuildRequires:  pkgconfig(elementary)
+BuildRequires:  pkgconfig(efl-extension)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(capi-system-system-settings)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(capi-system-device)
+BuildRequires:  pkgconfig(auth-fw)
+BuildRequires: pkgconfig(buxton2)
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(syspopup)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  app-core-efl-devel
+BuildRequires:  efl-extension-devel
+BuildRequires:  cmake
+BuildRequires:  gettext-tools
+BuildRequires:  edje-bin
+Requires:       %{name}-binary = %{version}-%{release}
+Requires(post): /usr/bin/buxton2ctl
+
+%description
+Tizen FIDO Convergence system popup
+
+%prep
+%setup -q
+
+%define _pkg_dir %{TZ_SYS_RO_APP}/%{name}
+
+%build
+rm -rf CMakeFiles CMakeCache.txt && cmake . -DCMAKE_INSTALL_PREFIX=%{_pkg_dir} -DPKG_MANIFEST_PATH=%{TZ_SYS_RO_PACKAGES} -DPKG_VERSION=%{version}
+make %{?jobs:-j%jobs}
+
+rm -rf CMakeFiles CMakeCache.txt && cmake . -DCMAKE_INSTALL_PREFIX=%{_pkg_dir} -DPKG_MANIFEST_PATH=%{TZ_SYS_RO_PACKAGES} -DPKG_VERSION=%{version} -DPROFILE=mobile
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+install -m 0755 fido-syspopup %{buildroot}%{_pkg_dir}/bin/
+
+mkdir -p %{buildroot}/%{_datadir}/packages/
+cp %{_builddir}/%{buildsubdir}/org.tizen.fido-syspopup.xml %{buildroot}/%{_datadir}/packages/org.tizen.fido-syspopup.xml
+
+mkdir -p %{buildroot}/%{_datadir}/license
+cp %{_builddir}/%{buildsubdir}/LICENSE %{buildroot}/%{_datadir}/license/%{name}
+
+%post
+buxton2ctl -i -d create-int32 "system" "LOCK_PWD_VERIFY_STATUS_KEY" "0" "http://tizen.org/privilege/internal/default/public" "http://tizen.org/privilege/internal/default/public"
+buxton2ctl -i -d create-string "system" "LOCK_PWD_VERIFY_STATUS_TS_KEY" "-1" "http://tizen.org/privilege/internal/default/public" "http://tizen.org/privilege/internal/default/public"
+
+%files
+%defattr(-,root,root,-)
+%{_pkg_dir}/bin/fido-syspopup
+%{_pkg_dir}/res/*
+%{_pkg_dir}/shared/*
+%{_datadir}/locale/*/LC_MESSAGES/*.mo
+%{TZ_SYS_RO_PACKAGES}/%{name}.xml
+%{_datadir}/license/%{name}
+%manifest %{name}.manifest
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4c2d9c8
--- /dev/null
@@ -0,0 +1,23 @@
+SET(POFILES
+       en_US.po
+)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+       SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+       MESSAGE(PO: "  ${pofile}")
+       GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+       GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+       SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+       ADD_CUSTOM_COMMAND(
+                       OUTPUT ${moFile}
+                       COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+                       DEPENDS ${absPofile}
+       )
+       INSTALL(FILES ${moFile}
+               DESTINATION /usr/share/locale/${lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
+       SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
diff --git a/po/en_US.po b/po/en_US.po
new file mode 100644 (file)
index 0000000..abb8891
--- /dev/null
@@ -0,0 +1,27 @@
+msgid "IDS_ST_BUTTON_CANCEL_ABB11"
+msgstr "Cancel"
+
+msgid "IDS_AT_TPOP_CONNECTION_REQUEST_CANCELLED_BY_OTHER_DEVICE"
+msgstr "Connection request canceled by other device."
+
+msgid "IDS_AT_BUTTON_CONNECT_ABB8"
+msgstr "Connect"
+
+msgid "IDS_AT_TPOP_CONNECTION_REQUEST_CANCELLED_BY_THIS_DEVICE"
+msgstr "Connection request canceled by this device."
+
+msgid "IDS_AT_POP_ENTER_THE_PASSWORD_THAT_IS_SHOWN_ON_THE_DEVICE_YOU_ARE_TRYING_TO_CONNECT_TO"
+msgstr "Enter the password that is shown on the device you are trying to connect to."
+
+msgid "IDS_AT_POP_PS_WANTS_TO_CONNECT_TO_THIS_DEVICE_TO_ALLOW_THIS_ENTER_THE_PASSWORD_SHOWN_BELOW_ON_THE_OTHER_DEVICE_TO_DENY_THE_CONNECTION_REQUEST_TAP_CANCEL"
+msgstr "%s wants to connect to this device. To allow this, enter the password shown below on the other device. To deny the connection request, tap Cancel."
+
+msgid "IDS_AT_HEADER_CONNECT_TO_DEVICE"
+msgstr "Connect to device"
+
+msgid "IDS_AT_TPOP_CONNECTED_TO_PS"
+msgstr "Connected to %s."
+
+msgid "IDS_AT_TPOP_INCORRECT_PASSWORD_ENTERED_TRY_AGAIN"
+msgstr "Incorrect password entered. Try again."
+
diff --git a/res/fido-syspopup.edc b/res/fido-syspopup.edc
new file mode 100644 (file)
index 0000000..9c014c0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+collections {
+   group { name: "main";
+      parts {
+         part { name: "txt_title";
+            type: TEXT;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               text { text: "Enter 4 digit PIN"; font: "Tizen:style=regular"; size: 40; min: 1 1; align: 0 0.717; ellipsis: -1; }
+               color: 0 0 0 255;
+            }
+         }
+         swallow { "";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.00 0.50;
+               rel2.relative: 1.00 1.00;
+            }
+         }
+         swallow { "swallow_entry";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.00 0.50;
+               rel2.relative: 1.00 1.00;
+
+            }
+         }
+
+         swallow { "swallow_button";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.6767 0.5000;
+               rel2.relative: 0.9467 0.6100;
+            }
+         }
+         swallow { "swallow_popup";
+            scale: 1;
+            desc { "default";
+               visible: 1;
+               align: 0.5 0.5;
+               rel1.relative: 0.00 0.54;
+               rel2.relative: 1.00 0.60;
+            }
+         }
+      }
+   }
+}
+
diff --git a/res/images/popup_btn_cancel.png b/res/images/popup_btn_cancel.png
new file mode 100644 (file)
index 0000000..5f346cb
Binary files /dev/null and b/res/images/popup_btn_cancel.png differ
diff --git a/res/images/popup_btn_check.png b/res/images/popup_btn_check.png
new file mode 100644 (file)
index 0000000..f20f62e
Binary files /dev/null and b/res/images/popup_btn_check.png differ
diff --git a/src/asm_ui.c b/src/asm_ui.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/key_storage_handler.c b/src/key_storage_handler.c
new file mode 100644 (file)
index 0000000..dfab5ee
--- /dev/null
@@ -0,0 +1,65 @@
+
+#include "util.h"
+#include <buxton2.h>
+
+#define PWD_VERIFY_STATUS_TS_KEY "LOCK_PWD_VERIFY_STATUS_TS_KEY"
+#define PWD_VERIFY_STATUS_KEY "LOCK_PWD_VERIFY_STATUS_KEY"
+
+/*1. auth_plugin sends ts to syspopup via bundle*/
+/*2. auth_plugin waits until PWD_VERIFY_STATUS_TS_KEY is same as set in 1 */
+/*3. syspopup verifies user password*/
+/*4. syspopup sets PWD_VERIFY_STATUS_KEY = true/false*/
+/*5. syspopup sets PWD_VERIFY_STATUS_TS_KEY = ts sent during 1 and exits*/
+/*6. When auth_plugin finds PWD_VERIFY_STATUS_TS_KEY = same as ts sent during 1*/
+/*7. auth_plugin gets PWD_VERIFY_STATUS_KEY*/
+
+int
+ks_notify(const char *ts, bool data)
+{
+       _INFO("fido ts = [%s]", ts);
+
+       int r;
+       struct buxton_client *cli;
+       struct buxton_layer *layer;
+       struct buxton_value *val_bool = buxton_value_create_boolean(data);
+       struct buxton_value *val_ts = buxton_value_create_string(ts);
+
+       r = buxton_open(&cli, NULL, NULL);
+       if (r) {
+               _ERR("buxton_open=[%d]", r);
+               return -1;
+       }
+
+       layer = buxton_create_layer("system");
+       _INFO("buxton layer=[%p]", layer);
+
+       r = buxton_set_value_sync(cli, layer, PWD_VERIFY_STATUS_KEY, val_bool);
+       _INFO("buxton_set_value_sync=[%d]", r);
+       if (r != 0) {
+               char err_buf[1024];
+               strerror_r(errno, err_buf, sizeof(err_buf));
+               _ERR("buxton_set_value_sync=[%s]", err_buf);
+//             r = buxton_key_create("fido", PWD_VERIFY_STATUS_KEY, "system", INT32);
+//             _INFO("buxton_key_create=[%d]", r);
+
+//             r = buxton_set_value_sync(cli, layer, PWD_VERIFY_STATUS_KEY, val_bool);
+//             _INFO("buxton_set_value_sync=[%d]", r);
+       }
+       r = buxton_set_value_sync(cli, layer, PWD_VERIFY_STATUS_TS_KEY, val_ts);
+       _INFO("buxton_set_value_sync=[%d]", r);
+       if (r != 0) {
+               char err_buf[1024];
+               strerror_r(errno, err_buf, sizeof(err_buf));
+               _ERR("buxton_set_value_sync=[%s]", err_buf);
+       }
+
+       buxton_value_free(val_bool);
+       buxton_value_free(val_ts);
+
+       buxton_free_layer(layer);
+
+       buxton_close(cli);
+
+       return 0;
+
+}
diff --git a/src/lockscreen.c b/src/lockscreen.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/main.c b/src/main.c
new file mode 100644 (file)
index 0000000..a77ce67
--- /dev/null
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "main.h"
+#include "password_handler.h"
+#include "util.h"
+#include "key_storage_handler.h"
+
+static Elm_Entry_Filter_Limit_Size limit_size = {
+       .max_char_count = 4,
+       .max_byte_count = 0
+};
+
+static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static void layout_back_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       appdata_s *ad = data;
+       /* Let window go to hide state. */
+       elm_win_lower(ad->win);
+       ui_app_exit();
+}
+
+static void app_get_resource(const char *edj_file_in, char *edj_path_out, int edj_path_max)
+{
+       char *res_path = app_get_resource_path();
+       if (res_path) {
+               snprintf(edj_path_out, edj_path_max, "%s%s", res_path,
+                               edj_file_in);
+               free(res_path);
+       }
+}
+
+void
+confirm_call(void *data, Evas_Object *obj, void *event_info) {
+
+       appdata_s *ad = data;
+       int ret = password_handler_set_password(ad->pin_buffer);
+       if (ret != 0 ) {
+               _ERR("failed");
+               ks_notify(ad->ts_Caller, false);
+               elm_exit();
+       }
+       /*TODO buxton notify*/
+       ks_notify(ad->ts_Caller, true);
+       elm_exit();
+}
+
+void
+click_login_btn(void *data, Evas_Object *obj, void *even_info) {
+
+       appdata_s *ad = data;
+       Evas_Object *popup;
+       Evas_Object *bg = elm_bg_add(ad->Naviframe);
+       elm_bg_color_set(bg, 66, 162, 206);
+
+       popup = elm_popup_add(ad->layout);
+       elm_popup_align_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+       elm_popup_timeout_set(popup, 1.0);
+
+       ad->pin_buffer = elm_entry_entry_get(ad->entry);
+
+       bool is_verified = password_handler_verify_password(ad->pin_buffer);
+       if (is_verified == true) {
+               ks_notify(ad->ts_Caller, is_verified);
+               elm_exit();
+       }
+
+       ad->attempt++;
+       if (ad->attempt > 2) {
+               ks_notify(ad->ts_Caller, false);
+               elm_exit();
+       }
+
+       elm_object_text_set(popup, "Incorrect PIN");
+       evas_object_show(popup);
+
+}
+
+void clicked_cb(void *data, Evas_Object *obj, void *event_info) {
+
+
+       char edj_path[PATH_MAX] = {0, };
+
+
+       appdata_s *ad = data;
+       Evas_Object* Button;
+
+       ad->pin_buffer = elm_entry_entry_get(ad->entry);
+
+
+       if ((ad->pin_buffer != NULL) &&
+                       (*ad->pin_buffer!='\0')) {
+               /* New Base Layout */
+               app_get_resource(EDJ_FILE, edj_path, (int)PATH_MAX);
+               ad->layout_confirm = elm_layout_add(ad->Naviframe);
+               elm_layout_file_set(ad->layout_confirm, edj_path, GRP_MAIN);
+               evas_object_size_hint_weight_set(ad->layout_confirm,
+                               EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               eext_object_event_callback_add(ad->layout_confirm,
+                       EEXT_CALLBACK_BACK, layout_back_cb, ad);
+               evas_object_show(ad->layout_confirm);
+
+
+               /*Button*/
+               Button = elm_button_add(ad->layout_confirm);
+               evas_object_size_hint_weight_set(Button, EVAS_HINT_EXPAND,
+                                                       EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(Button, EVAS_HINT_FILL, 1);
+               elm_object_text_set(Button, "Confirm");
+               evas_object_smart_callback_add(Button, "clicked",
+                                               confirm_call, ad);
+
+               elm_object_part_content_set(ad->layout_confirm,
+                                        "swallow_button", Button);
+               elm_box_pack_end(ad->layout_confirm, Button);
+               evas_object_show(Button);
+
+               /*entry*/
+               ad->entry_confirm = elm_entry_add(ad->layout_confirm);
+               evas_object_size_hint_weight_set(ad->entry_confirm,
+                               EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(ad->entry_confirm,
+                               EVAS_HINT_FILL, EVAS_HINT_FILL);
+               elm_entry_input_panel_layout_set(ad->entry_confirm,
+                               ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
+               elm_object_part_content_set(ad->layout_confirm,
+                               "swallow_entry", ad->entry_confirm);
+               elm_entry_password_set(ad->entry_confirm, EINA_TRUE);
+               elm_entry_markup_filter_append(ad->entry_confirm,
+                               elm_entry_filter_limit_size, &limit_size);
+               evas_object_show(ad->entry_confirm);
+               elm_object_focus_set(ad->entry_confirm, true);
+
+
+               elm_naviframe_prev_btn_auto_pushed_set(ad->Naviframe, EINA_TRUE);
+               elm_naviframe_item_push(ad->Naviframe, "CONFIRM", NULL, NULL,
+                               ad->layout_confirm, NULL);
+
+
+               /* Show window after base gui is set up */
+               evas_object_show(ad->win);
+
+       }
+
+}
+
+static void create_login_gui(appdata_s *ad)
+{
+       char edj_path[PATH_MAX] = {0, };
+
+       /* Window */
+       /* Create and initialize elm_win.
+          elm_win is mandatory to manipulate window. */
+       ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+       elm_win_conformant_set(ad->win, EINA_TRUE);
+       elm_win_autodel_set(ad->win, EINA_TRUE);
+
+       if (elm_win_wm_rotation_supported_get(ad->win)) {
+               int rots[4] = { 0, 90, 180, 270 };
+               elm_win_wm_rotation_available_rotations_set(ad->win,
+                               (const int *)(&rots), 4);
+       }
+
+       evas_object_smart_callback_add(ad->win, "delete, request",
+                       win_delete_request_cb, NULL);
+
+       /* Conformant */
+       /* Create and initialize elm_conformant.
+          elm_conformant is mandatory for base gui to have proper size
+          when indicator or virtual keypad is visible. */
+       ad->conform = elm_conformant_add(ad->win);
+       elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
+       evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND,
+                                                       EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(ad->win, ad->conform);
+       evas_object_show(ad->conform);
+
+
+       /*Naviframe*/
+       ad->Naviframe = elm_naviframe_add(ad->conform);
+       elm_object_content_set(ad->conform, ad->Naviframe);
+       evas_object_show(ad->Naviframe);
+
+       /* New Base Layout */
+       app_get_resource(EDJ_FILE, edj_path, (int)PATH_MAX);
+       ad->layout = elm_layout_add(ad->Naviframe);
+       elm_layout_file_set(ad->layout, edj_path, GRP_MAIN);
+       evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND,
+                                                  EVAS_HINT_EXPAND);
+       eext_object_event_callback_add(ad->layout, EEXT_CALLBACK_BACK,
+                                               layout_back_cb, ad);
+       elm_object_content_set(ad->Naviframe, ad->layout);
+       evas_object_show(ad->layout);
+
+       /*Button*/
+       ad->Button = elm_button_add(ad->layout);
+       evas_object_size_hint_weight_set(ad->Button, EVAS_HINT_EXPAND,
+                                                  EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(ad->Button, EVAS_HINT_FILL, 1);
+       elm_object_text_set(ad->Button, "ok");
+       evas_object_smart_callback_add(ad->Button, "clicked", click_login_btn, ad);
+       elm_object_part_content_set(ad->layout, "swallow_button", ad->Button);
+       elm_box_pack_end(ad->layout, ad->Button);
+       evas_object_show(ad->Button);
+
+       /*entry*/
+       ad->entry = elm_entry_add(ad->layout);
+       evas_object_size_hint_weight_set(ad->entry, EVAS_HINT_EXPAND,
+                                                  EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(ad->entry, EVAS_HINT_FILL,
+                                               EVAS_HINT_FILL);
+       elm_entry_input_panel_layout_set(ad->entry,
+                               ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
+       elm_object_part_content_set(ad->layout, "swallow_entry", ad->entry);
+       elm_entry_password_set(ad->entry, EINA_TRUE);
+       elm_entry_markup_filter_append(ad->entry, elm_entry_filter_limit_size,
+                                                               &limit_size);
+       evas_object_show(ad->entry);
+       elm_object_focus_set(ad->entry, true);
+       //elm_object_part_text_set(ad->entry, "Enter 4 digit PIN");
+       //elm_entry_entry_insert(ad->entry, "Enter 4 digit PIN");
+
+       elm_naviframe_item_push(ad->Naviframe, "PIN", NULL, NULL, ad->layout,
+                                                                       NULL);
+
+
+       /* Show window after base gui is set up */
+       evas_object_show(ad->win);
+
+
+
+}
+
+static void create_base_gui(appdata_s *ad)
+{
+       char edj_path[PATH_MAX] = {0, };
+
+       /* Window */
+       /* Create and initialize elm_win.
+          elm_win is mandatory to manipulate window. */
+       ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+       elm_win_conformant_set(ad->win, EINA_TRUE);
+       elm_win_autodel_set(ad->win, EINA_TRUE);
+
+       if (elm_win_wm_rotation_supported_get(ad->win)) {
+               int rots[4] = { 0, 90, 180, 270 };
+               elm_win_wm_rotation_available_rotations_set(ad->win,
+                                       (const int *)(&rots), 4);
+       }
+
+       evas_object_smart_callback_add(ad->win, "delete, request",
+                               win_delete_request_cb, NULL);
+
+       /* Conformant */
+       /* Create and initialize elm_conformant.
+          elm_conformant is mandatory for base gui to have proper size
+          when indicator or virtual keypad is visible. */
+       ad->conform = elm_conformant_add(ad->win);
+       elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
+       evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND,
+                                               EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(ad->win, ad->conform);
+       evas_object_show(ad->conform);
+
+
+       /*Naviframe*/
+       ad->Naviframe = elm_naviframe_add(ad->conform);
+       elm_object_content_set(ad->conform, ad->Naviframe);
+       evas_object_show(ad->Naviframe);
+
+       /* New Base Layout */
+       app_get_resource(EDJ_FILE, edj_path, (int)PATH_MAX);
+       ad->layout = elm_layout_add(ad->Naviframe);
+       elm_layout_file_set(ad->layout, edj_path, GRP_MAIN);
+       evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND,
+                                               EVAS_HINT_EXPAND);
+       eext_object_event_callback_add(ad->layout, EEXT_CALLBACK_BACK,
+                                               layout_back_cb, ad);
+       elm_object_content_set(ad->Naviframe, ad->layout);
+       evas_object_show(ad->layout);
+
+
+
+       /*Button*/
+       ad->Button = elm_button_add(ad->layout);
+       evas_object_size_hint_weight_set(ad->Button, EVAS_HINT_EXPAND,
+                                               EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(ad->Button, EVAS_HINT_FILL, 1);
+       elm_object_text_set(ad->Button, "ok");
+       evas_object_smart_callback_add(ad->Button, "clicked", clicked_cb, ad);
+       elm_object_part_content_set(ad->layout, "swallow_button", ad->Button);
+       elm_box_pack_end(ad->layout, ad->Button);
+       evas_object_show(ad->Button);
+
+       /*entry*/
+       ad->entry= elm_entry_add(ad->layout);
+       evas_object_size_hint_weight_set(ad->entry, EVAS_HINT_EXPAND,
+                                               EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(ad->entry, EVAS_HINT_FILL,
+                                               EVAS_HINT_FILL);
+       elm_entry_input_panel_layout_set(ad->entry,
+                       ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
+       elm_entry_password_set(ad->entry, EINA_TRUE);
+       elm_entry_markup_filter_append(ad->entry, elm_entry_filter_limit_size,
+                                                               &limit_size);
+       elm_object_part_content_set(ad->layout, "swallow_entry", ad->entry);
+       //elm_object_part_text_set(ad->entry, "Enter 4 digit PIN");
+       //elm_entry_entry_insert(ad->entry, "Enter 4 digit PIN");
+       evas_object_show(ad->entry);
+       elm_object_focus_set(ad->entry, true);
+
+       elm_naviframe_item_push(ad->Naviframe, "PIN", NULL, NULL, ad->layout,
+                                                               NULL);
+
+
+
+       /* Show window after base gui is set up */
+       evas_object_show(ad->win);
+
+
+}
+
+static bool app_create(void *data)
+{
+       /* Hook to take necessary actions before main event loop starts
+          Initialize UI resources and application's data
+          If this function returns true, the main loop of application starts
+          If this function returns false, the application is terminated */
+       return true;
+}
+
+static void
+app_control(app_control_h app_control, void *data)
+{
+       if (app_control == NULL || data == NULL) {
+               _ERR("app_control or data NULL");
+               elm_exit();
+       }
+
+       bundle *b = NULL;
+       int ret = app_control_export_as_bundle(app_control, &b);
+       if (ret != 0) {
+               _ERR("app_control_export_as_bundle=[%d]", ret);
+               free(b);
+               elm_exit();
+       }
+
+       char *ts = NULL;
+       bundle_get_str(b, "ts", &ts);
+       if (ts == NULL) {
+               _ERR("ts missing from launch request bundle");
+               free(b);
+               elm_exit();
+       }
+
+       appdata_s *ad = data;
+       ad->ts_Caller = _SAFE_DUP(ts);
+       _INFO("fido ts = [%s]", ad->ts_Caller);
+
+       /* Handle the launch request. */
+       bool is_set = password_handler_is_password_set();
+
+       if (is_set == true)
+               create_login_gui(data);
+       else
+               create_base_gui(data);
+}
+
+static void app_pause(void *data)
+{
+       /* Take necessary actions when application becomes invisible. */
+}
+
+static void app_resume(void *data)
+{
+       /* Take necessary actions when application becomes visible. */
+}
+
+static void app_terminate(void *data)
+{
+       /* Release all resources. */
+}
+
+static void ui_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_LANGUAGE_CHANGED*/
+
+       int ret;
+       char *language;
+
+       ret = app_event_get_language(event_info, &language);
+       if (ret != APP_ERROR_NONE) {
+               dlog_print(DLOG_ERROR, LOG_TAG,
+                       "app_event_get_language() failed. Err = %d.", ret);
+               return;
+       }
+
+       if (language != NULL) {
+               elm_language_set(language);
+               free(language);
+       }
+}
+
+static void ui_app_orient_changed(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
+       return;
+}
+
+static void ui_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void ui_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void ui_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+       /*APP_EVENT_LOW_MEMORY*/
+}
+
+int main(int argc, char *argv[])
+{
+       appdata_s ad = {0, };
+       int ret = 0;
+
+       ui_app_lifecycle_callback_s event_callback = {0, };
+       app_event_handler_h handlers[5] = {NULL, };
+
+       event_callback.create = app_create;
+       event_callback.terminate = app_terminate;
+       event_callback.pause = app_pause;
+       event_callback.resume = app_resume;
+       event_callback.app_control = app_control;
+
+       ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY],
+                       APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY],
+                       APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
+                       APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
+                       APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
+       ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
+                       APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
+
+       ret = ui_app_main(argc, argv, &event_callback, &ad);
+       if (ret != APP_ERROR_NONE) {
+               dlog_print(DLOG_ERROR, LOG_TAG,
+                               "ui_app_main() is failed. err = %d", ret);
+       }
+
+       return ret;
+}
diff --git a/src/password_handler.c b/src/password_handler.c
new file mode 100644 (file)
index 0000000..549c565
--- /dev/null
@@ -0,0 +1,65 @@
+#include "util.h"
+#include "password_handler.h"
+
+#include <auth-passwd.h>
+
+/*Pwd update not allowed*/
+int
+password_handler_set_password(const char *pwd)
+{
+       int ret = -1;
+       unsigned int attempt = 0;
+       unsigned int max_attempt = 0;
+       unsigned int expire_sec = 0;
+
+       ret = auth_passwd_check_passwd_state(AUTH_PWD_NORMAL, &attempt, &max_attempt, &expire_sec);
+       if(ret == AUTH_PASSWD_API_ERROR_NO_PASSWORD) {
+                _INFO("No prev password setting");
+                ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, NULL, pwd);
+                if(ret != AUTH_PASSWD_API_SUCCESS) {
+                                _ERR("auth_passwd_set_passwd failed = [%d]", ret);
+                                return ret;
+                }
+                return 0;
+       }
+
+       _ERR("Password update not allowed via fido-syspopup");
+       return -1;
+}
+
+bool
+password_handler_is_password_set(void)
+{
+       unsigned int attempt = 0;
+       unsigned int max_attempt = 0;
+       unsigned int expire_sec = 0;
+       int ret = auth_passwd_check_passwd_state(AUTH_PWD_NORMAL, &attempt, &max_attempt, &expire_sec);
+       _ERR("auth_passwd_check_passwd_state = [%d]", ret);
+       _ERR("attempt = [%d], max_attempt = [%d], expire_sec = [%d]", attempt,
+                max_attempt, expire_sec);
+
+       if (ret == AUTH_PASSWD_API_ERROR_NO_PASSWORD)
+               return false;
+
+       return true;
+}
+
+bool
+password_handler_verify_password(const char *pwd)
+{
+       unsigned int attempt = 0;
+       unsigned int max_attempt = 0;
+       unsigned int expire_sec = 0;
+
+       int ret = auth_passwd_check_passwd(AUTH_PWD_NORMAL, pwd, &attempt, &max_attempt, &expire_sec);
+       if(ret == AUTH_PASSWD_API_ERROR_PASSWORD_MISMATCH) {
+                _ERR("Wrong password, attempt [%d]", attempt);
+                return false;
+       }
+       else if(ret == AUTH_PASSWD_API_SUCCESS) {
+               _INFO("Correct password, attempt [%d]", attempt);
+               return true;
+       }
+       _ERR("auth_passwd_check_passwd = [%d]", ret);
+       return false;
+}