gosecret/session_funcs.go

53 lines
1005 B
Go
Raw Permalink Normal View History

package gosecret
import (
"github.com/godbus/dbus/v5"
)
// I'm still not 100% certain what Sessions are used for, aside from getting Secrets from Items.
2021-12-04 02:34:45 -05:00
/*
NewSession returns a pointer to a new Session based on a Service and a dbus.ObjectPath.
You will almost always want to use Service.GetSession or Service.OpenSession instead.
2021-12-04 02:34:45 -05:00
*/
2021-12-08 02:34:27 -05:00
func NewSession(service *Service, path dbus.ObjectPath) (session *Session, err error) {
if _, err = validConnPath(service.Conn, path); err != nil {
return
}
2021-12-04 02:34:45 -05:00
var ssn Session = Session{
DbusObject: &DbusObject{
2021-12-04 02:34:45 -05:00
Conn: service.Conn,
},
service: service,
}
ssn.Dbus = ssn.Conn.Object(DbusInterfaceSession, path)
2021-12-04 02:34:45 -05:00
session = &ssn
return
}
2021-12-04 02:34:45 -05:00
// Close cleanly closes a Session.
func (s *Session) Close() (err error) {
var c *dbus.Call
c = s.Dbus.Call(
DbusSessionClose, 0,
)
2021-12-04 02:34:45 -05:00
_ = c
return
}
// path is a *very* thin wrapper around Session.Dbus.Path().
func (s *Session) path() (dbusPath dbus.ObjectPath) {
dbusPath = s.Dbus.Path()
return
}