/*
Copyright © 2014 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre 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.
qTox 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 qTox. If not, see
*/
#include "widget.h"
#include "ui_widget.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "update.h"
#ifdef Q_OS_WIN
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0600 // Vista for SHGetKnownFolderPath
#include
#include
#include
#include
const bool supported = true;
const QString QTOX_PATH = "qtox.exe";
#else
const bool supported = false;
const QString QTOX_PATH;
#endif
const QString SETTINGS_FILE = "settings.ini";
Widget::Widget(const Settings &s) :
QWidget(nullptr),
ui(new Ui::Widget),
settings{s}
{
ui->setupUi(this);
// Updates only for supported platforms
if (!supported)
fatalError(tr("The qTox updater is not supported on this platform."));
QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection);
}
Widget::~Widget()
{
delete ui;
}
void Widget::setProgress(int value)
{
ui->progress->setValue(value);
ui->progress->repaint();
qApp->processEvents();
}
void Widget::fatalError(QString message)
{
qCritical() << "Update aborted with error:"< updateFlist = parseFlist(updateFlistData);
setProgress(5);
/// 2. Generate a diff (5-50%)
QList diff = genUpdateDiff(updateFlist, this);
for (UpdateFileMeta fileMeta : diff)
if (!QFile::exists(updateDirStr+fileMeta.installpath))
fatalError(tr("The update is incomplete."));
if (diff.size() == 0)
fatalError(tr("The update is empty!"));
setProgress(50);
qDebug() << "Diff generated,"<