1pass.lua
author Ryan C. Gordon <icculus@icculus.org>
Mon, 23 Dec 2013 15:57:24 -0500
changeset 12 6a2d5b34d5ca
parent 11 b52e0f1798b8
child 17 e884dbb403cc
permissions -rw-r--r--
Whole bunch of GUI work.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     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
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
     4
local passwordTypeNameMap = {
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
     5
    ["webforms.WebForm"] = "Logins",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
     6
    ["wallet.financial.CreditCard"] = "Credit cards",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
     7
    ["passwords.Password"] = "Passwords",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
     8
    ["wallet.financial.BankAccountUS"] = "Bank accounts",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
     9
    ["wallet.membership.Membership"] = "Memberships",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    10
    ["wallet.government.DriversLicense"] = "Drivers licenses",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    11
    ["system.Tombstone"] = "Dead items",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    12
    -- !!! FIXME: more!
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    13
}
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    14
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    15
local passwordTypeOrdering = {
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    16
    "webforms.WebForm",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    17
    "wallet.financial.CreditCard",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    18
    "passwords.Password",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    19
    "wallet.financial.BankAccountUS",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    20
    "wallet.membership.Membership",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    21
    "wallet.government.DriversLicense",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    22
    -- never show "system.Tombstone",
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    23
    -- !!! FIXME: more!
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    24
}
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
6
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    26
local function load_json_str(str, desc)
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    27
    local retval = JSON:decode(str)
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    28
    return retval
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    29
end
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    30
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
local function load_json(fname)
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
    local f = io.open(fname, "rb")
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
    if (f == nil) then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
        return nil
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
    end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
    local str = f:read("*all")
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
    f:close()
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
6
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    40
    return load_json_str(str, fname)
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
5
6f80cd157c13 Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
    44
local keys = {}
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
function loadKey(basedir, level, password)
5
6f80cd157c13 Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
    46
    if keys[level] ~= nil then
6f80cd157c13 Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
    47
        return keys[level]
6f80cd157c13 Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
    48
    end
6f80cd157c13 Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
    49
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    50
    local keysjson = load_json(basedir .. "/encryptionKeys.js")
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    if (keysjson == nil) or (keysjson[level] == nil) then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
        return nil
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
    end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
    local identifier = keysjson[level]
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
    for i,v in ipairs(keysjson.list) do
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
        if v.identifier == identifier then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
			local iterations = v.iterations
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
            if (iterations == nil) or (iterations < 1000) then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
			    iterations = 1000
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
            end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
			local decrypted = decryptUsingPBKDF2(v.data, password, iterations)
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
			if decrypted == nil then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
                return nil
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
            end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
			local validate = decryptBase64UsingKey(v.validation, decrypted)
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
			if validate ~= decrypted then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
                return nil
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
            end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
5
6f80cd157c13 Cache loaded encryption keys.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
    73
            keys[level] = decrypted
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
            return decrypted
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
        end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
    end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    return nil
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    81
local function getHint(basedir)
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
    local f = io.open(basedir .. "/.password.hint", "r")
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
    if (f == nil) then
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
        return
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
    end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    87
    local str = "(hint is '" .. f:read("*all") .. "')."
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    f:close()
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    89
    --print(str)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    90
    return str
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
end
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
1
0919d17b13f9 Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    93
6
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
    94
function loadContents(basedir)
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    95
    return load_json(basedir .. "/contents.js")
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    96
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    97
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
    98
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
    99
    if str == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   100
        return nil
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   101
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   102
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   103
    local valuestr = str
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   104
    if hidden == true then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   105
        valuestr = "*****"
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   106
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   107
    local text = type .. " " .. valuestr
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   108
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   109
    local callback = function()
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   110
        copyToClipboard(str)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   111
        --print("Copied data [" .. str .. "] to clipboard.")
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   112
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   113
    return appendGuiMenuItem(menu, text, callback)
6
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
   114
end
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
   115
