LCOV - code coverage report
Current view: top level - muse/framework/network/internal - networkconfiguration.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 29 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2025 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #include "networkconfiguration.h"
      23              : 
      24              : #include "global/configreader.h"
      25              : 
      26              : using namespace muse;
      27              : using namespace muse::network;
      28              : 
      29            0 : void NetworkConfiguration::init()
      30              : {
      31            0 :     m_userAgentConfig = ConfigReader::read(":/configs/user_agent.cfg");
      32            0 : }
      33              : 
      34            0 : RequestHeaders NetworkConfiguration::defaultHeaders(const std::string& userAgentName) const
      35              : {
      36            0 :     RequestHeaders headers;
      37              : 
      38            0 :     headers.knownHeaders[QNetworkRequest::UserAgentHeader] = makeUserAgent(userAgentName);
      39              : 
      40            0 :     return headers;
      41            0 : }
      42              : 
      43            0 : QString NetworkConfiguration::makeUserAgent(const std::string& tplName) const
      44              : {
      45            0 :     std::string _tplName = tplName;
      46            0 :     if (_tplName.empty()) {
      47            0 :         static const std::string GLOBAL_USER_AGENT = "general";
      48            0 :         _tplName = GLOBAL_USER_AGENT;
      49              :     }
      50              : 
      51            0 :     QString osName;
      52              : #if defined(Q_OS_WIN)
      53              :     osName = "Windows";
      54              : #elif defined (Q_OS_MACOS)
      55              :     osName = "Mac";
      56              : #else
      57            0 :     osName = "Linux";
      58              : #endif
      59              : 
      60            0 :     const static QString kernelType = QSysInfo::kernelType();
      61            0 :     const static QString kernelVersion = QSysInfo::kernelVersion();
      62            0 :     const static QString osVersion = QSysInfo::productVersion();
      63            0 :     const static QString cpuArchitecture = QSysInfo::currentCpuArchitecture();
      64              : 
      65            0 :     QString result = m_userAgentConfig.value(_tplName).toQString();
      66            0 :     result = result.replace("{app_version}", application()->version().toString());
      67            0 :     result = result.replace("{app_build}", application()->build());
      68              : 
      69            0 :     result = result.replace("{kernel_type}", kernelType);
      70            0 :     result = result.replace("{kernel_version}", kernelVersion);
      71            0 :     result = result.replace("{os_name}", osName);
      72            0 :     result = result.replace("{os_version}", osVersion);
      73            0 :     result = result.replace("{cpu_arch}", cpuArchitecture);
      74              : 
      75            0 :     return result;
      76            0 : }
        

Generated by: LCOV version 2.0-1