Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Fervor.pri
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
QT += core network
!build_pass:message("If you want to enable GUI for Fervor, add CONFIG += fervor_gui to your .pro file")
contains(QT_VERSION, ^5\\.[0-9]\\..*){
QT += core widgets webkitwidgets network
fervor_gui {
DEFINES += FV_GUI
QT += webkitwidgets
}
win32:INCLUDEPATH += $$[QT_INSTALL_PREFIX]/include/QtZlib
}else{
#QT += core gui webkit network
QT += core webkit network
fervor_gui {
DEFINES += FV_GUI
QT += gui
QT += gui webkit
}
win32:INCLUDEPATH += $$[QT_INSTALL_PREFIX]/../../../../QtSources/4.8.1/src/3rdparty/zlib
}
DEFINES += FV_APP_NAME=\\\"$$TARGET\\\"
DEFINES += FV_APP_VERSION=\\\"$$VERSION\\\"

PREVIOUS_FERVOR_GUI = $$cat($$PWD/fervor.gui)
fervor_gui {
CURRENT_FERVOR_GUI = enabled
} else {
CURRENT_FERVOR_GUI = disabled
}
# if last build was with another GUI option, recompile some files
!equals(PREVIOUS_FERVOR_GUI, $$CURRENT_FERVOR_GUI) {
write_file($$PWD/fervor.gui, CURRENT_FERVOR_GUI)
touch($$PWD/fvupdater.h, $$PWD/fervor.gui)
}


DEFINES +=QUAZIP_BUILD QUAZIP_STATIC
DEFINES += QUAZIP_BUILD QUAZIP_STATIC

INCLUDEPATH += $$PWD/quazip
HEADERS += $$PWD/quazip/crypt.h \
Expand Down
30 changes: 10 additions & 20 deletions fvignoredversions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "fvignoredversions.h"
#include "fvversioncomparator.h"
#include "fvupdater.h"
#include <QSettings>
#include <QCoreApplication>
#include <string>
Expand All @@ -9,7 +10,7 @@


FVIgnoredVersions::FVIgnoredVersions(QObject *parent) :
QObject(parent)
QObject(parent)
{
// noop
}
Expand All @@ -21,32 +22,27 @@ bool FVIgnoredVersions::VersionIsIgnored(QString version)
// 2) The version that was skipped before and thus stored in QSettings (ignore)
// 3) A newer version (don't ignore)
// 'version' is not likely to contain an older version in any case.

if (version == QCoreApplication::applicationVersion()) {
return true;
}

QSettings settings(QSettings::NativeFormat,
QSettings::UserScope,
QCoreApplication::organizationDomain(),
QCoreApplication::applicationName());

//QSettings settings;
if (settings.contains(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY)) {
QString lastSkippedVersion = settings.value(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY).toString();
QSettings* settings = FvUpdater::getSettings();
if (settings->contains(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY)) {
QString lastSkippedVersion = settings->value(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY).toString();
if (version == lastSkippedVersion) {
// Implicitly skipped version - skip
return true;
}
}

std::string currentAppVersion = QCoreApplication::applicationVersion().toStdString();
std::string suggestedVersion = std::string(version.toStdString());
if (FvVersionComparator::CompareVersions(currentAppVersion, suggestedVersion) == FvVersionComparator::kAscending) {
// Newer version - do not skip
return false;
}

// Fallback - skip
return true;
}
Expand All @@ -57,18 +53,12 @@ void FVIgnoredVersions::IgnoreVersion(QString version)
// Don't ignore the current version
return;
}

if (version.isEmpty()) {
return;
}

QSettings settings(QSettings::NativeFormat,
QSettings::UserScope,
QCoreApplication::organizationDomain(),
QCoreApplication::applicationName());


settings.setValue(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY, version);
FvUpdater::getSettings()->setValue(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY, version);

return;
}
39 changes: 31 additions & 8 deletions fvupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
# include "fvversioncomparatortest.h"
#endif

extern QSettings* settings;

