File: proxy.go

package info (click to toggle)
golang-go-dbus 1~bzr20150122-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 328 kB
  • sloc: makefile: 13
file content (172 lines) | stat: -rw-r--r-- 4,111 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package dbus

// This is not yet finished: it is an idea for what statically generated object bindings could look like.

type Introspectable struct {
	*ObjectProxy
}

func (o *Introspectable) Introspect() (data string, err error) {
	reply, err := o.Call("org.freedesktop.DBus.Introspectable", "Introspect")
	if err != nil {
		return
	}
	err = reply.Args(&data)
	return
}

type Properties struct {
	*ObjectProxy
}

func (o *Properties) Get(interfaceName string, propertyName string) (value interface{}, err error) {
	reply, err := o.Call("org.freedesktop.DBus.Properties", "Get", interfaceName, propertyName)
	if err != nil {
		return
	}
	var variant Variant
	err = reply.Args(&variant)
	value = variant.Value
	return
}

func (o *Properties) Set(interfaceName string, propertyName string, value interface{}) (err error) {
	_, err = o.Call("org.freedesktop.DBus.Properties", "Set", interfaceName, propertyName, Variant{value})
	return
}

func (o *Properties) GetAll(interfaceName string) (props map[string]Variant, err error) {
	reply, err := o.Call("org.freedesktop.DBus.Properties", "GetAll", interfaceName)
	if err != nil {
		return
	}
	err = reply.Args(&props)
	return
}

type BusDaemon struct {
	*ObjectProxy
}

func (o *BusDaemon) Hello() (uniqueName string, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "Hello")
	if err != nil {
		return
	}
	err = reply.Args(&uniqueName)
	return
}

func (o *BusDaemon) RequestName(name string, flags uint32) (result uint32, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "RequestName", name, flags)
	if err != nil {
		return
	}
	err = reply.Args(&result)
	return
}

func (o *BusDaemon) ReleaseName(name string) (result uint32, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "ReleaseName", name)
	if err != nil {
		return
	}
	err = reply.Args(&result)
	return
}

func (o *BusDaemon) ListQueuedOwners(name string) (owners []string, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "ListQueuedOwners", name)
	if err != nil {
		return
	}
	err = reply.Args(&owners)
	return
}

func (o *BusDaemon) ListNames() (names []string, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "ListNames")
	if err != nil {
		return
	}
	err = reply.Args(&names)
	return
}

func (o *BusDaemon) ListActivatableNames() (names []string, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "ListActivatableNames")
	if err != nil {
		return
	}
	err = reply.Args(&names)
	return
}

func (o *BusDaemon) NameHasOwner(name string) (hasOwner bool, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "NameHasOwner", name)
	if err != nil {
		return
	}
	err = reply.Args(&hasOwner)
	return
}

func (o *BusDaemon) StartServiceByName(name string, flags uint32) (result uint32, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "StartServiceByName", name, flags)
	if err != nil {
		return
	}
	err = reply.Args(&result)
	return
}

func (o *BusDaemon) UpdateActivationEnvironment(env map[string]string) (err error) {
	_, err = o.Call(BUS_DAEMON_IFACE, "UpdateActivationEnvironment", env)
	return
}

func (o *BusDaemon) GetNameOwner(name string) (owner string, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "GetNameOwner", name)
	if err != nil {
		return
	}
	err = reply.Args(&owner)
	return
}

func (o *BusDaemon) GetConnectionUnixUser(busName string) (user uint32, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "GetConnectionUnixUser", busName)
	if err != nil {
		return
	}
	err = reply.Args(&user)
	return
}

func (o *BusDaemon) GetConnectionUnixProcessID(busName string) (process uint32, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "GetConnectionUnixProcessID", busName)
	if err != nil {
		return
	}
	err = reply.Args(&process)
	return
}

func (o *BusDaemon) AddMatch(rule string) (err error) {
	_, err = o.Call(BUS_DAEMON_IFACE, "AddMatch", rule)
	return
}

func (o *BusDaemon) RemoveMatch(rule string) (err error) {
	_, err = o.Call(BUS_DAEMON_IFACE, "RemoveMatch", rule)
	return
}

func (o *BusDaemon) GetId() (busId string, err error) {
	reply, err := o.Call(BUS_DAEMON_IFACE, "GetId")
	if err != nil {
		return
	}
	err = reply.Args(&busId)
	return
}