Skip to content

Commit cd522c7

Browse files
committed
Various cleanup changes
- Move (*Object).GetProperty to call.go - Don't export SessionBusPlatform - Remove (*Conn).Unexport
1 parent 0811912 commit cd522c7

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

call.go

+21
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ func (o *Object) Call(method string, flags Flags, args ...interface{}) *Call {
4848
return <-o.Go(method, flags, make(chan *Call, 1), args...).Done
4949
}
5050

51+
// GetProperty calls org.freedesktop.DBus.Properties.GetProperty on the given
52+
// object. The property name must be given in interface.member notation.
53+
func (o *Object) GetProperty(p string) (Variant, error) {
54+
idx := strings.LastIndex(p, ".")
55+
if idx == -1 || idx+1 == len(p) {
56+
return Variant{}, errors.New("dbus: invalid property " + p)
57+
}
58+
59+
iface := p[:idx]
60+
prop := p[idx+1:]
61+
62+
result := Variant{}
63+
err := obj.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result)
64+
65+
if err != nil {
66+
return Variant{}, err
67+
}
68+
69+
return result, nil
70+
}
71+
5172
// Go calls a method with the given arguments asynchronously. It returns a
5273
// Call structure representing this method call. The passed channel will
5374
// return the same value once the call is done. If ch is nil, a new channel

conn.go

+1-21
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func SessionBusPrivate() (*Conn, error) {
9696
return Dial(address)
9797
}
9898

99-
return SessionBusPlatform()
99+
return sessionBusPlatform()
100100
}
101101

102102
// SystemBus returns a shared connection to the system bus, connecting to it if
@@ -490,26 +490,6 @@ func (conn *Conn) Signal(ch chan<- *Signal) {
490490
conn.signalsLck.Unlock()
491491
}
492492

493-
func (obj *Object) GetProperty(p string) (Variant, error) {
494-
495-
idx := strings.LastIndex(p, ".")
496-
if idx == -1 || idx+1 == len(p) {
497-
return Variant{}, errors.New("dbus: invalid property " + p)
498-
}
499-
500-
iface := p[:idx]
501-
prop := p[idx+1:]
502-
503-
result := Variant{}
504-
err := obj.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result)
505-
506-
if err != nil {
507-
return Variant{}, err
508-
}
509-
510-
return result, nil
511-
}
512-
513493
// SupportsUnixFDs returns whether the underlying transport supports passing of
514494
// unix file descriptors. If this is false, method calls containing unix file
515495
// descriptors will return an error and emitted signals containing them will

conn_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os/exec"
66
)
77

8-
func SessionBusPlatform() (*Conn, error) {
8+
func sessionBusPlatform() (*Conn, error) {
99
cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET")
1010
b, err := cmd.CombinedOutput()
1111

conn_other.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os/exec"
99
)
1010

11-
func SessionBusPlatform() (*Conn, error) {
11+
func sessionBusPlatform() (*Conn, error) {
1212
cmd := exec.Command("dbus-launch")
1313
b, err := cmd.CombinedOutput()
1414

export.go

-5
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,6 @@ func (conn *Conn) RequestName(name string, flags RequestNameFlags) (RequestNameR
254254
return RequestNameReply(r), nil
255255
}
256256

257-
func (conn *Conn) Unexport(path ObjectPath, iface string) {
258-
conn.handlersLck.Lock()
259-
conn.handlersLck.Unlock()
260-
}
261-
262257
// ReleaseNameReply is the reply to a ReleaseName call.
263258
type ReleaseNameReply uint32
264259

0 commit comments

Comments
 (0)