feat(client): 迁移Hub更新客户端实现
This commit is contained in:
+22
-17
@@ -35,8 +35,8 @@ const QString kConfigKeyPrefix = QStringLiteral("--config-key-b64=");
|
||||
const QString kConfigValuePrefix = QStringLiteral("--config-value-b64=");
|
||||
const QString kFilePathPrefix = QStringLiteral("--file-path-b64=");
|
||||
const QString kFileDataPrefix = QStringLiteral("--file-data-b64=");
|
||||
const QString kRegistryOrganization = QStringLiteral("Marsco");
|
||||
const QString kRegistryApplication = QStringLiteral("UpdateClientSDK");
|
||||
const QString kRegistryOrganization = QStringLiteral("SimCAE");
|
||||
const QString kRegistryApplication = QStringLiteral("HubUpdateClient");
|
||||
const QString kRegistryInstallationsGroup = QStringLiteral("installations");
|
||||
const QString kRegistryConfigGroup = QStringLiteral("config");
|
||||
const QString kRegistryMetaGroup = QStringLiteral("_meta");
|
||||
@@ -178,7 +178,8 @@ bool isRegistryManagedConfigKey(const QString& key)
|
||||
{
|
||||
// 服务端地址是编译期 qrc 配置,不进入注册表。
|
||||
// 其他运行配置会在 Launcher 首次启动时导入注册表,之后以注册表为准。
|
||||
return key != kApiBaseUrlKey;
|
||||
Q_UNUSED(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isPathInsideDirectory(const QString& path, const QString& directory)
|
||||
@@ -478,7 +479,6 @@ ConfigHelper::ConfigHelper()
|
||||
QCryptographicHash::Sha256).toHex());
|
||||
migrateLegacyIniIfNeeded();
|
||||
syncRegistryFromConfigFileIfChanged();
|
||||
removeRegistryValue(kApiBaseUrlKey);
|
||||
qDebug() << "Loading app config path:" << m_configPath;
|
||||
qDebug() << "File exists?" << QFile::exists(m_configPath);
|
||||
qDebug() << "Registry installation id:" << m_registryInstallId;
|
||||
@@ -508,7 +508,7 @@ QString ConfigHelper::dataRoot() const
|
||||
if (base.isEmpty())
|
||||
base = QDir::homePath();
|
||||
return QDir::cleanPath(QDir(base).filePath(
|
||||
QStringLiteral("Marsco/UpdateClientSDK/installations/%1").arg(m_registryInstallId)));
|
||||
QStringLiteral("SimCAE/HubUpdateClient/installations/%1").arg(m_registryInstallId)));
|
||||
}
|
||||
|
||||
QString ConfigHelper::dataConfigDir() const
|
||||
@@ -788,16 +788,18 @@ QString ConfigHelper::readFileValue(const QString& key) const
|
||||
QString ConfigHelper::getValue(const QString& section, const QString& key) const
|
||||
{
|
||||
Q_UNUSED(section);
|
||||
const QString embeddedValue = readEmbeddedValue(key);
|
||||
if (!embeddedValue.isEmpty())
|
||||
return embeddedValue;
|
||||
if (!isRegistryManagedConfigKey(key))
|
||||
return QString();
|
||||
|
||||
QString value;
|
||||
if (readRegistryValue(key, &value))
|
||||
return value;
|
||||
return readFileValue(key);
|
||||
|
||||
value = readFileValue(key).trimmed();
|
||||
if (!value.isEmpty())
|
||||
return value;
|
||||
|
||||
return readEmbeddedValue(key);
|
||||
}
|
||||
|
||||
bool ConfigHelper::setValue(const QString& section, const QString& key, const QString& value)
|
||||
@@ -824,15 +826,15 @@ bool ConfigHelper::migrateLegacyIniIfNeeded()
|
||||
config.insert(key, value);
|
||||
};
|
||||
|
||||
copyText("App", "app_id");
|
||||
copyText("App", "app_name", "Marsco Demo App");
|
||||
copyText("App", "app_id");
|
||||
copyText("App", "product_code", ini.value("App/app_id").toString());
|
||||
copyText("App", "app_name", "SimCAE");
|
||||
copyText("App", "channel", "stable");
|
||||
copyText("App", "current_version", "1.0.0");
|
||||
copyText("App", "client_protocol", "3");
|
||||
copyText("App", "launch_token");
|
||||
copyText("License", "license_key");
|
||||
copyText("Server", "api_base_url");
|
||||
copyText("Server", "client_token");
|
||||
copyText("App", "client_protocol", "3");
|
||||
copyText("Server", "client_token");
|
||||
copyText("App", "launch_token");
|
||||
copyText("Server", "api_base_url");
|
||||
copyText("Update", "request_timeout_ms", "5000");
|
||||
copyText("Update", "temp_folder", "update_temp");
|
||||
copyText("Update", "device_id");
|
||||
@@ -842,6 +844,9 @@ bool ConfigHelper::migrateLegacyIniIfNeeded()
|
||||
copyText("Runtime", "updater_executable", ConfigHelper::executableNameForCurrentPlatform(QString(), "Updater"));
|
||||
copyText("Runtime", "bootstrap_executable", ConfigHelper::executableNameForCurrentPlatform(QString(), "Bootstrap"));
|
||||
copyText("Runtime", "health_check_timeout_ms", "15000");
|
||||
copyText("Security", "require_manifest_signature", "false");
|
||||
copyText("Security", "verify_installed_on_start", "false");
|
||||
copyText("Platform", "abi");
|
||||
#ifdef Q_OS_WIN
|
||||
config.insert("platform", "windows");
|
||||
#elif defined(Q_OS_LINUX)
|
||||
@@ -849,7 +854,7 @@ bool ConfigHelper::migrateLegacyIniIfNeeded()
|
||||
#else
|
||||
config.insert("platform", "unknown");
|
||||
#endif
|
||||
config.insert("arch", "x64");
|
||||
config.insert("arch", "x86_64");
|
||||
|
||||
QDir().mkpath(QFileInfo(m_configPath).path());
|
||||
QSaveFile output(m_configPath);
|
||||
|
||||
Reference in New Issue
Block a user