aboutsummaryrefslogtreecommitdiff
path: root/main.qml
diff options
context:
space:
mode:
authordsc <xmrdsc@protonmail.com>2018-12-13 19:02:02 +0100
committerdsc <xmrdsc@protonmail.com>2018-12-20 10:38:38 +0100
commit5bebf83d52d39e833d0e299663165145ab940a92 (patch)
tree6f6266dfffc3772eed1faabc3c158b827d1b5dfb /main.qml
parentbac833c1dd95666e159406f290ad334decee2810 (diff)
downloadmonzero-gui-5bebf83d52d39e833d0e299663165145ab940a92.tar.gz
monzero-gui-5bebf83d52d39e833d0e299663165145ab940a92.tar.xz
monzero-gui-5bebf83d52d39e833d0e299663165145ab940a92.zip
Lock wallet on inactivity
Diffstat (limited to 'main.qml')
-rw-r--r--main.qml39
1 files changed, 39 insertions, 0 deletions
diff --git a/main.qml b/main.qml
index 84f7d38d..d8f9a699 100644
--- a/main.qml
+++ b/main.qml
@@ -75,6 +75,7 @@ ApplicationWindow {
property var cameraUi
property bool remoteNodeConnected: false
property bool androidCloseTapped: false;
+ property int userLastActive; // epoch
// Default daemon addresses
readonly property string localDaemonAddress : persistentSettings.nettype == NetworkType.MAINNET ? "localhost:18081" : persistentSettings.nettype == NetworkType.TESTNET ? "localhost:28081" : "localhost:38081"
property string currentDaemonAddress;
@@ -219,6 +220,8 @@ ApplicationWindow {
// Local daemon settings
walletManager.setDaemonAddress(localDaemonAddress)
+ // enable user inactivity timer
+ userInActivityTimer.running = true;
// wallet already opened with wizard, we just need to initialize it
if (typeof wizard.m_wallet !== 'undefined') {
@@ -932,6 +935,8 @@ ApplicationWindow {
rootItem.state = "wizard"
// reset balance
leftPanel.balanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(0);
+ // disable inactivity timer
+ userInActivityTimer.running = false;
}
function hideMenu() {
@@ -1041,6 +1046,8 @@ ApplicationWindow {
property int segregationHeight: 0
property int kdfRounds: 1
property bool hideBalance: false
+ property bool lockOnUserInActivity: true
+ property int lockOnUserInActivityInterval: 10 // minutes
}
// Information dialog
@@ -1696,6 +1703,12 @@ ApplicationWindow {
triggeredOnStart: false
}
+ Timer {
+ id: userInActivityTimer
+ interval: 2000; running: false; repeat: true
+ onTriggered: checkInUserActivity()
+ }
+
Rectangle {
id: statusMessage
z: 99
@@ -1823,6 +1836,32 @@ ApplicationWindow {
leftPanel.balanceLabelText = qsTr("Balance")
}
+ function userActivity() {
+ // register user activity
+ var epoch = Math.floor((new Date).getTime()/1000);
+ appWindow.userLastActive = epoch;
+ }
+
+ function checkInUserActivity() {
+ if(!persistentSettings.lockOnUserInActivity) return;
+
+ // prompt password after X seconds of inactivity
+ var epoch = Math.floor((new Date).getTime() / 1000);
+ var inactivity = epoch - appWindow.userLastActive;
+ if(inactivity < (persistentSettings.lockOnUserInActivityInterval * 60)) return;
+
+ passwordDialog.onAcceptedCallback = function() {
+ if(walletPassword === passwordDialog.password){
+ passwordDialog.close();
+ } else {
+ passwordDialog.showError(qsTr("Wrong password"));
+ }
+ }
+
+ passwordDialog.onRejectedCallback = function() { appWindow.showWizard(); }
+ passwordDialog.open();
+ }
+
// Daemon console
DaemonConsole {
id: daemonConsolePopup