mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-18 01:46:47 +08:00
[feat] add remote host version checks and update prompts
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2026-09-28
|
||||
* Copyright (c) 2026 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _APP_VERSION_H_
|
||||
#define _APP_VERSION_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace crossdesk {
|
||||
|
||||
struct VersionInfo {
|
||||
std::string version;
|
||||
std::string release_name;
|
||||
std::string release_notes;
|
||||
std::string release_date;
|
||||
int patch = -1;
|
||||
};
|
||||
|
||||
// Shared desktop release parsing and comparison for desktop and iOS controllers.
|
||||
std::optional<VersionInfo> ParseVersionInfoJSON(std::string_view json);
|
||||
bool IsValidAppVersion(const std::string& version);
|
||||
|
||||
bool IsNewerVersion(const std::string& current, const std::string& latest);
|
||||
|
||||
// Pass latest_patch < 0 when patch metadata is unavailable.
|
||||
bool IsNewerVersionWithMetadata(const std::string& current,
|
||||
const std::string& latest,
|
||||
const std::string& latest_date,
|
||||
int latest_patch);
|
||||
|
||||
// Returns the latest release label when the peer is older. Missing or invalid
|
||||
// peer versions are treated as legacy; the latest release must still be valid.
|
||||
std::optional<std::string> AvailableAppUpdate(const std::string& current,
|
||||
const VersionInfo& latest);
|
||||
|
||||
} // namespace crossdesk
|
||||
|
||||
#endif
|
||||
@@ -119,6 +119,8 @@ struct CursorState {
|
||||
struct HostInfo {
|
||||
char host_name[64];
|
||||
std::size_t host_name_size;
|
||||
// Optional; an empty string means the peer version is unknown.
|
||||
char app_version[64];
|
||||
char** display_list;
|
||||
std::size_t display_num;
|
||||
int* left;
|
||||
@@ -213,9 +215,11 @@ struct HostDisplay {
|
||||
// heap-allocated with the same layout the decoder produces; release the
|
||||
// result with FreeRemoteAction. An allocation failure yields an empty display
|
||||
// list rather than a partially filled one.
|
||||
// Missing or oversized app versions are advertised as unknown (empty).
|
||||
RemoteAction MakeHostInformation(const std::string& host_name,
|
||||
const std::vector<HostDisplay>& displays,
|
||||
bool supports_privacy_screen);
|
||||
bool supports_privacy_screen,
|
||||
const std::string& app_version = {});
|
||||
|
||||
} // namespace crossdesk
|
||||
|
||||
|
||||
Reference in New Issue
Block a user