1package dbus 2 3import ( 4 "context" 5 "errors" 6) 7 8var errSignature = errors.New("dbus: mismatched signature") 9 10// Call represents a pending or completed method call. 11type Call struct { 12 Destination string 13 Path ObjectPath 14 Method string 15 Args []interface{} 16 17 // Strobes when the call is complete. 18 Done chan *Call 19 20 // After completion, the error status. If this is non-nil, it may be an 21 // error message from the peer (with Error as its type) or some other error. 22 Err error 23 24 // Holds the response once the call is done. 25 Body []interface{} 26 27 // tracks context and canceler 28 ctx context.Context 29 ctxCanceler context.CancelFunc 30} 31 32func (c *Call) Context() context.Context { 33 if c.ctx == nil { 34 return context.Background() 35 } 36 37 return c.ctx 38} 39 40func (c *Call) ContextCancel() { 41 if c.ctxCanceler != nil { 42 c.ctxCanceler() 43 } 44} 45 46// Store stores the body of the reply into the provided pointers. It returns 47// an error if the signatures of the body and retvalues don't match, or if 48// the error status is not nil. 49func (c *Call) Store(retvalues ...interface{}) error { 50 if c.Err != nil { 51 return c.Err 52 } 53 54 return Store(c.Body, retvalues...) 55} 56 57func (c *Call) done() { 58 c.Done <- c 59 c.ContextCancel() 60} 61