1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: remove AppImage update bridge

When re-evaluating our dependencies we decided that the update bridge
has a high potential for security issues because it's not widely used.
Additionally similar functionality is already present in qTox.
This commit is contained in:
sudden6 2019-10-23 01:05:04 +02:00 committed by Anthony Bilinski
parent 7be327714a
commit 547a038e48
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
6 changed files with 0 additions and 143 deletions

View File

@ -26,7 +26,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(PLATFORM_EXTENSIONS "Enable platform specific extensions, requires extra dependencies" ON) option(PLATFORM_EXTENSIONS "Enable platform specific extensions, requires extra dependencies" ON)
option(USE_FILTERAUDIO "Enable the echo canceling backend" ON) option(USE_FILTERAUDIO "Enable the echo canceling backend" ON)
option(UPDATE_CHECK "Enable automatic update check" ON) option(UPDATE_CHECK "Enable automatic update check" ON)
option(APPIMAGE_UPDATER_BRIDGE "Use AppImageUpdaterBridge to do the update" OFF)
option(USE_CCACHE "Use ccache when available" ON) option(USE_CCACHE "Use ccache when available" ON)
option(SPELL_CHECK "Enable spell cheching support" ON) option(SPELL_CHECK "Enable spell cheching support" ON)
option(SVGZ_ICON "Compress the SVG icon of qTox" ON) option(SVGZ_ICON "Compress the SVG icon of qTox" ON)
@ -56,11 +55,6 @@ if(APPLE)
/usr/local/opt/openal-soft/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}) /usr/local/opt/openal-soft/lib/pkgconfig:$ENV{PKG_CONFIG_PATH})
endif() endif()
if(${APPIMAGE_UPDATER_BRIDGE})
set(ENV{PKG_CONFIG_PATH}
/usr/local/lib/pkgconfig:$ENV{PKG_CONFIG_PATH})
endif()
execute_process( execute_process(
COMMAND brew --prefix qt5 COMMAND brew --prefix qt5
OUTPUT_VARIABLE QT_PREFIX_PATH OUTPUT_VARIABLE QT_PREFIX_PATH
@ -648,17 +642,6 @@ endif()
if(${UPDATE_CHECK}) if(${UPDATE_CHECK})
add_definitions(-DUPDATE_CHECK_ENABLED=1) add_definitions(-DUPDATE_CHECK_ENABLED=1)
if(${APPIMAGE_UPDATER_BRIDGE})
search_dependency(AIUB PACKAGE AppImageUpdaterBridge)
if(AIUB_FOUND)
message(STATUS "using AppImageUpdaterBridge")
add_definitions(-DAPPIMAGE_UPDATER_BRIDGE_ENABLED=1)
else()
message(STATUS "cannot find AppImageUpdaterBridge , ignoring cmake flag")
endif()
else()
message(STATUS "not using AppImageUpdaterBridge")
endif()
set(${PROJECT_NAME}_SOURCES ${${PROJECT_NAME}_SOURCES} set(${PROJECT_NAME}_SOURCES ${${PROJECT_NAME}_SOURCES}
src/net/updatecheck.cpp src/net/updatecheck.cpp
src/net/updatecheck.h) src/net/updatecheck.h)

View File

@ -47,12 +47,6 @@ readonly APT_FLAGS="-y --no-install-recommends"
readonly SNORE_GIT="https://github.com/KDE/snorenotify" readonly SNORE_GIT="https://github.com/KDE/snorenotify"
# snorenotify build directory # snorenotify build directory
readonly SNORE_BUILD_DIR="$BUILD_DIR"/snorenotify readonly SNORE_BUILD_DIR="$BUILD_DIR"/snorenotify
# "appimage updater bridge" becomes aub
readonly AUB_SRC_DIR="$BUILD_DIR"/aub
# aub source
readonly AUB_GIT="https://github.com/antony-jr/AppImageUpdaterBridge"
# aub build dir
readonly AUB_BUILD_DIR="$BUILD_DIR"/aub/build
# update information to be embeded in AppImage # update information to be embeded in AppImage
if [ "cron" == "${TRAVIS_EVENT_TYPE:-}" ] if [ "cron" == "${TRAVIS_EVENT_TYPE:-}" ]
@ -110,18 +104,6 @@ LDFLAGS="-lcrypto"
make make
make install make install
# build aub into a static library and later use it in
# qTox
git clone "$AUB_GIT" "$AUB_SRC_DIR"
cd "$AUB_SRC_DIR" # we need to checkout first
git checkout tags/v1.1.2
mkdir $AUB_BUILD_DIR
cd $AUB_BUILD_DIR
cmake .. -DLOGGING_DISABLED=ON
make
make install
# copy qtox source # copy qtox source
cp -r "$QTOX_SRC_DIR" "$QTOX_BUILD_DIR" cp -r "$QTOX_SRC_DIR" "$QTOX_BUILD_DIR"
cd "$QTOX_BUILD_DIR" cd "$QTOX_BUILD_DIR"
@ -138,7 +120,6 @@ cd _build
# need to build with -DDESKTOP_NOTIFICATIONS=True for snorenotify # need to build with -DDESKTOP_NOTIFICATIONS=True for snorenotify
cmake -DDESKTOP_NOTIFICATIONS=True \ cmake -DDESKTOP_NOTIFICATIONS=True \
-DUPDATE_CHECK=True \ -DUPDATE_CHECK=True \
-DAPPIMAGE_UPDATER_BRIDGE=True \
../ ../
make make

View File

@ -19,14 +19,7 @@
#include "src/net/updatecheck.h" #include "src/net/updatecheck.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#else
#include <QApplication>
#include <QScreen>
#include <AppImageUpdaterBridge>
#include <AppImageUpdaterDialog>
#endif
#include <QDebug> #include <QDebug>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
@ -36,34 +29,16 @@
#include <QTimer> #include <QTimer>
#include <cassert> #include <cassert>
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
namespace { namespace {
const QString versionUrl{QStringLiteral("https://api.github.com/repos/qTox/qTox/releases/latest")}; const QString versionUrl{QStringLiteral("https://api.github.com/repos/qTox/qTox/releases/latest")};
} // namespace } // namespace
#else
using AppImageUpdaterBridge::AppImageDeltaRevisioner;
using AppImageUpdaterBridge::AppImageUpdaterDialog;
#endif
UpdateCheck::UpdateCheck(const Settings& settings) UpdateCheck::UpdateCheck(const Settings& settings)
: settings(settings) : settings(settings)
{ {
updateTimer.start(1000 * 60 * 60 * 24 /* 1 day */); updateTimer.start(1000 * 60 * 60 * 24 /* 1 day */);
connect(&updateTimer, &QTimer::timeout, this, &UpdateCheck::checkForUpdate); connect(&updateTimer, &QTimer::timeout, this, &UpdateCheck::checkForUpdate);
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
connect(&manager, &QNetworkAccessManager::finished, this, &UpdateCheck::handleResponse); connect(&manager, &QNetworkAccessManager::finished, this, &UpdateCheck::handleResponse);
#else
connect(&revisioner, &AppImageDeltaRevisioner::updateAvailable, this, &UpdateCheck::handleUpdate);
connect(&revisioner, &AppImageDeltaRevisioner::error, this, &UpdateCheck::updateCheckFailed,
Qt::DirectConnection);
updateDialog.reset(new AppImageUpdaterDialog(QPixmap(":/img/icons/qtox.svg")));
connect(updateDialog.data(), &AppImageUpdaterDialog::quit, QApplication::instance(),
&QApplication::quit, Qt::QueuedConnection);
connect(updateDialog.data(), &AppImageUpdaterDialog::canceled, this, &UpdateCheck::handleUpdateEnd);
connect(updateDialog.data(), &AppImageUpdaterDialog::finished, this, &UpdateCheck::handleUpdateEnd);
connect(updateDialog.data(), &AppImageUpdaterDialog::error, this, &UpdateCheck::handleUpdateEnd);
#endif
} }
void UpdateCheck::checkForUpdate() void UpdateCheck::checkForUpdate()
@ -72,30 +47,11 @@ void UpdateCheck::checkForUpdate()
// still run the timer to check periodically incase setting changes // still run the timer to check periodically incase setting changes
return; return;
} }
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
manager.setProxy(settings.getProxy()); manager.setProxy(settings.getProxy());
QNetworkRequest request{versionUrl}; QNetworkRequest request{versionUrl};
manager.get(request); manager.get(request);
#else
revisioner.clear();
revisioner.setProxy(settings.getProxy());
revisioner.checkForUpdate();
#endif
} }
#ifdef APPIMAGE_UPDATER_BRIDGE_ENABLED
void UpdateCheck::initUpdate()
{
disconnect(&revisioner, &AppImageDeltaRevisioner::updateAvailable, this,
&UpdateCheck::handleUpdate);
disconnect(&revisioner, &AppImageDeltaRevisioner::error, this, &UpdateCheck::updateCheckFailed);
updateDialog->move(QGuiApplication::primaryScreen()->geometry().center()
- updateDialog->rect().center());
updateDialog->init(&revisioner);
}
#endif
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
void UpdateCheck::handleResponse(QNetworkReply* reply) void UpdateCheck::handleResponse(QNetworkReply* reply)
{ {
assert(reply != nullptr); assert(reply != nullptr);
@ -135,23 +91,3 @@ void UpdateCheck::handleResponse(QNetworkReply* reply)
} }
reply->deleteLater(); reply->deleteLater();
} }
#else
void UpdateCheck::handleUpdate(bool aval)
{
if (aval) {
qInfo() << "Update available";
emit updateAvailable();
return;
}
qInfo() << "qTox is up to date";
emit upToDate();
}
void UpdateCheck::handleUpdateEnd()
{
connect(&revisioner, &AppImageDeltaRevisioner::error, this, &UpdateCheck::updateCheckFailed,
(Qt::ConnectionType)(Qt::DirectConnection | Qt::UniqueConnection));
connect(&revisioner, &AppImageDeltaRevisioner::updateAvailable, this,
&UpdateCheck::handleUpdate, Qt::UniqueConnection);
}
#endif // APPIMAGE_UPDATER_BRIDGE_ENABLED

