Commit b048aec5 authored by captainwong's avatar captainwong

version add force_update

parent 5fc667db
......@@ -156,12 +156,16 @@ struct DownLoadLink {
struct Release {
Branch branch = Branch::InvalidBranch;
Version version = {};
bool force_update = false;
//! 版本更新说明
std::string change = {};
std::vector<DownLoadLink> dllinks = {};
std::string toString() const {
auto s = std::string(branchName(branch)) + " " + version.toString() + "\nchange=" + change + "\ndownload_links=\n";
auto s = std::string(branchName(branch)) + " " + version.toString() +
"\nforce_update=" + (force_update ? "true" : "false") +
"\nchange=" + change +
"\ndownload_links=\n";
if (!dllinks.empty()) {
for (const auto& link : dllinks) { s += link.host + " : link=" + link.link + " md5=" + link.md5 + "\n"; }
} else { s += "empty"; }
......@@ -196,6 +200,7 @@ struct LatestRelease {
* {
* "test": {
* "version": "2.2.11.13262",
* "force_update": true,
* "release_note": "测试;",
* "download_links": {
* "local": {
......@@ -206,6 +211,7 @@ struct LatestRelease {
* },
* "stable": {
* "version": "2.2.12.13282",
* "force_update": false,
* "release_note": "测试稳定",
* "download_links": {
* "local": {
......@@ -230,6 +236,7 @@ int resolveLatestRelease(const JsonValue& value, LatestRelease& latestRelease) {
const auto& detail = value[branchName(branch)];
Release release;
release.branch = branch;
release.force_update = detail.isMember("force_update") ? detail["force_update"].asBool() : false;
release.version = detail["version"].asString();
release.change = detail["release_note"].asString();
if (detail["download_links"].isMember("local")) {
......
#include "../../jlib/util/version.h"
#include "../../jlib/util/curl_wrapper.h"
#include "../../jlib/3rdparty/json/jsoncpp/json.h"
#include <stdio.h>
#include <assert.h>
......@@ -35,5 +37,24 @@ int main()
assert(!(v4 < v3));
assert(!(v4 <= v3));
Curl curl;
curl.init();
auto url = "https://jcenter.captainwong.cn/api/v1/apps/latest?name=test";
curl.get(url);
printf("HTTP %ld\n", curl.lastHttpCode());
printf("error %d\n", curl.lastError());
printf("error msg %s\n", curl.lastErrorMsg().data());
printf("%s\n", curl.lastHttpContent().data());
Json::Value value;
Json::Reader parser;
if (parser.parse(curl.lastHttpContent(), value)) {
LatestRelease latestRelease;
resolveLatestRelease(value, latestRelease);
printf("%s\n", latestRelease.toString().data());
}
system("pause");
}
......@@ -124,8 +124,14 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\jlib\3rdparty\json\jsoncpp\json_reader.cpp" />
<ClCompile Include="..\..\jlib\3rdparty\json\jsoncpp\json_value.cpp" />
<ClCompile Include="..\..\jlib\3rdparty\json\jsoncpp\json_writer.cpp" />
<ClCompile Include="test_version.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\jlib\3rdparty\json\jsoncpp\json.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
......
......@@ -13,10 +13,27 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="jsoncpp">
<UniqueIdentifier>{5d498929-b47b-463e-a7d5-4c71896ef989}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="test_version.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\jlib\3rdparty\json\jsoncpp\json_reader.cpp">
<Filter>jsoncpp</Filter>
</ClCompile>
<ClCompile Include="..\..\jlib\3rdparty\json\jsoncpp\json_value.cpp">
<Filter>jsoncpp</Filter>
</ClCompile>
<ClCompile Include="..\..\jlib\3rdparty\json\jsoncpp\json_writer.cpp">
<Filter>jsoncpp</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\jlib\3rdparty\json\jsoncpp\json.h">
<Filter>jsoncpp</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment