refactor(deps): Manage deps with goven
This commit is contained in:
30
third_party/github.com/guelfey/go.dbus/_examples/eavesdrop.go
vendored
Normal file
30
third_party/github.com/guelfey/go.dbus/_examples/eavesdrop.go
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Failed to connect to session bus:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, v := range []string{"method_call", "method_return", "error", "signal"} {
|
||||
call := conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0,
|
||||
"eavesdrop='true',type='"+v+"'")
|
||||
if call.Err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Failed to add match:", call.Err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
c := make(chan *dbus.Message, 10)
|
||||
conn.Eavesdrop(c)
|
||||
fmt.Println("Listening for everything")
|
||||
for v := range c {
|
||||
fmt.Println(v)
|
||||
}
|
||||
}
|
21
third_party/github.com/guelfey/go.dbus/_examples/introspect.go
vendored
Normal file
21
third_party/github.com/guelfey/go.dbus/_examples/introspect.go
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus/introspect"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
node, err := introspect.Call(conn.Object("org.freedesktop.DBus", "/org/freedesktop/DBus"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
data, _ := json.MarshalIndent(node, "", " ")
|
||||
os.Stdout.Write(data)
|
||||
}
|
27
third_party/github.com/guelfey/go.dbus/_examples/list-names.go
vendored
Normal file
27
third_party/github.com/guelfey/go.dbus/_examples/list-names.go
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Failed to connect to session bus:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var s []string
|
||||
err = conn.BusObject().Call("org.freedesktop.DBus.ListNames", 0).Store(&s)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Failed to get list of owned names:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Currently owned names on the session bus:")
|
||||
for _, v := range s {
|
||||
fmt.Println(v)
|
||||
}
|
||||
}
|
17
third_party/github.com/guelfey/go.dbus/_examples/notification.go
vendored
Normal file
17
third_party/github.com/guelfey/go.dbus/_examples/notification.go
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import "github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
|
||||
call := obj.Call("org.freedesktop.Notifications.Notify", 0, "", uint32(0),
|
||||
"", "Test", "This is a test of the DBus bindings for go.", []string{},
|
||||
map[string]dbus.Variant{}, int32(5000))
|
||||
if call.Err != nil {
|
||||
panic(call.Err)
|
||||
}
|
||||
}
|
68
third_party/github.com/guelfey/go.dbus/_examples/prop.go
vendored
Normal file
68
third_party/github.com/guelfey/go.dbus/_examples/prop.go
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus/introspect"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus/prop"
|
||||
"os"
|
||||
)
|
||||
|
||||
type foo string
|
||||
|
||||
func (f foo) Foo() (string, *dbus.Error) {
|
||||
fmt.Println(f)
|
||||
return string(f), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
reply, err := conn.RequestName("com.github.guelfey.Demo",
|
||||
dbus.NameFlagDoNotQueue)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if reply != dbus.RequestNameReplyPrimaryOwner {
|
||||
fmt.Fprintln(os.Stderr, "name already taken")
|
||||
os.Exit(1)
|
||||
}
|
||||
propsSpec := map[string]map[string]*prop.Prop{
|
||||
"com.github.guelfey.Demo": {
|
||||
"SomeInt": {
|
||||
int32(0),
|
||||
true,
|
||||
prop.EmitTrue,
|
||||
func(c *prop.Change) *dbus.Error {
|
||||
fmt.Println(c.Name, "changed to", c.Value)
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
f := foo("Bar")
|
||||
conn.Export(f, "/com/github/guelfey/Demo", "com.github.guelfey.Demo")
|
||||
props := prop.New(conn, "/com/github/guelfey/Demo", propsSpec)
|
||||
n := &introspect.Node{
|
||||
Name: "/com/github/guelfey/Demo",
|
||||
Interfaces: []introspect.Interface{
|
||||
introspect.IntrospectData,
|
||||
prop.IntrospectData,
|
||||
{
|
||||
Name: "com.github.guelfey.Demo",
|
||||
Methods: introspect.Methods(f),
|
||||
Properties: props.Introspection("com.github.guelfey.Demo"),
|
||||
},
|
||||
},
|
||||
}
|
||||
conn.Export(introspect.NewIntrospectable(n), "/com/github/guelfey/Demo",
|
||||
"org.freedesktop.DBus.Introspectable")
|
||||
fmt.Println("Listening on com.github.guelfey.Demo / /com/github/guelfey/Demo ...")
|
||||
|
||||
c := make(chan *dbus.Signal)
|
||||
conn.Signal(c)
|
||||
for _ = range c {
|
||||
}
|
||||
}
|
45
third_party/github.com/guelfey/go.dbus/_examples/server.go
vendored
Normal file
45
third_party/github.com/guelfey/go.dbus/_examples/server.go
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus/introspect"
|
||||
"os"
|
||||
)
|
||||
|
||||
const intro = `
|
||||
<node>
|
||||
<interface name="com.github.guelfey.Demo">
|
||||
<method name="Foo">
|
||||
<arg direction="out" type="s"/>
|
||||
</method>
|
||||
</interface>` + introspect.IntrospectDataString + `</node> `
|
||||
|
||||
type foo string
|
||||
|
||||
func (f foo) Foo() (string, *dbus.Error) {
|
||||
fmt.Println(f)
|
||||
return string(f), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
reply, err := conn.RequestName("com.github.guelfey.Demo",
|
||||
dbus.NameFlagDoNotQueue)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if reply != dbus.RequestNameReplyPrimaryOwner {
|
||||
fmt.Fprintln(os.Stderr, "name already taken")
|
||||
os.Exit(1)
|
||||
}
|
||||
f := foo("Bar!")
|
||||
conn.Export(f, "/com/github/guelfey/Demo", "com.github.guelfey.Demo")
|
||||
conn.Export(introspect.Introspectable(intro), "/com/github/guelfey/Demo",
|
||||
"org.freedesktop.DBus.Introspectable")
|
||||
fmt.Println("Listening on com.github.guelfey.Demo / /com/github/guelfey/Demo ...")
|
||||
select {}
|
||||
}
|
24
third_party/github.com/guelfey/go.dbus/_examples/signal.go
vendored
Normal file
24
third_party/github.com/guelfey/go.dbus/_examples/signal.go
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Failed to connect to session bus:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0,
|
||||
"type='signal',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',sender='org.freedesktop.DBus'")
|
||||
|
||||
c := make(chan *dbus.Signal, 10)
|
||||
conn.Signal(c)
|
||||
for v := range c {
|
||||
fmt.Println(v)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user