Changeset View
Changeset View
Standalone View
Standalone View
greeter/greeterapp.cpp
Show All 13 Lines | |||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
17 | 17 | | |||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "greeterapp.h" | 21 | #include "greeterapp.h" | ||
22 | #include "greeteradapter.h" | ||||
22 | #include "kscreensaversettingsbase.h" | 23 | #include "kscreensaversettingsbase.h" | ||
23 | #include "authenticator.h" | 24 | #include "authenticator.h" | ||
24 | #include "noaccessnetworkaccessmanagerfactory.h" | 25 | #include "noaccessnetworkaccessmanagerfactory.h" | ||
25 | #include "wallpaper_integration.h" | 26 | #include "wallpaper_integration.h" | ||
26 | #include "lnf_integration.h" | 27 | #include "lnf_integration.h" | ||
28 | #include "notifications.h" | ||||
27 | 29 | | |||
28 | #include <config-kscreenlocker.h> | 30 | #include <config-kscreenlocker.h> | ||
29 | 31 | | |||
30 | // KDE | 32 | // KDE | ||
31 | #include <KAuthorized> | 33 | #include <KAuthorized> | ||
32 | #include <KCrash> | 34 | #include <KCrash> | ||
33 | #include <kdeclarative/kdeclarative.h> | 35 | #include <kdeclarative/kdeclarative.h> | ||
34 | #include <KDeclarative/KQuickAddons/QuickViewSharedEngine> | 36 | #include <KDeclarative/KQuickAddons/QuickViewSharedEngine> | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 116 | UnlockApp::UnlockApp(int &argc, char **argv) | |||
118 | , m_testing(false) | 120 | , m_testing(false) | ||
119 | , m_ignoreRequests(false) | 121 | , m_ignoreRequests(false) | ||
120 | , m_immediateLock(false) | 122 | , m_immediateLock(false) | ||
121 | , m_graceTime(0) | 123 | , m_graceTime(0) | ||
122 | , m_noLock(false) | 124 | , m_noLock(false) | ||
123 | , m_defaultToSwitchUser(false) | 125 | , m_defaultToSwitchUser(false) | ||
124 | , m_wallpaperIntegration(new WallpaperIntegration(this)) | 126 | , m_wallpaperIntegration(new WallpaperIntegration(this)) | ||
125 | , m_lnfIntegration(new LnFIntegration(this)) | 127 | , m_lnfIntegration(new LnFIntegration(this)) | ||
128 | , m_notification(new Notifications(this)) | ||||
126 | { | 129 | { | ||
127 | m_authenticator = createAuthenticator(); | 130 | m_authenticator = createAuthenticator(); | ||
128 | connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); | 131 | connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); | ||
129 | initialize(); | 132 | initialize(); | ||
130 | connect(this, &UnlockApp::screenAdded, this, &UnlockApp::desktopResized); | 133 | connect(this, &UnlockApp::screenAdded, this, &UnlockApp::desktopResized); | ||
131 | connect(this, &UnlockApp::screenRemoved, this, &UnlockApp::desktopResized); | 134 | connect(this, &UnlockApp::screenRemoved, this, &UnlockApp::desktopResized); | ||
132 | 135 | | |||
133 | if (QX11Info::isPlatformX11()) { | 136 | if (QX11Info::isPlatformX11()) { | ||
134 | installNativeEventFilter(new FocusOutEventFilter); | 137 | installNativeEventFilter(new FocusOutEventFilter); | ||
135 | } | 138 | } | ||
139 | | ||||
140 | (void) new GreeterAdapter(this); | ||||
141 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/Greeter"), this); | ||||
davidedmundson: Register objects before registering a service.
DBus receiving is in another thread so you… | |||||
142 | QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.screensaver.Greeter")); | ||||
136 | } | 143 | } | ||
137 | 144 | | |||
138 | UnlockApp::~UnlockApp() | 145 | UnlockApp::~UnlockApp() | ||
139 | { | 146 | { | ||
140 | //workaround QTBUG-55460 | 147 | //workaround QTBUG-55460 | ||
141 | //will be fixed when themes port to QQC2 | 148 | //will be fixed when themes port to QQC2 | ||
142 | for (auto view: qAsConst(m_views)) { | 149 | for (auto view: qAsConst(m_views)) { | ||
143 | if (QQuickItem *focusItem = view->activeFocusItem()) { | 150 | if (QQuickItem *focusItem = view->activeFocusItem()) { | ||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Line(s) | 306 | for (int i = m_views.count(); i < nScreens; ++i) { | |||
335 | 342 | | |||
336 | context->setContextProperty(QStringLiteral("kscreenlocker_userName"), m_userName); | 343 | context->setContextProperty(QStringLiteral("kscreenlocker_userName"), m_userName); | ||
337 | context->setContextProperty(QStringLiteral("kscreenlocker_userImage"), m_userImage); | 344 | context->setContextProperty(QStringLiteral("kscreenlocker_userImage"), m_userImage); | ||
338 | context->setContextProperty(QStringLiteral("authenticator"), m_authenticator); | 345 | context->setContextProperty(QStringLiteral("authenticator"), m_authenticator); | ||
339 | context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_interfaceVersion"), 2); | 346 | context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_interfaceVersion"), 2); | ||
340 | context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_view"), view); | 347 | context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_view"), view); | ||
341 | context->setContextProperty(QStringLiteral("defaultToSwitchUser"), m_defaultToSwitchUser); | 348 | context->setContextProperty(QStringLiteral("defaultToSwitchUser"), m_defaultToSwitchUser); | ||
342 | context->setContextProperty(QStringLiteral("config"), m_lnfIntegration->configuration()); | 349 | context->setContextProperty(QStringLiteral("config"), m_lnfIntegration->configuration()); | ||
350 | context->setContextProperty(QStringLiteral("notifications"), m_notification); | ||||
343 | 351 | | |||
344 | view->setSource(m_mainQmlPath); | 352 | view->setSource(m_mainQmlPath); | ||
345 | // on error, load the fallback lockscreen to not lock the user out of the system | 353 | // on error, load the fallback lockscreen to not lock the user out of the system | ||
346 | if (view->status() != QQmlComponent::Ready) { | 354 | if (view->status() != QQmlComponent::Ready) { | ||
347 | static const QUrl fallbackUrl(QUrl(QStringLiteral("qrc:/fallbacktheme/LockScreen.qml"))); | 355 | static const QUrl fallbackUrl(QUrl(QStringLiteral("qrc:/fallbacktheme/LockScreen.qml"))); | ||
348 | 356 | | |||
349 | qWarning() << "Failed to load lockscreen QML, falling back to built-in locker"; | 357 | qWarning() << "Failed to load lockscreen QML, falling back to built-in locker"; | ||
350 | m_mainQmlPath = fallbackUrl; | 358 | m_mainQmlPath = fallbackUrl; | ||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 480 | { | |||
474 | m_delayedLockTimer = nullptr; | 482 | m_delayedLockTimer = nullptr; | ||
475 | 483 | | |||
476 | for (KQuickAddons::QuickViewSharedEngine *view : qAsConst(m_views)) { | 484 | for (KQuickAddons::QuickViewSharedEngine *view : qAsConst(m_views)) { | ||
477 | QQmlProperty lockProperty(view->rootObject(), QStringLiteral("locked")); | 485 | QQmlProperty lockProperty(view->rootObject(), QStringLiteral("locked")); | ||
478 | lockProperty.write(true); | 486 | lockProperty.write(true); | ||
479 | } | 487 | } | ||
480 | } | 488 | } | ||
481 | 489 | | |||
490 | void UnlockApp::Notify(uint id, const QString &app_name, uint replaces_id, const QString &app_icon, | ||||
491 | const QString &summary, const QString &body, const QStringList &actions, | ||||
492 | const QVariantMap &hints, int timeout) | ||||
493 | { | ||||
494 | if (!m_notification) { | ||||
495 | return; | ||||
496 | } | ||||
497 | // trigger signal notification of the ScreenLocker::Notifications object | ||||
498 | Q_EMIT m_notification->notification(id, app_name, replaces_id, app_icon, summary, body, actions, hints, timeout); | ||||
499 | } | ||||
500 | | ||||
This pattern of fetching and poking the root object of a scene isn't one I like, it's better to expose an object to the view that then has normal signals and slots - but this does follow the convention already here, so I can't really object. davidedmundson: This pattern of fetching and poking the root object of a scene isn't one I like, it's better to… | |||||
Let's add a todo for future? Once this is done, I do have plan to change the OSD bit to also use greeter directly, instead of wayland protocol bit. That time I can update that. bshah: Let's add a todo for future? Once this is done, I do have plan to change the OSD bit to also… | |||||
501 | void UnlockApp::CloseNotification(uint id) | ||||
502 | { | ||||
503 | if (!m_notification) { | ||||
504 | return; | ||||
505 | } | ||||
506 | Q_EMIT m_notification->closeNotification(id); | ||||
507 | } | ||||
508 | | ||||
482 | void UnlockApp::resetRequestIgnore() | 509 | void UnlockApp::resetRequestIgnore() | ||
483 | { | 510 | { | ||
484 | m_ignoreRequests = false; | 511 | m_ignoreRequests = false; | ||
485 | } | 512 | } | ||
486 | 513 | | |||
487 | void UnlockApp::suspendToRam() | 514 | void UnlockApp::suspendToRam() | ||
488 | { | 515 | { | ||
489 | if (m_ignoreRequests) { | 516 | if (m_ignoreRequests) { | ||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |
Register objects before registering a service.
DBus receiving is in another thread so you could hypothetically get a message between the two events.
Doesn't really matter if we lose a notification in this case, but it's a good practice