2021-04-28 20:30:34 +02:00
/*
* ConfigPlist . h
*
* Created on : Oct 9 , 2020
* Author : jief
*/
# ifndef _CONFIGPLISTCLASS_SYSTEMPARAMETERS_H_
# define _CONFIGPLISTCLASS_SYSTEMPARAMETERS_H_
class SystemParameters_Class : public XmlDict
{
using super = XmlDict ;
public :
class InjectKextsClass : public XmlBoolOrString {
using super = XmlBoolOrString ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
if ( xmlString8 . isDefined ( ) ) {
if ( ! xmlString8 . value ( ) . isEqualIC ( " Detect " ) ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " InjectKexts must be a boolean or \" Detect \" in dict '%s:%d' " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
2021-04-28 20:30:34 +02:00
}
2021-10-21 11:53:15 +02:00
return b ;
2021-04-28 20:30:34 +02:00
}
} ;
class CustomUUIDClass : public XmlString8AllowEmpty {
using super = XmlString8AllowEmpty ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
if ( ! IsValidGuidString ( xstring8 ) ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " invalid CustomUUID '%s' - should be in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX in dict '%s:%d' " , xstring8 . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
return b ;
2021-04-28 20:30:34 +02:00
}
} ;
class BacklightLevelClass : public XmlUnion
{
using super = XmlUnion ;
public :
XmlInt16 xmlInt16 = XmlInt16 ( ) ;
XmlString8AllowEmpty xmlString8 = XmlString8AllowEmpty ( ) ;
virtual const char * getDescription ( ) override { return " int16|string " ; } ;
XmlUnionField m_fields [ 2 ] = { xmlInt16 , xmlString8 } ;
virtual void getFields ( XmlUnionField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
} ;
InjectKextsClass InjectKexts = InjectKextsClass ( ) ;
XmlBool NoCaches = XmlBool ( ) ;
//XmlFloat BlueValue = XmlFloat(); TODO
BacklightLevelClass BacklightLevel = BacklightLevelClass ( ) ;
CustomUUIDClass CustomUUID = CustomUUIDClass ( ) ;
XmlBool InjectSystemID = XmlBool ( ) ;
XmlBool NvidiaWeb = XmlBool ( ) ;
XmlDictField m_fields [ 6 ] = {
{ " InjectKexts " , InjectKexts } ,
{ " NoCaches " , NoCaches } ,
// {"BlueValue", BlueValue},
{ " BacklightLevel " , BacklightLevel } ,
{ " CustomUUID " , CustomUUID } ,
{ " InjectSystemID " , InjectSystemID } ,
{ " NvidiaWeb " , NvidiaWeb } ,
} ;
virtual void getFields ( XmlDictField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-04-28 20:30:34 +02:00
return b ;
}
2021-09-28 15:54:31 +02:00
XBool dgetWithKexts ( ) const { return true ; } // looks like it can never be false anymore...
XBool dgetWithKextsIfNoFakeSMC ( ) const { return InjectKexts . xmlString8 . isDefined ( ) ? InjectKexts . xmlString8 . value ( ) . isEqualIC ( " Detect " ) : false ; }
XBool dgetNoCaches ( ) const { return NoCaches . isDefined ( ) ? NoCaches . value ( ) : XBool ( false ) ; }
XBool dgetBacklightLevelConfig ( ) const { return BacklightLevel . isDefined ( ) ; }
2021-04-28 20:30:34 +02:00
uint16_t dgetBacklightLevel ( ) const { return BacklightLevel . isDefined ( ) & & BacklightLevel . xmlInt16 . isDefined ( ) ? BacklightLevel . xmlInt16 . value ( ) : 0xFFFF ; }
const XString8 & dgetCustomUuid ( ) const { return CustomUUID . isDefined ( ) ? CustomUUID . value ( ) : NullXString8 ; }
2021-09-28 15:54:31 +02:00
UINT8 dget_InjectSystemID ( ) const { return InjectSystemID . isDefined ( ) ? ( int ) InjectSystemID . value ( ) : 2 ; }
XBool dgetNvidiaWeb ( ) const { return NvidiaWeb . isDefined ( ) ? NvidiaWeb . value ( ) : XBool ( false ) ; }
2021-04-28 20:30:34 +02:00
} ;
# endif /* _CONFIGPLISTCLASS_SYSTEMPARAMETERS_H_ */