[mythtv] Ticket #3910: Mythshutdown cleanup / ShutdownWakeup Class

Matthew Wire devel at mrwire.co.uk
Sun Sep 2 18:53:25 UTC 2007

>  Replying to [comment:1 Matthew Wire <devel at mrwire.co.uk>]:
>  > I'm trying to work on some shutdown/wakeup features at the moment and
>  part of this includes centralising all the shutdown/wakeup functions into
>  a shutdownwakeup class within libmyth.  The changes on this patch facilite
>  part of this.
>  Can you be a little more specific about where you are going with all this.
>  What is the final goal? I'm not sure Isaac and the other devs will want to
>  add extra stuff to libmyth unless there is a very good reason to do so.
Currently there is a significant amount of duplication with code
involving shutdown/wakeup stuff.  There is code in mythshutdown,
mythwelcome, scheduler(mythbackend), mythfrontend all dealing with
There's various things I'd like to see in MythTV such as an improved
system-wide sleep timer, alarm clock etc. and centralising the
shutdown/wakeup code should go some way to facilitating this.

So, the way I've gone about this at the moment is to create a new class
called ShutdownWakeup within libmyth (shutdownwakeup.h/cpp) and
gradually migrate functions from elsewhere into this class.

I've reduced mythshutdown to four functions by using this class.
Mythwelcome doesn't call mythshutdown every time it needs status info
and can call getStatus() instead.  Scheduler and mythwelcome both call
WasStartedAutomatically instead of using their internal copy.
A fictional alarm plugin would call setWakeupTime for example.

I plan to add more helper functions for shutting down etc. as well.

Any comments would of course be much appreciated and if it would be
better in libmythtv or elsewhere please do let me know!

Here is a sample of what is in there so far:
enum systemStatus

class MPUBLIC ShutdownWakeup
    QString getStatusString(int status);
    int getStatus(bool bWantRecStatus);
    bool isRecording();
    QDateTime getDailyWakeupTime(QString sPeriod);
    QDateTime getWakeupTime();
    int setWakeupTime(QDateTime dtWakeupTime);
    int setScheduledWakeupTime();
    int setBIOSWakeupTime(QDateTime dtWakeupTime);
    bool WasStartedAutomatically();
    int checkOKShutdown(bool bWantRecStatus);

More information about the mythtv-dev mailing list