Commit 8a104aa4 authored by Nate Graham's avatar Nate Graham
Browse files

Recommend rebooting after installing Samba

After Samba is installed, very frequently it will not work correctly until the machine is
rebooted. One potential reason is when the installed package has made group membership
changes, which only take effect after a reboot.

This patch implements a reboot recommendation along with a button to reboot the machine.
Both are shown immediately after Samba has been installed.

Because some expert users may understand the technical details of what's going on, the
reboot is only recommended, not required. If the window is closed and then re-opened,
the normal Samba sharing configuration UI is displayed instead of the reboot prompt.

Added a new function rather than using a Lambda because it may be useful for additional
purposes too (e.g.

FEATURE: 407845
FIXED-IN: 20.04.0

Test Plan: (not uploaded to Phab due to file size limit)

1. Remove Samba
2. Go to share a folder
3. Click "Install Samba"
4. After the installation has completed, click the "Restart" button and see that the machine reboots

5. Remove Samba again
2. Go to share a folder
3. Click "Install Samba"
4. Close the window and re-open it instead of rebooting as recommended
5. See that the Samba sharing config UI is all there

Reviewers: #vdg, #frameworks, #dolphin, apol, sitter

Reviewed By: sitter

Subscribers: anthonyfieroni, sitter, bruns

Differential Revision:
parent 55c6ab1d
...@@ -20,9 +20,12 @@ ...@@ -20,9 +20,12 @@
*/ */
#include <QDBusInterface>
#include <QDBusPendingReply>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QFileInfo> #include <QFileInfo>
#include <QFrame> #include <QFrame>
#include <QIcon>
#include <QPushButton> #include <QPushButton>
#include <QStandardPaths> #include <QStandardPaths>
#include <QStringList> #include <QStringList>
...@@ -95,6 +98,20 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant ...@@ -95,6 +98,20 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QList<QVariant
vLayout->addWidget(m_sambaStatusMessage); vLayout->addWidget(m_sambaStatusMessage);
m_justInstalledSambaWidgets = new QWidget(vbox);
QVBoxLayout *vJustInstalledLayout = new QVBoxLayout(m_justInstalledSambaWidgets);
vJustInstalledLayout->addWidget(new QLabel(i18n("Restart the computer to complete the installation."), m_justInstalledSambaWidgets));
m_restartButton = new QPushButton(i18n("Restart"), m_justInstalledSambaWidgets);
connect(m_restartButton, &QPushButton::clicked,
this, &SambaUserSharePlugin::reboot);
m_installSambaButton = new QPushButton(i18n("Install Samba"), m_installSambaWidgets); m_installSambaButton = new QPushButton(i18n("Install Samba"), m_installSambaWidgets);
m_installSambaButton->setDefault(false); m_installSambaButton->setDefault(false);
vLayout->addWidget(m_installSambaButton); vLayout->addWidget(m_installSambaButton);
...@@ -188,13 +205,20 @@ void SambaUserSharePlugin::packageFinished(PackageKit::Transaction::Exit status, ...@@ -188,13 +205,20 @@ void SambaUserSharePlugin::packageFinished(PackageKit::Transaction::Exit status,
if (status == PackageKit::Transaction::ExitSuccess) { if (status == PackageKit::Transaction::ExitSuccess) {
m_installSambaWidgets->hide(); m_installSambaWidgets->hide();
m_failedSambaWidgets->hide(); m_failedSambaWidgets->hide();
m_shareWidgets->show(); m_shareWidgets->hide();
} else { } else {
m_shareWidgets->hide(); m_shareWidgets->hide();
m_installSambaWidgets->hide(); m_installSambaWidgets->hide();
m_failedSambaWidgets->show(); m_failedSambaWidgets->show();
} }
} }
void SambaUserSharePlugin::reboot()
QDBusInterface interface(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QStringLiteral("org.kde.KSMServerInterface"), QDBusConnection::sessionBus());
interface.asyncCall(QStringLiteral("logout"), 0, 1, 2); // Options: do not ask again | reboot | force
void SambaUserSharePlugin::setupModel() void SambaUserSharePlugin::setupModel()
...@@ -59,6 +59,10 @@ private: ...@@ -59,6 +59,10 @@ private:
QLabel *m_sambaStatusMessage; QLabel *m_sambaStatusMessage;
QProgressBar *m_installProgress; QProgressBar *m_installProgress;
QPushButton *m_installSambaButton; QPushButton *m_installSambaButton;
QWidget *m_justInstalledSambaWidgets;
QPushButton *m_restartButton;
void setupModel(); void setupModel();
void setupViews(); void setupViews();
...@@ -69,6 +73,7 @@ private: ...@@ -69,6 +73,7 @@ private:
void installSamba(); void installSamba();
void packageFinished(PackageKit::Transaction::Exit status, uint runtime); void packageFinished(PackageKit::Transaction::Exit status, uint runtime);
void reboot();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment