isStandby = 0;
firstBoot = 1;
connLost = NULL;
+ crashed = false;
}
Command::~Command()
return instance;
}
-int Command::init()
+int Command::init(bool tcrashed)
{
if (initted) return 0;
initted = 1;
+ crashed = tcrashed;
logger = Log::getInstance();
boxstack = BoxStack::getInstance();
#endif
//logger->log("Command", Log::DEBUG, "LOCKED");
- VConnect* vconnect = new VConnect();
- boxstack->add(vconnect);
- vconnect->run();
+ if (crashed)
+ {
+ buildCrashedBox();
+ }
+ else
+ {
+ VConnect* vconnect = new VConnect();
+ boxstack->add(vconnect);
+ vconnect->run();
+ }
// Start method 2 of getting commands in...
udp.run(this);
}
case Message::LAST_VIEW_CLOSE:
{
-// not currently used
+ // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
+ if (crashed)
+ {
+ crashed = false;
+ doFromTheTop(false);
+ }
+
// VWelcome* vw = new VWelcome();
// vw->draw();
// boxstack->add(vw);
}
case Remote::OK:
{
+ // FIXME
if (!connLost) return; // if connLost, handle Remote::OK
doFromTheTop(false);
return;
postMessageNoLock(m);
}
+void Command::buildCrashedBox()
+{
+ VInfo* crash = new VInfo();
+ crash->setSize(360, 250);
+ crash->createBuffer();
+ if (Video::getInstance()->getFormat() == Video::PAL)
+ crash->setPosition(190, 146);
+ else
+ crash->setPosition(180, 96);
+ crash->setMainText("Oops, vomp crashed.. :(\nPlease report this crash to the author, with as much detail as possible about what you were doing at the time that might have caused the crash.");
+ crash->setBorderOn(1);
+ crash->setTitleBarColour(Colour::DANGER);
+ crash->okButton();
+ crash->setExitable();
+ crash->draw();
+ boxstack->add(crash);
+ boxstack->update(crash);
+}
+
void Command::doJustConnected(VConnect* vconnect)
{
I18n::initialize();
~Command();
static Command* getInstance();
- int init();
+ int init(bool crashed = false);
int shutdown();
void run();
void stop();
void doJustConnected(VConnect* vconnect);
void doWallpaper();
void doFromTheTop(bool which); // true - show vinfo,wait. false - del vinfo,restart
+ void buildCrashedBox();
static Command* instance;
#ifndef WIN32
Remote* remote;
Boxx* wallpaper;
VInfo* connLost;
-
+ bool crashed;
+
UDP udp;
void processMessage(Message* m);
int Log::shutdown()
{
if (!initted) return 1;
- if (logfile) fclose(logfile);
+ if (enabled) fclose(logfile);
return 1;
}
}
// Global variables --------------------------------------------------------------------------------------------------
-int debugEnabled = 0;
Log* logger;
Remote* remote;
Mtd* mtd;
{
if (strstr(argv[0], "ticonfig")) return ticonfig_main(argc, argv);
- if ((argc > 1) && (!strcmp(argv[1], "-d"))) debugEnabled = 1;
-
+ bool daemonize = true;
+ bool debugEnabled = false;
+ bool crashed = false;
+ int c;
+ while ((c = getopt(argc, argv, "cdn")) != -1)
+ {
+ switch (c)
+ {
+ case 'c':
+ crashed = true;
+ break;
+ case 'd':
+ debugEnabled = true; // and...
+ case 'n':
+ daemonize = false;
+ break;
+ case '?':
+ printf("Unknown option\n");
+ return 1;
+ default:
+ printf("Option error\n");
+ return 1;
+ }
+ }
+
// Init global vars ------------------------------------------------------------------------------------------------
logger = new Log();
// Get logging module started --------------------------------------------------------------------------------------
- if (!logger->init(Log::DEBUG, "dummy", debugEnabled))
+ if (!logger->init(Log::DEBUG, "dummy", debugEnabled ? 1 : 0))
{
printf("Could not initialise log object. Aborting.\n");
shutdown(1);
// Daemonize if not -d
- if (!debugEnabled)
+ if (daemonize)
{
// Fork away
pid_t forkTest = fork();
shutdown(1);
}
- success = command->init();
+ success = command->init(crashed);
if (success)
{
logger->log("Core", Log::INFO, "Command module initialised");
#include "remote.h"
#include "colour.h"
-#include "wbutton.h"
#include "i18n.h"
#include "boxstack.h"
mainText = NULL;
exitable = 0;
dropThrough = 0;
- okbutton = false;
setTitleBarOn(1);
setTitleBarColour(Colour::TITLEBARBACKGROUND);
else drawTextCentre(mainText, area.w / 2, 55, Colour::LIGHTTEXT);
}
}
-
- if (okbutton)
- {
-/*
- WButton button;
- button.setPosition((area.w / 2) - 30, area.h - 50);
- button.setText(tr("OK"));
- button.setActive(1);
- add(&button);
- button.draw();
-*/
- } // FIXME check
}
int VInfo::handleCommand(int command)
void VInfo::okButton()
{
- okbutton = true;
+ okbutton.setPosition((area.w / 2) - 30, area.h - 50);
+ okbutton.setText(tr("OK"));
+ okbutton.setActive(1);
+ add(&okbutton);
}
void VInfo::processMessage(Message* m)
#include "tbboxx.h"
#include "defines.h"
+#include "wbutton.h"
class VInfo : public TBBoxx
{
UCHAR exitable;
UCHAR dropThrough;
UCHAR mainTextType;
- bool okbutton;
+ WButton okbutton;
const static UCHAR NORMAL = 1;
const static UCHAR ONELINER = 2;