]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-qt/QLightDM/greeter.h
Really tidy up liblightdm
[sojka/lightdm.git] / liblightdm-qt / QLightDM / greeter.h
1 /*
2  * Copyright (C) 2010-2011 David Edmundson.
3  * Copyright (C) 2010-2011 Robert Ancell
4  * Author: David Edmundson <kde@davidedmundson.co.uk>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by the Free
8  * Software Foundation; either version 3 of the License, or (at your option) any
9  * later version. See http://www.gnu.org/copyleft/lgpl.html the full text of the
10  * license.
11  */
12
13 #ifndef QLIGHTDM_GREETER_H
14 #define QLIGHTDM_GREETER_H
15
16 #include <QtCore/QObject>
17 #include <QtCore/QVariant>
18 #include "QLightDM/User"
19 #include "QLightDM/Language"
20
21 class GreeterPrivate;
22
23 namespace QLightDM
24 {
25   typedef enum
26   {
27     PROMPT_TYPE_QUESTION,
28     PROMPT_TYPE_SECRET
29   } PromptType;
30
31   typedef enum
32   {
33     MESSAGE_TYPE_INFO,
34     MESSAGE_TYPE_ERROR
35   } MessageType;
36
37   class Q_DECL_EXPORT Greeter : public QObject
38   {
39     Q_OBJECT
40     public:
41         explicit Greeter(QObject* parent=0);
42         virtual ~Greeter();
43
44         Q_PROPERTY(bool canSuspend READ canSuspend);
45         Q_PROPERTY(bool canHibernate READ canHibernate);
46         Q_PROPERTY(bool canShutdown READ canShutdown);
47         Q_PROPERTY(bool canRestart READ canRestart);
48
49         Q_PROPERTY(QString hostname READ hostname CONSTANT);
50
51         /** The hostname of the machine */
52         QString hostname() const;
53
54         QString timedLoginUser() const;
55         int timedLoginDelay() const;
56
57         QList<QLightDM::Language> languages() const;
58         QString defaultLanguage() const;
59
60         QString layout() const;
61
62         QString getHint(QString name) const;
63         QString defaultSessionHint() const;
64         bool hideUsersHint() const;
65         bool hasGuestAccountHint() const;
66         QString selectUserHint() const;
67         bool selectGuestHint() const;
68         QString autologinUserHint() const;
69         bool autologinGuestHint() const;
70         int autologinTimeoutHint() const;
71
72         bool inAuthentication() const;
73         bool isAuthenticated() const;
74         QString authenticationUser() const;
75
76         bool canSuspend() const;
77         bool canHibernate() const;
78         bool canShutdown() const;
79         bool canRestart() const;
80
81     public slots:
82         void suspend();
83         void hibernate();
84         void shutdown();
85         void restart();
86
87         void connectToServer();
88         void authenticate(const QString &username=QString());
89         void authenticateAsGuest();
90         void respond(const QString &response);
91         void cancelAuthentication();
92         void startSession(const QString &session=QString());
93
94     signals:
95         void connected();
96         void showPrompt(QString prompt, PromptType type);
97         void showMessage(QString message, MessageType type);
98         void authenticationComplete();
99         void sessionFailed();
100         void autologinTimerExpired();
101         void quit();
102
103     private slots:
104         void onRead(int fd);
105
106     private:
107         GreeterPrivate *d;
108         void writeInt(int value);
109         void writeString(QString value);
110         void writeHeader(int id, int length);
111         void flush();
112         int getPacketLength();
113         int readInt(int *offset);
114         QString readString(int *offset);
115     };
116 };
117
118 #endif // QLIGHTDM_GREETER_H