Skip to content

Commit

Permalink
Merge branch 'dir_info'
Browse files Browse the repository at this point in the history
  • Loading branch information
proglottis committed Nov 23, 2024
2 parents bf62a21 + 5c1f0b3 commit de26861
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
20 changes: 17 additions & 3 deletions gpgme.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package gpgme
// #include <gpgme.h>
// #include "go_gpgme.h"
import "C"

import (
"fmt"
"io"
Expand Down Expand Up @@ -235,6 +236,17 @@ func SetEngineInfo(proto Protocol, fileName, homeDir string) error {
return handleError(C.gpgme_set_engine_info(C.gpgme_protocol_t(proto), cfn, chome))
}

func GetDirInfo(what string) string {
cwhat := C.CString(what)
defer C.free(unsafe.Pointer(cwhat))

cdir := C.gpgme_get_dirinfo(cwhat)
if cdir == nil {
return ""
}
return C.GoString(cdir)
}

func FindKeys(pattern string, secretOnly bool) ([]*Key, error) {
var keys []*Key
ctx, err := New()
Expand Down Expand Up @@ -567,9 +579,11 @@ func (c *Context) Sign(signers []*Key, plain, sig *Data, mode SigMode) error {
return err
}

type AssuanDataCallback func(data []byte) error
type AssuanInquireCallback func(name, args string) error
type AssuanStatusCallback func(status, args string) error
type (
AssuanDataCallback func(data []byte) error
AssuanInquireCallback func(name, args string) error
AssuanStatusCallback func(status, args string) error
)

// AssuanSend sends a raw Assuan command to gpg-agent
func (c *Context) AssuanSend(
Expand Down
12 changes: 12 additions & 0 deletions gpgme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ func TestEngineInfo(t *testing.T) {
checkError(t, SetEngineInfo(testProto, "", testHomeDir))
}

func TestGetDirInfo(t *testing.T) {
info := GetDirInfo("fail")
if info != "" {
t.Errorf("expected no info, got: %q", info)
}

info = GetDirInfo("homedir")
if info == "" {
t.Error("expected dir info, got nothing")
}
}

func ctxWithCallback(t *testing.T) *Context {
ensureVersion(t, "1.", "can only set password callback for GPG v1.x")

Expand Down
1 change: 1 addition & 0 deletions unset_agent_info.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

package gpgme
Expand Down

0 comments on commit de26861

Please sign in to comment.