12
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 secret_menuitem_builders = {}
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   118
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   119
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
   120
    local addthis = false
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   121
    local username = nil
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   122
    local password = nil
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   123
    local email = nil
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   124
    for i,v in ipairs(secure.fields) do
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   125
        --print(info.name .. ": " .. v.type .. ", " .. v.value)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   126
        local ignored = false
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   127
        if (v.type == "P") and (password == nil) and (v.value ~= "") then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   128
            password = v.value
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   129
        elseif (v.type == "T") and (usenname == nil) and (v.value ~= "") then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   130
            username = v.value
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   131
        elseif (v.type == "E") and (email == nil) and (v.value ~= "") then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   132
            email = v.value
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   133
        else
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   134
            ignored = true
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   135
        end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   136
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   137
        if not ignored then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   138
            addthis = true
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   139
        end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   140
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   141
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   142
    if addthis then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   143
        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
   144
            email = nil
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   145
        end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   146
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   147
        build_secret_menuitem(menu, "username", username)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   148
        build_secret_menuitem(menu, "email", email)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   149
        build_secret_menuitem(menu, "password", password, true)
8
eada72719d17 Make the app basically useful.
Ryan C. Gordon <icculus@icculus.org>
parents: 7
diff changeset
   150
    end
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   151
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   152
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
   153
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   154
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   155
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
   156
    build_secret_menuitem(menu, "password", secure.password, true)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   157
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   158
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
   159
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   160
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   161
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
   162
    -- !!! 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
   163
    build_secret_menuitem(menu, "Account type", secure.accountType)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   164
    build_secret_menuitem(menu, "Routing number", secure.routingNo)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   165
    build_secret_menuitem(menu, "Account number", secure.accountNo)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   166
    build_secret_menuitem(menu, "Bank name", secure.bankName)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   167
    build_secret_menuitem(menu, "Owner", secure.owner)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   168
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   169
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
   170
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   171
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   172
local function build_secret_menuitem_driverslic(menu, info, secure)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   173
    -- !!! 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
   174
    local birthdate = secure.birthdate_yy .. "/" .. string.sub("00" .. secure.birthdate_mm, -2) .. "/" .. string.sub("00" .. secure.birthdate_dd, -2)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   175
    local expiredate = secure.expiry_date_yy .. "/" .. string.sub("00" .. secure.expiry_date_mm, -2)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   176
    build_secret_menuitem(menu, "License number", secure.number)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   177
    build_secret_menuitem(menu, "Class", secure.class)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   178
    build_secret_menuitem(menu, "Expires", expiredate)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   179
    build_secret_menuitem(menu, "State", secure.state)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   180
    build_secret_menuitem(menu, "Country", secure.country)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   181
    build_secret_menuitem(menu, "Conditions", secure.conditions)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   182
    build_secret_menuitem(menu, "Full name", secure.fullname)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   183
    build_secret_menuitem(menu, "Address", secure.address)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   184
    build_secret_menuitem(menu, "Gender", secure.sex)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   185
    build_secret_menuitem(menu, "Birthdate", birthdate)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   186
    build_secret_menuitem(menu, "Height", secure.height)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   187
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   188
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
   189
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   190
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   191
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
   192
    -- !!! 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
   193
    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
   194
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   195
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
   196
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   197
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   198
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
   199
    -- !!! 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
   200
    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
   201
    build_secret_menuitem(menu, "Type", secure.type)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   202
    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
   203
    build_secret_menuitem(menu, "CVV", secure.cvv, true)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   204
    build_secret_menuitem(menu, "Expires", secure.expirydate)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   205
    build_secret_menuitem(menu, "Card holder", secure.cardholder)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   206
    build_secret_menuitem(menu, "Bank", secure.bank)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   207
