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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
/*
* playlist: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id: menusetup.c 0.2 2004/10/08 02:34:00 hflor Exp $
*/
#include "menusetup.h"
#include "playlist.h"
#include "menuplaylists.h"
#include "menucontrol.h"
#include "vdrtools.h"
#include <vdr/plugin.h>
// --- cMenuSetupPlayList -------------------------------------------------------
cMenuSetupPlayList::cMenuSetupPlayList(void)
{
#ifdef PL_Debug2
dsyslog("%s: cMenuSetupPlayList::cMenuSetupPlayList", plugin_name);
#endif
store = false;
changedefault = false;
#define StoreValue(T) T.o = T.u
#define StoreValueFile(T) strcpy(T.o, T.u)
// var pos7
StoreValue (charentry);
StoreValue (charfolder);
StoreValue (charrecord);
StoreValue (commandline_preference);
StoreValueFile (lastplaylist);
StoreValueFile (mainmenu_name);
StoreValue (mainmenu_visible);
StoreValue (confirmdelplentry);
StoreValue (okstartplay);
StoreValue (deleterecords);
StoreValueFile (pathplaylists);
StoreValue (startoption);
StoreValue (storeplaylist);
StoreValue (timeoutreadrecords);
StoreValue (verbose);
for (int i = Option_confirmdeleterecord; i < Option_max; i++)
StoreValue (PL_options[i]);
#undef StoreValue
#undef StoreValueFile
Set();
}
cMenuSetupPlayList::~cMenuSetupPlayList(void)
{
#ifdef PL_Debug2
dsyslog("%s: cMenuSetupPlayList::~cMenuSetupPlayList store=%s", plugin_name, store ? "true" : "false");
#endif
if (!store)
{
#define RestoreValue(T) T.u = T.o
#define RestoreValueFile(T) strcpy(T.u, T.o)
// var pos8
RestoreValue (charentry);
RestoreValue (charfolder);
RestoreValue (charrecord);
RestoreValue (commandline_preference);
RestoreValueFile (lastplaylist);
RestoreValueFile (mainmenu_name);
RestoreValue (mainmenu_visible);
RestoreValue (confirmdelplentry);
RestoreValue (okstartplay);
RestoreValue (deleterecords);
RestoreValueFile (pathplaylists);
RestoreValue (startoption);
RestoreValue (storeplaylist);
RestoreValue (timeoutreadrecords);
RestoreValue (verbose);
for (int i = Option_confirmdeleterecord; i < Option_max; i++)
RestoreValue (PL_options[i]);
#undef RestoreValue
#undef RestoreValueFile
}
}
void cMenuSetupPlayList::Store(void)
{
#ifdef PL_Debug2
dsyslog("%s: cMenuSetupPlayList::Store", plugin_name);
#endif
#define SaveValue(T, N) if (T.u != T.o) SetupStore(N, T.u);
#define SaveValueChar(T, N) if (T.u != T.o) SetupStore(N, T.u + 256);
#define SaveValueFile(T, N) if (strcmp(T.u, T.o)) SetupStore(N, T.u);
// var pos9
SaveValueChar (charentry, "cahre");
SaveValueChar (charfolder, "charf");
SaveValueChar (charrecord, "charr");
SaveValue (commandline_preference, "commandline");
SaveValueFile (lastplaylist, "lastpl");
SaveValueFile (mainmenu_name, "name");
SaveValue (mainmenu_visible, "visible");
SaveValue (confirmdelplentry, "deletentry");
SaveValue (okstartplay, "okplay");
SaveValue (deleterecords, "delete");
SaveValueFile (pathplaylists, "path");
SaveValue (startoption, "start");
SaveValue (storeplaylist, "storepl");
SaveValue (timeoutreadrecords, "timerecords");
SaveValue (verbose, "verbose");
SaveValue (PL_options[Option_confirmdeleterecord], "confdelete");
SaveValue (PL_options[Option_confirmstartnewrecord], "startnew");
SaveValue (PL_options[Option_deletefromlist], "deletel");
SaveValue (PL_options[Option_deleterecord], "deleter");
SaveValue (PL_options[Option_jumpmark], "jumpmark");
SaveValue (PL_options[Option_playoption1], "playoption1");
SaveValue (PL_options[Option_playoption2], "playoption2");
SaveValue (PL_options[Option_playonlynew], "playonlynew");
SaveValue (PL_options[Option_searchnewrecord], "searchnew");
SaveValue (PL_options[Option_searchrecordsub], "searchsub");
#undef SaveValue
#undef SaveValueChar
#undef SaveValueFile
store = true;
}
void cMenuSetupPlayList::Set(bool sel)
{
#ifdef PL_Debug2
dsyslog("%s: cMenuSetupPlayList::Set Current=%d", plugin_name, Current());
#endif
int current = Current();
Clear();
fileitempos = -1;
#define DisplayLine(T) !T.h && (!commandline_preference.u || !T.c)
Add(new cOsdItem (tr("Setup$Display playlists now"), osUser6));
Add(new cOsdItem (tr("Setup$Play last playlist now"), osUser7));
if (DisplayLine(commandline_preference))
Add(new cMenuEditBoolItem(tr("Setup$Preferr Command Line Parameter"), &commandline_preference.u));
if (DisplayLine(mainmenu_visible))
Add(new cMenuEditBoolItem(tr("Setup$Visible in Mainmenu"), &mainmenu_visible.u));
if (DisplayLine(mainmenu_name) && mainmenu_visible.u)
Add(new cMenuEditStrItem (tr("Setup$ Name for Mainmenu"), mainmenu_name.u, sizeof(mainmenu_name.u), tr(FileNameChars)));
if (DisplayLine(startoption))
Add(new cMenuEditStraItem(tr("Setup$Startoptions for plugin"), &startoption.u, 4, StartOptions));
if (DisplayLine(okstartplay))
Add(new cMenuEditBoolItem(tr("Setup$Press OK in Playlistview starts"), &okstartplay.u, tr("Setup$Edit"), tr("Setup$Play")));
if (DisplayLine(storeplaylist))
Add(new cMenuEditBoolItem(tr("Setup$Store playlist after change"), &storeplaylist.u, tr("Setup$automatically"), tr("Setup$after question")));
if (DisplayLine(deleterecords))
Add(new cMenuEditBoolItem(tr("Setup$Allow delete Records"), &deleterecords.u));
if (DisplayLine(confirmdelplentry))
Add(new cMenuEditBoolItem(tr("Setup$Confirm delete playlistentries"), &confirmdelplentry.u));
if (DisplayLine(pathplaylists))
{
fileitempos = Count();
Add(new cMenuEditStrItem (tr("Setup$Path for store playlists"), pathplaylists.u, sizeof(pathplaylists.u), FileNameCharsAllowed));
}
Add(new cMenuEditBoolItem(tr("Setup$Change default options for playlist"), &changedefault));
if (changedefault)
{
if (DisplayLine(PL_options[Option_playoption1]))
Add(new cMenuEditStraItem(tr("OptionPL$ In playlistview starts play at"), &PL_options[Option_playoption1].u, PlayOptions_max - 1, PlayOptions));
if (DisplayLine(PL_options[Option_playoption2]))
Add(new cMenuEditStraItem(tr("OptionPL$ In detailview starts play at"), &PL_options[Option_playoption2].u, PlayOptions_max - 1, PlayOptions));
if (DisplayLine(PL_options[Option_searchnewrecord]))
Add(new cMenuEditBoolItem(tr("OptionPL$ Search new records on folders"), &PL_options[Option_searchnewrecord].u));
if (DisplayLine(PL_options[Option_searchrecordsub]))
Add(new cMenuEditBoolItem(tr("OptionPL$ Search new records on subfolders"), &PL_options[Option_searchrecordsub].u));
if (DisplayLine(PL_options[Option_playonlynew]))
Add(new cMenuEditBoolItem(tr("OptionPL$ Play only new Records"), &PL_options[Option_playonlynew].u));
if (DisplayLine(PL_options[Option_jumpmark]))
Add(new cMenuEditBoolItem(tr("OptionPL$ Jump to first segment of movie"), &PL_options[Option_jumpmark].u));
if (DisplayLine(PL_options[Option_confirmstartnewrecord]))
Add(new cMenuEditBoolItem(tr("OptionPL$ Confirm start new record"), &PL_options[Option_confirmstartnewrecord].u));
if (DisplayLine(PL_options[Option_deletefromlist]))
Add(new cMenuEditBoolItem(tr("OptionPL$ Remove records after play from list"), &PL_options[Option_deletefromlist].u));
if (DisplayLine(PL_options[Option_deleterecord]) && deleterecords.u)
Add(new cMenuEditBoolItem(tr("OptionPL$ Delete records after play"), &PL_options[Option_deleterecord].u));
if (DisplayLine(PL_options[Option_confirmdeleterecord]) && PL_options[Option_deleterecord].u && deleterecords.u)
Add(new cMenuEditBoolItem(tr("OptionPL$ Confirm delete records"), &PL_options[Option_confirmdeleterecord].u));
}
Add(new cMenuEditBoolItem(tr("Setup$Change Character for identification"), &changechar));
if (changechar)
{
if (DisplayLine(charfolder))
Add(new cMenuEditChrItem(tr("OptionPL$ Character for folders"), &charfolder.u, AllCharsAllowed));
if (DisplayLine(charentry))
Add(new cMenuEditChrItem(tr("OptionPL$ Character for records in folders"), &charentry.u, AllCharsAllowed));
if (DisplayLine(charrecord))
Add(new cMenuEditChrItem(tr("OptionPL$ Character for normal records"), &charrecord.u, AllCharsAllowed));
}
if (DisplayLine(verbose))
Add(new cMenuEditBoolItem(tr("Setup$Verbose Log Mode"), &verbose.u));
if (sel && changechar)
SetCurrent(Get(Count() - 1));
#undef DisplayLine
#ifdef PL_Debug2
dsyslog("%s: Count=%d", plugin_name, Count());
#endif
SetCurrent(Get(current));
}
eOSState cMenuSetupPlayList::ProcessKey(eKeys Key)
{
#ifdef PL_Debug3
bool noneKey = Key == kNone;
if (!noneKey)
dsyslog("%s: cMenuSetupPlayList::ProcessKey Key=%s", plugin_name, KeyName(Key));
#endif
static char oldstatus[MAXOSDTEXTWIDTH];
char status[MAXOSDTEXTWIDTH];
int pathlen;
int m_commandline_preference = commandline_preference.u;
int m_mainmenu_visible = mainmenu_visible.u;
int m_deleterecords = deleterecords.u;
int m_changedefault = changedefault;
int m_deleterecord = PL_options[Option_deleterecord].u;
int m_changechar = changechar;
int m_playoption = PL_options[Option_playoption1].u;
eOSState state = cMenuSetupPage::ProcessKey(Key);
#ifdef PL_Debug3
if (!noneKey || (state != osUnknown && state != osContinue))
{
dsyslog("%s: cMenuSetupPlayList::ProcessKey OSState=%s", plugin_name, OSStateName(state));
noneKey = false;
}
#endif
if (m_commandline_preference != commandline_preference.u || m_mainmenu_visible != mainmenu_visible.u || m_deleterecords != deleterecords.u || m_changedefault != changedefault || m_deleterecord != PL_options[Option_deleterecord].u || m_changechar != changechar)
{
Set(m_changechar != changechar);
Display();
if (!m_changedefault && changedefault)
{
for (int i = 0; i < 5; i++)
CursorDown();
for (int i = 0; i < 5; i++)
CursorUp();
}
} else if (m_playoption != PL_options[Option_playoption1].u && PL_options[Option_playoption1].u == PlayOptions_selectpos)
{
PL_options[Option_playoption1].u = m_playoption < PlayOptions_selectpos ? PlayOptions_question : PlayOptions_lastplay;
RefreshCurrent();
}
if (Current() == fileitempos)
{
const char *temp = PluginPlaylist->ExpandPath("", false);
pathlen = strlen(temp);
if (pathlen > AKTOSDTEXTWIDTH - 10)
sprintf(status, "...%s", temp + pathlen - AKTOSDTEXTWIDTH + 10);
else
strcpy(status, temp);
if (oldstatus != status)
{
SetStatus(status);
strcpy(oldstatus, status);
}
} else if (strlen(oldstatus))
{
SetStatus(NULL);
oldstatus[0] = 0;
}
switch (state)
{
case osUser6: state = AddSubMenu(new cMenuPlaylists);
break;
case osUser7: {
cMenuPlaylists *menu = new cMenuPlaylists;
if (SelectPLR)
menu->ProcessKey(kUser2);
state = AddSubMenu(menu);
}
break;
case osUser9: if (SelectPLR)
{
cControl::Shutdown(); // Start play (SelectPLR)
cControl::Launch(new cControlPlaylist);
}
state = osEnd;
break;
default: break;
}
#ifdef PL_Debug3
if (!noneKey || (state != osUnknown && state != osContinue))
dsyslog("%s: cMenuSetupPlayList::ProcessKey returned OSState=%s", plugin_name, OSStateName(state));
#endif
return state;
}
|