diff --git a/README.md b/README.md
index de5d0181b..57672f3a3 100644
--- a/README.md
+++ b/README.md
@@ -30,9 +30,7 @@ You can download source tarballs or binaries for some platforms in [Downloads](d
* [stable releases](http://software.opensuse.org/download.html?project=home%3Askunkos&package=rssguard),
* [development releases](http://software.opensuse.org/download.html?project=home%3Askunkos&package=rssguard-git) (compiled from the master branch of RSS Guard Git repository),
-* [Archlinux AUR stable package (compiled with Qt 5)](https://aur.archlinux.org/packages/rssguard/),
-* [Archlinux AUR stable package (compiled with Qt 4)](https://aur.archlinux.org/packages/rssguard-qt4/),
-* [Archlinux AUR development package (compiled with Qt 5)](https://aur.archlinux.org/packages/rssguard-git/).
+* Archlinux AUR package ([stable-qt5](https://aur.archlinux.org/packages/rssguard/), [stable-qt4](https://aur.archlinux.org/packages/rssguard-qt4/), [development-qt5](https://aur.archlinux.org/packages/rssguard-git/)].
- - -
Features
--------
diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG
index e73d7a40b..dfc9482cb 100644
--- a/resources/text/CHANGELOG
+++ b/resources/text/CHANGELOG
@@ -8,7 +8,7 @@ Fixed:
Added:
-- Application is now able to self-update itself on OS/2 and Windows. Currently, this is EXPERIMENTAL support. Please, report any bugs.
+- Application is now able to self-update itself on OS/2 and Windows. Currently, this is EXPERIMENTAL support. Please, report any bugs. Authors take no responsibility for removed files or lost application settings.
- Added option to adjust icons/buttons displayed in toolbars. See Settings/User interface/Toolbars dialog for more information.
- Added option to search messages via regular expression.
- Added option to highlight particular messages - unread, important, none.
diff --git a/src/application.cpp b/src/application.cpp
index b346e3efc..e307a99b6 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -1,8 +1,25 @@
+// This file is part of RSS Guard.
+//
+// Copyright (C) 2011-2014 by Martin Rotter
+//
+// RSS Guard is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// RSS Guard is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RSS Guard. If not, see .
+
#include "application.h"
-Application::Application(int &argc, char **argv)
- : QtSingleApplication(argc, argv) {
+Application::Application(const QString &id, int &argc, char **argv)
+ : QtSingleApplication(id, argc, argv) {
}
Application::~Application() {
diff --git a/src/application.h b/src/application.h
index 4c9c5ae87..fb9b88182 100644
--- a/src/application.h
+++ b/src/application.h
@@ -1,8 +1,30 @@
+// This file is part of RSS Guard.
+//
+// Copyright (C) 2011-2014 by Martin Rotter
+//
+// RSS Guard is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// RSS Guard is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RSS Guard. If not, see .
+
#ifndef APPLICATION_H
#define APPLICATION_H
#include "qtsingleapplication/qtsingleapplication.h"
+#if defined(qApp)
+#undef qApp
+#endif
+#define qApp (Application::instance())
+
// TODO: presunout nektery veci sem, settings atp
class Application : public QtSingleApplication {
@@ -10,7 +32,7 @@ class Application : public QtSingleApplication {
public:
// Constructors and destructors.
- explicit Application(int &argc, char **argv);
+ explicit Application(const QString &id, int &argc, char **argv);
virtual ~Application();
// Returns pointer to "GOD" application singleton.
diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp
index 596be3355..9a3330e04 100644
--- a/src/core/feeddownloader.cpp
+++ b/src/core/feeddownloader.cpp
@@ -21,7 +21,6 @@
#include
#include
-#include
FeedDownloader::FeedDownloader(QObject *parent) : QObject(parent) {
diff --git a/src/core/feedsmodelcategory.h b/src/core/feedsmodelcategory.h
index 2b2bc3b3e..0b90c09b9 100755
--- a/src/core/feedsmodelcategory.h
+++ b/src/core/feedsmodelcategory.h
@@ -21,7 +21,7 @@
#include "core/feedsmodelrootitem.h"
#include
-#include
+#include
class FeedsModelFeed;
diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h
index 89a336dd0..69fc1960f 100755
--- a/src/core/feedsmodelfeed.h
+++ b/src/core/feedsmodelfeed.h
@@ -25,12 +25,11 @@
#include
#include
#include
-#include
+#include
class Message;
-
// Represents BASE class for feeds contained in FeedsModel.
// NOTE: This class should be derived to create PARTICULAR feed types.
class FeedsModelFeed : public FeedsModelRootItem {
diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp
index 8842d37cf..1396561c4 100755
--- a/src/core/feedsmodelrootitem.cpp
+++ b/src/core/feedsmodelrootitem.cpp
@@ -17,7 +17,7 @@
#include "core/feedsmodelrootitem.h"
-#include "qtsingleapplication/qtsingleapplication.h"
+#include "application.h"
#include
@@ -35,7 +35,7 @@ FeedsModelRootItem::~FeedsModelRootItem() {
}
void FeedsModelRootItem::setupFonts() {
- m_normalFont = QtSingleApplication::font("FeedsView");
+ m_normalFont = Application::font("FeedsView");
m_boldFont = m_normalFont;
m_boldFont.setBold(true);
}
diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp
index c90aaa5d9..2618feb4e 100644
--- a/src/core/messagesmodel.cpp
+++ b/src/core/messagesmodel.cpp
@@ -21,7 +21,7 @@
#include "miscellaneous/textfactory.h"
#include "miscellaneous/databasefactory.h"
#include "miscellaneous/iconfactory.h"
-#include "qtsingleapplication/qtsingleapplication.h"
+#include "application.h"
#include
#include
@@ -62,7 +62,7 @@ void MessagesModel::fetchAll() {
}
void MessagesModel::setupFonts() {
- m_normalFont = QtSingleApplication::font("MessagesView");
+ m_normalFont = Application::font("MessagesView");
m_boldFont = m_normalFont;
m_boldFont.setBold(true);
}
diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp
index 4d40c3cc5..bb8f815ff 100644
--- a/src/gui/feedmessageviewer.cpp
+++ b/src/gui/feedmessageviewer.cpp
@@ -38,7 +38,6 @@
#include
#include
#include
-#include
#include
#include
#include
diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp
index 2c1bac752..6c961587b 100755
--- a/src/gui/formmain.cpp
+++ b/src/gui/formmain.cpp
@@ -33,7 +33,7 @@
#include "gui/statusbar.h"
#include "gui/feedmessageviewer.h"
#include "gui/formupdate.h"
-#include "qtsingleapplication/qtsingleapplication.h"
+#include "application.h"
#include
#include
@@ -219,7 +219,7 @@ void FormMain::display() {
raise();
// Raise alert event. Check the documentation for more info on this.
- QtSingleApplication::alert(this);
+ Application::alert(this);
}
void FormMain::onCommitData(QSessionManager &manager) {
diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp
index 5f9f2805d..111fc5152 100755
--- a/src/gui/formsettings.cpp
+++ b/src/gui/formsettings.cpp
@@ -38,8 +38,8 @@
#include "gui/messagebox.h"
#include "gui/basetoolbar.h"
#include "gui/messagestoolbar.h"
-#include "qtsingleapplication/qtsingleapplication.h"
#include "dynamic-shortcuts/dynamicshortcuts.h"
+#include "application.h"
#include
#include
diff --git a/src/gui/locationlineedit.cpp b/src/gui/locationlineedit.cpp
index f2aa96e4d..84185eff2 100644
--- a/src/gui/locationlineedit.cpp
+++ b/src/gui/locationlineedit.cpp
@@ -17,13 +17,7 @@
#include "gui/locationlineedit.h"
-#include "definitions/definitions.h"
-#include "miscellaneous/settings.h"
-
-#include
-#include
-#include
-#include
+#include
LocationLineEdit::LocationLineEdit(QWidget *parent)
diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp
index 440e8355e..5324ded57 100644
--- a/src/gui/messagebox.cpp
+++ b/src/gui/messagebox.cpp
@@ -18,13 +18,14 @@
#include "gui/messagebox.h"
#include "miscellaneous/iconfactory.h"
+#include "application.h"
-#include
#include
+#include
#include
#include
#include
-#include
+
MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) {
}
diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp
index fde662880..9a626b223 100644
--- a/src/gui/systemtrayicon.cpp
+++ b/src/gui/systemtrayicon.cpp
@@ -21,7 +21,7 @@
#include "miscellaneous/settings.h"
#include "gui/formmain.h"
#include "gui/formsettings.h"
-#include "qtsingleapplication/qtsingleapplication.h"
+#include "application.h"
#include
#include
@@ -36,7 +36,7 @@ TrayIconMenu::~TrayIconMenu() {
}
bool TrayIconMenu::event(QEvent *event) {
- if (QtSingleApplication::activeModalWidget() != NULL &&
+ if (Application::activeModalWidget() != NULL &&
event->type() == QEvent::Show) {
QTimer::singleShot(0, this, SLOT(hide()));
SystemTrayIcon::instance()->showMessage(APP_LONG_NAME,
diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp
index dbebac8ac..8185cc42e 100644
--- a/src/gui/tabwidget.cpp
+++ b/src/gui/tabwidget.cpp
@@ -26,8 +26,8 @@
#include "gui/formmain.h"
#include "gui/feedmessageviewer.h"
#include "gui/plaintoolbutton.h"
+#include "application.h"
-#include
#include
#include
diff --git a/src/main.cpp b/src/main.cpp
index c277cebae..bc17476f3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -27,7 +27,7 @@
#include "gui/systemtrayicon.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedsview.h"
-#include "qtsingleapplication/qtsingleapplication.h"
+#include "application.h"
// Needed for setting ini file format on Mac OS.
#ifdef Q_OS_MAC
@@ -66,8 +66,8 @@ int main(int argc, char *argv[]) {
#endif
// Instantiate base application object.
- QtSingleApplication application(APP_LOW_NAME, argc, argv);
- qDebug("Instantiated QtSingleApplication class.");
+ Application application(APP_LOW_NAME, argc, argv);
+ qDebug("Instantiated Application class.");
// Check if another instance is running.
if (application.sendMessage(APP_IS_RUNNING)) {
@@ -85,11 +85,11 @@ int main(int argc, char *argv[]) {
Localization::instance()->load();
// These settings needs to be set before any QSettings object.
- QtSingleApplication::setApplicationName(APP_NAME);
- QtSingleApplication::setApplicationVersion(APP_VERSION);
- QtSingleApplication::setOrganizationName(APP_AUTHOR);
- QtSingleApplication::setOrganizationDomain(APP_URL);
- QtSingleApplication::setWindowIcon(QIcon(APP_ICON_PATH));
+ Application::setApplicationName(APP_NAME);
+ Application::setApplicationVersion(APP_VERSION);
+ Application::setOrganizationName(APP_AUTHOR);
+ Application::setOrganizationDomain(APP_URL);
+ Application::setWindowIcon(QIcon(APP_ICON_PATH));
qDebug().nospace() << "Creating main application form in thread: \'" <<
QThread::currentThreadId() << "\'.";
@@ -126,5 +126,5 @@ int main(int argc, char *argv[]) {
&main_window, SLOT(processExecutionMessage(QString)));
// Enter global event loop.
- return QtSingleApplication::exec();
+ return Application::exec();
}
diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp
index 11a0be88a..fffc608f7 100644
--- a/src/miscellaneous/databasefactory.cpp
+++ b/src/miscellaneous/databasefactory.cpp
@@ -19,8 +19,8 @@
#include "definitions/definitions.h"
#include "miscellaneous/settings.h"
+#include "application.h"
-#include
#include
#include
#include
diff --git a/src/miscellaneous/debugging.cpp b/src/miscellaneous/debugging.cpp
index bf57b6abe..84112f4d2 100644
--- a/src/miscellaneous/debugging.cpp
+++ b/src/miscellaneous/debugging.cpp
@@ -18,8 +18,8 @@
#include "miscellaneous/debugging.h"
#include "definitions/definitions.h"
+#include "application.h"
-#include
#include
#include
diff --git a/src/miscellaneous/iconfactory.h b/src/miscellaneous/iconfactory.h
index 1fa1c6cc9..c440686a4 100644
--- a/src/miscellaneous/iconfactory.h
+++ b/src/miscellaneous/iconfactory.h
@@ -18,15 +18,17 @@
#ifndef ICONFACTORY_H
#define ICONFACTORY_H
+#include
+
+#include "definitions/definitions.h"
+#include "application.h"
+
#include
#include
#include
#include
-#include
#include
-#include "definitions/definitions.h"
-
class IconFactory : public QObject {
public:
diff --git a/src/miscellaneous/localization.cpp b/src/miscellaneous/localization.cpp
index 33e73bcc1..291610320 100644
--- a/src/miscellaneous/localization.cpp
+++ b/src/miscellaneous/localization.cpp
@@ -19,10 +19,9 @@
#include "definitions/definitions.h"
#include "miscellaneous/settings.h"
-#include "qtsingleapplication/qtsingleapplication.h"
+#include "application.h"
#include
-#include
#include
#include
#include
@@ -61,7 +60,7 @@ void Localization::load() {
if (app_translator->load(QString("rssguard-%1.qm").arg(desired_localization),
APP_LANG_PATH,
"-")) {
- QApplication::installTranslator(app_translator);
+ Application::installTranslator(app_translator);
qDebug("Application localization '%s' loaded successfully.",
qPrintable(desired_localization));
}
@@ -74,7 +73,7 @@ void Localization::load() {
if (qt_translator->load(QString("qt-%1.qm").arg(desired_localization),
APP_LANG_PATH,
"-")) {
- QApplication::installTranslator(qt_translator);
+ Application::installTranslator(qt_translator);
qDebug("Qt localization '%s' loaded successfully.",
qPrintable(desired_localization));
}
diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp
index 0200511ab..f30a87e43 100644
--- a/src/miscellaneous/settings.cpp
+++ b/src/miscellaneous/settings.cpp
@@ -18,8 +18,8 @@
#include "miscellaneous/settings.h"
#include "definitions/definitions.h"
+#include "application.h"
-#include
#include
#include
#include
diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h
index 0c9df77d5..dc825d874 100644
--- a/src/miscellaneous/settings.h
+++ b/src/miscellaneous/settings.h
@@ -19,6 +19,7 @@
#define SETTINGS_H
#include
+
#include
diff --git a/src/miscellaneous/skinfactory.cpp b/src/miscellaneous/skinfactory.cpp
index ee60e17c9..3958428d8 100644
--- a/src/miscellaneous/skinfactory.cpp
+++ b/src/miscellaneous/skinfactory.cpp
@@ -19,8 +19,8 @@
#include "definitions/definitions.h"
#include "miscellaneous/settings.h"
+#include "application.h"
-#include
#include
#include
#include
diff --git a/src/miscellaneous/skinfactory.h b/src/miscellaneous/skinfactory.h
index 7c293847b..0d244ece5 100644
--- a/src/miscellaneous/skinfactory.h
+++ b/src/miscellaneous/skinfactory.h
@@ -19,6 +19,7 @@
#define SKINFACTORY_H
#include
+
#include
#include
#include
diff --git a/src/miscellaneous/systemfactory.cpp b/src/miscellaneous/systemfactory.cpp
index 4e21c5f55..0bb0df299 100644
--- a/src/miscellaneous/systemfactory.cpp
+++ b/src/miscellaneous/systemfactory.cpp
@@ -19,16 +19,14 @@
#include "definitions/definitions.h"
#include "network-web/networkfactory.h"
+#include "application.h"
#if defined(Q_OS_WIN)
-#include "qtsingleapplication/qtsingleapplication.h"
-
#include
#endif
#include
#include
-#include
#include
#include
#include
@@ -55,7 +53,7 @@ SystemFactory::AutoStartStatus SystemFactory::getAutoStartStatus() {
bool autostart_enabled = registry_key.value(APP_LOW_NAME,
"").toString().replace('\\',
'/') ==
- QtSingleApplication::applicationFilePath();
+ Application::applicationFilePath();
if (autostart_enabled) {
return SystemFactory::Enabled;
@@ -138,8 +136,8 @@ bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) {
switch (new_status) {
case SystemFactory::Enabled:
registry_key.setValue(APP_LOW_NAME,
- QtSingleApplication::applicationFilePath().replace('/',
- '\\'));
+ Application::applicationFilePath().replace('/',
+ '\\'));
return true;
case SystemFactory::Disabled:
registry_key.remove(APP_LOW_NAME);
diff --git a/src/miscellaneous/systemfactory.h b/src/miscellaneous/systemfactory.h
index 31168e8ce..8b23355a1 100644
--- a/src/miscellaneous/systemfactory.h
+++ b/src/miscellaneous/systemfactory.h
@@ -19,6 +19,7 @@
#define SYSTEMFACTORY_H
#include
+
#include
#include
#include
diff --git a/src/network-web/networkfactory.h b/src/network-web/networkfactory.h
index c6707ca2d..d45c50b47 100644
--- a/src/network-web/networkfactory.h
+++ b/src/network-web/networkfactory.h
@@ -19,7 +19,7 @@
#define NETWORKFACTORY_H
#include
-#include
+#include
class NetworkFactory {
diff --git a/src/network-web/silentnetworkaccessmanager.cpp b/src/network-web/silentnetworkaccessmanager.cpp
index 05ea2bd4f..e8f5d504c 100644
--- a/src/network-web/silentnetworkaccessmanager.cpp
+++ b/src/network-web/silentnetworkaccessmanager.cpp
@@ -19,7 +19,6 @@
#include
#include
-#include
SilentNetworkAccessManager::SilentNetworkAccessManager(QObject *parent)
diff --git a/src/network-web/webbrowsernetworkaccessmanager.cpp b/src/network-web/webbrowsernetworkaccessmanager.cpp
index 4b2db15ed..567eed16a 100644
--- a/src/network-web/webbrowsernetworkaccessmanager.cpp
+++ b/src/network-web/webbrowsernetworkaccessmanager.cpp
@@ -17,8 +17,9 @@
#include "network-web/webbrowsernetworkaccessmanager.h"
+#include "application.h"
+
#include
-#include
QPointer WebBrowserNetworkAccessManager::s_instance;
diff --git a/src/network-web/webfactory.cpp b/src/network-web/webfactory.cpp
index 13941bc71..b02d590e2 100644
--- a/src/network-web/webfactory.cpp
+++ b/src/network-web/webfactory.cpp
@@ -2,8 +2,8 @@
#include "definitions/definitions.h"
#include "miscellaneous/settings.h"
+#include "application.h"
-#include
#include
#include
#include
diff --git a/src/network-web/webview.cpp b/src/network-web/webview.cpp
index 03b2f9eb1..a0276ff4a 100644
--- a/src/network-web/webview.cpp
+++ b/src/network-web/webview.cpp
@@ -54,7 +54,7 @@ void WebView::onLoadFinished(bool ok) {
}
void WebView::copySelectedText() {
- QApplication::clipboard()->setText(selectedText());
+ Application::clipboard()->setText(selectedText());
}
void WebView::openLinkInNewTab() {
diff --git a/src/updater/formupdater.cpp b/src/updater/formupdater.cpp
index 8180eb95d..f96c1ce2b 100644
--- a/src/updater/formupdater.cpp
+++ b/src/updater/formupdater.cpp
@@ -1,9 +1,25 @@
+// This file is part of RSS Guard.
+//
+// Copyright (C) 2011-2014 by Martin Rotter
+//
+// RSS Guard is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// RSS Guard is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RSS Guard. If not, see .
+
#include "updater/formupdater.h"
#include "definitions/definitions.h"
#include "qtsingleapplication/qtsingleapplication.h"
-#include
#include
#include
#include
@@ -19,12 +35,17 @@
#include
+FormUpdater *FormUpdater::s_instance;
+
FormUpdater::FormUpdater(QWidget *parent)
: QMainWindow(parent, Qt::Dialog | Qt::WindowStaysOnTopHint),
m_state(NoState),
m_txtOutput(new QTextEdit(this)),
m_parsedArguments(QHash()) {
+ // Initialize singleton.
+ s_instance = this;
+
m_txtOutput->setAutoFormatting(QTextEdit::AutoNone);
m_txtOutput->setAcceptRichText(true);
m_txtOutput->setFontPointSize(10.0);
@@ -41,16 +62,21 @@ FormUpdater::FormUpdater(QWidget *parent)
setWindowIcon(QIcon(APP_ICON_PATH));
moveToCenterAndResize();
+
+ connect(this, SIGNAL(debugMessageProduced(QtMsgType,QString)),
+ this, SLOT(consumeDebugMessage(QtMsgType,QString)));
}
FormUpdater::~FormUpdater() {
}
void FormUpdater::startUpgrade() {
+ qDebug("Started...");
+
printHeading("Welcome to RSS Guard updater");
printText("Analyzing updater arguments.");
- if (QApplication::arguments().size() != 5) {
+ if (QtSingleApplication::arguments().size() != 5) {
printText("Insufficient arguments passed. Update process cannot proceed.");
printText("\nPress any key to exit updater...");
@@ -70,23 +96,14 @@ void FormUpdater::startUpgrade() {
}
doFinalCleanup();
-
- printText("Application was upgraded without serious errors.");
-
- if (!QProcess::startDetached(m_parsedArguments["rssguard_executable_path"])) {
- printText("RSS Guard was not started successfully. Start it manually.");
- m_state = ExitError;
- }
- else {
- m_state = ExitNormal;
- }
+ executeMainApplication();
printText("\nPress any key to exit updater...");
}
void FormUpdater::saveArguments() {
// Obtain parameters.
- QStringList arguments = QApplication::arguments();
+ QStringList arguments = QtSingleApplication::arguments();
m_parsedArguments["updater_path"] = QDir::toNativeSeparators(qApp->applicationFilePath());
m_parsedArguments["current_version"] = arguments.at(1);
@@ -98,6 +115,70 @@ void FormUpdater::saveArguments() {
m_parsedArguments["output_temp_path"] = m_parsedArguments["temp_path"] + QDir::separator() + APP_LOW_NAME;
}
+void FormUpdater::executeMainApplication() {
+ printText("\nApplication was upgraded without serious errors.");
+
+ if (!QProcess::startDetached(m_parsedArguments["rssguard_executable_path"])) {
+ printText("RSS Guard was not started successfully. Start it manually.");
+ m_state = ExitError;
+ }
+ else {
+ m_state = ExitNormal;
+ }
+}
+
+void FormUpdater::triggerDebugMessageConsumption(QtMsgType type, const QString &message) {
+ emit debugMessageProduced(type, message);
+}
+
+void FormUpdater::consumeDebugMessage(QtMsgType type, const QString &message) {
+ switch (type) {
+ case QtDebugMsg:
+ s_instance->printText(QString("DEBUG: %1").arg(message));
+ break;
+
+ case QtWarningMsg:
+ s_instance->printText(QString("WARNING: %1").arg(message));
+ break;
+
+ case QtCriticalMsg:
+ s_instance->printText(QString("CRITICAL: %1").arg(message));
+ break;
+
+ case QtFatalMsg:
+ s_instance->printText(QString("FATAL: %1").arg(message));
+ qApp->exit(EXIT_FAILURE);
+
+ default:
+ break;
+ }
+}
+
+#if QT_VERSION >= 0x050000
+void FormUpdater::debugHandler(QtMsgType type,
+ const QMessageLogContext &placement,
+ const QString &message) {
+#ifndef QT_NO_DEBUG_OUTPUT
+ Q_UNUSED(placement)
+
+ s_instance->triggerDebugMessageConsumption(type, message);
+#else
+ Q_UNUSED(type)
+ Q_UNUSED(placement)
+ Q_UNUSED(message)
+#endif
+}
+#else
+void FormUpdater::debugHandler(QtMsgType type, const char *message) {
+#ifndef QT_NO_DEBUG_OUTPUT
+ s_instance->triggerDebugMessageConsumption(type, QString(message));
+#else
+ Q_UNUSED(type)
+ Q_UNUSED(message)
+#endif
+}
+#endif
+
void FormUpdater::printArguments() {
printNewline();
printHeading("Arguments");
@@ -145,7 +226,7 @@ bool FormUpdater::doPreparationCleanup() {
printText(QString("Check for running instances of RSS Guard, attempt %1.").arg(i));
- if (static_cast(qApp)->sendMessage(APP_QUIT_INSTANCE)) {
+ if (static_cast(QCoreApplication::instance())->sendMessage(APP_QUIT_INSTANCE)) {
printText("The main application is running. Quitting it.");
printText("Waiting for 6000 ms for main application to finish.");
@@ -198,7 +279,7 @@ bool FormUpdater::doExtractionAndCopying() {
extractor_arguments << "x" << "-r" << "-y" <<
QString("-o%1").arg(m_parsedArguments["output_temp_path"]) <<
- m_parsedArguments["update_file_path"];
+ m_parsedArguments["update_file_path"];
printText(QString("Calling extractor %1 with these arguments:").arg(APP_7ZA_EXECUTABLE));
@@ -209,13 +290,7 @@ bool FormUpdater::doExtractionAndCopying() {
process_extractor.setEnvironment(QProcessEnvironment::systemEnvironment().toStringList());
process_extractor.setWorkingDirectory(m_parsedArguments["rssguard_path"]);
- QString prog_line = QString(APP_7ZA_EXECUTABLE) + " " +
- "x -r -y \"-o" + m_parsedArguments["output_temp_path"] +
- "\" \"" + m_parsedArguments["update_file_path"] + "\"";
- printText(prog_line);
-
- process_extractor.start(prog_line);
- //process_extractor.start(APP_7ZA_EXECUTABLE, extractor_arguments);
+ process_extractor.start(APP_7ZA_EXECUTABLE, extractor_arguments);
if (!process_extractor.waitForFinished()) {
process_extractor.close();
@@ -252,13 +327,22 @@ bool FormUpdater::doExtractionAndCopying() {
}
bool FormUpdater::doFinalCleanup() {
+ bool result_file;
+ bool result_path;
+
qApp->processEvents();
printNewline();
printHeading("Final cleanup");
- return removeDirectory(m_parsedArguments["output_temp_path"]) &&
- QFile::remove(m_parsedArguments["update_file_path"]);
+ result_path = removeDirectory(m_parsedArguments["output_temp_path"]);
+ result_file = QFile::remove(m_parsedArguments["update_file_path"]);
+
+ printText(QString("Removing temporary files\n -> %1 -> %2\n -> %3 -> %4").arg(
+ m_parsedArguments["output_temp_path"], result_path ? "success" : "failure",
+ m_parsedArguments["update_file_path"], result_file ? "success" : "failure"));
+
+ return result_file && result_path;
}
void FormUpdater::keyPressEvent(QKeyEvent* event) {
diff --git a/src/updater/formupdater.h b/src/updater/formupdater.h
index 44ff4a1b2..35cff9480 100644
--- a/src/updater/formupdater.h
+++ b/src/updater/formupdater.h
@@ -1,8 +1,26 @@
+// This file is part of RSS Guard.
+//
+// Copyright (C) 2011-2014 by Martin Rotter
+//
+// RSS Guard is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// RSS Guard is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RSS Guard. If not, see .
+
#ifndef FORMUPDATER_H
#define FORMUPDATER_H
#include
+#include
#include
@@ -13,6 +31,7 @@ class FormUpdater : public QMainWindow {
Q_OBJECT
public:
+ // Describes the state of updater.
enum UpdaterState {
NoState,
ExitNormal,
@@ -23,6 +42,11 @@ class FormUpdater : public QMainWindow {
explicit FormUpdater(QWidget *parent = 0);
virtual ~FormUpdater();
+ // Prints various texts.
+ void printText(const QString &text);
+ void printNewline();
+ void printHeading(const QString &header);
+
// Starts the whole update process.
void startUpgrade();
@@ -33,17 +57,34 @@ class FormUpdater : public QMainWindow {
bool doPreparationCleanup();
bool doExtractionAndCopying();
bool doFinalCleanup();
+ void executeMainApplication();
+
+ // Used to trigger signal informaing about new debug message.
+ void triggerDebugMessageConsumption(QtMsgType type, const QString &message);
+
+ // Debug handlers for messages.
+#if QT_VERSION >= 0x050000
+ static void debugHandler(QtMsgType type,
+ const QMessageLogContext &placement,
+ const QString &message);
+#else
+ static void debugHandler(QtMsgType type,
+ const char *message);
+#endif
+
+ public slots:
+ // Should be always called on GUI thread which is enforced
+ // by signal/slot auto connection.
+ void consumeDebugMessage(QtMsgType type, const QString &message);
+
+ signals:
+ // Emitted if new debug messaages is produced and should be printed.
+ void debugMessageProduced(QtMsgType type, QString message);
protected:
// Catch the "press any key event" to exit the updater.
void keyPressEvent(QKeyEvent *event);
- private:
- // Prints various texts.
- void printText(const QString &text);
- void printNewline();
- void printHeading(const QString &header);
-
// Moves the window into the center of the screen and resizes it.
void moveToCenterAndResize();
@@ -56,8 +97,9 @@ class FormUpdater : public QMainWindow {
private:
UpdaterState m_state;
QTextEdit *m_txtOutput;
-
QHash m_parsedArguments;
+
+ static FormUpdater *s_instance;
};
#endif // FORMUPDATER_H
diff --git a/src/updater/main.cpp b/src/updater/main.cpp
index 5d9963eb2..9a638a8c1 100644
--- a/src/updater/main.cpp
+++ b/src/updater/main.cpp
@@ -26,8 +26,6 @@
#include
#include
-#include
-#include
// Main entry point to "rssguard_updater.exe".
// It expects 4 ARGUMENTS:
@@ -39,11 +37,17 @@
int main(int argc, char *argv[]) {
// Instantiate base application object.
QtSingleApplication application(APP_LOW_NAME, argc, argv);
-
- application.setQuitOnLastWindowClosed(true);
+ QtSingleApplication::setQuitOnLastWindowClosed(true);
FormUpdater main_form;
+ // Setup debug output system.
+#if QT_VERSION >= 0x050000
+ qInstallMessageHandler(FormUpdater::debugHandler);
+#else
+ qInstallMsgHandler(FormUpdater::debugHandler);
+#endif
+
main_form.show();
main_form.startUpgrade();