vdr
2.0.4
Main Page
Namespaces
Classes
Files
File List
File Members
PLUGINS
src
pictures
pictures.c
Go to the documentation of this file.
1
/*
2
* pictures.c: A plugin for the Video Disk Recorder
3
*
4
* See the README file for copyright information and how to reach the author.
5
*
6
* $Id: pictures.c 2.9 2013/03/31 09:30:18 kls Exp $
7
*/
8
9
#include <getopt.h>
10
#include <vdr/plugin.h>
11
#include "
menu.h
"
12
#include "
player.h
"
13
14
static
const
char
*
VERSION
=
"2.0.0"
;
15
static
const
char
*
DESCRIPTION
=
trNOOP
(
"A simple picture viewer"
);
16
static
const
char
*
MAINMENUENTRY
=
trNOOP
(
"Pictures"
);
17
18
// --- cMenuSetupPictures ----------------------------------------------------
19
20
class
cMenuSetupPictures
:
public
cMenuSetupPage
{
21
private
:
22
char
newPictureDirectory
[PATH_MAX];
23
int
newSlideShowDelay
;
24
protected
:
25
virtual
void
Store
(
void
);
26
public
:
27
cMenuSetupPictures
(
void
);
28
};
29
30
cMenuSetupPictures::cMenuSetupPictures
(
void
)
31
{
32
strn0cpy
(
newPictureDirectory
,
PictureDirectory
,
sizeof
(
newPictureDirectory
));
33
newSlideShowDelay
=
SlideShowDelay
;
34
Add
(
new
cMenuEditStrItem
(
tr
(
"Picture directory"
),
newPictureDirectory
,
sizeof
(
newPictureDirectory
)));
35
Add
(
new
cMenuEditIntItem
(
tr
(
"Slide show delay (s)"
), &
newSlideShowDelay
));
36
}
37
38
void
cMenuSetupPictures::Store
(
void
)
39
{
40
SetupStore
(
"PictureDirectory"
,
strn0cpy
(
PictureDirectory
,
newPictureDirectory
,
sizeof
(
PictureDirectory
)));
41
SetupStore
(
"SlideShowDelay"
,
SlideShowDelay
=
newSlideShowDelay
);
42
}
43
44
// --- cPluginPictures -------------------------------------------------------
45
46
class
cPluginPictures
:
public
cPlugin
{
47
private
:
48
// Add any member variables or functions you may need here.
49
public
:
50
cPluginPictures
(
void
);
51
virtual
~cPluginPictures
();
52
virtual
const
char
*
Version
(
void
) {
return
VERSION
; }
53
virtual
const
char
*
Description
(
void
) {
return
tr
(
DESCRIPTION
); }
54
virtual
const
char
*
CommandLineHelp
(
void
);
55
virtual
bool
ProcessArgs
(
int
argc,
char
*argv[]);
56
virtual
const
char
*
MainMenuEntry
(
void
) {
return
tr
(
MAINMENUENTRY
); }
57
virtual
cOsdObject
*
MainMenuAction
(
void
);
58
virtual
cMenuSetupPage
*
SetupMenu
(
void
);
59
virtual
bool
SetupParse
(
const
char
*
Name
,
const
char
*Value);
60
};
61
62
cPluginPictures::cPluginPictures
(
void
)
63
{
64
// Initialize any member variables here.
65
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
66
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
67
}
68
69
cPluginPictures::~cPluginPictures
()
70
{
71
// Clean up after yourself!
72
}
73
74
const
char
*
cPluginPictures::CommandLineHelp
(
void
)
75
{
76
// Return a string that describes all known command line options.
77
return
" -d DIR, --dir=DIR set the picture directory to DIR\n"
;
78
}
79
80
bool
cPluginPictures::ProcessArgs
(
int
argc,
char
*argv[])
81
{
82
// Implement command line argument processing here if applicable.
83
static
struct
option long_options[] = {
84
{
"dir"
, required_argument, NULL,
'd'
},
85
{ NULL, no_argument, NULL, 0 }
86
};
87
88
int
c;
89
while
((c = getopt_long(argc, argv,
"d:"
, long_options, NULL)) != -1) {
90
switch
(c) {
91
case
'd'
:
strn0cpy
(
PictureDirectory
, optarg,
sizeof
(
PictureDirectory
));
92
break
;
93
default
:
return
false
;
94
}
95
}
96
return
true
;
97
}
98
99
cOsdObject
*
cPluginPictures::MainMenuAction
(
void
)
100
{
101
// Perform the action when selected from the main VDR menu.
102
if
(*
PictureDirectory
)
103
return
cPictureMenu::CreatePictureMenu
();
104
Skins
.
Message
(
mtWarning
,
tr
(
"No picture directory has been defined!"
));
105
return
NULL;
106
}
107
108
cMenuSetupPage
*
cPluginPictures::SetupMenu
(
void
)
109
{
110
// Return a setup menu in case the plugin supports one.
111
return
new
cMenuSetupPictures
;
112
}
113
114
bool
cPluginPictures::SetupParse
(
const
char
*Name,
const
char
*Value)
115
{
116
// Parse your own setup parameters and store their values.
117
if
(!strcasecmp(Name,
"PictureDirectory"
))
strn0cpy
(
PictureDirectory
, Value,
sizeof
(
PictureDirectory
));
118
else
if
(!strcasecmp(Name,
"SlideShowDelay"
))
SlideShowDelay
= atoi(Value);
119
else
120
return
false
;
121
return
true
;
122
}
123
124
VDRPLUGINCREATOR
(
cPluginPictures
);
// Don't touch this!
125
Generated by
1.8.3.1