1pass.lua
changeset 11 b52e0f1798b8
parent 9 98c872cc0560
child 12 6a2d5b34d5ca
equal deleted inserted replaced
10:85496558f3a4 11:b52e0f1798b8
    92 --    print("argv[" .. i .. "] = " .. v)
    92 --    print("argv[" .. i .. "] = " .. v)
    93 --end
    93 --end
    94 
    94 
    95 local basedir = "1Password/1Password.agilekeychain/data/default"  -- !!! FIXME
    95 local basedir = "1Password/1Password.agilekeychain/data/default"  -- !!! FIXME
    96 
    96 
       
    97 local passwordTypeNameMap = {
       
    98     ["wallet.financial.BankAccountUS"] = "Bank accounts",
       
    99     ["wallet.financial.CreditCard"] = "Credit cards",
       
   100     ["webforms.WebForm"] = "Logins",
       
   101     ["system.Tombstone"] = "Dead items",
       
   102     ["wallet.membership.Membership"] = "Memberships",
       
   103     ["wallet.government.DriversLicense"] = "Drivers licenses",
       
   104     ["passwords.Password"] = "Passwords",
       
   105     -- !!! FIXME: more!
       
   106 }
       
   107 
       
   108 local contents = loadContents(basedir)
       
   109 local items = {}
       
   110 for i,v in ipairs(contents) do
       
   111     local t = v[2]
       
   112     if t ~= "system.Tombstone" then
       
   113         if items[t] == nil then
       
   114             items[t] = {}
       
   115         end
       
   116         local bucket = items[t]
       
   117         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.
       
   118     end
       
   119 end
       
   120 contents = nil
       
   121 
       
   122 local topmenu = makeGuiMenu()
       
   123 for type,bucket in pairs(items) do
       
   124 print(type)
       
   125     local realname = passwordTypeNameMap[type]
       
   126     if realname == nil then
       
   127         realname = type
       
   128     end
       
   129     local menuitem = appendGuiMenuItem(topmenu, realname)
       
   130     local submenu = makeGuiMenu()
       
   131     for i,v in pairs(bucket) do
       
   132         local submenuitem = appendGuiMenuItem(submenu, v.name, function() print("Clicked on " .. v.name .. ", uuid is '" .. v.uuid .. "'") end)
       
   133     end
       
   134     setGuiMenuItemSubmenu(menuitem, submenu)
       
   135 end
       
   136 
       
   137 popupGuiMenu(topmenu)
       
   138 giveControlToGui()
       
   139 
       
   140 os.exit(1)
       
   141 
       
   142 
    97 local password = argv[3]
   143 local password = argv[3]
    98 if password == nil then
   144 if password == nil then
    99     showHint(basedir)
   145     showHint(basedir)
   100     io.write("password: ")
   146     io.write("password: ")
   101     password = io.read("*l")
   147     password = io.read("*l")