Skip to content

Commit

Permalink
Adds Alpha and Beta channels for the update manager
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Mar 5, 2024
1 parent 0ccd42b commit 3203d37
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 21 deletions.
10 changes: 9 additions & 1 deletion src/update/UpdateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ VersionPatch UpdateManager::GetVersionPatch() const

void UpdateManager::GetUpdates(bool ignoreNetworkErrors, bool configurableNotification)
{
const audacity::network_manager::Request request("https://updates.audacityteam.org/feed/latest.xml");
#if AUDACITY_BUILD_LEVEL == 0
const auto url = "https://updates.audacityteam.org/builds/alpha.xml";
#elif AUDACITY_BUILD_LEVEL == 1
const auto url = "https://updates.audacityteam.org/builds/beta.xml";
#else
const auto url = "https://updates.audacityteam.org/feed/latest.xml";
#endif

const audacity::network_manager::Request request(url);
auto response = audacity::network_manager::NetworkManager::GetInstance().doGet(request);

response->setRequestFinishedCallback([response, ignoreNetworkErrors, configurableNotification, this](audacity::network_manager::IResponse*) {
Expand Down
13 changes: 12 additions & 1 deletion src/update/UpdatePopupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,21 @@ HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
wxStringOutputStream o;
wxTextOutputStream informationStr (o);

#if AUDACITY_BUILD_LEVEL == 0
const auto versionPostfix = " Alpha";
#elif AUDACITY_BUILD_LEVEL == 1
const auto versionPostfix = " Beta";
#else
const auto versionPostfix = "";
#endif

informationStr
<< wxT("<html><body><h3>")
// i18n-hint Substitution of version number for %s.
<< XC("Audacity %s is available!", "update dialog").Format(mVersionPatch.version.GetString()).Translation()
<< XC("Audacity %s is available!", "update dialog")
.Format(
mVersionPatch.version.GetString() + versionPostfix)
.Translation()
<< wxT("</h3><h5>")
<< XC("Changelog", "update dialog")
<< wxT("</h5><p>");
Expand Down
44 changes: 29 additions & 15 deletions src/update/VersionId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@
**********************************************************************/
#include "VersionId.h"

VersionId::VersionId(int version, int release, int revision)
VersionId::VersionId(int version, int release, int revision, int patch)
: mVersion(version),
mRelease(release),
mRevision(revision)
mRevision(revision),
mPatch(patch)
{}

wxString VersionId::MakeString(int version, int release, int revision)
wxString VersionId::MakeString(int version, int release, int revision, int patch)
{
return std::to_string(version)
if (patch == 0)
return std::to_string(version)
+ "." + std::to_string(release)
+ "." + std::to_string(revision);
else
return std::to_string(version)
+ "." + std::to_string(release)
+ "." + std::to_string(revision)
+ "." + std::to_string(patch);
}

VersionId VersionId::ParseFromString(wxString& versionString)
Expand All @@ -27,31 +34,38 @@ VersionId VersionId::ParseFromString(wxString& versionString)

// If we have corrupted version string,
// then return the zero version number, that not allow us to update.
if (versionStringParts.size() != 3)
const auto size = versionStringParts.size();
if (size < 2 || size > 4)
return VersionId{};

VersionId versionId;

const auto fields = { &versionId.mVersion, &versionId.mRelease,
&versionId.mRevision, &versionId.mPatch };

auto currentField = fields.begin();

for (auto& v : versionStringParts)
{
if (v.empty() || !v.IsNumber())
return VersionId{};

**currentField = std::stoi(v.ToStdString());
++currentField;
}

return VersionId(
std::stoi(versionStringParts[0].ToStdString()),
std::stoi(versionStringParts[1].ToStdString()),
std::stoi(versionStringParts[2].ToStdString())
);
return versionId;
}

wxString VersionId::GetString() const
{
return MakeString(mVersion, mRelease, mRevision);
return MakeString(mVersion, mRelease, mRevision, mPatch);
}

bool VersionId::operator== (const VersionId& other)
{
return std::tie(mVersion, mRelease, mRevision) ==
std::tie(other.mVersion, other.mRelease, other.mRevision);
return std::tie(mVersion, mRelease, mRevision, mPatch) ==
std::tie(other.mVersion, other.mRelease, other.mRevision, other.mPatch);
}

bool VersionId::operator!= (const VersionId& other)
Expand All @@ -61,8 +75,8 @@ bool VersionId::operator!= (const VersionId& other)

bool VersionId::operator< (const VersionId& other)
{
return std::tie(mVersion, mRelease, mRevision) <
std::tie(other.mVersion, other.mRelease, other.mRevision);
return std::tie(mVersion, mRelease, mRevision, mPatch) <
std::tie(other.mVersion, other.mRelease, other.mRevision, other.mPatch);
}

bool VersionId::operator> (const VersionId& other)
Expand Down
10 changes: 6 additions & 4 deletions src/update/VersionId.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@

/// A class, that supports base manipulation with version number.
/**
By default initialized by zero version number (Version = 0, Release = 0, Revision = 0),
By default initialized by zero version number (Version = 0, Release = 0, Revision = 0, Patch = 0),
that not allow us to update.
*/
class VersionId final
{
public:
/// Creates an zero version object.
VersionId() = default;
VersionId(int version, int release, int revision);
VersionId(int version, int release, int revision, int patch = 0);

/// Creates version string like "1.2.3" by parameters.
static wxString MakeString(int version, int release, int revision);
static wxString MakeString(int version, int release, int revision, int patch);
/// Parse and return version object from version string like "1.2.3".
static VersionId ParseFromString(wxString& versionString);

Expand All @@ -40,10 +40,12 @@ class VersionId final
int mVersion{ 0 };
int mRelease{ 0 };
int mRevision{ 0 };
int mPatch { 0 };
};

/// Return version (VersionId) object with current Audacity build version.
static inline VersionId CurrentBuildVersion()
{
return VersionId{ AUDACITY_VERSION, AUDACITY_RELEASE, AUDACITY_REVISION };
return VersionId { AUDACITY_VERSION, AUDACITY_RELEASE, AUDACITY_REVISION,
AUDACITY_MODLEVEL };
}

0 comments on commit 3203d37

Please sign in to comment.