示例#1
0
func NewMailer(root string) (*Mailer, error) {
	mailerRC := MailerRC{}
	if err := config.Load("mailer", &mailerRC); err != nil {
		return nil, err
	}
	return &Mailer{
		Config: mailerRC,
		Root:   root,
	}, nil
}
示例#2
0
func main() {
	conf := WMATADbus{}
	if err := config.Load("wmatadbusd", &conf); err != nil {
		panic(err)
	}
	wmata.SetAPIKey(conf.APIKey)

	conn, err := dbus.SessionBus()
	if err != nil {
		panic(err)
	}
	reply, err := conn.RequestName("org.anized.wmata.Rail",
		dbus.NameFlagDoNotQueue)
	if err != nil {
		panic(err)
	}
	if reply != dbus.RequestNameReplyPrimaryOwner {
		fmt.Fprintln(os.Stderr, "name already taken")
		os.Exit(1)
	}

	wmata := WMATADbusInterface{}
	introspectedMethods := introspect.Methods(wmata)

	node := introspect.Node{
		Name: "/org/anized/wmata",
		Interfaces: []introspect.Interface{
			introspect.Interface{
				Name:    "org.anized.wmata.Rail",
				Methods: introspectedMethods,
			},
		},
	}

	export := introspect.NewIntrospectable(&node)
	// str, err := export.Introspect()
	// fmt.Printf("%s %s\n", str, err)
	conn.Export(wmata, "/org/anized/wmata/Rail", "org.anized.wmata.Rail")
	conn.Export(
		export,
		"/org/anized/wmata/Rail",
		"org.freedesktop.DBus.Introspectable",
	)
	select {}
}