Skip to content

Commit

Permalink
fix: Allow building qtox without update check.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Nov 26, 2024
1 parent 3721ad0 commit 55ec911
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions .ci-scripts/build-qtox-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ if [ "$MINIMAL" -eq 1 ]; then
cmake "$SRCDIR" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DSMILEYS=DISABLED \
-DUPDATE_CHECK=OFF \
-DSTRICT_OPTIONS=ON \
-DSPELL_CHECK=OFF \
-GNinja \
Expand Down
10 changes: 9 additions & 1 deletion src/net/updatecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
#include "src/net/updatecheck.h"

#ifdef UPDATE_CHECK_ENABLED
#include "src/persistence/settings.h"
#ifndef CMAKE_BUILD
#include "src/version.h"
Expand All @@ -20,6 +19,7 @@
#include <QTimer>
#include <cassert>

#ifdef UPDATE_CHECK_ENABLED
namespace {
const QString versionUrl{
QStringLiteral("https://api.github.com/repos/TokTok/qTox/releases/latest")};
Expand Down Expand Up @@ -91,16 +91,24 @@ bool isCurrentVersionStable()
}

} // namespace
#endif

UpdateCheck::UpdateCheck(const Settings& settings_)
#ifdef UPDATE_CHECK_ENABLED
: settings(settings_)
{
qInfo() << "qTox is running version:" << GIT_DESCRIBE;
updateTimer.start(1000 * 60 * 60 * 24 /* 1 day */);
connect(&updateTimer, &QTimer::timeout, this, &UpdateCheck::checkForUpdate);
connect(&manager, &QNetworkAccessManager::finished, this, &UpdateCheck::handleResponse);
}
#else
{
std::ignore = settings_;
}
#endif

#ifdef UPDATE_CHECK_ENABLED
void UpdateCheck::checkForUpdate()
{
if (!settings.getCheckUpdates()) {
Expand Down
5 changes: 3 additions & 2 deletions src/net/updatecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <memory>

#ifdef UPDATE_CHECK_ENABLED
class Settings;
class QString;
class QUrl;
Expand All @@ -23,6 +22,8 @@ class UpdateCheck : public QObject

public:
UpdateCheck(const Settings& settings_);

#ifdef UPDATE_CHECK_ENABLED
void checkForUpdate();

signals:
Expand All @@ -38,5 +39,5 @@ private slots:
QNetworkAccessManager manager;
QTimer updateTimer;
const Settings& settings;
};
#endif
};
6 changes: 3 additions & 3 deletions src/widget/form/settings/aboutform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ AboutForm::AboutForm(UpdateCheck* updateCheck_, Style& style_)
{
bodyUI->setupUi(this);

#if !UPDATE_CHECK_ENABLED
#ifndef UPDATE_CHECK_ENABLED
bodyUI->updateStack->setVisible(false);
#endif
bodyUI->unstableVersion->setVisible(false);
#if UPDATE_CHECK_ENABLED
#ifdef UPDATE_CHECK_ENABLED
connect(updateCheck_, &UpdateCheck::versionIsUnstable, this, &AboutForm::onUnstableVersion);
#endif

Expand Down Expand Up @@ -89,7 +89,7 @@ void AboutForm::replaceVersions()

bodyUI->youAreUsing->setText(tr("You are using qTox version %1.").arg(QString(GIT_DESCRIBE)));

#if UPDATE_CHECK_ENABLED
#ifdef UPDATE_CHECK_ENABLED
if (updateCheck != nullptr) {
connect(updateCheck, &UpdateCheck::updateAvailable, this, &AboutForm::onUpdateAvailable);
connect(updateCheck, &UpdateCheck::upToDate, this, &AboutForm::onUpToDate);
Expand Down
2 changes: 1 addition & 1 deletion src/widget/form/settingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SettingsWidget::SettingsWidget(UpdateCheck* updateCheck, IAudioControl& audio, C
std::unique_ptr<AdvancedForm> expfrm(new AdvancedForm(settings, style, messageBoxManager));
std::unique_ptr<AboutForm> abtfrm(new AboutForm(updateCheck, style));

#if UPDATE_CHECK_ENABLED
#ifdef UPDATE_CHECK_ENABLED
if (updateCheck != nullptr) {
connect(updateCheck, &UpdateCheck::updateAvailable, this, &SettingsWidget::onUpdateAvailable);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ void Widget::init()
addFriendForm = new AddFriendForm(core->getSelfId(), settings, style, *messageBoxManager, *core);
conferenceInviteForm = new ConferenceInviteForm(settings, *core);

#if UPDATE_CHECK_ENABLED
#ifdef UPDATE_CHECK_ENABLED
updateCheck = std::unique_ptr<UpdateCheck>(new UpdateCheck(settings));
connect(updateCheck.get(), &UpdateCheck::updateAvailable, this, &Widget::onUpdateAvailable);
#endif
settingsWidget = new SettingsWidget(updateCheck.get(), audio, core, *smileyPack, cameraSource,
settings, style, *messageBoxManager, profile, this);
#if UPDATE_CHECK_ENABLED
#ifdef UPDATE_CHECK_ENABLED
updateCheck->checkForUpdate();
#endif

Expand Down

0 comments on commit 55ec911

Please sign in to comment.