new notification events for nodejs packages info
This commit is contained in:
parent
f9d0607adf
commit
d21520f28a
10 changed files with 63 additions and 41 deletions
|
@ -26,7 +26,7 @@
|
||||||
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="4.1.2" date="2022-02-10"/>
|
<release version="4.1.2" date="2022-02-11"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "miscellaneous/iofactory.h"
|
#include "miscellaneous/iofactory.h"
|
||||||
#include "miscellaneous/mutex.h"
|
#include "miscellaneous/mutex.h"
|
||||||
#include "miscellaneous/nodejs.h"
|
|
||||||
#include "miscellaneous/notificationfactory.h"
|
#include "miscellaneous/notificationfactory.h"
|
||||||
#include "network-web/webfactory.h"
|
#include "network-web/webfactory.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
|
@ -91,6 +90,9 @@ Application::Application(const QString& id, int& argc, char** argv)
|
||||||
connect(this, &Application::commitDataRequest, this, &Application::onCommitData);
|
connect(this, &Application::commitDataRequest, this, &Application::onCommitData);
|
||||||
connect(this, &Application::saveStateRequest, this, &Application::onSaveState);
|
connect(this, &Application::saveStateRequest, this, &Application::onSaveState);
|
||||||
|
|
||||||
|
connect(m_nodejs, &NodeJs::packageError, this, &Application::onNodeJsPackageUpdateError);
|
||||||
|
connect(m_nodejs, &NodeJs::packageInstalledUpdated, this, &Application::onNodeJsPackageInstalled);
|
||||||
|
|
||||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||||
QString app_dir = QString::fromLocal8Bit(qgetenv("APPDIR"));
|
QString app_dir = QString::fromLocal8Bit(qgetenv("APPDIR"));
|
||||||
|
|
||||||
|
@ -132,7 +134,9 @@ Application::Application(const QString& id, int& argc, char** argv)
|
||||||
Notification(Notification::Event::NewUnreadArticlesFetched, true,
|
Notification(Notification::Event::NewUnreadArticlesFetched, true,
|
||||||
QSL("%1/notify.wav").arg(SOUNDS_BUILTIN_DIRECTORY)),
|
QSL("%1/notify.wav").arg(SOUNDS_BUILTIN_DIRECTORY)),
|
||||||
Notification(Notification::Event::NewAppVersionAvailable, true),
|
Notification(Notification::Event::NewAppVersionAvailable, true),
|
||||||
Notification(Notification::Event::LoginFailure, true)
|
Notification(Notification::Event::LoginFailure, true),
|
||||||
|
Notification(Notification::Event::NodePackageUpdated, true),
|
||||||
|
Notification(Notification::Event::NodePackageFailedToUpdate, true)
|
||||||
}, settings());
|
}, settings());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -141,8 +145,6 @@ Application::Application(const QString& id, int& argc, char** argv)
|
||||||
|
|
||||||
QTimer::singleShot(1000, system(), &SystemFactory::checkForUpdatesOnStartup);
|
QTimer::singleShot(1000, system(), &SystemFactory::checkForUpdatesOnStartup);
|
||||||
|
|
||||||
//nodejs()->installUpdatePackage({ "@cliqz/adblocker", ">=1.0.0 <2.0.0" });
|
|
||||||
|
|
||||||
qDebugNN << LOGSEC_CORE
|
qDebugNN << LOGSEC_CORE
|
||||||
<< "OpenSSL version:"
|
<< "OpenSSL version:"
|
||||||
<< QUOTE_W_SPACE_DOT(QSslSocket::sslLibraryVersionString());
|
<< QUOTE_W_SPACE_DOT(QSslSocket::sslLibraryVersionString());
|
||||||
|
@ -535,7 +537,13 @@ void Application::showGuiMessage(Notification::Event event,
|
||||||
SystemTrayIcon::isSystemTrayAreaAvailable() &&
|
SystemTrayIcon::isSystemTrayAreaAvailable() &&
|
||||||
notification.balloonEnabled() &&
|
notification.balloonEnabled() &&
|
||||||
dest.m_tray) {
|
dest.m_tray) {
|
||||||
trayIcon()->showMessage(msg.m_title, msg.m_message, msg.m_type, TRAY_ICON_BUBBLE_TIMEOUT, std::move(action.m_action));
|
trayIcon()->showMessage(msg.m_title.simplified().isEmpty()
|
||||||
|
? Notification::nameForEvent(notification.event())
|
||||||
|
: msg.m_title,
|
||||||
|
msg.m_message,
|
||||||
|
msg.m_type,
|
||||||
|
TRAY_ICON_BUBBLE_TIMEOUT,
|
||||||
|
std::move(action.m_action));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,6 +847,24 @@ void Application::parseCmdArgumentsFromMyInstance() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::onNodeJsPackageUpdateError(const NodeJs::PackageMetadata& pkg, const QString& error) {
|
||||||
|
qApp->showGuiMessage(Notification::Event::NodePackageUpdated,
|
||||||
|
{ {},
|
||||||
|
tr("Package %1 was NOT updated to version %2 because of error: %3.").arg(pkg.m_name,
|
||||||
|
pkg.m_version,
|
||||||
|
error),
|
||||||
|
QSystemTrayIcon::MessageIcon::Critical });
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::onNodeJsPackageInstalled(const NodeJs::PackageMetadata& pkg, bool already_up_to_date) {
|
||||||
|
if (!already_up_to_date) {
|
||||||
|
qApp->showGuiMessage(Notification::Event::NodePackageUpdated,
|
||||||
|
{ {},
|
||||||
|
tr("Package %1 was updated to version %2.").arg(pkg.m_name, pkg.m_version),
|
||||||
|
QSystemTrayIcon::MessageIcon::Information });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Application::customDataFolder() const {
|
QString Application::customDataFolder() const {
|
||||||
return m_customDataFolder;
|
return m_customDataFolder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "miscellaneous/feedreader.h"
|
#include "miscellaneous/feedreader.h"
|
||||||
#include "miscellaneous/iofactory.h"
|
#include "miscellaneous/iofactory.h"
|
||||||
#include "miscellaneous/localization.h"
|
#include "miscellaneous/localization.h"
|
||||||
|
#include "miscellaneous/nodejs.h"
|
||||||
#include "miscellaneous/notification.h"
|
#include "miscellaneous/notification.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
#include "miscellaneous/singleapplication.h"
|
#include "miscellaneous/singleapplication.h"
|
||||||
|
@ -33,7 +34,6 @@ class FormMain;
|
||||||
class IconFactory;
|
class IconFactory;
|
||||||
class QAction;
|
class QAction;
|
||||||
class Mutex;
|
class Mutex;
|
||||||
class NodeJs;
|
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR == 6
|
#if QT_VERSION_MAJOR == 6
|
||||||
class QWebEngineDownloadRequest;
|
class QWebEngineDownloadRequest;
|
||||||
|
@ -172,6 +172,8 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
|
||||||
void parseCmdArgumentsFromMyInstance();
|
void parseCmdArgumentsFromMyInstance();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onNodeJsPackageUpdateError(const NodeJs::PackageMetadata& pkg, const QString& error);
|
||||||
|
void onNodeJsPackageInstalled(const NodeJs::PackageMetadata& pkg, bool already_up_to_date);
|
||||||
void onCommitData(QSessionManager& manager);
|
void onCommitData(QSessionManager& manager);
|
||||||
void onSaveState(QSessionManager& manager);
|
void onSaveState(QSessionManager& manager);
|
||||||
void onAboutToQuit();
|
void onAboutToQuit();
|
||||||
|
|
|
@ -106,7 +106,7 @@ void NodeJs::installUpdatePackage(const PackageMetadata& pkg) {
|
||||||
case PackageStatus::UpToDate:
|
case PackageStatus::UpToDate:
|
||||||
qDebugNN << LOGSEC_NODEJS << "Package" << QUOTE_W_SPACE(pkg.m_name) << "is up-to-date.";
|
qDebugNN << LOGSEC_NODEJS << "Package" << QUOTE_W_SPACE(pkg.m_name) << "is up-to-date.";
|
||||||
|
|
||||||
emit packageInstalledUpdated(pkg);
|
emit packageInstalledUpdated(pkg, true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ void NodeJs::installPackage(const PackageMetadata& pkg) {
|
||||||
else {
|
else {
|
||||||
qDebugNN << LOGSEC_NODEJS << "Installed/updated package" << QUOTE_W_SPACE(pkg.m_name)
|
qDebugNN << LOGSEC_NODEJS << "Installed/updated package" << QUOTE_W_SPACE(pkg.m_name)
|
||||||
<< "with version" << QUOTE_W_SPACE_DOT(pkg.m_version);
|
<< "with version" << QUOTE_W_SPACE_DOT(pkg.m_version);
|
||||||
emit packageInstalledUpdated(pkg);
|
emit packageInstalledUpdated(pkg, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(proc, &QProcess::errorOccurred, this, [pkg, this](QProcess::ProcessError error) {
|
connect(proc, &QProcess::errorOccurred, this, [pkg, this](QProcess::ProcessError error) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ class NodeJs : public QObject {
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void packageError(const PackageMetadata& pkg, const QString& error);
|
void packageError(const PackageMetadata& pkg, const QString& error);
|
||||||
void packageInstalledUpdated(const PackageMetadata& pkg);
|
void packageInstalledUpdated(const PackageMetadata& pkg, bool already_up_to_date);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installPackage(const PackageMetadata& pkg);
|
void installPackage(const PackageMetadata& pkg);
|
||||||
|
|
|
@ -120,6 +120,8 @@ QList<Notification::Event> Notification::allEvents() {
|
||||||
Event::LoginDataRefreshed,
|
Event::LoginDataRefreshed,
|
||||||
Event::LoginFailure,
|
Event::LoginFailure,
|
||||||
Event::NewAppVersionAvailable,
|
Event::NewAppVersionAvailable,
|
||||||
|
Event::NodePackageUpdated,
|
||||||
|
Event::NodePackageFailedToUpdate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +145,12 @@ QString Notification::nameForEvent(Notification::Event event) {
|
||||||
case Notification::Event::GeneralEvent:
|
case Notification::Event::GeneralEvent:
|
||||||
return QObject::tr("Miscellaneous events");
|
return QObject::tr("Miscellaneous events");
|
||||||
|
|
||||||
|
case Notification::Event::NodePackageUpdated:
|
||||||
|
return QObject::tr("Node.js - package updated");
|
||||||
|
|
||||||
|
case Notification::Event::NodePackageFailedToUpdate:
|
||||||
|
return QObject::tr("Node.js - package failed to updated");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QObject::tr("Unknown event");
|
return QObject::tr("Unknown event");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,17 @@ class Notification {
|
||||||
// OAuth or similar mechanism.
|
// OAuth or similar mechanism.
|
||||||
LoginDataRefreshed = 4,
|
LoginDataRefreshed = 4,
|
||||||
|
|
||||||
|
// New RSS Guard version available.
|
||||||
NewAppVersionAvailable = 5,
|
NewAppVersionAvailable = 5,
|
||||||
|
|
||||||
LoginFailure = 6
|
// Some service failed to login.
|
||||||
|
LoginFailure = 6,
|
||||||
|
|
||||||
|
// Node.js - package updated.
|
||||||
|
NodePackageUpdated = 7,
|
||||||
|
|
||||||
|
// Node.js - package failde to update.
|
||||||
|
NodePackageFailedToUpdate = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Notification(Event event = Event::NoEvent, bool balloon = {}, const QString& sound_path = {},
|
explicit Notification(Event event = Event::NoEvent, bool balloon = {}, const QString& sound_path = {},
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVersionNumber>
|
||||||
|
|
||||||
using UpdateCheck = QPair<UpdateInfo, QNetworkReply::NetworkError>;
|
using UpdateCheck = QPair<UpdateInfo, QNetworkReply::NetworkError>;
|
||||||
|
|
||||||
|
@ -226,35 +227,10 @@ void SystemFactory::checkForUpdatesOnStartup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemFactory::isVersionNewer(const QString& new_version, const QString& base_version) {
|
bool SystemFactory::isVersionNewer(const QString& new_version, const QString& base_version) {
|
||||||
QStringList base_version_tkn = base_version.split(QL1C('.'));
|
QVersionNumber nw = QVersionNumber::fromString(new_version);
|
||||||
QStringList new_version_tkn = new_version.split(QL1C('.'));
|
QVersionNumber bs = QVersionNumber::fromString(base_version);
|
||||||
|
|
||||||
while (!base_version_tkn.isEmpty() && !new_version_tkn.isEmpty()) {
|
return nw > bs;
|
||||||
const int base_number = base_version_tkn.takeFirst().toInt();
|
|
||||||
const int new_number = new_version_tkn.takeFirst().toInt();
|
|
||||||
|
|
||||||
if (new_number > base_number) {
|
|
||||||
// New version is indeed higher that current version.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (new_number < base_number) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Versions are either the same or they have unequal sizes.
|
|
||||||
if (base_version_tkn.isEmpty() && new_version_tkn.isEmpty()) {
|
|
||||||
// Versions are the same.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (new_version_tkn.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new_version_tkn.join(QString()).toInt() > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemFactory::isVersionEqualOrNewer(const QString& new_version, const QString& base_version) {
|
bool SystemFactory::isVersionEqualOrNewer(const QString& new_version, const QString& base_version) {
|
||||||
|
|
|
@ -175,7 +175,9 @@ void AdBlockManager::showDialog() {
|
||||||
AdBlockDialog(qApp->mainFormWidget()).exec();
|
AdBlockDialog(qApp->mainFormWidget()).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockManager::onPackageReady(const NodeJs::PackageMetadata& pkg) {
|
void AdBlockManager::onPackageReady(const NodeJs::PackageMetadata& pkg, bool already_up_to_date) {
|
||||||
|
Q_UNUSED(already_up_to_date)
|
||||||
|
|
||||||
if (pkg.m_name == QSL(CLIQZ_ADBLOCKED_PACKAGE)) {
|
if (pkg.m_name == QSL(CLIQZ_ADBLOCKED_PACKAGE)) {
|
||||||
m_installing = false;
|
m_installing = false;
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class AdBlockManager : public QObject {
|
||||||
void processTerminated();
|
void processTerminated();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPackageReady(const NodeJs::PackageMetadata& pkg);
|
void onPackageReady(const NodeJs::PackageMetadata& pkg, bool already_up_to_date);
|
||||||
void onPackageError(const NodeJs::PackageMetadata& pkg, const QString& error);
|
void onPackageError(const NodeJs::PackageMetadata& pkg, const QString& error);
|
||||||
void onServerProcessFinished(int exit_code, QProcess::ExitStatus exit_status);
|
void onServerProcessFinished(int exit_code, QProcess::ExitStatus exit_status);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue