summaryrefslogtreecommitdiff
path: root/vendor/github.com/godbus
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/godbus')
-rw-r--r--vendor/github.com/godbus/dbus/conn.go6
-rw-r--r--vendor/github.com/godbus/dbus/conn_other.go6
-rw-r--r--vendor/github.com/godbus/dbus/decoder.go53
-rw-r--r--vendor/github.com/godbus/dbus/default_handler.go4
-rw-r--r--vendor/github.com/godbus/dbus/go.mod2
-rw-r--r--vendor/github.com/godbus/dbus/object.go19
-rw-r--r--vendor/github.com/godbus/dbus/transport_tcp.go2
-rw-r--r--vendor/github.com/godbus/dbus/transport_unix.go2
8 files changed, 81 insertions, 13 deletions
diff --git a/vendor/github.com/godbus/dbus/conn.go b/vendor/github.com/godbus/dbus/conn.go
index b38920baf..9dced0cc4 100644
--- a/vendor/github.com/godbus/dbus/conn.go
+++ b/vendor/github.com/godbus/dbus/conn.go
@@ -134,6 +134,8 @@ func SystemBus() (conn *Conn, err error) {
}
// SystemBusPrivate returns a new private connection to the system bus.
+// Note: this connection is not ready to use. One must perform Auth and Hello
+// on the connection before it is useable.
func SystemBusPrivate(opts ...ConnOption) (*Conn, error) {
return Dial(getSystemBusPlatformAddress(), opts...)
}
@@ -267,7 +269,7 @@ func (conn *Conn) Eavesdrop(ch chan<- *Message) {
conn.eavesdroppedLck.Unlock()
}
-// GetSerial returns an unused serial.
+// getSerial returns an unused serial.
func (conn *Conn) getSerial() uint32 {
return conn.serialGen.GetSerial()
}
@@ -381,8 +383,6 @@ func (conn *Conn) Object(dest string, path ObjectPath) BusObject {
return &Object{conn, dest, path}
}
-// outWorker runs in an own goroutine, encoding and sending messages that are
-// sent to conn.out.
func (conn *Conn) sendMessage(msg *Message) {
conn.sendMessageAndIfClosed(msg, func() {})
}
diff --git a/vendor/github.com/godbus/dbus/conn_other.go b/vendor/github.com/godbus/dbus/conn_other.go
index 289044a44..616dcf664 100644
--- a/vendor/github.com/godbus/dbus/conn_other.go
+++ b/vendor/github.com/godbus/dbus/conn_other.go
@@ -14,8 +14,10 @@ import (
"strings"
)
+var execCommand = exec.Command
+
func getSessionBusPlatformAddress() (string, error) {
- cmd := exec.Command("dbus-launch")
+ cmd := execCommand("dbus-launch")
b, err := cmd.CombinedOutput()
if err != nil {
@@ -25,7 +27,7 @@ func getSessionBusPlatformAddress() (string, error) {
i := bytes.IndexByte(b, '=')
j := bytes.IndexByte(b, '\n')
- if i == -1 || j == -1 {
+ if i == -1 || j == -1 || i > j {
return "", errors.New("dbus: couldn't determine address of session bus")
}
diff --git a/vendor/github.com/godbus/dbus/decoder.go b/vendor/github.com/godbus/dbus/decoder.go
index 5c27d3b51..ede91575b 100644
--- a/vendor/github.com/godbus/dbus/decoder.go
+++ b/vendor/github.com/godbus/dbus/decoder.go
@@ -188,8 +188,14 @@ func (dec *decoder) decode(s string, depth int) interface{} {
if depth >= 64 {
panic(FormatError("input exceeds container depth limit"))
}
+ sig := s[1:]
length := dec.decode("u", depth).(uint32)
- v := reflect.MakeSlice(reflect.SliceOf(typeFor(s[1:])), 0, int(length))
+ // capacity can be determined only for fixed-size element types
+ var capacity int
+ if s := sigByteSize(sig); s != 0 {
+ capacity = int(length) / s
+ }
+ v := reflect.MakeSlice(reflect.SliceOf(typeFor(sig)), 0, capacity)
// Even for empty arrays, the correct padding must be included
align := alignment(typeFor(s[1:]))
if len(s) > 1 && s[1] == '(' {
@@ -227,6 +233,51 @@ func (dec *decoder) decode(s string, depth int) interface{} {
}
}
+// sigByteSize tries to calculates size of the given signature in bytes.
+//
+// It returns zero when it can't, for example when it contains non-fixed size
+// types such as strings, maps and arrays that require reading of the transmitted
+// data, for that we would need to implement the unread method for Decoder first.
+func sigByteSize(sig string) int {
+ var total int
+ for offset := 0; offset < len(sig); {
+ switch sig[offset] {
+ case 'y':
+ total += 1
+ offset += 1
+ case 'n', 'q':
+ total += 2
+ offset += 1
+ case 'b', 'i', 'u', 'h':
+ total += 4
+ offset += 1
+ case 'x', 't', 'd':
+ total += 8
+ offset += 1
+ case '(':
+ i := 1
+ depth := 1
+ for i < len(sig[offset:]) && depth != 0 {
+ if sig[offset+i] == '(' {
+ depth++
+ } else if sig[offset+i] == ')' {
+ depth--
+ }
+ i++
+ }
+ s := sigByteSize(sig[offset+1 : offset+i-1])
+ if s == 0 {
+ return 0
+ }
+ total += s
+ offset += i
+ default:
+ return 0
+ }
+ }
+ return total
+}
+
// A FormatError is an error in the wire format.
type FormatError string
diff --git a/vendor/github.com/godbus/dbus/default_handler.go b/vendor/github.com/godbus/dbus/default_handler.go
index 81dbcc7e4..890b6f4e0 100644
--- a/vendor/github.com/godbus/dbus/default_handler.go
+++ b/vendor/github.com/godbus/dbus/default_handler.go
@@ -263,13 +263,13 @@ func (sh *defaultSignalHandler) DeliverSignal(intf, name string, signal *Signal)
case <-sh.closeChan:
return
default:
- go func() {
+ go func(ch chan<- *Signal) {
select {
case ch <- signal:
case <-sh.closeChan:
return
}
- }()
+ }(ch)
}
}
}
diff --git a/vendor/github.com/godbus/dbus/go.mod b/vendor/github.com/godbus/dbus/go.mod
index bdcd12598..57014e4ac 100644
--- a/vendor/github.com/godbus/dbus/go.mod
+++ b/vendor/github.com/godbus/dbus/go.mod
@@ -1 +1,3 @@
module github.com/godbus/dbus
+
+go 1.12
diff --git a/vendor/github.com/godbus/dbus/object.go b/vendor/github.com/godbus/dbus/object.go
index f27ffe144..9309b9b40 100644
--- a/vendor/github.com/godbus/dbus/object.go
+++ b/vendor/github.com/godbus/dbus/object.go
@@ -16,6 +16,7 @@ type BusObject interface {
AddMatchSignal(iface, member string, options ...MatchOption) *Call
RemoveMatchSignal(iface, member string, options ...MatchOption) *Call
GetProperty(p string) (Variant, error)
+ SetProperty(p string, v interface{}) error
Destination() string
Path() ObjectPath
}
@@ -146,7 +147,7 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch
}
if msg.Flags&FlagNoReplyExpected == 0 {
if ch == nil {
- ch = make(chan *Call, 10)
+ ch = make(chan *Call, 1)
} else if cap(ch) == 0 {
panic("dbus: unbuffered channel passed to (*Object).Go")
}
@@ -187,7 +188,7 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch
return call
}
-// GetProperty calls org.freedesktop.DBus.Properties.GetProperty on the given
+// GetProperty calls org.freedesktop.DBus.Properties.Get on the given
// object. The property name must be given in interface.member notation.
func (o *Object) GetProperty(p string) (Variant, error) {
idx := strings.LastIndex(p, ".")
@@ -208,6 +209,20 @@ func (o *Object) GetProperty(p string) (Variant, error) {
return result, nil
}
+// SetProperty calls org.freedesktop.DBus.Properties.Set on the given
+// object. The property name must be given in interface.member notation.
+func (o *Object) SetProperty(p string, v interface{}) error {
+ idx := strings.LastIndex(p, ".")
+ if idx == -1 || idx+1 == len(p) {
+ return errors.New("dbus: invalid property " + p)
+ }
+
+ iface := p[:idx]
+ prop := p[idx+1:]
+
+ return o.Call("org.freedesktop.DBus.Properties.Set", 0, iface, prop, v).Err
+}
+
// Destination returns the destination that calls on (o *Object) are sent to.
func (o *Object) Destination() string {
return o.dest
diff --git a/vendor/github.com/godbus/dbus/transport_tcp.go b/vendor/github.com/godbus/dbus/transport_tcp.go
index dd1c8e59c..f91c9b7d7 100644
--- a/vendor/github.com/godbus/dbus/transport_tcp.go
+++ b/vendor/github.com/godbus/dbus/transport_tcp.go
@@ -1,5 +1,3 @@
-//+build !windows
-
package dbus
import (
diff --git a/vendor/github.com/godbus/dbus/transport_unix.go b/vendor/github.com/godbus/dbus/transport_unix.go
index f000c6b5d..c7cd02f97 100644
--- a/vendor/github.com/godbus/dbus/transport_unix.go
+++ b/vendor/github.com/godbus/dbus/transport_unix.go
@@ -203,7 +203,7 @@ func (t *unixTransport) SendMessage(msg *Message) error {
}
} else {
if err := msg.EncodeTo(t, nativeEndian); err != nil {
- return nil
+ return err
}
}
return nil