summaryrefslogtreecommitdiffstats
path: root/src/global.h
blob: 79851759d43aaa04b85f065646fe17c60c8de05f (plain) (blame)
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
#ifndef GLOBAL_H_
#define GLOBAL_H_

#include <QLightDM/Power>
#include <QLightDM/Greeter>
#include <QLightDM/SessionsModel>
#include <QImage>

class Global {
public:
	static inline QLightDM::Greeter* greeter()
	{
		if (!m_testMode && m_Greeter == nullptr) {
			initGreeter();
		}
		return m_Greeter;
	}

	static inline QLightDM::PowerInterface* power()
	{
		if (!m_testMode && m_Power == nullptr) {
			m_Power = new QLightDM::PowerInterface();
		}
		return m_Power;
	}

	static inline QLightDM::SessionsModel* sessions()
	{
		if (!m_testMode && m_Sessions == nullptr) {
			m_Sessions = new QLightDM::SessionsModel();
		}
		return m_Sessions;
	}

	static inline void enableTestMode()
	{
		m_testMode = true;
	}

	static inline bool testMode()
	{
		return m_testMode;
	}

	static bool autoLoginGuest();

	static bool startSession();

    static QImage getConfigGradient();

    static QStringList urlWhitelist();

    static QStringList urlBlacklist();

    static void writeCowToken(const QString &user, const QString &token);

    static bool isValidShibCreds(const QString &ustr, const QString &upass);

    static QString getCombinedIdpWhitelist();

private:
	static bool m_testMode;
	static QLightDM::Greeter *m_Greeter;
	static QLightDM::PowerInterface *m_Power;
	static QLightDM::SessionsModel *m_Sessions;

	static void initGreeter();

	Global() {};
};

class GreeterCb : public QObject
{
	Q_OBJECT
public slots:
	void authenticationComplete() { authComplete = true; }
	void autologinTimerExpired() { authError = true; }
	void reset() { authError = true; }
	void customTimeout() { authError = true; }
public:
	GreeterCb() : authComplete(false), authError(false) {}
	bool authComplete, authError;
};

#endif /* GLOBAL_H_ */