Skip to content

Commit

Permalink
Merge pull request #62 from llewelld/jb57941
Browse files Browse the repository at this point in the history
 [sailfish-utilities] Add a Restart Fingerprint button. Fixes JB#57941
  • Loading branch information
llewelld authored Apr 23, 2022
2 parents 73be996 + da8ea3a commit c61c88e
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 6 deletions.
5 changes: 5 additions & 0 deletions plugin/utiltools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ void UtilTools::restartLipstick(QJSValue successCallback, QJSValue errorCallback
execute(SystemTool, QStringList("restart_lipstick"), successCallback, errorCallback);
}

void UtilTools::restartFingerprint(QJSValue successCallback, QJSValue errorCallback)
{
execute(SystemTool, QStringList("restart_fingerprint"), successCallback, errorCallback);
}

void UtilTools::handleProcessExit(int exitCode, QProcess::ExitStatus status)
{
QProcess *process = qobject_cast<QProcess*>(sender());
Expand Down
3 changes: 3 additions & 0 deletions plugin/utiltools.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class UtilTools: public QObject
Q_INVOKABLE void restartLipstick(QJSValue successCallback = QJSValue::UndefinedValue,
QJSValue errorCallback = QJSValue::UndefinedValue);

Q_INVOKABLE void restartFingerprint(QJSValue successCallback = QJSValue::UndefinedValue,
QJSValue errorCallback = QJSValue::UndefinedValue);

private slots:
void handleProcessExit(int exitCode, QProcess::ExitStatus status);

Expand Down
3 changes: 2 additions & 1 deletion qml/ActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Column {
plugins.append(info)
}
var names = [ "RestartNetwork", "RestartUI",
"CleanPackageCache", "CleanTracker" ]
"CleanPackageCache", "CleanTracker",
"RestartFingerprint"]
for (var i = 0; i < names.length; ++i)
justLoad(names[i])
}
Expand Down
19 changes: 19 additions & 0 deletions qml/plugins/RestartFingerprint.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Utilities 1.0

ActionItem {
//% "Fingerprint"
title: qsTrId("sailfish-tools-he-fingerprint")
//% "Restart"
actionName: qsTrId("sailfish-tools-bt-fingerprint_restart")
deviceLockRequired: false
//% "Restart fingerprint service. In some circumstancces this can "
//% "resolve issues where valid fingerprints are no longer being "
//% "recognised."
description: qsTrId("sailfish-utilities-restart-fingerprint_desc")

function action(on_reply, on_error) {
UtilTools.restartFingerprint(on_reply, on_error)
}
}
15 changes: 11 additions & 4 deletions sailfish-utilities.pro
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
TEMPLATE = aux

PROJECTS = qml plugin qml/plugins
PROJECTS = qml plugin qml/plugins tools

message($${PROJECTS})
OTHER_FILES += *.qml *.js
OTHER_FILES += *.qml *.js *.txt qmldir
HEADERS += *.h
SOURCES += *.cpp
for (PROJECT, PROJECTS) {
OTHER_FILES += $${PROJECT}/*.qml \
$${PROJECT}/*.js
$${PROJECT}/*.js \
$${PROJECT}/*.txt \
$${PROJECT}/qmldir \
$${PROJECT}/*.sh \
$${PROJECT}/*.in
HEADERS += $${PROJECT}/*.h
SOURCES += $${PROJECT}/*.cpp
}
j
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ install(PROGRAMS
restart_network.sh
restart_lipstick.sh
tracker_reindex.sh
restart_fingerprint.sh
DESTINATION share/sailfish-utilities
)
18 changes: 18 additions & 0 deletions tools/restart_fingerprint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

warning() {
printf "%s: Warning: %s\n" "$(basename $0)" "${@}" 1>&2;
}

service_do() {
if systemctl "$1" "$2"; then
return 0;
else
warning "Status $? on" "${@}"
return 1;
fi
}

service_do restart sailfish-fpd
sleep 3
service_do restart sailfish-fpd
5 changes: 4 additions & 1 deletion tools/sailfish_tools_system_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ std::map<std::string, action_type> actions = {
}},
{ "tracker_reindex", [](action_ctx const *) {
return execute_own_utility("tracker_reindex.sh");
}},
{ "restart_fingerprint", [](action_ctx const *) {
return execute_own_utility("restart_fingerprint.sh");
}}
};

std::set<std::string> root_actions = {
"repair_rpm_db", "restart_network"
"repair_rpm_db", "restart_network", "restart_fingerprint"
};

class BecomeRoot
Expand Down

0 comments on commit c61c88e

Please sign in to comment.