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
5ac9d0b7
Commit
5ac9d0b7
authored
Dec 19, 2017
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a persistant notification when pk says a reboot is required
BUG: 387211
parent
e8923e97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
5 deletions
+58
-5
libdiscover/backends/PackageKitBackend/CMakeLists.txt
libdiscover/backends/PackageKitBackend/CMakeLists.txt
+2
-2
libdiscover/backends/PackageKitBackend/PackageKitNotifier.cpp
...iscover/backends/PackageKitBackend/PackageKitNotifier.cpp
+51
-2
libdiscover/backends/PackageKitBackend/PackageKitNotifier.h
libdiscover/backends/PackageKitBackend/PackageKitNotifier.h
+5
-1
No files found.
libdiscover/backends/PackageKitBackend/CMakeLists.txt
View file @
5ac9d0b7
find_package
(
KF5
Archive REQUIRED
)
find_package
(
KF5
REQUIRED Notifications
)
add_subdirectory
(
runservice
)
...
...
@@ -25,7 +25,7 @@ install(TARGETS packagekit-backend DESTINATION ${PLUGIN_INSTALL_DIR}/discover)
#notifier
add_library
(
DiscoverPackageKitNotifier MODULE PackageKitNotifier.cpp
)
target_link_libraries
(
DiscoverPackageKitNotifier PRIVATE PK::packagekitqt5 Discover::Notifiers
)
target_link_libraries
(
DiscoverPackageKitNotifier PRIVATE PK::packagekitqt5 Discover::Notifiers
KF5::I18n KF5::Notifications
)
set_target_properties
(
DiscoverPackageKitNotifier PROPERTIES INSTALL_RPATH
${
CMAKE_INSTALL_FULL_LIBDIR
}
/plasma-discover
)
install
(
TARGETS DiscoverPackageKitNotifier DESTINATION
${
PLUGIN_INSTALL_DIR
}
/discover-notifier
)
...
...
libdiscover/backends/PackageKitBackend/PackageKitNotifier.cpp
View file @
5ac9d0b7
...
...
@@ -27,7 +27,10 @@
#include <QProcess>
#include <QTextStream>
#include <QDebug>
#include <KNotification>
#include <PackageKit/Daemon>
#include <QDBusInterface>
#include <KLocalizedString>
PackageKitNotifier
::
PackageKitNotifier
(
QObject
*
parent
)
:
BackendNotifierModule
(
parent
)
...
...
@@ -40,13 +43,13 @@ PackageKitNotifier::PackageKitNotifier(QObject* parent)
connect
(
PackageKit
::
Daemon
::
global
(),
&
PackageKit
::
Daemon
::
networkStateChanged
,
this
,
&
PackageKitNotifier
::
recheckSystemUpdateNeeded
);
connect
(
PackageKit
::
Daemon
::
global
(),
&
PackageKit
::
Daemon
::
updatesChanged
,
this
,
&
PackageKitNotifier
::
recheckSystemUpdateNeeded
);
connect
(
PackageKit
::
Daemon
::
global
(),
&
PackageKit
::
Daemon
::
isRunningChanged
,
this
,
&
PackageKitNotifier
::
recheckSystemUpdateNeeded
);
connect
(
PackageKit
::
Daemon
::
global
(),
&
PackageKit
::
Daemon
::
transactionListChanged
,
this
,
&
PackageKitNotifier
::
transactionListChanged
);
//Check if there's packages after 5'
QTimer
::
singleShot
(
5
*
60
*
1000
,
this
,
&
PackageKitNotifier
::
refreshDatabase
);
int
interval
=
24
*
60
*
60
*
1000
;
QTimer
*
regularCheck
=
new
QTimer
(
this
);
regularCheck
->
setInterval
(
interval
);
//refresh at least once every day
regularCheck
->
setInterval
(
24
*
60
*
60
*
1000
);
//refresh at least once every day
connect
(
regularCheck
,
&
QTimer
::
timeout
,
this
,
&
PackageKitNotifier
::
refreshDatabase
);
const
QString
aptconfig
=
QStandardPaths
::
findExecutable
(
QStringLiteral
(
"apt-config"
));
...
...
@@ -158,3 +161,49 @@ QProcess* PackageKitNotifier::checkAptVariable(const QString &aptconfig, const Q
connect
(
process
,
static_cast
<
void
(
QProcess
::*
)(
int
)
>
(
&
QProcess
::
finished
),
process
,
&
QObject
::
deleteLater
);
return
process
;
}
void
PackageKitNotifier
::
transactionListChanged
(
const
QStringList
&
tids
)
{
for
(
const
auto
&
tid
:
tids
)
{
if
(
m_transactions
.
contains
(
tid
))
continue
;
auto
t
=
new
PackageKit
::
Transaction
(
QDBusObjectPath
(
tid
));
connect
(
t
,
&
PackageKit
::
Transaction
::
requireRestart
,
this
,
&
PackageKitNotifier
::
onRequireRestart
);
connect
(
t
,
&
PackageKit
::
Transaction
::
finished
,
this
,
[
this
,
t
](){
m_transactions
.
remove
(
t
->
tid
().
path
());
t
->
deleteLater
();
});
m_transactions
.
insert
(
tid
,
t
);
}
}
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."
));
}
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
();
}
qDebug
()
<<
"RESTART"
<<
type
<<
"is required for package"
<<
packageID
;
}
libdiscover/backends/PackageKitBackend/PackageKitNotifier.h
View file @
5ac9d0b7
...
...
@@ -46,13 +46,17 @@ public:
private
Q_SLOTS
:
void
package
(
PackageKit
::
Transaction
::
Info
info
,
const
QString
&
packageID
,
const
QString
&
summary
);
void
finished
(
PackageKit
::
Transaction
::
Exit
exit
,
uint
);
void
onRequireRestart
(
PackageKit
::
Transaction
::
Restart
type
,
const
QString
&
packageID
);
void
transactionListChanged
(
const
QStringList
&
tids
);
private:
QProcess
*
checkAptVariable
(
const
QString
&
aptconfig
,
const
QLatin1String
&
varname
,
std
::
function
<
void
(
const
QStringRef
&
val
)
>
func
);
uint
m_securityUpdates
;
uint
m_normalUpdates
;
QPointer
<
PackageKit
::
Transaction
>
m_refresher
;
QHash
<
QString
,
PackageKit
::
Transaction
*>
m_transactions
;
};
#endif
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