<def-group>
  <definition class="compliance" id="dconf_gnome_screensaver_idle_delay" version="2">
    {{{ oval_metadata("The allowed period of inactivity before the screensaver is activated.") }}}
    <criteria operator="OR">
      <extend_definition comment="dconf installed" definition_ref="package_dconf_installed" negate="true" />
      <criteria comment="check screensaver idle delay and prevent user from changing it" operator="AND">
        <extend_definition comment="dconf user profile exists" definition_ref="enable_dconf_user_profile" />
        <criterion comment="idle delay has been configured" test_ref="test_screensaver_idle_delay" />
        <criterion comment="idle delay is set correctly" test_ref="test_screensaver_idle_delay_setting" />
        {{% if 'ubuntu' in product %}}
        <criterion comment="screensaver idle delay setting is locked" test_ref="test_screensaver_idle_delay_locked" />
        {{% endif %}}
      </criteria>
    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="screensaver idle delay is configured"
  id="test_screensaver_idle_delay" version="1">
    <ind:object object_ref="obj_screensaver_idle_delay" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_screensaver_idle_delay"
  version="1">
    <ind:path>/etc/dconf/db/local.d/</ind:path>
    <ind:filename operation="pattern match">^.*$</ind:filename>
    <!-- GSettings expects unsigned integer when setting 'idle-delay' per:
         https://bugzilla.redhat.com/show_bug.cgi?id=1141779#c3
         Thus require the proper datatype to be specified in 'idle-delay' configuration too -->
    <ind:pattern operation="pattern match">^\[org/gnome/desktop/session\]([^\n]*\n+)+?idle-delay=uint32[\s][0-9]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_test check="all" check_existence="all_exist"
           comment="screensaver idle delay setting is correct"
  id="test_screensaver_idle_delay_setting" version="1">
    <ind:object object_ref="obj_screensaver_idle_delay_setting" />
    <ind:state state_ref="state_screensaver_idle_delay_setting" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_screensaver_idle_delay_setting"
  version="1"> 
    <ind:path>/etc/dconf/db/local.d/</ind:path>
    <ind:filename operation="pattern match">^.*$</ind:filename>
    <!-- GSettings expects unsigned integer when setting 'idle-delay' per:
         https://bugzilla.redhat.com/show_bug.cgi?id=1141779#c3
         Thus require the proper datatype to be specified in 'idle-delay' configuration too -->
    <ind:pattern operation="pattern match">^idle-delay[\s=]*uint32[\s]([^=\s]*)</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_state id="state_screensaver_idle_delay_setting" version="1">
    <ind:subexpression datatype="int" operation="less than or equal" var_check="all" var_ref="inactivity_timeout_value" />
  </ind:textfilecontent54_state>

  <external_variable comment="inactivity timeout variable" datatype="int"
  id="inactivity_timeout_value" version="1" />

{{% if 'ubuntu' in product %}}
  <ind:textfilecontent54_test check="all" check_existence="all_exist"
      comment="screensaver idle delay setting is locked"
      id="test_screensaver_idle_delay_locked" version="1">
    <ind:object object_ref="obj_screensaver_idle_delay_locked" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_screensaver_idle_delay_locked"
  version="1">
    <ind:path>/etc/dconf/db/local.d/locks/</ind:path>
    <ind:filename operation="pattern match">^.*$</ind:filename>
    <ind:pattern operation="pattern match">^/org/gnome/desktop/session/idle-delay$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
{{% endif %}}
</def-group>
