passgo package: modernize for go 1.24; reset store.Empty in GetStore.

- Update to //go:build tags, gofmt, and the android-35 javac template
  in //go:generate.
- GetStore: reset store.Empty when the store directory exists (it was
  only set true when the dir was missing, so a reconfigured store kept
  the stale 'Empty' state and showed the configure button).
- Rebuild PgpConnect.jar (android-35).
This commit is contained in:
Greg Pomerantz 2026-08-21 13:00:03 -04:00
parent edb38a6b85
commit af1b878308
7 changed files with 22 additions and 14 deletions

Binary file not shown.

View File

@ -1,6 +1,8 @@
//+build android //go:build android
// +build android
//go:generate mkdir -p classes //go:generate mkdir -p classes
//go:generate javac -bootclasspath $ANDROID_HOME/platforms/android-29/android.jar -classpath openpgp-api.jar -d classes PgpConnect.java Foo.java //go:generate javac -nowarn -classpath $ANDROID_HOME/platforms/android-35/android.jar:openpgp-api.jar -d classes PgpConnect.java
//go:generate jar cf PgpConnect.jar -C classes . //go:generate jar cf PgpConnect.jar -C classes .
//go:generate rm -rf classes //go:generate rm -rf classes
@ -15,8 +17,8 @@ import "C"
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"path"
"log" "log"
"path"
"strings" "strings"
"sync" "sync"
"unsafe" "unsafe"
@ -27,10 +29,10 @@ import (
) )
var ( var (
jvm uintptr jvm uintptr
waitch chan struct{} waitch chan struct{}
//w *app.Window //w *app.Window
pgp PGP pgp PGP
installCompleteOnce sync.Once installCompleteOnce sync.Once
) )
@ -64,7 +66,7 @@ func connect() {
<-waitch <-waitch
} }
//Clip copies a string to the clipboard // Clip copies a string to the clipboard
func Clip(x string) { func Clip(x string) {
pgp.Clip(x) pgp.Clip(x)
} }

View File

@ -1,4 +1,5 @@
//+build darwin //go:build darwin
// +build darwin
package passgo package passgo
@ -119,7 +120,7 @@ func init() {
setAgentInfo() setAgentInfo()
} }
//Clip copies a string to the clipboard // Clip copies a string to the clipboard
func Clip(x string) { func Clip(x string) {
clip.Set(x) clip.Set(x)
} }

View File

@ -1,4 +1,5 @@
//+build !android,linux //go:build !android && linux
// +build !android,linux
package passgo package passgo
@ -7,7 +8,7 @@ import (
"os/exec" "os/exec"
) )
//Clip copies a string to the clipboard // Clip copies a string to the clipboard
func Clip(x string) { func Clip(x string) {
b := bytes.NewBuffer([]byte(x)) b := bytes.NewBuffer([]byte(x))
cmd := exec.Command("xclip") cmd := exec.Command("xclip")

View File

@ -1,4 +1,5 @@
//+build darwin !android,linux //go:build darwin || (!android && linux)
// +build darwin !android,linux
package passgo package passgo

View File

@ -13,11 +13,12 @@ import (
"fmt" "fmt"
"log" "log"
"runtime" "runtime"
"unsafe"
"sync" "sync"
"unsafe"
) )
var theJVM *C.JavaVM var theJVM *C.JavaVM
type JNIEnv = C.JNIEnv type JNIEnv = C.JNIEnv
func SetJVM(jvm uintptr) { func SetJVM(jvm uintptr) {
@ -33,8 +34,8 @@ type PGP C.jobject
var ( var (
fragChans map[int]chan string fragChans map[int]chan string
chmux sync.Mutex chmux sync.Mutex
chint int chint int
) )
func (p PGP) GetId() (string, error) { func (p PGP) GetId() (string, error) {

View File

@ -49,6 +49,8 @@ func GetStore(store *Store) error {
} }
if _, err := os.Stat(store.Dir); os.IsNotExist(err) { if _, err := os.Stat(store.Dir); os.IsNotExist(err) {
store.Empty = true store.Empty = true
} else {
store.Empty = false
} }
id, err := ioutil.ReadFile(path.Join(store.Dir, ".gpg-id")) id, err := ioutil.ReadFile(path.Join(store.Dir, ".gpg-id"))
if err != nil { if err != nil {