checking in some new funcs for Service

This commit is contained in:
2021-12-04 02:34:45 -05:00
parent 1d9145bcf2
commit c0a1e4a281
3 changed files with 82 additions and 15 deletions

View File

@@ -4,24 +4,34 @@ import (
"github.com/godbus/dbus"
)
// NewSession returns a pointer to a new Session based on a Dbus connection and a Dbus path.
func NewSession(conn *dbus.Conn, path dbus.ObjectPath) (session *Session) {
/*
NewSession returns a pointer to a new Session based on a Service and a dbus.ObjectPath.
If path is empty (""), the default
*/
func NewSession(service *Service, path dbus.ObjectPath) (session *Session) {
session = &Session{
var ssn Session = Session{
&DbusObject{
Conn: conn,
Dbus: conn.Object(DbusService, path),
Conn: service.Conn,
},
}
session.Dbus = session.Conn.Object(DbusInterfaceSession, path)
session = &ssn
return
}
// Path returns the path of the underlying Dbus connection.
func (s Session) Path() (path dbus.ObjectPath) {
// Close cleanly closes a Session.
func (s *Session) Close() (err error) {
// Remove this method in V1. It's bloat since we now have an exported Dbus.
path = s.Dbus.Path()
var c *dbus.Call
c = s.Dbus.Call(
DbusSessionClose, 0,
)
_ = c
return
}