]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-qt/QLightDM/Greeter
83d7d75b397153c702d4b85110994d85b245f9a7
[sojka/lightdm.git] / liblightdm-qt / QLightDM / Greeter
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         QString timedLoginUser() const;
45         int timedLoginDelay() const;
46
47         QString getHint(QString name) const;
48         QString defaultSessionHint() const;
49         bool hideUsersHint() const;
50         bool hasGuestAccountHint() const;
51         QString selectUserHint() const;
52         bool selectGuestHint() const;
53         QString autologinUserHint() const;
54         bool autologinGuestHint() const;
55         int autologinTimeoutHint() const;
56
57         bool inAuthentication() const;
58         bool isAuthenticated() const;
59         QString authenticationUser() const;
60
61     public slots:
62         void connectToServer();
63         void authenticate(const QString &username=QString());
64         void authenticateAsGuest();
65         void respond(const QString &response);
66         void cancelAuthentication();
67         void startSession(const QString &session=QString());
68
69     signals:
70         void connected();
71         void showPrompt(QString prompt, PromptType type);
72         void showMessage(QString message, MessageType type);
73         void authenticationComplete();
74         void sessionFailed();
75         void autologinTimerExpired();
76         void quit();
77
78     private slots:
79         void onRead(int fd);
80
81     private:
82         GreeterPrivate *d;
83         void writeInt(int value);
84         void writeString(QString value);
85         void writeHeader(int id, int length);
86         void flush();
87         int getPacketLength();
88         int readInt(int *offset);
89         QString readString(int *offset);
90     };
91 };
92
93 #endif // QLIGHTDM_GREETER_H