work on nodejs int

This commit is contained in:
Martin Rotter 2022-02-16 14:07:48 +01:00
parent ddb805438f
commit beb9c5a263
32 changed files with 53249 additions and 1486 deletions

View file

@ -1,11 +1,13 @@
if(UPDATE_TRANSLATIONS) if(UPDATE_TRANSLATIONS)
# Regenerate "en" .ts file. # Regenerate "en" .ts file.
file(GLOB_RECURSE ALL_SOURCES file(GLOB_RECURSE ALL_SOURCES
"${CMAKE_SOURCE_DIR}/src/librssguard/*.cpp") "${CMAKE_SOURCE_DIR}/src/librssguard/*.cpp"
"${CMAKE_SOURCE_DIR}/src/librssguard/*.ui")
qt_add_lupdate(rssguard qt_add_lupdate(rssguard
TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/rssguard_en.ts" TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/rssguard_en.ts"
SOURCES ${ALL_SOURCES} SOURCES ${ALL_SOURCES}
INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/src/librssguard"
OPTIONS "-no-obsolete") OPTIONS "-no-obsolete")
endif() endif()

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,8 +2,9 @@
#include "exceptions/processexception.h" #include "exceptions/processexception.h"
ProcessException::ProcessException(int exit_code, QProcess::ExitStatus exit_status, const QString& message) ProcessException::ProcessException(int exit_code, QProcess::ExitStatus exit_status,
: ApplicationException(message), m_exitStatus(exit_status), m_exitCode(exit_code) {} QProcess::ProcessError error, const QString& message)
: ApplicationException(message), m_error(error), m_exitStatus(exit_status), m_exitCode(exit_code) {}
QProcess::ExitStatus ProcessException::exitStatus() const { QProcess::ExitStatus ProcessException::exitStatus() const {
return m_exitStatus; return m_exitStatus;
@ -12,3 +13,7 @@ QProcess::ExitStatus ProcessException::exitStatus() const {
int ProcessException::exitCode() const { int ProcessException::exitCode() const {
return m_exitCode; return m_exitCode;
} }
QProcess::ProcessError ProcessException::error() const {
return m_error;
}

View file

@ -9,12 +9,15 @@
class ProcessException : public ApplicationException { class ProcessException : public ApplicationException {
public: public:
ProcessException(int exit_code, QProcess::ExitStatus exit_status, const QString& message = QString()); ProcessException(int exit_code, QProcess::ExitStatus exit_status,
QProcess::ProcessError error, const QString& message = QString());
QProcess::ExitStatus exitStatus() const; QProcess::ExitStatus exitStatus() const;
int exitCode() const; int exitCode() const;
QProcess::ProcessError error() const;
private: private:
QProcess::ProcessError m_error;
QProcess::ExitStatus m_exitStatus; QProcess::ExitStatus m_exitStatus;
int m_exitCode; int m_exitCode;
}; };

View file

@ -105,7 +105,7 @@ void SettingsNodejs::saveSettings() {
void SettingsNodejs::testNodejs() { void SettingsNodejs::testNodejs() {
try { try {
QString node_version = qApp->nodejs()->nodejsVersion(m_ui.m_tbNodeExecutable->lineEdit()->text()); QString node_version = qApp->nodejs()->nodeJsVersion(m_ui.m_tbNodeExecutable->lineEdit()->text());
m_ui.m_tbNodeExecutable->setStatus(WidgetWithStatus::StatusType::Ok, m_ui.m_tbNodeExecutable->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Node.js has version %1.").arg(node_version)); tr("Node.js has version %1.").arg(node_version));

View file

@ -671,9 +671,9 @@ void Application::downloadRequested(QWebEngineDownloadItem* download_item) {
void Application::onAdBlockFailure() { void Application::onAdBlockFailure() {
qApp->showGuiMessage(Notification::Event::GeneralEvent, { qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("AdBlock needs to be configured"), tr("AdBlock needs to be configured"),
tr("AdBlock component is not configured properly. Go to \"Settings\" -> \"Node.js\" and check " tr("AdBlock is not configured properly. Go to \"Settings\" -> \"Node.js\" and check "
"if your Node.js is properly configured."), "if your Node.js is properly configured."),
QSystemTrayIcon::MessageIcon::Critical }, {}); QSystemTrayIcon::MessageIcon::Critical }, { true, true, false });
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, false); qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, false);
} }

View file

@ -140,7 +140,12 @@ QString IOFactory::startProcessGetOutput(const QString& executable,
return proc.readAllStandardOutput(); return proc.readAllStandardOutput();
} }
else { else {
throw ProcessException(proc.exitCode(), proc.exitStatus(), proc.readAllStandardError().simplified()); QString err_output = proc.readAllStandardError().simplified();
throw ProcessException(proc.exitCode(),
proc.exitStatus(),
proc.error(),
err_output.isEmpty() ? proc.errorString() : err_output);
} }
} }

View file

@ -61,7 +61,7 @@ QString NodeJs::processedPackageFolder() const {
return QDir::toNativeSeparators(path); return QDir::toNativeSeparators(path);
} }
QString NodeJs::nodejsVersion(const QString& nodejs_exe) const { QString NodeJs::nodeJsVersion(const QString& nodejs_exe) const {
if (nodejs_exe.simplified().isEmpty()) { if (nodejs_exe.simplified().isEmpty()) {
throw ApplicationException(tr("file not found")); throw ApplicationException(tr("file not found"));
} }

View file

@ -48,7 +48,7 @@ class NodeJs : public QObject {
QString processedPackageFolder() const; QString processedPackageFolder() const;
void setPackageFolder(const QString& path); void setPackageFolder(const QString& path);
QString nodejsVersion(const QString& nodejs_exe) const; QString nodeJsVersion(const QString& nodejs_exe) const;
QString npmVersion(const QString& npm_exe) const; QString npmVersion(const QString& npm_exe) const;
// Checks status of package. // Checks status of package.

View file

@ -3,6 +3,7 @@
#include "network-web/readability.h" #include "network-web/readability.h"
#include "3rd-party/boolinq/boolinq.h" #include "3rd-party/boolinq/boolinq.h"
#include "exceptions/applicationexception.h"
#include "gui/messagebox.h" #include "gui/messagebox.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
@ -61,26 +62,41 @@ void Readability::onPackageError(const QList<NodeJs::PackageMetadata>& pkgs, con
void Readability::makeHtmlReadable(const QString& html, const QString& base_url) { void Readability::makeHtmlReadable(const QString& html, const QString& base_url) {
if (!m_modulesInstalled) { if (!m_modulesInstalled) {
NodeJs::PackageStatus st = qApp->nodejs()->packageStatus({ QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) }); try {
NodeJs::PackageStatus st = qApp->nodejs()->packageStatus({ QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) });
if (st != NodeJs::PackageStatus::UpToDate) { if (st != NodeJs::PackageStatus::UpToDate) {
if (!m_modulesInstalling) { if (!m_modulesInstalling) {
// We make sure to update modules. // We make sure to update modules.
m_modulesInstalling = true; m_modulesInstalling = true;
qApp->showGuiMessage(Notification::Event::NodePackageUpdated, qApp->showGuiMessage(Notification::Event::NodePackageUpdated,
{ tr("Node.js libraries not installed"), { tr("Node.js libraries not installed"),
tr("%1 will now install some needed libraries, this will take only a few seconds. " tr("%1 will now install some needed libraries, this will take only a few seconds. "
"You will be notified when installation is complete.").arg(QSL(APP_NAME)), "You will be notified when installation is complete.").arg(QSL(APP_NAME)),
QSystemTrayIcon::MessageIcon::Information }, QSystemTrayIcon::MessageIcon::Warning },
{ true, true, false }); { true, true, false });
qApp->nodejs()->installPackages({ { QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) } }); qApp->nodejs()->installPackages({ { QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) } });
}
return;
}
else {
m_modulesInstalled = true;
} }
return;
} }
else { catch (const ApplicationException& ex) {
m_modulesInstalled = true; qApp->showGuiMessage(Notification::Event::NodePackageUpdated,
{ tr("Node.js libraries not installed"),
tr("Node.js is not configured properly. Go to \"Settings\" -> \"Node.js\" and check "
"if your Node.js is properly configured."),
QSystemTrayIcon::MessageIcon::Critical },
{ true, true, false });
qCriticalNN << LOGSEC_CORE << "Failed to check for Node.js package status:" << QUOTE_W_SPACE_DOT(ex.message());
// Emit this just to allow readability again for user.
emit htmlReadabled({});
} }
} }