Skip to content

Commit

Permalink
feat(login1): add context-aware ListSessions and ListUsers methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 committed Aug 30, 2022
1 parent 458b399 commit 7bb8d0d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions login1/dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package login1

import (
"context"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -253,10 +254,15 @@ func (c *Conn) GetSession(id string) (dbus.ObjectPath, error) {
return ret, nil
}

// ListSessions returns an array with all current sessions.
// Deprecated: use ListSessionsContext instead.
func (c *Conn) ListSessions() ([]Session, error) {
return c.ListSessionsContext(context.Background())
}

// ListSessionsContext returns an array with all current sessions.
func (c *Conn) ListSessionsContext(ctx context.Context) ([]Session, error) {
out := [][]interface{}{}
if err := c.object.Call(dbusInterface+".ListSessions", 0).Store(&out); err != nil {
if err := c.object.CallWithContext(ctx, dbusInterface+".ListSessions", 0).Store(&out); err != nil {
return nil, err
}

Expand All @@ -271,10 +277,15 @@ func (c *Conn) ListSessions() ([]Session, error) {
return ret, nil
}

// ListUsers returns an array with all currently logged in users.
// Deprecated: use ListUsersContext instead.
func (c *Conn) ListUsers() ([]User, error) {
return c.ListUsersContext(context.Background())
}

// ListUsersContext returns an array with all currently logged-in users.
func (c *Conn) ListUsersContext(ctx context.Context) ([]User, error) {
out := [][]interface{}{}
if err := c.object.Call(dbusInterface+".ListUsers", 0).Store(&out); err != nil {
if err := c.object.CallWithContext(ctx, dbusInterface+".ListUsers", 0).Store(&out); err != nil {
return nil, err
}

Expand Down

0 comments on commit 7bb8d0d

Please # to comment.