Audacity 3.2.0
ServiceConfig.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 ServiceConfig.cpp
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#include "ServiceConfig.h"
12#include "Languages.h"
13
14namespace cloud::audiocom
15{
16std::string_view ServiceConfig::GetAPIEndpoint() const
17{
18 return "https://api.audio.com";
19}
20
21std::string_view ServiceConfig::GetOAuthLoginPage() const
22{
23 static const std::string loginPage =
24 std::string("https://audio.com/audacity/link?clientId=") +
25 std::string(GetOAuthClientID());
26
27 return loginPage;
28}
29
30std::string_view ServiceConfig::GetOAuthClientID() const
31{
32 return "1741964426607541";
33}
34
35std::string_view ServiceConfig::GetOAuthRedirectURL() const
36{
37 //return "audacity://link";
38 return "https://audio.com/auth/sign-in/success";
39}
40
41std::string ServiceConfig::GetAPIUrl(std::string_view apiURI) const
42{
43 return std::string(GetAPIEndpoint()) + std::string(apiURI);
44}
45
47 std::string_view audioID, std::string_view token) const
48{
49 return "http://audio.com/audacity/upload?audioId=" + std::string(audioID) +
50 "&token=" + std::string(token) +
51 "&clientId=" + std::string(GetOAuthClientID());
52}
53
54std::chrono::milliseconds ServiceConfig::GetProgressCallbackTimeout() const
55{
56 return std::chrono::seconds(3);
57}
58
60{
61 return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
62}
63
65{
66 return "audio/x-wav";
67}
68
70{
71 auto language = Languages::GetLang();
72
73 if (language.Contains(L"-") && language.Length() > 2)
74 return wxString::Format("%s;q=1.0, %s;q=0.7, *;q=0.5", language, language.Left(2)).ToStdString();
75 else
76 return wxString::Format("%s;q=1.0, *;q=0.5", language).ToStdString();
77}
78
80{
81 static ServiceConfig config;
82 return config;
83}
84
85} // namespace cloud::audiocom
Configuration for the audio.com.
Definition: ServiceConfig.h:24
MimeTypesList GetPreferredAudioFormats() const
Preferred audio format.
std::string GetAcceptLanguageValue() const
Returns the preferred language.
std::string_view GetOAuthRedirectURL() const
OAuth2 redirect URL. Only used to satisfy the protocol.
std::string GetAPIUrl(std::string_view apiURI) const
Helper to construct the full URLs for the API.
std::chrono::milliseconds GetProgressCallbackTimeout() const
Timeout between progress callbacks.
MimeType GetDownloadMime() const
Return the mime type server should store the file. This is a requirement from audiocom.
std::string_view GetOAuthLoginPage() const
Page to open in browser to initiate OAuth.
std::string GetFinishUploadPage(std::string_view audioID, std::string_view token) const
Helper to construct the page URL for the anonymous upload last stage.
std::string_view GetOAuthClientID() const
OAuth2 client ID.
std::string_view GetAPIEndpoint() const
API endpoint.
wxString GetLang()
Definition: Languages.cpp:395
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.
std::string MimeType
Definition: MimeTypesList.h:18
std::vector< std::string > MimeTypesList
Ordered list of mime types.
Definition: MimeTypesList.h:20