--[[----------------------------------------------------------------------------

WFDeviceInfo.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2014 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

------------------------------------------------------------------------------]]

	-- WF.core.os
local WFDeviceInfoImp = require 'WFDeviceInfoImp'

	-- WF.core.crypto
local WFCrypto = require 'WFCrypto'

local logger = require 'WFLogger'( "WFDeviceInfo" )

--============================================================================--

-- @mark WFDeviceInfo namespace

local WFDeviceInfo = {}

--------------------------------------------------------------------------------
--[[!
	\brief Returns the user-assigned name for this device.
]]--

function WFDeviceInfo.deviceName()

	return WFDeviceInfoImp.deviceName()

end

--------------------------------------------------------------------------------
--[[!
	\brief Returns the manufacturer-assigned name for this device model.
]]--

function WFDeviceInfo.deviceModel()

	return WFDeviceInfoImp.deviceModel()

end

--------------------------------------------------------------------------------
--[[!
	\brief Returns the manufacturer-assigned name for the CPU type.
]]--

function WFDeviceInfo.cpuType()

	return WFDeviceInfoImp.cpuType()
	
end

--------------------------------------------------------------------------------
--[[!
	\brief Returns the user's name as known by the OS.
]]--

function WFDeviceInfo.userName()

	return WFDeviceInfoImp.userName()

end

--------------------------------------------------------------------------------
--[[!
	\brief Returns the system's primary MAC interface address (if available).
]]--

function WFDeviceInfo.macAddress()

	return WFDeviceInfoImp.macAddress()

end

--------------------------------------------------------------------------------
--[[!
	\brief Return a vendor-specific ID for use in identifying this device.
		This may be a UUID that is stored by the app or it may be the MAC
		address, depending on platform.
]]--

function WFDeviceInfo.uniqueVendorIdentifier()

	return WFDeviceInfoImp.uniqueVendorIdentifier()

end

--[[!
	\brief Return a device ID for use in identifying this device generated at Core.java.
		This may be a UUID that is stored by the app or it may be the AndroidID
		address, depending on platform.
]]--

function WFDeviceInfo.deviceId()

	return WFDeviceInfoImp.deviceId()

end

--------------------------------------------------------------------------------
--[[!
	\brief Return an unique ID for use in identifying this device that stays the
		same even after re-installs of the app.
		This may be a UUID that is stored by the app or it may be the MAC
		address, depending on platform.
]]--

function WFDeviceInfo.uniqueDeviceId()

	local uniqueDeviceId = WFDeviceInfoImp.uniqueDeviceId()
	
	if uniqueDeviceId then
	
		return WFCrypto.SHA256.digest( uniqueDeviceId )
		
	end
	
	return nil

end

--------------------------------------------------------------------------------
--[[!
	\brief Return the number of CPUs available. Returns 0 if method is 
	not implemented on current platform.
]]--

function WFDeviceInfo.numCPUs()

	if type( WFDeviceInfoImp.numCPUs ) ~= "function" then

		logger:warn( "numCPUs not supported" )

		return 0

	end

	local numCPUs = WFDeviceInfoImp.numCPUs()

	if numCPUs == 0 then

		logger:warn( "native API reported 0 cpus" )

	end

	return numCPUs
	
end

--------------------------------------------------------------------------------

return WFDeviceInfo
