diff --git a/CMakeLists.txt b/CMakeLists.txt index c13fe4d7d..55adcc022 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -458,7 +458,6 @@ set(APP_TEXT resources/text/COPYING_GNU_GPL resources/text/COPYING_GNU_GPL_HTML resources/text/COPYING_BSD - resources/text/AUTHORS ) # Setup source & header files for "rssguard_updater". diff --git a/resources/text/AUTHORS b/resources/text/AUTHORS deleted file mode 100644 index af60afd41..000000000 --- a/resources/text/AUTHORS +++ /dev/null @@ -1,10 +0,0 @@ - -Authors and contributors: - - \ No newline at end of file diff --git a/src/gui/formabout.cpp b/src/gui/formabout.cpp index 60df46f64..e266f9a53 100644 --- a/src/gui/formabout.cpp +++ b/src/gui/formabout.cpp @@ -67,16 +67,6 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) } file.close(); - file.setFileName(APP_INFO_PATH + "/AUTHORS"); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - m_ui->m_txtThanks->setText(text_stream.readAll()); - } - else { - //: File containing list of authors was not found. - m_ui->m_txtThanks->setText(tr("Authors information not found.")); - } - file.close(); - file.setFileName(APP_INFO_PATH + "/CHANGELOG"); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { m_ui->m_txtChangelog->setText(text_stream.readAll()); diff --git a/src/gui/formabout.ui b/src/gui/formabout.ui index 80598e7b5..bc94feaac 100644 --- a/src/gui/formabout.ui +++ b/src/gui/formabout.ui @@ -132,8 +132,8 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html> false @@ -157,7 +157,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -166,12 +166,12 @@ p, li { white-space: pre-wrap; } 0 0 - 67 - 66 + 685 + 184 - false + true GNU GPL License (applies to RSS Guard source code) @@ -180,7 +180,16 @@ p, li { white-space: pre-wrap; } GNU GPL License - + + 0 + + + 0 + + + 0 + + 0 @@ -215,8 +224,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html> +</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html> Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -233,15 +242,24 @@ p, li { white-space: pre-wrap; } 0 0 - 85 - 66 + 98 + 69 BSD License (applies to QtSingleApplication source code) - + + 0 + + + 0 + + + 0 + + 0 @@ -276,8 +294,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p></body></html> +</style></head><body style=" font-family:'DejaVu Sans Mono'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html> Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -300,49 +318,6 @@ p, li { white-space: pre-wrap; } - - - Thanks to - - - - - - QFrame::NoFrame - - - false - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - 30 - - - false - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - true - - - - - - - Thanks to page is available only in English language. - - - - - Changelog @@ -360,8 +335,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html> false diff --git a/src/gui/formfeeddetails.h b/src/gui/formfeeddetails.h index 29ee71aab..0574c59bb 100644 --- a/src/gui/formfeeddetails.h +++ b/src/gui/formfeeddetails.h @@ -18,10 +18,10 @@ #ifndef FORMSTANDARDFEEDDETAILS_H #define FORMSTANDARDFEEDDETAILS_H -#include - #include "ui_formfeeddetails.h" +#include + namespace Ui { class FormFeedDetails; diff --git a/src/gui/formupdate.h b/src/gui/formupdate.h index 9d33effb0..a8c5db3ad 100644 --- a/src/gui/formupdate.h +++ b/src/gui/formupdate.h @@ -18,14 +18,14 @@ #ifndef FORMUPDATE_H #define FORMUPDATE_H -#include -#include -#include - #include "ui_formupdate.h" #include "miscellaneous/systemfactory.h" +#include +#include +#include + namespace Ui { class FormUpdate; diff --git a/src/gui/formupdate.ui b/src/gui/formupdate.ui index 086f3f32c..1fbed944e 100755 --- a/src/gui/formupdate.ui +++ b/src/gui/formupdate.ui @@ -7,7 +7,7 @@ 0 0 607 - 322 + 366 @@ -71,8 +71,8 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p></body></html> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse diff --git a/src/updater/formupdater.cpp b/src/updater/formupdater.cpp index a0c6d8fc9..0667aa5d9 100644 --- a/src/updater/formupdater.cpp +++ b/src/updater/formupdater.cpp @@ -1,6 +1,7 @@ #include "updater/formupdater.h" #include "definitions/definitions.h" +#include "qtsingleapplication/qtsingleapplication.h" #include #include @@ -12,15 +13,24 @@ #include #include #include +#include +#include FormUpdater::FormUpdater(QWidget *parent) : QMainWindow(parent), m_state(NoState), - m_txtOutput(new QTextEdit(this)) { + m_txtOutput(new QTextEdit(this)), + m_parsedArguments(QHash()) { + m_txtOutput->setFontPointSize(10.0); m_txtOutput->setReadOnly(true); - m_txtOutput->setFocusPolicy(Qt::NoFocus); + m_txtOutput->setFocusPolicy(Qt::StrongFocus); + m_txtOutput->setContextMenuPolicy(Qt::DefaultContextMenu); + m_txtOutput->setTextInteractionFlags(Qt::TextSelectableByMouse | + Qt::TextSelectableByKeyboard | + Qt::LinksAccessibleByKeyboard | + Qt::LinksAccessibleByMouse); setCentralWidget(m_txtOutput); setWindowTitle("RSS Guard updater"); @@ -32,20 +42,131 @@ FormUpdater::~FormUpdater() { } void FormUpdater::startUpgrade() { - m_txtOutput->append("Welcome to RSS Guard updater."); + printHeading("Welcome to RSS Guard updater"); + + printText("Analyzing updater arguments..."); if (QApplication::arguments().size() != 5) { - m_txtOutput->append("Insufficient arguments passed. Update process cannot proceed."); - m_txtOutput->append("Press any key to exit updater..."); + printText("Insufficient arguments passed. Update process cannot proceed."); + printText("\nPress any key to exit updater..."); + m_state = ExitError; - // Ted je nastavenej state a pri keyPressEvent se appka ukonci + return; } - // do datovejch memberu teto tridy ulozit argumenty a pokracovat + // Obtain parameters. + QStringList arguments = QApplication::arguments(); + + m_parsedArguments["updater_path"] = QDir::toNativeSeparators(qApp->applicationFilePath()); + m_parsedArguments["current_version"] = arguments.at(1); + m_parsedArguments["next_version"] = arguments.at(2); + m_parsedArguments["rssguard_executable_path"] = QDir::toNativeSeparators(arguments.at(3)); + m_parsedArguments["rssguard_path"] = QDir::toNativeSeparators(QFileInfo(m_parsedArguments["rssguard_executable_path"]).absolutePath()); + m_parsedArguments["update_file_path"] = QDir::toNativeSeparators(arguments.at(4)); + m_parsedArguments["temp_path"] = QDir::toNativeSeparators(QFileInfo(m_parsedArguments["update_file_path"]).absolutePath()); + m_parsedArguments["output_temp_path"] = m_parsedArguments["temp_path"] + QDir::separator() + APP_LOW_NAME; + + printArguments(); + + if (!printUpdateInformation()) { + printText("Update file does not exist or is corrupted."); + printText("\nPress any key to exit updater..."); + + m_state = ExitError; + return; + } + + doPreparationCleanup(); + doExtractionAndCopying(); +} + +void FormUpdater::printArguments() { + printNewline(); + printHeading("Arguments"); + + printText(QString("Updater executable file:\n -> %1").arg(m_parsedArguments["updater_path"])); + printText(QString("Application executable file:\n -> %1").arg(m_parsedArguments["rssguard_executable_path"])); + printText(QString("Temp folder:\n -> %1").arg(m_parsedArguments["temp_path"])); + printText(QString("Application temp folder:\n -> %1").arg(m_parsedArguments["output_temp_path"])); +} + +bool FormUpdater::printUpdateInformation() { + bool update_file_exists = QFile::exists(m_parsedArguments["update_file_path"]); + + printNewline(); + printHeading("Update information"); + + printText(QString("Version change:\n -> %1 --> %2").arg(m_parsedArguments["current_version"], m_parsedArguments["next_version"])); + printText(QString("Update file:\n -> %1").arg(m_parsedArguments["update_file_path"])); + printText(QString("Update file exists:\n -> %1").arg(update_file_exists ? "yes" : "no")); + printText(QString("Update file size:\n -> %1 bytes").arg(QFileInfo(m_parsedArguments["update_file_path"]).size())); + + return update_file_exists; +} + +bool FormUpdater::doPreparationCleanup() { + printNewline(); + printHeading("Initial cleanup"); + + // Check if main RSS Guard instance is running. + if (static_cast(qApp)->sendMessage(APP_QUIT_INSTANCE)) { + printText("The main application is running. Quitting it."); + } + else { + printText("The main application is not running."); + } + + // Remove old folders. + if (QDir(m_parsedArguments["output_temp_path"]).exists()) { + if (!removeDirectory(m_parsedArguments["output_temp_path"])) { + printText("Cleanup of old temporary files failed."); + return false; + } + } + + if (!removeDirectory(m_parsedArguments["rssguard_path"], + QStringList() << APP_7ZA_EXECUTABLE, + QStringList() << "data")) { + printText("Full cleanup of actual RSS Guard installation failed."); + printText("Some files from old installation may persist."); + } + + if (!QFile::rename(m_parsedArguments["updater_path"], m_parsedArguments["updater_path"] + ".old")) { + qDebug("Updater executable was not renamed and it will not be updated."); + } + + return true; +} + +bool FormUpdater::doExtractionAndCopying() { + QStringList extractor_arguments; + + extractor_arguments << "x" << m_parsedArguments["update_file_path"] << "-r" << + "-y" << QString("-o%1").arg(m_parsedArguments["output_temp_path"]); + + QProcess process_extractor(this); + process_extractor.setEnvironment(QProcessEnvironment::systemEnvironment().toStringList()); + process_extractor.setProcessChannelMode(QProcess::MergedChannels); + process_extractor.start(APP_7ZA_EXECUTABLE, extractor_arguments); + + if (process_extractor.waitForFinished()) { + printText("Extraction of update files failed."); + return false; + } + + printText("Extraction done successfully."); + + return true; } void FormUpdater::keyPressEvent(QKeyEvent* event) { - event->ignore(); + if (event->matches(QKeySequence::Copy)) { + event->accept(); + return; + } + else { + event->ignore(); + } switch (m_state) { case NoState: @@ -63,8 +184,22 @@ void FormUpdater::keyPressEvent(QKeyEvent* event) { } } +void FormUpdater::printHeading(const QString &header) { + m_txtOutput->setAlignment(Qt::AlignCenter); + m_txtOutput->append(QString("****** %1 ******\n").arg(header)); +} + +void FormUpdater::printText(const QString &text) { + m_txtOutput->setAlignment(Qt::AlignLeft); + m_txtOutput->append(text); +} + +void FormUpdater::printNewline() { + m_txtOutput->append("\n"); +} + void FormUpdater::moveToCenterAndResize() { - resize(500, 400); + resize(600, 400); move(qApp->desktop()->screenGeometry().center() - rect().center()); } diff --git a/src/updater/formupdater.h b/src/updater/formupdater.h index d4397ffbb..7dd1931ba 100644 --- a/src/updater/formupdater.h +++ b/src/updater/formupdater.h @@ -3,6 +3,8 @@ #include +#include + class QTextEdit; class QKeyEvent; @@ -22,11 +24,18 @@ class FormUpdater : public QMainWindow { virtual ~FormUpdater(); void startUpgrade(); + void printArguments(); + bool printUpdateInformation(); + bool doPreparationCleanup(); + bool doExtractionAndCopying(); protected: void keyPressEvent(QKeyEvent *event); private: + void printText(const QString &text); + void printNewline(); + void printHeading(const QString &header); void moveToCenterAndResize(); // File/directory manipulators. @@ -39,8 +48,7 @@ class FormUpdater : public QMainWindow { UpdaterState m_state; QTextEdit *m_txtOutput; - QString m_rssguardExecutablePath; - + QHash m_parsedArguments; }; #endif // FORMUPDATER_H