Skip to content

Commit

Permalink
Using constants for versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 12, 2023
1 parent f2880d3 commit c1104ce
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 35 deletions.
17 changes: 0 additions & 17 deletions source/base/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,6 @@ Version Version::fromProto(const proto::Version& proto_version)
proto_version.patch(), proto_version.revision());
}

//--------------------------------------------------------------------------------------------------
// static
const Version& Version::currentShort()
{
static const Version version(ASPIA_VERSION_MAJOR, ASPIA_VERSION_MINOR, ASPIA_VERSION_PATCH);
return version;
}

//--------------------------------------------------------------------------------------------------
// static
const Version& Version::currentFull()
{
static const Version version(
ASPIA_VERSION_MAJOR, ASPIA_VERSION_MINOR, ASPIA_VERSION_PATCH, GIT_COMMIT_COUNT);
return version;
}

//--------------------------------------------------------------------------------------------------
bool operator==(const Version& v1, const Version& v2)
{
Expand Down
10 changes: 2 additions & 8 deletions source/base/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace base {
class Version
{
public:
static const Version& kVersion_CurrentFull;
static const Version& kVersion_CurrentShort;
static const Version& kVersion_CurrentFull; // Version of application (with build number).
static const Version& kVersion_CurrentShort; // Version of application (without build number).
static const Version& kVersion_2_4_0;
static const Version& kVersion_2_6_0;

Expand Down Expand Up @@ -82,12 +82,6 @@ class Version
proto::Version toProto() const;
static Version fromProto(const proto::Version& proto_version);

// Returns current version of application (without build number).
static const Version& currentShort();

// Returns current version of application (with build number).
static const Version& currentFull();

private:
std::vector<uint32_t> components_;
};
Expand Down
2 changes: 1 addition & 1 deletion source/client/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void Client::startAuthentication()
channel_->setChannelIdSupport(true);
}

const base::Version& client_version = base::Version::currentFull();
const base::Version& client_version = base::Version::kVersion_CurrentFull;
if (host_version > client_version)
{
LOG(LS_ERROR) << "Version mismatch (host: " << host_version.toString()
Expand Down
2 changes: 1 addition & 1 deletion source/client/router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Router::onTcpConnected()
channel_->setChannelIdSupport(true);
}

const base::Version& client_version = base::Version::currentFull();
const base::Version& client_version = base::Version::kVersion_CurrentFull;
if (router_version > client_version)
{
LOG(LS_ERROR) << "Version mismatch (router: " << router_version.toString()
Expand Down
2 changes: 1 addition & 1 deletion source/client/ui/client_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void ClientWindow::onUpdateCheckedFinished(const base::ByteArray& result)
}
else
{
const base::Version& current_version = base::Version::currentShort();
const base::Version& current_version = base::Version::kVersion_CurrentShort;
const base::Version& update_version = update_info.version();

if (update_version > current_version)
Expand Down
2 changes: 1 addition & 1 deletion source/client/ui/desktop/qt_desktop_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void QtDesktopWindow::setCapabilities(const proto::DesktopCapabilities& capabili

if (base::contains(extensions_list, common::kRemoteUpdateExtension))
{
if (base::Version::currentFull() > peer_version_)
if (base::Version::kVersion_CurrentFull > peer_version_)
toolbar_->enableRemoteUpdate(true);
}

Expand Down
4 changes: 2 additions & 2 deletions source/common/ui/update_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void UpdateDialog::onUpdateCheckedFinished(const base::ByteArray& result)
}
else
{
const base::Version& current_version = base::Version::currentShort();
const base::Version& current_version = base::Version::kVersion_CurrentShort;

update_info_ = UpdateInfo::fromXml(result);
if (!update_info_.isValid())
Expand Down Expand Up @@ -254,7 +254,7 @@ void UpdateDialog::initialize()
connect(ui->button_update, &QPushButton::clicked, this, &UpdateDialog::onUpdateNow);
connect(ui->button_close, &QPushButton::clicked, this, &UpdateDialog::close);

const base::Version& current_version = base::Version::currentShort();
const base::Version& current_version = base::Version::kVersion_CurrentShort;

ui->label_current->setText(QString::fromStdString(current_version.toString(3)));
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/update_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void UpdateChecker::run()
#error Unknown architecture
#endif

const base::Version& version = base::Version::currentShort();
const base::Version& version = base::Version::kVersion_CurrentShort;

std::string url(update_server_);
url += "/update.php?";
Expand Down
2 changes: 1 addition & 1 deletion source/console/main_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ void MainWindow::onUpdateCheckedFinished(const base::ByteArray& result)
}
else
{
const base::Version& current_version = base::Version::currentShort();
const base::Version& current_version = base::Version::kVersion_CurrentShort;
const base::Version& update_version = update_info.version();

if (update_version > current_version)
Expand Down
4 changes: 2 additions & 2 deletions source/host/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void Server::onNewSession(base::ServerAuthenticatorManager::SessionInfo&& sessio

LOG(LS_INFO) << "Channel ID supported: " << (channel_id_support ? "YES" : "NO");

const base::Version& host_version = base::Version::currentFull();
const base::Version& host_version = base::Version::kVersion_CurrentFull;
if (host_version > session_info.version)
{
LOG(LS_ERROR) << "Version mismatch (host: " << host_version.toString()
Expand Down Expand Up @@ -285,7 +285,7 @@ void Server::onUpdateCheckedFinished(const base::ByteArray& result)
}
else
{
const base::Version& current_version = base::Version::currentShort();
const base::Version& current_version = base::Version::kVersion_CurrentShort;
const base::Version& update_version = update_info.version();

if (update_version > current_version)
Expand Down

0 comments on commit c1104ce

Please sign in to comment.