当前位置: 首页>>代码示例>>Golang>>正文


Golang dbus.DMessage类代码示例

本文整理汇总了Golang中pkg/linuxdeepin/com/lib/dbus.DMessage的典型用法代码示例。如果您正苦于以下问题:Golang DMessage类的具体用法?Golang DMessage怎么用?Golang DMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DMessage类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CreateUser

func (m *Manager) CreateUser(dbusMsg dbus.DMessage,
	name, fullname string, ty int32) error {
	pid := dbusMsg.GetSenderPID()
	err := m.polkitAuthManagerUser(pid, "CreateUser")
	if err != nil {
		return err
	}

	// Avoid dde-control-center UI block
	go func() {
		err := users.CreateUser(name, fullname, "", ty)
		if err != nil {
			logger.Warningf("DoAction: create user '%s' failed: %v\n",
				name, err)
			triggerSigErr(pid, "CreateUser", err.Error())
			return
		}

		err = users.SetUserType(ty, name)
		if err != nil {
			logger.Warningf("DoAction: set user type '%s' failed: %v\n",
				name, err)
		}
	}()

	return nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:27,代码来源:manager_ifc.go

示例2: DeleteUser

func (m *Manager) DeleteUser(dbusMsg dbus.DMessage,
	name string, rmFiles bool) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := m.polkitAuthManagerUser(pid, "DeleteUser")
	if err != nil {
		return false, err
	}

	go func() {
		err := users.DeleteUser(rmFiles, name)
		if err != nil {
			logger.Warningf("DoAction: delete user '%s' failed: %v\n",
				name, err)
			triggerSigErr(pid, "DeleteUser", err.Error())
			return
		}

		//delete user config and icons
		if !rmFiles {
			return
		}
		clearUserDatas(name)
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:26,代码来源:manager_ifc.go

示例3: SetBackgroundFile

func (u *User) SetBackgroundFile(dbusMsg dbus.DMessage, bg string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, true, "SetBackgroundFile")
	if err != nil {
		return false, err
	}

	if bg == u.BackgroundFile {
		return true, nil
	}

	if !graphic.IsSupportedImage(bg) {
		reason := fmt.Sprintf("This background '%s' not a image", bg)
		logger.Debug(reason)
		triggerSigErr(pid, "SetBackgroundFile", reason)
		return false, err
	}

	go func() {
		src := u.BackgroundFile
		u.setPropString(&u.BackgroundFile, "BackgroundFile", bg)
		err = u.writeUserConfig()
		if err != nil {
			logger.Warning("Write user config failed:", err)
			triggerSigErr(pid, "SetBackgroundFile", err.Error())
			u.setPropString(&u.BackgroundFile, "BackgroundFile", src)
			return
		}
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:32,代码来源:user_ifc.go

示例4: DeleteIconFile

func (u *User) DeleteIconFile(dbusMsg dbus.DMessage, icon string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, true, "DeleteIconFile")
	if err != nil {
		return false, err
	}

	if !u.IsIconDeletable(icon) {
		reason := "This icon is not allowed to be deleted!"
		logger.Warning(reason)
		triggerSigErr(pid, "DeleteHistoryIcon", reason)
		return false, fmt.Errorf(reason)
	}

	go func() {
		err := os.Remove(icon)
		if err != nil {
			triggerSigErr(pid, "DeleteIconFile", err.Error())
			return
		}

		u.DeleteHistoryIcon(dbusMsg, icon)
		u.setPropStrv(&u.IconList, "IconList", u.getAllIcons())
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:27,代码来源:user_ifc.go

示例5: SetAutomaticLogin

func (u *User) SetAutomaticLogin(dbusMsg dbus.DMessage, auto bool) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, false, "SetAutomaticLogin")
	if err != nil {
		return false, err
	}

	var name = u.UserName
	if !auto {
		name = ""
	}

	go func() {
		err := users.SetAutoLoginUser(name)
		if err != nil {
			logger.Warning("DoAction: set auto login failed:", err)
			triggerSigErr(pid, "SetAutomaticLogin", err.Error())
			return
		}

		u.setPropBool(&u.AutomaticLogin, "AutomaticLogin", auto)
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:25,代码来源:user_ifc.go

示例6: DeleteHistoryIcon

func (u *User) DeleteHistoryIcon(dbusMsg dbus.DMessage, icon string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, true, "DeleteHistoryIcon")
	if err != nil {
		return false, err
	}

	u.deleteHistoryIcon(icon)
	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:10,代码来源:user_ifc.go

示例7: SetIconFile

func (u *User) SetIconFile(dbusMsg dbus.DMessage, icon string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, true, "SetIconFile")
	if err != nil {
		return false, err
	}

	if u.IconFile == icon {
		return true, nil
	}

	if !graphic.IsSupportedImage(icon) {
		reason := fmt.Sprintf("This icon '%s' not a image", icon)
		logger.Debug(reason)
		triggerSigErr(pid, "SetIconFile", reason)
		return false, err
	}

	go func() {
		target, added, err := u.addIconFile(icon)
		if err != nil {
			logger.Warning("Set icon failed:", err)
			triggerSigErr(pid, "SetIconFile", err.Error())
			return
		}

		src := u.IconFile
		u.setPropString(&u.IconFile, "IconFile", target)
		err = u.writeUserConfig()
		if err != nil {
			logger.Warning("Write user config failed:", err)
			triggerSigErr(pid, "SetIconFile", err.Error())
			u.setPropString(&u.IconFile, "IconFile", src)
			return
		}
		u.addHistoryIcon(src)
		if added {
			u.setPropStrv(&u.IconList, "IconList", u.getAllIcons())
		}
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:43,代码来源:user_ifc.go

示例8: SetShell

func (u *User) SetShell(dbusMsg dbus.DMessage, shell string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, true, "SetShell")
	if err != nil {
		return false, err
	}

	go func() {
		err := users.ModifyShell(shell, u.UserName)
		if err != nil {
			logger.Warning("DoAction: modify shell failed:", err)
			triggerSigErr(pid, "SetShell", err.Error())
			return
		}

		u.setPropString(&u.Shell, "Shell", shell)
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:20,代码来源:user_ifc.go

示例9: SetHomeDir

func (u *User) SetHomeDir(dbusMsg dbus.DMessage, home string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, false, "SetHomeDir")
	if err != nil {
		return false, err
	}

	go func() {
		err := users.ModifyHome(home, u.UserName)
		if err != nil {
			logger.Warning("DoAction: modify home failed:", err)
			triggerSigErr(pid, "SetHomeDir", err.Error())
			return
		}

		u.setPropString(&u.HomeDir, "HomeDir", home)
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:20,代码来源:user_ifc.go

示例10: SetLocked

func (u *User) SetLocked(dbusMsg dbus.DMessage, locked bool) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, false, "SetLocked")
	if err != nil {
		return false, err
	}

	go func() {
		err := users.LockedUser(locked, u.UserName)
		if err != nil {
			logger.Warning("DoAction: locked user failed:", err)
			triggerSigErr(pid, "SetLocked", err.Error())
			return
		}

		u.setPropBool(&u.Locked, "Locked", locked)
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:20,代码来源:user_ifc.go

示例11: SetAccountType

func (u *User) SetAccountType(dbusMsg dbus.DMessage, ty int32) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, false, "SetAccountType")
	if err != nil {
		return false, err
	}

	go func() {
		err := users.SetUserType(ty, u.UserName)
		if err != nil {
			logger.Warning("DoAction: set user type failed:", err)
			triggerSigErr(pid, "SetAccountType", err.Error())
			return
		}

		u.setPropInt32(&u.AccountType, "AccountType", ty)
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:20,代码来源:user_ifc.go

示例12: AllowGuestAccount

func (m *Manager) AllowGuestAccount(dbusMsg dbus.DMessage, allow bool) error {
	pid := dbusMsg.GetSenderPID()
	err := m.polkitAuthManagerUser(pid, "AllowGuestAccount")
	if err != nil {
		return err
	}

	if allow == isGuestUserEnabled() {
		return nil
	}

	success := dutils.WriteKeyToKeyFile(actConfigFile,
		actConfigGroupGroup, actConfigKeyGuest, allow)
	if !success {
		reason := "Enable guest user failed"
		triggerSigErr(pid, "AllowGuestAccount", reason)
		return fmt.Errorf(reason)
	}
	m.setPropAllowGuest(allow)

	return nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:22,代码来源:manager_ifc.go

示例13: SetPassword

func (u *User) SetPassword(dbusMsg dbus.DMessage, words string) (bool, error) {
	pid := dbusMsg.GetSenderPID()
	err := u.accessAuthentication(pid, false, "SetPassword")
	if err != nil {
		return false, err
	}

	go func() {
		err := users.ModifyPasswd(words, u.UserName)
		if err != nil {
			logger.Warning("DoAction: modify passwd failed:", err)
			triggerSigErr(pid, "SetPassword", err.Error())
			return
		}

		err = users.LockedUser(false, u.UserName)
		if err != nil {
			logger.Warning("DoAction: unlock user failed:", err)
		}
	}()

	return true, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:23,代码来源:user_ifc.go


注:本文中的pkg/linuxdeepin/com/lib/dbus.DMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。