Skip to content

Commit 1d04472

Browse files
authored
Merge pull request #408 from ilyam8/login1_context_aware_some_methods
login1: add context-aware ListSessions and ListUsers methods
2 parents 458b399 + 7bb8d0d commit 1d04472

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

login1/dbus.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package login1
1717

1818
import (
19+
"context"
1920
"fmt"
2021
"os"
2122
"strconv"
@@ -253,10 +254,15 @@ func (c *Conn) GetSession(id string) (dbus.ObjectPath, error) {
253254
return ret, nil
254255
}
255256

256-
// ListSessions returns an array with all current sessions.
257+
// Deprecated: use ListSessionsContext instead.
257258
func (c *Conn) ListSessions() ([]Session, error) {
259+
return c.ListSessionsContext(context.Background())
260+
}
261+
262+
// ListSessionsContext returns an array with all current sessions.
263+
func (c *Conn) ListSessionsContext(ctx context.Context) ([]Session, error) {
258264
out := [][]interface{}{}
259-
if err := c.object.Call(dbusInterface+".ListSessions", 0).Store(&out); err != nil {
265+
if err := c.object.CallWithContext(ctx, dbusInterface+".ListSessions", 0).Store(&out); err != nil {
260266
return nil, err
261267
}
262268

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

274-
// ListUsers returns an array with all currently logged in users.
280+
// Deprecated: use ListUsersContext instead.
275281
func (c *Conn) ListUsers() ([]User, error) {
282+
return c.ListUsersContext(context.Background())
283+
}
284+
285+
// ListUsersContext returns an array with all currently logged-in users.
286+
func (c *Conn) ListUsersContext(ctx context.Context) ([]User, error) {
276287
out := [][]interface{}{}
277-
if err := c.object.Call(dbusInterface+".ListUsers", 0).Store(&out); err != nil {
288+
if err := c.object.CallWithContext(ctx, dbusInterface+".ListUsers", 0).Store(&out); err != nil {
278289
return nil, err
279290
}
280291

0 commit comments

Comments
 (0)