Skip to content

Instantly share code, notes, and snippets.

@sergiusens
Created September 29, 2014 21:24
Show Gist options
  • Save sergiusens/703f3eb664b05b891b91 to your computer and use it in GitHub Desktop.
Save sergiusens/703f3eb664b05b891b91 to your computer and use it in GitHub Desktop.
Set a preferred context
package main
import (
"fmt"
"os"
"launchpad.net/go-dbus/v1"
)
func main() {
if len(os.Args) != 3 {
fmt.Println("Usage:", os.Args[0], "[service object path] [context]")
os.Exit(1)
}
var conn *dbus.Connection
var err error
if conn, err = dbus.Connect(dbus.SessionBus); err != nil {
fmt.Println("Connection error: ", err)
os.Exit(1)
}
p := dbus.Variant{dbus.ObjectPath(os.Args[2])}
obj := conn.Object("org.ofono.mms", dbus.ObjectPath(os.Args[1]))
if _, err := obj.Call("org.ofono.mms.Service", "SetProperty", "PreferredContext", p); err != nil {
fmt.Println("Cannot set property :", err)
os.Exit(1)
}
fmt.Println("Property set to", os.Args[2], "for", os.Args[1])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment