Skip to content

Commit

Permalink
Merge branch 'jb49966' into 'master'
Browse files Browse the repository at this point in the history
[lipstick] Support for detecting failed user changed. Contributes to JB#49966

See merge request mer-core/lipstick!143
  • Loading branch information
kende committed Jul 1, 2020
2 parents 64a3358 + 5f51997 commit 6c7bc76
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/devicestate/devicestate.cpp
Expand Up @@ -184,11 +184,17 @@ void DeviceState::connectUserManager()
{
Q_D(DeviceState);
QDBusConnection::systemBus().connect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
d,
SLOT(emitUserSwitching(uint)));
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
d,
SLOT(emitUserSwitching(uint)));
QDBusConnection::systemBus().connect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"currentUserChangeFailed",
d,
SLOT(emitUserSwitchingFailed(uint)));
}

void DeviceState::disconnectUserManager()
Expand All @@ -199,7 +205,13 @@ void DeviceState::disconnectUserManager()
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
d,
SLOT(emitUserChanging(uint)));
SLOT(emitUserSwitching(uint)));
QDBusConnection::systemBus().disconnect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"currentUserChangeFailed",
d,
SLOT(emitUserSwitchingFailed(uint)));
}

} // DeviceState namespace
3 changes: 2 additions & 1 deletion src/devicestate/devicestate.h
Expand Up @@ -67,7 +67,8 @@ class DeviceState : public QObject
RebootDeniedUSB, //!< Reboot denied because USB is connected in mass storage mode
ShutdownDeniedUSB, //!< Shutdown denied because USB is connected in mass storage mode
Reboot, //!< Reboot
UserSwitching //!< User switching
UserSwitching, //!< User switching
UserSwitchingFailed //!< User switching failed
};

public:
Expand Down
5 changes: 5 additions & 0 deletions src/devicestate/devicestate_p.h
Expand Up @@ -107,6 +107,11 @@ namespace DeviceState
emit nextUserChanged(uid);
emit systemStateChanged(DeviceState::UserSwitching);
}

void emitUserSwitchingFailed(uint uid) {
Q_UNUSED(uid)
emit systemStateChanged(DeviceState::UserSwitchingFailed);
}
};
}
#endif // DEVICESTATE_P_H
12 changes: 12 additions & 0 deletions src/shutdownscreen.cpp
Expand Up @@ -56,6 +56,7 @@ void ShutdownScreen::setWindowVisible(bool visible)
}

if (!m_window->isVisible()) {
m_window->setContextProperty("shutdownMode", m_shutdownMode);
m_window->show();
emit windowVisibleChanged();
}
Expand Down Expand Up @@ -107,6 +108,17 @@ void ShutdownScreen::applySystemState(DeviceState::DeviceState::StateIndication
applySystemState(DeviceState::DeviceState::Shutdown);
break;

case DeviceState::DeviceState::UserSwitchingFailed:
m_shutdownMode = "userswitchFailed";
m_window->setContextProperty("shutdownMode", m_shutdownMode);
emit userSwitchFailed();
QTimer::singleShot(10000, this, [this] {
// Allow for some time for the notification to be visible
setWindowVisible(false);
m_shutdownMode.clear();
});
break;

default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/shutdownscreen.h
Expand Up @@ -55,6 +55,8 @@ class LIPSTICK_EXPORT ShutdownScreen : public QObject, protected QDBusContext
signals:
//! Sent when the visibility of the window has changed.
void windowVisibleChanged();
//! Sent when user change has failed.
void userSwitchFailed();

private slots:
/*!
Expand Down

0 comments on commit 6c7bc76

Please sign in to comment.