end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   208
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
   209
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   210
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   211
local function build_secret_menuitems(basedir, info, menu, password)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   212
    local metadata = load_json(basedir .. "/" .. info.uuid .. ".1password")
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   213
    if metadata == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   214
        return
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   215
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   216
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   217
    local plaintext = decryptBase64UsingKey(metadata.encrypted, loadKey(basedir, metadata.securityLevel, password))
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   218
    if plaintext == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   219
        return
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   220
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   221
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   222
    local secure = load_json_str(plaintext, info.uuid)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   223
    if secure == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   224
        return
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   225
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   226
    --dumptable("secure " .. info.name, secure)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   227
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   228
    local menuitem = appendGuiMenuItem(menu, info.name)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   229
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   230
    if secret_menuitem_builders[info.type] == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   231
        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
   232
        dumptable("secure " .. info.type .. " (" .. info.name .. ")", secure)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   233
        return
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   234
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   235
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   236
    local submenu = makeGuiMenu()
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   237
    secret_menuitem_builders[info.type](submenu, info, secure)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   238
    setGuiMenuItemSubmenu(menuitem, submenu)
8
eada72719d17 Make the app basically useful.
Ryan C. Gordon <icculus@icculus.org>
parents: 7
diff changeset
   239
end
eada72719d17 Make the app basically useful.
Ryan C. Gordon <icculus@icculus.org>
parents: 7
diff changeset
   240
6
b7f19e0599db Dump out all the encrypted data.
Ryan C. Gordon <icculus@icculus.org>
parents: 5
diff changeset
   241
1
0919d17b13f9 Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
   242
-- Mainline!
0919d17b13f9 Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
   243
7
682d7ea1e7f3 Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 6
diff changeset
   244
--for i,v in ipairs(argv) do
682d7ea1e7f3 Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 6
diff changeset
   245
--    print("argv[" .. i .. "] = " .. v)
682d7ea1e7f3 Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 6
diff changeset
   246
--end
682d7ea1e7f3 Moved command lines into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 6
diff changeset
   247
1
0919d17b13f9 Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
   248
local basedir = "1Password/1Password.agilekeychain/data/default"  -- !!! FIXME
0919d17b13f9 Move the mainline into Lua.
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
   249
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   250
local password = argv[2]
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   251
while password == nil do
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   252
    password = runGuiPasswordPrompt(getHint(basedir))
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   253
    if password == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   254
        os.exit(1)
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   255
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   256
    if loadKey(basedir, "SL5", password) == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   257
        password = nil  -- wrong password
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   258
        local start = os.time()  -- cook the CPU for three seconds.
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   259
        local now = start
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   260
        while os.difftime(now, start) < 3 do
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   261
            now = os.time()
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
    end
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   264
end
11
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   265
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   266
local contents = loadContents(basedir)
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   267
local items = {}
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   268
for i,v in ipairs(contents) do
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   269
    local t = v[2]
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   270
    if items[t] == nil then
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   271
        items[t] = {}
11
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   272
    end
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   273
    local bucket = items[t]
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   274
    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.
11
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   275
end
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   276
contents = nil
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   277
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   278
local topmenu = makeGuiMenu()
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   279
for orderi,type in ipairs(passwordTypeOrdering) do
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   280
    local bucket = items[type]
11
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   281
    local realname = passwordTypeNameMap[type]
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   282
    if realname == nil then
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   283
        realname = type
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   284
    end
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   285
    local menuitem = appendGuiMenuItem(topmenu, realname)
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   286
    local submenu = makeGuiMenu()
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   287
    table.sort(bucket, function(a, b) return a.name < b.name end)
11
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   288
    for i,v in pairs(bucket) do
12
6a2d5b34d5ca Whole bunch of GUI work.
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   289
        build_secret_menuitems(basedir, v, submenu, password)
11
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   290
    end
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   291
    setGuiMenuItemSubmenu(menuitem, submenu)
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   292
end
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   293
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   294
popupGuiMenu(topmenu)
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   295
giveControlToGui()
b52e0f1798b8 Start building in GUI stuff.
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   296
0
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
-- end of 1pass.lua ...
d7ee4e2ed49d Initial work.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298