summaryrefslogtreecommitdiff
path: root/setup.h
blob: 32512e43496ec81b2cb5f2ce91898f830382b800 (plain)
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
#ifndef VDR_LIVE_SETUP_H
#define VDR_LIVE_SETUP_H

#include <list>
#include <numeric>
#include <string>
#include "live.h"
#include <vdr/menuitems.h>

#define LIVEVERSION "0.1.0"
#define LIVEVERSNUM 1
#define LIVESUMMARY "Live Integrated VDR Environment"

namespace vdrlive {

// forward declaration, see below
class cMenuSetupLive;

class Setup
{
	friend Setup& LiveSetup();
	friend class cMenuSetupLive; // friend declaration is not forward 
								 // declaration, although gcc 3.3 claims so

public:
	typedef std::list< std::string > IpList;

	// commandline
	int GetServerPort() const { return m_serverPort; }
	IpList const& GetServerIps() const { return m_serverIps; }
	// vdr-setup
	int GetLastChannel() const { return m_lastChannel == 0 ? std::numeric_limits< int >::max() : m_lastChannel; }
	int GetScreenshotInterval() const { return m_screenshotInterval; }
	std::string GetAdminLogin() const { return m_adminLogin; }
	std::string GetMD5HashAdminPassword() const;
	int GetAdminPasswordLength() const;
	bool UseAuth() const { return m_useAuth; }
	std::string GetTimes() const { return m_times; }
	
	void SetLastChannel(int lastChannel) { m_lastChannel = lastChannel; }
	void SetAdminLogin(std::string login) { m_adminLogin = login; }
	std::string SetAdminPassword(std::string password);
	void SetUseAuth(int auth) { m_useAuth = auth; }
	void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; }
	void SetTimes(std::string times) { m_times = times; }

	bool SaveSetup();

	bool ParseCommandLine( int argc, char* argv[] );
	char const* CommandLineHelp() const;

	bool ParseSetupEntry( char const* name, char const* value );
	bool HaveEPGSearch(void);	
private:
	Setup();
	Setup( Setup const& );

	// me
	cPlugin* liveplugin;

	mutable std::string m_helpString;
	// commandline options
	int m_serverPort;
	IpList m_serverIps;
	// setup options
	int m_lastChannel;
	int m_screenshotInterval;
	
	int m_useAuth;
	std::string m_adminLogin;
	std::string m_adminPasswordMD5;
	std::string m_times;

	bool CheckServerPort();
	bool CheckServerIps();
};

Setup& LiveSetup();

class cMenuSetupLive : public cMenuSetupPage {

protected:
	virtual void Store(void);
	virtual eOSState ProcessKey(eKeys Key);
public:
  cMenuSetupLive();
  
private:
	int m_lastChannel;
	int m_screenshotInterval;
	
	int m_useAuth;
	char m_adminLogin[20];
	char m_adminPassword[20];
	char m_tmpPassword[20]; 
	std::string m_oldpasswordMD5;
	std::string m_newpasswordMD5;

	void Set(void);
	bool InEditMode(const char* ItemText, const char* ItemName, const char* ItemValue);
};

} // namespace vdrlive

#endif // VDR_LIVE_SETUP_H