[RecordTimer] callback ordering inconsistencies

Issue #522 resolved
prl created an issue

The RecordTimer class has three lists of callback functions onTimerAdded, onTimerRemoved and onTimerChanged. The callbacks through those lists seem a bit inconsistent with respect to when the RecordTimer methods invoke them, and when they invoke RecordTimer.saveTimer() to write the timers to timers.xml.

RecordTimer.record()
    saveTimer() (not called when reading timers.xml, which is correct)
    onTimerAdded callbacks

RecordTimer.removeEntry()
    onTimerChanged callbacks (conditional, called via RecordTimer.timeChanged())
    onTimerChanged callbacks (conditional, called via RecordTimer.timeChanged())
    saveTimer()
    onTimerRemoved callbacks

RecordTimer.cleanup()
    onTimerRemoved callbacks
    saveTimer()

RecordTimer.timeChanged()
    onTimerChanged callbacks
    saveTimer()

There's an inconsistency in the order of the call to saveTimer() and the onTimerRemoved callbacks, but that's not likely to be a problem, because the timer won't be in the saved timers.xml file.

The ordering in RecordTimer.record() does cause a problem in the one place that it's used in the Beyonwiz easy-4-ui code, in the IceTV plugins.

When IceTV is used, and the user creates a recording on the Beyonwiz, the IceTV plugin is informed of the new timer via an onTimerAdded callback. That callback contacts the IceTV server to inform it about the new timer, and receives back the timer's newly allocated IceTV timer id, which it adds to the timer.

However, RecordTimer.record() calls RecordTimer.saveTimer() before it calls the IceTV plugin. This means that unless the plugin calls RecordTimer.saveTimer() a second time, the newly created timer won't have an IceTV id in its timers.xml entry until some other action (creation of another timer, for example) causes timers.xml to be written. It seems wasteful to re-write timers.xml in the plugin immediately after it has bee written by RecordTimer.record().

The only place that the callbacks are used in easy-4-ui are in the IceTV plugin. They aren't used in the OE-Alliance enigma2-plugins collection. I haven't checked other plugins collections.

The consensus from forum discussion is that the methods that call the onTimer* callouts should always call RecordTimer.saveTimer() only after all the callbacks have been called, to make sure that any changes to the timers made by the callbacks are captured in timers.xml.

Comments (3)

  1. Peter Urbanec

    Fix Bug #522: [RecordTimer] callback ordering inconsistencies

    [RecordTimer]

    Move calls of method saveTimer() so that they are after any callbacks for onTimerAdded/Remooved/Changed, so that if the callback code changes the timer, those changes are captured in the saved timers.xml.

    → <<cset 609e2886ebad>>

  2. Log in to comment