File indexing completed on 2024-06-23 05:28:18
0001 /* 0002 This file is part of LightDM-KDE. 0003 0004 Copyright 2012 David Edmundson <kde@davidedmundson.co.uk> 0005 0006 LightDM-KDE is free software: you can redistribute it and/or modify 0007 it under the terms of the GNU General Public License as published by 0008 the Free Software Foundation, either version 3 of the License, or 0009 (at your option) any later version. 0010 0011 LightDM-KDE is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with LightDM-KDE. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "greeterwrapper.h" 0021 0022 #include <KConfig> 0023 #include <KConfigGroup> 0024 #include <KDebug> 0025 0026 GreeterWrapper::GreeterWrapper(QObject *parent) : 0027 QLightDM::Greeter(parent) 0028 { 0029 connectSync(); 0030 KSharedConfig::Ptr config = KSharedConfig::openConfig("state-kde"); 0031 0032 //store a different config per display so last user is remembered per session 0033 m_configGroup = config->group(QLatin1String("lightdm_") + qgetenv("DISPLAY")); 0034 } 0035 0036 QString GreeterWrapper::lastLoggedInUser() const 0037 { 0038 //use suggested user from lightdm.conf if they exist, otherwise load from local config file of last logged in user. 0039 //if nothing exists, return nothing 0040 if (selectGuestHint()) { 0041 return "*guest"; 0042 } 0043 if (!selectUserHint().isEmpty()) { 0044 return selectUserHint(); 0045 } 0046 0047 return m_configGroup.readEntry("lastUser"); 0048 } 0049 0050 QString GreeterWrapper::guestLoginName() const 0051 { 0052 return QLatin1String("*guest"); 0053 } 0054 0055 bool GreeterWrapper::startSessionSync(const QString &session) 0056 { 0057 Q_EMIT aboutToLogin(); 0058 saveLastUser(authenticationUser()); 0059 return QLightDM::Greeter::startSessionSync(session); 0060 } 0061 0062 void GreeterWrapper::saveLastUser(const QString &user) 0063 { 0064 m_configGroup.writeEntry("lastUser", user); 0065 //force a sync as our greeter gets killed 0066 m_configGroup.sync(); 0067 }