import QtQuick 2.0
import Nemo.DBus 2.0

Item {
    property bool enabled: false
    function request(){
        var method = "req_display"+(enabled?"":"_cancel")+"_blanking_pause";
        dbif.call(method, [])
    }

    onEnabledChanged: {
        request();
    }

    DBusInterface {
        id: dbif

        service: "com.nokia.mce"
        path: "/com/nokia/mce/request"
        iface: "com.nokia.mce.request"

        bus: DBusInterface.SystemBus
    }
    Timer {
        running: parent.enabled
        interval: 15000
        repeat: true
        onTriggered: {
            if(parent.enabled) {
                parent.request()
            }
        }
    }

    Component.onDestruction: {
        if(enabled){
            enabled=false
        }
    }
}
