예제 #1
0
func initializeLibs() error {
	var err error
	upower, err = libupower.NewUpower(UPOWER_BUS_NAME, "/org/freedesktop/UPower")
	if err != nil {
		logger.Warning("create dbus upower failed:", err)
		return err
	}
	login1, err = liblogin1.NewManager("org.freedesktop.login1", "/org/freedesktop/login1")
	if err != nil {
		logger.Warning("create dbus login1 failed:", err)
		finalizeLibs()
		return err
	}
	mediaKey, err = libkeybinding.NewMediaKey("com.deepin.daemon.KeyBinding", "/com/deepin/daemon/MediaKey")
	if err != nil {
		logger.Warning("create dbus mediaKey failed:", err)
		finalizeLibs()
		return err
	}
	notifier, err = libnotifications.NewNotifier("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
	if err != nil {
		logger.Warning("Can't build org.freedesktop.Notficaations:", err)
		finalizeLibs()
		return err
	}
	player, err = libsound.NewSound("com.deepin.api.Sound", "/com/deepin/api/Sound")
	if err != nil {
		logger.Warning("Can't build com.deepin.api.Sound:", err)
		finalizeLibs()
		return err
	}

	power = NewPower()
	return nil
}
예제 #2
0
func (dbusIfc *DBusInterfaceTest) TestDeviceInterfaceExist(c *C.C) {
	upowerObj, err := libupower.NewUpower("org.freedesktop.UPower",
		"/org/freedesktop/UPower")
	if err != nil {
		c.Error(err)
		return
	}

	devs, err := upowerObj.EnumerateDevices()
	if err != nil {
		c.Error(err)
		return
	}

	if len(devs) == 0 {
		return
	}

	root, err := getNodeInfo("org.freedesktop.UPower", devs[0])
	if err != nil {
		c.Error(err)
		return
	}

	IfcInfos := []interfaceInfo{
		interfaceInfo{"Percentage", "property", true},
		interfaceInfo{"State", "property", true},
		interfaceInfo{"IsPresent", "property", true},
		interfaceInfo{"Type", "property", true},
		interfaceInfo{"Changed", "signal", false},
	}

	for _, info := range IfcInfos {
		c.Check(isInterfaceNameFound(info.name, info.ifcType, root),
			C.Equals, info.exist)
	}
}