Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Discover
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
Discover
Commits
45cea4fc
Commit
45cea4fc
authored
Dec 19, 2017
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delay the reboot notification after the update transaction has finished
parent
4a072216
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
22 deletions
+33
-22
libdiscover/backends/PackageKitBackend/PackageKitNotifier.cpp
...iscover/backends/PackageKitBackend/PackageKitNotifier.cpp
+32
-22
libdiscover/backends/PackageKitBackend/PackageKitNotifier.h
libdiscover/backends/PackageKitBackend/PackageKitNotifier.h
+1
-0
No files found.
libdiscover/backends/PackageKitBackend/PackageKitNotifier.cpp
View file @
45cea4fc
...
...
@@ -203,6 +203,9 @@ void PackageKitNotifier::transactionListChanged(const QStringList& tids)
auto
t
=
new
PackageKit
::
Transaction
(
QDBusObjectPath
(
tid
));
connect
(
t
,
&
PackageKit
::
Transaction
::
requireRestart
,
this
,
&
PackageKitNotifier
::
onRequireRestart
);
connect
(
t
,
&
PackageKit
::
Transaction
::
finished
,
this
,
[
this
,
t
](){
auto
restart
=
t
->
property
(
"requireRestart"
);
if
(
!
restart
.
isNull
())
requireRestartNotification
(
PackageKit
::
Transaction
::
Restart
(
restart
.
toInt
()));
m_transactions
.
remove
(
t
->
tid
().
path
());
t
->
deleteLater
();
});
...
...
@@ -212,30 +215,37 @@ void PackageKitNotifier::transactionListChanged(const QStringList& tids)
void
PackageKitNotifier
::
onRequireRestart
(
PackageKit
::
Transaction
::
Restart
type
,
const
QString
&
packageID
)
{
if
(
type
==
PackageKit
::
Transaction
::
RestartSystem
||
type
==
PackageKit
::
Transaction
::
RestartSession
)
{
KNotification
*
notification
=
new
KNotification
(
QLatin1String
(
"notification"
),
KNotification
::
Persistent
|
KNotification
::
DefaultEvent
);
notification
->
setIconName
(
QStringLiteral
(
"system-software-update"
));
if
(
type
==
PackageKit
::
Transaction
::
RestartSystem
)
{
notification
->
setActions
(
QStringList
{
QLatin1String
(
"Restart"
)});
notification
->
setTitle
(
i18n
(
"Restart is required"
));
notification
->
setText
(
i18n
(
"The computer will have to be restarted after the update for the changes to take effect."
));
}
else
{
notification
->
setActions
(
QStringList
{
QLatin1String
(
"Logout"
)});
notification
->
setTitle
(
i18n
(
"Session restart is required"
));
notification
->
setText
(
i18n
(
"You will need to log out and back in after the update for the changes to take effect."
));
}
PackageKit
::
Transaction
*
t
=
qobject_cast
<
PackageKit
::
Transaction
*>
(
sender
());
t
->
setProperty
(
"requireRestart"
,
qMax
<
int
>
(
t
->
property
(
"requireRestart"
).
toInt
(),
type
));
qDebug
()
<<
"RESTART"
<<
type
<<
"is required for package"
<<
packageID
;
}
connect
(
notification
,
&
KNotification
::
action1Activated
,
this
,
[
type
]
()
{
QDBusInterface
interface
(
QStringLiteral
(
"org.kde.ksmserver"
),
QStringLiteral
(
"/KSMServer"
),
QStringLiteral
(
"org.kde.KSMServerInterface"
),
QDBusConnection
::
sessionBus
());
if
(
type
==
PackageKit
::
Transaction
::
RestartSystem
)
{
interface
.
asyncCall
(
QStringLiteral
(
"logout"
),
0
,
1
,
2
);
// Options: do not ask again | reboot | force
}
else
{
interface
.
asyncCall
(
QStringLiteral
(
"logout"
),
0
,
0
,
2
);
// Options: do not ask again | logout | force
}
});
void
PackageKitNotifier
::
requireRestartNotification
(
PackageKit
::
Transaction
::
Restart
type
)
{
if
(
type
<
PackageKit
::
Transaction
::
RestartSession
)
{
return
;
}
notification
->
sendEvent
();
KNotification
*
notification
=
new
KNotification
(
QLatin1String
(
"notification"
),
KNotification
::
Persistent
|
KNotification
::
DefaultEvent
);
notification
->
setIconName
(
QStringLiteral
(
"system-software-update"
));
if
(
type
==
PackageKit
::
Transaction
::
RestartSystem
||
type
==
PackageKit
::
Transaction
::
RestartSecuritySystem
)
{
notification
->
setActions
(
QStringList
{
QLatin1String
(
"Restart"
)});
notification
->
setTitle
(
i18n
(
"Restart is required"
));
notification
->
setText
(
i18n
(
"The system needs to be restarted for the updates to take effect."
));
}
else
{
notification
->
setActions
(
QStringList
{
QLatin1String
(
"Logout"
)});
notification
->
setTitle
(
i18n
(
"Session restart is required"
));
notification
->
setText
(
i18n
(
"You will need to log out and back in for the update to take effect."
));
}
qDebug
()
<<
"RESTART"
<<
type
<<
"is required for package"
<<
packageID
;
connect
(
notification
,
&
KNotification
::
action1Activated
,
this
,
[
type
]
()
{
QDBusInterface
interface
(
QStringLiteral
(
"org.kde.ksmserver"
),
QStringLiteral
(
"/KSMServer"
),
QStringLiteral
(
"org.kde.KSMServerInterface"
),
QDBusConnection
::
sessionBus
());
if
(
type
==
PackageKit
::
Transaction
::
RestartSystem
)
{
interface
.
asyncCall
(
QStringLiteral
(
"logout"
),
0
,
1
,
2
);
// Options: do not ask again | reboot | force
}
else
{
interface
.
asyncCall
(
QStringLiteral
(
"logout"
),
0
,
0
,
2
);
// Options: do not ask again | logout | force
}
});
notification
->
sendEvent
();
}
libdiscover/backends/PackageKitBackend/PackageKitNotifier.h
View file @
45cea4fc
...
...
@@ -51,6 +51,7 @@ private Q_SLOTS:
void
onDistroUpgrade
(
PackageKit
::
Transaction
::
DistroUpgrade
type
,
const
QString
&
name
,
const
QString
&
description
);
private:
void
requireRestartNotification
(
PackageKit
::
Transaction
::
Restart
type
);
QProcess
*
checkAptVariable
(
const
QString
&
aptconfig
,
const
QLatin1String
&
varname
,
std
::
function
<
void
(
const
QStringRef
&
val
)
>
func
);
uint
m_securityUpdates
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment