author | Ryan C. Gordon <icculus@icculus.org> |
Tue, 31 Mar 2015 20:18:10 -0400 | |
changeset 44 | 2150bce729df |
parent 43 | 85b1cb11d948 |
child 45 | cf6a06f368e6 |
permissions | -rw-r--r-- |
0 | 1 |
JSON = (loadfile "JSON.lua")() |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
2 |
dofile("dumptable.lua") |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
3 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
4 |
local basedir = "1Password/1Password.agilekeychain/data/default" -- !!! FIXME |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
5 |
local password = argv[2] |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
6 |
local items = nil |
35
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
7 |
local faveitems = nil |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
8 |
local keyhookRunning = false |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
9 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
10 |
local passwordTypeNameMap = { |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
11 |
["webforms.WebForm"] = "Logins", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
12 |
["wallet.financial.CreditCard"] = "Credit cards", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
13 |
["passwords.Password"] = "Passwords", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
14 |
["wallet.financial.BankAccountUS"] = "Bank accounts", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
15 |
["wallet.membership.Membership"] = "Memberships", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
16 |
["wallet.government.DriversLicense"] = "Drivers licenses", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
17 |
["system.Tombstone"] = "Dead items", |
25
44b6b8b34eb8
Added Secure Notes items to menu.
Ryan C. Gordon <icculus@icculus.org>
parents:
24
diff
changeset
|
18 |
["securenotes.SecureNote"] = "Secure notes", |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
19 |
-- !!! FIXME: more! |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
20 |
} |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
21 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
22 |
local passwordTypeOrdering = { |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
23 |
"webforms.WebForm", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
24 |
"wallet.financial.CreditCard", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
25 |
"passwords.Password", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
26 |
"wallet.financial.BankAccountUS", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
27 |
"wallet.membership.Membership", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
28 |
"wallet.government.DriversLicense", |
25
44b6b8b34eb8
Added Secure Notes items to menu.
Ryan C. Gordon <icculus@icculus.org>
parents:
24
diff
changeset
|
29 |
"securenotes.SecureNote", |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
30 |
-- never show "system.Tombstone", |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
31 |
-- !!! FIXME: more! |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
32 |
} |
0 | 33 |
|
6
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
34 |
local function load_json_str(str, desc) |
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
35 |
local retval = JSON:decode(str) |
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
36 |
return retval |
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
37 |
end |
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
38 |
|
0 | 39 |
local function load_json(fname) |
40 |
local f = io.open(fname, "rb") |
|
41 |
if (f == nil) then |
|
42 |
return nil |
|
43 |
end |
|
44 |
||
45 |
local str = f:read("*all") |
|
46 |
f:close() |
|
47 |
||
6
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
48 |
return load_json_str(str, fname) |
0 | 49 |
end |
50 |
||
51 |
||
5
6f80cd157c13
Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
52 |
local keys = {} |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
53 |
local function loadKey(level, password) |
5
6f80cd157c13
Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
54 |
if keys[level] ~= nil then |
6f80cd157c13
Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
55 |
return keys[level] |
6f80cd157c13
Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
56 |
end |
6f80cd157c13
Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
57 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
58 |
local keysjson = load_json(basedir .. "/encryptionKeys.js") |
0 | 59 |
if (keysjson == nil) or (keysjson[level] == nil) then |
60 |
return nil |
|
61 |
end |
|
62 |
||
63 |
local identifier = keysjson[level] |
|
64 |
for i,v in ipairs(keysjson.list) do |
|
65 |
if v.identifier == identifier then |
|
66 |
local iterations = v.iterations |
|
67 |
if (iterations == nil) or (iterations < 1000) then |
|
68 |
iterations = 1000 |
|
69 |
end |
|
70 |
||
71 |
local decrypted = decryptUsingPBKDF2(v.data, password, iterations) |
|
72 |
if decrypted == nil then |
|
73 |
return nil |
|
74 |
end |
|
75 |
||
76 |
local validate = decryptBase64UsingKey(v.validation, decrypted) |
|
77 |
if validate ~= decrypted then |
|
78 |
return nil |
|
79 |
end |
|
80 |
||
5
6f80cd157c13
Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
81 |
keys[level] = decrypted |
0 | 82 |
return decrypted |
83 |
end |
|
84 |
end |
|
85 |
||
86 |
return nil |
|
87 |
end |
|
88 |
||
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
89 |
local function getHint() |
0 | 90 |
local f = io.open(basedir .. "/.password.hint", "r") |
91 |
if (f == nil) then |
|
92 |
return |
|
93 |
end |
|
94 |
||
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
95 |
local str = "(hint is '" .. f:read("*all") .. "')." |
0 | 96 |
f:close() |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
97 |
--print(str) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
98 |
return str |
0 | 99 |
end |
100 |
||
1
0919d17b13f9
Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
101 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
102 |
local function loadContents() |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
103 |
return load_json(basedir .. "/contents.js") |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
104 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
105 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
106 |
local function build_secret_menuitem(menu, type, str, hidden) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
107 |
if str == nil then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
108 |
return nil |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
109 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
110 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
111 |
local valuestr = str |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
112 |
if hidden == true then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
113 |
valuestr = "*****" |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
114 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
115 |
local text = type .. " " .. valuestr |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
116 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
117 |
local callback = function() |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
118 |
copyToClipboard(str) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
119 |
--print("Copied data [" .. str .. "] to clipboard.") |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
120 |
keyhookRunning = false |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
121 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
122 |
return appendGuiMenuItem(menu, text, callback) |
6
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
123 |
end |
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
124 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
125 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
126 |
local secret_menuitem_builders = {} |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
127 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
128 |
local function build_secret_menuitem_webform(menu, info, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
129 |
local addthis = false |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
130 |
local username = nil |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
131 |
local password = nil |
32
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
132 |
local designated_password = nil |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
133 |
local designated_username = nil |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
134 |
local email = nil |
21
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
135 |
|
24
c34cc914f09d
Checked for secure.fields in the wrong place.
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
136 |
if secure.fields == nil then |
c34cc914f09d
Checked for secure.fields in the wrong place.
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
137 |
print("no secure fields, don't know how to handle this item") |
c34cc914f09d
Checked for secure.fields in the wrong place.
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
138 |
return |
c34cc914f09d
Checked for secure.fields in the wrong place.
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
139 |
end |
c34cc914f09d
Checked for secure.fields in the wrong place.
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
140 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
141 |
for i,v in ipairs(secure.fields) do |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
142 |
--print(info.name .. ": " .. v.type .. ", " .. v.value) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
143 |
local ignored = false |
32
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
144 |
if (v.value == nil) or (v.value == "") then |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
145 |
ignored = true |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
146 |
elseif (v.designation ~= nil) and (v.designation == "password") then |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
147 |
designated_password = v.value |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
148 |
elseif (v.designation ~= nil) and (v.designation == "username") then |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
149 |
designated_username = v.value |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
150 |
elseif (v.type == "P") then |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
151 |
password = v.value |
32
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
152 |
elseif (v.type == "T") then |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
153 |
username = v.value |
32
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
154 |
elseif (v.type == "E") then |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
155 |
email = v.value |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
156 |
else |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
157 |
ignored = true |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
158 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
159 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
160 |
if not ignored then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
161 |
addthis = true |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
162 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
163 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
164 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
165 |
if addthis then |
32
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
166 |
-- designated fields always win out. |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
167 |
if (designated_username ~= nil) then |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
168 |
username = designated_username |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
169 |
end |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
170 |
|
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
171 |
if (designated_password ~= nil) then |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
172 |
password = designated_password |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
173 |
end |
8f45f1e8bcfa
Pick out the right password when multiple passwords are included.
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
174 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
175 |
if (username ~= nil) and (email ~= nil) and (email == username) then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
176 |
email = nil |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
177 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
178 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
179 |
build_secret_menuitem(menu, "username", username) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
180 |
build_secret_menuitem(menu, "email", email) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
181 |
build_secret_menuitem(menu, "password", password, true) |
8
eada72719d17
Make the app basically useful.
Ryan C. Gordon <icculus@icculus.org>
parents:
7
diff
changeset
|
182 |
end |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
183 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
184 |
secret_menuitem_builders["webforms.WebForm"] = build_secret_menuitem_webform |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
185 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
186 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
187 |
local function build_secret_menuitem_password(menu, info, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
188 |
build_secret_menuitem(menu, "password", secure.password, true) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
189 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
190 |
secret_menuitem_builders["passwords.Password"] = build_secret_menuitem_password |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
191 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
192 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
193 |
local function build_secret_menuitem_bankacctus(menu, info, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
194 |
-- !!! FIXME: there's more data than this in a generic dictionary. |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
195 |
build_secret_menuitem(menu, "Account type", secure.accountType) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
196 |
build_secret_menuitem(menu, "Routing number", secure.routingNo) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
197 |
build_secret_menuitem(menu, "Account number", secure.accountNo) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
198 |
build_secret_menuitem(menu, "Bank name", secure.bankName) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
199 |
build_secret_menuitem(menu, "Owner", secure.owner) |
41
5155ff0e6d3d
Added SWIFT code and PIN fields to bank account menus.
Ryan C. Gordon <icculus@icculus.org>
parents:
40
diff
changeset
|
200 |
build_secret_menuitem(menu, "SWIFT code", secure.swift) |
5155ff0e6d3d
Added SWIFT code and PIN fields to bank account menus.
Ryan C. Gordon <icculus@icculus.org>
parents:
40
diff
changeset
|
201 |
build_secret_menuitem(menu, "PIN", secure.telephonePin) |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
202 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
203 |
secret_menuitem_builders["wallet.financial.BankAccountUS"] = build_secret_menuitem_bankacctus |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
204 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
205 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
206 |
local function build_secret_menuitem_driverslic(menu, info, secure) |
42
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
207 |
-- !!! FIXME: there's more data for this menuitem than this, in a generic dictionary. |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
208 |
|
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
209 |
local birthdate = nil |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
210 |
if secure.birthdate_yy ~= nil then |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
211 |
birthdate = secure.birthdate_yy |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
212 |
if secure.birthdate_mm ~= nil then |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
213 |
birthdate = birthdate .. "/" .. string.sub("00" .. secure.birthdate_mm, -2) |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
214 |
if secure.birthdate_dd ~= nil then |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
215 |
birthdate = birthdate .. "/" .. string.sub("00" .. secure.birthdate_dd, -2) |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
216 |
end |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
217 |
end |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
218 |
end |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
219 |
|
43
85b1cb11d948
Whoops, forgot to remove original code that I was fixing. :)
Ryan C. Gordon <icculus@icculus.org>
parents:
42
diff
changeset
|
220 |
local expiredate = nil |
42
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
221 |
if secure.expiry_date_yy ~= nil then |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
222 |
expiredate = secure.expiry_date_yy |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
223 |
if secure.expiry_date_mm ~= nil then |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
224 |
expiredate = expiredate .. "/" .. string.sub("00" .. secure.expiry_date_mm, -2) |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
225 |
if secure.expiry_date_dd ~= nil then |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
226 |
expiredate = expiredate .. "/" .. string.sub("00" .. secure.expiry_date_dd, -2) |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
227 |
end |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
228 |
end |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
229 |
end |
ca071626bfa0
Fixed driver license dates that might be missing (thanks, Patrick!).
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
230 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
231 |
build_secret_menuitem(menu, "License number", secure.number) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
232 |
build_secret_menuitem(menu, "Class", secure.class) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
233 |
build_secret_menuitem(menu, "Expires", expiredate) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
234 |
build_secret_menuitem(menu, "State", secure.state) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
235 |
build_secret_menuitem(menu, "Country", secure.country) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
236 |
build_secret_menuitem(menu, "Conditions", secure.conditions) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
237 |
build_secret_menuitem(menu, "Full name", secure.fullname) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
238 |
build_secret_menuitem(menu, "Address", secure.address) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
239 |
build_secret_menuitem(menu, "Gender", secure.sex) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
240 |
build_secret_menuitem(menu, "Birthdate", birthdate) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
241 |
build_secret_menuitem(menu, "Height", secure.height) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
242 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
243 |
secret_menuitem_builders["wallet.government.DriversLicense"] = build_secret_menuitem_driverslic |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
244 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
245 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
246 |
local function build_secret_menuitem_membership(menu, info, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
247 |
-- !!! FIXME: there's more data than this in a generic dictionary. |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
248 |
build_secret_menuitem(menu, "Membership number", secure.membership_no) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
249 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
250 |
secret_menuitem_builders["wallet.membership.Membership"] = build_secret_menuitem_membership |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
251 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
252 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
253 |
local function build_secret_menuitem_creditcard(menu, info, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
254 |
-- !!! FIXME: there's more data than this in a generic dictionary. |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
255 |
local expiredate = secure.expiry_yy .. "/" .. string.sub("00" .. secure.expiry_mm, -2) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
256 |
build_secret_menuitem(menu, "Type", secure.type) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
257 |
build_secret_menuitem(menu, "CC number", secure.ccnum, true) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
258 |
build_secret_menuitem(menu, "CVV", secure.cvv, true) |
38
115b6a0bd0af
Fixed display of credit card expiration date.
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
259 |
build_secret_menuitem(menu, "Expires", expiredate) |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
260 |
build_secret_menuitem(menu, "Card holder", secure.cardholder) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
261 |
build_secret_menuitem(menu, "Bank", secure.bank) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
262 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
263 |
secret_menuitem_builders["wallet.financial.CreditCard"] = build_secret_menuitem_creditcard |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
264 |
|
25
44b6b8b34eb8
Added Secure Notes items to menu.
Ryan C. Gordon <icculus@icculus.org>
parents:
24
diff
changeset
|
265 |
local function build_secret_menuitem_securenote(menu, info, secure) |
44b6b8b34eb8
Added Secure Notes items to menu.
Ryan C. Gordon <icculus@icculus.org>
parents:
24
diff
changeset
|
266 |
build_secret_menuitem(menu, "Notes", secure.notesPlain, true) |
44b6b8b34eb8
Added Secure Notes items to menu.
Ryan C. Gordon <icculus@icculus.org>
parents:
24
diff
changeset
|
267 |
end |
44b6b8b34eb8
Added Secure Notes items to menu.
Ryan C. Gordon <icculus@icculus.org>
parents:
24
diff
changeset
|
268 |
secret_menuitem_builders["securenotes.SecureNote"] = build_secret_menuitem_securenote |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
269 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
270 |
local function build_secret_menuitems(info, menu) |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
271 |
local metadata = load_json(basedir .. "/" .. info.uuid .. ".1password") |
40
3c2fddfada9f
Don't crash if you get one of these "{}" entries that 1Password makes.
Ryan C. Gordon <icculus@icculus.org>
parents:
38
diff
changeset
|
272 |
if (metadata == nil) or (next(metadata) == nil) then -- the "next" trick tests if table is empty. |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
273 |
return |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
274 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
275 |
|
21
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
276 |
local securityLevel = metadata.securityLevel |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
277 |
if securityLevel == nil then |
36 | 278 |
securityLevel = metadata.openContents.securityLevel |
21
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
279 |
end |
30
c8f3db869ce0
Comment out some debug output.
Ryan C. Gordon <icculus@icculus.org>
parents:
29
diff
changeset
|
280 |
--print("title: " .. metadata.title) |
21
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
281 |
if securityLevel == nil then |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
282 |
--print("can't find security level, assuming SL5" .. metadata.title) |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
283 |
securityLevel = "SL5" |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
284 |
end |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
285 |
|
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
286 |
local plaintext = decryptBase64UsingKey(metadata.encrypted, loadKey(securityLevel, password)) |
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
287 |
if plaintext == nil then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
288 |
return |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
289 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
290 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
291 |
local secure = load_json_str(plaintext, info.uuid) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
292 |
if secure == nil then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
293 |
return |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
294 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
295 |
--dumptable("secure " .. info.name, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
296 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
297 |
local menuitem = appendGuiMenuItem(menu, info.name) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
298 |
|
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
299 |
if secret_menuitem_builders[info.type] == nil then |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
300 |
print("WARNING: don't know how to handle items of type " .. info.type) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
301 |
dumptable("secure " .. info.type .. " (" .. info.name .. ")", secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
302 |
return |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
303 |
end |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
304 |
|
35
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
305 |
if metadata.faveIndex ~= nil then |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
306 |
--dumptable("fave metadata " .. info.name, metadata) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
307 |
faveitems[metadata.faveIndex] = { info=info, secure=secure } |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
308 |
end |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
309 |
|
12
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
310 |
local submenu = makeGuiMenu() |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
311 |
secret_menuitem_builders[info.type](submenu, info, secure) |
6a2d5b34d5ca
Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
312 |
setGuiMenuItemSubmenu(menuitem, submenu) |
8
eada72719d17
Make the app basically useful.
Ryan C. Gordon <icculus@icculus.org>
parents:
7
diff
changeset
|
313 |
end |
eada72719d17
Make the app basically useful.
Ryan C. Gordon <icculus@icculus.org>
parents:
7
diff
changeset
|
314 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
315 |
local function prepItems() |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
316 |
items = {} |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
317 |
local contents = loadContents() |
44
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
318 |
if contents == nil then |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
319 |
return false |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
320 |
end |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
321 |
for i,v in ipairs(contents) do |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
322 |
local t = v[2] |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
323 |
if items[t] == nil then |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
324 |
items[t] = {} |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
325 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
326 |
local bucket = items[t] |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
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. |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
328 |
end |
44
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
329 |
return true |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
330 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
331 |
|
18
e7821efc78f6
Added some keychain lock management.
Ryan C. Gordon <icculus@icculus.org>
parents:
17
diff
changeset
|
332 |
local passwordUnlockTime = nil |
e7821efc78f6
Added some keychain lock management.
Ryan C. Gordon <icculus@icculus.org>
parents:
17
diff
changeset
|
333 |
|
29
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
334 |
local function lockKeychain() |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
335 |
-- lose the existing password and key, prompt user again. |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
336 |
password = argv[2] -- might be nil, don't reset if on command line. |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
337 |
keys["SL5"] = nil |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
338 |
passwordUnlockTime = nil |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
339 |
keyhookRunning = false |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
340 |
setPowermateLED(false) |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
341 |
collectgarbage() |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
342 |
end |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
343 |
|
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
344 |
function pumpLua() -- not local! Called from C! |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
345 |
-- !!! FIXME: this should lose the key in RAM and turn off the Powermate |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
346 |
-- !!! FIXME: LED when the time expires instead of if the time has |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
347 |
-- !!! FIXME: expired when the user is trying to get at the keychain. |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
348 |
if passwordUnlockTime ~= nil then |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
349 |
local now = os.time() |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
350 |
local maxTime = (15 * 60) -- !!! FIXME: don't hardcode. |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
351 |
if os.difftime(now, passwordUnlockTime) > maxTime then |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
352 |
lockKeychain() |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
353 |
end |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
354 |
end |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
355 |
end |
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
356 |
|
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
357 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
358 |
function keyhookPressed() -- not local! Called from C! |
22
9adb804d66b0
Commented out a debug string.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
359 |
--print("keyhookPressed: running==" .. tostring(keyhookRunning)) |
19 | 360 |
-- if keyhookRunning then |
361 |
-- return |
|
362 |
-- end |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
363 |
|
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
364 |
keyhookRunning = true |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
365 |
|
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
366 |
while password == nil do |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
367 |
password = runGuiPasswordPrompt(getHint()) |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
368 |
if password == nil then |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
369 |
keyhookRunning = false |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
370 |
return |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
371 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
372 |
if loadKey("SL5", password) == nil then |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
373 |
password = nil -- wrong password |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
374 |
local start = os.time() -- cook the CPU for three seconds. |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
375 |
local now = start |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
376 |
while os.difftime(now, start) < 3 do |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
377 |
now = os.time() |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
378 |
end |
18
e7821efc78f6
Added some keychain lock management.
Ryan C. Gordon <icculus@icculus.org>
parents:
17
diff
changeset
|
379 |
else |
e7821efc78f6
Added some keychain lock management.
Ryan C. Gordon <icculus@icculus.org>
parents:
17
diff
changeset
|
380 |
passwordUnlockTime = os.time() |
28
60136c984e3b
Hooked up support for a Griffin Powermate.
Ryan C. Gordon <icculus@icculus.org>
parents:
27
diff
changeset
|
381 |
setPowermateLED(true) |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
382 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
383 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
384 |
|
44
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
385 |
if not prepItems() then |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
386 |
keyhookRunning = false |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
387 |
return |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
388 |
end |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
389 |
|
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
390 |
local topmenu = makeGuiMenu() |
35
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
391 |
local favesmenu = makeGuiMenu() |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
392 |
faveitems = {} |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
393 |
|
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
394 |
setGuiMenuItemSubmenu(appendGuiMenuItem(topmenu, "Favorites"), favesmenu) |
18
e7821efc78f6
Added some keychain lock management.
Ryan C. Gordon <icculus@icculus.org>
parents:
17
diff
changeset
|
395 |
|
29
769393898e93
Forcibly lock keychain on timeout instead of checking timeout on next access.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
396 |
appendGuiMenuItem(topmenu, "Lock keychain", function() lockKeychain() end) |
18
e7821efc78f6
Added some keychain lock management.
Ryan C. Gordon <icculus@icculus.org>
parents:
17
diff
changeset
|
397 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
398 |
for orderi,type in ipairs(passwordTypeOrdering) do |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
399 |
local bucket = items[type] |
21
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
400 |
if bucket ~= nil then |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
401 |
local realname = passwordTypeNameMap[type] |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
402 |
if realname == nil then |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
403 |
realname = type |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
404 |
end |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
405 |
local menuitem = appendGuiMenuItem(topmenu, realname) |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
406 |
local submenu = makeGuiMenu() |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
407 |
table.sort(bucket, function(a, b) return a.name < b.name end) |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
408 |
for i,v in pairs(bucket) do |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
409 |
build_secret_menuitems(v, submenu) |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
410 |
end |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
411 |
setGuiMenuItemSubmenu(menuitem, submenu) |
9884f4078c68
Build on Ubuntu 12.04, fix some crash problems
Robbie Vanbrabant <robbie.vanbrabant@gmail.com>
parents:
19
diff
changeset
|
412 |
else |
37
7cdad5c73521
Improved, then commented out, some debug output.
Ryan C. Gordon <icculus@icculus.org>
parents:
36
diff
changeset
|
413 |
--print("no bucket found for item type '" .. type .. "'") |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
414 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
415 |
end |
35
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
416 |
|
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
417 |
-- This favepairs stuff is obnoxious. |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
418 |
local function favepairs(t) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
419 |
local a = {} |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
420 |
for n in pairs(t) do table.insert(a, n) end |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
421 |
table.sort(a) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
422 |
local i = 0 |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
423 |
local iter = function() |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
424 |
i = i + 1 |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
425 |
if a[i] == nil then |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
426 |
return nil |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
427 |
else |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
428 |
return a[i], t[a[i]] |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
429 |
end |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
430 |
end |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
431 |
return iter |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
432 |
end |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
433 |
|
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
434 |
for i,v in favepairs(faveitems) do |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
435 |
--dumptable("fave " .. i, v) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
436 |
local menuitem = appendGuiMenuItem(favesmenu, v.info.name) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
437 |
local submenu = makeGuiMenu() |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
438 |
secret_menuitem_builders[v.info.type](submenu, v.info, v.secure) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
439 |
setGuiMenuItemSubmenu(menuitem, submenu) |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
440 |
end |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
441 |
|
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
442 |
favepairs = nil |
4a970a4f6bc1
Added favorites submenu.
Ryan C. Gordon <icculus@icculus.org>
parents:
32
diff
changeset
|
443 |
faveitems = nil |
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
444 |
|
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
445 |
popupGuiMenu(topmenu) |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
446 |
end |
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
447 |
|
6
b7f19e0599db
Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents:
5
diff
changeset
|
448 |
|
1
0919d17b13f9
Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
449 |
-- Mainline! |
0919d17b13f9
Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
450 |
|
7
682d7ea1e7f3
Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
451 |
--for i,v in ipairs(argv) do |
682d7ea1e7f3
Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
452 |
-- print("argv[" .. i .. "] = " .. v) |
682d7ea1e7f3
Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
453 |
--end |
682d7ea1e7f3
Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
454 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
455 |
-- !!! FIXME: message box, exit if basedir is wack. |
44
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
456 |
local f = io.open(basedir .. "/contents.js", "rb") |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
457 |
if f == nil then |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
458 |
print("ERROR: Couldn't read your 1Password keychain in '" .. basedir .. "'.") |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
459 |
print("ERROR: Please make sure it exists and you have permission to access it.") |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
460 |
print("ERROR: (maybe you need to run 'ln -s ~/Dropbox/1Password' here?") |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
461 |
print("ERROR: Giving up for now.") |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
462 |
os.exit(1) |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
463 |
end |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
464 |
f:close() |
2150bce729df
Be more robust about i/o failures to the keychain.
Ryan C. Gordon <icculus@icculus.org>
parents:
43
diff
changeset
|
465 |
|
17
e884dbb403cc
Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
466 |
-- !!! FIXME: this can probably happen in C now (the Lua mainline is basically gone now). |
28
60136c984e3b
Hooked up support for a Griffin Powermate.
Ryan C. Gordon <icculus@icculus.org>
parents:
27
diff
changeset
|
467 |
setPowermateLED(false) -- off by default |
27
d4d54dc1ee5f
Print a message to stdout at startup, for people that think the app froze up.
Ryan C. Gordon <icculus@icculus.org>
parents:
25
diff
changeset
|
468 |
print("Now waiting for the magic key combo (probably Alt-Meta-\\) ...") |
11
b52e0f1798b8
Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
469 |
giveControlToGui() |
b52e0f1798b8
Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
470 |
|
0 | 471 |
-- end of 1pass.lua ... |
472 |