FvUpdater* FvUpdater::m_Instance = 0;
QSettings* FvUpdater::m_Settings = 0;

FvUpdater* FvUpdater::sharedUpdater()
{
Expand All @@ -57,6 +56,31 @@ void FvUpdater::drop()
mutex.unlock();
}

void FvUpdater::setSettings(QSettings* settings)
{
m_Settings = settings;
}

QSettings* FvUpdater::getSettings()
{
static QMutex mutex;
if (! m_Settings) {
mutex.lock();

if (!m_Settings) {
QSettings settings(QSettings::NativeFormat,
QSettings::UserScope,
QCoreApplication::organizationDomain(),
QCoreApplication::applicationName());
m_Settings = &settings;
}

mutex.unlock();
}

return m_Settings;
}

FvUpdater::FvUpdater() : QObject(0)
{
m_reply = 0;
Expand Down Expand Up @@ -786,12 +810,12 @@ void FvUpdater::finishUpdate(QString pathToFinish)
void FvUpdater::restartApplication()
{
// Spawn a new instance of myApplication:
QString app = QApplication::applicationFilePath();
QStringList arguments = QApplication::arguments();
QString app = QCoreApplication::applicationFilePath();
QStringList arguments = QCoreApplication::arguments();
QString wd = QDir::currentPath();
qDebug() << app << arguments << wd;
QProcess::startDetached(app, arguments, wd);
QApplication::exit();
QCoreApplication::exit();
}

void FvUpdater::setRequiredSslFingerPrint(QString md5)
Expand Down Expand Up @@ -891,10 +915,9 @@ bool FvUpdater::getRemindLaterAllowed()
}

#ifndef FV_GUI

void FvUpdater::decideWhatToDoWithCurrentUpdateProposal()
{
QString policy = settings->value(FV_NEW_VERSION_POLICY_KEY).toString();
QString policy = getSettings()->value(FV_NEW_VERSION_POLICY_KEY).toString();
if(policy == "install")
InstallUpdate();
else if(policy == "skip")
Expand All @@ -903,4 +926,4 @@ void FvUpdater::decideWhatToDoWithCurrentUpdateProposal()
RemindMeLater();
}

#endif
#endif
10 changes: 7 additions & 3 deletions fvupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QUrl>
#include <QXmlStreamReader>
class QNetworkReply;
class QSettings;
class FvUpdateWindow;
class FvUpdateConfirmDialog;
class FvAvailableUpdate;
Expand All @@ -29,15 +30,18 @@ class FvUpdater : public QObject
void finishUpdate(QString pathToFinish = "");
void setRequiredSslFingerPrint(QString md5);
QString getRequiredSslFingerPrint(); // returns md5!
// HTTP Authentuication - for security reasons no getters are provided, only a setter
// HTTP Authentication - for security reasons no getters are provided, only a setter
void setHtAuthCredentials(QString user, QString pass);
void setHtAuthUsername(QString user);
void setHtAuthPassword(QString pass);
void setSkipVersionAllowed(bool allowed);
void setRemindLaterAllowed(bool allowed);
bool getSkipVersionAllowed();
bool getRemindLaterAllowed();

// This is to set QSettings object which is shared with the rest of user application.
// We will use the settings, but we will not own it. Someone else should be responsible for freeing the object.
static void setSettings(QSettings *settings);
static QSettings* getSettings();

public slots:

Expand Down Expand Up @@ -83,7 +87,7 @@ protected slots:
FvUpdater& operator=(const FvUpdater&); // Hide assign op

static FvUpdater* m_Instance; // Singleton instance

static QSettings* m_Settings;

//
// Windows / dialogs
Expand Down
6 changes: 1 addition & 5 deletions fvupdatewindow.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#ifndef FVUPDATEWINDOW_H
#define FVUPDATEWINDOW_H

#if QT_VERSION >= 0x050000
#include <QtWidgets/QWidget>
#else
#include <QWidget>
#endif
#include <QWidget>

class QGraphicsScene;

Expand Down