gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

server_interfaces.go (3887B)


      1 package dbus
      2 
      3 // Terminator allows a handler to implement a shutdown mechanism that
      4 // is called when the connection terminates.
      5 type Terminator interface {
      6 	Terminate()
      7 }
      8 
      9 // Handler is the representation of a D-Bus Application.
     10 //
     11 // The Handler must have a way to lookup objects given
     12 // an ObjectPath. The returned object must implement the
     13 // ServerObject interface.
     14 type Handler interface {
     15 	LookupObject(path ObjectPath) (ServerObject, bool)
     16 }
     17 
     18 // ServerObject is the representation of an D-Bus Object.
     19 //
     20 // Objects are registered at a path for a given Handler.
     21 // The Objects implement D-Bus interfaces. The semantics
     22 // of Interface lookup is up to the implementation of
     23 // the ServerObject. The ServerObject implementation may
     24 // choose to implement empty string as a valid interface
     25 // represeting all methods or not per the D-Bus specification.
     26 type ServerObject interface {
     27 	LookupInterface(name string) (Interface, bool)
     28 }
     29 
     30 // An Interface is the representation of a D-Bus Interface.
     31 //
     32 // Interfaces are a grouping of methods implemented by the Objects.
     33 // Interfaces are responsible for routing method calls.
     34 type Interface interface {
     35 	LookupMethod(name string) (Method, bool)
     36 }
     37 
     38 // A Method represents the exposed methods on D-Bus.
     39 type Method interface {
     40 	// Call requires that all arguments are decoded before being passed to it.
     41 	Call(args ...interface{}) ([]interface{}, error)
     42 	NumArguments() int
     43 	NumReturns() int
     44 	// ArgumentValue returns a representative value for the argument at position
     45 	// it should be of the proper type. reflect.Zero would be a good mechanism
     46 	// to use for this Value.
     47 	ArgumentValue(position int) interface{}
     48 	// ReturnValue returns a representative value for the return at position
     49 	// it should be of the proper type. reflect.Zero would be a good mechanism
     50 	// to use for this Value.
     51 	ReturnValue(position int) interface{}
     52 }
     53 
     54 // An Argument Decoder can decode arguments using the non-standard mechanism
     55 //
     56 // If a method implements this interface then the non-standard
     57 // decoder will be used.
     58 //
     59 // Method arguments must be decoded from the message.
     60 // The mechanism for doing this will vary based on the
     61 // implementation of the method. A normal approach is provided
     62 // as part of this library, but may be replaced with
     63 // any other decoding scheme.
     64 type ArgumentDecoder interface {
     65 	// To decode the arguments of a method the sender and message are
     66 	// provided incase the semantics of the implementer provides access
     67 	// to these as part of the method invocation.
     68 	DecodeArguments(conn *Conn, sender string, msg *Message, args []interface{}) ([]interface{}, error)
     69 }
     70 
     71 // A SignalHandler is responsible for delivering a signal.
     72 //
     73 // Signal delivery may be changed from the default channel
     74 // based approach by Handlers implementing the SignalHandler
     75 // interface.
     76 type SignalHandler interface {
     77 	DeliverSignal(iface, name string, signal *Signal)
     78 }
     79 
     80 // SignalRegistrar manages signal delivery channels.
     81 //
     82 // This is an optional set of methods for `SignalHandler`.
     83 type SignalRegistrar interface {
     84 	AddSignal(ch chan<- *Signal)
     85 	RemoveSignal(ch chan<- *Signal)
     86 }
     87 
     88 // A DBusError is used to convert a generic object to a D-Bus error.
     89 //
     90 // Any custom error mechanism may implement this interface to provide
     91 // a custom encoding of the error on D-Bus. By default if a normal
     92 // error is returned, it will be encoded as the generic
     93 // "org.freedesktop.DBus.Error.Failed" error. By implementing this
     94 // interface as well a custom encoding may be provided.
     95 type DBusError interface {
     96 	DBusError() (string, []interface{})
     97 }
     98 
     99 // SerialGenerator is responsible for serials generation.
    100 //
    101 // Different approaches for the serial generation can be used,
    102 // maintaining a map guarded with a mutex (the standard way) or
    103 // simply increment an atomic counter.
    104 type SerialGenerator interface {
    105 	GetSerial() uint32
    106 	RetireSerial(serial uint32)
    107 }