File: dvd.c

package info (click to toggle)
vdr-plugin-dvd 0.3.6~b03+cvs20090426.0013-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 480 kB
  • ctags: 619
  • sloc: ansic: 4,866; sh: 624; makefile: 89
file content (140 lines) | stat: -rwxr-xr-x 3,675 bytes parent folder | download | duplicates (6)
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
/*
 * DVD Player plugin for VDR
 *
 * Copyright (C) 2001.2002 Andreas Schultz <aschultz@warp10.net>
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 *
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "dvd.h"

static const char *VERSION        = "0.3.6-b03";
#if VDRVERSNUM >= 10507
static const char *DESCRIPTION    = trNOOP("Plugin.DVD$turn VDR into an (almost) full featured DVD player");
static const char *MAINMENUENTRY  = trNOOP("Plugin.DVD$DVD");
#else
static const char *DESCRIPTION    = "Plugin.DVD$turn VDR into an (almost) full featured DVD player";
static const char *MAINMENUENTRY  = "Plugin.DVD$DVD";
#endif

// --- cPluginDvd ------------------------------------------------------------
cPluginDvd::cPluginDvd(void)
{
    // Initialize any member varaiables here.
    // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
    // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
}

cPluginDvd::~cPluginDvd()
{
    // Clean up after yourself!
}

const char *cPluginDvd::Description(void) {
    return tr(DESCRIPTION);
}

const char *cPluginDvd::MainMenuEntry(void) {
    return DVDSetup.HideMainMenu ? NULL : tr(MAINMENUENTRY);
}

const char *cPluginDvd::Version(void) {
    return VERSION;
}

const char *cPluginDvd::CommandLineHelp(void)
{
    // Return a string that describes all known command line options.
    return   "  -C DEV,   --dvd=DEV      use DEV as the DVD device (default: /dev/dvd)\n";
}

bool cPluginDvd::ProcessArgs(int argc, char *argv[])
{
    // Implement command line argument processing here if applicable.
#ifndef __QNXNTO__
    static struct option long_options[] = {
        { "dvd",      required_argument, NULL, 'C' },
        { NULL }
    };
#endif

    int c;
#ifndef __QNXNTO__
    while ((c = getopt_long(argc, argv, "C:", long_options, NULL)) != -1) {
#else
    optind = 1;
    while ((c = getopt(argc, argv, "C:")) != -1) {
#endif
        switch (c) {
            case 'C':
                fprintf(stderr, "arg: %s\n", optarg);
                cDVD::SetDeviceName(optarg);
                if (!cDVD::DriveExists()) {
                    esyslog("vdr: DVD drive not found: %s", optarg);
                    return false;
                }
                break;
            default:
                fprintf(stderr, "arg char: %c\n", c);
                return false;
        }
    }
    return true;
}

bool cPluginDvd::Initialize(void)
{
    // Initialize any background activities the plugin shall perform.
#if VDRVERSNUM < 10507
    RegisterI18n(DvdPhrases);
#endif
    return true;
}

bool cPluginDvd::Start(void)
{
    // Start any background activities the plugin shall perform.
    return true;
}

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

cOsdMenu *cPluginDvd::MainMenuAction(void)
{
    if (!cDvdPlayerControl::DVDActive())
        cControl::Launch(new cDvdPlayerControl);
    return NULL;
}

cMenuSetupPage *cPluginDvd::SetupMenu(void)
{
    // Return a setup menu in case the plugin supports one.
    return new cMenuSetupDVD;
}

bool cPluginDvd::SetupParse(const char *Name, const char *Value)
{
    return DVDSetup.SetupParse(Name, Value);
}

cSetupLine *cPluginDvd::GetSetupLine(const char *Name, const char *Plugin)
{
  	for (cSetupLine *l = Setup.First(); l; l = Setup.Next(l)) {
        if ((l->Plugin() == NULL) == (Plugin == NULL)) {
            if ((!Plugin || strcasecmp(l->Plugin(), Plugin) == 0) && strcasecmp(l->Name(), Name) == 0)
                return l;
        }
    }
    return NULL;
}

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