Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Version 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JumpMaster committed Sep 21, 2014
1 parent 7cceab4 commit e1966ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/js/pebble-js-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function loadLocalVariables() {
for (var i=0; i<MAX_OTP; i++)
{
var tempKey = localStorage.getItem("secret_pair"+i);
if (tempKey)
if (tempKey !== null)
otp_count++;
else
break;
Expand Down Expand Up @@ -137,6 +137,9 @@ Pebble.addEventListener("appmessage",
});

Pebble.addEventListener('showConfiguration', function(e) {
// Disable timeout while in configuration menu
sendAppMessage({"idle_timeout":0});

var url = 'http://oncloudvirtual.com/pebble/pebbleauth/v'+
app_version+'/'+
'?otp_count='+otp_count+
Expand All @@ -158,7 +161,7 @@ Pebble.addEventListener("webviewclosed",
if(!isNaN(configuration.delete_all)) {
if (debug)
console.log("INFO: Delete all requested");
for (i = 0; i <= MAX_OTP;i++) {
for (i = 0; i < MAX_OTP;i++) {
if (debug)
console.log("INFO: Deleting key "+i);
localStorage.removeItem('secret_pair'+i);
Expand Down Expand Up @@ -192,8 +195,10 @@ Pebble.addEventListener("webviewclosed",

idle_timeout = configuration.idle_timeout;
localStorage.setItem("idle_timeout",idle_timeout);
config.idle_timeout = idle_timeout;
}
// Always send idle_timeout to reset it after
// it was disabled while configuring
config.idle_timeout = idle_timeout;

if(configuration.label && configuration.secret) {
var secret = configuration.secret
Expand Down
11 changes: 9 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ void expand_key(char *inputString, bool new_code) {
}
otp_key[outputChar] = '\0';

// If the label or key are null ignore them
if (otp_label == '\0' || otp_key == '\0') {
APP_LOG(APP_LOG_LEVEL_DEBUG, "INFO: NULL key or label, ignoring");
return;
}

bool updating_label = false;
if (new_code) {
for(unsigned int i = 0; i < watch_otp_count; i++) {
Expand Down Expand Up @@ -664,7 +670,7 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
if (DEBUG)
APP_LOG(APP_LOG_LEVEL_DEBUG, "INFO: Delete all requested");

for (unsigned int i = 0; i <= MAX_OTP; i++) {
for (unsigned int i = 0; i < MAX_OTP; i++) {
if (DEBUG)
APP_LOG(APP_LOG_LEVEL_DEBUG, "INFO: Deleting key: %d", i);
persist_delete(PS_SECRET+i);
Expand Down Expand Up @@ -776,7 +782,8 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
if (idle_timeout != idle_timeout_value) {
idle_timeout = idle_timeout_value;
persist_write_int(PS_IDLE_TIMEOUT, idle_timeout);

resetIdleTime();

if (DEBUG)
APP_LOG(APP_LOG_LEVEL_DEBUG, "INFO: Idle Timeout: %d", idle_timeout);
}
Expand Down

0 comments on commit e1966ce

Please sign in to comment.