diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml index 2aa4247..9937bc8 100644 --- a/qml/cover/CoverPage.qml +++ b/qml/cover/CoverPage.qml @@ -41,15 +41,9 @@ CoverBackground { function updateOTP() { // get seconds from current Date var curDate = new Date(); - var type; if (lOTP.text == "------" || curDate.getSeconds() == 30 || curDate.getSeconds() == 0 || (curDate.getTime() - lastUpdated > 2000)) { - if (appWin.coverTitle.substr(0,6) == "Steam:") { - type = "TOTP_STEAM" - } else { - type = "TOTP" - } - appWin.coverOTP = OTP.calcOTP(appWin.coverSecret, type, 0); + appWin.coverOTP = OTP.calcOTP(appWin.coverSecret, appWin.coverType, 0); } // Change color of the OTP to red if less than 5 seconds left @@ -65,7 +59,7 @@ CoverBackground { Timer { interval: 1000 // Timer runs only when cover is visible and favourite is set - running: !Qt.application.active && appWin.coverSecret != "" && appWin.coverType == "TOTP" + running: !Qt.application.active && appWin.coverSecret != "" && (appWin.coverType == "TOTP" || appWin.coverType == "TOTP_STEAM") repeat: true onTriggered: updateOTP(); } @@ -113,7 +107,7 @@ CoverBackground { if (index < 0) index = appWin.listModel.count - 1 appWin.setCover(index); DB.setFav(appWin.coverTitle, appWin.coverSecret) - if (appWin.coverType == "TOTP") updateOTP(); + if (appWin.coverType == "TOTP" || appWin.coverType == "TOTP_STEAM") updateOTP(); } } } @@ -124,7 +118,7 @@ CoverBackground { if (index >= appWin.listModel.count) index = 0 appWin.setCover(index); DB.setFav(appWin.coverTitle, appWin.coverSecret) - if (appWin.coverType == "TOTP") updateOTP(); + if (appWin.coverType == "TOTP" || appWin.coverType == "TOTP_STEAM") updateOTP(); } } } diff --git a/qml/lib/storage.js b/qml/lib/storage.js index ec139ff..94fc281 100644 --- a/qml/lib/storage.js +++ b/qml/lib/storage.js @@ -200,13 +200,10 @@ function changeOTP(title, secret, type, counter, oldtitle, oldsecret) { db.transaction( function(tx) { - if (checkOTP(title, secret)) { - console.log("Token " + title + " is already in DB"); - } else { tx.executeSql("UPDATE OTPStorage SET title=?, secret=?, type=?, counter=? WHERE title=? and secret=?;", [title, secret, type, counter, oldtitle, oldsecret]); console.log("Token " + title + " modified."); } - }); + ); } function changeOTPSort(title, secret, sort) { diff --git a/qml/pages/AddOTP.qml b/qml/pages/AddOTP.qml index 11e4224..fe79017 100644 --- a/qml/pages/AddOTP.qml +++ b/qml/pages/AddOTP.qml @@ -67,7 +67,7 @@ Dialog { MenuItem { text: qsTr("Show QR-Code") onClicked: { - if ((paramType == "TOTP" && (otpLabel.text == "" || otpSecret.text == "")) || (paramType == "HOTP" && (otpLabel.text == "" || otpSecret.text == "" || otpCounter.text <= 0))) { + if (((paramType == "TOTP" || paramType == "TOTP_STEAM") && (otpLabel.text == "" || otpSecret.text == "")) || (paramType == "HOTP" && (otpLabel.text == "" || otpSecret.text == "" || otpCounter.text <= 0))) { notify.show(qsTr("Can't create QR-Code from incomplete settings!"), 4000); } else { pageStack.push(Qt.resolvedUrl("QRPage.qml"), {paramLabel: otpLabel.text, paramKey: otpSecret.text, paramType: paramType, paramCounter: otpCounter.text}); @@ -90,6 +90,7 @@ Dialog { menu: ContextMenu { MenuItem { text: qsTr("Time-based (TOTP)"); onClicked: { paramType = "TOTP" } } MenuItem { text: qsTr("Counter-based (HOTP)"); onClicked: { paramType = "HOTP" } } + MenuItem { text: qsTr("Steam Guard"); onClicked: { paramType = "TOTP_STEAM" } } } } TextField { @@ -115,8 +116,8 @@ Dialog { horizontalAlignment: TextInput.AlignLeft EnterKey.enabled: text.length > 15 - EnterKey.iconSource: paramType == "TOTP" ? "image://theme/icon-m-enter-accept" : "image://theme/icon-m-enter-next" - EnterKey.onClicked: paramType == "TOTP" ? addOTP.accept() : otpCounter.focus = true + EnterKey.iconSource: paramType == "HOTP" ? "image://theme/icon-m-enter-next" : "image://theme/icon-m-enter-accept" + EnterKey.onClicked: paramType == "HOTP" ? otpCounter.focus = true : addOTP.accept() } TextField { id: otpCounter @@ -137,7 +138,7 @@ Dialog { } // Check if we can Save - canAccept: otpLabel.text.length > 0 && otpSecret.text.length >= 16 && (paramType == "TOTP" || otpCounter.text.length > 0) ? true : false + canAccept: otpLabel.text.length > 0 && otpSecret.text.length >= 16 && (paramType == "TOTP" || paramType == "TOTP_STEAM" || otpCounter.text.length > 0) ? true : false // Save if page is Left with Add onDone: { diff --git a/qml/pages/MainView.qml b/qml/pages/MainView.qml index 8a82e61..eb6b865 100644 --- a/qml/pages/MainView.qml +++ b/qml/pages/MainView.qml @@ -69,20 +69,13 @@ Page { // get seconds from current Date var curDate = new Date(); var seconds = curDate.getSeconds(); - var type; // Iterate over all List entries for (var i=0; i 2000)) { - if (appWin.listModel.get(i).title.substr(0,6) == "Steam:") { - type = "TOTP_STEAM" - } else { - type = "TOTP" - } - - var curOTP = OTP.calcOTP(appWin.listModel.get(i).secret, type) + var curOTP = OTP.calcOTP(appWin.listModel.get(i).secret, appWin.listModel.get(i).type) appWin.listModel.setProperty(i, "otp", curOTP); } } else if (appWin.coverType == "HOTP" && (curDate.getTime() - lastUpdated > 2000) && appWin.listModel.get(i).fav == 1) {