當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。