Created
September 29, 2014 21:24
-
-
Save sergiusens/703f3eb664b05b891b91 to your computer and use it in GitHub Desktop.
Set a preferred context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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