View File

@ -20,12 +20,6 @@
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#ifdef APPIMAGE_UPDATER_BRIDGE_ENABLED
#include <QScopedPointer>
#include <AppImageUpdaterBridge>
#include <AppImageUpdaterDialog>
#endif // APPIMAGE_UPDATER_BRIDGE_ENABLED
#include <memory> #include <memory>
class Settings; class Settings;
@ -41,35 +35,15 @@ public:
void checkForUpdate(); void checkForUpdate();
signals: signals:
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
void updateAvailable(QString latestVersion, QUrl link); void updateAvailable(QString latestVersion, QUrl link);
#else
void updateAvailable();
#endif
void upToDate(); void upToDate();
void updateCheckFailed(); void updateCheckFailed();
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
private slots: private slots:
void handleResponse(QNetworkReply* reply); void handleResponse(QNetworkReply* reply);
#endif
#ifdef APPIMAGE_UPDATER_BRIDGE_ENABLED
public slots:
void initUpdate();
private slots:
void handleUpdate(bool);
void handleUpdateEnd();
#endif
private: private:
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
QNetworkAccessManager manager; QNetworkAccessManager manager;
#else
AppImageUpdaterBridge::AppImageDeltaRevisioner revisioner;
QScopedPointer<AppImageUpdaterBridge::AppImageUpdaterDialog> updateDialog;
#endif // APPIMAGE_UPDATER_BRIDGE_ENABLED
QTimer updateTimer; QTimer updateTimer;
const Settings& settings; const Settings& settings;
}; };

