1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/*
* console.c: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include <getopt.h>
#include <vdr/plugin.h>
#include <vdr/skins.h>
#include <vdr/interface.h>
#include "virtualconsoles.h"
#include "config.h"
#include "menu.h"
#include "i18n.h"
static const char *VERSION = "0.6.0";
static const char *DESCRIPTION = "Expands VDR to a Console on TV";
static const char *MAINMENUENTRY = "Consoles";
cConsConsoles* gl_pConsConsoles = NULL;
class cPluginConsole : public cPlugin {
private:
public:
cPluginConsole(void);
virtual ~cPluginConsole();
virtual const char* Version(void) { return VERSION; }
virtual const char* Description(void) { return tr(DESCRIPTION); }
virtual const char* CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]);
virtual bool Start();
virtual void Housekeeping();
virtual const char* MainMenuEntry();
virtual cOsdObject* MainMenuAction();
virtual cMenuSetupPage* SetupMenu();
virtual bool SetupParse(const char* Name, const char* Value);
virtual bool CanShutdown(bool UserShutdown);
};
cPluginConsole::cPluginConsole()
{}
cPluginConsole::~cPluginConsole() {
delete gl_pConsConsoles;
gl_pConsConsoles = NULL;
}
const char *cPluginConsole::CommandLineHelp() {
return NULL;
}
bool cPluginConsole::ProcessArgs(int argc, char *argv[]) {
return true;
}
bool cPluginConsole::Start() {
RegisterI18n(Phrases);
gl_ConsoleCommands.Load(AddDirectory(ConfigDirectory(), "commands.conf"));
// Register a key macro so we can start our own plugin later
// ---------------------------------------------------------
// Special thanks for this trick to Andreas Brachold
// Search for a free virtual key
consoleOwnerMacro = kSetup + 101;
for (cKeyMacro* searchKey = KeyMacros.First(); searchKey; searchKey = KeyMacros.Next(searchKey)) {
if (*searchKey->Macro() > consoleOwnerMacro) {
consoleOwnerMacro = *searchKey->Macro() + 1;
break;
}
}
// Register a key macro so we can start our own plugin later
cKeyMacro* pMacro = new cKeyMacro();
char* ch = strdup("User9 @console");// Create phantom macro with plugin name
pMacro->Parse(ch);
free(ch);
eKeys* pKeys = ((eKeys*)pMacro->Macro());
*(pKeys + 0) = ((eKeys)consoleOwnerMacro);
*(pKeys + 1) = k_Plugin;
KeyMacros.Add(pMacro);
// Start the consoles handler
// --------------------------
gl_pConsConsoles = new cConsConsoles();
if (gl_pConsConsoles) {
gl_pConsConsoles->Start();
return true;
}
return false;
}
void cPluginConsole::Housekeeping() {
// Perform any cleanup or other regular tasks.
}
const char* cPluginConsole::MainMenuEntry() {
return tr(MAINMENUENTRY);
}
cOsdObject* cPluginConsole::MainMenuAction() {
if (! cKbdRemote::KbdAvailable()) {
// No keyboad available - end with a error message.
//esyslog("[console] VDR reports: no keyboard avaiable!");
Skins.Message(mtError, "No Keyboard available!");
return NULL;
}
// What shall we display?
if (gl_pConsConsoles && gl_pConsConsoles->OpenConsoleNr() >= 0) {
// Ah, display a special console!
// Save the number of console to be displayed...
int nr = gl_pConsConsoles->OpenConsoleNr();
// ...and reset the nr for the next MainMenuAction.
gl_pConsConsoles->SetOpenConsoleNr(-1);
if (nr < gl_pConsConsoles->getCount())
return new cMenuConsole(nr);
}
// Display the usual console list.
return new cMenuConsoleList();
}
cMenuSetupPage* cPluginConsole::SetupMenu(void) {
return new cMenuConsoleSetup();
}
bool cPluginConsole::SetupParse(const char* Name, const char* Value) {
if (!strcasecmp(Name, "TextColor")) config.TextColor = atoi(Value);
else if (!strcasecmp(Name, "BoldTextColor")) config.BoldTextColor = atoi(Value);
else if (!strcasecmp(Name, "TextBackColor")) config.TextBackColor = atoi(Value);
else if (!strcasecmp(Name, "Font")) config.Font = atoi(Value);
else if (!strcasecmp(Name, "AutoEnterKeyboardMode")) config.AutoEnterKeyboardMode = atoi(Value);
else if (!strcasecmp(Name, "BellTimeout")) config.BellTimeout = atoi(Value);
else if (!strcasecmp(Name, "InfobarTimeout")) config.InfobarTimeout = atoi(Value);
else if (!strcasecmp(Name, "PreventShutdown")) config.PreventShutdown = atoi(Value);
else if (!strcasecmp(Name, "BlinkRate")) config.BlinkRate = atoi(Value);
// For backward compatibility
else if (!strcasecmp(Name, "CompressText")) {
config.Font = atoi(Value) ? 2 : 1;
// Remove this old Setting
// SetupStore("CompressText");
}
else
return false;
return true;
}
bool cPluginConsole::CanShutdown(bool UserShutdown) {
if (config.PreventShutdown && cConsConsoles::Active()) {
if (UserShutdown)
return Interface->Confirm(tr("Console(s) running - shut down anyway?"));
return false;
}
return true;
}
VDRPLUGINCREATOR(cPluginConsole); // Don't touch this!
|