|
Lines 51-62
static void signalHandler(int signum)
Link Here
|
| 51 |
|
51 |
|
| 52 |
int main(int argc, char* argv[]) |
52 |
int main(int argc, char* argv[]) |
| 53 |
{ |
53 |
{ |
|
|
54 |
int retcode = 0; |
| 55 |
bool again = false; |
| 56 |
do { |
| 54 |
KLocalizedString::setApplicationDomain("kscreenlocker_greet"); |
57 |
KLocalizedString::setApplicationDomain("kscreenlocker_greet"); |
| 55 |
|
58 |
|
| 56 |
// explicitly disable input methods as it makes it impossible to unlock, see BUG 306932 |
59 |
// explicitly disable input methods as it makes it impossible to unlock, see BUG 306932 |
| 57 |
// but explicitly set on screen keyboard such as maliit is allowed |
60 |
// but explicitly set on screen keyboard such as maliit is allowed |
| 58 |
if (qgetenv("QT_IM_MODULE") != QByteArrayLiteral("maliit")) { |
61 |
if (qgetenv("QT_IM_MODULE") != QByteArrayLiteral("maliit")) { |
| 59 |
qputenv("QT_IM_MODULE", QByteArrayLiteral("compose")); |
62 |
qputenv("QT_IM_MODULE", QByteArrayLiteral("compose")); |
| 60 |
} |
63 |
} |
| 61 |
ScreenLocker::UnlockApp app(argc, argv); |
64 |
ScreenLocker::UnlockApp app(argc, argv); |
| 62 |
app.setQuitOnLastWindowClosed(false); |
65 |
app.setQuitOnLastWindowClosed(false); |
|
Lines 66-72
int main(int argc, char* argv[])
Link Here
|
| 66 |
|
69 |
|
| 67 |
// disable session management for the greeter |
70 |
// disable session management for the greeter |
| 68 |
auto disableSessionManagement = [](QSessionManager &sm) { |
71 |
auto disableSessionManagement = [](QSessionManager &sm) { |
| 69 |
sm.setRestartHint(QSessionManager::RestartNever); |
72 |
sm.setRestartHint(QSessionManager::RestartNever); |
| 70 |
}; |
73 |
}; |
| 71 |
QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); |
74 |
QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); |
| 72 |
QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); |
75 |
QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); |
|
Lines 77-94
int main(int argc, char* argv[])
Link Here
|
| 77 |
parser.addVersionOption(); |
80 |
parser.addVersionOption(); |
| 78 |
|
81 |
|
| 79 |
QCommandLineOption testingOption(QStringLiteral("testing"), |
82 |
QCommandLineOption testingOption(QStringLiteral("testing"), |
| 80 |
i18n("Starts the greeter in testing mode")); |
83 |
i18n("Starts the greeter in testing mode")); |
| 81 |
QCommandLineOption immediateLockOption(QStringLiteral("immediateLock"), |
84 |
QCommandLineOption immediateLockOption(QStringLiteral("immediateLock"), |
| 82 |
i18n("Lock immediately, ignoring any grace time etc.")); |
85 |
i18n("Lock immediately, ignoring any grace time etc.")); |
| 83 |
QCommandLineOption graceTimeOption(QStringLiteral("graceTime"), |
86 |
QCommandLineOption graceTimeOption(QStringLiteral("graceTime"), |
| 84 |
i18n("Delay till the lock user interface gets shown in milliseconds."), |
87 |
i18n("Delay till the lock user interface gets shown in milliseconds."), |
| 85 |
QStringLiteral("milliseconds"), |
88 |
QStringLiteral("milliseconds"), |
| 86 |
QStringLiteral("0")); |
89 |
QStringLiteral("0")); |
| 87 |
QCommandLineOption nolockOption(QStringLiteral("nolock"), |
90 |
QCommandLineOption nolockOption(QStringLiteral("nolock"), |
| 88 |
i18n("Don't show any lock user interface.")); |
91 |
i18n("Don't show any lock user interface.")); |
| 89 |
QCommandLineOption waylandFdOption(QStringLiteral("ksldfd"), |
92 |
QCommandLineOption waylandFdOption(QStringLiteral("ksldfd"), |
| 90 |
i18n("File descriptor for connecting to ksld."), |
93 |
i18n("File descriptor for connecting to ksld."), |
| 91 |
QStringLiteral("fd")); |
94 |
QStringLiteral("fd")); |
| 92 |
|
95 |
|
| 93 |
parser.addOption(testingOption); |
96 |
parser.addOption(testingOption); |
| 94 |
parser.addOption(immediateLockOption); |
97 |
parser.addOption(immediateLockOption); |
|
Lines 98-122
int main(int argc, char* argv[])
Link Here
|
| 98 |
parser.process(app); |
101 |
parser.process(app); |
| 99 |
|
102 |
|
| 100 |
if (parser.isSet(testingOption)) { |
103 |
if (parser.isSet(testingOption)) { |
| 101 |
app.setTesting(true); |
104 |
app.setTesting(true); |
| 102 |
app.setImmediateLock(true); |
105 |
app.setImmediateLock(true); |
| 103 |
} else { |
106 |
} else { |
| 104 |
app.setImmediateLock(parser.isSet(immediateLockOption)); |
107 |
app.setImmediateLock(parser.isSet(immediateLockOption)); |
| 105 |
} |
108 |
} |
| 106 |
app.setNoLock(parser.isSet(nolockOption)); |
109 |
app.setNoLock(parser.isSet(nolockOption)); |
| 107 |
|
110 |
|
| 108 |
bool ok = false; |
111 |
bool ok = false; |
| 109 |
int graceTime = parser.value(graceTimeOption).toInt(&ok); |
112 |
int graceTime = parser.value(graceTimeOption).toInt(&ok); |
| 110 |
if (ok) { |
113 |
if (ok) { |
| 111 |
app.setGraceTime(graceTime); |
114 |
app.setGraceTime(graceTime); |
| 112 |
} |
115 |
} |
| 113 |
|
116 |
|
| 114 |
if (parser.isSet(waylandFdOption)) { |
117 |
if (parser.isSet(waylandFdOption)) { |
| 115 |
ok = false; |
118 |
ok = false; |
| 116 |
const int fd = parser.value(waylandFdOption).toInt(&ok); |
119 |
const int fd = parser.value(waylandFdOption).toInt(&ok); |
| 117 |
if (ok) { |
120 |
if (ok) { |
| 118 |
app.setKsldSocket(fd); |
121 |
app.setKsldSocket(fd); |
| 119 |
} |
122 |
} |
| 120 |
} |
123 |
} |
| 121 |
app.desktopResized(); |
124 |
app.desktopResized(); |
| 122 |
|
125 |
|
|
Lines 124-134
int main(int argc, char* argv[])
Link Here
|
| 124 |
// Crucial for blocking until it is ready, ensuring locking happens before sleep, e.g. |
127 |
// Crucial for blocking until it is ready, ensuring locking happens before sleep, e.g. |
| 125 |
std::cout << "Locked at " << QDateTime::currentDateTime().toTime_t() << std::endl; |
128 |
std::cout << "Locked at " << QDateTime::currentDateTime().toTime_t() << std::endl; |
| 126 |
|
129 |
|
| 127 |
struct sigaction sa; |
130 |
if (!again) { |
| 128 |
sa.sa_handler = signalHandler; |
131 |
struct sigaction sa; |
| 129 |
sigemptyset(&sa.sa_mask); |
132 |
sa.sa_handler = signalHandler; |
| 130 |
sa.sa_flags = SA_RESTART; |
133 |
sigemptyset(&sa.sa_mask); |
| 131 |
sigaction(SIGTERM, &sa, nullptr); |
134 |
sa.sa_flags = SA_RESTART; |
| 132 |
sigaction(SIGUSR1, &sa, nullptr); |
135 |
sigaction(SIGTERM, &sa, nullptr); |
| 133 |
return app.exec(); |
136 |
sigaction(SIGUSR1, &sa, nullptr); |
|
|
137 |
again = true; |
| 138 |
} |
| 139 |
else { |
| 140 |
app.lockImmediately(); |
| 141 |
} |
| 142 |
|
| 143 |
retcode = app.exec(); |
| 144 |
} while (retcode == 123); |
| 145 |
|
| 146 |
return retcode; |
| 134 |
} |
147 |
} |