View File

@ -96,10 +96,6 @@ void AboutForm::replaceVersions()
connect(updateCheck, &UpdateCheck::updateAvailable, this, &AboutForm::onUpdateAvailable); connect(updateCheck, &UpdateCheck::updateAvailable, this, &AboutForm::onUpdateAvailable);
connect(updateCheck, &UpdateCheck::upToDate, this, &AboutForm::onUpToDate); connect(updateCheck, &UpdateCheck::upToDate, this, &AboutForm::onUpToDate);
connect(updateCheck, &UpdateCheck::updateCheckFailed, this, &AboutForm::onUpdateCheckFailed); connect(updateCheck, &UpdateCheck::updateCheckFailed, this, &AboutForm::onUpdateCheckFailed);
#ifdef APPIMAGE_UPDATER_BRIDGE_ENABLED
connect(bodyUI->updateAvailableButton, &QPushButton::clicked, updateCheck,
&UpdateCheck::initUpdate);
#endif
} else { } else {
qWarning() << "AboutForm passed null UpdateCheck!"; qWarning() << "AboutForm passed null UpdateCheck!";
} }
@ -169,7 +165,6 @@ void AboutForm::replaceVersions()
bodyUI->authorInfo->setText(authorInfo); bodyUI->authorInfo->setText(authorInfo);
} }
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
void AboutForm::onUpdateAvailable(QString latestVersion, QUrl link) void AboutForm::onUpdateAvailable(QString latestVersion, QUrl link)
{ {
QObject::disconnect(linkConnection); QObject::disconnect(linkConnection);
@ -177,12 +172,6 @@ void AboutForm::onUpdateAvailable(QString latestVersion, QUrl link)
[link]() { QDesktopServices::openUrl(link); }); [link]() { QDesktopServices::openUrl(link); });
bodyUI->updateStack->setCurrentIndex(static_cast<int>(updateIndex::available)); bodyUI->updateStack->setCurrentIndex(static_cast<int>(updateIndex::available));
} }
#else
void AboutForm::onUpdateAvailable()
{
bodyUI->updateStack->setCurrentIndex(static_cast<int>(updateIndex::available));
}
#endif
void AboutForm::onUpToDate() void AboutForm::onUpToDate()
{ {

View File

@ -45,11 +45,7 @@ public:
} }
public slots: public slots:
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
void onUpdateAvailable(QString latestVersion, QUrl link); void onUpdateAvailable(QString latestVersion, QUrl link);
#else
void onUpdateAvailable();
#endif
void onUpToDate(); void onUpToDate();
void onUpdateCheckFailed(); void onUpdateCheckFailed();
@ -62,9 +58,7 @@ private:
Ui::AboutSettings* bodyUI; Ui::AboutSettings* bodyUI;
QTimer* progressTimer; QTimer* progressTimer;
UpdateCheck* updateCheck; UpdateCheck* updateCheck;
#ifndef APPIMAGE_UPDATER_BRIDGE_ENABLED
QMetaObject::Connection linkConnection; QMetaObject::Connection linkConnection;
#endif
}; };
#endif // ABOUTFORM_H #endif // ABOUTFORM_H