File: setup.c

package info (click to toggle)
vdr-plugin-remoteosd 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 168 kB
  • ctags: 126
  • sloc: ansic: 661; makefile: 62; sh: 9
file content (85 lines) | stat: -rw-r--r-- 2,837 bytes parent folder | download | duplicates (2)
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
/*
 * remoteosd.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include <vdr/menuitems.h>
#include <vdr/skins.h>
#include <vdr/i18n.h>
#include "setup.h"

cRemoteOsdSetup RemoteOsdSetup;

cRemoteOsdSetup::cRemoteOsdSetup() {
	hideMainMenuEntry = 0;
	replaceSchedule = 0;
	replaceTimers = 0;
	serverIp[0] = 0;
	serverPort = 0;
	tuneServer = 0;
	maxItems = 0;
	remoteTheme[0] = 0;
}

cRemoteOsdSetup& cRemoteOsdSetup::operator=(const cRemoteOsdSetup &Setup) {
	hideMainMenuEntry = Setup.hideMainMenuEntry;
	replaceSchedule = Setup.replaceSchedule;
	replaceTimers = Setup.replaceTimers;
	strn0cpy(serverIp, Setup.serverIp, sizeof(serverIp));
	serverPort = Setup.serverPort;
	tuneServer = Setup.tuneServer;
	maxItems = Setup.maxItems;
	strn0cpy(remoteTheme, Setup.remoteTheme, sizeof(remoteTheme));
	return *this;
}

void cRemoteOsdMenuSetup::Store() {
	setupTmp.remoteTheme[0] = 0;
	if (themeIndex > 0)
		strn0cpy(setupTmp.remoteTheme, themes.Name(themeIndex - 1), sizeof(setupTmp.remoteTheme));

	SetupStore("HideMainMenuEntry", setupTmp.hideMainMenuEntry);
	SetupStore("ReplaceSchedule", setupTmp.replaceSchedule);
	SetupStore("ReplaceTimers", setupTmp.replaceTimers);
	SetupStore("ServerIp", setupTmp.serverIp);
	SetupStore("ServerPort", setupTmp.serverPort);
	SetupStore("TuneServer", setupTmp.tuneServer);
	SetupStore("MaxItems", setupTmp.maxItems);
	SetupStore("RemoteTheme", setupTmp.remoteTheme);
	RemoteOsdSetup = setupTmp;
}

cRemoteOsdMenuSetup::cRemoteOsdMenuSetup() {
	setupTmp = RemoteOsdSetup;

	themes.Load(Skins.Current()->Name());
	int numThemes = themes.NumThemes();
	const char* const* descriptions = themes.Descriptions();
	themeList = MALLOC(const char*, numThemes + 1);
	themeIndex = 0;
	themeList[0] = strdup("");
	for (int i = 0; i < themes.NumThemes(); i++) {
		themeList[i + 1] = descriptions[i];
		if (strcmp(setupTmp.remoteTheme, themes.Name(i)) == 0)
			themeIndex = i + 1;
	}

	Add(new cMenuEditBoolItem(tr("Hide mainmenu entry"), &setupTmp.hideMainMenuEntry));
#ifdef MAINMENUHOOKSVERSNUM
	Add(new cMenuEditBoolItem(tr("Replace mainmenu \"Schedule\""), &setupTmp.replaceSchedule));
	Add(new cMenuEditBoolItem(tr("Replace mainmenu \"Timers\""), &setupTmp.replaceTimers));
#endif
	Add(new cMenuEditStrItem(tr("Server IP"), setupTmp.serverIp, 15, ".1234567890"));
	Add(new cMenuEditIntItem(tr("Server port"), &setupTmp.serverPort, 0, 65535, tr("from svdrpservice")));
	Add(new cMenuEditBoolItem(tr("Tune server channel"), &setupTmp.tuneServer));
	Add(new cMenuEditIntItem(tr("Number of lines per page"), &setupTmp.maxItems, 0));
	Add(new cMenuEditStraItem(tr("Remote menu theme"), &themeIndex, numThemes + 1, themeList));
}

cRemoteOsdMenuSetup::~cRemoteOsdMenuSetup() {
	free((void *) themeList[0]);
	free(themeList);
}