Build on Ubuntu 12.04, fix some crash problems
authorRobbie Vanbrabant <robbie.vanbrabant@gmail.com>
Sun, 19 Jan 2014 16:51:36 +0000
changeset 21 9884f4078c68
parent 20 ca0e1747b708
child 22 9adb804d66b0
Build on Ubuntu 12.04, fix some crash problems
.hgignore
1pass.lua
CMakeLists.txt
build.sh
--- a/.hgignore	Thu Dec 26 16:56:53 2013 -0500
+++ b/.hgignore	Sun Jan 19 16:51:36 2014 +0000
@@ -1,3 +1,8 @@
 syntax:glob
 cmake-build
 1Password
+CMakeFiles
+CMakeCache.txt
+Makefile
+1pass
+cmake_install.cmake
--- a/1pass.lua	Thu Dec 26 16:56:53 2013 -0500
+++ b/1pass.lua	Sun Jan 19 16:51:36 2014 +0000
@@ -127,6 +127,7 @@
     local username = nil
     local password = nil
     local email = nil
+
     for i,v in ipairs(secure.fields) do
         --print(info.name .. ": " .. v.type .. ", " .. v.value)
         local ignored = false
@@ -220,7 +221,17 @@
         return
     end
 
-    local plaintext = decryptBase64UsingKey(metadata.encrypted, loadKey(metadata.securityLevel, password))
+    local securityLevel = metadata.securityLevel
+    if securityLevel == nil then
+	securityLevel = metadata.openContents.securityLevel
+    end
+    print("title: " .. metadata.title)
+    if securityLevel == nil then
+        --print("can't find security level, assuming SL5" .. metadata.title)
+        securityLevel = "SL5"
+    end
+
+    local plaintext = decryptBase64UsingKey(metadata.encrypted, loadKey(securityLevel, password))
     if plaintext == nil then
         return
     end
@@ -230,6 +241,10 @@
         return
     end
     --dumptable("secure " .. info.name, secure)
+    if secure.fields == nil then
+      print("no secure fields, don't know how to handle this item") 
+      return
+    end
 
     local menuitem = appendGuiMenuItem(menu, info.name)
 
@@ -309,17 +324,21 @@
 
     for orderi,type in ipairs(passwordTypeOrdering) do
         local bucket = items[type]
-        local realname = passwordTypeNameMap[type]
-        if realname == nil then
-            realname = type
+        if bucket ~= nil then
+            local realname = passwordTypeNameMap[type]
+            if realname == nil then
+                realname = type
+            end
+            local menuitem = appendGuiMenuItem(topmenu, realname)
+            local submenu = makeGuiMenu()
+            table.sort(bucket, function(a, b) return a.name < b.name end)
+            for i,v in pairs(bucket) do
+                build_secret_menuitems(v, submenu)
+            end
+            setGuiMenuItemSubmenu(menuitem, submenu)
+        else
+            print("no bucket found")
         end
-        local menuitem = appendGuiMenuItem(topmenu, realname)
-        local submenu = makeGuiMenu()
-        table.sort(bucket, function(a, b) return a.name < b.name end)
-        for i,v in pairs(bucket) do
-            build_secret_menuitems(v, submenu)
-        end
-        setGuiMenuItemSubmenu(menuitem, submenu)
     end
 
     popupGuiMenu(topmenu)
--- a/CMakeLists.txt	Thu Dec 26 16:56:53 2013 -0500
+++ b/CMakeLists.txt	Sun Jan 19 16:51:36 2014 +0000
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8.10)
+cmake_minimum_required(VERSION 2.8.7)
 project(1pass)
 
 include(FindPkgConfig)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build.sh	Sun Jan 19 16:51:36 2014 +0000
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# Need to install the following on Ubuntu 12.04:
+# - cmake
+# - libgtk2.0-dev
+# - libxtst-dev
+#
+# If you find other deps, add them here
+
+cmake -DCMAKE_BUILD_TYPE=Release .
+make