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
143 changes: 0 additions & 143 deletions YUViewLib/src/handler/UpdateHandler.h

This file was deleted.

78 changes: 78 additions & 0 deletions YUViewLib/src/handler/update/UpdateDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* This program 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.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "UpdateDialog.h"

#include <common/Typedef.h>

#include <QSettings>

UpdateDialog::UpdateDialog(QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);

// Load the update settings from the QSettings
QSettings settings;
settings.beginGroup("updates");
bool checkForUpdates = settings.value("checkForUpdates", true).toBool();
QString updateBehavior = settings.value("updateBehavior", "ask").toString();
settings.endGroup();

ui.checkUpdatesGroupBox->setChecked(checkForUpdates);
if (updateBehavior == "ask")
ui.updateSettingComboBox->setCurrentIndex(1);
else if (updateBehavior == "auto")
ui.updateSettingComboBox->setCurrentIndex(0);

connect(ui.cancelButton, &QPushButton::clicked, this, &QDialog::reject);

if (!UPDATE_FEATURE_ENABLE)
// If the update feature is not available, we will grey this out.
ui.updateSettingComboBox->setEnabled(false);
}

void UpdateDialog::on_updateButton_clicked()
{
// The user wants to download/install the update.

// First save the settings
QSettings settings;
settings.beginGroup("updates");
settings.setValue("checkForUpdates", ui.checkUpdatesGroupBox->isChecked());
QString updateBehavior = "ask";
if (ui.updateSettingComboBox->currentIndex() == 0)
updateBehavior = "auto";
settings.setValue("updateBehavior", updateBehavior);

// The update request was accepted by the user
accept();
}
50 changes: 50 additions & 0 deletions YUViewLib/src/handler/update/UpdateDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* This program 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.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "ui_updateDialog.h"

// Ask the user if he wants to update to the new version and how to handle updates in the future.
class UpdateDialog : public QDialog
{
Q_OBJECT

public:
explicit UpdateDialog(QWidget *parent = 0);

private slots:
void on_updateButton_clicked();

private:
Ui::UpdateDialog ui;
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "UpdateHandlerFile.h"
#include "UpdateFileHandler.h"

#include <QFileInfo>
#include <QTextStream>
Expand All @@ -43,31 +43,31 @@
#define DEBUG_UPDATE_FILE(msg) ((void)0)
#endif

const auto UPDATEFILEHANDLER_FILE_NAME = "versioninfo.txt";
const auto UpdateFileHandler_FILE_NAME = "versioninfo.txt";

updateFileHandler::updateFileHandler()
UpdateFileHandler::UpdateFileHandler()
{}

updateFileHandler::updateFileHandler(QString fileName, QString updatePath) :
UpdateFileHandler::UpdateFileHandler(QString fileName, QString updatePath) :
updatePath(updatePath)
{
this->readFromFile(fileName);
}

updateFileHandler::updateFileHandler(QByteArray &byteArray)
UpdateFileHandler::UpdateFileHandler(QByteArray &byteArray)
{
this->readRemoteFromData(byteArray);
}

void updateFileHandler::readFromFile(QString fileName)
void UpdateFileHandler::readFromFile(QString fileName)
{
DEBUG_UPDATE_FILE("updateFileHandler::readFromFile Current working dir " << this->updatePath);
DEBUG_UPDATE_FILE("UpdateFileHandler::readFromFile Current working dir " << this->updatePath);

// Open the file and get all files and their current version (int) from the file.
QFileInfo updateFileInfo(fileName);
if (!updateFileInfo.exists() || !updateFileInfo.isFile())
{
DEBUG_UPDATE_FILE("updateFileHandler::readFromFile local update file " << fileName << " not found");
DEBUG_UPDATE_FILE("UpdateFileHandler::readFromFile local update file " << fileName << " not found");
return;
}

Expand All @@ -87,21 +87,21 @@ void updateFileHandler::readFromFile(QString fileName)
this->loaded = true;
}

void updateFileHandler::readRemoteFromData(QByteArray &arr)
void UpdateFileHandler::readRemoteFromData(QByteArray &arr)
{
const QString reply = QString(arr);
const QStringList lines = reply.split("\n");
for (auto line : lines)
this->parseOneLine(line);
}

void updateFileHandler::parseOneLine(QString &line, bool checkExistence)
void UpdateFileHandler::parseOneLine(QString &line, bool checkExistence)
{
QStringList lineSplit = line.split(" ");
if (line.startsWith("Last Commit"))
{
if (line.startsWith("Last Commit: "))
DEBUG_UPDATE_FILE("updateFileHandler::parseOneLine Local file last commit: " << lineSplit[2]);
DEBUG_UPDATE_FILE("UpdateFileHandler::parseOneLine Local file last commit: " << lineSplit[2]);
return;
}
// Ignore all lines that start with %, / or #
Expand All @@ -120,15 +120,15 @@ void updateFileHandler::parseOneLine(QString &line, bool checkExistence)
else
// The file does not exist locally. That is strange since it is in the update info file.
// Files that do not exist locally should always be downloaded so we don't put them into the list.
DEBUG_UPDATE_FILE("updateFileHandler::parseOneLine The local file " << fInfo.absoluteFilePath() << " could not be found.");
DEBUG_UPDATE_FILE("UpdateFileHandler::parseOneLine The local file " << fInfo.absoluteFilePath() << " could not be found.");
}
else
// Do not check if the file exists
this->updateFileList.append(entry);
}
}

QList<downloadFile> updateFileHandler::getFilesToUpdate(updateFileHandler &localFiles) const
QList<downloadFile> UpdateFileHandler::getFilesToUpdate(UpdateFileHandler &localFiles) const
{
QList<downloadFile> updateList;
for (auto remoteFile : this->updateFileList)
Expand All @@ -149,11 +149,11 @@ QList<downloadFile> updateFileHandler::getFilesToUpdate(updateFileHandler &local
updateList.append(downloadFile(remoteFile.filePath, remoteFile.fileSize));
}
// No matter what, we will update the "versioninfo.txt" file (assume it to be 10kbyte)
updateList.append(downloadFile(UPDATEFILEHANDLER_FILE_NAME, 10000));
updateList.append(downloadFile(UpdateFileHandler_FILE_NAME, 10000));
return updateList;
}

QString updateFileHandler::getInfo() const
QString UpdateFileHandler::getInfo() const
{
QString s;
for (auto f : this->updateFileList)
Expand All @@ -163,7 +163,7 @@ QString updateFileHandler::getInfo() const
return s;
}

updateFileHandler::fileListEntry updateFileHandler::createFileEntry(QStringList &lineSplit) const
UpdateFileHandler::fileListEntry UpdateFileHandler::createFileEntry(QStringList &lineSplit) const
{
fileListEntry entry;

Expand Down
Loading
Loading