summaryrefslogtreecommitdiffstats
path: root/src/global.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/global.h')
-rw-r--r--src/global.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/global.h b/src/global.h
new file mode 100644
index 0000000..bdfda89
--- /dev/null
+++ b/src/global.h
@@ -0,0 +1,72 @@
+#ifndef GLOBAL_H_
+#define GLOBAL_H_
+
+#include <QLightDM/Power>
+#include <QLightDM/Greeter>
+#include <QLightDM/SessionsModel>
+
+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();
+
+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_ */