Коммит 06acf6c5 создал по автору vmkspv's avatar vmkspv
Просмотр файлов

Added expiration tracker

владелец 84ce888c
......@@ -19,8 +19,14 @@ Item {
property string certOwner: ""
property string issueDate: ""
property string expiryDate: ""
property int daysUntilExpiry: 0
property int busyCounter: 0
readonly property bool busy: busyCounter != 0
property bool notificationShown: false
property var notificationSource: PlasmaCore.DataSource {
engine: "notifications"
connectedSources: ["notifications"]
}
PlasmaCore.DataSource {
id: executeSource
......@@ -49,6 +55,8 @@ Item {
let expiryMatch = stdout.match(/Истекает\s*:\s*(.+)/)
expiryDate = expiryMatch ? expiryMatch[1] : ""
checkExpiryDate()
disconnectSource(sourceName)
} else {
updateAll()
......@@ -361,6 +369,41 @@ Item {
}
}
function checkExpiryDate() {
if (!expiryDate) {
return;
}
let [datePart, timePart] = expiryDate.split(' ');
let [day, month, year] = datePart.split('/');
let [hours, minutes, seconds] = timePart.split(':');
let expiryTime = new Date(year, month - 1, day, hours, minutes, seconds);
let currentTime = new Date();
daysUntilExpiry = Math.ceil((expiryTime - currentTime) / (1000 * 60 * 60 * 24));
if (!notificationShown && daysUntilExpiry <= 30 && daysUntilExpiry > 0) {
showExpiryNotification();
notificationShown = true;
}
}
function showExpiryNotification() {
var service = notificationSource.serviceForSource("notifications");
var operation = service.operationDescription("createNotification");
operation.appName = "Управление КриптоПро";
operation.appIcon = "document-edit-encrypt";
operation.summary = i18n("Сертификат скоро истекает");
operation.body = i18n("Ваш сертификат ЭП истекает через %1 дней", daysUntilExpiry);
operation.eventId = "certExpiry";
operation.persistent = true;
operation.urgency = 2;
service.startOperationCall(operation);
}
Timer {
id: certCheckTimer
interval: 2000
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать