package privilegeManagement

import (
	"errors"
	"netease_control_center/globals"
	"netease_control_center/utils"
)

var (
	blackList = make(map[Privilege_Module][]string)
)

type PrivilegeResult struct {
	HasPrivilege bool
	Err          error
}

func init() {
	//define all module cpu serial
	//usa in apple: 881c9f86f7676c118000; qa: 881c1e88a8b76c118000
	blackList[Privilege_AirPlay] = []string{"6c1180009f86f767881c60840461872a", "6c1180001e88a8b7881c60840461872a"}
}

func GetModulePrivilege(key Privilege_Module) (Privilege PrivilegeResult) {
	switch key {
	case Privilege_AirPlay:
		if lt, ok := blackList[key]; ok == true {
			if contained, err := utils.Contain(globals.CPU_ID, lt); err == nil && contained == true {
				Privilege.HasPrivilege = false
				return
			}
		}

		if globals.AirPlayPrivilege.GetCfgListVui() == 1 {
			Privilege.HasPrivilege = true
		} else {
			Privilege.HasPrivilege = false
		}

	default:
		Privilege.HasPrivilege = false
		Privilege.Err = errors.New("Not found the module!")
	}

	return
}
