<!--
........................................................................................................................
Description:
    This rule script checks if the auto rotate ui feature is required to be activated on start up.

Feature:
    autorotateui

Dependencies:
    autorotateui_rotate.rul
........................................................................................................................
-->
<script xmlns="http://www.nokia.com/ns/cep/script/1.0/"
xmlns:cep="http://www.nokia.com/ns/cep/1.0/">

<!--
........................................................................................................................
Description:
    Activate orientation channel from sensor source.
........................................................................................................................
-->
    <if>
        <and>
            <!-- Context Framework status changes to 'Ready' -->
            <contextChanged>
                <contextRef source='ContextFramework' type='Status'/>
            </contextChanged>
            <equals>
                <contextRef source='ContextFramework' type='Status'/>
                <string>Ready</string>
            </equals>

            <!-- Check that the feature has not yet been enabled -->
            <notEqual>
                <contextRef source='Sensor' type='Event.AutoRotate'/>
                <string>Enabled</string>
            </notEqual>

            <!-- Sensor setting must be currently enabled -->
            <equals>
                <contextRef source='Sensor' type='Setting.Active'/>
                <string>On</string>
            </equals>

            <!-- Turning interaction must be currently enabled -->
            <equals>
                <contextRef source='Sensor' type='Setting.TurningInteraction.AutoRotation'/>
                <string>On</string>
            </equals>
        </and>
        <actions>
            <!-- Activate orientation channel from sensor source -->
            <publishContext>
                <contextRef source="Sensor" type="Event" value="Orientation.Activate"/>
            </publishContext>

            <!-- Mark feature as 'Enabled' -->
            <publishContext>
                <contextRef source="Sensor" type="Event.AutoRotate" value="Enabled"/>
            </publishContext>
        </actions>
    </if>

</script>
