Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/update/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target_sources(muse_update PRIVATE
updatetypes.h
updateerrors.h
iupdateconfiguration.h
iupdaterequestparamsprovider.h
iappupdatescenario.h
iappupdateservice.h

Expand Down
12 changes: 12 additions & 0 deletions framework/update/internal/appupdateservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QJsonValue>
#include <QJsonArray>
#include <QJsonDocument>
#include <QUrlQuery>

#include "update/updateerrors.h"

Expand Down Expand Up @@ -134,6 +135,17 @@ Promise<RetVal<ReleaseInfo> > AppUpdateService::checkForUpdate()
}

QUrl url = QString::fromStdString(configuration()->checkForAppUpdateUrl());
if (requestParamsProvider()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this if, this is an internal service and will always exist in this module

@kryksyh kryksyh Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that this provider is set by the app, and the framework only provides an interface. That is, only the app knows which params to add.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to IShortcutContextPriority and a few other services

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's still worth registering interfaces in those modules rather than relying on someone else to register them somewhere

@kryksyh kryksyh Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I am confused. Please help me understand, what framework side params provider should do.

This is an excerp from pending auadicty PR:

std::vector<std::pair<std::string, std::string> > UsageInfoService::updateRequestParams() const
{
    std::vector<std::pair<std::string, std::string> > params;

    if (!getSendAnonymousUsageInfo()) {
        return params;
    }

    params.emplace_back("audacity-instance-id", instanceId());

    if (authorization()) {
        const std::string userId = authorization()->accountInfo().id;
        if (!userId.empty()) {
            params.emplace_back("user_id", userId);
        }
    }

    return params;
}

QUrlQuery query(url);
for (const auto& [key, value] : requestParamsProvider()->updateRequestParams()) {
query.addQueryItem(QString::fromStdString(key), QString::fromStdString(value));
}

if (!query.isEmpty()) {
url.setQuery(query);
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

RequestHeaders headers = prepareHeaders(historyRv.val);
auto buff = std::make_shared<QBuffer>();

Expand Down
2 changes: 2 additions & 0 deletions framework/update/internal/appupdateservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@

#include "network/inetworkmanagercreator.h"
#include "update/iupdateconfiguration.h"
#include "update/iupdaterequestparamsprovider.h"

namespace muse::update {
class AppUpdateService : public IAppUpdateService, public Contextable, public async::Asyncable
{
GlobalInject<io::IFileSystem> fileSystem;
GlobalInject<ISystemInfo> systemInfo;
GlobalInject<IUpdateConfiguration> configuration;
GlobalInject<IUpdateRequestParamsProvider> requestParamsProvider;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you didn't register this service in the module for use

GlobalInject<network::INetworkManagerCreator> networkManagerCreator;
GlobalInject<IApplication> application;

Expand Down
38 changes: 38 additions & 0 deletions framework/update/iupdaterequestparamsprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore/Audacity CLA applies
*
* Copyright (C) 2026 MuseScore/Audacity and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <string>
#include <utility>
#include <vector>

#include "modularity/imoduleinterface.h"

namespace muse::update {
class IUpdateRequestParamsProvider : MODULE_GLOBAL_INTERFACE
{
INTERFACE_ID(IUpdateRequestParamsProvider)

public:
virtual ~IUpdateRequestParamsProvider() = default;

virtual std::vector<std::pair<std::string, std::string> > updateRequestParams() const = 0;
};
}