本文整理汇总了Golang中github.com/godbus/dbus.Conn.Object方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.Object方法的具体用法?Golang Conn.Object怎么用?Golang Conn.Object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/godbus/dbus.Conn
的用法示例。
在下文中一共展示了Conn.Object方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: recurseObjects
func recurseObjects(bus *dbus.Conn, service, prefix string) ([]string, error) {
var s string
err := bus.Object(service, dbus.ObjectPath(prefix)).Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&s)
if err != nil {
return nil, err
}
var n introspect.Node
err = xml.Unmarshal([]byte(s), &n)
if err != nil {
return nil, err
}
names := make([]string, 0, 100)
if len(n.Interfaces) > 1 {
names = append(names, prefix)
}
for _, child := range n.Children {
childPath := path.Join(prefix, child.Name)
items, err := recurseObjects(bus, service, childPath)
if err != nil {
return nil, err
}
names = append(names, items...)
}
return names, nil
}
示例2: traverseDbusObjects
func traverseDbusObjects(bus *dbus.Conn, dbusService, dbusPath string, fn func(path string, node *introspect.Node)) {
var xmldata string
var node introspect.Node
var o = bus.Object(dbusService, dbus.ObjectPath(dbusPath))
err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata)
if err != nil {
log.Printf("Error getting introspect from [%s, %s]: %s", dbusService, dbusPath, err)
}
err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node)
if err != nil {
log.Printf("Error decoding introspect from [%s, %s]: %s", dbusService, dbusPath, err)
}
// log.Printf("Introspect: %+v", node)
if node.Name != "" && len(node.Interfaces) > 0 {
fn(dbusPath, &node)
}
for _, child := range node.Children {
traverseDbusObjects(bus, dbusService, dbusPath+"/"+child.Name, fn)
}
}
示例3: newPrompter
func newPrompter(conn *dbus.Conn) *prompter {
p := new(prompter)
p.cond = sync.NewCond(&p.lock)
p.dbusObj = conn.Object("com.subgraph.FirewallPrompt", "/com/subgraph/FirewallPrompt")
p.policyMap = make(map[string]*Policy)
go p.promptLoop()
return p
}
示例4: New
func New(conn *dbus.Conn, name string) *Player {
obj := conn.Object(name, dbusObjectPath).(*dbus.Object)
return &Player{
&base{obj},
&player{obj},
}
}
示例5: SendNotification
// SendNotification is same as Notifier.SendNotification
// Provided for convenience.
func SendNotification(conn *dbus.Conn, note Notification) (uint32, error) {
obj := conn.Object(dbusNotificationsInterface, objectPath)
call := obj.Call(notify, 0,
note.AppName,
note.ReplacesID,
note.AppIcon,
note.Summary,
note.Body,
note.Actions,
note.Hints,
note.ExpireTimeout)
if call.Err != nil {
return 0, call.Err
}
var ret uint32
err := call.Store(&ret)
if err != nil {
log.Printf("error getting uint32 ret value: %v", err)
return ret, err
}
return ret, nil
}
示例6: dbusPath
// dbusPath returns the dbus path of the job object.
func (j *job) dbusPath(conn *dbus.Conn) (dbus.ObjectPath, error) {
var jobpath dbus.ObjectPath
// get the job path
err := conn.
Object(upstartServiceDBusPath, upstartManagerObject).
Call("com.ubuntu.Upstart0_6.GetJobByName", 0, j.Name).
Store(&jobpath)
if err != nil {
return jobpath, err
}
return jobpath, nil
}
示例7: systemdObject
func systemdObject(conn *dbus.Conn) dbus.BusObject {
return conn.Object("org.freedesktop.systemd1", dbus.ObjectPath("/org/freedesktop/systemd1"))
}
示例8: NewNotificationObject
func NewNotificationObject(conn *dbus.Conn) *NotificationObject {
return &NotificationObject{
conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications"),
}
}
示例9: NewCollection
func NewCollection(conn *dbus.Conn, path dbus.ObjectPath) *Collection {
return &Collection{
conn: conn,
dbus: conn.Object(DBusServiceName, path),
}
}
示例10: NewLogindObject
func NewLogindObject(conn *dbus.Conn) *LogindObject {
return &LogindObject{
conn.Object("org.freedesktop.login1", "/org/freedesktop/login1"),
}
}
示例11: NewItem
func NewItem(conn *dbus.Conn, path dbus.ObjectPath) *Item {
return &Item{
conn: conn,
dbus: conn.Object(DBusServiceName, path),
}
}
示例12: NewSession
func NewSession(conn *dbus.Conn, path dbus.ObjectPath) *Session {
return &Session{
conn: conn,
dbus: conn.Object(DBusServiceName, path),
}
}