transport_generic.go 644 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dbus
  2. import (
  3. "encoding/binary"
  4. "errors"
  5. "io"
  6. )
  7. type genericTransport struct {
  8. io.ReadWriteCloser
  9. }
  10. func (t genericTransport) SendNullByte() error {
  11. _, err := t.Write([]byte{0})
  12. return err
  13. }
  14. func (t genericTransport) SupportsUnixFDs() bool {
  15. return false
  16. }
  17. func (t genericTransport) EnableUnixFDs() {}
  18. func (t genericTransport) ReadMessage() (*Message, error) {
  19. return DecodeMessage(t)
  20. }
  21. func (t genericTransport) SendMessage(msg *Message) error {
  22. for _, v := range msg.Body {
  23. if _, ok := v.(UnixFD); ok {
  24. return errors.New("dbus: unix fd passing not enabled")
  25. }
  26. }
  27. return msg.EncodeTo(t, binary.LittleEndian)
  28. }