return instance;
}
-int Control::init(bool tcrashed)
+bool Control::init(bool tcrashed)
{
- if (initted) return 0;
- initted = true;
+ if (initted) return false;
crashed = tcrashed;
SkinFactory::InitSkin(0);
-
logger = Log::getInstance();
- bool success;
- boxstack = new BoxStack();
-
- success = boxstack->init();
- if (success)
+ try
{
- logger->log("Core", Log::INFO, "BoxStack module initialised");
+ boxstack = new BoxStack(); if (!boxstack) throw 10;
+ if (!boxstack->init()) throw 20;
+
+ sleeptimer = new Sleeptimer(); if (!sleeptimer) throw 30;
+
+ wol = new Wol(); if (!wol) throw 40;
+
}
- else
+ catch (int e)
{
- logger->log("Core", Log::EMERG, "BoxStack module failed to initialise");
- shutdown();
- }
+ if (e == 10) logger->log("Control", Log::EMERG, "BoxStack module failed to create");
+ else if (e == 20) logger->log("Control", Log::EMERG, "BoxStack module failed to initialise");
+ else if (e == 30) logger->log("Control", Log::EMERG, "SleepTimer module failed to create");
+ else if (e == 40) logger->log("Control", Log::EMERG, "WOL module failed to create");
+ switch(e)
+ {
+ case 40:
+ FALLTHROUGH
+ case 30:
+ FALLTHROUGH
+ case 20:
+ delete boxstack;
+ boxstack = NULL;
+ FALLTHROUGH
+ case 10:
+ FALLTHROUGH
+ }
+ return false;
+ }
inputMan = InputMan::getInstance();
- if (!logger || !boxstack || !inputMan)
+ if (!inputMan)
{
initted = false;
return 0;
-
- return 1;
+ initted = true;
+ return true;
}
-int Control::shutdown()
+void Control::shutdown()
{
+ if (!initted) return;
+ initted = false;
+
+ if (wol)
+ {
+ delete wol;
+ logger->log("Control", Log::NOTICE, "WOL module shut down");
+ }
+
+ if (sleeptimer)
+ {
+ delete sleeptimer;
+ sleeptimer = NULL;
+ logger->log("Control", Log::NOTICE, "Sleeptimer module shut down");
+ }
+
if (boxstack)
{
boxstack->shutdown();
delete boxstack;
boxstack = NULL;
- logger->log("Core", Log::NOTICE, "BoxStack module shut down");
+ logger->log("Control", Log::NOTICE, "BoxStack module shut down");
}
- if (!initted) return 0;
- initted = false;
- return 1;
}
void Control::stop()
class Log;
class VInfo;
class WJpeg;
+class Sleeptimer;
+class Wol;
struct ASLPref
{
~Control();
static Control* getInstance();
- int init(bool crashed = false);
- int shutdown();
+ bool init(bool crashed = false);
+ void shutdown();
void run();
void stop();
void doReboot();
private:
// I own:
BoxStack* boxstack{};
+ Sleeptimer* sleeptimer{};
+ Wol* wol{};
#include "vdr.h"
#include "control.h"
#include "inputman.h"
-#include "wol.h"
-#include "vsleeptimer.h"
#ifdef VOMP_PLATTFORM_NMT
#include "lednmt.h"
VDR* vdr;
Video* video;
Audio* audio;
-Wol* wol;
-Sleeptimer* sleeptimer;
// Temporary, will move to Config system
std::string argvServer;
video = new Video_TYPE();
control = new Control();
- wol = new Wol();
- sleeptimer = new Sleeptimer();
- if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !control || !wol || !sleeptimer)
+ if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !control)
{
printf("Could not create objects. Memory problems?\n");
shutdown(1);
- success = control->init(crashed);
- if (success)
+ bool bsuccess = control->init(crashed);
+ if (bsuccess)
{
logger->log("Core", Log::INFO, "Control module initialised");
}
logger->log("Core", Log::NOTICE, "InputMan module shut down");
}
- if (wol)
- {
- delete wol;
- logger->log("Core", Log::NOTICE, "WOL module shut down");
- }
- if (sleeptimer)
- {
- delete sleeptimer;
- logger->log("Core", Log::NOTICE, "Sleeptimer module shut down");
- }
#ifdef HANDLE_VT_SWITCHING
ioctl(fdtty, VT_UNLOCKSWITCH, 1);
#include "osdwinvector.h"
#endif
#include "control.h"
-#include "wol.h"
-#include "vsleeptimer.h"
#include "messagequeue.h"
void sighandler(int signalReceived);
VDR* vdr;
Video* video;
Audio* audio;
-Wol* wol;
-Sleeptimer* sleeptimer;
std::string commandLineServer;
bool wnd_fullscreen=false;
void MILLISLEEP(ULONG a)
{
-
Sleep(a);
-
}
int getClockRealTime(struct timespec *tp){
video = new VideoWin();
audio = new AudioWin();
control = new Control();
- wol = new Wol();
- sleeptimer = new Sleeptimer();
- if (!logger || !remote || !led || !osd || !video || !audio || !control || !sleeptimer)
+ if (!logger || !remote || !led || !osd || !video || !audio || !control)
{
ERROR_MSG("Could not create objects. Memory problems?\n");
shutdown(1);
delete remote;
logger->log("Core", Log::NOTICE, "Remote module shut down");
}
- if (wol)
- {
- delete wol;
- logger->log("Core", Log::NOTICE, "WOL module shut down");
- }
if (logger)
{
logger->shutdown();
delete logger;
}
- if (sleeptimer)
- {
- delete sleeptimer;
- logger->log("Core", Log::NOTICE, "Sleeptimer module shut down");
- }
- ExitProcess(0);
+ ExitProcess(0);
}
// -------------------------------------------------------------------------------------------------------------------