2018-03-05 16:58:46 +08:00
|
|
|
/* greeterwrapper.cpp
|
2018-03-05 17:40:30 +08:00
|
|
|
* Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
|
2018-03-05 16:58:46 +08:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
|
* 02110-1301, USA.
|
|
|
|
|
**/
|
2018-02-08 17:48:39 +08:00
|
|
|
#include "greeterwrapper.h"
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include "globalv.h"
|
|
|
|
|
|
|
|
|
|
GreeterWrapper::GreeterWrapper(QObject *parent) : QLightDM::Greeter(parent)
|
|
|
|
|
{
|
|
|
|
|
//连接到lightdm
|
|
|
|
|
if(!connectToDaemonSync()){
|
|
|
|
|
qDebug() << "connect to Daemon failed";
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GreeterWrapper::setLang(const QString &lang)
|
|
|
|
|
{
|
|
|
|
|
this->m_language = lang;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GreeterWrapper::lang()
|
|
|
|
|
{
|
|
|
|
|
return this->m_language;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GreeterWrapper::setSession(const QString &session)
|
|
|
|
|
{
|
|
|
|
|
m_session = session;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GreeterWrapper::session()
|
|
|
|
|
{
|
|
|
|
|
return m_session;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-16 08:52:03 +08:00
|
|
|
QString GreeterWrapper::userName()
|
|
|
|
|
{
|
|
|
|
|
return m_userName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GreeterWrapper::setUserName(const QString &userName)
|
|
|
|
|
{
|
|
|
|
|
m_userName = userName;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-08 17:48:39 +08:00
|
|
|
void GreeterWrapper::startSession()
|
2018-03-05 16:58:46 +08:00
|
|
|
{
|
2018-03-16 08:52:03 +08:00
|
|
|
if(isAuthenticated())
|
|
|
|
|
Q_EMIT authenticationSucess();
|
2018-02-08 17:48:39 +08:00
|
|
|
//设置language
|
|
|
|
|
if(!m_language.isEmpty()) {
|
|
|
|
|
setLanguage(m_language);
|
|
|
|
|
}
|
|
|
|
|
qDebug() << "start session: " << m_session;
|
|
|
|
|
//启动session
|
|
|
|
|
if(!startSessionSync(m_session)) {
|
2018-03-16 08:52:03 +08:00
|
|
|
Q_EMIT startSessionFailed();
|
2018-02-08 17:48:39 +08:00
|
|
|
Q_EMIT showMessage(tr("failed to start session."), QLightDM::Greeter::MessageTypeError);
|
|
|
|
|
}
|
|
|
|
|
}
|