File: console.c

package info (click to toggle)
vdr-plugin-console 0.5.1-16
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 324 kB
  • ctags: 353
  • sloc: ansic: 6,668; sh: 109; makefile: 100
file content (123 lines) | stat: -rw-r--r-- 2,804 bytes parent folder | download
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
/*
 * console.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: console.c,v 1.1 2004/10/24 12:57:09 chelli-guest Exp $
 */


#include <getopt.h>

#include <vdr/plugin.h>


#include "engine.h"
#include "config.h"
#include "menu.h"
#include "i18n.h"


static const char *VERSION        = "0.5.1";
static const char *DESCRIPTION    = "Expands VDR to a Console on TV";
static const char *MAINMENUENTRY  = "Consoles";

cConsoles* gl_pConsoles = 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(void);
  virtual void Housekeeping(void);
  virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); }
  virtual cOsdMenu *MainMenuAction(void);
  virtual cMenuSetupPage *SetupMenu(void);
  virtual bool SetupParse(const char *Name, const char *Value);
};



cPluginConsole::cPluginConsole(void)
{}



cPluginConsole::~cPluginConsole() {
  delete gl_pConsoles;
  gl_pConsoles = NULL;
}


const char *cPluginConsole::CommandLineHelp(void) {

  return NULL;  
}


bool cPluginConsole::ProcessArgs(int argc, char *argv[]) {

  return true;
}


bool cPluginConsole::Start(void) {

  RegisterI18n(Phrases);

  gl_ConsoleCommands.Load( AddDirectory( ConfigDirectory(), "commands.conf" ) );

  gl_pConsoles = new cConsoles();
  if ( gl_pConsoles ) {

    gl_pConsoles->Start();
    return true;
  }
  return false;
}


void cPluginConsole::Housekeeping(void) {
  // Perform any cleanup or other regular tasks.
}



cOsdMenu *cPluginConsole::MainMenuAction(void) {

  if ( ! cKbdRemote::KbdAvailable() ) {
    esyslog("console: no keyboard avaiable!");
    return NULL;
  }
  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, "CompressText"))          config.CompressText = atoi(Value);
  else if (!strcasecmp(Name, "AutoEnterKeyboardMode")) config.AutoEnterKeyboardMode = atoi(Value);
  else if (!strcasecmp(Name, "BellTimeout"))           config.BellTimeout = atoi(Value);
  else
     return false;

  return true;
}


VDRPLUGINCREATOR(cPluginConsole); // Don't touch this!