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
13namespace cloud::audiocom
14{
15std::string_view ServiceConfig::GetAPIEndpoint() const
16{
17 return "https://api.audio.com";
18}
19
20std::string_view ServiceConfig::GetOAuthLoginPage() const
21{
22 static const std::string loginPage =
23 std::string("https://audio.com/audacity/link?clientId=") +
24 std::string(GetOAuthClientID());
25
26 return loginPage;
27}
28
29std::string_view ServiceConfig::GetOAuthClientID() const
30{
31 return "1741964426607541";
32}
33
34std::string_view ServiceConfig::GetOAuthRedirectURL() const
35{
36 //return "audacity://link";
37 return "https://audio.com/auth/sign-in/success";
38}
39
40std::string ServiceConfig::GetAPIUrl(std::string_view apiURI) const
41{
42 return std::string(GetAPIEndpoint()) + std::string(apiURI);
43}
44
46 std::string_view audioID, std::string_view token) const
47{
48 return "http://audio.com/audacity/upload?audioId=" + std::string(audioID) +
49 "&token=" + std::string(token) +
50 "&clientId=" + std::string(GetOAuthClientID());
51}
52
53std::chrono::milliseconds ServiceConfig::GetProgressCallbackTimeout() const
54{
55 return std::chrono::seconds(3);
56}
57
59{
60 return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
61}
62
64{
65 return "audio/x-wav";
66}
67
69{
70 static ServiceConfig config;
71 return config;
72}
73
74} // namespace cloud::audiocom
Configuration for the audio.com.
Definition: ServiceConfig.h:24
MimeTypesList GetPreferredAudioFormats() const
Preferred audio format.
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.
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