diff --git a/core/src/avm1/globals/system.rs b/core/src/avm1/globals/system.rs index c6afe3806..0b16d0e10 100644 --- a/core/src/avm1/globals/system.rs +++ b/core/src/avm1/globals/system.rs @@ -9,6 +9,25 @@ use gc_arena::MutationContext; use num_enum::TryFromPrimitive; use std::convert::TryFrom; +/// Available cpu architectures +pub enum CpuArchitecture { + PowerPC, + X86, + SPARC, + ARM, +} + +impl fmt::Display for CpuArchitecture { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self { + CpuArchitecture::PowerPC => "PowerPC", + CpuArchitecture::X86 => "x86", + CpuArchitecture::SPARC => "SPARC", + CpuArchitecture::ARM => "ARM", + }) + } +} + /// Available type of sandbox for a given SWF pub enum SandboxType { Remote, @@ -211,6 +230,11 @@ pub enum SystemCapabilities { VideoEncoder, Debugger, LocalFileRead, + Process64Bit, + Process32Bit, + AcrobatEmbedded, + TLS, + WindowLess, } /// The properties modified by 'System' @@ -241,6 +265,10 @@ pub struct SystemProperties { pub os: OperatingSystem, /// The type of the player sandbox pub sandbox_type: SandboxType, + /// The cpu architecture of the platform + pub cpu_architecture: CpuArchitecture, + /// The highest supported h264 decoder level + pub idc_level: String, } impl SystemProperties { @@ -363,6 +391,8 @@ impl Default for SystemProperties { manufacturer: Manufacturer::Linux, os: OperatingSystem::Linux, sandbox_type: SandboxType::LocalTrusted, + cpu_architecture: CpuArchitecture::X86, + idc_level: "5.1".into(), } } } diff --git a/core/src/avm1/globals/system_capabilities.rs b/core/src/avm1/globals/system_capabilities.rs index 51b670aad..8f658dc16 100644 --- a/core/src/avm1/globals/system_capabilities.rs +++ b/core/src/avm1/globals/system_capabilities.rs @@ -47,6 +47,10 @@ macro_rules! capabilities_prop { }}; } +capabilities_func!(get_has_64_bit_support, SystemCapabilities::Process64Bit); +capabilities_func!(get_has_32_bit_support, SystemCapabilities::Process32Bit); +capabilities_func!(get_is_acrobat_embedded, SystemCapabilities::AcrobatEmbedded); +capabilities_func!(get_has_tls, SystemCapabilities::TLS); capabilities_func!(get_has_accessibility, SystemCapabilities::Accessibility); capabilities_func!(get_has_audio, SystemCapabilities::Audio); capabilities_func!(get_has_audio_encoder, SystemCapabilities::AudioEncoder); @@ -69,6 +73,7 @@ inverse_capabilities_func!( SystemCapabilities::LocalFileRead ); inverse_capabilities_func!(get_is_av_hardware_disabled, SystemCapabilities::AvHardware); +inverse_capabilities_func!(get_is_windowless_disabled, SystemCapabilities::WindowLess); pub fn get_player_type<'gc>( _avm: &mut Avm1<'gc>, @@ -177,6 +182,24 @@ pub fn get_server_string<'gc>( Ok(context.system.get_server_string(avm).into()) } +pub fn get_cpu_architecture<'gc>( + _avm: &mut Avm1<'gc>, + context: &mut UpdateContext<'_, 'gc, '_>, + _this: Object<'gc>, + _args: &[Value<'gc>], +) -> Result, Error> { + Ok(context.system.cpu_architecture.to_string().into()) +} + +pub fn get_max_idc_level<'gc>( + _avm: &mut Avm1<'gc>, + context: &mut UpdateContext<'_, 'gc, '_>, + _this: Object<'gc>, + _args: &[Value<'gc>], +) -> Result, Error> { + Ok(context.system.idc_level.clone().into()) +} + pub fn create<'gc>( gc_context: MutationContext<'gc, '_>, proto: Option>, @@ -184,6 +207,11 @@ pub fn create<'gc>( let capabilities = ScriptObject::object(gc_context, proto); capabilities_prop!(gc_context, capabilities, + "supports64BitProcesses" => get_has_64_bit_support, + "supports32BitProcesses" => get_has_32_bit_support, + "isEmbeddedInAcrobat" => get_is_acrobat_embedded, + "hasTLS" => get_has_tls, + "cpuArchitecture" => get_cpu_architecture, "hasAccessibility" => get_has_accessibility, "hasAudio" => get_has_audio, "hasAudioEncoder" => get_has_audio_encoder, @@ -199,6 +227,7 @@ pub fn create<'gc>( "isDebugger" => get_is_debugger, "avHardwareDisable" => get_is_av_hardware_disabled, "localFileReadDisable" => get_is_local_file_read_disabled, + "windowlessDisable" => get_is_windowless_disabled, "language" => get_language, "manufacturer" => get_manufacturer, "os" => get_os_name, @@ -209,7 +238,8 @@ pub fn create<'gc>( "screenResolutionX" => get_screen_resolution_x, "screenResolutionY" => get_screen_resolution_y, "serverString" => get_server_string, - "version" => get_version + "version" => get_version, + "maxLevelIDC" => get_max_idc_level ); capabilities.into()