]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-qt/QLightDM/Greeter
connect_to_server -> connect_sync, start_session -> start_session_sync
[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         bool connectSync();
63         void authenticate(const QString &username=QString());
64         void authenticateAsGuest();
65         void respond(const QString &response);
66         void cancelAuthentication();
67         bool startSessionSync(const QString &session=QString());
68
69     signals:
70         void showPrompt(QString prompt, PromptType type);
71         void showMessage(QString message, MessageType type);
72         void authenticationComplete();
73         void autologinTimerExpired();
74
75     private slots:
76         void onRead(int fd);
77
78     private:
79         GreeterPrivate *d;
80         void writeInt(int value);
81         void writeString(QString value);
82         void writeHeader(int id, int length);
83         void flush();
84         char *readMessage(int *length, bool block);
85     };
86 };
87
88 #endif // QLIGHTDM_GREETER_H