]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-qt/QLightDM/greeter.h
efa6839d3f833ae460a3580a1e7b6d7c33ce8157
[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 QLIGTHDM_GREETER_H
14 #define QLIGTHDM_GREETER_H
15
16 #include <QtCore/QObject>
17 #include <QtCore/QVariant>
18
19 #include "user.h"
20 #include "language.h"
21 //#include "ldmlayout.h"
22
23 class GreeterPrivate;
24
25 namespace QLightDM
26 {
27   class Config;
28   
29   class Q_DECL_EXPORT Greeter : public QObject
30   {
31     Q_OBJECT
32     public:
33         explicit Greeter(QObject* parent=0);
34         virtual ~Greeter();
35
36         Q_PROPERTY(bool canSuspend READ canSuspend);
37         Q_PROPERTY(bool canHibernate READ canHibernate);
38         Q_PROPERTY(bool canShutdown READ canShutdown);
39         Q_PROPERTY(bool canRestart READ canRestart);
40
41         Q_PROPERTY(QString hostname READ hostname CONSTANT);
42
43         /** The hostname of the machine */
44         QString hostname() const;
45         QString theme() const;
46
47         Q_INVOKABLE QVariant getProperty(const QString &name) const;
48
49         QString timedLoginUser() const;
50         int timedLoginDelay() const;
51
52         QList<QLightDM::Language> languages() const;
53         QString defaultLanguage() const;
54
55         //QList<LdmLayout> layouts() const;
56         QString layout() const;
57
58         QLightDM::Config *config() const;
59
60         QString defaultSession() const;
61         bool guestAccountSupported() const;
62
63         bool inAuthentication() const;
64         bool isAuthenticated() const;
65         QString authenticationUser() const;
66
67         bool canSuspend() const;
68         bool canHibernate() const;
69         bool canShutdown() const;
70         bool canRestart() const;
71
72     public slots:
73         void suspend();
74         void hibernate();
75         void shutdown();
76         void restart();
77
78         void connectToServer();
79         void cancelTimedLogin();  
80         void login(const QString &username);
81         void loginAsGuest();
82         void respond(const QString &response);
83         void cancelAuthentication();
84         void startSession(const QString &session=QString());
85         
86     signals:
87         void connected();
88         void showPrompt(QString prompt);
89         void showMessage(QString message);
90         void showError(QString message);
91         void authenticationComplete(bool isAuthenticated);
92         void timedLogin(QString username);
93         void selectUser(QString username);
94         void selectGuest();
95         void quit();
96     
97     private slots:  
98         void onRead(int fd);
99
100     private:
101         GreeterPrivate *d;
102         void writeInt(int value);
103         void writeString(QString value);
104         void writeHeader(int id, int length);
105         void flush();
106         int getPacketLength();
107         int readInt(int *offset);
108         QString readString(int *offset);
109     };
110
111 };//end namespace
112
113 #endif // LDMGREETER_H