1pass.lua
changeset 44 2150bce729df
parent 43 85b1cb11d948
child 45 cf6a06f368e6
equal deleted inserted replaced
43:85b1cb11d948 44:2150bce729df
   313 end
   313 end
   314 
   314 
   315 local function prepItems()
   315 local function prepItems()
   316     items = {}
   316     items = {}
   317     local contents = loadContents()
   317     local contents = loadContents()
       
   318     if contents == nil then
       
   319         return false
       
   320     end
   318     for i,v in ipairs(contents) do
   321     for i,v in ipairs(contents) do
   319         local t = v[2]
   322         local t = v[2]
   320         if items[t] == nil then
   323         if items[t] == nil then
   321             items[t] = {}
   324             items[t] = {}
   322         end
   325         end
   323         local bucket = items[t]
   326         local bucket = items[t]
   324         bucket[#bucket+1] = { uuid=v[1], type=t, name=v[3], url=v[4] }  -- !!! FIXME: there are more fields, don't know what they mean yet.
   327         bucket[#bucket+1] = { uuid=v[1], type=t, name=v[3], url=v[4] }  -- !!! FIXME: there are more fields, don't know what they mean yet.
   325     end
   328     end
       
   329     return true
   326 end
   330 end
   327 
   331 
   328 local passwordUnlockTime = nil
   332 local passwordUnlockTime = nil
   329 
   333 
   330 local function lockKeychain()
   334 local function lockKeychain()
   376             passwordUnlockTime = os.time()
   380             passwordUnlockTime = os.time()
   377             setPowermateLED(true)
   381             setPowermateLED(true)
   378         end
   382         end
   379     end
   383     end
   380 
   384 
   381     prepItems()
   385     if not prepItems() then
       
   386         keyhookRunning = false
       
   387         return
       
   388     end
   382 
   389 
   383     local topmenu = makeGuiMenu()
   390     local topmenu = makeGuiMenu()
   384     local favesmenu = makeGuiMenu()
   391     local favesmenu = makeGuiMenu()
   385     faveitems = {}
   392     faveitems = {}
   386 
   393 
   444 --for i,v in ipairs(argv) do
   451 --for i,v in ipairs(argv) do
   445 --    print("argv[" .. i .. "] = " .. v)
   452 --    print("argv[" .. i .. "] = " .. v)
   446 --end
   453 --end
   447 
   454 
   448 -- !!! FIXME: message box, exit if basedir is wack.
   455 -- !!! FIXME: message box, exit if basedir is wack.
       
   456 local f = io.open(basedir .. "/contents.js", "rb")
       
   457 if f == nil then
       
   458     print("ERROR: Couldn't read your 1Password keychain in '" .. basedir .. "'.")
       
   459     print("ERROR: Please make sure it exists and you have permission to access it.")
       
   460     print("ERROR: (maybe you need to run 'ln -s ~/Dropbox/1Password' here?")
       
   461     print("ERROR: Giving up for now.")
       
   462     os.exit(1)
       
   463 end
       
   464 f:close()
       
   465 
   449 -- !!! FIXME: this can probably happen in C now (the Lua mainline is basically gone now).
   466 -- !!! FIXME: this can probably happen in C now (the Lua mainline is basically gone now).
   450 setPowermateLED(false)  -- off by default
   467 setPowermateLED(false)  -- off by default
   451 print("Now waiting for the magic key combo (probably Alt-Meta-\\) ...")
   468 print("Now waiting for the magic key combo (probably Alt-Meta-\\) ...")
   452 giveControlToGui()
   469 giveControlToGui()
   453 
   470